package org.jboss.mq.referenceable;
import org.jboss.logging.Logger;
import org.jboss.mq.GenericConnectionFactory;
public class SpyConnectionFactoryObjectFactory implements javax.naming.spi.ObjectFactory {
static Logger cat = Logger.getLogger( SpyConnectionFactoryObjectFactory.class );
public java.lang.Object getObjectInstance( java.lang.Object reference, javax.naming.Name name, javax.naming.Context contex, java.util.Hashtable properties )
throws java.lang.Exception {
boolean debug = cat.isDebugEnabled();
if (debug)
cat.debug( "Extracting SpyConnectionFactory from reference" );
try {
javax.naming.Reference ref = ( javax.naming.Reference )reference;
GenericConnectionFactory dcf = ( GenericConnectionFactory )
ObjectRefAddr.extractObjectRefFrom( ref, "DCF" );
if (debug)
cat.debug("The GenericConnectionFactory is: "+dcf);
if ( ref.getClassName().equals( "org.jboss.mq.SpyConnectionFactory" ) ) {
return new org.jboss.mq.SpyConnectionFactory( dcf );
} else if ( ref.getClassName().equals( "org.jboss.mq.SpyXAConnectionFactory" ) ) {
return new org.jboss.mq.SpyXAConnectionFactory( dcf );
}
} catch ( Throwable ignore ) {
ignore.printStackTrace();
}
return null;
}
}