in src/main/java/org/apache/log4j/receivers/net/JMSReceiver.java [186:241]
public void activateOptions() {
if (!isActive()) {
try {
remoteInfo = topicFactoryName + ":" + topicName;
Context ctx = null;
if (jndiPath == null || jndiPath.equals("")) {
ctx = new InitialContext();
} else {
FileInputStream is = new FileInputStream(jndiPath);
Properties p = new Properties();
p.load(is);
is.close();
ctx = new InitialContext(p);
}
// give some more flexibility about the choice of a tab name
providerUrl = (String)ctx.getEnvironment().get(Context.PROVIDER_URL);
TopicConnectionFactory topicConnectionFactory;
topicConnectionFactory =
(TopicConnectionFactory) lookup(ctx, topicFactoryName);
if (userId != null && password != null) {
topicConnection =
topicConnectionFactory.createTopicConnection(userId, password);
} else {
topicConnection =
topicConnectionFactory.createTopicConnection();
}
TopicSession topicSession =
topicConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
Topic topic = (Topic)ctx.lookup(topicName);
TopicSubscriber topicSubscriber = topicSession.createSubscriber(topic);
topicSubscriber.setMessageListener(this);
topicConnection.start();
setActive(true);
} catch(Exception e) {
setActive(false);
if (topicConnection != null) {
try {
topicConnection.close();
} catch (Exception e2) {
// do nothing
}
topicConnection = null;
}
getLogger().error("Could not start JMSReceiver.", e);
}
}
}