{
Channel channel = (Channel)itr.next();
if (channel instanceof MessageQueue && channel.isEnabled())
{
MessageQueue mq = (MessageQueue)channel;
String sConnFactoryType = (channel.isTransactional()) ? "tx-connection-factory" : "no-tx-connection-factory";
if (mq.isConnectionFactoryManaged())
{
String sCFJNDIName = getCFJNDIName(mq);
Element connectionFactory = XMLUtil.findChildElementBySubelement(
connectionFactories, "tx-connection-factory", "jndi-name", sCFJNDIName);
/*
* If we change from tx-connection-factory to no-tx-connection-factory or the other way around
* we delete the old definitions and create new ones from scratch
*/
if (connectionFactory != null)
{
if (!channel.isTransactional())
{
XMLUtil.removeNode(connectionFactory);
connectionFactory = null;
}
}
else
{
connectionFactory = XMLUtil.findChildElementBySubelement(
connectionFactories, "no-tx-connection-factory", "jndi-name", sCFJNDIName);
if (connectionFactory != null)
{
if (channel.isTransactional())
{
XMLUtil.removeNode(connectionFactory);
connectionFactory = null;
}
}
}
if (mq.getConnectionFactory() == null)
{
if (connectionFactory == null)
{
connectionFactory = doc.createElement(sConnFactoryType);
connectionFactories.appendChild(connectionFactory);
}
XMLUtil.setChildElement(connectionFactory, CONNECTION_FACTORY_ELEMENTS,
"jndi-name", sCFJNDIName, false);
XMLUtil.removeNode(XMLUtil.findChildElement(connectionFactory, "local-transaction"));
if (channel.isTransactional())
{
XMLUtil.setChildElement(connectionFactory, CONNECTION_FACTORY_ELEMENTS,
"xa-transaction", null, false);
}
XMLUtil.setChildElement(connectionFactory, CONNECTION_FACTORY_ELEMENTS,
"rar-name", "jms-ra.rar", false);
XMLUtil.setChildElement(connectionFactory, CONNECTION_FACTORY_ELEMENTS,
"connection-definition", "org.jboss.resource.adapter.jms.JmsConnectionFactory", false);
Element element = XMLUtil.findChildElement(connectionFactory, "config-property", "name", "SessionDefaultType");
if (element == null)
{
element = XMLUtil.addChildElement(connectionFactory, CONNECTION_FACTORY_ELEMENTS,
"config-property", "javax.jms.Topic");
XMLUtil.setAttribute(element, "name", "SessionDefaultType", true);
XMLUtil.setAttribute(element, "type", "java.lang.String", true);
}
element = XMLUtil.findChildElement(connectionFactory, "config-property", "name", "JmsProviderAdapterJNDI");
if (element == null)
{
element = XMLUtil.addChildElement(connectionFactory, CONNECTION_FACTORY_ELEMENTS,
"config-property", "java:/DefaultJMSProvider");
XMLUtil.setAttribute(element, "name", "JmsProviderAdapterJNDI", true);
XMLUtil.setAttribute(element, "type", "java.lang.String", true);
}
XMLUtil.setChildElement(connectionFactory, CONNECTION_FACTORY_ELEMENTS,
"max-pool-size", String.valueOf(mq.getMaxSenders() + ((mq.isReceivable()) ? 1 : 0)), true);
XMLUtil.setChildElement(connectionFactory, CONNECTION_FACTORY_ELEMENTS,
"security-domain-and-application", getJAASDomain(mq), true);
}
else
{