User: starksm
Date: 01/12/13 19:22:11
Modified: src/main/org/jboss/jms/jndi Tag: Branch_2_4
JMSProviderLoader.java
Log:
Integrate changes from 3.0 to improve the MDB/ASF layer. This includes
support for the dead message queue for repeated MDB.onMessage failures.
Revision Changes Path
No revision
No revision
1.2.6.2 +202 -235 jboss/src/main/org/jboss/jms/jndi/JMSProviderLoader.java
Index: JMSProviderLoader.java
===================================================================
RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/jms/jndi/JMSProviderLoader.java,v
retrieving revision 1.2.6.1
retrieving revision 1.2.6.2
diff -u -r1.2.6.1 -r1.2.6.2
--- JMSProviderLoader.java 2001/07/08 21:19:29 1.2.6.1
+++ JMSProviderLoader.java 2001/12/14 03:22:11 1.2.6.2
@@ -1,235 +1,202 @@
-/*
- * Copyright (c) 2000 Peter Antman Tim <[EMAIL PROTECTED]>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-package org.jboss.jms.jndi;
-
-import javax.management.ObjectName;
-import javax.management.MBeanServer;
-import javax.management.MalformedObjectNameException;
-import javax.naming.Context;
-import javax.naming.Name;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import javax.naming.NameNotFoundException;
-
-import org.apache.log4j.Category;
-
-import org.jboss.configuration.ConfigurationException;
-import org.jboss.util.ServiceMBeanSupport;
-
-/**
- * A JMX service to load a JMSProviderAdapter and register it.
- *
- * <p>Created: Wed Nov 29 14:07:07 2000
- *
- * <p>6/22/01 - hchirino - The queue/topic jndi references are now configed via JMX
- *
- * @author <a href="mailto:[EMAIL PROTECTED]">Hiram Chirino</a>
- * @author <a href="mailto:[EMAIL PROTECTED]">Jason Dillon</a>
- * @version $Revision: 1.2.6.1 $
- */
-public class JMSProviderLoader
- extends ServiceMBeanSupport
- implements JMSProviderLoaderMBean
-{
- /** Instance logger. */
- private final Category log = Category.getInstance(this.getClass());
-
- /** The provider adapter which we are loading. */
- protected JMSProviderAdapter providerAdapter;
-
- /** The provider url. */
- protected String url;
-
- /** The provider name. */
- protected String providerName;
-
- /** The provider adapter classname. */
- protected String providerAdapterClass;
-
- /** The queue factory jndi name. */
- protected String queueFactoryRef;
-
- /** The topic factory jndi name. */
- protected String topicFactoryRef;
-
- public void setProviderName(String name)
- {
- this.providerName = name;
- }
-
- public String getProviderName()
- {
- return providerName;
- }
-
- public void setProviderAdapterClass(String clazz)
- {
- providerAdapterClass = clazz;
- }
-
- public String getProviderAdapterClass()
- {
- return providerAdapterClass;
- }
-
- public void setProviderUrl(final String url)
- {
- this.url = url;
- }
-
- public String getProviderUrl()
- {
- return url;
- }
-
- public ObjectName getObjectName(MBeanServer parm1, ObjectName parm2)
- throws MalformedObjectNameException
- {
- return (parm2 == null) ? new ObjectName(OBJECT_NAME) : parm2;
- }
-
- public String getName()
- {
- return providerName;
- }
-
- public void initService() throws Exception
- {
- // validate the configuration
- if (queueFactoryRef == null)
- throw new ConfigurationException
- ("missing required attribute: QueueFactoryRef");
-
- if (topicFactoryRef == null)
- throw new ConfigurationException
- ("missing required attribute: TopicFactoryRef");
-
- Class cls = Class.forName(providerAdapterClass);
- providerAdapter = (JMSProviderAdapter)cls.newInstance();
- providerAdapter.setName(providerName);
- providerAdapter.setProviderUrl(url);
- providerAdapter.setQueueFactoryRef(queueFactoryRef);
- providerAdapter.setTopicFactoryRef(topicFactoryRef);
- }
-
- public void startService() throws Exception
- {
- InitialContext context = new InitialContext();
- try {
- // Bind in JNDI
- String name = providerAdapter.getName();
- String jndiname = "java:/" + name;
- bind(context, jndiname, providerAdapter);
- log.info("bound adapter " + name + " to " + jndiname);
- }
- finally {
- context.close();
- }
- }
-
- public void stopService()
- {
- InitialContext context = null;
-
- try {
- context = new InitialContext();
-
- // Unbind from JNDI
- String name = providerAdapter.getName();
- String jndiname = "java:/" + name;
- context.unbind(jndiname);
- log.info("unbound adapter " + name + " from " + jndiname);
-
- //source.close();
- //log.log("XA Connection pool "+name+" shut down");
- }
- catch (Exception e) {
- log.warn("failed to unbind; ignoring", e);
- }
- finally {
- if (context != null) {
- try {
- context.close();
- }
- catch (NamingException ignore) {}
- }
- }
- }
-
- // Private -------------------------------------------------------
-
- private void bind(Context ctx, String name, Object val)
- throws NamingException
- {
- log.debug("attempting to bind " + val + " to " + name);
-
- // Bind val to name in ctx, and make sure that all
- // intermediate contexts exist
- Name n = ctx.getNameParser("").parse(name);
- while (n.size() > 1)
- {
- String ctxName = n.get(0);
- try
- {
- ctx = (Context)ctx.lookup(ctxName);
- } catch (NameNotFoundException e)
- {
- ctx = ctx.createSubcontext(ctxName);
- }
- n = n.getSuffix(1);
- }
-
- ctx.bind(n.get(0), val);
- }
-
- /**
- * Insert the method's description here.
- * Creation date: (6/22/2001 12:38:31 AM)
- * @param newQueueFactoryRef String
- */
- public void setQueueFactoryRef(final String newQueueFactoryRef) {
- queueFactoryRef = newQueueFactoryRef;
- }
-
- /**
- * Insert the method's description here.
- * Creation date: (6/22/2001 12:38:31 AM)
- * @param newTopicFactoryRef String
- */
- public void setTopicFactoryRef(final String newTopicFactoryRef) {
- topicFactoryRef = newTopicFactoryRef;
- }
-
- /**
- * Insert the method's description here.
- * Creation date: (6/22/2001 12:38:31 AM)
- * @return String
- */
- public String getQueueFactoryRef() {
- return queueFactoryRef;
- }
-
- /**
- * Insert the method's description here.
- * Creation date: (6/22/2001 12:38:31 AM)
- * @return String
- */
- public String getTopicFactoryRef() {
- return topicFactoryRef;
- }
-}
+/*
+ * Copyright (c) 2000 Peter Antman Tim <[EMAIL PROTECTED]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package org.jboss.jms.jndi;
+
+import javax.management.ObjectName;
+import javax.management.MBeanServer;
+import javax.management.MalformedObjectNameException;
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.naming.NameNotFoundException;
+
+import org.jboss.configuration.ConfigurationException;
+import org.jboss.naming.Util;
+import org.jboss.util.ServiceMBeanSupport;
+
+/**
+ * A JMX service to load a JMSProviderAdapter and register it.
+ *
+ * <p>Created: Wed Nov 29 14:07:07 2000
+ *
+ * <p>6/22/01 - hchirino - The queue/topic jndi references are now configed via JMX
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Hiram Chirino</a>
+ * @author <a href="mailto:[EMAIL PROTECTED]">Jason Dillon</a>
+ * @version $Revision: 1.2.6.2 $
+ */
+public class JMSProviderLoader
+ extends ServiceMBeanSupport
+ implements JMSProviderLoaderMBean
+{
+ /** The provider adapter which we are loading. */
+ protected JMSProviderAdapter providerAdapter;
+
+ /** The provider url. */
+ protected String url;
+
+ /** The provider name. */
+ protected String providerName;
+
+ /** The provider adapter classname. */
+ protected String providerAdapterClass;
+
+ /** The queue factory jndi name. */
+ protected String queueFactoryRef;
+
+ /** The topic factory jndi name. */
+ protected String topicFactoryRef;
+
+ public void setProviderName(String name)
+ {
+ this.providerName = name;
+ }
+
+ public String getProviderName()
+ {
+ return providerName;
+ }
+
+ public void setProviderAdapterClass(String clazz)
+ {
+ providerAdapterClass = clazz;
+ }
+
+ public String getProviderAdapterClass()
+ {
+ return providerAdapterClass;
+ }
+
+ public void setProviderUrl(final String url)
+ {
+ this.url = url;
+ }
+
+ public String getProviderUrl()
+ {
+ return url;
+ }
+
+ public ObjectName getObjectName(MBeanServer parm1, ObjectName parm2)
+ throws MalformedObjectNameException
+ {
+ return (parm2 == null) ? new ObjectName(OBJECT_NAME) : parm2;
+ }
+
+ public String getName()
+ {
+ return providerName;
+ }
+
+ public void initService() throws Exception
+ {
+ // validate the configuration
+ if (queueFactoryRef == null)
+ throw new ConfigurationException
+ ("missing required attribute: QueueFactoryRef");
+
+ if (topicFactoryRef == null)
+ throw new ConfigurationException
+ ("missing required attribute: TopicFactoryRef");
+
+ Class cls = Class.forName(providerAdapterClass);
+ providerAdapter = (JMSProviderAdapter)cls.newInstance();
+ providerAdapter.setName(providerName);
+ providerAdapter.setProviderUrl(url);
+ providerAdapter.setQueueFactoryRef(queueFactoryRef);
+ providerAdapter.setTopicFactoryRef(topicFactoryRef);
+ }
+
+ public void startService() throws Exception
+ {
+ InitialContext context = new InitialContext();
+ try {
+ // Bind in JNDI
+ String name = providerAdapter.getName();
+ String jndiname = "java:/" + name;
+ Util.bind(context, jndiname, providerAdapter);
+ log.info("bound adapter " + name + " to " + jndiname);
+ }
+ finally {
+ context.close();
+ }
+ }
+
+ public void stopService()
+ {
+ InitialContext context = null;
+
+ try {
+ context = new InitialContext();
+
+ // Unbind from JNDI
+ String name = providerAdapter.getName();
+ String jndiname = "java:/" + name;
+ context.unbind(jndiname);
+ log.info("unbound adapter " + name + " from " + jndiname);
+ }
+ catch (Exception e) {
+ log.warn("failed to unbind; ignoring", e);
+ }
+ finally {
+ if (context != null) {
+ try {
+ context.close();
+ }
+ catch (NamingException ignore) {}
+ }
+ }
+ }
+
+ /**
+ * Insert the method's description here.
+ * Creation date: (6/22/2001 12:38:31 AM)
+ * @param newQueueFactoryRef String
+ */
+ public void setQueueFactoryRef(final String newQueueFactoryRef) {
+ queueFactoryRef = newQueueFactoryRef;
+ }
+
+ /**
+ * Insert the method's description here.
+ * Creation date: (6/22/2001 12:38:31 AM)
+ * @param newTopicFactoryRef String
+ */
+ public void setTopicFactoryRef(final String newTopicFactoryRef) {
+ topicFactoryRef = newTopicFactoryRef;
+ }
+
+ /**
+ * Insert the method's description here.
+ * Creation date: (6/22/2001 12:38:31 AM)
+ * @return String
+ */
+ public String getQueueFactoryRef() {
+ return queueFactoryRef;
+ }
+
+ /**
+ * Insert the method's description here.
+ * Creation date: (6/22/2001 12:38:31 AM)
+ * @return String
+ */
+ public String getTopicFactoryRef() {
+ return topicFactoryRef;
+ }
+}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development