code: @Override
  	public Object getObjectInstance(Object obj, Name name, Context context, Hashtable<?,?> environment) throws Exception
  	{
  		if (!(obj instanceof Reference))
  			throw new IllegalStateException("Object is not a reference : "+obj);
  		
          Reference reference = (Reference)obj;
          String objClassName = reference.getClassName();
          
          // Queue
          if (objClassName.equals(QueueRef.class.getName()))
          {
          	String queueName = getRequiredAttribute(reference, "queueName");
          	return new QueueRef(queueName);
          }
          
          // Topic
          if (objClassName.equals(TopicRef.class.getName()))
          {
          	String topicName = getRequiredAttribute(reference, "topicName");
          	return new TopicRef(topicName);
          }
          
          // ConnectionFactory
          if (objClassName.equals(FFMQConnectionFactory.class.getName()))
          	return new FFMQConnectionFactory(recreateConnectionFactoryEnv(reference));
          
          // QueueConnectionFactory
          if (objClassName.equals(FFMQQueueConnectionFactory.class.getName()))
          	return new FFMQQueueConnectionFactory(recreateConnectionFactoryEnv(reference));
          
          // TopicConnectionFactory
          if (objClassName.equals(FFMQTopicConnectionFactory.class.getName()))
          	return new FFMQTopicConnectionFactory(recreateConnectionFactoryEnv(reference));
  
          // We don't know how to handle this
          return null; 
  	}
docs: /* (non-Javadoc)
  @see javax.naming.spi.ObjectFactory#getObjectInstance(java.lang.Object, javax.naming.Name, javax.naming.Context, java.util.Hashtable)