[jboss-cvs] JBoss Messaging SVN: r3328 - in branches/Branch_MC_Integration_New: src/etc/server/standalone/config/local and 3 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Nov 14 09:29:03 EST 2007
Author: ataylor
Date: 2007-11-14 09:29:03 -0500 (Wed, 14 Nov 2007)
New Revision: 3328
Added:
branches/Branch_MC_Integration_New/src/main/org/jboss/jms/server/jndi/
branches/Branch_MC_Integration_New/src/main/org/jboss/jms/server/jndi/InVMContext.java
branches/Branch_MC_Integration_New/src/main/org/jboss/jms/server/jndi/InVMInitialContextFactory.java
branches/Branch_MC_Integration_New/src/main/org/jboss/jms/server/jndi/InVMNameParser.java
Modified:
branches/Branch_MC_Integration_New/build-messaging.xml
branches/Branch_MC_Integration_New/src/etc/server/standalone/config/local/jndi.properties
branches/Branch_MC_Integration_New/src/etc/server/standalone/config/local/local.xml
branches/Branch_MC_Integration_New/src/main/org/jboss/jms/server/microcontainer/JndiBinder.java
Log:
initial microcontainer integration, changes to use JBM invmcontext
Modified: branches/Branch_MC_Integration_New/build-messaging.xml
===================================================================
--- branches/Branch_MC_Integration_New/build-messaging.xml 2007-11-14 10:20:05 UTC (rev 3327)
+++ branches/Branch_MC_Integration_New/build-messaging.xml 2007-11-14 14:29:03 UTC (rev 3328)
@@ -412,10 +412,6 @@
<fileset dir="${oswego.concurrent.lib}">
<include name="concurrent.jar"/>
</fileset>
- <fileset dir="${project.thirdparty}/naming/">
- <include name="jnp-client.jar"/>
- <include name="jnpserver.jar"/>
- </fileset>
<fileset dir="${apache.xerces.lib}">
<include name="xercesImpl.jar"/>
</fileset>
Modified: branches/Branch_MC_Integration_New/src/etc/server/standalone/config/local/jndi.properties
===================================================================
--- branches/Branch_MC_Integration_New/src/etc/server/standalone/config/local/jndi.properties 2007-11-14 10:20:05 UTC (rev 3327)
+++ branches/Branch_MC_Integration_New/src/etc/server/standalone/config/local/jndi.properties 2007-11-14 14:29:03 UTC (rev 3328)
@@ -1,3 +1,3 @@
-java.naming.factory.initial=org.jnp.interfaces.LocalOnlyContextFactory
+java.naming.factory.initial=org.jboss.jms.server.jndi.InVMInitialContextFactory
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
Modified: branches/Branch_MC_Integration_New/src/etc/server/standalone/config/local/local.xml
===================================================================
--- branches/Branch_MC_Integration_New/src/etc/server/standalone/config/local/local.xml 2007-11-14 10:20:05 UTC (rev 3327)
+++ branches/Branch_MC_Integration_New/src/etc/server/standalone/config/local/local.xml 2007-11-14 14:29:03 UTC (rev 3328)
@@ -2,7 +2,7 @@
<deployment xmlns="urn:jboss:bean-deployer:2.0">
- <bean name="Naming" class="org.jnp.server.SingletonNamingServer"/>
+ <!--<bean name="Naming" class="org.jnp.server.SingletonNamingServer"/>-->
<bean name="InitialContextProperties" class="java.util.Hashtable">
<constructor>
@@ -10,12 +10,8 @@
<map keyClass="java.lang.String" valueClass="java.lang.String">
<entry>
<key>java.naming.factory.initial</key>
- <value>org.jnp.interfaces.LocalOnlyContextFactory</value>
+ <value>org.jboss.jms.server.jndi.InVMInitialContextFactory</value>
</entry>
- <entry>
- <key>java.naming.factory.url.pkgs</key>
- <value>org.jboss.naming:org.jnp.interfaces</value>
- </entry>
</map>
</parameter>
</constructor>
@@ -29,7 +25,6 @@
<inject bean="Jaas"/>
</property>
<property name="bindTo">java:/jaas/messaging</property>
- <property name="serializable">false</property>
</bean>
<bean name="Jaas" class="org.jboss.jms.server.microcontainer.AuthenticationManager"/>
@@ -47,7 +42,6 @@
<inject bean="jboss.jca:name=DefaultDS,service=DataSourceBinding"/>
</property>
<property name="bindTo">java:/DefaultDS</property>
- <property name="serializable">false</property>
</bean>
<bean name="TMBinding" class="org.jboss.jms.server.microcontainer.JndiBinder">
@@ -58,7 +52,6 @@
<inject bean="jboss:service=TransactionManager"/>
</property>
<property name="bindTo">java:/TransactionManager</property>
- <property name="serializable">false</property>
</bean>
<bean name="jboss:service=TransactionManager"
Added: branches/Branch_MC_Integration_New/src/main/org/jboss/jms/server/jndi/InVMContext.java
===================================================================
--- branches/Branch_MC_Integration_New/src/main/org/jboss/jms/server/jndi/InVMContext.java (rev 0)
+++ branches/Branch_MC_Integration_New/src/main/org/jboss/jms/server/jndi/InVMContext.java 2007-11-14 14:29:03 UTC (rev 3328)
@@ -0,0 +1,360 @@
+/*
+ * 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.jms.server.jndi;
+
+import org.jboss.logging.Logger;
+import org.jboss.messaging.util.NotYetImplementedException;
+import org.jboss.util.naming.NonSerializableFactory;
+
+import javax.naming.*;
+import java.io.Serializable;
+import java.util.*;
+
+/**
+ * @author <a href="ataylor at redhat.com">Andy Taylor</a>
+ */
+public class InVMContext implements Context, Serializable
+{
+ // Constants -----------------------------------------------------
+
+ private static final long serialVersionUID = 385743957345L;
+
+ private static final Logger log = Logger.getLogger(InVMContext.class);
+
+
+ // Static --------------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ protected Map map;
+ protected NameParser parser = new InVMNameParser();
+
+ // Constructors --------------------------------------------------
+
+ public InVMContext()
+ {
+ map = Collections.synchronizedMap(new HashMap());
+ }
+
+ // Context implementation ----------------------------------------
+
+ public Object lookup(Name name) throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public Object lookup(String name) throws NamingException
+ {
+ name = trimSlashes(name);
+ int i = name.indexOf("/");
+ String tok = i == -1 ? name : name.substring(0, i);
+ Object value = map.get(tok);
+ if (value == null)
+ {
+ throw new NameNotFoundException("Name not found: " + tok);
+ }
+ if (value instanceof InVMContext && i != -1)
+ {
+ return ((InVMContext)value).lookup(name.substring(i));
+ }
+ if (value instanceof Reference)
+ {
+ Reference ref = (Reference)value;
+ RefAddr refAddr = ref.get("nns");
+
+ // we only deal with references create by NonSerializableFactory
+ String key = (String)refAddr.getContent();
+ return NonSerializableFactory.lookup(key);
+ }
+ else
+ {
+ return value;
+ }
+ }
+
+ public void bind(Name name, Object obj) throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void bind(String name, Object obj) throws NamingException
+ {
+ internalBind(name, obj, false);
+ }
+
+ public void rebind(Name name, Object obj) throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void rebind(String name, Object obj) throws NamingException
+ {
+ internalBind(name, obj, true);
+ }
+
+ public void unbind(Name name) throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void unbind(String name) throws NamingException
+ {
+ name = trimSlashes(name);
+ int i = name.indexOf("/");
+ boolean terminal = i == -1;
+ if (terminal)
+ {
+ map.remove(name);
+ }
+ else
+ {
+ String tok = name.substring(0, i);
+ InVMContext c = (InVMContext)map.get(tok);
+ if (c == null)
+ {
+ throw new NameNotFoundException("Context not found: " + tok);
+ }
+ c.unbind(name.substring(i));
+ }
+ }
+
+ public void rename(Name oldName, Name newName) throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void rename(String oldName, String newName) throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public NamingEnumeration list(Name name) throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public NamingEnumeration list(String name) throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public NamingEnumeration listBindings(Name name) throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public NamingEnumeration listBindings(String contextName) throws NamingException
+ {
+ contextName = trimSlashes(contextName);
+ if (!"".equals(contextName) && !".".equals(contextName))
+ {
+ try
+ {
+ return ((InVMContext)lookup(contextName)).listBindings("");
+ }
+ catch(Throwable t)
+ {
+ throw new NamingException(t.getMessage());
+ }
+ }
+
+ List l = new ArrayList();
+ for(Iterator i = map.keySet().iterator(); i.hasNext(); )
+ {
+ String name = (String)i.next();
+ Object object = map.get(name);
+ l.add(new Binding(name, object));
+ }
+ return new NamingEnumerationImpl(l.iterator());
+ }
+
+ public void destroySubcontext(Name name) throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void destroySubcontext(String name) throws NamingException
+ {
+ map.remove(trimSlashes(name));
+ }
+
+ public Context createSubcontext(Name name) throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public Context createSubcontext(String name) throws NamingException
+ {
+ name = trimSlashes(name);
+ if (map.get(name) != null)
+ {
+ throw new NameAlreadyBoundException(name);
+ }
+ InVMContext c = new InVMContext();
+ map.put(name, c);
+ return c;
+ }
+
+ public Object lookupLink(Name name) throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public Object lookupLink(String name) throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public NameParser getNameParser(Name name) throws NamingException
+ {
+ return getNameParser(name.toString());
+ }
+
+ public NameParser getNameParser(String name) throws NamingException
+ {
+ return parser;
+ }
+
+ public Name composeName(Name name, Name prefix) throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public String composeName(String name, String prefix) throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public Object addToEnvironment(String propName, Object propVal) throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public Object removeFromEnvironment(String propName) throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public Hashtable getEnvironment() throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public void close() throws NamingException
+ {
+ }
+
+ public String getNameInNamespace() throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ // Public --------------------------------------------------------
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ private String trimSlashes(String s)
+ {
+ int i = 0;
+ while(true)
+ {
+ if (i == s.length() || s.charAt(i) != '/')
+ {
+ break;
+ }
+ i++;
+ }
+ s = s.substring(i);
+ i = s.length() - 1;
+ while(true)
+ {
+ if (i == -1 || s.charAt(i) != '/')
+ {
+ break;
+ }
+ i--;
+ }
+ return s.substring(0, i + 1);
+ }
+
+ private void internalBind(String name, Object obj, boolean rebind) throws NamingException
+ {
+ log.info("Binding " + name + " obj " + obj + " rebind " + rebind);
+ name = trimSlashes(name);
+ int i = name.lastIndexOf("/");
+ InVMContext c = this;
+ if (i != -1)
+ {
+ String path = name.substring(0, i);
+ c = (InVMContext)lookup(path);
+ }
+ name = name.substring(i + 1);
+ if (!rebind && c.map.get(name) != null)
+ {
+ throw new NameAlreadyBoundException(name);
+ }
+ c.map.put(name, obj);
+ }
+
+ // Inner classes -------------------------------------------------
+
+ private class NamingEnumerationImpl implements NamingEnumeration
+ {
+ private Iterator iterator;
+
+ NamingEnumerationImpl(Iterator bindingIterator)
+ {
+ this.iterator = bindingIterator;
+ }
+
+ public void close() throws NamingException
+ {
+ throw new NotYetImplementedException();
+ }
+
+ public boolean hasMore() throws NamingException
+ {
+ return iterator.hasNext();
+ }
+
+ public Object next() throws NamingException
+ {
+ return iterator.next();
+ }
+
+ public boolean hasMoreElements()
+ {
+ return iterator.hasNext();
+ }
+
+ public Object nextElement()
+ {
+ return iterator.next();
+ }
+ }
+}
+
+
Added: branches/Branch_MC_Integration_New/src/main/org/jboss/jms/server/jndi/InVMInitialContextFactory.java
===================================================================
--- branches/Branch_MC_Integration_New/src/main/org/jboss/jms/server/jndi/InVMInitialContextFactory.java (rev 0)
+++ branches/Branch_MC_Integration_New/src/main/org/jboss/jms/server/jndi/InVMInitialContextFactory.java 2007-11-14 14:29:03 UTC (rev 3328)
@@ -0,0 +1,40 @@
+/*
+ * 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.jms.server.jndi;
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.naming.spi.InitialContextFactory;
+import java.util.Hashtable;
+
+/**
+ * @author <a href="ataylor at redhat.com">Andy Taylor</a>
+ */
+public class InVMInitialContextFactory implements InitialContextFactory
+{
+ private static InVMContext context = new InVMContext();
+
+ public Context getInitialContext(Hashtable<?, ?> environment) throws NamingException
+ {
+ return context;
+ }
+}
Added: branches/Branch_MC_Integration_New/src/main/org/jboss/jms/server/jndi/InVMNameParser.java
===================================================================
--- branches/Branch_MC_Integration_New/src/main/org/jboss/jms/server/jndi/InVMNameParser.java (rev 0)
+++ branches/Branch_MC_Integration_New/src/main/org/jboss/jms/server/jndi/InVMNameParser.java 2007-11-14 14:29:03 UTC (rev 3328)
@@ -0,0 +1,77 @@
+/*
+ * 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.jms.server.jndi;
+
+import javax.naming.CompoundName;
+import javax.naming.Name;
+import javax.naming.NameParser;
+import javax.naming.NamingException;
+import java.io.Serializable;
+import java.util.Properties;
+
+/**
+ * @author <a href="ataylor at redhat.com">Andy Taylor</a>
+ */
+public class InVMNameParser implements NameParser, Serializable
+{
+ // Constants -----------------------------------------------------
+
+ private static final long serialVersionUID = 2925203703371001031L;
+
+ // Static --------------------------------------------------------
+
+ static Properties syntax;
+
+ static
+ {
+ syntax = new Properties();
+ syntax.put("jndi.syntax.direction", "left_to_right");
+ syntax.put("jndi.syntax.ignorecase", "false");
+ syntax.put("jndi.syntax.separator", "/");
+ }
+
+ // Attributes ----------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ public static Properties getSyntax()
+ {
+ return syntax;
+ }
+
+ public Name parse(String name) throws NamingException
+ {
+ return new CompoundName(name, syntax);
+ }
+
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
Modified: branches/Branch_MC_Integration_New/src/main/org/jboss/jms/server/microcontainer/JndiBinder.java
===================================================================
--- branches/Branch_MC_Integration_New/src/main/org/jboss/jms/server/microcontainer/JndiBinder.java 2007-11-14 10:20:05 UTC (rev 3327)
+++ branches/Branch_MC_Integration_New/src/main/org/jboss/jms/server/microcontainer/JndiBinder.java 2007-11-14 14:29:03 UTC (rev 3328)
@@ -33,83 +33,69 @@
public class JndiBinder
{
- public JndiBinder()
- {
- }
+ public JndiBinder()
+ {
+ }
- public void setBindTo(String bindTo)
- {
- this.bindTo = bindTo;
- }
+ public void setBindTo(String bindTo)
+ {
+ this.bindTo = bindTo;
+ }
- public void setTarget(Object target)
- {
- this.target = target;
- }
+ public void setTarget(Object target)
+ {
+ this.target = target;
+ }
- public void setSerializable(boolean serializable)
- {
- this.serializable = serializable;
- }
+ public void setJndiProperties(Hashtable properties)
+ {
+ this.properties = properties;
+ }
+ public void start()
+ throws Exception
+ {
+ InitialContext ctx = getInitialContext(properties);
- public void setJndiProperties(Hashtable properties)
- {
- this.properties = properties;
- }
- public void start()
- throws Exception
- {
- InitialContext ctx = getInitialContext(properties);
+ try
+ {
+ Util.rebind(ctx, bindTo, target);
+ }
+ catch (NamingException e)
+ {
- try
- {
- if (serializable)
+ 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;
+ }
+ }
- Util.rebind(ctx, bindTo, target);
+ public void stop()
+ throws Exception
+ {
+ InitialContext ctx = getInitialContext(properties);
+ Util.unbind(ctx, bindTo);
- else NonSerializableFactory.rebind(ctx, bindTo, target);
- }
- catch (NamingException e)
- {
+ }
- 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;
- }
- }
+ private String bindTo;
+ private Object target;
+ private Hashtable properties;
- public void stop()
- throws Exception
- {
- InitialContext ctx = getInitialContext(properties);
- if (serializable)
+ private static InitialContext getInitialContext(Hashtable props)
+ throws NamingException
+ {
+ InitialContext ctx = null;
+ if (props != null)
- Util.unbind(ctx, bindTo);
+ ctx = new InitialContext(props);
-
- else NonSerializableFactory.unbind(ctx, bindTo);
- }
-
- private String bindTo;
- private Object target;
- private boolean serializable;
- private Hashtable properties;
-
- private static InitialContext getInitialContext(Hashtable props)
- throws NamingException
- {
- InitialContext ctx = null;
- if (props != null)
-
- ctx = new InitialContext(props);
-
- else ctx = new InitialContext();
- return ctx;
- }
+ else ctx = new InitialContext();
+ return ctx;
+ }
}
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list