001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.ejb.plugins.inflow;
023:
024: import javax.jms.Session;
025:
026: import org.jboss.deployment.DeploymentException;
027: import org.jboss.metadata.ActivationConfigPropertyMetaData;
028: import org.jboss.metadata.MessageDrivenMetaData;
029: import org.jboss.metadata.MetaData;
030: import org.w3c.dom.Element;
031:
032: /**
033: * Hacked version of message endpoint factory for backwards compatibility
034: *
035: * @author <a href="mailto:adrian@jboss.com">Adrian Brock</a> .
036: * @version <tt>$Revision: 57209 $</tt>
037: */
038: public class JBossJMSMessageEndpointFactory extends
039: JBossMessageEndpointFactory {
040: // Constants -----------------------------------------------------
041:
042: /** The JBoss resource adapter deployment name */
043: protected static String jmsra = "jms-ra.rar";
044:
045: // Attributes ----------------------------------------------------
046:
047: // Static --------------------------------------------------------
048:
049: // Constructors --------------------------------------------------
050:
051: // Public --------------------------------------------------------
052:
053: // Protected -----------------------------------------------------
054:
055: protected String resolveResourceAdapterName()
056: throws DeploymentException {
057: String result = super .resolveResourceAdapterName();
058: if (result == null)
059: result = jmsra;
060: return result;
061: }
062:
063: /**
064: * Add activation config properties
065: *
066: * @throws DeploymentException for any error
067: */
068: protected void augmentActivationConfigProperties()
069: throws DeploymentException {
070: super .augmentActivationConfigProperties();
071:
072: // Hack for old style deployments (jms)
073: if (metaData.isJMSMessagingType()) {
074: checkActivationConfig("destination", metaData
075: .getDestinationJndiName());
076: checkActivationConfig("destinationType", metaData
077: .getDestinationType());
078: checkActivationConfig("messageSelector", metaData
079: .getMessageSelector());
080: if (Session.DUPS_OK_ACKNOWLEDGE == metaData
081: .getAcknowledgeMode())
082: checkActivationConfig("acknowledgeMode",
083: "DUPS_OK_ACKNOWLEDGE");
084: else
085: checkActivationConfig("acknowledgeMode",
086: "AUTO_ACKNOWLEDGE");
087: if (MessageDrivenMetaData.DURABLE_SUBSCRIPTION == metaData
088: .getSubscriptionDurability())
089: checkActivationConfig("subscriptionDurability",
090: "Durable");
091: else
092: checkActivationConfig("subscriptionDurability",
093: "NonDurable");
094: checkActivationConfig("clientID", metaData.getClientId());
095: checkActivationConfig("subscriptionName", metaData
096: .getSubscriptionId());
097:
098: // Only for JBoss's resource adapter
099: if (jmsra.equals(resourceAdapterName)) {
100: checkActivationConfig("user", metaData.getUser());
101: checkActivationConfig("password", metaData.getPasswd());
102: Element proxyConfig = invokerMetaData
103: .getProxyFactoryConfig();
104: checkActivationConfig("maxMessages", MetaData
105: .getOptionalChildContent(proxyConfig,
106: "MaxMessages"));
107: checkActivationConfig("minSession", MetaData
108: .getOptionalChildContent(proxyConfig,
109: "MinimumSize"));
110: checkActivationConfig("maxSession", MetaData
111: .getOptionalChildContent(proxyConfig,
112: "MaximumSize"));
113: checkActivationConfig("keepAlive", MetaData
114: .getOptionalChildContent(proxyConfig,
115: "KeepAliveMillis"));
116: Element mdbConfig = MetaData.getOptionalChild(
117: proxyConfig, "MDBConfig");
118: if (mdbConfig != null) {
119: checkActivationConfig("reconnectInterval", MetaData
120: .getOptionalChildContent(proxyConfig,
121: "ReconnectIntervalSec"));
122: checkActivationConfig("deliveryActive", MetaData
123: .getOptionalChildContent(proxyConfig,
124: "DeliveryActive"));
125: checkActivationConfig("providerAdapterJNDI",
126: MetaData.getOptionalChildContent(
127: proxyConfig,
128: "JMSProviderAdapterJNDI"));
129: // TODO DLQ
130: }
131: }
132: }
133: }
134:
135: /**
136: * When the config doesn't exist for a given name adds the value when not null
137: *
138: * @param name the name of the config property
139: * @param value the value to add
140: */
141: void checkActivationConfig(String name, String value) {
142: if (value != null && properties.containsKey(name) == false) {
143: ActivationConfigPropertyMetaData md = new ActivationConfigPropertyMetaData(
144: name, value);
145: properties.put(name, md);
146: }
147: }
148:
149: // Package Private -----------------------------------------------
150:
151: // Private -------------------------------------------------------
152:
153: // Inner Classes -------------------------------------------------
154: }
|