Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In the absence of any better knowledge I created my own ObjectFactory</p> <pre><code>public class ProvisioningConnectionsFactory implements ObjectFactory { public Object getObjectInstance(Object obj, Name namex, Context nameCtx, Hashtable environment) throws NamingException { // Acquire an instance of our specified bean class ProvisioningConnection conns = new ProvisioningConnection(); // Customize the bean properties from our attributes Reference ref = (Reference) obj; Enumeration addrs = ref.getAll(); while (addrs.hasMoreElements()) { RefAddr addr = (RefAddr) addrs.nextElement(); String name = addr.getType(); String value = (String) addr.getContent(); if (name.equals("serverUrl")) { conns.setServerUrl(value); } else if (name.equals("username")) { conns.setUsername(value); } else if (name.equals("password")) { conns.setPassword(value); } else if (name.equals("durableTopicSubscriberName")) { conns.setDurableTopicSubscriberName(value); } else if (name.equals("topicName")) { conns.setTopicName(value); } } // Return the customized instance return conns; } } </code></pre> <p>which meant I could add the following to my context.xml:</p> <pre><code>&lt;Resource name="jms/ProvisioningMessageConnection" auth="Container" type="com.foo.mytrialsprovisioning.ProvisioningConnection" factory="com.foo.mytrialsprovisioning.ProvisioningConnectionsFactory" serverUrl = "tcp://not-tibco-952v:10905" username = "tibco" password = "tibco" durableTopicSubscriberName = "PROVISIONING_SUBSCRIBER" topicName = "FOOBAR" /&gt; </code></pre> <p>and an instance of ProvisioningConnection:</p> <pre><code>public class ProvisioningConnection { private static final Log LOG = LogFactory.getLog(new CurrentClassGetter().getClassName()); private static final String MESSAGE_SELECTOR = "client_ID='%s'"; private String serverUrl; private String username; private String password; private String durableTopicSubscriberName; private String projectIdentifier; private String topicName; public void setServerUrl(String serverUrl) { this.serverUrl = serverUrl; } public void setUsername(String username) { this.username = username; } public void setPassword(String password) { this.password = password; } public void setDurableTopicSubscriberName(String durableTopicSubscriberName) { this.durableTopicSubscriberName = durableTopicSubscriberName; } public void setProjectIdentifier(String projectIdentifier) { this.projectIdentifier = projectIdentifier; } public void setTopicName(String topicName) { this.topicName = topicName; } public TopicConnection getTopicConnection() throws JMSException, NamingException { LOG.info("Provisioning against server: " + serverUrl); TopicConnectionFactory factory = new TibjmsTopicConnectionFactory(serverUrl); TopicConnection connection = factory.createTopicConnection(username, password); /* if clientID is specified we must set it right here */ if (projectIdentifier != null) { connection.setClientID(projectIdentifier); } return connection; } public TopicSubscriber getTopicSubscriber(Session session) throws JMSException { LOG.info("Provisioning subscription on topic: " + topicName); // Use createTopic() to enable subscriptions to dynamic topics. Topic topic = session.createTopic(topicName); return session.createDurableSubscriber(topic, durableTopicSubscriberName, ( Tools.isNullOrEmptyString(projectIdentifier) ? "" : String.format(MESSAGE_SELECTOR, projectIdentifier) ), true); } } </code></pre> <p>could be created using:</p> <pre><code>Context envCtx = (Context) initCtx.lookup("java:comp/env"); return (ProvisioningConnection)envCtx.lookup("jms/ProvisioningMessageConnection"); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload