/**
* Options are activated and become effective only after calling
* this method.*/
public void activateOptions() {
TopicConnectionFactory topicConnectionFactory;
try {
Context jndi;
getLogger().debug("Getting initial context.");
if (initialContextFactoryName != null) {
Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY, initialContextFactoryName);
if (providerURL != null) {
env.put(Context.PROVIDER_URL, providerURL);
} else {
getLogger().warn(
"You have set InitialContextFactoryName option but not the "
+ "ProviderURL. This is likely to cause problems.");
}
if (urlPkgPrefixes != null) {
env.put(Context.URL_PKG_PREFIXES, urlPkgPrefixes);
}
if (securityPrincipalName != null) {
env.put(Context.SECURITY_PRINCIPAL, securityPrincipalName);
if (securityCredentials != null) {
env.put(Context.SECURITY_CREDENTIALS, securityCredentials);
} else {
getLogger().warn(
"You have set SecurityPrincipalName option but not the "
+ "SecurityCredentials. This is likely to cause problems.");
}
}
jndi = new InitialContext(env);
} else {
jndi = new InitialContext();
}
getLogger().debug("Looking up [{}]", tcfBindingName);
topicConnectionFactory =
(TopicConnectionFactory) lookup(jndi, tcfBindingName);
getLogger().debug("About to create TopicConnection.");
if (userName != null) {
this.topicConnection =
topicConnectionFactory.createTopicConnection(userName, password);
} else {
this.topicConnection = topicConnectionFactory.createTopicConnection();
}
getLogger().debug(
"Creating TopicSession, non-transactional, "
+ "in AUTO_ACKNOWLEDGE mode.");