User: user57 Date: 01/07/10 17:29:08 Modified: src/main/org/jboss/jms/ra JmsManagedConnectionFactory.java Log: o re-indent (no code change) Revision Changes Path 1.3 +147 -157 jboss/src/main/org/jboss/jms/ra/JmsManagedConnectionFactory.java Index: JmsManagedConnectionFactory.java =================================================================== RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/jms/ra/JmsManagedConnectionFactory.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- JmsManagedConnectionFactory.java 2001/06/18 20:01:26 1.2 +++ JmsManagedConnectionFactory.java 2001/07/11 00:29:08 1.3 @@ -44,170 +44,160 @@ * Created: Sat Mar 31 03:08:35 2001 * * @author <a href="mailto:[EMAIL PROTECTED]">Peter Antman</a>. - * @version $Revision: 1.2 $ + * @version $Revision: 1.3 $ */ - -public class JmsManagedConnectionFactory implements ManagedConnectionFactory { - - private PrintWriter logWriter = null; - private String providerJNDI; - private JmsLogger logger = new JmsLogger(); - - //For local access - private JMSProviderAdapter adapter; - public JmsManagedConnectionFactory() { - - } - /** - * Create a "non managed" connection factory. No appserver involved - */ - public Object createConnectionFactory() throws ResourceException - { - return new JmsConnectionFactoryImpl(this, null); - } - - /** - * Create a ConnectionFactory with appserver hook - */ - public Object createConnectionFactory(ConnectionManager cxManager) - throws ResourceException - { - return new JmsConnectionFactoryImpl(this, cxManager); - } +public class JmsManagedConnectionFactory + implements ManagedConnectionFactory +{ + private PrintWriter logWriter = null; + private String providerJNDI; + private JmsLogger logger = new JmsLogger(); + + //For local access + private JMSProviderAdapter adapter; + + public JmsManagedConnectionFactory() { + } + + /** + * Create a "non managed" connection factory. No appserver involved + */ + public Object createConnectionFactory() throws ResourceException + { + return new JmsConnectionFactoryImpl(this, null); + } + + /** + * Create a ConnectionFactory with appserver hook + */ + public Object createConnectionFactory(ConnectionManager cxManager) + throws ResourceException + { + return new JmsConnectionFactoryImpl(this, cxManager); + } - /** - * Create a new connection to manage in pool - */ - public ManagedConnection createManagedConnection(Subject subject, - ConnectionRequestInfo info) - throws ResourceException - { - JmsCred cred = JmsCred.getJmsCred(this,subject, info); - // OK we got autentication stuff - JmsManagedConnection mc = new JmsManagedConnection - (this, info,cred.name, cred.pwd); - // Set default logwriter according to spec - mc.setLogWriter(logWriter); - return mc; - - } - - /** - * Match a set of connections from the pool - */ - public ManagedConnection - matchManagedConnections(Set connectionSet, - Subject subject, - ConnectionRequestInfo info) - throws ResourceException { - - // Get cred - JmsCred cred = JmsCred.getJmsCred(this,subject, info); - - // Traverse the pooled connections and look for a match, return - // first found - Iterator connections = connectionSet.iterator(); - while (connections.hasNext()) { - Object obj = connections.next(); + /** + * Create a new connection to manage in pool + */ + public ManagedConnection createManagedConnection(Subject subject, + ConnectionRequestInfo info) + throws ResourceException + { + JmsCred cred = JmsCred.getJmsCred(this,subject, info); + // OK we got autentication stuff + JmsManagedConnection mc = new JmsManagedConnection + (this, info,cred.name, cred.pwd); + // Set default logwriter according to spec + mc.setLogWriter(logWriter); + return mc; + + } + + /** + * Match a set of connections from the pool + */ + public ManagedConnection matchManagedConnections(Set connectionSet, + Subject subject, + ConnectionRequestInfo info) + throws ResourceException + { + // Get cred + JmsCred cred = JmsCred.getJmsCred(this,subject, info); + + // Traverse the pooled connections and look for a match, return + // first found + Iterator connections = connectionSet.iterator(); + while (connections.hasNext()) { + Object obj = connections.next(); - // We only care for connections of our own type - if (obj instanceof JmsManagedConnection) { - // This is one from the pool - JmsManagedConnection mc = (JmsManagedConnection) obj; + // We only care for connections of our own type + if (obj instanceof JmsManagedConnection) { + // This is one from the pool + JmsManagedConnection mc = (JmsManagedConnection) obj; - // Check if we even created this on - ManagedConnectionFactory mcf = - mc.getManagedConnectionFactory(); + // Check if we even created this on + ManagedConnectionFactory mcf = + mc.getManagedConnectionFactory(); - // Only admit a connection if it has the same username as our - // asked for creds - // FIXME, Here we have a problem, jms connection - // may be anonymous, have a user name + // Only admit a connection if it has the same username as our + // asked for creds + // FIXME, Here we have a problem, jms connection + // may be anonymous, have a user name - if ( - (mc.getUserName() == null || - (mc.getUserName() != null && - mc.getUserName().equals(cred.name)) - ) && - mcf.equals(this)) { - // Now check if ConnectionInfo equals - if (info.equals( mc.getInfo() )) { - - return mc; - } - } + if ( + (mc.getUserName() == null || + (mc.getUserName() != null && + mc.getUserName().equals(cred.name)) + ) && + mcf.equals(this)) { + // Now check if ConnectionInfo equals + if (info.equals( mc.getInfo() )) { + + return mc; + } } - } - return null; - } - - /** - * - */ - public void setLogWriter(PrintWriter out) - throws ResourceException { - this.logWriter = out; - logger.setLogWriter(out); - } - /** - * - */ - public PrintWriter getLogWriter() throws ResourceException { - return logWriter; - } - - // FIXME, what should be the unique identity of a ConnectionFactory for - // JMS, hard do say actually - - public boolean equals(Object obj) { - if (obj == null) return false; - if (obj instanceof JmsManagedConnectionFactory) { - String you = ((JmsManagedConnectionFactory) obj). - getJmsProviderAdapterJNDI(); - String me = this.providerJNDI; - return (you == null) ? (me == null) : (you.equals(me)); - } else { - return false; - } - } - - public int hashCode() { - if (providerJNDI == null) { - return (new String("")).hashCode(); - } else { - return providerJNDI.hashCode(); - } - } - - // --- Connfiguration API --- - public void setJmsProviderAdapterJNDI(String jndi) { - providerJNDI = jndi; - } - - public String getJmsProviderAdapterJNDI() { - return providerJNDI; - } - - /** - * For local access - */ - public void setJmsProviderAdapter(JMSProviderAdapter adapter) { - this.adapter = adapter; - } + } + } + return null; + } + + /** + * + */ + public void setLogWriter(PrintWriter out) + throws ResourceException { + this.logWriter = out; + logger.setLogWriter(out); + } + + /** + * + */ + public PrintWriter getLogWriter() throws ResourceException { + return logWriter; + } + + // FIXME, what should be the unique identity of a ConnectionFactory for + // JMS, hard do say actually + + public boolean equals(Object obj) { + if (obj == null) return false; + if (obj instanceof JmsManagedConnectionFactory) { + String you = ((JmsManagedConnectionFactory) obj). + getJmsProviderAdapterJNDI(); + String me = this.providerJNDI; + return (you == null) ? (me == null) : (you.equals(me)); + } else { + return false; + } + } + + public int hashCode() { + if (providerJNDI == null) { + return (new String("")).hashCode(); + } else { + return providerJNDI.hashCode(); + } + } + + // --- Connfiguration API --- + public void setJmsProviderAdapterJNDI(String jndi) { + providerJNDI = jndi; + } - public JMSProviderAdapter getJmsProviderAdapter() { - return adapter; - - } - + public String getJmsProviderAdapterJNDI() { + return providerJNDI; + } + + /** + * For local access + */ + public void setJmsProviderAdapter(JMSProviderAdapter adapter) { + this.adapter = adapter; + } + public JMSProviderAdapter getJmsProviderAdapter() { + return adapter; + } + } // JmsManagedConnectionFactory - - - - - - - - - _______________________________________________ Jboss-development mailing list [EMAIL PROTECTED] http://lists.sourceforge.net/lists/listinfo/jboss-development