KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > ejb > plugins > inflow > JBossJMSMessageEndpointFactory


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.ejb.plugins.inflow;
23
24 import javax.jms.Session JavaDoc;
25
26 import org.jboss.deployment.DeploymentException;
27 import org.jboss.metadata.ActivationConfigPropertyMetaData;
28 import org.jboss.metadata.MessageDrivenMetaData;
29 import org.jboss.metadata.MetaData;
30 import org.w3c.dom.Element JavaDoc;
31
32 /**
33  * Hacked version of message endpoint factory for backwards compatibility
34  *
35  * @author <a HREF="mailto:adrian@jboss.com">Adrian Brock</a> .
36  * @version <tt>$Revision: 37459 $</tt>
37  */

38 public class JBossJMSMessageEndpointFactory
39    extends JBossMessageEndpointFactory
40 {
41    // Constants -----------------------------------------------------
42

43    /** The JBoss resource adapter deployment name */
44    protected static String JavaDoc jmsra = "jms-ra.rar";
45    
46    // Attributes ----------------------------------------------------
47

48    // Static --------------------------------------------------------
49

50    // Constructors --------------------------------------------------
51

52    // Public --------------------------------------------------------
53

54    // Protected -----------------------------------------------------
55

56    protected String JavaDoc resolveResourceAdapterName() throws DeploymentException
57    {
58       String JavaDoc result = super.resolveResourceAdapterName();
59       if (result == null)
60          result = jmsra;
61       return result;
62    }
63    
64    /**
65     * Add activation config properties
66     *
67     * @throws DeploymentException for any error
68     */

69    protected void augmentActivationConfigProperties() throws DeploymentException
70    {
71       super.augmentActivationConfigProperties();
72       
73       // Hack for old style deployments (jms)
74
if (metaData.isJMSMessagingType())
75       {
76          checkActivationConfig("destination", metaData.getDestinationJndiName());
77          checkActivationConfig("destinationType", metaData.getDestinationType());
78          checkActivationConfig("messageSelector", metaData.getMessageSelector());
79          if (Session.DUPS_OK_ACKNOWLEDGE == metaData.getAcknowledgeMode())
80             checkActivationConfig("acknowledgeMode", "DUPS_OK_ACKNOWLEDGE");
81          else
82             checkActivationConfig("acknowledgeMode", "AUTO_ACKNOWLEDGE");
83          if (MessageDrivenMetaData.DURABLE_SUBSCRIPTION == metaData.getSubscriptionDurability())
84             checkActivationConfig("subscriptionDurability", "Durable");
85          else
86             checkActivationConfig("subscriptionDurability", "NonDurable");
87          checkActivationConfig("clientID", metaData.getClientId());
88          checkActivationConfig("subscriptionName", metaData.getSubscriptionId());
89          
90          // Only for JBoss's resource adapter
91
if (jmsra.equals(resourceAdapterName))
92          {
93             checkActivationConfig("user", metaData.getUser());
94             checkActivationConfig("password", metaData.getPasswd());
95             Element JavaDoc proxyConfig = invokerMetaData.getProxyFactoryConfig();
96             checkActivationConfig("maxMessages", MetaData.getOptionalChildContent(proxyConfig, "MaxMessages"));
97             checkActivationConfig("minSession", MetaData.getOptionalChildContent(proxyConfig, "MinimumSize"));
98             checkActivationConfig("maxSession", MetaData.getOptionalChildContent(proxyConfig, "MaximumSize"));
99             checkActivationConfig("keepAlive", MetaData.getOptionalChildContent(proxyConfig, "KeepAliveMillis"));
100             Element JavaDoc mdbConfig = MetaData.getOptionalChild(proxyConfig, "MDBConfig");
101             if (mdbConfig != null)
102             {
103                checkActivationConfig("reconnectInterval", MetaData.getOptionalChildContent(proxyConfig, "ReconnectIntervalSec"));
104                checkActivationConfig("deliveryActive", MetaData.getOptionalChildContent(proxyConfig, "DeliveryActive"));
105                checkActivationConfig("providerAdapterJNDI", MetaData.getOptionalChildContent(proxyConfig, "JMSProviderAdapterJNDI"));
106                // TODO DLQ
107
}
108          }
109       }
110    }
111
112    /**
113     * When the config doesn't exist for a given name adds the value when not null
114     *
115     * @param name the name of the config property
116     * @param value the value to add
117     */

118    void checkActivationConfig(String JavaDoc name, String JavaDoc value)
119    {
120       if (value != null && properties.containsKey(name) == false)
121       {
122          ActivationConfigPropertyMetaData md = new ActivationConfigPropertyMetaData(name, value);
123          properties.put(name, md);
124       }
125    }
126    
127    // Package Private -----------------------------------------------
128

129    // Private -------------------------------------------------------
130

131    // Inner Classes -------------------------------------------------
132
}
133
Popular Tags