org.jboss.mq.referenceable.SpyDestinationObjectFactory Maven / Gradle / Ivy
The newest version!
/*
* JBoss, Home of Professional Open Source
* Copyright 2005, JBoss Inc., and individual contributors as indicated
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.mq.referenceable;
import org.jboss.logging.Logger;
/**
* This class is used to create instances of of: SpyTopic SpyQueue classes from
* a javax.naming.Reference instance.
*
* @author Hiram Chirino ([email protected])
* @created August 16, 2001
* @version $Revision: 37459 $
*/
public class SpyDestinationObjectFactory implements javax.naming.spi.ObjectFactory {
static Logger cat = Logger.getLogger( SpyDestinationObjectFactory.class );
/**
* SpyTopicObjectFactory constructor
*/
public SpyDestinationObjectFactory() {
super();
}
/**
* getObjectInstance method
*
* @param reference Description of Parameter
* @param name Description of Parameter
* @param contex Description of Parameter
* @param properties Description of Parameter
* @return The ObjectInstance value
* @exception java.lang.Exception Description of Exception
*/
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 {
cat.debug( "SpyDestinationObjectFactory->getObjectInstance()" );
try {
javax.naming.Reference ref = ( javax.naming.Reference )reference;
if ( ref.getClassName().equals( "org.jboss.mq.SpyTopic" ) ) {
String dest = ( String )ref.get( "name" ).getContent();
return new org.jboss.mq.SpyTopic( dest );
} else if ( ref.getClassName().equals( "org.jboss.mq.SpyQueue" ) ) {
String dest = ( String )ref.get( "name" ).getContent();
return new org.jboss.mq.SpyQueue( dest );
}
} catch ( RuntimeException ignore ) {
} catch ( Exception ignore ) {
// This method should not throw an exception since
// It would prevent another ObjectFactory from attempting
// to create an instance of the object.
}
return null;
}
}