if (rawName.equals(ELT_ADMINMODULE)) {
} else if (rawName.equals(ELT_CONNECT)) {
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG,
"JoramSaxWrapper creates wrapper (TCP): " + host + ',' + port + ',' + name);
ConnectionFactory cf = TcpConnectionFactory.create(host, port, reliableClass);
cf.getParameters().connectingTimer = cnxTimer;
cf.setIdentityClassName(identityClass);
cnx = cf.createConnection(name, password);
cnx.start();
wrapper = new AdminWrapper(cnx);
} else if (rawName.equals(ELT_HACONNECT)) {
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG,
"JoramSaxWrapper creates wrapper (HA): " + url + ',' + name);
ConnectionFactory cf = HATcpConnectionFactory.create(url);
cf.getParameters().connectingTimer = cnxTimer;
cf.setIdentityClassName(identityClass);
cnx = cf.createConnection(name, password);
cnx.start();
wrapper = new AdminWrapper(cnx);
} else if (rawName.equals(ELT_COLLOCATEDCONNECT)) {
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG,
"JoramSaxWrapper creates wrapper (Local): " + name);
ConnectionFactory cf = LocalConnectionFactory.create();
cf.setIdentityClassName(identityClass);
cnx = cf.createConnection(name, password);
cnx.start();
wrapper = new AdminWrapper(cnx);
} else if (rawName.equals(ELT_CONNECTIONFACTORY)) {
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG, "cf \""+ name + "\"= " + obj);
// set identity className
if (isSet(identityClass))
((AbstractConnectionFactory) obj).setIdentityClassName(identityClass);
// Bind the ConnectionFactory in JNDI.
// Be Careful, currently only one binding is handled.
if (isSet(jndiName))
toBind.put(jndiName, obj);
jndiName = null;
// Register the CF in order to handle it later (cluster, etc.)
if (isSet(name)){
cfs.put(name, obj);
}
//Add interceptors if any
if ((inInterceptorClassname!=null) && (!inInterceptorClassname.isEmpty())) {
for (Iterator it=inInterceptorClassname.iterator(); it.hasNext(); ) {
String iicn = (String) it.next();
((AbstractConnectionFactory) obj).getParameters().addInInterceptor(iicn);
}
inInterceptorClassname.clear();
}
if ((outInterceptorClassname != null) && (!outInterceptorClassname.isEmpty())) {
for (Iterator it=outInterceptorClassname.iterator(); it.hasNext(); ) {
String oicn = (String) it.next();
((AbstractConnectionFactory) obj).getParameters().addOutInterceptor(oicn);
}
outInterceptorClassname.clear();
}
className = null;
obj = null;
identityClass = null;
} else if (rawName.equals(ELT_TCP)) {
try {
Class clazz = Class.forName(className);
Class [] classParams = {new String().getClass(),
Integer.TYPE,
new String().getClass()};
Method methode = clazz.getMethod("create", classParams);
Object[] objParams = {host, new Integer(port), reliableClass};
obj = methode.invoke(null, objParams);
} catch (Throwable exc) {
logger.log(BasicLevel.ERROR,
"JoramSaxWrapper: Cannot instantiate " + className, exc);
throw new SAXException(exc.getMessage());
}
} else if (rawName.equals(ELT_LOCAL)) {
try {
Class clazz = Class.forName(className);
Method methode = clazz.getMethod("create", new Class[0]);
obj = methode.invoke(null, new Object[0]);
} catch (Throwable exc) {
logger.log(BasicLevel.ERROR,
"JoramSaxWrapper: Cannot instantiate " + className, exc);
throw new SAXException(exc.getMessage());
}
} else if (rawName.equals(ELT_HATCP)) {
try {
Class clazz = Class.forName(className);
Class [] classParams = {new String().getClass(),
new String().getClass()};
Method methode = clazz.getMethod("create",classParams);
Object[] objParams = {url,reliableClass};
obj = methode.invoke(null,objParams);
} catch (Throwable exc) {
logger.log(BasicLevel.ERROR,
"JoramSaxWrapper: Cannot instantiate " + className, exc);
throw new SAXException(exc.getMessage());
}
} else if (rawName.equals(ELT_HALOCAL)) {
try {
Class clazz = Class.forName(className);
Method methode = clazz.getMethod("create", new Class[0]);
obj = methode.invoke(null, new Object[0]);
} catch (Throwable exc) {
logger.log(BasicLevel.ERROR,
"JoramSaxWrapper: Cannot instantiate " + className, exc);
throw new SAXException(exc.getMessage());
}
} else if (rawName.equals(ELT_SOAP)) {
try {
Class clazz = Class.forName(className);
Class [] classParams = {new String().getClass(),
Integer.TYPE,
Integer.TYPE};
Method methode = clazz.getMethod("create", classParams);
Object[] objParams = {host, new Integer(port), new Integer(timeout)};
obj = methode.invoke(null, objParams);
} catch (Throwable exc) {
logger.log(BasicLevel.ERROR,
"JoramSaxWrapper: Cannot instantiate " + className, exc);
throw new SAXException(exc.getMessage());
}
} else if (rawName.equals(ELT_JNDI)) {
} else if (rawName.equals(ELT_SERVER)) {
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG,
"Server.configure(" + serverId + ")");
if (threshold > 0)
getWrapper().setDefaultThreshold(serverId, threshold);
if (isSet(dmq)) {
if (dmqs.containsKey(dmq)) {
getWrapper().setDefaultDMQ(serverId, (DeadMQueue) dmqs.get(dmq));
} else {
logger.log(BasicLevel.ERROR,
"Cannot set default DMQ, unknown DMQ: " + dmq);
}
}
} else if (rawName.equals(ELT_USER)) {
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG,
"User.create(" + name + "," + login + "," + "-," + serverId + " ," + properties + ")");
if (! isSet(login)) login = name;
if (! isSet(identityClass)) identityClass = SimpleIdentity.class.getName();
User user = getWrapper().createUser(login, password, serverId, identityClass, properties);
users.put(name, user);
if (threshold > 0)
user.setThreshold(threshold);
if (isSet(dmq)) {
if (dmqs.containsKey(dmq)) {
user.setDMQ((DeadMQueue) dmqs.get(dmq));
} else {
logger.log(BasicLevel.ERROR,
"User.create(), unknown DMQ: " + dmq);
}
}
properties = null;
} else if (rawName.equals(ELT_DESTINATION)) {
Destination dest = null;
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG, "dest type =" + type);
if (type.equals("queue")) {
if (className == null)
className = "org.objectweb.joram.mom.dest.Queue";
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG,
"Queue.create(" + serverId + "," + name + "," + className + "," + properties + ")");
dest = getWrapper().createQueue(serverId, name, className, properties);
} else if (type.equals("topic")) {
if (className == null)
className = "org.objectweb.joram.mom.dest.Topic";
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG,
"Topic.create(" + serverId + "," + name + "," + className + "," + properties + ")");
dest = getWrapper().createTopic(serverId, name, className, properties);
} else
throw new Exception("type " + type + " bad value. (queue or topic)");
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG, "destination = " + dest);
properties = null;
configureDestination(dest);
// Bind the destination in JNDI.
// Be Careful, currently only one binding is handled.
if (isSet(jndiName))
toBind.put(jndiName, dest);
jndiName = null;
// Register the destination in order to handle it later.
String name = dest.getAdminName();
if (! isSet(name))
name = dest.getName();
if (dest instanceof Queue) {
queues.put(name, dest);
} else {
// It's a Topic
topics.put(name, dest);
}
// Fix DMQ if any
setDestinationDMQ(dest, dmq);
} else if (rawName.equals(ELT_QUEUE)) {
if (className == null)
className = "org.objectweb.joram.mom.dest.Queue";
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG,
"Queue.create(" + serverId + "," + name + "," + className + "," + properties + ")");
Queue queue = (Queue) getWrapper().createQueue(serverId, name, className, properties);
properties = null;
configureDestination(queue);
if (threshold > 0)
queue.setThreshold(threshold);
if (nbMaxMsg > 0)
queue.setNbMaxMsg(nbMaxMsg);
// Bind the queue in JNDI.
// Be Careful, currently only one binding is handled.
if (isSet(jndiName))
toBind.put(jndiName, queue);
jndiName = null;
// Register the queue in order to handle it later (cluster, etc.)
String name = queue.getAdminName();
if (! isSet(name)) name = queue.getName();
queues.put(name, queue);
// Fix DMQ if any
setDestinationDMQ(queue, dmq);
} else if (rawName.equals(ELT_TOPIC)) {
if (className == null)
className = "org.objectweb.joram.mom.dest.Topic";
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG,
"Topic.create(" + serverId + "," + name + "," + className + "," + properties + ")");
Topic topic = (Topic) getWrapper().createTopic(serverId, name, className, properties);
properties = null;
configureDestination(topic);
if (isSet(parent)) {
// TODO (AF): may be we should search the parent topic: JNDI? Joram?
if (topics.containsKey(parent)) {
topic.setParent((Topic) topics.get(parent));
} else {
logger.log(BasicLevel.ERROR,
"Topic.create(): Unknown parent: " + parent);
}
}
// Bind the topic in JNDI.
// Be Careful, currently only one binding is handled.
if (isSet(jndiName))
toBind.put(jndiName, topic);
jndiName = null;
// Register the topic in order to handle it later (cluster, etc.)
String name = topic.getAdminName();
if (! isSet(name)) name = topic.getName();
topics.put(name, topic);
// Fix DMQ if any
setDestinationDMQ(topic, dmq);
} else if (rawName.equals(ELT_DMQUEUE)) {
className = "org.objectweb.joram.mom.dest.Queue";
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG,
"DeadMQueue.create(" + serverId + "," + name + ")");
DeadMQueue dmq = (DeadMQueue) getWrapper().createDeadMQueue(serverId, name);
configureDestination(dmq);
// Bind the destination in JNDI.
// Be Careful, currently only one binding is handled.
if (isSet(jndiName))
toBind.put(jndiName, dmq);
jndiName = null;
// Register the DMQ in order to handle it later.
if (isSet(name))
dmqs.put(name, dmq);
} else if (rawName.equals(ELT_PROPERTY)) {
} else if (rawName.equals(ELT_READER)) {
readers.add(user);
} else if (rawName.equals(ELT_WRITER)) {
writers.add(user);
} else if (rawName.equals(ELT_FREEREADER)) {
} else if (rawName.equals(ELT_FREEWRITER)) {
} else if (rawName.equals(ELT_INITIALCONTEXT)) {
try {
jndiCtx = new javax.naming.InitialContext(properties);
} catch (NamingException exc) {
logger.log(BasicLevel.ERROR,"",exc);
}
} else if (rawName.equals(ELT_CLUSTER_ELEMENT)) {
} else if (rawName.equals(ELT_CLUSTER_CF)) {
Map.Entry entries[] = new Map.Entry [cluster.size()];
cluster.entrySet().toArray(entries);
ClusterConnectionFactory clusterCF = new ClusterConnectionFactory();
for (int i=0; i<entries.length; i++) {
ConnectionFactory cf = (ConnectionFactory) cfs.get(entries[i].getKey());
clusterCF.addConnectionFactory((String) entries[i].getValue(), cf);
}
cluster.clear();
// Bind the destination in JNDI.