KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > connector > mock > MockConnectionFactory


1 /**
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 package org.apache.geronimo.connector.mock;
19
20 import javax.naming.NamingException JavaDoc;
21 import javax.naming.Reference JavaDoc;
22 import javax.resource.ResourceException JavaDoc;
23 import javax.resource.cci.Connection JavaDoc;
24 import javax.resource.cci.ConnectionFactory JavaDoc;
25 import javax.resource.cci.ConnectionSpec JavaDoc;
26 import javax.resource.cci.RecordFactory JavaDoc;
27 import javax.resource.cci.ResourceAdapterMetaData JavaDoc;
28 import javax.resource.spi.ConnectionManager JavaDoc;
29
30 /**
31  *
32  *
33  * @version $Rev: 476049 $ $Date: 2006-11-16 23:35:17 -0500 (Thu, 16 Nov 2006) $
34  *
35  * */

36 public class MockConnectionFactory implements ConnectionFactoryExtension {
37
38     private ConnectionManager JavaDoc connectionManager;
39     private MockManagedConnectionFactory managedConnectionFactory;
40     private Reference JavaDoc reference;
41
42     public MockConnectionFactory(MockManagedConnectionFactory managedConnectionFactory, ConnectionManager JavaDoc connectionManager) {
43         this.managedConnectionFactory = managedConnectionFactory;
44         this.connectionManager = connectionManager;
45     }
46
47     public Connection JavaDoc getConnection() throws ResourceException JavaDoc {
48         return getConnection(null);
49     }
50
51     public Connection JavaDoc getConnection(ConnectionSpec JavaDoc properties) throws ResourceException JavaDoc {
52         return (MockConnection) connectionManager.allocateConnection(managedConnectionFactory, (MockConnectionRequestInfo) properties);
53     }
54
55     public RecordFactory JavaDoc getRecordFactory() throws ResourceException JavaDoc {
56         return null;
57     }
58
59     public ResourceAdapterMetaData JavaDoc getMetaData() throws ResourceException JavaDoc {
60         return null;
61     }
62
63     public void setReference(Reference JavaDoc reference) {
64         this.reference = reference;
65     }
66
67     public Reference JavaDoc getReference() throws NamingException JavaDoc {
68         return reference;
69     }
70
71     public String JavaDoc doSomethingElse() {
72         return "SomethingElse";
73     }
74 }
75
Popular Tags