KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > ra > DefaultMuleConnectionFactory


1 /*
2  * $Id: DefaultMuleConnectionFactory.java 3798 2006-11-04 04:07:14Z aperepel $
3  * --------------------------------------------------------------------------------------
4  * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
5  *
6  * The software in this package is published under the terms of the MuleSource MPL
7  * license, a copy of which has been included with this distribution in the
8  * LICENSE.txt file.
9  */

10
11 package org.mule.ra;
12
13 import java.io.IOException JavaDoc;
14 import java.io.ObjectInputStream JavaDoc;
15
16 import javax.naming.Reference JavaDoc;
17 import javax.resource.ResourceException JavaDoc;
18 import javax.resource.spi.ConnectionManager JavaDoc;
19
20 import org.apache.commons.logging.Log;
21 import org.apache.commons.logging.LogFactory;
22
23 /**
24  * <code>DefaultMuleConnectionFactory</code> an implementation of the
25  * MuleconnectionFactory interface used by clients of this ResourceAdapter to obtain
26  * a connection to Mule resources.
27  */

28 public class DefaultMuleConnectionFactory implements MuleConnectionFactory
29 {
30     /**
31      * Serial version
32      */

33     private static final long serialVersionUID = 1552386015565975623L;
34
35     /**
36      * logger used by this class
37      */

38     protected transient Log logger = LogFactory.getLog(this.getClass());
39
40     private transient ConnectionManager JavaDoc manager;
41     private transient MuleManagedConnectionFactory factory;
42     private Reference JavaDoc reference;
43     private MuleConnectionRequestInfo info;
44
45     public DefaultMuleConnectionFactory(MuleManagedConnectionFactory factory,
46                                         ConnectionManager JavaDoc manager,
47                                         MuleConnectionRequestInfo info)
48     {
49         this.factory = factory;
50         this.manager = manager;
51         this.info = info;
52     }
53
54     private void readObject(ObjectInputStream JavaDoc ois) throws ClassNotFoundException JavaDoc, IOException JavaDoc
55     {
56         ois.defaultReadObject();
57         // TODO this is incomplete:
58
// MuleManagedConnectionFactory is Serializable but marked transient?!
59
this.logger = LogFactory.getLog(this.getClass());
60     }
61
62     public MuleConnection createConnection() throws ResourceException JavaDoc
63     {
64         return createConnection(info);
65     }
66
67     public MuleConnection createConnection(MuleConnectionRequestInfo info) throws ResourceException JavaDoc
68     {
69         // TODO try {
70
return (MuleConnection)manager.allocateConnection(factory, info);
71         // }
72
// catch (ResourceException e) {
73
//
74
// logger.warn("Connection could not be created: " + e.getMessage(), e);
75
// throw new UMOException(e.getMessage());
76
// }
77
}
78
79     public ConnectionManager JavaDoc getManager()
80     {
81         return manager;
82     }
83
84     public void setManager(ConnectionManager JavaDoc manager)
85     {
86         this.manager = manager;
87     }
88
89     public MuleManagedConnectionFactory getFactory()
90     {
91         return factory;
92     }
93
94     public void setFactory(MuleManagedConnectionFactory factory)
95     {
96         this.factory = factory;
97     }
98
99     public Reference JavaDoc getReference()
100     {
101         return reference;
102     }
103
104     public void setReference(Reference JavaDoc reference)
105     {
106         this.reference = reference;
107     }
108
109     public MuleConnectionRequestInfo getInfo()
110     {
111         return info;
112     }
113
114     public void setInfo(MuleConnectionRequestInfo info)
115     {
116         this.info = info;
117     }
118 }
119
Popular Tags