[jboss-cvs] JBoss Messaging SVN: r3810 - in trunk: src/main/org/jboss/messaging/microcontainer and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Feb 27 06:58:52 EST 2008


Author: ataylor
Date: 2008-02-27 06:58:51 -0500 (Wed, 27 Feb 2008)
New Revision: 3810

Added:
   trunk/tests/src/org/jboss/test/messaging/tools/container/NonSerializableFactory.java
Removed:
   trunk/src/main/org/jboss/messaging/microcontainer/JndiBinder.java
   trunk/src/main/org/jboss/messaging/microcontainer/factory/
Modified:
   trunk/src/etc/server/default/deploy/jbm-beans.xml
   trunk/src/main/org/jboss/messaging/microcontainer/ServiceLocator.java
Log:
removed MC classes no longer needed

Modified: trunk/src/etc/server/default/deploy/jbm-beans.xml
===================================================================
--- trunk/src/etc/server/default/deploy/jbm-beans.xml	2008-02-27 11:58:29 UTC (rev 3809)
+++ trunk/src/etc/server/default/deploy/jbm-beans.xml	2008-02-27 11:58:51 UTC (rev 3810)
@@ -5,9 +5,6 @@
    <bean name="Configuration" class="org.jboss.messaging.core.config.impl.FileConfiguration"/>
 
    <bean name="ServiceLocator" class="org.jboss.messaging.microcontainer.ServiceLocator">
-      <demand>jboss.jca:name=DefaultDS,service=DataSourceBinding</demand>
-      <!--<depends>jboss:service=TransactionManager</depends>-->
-      <!-- <depends>jboss.jca:service=DataSourceBinding,name=DefaultDS</depends>-->
    </bean>
 
    <bean name="MessagingServerManagement" class="org.jboss.messaging.core.management.impl.MessagingServerManagementImpl">

Deleted: trunk/src/main/org/jboss/messaging/microcontainer/JndiBinder.java
===================================================================
--- trunk/src/main/org/jboss/messaging/microcontainer/JndiBinder.java	2008-02-27 11:58:29 UTC (rev 3809)
+++ trunk/src/main/org/jboss/messaging/microcontainer/JndiBinder.java	2008-02-27 11:58:51 UTC (rev 3810)
@@ -1,132 +0,0 @@
-/*
-   * JBoss, Home of Professional Open Source
-   * Copyright 2005, JBoss Inc., and individual contributors as indicated
-   * by the @authors tag. See the copyright.txt in the distribution for a
-   * full listing of individual contributors.
-   *
-   * This 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.1 of
-   * the License, or (at your option) any later version.
-   *
-   * This software 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 software; if not, write to the Free
-   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-   */
-package org.jboss.messaging.microcontainer;
-
-import java.io.Serializable;
-import java.util.Hashtable;
-
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
-import org.jboss.util.naming.Util;
-
-/**
- * @author <a href="ataylor at redhat.com">Andy Taylor</a>
- */
-public class JndiBinder
-{
-
-   private String bindTo;
-   private Object target;
-   private Hashtable properties;
-
-   public JndiBinder()
-   {
-   }
-
-
-   public void setBindTo(String bindTo)
-   {
-      this.bindTo = bindTo;
-   }
-
-
-   public void setTarget(Object target)
-   {
-      this.target = target;
-   }
-
-
-   public void setJndiProperties(Hashtable properties)
-   {
-      this.properties = properties;
-   }
-
-   public void start()
-           throws Exception
-   {
-      InitialContext ctx = getInitialContext(properties);
-
-      try
-      {
-         if (target.getClass().isAssignableFrom(Serializable.class))
-         {
-            Util.rebind(ctx, bindTo, target);
-         }
-         else
-         {
-            bindToNonSerializableFactory(ctx);
-         }
-
-      }
-      catch (NamingException e)
-      {
-
-         e.printStackTrace();
-         NamingException namingException = new NamingException((new StringBuilder()).append("Could not bind JndiBinder service into JNDI under jndiName:").append(ctx.getNameInNamespace()).append("/").append(bindTo).toString());
-         namingException.setRootCause(e);
-         throw namingException;
-      }
-   }
-
-
-
-   public void stop()
-           throws Exception
-   {
-      InitialContext ctx = getInitialContext(properties);
-
-      if (target.getClass().isAssignableFrom(Serializable.class))
-      {
-         Util.unbind(ctx, bindTo);
-      }
-      else
-      {
-         unbindFromSerializableFactory(ctx);
-      }
-
-   }
-
-   private void unbindFromSerializableFactory(InitialContext ctx)
-           throws NamingException
-   {
-      NonSerializableFactory.unbind(ctx, bindTo);
-   }
-
-   protected void bindToNonSerializableFactory(InitialContext ctx)
-           throws NamingException
-   {
-      NonSerializableFactory.bind(ctx, bindTo, target);
-   }
-
-   private static InitialContext getInitialContext(Hashtable props)
-           throws NamingException
-   {
-      InitialContext ctx = null;
-      if (props != null)
-
-         ctx = new InitialContext(props);
-
-      else ctx = new InitialContext();
-      return ctx;
-   }
-}
\ No newline at end of file

Modified: trunk/src/main/org/jboss/messaging/microcontainer/ServiceLocator.java
===================================================================
--- trunk/src/main/org/jboss/messaging/microcontainer/ServiceLocator.java	2008-02-27 11:58:29 UTC (rev 3809)
+++ trunk/src/main/org/jboss/messaging/microcontainer/ServiceLocator.java	2008-02-27 11:58:51 UTC (rev 3810)
@@ -41,10 +41,7 @@
  */
 public class ServiceLocator implements KernelControllerContextAware
 {
-    private ObjectName multiplexer;
-    private TransactionManager tm;
     private org.jboss.security.AuthenticationManager authenticationManager;
-    private DataSource dataSource;
     private KernelControllerContext kernelControllerContext;
 
     public void setKernelControllerContext(KernelControllerContext kernelControllerContext) throws Exception
@@ -57,78 +54,6 @@
         kernelControllerContext = null;
     }
 
-    public TransactionManager getTransactionManager() throws Exception
-    {
-        if(tm == null)
-        {
-            ControllerContext controllerContext = kernelControllerContext.getController().getInstalledContext("jbm:TransactionManager");
-           if(controllerContext != null)
-           {
-              tm = (TransactionManager) controllerContext.getTarget();
-           }
-           else
-           {
-              try
-              {
-                 tm = TransactionManagerLocator.locateTransactionManager();
-              }
-              catch (Exception e)
-              {
-                 throw new Exception("TransactionManager unavailable", e);
-              }
-           }
-        }
-        return tm;
-    }
-
-    public void setTransactionManager(TransactionManager transactionManager)
-    {
-        this.tm = transactionManager;
-    }
-
-    public DataSource getDataSource() throws Exception
-    {
-        if(dataSource == null)
-        {
-           ControllerContext controllerContext = kernelControllerContext.getController().getInstalledContext("jbm:DataSource");
-           if(controllerContext != null)
-           {
-              dataSource =  (DataSource) controllerContext.getTarget();
-           }
-           else
-           {
-              InitialContext ic = new InitialContext();
-              //try in the initial context, if its not there use the one that has been injected
-              try
-              {
-                 dataSource = (DataSource) ic.lookup("java:/DefaultDS");
-              }
-              catch (Exception e)
-              {
-                 throw new Exception("DataSource unavailable", e);
-              }
-           }
-
-        }
-        return dataSource;
-    }
-
-    public void setDataSource(DataSource datasource)
-    {
-        this.dataSource = datasource;
-    }
-
-
-   public TransactionManager getTm()
-   {
-      return tm;
-   }
-
-   public void setTm(TransactionManager tm)
-   {
-      this.tm = tm;
-   }
-
    public AuthenticationManager getAuthenticationManager() throws Exception
    {
       if(authenticationManager == null)
@@ -158,14 +83,4 @@
    {
       this.authenticationManager = authenticationManager;
    }
-
-   public ObjectName getMultiplexer()
-    {
-        return multiplexer;
-    }
-
-    public void setMultiplexer(ObjectName multiplexer)
-    {
-        this.multiplexer = multiplexer;
-    }
 }

Copied: trunk/tests/src/org/jboss/test/messaging/tools/container/NonSerializableFactory.java (from rev 3806, trunk/src/main/org/jboss/messaging/microcontainer/NonSerializableFactory.java)
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/tools/container/NonSerializableFactory.java	                        (rev 0)
+++ trunk/tests/src/org/jboss/test/messaging/tools/container/NonSerializableFactory.java	2008-02-27 11:58:51 UTC (rev 3810)
@@ -0,0 +1,120 @@
+/*
+   * JBoss, Home of Professional Open Source
+   * Copyright 2005, JBoss Inc., and individual contributors as indicated
+   * by the @authors tag. See the copyright.txt in the distribution for a
+   * full listing of individual contributors.
+   *
+   * This 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.1 of
+   * the License, or (at your option) any later version.
+   *
+   * This software 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 software; if not, write to the Free
+   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+   */
+package org.jboss.test.messaging.tools.container;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Map;
+
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.NamingException;
+import javax.naming.RefAddr;
+import javax.naming.Reference;
+import javax.naming.StringRefAddr;
+import javax.naming.spi.ObjectFactory;
+
+import org.jboss.util.naming.Util;
+
+/**
+ * used by the default context when running in embedded local configuration
+ * @author <a href="ataylor at redhat.com">Andy Taylor</a>
+ */
+public class NonSerializableFactory implements ObjectFactory
+{
+
+    public NonSerializableFactory()
+    {
+    }
+
+    public static void unbind(Context ctx, String strName)
+            throws NamingException
+    {
+        Name name = ctx.getNameParser("").parse(strName);
+        int size = name.size();
+        String atom = name.get(size - 1);
+        Context parentCtx = Util.createSubcontext(ctx, name.getPrefix(size - 1));
+        String key = (new StringBuilder()).append(parentCtx.getNameInNamespace()).append("/").append(atom).toString();
+        getWrapperMap().remove(key);
+        Util.unbind(ctx, strName);
+    }
+
+
+    public static void rebind(Context ctx, String strName, Object value)
+            throws NamingException
+    {
+        Name name = ctx.getNameParser("").parse(strName);
+        int size = name.size();
+        String atom = name.get(size - 1);
+        Context parentCtx = Util.createSubcontext(ctx, name.getPrefix(size - 1));
+        String key = (new StringBuilder()).append(parentCtx.getNameInNamespace()).append("/").append(atom).toString();
+        getWrapperMap().put(key, value);
+        String className = value.getClass().getName();
+        String factory = NonSerializableFactory.class.getName();
+        StringRefAddr addr = new StringRefAddr("nns", key);
+        Reference memoryRef = new Reference(className, addr, factory, null);
+        parentCtx.rebind(atom, memoryRef);
+    }
+
+    public static void bind(Context ctx, String strName, Object value)
+            throws NamingException
+    {
+        Name name = ctx.getNameParser("").parse(strName);
+        int size = name.size();
+        String atom = name.get(size - 1);
+        Context parentCtx = Util.createSubcontext(ctx, name.getPrefix(size - 1));
+        String key = (new StringBuilder()).append(parentCtx.getNameInNamespace()).append("/").append(atom).toString();
+        getWrapperMap().put(key, value);
+        String className = value.getClass().getName();
+        String factory = NonSerializableFactory.class.getName();
+        StringRefAddr addr = new StringRefAddr("nns", key);
+        Reference memoryRef = new Reference(className, addr, factory, null);
+
+        parentCtx.bind(atom, memoryRef);
+    }
+
+   public static Object lookup(String name)  throws NamingException
+    {
+        if(getWrapperMap().get(name) == null)
+        {
+           throw new NamingException(name + " not found");
+        }
+        return getWrapperMap().get(name);
+    }
+
+    public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable env)
+            throws Exception
+    {
+        Reference ref = (Reference) obj;
+        RefAddr addr = ref.get("nns");
+        String key = (String) addr.getContent();
+        return getWrapperMap().get(key);
+    }
+
+   public static Map getWrapperMap()
+   {
+      return wrapperMap;
+   }
+
+    private static Map wrapperMap = Collections.synchronizedMap(new HashMap());
+}
\ No newline at end of file




More information about the jboss-cvs-commits mailing list