code: public TopicConnectionFactory getTopicConnectionFactory(String
        topicConnFactoryName) throws ServiceLocatorException {
      TopicConnectionFactory factory = null;
      try {
        if (cache.containsKey(topicConnFactoryName)) {
          factory = (TopicConnectionFactory) cache.get(topicConnFactoryName);
        } else {
          factory = (TopicConnectionFactory) ic.lookup(topicConnFactoryName);
          cache.put(topicConnFactoryName, factory);
        }
      } catch (NamingException ne) {
        throw new ServiceLocatorException(ne);
      } catch (Exception e) {
        throw new ServiceLocatorException(e);
      }
      return factory;
    }
docs: This method helps in obtaining the topic factory
  @return the factory for the factory to get topic connections from