JBoss-OSGI SVN: r88203 - projects/jboss-osgi/trunk/build/distribution/runtime/conf.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-05-05 06:48:30 -0400 (Tue, 05 May 2009)
New Revision: 88203
Modified:
projects/jboss-osgi/trunk/build/distribution/runtime/conf/jboss-osgi-framework.properties
Log:
Use new property syntax
Modified: projects/jboss-osgi/trunk/build/distribution/runtime/conf/jboss-osgi-framework.properties
===================================================================
--- projects/jboss-osgi/trunk/build/distribution/runtime/conf/jboss-osgi-framework.properties 2009-05-05 10:40:41 UTC (rev 88202)
+++ projects/jboss-osgi/trunk/build/distribution/runtime/conf/jboss-osgi-framework.properties 2009-05-05 10:48:30 UTC (rev 88203)
@@ -5,12 +5,11 @@
#
# The OSGiFramework implementation
-framework.impl=org.jboss.osgi.felix.framework.FelixIntegration
+org.jboss.osgi.spi.framework.impl=org.jboss.osgi.felix.framework.FelixIntegration
# Properties to configure the Framework
-# All props start with 'framework.prop'
-framework.prop.org.osgi.framework.storage.clean=onFirstInit
-framework.prop.org.osgi.framework.system.packages.extra=\
+org.osgi.framework.storage.clean=onFirstInit
+org.osgi.framework.system.packages.extra=\
org.jboss.logging, \
org.jboss.osgi.spi, \
org.jboss.osgi.spi.management, \
@@ -22,11 +21,11 @@
org.jboss.virtual.protocol
# Bundles that need to be installed with the Framework automatically
-framework.autoInstall=\
+org.jboss.osgi.spi.framework.autoInstall=\
file://${osgi.home}/bundles/org.osgi.compendium.jar
# Bundles that need to be started automatically
-framework.autoStart=\
+org.jboss.osgi.spi.framework.autoStart=\
file://${osgi.home}/bundles/org.apache.felix.log.jar \
file://${osgi.home}/bundles/apache-xerces-bundle.jar \
file://${osgi.home}/bundles/jboss-common-core-bundle.jar \
17 years, 2 months
JBoss-OSGI SVN: r88202 - in projects/jboss-osgi/trunk: bundle/jndi/src/main/java/org/jboss/osgi/jndi/internal and 11 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-05-05 06:40:41 -0400 (Tue, 05 May 2009)
New Revision: 88202
Modified:
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/ServiceActivator.java
projects/jboss-osgi/trunk/bundle/microcontainer/src/main/java/org/jboss/osgi/microcontainer/internal/MicrocontainerServiceImpl.java
projects/jboss-osgi/trunk/bundle/remotelog/src/main/java/org/jboss/osgi/service/remotelog/RemoteLogActivator.java
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/http/bundle/ServiceActivator.java
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/microcontainer/bundle/ServiceActivator.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/deployer/jbosgi36/bundle/SomeServiceActivator.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi37/bundleA/ServiceActivator.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi37/bundleB/ServiceActivator.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi38/bundleA/ServiceActivator.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi38/bundleB/ServiceActivator.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi39/bundleB/ServiceActivator.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi41/bundleA/ServiceActivator.java
Log:
Remove unwanted ServiceRegistration
Modified: projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/internal/JMXConnectorService.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/internal/JMXConnectorService.java 2009-05-05 10:31:16 UTC (rev 88201)
+++ projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/internal/JMXConnectorService.java 2009-05-05 10:40:41 UTC (rev 88202)
@@ -49,7 +49,7 @@
{
private LogService log;
private JMXServiceURL serviceURL;
- private JMXConnectorServer conServer;
+ private JMXConnectorServer jmxConnectorServer;
public JMXConnectorService(BundleContext context, MBeanServer mbeanServer, String host, int rmiPort)
{
@@ -82,7 +82,7 @@
// create new connector server and start it
serviceURL = new JMXServiceURL("service:jmx:rmi://" + host + "/jndi/rmi://" + host + ":" + rmiPort + jmxConnectorServerPath);
- conServer = JMXConnectorServerFactory.newJMXConnectorServer(serviceURL, null, mbeanServer);
+ jmxConnectorServer = JMXConnectorServerFactory.newJMXConnectorServer(serviceURL, null, mbeanServer);
log.log(LogService.LOG_DEBUG, "JMX Connector created: " + serviceURL);
}
@@ -103,15 +103,14 @@
public void start()
{
- if (conServer == null)
+ if (jmxConnectorServer == null)
throw new IllegalStateException("JMXConnector not available");
ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
try
{
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
-
- conServer.start();
+ jmxConnectorServer.start();
log.log(LogService.LOG_INFO, "JMXConnector started: " + serviceURL);
}
catch (IOException ex)
@@ -126,14 +125,20 @@
public void stop()
{
+ ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
try
{
- conServer.stop();
+ Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
+ jmxConnectorServer.stop();
log.log(LogService.LOG_DEBUG, "JMXConnector stopped");
}
catch (IOException ex)
{
log.log(LogService.LOG_WARNING, "Cannot stop JMXConnector", ex);
}
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(ctxLoader);
+ }
}
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/bundle/jndi/src/main/java/org/jboss/osgi/jndi/internal/ServiceActivator.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/jndi/src/main/java/org/jboss/osgi/jndi/internal/ServiceActivator.java 2009-05-05 10:31:16 UTC (rev 88201)
+++ projects/jboss-osgi/trunk/bundle/jndi/src/main/java/org/jboss/osgi/jndi/internal/ServiceActivator.java 2009-05-05 10:40:41 UTC (rev 88202)
@@ -27,7 +27,6 @@
import org.jboss.osgi.jndi.NamingService;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
import org.osgi.service.log.LogService;
/**
@@ -42,7 +41,6 @@
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 ServiceRegistration regNaming;
private JNPServer jnpServer;
private LogService log;
@@ -65,19 +63,12 @@
jnpServer = new JNPServer(context, jndiHost, Integer.parseInt(jndiPort), Integer.parseInt(jndiRmiPort));
jnpServer.start();
- regNaming = context.registerService(NamingService.class.getName(), new NamingServiceImpl(), null);
+ context.registerService(NamingService.class.getName(), new NamingServiceImpl(), null);
log.log(LogService.LOG_DEBUG, "NamingService registered");
}
public void stop(BundleContext context)
{
- if (regNaming != null)
- {
- regNaming.unregister();
- regNaming = null;
- log.log(LogService.LOG_DEBUG, "NamingService unregistered");
- }
-
if (jnpServer != null)
{
jnpServer.stop();
Modified: projects/jboss-osgi/trunk/bundle/microcontainer/src/main/java/org/jboss/osgi/microcontainer/internal/MicrocontainerServiceImpl.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/microcontainer/src/main/java/org/jboss/osgi/microcontainer/internal/MicrocontainerServiceImpl.java 2009-05-05 10:31:16 UTC (rev 88201)
+++ projects/jboss-osgi/trunk/bundle/microcontainer/src/main/java/org/jboss/osgi/microcontainer/internal/MicrocontainerServiceImpl.java 2009-05-05 10:40:41 UTC (rev 88202)
@@ -54,7 +54,6 @@
import org.jboss.virtual.VirtualFile;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
-import org.osgi.framework.ServiceRegistration;
import org.osgi.service.log.LogService;
/**
@@ -67,7 +66,6 @@
{
private BundleContext context;
private EmbeddedBeansDeployer deployer;
- private ServiceRegistration registration;
private LogService log;
private VFSDeploymentFactory deploymentFactory = VFSDeploymentFactory.getInstance();
@@ -79,7 +77,7 @@
this.log = new LogServiceTracker(context);
VFS.init();
-
+
deployer = new EmbeddedBeansDeployer(context);
}
@@ -157,7 +155,7 @@
{
// Get the required MBeanServer
MBeanServer mbeanServer = getMBeanServer();
-
+
// Preregister some beans
try
{
@@ -182,21 +180,15 @@
}
log.log(LogService.LOG_DEBUG, "Register MicrocontainerService");
- registration = context.registerService(MicrocontainerService.class.getName(), this, null);
-
- // Register the MicrocontainerServiceMBean
+ context.registerService(MicrocontainerService.class.getName(), this, null);
+
+ // Register the MicrocontainerServiceMBean
registerMicrocontainerServiceMBean(mbeanServer);
}
void stop()
{
- if (registration != null)
- {
- log.log(LogService.LOG_DEBUG, "Unregister MicrocontainerService");
- unregisterMicrocontainerServiceMBean(getMBeanServer());
- registration.unregister();
- registration = null;
- }
+ unregisterMicrocontainerServiceMBean(getMBeanServer());
}
private MBeanServer getMBeanServer()
@@ -204,7 +196,7 @@
ServiceReference sref = context.getServiceReference(MBeanServer.class.getName());
if (sref == null)
throw new IllegalStateException("No MBeanServer registered");
-
+
MBeanServer mbeanServer = (MBeanServer)context.getService(sref);
return mbeanServer;
}
Modified: projects/jboss-osgi/trunk/bundle/remotelog/src/main/java/org/jboss/osgi/service/remotelog/RemoteLogActivator.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/remotelog/src/main/java/org/jboss/osgi/service/remotelog/RemoteLogActivator.java 2009-05-05 10:31:16 UTC (rev 88201)
+++ projects/jboss-osgi/trunk/bundle/remotelog/src/main/java/org/jboss/osgi/service/remotelog/RemoteLogActivator.java 2009-05-05 10:40:41 UTC (rev 88202)
@@ -29,7 +29,6 @@
import org.jboss.osgi.spi.logging.RemoteLogReaderService;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
/**
* [TODO]
@@ -47,7 +46,6 @@
private Boolean isReader = Boolean.FALSE;
private Boolean isSender = Boolean.FALSE;
private RemoteLogReaderServiceImpl readerService;
- private ServiceRegistration readerRegistration;
private RemoteLogListener remoteSender;
public void start(BundleContext context)
@@ -78,7 +76,7 @@
if (isReader == true)
{
readerService = new RemoteLogReaderServiceImpl(context, props);
- readerRegistration = context.registerService(RemoteLogReaderService.class.getName(), readerService, props);
+ context.registerService(RemoteLogReaderService.class.getName(), readerService, props);
readerService.start();
}
@@ -98,9 +96,6 @@
{
if (isReader == true)
{
- readerRegistration.unregister();
- readerRegistration = null;
-
readerService.stop();
readerService = null;
}
Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/http/bundle/ServiceActivator.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/http/bundle/ServiceActivator.java 2009-05-05 10:31:16 UTC (rev 88201)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/http/bundle/ServiceActivator.java 2009-05-05 10:40:41 UTC (rev 88202)
@@ -25,7 +25,6 @@
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
/**
* A Service Activator
@@ -35,8 +34,6 @@
*/
public class ServiceActivator implements BundleActivator
{
- private ServiceRegistration registration;
-
/*
* Implements BundleActivator.start().
* Registers an instance of a HttpEndpoint Service using the bundle context.
@@ -44,7 +41,7 @@
public void start(BundleContext context)
{
EndpointService service = new EndpointService(context);
- registration = context.registerService(EndpointService.class.getName(), service, null);
+ context.registerService(EndpointService.class.getName(), service, null);
}
/*
@@ -52,10 +49,5 @@
*/
public void stop(BundleContext context)
{
- if (registration != null)
- {
- registration.unregister();
- registration = null;
- }
}
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/microcontainer/bundle/ServiceActivator.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/microcontainer/bundle/ServiceActivator.java 2009-05-05 10:31:16 UTC (rev 88201)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/microcontainer/bundle/ServiceActivator.java 2009-05-05 10:40:41 UTC (rev 88202)
@@ -25,7 +25,6 @@
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
/**
* A Service Activator
@@ -35,20 +34,13 @@
*/
public class ServiceActivator implements BundleActivator
{
- private ServiceRegistration registration;
-
public void start(BundleContext context)
{
MBeanTestService service = new MBeanTestService(context);
- registration = context.registerService(MBeanTestService.class.getName(), service, null);
+ context.registerService(MBeanTestService.class.getName(), service, null);
}
public void stop(BundleContext context)
{
- if (registration != null)
- {
- registration.unregister();
- registration = null;
- }
}
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/deployer/jbosgi36/bundle/SomeServiceActivator.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/deployer/jbosgi36/bundle/SomeServiceActivator.java 2009-05-05 10:31:16 UTC (rev 88201)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/deployer/jbosgi36/bundle/SomeServiceActivator.java 2009-05-05 10:40:41 UTC (rev 88202)
@@ -25,7 +25,6 @@
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
/**
* A Service Activator
@@ -35,20 +34,13 @@
*/
public class SomeServiceActivator implements BundleActivator
{
- private ServiceRegistration registration;
-
public void start(BundleContext context)
{
SomeService service = new SomeService();
- registration = context.registerService(SomeService.class.getName(), service, null);
+ context.registerService(SomeService.class.getName(), service, null);
}
public void stop(BundleContext context)
{
- if (registration != null)
- {
- registration.unregister();
- registration = null;
- }
}
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi37/bundleA/ServiceActivator.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi37/bundleA/ServiceActivator.java 2009-05-05 10:31:16 UTC (rev 88201)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi37/bundleA/ServiceActivator.java 2009-05-05 10:40:41 UTC (rev 88202)
@@ -25,24 +25,16 @@
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
public class ServiceActivator implements BundleActivator
{
- private ServiceRegistration registration;
-
public void start(BundleContext context)
{
ServiceA service = new ServiceA(context);
- registration = context.registerService(ServiceA.class.getName(), service, null);
+ context.registerService(ServiceA.class.getName(), service, null);
}
public void stop(BundleContext context)
{
- if (registration != null)
- {
- registration.unregister();
- registration = null;
- }
}
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi37/bundleB/ServiceActivator.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi37/bundleB/ServiceActivator.java 2009-05-05 10:31:16 UTC (rev 88201)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi37/bundleB/ServiceActivator.java 2009-05-05 10:40:41 UTC (rev 88202)
@@ -25,24 +25,16 @@
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
public class ServiceActivator implements BundleActivator
{
- private ServiceRegistration registration;
-
public void start(BundleContext context)
{
ServiceB service = new ServiceB(context);
- registration = context.registerService(ServiceB.class.getName(), service, null);
+ context.registerService(ServiceB.class.getName(), service, null);
}
public void stop(BundleContext context)
{
- if (registration != null)
- {
- registration.unregister();
- registration = null;
- }
}
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi38/bundleA/ServiceActivator.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi38/bundleA/ServiceActivator.java 2009-05-05 10:31:16 UTC (rev 88201)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi38/bundleA/ServiceActivator.java 2009-05-05 10:40:41 UTC (rev 88202)
@@ -25,24 +25,16 @@
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
public class ServiceActivator implements BundleActivator
{
- private ServiceRegistration registration;
-
public void start(BundleContext context)
{
ServiceA service = new ServiceA(context);
- registration = context.registerService(ServiceA.class.getName(), service, null);
+ context.registerService(ServiceA.class.getName(), service, null);
}
public void stop(BundleContext context)
{
- if (registration != null)
- {
- registration.unregister();
- registration = null;
- }
}
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi38/bundleB/ServiceActivator.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi38/bundleB/ServiceActivator.java 2009-05-05 10:31:16 UTC (rev 88201)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi38/bundleB/ServiceActivator.java 2009-05-05 10:40:41 UTC (rev 88202)
@@ -25,24 +25,16 @@
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
public class ServiceActivator implements BundleActivator
{
- private ServiceRegistration registration;
-
public void start(BundleContext context)
{
ServiceB service = new ServiceB();
- registration = context.registerService(ServiceB.class.getName(), service, null);
+ context.registerService(ServiceB.class.getName(), service, null);
}
public void stop(BundleContext context)
{
- if (registration != null)
- {
- registration.unregister();
- registration = null;
- }
}
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi39/bundleB/ServiceActivator.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi39/bundleB/ServiceActivator.java 2009-05-05 10:31:16 UTC (rev 88201)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi39/bundleB/ServiceActivator.java 2009-05-05 10:40:41 UTC (rev 88202)
@@ -25,24 +25,16 @@
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
public class ServiceActivator implements BundleActivator
{
- private ServiceRegistration registration;
-
public void start(BundleContext context)
{
ServiceB service = new ServiceB();
- registration = context.registerService(ServiceB.class.getName(), service, null);
+ context.registerService(ServiceB.class.getName(), service, null);
}
public void stop(BundleContext context)
{
- if (registration != null)
- {
- registration.unregister();
- registration = null;
- }
}
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi41/bundleA/ServiceActivator.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi41/bundleA/ServiceActivator.java 2009-05-05 10:31:16 UTC (rev 88201)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/jbosgi41/bundleA/ServiceActivator.java 2009-05-05 10:40:41 UTC (rev 88202)
@@ -28,22 +28,19 @@
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
public class ServiceActivator implements BundleActivator
{
- private ServiceRegistration regA, regB;
-
public void start(BundleContext context)
{
ServiceA serviceA = new ServiceA(context);
- regA = context.registerService(ServiceA.class.getName(), serviceA, null);
+ context.registerService(ServiceA.class.getName(), serviceA, null);
Dictionary<String, String> props = new Hashtable<String, String>();
props.put("service.pid", ServiceB.class.getName());
ServiceB serviceB = new ServiceB(context);
- regB = context.registerService(ServiceB.class.getName(), serviceB, props);
+ context.registerService(ServiceB.class.getName(), serviceB, props);
serviceB.updateConfig("xxx", "yyy");
serviceB.updateConfig("xxx", "zzz");
@@ -51,15 +48,5 @@
public void stop(BundleContext context)
{
- if (regA != null)
- {
- regA.unregister();
- regA = null;
- }
- if (regB != null)
- {
- regB.unregister();
- regB = null;
- }
}
}
\ No newline at end of file
17 years, 2 months
JBoss-OSGI SVN: r88200 - in projects/jboss-osgi/trunk: build/hudson/hudson-home/jobs/jbossosgi-embedded and 5 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-05-05 06:12:18 -0400 (Tue, 05 May 2009)
New Revision: 88200
Modified:
projects/jboss-osgi/trunk/build/hudson/hudson-home/jobs/jbossosgi-embedded/config.xml
projects/jboss-osgi/trunk/bundle/blueprint/pom.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/resources/basic-felix-framework.properties
projects/jboss-osgi/trunk/bundle/blueprint/src/test/resources/jboss-osgi-framework.properties
projects/jboss-osgi/trunk/bundle/blueprint/src/test/resources/jndi.properties
projects/jboss-osgi/trunk/pom.xml
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/framework/PropertiesBootstrapProvider.java
projects/jboss-osgi/trunk/testsuite/pom.xml
Log:
Remove dependency on localhost
Modified: projects/jboss-osgi/trunk/build/hudson/hudson-home/jobs/jbossosgi-embedded/config.xml
===================================================================
--- projects/jboss-osgi/trunk/build/hudson/hudson-home/jobs/jbossosgi-embedded/config.xml 2009-05-05 09:16:02 UTC (rev 88199)
+++ projects/jboss-osgi/trunk/build/hudson/hudson-home/jobs/jbossosgi-embedded/config.xml 2009-05-05 10:12:18 UTC (rev 88200)
@@ -31,7 +31,7 @@
<hudson.tasks.Maven>
<targets>clean install</targets>
<mavenName>apache-maven</mavenName>
- <properties>-U</properties>
+ <properties>-U -Djboss.bind.address=(a)jboss.bind.address@</properties>
</hudson.tasks.Maven>
<hudson.tasks.Shell>
<command>
Modified: projects/jboss-osgi/trunk/bundle/blueprint/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/pom.xml 2009-05-05 09:16:02 UTC (rev 88199)
+++ projects/jboss-osgi/trunk/bundle/blueprint/pom.xml 2009-05-05 10:12:18 UTC (rev 88200)
@@ -113,6 +113,12 @@
</dependencies>
<build>
+ <testResources>
+ <testResource>
+ <directory>src/test/resources</directory>
+ <filtering>true</filtering>
+ </testResource>
+ </testResources>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
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-05 09:16:02 UTC (rev 88199)
+++ projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/bootstrap/BundleTestCase.java 2009-05-05 10:12:18 UTC (rev 88200)
@@ -24,9 +24,6 @@
//$Id$
package org.jboss.test.osgi.blueprint.bootstrap;
-import javax.management.MBeanServerConnection;
-import javax.naming.InitialContext;
-
import org.jboss.osgi.spi.framework.OSGiBootstrap;
import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
import org.jboss.osgi.spi.framework.OSGiFramework;
@@ -163,10 +160,6 @@
bundle = installBundle(context, "bundles/jboss-osgi-jmx.jar", true);
assertEquals("Test bundle ACTIVE", Bundle.ACTIVE, bundle.getState());
-
- InitialContext iniCtx = new InitialContext();
- MBeanServerConnection lookup = (MBeanServerConnection)iniCtx.lookup("jmx/invoker/RMIAdaptor");
- assertEquals("DefaultDomain", lookup.getDefaultDomain());
}
finally
{
Modified: projects/jboss-osgi/trunk/bundle/blueprint/src/test/resources/basic-felix-framework.properties
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/src/test/resources/basic-felix-framework.properties 2009-05-05 09:16:02 UTC (rev 88199)
+++ projects/jboss-osgi/trunk/bundle/blueprint/src/test/resources/basic-felix-framework.properties 2009-05-05 10:12:18 UTC (rev 88200)
@@ -5,20 +5,19 @@
#
# The OSGiFramework implementation
-framework.impl=org.jboss.osgi.felix.framework.FelixIntegration
+org.jboss.osgi.spi.framework.impl=org.jboss.osgi.felix.framework.FelixIntegration
# Properties to configure the Framework
-# All props start with 'framework.prop'
-framework.prop.org.osgi.framework.storage.clean=onFirstInit
-framework.prop.org.osgi.framework.system.packages.extra=\
+org.osgi.framework.storage.clean=onFirstInit
+org.osgi.framework.system.packages.extra=\
org.jboss.logging
# Bundles that need to be installed with the Framework automatically
-framework.autoInstall=\
+org.jboss.osgi.spi.framework.autoInstall=\
file://${test.archive.directory}/bundles/org.osgi.compendium.jar
# Bundles that need to be started automatically
-framework.autoStart=\
+org.jboss.osgi.spi.framework.autoStart=\
file://${test.archive.directory}/bundles/org.apache.felix.log.jar \
file://${test.archive.directory}/bundles/jboss-osgi-common.jar \
file://${test.archive.directory}/bundles/jboss-osgi-logging.jar
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-05 09:16:02 UTC (rev 88199)
+++ projects/jboss-osgi/trunk/bundle/blueprint/src/test/resources/jboss-osgi-framework.properties 2009-05-05 10:12:18 UTC (rev 88200)
@@ -5,12 +5,11 @@
#
# The OSGiFramework implementation
-framework.impl=org.jboss.osgi.felix.framework.FelixIntegration
+org.jboss.osgi.spi.framework.impl=org.jboss.osgi.felix.framework.FelixIntegration
# Properties to configure the Framework
-# All props start with 'framework.prop'
-framework.prop.org.osgi.framework.storage.clean=onFirstInit
-framework.prop.org.osgi.framework.system.packages.extra=\
+org.osgi.framework.storage.clean=onFirstInit
+org.osgi.framework.system.packages.extra=\
org.jboss.logging, \
org.jboss.osgi.spi, \
org.jboss.osgi.spi.management, \
@@ -20,13 +19,15 @@
org.jboss.virtual.plugins.vfs.helpers, \
org.jboss.net.protocol, \
org.jboss.virtual.protocol
+org.jboss.osgi.jmx.host=(a)jboss.bind.address@
+org.jboss.osgi.jndi.host=(a)jboss.bind.address@
# Bundles that need to be installed with the Framework automatically
-framework.autoInstall=\
+org.jboss.osgi.spi.framework.autoInstall=\
file://${test.archive.directory}/bundles/org.osgi.compendium.jar
# Bundles that need to be started automatically
-framework.autoStart=\
+org.jboss.osgi.spi.framework.autoStart=\
file://${test.archive.directory}/bundles/org.apache.felix.log.jar \
file://${test.archive.directory}/bundles/apache-xerces-bundle.jar \
file://${test.archive.directory}/bundles/jboss-common-core-bundle.jar \
Modified: projects/jboss-osgi/trunk/bundle/blueprint/src/test/resources/jndi.properties
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/src/test/resources/jndi.properties 2009-05-05 09:16:02 UTC (rev 88199)
+++ projects/jboss-osgi/trunk/bundle/blueprint/src/test/resources/jndi.properties 2009-05-05 10:12:18 UTC (rev 88200)
@@ -1,3 +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
+java.naming.provider.url=jnp://@jboss.bind.address@:1099
Modified: projects/jboss-osgi/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/pom.xml 2009-05-05 09:16:02 UTC (rev 88199)
+++ projects/jboss-osgi/trunk/pom.xml 2009-05-05 10:12:18 UTC (rev 88200)
@@ -477,6 +477,23 @@
</plugins>
</build>
</profile>
+
+ <!--
+ Name: no-jboss-bind-address
+ Desc: Set the default jboss.bind.address
+ -->
+ <profile>
+ <id>no-jboss-bind-address</id>
+ <activation>
+ <property>
+ <name>!jboss.bind.address</name>
+ </property>
+ </activation>
+ <properties>
+ <jboss.bind.address>localhost</jboss.bind.address>
+ </properties>
+ </profile>
+
</profiles>
</project>
Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/framework/PropertiesBootstrapProvider.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/framework/PropertiesBootstrapProvider.java 2009-05-05 09:16:02 UTC (rev 88199)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/framework/PropertiesBootstrapProvider.java 2009-05-05 10:12:18 UTC (rev 88200)
@@ -30,9 +30,11 @@
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;
+import java.util.Set;
import org.jboss.osgi.spi.NotImplementedException;
import org.jboss.util.StringPropertyReplacer;
@@ -43,30 +45,30 @@
* The PropertiesBootstrapProvider supports the following properties
*
* <ul>
- * <li><b>framework.impl</b> - The OSGiFramework implementation</li>
- * <li><b>framework.prop.*</b> - Properties to configure the Framework</li>
- * <li><b>framework.autoInstall</b> - Bundles that need to be installed with the Framework automatically</li>
- * <li><b>framework.autoStart</b> - Bundles that need to be started automatically</li>
+ * <li><b>org.jboss.osgi.spi.framework.impl</b> - The OSGiFramework implementation</li>
+ * <li><b>org.jboss.osgi.spi.framework.autoInstall</b> - Bundles that need to be installed with the Framework automatically</li>
+ * <li><b>org.jboss.osgi.spi.framework.autoStart</b> - Bundles that need to be started automatically</li>
* </ul>
*
+ * All other properties are passed on to configure the framework.
+ *
* <pre>
* # The OSGiFramework implementation
- * framework.impl=org.jboss.osgi.felix.framework.FelixIntegration
+ * org.jboss.osgi.spi.framework.impl=org.jboss.osgi.felix.framework.FelixIntegration
*
* # Properties to configure the Framework
- * # All props start with 'framework.prop'
- * framework.prop.org.osgi.framework.storage.clean=onFirstInit
- * framework.prop.org.osgi.framework.system.packages=\
+ * org.osgi.framework.storage.clean=onFirstInit
+ * org.osgi.framework.system.packages=\
* org.jboss.logging, \
* org.osgi.framework; version=1.4, \
* javax.management
*
* # Bundles that need to be installed with the Framework automatically
- * framework.autoInstall=\
+ * org.jboss.osgi.spi.framework.autoInstall=\
* file://${test.archive.directory}/bundles/org.osgi.compendium.jar
*
* # Bundles that need to be started automatically
- * framework.autoStart=\
+ * org.jboss.osgi.spi.framework.autoStart=\
* file://${test.archive.directory}/bundles/org.apache.felix.log.jar \
* file://${test.archive.directory}/bundles/jboss-osgi-logging.jar \
* file://${test.archive.directory}/bundles/jboss-osgi-common.jar \
@@ -79,9 +81,21 @@
*/
public class PropertiesBootstrapProvider implements OSGiBootstrapProvider
{
- /** The OSGi framework integration class: osgi.framework.impl */
- public static final String PROP_OSGI_FRAMEWORK_IMPL = "framework.impl";
+ /** The OSGi framework integration class: org.jboss.osgi.spi.framework.impl */
+ public static final String PROP_OSGI_FRAMEWORK_IMPL = "org.jboss.osgi.spi.framework.impl";
+ /** The OSGi framework integration class: org.jboss.osgi.spi.framework.autoInstall */
+ public static final String PROP_OSGI_FRAMEWORK_AUTO_INSTALL = "org.jboss.osgi.spi.framework.autoInstall";
+ /** The OSGi framework integration class: org.jboss.osgi.spi.framework.autoStart */
+ public static final String PROP_OSGI_FRAMEWORK_AUTO_START = "org.jboss.osgi.spi.framework.autoStart";
+ private static Set<String> internalProps = new HashSet<String>();
+ static
+ {
+ internalProps.add(PROP_OSGI_FRAMEWORK_IMPL);
+ internalProps.add(PROP_OSGI_FRAMEWORK_AUTO_INSTALL);
+ internalProps.add(PROP_OSGI_FRAMEWORK_AUTO_START);
+ }
+
/** The default framework beans property: jboss.osgi.bootstrap.config */
public static final String OSGI_BOOTSTRAP_CONFIG = "jboss.osgi.bootstrap.config";
/** The default framework beans: jboss-osgi-bootstrap-beans.xml */
@@ -111,11 +125,11 @@
initFrameworkProperties(props);
// Init the the autoInstall URLs
- List<URL> installURLs = getBundleURLs(props, "framework.autoInstall");
+ List<URL> installURLs = getBundleURLs(props, PROP_OSGI_FRAMEWORK_AUTO_INSTALL);
framework.setAutoInstall(installURLs);
// Init the the autoStart URLs
- List<URL> startURLs = getBundleURLs(props, "framework.autoStart");
+ List<URL> startURLs = getBundleURLs(props, PROP_OSGI_FRAMEWORK_AUTO_START);
framework.setAutoStart(startURLs);
configured = true;
@@ -194,16 +208,14 @@
private void initFrameworkProperties(Properties props)
{
- String prefix = "framework.prop.";
Map<String,Object> frameworkProps = new HashMap<String,Object>();
Enumeration<?> keys = props.propertyNames();
while(keys.hasMoreElements())
{
String key = (String)keys.nextElement();
- if (key.startsWith(prefix))
+ if (internalProps.contains(key) == false)
{
String value = props.getProperty(key);
- key = key.substring(prefix.length());
frameworkProps.put(key, value);
}
}
Modified: projects/jboss-osgi/trunk/testsuite/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/pom.xml 2009-05-05 09:16:02 UTC (rev 88199)
+++ projects/jboss-osgi/trunk/testsuite/pom.xml 2009-05-05 10:12:18 UTC (rev 88200)
@@ -73,7 +73,7 @@
<id>framework-felix</id>
<activation>
<property>
- <name>!framework</name>
+ <name>framework</name>
<value>felix</value>
</property>
</activation>
@@ -117,7 +117,7 @@
<id>framework-equinox</id>
<activation>
<property>
- <name>!framework</name>
+ <name>framework</name>
<value>equinox</value>
</property>
</activation>
@@ -162,7 +162,7 @@
<id>framework-knopflerfish</id>
<activation>
<property>
- <name>!framework</name>
+ <name>framework</name>
<value>knopflerfish</value>
</property>
</activation>
@@ -207,7 +207,7 @@
<id>embedded-tesing</id>
<activation>
<property>
- <name>!jboss.bind.address</name>
+ <name>!target.container</name>
</property>
</activation>
<build>
@@ -234,7 +234,7 @@
<id>remote-tesing</id>
<activation>
<property>
- <name>jboss.bind.address</name>
+ <name>target.container</name>
</property>
</activation>
<dependencies>
17 years, 2 months
JBoss-OSGI SVN: r88199 - in projects/jboss-osgi/trunk/bundle: blueprint/src/test/resources and 4 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-05-05 05:16:02 -0400 (Tue, 05 May 2009)
New Revision: 88199
Removed:
projects/jboss-osgi/trunk/bundle/jndi/src/main/java/org/jboss/osgi/jmx/
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/resources/basic-felix-framework.properties
projects/jboss-osgi/trunk/bundle/jmx/pom.xml
projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/internal/JMXConnectorService.java
projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/internal/ServiceActivator.java
projects/jboss-osgi/trunk/bundle/jndi/src/main/java/org/jboss/osgi/jndi/internal/NamingServiceImpl.java
Log:
RMIAdaptor startup in runtime - ok
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-05 08:32:11 UTC (rev 88198)
+++ projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/bootstrap/BundleTestCase.java 2009-05-05 09:16:02 UTC (rev 88199)
@@ -24,6 +24,9 @@
//$Id$
package org.jboss.test.osgi.blueprint.bootstrap;
+import javax.management.MBeanServerConnection;
+import javax.naming.InitialContext;
+
import org.jboss.osgi.spi.framework.OSGiBootstrap;
import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
import org.jboss.osgi.spi.framework.OSGiFramework;
@@ -144,4 +147,30 @@
framework.stop();
}
}
+
+ public void testJMXBundle() throws Exception
+ {
+ 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);
+ bundle = installBundle(context, "bundles/jboss-osgi-jmx.jar", true);
+
+ assertEquals("Test bundle ACTIVE", Bundle.ACTIVE, bundle.getState());
+
+ InitialContext iniCtx = new InitialContext();
+ MBeanServerConnection lookup = (MBeanServerConnection)iniCtx.lookup("jmx/invoker/RMIAdaptor");
+ assertEquals("DefaultDomain", lookup.getDefaultDomain());
+ }
+ finally
+ {
+ framework.stop();
+ }
+ }
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/bundle/blueprint/src/test/resources/basic-felix-framework.properties
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/src/test/resources/basic-felix-framework.properties 2009-05-05 08:32:11 UTC (rev 88198)
+++ projects/jboss-osgi/trunk/bundle/blueprint/src/test/resources/basic-felix-framework.properties 2009-05-05 09:16:02 UTC (rev 88199)
@@ -21,6 +21,5 @@
framework.autoStart=\
file://${test.archive.directory}/bundles/org.apache.felix.log.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-jmx.jar
+ file://${test.archive.directory}/bundles/jboss-osgi-logging.jar
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/bundle/jmx/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/bundle/jmx/pom.xml 2009-05-05 08:32:11 UTC (rev 88198)
+++ projects/jboss-osgi/trunk/bundle/jmx/pom.xml 2009-05-05 09:16:02 UTC (rev 88199)
@@ -61,14 +61,16 @@
<Bundle-SymbolicName>${artifactId}</Bundle-SymbolicName>
<Bundle-Activator>org.jboss.osgi.jmx.internal.ServiceActivator</Bundle-Activator>
<Import-Package>
- javax.management*,
- javax.naming,
- javax.naming.spi,
- org.jboss.net.sockets,
- org.jboss.osgi.common.log,
- org.jboss.osgi.jndi,
- org.osgi.framework;version=1.4,
- org.osgi.service.log,
+ javax.management*,
+ javax.naming,
+ javax.naming.spi,
+ org.jboss.net.sockets,
+ org.jboss.osgi.common.log,
+ org.jboss.osgi.jndi,
+ org.jnp.interfaces,
+ org.osgi.framework;version=1.4,
+ org.osgi.service.log,
+ org.osgi.util.tracker,
</Import-Package>
</instructions>
</configuration>
Modified: projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/internal/JMXConnectorService.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/internal/JMXConnectorService.java 2009-05-05 08:32:11 UTC (rev 88198)
+++ projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/internal/JMXConnectorService.java 2009-05-05 09:16:02 UTC (rev 88199)
@@ -106,8 +106,11 @@
if (conServer == null)
throw new IllegalStateException("JMXConnector not available");
+ ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
try
{
+ Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
+
conServer.start();
log.log(LogService.LOG_INFO, "JMXConnector started: " + serviceURL);
}
@@ -115,6 +118,10 @@
{
log.log(LogService.LOG_ERROR, "Cannot start JMXConnector", ex);
}
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(ctxLoader);
+ }
}
public void stop()
Modified: projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/internal/ServiceActivator.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/internal/ServiceActivator.java 2009-05-05 08:32:11 UTC (rev 88198)
+++ projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/internal/ServiceActivator.java 2009-05-05 09:16:02 UTC (rev 88199)
@@ -51,7 +51,12 @@
public static final String REMOTE_JMX_RMI_PORT = "org.jboss.osgi.jmx.rmi.port";
public static final String REMOTE_JMX_RMI_ADAPTOR = "org.jboss.osgi.jmx.rmi.adaptor";
- private JMXConnectorService conService;
+ private JMXConnectorService jmxConnector;
+ private String jmxHost;
+ private String jmxRmiPort;
+ private String rmiAdaptorPath;
+ private MBeanServer mbanServer;
+
private LogService log;
public void start(BundleContext context)
@@ -59,23 +64,20 @@
log = new LogServiceTracker(context);
MBeanServerService mbeanService = new MBeanServerService(context);
- MBeanServer mbs = mbeanService.getMBeanServer();
+ mbanServer = mbeanService.getMBeanServer();
- String jmxHost = context.getProperty(REMOTE_JMX_HOST);
+ jmxHost = context.getProperty(REMOTE_JMX_HOST);
if (jmxHost == null)
jmxHost = "localhost";
- String jmxRmiPort = context.getProperty(REMOTE_JMX_RMI_PORT);
+ jmxRmiPort = context.getProperty(REMOTE_JMX_RMI_PORT);
if (jmxRmiPort == null)
jmxRmiPort = "1098";
- String rmiAdaptorPath = context.getProperty(REMOTE_JMX_RMI_ADAPTOR);
+ rmiAdaptorPath = context.getProperty(REMOTE_JMX_RMI_ADAPTOR);
if (rmiAdaptorPath == null)
rmiAdaptorPath = "jmx/invoker/RMIAdaptor";
- conService = new JMXConnectorService(context, mbs, jmxHost, Integer.parseInt(jmxRmiPort));
- conService.start();
-
// Start tracking the NamingService
NamingServiceTracker tracker = new NamingServiceTracker(context, rmiAdaptorPath);
tracker.open();
@@ -83,10 +85,15 @@
public void stop(BundleContext context)
{
- if (conService != null)
+ stopJMXConnectorService();
+ }
+
+ private void stopJMXConnectorService()
+ {
+ if (jmxConnector != null)
{
- conService.stop();
- conService = null;
+ jmxConnector.stop();
+ jmxConnector = null;
}
}
@@ -105,12 +112,19 @@
{
NamingService naming = (NamingService)super.addingService(reference);
+ // Start JMXConnectorService
+ if (jmxConnector == null)
+ {
+ jmxConnector = new JMXConnectorService(context, mbanServer, jmxHost, Integer.parseInt(jmxRmiPort));
+ jmxConnector.start();
+ }
+
// Bind the RMIAdaptor
try
{
InitialContext iniCtx = naming.getInitialContext();
iniCtx.createSubcontext("jmx").createSubcontext("invoker");
- StringRefAddr addr = new StringRefAddr(JMXServiceURL.class.getName(), conService.getServiceURL().toString());
+ StringRefAddr addr = new StringRefAddr(JMXServiceURL.class.getName(), jmxConnector.getServiceURL().toString());
Reference ref = new Reference(MBeanServerConnection.class.getName(), addr, RMIAdaptorFactory.class.getName(), null);
iniCtx.bind(rmiAdaptorPath, ref);
@@ -129,6 +143,9 @@
{
NamingService naming = (NamingService)service;
+ // Stop JMXConnectorService
+ stopJMXConnectorService();
+
// Unbind the RMIAdaptor
try
{
Modified: projects/jboss-osgi/trunk/bundle/jndi/src/main/java/org/jboss/osgi/jndi/internal/NamingServiceImpl.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/jndi/src/main/java/org/jboss/osgi/jndi/internal/NamingServiceImpl.java 2009-05-05 08:32:11 UTC (rev 88198)
+++ projects/jboss-osgi/trunk/bundle/jndi/src/main/java/org/jboss/osgi/jndi/internal/NamingServiceImpl.java 2009-05-05 09:16:02 UTC (rev 88199)
@@ -36,8 +36,23 @@
*/
public class NamingServiceImpl implements NamingService
{
+ private InitialContext initialContext;
+
public InitialContext getInitialContext() throws NamingException
{
- return new InitialContext();
+ if (initialContext == null)
+ {
+ ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
+ try
+ {
+ Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
+ initialContext = new InitialContext();
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(ctxLoader);
+ }
+ }
+ return initialContext;
}
}
\ No newline at end of file
17 years, 2 months
JBoss-OSGI SVN: r88196 - in projects/jboss-osgi/trunk/bundle/jmx: src/main/java/org/jboss/osgi/jmx and 1 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-05-05 03:20:14 -0400 (Tue, 05 May 2009)
New Revision: 88196
Added:
projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/internal/ServiceActivator.java
Removed:
projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/ServiceActivator.java
Modified:
projects/jboss-osgi/trunk/bundle/jmx/pom.xml
projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/internal/JMXConnectorService.java
Log:
RMIAdaptor tracks NamingService
Modified: projects/jboss-osgi/trunk/bundle/jmx/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/bundle/jmx/pom.xml 2009-05-05 07:19:57 UTC (rev 88195)
+++ projects/jboss-osgi/trunk/bundle/jmx/pom.xml 2009-05-05 07:20:14 UTC (rev 88196)
@@ -24,16 +24,23 @@
<artifactId>jboss-osgi-spi</artifactId>
<version>${version}</version>
</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>
+ <scope>provided</scope>
</dependency>
-
<dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
+ <groupId>org.jboss.osgi.bundles</groupId>
+ <artifactId>jboss-osgi-jndi</artifactId>
+ <version>${version}</version>
<scope>provided</scope>
</dependency>
<dependency>
@@ -41,14 +48,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,14 +59,14 @@
<configuration>
<instructions>
<Bundle-SymbolicName>${artifactId}</Bundle-SymbolicName>
- <Bundle-Activator>org.jboss.osgi.jmx.ServiceActivator</Bundle-Activator>
+ <Bundle-Activator>org.jboss.osgi.jmx.internal.ServiceActivator</Bundle-Activator>
<Import-Package>
javax.management*,
javax.naming,
javax.naming.spi,
org.jboss.net.sockets,
org.jboss.osgi.common.log,
- org.jnp.interfaces,
+ org.jboss.osgi.jndi,
org.osgi.framework;version=1.4,
org.osgi.service.log,
</Import-Package>
Deleted: projects/jboss-osgi/trunk/bundle/jmx/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-05 07:19:57 UTC (rev 88195)
+++ projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/ServiceActivator.java 2009-05-05 07:20:14 UTC (rev 88196)
@@ -1,71 +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(a)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";
-
- private JMXConnectorService conService;
-
- public void start(BundleContext context)
- {
- MBeanServerService mbeanService = new MBeanServerService(context);
- MBeanServer mbs = mbeanService.getMBeanServer();
-
- 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";
-
- conService = new JMXConnectorService(context, mbs, jndiHost, Integer.parseInt(jndiRmiPort));
- conService.start();
- }
-
- public void stop(BundleContext context)
- {
- if (conService != null)
- {
- conService.stop();
- conService = null;
- }
- }
-}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/internal/JMXConnectorService.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/internal/JMXConnectorService.java 2009-05-05 07:19:57 UTC (rev 88195)
+++ projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/internal/JMXConnectorService.java 2009-05-05 07:20:14 UTC (rev 88196)
@@ -30,13 +30,9 @@
import java.rmi.registry.Registry;
import javax.management.MBeanServer;
-import javax.management.MBeanServerConnection;
import javax.management.remote.JMXConnectorServer;
import javax.management.remote.JMXConnectorServerFactory;
import javax.management.remote.JMXServiceURL;
-import javax.naming.InitialContext;
-import javax.naming.Reference;
-import javax.naming.StringRefAddr;
import org.jboss.net.sockets.DefaultSocketFactory;
import org.jboss.osgi.common.log.LogServiceTracker;
@@ -52,7 +48,7 @@
public class JMXConnectorService
{
private LogService log;
- private JMXServiceURL conURL;
+ private JMXServiceURL serviceURL;
private JMXConnectorServer conServer;
public JMXConnectorService(BundleContext context, MBeanServer mbeanServer, String host, int rmiPort)
@@ -60,7 +56,6 @@
log = new LogServiceTracker(context);
String jmxConnectorServerPath = "/jmxconnector";
- String rmiAdaptorPath = "jmx/invoker/RMIAdaptor";
try
{
@@ -84,23 +79,12 @@
{
rmiRegistry = LocateRegistry.createRegistry(rmiPort, null, new DefaultSocketFactory(bindAddress));
}
-
- String serviceURL = "service:jmx:rmi://" + host + "/jndi/rmi://" + host + ":" + rmiPort + jmxConnectorServerPath;
- JMXServiceURL url = new JMXServiceURL(serviceURL);
// create new connector server and start it
- conServer = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbeanServer);
+ serviceURL = new JMXServiceURL("service:jmx:rmi://" + host + "/jndi/rmi://" + host + ":" + rmiPort + jmxConnectorServerPath);
+ conServer = JMXConnectorServerFactory.newJMXConnectorServer(serviceURL, null, mbeanServer);
log.log(LogService.LOG_DEBUG, "JMX Connector created: " + serviceURL);
-
- // Bind an ObjectFactory that creates the MBeanServerConnection
- InitialContext iniCtx = new InitialContext();
- iniCtx.createSubcontext("jmx").createSubcontext("invoker");
- StringRefAddr addr = new StringRefAddr(JMXServiceURL.class.getName(), serviceURL);
- Reference ref = new Reference(MBeanServerConnection.class.getName(), addr, RMIAdaptorFactory.class.getName(), null);
- iniCtx.bind(rmiAdaptorPath, ref);
-
- log.log(LogService.LOG_INFO, "MBeanServerConnection bound: " + rmiAdaptorPath);
}
catch (RuntimeException rte)
{
@@ -112,6 +96,11 @@
}
}
+ public JMXServiceURL getServiceURL()
+ {
+ return serviceURL;
+ }
+
public void start()
{
if (conServer == null)
@@ -120,7 +109,7 @@
try
{
conServer.start();
- log.log(LogService.LOG_INFO, "JMXConnector started: " + conURL);
+ log.log(LogService.LOG_INFO, "JMXConnector started: " + serviceURL);
}
catch (IOException ex)
{
Copied: projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/internal/ServiceActivator.java (from rev 88189, projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/ServiceActivator.java)
===================================================================
--- projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/internal/ServiceActivator.java (rev 0)
+++ projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/internal/ServiceActivator.java 2009-05-05 07:20:14 UTC (rev 88196)
@@ -0,0 +1,148 @@
+/*
+ * 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 javax.management.MBeanServer;
+import javax.management.MBeanServerConnection;
+import javax.management.remote.JMXServiceURL;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.naming.Reference;
+import javax.naming.StringRefAddr;
+
+import org.jboss.osgi.common.log.LogServiceTracker;
+import org.jboss.osgi.jndi.NamingService;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.log.LogService;
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ * A BundleActivator for the MBeanServer related services
+ *
+ * @author thomas.diesler(a)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_RMI_PORT = "org.jboss.osgi.jmx.rmi.port";
+ public static final String REMOTE_JMX_RMI_ADAPTOR = "org.jboss.osgi.jmx.rmi.adaptor";
+
+ private JMXConnectorService conService;
+ private LogService log;
+
+ public void start(BundleContext context)
+ {
+ log = new LogServiceTracker(context);
+
+ MBeanServerService mbeanService = new MBeanServerService(context);
+ MBeanServer mbs = mbeanService.getMBeanServer();
+
+ String jmxHost = context.getProperty(REMOTE_JMX_HOST);
+ if (jmxHost == null)
+ jmxHost = "localhost";
+
+ String jmxRmiPort = context.getProperty(REMOTE_JMX_RMI_PORT);
+ if (jmxRmiPort == null)
+ jmxRmiPort = "1098";
+
+ String rmiAdaptorPath = context.getProperty(REMOTE_JMX_RMI_ADAPTOR);
+ if (rmiAdaptorPath == null)
+ rmiAdaptorPath = "jmx/invoker/RMIAdaptor";
+
+ conService = new JMXConnectorService(context, mbs, jmxHost, Integer.parseInt(jmxRmiPort));
+ conService.start();
+
+ // Start tracking the NamingService
+ NamingServiceTracker tracker = new NamingServiceTracker(context, rmiAdaptorPath);
+ tracker.open();
+ }
+
+ public void stop(BundleContext context)
+ {
+ if (conService != null)
+ {
+ conService.stop();
+ conService = null;
+ }
+ }
+
+ class NamingServiceTracker extends ServiceTracker
+ {
+ private String rmiAdaptorPath;
+
+ public NamingServiceTracker(BundleContext context, String rmiAdaptorPath)
+ {
+ super(context, NamingService.class.getName(), null);
+ this.rmiAdaptorPath = rmiAdaptorPath;
+ }
+
+ @Override
+ public Object addingService(ServiceReference reference)
+ {
+ NamingService naming = (NamingService)super.addingService(reference);
+
+ // Bind the RMIAdaptor
+ try
+ {
+ InitialContext iniCtx = naming.getInitialContext();
+ iniCtx.createSubcontext("jmx").createSubcontext("invoker");
+ StringRefAddr addr = new StringRefAddr(JMXServiceURL.class.getName(), conService.getServiceURL().toString());
+ Reference ref = new Reference(MBeanServerConnection.class.getName(), addr, RMIAdaptorFactory.class.getName(), null);
+ iniCtx.bind(rmiAdaptorPath, ref);
+
+ log.log(LogService.LOG_INFO, "MBeanServerConnection bound to: " + rmiAdaptorPath);
+ }
+ catch (NamingException ex)
+ {
+ log.log(LogService.LOG_ERROR, "Cannot bind RMIAdoaptor", ex);
+ }
+
+ return naming;
+ }
+
+ @Override
+ public void removedService(ServiceReference reference, Object service)
+ {
+ NamingService naming = (NamingService)service;
+
+ // Unbind the RMIAdaptor
+ try
+ {
+ InitialContext iniCtx = naming.getInitialContext();
+ iniCtx.unbind(rmiAdaptorPath);
+
+ log.log(LogService.LOG_INFO, "MBeanServerConnection unbound from: " + rmiAdaptorPath);
+ }
+ catch (NamingException ex)
+ {
+ log.log(LogService.LOG_ERROR, "Cannot unbind RMIAdoaptor", ex);
+ }
+
+ super.removedService(reference, service);
+ }
+ }
+}
\ No newline at end of file
17 years, 2 months
JBoss-OSGI SVN: r88194 - in projects/jboss-osgi/trunk/bundle: blueprint/.settings and 11 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-05-05 02:51:43 -0400 (Tue, 05 May 2009)
New Revision: 88194
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/java/org/jboss/test/osgi/blueprint/jndi/bundle/
projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jndi/bundle/ServiceActivator.java
projects/jboss-osgi/trunk/bundle/blueprint/src/test/resources/jndi/
projects/jboss-osgi/trunk/bundle/blueprint/src/test/resources/jndi/jndi-test.bnd
projects/jboss-osgi/trunk/bundle/jndi/src/main/java/org/jboss/osgi/jndi/NamingService.java
projects/jboss-osgi/trunk/bundle/jndi/src/main/java/org/jboss/osgi/jndi/internal/NamingServiceImpl.java
projects/jboss-osgi/trunk/bundle/jndi/src/main/java/org/jboss/osgi/jndi/internal/ServiceActivator.java
projects/jboss-osgi/trunk/bundle/jndi/src/main/resources/
projects/jboss-osgi/trunk/bundle/jndi/src/main/resources/jnp.properties
Removed:
projects/jboss-osgi/trunk/bundle/jndi/src/main/java/org/jboss/osgi/jndi/ServiceActivator.java
Modified:
projects/jboss-osgi/trunk/bundle/blueprint/.classpath
projects/jboss-osgi/trunk/bundle/blueprint/.project
projects/jboss-osgi/trunk/bundle/blueprint/.settings/org.maven.ide.eclipse.prefs
projects/jboss-osgi/trunk/bundle/blueprint/scripts/antrun-test-jars.xml
projects/jboss-osgi/trunk/bundle/jndi/pom.xml
projects/jboss-osgi/trunk/bundle/jndi/src/main/java/org/jboss/osgi/jndi/internal/JNPServer.java
Log:
Add a JNDI bundle test
Modified: projects/jboss-osgi/trunk/bundle/blueprint/.classpath
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/.classpath 2009-05-05 06:29:39 UTC (rev 88193)
+++ projects/jboss-osgi/trunk/bundle/blueprint/.classpath 2009-05-05 06:51:43 UTC (rev 88194)
@@ -2,6 +2,7 @@
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
+ <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
Modified: projects/jboss-osgi/trunk/bundle/blueprint/.project
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/.project 2009-05-05 06:29:39 UTC (rev 88193)
+++ projects/jboss-osgi/trunk/bundle/blueprint/.project 2009-05-05 06:51:43 UTC (rev 88194)
@@ -17,7 +17,7 @@
</buildCommand>
</buildSpec>
<natures>
+ <nature>org.maven.ide.eclipse.maven2Nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
- <nature>org.maven.ide.eclipse.maven2Nature</nature>
</natures>
</projectDescription>
Modified: projects/jboss-osgi/trunk/bundle/blueprint/.settings/org.maven.ide.eclipse.prefs
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/.settings/org.maven.ide.eclipse.prefs 2009-05-05 06:29:39 UTC (rev 88193)
+++ projects/jboss-osgi/trunk/bundle/blueprint/.settings/org.maven.ide.eclipse.prefs 2009-05-05 06:51:43 UTC (rev 88194)
@@ -1,4 +1,4 @@
-#Tue Apr 14 17:48:48 CEST 2009
+#Tue May 05 08:38:16 CEST 2009
activeProfiles=
eclipse.preferences.version=1
fullBuildGoals=process-test-resources
Modified: projects/jboss-osgi/trunk/bundle/blueprint/scripts/antrun-test-jars.xml
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/scripts/antrun-test-jars.xml 2009-05-05 06:29:39 UTC (rev 88193)
+++ projects/jboss-osgi/trunk/bundle/blueprint/scripts/antrun-test-jars.xml 2009-05-05 06:51:43 UTC (rev 88194)
@@ -46,6 +46,9 @@
<!-- jmx -->
<bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/jmx-test.jar" files="${tests.resources.dir}/jmx/jmx-test.bnd" />
+ <!-- jndi -->
+ <bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/jndi-test.jar" files="${tests.resources.dir}/jndi/jndi-test.bnd" />
+
<!-- mcservice -->
<bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/mcservice-bundleA.jar" files="${tests.resources.dir}/mcservice/mcservice-bundleA.bnd" />
<bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/mcservice-bundleB.jar" files="${tests.resources.dir}/mcservice/mcservice-bundleB.bnd" />
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-05 06:51:43 UTC (rev 88194)
@@ -0,0 +1,74 @@
+/*
+ * 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 javax.naming.InitialContext;
+import javax.naming.NameNotFoundException;
+
+import org.jboss.osgi.spi.framework.OSGiFramework;
+import org.jboss.test.osgi.blueprint.BlueprintTest;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+
+/**
+ * A test that deployes a bundle that binds a String to JNDI
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 05-May-2009
+ */
+public class JNDITestCase extends BlueprintTest
+{
+ public void testJNDIAccess() throws Exception
+ {
+ OSGiFramework framework = getBootstrapProvider().getFramework();
+ BundleContext sysContext = framework.getSystemBundleContext();
+
+ try
+ {
+ Bundle bundle = installBundle(sysContext, "jndi-test.jar", true);
+ assertEquals("Test bundle ACTIVE", Bundle.ACTIVE, bundle.getState());
+
+ InitialContext iniCtx = new InitialContext();
+ String lookup = (String)iniCtx.lookup("test/Foo");
+ assertEquals("JNDI bound String expected", "Bar", lookup);
+
+ // Uninstall should unbind the object
+ bundle.uninstall();
+
+ try
+ {
+ iniCtx.lookup("test/Foo");
+ fail("NameNotFoundException expected");
+ }
+ catch (NameNotFoundException ex)
+ {
+ // expected
+ }
+ }
+ finally
+ {
+ framework.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
Added: projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jndi/bundle/ServiceActivator.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jndi/bundle/ServiceActivator.java (rev 0)
+++ projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jndi/bundle/ServiceActivator.java 2009-05-05 06:51:43 UTC (rev 88194)
@@ -0,0 +1,79 @@
+/*
+ * 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.bundle;
+
+//$Id$
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.jboss.osgi.jndi.NamingService;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+
+/**
+ * A Service Activator
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 05-May-2009
+ */
+public class ServiceActivator implements BundleActivator
+{
+ public void start(BundleContext context)
+ {
+ NamingService service = getNamingService(context);
+ try
+ {
+ InitialContext iniCtx = service.getInitialContext();
+ iniCtx.createSubcontext("test").bind("Foo", new String("Bar"));
+ }
+ catch (NamingException ex)
+ {
+ throw new IllegalStateException("Cannot bind to JNDI", ex);
+ }
+ }
+
+ public void stop(BundleContext context)
+ {
+ NamingService service = getNamingService(context);
+ try
+ {
+ InitialContext iniCtx = service.getInitialContext();
+ iniCtx.unbind("test/Foo");
+ }
+ catch (NamingException ex)
+ {
+ throw new IllegalStateException("Cannot unbind from JNDI", ex);
+ }
+ }
+
+ private NamingService getNamingService(BundleContext context)
+ {
+ ServiceReference sref = context.getServiceReference(NamingService.class.getName());
+ if (sref == null)
+ throw new IllegalStateException("NamingService not available");
+
+ NamingService service = (NamingService)context.getService(sref);
+ return service;
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jndi/bundle/ServiceActivator.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/trunk/bundle/blueprint/src/test/resources/jndi/jndi-test.bnd
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/src/test/resources/jndi/jndi-test.bnd (rev 0)
+++ projects/jboss-osgi/trunk/bundle/blueprint/src/test/resources/jndi/jndi-test.bnd 2009-05-05 06:51:43 UTC (rev 88194)
@@ -0,0 +1,6 @@
+# bnd build -classpath target/test-classes -output target/test-libs/jndi-test.jar src/test/resources/jndi/jndi-test.bnd
+
+Bundle-SymbolicName: jndi-test
+Bundle-Activator: org.jboss.test.osgi.blueprint.jndi.bundle.ServiceActivator
+Export-Package: org.jboss.test.osgi.blueprint.jndi.bundle
+Import-Package: javax.naming, org.osgi.framework, org.jboss.osgi.jndi
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/bundle/jndi/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/bundle/jndi/pom.xml 2009-05-05 06:29:39 UTC (rev 88193)
+++ projects/jboss-osgi/trunk/bundle/jndi/pom.xml 2009-05-05 06:51:43 UTC (rev 88194)
@@ -54,7 +54,8 @@
<configuration>
<instructions>
<Bundle-SymbolicName>${artifactId}</Bundle-SymbolicName>
- <Bundle-Activator>org.jboss.osgi.jndi.ServiceActivator</Bundle-Activator>
+ <Bundle-Activator>org.jboss.osgi.jndi.internal.ServiceActivator</Bundle-Activator>
+ <Export-Package>org.jboss.osgi.jndi</Export-Package>
<Import-Package>
javax.naming*,
javax.net,
Added: projects/jboss-osgi/trunk/bundle/jndi/src/main/java/org/jboss/osgi/jndi/NamingService.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/jndi/src/main/java/org/jboss/osgi/jndi/NamingService.java (rev 0)
+++ projects/jboss-osgi/trunk/bundle/jndi/src/main/java/org/jboss/osgi/jndi/NamingService.java 2009-05-05 06:51:43 UTC (rev 88194)
@@ -0,0 +1,42 @@
+/*
+ * 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 javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+/**
+ * A service that gives access to JNDI
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 05-May-2009
+ */
+public interface NamingService
+{
+ /**
+ * Get the InitialContext
+ * @throws NamingException if a naming exception is encountered
+ */
+ InitialContext getInitialContext() throws NamingException;
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/bundle/jndi/src/main/java/org/jboss/osgi/jndi/NamingService.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Deleted: 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/ServiceActivator.java 2009-05-05 06:29:39 UTC (rev 88193)
+++ projects/jboss-osgi/trunk/bundle/jndi/src/main/java/org/jboss/osgi/jndi/ServiceActivator.java 2009-05-05 06:51:43 UTC (rev 88194)
@@ -1,70 +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.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(a)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
Modified: projects/jboss-osgi/trunk/bundle/jndi/src/main/java/org/jboss/osgi/jndi/internal/JNPServer.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/jndi/src/main/java/org/jboss/osgi/jndi/internal/JNPServer.java 2009-05-05 06:29:39 UTC (rev 88193)
+++ projects/jboss-osgi/trunk/bundle/jndi/src/main/java/org/jboss/osgi/jndi/internal/JNPServer.java 2009-05-05 06:51:43 UTC (rev 88194)
@@ -49,7 +49,7 @@
public JNPServer(BundleContext context, String jndiHost, int jndiPort, int jndiRmiPort)
{
- log = new LogServiceTracker(context);
+ this.log = new LogServiceTracker(context);
try
{
Added: projects/jboss-osgi/trunk/bundle/jndi/src/main/java/org/jboss/osgi/jndi/internal/NamingServiceImpl.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/jndi/src/main/java/org/jboss/osgi/jndi/internal/NamingServiceImpl.java (rev 0)
+++ projects/jboss-osgi/trunk/bundle/jndi/src/main/java/org/jboss/osgi/jndi/internal/NamingServiceImpl.java 2009-05-05 06:51:43 UTC (rev 88194)
@@ -0,0 +1,43 @@
+/*
+ * 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 javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.jboss.osgi.jndi.NamingService;
+
+/**
+ * A Service Activator that activates the JNP Server
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 24-Apr-2009
+ */
+public class NamingServiceImpl implements NamingService
+{
+ public InitialContext getInitialContext() throws NamingException
+ {
+ return new InitialContext();
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/bundle/jndi/src/main/java/org/jboss/osgi/jndi/internal/NamingServiceImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied: projects/jboss-osgi/trunk/bundle/jndi/src/main/java/org/jboss/osgi/jndi/internal/ServiceActivator.java (from rev 88189, 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/ServiceActivator.java (rev 0)
+++ projects/jboss-osgi/trunk/bundle/jndi/src/main/java/org/jboss/osgi/jndi/internal/ServiceActivator.java 2009-05-05 06:51:43 UTC (rev 88194)
@@ -0,0 +1,87 @@
+/*
+ * 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 org.jboss.osgi.common.log.LogServiceTracker;
+import org.jboss.osgi.jndi.NamingService;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.log.LogService;
+
+/**
+ * A BundleActivator for the JNDI related services
+ *
+ * @author thomas.diesler(a)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 ServiceRegistration regNaming;
+ private JNPServer jnpServer;
+ private LogService log;
+
+ public void start(BundleContext context)
+ {
+ log = new LogServiceTracker(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();
+
+ regNaming = context.registerService(NamingService.class.getName(), new NamingServiceImpl(), null);
+ log.log(LogService.LOG_DEBUG, "NamingService registered");
+ }
+
+ public void stop(BundleContext context)
+ {
+ if (regNaming != null)
+ {
+ regNaming.unregister();
+ regNaming = null;
+ log.log(LogService.LOG_DEBUG, "NamingService unregistered");
+ }
+
+ if (jnpServer != null)
+ {
+ jnpServer.stop();
+ jnpServer = null;
+ }
+ }
+}
\ No newline at end of file
Added: projects/jboss-osgi/trunk/bundle/jndi/src/main/resources/jnp.properties
===================================================================
--- projects/jboss-osgi/trunk/bundle/jndi/src/main/resources/jnp.properties (rev 0)
+++ projects/jboss-osgi/trunk/bundle/jndi/src/main/resources/jnp.properties 2009-05-05 06:51:43 UTC (rev 88194)
@@ -0,0 +1 @@
+# Intentionally left empty
\ No newline at end of file
17 years, 2 months
JBoss-OSGI SVN: r88151 - in projects/jboss-osgi/trunk: build/distribution/runtime/conf and 3 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-05-04 10:07:00 -0400 (Mon, 04 May 2009)
New Revision: 88151
Added:
projects/jboss-osgi/trunk/build/distribution/runtime/conf/jndi.properties
Modified:
projects/jboss-osgi/trunk/build/distribution/pom.xml
projects/jboss-osgi/trunk/build/distribution/runtime/conf/jboss-osgi-framework.properties
projects/jboss-osgi/trunk/build/distribution/src/main/resources/installer/install-definition.xml
projects/jboss-osgi/trunk/bundle/jmx/pom.xml
projects/jboss-osgi/trunk/bundle/jndi/pom.xml
Log:
Add org.jnp.interfaces to JNDI exports
Modified: projects/jboss-osgi/trunk/build/distribution/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/build/distribution/pom.xml 2009-05-04 13:56:01 UTC (rev 88150)
+++ projects/jboss-osgi/trunk/build/distribution/pom.xml 2009-05-04 14:07:00 UTC (rev 88151)
@@ -103,6 +103,11 @@
</dependency>
<dependency>
<groupId>org.jboss.osgi.bundles</groupId>
+ <artifactId>jboss-osgi-jndi</artifactId>
+ <version>${version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.osgi.bundles</groupId>
<artifactId>jboss-osgi-logging</artifactId>
<version>${version}</version>
</dependency>
Modified: projects/jboss-osgi/trunk/build/distribution/runtime/conf/jboss-osgi-framework.properties
===================================================================
--- projects/jboss-osgi/trunk/build/distribution/runtime/conf/jboss-osgi-framework.properties 2009-05-04 13:56:01 UTC (rev 88150)
+++ projects/jboss-osgi/trunk/build/distribution/runtime/conf/jboss-osgi-framework.properties 2009-05-04 14:07:00 UTC (rev 88151)
@@ -34,6 +34,7 @@
file://${osgi.home}/bundles/jbossxb-bundle.jar \
file://${osgi.home}/bundles/jboss-osgi-common.jar \
file://${osgi.home}/bundles/jboss-osgi-logging.jar \
+ file://${osgi.home}/bundles/jboss-osgi-jndi.jar \
file://${osgi.home}/bundles/jboss-osgi-jmx.jar \
file://${osgi.home}/bundles/jboss-osgi-microcontainer.jar
\ No newline at end of file
Added: projects/jboss-osgi/trunk/build/distribution/runtime/conf/jndi.properties
===================================================================
--- projects/jboss-osgi/trunk/build/distribution/runtime/conf/jndi.properties (rev 0)
+++ projects/jboss-osgi/trunk/build/distribution/runtime/conf/jndi.properties 2009-05-04 14:07:00 UTC (rev 88151)
@@ -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
Modified: projects/jboss-osgi/trunk/build/distribution/src/main/resources/installer/install-definition.xml
===================================================================
--- projects/jboss-osgi/trunk/build/distribution/src/main/resources/installer/install-definition.xml 2009-05-04 13:56:01 UTC (rev 88150)
+++ projects/jboss-osgi/trunk/build/distribution/src/main/resources/installer/install-definition.xml 2009-05-04 14:07:00 UTC (rev 88151)
@@ -185,6 +185,7 @@
<include name="jboss-common-core-bundle.jar" />
<include name="jboss-osgi-common.jar" />
<include name="jboss-osgi-logging.jar" />
+ <include name="jboss-osgi-jndi.jar" />
<include name="jboss-osgi-jmx.jar" />
<include name="jboss-osgi-microcontainer.jar" />
<include name="jboss-osgi-webconsole.jar" />
Modified: projects/jboss-osgi/trunk/bundle/jmx/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/bundle/jmx/pom.xml 2009-05-04 13:56:01 UTC (rev 88150)
+++ projects/jboss-osgi/trunk/bundle/jmx/pom.xml 2009-05-04 14:07:00 UTC (rev 88151)
@@ -67,6 +67,7 @@
javax.naming.spi,
org.jboss.net.sockets,
org.jboss.osgi.common.log,
+ org.jnp.interfaces,
org.osgi.framework;version=1.4,
org.osgi.service.log,
</Import-Package>
Modified: projects/jboss-osgi/trunk/bundle/jndi/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/bundle/jndi/pom.xml 2009-05-04 13:56:01 UTC (rev 88150)
+++ projects/jboss-osgi/trunk/bundle/jndi/pom.xml 2009-05-04 14:07:00 UTC (rev 88151)
@@ -56,19 +56,22 @@
<Bundle-SymbolicName>${artifactId}</Bundle-SymbolicName>
<Bundle-Activator>org.jboss.osgi.jndi.ServiceActivator</Bundle-Activator>
<Import-Package>
- 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,
+ 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>
+ <_exportcontents>
+ org.jnp.interfaces,
+ </_exportcontents>
</instructions>
</configuration>
</plugin>
17 years, 2 months
JBoss-OSGI SVN: r88150 - in projects/jboss-osgi/trunk: bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jmx and 4 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-05-04 09:56:01 -0400 (Mon, 04 May 2009)
New Revision: 88150
Added:
projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/internal/RMIAdaptor.java
projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/internal/RMIAdaptorFactory.java
Removed:
projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jndi/
Modified:
projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jmx/JMXTestCase.java
projects/jboss-osgi/trunk/bundle/jmx/pom.xml
projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/ServiceActivator.java
projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/internal/JMXConnectorService.java
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/junit/OSGiTestSetup.java
Log:
JMXConnector started from BundleActivator
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 13:42:18 UTC (rev 88149)
+++ projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jmx/JMXTestCase.java 2009-05-04 13:56:01 UTC (rev 88150)
@@ -23,60 +23,18 @@
//$Id$
-import java.io.IOException;
-import java.io.Serializable;
-import java.net.InetAddress;
-import java.rmi.RemoteException;
-import java.rmi.registry.LocateRegistry;
-import java.rmi.registry.Registry;
-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.NamingException;
-import javax.naming.RefAddr;
-import javax.naming.Reference;
-import javax.naming.StringRefAddr;
-import javax.naming.spi.ObjectFactory;
-import org.jboss.logging.Logger;
-import org.jboss.net.sockets.DefaultSocketFactory;
+import junit.framework.Test;
+
import org.jboss.osgi.spi.framework.OSGiFramework;
+import org.jboss.osgi.spi.junit.OSGiTestSetup;
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.interfaces.Naming;
-import org.jnp.server.Main;
-import org.jnp.server.NamingBean;
-import org.jnp.server.NamingServer;
+import org.jboss.test.osgi.blueprint.mcservice.MicrocontainerServiceTestCase;
import org.osgi.framework.BundleContext;
/**
@@ -87,285 +45,49 @@
*/
public class JMXTestCase extends BlueprintTest
{
- private static final Logger log = Logger.getLogger(JMXTestCase.class);
+ private static OSGiFramework framework;
- private Main namingMain;
- private Naming namingServer;
-
- public void testJMXConnector() throws Exception
+ public static Test suite()
{
- // Get the MBeanServer and register an MBean
- MBeanServer mbeanServer = getMBeanServer();
- ObjectName oname = new ObjectName("jboss.osgi:service=mbean-test-service");
- mbeanServer.registerMBean(new Foo(), oname);
-
- // Access the MBean
- FooMBean foo = (FooMBean)MBeanProxy.get(FooMBean.class, oname, mbeanServer);
- assertEquals("hello", foo.echo("hello"));
-
- NamingBean namingBean = new NamingBean()
+ OSGiTestSetup setup = new OSGiTestSetup(MicrocontainerServiceTestCase.class)
{
- public Naming getNamingInstance()
+ @Override
+ protected void setUp() throws Exception
{
- if (namingServer == null)
- {
- try
- {
- namingServer = new NamingServer();
- }
- catch (NamingException ex)
- {
- throw new IllegalStateException("Cannot create NamingServer", ex);
- }
- }
- return namingServer;
+ super.setUp();
+ framework = getBootstrapProvider().getFramework();
+ framework.start();
+
+ BundleContext sysContext = framework.getSystemBundleContext();
+ installBundle(sysContext, "jmx-test.jar", true);
}
- };
- // the address to expose in the urls
- String host = System.getProperty("java.rmi.server.hostname");
- if (host == null)
- host = "localhost";
-
- String jndiPath = "/jmxconnector";
- InetAddress bindAddress = InetAddress.getByName(host);
- int rmiPort = 1098;
-
- namingMain = new Main();
- namingMain.setNamingInfo(namingBean);
- namingMain.setBindAddress(host);
- namingMain.setRmiPort(rmiPort);
- namingMain.setPort(1099);
-
- namingMain.start();
-
- // check to see if registry already created
- Registry rmiRegistry = LocateRegistry.getRegistry(host, rmiPort);
- if (rmiRegistry != null)
- {
- try
+ @Override
+ protected void tearDown() throws Exception
{
- rmiRegistry.list();
+ framework.stop();
+ super.tearDown();
}
- catch (RemoteException e)
- {
- log.debug("No registry running at host '" + host + "', port '" + rmiPort + "'. Will create one.");
- rmiRegistry = LocateRegistry.createRegistry(rmiPort, null, new DefaultSocketFactory(bindAddress));
- }
- }
- else
- {
- rmiRegistry = LocateRegistry.createRegistry(rmiPort, null, new DefaultSocketFactory(bindAddress));
- }
-
- String serviceURL = "service:jmx:rmi://" + host + "/jndi/rmi://" + host + ":" + rmiPort + jndiPath;
-
- final JMXServiceURL url = new JMXServiceURL(serviceURL);
-
- // create new connector server and start it
- JMXConnectorServer connectorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbeanServer);
- connectorServer.start();
-
- log.info("JMX Connector server: " + serviceURL);
-
- // Bind the ObjectFactory that creates the MBeanServerConnection
- InitialContext iniCtx = new InitialContext();
- iniCtx.createSubcontext("jmx").createSubcontext("invoker");
- StringRefAddr addr = new StringRefAddr(JMXServiceURL.class.getName(), serviceURL);
- Reference ref = new Reference(MBeanServerConnection.class.getName(), addr, RMIAdaptorFactory.class.getName(), null);
- iniCtx.bind("jmx/invoker/RMIAdaptor", ref);
-
- // Lookup the MBeanServerConnection
- MBeanServerConnection rmiAdaptor = (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"));
-
- rmiAdaptor.unregisterMBean(oname);
+ };
+ return setup;
}
public void testMBeanAccess() throws Exception
{
- OSGiFramework framework = getBootstrapProvider().getFramework();
-
- try
- {
- BundleContext sysContext = framework.getSystemBundleContext();
-
- installBundle(sysContext, "jmx-test.jar", true);
-
- ObjectName oname = new ObjectName("jboss.osgi:service=mbean-test-service");
- FooMBean foo = (FooMBean)MBeanProxy.get(FooMBean.class, oname, getMBeanServer());
- assertEquals("hello", foo.echo("hello"));
- }
- finally
- {
- framework.stop();
- }
+ ObjectName oname = new ObjectName("jboss.osgi:service=mbean-test-service");
+ FooMBean foo = (FooMBean)MBeanProxy.get(FooMBean.class, oname, getMBeanServer());
+ assertEquals("hello", foo.echo("hello"));
}
- public static class RMIAdaptorFactory implements ObjectFactory, Serializable
+ public void testRMIAdaptor() throws Exception
{
- private static final long serialVersionUID = 2560477127430087074L;
+ // Lookup the MBeanServerConnection
+ InitialContext iniCtx = new InitialContext();
+ MBeanServerConnection rmiAdaptor = (MBeanServerConnection)iniCtx.lookup("jmx/invoker/RMIAdaptor");
- public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment) throws Exception
- {
- Reference ref = (Reference)obj;
- RefAddr refAddr = ref.get(JMXServiceURL.class.getName());
- String serviceURL = (String)refAddr.getContent();
- JMXServiceURL url = new JMXServiceURL(serviceURL);
- return new RMIAdaptor(url);
- }
+ // Access the MBean through the MBeanServerConnection
+ ObjectName oname = new ObjectName("jboss.osgi:service=mbean-test-service");
+ FooMBean foo = (FooMBean)MBeanProxy.get(FooMBean.class, oname, rmiAdaptor);
+ assertEquals("hello", foo.echo("hello"));
}
-
- public static class RMIAdaptor implements MBeanServerConnection, Serializable
- {
- private static final long serialVersionUID = 6066226353118090215L;
-
- 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
Modified: projects/jboss-osgi/trunk/bundle/jmx/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/bundle/jmx/pom.xml 2009-05-04 13:42:18 UTC (rev 88149)
+++ projects/jboss-osgi/trunk/bundle/jmx/pom.xml 2009-05-04 13:56:01 UTC (rev 88150)
@@ -63,6 +63,9 @@
<Bundle-Activator>org.jboss.osgi.jmx.ServiceActivator</Bundle-Activator>
<Import-Package>
javax.management*,
+ javax.naming,
+ javax.naming.spi,
+ org.jboss.net.sockets,
org.jboss.osgi.common.log,
org.osgi.framework;version=1.4,
org.osgi.service.log,
Modified: projects/jboss-osgi/trunk/bundle/jmx/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 13:42:18 UTC (rev 88149)
+++ projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/ServiceActivator.java 2009-05-04 13:56:01 UTC (rev 88150)
@@ -38,24 +38,26 @@
*/
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";
-
+ 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";
+
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();
- }
+
+ 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";
+
+ conService = new JMXConnectorService(context, mbs, jndiHost, Integer.parseInt(jndiRmiPort));
+ conService.start();
}
public void stop(BundleContext context)
Modified: projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/internal/JMXConnectorService.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/internal/JMXConnectorService.java 2009-05-04 13:42:18 UTC (rev 88149)
+++ projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/internal/JMXConnectorService.java 2009-05-04 13:56:01 UTC (rev 88150)
@@ -24,12 +24,21 @@
//$Id$
import java.io.IOException;
+import java.net.InetAddress;
+import java.rmi.RemoteException;
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
import javax.management.MBeanServer;
+import javax.management.MBeanServerConnection;
import javax.management.remote.JMXConnectorServer;
import javax.management.remote.JMXConnectorServerFactory;
import javax.management.remote.JMXServiceURL;
+import javax.naming.InitialContext;
+import javax.naming.Reference;
+import javax.naming.StringRefAddr;
+import org.jboss.net.sockets.DefaultSocketFactory;
import org.jboss.osgi.common.log.LogServiceTracker;
import org.osgi.framework.BundleContext;
import org.osgi.service.log.LogService;
@@ -46,34 +55,76 @@
private JMXServiceURL conURL;
private JMXConnectorServer conServer;
- public JMXConnectorService(BundleContext context, MBeanServer mbs, String jmxHost, String jmxPort)
+ public JMXConnectorService(BundleContext context, MBeanServer mbeanServer, String host, int rmiPort)
{
log = new LogServiceTracker(context);
+ String jmxConnectorServerPath = "/jmxconnector";
+ String rmiAdaptorPath = "jmx/invoker/RMIAdaptor";
+
try
{
- conURL = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://" + jmxHost + ":" + jmxPort + "/server");
- conServer = JMXConnectorServerFactory.newJMXConnectorServer(conURL, null, mbs);
+ InetAddress bindAddress = InetAddress.getByName(host);
+
+ // check to see if registry already created
+ Registry rmiRegistry = LocateRegistry.getRegistry(host, rmiPort);
+ if (rmiRegistry != null)
+ {
+ try
+ {
+ rmiRegistry.list();
+ }
+ catch (RemoteException e)
+ {
+ log.log(LogService.LOG_DEBUG, "No registry running at host '" + host + "', port '" + rmiPort + "'. Will create one.");
+ rmiRegistry = LocateRegistry.createRegistry(rmiPort, null, new DefaultSocketFactory(bindAddress));
+ }
+ }
+ else
+ {
+ rmiRegistry = LocateRegistry.createRegistry(rmiPort, null, new DefaultSocketFactory(bindAddress));
+ }
+
+ String serviceURL = "service:jmx:rmi://" + host + "/jndi/rmi://" + host + ":" + rmiPort + jmxConnectorServerPath;
+ JMXServiceURL url = new JMXServiceURL(serviceURL);
+
+ // create new connector server and start it
+ conServer = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbeanServer);
+
+ log.log(LogService.LOG_DEBUG, "JMX Connector created: " + serviceURL);
+
+ // Bind an ObjectFactory that creates the MBeanServerConnection
+ InitialContext iniCtx = new InitialContext();
+ iniCtx.createSubcontext("jmx").createSubcontext("invoker");
+ StringRefAddr addr = new StringRefAddr(JMXServiceURL.class.getName(), serviceURL);
+ Reference ref = new Reference(MBeanServerConnection.class.getName(), addr, RMIAdaptorFactory.class.getName(), null);
+ iniCtx.bind(rmiAdaptorPath, ref);
+
+ log.log(LogService.LOG_INFO, "MBeanServerConnection bound: " + rmiAdaptorPath);
}
- catch (IOException ex)
+ catch (RuntimeException rte)
{
- log.log(LogService.LOG_ERROR, "Cannot create JMXConnectorServer", ex);
+ throw rte;
}
+ catch (Exception ex)
+ {
+ log.log(LogService.LOG_ERROR, "Cannot create JMXConnector", ex);
+ }
}
public void start()
{
if (conServer == null)
- throw new IllegalStateException("JMXConnectorServer not available");
+ throw new IllegalStateException("JMXConnector not available");
try
{
conServer.start();
- log.log(LogService.LOG_DEBUG, "JMXConnector started: " + conURL);
+ log.log(LogService.LOG_INFO, "JMXConnector started: " + conURL);
}
catch (IOException ex)
{
- log.log(LogService.LOG_ERROR, "Cannot start JMXConnectorServer", ex);
+ log.log(LogService.LOG_ERROR, "Cannot start JMXConnector", ex);
}
}
@@ -86,7 +137,7 @@
}
catch (IOException ex)
{
- log.log(LogService.LOG_WARNING, "Cannot stop JMXConnectorServer", ex);
+ log.log(LogService.LOG_WARNING, "Cannot stop JMXConnector", ex);
}
}
}
\ No newline at end of file
Added: projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/internal/RMIAdaptor.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/internal/RMIAdaptor.java (rev 0)
+++ projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/internal/RMIAdaptor.java 2009-05-04 13:56:01 UTC (rev 88150)
@@ -0,0 +1,183 @@
+/**
+ *
+ */
+package org.jboss.osgi.jmx.internal;
+
+import java.io.IOException;
+import java.io.Serializable;
+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.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.JMXServiceURL;
+
+public class RMIAdaptor implements MBeanServerConnection, Serializable
+{
+ private static final long serialVersionUID = 6066226353118090215L;
+
+ 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);
+ }
+
+ @SuppressWarnings("unchecked")
+ public Set queryMBeans(ObjectName name, QueryExp query) throws IOException
+ {
+ return delegate.queryMBeans(name, query);
+ }
+
+ @SuppressWarnings("unchecked")
+ 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
Property changes on: projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/internal/RMIAdaptor.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/internal/RMIAdaptorFactory.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/internal/RMIAdaptorFactory.java (rev 0)
+++ projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/internal/RMIAdaptorFactory.java 2009-05-04 13:56:01 UTC (rev 88150)
@@ -0,0 +1,30 @@
+/**
+ *
+ */
+package org.jboss.osgi.jmx.internal;
+
+// $Id$
+
+import java.io.Serializable;
+import java.util.Hashtable;
+
+import javax.management.remote.JMXServiceURL;
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.RefAddr;
+import javax.naming.Reference;
+import javax.naming.spi.ObjectFactory;
+
+public class RMIAdaptorFactory implements ObjectFactory, Serializable
+{
+ private static final long serialVersionUID = 2560477127430087074L;
+
+ public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment) throws Exception
+ {
+ Reference ref = (Reference)obj;
+ RefAddr refAddr = ref.get(JMXServiceURL.class.getName());
+ String serviceURL = (String)refAddr.getContent();
+ JMXServiceURL url = new JMXServiceURL(serviceURL);
+ return new RMIAdaptor(url);
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/internal/RMIAdaptorFactory.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/junit/OSGiTestSetup.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/junit/OSGiTestSetup.java 2009-05-04 13:42:18 UTC (rev 88149)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/junit/OSGiTestSetup.java 2009-05-04 13:56:01 UTC (rev 88150)
@@ -31,6 +31,9 @@
import org.jboss.logging.Logger;
import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
import org.jboss.virtual.VFS;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
/**
* An OSGi Test Setup
@@ -100,4 +103,9 @@
{
return delegate.getTestArchiveFile(archive).toURI().toURL();
}
+
+ public Bundle installBundle(BundleContext sysContext, String bundlePath, boolean start) throws BundleException
+ {
+ return delegate.installBundle(sysContext, bundlePath, start);
+ }
}
17 years, 2 months
JBoss-OSGI SVN: r88147 - projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jmx.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-05-04 09:17:32 -0400 (Mon, 04 May 2009)
New Revision: 88147
Modified:
projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jmx/JMXTestCase.java
Log:
bind/lookup of MBeanServerConnection ok
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 13:13:34 UTC (rev 88146)
+++ projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jmx/JMXTestCase.java 2009-05-04 13:17:32 UTC (rev 88147)
@@ -24,7 +24,11 @@
//$Id$
import java.io.IOException;
+import java.io.Serializable;
+import java.net.InetAddress;
+import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
import java.util.Hashtable;
import java.util.Set;
@@ -56,15 +60,23 @@
import javax.naming.Context;
import javax.naming.InitialContext;
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.osgi.jndi.internal.JNPServer;
+import org.jboss.logging.Logger;
+import org.jboss.net.sockets.DefaultSocketFactory;
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.interfaces.Naming;
import org.jnp.server.Main;
+import org.jnp.server.NamingBean;
+import org.jnp.server.NamingServer;
import org.osgi.framework.BundleContext;
/**
@@ -75,51 +87,114 @@
*/
public class JMXTestCase extends BlueprintTest
{
- public void _testJMXConnector() throws Exception
+ private static final Logger log = Logger.getLogger(JMXTestCase.class);
+
+ private Main namingMain;
+ private Naming namingServer;
+
+ public void testJMXConnector() throws Exception
{
// Get the MBeanServer and register an MBean
- MBeanServer mbs = getMBeanServer();
+ MBeanServer mbeanServer = getMBeanServer();
ObjectName oname = new ObjectName("jboss.osgi:service=mbean-test-service");
- mbs.registerMBean(new Foo(), oname);
-
+ mbeanServer.registerMBean(new Foo(), oname);
+
// Access the MBean
- FooMBean foo = (FooMBean)MBeanProxy.get(FooMBean.class, oname, getMBeanServer());
+ FooMBean foo = (FooMBean)MBeanProxy.get(FooMBean.class, oname, mbeanServer);
assertEquals("hello", foo.echo("hello"));
-
- Main namingMain = new Main();
+
+ 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;
+ }
+ };
+
+ // the address to expose in the urls
+ String host = System.getProperty("java.rmi.server.hostname");
+ if (host == null)
+ host = "localhost";
+
+ String jndiPath = "/jmxconnector";
+ InetAddress bindAddress = InetAddress.getByName(host);
+ int rmiPort = 1098;
+
+ namingMain = new Main();
+ namingMain.setNamingInfo(namingBean);
+ namingMain.setBindAddress(host);
+ namingMain.setRmiPort(rmiPort);
+ namingMain.setPort(1099);
+
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);
+ // check to see if registry already created
+ Registry rmiRegistry = LocateRegistry.getRegistry(host, rmiPort);
+ if (rmiRegistry != null)
+ {
+ try
+ {
+ rmiRegistry.list();
+ }
+ catch (RemoteException e)
+ {
+ log.debug("No registry running at host '" + host + "', port '" + rmiPort + "'. Will create one.");
+ rmiRegistry = LocateRegistry.createRegistry(rmiPort, null, new DefaultSocketFactory(bindAddress));
+ }
+ }
+ else
+ {
+ rmiRegistry = LocateRegistry.createRegistry(rmiPort, null, new DefaultSocketFactory(bindAddress));
+ }
+
+ String serviceURL = "service:jmx:rmi://" + host + "/jndi/rmi://" + host + ":" + rmiPort + jndiPath;
+
+ final JMXServiceURL url = new JMXServiceURL(serviceURL);
+
+ // create new connector server and start it
+ JMXConnectorServer connectorServer = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbeanServer);
+ connectorServer.start();
+
+ log.info("JMX Connector server: " + serviceURL);
+
+ // Bind the ObjectFactory that creates the MBeanServerConnection
InitialContext iniCtx = new InitialContext();
- iniCtx.bind("jmx/invoker/RMIAdaptor", new RMIAdaptorFactory(url));
- //MBeanServerConnection rmiAdaptor = mbsc; //(MBeanServerConnection)iniCtx.lookup("jmx/invoker/RMIAdaptor");
-
+ iniCtx.createSubcontext("jmx").createSubcontext("invoker");
+ StringRefAddr addr = new StringRefAddr(JMXServiceURL.class.getName(), serviceURL);
+ Reference ref = new Reference(MBeanServerConnection.class.getName(), addr, RMIAdaptorFactory.class.getName(), null);
+ iniCtx.bind("jmx/invoker/RMIAdaptor", ref);
+
+ // Lookup the MBeanServerConnection
+ MBeanServerConnection rmiAdaptor = (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"));
+ rmiAdaptor.unregisterMBean(oname);
}
-
+
public void testMBeanAccess() throws Exception
{
OSGiFramework framework = getBootstrapProvider().getFramework();
-
+
try
{
BundleContext sysContext = framework.getSystemBundleContext();
-
+
installBundle(sysContext, "jmx-test.jar", true);
-
+
ObjectName oname = new ObjectName("jboss.osgi:service=mbean-test-service");
FooMBean foo = (FooMBean)MBeanProxy.get(FooMBean.class, oname, getMBeanServer());
assertEquals("hello", foo.echo("hello"));
@@ -129,32 +204,33 @@
framework.stop();
}
}
-
- static class RMIAdaptorFactory implements ObjectFactory
+
+ public static class RMIAdaptorFactory implements ObjectFactory, Serializable
{
- private JMXServiceURL url;
-
- public RMIAdaptorFactory(JMXServiceURL url)
- {
- this.url = url;
- }
+ private static final long serialVersionUID = 2560477127430087074L;
public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment) throws Exception
{
+ Reference ref = (Reference)obj;
+ RefAddr refAddr = ref.get(JMXServiceURL.class.getName());
+ String serviceURL = (String)refAddr.getContent();
+ JMXServiceURL url = new JMXServiceURL(serviceURL);
return new RMIAdaptor(url);
}
}
-
- static class RMIAdaptor implements MBeanServerConnection
+
+ public static class RMIAdaptor implements MBeanServerConnection, Serializable
{
+ private static final long serialVersionUID = 6066226353118090215L;
+
private MBeanServerConnection delegate;
public RMIAdaptor(JMXServiceURL url) throws IOException
{
- JMXConnector jmxc = JMXConnectorFactory.connect(url, null);
- delegate = jmxc.getMBeanServerConnection();
+ JMXConnector jmxc = JMXConnectorFactory.connect(url, null);
+ delegate = jmxc.getMBeanServerConnection();
}
-
+
public void addNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback)
throws InstanceNotFoundException, IOException
{
17 years, 2 months
JBoss-OSGI SVN: r88144 - in projects/jboss-osgi/trunk: bundle and 12 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)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(a)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(a)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(a)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(a)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(a)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(a)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(a)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>
17 years, 2 months