[jboss-osgi-commits] JBoss-OSGI SVN: r88144 - in projects/jboss-osgi/trunk: bundle and 12 other directories.

jboss-osgi-commits at lists.jboss.org jboss-osgi-commits at lists.jboss.org
Mon May 4 06:46:42 EDT 2009


Author: thomas.diesler at jboss.com
Date: 2009-05-04 06:46:41 -0400 (Mon, 04 May 2009)
New Revision: 88144

Added:
   projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jndi/
   projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jndi/JNDITestCase.java
   projects/jboss-osgi/trunk/bundle/blueprint/src/test/resources/jndi.properties
   projects/jboss-osgi/trunk/bundle/jndi/
   projects/jboss-osgi/trunk/bundle/jndi/src/main/java/org/jboss/osgi/jndi/
   projects/jboss-osgi/trunk/bundle/jndi/src/main/java/org/jboss/osgi/jndi/ServiceActivator.java
   projects/jboss-osgi/trunk/bundle/jndi/src/main/java/org/jboss/osgi/jndi/internal/
   projects/jboss-osgi/trunk/bundle/jndi/src/main/java/org/jboss/osgi/jndi/internal/JNPServer.java
Removed:
   projects/jboss-osgi/trunk/bundle/jndi/src/main/java/org/jboss/osgi/jmx/ObjectNameFactory.java
   projects/jboss-osgi/trunk/bundle/jndi/src/main/java/org/jboss/osgi/jmx/ServiceActivator.java
   projects/jboss-osgi/trunk/bundle/jndi/src/main/java/org/jboss/osgi/jmx/internal/
   projects/jboss-osgi/trunk/bundle/jndi/src/main/java/org/jboss/osgi/jndi/internal/JMXConnectorService.java
   projects/jboss-osgi/trunk/bundle/jndi/src/main/java/org/jboss/osgi/jndi/internal/MBeanServerService.java
Modified:
   projects/jboss-osgi/trunk/bundle/blueprint/pom.xml
   projects/jboss-osgi/trunk/bundle/blueprint/scripts/assembly-bundles.xml
   projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/bootstrap/BundleTestCase.java
   projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jmx/JMXTestCase.java
   projects/jboss-osgi/trunk/bundle/blueprint/src/test/resources/jboss-osgi-framework.properties
   projects/jboss-osgi/trunk/bundle/jndi/pom.xml
   projects/jboss-osgi/trunk/bundle/pom.xml
   projects/jboss-osgi/trunk/pom.xml
Log:
Add jndi bundle

Modified: projects/jboss-osgi/trunk/bundle/blueprint/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/pom.xml	2009-05-04 09:52:32 UTC (rev 88143)
+++ projects/jboss-osgi/trunk/bundle/blueprint/pom.xml	2009-05-04 10:46:41 UTC (rev 88144)
@@ -35,6 +35,16 @@
       <artifactId>org.apache.felix.log</artifactId>
       <scope>provided</scope>
     </dependency>
+    <dependency>
+      <groupId>org.jboss.naming</groupId>
+      <artifactId>jnpserver</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi.core</artifactId>
+      <scope>provided</scope>
+    </dependency>
 
     <!-- Bundle Dependencies -->
     <dependency>
@@ -66,6 +76,12 @@
     </dependency>
     <dependency>
       <groupId>org.jboss.osgi.bundles</groupId>
+      <artifactId>jboss-osgi-jndi</artifactId>
+      <version>${version}</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.osgi.bundles</groupId>
       <artifactId>jboss-osgi-logging</artifactId>
       <version>${version}</version>
       <scope>provided</scope>
@@ -81,14 +97,8 @@
       <artifactId>jbossxb-bundle</artifactId>
       <scope>provided</scope>
     </dependency>
-
     <dependency>
       <groupId>org.osgi</groupId>
-      <artifactId>org.osgi.core</artifactId>
-      <scope>provided</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.osgi</groupId>
       <artifactId>org.osgi.compendium</artifactId>
       <scope>provided</scope>
     </dependency>

Modified: projects/jboss-osgi/trunk/bundle/blueprint/scripts/assembly-bundles.xml
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/scripts/assembly-bundles.xml	2009-05-04 09:52:32 UTC (rev 88143)
+++ projects/jboss-osgi/trunk/bundle/blueprint/scripts/assembly-bundles.xml	2009-05-04 10:46:41 UTC (rev 88144)
@@ -23,6 +23,7 @@
         <include>*:jboss-osgi-logging:jar</include>
         <include>*:jboss-osgi-microcontainer:jar</include>
         <include>*:jboss-osgi-jmx:jar</include>
+        <include>*:jboss-osgi-jndi:jar</include>
         <include>*:jboss-common-core-bundle:jar</include>
         <include>*:jbossxb-bundle:jar</include>
       </includes>

Modified: projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/bootstrap/BundleTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/bootstrap/BundleTestCase.java	2009-05-04 09:52:32 UTC (rev 88143)
+++ projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/bootstrap/BundleTestCase.java	2009-05-04 10:46:41 UTC (rev 88144)
@@ -123,4 +123,25 @@
          framework.stop();
       }
    }
+   
+   public void testJNDIBundle() throws BundleException
+   {
+      OSGiBootstrapProvider configProvider = OSGiBootstrap.getBootstrapProvider();
+      configProvider.configure("basic-felix-framework.properties");
+      
+      OSGiFramework framework = configProvider.getFramework();
+      try
+      {
+         BundleContext context = framework.getSystemBundleContext();
+         
+         Bundle bundle = installBundle(context, "bundles/jboss-common-core-bundle.jar", true);
+         bundle = installBundle(context, "bundles/jboss-osgi-jndi.jar", true);
+         
+         assertEquals("Test bundle ACTIVE", Bundle.ACTIVE, bundle.getState());
+      }
+      finally
+      {
+         framework.stop();
+      }
+   }
 }
\ No newline at end of file

Modified: projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jmx/JMXTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jmx/JMXTestCase.java	2009-05-04 09:52:32 UTC (rev 88143)
+++ projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jmx/JMXTestCase.java	2009-05-04 10:46:41 UTC (rev 88144)
@@ -23,12 +23,48 @@
 
 //$Id$
 
+import java.io.IOException;
+import java.rmi.registry.LocateRegistry;
+import java.util.Hashtable;
+import java.util.Set;
+
+import javax.management.Attribute;
+import javax.management.AttributeList;
+import javax.management.AttributeNotFoundException;
+import javax.management.InstanceAlreadyExistsException;
+import javax.management.InstanceNotFoundException;
+import javax.management.IntrospectionException;
+import javax.management.InvalidAttributeValueException;
+import javax.management.ListenerNotFoundException;
+import javax.management.MBeanException;
+import javax.management.MBeanInfo;
+import javax.management.MBeanRegistrationException;
+import javax.management.MBeanServer;
+import javax.management.MBeanServerConnection;
+import javax.management.NotCompliantMBeanException;
+import javax.management.NotificationFilter;
+import javax.management.NotificationListener;
+import javax.management.ObjectInstance;
 import javax.management.ObjectName;
+import javax.management.QueryExp;
+import javax.management.ReflectionException;
+import javax.management.remote.JMXConnector;
+import javax.management.remote.JMXConnectorFactory;
+import javax.management.remote.JMXConnectorServer;
+import javax.management.remote.JMXConnectorServerFactory;
+import javax.management.remote.JMXServiceURL;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.Name;
+import javax.naming.spi.ObjectFactory;
 
+import org.jboss.osgi.jndi.internal.JNPServer;
 import org.jboss.osgi.spi.framework.OSGiFramework;
 import org.jboss.osgi.spi.management.MBeanProxy;
 import org.jboss.test.osgi.blueprint.BlueprintTest;
+import org.jboss.test.osgi.blueprint.jmx.bundle.Foo;
 import org.jboss.test.osgi.blueprint.jmx.bundle.FooMBean;
+import org.jnp.server.Main;
 import org.osgi.framework.BundleContext;
 
 /**
@@ -39,6 +75,41 @@
  */
 public class JMXTestCase extends BlueprintTest
 {
+   public void _testJMXConnector() throws Exception
+   {
+      // Get the MBeanServer and register an MBean
+      MBeanServer mbs = getMBeanServer();
+      ObjectName oname = new ObjectName("jboss.osgi:service=mbean-test-service");
+      mbs.registerMBean(new Foo(), oname);
+      
+      // Access the MBean
+      FooMBean foo = (FooMBean)MBeanProxy.get(FooMBean.class, oname, getMBeanServer());
+      assertEquals("hello", foo.echo("hello"));
+      
+      Main namingMain = new Main();
+      namingMain.start();
+      
+      // Create the RMI registry
+      LocateRegistry.createRegistry(1099);
+      
+      // Create and start the the JMXConnectorServer 
+      JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:1099/server");
+      JMXConnectorServer cs = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
+      cs.start();
+      
+      // Create a client JMXConnector and get the MBeanServerConnection   
+      MBeanServerConnection rmiAdaptor = new RMIAdaptor(url);
+
+      InitialContext iniCtx = new InitialContext();
+      iniCtx.bind("jmx/invoker/RMIAdaptor", new RMIAdaptorFactory(url));
+      //MBeanServerConnection rmiAdaptor = mbsc; //(MBeanServerConnection)iniCtx.lookup("jmx/invoker/RMIAdaptor");
+      
+      // Access the MBean through the MBeanServerConnection
+      FooMBean remfoo = (FooMBean)MBeanProxy.get(FooMBean.class, oname, rmiAdaptor);
+      assertEquals("hello", remfoo.echo("hello"));
+      
+   }
+   
    public void testMBeanAccess() throws Exception
    {
       OSGiFramework framework = getBootstrapProvider().getFramework();
@@ -58,4 +129,167 @@
          framework.stop();
       }
    }
+   
+   static class RMIAdaptorFactory implements ObjectFactory
+   {
+      private JMXServiceURL url;
+      
+      public RMIAdaptorFactory(JMXServiceURL url)
+      {
+         this.url = url;
+      }
+
+      public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment) throws Exception
+      {
+         return new RMIAdaptor(url);
+      }
+   }
+   
+   static class RMIAdaptor implements MBeanServerConnection
+   {
+      private MBeanServerConnection delegate;
+
+      public RMIAdaptor(JMXServiceURL url) throws IOException
+      {
+         JMXConnector jmxc = JMXConnectorFactory.connect(url, null); 
+         delegate = jmxc.getMBeanServerConnection(); 
+      }
+      
+      public void addNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback)
+            throws InstanceNotFoundException, IOException
+      {
+         delegate.addNotificationListener(name, listener, filter, handback);
+      }
+
+      public void addNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException,
+            IOException
+      {
+         delegate.addNotificationListener(name, listener, filter, handback);
+      }
+
+      public ObjectInstance createMBean(String className, ObjectName name, Object[] params, String[] signature) throws ReflectionException,
+            InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, IOException
+      {
+         return delegate.createMBean(className, name, params, signature);
+      }
+
+      public ObjectInstance createMBean(String className, ObjectName name, ObjectName loaderName, Object[] params, String[] signature) throws ReflectionException,
+            InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException, IOException
+      {
+         return delegate.createMBean(className, name, loaderName, params, signature);
+      }
+
+      public ObjectInstance createMBean(String className, ObjectName name, ObjectName loaderName) throws ReflectionException, InstanceAlreadyExistsException,
+            MBeanRegistrationException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException, IOException
+      {
+         return delegate.createMBean(className, name, loaderName);
+      }
+
+      public ObjectInstance createMBean(String className, ObjectName name) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException,
+            MBeanException, NotCompliantMBeanException, IOException
+      {
+         return delegate.createMBean(className, name);
+      }
+
+      public Object getAttribute(ObjectName name, String attribute) throws MBeanException, AttributeNotFoundException, InstanceNotFoundException,
+            ReflectionException, IOException
+      {
+         return delegate.getAttribute(name, attribute);
+      }
+
+      public AttributeList getAttributes(ObjectName name, String[] attributes) throws InstanceNotFoundException, ReflectionException, IOException
+      {
+         return delegate.getAttributes(name, attributes);
+      }
+
+      public String getDefaultDomain() throws IOException
+      {
+         return delegate.getDefaultDomain();
+      }
+
+      public String[] getDomains() throws IOException
+      {
+         return delegate.getDomains();
+      }
+
+      public Integer getMBeanCount() throws IOException
+      {
+         return delegate.getMBeanCount();
+      }
+
+      public MBeanInfo getMBeanInfo(ObjectName name) throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException
+      {
+         return delegate.getMBeanInfo(name);
+      }
+
+      public ObjectInstance getObjectInstance(ObjectName name) throws InstanceNotFoundException, IOException
+      {
+         return delegate.getObjectInstance(name);
+      }
+
+      public Object invoke(ObjectName name, String operationName, Object[] params, String[] signature) throws InstanceNotFoundException, MBeanException,
+            ReflectionException, IOException
+      {
+         return delegate.invoke(name, operationName, params, signature);
+      }
+
+      public boolean isInstanceOf(ObjectName name, String className) throws InstanceNotFoundException, IOException
+      {
+         return delegate.isInstanceOf(name, className);
+      }
+
+      public boolean isRegistered(ObjectName name) throws IOException
+      {
+         return delegate.isRegistered(name);
+      }
+
+      public Set queryMBeans(ObjectName name, QueryExp query) throws IOException
+      {
+         return delegate.queryMBeans(name, query);
+      }
+
+      public Set queryNames(ObjectName name, QueryExp query) throws IOException
+      {
+         return delegate.queryNames(name, query);
+      }
+
+      public void removeNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback)
+            throws InstanceNotFoundException, ListenerNotFoundException, IOException
+      {
+         delegate.removeNotificationListener(name, listener, filter, handback);
+      }
+
+      public void removeNotificationListener(ObjectName name, NotificationListener listener) throws InstanceNotFoundException, ListenerNotFoundException,
+            IOException
+      {
+         delegate.removeNotificationListener(name, listener);
+      }
+
+      public void removeNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException,
+            ListenerNotFoundException, IOException
+      {
+         delegate.removeNotificationListener(name, listener, filter, handback);
+      }
+
+      public void removeNotificationListener(ObjectName name, ObjectName listener) throws InstanceNotFoundException, ListenerNotFoundException, IOException
+      {
+         delegate.removeNotificationListener(name, listener);
+      }
+
+      public void setAttribute(ObjectName name, Attribute attribute) throws InstanceNotFoundException, AttributeNotFoundException, InvalidAttributeValueException,
+            MBeanException, ReflectionException, IOException
+      {
+         delegate.setAttribute(name, attribute);
+      }
+
+      public AttributeList setAttributes(ObjectName name, AttributeList attributes) throws InstanceNotFoundException, ReflectionException, IOException
+      {
+         return delegate.setAttributes(name, attributes);
+      }
+
+      public void unregisterMBean(ObjectName name) throws InstanceNotFoundException, MBeanRegistrationException, IOException
+      {
+         delegate.unregisterMBean(name);
+      }
+   }
 }
\ No newline at end of file

Added: projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jndi/JNDITestCase.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jndi/JNDITestCase.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jndi/JNDITestCase.java	2009-05-04 10:46:41 UTC (rev 88144)
@@ -0,0 +1,86 @@
+/*
+ * 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.osgi.blueprint.jndi;
+
+//$Id$
+
+import java.rmi.registry.LocateRegistry;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.jboss.test.osgi.blueprint.BlueprintTest;
+import org.jnp.interfaces.Naming;
+import org.jnp.server.Main;
+import org.jnp.server.NamingBean;
+import org.jnp.server.NamingBeanImpl;
+import org.jnp.server.NamingServer;
+
+/**
+ * A test that deployes a bundle that registeres an MBean
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 12-Feb-2009
+ */
+public class JNDITestCase extends BlueprintTest
+{
+   public void testJNDIAccess() throws Exception
+   {
+      // Create the RMI registry
+      //LocateRegistry.createRegistry(1098);
+
+      NamingBean namingBean = new NamingBean()
+      {
+         private Naming theServer;
+         public Naming getNamingInstance()
+         {
+            if (theServer == null)
+            {
+               try
+               {
+                  theServer = new NamingServer();
+               }
+               catch (NamingException ex)
+               {
+                  throw new IllegalStateException("Cannot create NamingServer", ex);
+               }
+            }
+            return theServer;
+         }
+      };
+      
+      Main namingMain = new Main();
+      namingMain.setNamingInfo(namingBean);
+      namingMain.setBindAddress("localhost");
+      namingMain.setRmiPort(1098);
+      namingMain.setPort(1099);
+      namingMain.start();
+      
+      InitialContext iniCtx = new InitialContext();
+      iniCtx.bind("foo", new String("hello"));
+      
+      String lookup = (String)iniCtx.lookup("foo");
+      System.out.println(lookup);
+      
+      namingMain.stop();
+   }
+}
\ No newline at end of file


Property changes on: projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jndi/JNDITestCase.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Modified: projects/jboss-osgi/trunk/bundle/blueprint/src/test/resources/jboss-osgi-framework.properties
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/src/test/resources/jboss-osgi-framework.properties	2009-05-04 09:52:32 UTC (rev 88143)
+++ projects/jboss-osgi/trunk/bundle/blueprint/src/test/resources/jboss-osgi-framework.properties	2009-05-04 10:46:41 UTC (rev 88144)
@@ -34,6 +34,7 @@
 	file://${test.archive.directory}/bundles/jbossxb-bundle.jar \
 	file://${test.archive.directory}/bundles/jboss-osgi-common.jar \
 	file://${test.archive.directory}/bundles/jboss-osgi-logging.jar \
+	file://${test.archive.directory}/bundles/jboss-osgi-jndi.jar \
 	file://${test.archive.directory}/bundles/jboss-osgi-jmx.jar \
 	file://${test.archive.directory}/bundles/jboss-osgi-microcontainer.jar
 	
\ No newline at end of file

Added: projects/jboss-osgi/trunk/bundle/blueprint/src/test/resources/jndi.properties
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/src/test/resources/jndi.properties	                        (rev 0)
+++ projects/jboss-osgi/trunk/bundle/blueprint/src/test/resources/jndi.properties	2009-05-04 10:46:41 UTC (rev 88144)
@@ -0,0 +1,3 @@
+java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
+java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
+java.naming.provider.url=jnp://localhost:1099

Copied: projects/jboss-osgi/trunk/bundle/jndi (from rev 88135, projects/jboss-osgi/trunk/bundle/jmx)

Modified: projects/jboss-osgi/trunk/bundle/jndi/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/bundle/jmx/pom.xml	2009-05-04 05:30:22 UTC (rev 88135)
+++ projects/jboss-osgi/trunk/bundle/jndi/pom.xml	2009-05-04 10:46:41 UTC (rev 88144)
@@ -1,39 +1,41 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
   <modelVersion>4.0.0</modelVersion>
-  
-  <name>JBossOSGi - Bundle JMX</name>
-  
+
+  <name>JBossOSGi - Bundle JNDI</name>
+
   <groupId>org.jboss.osgi.bundles</groupId>
-  <artifactId>jboss-osgi-jmx</artifactId>
+  <artifactId>jboss-osgi-jndi</artifactId>
   <packaging>bundle</packaging>
-  
+
   <parent>
     <groupId>org.jboss.osgi</groupId>
     <artifactId>jboss-osgi-bundle</artifactId>
     <version>1.0.0.Beta2</version>
   </parent>
-  
+
   <!-- Properties -->
   <properties>
   </properties>
 
   <!-- Dependencies -->
   <dependencies>
+    <!-- Provided Dependencies -->
     <dependency>
-      <groupId>org.jboss.osgi</groupId>
-      <artifactId>jboss-osgi-spi</artifactId>
-      <version>${version}</version>
+      <groupId>org.jboss.naming</groupId>
+      <artifactId>jnpserver</artifactId>
+      <scope>provided</scope>
     </dependency>
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi.core</artifactId>
+      <scope>provided</scope>
+    </dependency>
     
+    <!-- Bundles -->
     <dependency>
       <groupId>org.jboss.osgi.bundles</groupId>
       <artifactId>jboss-osgi-common</artifactId>
       <version>${version}</version>
-    </dependency>
-    
-    <dependency>
-      <groupId>org.osgi</groupId>
-      <artifactId>org.osgi.core</artifactId>
       <scope>provided</scope>
     </dependency>
     <dependency>
@@ -41,14 +43,6 @@
       <artifactId>org.osgi.compendium</artifactId>
       <scope>provided</scope>
     </dependency>
-    
-    <!-- Test Dependencies -->
-    <dependency>
-      <groupId>org.jboss.osgi</groupId>
-      <artifactId>jboss-osgi-runtime-felix</artifactId>
-      <version>${version}</version>
-      <scope>test</scope>
-    </dependency>
   </dependencies>
 
   <build>
@@ -60,17 +54,25 @@
         <configuration>
           <instructions>
             <Bundle-SymbolicName>${artifactId}</Bundle-SymbolicName>
-            <Bundle-Activator>org.jboss.osgi.jmx.ServiceActivator</Bundle-Activator>
+            <Bundle-Activator>org.jboss.osgi.jndi.ServiceActivator</Bundle-Activator>
             <Import-Package>
-               javax.management*,
-               org.jboss.osgi.common.log, 
-               org.osgi.framework;version=1.4,
-               org.osgi.service.log,
+            javax.naming*, 
+            javax.net, 
+            org.jboss.logging, 
+            org.jboss.net.sockets, 
+            org.jboss.osgi.common.log, 
+            org.jboss.util.naming, 
+            org.jboss.util.threadpool, 
+            org.osgi.framework, 
+            org.osgi.service.log,
             </Import-Package>
+            <Embed-Dependency>
+              jnpserver;inline=false,
+            </Embed-Dependency>
           </instructions>
         </configuration>
       </plugin>
     </plugins>
   </build>
-  
+
 </project>

Deleted: projects/jboss-osgi/trunk/bundle/jndi/src/main/java/org/jboss/osgi/jmx/ObjectNameFactory.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/ObjectNameFactory.java	2009-05-04 05:30:22 UTC (rev 88135)
+++ projects/jboss-osgi/trunk/bundle/jndi/src/main/java/org/jboss/osgi/jmx/ObjectNameFactory.java	2009-05-04 10:46:41 UTC (rev 88144)
@@ -1,74 +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.osgi.jmx;
-
-// $Id$
-
-import java.util.Hashtable;
-
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-
-/**
- * A simple factory for creating safe object names.
- *
- * @author Thomas.Diesler at jboss.org
- * @since 08-May-2006
- */
-public class ObjectNameFactory
-{
-   public static ObjectName create(String name)
-   {
-      try
-      {
-         return new ObjectName(name);
-      }
-      catch (MalformedObjectNameException e)
-      {
-         throw new Error("Invalid ObjectName: " + name + "; " + e);
-      }
-   }
-
-   public static ObjectName create(String domain, String key, String value)
-   {
-      try
-      {
-         return new ObjectName(domain, key, value);
-      }
-      catch (MalformedObjectNameException e)
-      {
-         throw new Error("Invalid ObjectName: " + domain + "," + key + "," + value + "; " + e);
-      }
-   }
-
-   public static ObjectName create(String domain, Hashtable<String, String> table)
-   {
-      try
-      {
-         return new ObjectName(domain, table);
-      }
-      catch (MalformedObjectNameException e)
-      {
-         throw new Error("Invalid ObjectName: " + domain + "," + table + "; " + e);
-      }
-   }
-}

Deleted: projects/jboss-osgi/trunk/bundle/jndi/src/main/java/org/jboss/osgi/jmx/ServiceActivator.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/ServiceActivator.java	2009-05-04 05:30:22 UTC (rev 88135)
+++ projects/jboss-osgi/trunk/bundle/jndi/src/main/java/org/jboss/osgi/jmx/ServiceActivator.java	2009-05-04 10:46:41 UTC (rev 88144)
@@ -1,69 +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.osgi.jmx;
-
-//$Id$
-
-import javax.management.MBeanServer;
-
-import org.jboss.osgi.jmx.internal.JMXConnectorService;
-import org.jboss.osgi.jmx.internal.MBeanServerService;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-
-/**
- * A BundleActivator for the MBeanServer related services
- * 
- * @author thomas.diesler at jboss.com
- * @since 24-Apr-2009
- */
-public class ServiceActivator implements BundleActivator
-{
-   public static final String REMOTE_JMX_HOST = "org.jboss.osgi.jmx.host";
-   public static final String REMOTE_JMX_PORT = "org.jboss.osgi.jmx.port";
-   
-   private JMXConnectorService conService;
-   
-   public void start(BundleContext context)
-   {
-      MBeanServerService mbeanService = new MBeanServerService(context);
-      MBeanServer mbs = mbeanService.getMBeanServer();
-      
-      String jmxHost = context.getProperty(REMOTE_JMX_HOST);
-      String jmxPort = context.getProperty(REMOTE_JMX_PORT);
-      
-      if (jmxHost != null && jmxPort != null)
-      {
-         conService = new JMXConnectorService(context, mbs, jmxHost, jmxPort);
-         conService.start();
-      }
-   }
-
-   public void stop(BundleContext context)
-   {
-      if (conService != null)
-      {
-         conService.stop();
-         conService = null;
-      }
-   }
-}
\ No newline at end of file

Copied: projects/jboss-osgi/trunk/bundle/jndi/src/main/java/org/jboss/osgi/jndi/ServiceActivator.java (from rev 88135, projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/ServiceActivator.java)
===================================================================
--- projects/jboss-osgi/trunk/bundle/jndi/src/main/java/org/jboss/osgi/jndi/ServiceActivator.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/bundle/jndi/src/main/java/org/jboss/osgi/jndi/ServiceActivator.java	2009-05-04 10:46:41 UTC (rev 88144)
@@ -0,0 +1,70 @@
+/*
+ * 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.osgi.jndi;
+
+//$Id$
+
+import org.jboss.osgi.jndi.internal.JNPServer;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+/**
+ * A BundleActivator for the JNDI related services
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 24-Apr-2009
+ */
+public class ServiceActivator implements BundleActivator
+{
+   public static final String REMOTE_JNDI_HOST = "org.jboss.osgi.jndi.host";
+   public static final String REMOTE_JNDI_RMI_PORT = "org.jboss.osgi.jndi.rmi.port";
+   public static final String REMOTE_JNDI_PORT = "org.jboss.osgi.jndi.port";
+
+   private JNPServer jnpServer;
+
+   public void start(BundleContext context)
+   {
+      String jndiHost = context.getProperty(REMOTE_JNDI_HOST);
+      if (jndiHost == null)
+         jndiHost = "localhost";
+
+      String jndiRmiPort = context.getProperty(REMOTE_JNDI_RMI_PORT);
+      if (jndiRmiPort == null)
+         jndiRmiPort = "1098";
+
+      String jndiPort = context.getProperty(REMOTE_JNDI_PORT);
+      if (jndiPort == null)
+         jndiPort = "1099";
+
+      jnpServer = new JNPServer(context, jndiHost, Integer.parseInt(jndiPort), Integer.parseInt(jndiRmiPort));
+      jnpServer.start();
+   }
+
+   public void stop(BundleContext context)
+   {
+      if (jnpServer != null)
+      {
+         jnpServer.stop();
+         jnpServer = null;
+      }
+   }
+}
\ No newline at end of file

Copied: projects/jboss-osgi/trunk/bundle/jndi/src/main/java/org/jboss/osgi/jndi/internal (from rev 88135, projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/internal)

Deleted: projects/jboss-osgi/trunk/bundle/jndi/src/main/java/org/jboss/osgi/jndi/internal/JMXConnectorService.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/internal/JMXConnectorService.java	2009-05-04 05:30:22 UTC (rev 88135)
+++ projects/jboss-osgi/trunk/bundle/jndi/src/main/java/org/jboss/osgi/jndi/internal/JMXConnectorService.java	2009-05-04 10:46:41 UTC (rev 88144)
@@ -1,92 +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.osgi.jmx.internal;
-
-//$Id$
-
-import java.io.IOException;
-
-import javax.management.MBeanServer;
-import javax.management.remote.JMXConnectorServer;
-import javax.management.remote.JMXConnectorServerFactory;
-import javax.management.remote.JMXServiceURL;
-
-import org.jboss.osgi.common.log.LogServiceTracker;
-import org.osgi.framework.BundleContext;
-import org.osgi.service.log.LogService;
-
-/**
- * A Service Activator that registers an MBeanServer
- * 
- * @author thomas.diesler at jboss.com
- * @since 24-Apr-2009
- */
-public class JMXConnectorService
-{
-   private LogService log;
-   private JMXServiceURL conURL;
-   private JMXConnectorServer conServer;
-
-   public JMXConnectorService(BundleContext context, MBeanServer mbs, String jmxHost, String jmxPort)
-   {
-      log = new LogServiceTracker(context);
-
-      try
-      {
-         conURL = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://" + jmxHost + ":" + jmxPort + "/server");
-         conServer = JMXConnectorServerFactory.newJMXConnectorServer(conURL, null, mbs);
-      }
-      catch (IOException ex)
-      {
-         log.log(LogService.LOG_ERROR, "Cannot create JMXConnectorServer", ex);
-      }
-   }
-
-   public void start()
-   {
-      if (conServer == null)
-         throw new IllegalStateException("JMXConnectorServer not available");
-      
-      try
-      {
-         conServer.start();
-         log.log(LogService.LOG_DEBUG, "JMXConnector started: " + conURL);
-      }
-      catch (IOException ex)
-      {
-         log.log(LogService.LOG_ERROR, "Cannot start JMXConnectorServer", ex);
-      }
-   }
-
-   public void stop()
-   {
-      try
-      {
-         conServer.stop();
-         log.log(LogService.LOG_DEBUG, "JMXConnector stopped");
-      }
-      catch (IOException ex)
-      {
-         log.log(LogService.LOG_WARNING, "Cannot stop JMXConnectorServer", ex);
-      }
-   }
-}
\ No newline at end of file

Copied: projects/jboss-osgi/trunk/bundle/jndi/src/main/java/org/jboss/osgi/jndi/internal/JNPServer.java (from rev 88135, projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/internal/JMXConnectorService.java)
===================================================================
--- projects/jboss-osgi/trunk/bundle/jndi/src/main/java/org/jboss/osgi/jndi/internal/JNPServer.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/bundle/jndi/src/main/java/org/jboss/osgi/jndi/internal/JNPServer.java	2009-05-04 10:46:41 UTC (rev 88144)
@@ -0,0 +1,111 @@
+/*
+ * 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.osgi.jndi.internal;
+
+//$Id$
+
+import java.io.IOException;
+
+import javax.naming.NamingException;
+
+import org.jboss.osgi.common.log.LogServiceTracker;
+import org.jnp.interfaces.Naming;
+import org.jnp.server.Main;
+import org.jnp.server.NamingBean;
+import org.jnp.server.NamingServer;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.log.LogService;
+
+/**
+ * A Service Activator that activates the JNP Server
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 24-Apr-2009
+ */
+public class JNPServer
+{
+   private LogService log;
+   private Main namingMain;
+   private Naming namingServer;
+
+   public JNPServer(BundleContext context, String jndiHost, int jndiPort, int jndiRmiPort)
+   {
+      log = new LogServiceTracker(context);
+
+      try
+      {
+         NamingBean namingBean = new NamingBean()
+         {
+            public Naming getNamingInstance()
+            {
+               if (namingServer == null)
+               {
+                  try
+                  {
+                     namingServer = new NamingServer();
+                  }
+                  catch (NamingException ex)
+                  {
+                     throw new IllegalStateException("Cannot create NamingServer", ex);
+                  }
+               }
+               return namingServer;
+            }
+         };
+
+         namingMain = new Main();
+         namingMain.setNamingInfo(namingBean);
+         namingMain.setBindAddress(jndiHost);
+         namingMain.setRmiPort(jndiRmiPort);
+         namingMain.setPort(jndiPort);
+      }
+      catch (IOException ex)
+      {
+         log.log(LogService.LOG_ERROR, "Cannot create JMXConnectorServer", ex);
+      }
+   }
+
+   public void start()
+   {
+      if (namingMain == null)
+         throw new IllegalStateException("Naming server not available");
+
+      try
+      {
+         namingMain.start();
+         log.log(LogService.LOG_DEBUG, "JNDI server started");
+      }
+      catch (Exception ex)
+      {
+         log.log(LogService.LOG_ERROR, "Cannot start JNDI server", ex);
+      }
+   }
+
+   public void stop()
+   {
+      if (namingMain != null)
+      {
+         namingMain.stop();
+         log.log(LogService.LOG_DEBUG, "JMXConnector stopped");
+      }
+   }
+}
\ No newline at end of file

Deleted: projects/jboss-osgi/trunk/bundle/jndi/src/main/java/org/jboss/osgi/jndi/internal/MBeanServerService.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/internal/MBeanServerService.java	2009-05-04 05:30:22 UTC (rev 88135)
+++ projects/jboss-osgi/trunk/bundle/jndi/src/main/java/org/jboss/osgi/jndi/internal/MBeanServerService.java	2009-05-04 10:46:41 UTC (rev 88144)
@@ -1,74 +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.osgi.jmx.internal;
-
-//$Id$
-
-import java.util.ArrayList;
-
-import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
-
-import org.jboss.osgi.common.log.LogServiceTracker;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.log.LogService;
-
-/**
- * A service that registers an MBeanServer
- * 
- * @author thomas.diesler at jboss.com
- * @since 24-Apr-2009
- */
-public class MBeanServerService 
-{
-   private LogService log;
-   private MBeanServer mbeanServer;
-   
-   @SuppressWarnings("unchecked")
-   public MBeanServerService(BundleContext context)
-   {
-      log = new LogServiceTracker(context);
-      
-      ServiceReference sref = context.getServiceReference(MBeanServer.class.getName());
-      if (sref == null)
-      {
-         ArrayList<MBeanServer> serverArr = MBeanServerFactory.findMBeanServer(null);
-         if (serverArr.size() > 1)
-            throw new IllegalStateException("Multiple MBeanServer instances not supported");
-
-         if (serverArr.size() == 1)
-            mbeanServer = serverArr.get(0);
-
-         if (mbeanServer == null)
-            mbeanServer = MBeanServerFactory.createMBeanServer();
-         
-         log.log(LogService.LOG_DEBUG, "Register MBeanServer");
-         context.registerService(MBeanServer.class.getName(), mbeanServer, null);
-      }
-   }
-
-   public MBeanServer getMBeanServer()
-   {
-      return mbeanServer;
-   }
-}
\ No newline at end of file

Modified: projects/jboss-osgi/trunk/bundle/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/bundle/pom.xml	2009-05-04 09:52:32 UTC (rev 88143)
+++ projects/jboss-osgi/trunk/bundle/pom.xml	2009-05-04 10:46:41 UTC (rev 88144)
@@ -16,6 +16,7 @@
     <module>blueprint</module>
     <module>common</module>
     <module>jmx</module>
+    <module>jndi</module>
     <module>logging</module>
     <module>microcontainer</module>
     <module>remotelog</module>

Modified: projects/jboss-osgi/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/pom.xml	2009-05-04 09:52:32 UTC (rev 88143)
+++ projects/jboss-osgi/trunk/pom.xml	2009-05-04 10:46:41 UTC (rev 88144)
@@ -172,6 +172,11 @@
         <artifactId>jboss-aop-mc-int</artifactId>
         <version>${version.jboss.microcontainer}</version>
       </dependency>
+      <dependency>
+        <groupId>org.jboss.naming</groupId>
+        <artifactId>jnpserver</artifactId>
+        <version>${version.jbossas}</version>
+      </dependency>
       
       <!-- Bundle Dependencies -->
       <dependency>




More information about the jboss-osgi-commits mailing list