1 package org.drools.jsr94.jca.spi;
2
3 /*
4 $Id: RuleManagedConnectionFactory.java,v 1.5 2003/06/19 09:28:35 tdiesler Exp $
5
6 Copyright 2002 (C) The Werken Company. All Rights Reserved.
7
8 Redistribution and use of this software and associated documentation
9 ("Software"), with or without modification, are permitted provided
10 that the following conditions are met:
11
12 1. Redistributions of source code must retain copyright
13 statements and notices. Redistributions must also contain a
14 copy of this document.
15
16 2. Redistributions in binary form must reproduce the
17 above copyright notice, this list of conditions and the
18 following disclaimer in the documentation and/or other
19 materials provided with the distribution.
20
21 3. The name "drools" must not be used to endorse or promote
22 products derived from this Software without prior written
23 permission of The Werken Company. For written permission,
24 please contact bob@werken.com.
25
26 4. Products derived from this Software may not be called "drools"
27 nor may "drools" appear in their names without prior written
28 permission of The Werken Company. "drools" is a registered
29 trademark of The Werken Company.
30
31 5. Due credit should be given to The Werken Company.
32 (http://drools.werken.com/).
33
34 THIS SOFTWARE IS PROVIDED BY THE WERKEN COMPANY AND CONTRIBUTORS
35 ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
36 NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
37 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
38 THE WERKEN COMPANY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
39 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
40 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
41 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
42 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
43 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
44 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
45 OF THE POSSIBILITY OF SUCH DAMAGE.
46
47 */
48
49 import javax.resource.ResourceException;
50 import javax.resource.spi.ConnectionManager;
51 import javax.resource.spi.ConnectionRequestInfo;
52 import javax.resource.spi.ManagedConnection;
53 import javax.resource.spi.ManagedConnectionFactory;
54 import javax.security.auth.Subject;
55 import java.io.PrintWriter;
56 import java.io.Serializable;
57 import java.util.Set;
58
59 /***
60 * ManagedConnectionFactory instance is a factory of both ManagedConnection and EIS-specific connection factory instances.
61 * This interface supports connection pooling by providing methods for matching and creation of ManagedConnection instance.
62 *
63 * @author <a href="mailto:thomas.diesler@softcon-itec.de">thomas diesler</a>
64 */
65 public class RuleManagedConnectionFactory implements ManagedConnectionFactory, Serializable
66 {
67
68 private PrintWriter logWriter;
69
70 /***
71 * Creates a Connection Factory instance.
72 * The Connection Factory instance gets initialized with the passed ConnectionManager.
73 * In the managed scenario, ConnectionManager is provided by the application server.
74 */
75 public Object createConnectionFactory( ConnectionManager cxManager ) throws ResourceException
76 {
77 logWriter.println( "RuleManagedConnectionFactory.createConnectionFactory" );
78 return new RuleConnectionFactory( this, cxManager );
79 }
80
81 /***
82 * Creates a Connection Factory instance.
83 * The Connection Factory instance gets initialized with a default ConnectionManager provided by the resource adapter.
84 */
85 public Object createConnectionFactory() throws ResourceException
86 {
87 logWriter.println( "RuleManagedConnectionFactory.createManagedFactory" );
88 return new RuleConnectionFactory( this, null );
89 }
90
91 /***
92 * Creates a new physical connection to the underlying EIS resource manager.
93 * <p>
94 * ManagedConnectionFactory uses the security information (passed as Subject) and additional
95 * ConnectionRequestInfo (which is specific to ResourceAdapter and opaque to application server) to create this new connection.
96 */
97 public ManagedConnection createManagedConnection( Subject subject, ConnectionRequestInfo info )
98 {
99 logWriter.println( "RuleManagedConnectionFactory.createManagedConnection" );
100 return null;
101 }
102
103 /***
104 * Returns a matched connection from the candidate set of connections.
105 * <p>
106 * ManagedConnectionFactory uses the security info (as in Subject) and information provided through
107 * ConnectionRequestInfo and additional Resource Adapter specific criteria to do matching.
108 * Note that criteria used for matching is specific to a resource adapter and is not prescribed by the Connector specification.
109 * <p>
110 * This method returns a ManagedConnection instance that is the best match for handling the connection allocation request.
111 *
112 */
113 public ManagedConnection matchManagedConnections( Set connectionSet, Subject subject, ConnectionRequestInfo info ) throws ResourceException
114 {
115 logWriter.println( "RuleManagedConnectionFactory.matchManagedConnections" );
116 return null;
117 }
118
119 /***
120 * Set the log writer for this ManagedConnectionFactory instance.
121 * <p>
122 * The log writer is a character output stream to which all logging and tracing messages for this
123 * ManagedConnectionfactory instance will be printed.
124 * <p>
125 * ApplicationServer manages the association of output stream with the ManagedConnectionFactory.
126 * When a ManagedConnectionFactory object is created the log writer is initially null, in other words, logging is disabled.
127 * Once a log writer is associated with a ManagedConnectionFactory, logging and tracing for ManagedConnectionFactory
128 * instance is enabled.
129 * <p>
130 * The ManagedConnection instances created by ManagedConnectionFactory "inherits" the log writer,
131 * which can be overridden by ApplicationServer using ManagedConnection.setLogWriter to set ManagedConnection
132 * specific logging and tracing.
133 */
134 public void setLogWriter( PrintWriter logWriter ) throws ResourceException
135 {
136 this.logWriter = logWriter;
137 }
138
139 /***
140 * Get the log writer for this ManagedConnectionFactory instance.
141 * <p>
142 * The log writer is a character output stream to which all logging and tracing messages for this
143 * ManagedConnectionFactory instance will be printed.
144 * <p>
145 * ApplicationServer manages the association of output stream with the ManagedConnectionFactory.
146 * When a ManagedConnectionFactory object is created the log writer is initially null, in other words, logging is disabled.
147 */
148 public PrintWriter getLogWriter() throws ResourceException
149 {
150 return logWriter;
151 }
152 }
This page was automatically generated by Maven