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