KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > webdav > connector > WebDAVConnectionFactory


1 /*
2  * $Header: /home/cvs/jakarta-slide/webdavclient/connector/src/java/org/apache/webdav/connector/WebDAVConnectionFactory.java,v 1.2 2004/07/15 12:37:36 ozeigermann Exp $
3  * $Revision: 1.2 $
4  * $Date: 2004/07/15 12:37:36 $
5  *
6  * ====================================================================
7  *
8  * Copyright 2004 The Apache Software Foundation
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  *
22  */

23
24 package org.apache.webdav.connector;
25
26 import javax.naming.NamingException JavaDoc;
27 import javax.naming.Reference JavaDoc;
28 import javax.resource.NotSupportedException JavaDoc;
29 import javax.resource.ResourceException JavaDoc;
30 import javax.resource.cci.Connection JavaDoc;
31 import javax.resource.cci.ConnectionFactory JavaDoc;
32 import javax.resource.cci.ConnectionSpec JavaDoc;
33 import javax.resource.cci.RecordFactory JavaDoc;
34 import javax.resource.cci.ResourceAdapterMetaData JavaDoc;
35 import javax.resource.spi.ConnectionManager JavaDoc;
36 import javax.resource.spi.ManagedConnectionFactory JavaDoc;
37
38 /**
39  *
40  * @version $Revision: 1.2 $
41  *
42  */

43 public class WebDAVConnectionFactory implements ConnectionFactory JavaDoc {
44
45     protected Reference JavaDoc reference;
46     protected ConnectionManager JavaDoc cm;
47     protected ManagedConnectionFactory JavaDoc mcf;
48
49     public WebDAVConnectionFactory(ManagedConnectionFactory JavaDoc mcf, ConnectionManager JavaDoc cm) {
50         System.out.println("MCF Init with mcf " + mcf + " cm " + cm);
51         this.mcf = mcf;
52         this.cm = cm;
53     }
54
55     public Connection JavaDoc getConnection() throws ResourceException JavaDoc {
56         throw new NotSupportedException JavaDoc(
57                 "Need a WebDAVConnectionSpec to create a connection. Call getConnection(ConnectionSpec spec) instead!");
58     }
59
60     public Connection JavaDoc getConnection(ConnectionSpec JavaDoc spec) throws ResourceException JavaDoc {
61         if (!(spec instanceof WebDAVConnectionSpec)) {
62             throw new NotSupportedException JavaDoc("Need a WebDAVConnectionSpec to create a connection!");
63         }
64         System.out.println("Getting connection with spec "+spec);
65         return (Connection JavaDoc) cm.allocateConnection(mcf, (WebDAVConnectionSpec)spec);
66     }
67
68     public RecordFactory JavaDoc getRecordFactory() throws ResourceException JavaDoc {
69         return null;
70     }
71
72     public ResourceAdapterMetaData JavaDoc getMetaData() throws ResourceException JavaDoc {
73         return null;
74     }
75
76     public void setReference(Reference JavaDoc reference) {
77         this.reference = reference;
78     }
79
80     public Reference JavaDoc getReference() throws NamingException JavaDoc {
81         return reference;
82     }
83
84 }
85
Popular Tags