1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
package org.mule.module.jca; |
8 | |
|
9 | |
import java.io.IOException; |
10 | |
import java.io.ObjectInputStream; |
11 | |
|
12 | |
import javax.naming.Reference; |
13 | |
import javax.resource.ResourceException; |
14 | |
import javax.resource.spi.ConnectionManager; |
15 | |
|
16 | |
import org.apache.commons.logging.Log; |
17 | |
import org.apache.commons.logging.LogFactory; |
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
public class DefaultMuleConnectionFactory implements MuleConnectionFactory |
25 | |
{ |
26 | |
|
27 | |
|
28 | |
|
29 | |
private static final long serialVersionUID = 1552386015565975623L; |
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | 0 | protected transient Log logger = LogFactory.getLog(this.getClass()); |
35 | |
|
36 | |
private transient ConnectionManager manager; |
37 | |
private transient MuleManagedConnectionFactory factory; |
38 | |
private Reference reference; |
39 | |
private MuleConnectionRequestInfo info; |
40 | |
|
41 | |
public DefaultMuleConnectionFactory(MuleManagedConnectionFactory factory, |
42 | |
ConnectionManager manager, |
43 | |
MuleConnectionRequestInfo info) |
44 | 0 | { |
45 | 0 | this.factory = factory; |
46 | 0 | this.manager = manager; |
47 | 0 | this.info = info; |
48 | 0 | } |
49 | |
|
50 | |
private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException |
51 | |
{ |
52 | 0 | ois.defaultReadObject(); |
53 | |
|
54 | |
|
55 | 0 | this.logger = LogFactory.getLog(this.getClass()); |
56 | 0 | } |
57 | |
|
58 | |
public MuleConnection createConnection() throws ResourceException |
59 | |
{ |
60 | 0 | return createConnection(info); |
61 | |
} |
62 | |
|
63 | |
public MuleConnection createConnection(MuleConnectionRequestInfo info) throws ResourceException |
64 | |
{ |
65 | |
|
66 | 0 | return (MuleConnection)manager.allocateConnection(factory, info); |
67 | |
|
68 | |
|
69 | |
|
70 | |
|
71 | |
|
72 | |
|
73 | |
} |
74 | |
|
75 | |
public ConnectionManager getManager() |
76 | |
{ |
77 | 0 | return manager; |
78 | |
} |
79 | |
|
80 | |
public void setManager(ConnectionManager manager) |
81 | |
{ |
82 | 0 | this.manager = manager; |
83 | 0 | } |
84 | |
|
85 | |
public MuleManagedConnectionFactory getFactory() |
86 | |
{ |
87 | 0 | return factory; |
88 | |
} |
89 | |
|
90 | |
public void setFactory(MuleManagedConnectionFactory factory) |
91 | |
{ |
92 | 0 | this.factory = factory; |
93 | 0 | } |
94 | |
|
95 | |
public Reference getReference() |
96 | |
{ |
97 | 0 | return reference; |
98 | |
} |
99 | |
|
100 | |
public void setReference(Reference reference) |
101 | |
{ |
102 | 0 | this.reference = reference; |
103 | 0 | } |
104 | |
|
105 | |
public MuleConnectionRequestInfo getInfo() |
106 | |
{ |
107 | 0 | return info; |
108 | |
} |
109 | |
|
110 | |
public void setInfo(MuleConnectionRequestInfo info) |
111 | |
{ |
112 | 0 | this.info = info; |
113 | 0 | } |
114 | |
} |