private String queuePrefix = "queue.";
private String topicPrefix = "topic.";
public Context getInitialContext(Hashtable environment) throws NamingException {
// lets create a factory
Map data = new ConcurrentHashMap();
String[] names = getConnectionFactoryNames(environment);
for (int i = 0; i < names.length; i++) {
ActiveMQConnectionFactory factory =null;
String name = names[i];
try{
factory = createConnectionFactory(name, environment);
}catch(Exception e){
throw new NamingException("Invalid broker URL");
}
/* if( broker==null ) {
try {
broker = factory.getEmbeddedBroker();
}
catch (JMSException e) {
log.warn("Failed to get embedded broker", e);
}
}
*/
data.put(name,factory);
}
createQueues(data, environment);
createTopics(data, environment);
/*
if (broker != null) {
data.put("destinations", broker.getDestinationContext(environment));
}
*/
data.put("dynamicQueues", new LazyCreateContext() {
private static final long serialVersionUID = 6503881346214855588L;
protected Object createEntry(String name) {
return new ActiveMQQueue(name);
}
});
data.put("dynamicTopics", new LazyCreateContext() {
private static final long serialVersionUID = 2019166796234979615L;
protected Object createEntry(String name) {
return new ActiveMQTopic(name);
}