[jboss-osgi-commits] JBoss-OSGI SVN: r89530 - in projects/jboss-osgi/trunk: bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal and 14 other directories.
jboss-osgi-commits at lists.jboss.org
jboss-osgi-commits at lists.jboss.org
Fri May 29 10:09:22 EDT 2009
Author: thomas.diesler at jboss.com
Date: 2009-05-29 10:09:21 -0400 (Fri, 29 May 2009)
New Revision: 89530
Added:
projects/jboss-osgi/trunk/bundles/jmx/src/main/java/org/jboss/osgi/jmx/internal/JMXServiceActivator.java
projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/jmx/internal/ManagementServiceBean.java
projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/jndi/internal/NamingServiceBean.java
projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/microcontainer/internal/MicrocontainerServiceBean.java
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/management/ManagedBundle.java
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/management/ManagedFramework.java
Removed:
projects/jboss-osgi/trunk/bundles/jmx/src/main/java/org/jboss/osgi/jmx/internal/MBeanServerServiceActivator.java
projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/jmx/internal/ManagementServiceImpl.java
projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/jndi/internal/NamingServiceImpl.java
projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/microcontainer/internal/MicrocontainerServiceImpl.java
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/management/ManagedBundle.java
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/management/ManagedFramework.java
Modified:
projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/service/DeployerService.java
projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/SimpleDeployerService.java
projects/jboss-osgi/trunk/bundles/jmx/pom.xml
projects/jboss-osgi/trunk/bundles/jmx/src/main/java/org/jboss/osgi/jmx/internal/MBeanServerService.java
projects/jboss-osgi/trunk/bundles/microcontainer/src/main/java/org/jboss/osgi/microcontainer/MicrocontainerServiceMBean.java
projects/jboss-osgi/trunk/bundles/microcontainer/src/main/resources/META-INF/base-deployers-beans.xml
projects/jboss-osgi/trunk/distribution/runtime/conf/jboss-osgi-felix.properties
projects/jboss-osgi/trunk/distribution/runtime/conf/log4j.xml
projects/jboss-osgi/trunk/distribution/src/main/resources/installer/install-definition.xml
projects/jboss-osgi/trunk/runtime/equinox/src/main/resources/osgi-deployers-jboss-beans.xml
projects/jboss-osgi/trunk/runtime/felix/src/main/resources/osgi-deployers-jboss-beans.xml
projects/jboss-osgi/trunk/runtime/knopflerfish/src/main/resources/osgi-deployers-jboss-beans.xml
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/framework/OSGiBootstrap.java
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/management/ManagedServiceReference.java
Log:
WIP
Modified: projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/service/DeployerService.java
===================================================================
--- projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/service/DeployerService.java 2009-05-29 13:51:03 UTC (rev 89529)
+++ projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/service/DeployerService.java 2009-05-29 14:09:21 UTC (rev 89530)
@@ -21,6 +21,8 @@
*/
package org.jboss.osgi.common.service;
+import java.net.URL;
+
//$Id$
@@ -42,4 +44,14 @@
* Undeploy an array of bundles
*/
void undeploy(BundleInfo[] bundles) throws Exception;
+
+ /**
+ * Deploy MC beans from URL
+ */
+ void deploy(URL url) throws Exception;
+
+ /**
+ * Undeploy MC beans from URL
+ */
+ void undeploy(URL url) throws Exception;
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/SimpleDeployerService.java
===================================================================
--- projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/SimpleDeployerService.java 2009-05-29 13:51:03 UTC (rev 89529)
+++ projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/SimpleDeployerService.java 2009-05-29 14:09:21 UTC (rev 89530)
@@ -23,8 +23,12 @@
//$Id$
+import java.net.URI;
+import java.net.URL;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import org.jboss.osgi.common.log.LogServiceTracker;
import org.jboss.osgi.common.service.BundleInfo;
@@ -44,6 +48,8 @@
{
private LogServiceTracker log;
private BundleContext context;
+
+ private Map<URI, Bundle> urlDeployments = new HashMap<URI, Bundle>();
public SimpleDeployerService(BundleContext context)
{
@@ -104,6 +110,24 @@
}
}
+ public void deploy(URL url) throws Exception
+ {
+ log.log(LogService.LOG_DEBUG, "Install: " + url);
+ Bundle bundle = context.installBundle(url.toExternalForm());
+ urlDeployments.put(url.toURI(), bundle);
+ bundle.start();
+ }
+
+ public void undeploy(URL url) throws Exception
+ {
+ Bundle bundle = urlDeployments.remove(url.toURI());
+ if (bundle != null)
+ {
+ log.log(LogService.LOG_DEBUG, "Uninstall: " + bundle.getSymbolicName());
+ bundle.uninstall();
+ }
+ }
+
public static Bundle getInstalledBundle(BundleContext context, BundleInfo bundleInfo)
{
Bundle bundle = null;
Modified: projects/jboss-osgi/trunk/bundles/jmx/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/bundles/jmx/pom.xml 2009-05-29 13:51:03 UTC (rev 89529)
+++ projects/jboss-osgi/trunk/bundles/jmx/pom.xml 2009-05-29 14:09:21 UTC (rev 89530)
@@ -57,7 +57,7 @@
<configuration>
<instructions>
<Bundle-SymbolicName>${artifactId}</Bundle-SymbolicName>
- <Bundle-Activator>org.jboss.osgi.jmx.internal.MBeanServerServiceActivator</Bundle-Activator>
+ <Bundle-Activator>org.jboss.osgi.jmx.internal.JMXServiceActivator</Bundle-Activator>
<Import-Package>
<!-- system -->
@@ -67,6 +67,7 @@
<!-- jboss-osgi -->
org.jboss.osgi.common.log;version="1.0",
+ org.jboss.osgi.spi.management;version="1.0",
<!-- osgi -->
org.osgi.framework;version=1.4,
Copied: projects/jboss-osgi/trunk/bundles/jmx/src/main/java/org/jboss/osgi/jmx/internal/JMXServiceActivator.java (from rev 89521, projects/jboss-osgi/trunk/bundles/jmx/src/main/java/org/jboss/osgi/jmx/internal/MBeanServerServiceActivator.java)
===================================================================
--- projects/jboss-osgi/trunk/bundles/jmx/src/main/java/org/jboss/osgi/jmx/internal/JMXServiceActivator.java (rev 0)
+++ projects/jboss-osgi/trunk/bundles/jmx/src/main/java/org/jboss/osgi/jmx/internal/JMXServiceActivator.java 2009-05-29 14:09:21 UTC (rev 89530)
@@ -0,0 +1,170 @@
+/*
+ * 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.spi.management.ManagedFramework;
+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 at jboss.com
+ * @since 24-Apr-2009
+ */
+public class JMXServiceActivator 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 jmxConnector;
+ private String jmxHost;
+ private String jmxRmiPort;
+ private String rmiAdaptorPath;
+ private MBeanServer mbeanServer;
+
+ private LogService log;
+
+ public void start(BundleContext context)
+ {
+ log = new LogServiceTracker(context);
+
+ MBeanServerService mbeanService = new MBeanServerService(context);
+ mbeanServer = mbeanService.getMBeanServer();
+
+ // Register the MBeanServer
+ context.registerService(MBeanServer.class.getName(), mbeanServer, null);
+ log.log(LogService.LOG_DEBUG, "MBeanServer registered");
+
+ // Register the ManagedFramework
+ new ManagedFramework(context, mbeanServer).start();
+
+ jmxHost = context.getProperty(REMOTE_JMX_HOST);
+ if (jmxHost == null)
+ jmxHost = "localhost";
+
+ jmxRmiPort = context.getProperty(REMOTE_JMX_RMI_PORT);
+ if (jmxRmiPort == null)
+ jmxRmiPort = "1098";
+
+ rmiAdaptorPath = context.getProperty(REMOTE_JMX_RMI_ADAPTOR);
+ if (rmiAdaptorPath == null)
+ rmiAdaptorPath = "jmx/invoker/RMIAdaptor";
+
+ // Start tracking the NamingService
+ InitialContextTracker tracker = new InitialContextTracker(context, rmiAdaptorPath);
+ tracker.open();
+ }
+
+ public void stop(BundleContext context)
+ {
+ stopJMXConnectorService();
+ }
+
+ private void stopJMXConnectorService()
+ {
+ if (jmxConnector != null)
+ {
+ jmxConnector.stop();
+ jmxConnector = null;
+ }
+ }
+
+ class InitialContextTracker extends ServiceTracker
+ {
+ private String rmiAdaptorPath;
+
+ public InitialContextTracker(BundleContext context, String rmiAdaptorPath)
+ {
+ super(context, InitialContext.class.getName(), null);
+ this.rmiAdaptorPath = rmiAdaptorPath;
+ }
+
+ @Override
+ public Object addingService(ServiceReference reference)
+ {
+ InitialContext iniCtx = (InitialContext)super.addingService(reference);
+
+ // Start JMXConnectorService
+ if (jmxConnector == null)
+ {
+ jmxConnector = new JMXConnectorService(context, mbeanServer, jmxHost, Integer.parseInt(jmxRmiPort));
+ jmxConnector.start();
+ }
+
+ // Bind the RMIAdaptor
+ try
+ {
+ iniCtx.createSubcontext("jmx").createSubcontext("invoker");
+ 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);
+
+ log.log(LogService.LOG_INFO, "MBeanServerConnection bound to: " + rmiAdaptorPath);
+ }
+ catch (NamingException ex)
+ {
+ log.log(LogService.LOG_ERROR, "Cannot bind RMIAdaptor", ex);
+ }
+
+ return iniCtx;
+ }
+
+ @Override
+ public void removedService(ServiceReference reference, Object service)
+ {
+ InitialContext iniCtx = (InitialContext)service;
+
+ // Stop JMXConnectorService
+ stopJMXConnectorService();
+
+ // Unbind the RMIAdaptor
+ try
+ {
+ iniCtx.unbind(rmiAdaptorPath);
+
+ log.log(LogService.LOG_INFO, "MBeanServerConnection unbound from: " + rmiAdaptorPath);
+ }
+ catch (NamingException ex)
+ {
+ log.log(LogService.LOG_ERROR, "Cannot unbind RMIAdaptor", ex);
+ }
+
+ super.removedService(reference, service);
+ }
+ }
+}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/bundles/jmx/src/main/java/org/jboss/osgi/jmx/internal/MBeanServerService.java
===================================================================
--- projects/jboss-osgi/trunk/bundles/jmx/src/main/java/org/jboss/osgi/jmx/internal/MBeanServerService.java 2009-05-29 13:51:03 UTC (rev 89529)
+++ projects/jboss-osgi/trunk/bundles/jmx/src/main/java/org/jboss/osgi/jmx/internal/MBeanServerService.java 2009-05-29 14:09:21 UTC (rev 89530)
@@ -68,9 +68,6 @@
log.log(LogService.LOG_DEBUG, "No MBeanServer, create one ...");
mbeanServer = MBeanServerFactory.createMBeanServer();
}
-
- log.log(LogService.LOG_DEBUG, "Register MBeanServer");
- context.registerService(MBeanServer.class.getName(), mbeanServer, null);
}
}
Deleted: projects/jboss-osgi/trunk/bundles/jmx/src/main/java/org/jboss/osgi/jmx/internal/MBeanServerServiceActivator.java
===================================================================
--- projects/jboss-osgi/trunk/bundles/jmx/src/main/java/org/jboss/osgi/jmx/internal/MBeanServerServiceActivator.java 2009-05-29 13:51:03 UTC (rev 89529)
+++ projects/jboss-osgi/trunk/bundles/jmx/src/main/java/org/jboss/osgi/jmx/internal/MBeanServerServiceActivator.java 2009-05-29 14:09:21 UTC (rev 89530)
@@ -1,162 +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 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.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 at jboss.com
- * @since 24-Apr-2009
- */
-public class MBeanServerServiceActivator 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 jmxConnector;
- private String jmxHost;
- private String jmxRmiPort;
- private String rmiAdaptorPath;
- private MBeanServer mbanServer;
-
- private LogService log;
-
- public void start(BundleContext context)
- {
- log = new LogServiceTracker(context);
-
- MBeanServerService mbeanService = new MBeanServerService(context);
- mbanServer = mbeanService.getMBeanServer();
-
- jmxHost = context.getProperty(REMOTE_JMX_HOST);
- if (jmxHost == null)
- jmxHost = "localhost";
-
- jmxRmiPort = context.getProperty(REMOTE_JMX_RMI_PORT);
- if (jmxRmiPort == null)
- jmxRmiPort = "1098";
-
- rmiAdaptorPath = context.getProperty(REMOTE_JMX_RMI_ADAPTOR);
- if (rmiAdaptorPath == null)
- rmiAdaptorPath = "jmx/invoker/RMIAdaptor";
-
- // Start tracking the NamingService
- InitialContextTracker tracker = new InitialContextTracker(context, rmiAdaptorPath);
- tracker.open();
- }
-
- public void stop(BundleContext context)
- {
- stopJMXConnectorService();
- }
-
- private void stopJMXConnectorService()
- {
- if (jmxConnector != null)
- {
- jmxConnector.stop();
- jmxConnector = null;
- }
- }
-
- class InitialContextTracker extends ServiceTracker
- {
- private String rmiAdaptorPath;
-
- public InitialContextTracker(BundleContext context, String rmiAdaptorPath)
- {
- super(context, InitialContext.class.getName(), null);
- this.rmiAdaptorPath = rmiAdaptorPath;
- }
-
- @Override
- public Object addingService(ServiceReference reference)
- {
- InitialContext iniCtx = (InitialContext)super.addingService(reference);
-
- // Start JMXConnectorService
- if (jmxConnector == null)
- {
- jmxConnector = new JMXConnectorService(context, mbanServer, jmxHost, Integer.parseInt(jmxRmiPort));
- jmxConnector.start();
- }
-
- // Bind the RMIAdaptor
- try
- {
- iniCtx.createSubcontext("jmx").createSubcontext("invoker");
- 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);
-
- log.log(LogService.LOG_INFO, "MBeanServerConnection bound to: " + rmiAdaptorPath);
- }
- catch (NamingException ex)
- {
- log.log(LogService.LOG_ERROR, "Cannot bind RMIAdaptor", ex);
- }
-
- return iniCtx;
- }
-
- @Override
- public void removedService(ServiceReference reference, Object service)
- {
- InitialContext iniCtx = (InitialContext)service;
-
- // Stop JMXConnectorService
- stopJMXConnectorService();
-
- // Unbind the RMIAdaptor
- try
- {
- iniCtx.unbind(rmiAdaptorPath);
-
- log.log(LogService.LOG_INFO, "MBeanServerConnection unbound from: " + rmiAdaptorPath);
- }
- catch (NamingException ex)
- {
- log.log(LogService.LOG_ERROR, "Cannot unbind RMIAdaptor", ex);
- }
-
- super.removedService(reference, service);
- }
- }
-}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/bundles/microcontainer/src/main/java/org/jboss/osgi/microcontainer/MicrocontainerServiceMBean.java
===================================================================
--- projects/jboss-osgi/trunk/bundles/microcontainer/src/main/java/org/jboss/osgi/microcontainer/MicrocontainerServiceMBean.java 2009-05-29 13:51:03 UTC (rev 89529)
+++ projects/jboss-osgi/trunk/bundles/microcontainer/src/main/java/org/jboss/osgi/microcontainer/MicrocontainerServiceMBean.java 2009-05-29 14:09:21 UTC (rev 89530)
@@ -23,7 +23,6 @@
//$Id$
-import java.net.URL;
import java.util.List;
import javax.management.ObjectName;
@@ -47,14 +46,4 @@
* Get the list of registered beans.
*/
List<String> getRegisteredBeans();
-
- /**
- * Deploy MC beans from URL
- */
- void deploy(URL url) throws Exception;
-
- /**
- * Undeploy MC beans from URL
- */
- void undeploy(URL url) throws Exception;
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/bundles/microcontainer/src/main/resources/META-INF/base-deployers-beans.xml
===================================================================
--- projects/jboss-osgi/trunk/bundles/microcontainer/src/main/resources/META-INF/base-deployers-beans.xml 2009-05-29 13:51:03 UTC (rev 89529)
+++ projects/jboss-osgi/trunk/bundles/microcontainer/src/main/resources/META-INF/base-deployers-beans.xml 2009-05-29 14:09:21 UTC (rev 89530)
@@ -77,12 +77,6 @@
<!-- OSGi Deployment -->
- <!-- The Framework Management -->
- <bean name="jboss.osgi:service=ManagedFramework" class="org.jboss.osgi.spi.management.ManagedFramework">
- <property name="systemContext"><inject bean="jboss.osgi:service=BundleContext" /></property>
- <property name="mbeanServer"><inject bean="jboss.osgi:service=MBeanServer"/></property>
- </bean>
-
<bean name="BundleMetaDataDeployer" class="org.jboss.osgi.deployer.BundleMetaDataDeployer" />
<bean name="BundleStructureDeployer" class="org.jboss.osgi.deployer.BundleStructureDeployer" />
<bean name="BundleRealDeployer" class="org.jboss.osgi.deployer.BundleRealDeployer">
Modified: projects/jboss-osgi/trunk/distribution/runtime/conf/jboss-osgi-felix.properties
===================================================================
--- projects/jboss-osgi/trunk/distribution/runtime/conf/jboss-osgi-felix.properties 2009-05-29 13:51:03 UTC (rev 89529)
+++ projects/jboss-osgi/trunk/distribution/runtime/conf/jboss-osgi-felix.properties 2009-05-29 14:09:21 UTC (rev 89530)
@@ -8,17 +8,17 @@
org.jboss.osgi.spi.framework.impl=org.jboss.osgi.felix.framework.FelixIntegration
# Properties to configure the Framework
-org.osgi.framework.storage=${osgi.home}/server/${jboss.server.name}/data/osgi-store
+org.osgi.framework.storage=${osgi.server.home}/data/osgi-store
org.osgi.framework.storage.clean=onFirstInit
# Hot Deployement
-org.jboss.osgi.hotdeploy.scandir=${osgi.home}/server/${jboss.server.name}/bundles
+org.jboss.osgi.hotdeploy.scandir=${osgi.server.home}/bundles
# HTTP Service Port
org.osgi.service.http.port=8090
# Config Admin Service
-felix.cm.dir=${osgi.home}/server/${jboss.server.name}/data/osgi-configadmin
+felix.cm.dir=${osgi.server.home}/data/osgi-configadmin
# JMX bundle properties
org.jboss.osgi.jmx.host=${jboss.bind.address}
Modified: projects/jboss-osgi/trunk/distribution/runtime/conf/log4j.xml
===================================================================
--- projects/jboss-osgi/trunk/distribution/runtime/conf/log4j.xml 2009-05-29 13:51:03 UTC (rev 89529)
+++ projects/jboss-osgi/trunk/distribution/runtime/conf/log4j.xml 2009-05-29 14:09:21 UTC (rev 89530)
@@ -8,7 +8,7 @@
<!-- ================================= -->
<appender name="FILE" class="org.apache.log4j.FileAppender">
- <param name="File" value="${osgi.home}/server/${jboss.server.name}/log/server.log"/>
+ <param name="File" value="${osgi.server.home}/log/server.log"/>
<param name="Append" value="false"/>
<layout class="org.apache.log4j.PatternLayout">
<!-- The default pattern: Date Priority [Category] Message\n -->
Modified: projects/jboss-osgi/trunk/distribution/src/main/resources/installer/install-definition.xml
===================================================================
--- projects/jboss-osgi/trunk/distribution/src/main/resources/installer/install-definition.xml 2009-05-29 13:51:03 UTC (rev 89529)
+++ projects/jboss-osgi/trunk/distribution/src/main/resources/installer/install-definition.xml 2009-05-29 14:09:21 UTC (rev 89530)
@@ -183,6 +183,9 @@
</fileset>
<fileset dir="@{deploy.artifacts.dir}/lib" targetdir="$INSTALL_PATH/runtime/server/default/bundles" override="true">
+ <include name="jboss-osgi-common-core.jar" />
+ <include name="jboss-osgi-jmx.jar" />
+ <include name="jboss-osgi-jndi.jar" />
<include name="jboss-osgi-webconsole.jar" />
<include name="org.apache.felix.configadmin.jar" />
<include name="org.apache.felix.http.jetty.jar" />
@@ -191,10 +194,10 @@
<fileset dir="@{deploy.artifacts.dir}/lib" targetdir="$INSTALL_PATH/runtime/server/all/bundles" override="true">
<include name="jboss-osgi-apache-xerces.jar" />
+ <include name="jboss-osgi-common-core.jar" />
<include name="jboss-osgi-jaxb.jar" />
- <include name="jboss-osgi-common-core.jar" />
+ <include name="jboss-osgi-jmx.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" />
<include name="jboss-osgi-xml-binding.jar" />
Copied: projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/jmx/internal/ManagementServiceBean.java (from rev 89516, projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/jmx/internal/ManagementServiceImpl.java)
===================================================================
--- projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/jmx/internal/ManagementServiceBean.java (rev 0)
+++ projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/jmx/internal/ManagementServiceBean.java 2009-05-29 14:09:21 UTC (rev 89530)
@@ -0,0 +1,55 @@
+/*
+ * 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 org.osgi.framework.BundleContext;
+
+/**
+ * A service that gives access to the MBeanServer
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 24-Apr-2009
+ */
+public class ManagementServiceBean
+{
+ private MBeanServer mbeanServer;
+ private BundleContext context;
+
+ public void setSystemContext(BundleContext context)
+ {
+ this.context = context;
+ }
+
+ public void setMbeanServer(MBeanServer mbeanServer)
+ {
+ this.mbeanServer = mbeanServer;
+ }
+
+ public void start()
+ {
+ context.registerService(MBeanServer.class.getName(), mbeanServer, null);
+ }
+}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/jmx/internal/ManagementServiceImpl.java
===================================================================
--- projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/jmx/internal/ManagementServiceImpl.java 2009-05-29 13:51:03 UTC (rev 89529)
+++ projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/jmx/internal/ManagementServiceImpl.java 2009-05-29 14:09:21 UTC (rev 89530)
@@ -1,55 +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 javax.management.MBeanServer;
-
-import org.osgi.framework.BundleContext;
-
-/**
- * A service that gives access to the MBeanServer
- *
- * @author thomas.diesler at jboss.com
- * @since 24-Apr-2009
- */
-public class ManagementServiceImpl
-{
- private MBeanServer mbeanServer;
- private BundleContext context;
-
- public void setSystemContext(BundleContext context)
- {
- this.context = context;
- }
-
- public void setMbeanServer(MBeanServer mbeanServer)
- {
- this.mbeanServer = mbeanServer;
- }
-
- public void start()
- {
- context.registerService(MBeanServer.class.getName(), mbeanServer, null);
- }
-}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/jndi/internal/NamingServiceBean.java (from rev 89516, projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/jndi/internal/NamingServiceImpl.java)
===================================================================
--- projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/jndi/internal/NamingServiceBean.java (rev 0)
+++ projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/jndi/internal/NamingServiceBean.java 2009-05-29 14:09:21 UTC (rev 89530)
@@ -0,0 +1,58 @@
+/*
+ * 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.osgi.framework.BundleContext;
+
+/**
+ * A service that gives access to JNDI
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 05-May-2009
+ */
+public class NamingServiceBean
+{
+ private BundleContext context;
+
+ public void setSystemContext(BundleContext context)
+ {
+ this.context = context;
+ }
+
+ public void start()
+ {
+ try
+ {
+ InitialContext initialContext = new InitialContext();
+ context.registerService(InitialContext.class.getName(), initialContext, null);
+ }
+ catch (NamingException ex)
+ {
+ throw new IllegalStateException("Cannot register InitialContext", ex);
+ }
+ }
+}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/jndi/internal/NamingServiceImpl.java
===================================================================
--- projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/jndi/internal/NamingServiceImpl.java 2009-05-29 13:51:03 UTC (rev 89529)
+++ projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/jndi/internal/NamingServiceImpl.java 2009-05-29 14:09:21 UTC (rev 89530)
@@ -1,58 +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.internal;
-
-//$Id$
-
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
-import org.osgi.framework.BundleContext;
-
-/**
- * A service that gives access to JNDI
- *
- * @author thomas.diesler at jboss.com
- * @since 05-May-2009
- */
-public class NamingServiceImpl
-{
- private BundleContext context;
-
- public void setSystemContext(BundleContext context)
- {
- this.context = context;
- }
-
- public void start()
- {
- try
- {
- InitialContext initialContext = new InitialContext();
- context.registerService(InitialContext.class.getName(), initialContext, null);
- }
- catch (NamingException ex)
- {
- throw new IllegalStateException("Cannot register InitialContext", ex);
- }
- }
-}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/microcontainer/internal/MicrocontainerServiceBean.java (from rev 89516, projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/microcontainer/internal/MicrocontainerServiceImpl.java)
===================================================================
--- projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/microcontainer/internal/MicrocontainerServiceBean.java (rev 0)
+++ projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/microcontainer/internal/MicrocontainerServiceBean.java 2009-05-29 14:09:21 UTC (rev 89530)
@@ -0,0 +1,145 @@
+/*
+ * 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.microcontainer.internal;
+
+//$Id$
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import javax.management.StandardMBean;
+
+import org.jboss.dependency.plugins.AbstractController;
+import org.jboss.dependency.plugins.AbstractControllerContext;
+import org.jboss.dependency.plugins.AbstractControllerContextActions;
+import org.jboss.dependency.plugins.action.ControllerContextAction;
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.dependency.spi.ControllerContextActions;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.osgi.microcontainer.MicrocontainerService;
+import org.jboss.osgi.microcontainer.MicrocontainerServiceMBean;
+import org.osgi.framework.BundleContext;
+
+/**
+ * A service the gives access to the Microcontainer.
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 05-May-2009
+ */
+public class MicrocontainerServiceBean implements MicrocontainerService, MicrocontainerServiceMBean
+{
+ private BundleContext context;
+ private MBeanServer mbeanServer;
+ private Kernel kernel;
+
+ public void setSystemContext(BundleContext context)
+ {
+ this.context = context;
+ }
+
+ public void setMbeanServer(MBeanServer mbeanServer)
+ {
+ this.mbeanServer = mbeanServer;
+ }
+
+ public void setKernel(Kernel kernel)
+ {
+ this.kernel = kernel;
+ }
+
+ public void deploy(URL url) throws Exception
+ {
+ invokeMainDeployer("deploy", url);
+ }
+
+ public void undeploy(URL url) throws Exception
+ {
+ invokeMainDeployer("undeploy", url);
+ }
+
+ private void invokeMainDeployer(String method, URL archiveURL) throws Exception
+ {
+ ObjectName oname = new ObjectName("jboss.system:service=MainDeployer");
+ mbeanServer.invoke(oname, method, new Object[] { archiveURL }, new String[] { "java.net.URL" });
+ }
+
+ public Kernel getKernel()
+ {
+ return kernel;
+ }
+
+ public List<String> getRegisteredBeans()
+ {
+ List<String> names = new ArrayList<String>();
+
+ AbstractController controller = (AbstractController)getKernel().getController();
+ for (ControllerContext ctx : controller.getAllContexts())
+ {
+ if (ctx instanceof KernelControllerContext || ctx instanceof PreInstalledControllerContext)
+ names.add(ctx.getName().toString());
+ }
+
+ return names;
+ }
+
+ public Object getRegisteredBean(String beanName)
+ {
+ ControllerContext context = getKernel().getController().getInstalledContext(beanName);
+ return context != null ? context.getTarget() : null;
+ }
+
+ public void start()
+ {
+ context.registerService(MicrocontainerService.class.getName(), this, null);
+
+ try
+ {
+ KernelController controller = kernel.getController();
+ ControllerContextActions actions = new AbstractControllerContextActions(new HashMap<ControllerState, ControllerContextAction>());
+ controller.install(new PreInstalledControllerContext(BEAN_SYSTEM_BUNDLE_CONTEXT, actions, context));
+ controller.install(new PreInstalledControllerContext(BEAN_MBEAN_SERVER, actions, mbeanServer));
+ controller.install(new PreInstalledControllerContext(BEAN_KERNEL, actions, kernel));
+
+ StandardMBean mbean = new StandardMBean(this, MicrocontainerServiceMBean.class);
+ mbeanServer.registerMBean(mbean, MicrocontainerServiceMBean.MBEAN_MICROCONTAINER_SERVICE);
+ }
+ catch (Throwable ex)
+ {
+ throw new IllegalStateException("Cannot register MicrocontainerServiceMBean", ex);
+ }
+ }
+
+ static class PreInstalledControllerContext extends AbstractControllerContext
+ {
+ public PreInstalledControllerContext(Object name, ControllerContextActions actions, Object target)
+ {
+ super(name, actions, null, target);
+ }
+ }
+}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/microcontainer/internal/MicrocontainerServiceImpl.java
===================================================================
--- projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/microcontainer/internal/MicrocontainerServiceImpl.java 2009-05-29 13:51:03 UTC (rev 89529)
+++ projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/microcontainer/internal/MicrocontainerServiceImpl.java 2009-05-29 14:09:21 UTC (rev 89530)
@@ -1,145 +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.microcontainer.internal;
-
-//$Id$
-
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-import javax.management.StandardMBean;
-
-import org.jboss.dependency.plugins.AbstractController;
-import org.jboss.dependency.plugins.AbstractControllerContext;
-import org.jboss.dependency.plugins.AbstractControllerContextActions;
-import org.jboss.dependency.plugins.action.ControllerContextAction;
-import org.jboss.dependency.spi.ControllerContext;
-import org.jboss.dependency.spi.ControllerContextActions;
-import org.jboss.dependency.spi.ControllerState;
-import org.jboss.kernel.Kernel;
-import org.jboss.kernel.spi.dependency.KernelController;
-import org.jboss.kernel.spi.dependency.KernelControllerContext;
-import org.jboss.osgi.microcontainer.MicrocontainerService;
-import org.jboss.osgi.microcontainer.MicrocontainerServiceMBean;
-import org.osgi.framework.BundleContext;
-
-/**
- * A service the gives access to the Microcontainer.
- *
- * @author thomas.diesler at jboss.com
- * @since 05-May-2009
- */
-public class MicrocontainerServiceImpl implements MicrocontainerService, MicrocontainerServiceMBean
-{
- private BundleContext context;
- private MBeanServer mbeanServer;
- private Kernel kernel;
-
- public void setSystemContext(BundleContext context)
- {
- this.context = context;
- }
-
- public void setMbeanServer(MBeanServer mbeanServer)
- {
- this.mbeanServer = mbeanServer;
- }
-
- public void setKernel(Kernel kernel)
- {
- this.kernel = kernel;
- }
-
- public void deploy(URL url) throws Exception
- {
- invokeMainDeployer("deploy", url);
- }
-
- public void undeploy(URL url) throws Exception
- {
- invokeMainDeployer("undeploy", url);
- }
-
- private void invokeMainDeployer(String method, URL archiveURL) throws Exception
- {
- ObjectName oname = new ObjectName("jboss.system:service=MainDeployer");
- mbeanServer.invoke(oname, method, new Object[] { archiveURL }, new String[] { "java.net.URL" });
- }
-
- public Kernel getKernel()
- {
- return kernel;
- }
-
- public List<String> getRegisteredBeans()
- {
- List<String> names = new ArrayList<String>();
-
- AbstractController controller = (AbstractController)getKernel().getController();
- for (ControllerContext ctx : controller.getAllContexts())
- {
- if (ctx instanceof KernelControllerContext || ctx instanceof PreInstalledControllerContext)
- names.add(ctx.getName().toString());
- }
-
- return names;
- }
-
- public Object getRegisteredBean(String beanName)
- {
- ControllerContext context = getKernel().getController().getInstalledContext(beanName);
- return context != null ? context.getTarget() : null;
- }
-
- public void start()
- {
- context.registerService(MicrocontainerService.class.getName(), this, null);
-
- try
- {
- KernelController controller = kernel.getController();
- ControllerContextActions actions = new AbstractControllerContextActions(new HashMap<ControllerState, ControllerContextAction>());
- controller.install(new PreInstalledControllerContext(BEAN_SYSTEM_BUNDLE_CONTEXT, actions, context));
- controller.install(new PreInstalledControllerContext(BEAN_MBEAN_SERVER, actions, mbeanServer));
- controller.install(new PreInstalledControllerContext(BEAN_KERNEL, actions, kernel));
-
- StandardMBean mbean = new StandardMBean(this, MicrocontainerServiceMBean.class);
- mbeanServer.registerMBean(mbean, MicrocontainerServiceMBean.MBEAN_MICROCONTAINER_SERVICE);
- }
- catch (Throwable ex)
- {
- throw new IllegalStateException("Cannot register MicrocontainerServiceMBean", ex);
- }
- }
-
- static class PreInstalledControllerContext extends AbstractControllerContext
- {
- public PreInstalledControllerContext(Object name, ControllerContextActions actions, Object target)
- {
- super(name, actions, null, target);
- }
- }
-}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/runtime/equinox/src/main/resources/osgi-deployers-jboss-beans.xml
===================================================================
--- projects/jboss-osgi/trunk/runtime/equinox/src/main/resources/osgi-deployers-jboss-beans.xml 2009-05-29 13:51:03 UTC (rev 89529)
+++ projects/jboss-osgi/trunk/runtime/equinox/src/main/resources/osgi-deployers-jboss-beans.xml 2009-05-29 14:09:21 UTC (rev 89530)
@@ -74,19 +74,19 @@
-->
<!-- A Service that gives access to the Microcontainer -->
- <bean name="jboss.osgi:service=Microcontainer" class="org.jboss.osgi.microcontainer.internal.MicrocontainerServiceImpl">
+ <bean name="jboss.osgi:service=Microcontainer" class="org.jboss.osgi.microcontainer.internal.MicrocontainerServiceBean">
<property name="systemContext"><inject bean="jboss.osgi:service=Framework" property="bundleContext"/></property>
<property name="mbeanServer"><inject bean="JMXKernel" property="mbeanServer"/></property>
<property name="kernel"><inject bean="jboss.kernel:service=Kernel" /></property>
</bean>
<!-- A Service that gives access to JNDI -->
- <bean name="jboss.osgi:service=Naming" class="org.jboss.osgi.jndi.internal.NamingServiceImpl">
+ <bean name="jboss.osgi:service=Naming" class="org.jboss.osgi.jndi.internal.NamingServiceBean">
<property name="systemContext"><inject bean="jboss.osgi:service=Framework" property="bundleContext"/></property>
</bean>
<!-- A Service that gives access to the MBeanServer -->
- <bean name="jboss.osgi:service=Management" class="org.jboss.osgi.jmx.internal.ManagementServiceImpl">
+ <bean name="jboss.osgi:service=Management" class="org.jboss.osgi.jmx.internal.ManagementServiceBean">
<property name="systemContext"><inject bean="jboss.osgi:service=Framework" property="bundleContext"/></property>
<property name="mbeanServer"><inject bean="JMXKernel" property="mbeanServer"/></property>
</bean>
Modified: projects/jboss-osgi/trunk/runtime/felix/src/main/resources/osgi-deployers-jboss-beans.xml
===================================================================
--- projects/jboss-osgi/trunk/runtime/felix/src/main/resources/osgi-deployers-jboss-beans.xml 2009-05-29 13:51:03 UTC (rev 89529)
+++ projects/jboss-osgi/trunk/runtime/felix/src/main/resources/osgi-deployers-jboss-beans.xml 2009-05-29 14:09:21 UTC (rev 89530)
@@ -87,19 +87,19 @@
-->
<!-- A Service that gives access to the Microcontainer -->
- <bean name="jboss.osgi:service=Microcontainer" class="org.jboss.osgi.microcontainer.internal.MicrocontainerServiceImpl">
+ <bean name="jboss.osgi:service=Microcontainer" class="org.jboss.osgi.microcontainer.internal.MicrocontainerServiceBean">
<property name="systemContext"><inject bean="jboss.osgi:service=Framework" property="bundleContext"/></property>
<property name="mbeanServer"><inject bean="JMXKernel" property="mbeanServer"/></property>
<property name="kernel"><inject bean="jboss.kernel:service=Kernel" /></property>
</bean>
<!-- A Service that gives access to JNDI -->
- <bean name="jboss.osgi:service=Naming" class="org.jboss.osgi.jndi.internal.NamingServiceImpl">
+ <bean name="jboss.osgi:service=Naming" class="org.jboss.osgi.jndi.internal.NamingServiceBean">
<property name="systemContext"><inject bean="jboss.osgi:service=Framework" property="bundleContext"/></property>
</bean>
<!-- A Service that gives access to the MBeanServer -->
- <bean name="jboss.osgi:service=Management" class="org.jboss.osgi.jmx.internal.ManagementServiceImpl">
+ <bean name="jboss.osgi:service=Management" class="org.jboss.osgi.jmx.internal.ManagementServiceBean">
<property name="systemContext"><inject bean="jboss.osgi:service=Framework" property="bundleContext"/></property>
<property name="mbeanServer"><inject bean="JMXKernel" property="mbeanServer"/></property>
</bean>
Modified: projects/jboss-osgi/trunk/runtime/knopflerfish/src/main/resources/osgi-deployers-jboss-beans.xml
===================================================================
--- projects/jboss-osgi/trunk/runtime/knopflerfish/src/main/resources/osgi-deployers-jboss-beans.xml 2009-05-29 13:51:03 UTC (rev 89529)
+++ projects/jboss-osgi/trunk/runtime/knopflerfish/src/main/resources/osgi-deployers-jboss-beans.xml 2009-05-29 14:09:21 UTC (rev 89530)
@@ -73,19 +73,19 @@
-->
<!-- A Service that gives access to the Microcontainer -->
- <bean name="jboss.osgi:service=Microcontainer" class="org.jboss.osgi.microcontainer.internal.MicrocontainerServiceImpl">
+ <bean name="jboss.osgi:service=Microcontainer" class="org.jboss.osgi.microcontainer.internal.MicrocontainerServiceBean">
<property name="systemContext"><inject bean="jboss.osgi:service=Framework" property="bundleContext"/></property>
<property name="mbeanServer"><inject bean="JMXKernel" property="mbeanServer"/></property>
<property name="kernel"><inject bean="jboss.kernel:service=Kernel" /></property>
</bean>
<!-- A Service that gives access to JNDI -->
- <bean name="jboss.osgi:service=Naming" class="org.jboss.osgi.jndi.internal.NamingServiceImpl">
+ <bean name="jboss.osgi:service=Naming" class="org.jboss.osgi.jndi.internal.NamingServiceBean">
<property name="systemContext"><inject bean="jboss.osgi:service=Framework" property="bundleContext"/></property>
</bean>
<!-- A Service that gives access to the MBeanServer -->
- <bean name="jboss.osgi:service=Management" class="org.jboss.osgi.jmx.internal.ManagementServiceImpl">
+ <bean name="jboss.osgi:service=Management" class="org.jboss.osgi.jmx.internal.ManagementServiceBean">
<property name="systemContext"><inject bean="jboss.osgi:service=Framework" property="bundleContext"/></property>
<property name="mbeanServer"><inject bean="JMXKernel" property="mbeanServer"/></property>
</bean>
Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/framework/OSGiBootstrap.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/framework/OSGiBootstrap.java 2009-05-29 13:51:03 UTC (rev 89529)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/framework/OSGiBootstrap.java 2009-05-29 14:09:21 UTC (rev 89530)
@@ -57,7 +57,9 @@
private static final String JAVA_PROTOCOL_HANDLERS = "java.protocol.handler.pkgs";
private static final String JBOSS_BIND_ADDRESS = "jboss.bind.address";
- private static final String JBOSS_SERVER_NAME = "jboss.server.name";
+ private static final String OSGI_SERVER_NAME = "osgi.server.name";
+ private static final String OSGI_SERVER_HOME = "osgi.server.home";
+ private static final String OSGI_HOME = "osgi.home";
@Option(name = "-c", aliases = { "--server-name" }, usage = "Sets the server config (-c minimal)")
public String serverName = "default";
@@ -65,6 +67,9 @@
@Option(name = "-b", aliases = { "--bind-address" }, usage = "Sets the bind address (-b 127.0.0.1)")
public String bindAdress = "localhost";
+ private String osgiHome;
+ private String osgiServerHome;
+
/*
* The main entry point
*/
@@ -100,12 +105,20 @@
private void initSystemProperties()
{
+ osgiHome = System.getProperty(OSGI_HOME);
+ if (osgiHome == null)
+ throw new IllegalStateException("Cannot obtain system property: '" + OSGI_HOME + "'");
+
+ osgiServerHome = osgiHome + "/server/" + serverName;
+
Properties defaults = new Properties();
- defaults.setProperty(JBOSS_SERVER_NAME, serverName);
+ defaults.setProperty(OSGI_SERVER_NAME, serverName);
+ defaults.setProperty(OSGI_SERVER_HOME, osgiServerHome);
defaults.setProperty(JBOSS_BIND_ADDRESS, bindAdress);
defaults.setProperty(JAVA_PROTOCOL_HANDLERS, "org.jboss.net.protocol|org.jboss.virtual.protocol");
getLogger().debug("JBoss OSGi System Properties");
+ getLogger().debug(" " + OSGI_SERVER_HOME + "=" + osgiServerHome);
Enumeration<?> defaultNames = defaults.propertyNames();
while (defaultNames.hasMoreElements())
@@ -125,7 +138,7 @@
{
if (log == null)
{
- System.setProperty(JBOSS_SERVER_NAME, serverName);
+ System.setProperty(OSGI_SERVER_HOME, osgiServerHome);
log = Logger.getLogger(OSGiBootstrap.class);
}
return log;
Deleted: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/management/ManagedBundle.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/management/ManagedBundle.java 2009-05-29 13:51:03 UTC (rev 89529)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/management/ManagedBundle.java 2009-05-29 14:09:21 UTC (rev 89530)
@@ -1,102 +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.spi.management;
-
-//$Id$
-
-import java.util.Dictionary;
-import java.util.Enumeration;
-import java.util.Hashtable;
-
-import javax.management.ObjectName;
-
-import org.jboss.osgi.spi.Constants;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleException;
-
-/**
- * The managed view of an OSGi Bundle
- *
- * @author thomas.diesler at jboss.com
- * @since 23-Jan-2009
- */
-public class ManagedBundle implements ManagedBundleMBean
-{
- private Bundle bundle;
- private ObjectName oname;
-
- public ManagedBundle(Bundle bundle)
- {
- this.bundle = bundle;
- this.oname = ObjectNameFactory.create(Constants.DOMAIN_NAME + ":bundle=" + bundle.getSymbolicName() + ",id=" + bundle.getBundleId());
- }
-
- public ObjectName getObjectName()
- {
- return oname;
- }
-
- public String getProperty(String key)
- {
- return bundle.getBundleContext().getProperty(key);
- }
-
- public int getState()
- {
- return bundle.getState();
- }
-
- public long getBundleId()
- {
- return bundle.getBundleId();
- }
-
- public String getSymbolicName()
- {
- return bundle.getSymbolicName();
- }
-
- @SuppressWarnings("unchecked")
- public Dictionary<String, String> getHeaders()
- {
- Hashtable<String, String> retHeaders = new Hashtable<String, String>();
- Dictionary bundleHeaders = bundle.getHeaders();
- Enumeration keys = bundleHeaders.keys();
- while(keys.hasMoreElements())
- {
- String key = (String)keys.nextElement();
- String value = (String)bundleHeaders.get(key);
- retHeaders.put(key, value);
- }
- return retHeaders;
- }
-
- public void start() throws BundleException
- {
- bundle.start();
- }
-
- public void stop() throws BundleException
- {
- bundle.stop();
- }
-}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/management/ManagedBundle.java (from rev 89516, projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/management/ManagedBundle.java)
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/management/ManagedBundle.java (rev 0)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/management/ManagedBundle.java 2009-05-29 14:09:21 UTC (rev 89530)
@@ -0,0 +1,102 @@
+/*
+ * 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.spi.management;
+
+//$Id$
+
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.Hashtable;
+
+import javax.management.ObjectName;
+
+import org.jboss.osgi.spi.Constants;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
+
+/**
+ * The managed view of an OSGi Bundle
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 23-Jan-2009
+ */
+public class ManagedBundle implements ManagedBundleMBean
+{
+ private Bundle bundle;
+ private ObjectName oname;
+
+ public ManagedBundle(Bundle bundle)
+ {
+ this.bundle = bundle;
+ this.oname = ObjectNameFactory.create(Constants.DOMAIN_NAME + ":bundle=" + bundle.getSymbolicName() + ",id=" + bundle.getBundleId());
+ }
+
+ public ObjectName getObjectName()
+ {
+ return oname;
+ }
+
+ public String getProperty(String key)
+ {
+ return bundle.getBundleContext().getProperty(key);
+ }
+
+ public int getState()
+ {
+ return bundle.getState();
+ }
+
+ public long getBundleId()
+ {
+ return bundle.getBundleId();
+ }
+
+ public String getSymbolicName()
+ {
+ return bundle.getSymbolicName();
+ }
+
+ @SuppressWarnings("unchecked")
+ public Dictionary<String, String> getHeaders()
+ {
+ Hashtable<String, String> retHeaders = new Hashtable<String, String>();
+ Dictionary bundleHeaders = bundle.getHeaders();
+ Enumeration keys = bundleHeaders.keys();
+ while(keys.hasMoreElements())
+ {
+ String key = (String)keys.nextElement();
+ String value = (String)bundleHeaders.get(key);
+ retHeaders.put(key, value);
+ }
+ return retHeaders;
+ }
+
+ public void start() throws BundleException
+ {
+ bundle.start();
+ }
+
+ public void stop() throws BundleException
+ {
+ bundle.stop();
+ }
+}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/management/ManagedFramework.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/management/ManagedFramework.java 2009-05-29 13:51:03 UTC (rev 89529)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/management/ManagedFramework.java 2009-05-29 14:09:21 UTC (rev 89530)
@@ -1,183 +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.spi.management;
-
-//$Id$
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-import javax.management.QueryExp;
-
-import org.jboss.logging.Logger;
-import org.jboss.osgi.spi.Constants;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.packageadmin.PackageAdmin;
-
-/**
- * The managed view of an OSGi Framework
- *
- * @author thomas.diesler at jboss.com
- * @since 04-Mar-2009
- */
-public class ManagedFramework implements ManagedFrameworkMBean
-{
- // Provide logging
- final Logger log = Logger.getLogger(ManagedFramework.class);
-
- private MBeanServer mbeanServer;
- private BundleContext systemContext;
-
- public void setMbeanServer(MBeanServer server)
- {
- this.mbeanServer = server;
- }
-
- public void setSystemContext(BundleContext systemContext)
- {
- this.systemContext = systemContext;
- }
-
- @SuppressWarnings("unchecked")
- public ObjectName getBundle(String symbolicName)
- {
- ObjectName pattern = ObjectNameFactory.create(Constants.DOMAIN_NAME + ":bundle=" + symbolicName + ",*");
- Set<ObjectName> names = mbeanServer.queryNames(pattern, null);
-
- if (names.size() < 1)
- return null;
-
- if (names.size() > 1)
- throw new IllegalArgumentException("Multiple bundles found: " + names);
-
- return names.iterator().next();
- }
-
- @SuppressWarnings("unchecked")
- public Set<ObjectName> getBundles()
- {
- // [JBAS-6571] JMX filtering does not work with wildcards
- // ObjectName pattern = ObjectNameFactory.create(Constants.DOMAIN_NAME + ":bundle=*,*");
- // Set<ObjectName> names = mbeanServer.queryNames(pattern, null);
-
- ObjectName pattern = ObjectNameFactory.create(Constants.DOMAIN_NAME + ":*");
- Set<ObjectName> names = mbeanServer.queryNames(pattern, new IsBundleQueryExp());
- return names;
- }
-
- public ManagedServiceReference getServiceReference(String clazz)
- {
- ManagedServiceReference manref = null;
- ServiceReference sref = systemContext.getServiceReference(clazz);
- if (sref != null)
- {
- Map<String, Object> props = new HashMap<String, Object>();
- for (String key : sref.getPropertyKeys())
- props.put(key, sref.getProperty(key));
-
- manref = new ManagedServiceReference(clazz, props);
- }
- return manref;
- }
-
- public ManagedServiceReference[] getServiceReferences(String clazz, String filter) throws InvalidSyntaxException
- {
- List<ManagedServiceReference> foundRefs = new ArrayList<ManagedServiceReference>();
- ServiceReference[] srefs = systemContext.getServiceReferences(clazz, filter);
- if (srefs != null)
- {
- for (ServiceReference sref : srefs)
- {
- Map<String, Object> props = new HashMap<String, Object>();
- for (String key : sref.getPropertyKeys())
- props.put(key, sref.getProperty(key));
-
- foundRefs.add(new ManagedServiceReference(clazz, props));
- }
- }
-
- ManagedServiceReference[] manrefs = null;
- if (foundRefs.size() > 0)
- manrefs = foundRefs.toArray(new ManagedServiceReference[foundRefs.size()]);
-
- return manrefs;
- }
-
- public void refreshPackages(String[] symbolicNames)
- {
- ServiceReference sref = systemContext.getServiceReference(PackageAdmin.class.getName());
- PackageAdmin service = (PackageAdmin)systemContext.getService(sref);
-
- Bundle[] bundles = null;
- if (symbolicNames != null)
- {
- List<String> nameList = Arrays.asList(symbolicNames);
- Set<Bundle> bundleSet = new HashSet<Bundle>();
- for (Bundle bundle : systemContext.getBundles())
- {
- if (nameList.contains(bundle.getSymbolicName()))
- bundleSet.add(bundle);
- }
- bundles = new Bundle[bundleSet.size()];
- bundleSet.toArray(bundles);
- }
- service.refreshPackages(bundles);
- }
-
- public void start()
- {
- try
- {
- if (mbeanServer != null)
- mbeanServer.registerMBean(this, ManagedFrameworkMBean.MBEAN_MANAGED_FRAMEWORK);
- }
- catch (Exception ex)
- {
- log.warn("Cannot register: " + ManagedFrameworkMBean.MBEAN_MANAGED_FRAMEWORK);
- }
- }
-
- // Accept names like "jboss.osgi:bundle=*"
- static class IsBundleQueryExp implements QueryExp
- {
- private static final long serialVersionUID = 1L;
-
- public boolean apply(ObjectName name)
- {
- return name.getKeyProperty("bundle") != null;
- }
-
- public void setMBeanServer(MBeanServer server)
- {
- }
- }
-}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/management/ManagedFramework.java (from rev 89516, projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/management/ManagedFramework.java)
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/management/ManagedFramework.java (rev 0)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/management/ManagedFramework.java 2009-05-29 14:09:21 UTC (rev 89530)
@@ -0,0 +1,193 @@
+/*
+ * 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.spi.management;
+
+//$Id$
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import javax.management.QueryExp;
+
+import org.jboss.logging.Logger;
+import org.jboss.osgi.spi.Constants;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.packageadmin.PackageAdmin;
+
+/**
+ * The managed view of an OSGi Framework
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 04-Mar-2009
+ */
+public class ManagedFramework implements ManagedFrameworkMBean
+{
+ // Provide logging
+ final Logger log = Logger.getLogger(ManagedFramework.class);
+
+ private MBeanServer mbeanServer;
+ private BundleContext systemContext;
+
+ public ManagedFramework(BundleContext systemContext, MBeanServer mbeanServer)
+ {
+ this.systemContext = systemContext;
+ this.mbeanServer = mbeanServer;
+ }
+
+ public ManagedFramework()
+ {
+ }
+
+ public void setMbeanServer(MBeanServer server)
+ {
+ this.mbeanServer = server;
+ }
+
+ public void setSystemContext(BundleContext systemContext)
+ {
+ this.systemContext = systemContext;
+ }
+
+ @SuppressWarnings("unchecked")
+ public ObjectName getBundle(String symbolicName)
+ {
+ ObjectName pattern = ObjectNameFactory.create(Constants.DOMAIN_NAME + ":bundle=" + symbolicName + ",*");
+ Set<ObjectName> names = mbeanServer.queryNames(pattern, null);
+
+ if (names.size() < 1)
+ return null;
+
+ if (names.size() > 1)
+ throw new IllegalArgumentException("Multiple bundles found: " + names);
+
+ return names.iterator().next();
+ }
+
+ @SuppressWarnings("unchecked")
+ public Set<ObjectName> getBundles()
+ {
+ // [JBAS-6571] JMX filtering does not work with wildcards
+ // ObjectName pattern = ObjectNameFactory.create(Constants.DOMAIN_NAME + ":bundle=*,*");
+ // Set<ObjectName> names = mbeanServer.queryNames(pattern, null);
+
+ ObjectName pattern = ObjectNameFactory.create(Constants.DOMAIN_NAME + ":*");
+ Set<ObjectName> names = mbeanServer.queryNames(pattern, new IsBundleQueryExp());
+ return names;
+ }
+
+ public ManagedServiceReference getServiceReference(String clazz)
+ {
+ ManagedServiceReference manref = null;
+ ServiceReference sref = systemContext.getServiceReference(clazz);
+ if (sref != null)
+ {
+ Map<String, Object> props = new HashMap<String, Object>();
+ for (String key : sref.getPropertyKeys())
+ props.put(key, sref.getProperty(key));
+
+ manref = new ManagedServiceReference(clazz, props);
+ }
+ return manref;
+ }
+
+ public ManagedServiceReference[] getServiceReferences(String clazz, String filter) throws InvalidSyntaxException
+ {
+ List<ManagedServiceReference> foundRefs = new ArrayList<ManagedServiceReference>();
+ ServiceReference[] srefs = systemContext.getServiceReferences(clazz, filter);
+ if (srefs != null)
+ {
+ for (ServiceReference sref : srefs)
+ {
+ Map<String, Object> props = new HashMap<String, Object>();
+ for (String key : sref.getPropertyKeys())
+ props.put(key, sref.getProperty(key));
+
+ foundRefs.add(new ManagedServiceReference(clazz, props));
+ }
+ }
+
+ ManagedServiceReference[] manrefs = null;
+ if (foundRefs.size() > 0)
+ manrefs = foundRefs.toArray(new ManagedServiceReference[foundRefs.size()]);
+
+ return manrefs;
+ }
+
+ public void refreshPackages(String[] symbolicNames)
+ {
+ ServiceReference sref = systemContext.getServiceReference(PackageAdmin.class.getName());
+ PackageAdmin service = (PackageAdmin)systemContext.getService(sref);
+
+ Bundle[] bundles = null;
+ if (symbolicNames != null)
+ {
+ List<String> nameList = Arrays.asList(symbolicNames);
+ Set<Bundle> bundleSet = new HashSet<Bundle>();
+ for (Bundle bundle : systemContext.getBundles())
+ {
+ if (nameList.contains(bundle.getSymbolicName()))
+ bundleSet.add(bundle);
+ }
+ bundles = new Bundle[bundleSet.size()];
+ bundleSet.toArray(bundles);
+ }
+ service.refreshPackages(bundles);
+ }
+
+ public void start()
+ {
+ try
+ {
+ if (mbeanServer != null)
+ mbeanServer.registerMBean(this, ManagedFrameworkMBean.MBEAN_MANAGED_FRAMEWORK);
+ }
+ catch (Exception ex)
+ {
+ log.warn("Cannot register: " + ManagedFrameworkMBean.MBEAN_MANAGED_FRAMEWORK);
+ }
+ }
+
+ // Accept names like "jboss.osgi:bundle=*"
+ static class IsBundleQueryExp implements QueryExp
+ {
+ private static final long serialVersionUID = 1L;
+
+ public boolean apply(ObjectName name)
+ {
+ return name.getKeyProperty("bundle") != null;
+ }
+
+ public void setMBeanServer(MBeanServer server)
+ {
+ }
+ }
+}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/management/ManagedServiceReference.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/management/ManagedServiceReference.java 2009-05-29 13:51:03 UTC (rev 89529)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/management/ManagedServiceReference.java 2009-05-29 14:09:21 UTC (rev 89530)
@@ -21,6 +21,7 @@
*/
package org.jboss.osgi.spi.management;
+import java.io.Serializable;
import java.util.Map;
import java.util.Set;
@@ -30,16 +31,23 @@
* @author Thomas.Diesler at jboss.org
* @since 25-Sep-2008
*/
-public class ManagedServiceReference
+public class ManagedServiceReference implements Serializable
{
- private String className;
+ private static final long serialVersionUID = 1L;
+
+ private String serviceInterface;
private Map<String, Object> props;
public ManagedServiceReference(String className, Map<String, Object> props)
{
- this.className = className;
+ this.serviceInterface = className;
}
+ public String getServiceInterface()
+ {
+ return serviceInterface;
+ }
+
public Object getProperty(String key)
{
return props.get(key);
More information about the jboss-osgi-commits
mailing list