JBoss-OSGI SVN: r101424 - in projects/jboss-osgi/projects: testing/trunk/src/main/java/org/jboss/osgi/testing/internal and 1 other directory.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-02-24 15:36:12 -0500 (Wed, 24 Feb 2010)
New Revision: 101424
Modified:
projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/BundleStateExt.java
projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteBundle.java
Log:
Allign return values & prevent NPEs
Modified: projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/BundleStateExt.java
===================================================================
--- projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/BundleStateExt.java 2010-02-24 20:25:46 UTC (rev 101423)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/BundleStateExt.java 2010-02-24 20:36:12 UTC (rev 101424)
@@ -93,7 +93,7 @@
{
BundleContext context = assertBundleContext(bundleId);
File dataFile = context.getDataFile(filename);
- return dataFile.getCanonicalPath();
+ return dataFile != null ? dataFile.getCanonicalPath() : null;
}
@Override
@@ -101,10 +101,18 @@
{
Bundle bundle = assertBundle(bundleId);
URL entry = bundle.getEntry(path);
- return entry.toExternalForm();
+ return entry != null ? entry.toExternalForm() : null;
}
@Override
+ public String getResource(long bundleId, String name) throws IOException
+ {
+ Bundle bundle = assertBundle(bundleId);
+ URL resource = bundle.getResource(name);
+ return resource != null ? resource.toExternalForm() : null;
+ }
+
+ @Override
@SuppressWarnings("unchecked")
public TabularData getHeaders(long bundleId, String locale) throws IOException
{
@@ -147,14 +155,6 @@
}
@Override
- public String getResource(long bundleId, String name) throws IOException
- {
- Bundle bundle = assertBundle(bundleId);
- URL entry = bundle.getResource(name);
- return entry.toExternalForm();
- }
-
- @Override
public long loadClass(long bundleId, String name) throws ClassNotFoundException, IOException
{
Bundle bundle = assertBundle(bundleId);
@@ -162,10 +162,7 @@
ServiceReference sref = context.getServiceReference(PackageAdmin.class.getName());
PackageAdmin service = (PackageAdmin)context.getService(sref);
Bundle exporter = service.getBundle(clazz);
- if (exporter == null)
- return 0;
-
- return exporter.getBundleId();
+ return exporter != null ? exporter.getBundleId() : 0;
}
public String[] getExportedPackages(long arg0) throws IOException
Modified: projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteBundle.java
===================================================================
--- projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteBundle.java 2010-02-24 20:25:46 UTC (rev 101423)
+++ projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteBundle.java 2010-02-24 20:36:12 UTC (rev 101424)
@@ -251,7 +251,8 @@
assertNotUninstalled();
try
{
- return new File(bundleState.getDataFile(bundleId, filename));
+ String filepath = bundleState.getDataFile(bundleId, filename);
+ return filepath != null ? new File(filepath) : null;
}
catch (IOException ex)
{
14 years, 3 months
JBoss-OSGI SVN: r101423 - projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-02-24 15:25:46 -0500 (Wed, 24 Feb 2010)
New Revision: 101423
Modified:
projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteBundle.java
Log:
Fix getHeaders(locale)
Modified: projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteBundle.java
===================================================================
--- projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteBundle.java 2010-02-24 20:20:28 UTC (rev 101422)
+++ projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteBundle.java 2010-02-24 20:25:46 UTC (rev 101423)
@@ -101,7 +101,7 @@
private Dictionary<String, String> getHeadersInternal(String locale) throws IOException
{
Dictionary<String, String> defaultHeaders = new Hashtable<String, String>();
- TabularData headers = bundleState.getHeaders(bundleId, null);
+ TabularData headers = bundleState.getHeaders(bundleId, locale);
for (CompositeData aux : (Collection<CompositeData>)headers.values())
{
String key = (String)aux.get(JmxConstants.KEY);
14 years, 3 months
JBoss-OSGI SVN: r101419 - in projects/jboss-osgi/projects: bundles/jmx/trunk/jmx-bundle and 3 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-02-24 15:18:06 -0500 (Wed, 24 Feb 2010)
New Revision: 101419
Added:
projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/AbstractState.java
projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/BundleStateExt.java
projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/FrameworkStateExt.java
projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/ServiceStateExt.java
Removed:
projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/AbstractStateMBean.java
projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/BundleState.java
projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/FrameworkState.java
projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/ManagedBundleTracker.java
projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/ServiceState.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/management/ManagedBundle.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/management/ManagedBundleMBean.java
Modified:
projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-api/src/main/java/org/jboss/osgi/jmx/BundleStateMBeanExt.java
projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/pom.xml
projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/JMXServiceActivator.java
projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteBundle.java
Log:
Migrate ManagedBundle to BundleStateMBean
Modified: projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-api/src/main/java/org/jboss/osgi/jmx/BundleStateMBeanExt.java
===================================================================
--- projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-api/src/main/java/org/jboss/osgi/jmx/BundleStateMBeanExt.java 2010-02-24 20:04:08 UTC (rev 101418)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-api/src/main/java/org/jboss/osgi/jmx/BundleStateMBeanExt.java 2010-02-24 20:18:06 UTC (rev 101419)
@@ -28,6 +28,7 @@
import javax.management.openmbean.CompositeData;
import javax.management.openmbean.TabularData;
+import org.osgi.jmx.JmxConstants;
import org.osgi.jmx.framework.BundleStateMBean;
/**
@@ -64,6 +65,19 @@
TabularData getHeaders(long bundleId, String locale) throws IOException;
/**
+ * Answer the map of properties associated with this bundle
+ *
+ * @see JmxConstants#PROPERTIES_TYPE for the details of the CompositeType
+ *
+ * @param bundleId the unique identifier of the bundle
+ * @param key The name of the requested property.
+ * @return the property data, or null if the property is undefined.
+ * @throws IOException if the operation fails
+ * @throws IllegalArgumentException if the bundle indicated does not exist
+ */
+ CompositeData getProperty(long bundleId, String key) throws IOException;
+
+ /**
* Loads the specified class using the class loader of the bundle with the given identifier.
*
* @param bundleId the unique identifier of the bundle
Modified: projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/pom.xml
===================================================================
--- projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/pom.xml 2010-02-24 20:04:08 UTC (rev 101418)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/pom.xml 2010-02-24 20:18:06 UTC (rev 101419)
@@ -127,7 +127,7 @@
<!-- osgi -->
org.osgi.framework;version="[1.5,2.0)",
- org.osgi.jmx.framework;version="[1.0,2.0)",
+ org.osgi.jmx*;version="[1.0,2.0)",
org.osgi.service.packageadmin;version="[1.2,2.0)",
org.osgi.util.tracker;version="[1.4,2.0)",
Copied: projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/AbstractState.java (from rev 101404, projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/AbstractStateMBean.java)
===================================================================
--- projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/AbstractState.java (rev 0)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/AbstractState.java 2010-02-24 20:18:06 UTC (rev 101419)
@@ -0,0 +1,120 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.jmx.internal;
+
+//$Id$
+
+import javax.management.JMException;
+import javax.management.MBeanServer;
+import javax.management.NotCompliantMBeanException;
+import javax.management.ObjectName;
+import javax.management.StandardMBean;
+
+import org.jboss.logging.Logger;
+import org.jboss.osgi.spi.management.MBeanProxy;
+import org.jboss.osgi.spi.management.ObjectNameFactory;
+import org.osgi.framework.BundleContext;
+import org.osgi.jmx.framework.BundleStateMBean;
+import org.osgi.jmx.framework.FrameworkMBean;
+import org.osgi.jmx.framework.ServiceStateMBean;
+
+/**
+ * An extension to {@link BundleStateMBean}.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 23-Feb-2010
+ */
+abstract class AbstractState
+{
+ // Provide logging
+ private static final Logger log = Logger.getLogger(AbstractState.class);
+
+ protected MBeanServer mbeanServer;
+ protected BundleContext context;
+
+ AbstractState(BundleContext context, MBeanServer mbeanServer)
+ {
+ if (context == null)
+ throw new IllegalArgumentException("Null BundleContext");
+ if (mbeanServer == null)
+ throw new IllegalArgumentException("Null MBeanServer");
+
+ if (context.getBundle().getBundleId() != 0)
+ throw new IllegalArgumentException("Not the system bundle context: " + context);
+
+ this.context = context;
+ this.mbeanServer = mbeanServer;
+ }
+
+ void start()
+ {
+ ObjectName objectName = getObjectName();
+ try
+ {
+ log.debug("Register: " + objectName);
+ mbeanServer.registerMBean(getStandardMBean(), objectName);
+ }
+ catch (JMException ex)
+ {
+ log.warn("Cannot register: " + objectName);
+ }
+ }
+
+ void stop()
+ {
+ ObjectName objectName = getObjectName();
+ try
+ {
+ if (mbeanServer.isRegistered(objectName))
+ {
+ log.debug("Unregister: " + objectName);
+ mbeanServer.unregisterMBean(objectName);
+ }
+ }
+ catch (JMException ex)
+ {
+ log.warn("Cannot unregister: " + objectName);
+ }
+ }
+
+ abstract StandardMBean getStandardMBean() throws NotCompliantMBeanException;
+
+ abstract ObjectName getObjectName();
+
+ FrameworkMBean getFrameworkMBean()
+ {
+ ObjectName objectName = ObjectNameFactory.create(FrameworkMBean.OBJECTNAME);
+ return MBeanProxy.get(mbeanServer, objectName, FrameworkMBean.class);
+ }
+
+ BundleStateMBean getBundleStateMBean()
+ {
+ ObjectName objectName = ObjectNameFactory.create(BundleStateMBean.OBJECTNAME);
+ return MBeanProxy.get(mbeanServer, objectName, BundleStateMBean.class);
+ }
+
+ ServiceStateMBean getServiceStateMBean()
+ {
+ ObjectName objectName = ObjectNameFactory.create(ServiceStateMBean.OBJECTNAME);
+ return MBeanProxy.get(mbeanServer, objectName, ServiceStateMBean.class);
+ }
+}
\ No newline at end of file
Deleted: projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/AbstractStateMBean.java
===================================================================
--- projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/AbstractStateMBean.java 2010-02-24 20:04:08 UTC (rev 101418)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/AbstractStateMBean.java 2010-02-24 20:18:06 UTC (rev 101419)
@@ -1,120 +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.JMException;
-import javax.management.MBeanServer;
-import javax.management.NotCompliantMBeanException;
-import javax.management.ObjectName;
-import javax.management.StandardMBean;
-
-import org.jboss.logging.Logger;
-import org.jboss.osgi.spi.management.MBeanProxy;
-import org.jboss.osgi.spi.management.ObjectNameFactory;
-import org.osgi.framework.BundleContext;
-import org.osgi.jmx.framework.BundleStateMBean;
-import org.osgi.jmx.framework.FrameworkMBean;
-import org.osgi.jmx.framework.ServiceStateMBean;
-
-/**
- * An extension to {@link BundleStateMBean}.
- *
- * @author thomas.diesler(a)jboss.com
- * @since 23-Feb-2010
- */
-abstract class AbstractStateMBean
-{
- // Provide logging
- private static final Logger log = Logger.getLogger(AbstractStateMBean.class);
-
- protected MBeanServer mbeanServer;
- protected BundleContext context;
-
- AbstractStateMBean(BundleContext context, MBeanServer mbeanServer)
- {
- if (context == null)
- throw new IllegalArgumentException("Null BundleContext");
- if (mbeanServer == null)
- throw new IllegalArgumentException("Null MBeanServer");
-
- if (context.getBundle().getBundleId() != 0)
- throw new IllegalArgumentException("Not the system bundle context: " + context);
-
- this.context = context;
- this.mbeanServer = mbeanServer;
- }
-
- void start()
- {
- ObjectName objectName = getObjectName();
- try
- {
- log.debug("Register: " + objectName);
- mbeanServer.registerMBean(getStandardMBean(), objectName);
- }
- catch (JMException ex)
- {
- log.warn("Cannot register: " + objectName);
- }
- }
-
- void stop()
- {
- ObjectName objectName = getObjectName();
- try
- {
- if (mbeanServer.isRegistered(objectName))
- {
- log.debug("Unregister: " + objectName);
- mbeanServer.unregisterMBean(objectName);
- }
- }
- catch (JMException ex)
- {
- log.warn("Cannot unregister: " + objectName);
- }
- }
-
- abstract StandardMBean getStandardMBean() throws NotCompliantMBeanException;
-
- abstract ObjectName getObjectName();
-
- FrameworkMBean getFrameworkMBean()
- {
- ObjectName objectName = ObjectNameFactory.create(FrameworkMBean.OBJECTNAME);
- return MBeanProxy.get(mbeanServer, objectName, FrameworkMBean.class);
- }
-
- BundleStateMBean getBundleStateMBean()
- {
- ObjectName objectName = ObjectNameFactory.create(BundleStateMBean.OBJECTNAME);
- return MBeanProxy.get(mbeanServer, objectName, BundleStateMBean.class);
- }
-
- ServiceStateMBean getServiceStateMBean()
- {
- ObjectName objectName = ObjectNameFactory.create(ServiceStateMBean.OBJECTNAME);
- return MBeanProxy.get(mbeanServer, objectName, ServiceStateMBean.class);
- }
-}
\ No newline at end of file
Deleted: projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/BundleState.java
===================================================================
--- projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/BundleState.java 2010-02-24 20:04:08 UTC (rev 101418)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/BundleState.java 2010-02-24 20:18:06 UTC (rev 101419)
@@ -1,309 +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.File;
-import java.io.IOException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Dictionary;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.management.JMRuntimeException;
-import javax.management.MBeanServer;
-import javax.management.NotCompliantMBeanException;
-import javax.management.ObjectName;
-import javax.management.StandardMBean;
-import javax.management.openmbean.CompositeData;
-import javax.management.openmbean.CompositeDataSupport;
-import javax.management.openmbean.OpenDataException;
-import javax.management.openmbean.TabularData;
-import javax.management.openmbean.TabularDataSupport;
-
-import org.jboss.osgi.jmx.BundleStateMBeanExt;
-import org.jboss.osgi.spi.management.ObjectNameFactory;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.jmx.framework.BundleStateMBean;
-import org.osgi.service.packageadmin.PackageAdmin;
-
-/**
- * An extension to {@link BundleStateMBean}.
- *
- * @author thomas.diesler(a)jboss.com
- * @since 23-Feb-2010
- */
-public class BundleState extends AbstractStateMBean implements BundleStateMBeanExt
-{
- public BundleState(BundleContext context, MBeanServer mbeanServer)
- {
- super(context, mbeanServer);
- }
-
- @Override
- ObjectName getObjectName()
- {
- return ObjectNameFactory.create(OBJECTNAME);
- }
-
- @Override
- StandardMBean getStandardMBean() throws NotCompliantMBeanException
- {
- return new StandardMBean(this, BundleStateMBeanExt.class);
- }
-
- @Override
- public CompositeData getBundle(long bundleId) throws IOException
- {
- TabularData bundleList = listBundles();
- CompositeData bundleData = bundleList.get(new Object[] { (Long)bundleId });
- if (bundleData == null)
- throw new IllegalArgumentException("No such bundle: " + bundleId);
- return bundleData;
- }
-
- @Override
- public String getDataFile(long bundleId, String filename) throws IOException
- {
- Bundle bundle = assertBundle(bundleId);
- File dataFile = bundle.getBundleContext().getDataFile(filename);
- return dataFile.getCanonicalPath();
- }
-
- @Override
- public String getEntry(long bundleId, String path) throws IOException
- {
- Bundle bundle = assertBundle(bundleId);
- URL entry = bundle.getEntry(path);
- return entry.toExternalForm();
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public TabularData getHeaders(long bundleId, String locale) throws IOException
- {
- Bundle bundle = assertBundle(bundleId);
- List<Header> headers = new ArrayList<Header>();
- Dictionary<String, String> bundleHeaders = bundle.getHeaders(locale);
- Enumeration<String> keys = bundleHeaders.keys();
- while (keys.hasMoreElements())
- {
- String key = keys.nextElement();
- headers.add(new Header(key, bundleHeaders.get(key)));
- }
- TabularData headerTable = new TabularDataSupport(HEADERS_TYPE);
- for (Header header : headers)
- {
- headerTable.put(header.toCompositeData());
- }
- return headerTable;
- }
-
- @Override
- public String getResource(long bundleId, String name) throws IOException
- {
- Bundle bundle = assertBundle(bundleId);
- URL entry = bundle.getResource(name);
- return entry.toExternalForm();
- }
-
- @Override
- public long loadClass(long bundleId, String name) throws ClassNotFoundException, IOException
- {
- Bundle bundle = assertBundle(bundleId);
- Class<?> clazz = bundle.loadClass(name);
- ServiceReference sref = context.getServiceReference(PackageAdmin.class.getName());
- PackageAdmin service = (PackageAdmin)context.getService(sref);
- Bundle exporter = service.getBundle(clazz);
- if (exporter == null)
- return 0;
-
- return exporter.getBundleId();
- }
-
- public String[] getExportedPackages(long arg0) throws IOException
- {
- return getBundleStateMBean().getExportedPackages(arg0);
- }
-
- public long[] getFragments(long arg0) throws IOException
- {
- return getBundleStateMBean().getFragments(arg0);
- }
-
- public TabularData getHeaders(long arg0) throws IOException
- {
- return getBundleStateMBean().getHeaders(arg0);
- }
-
- public long[] getHosts(long arg0) throws IOException
- {
- return getBundleStateMBean().getHosts(arg0);
- }
-
- public String[] getImportedPackages(long arg0) throws IOException
- {
- return getBundleStateMBean().getImportedPackages(arg0);
- }
-
- public long getLastModified(long arg0) throws IOException
- {
- return getBundleStateMBean().getLastModified(arg0);
- }
-
- public String getLocation(long arg0) throws IOException
- {
- return getBundleStateMBean().getLocation(arg0);
- }
-
- public long[] getRegisteredServices(long arg0) throws IOException
- {
- return getBundleStateMBean().getRegisteredServices(arg0);
- }
-
- public long[] getRequiredBundles(long arg0) throws IOException
- {
- return getBundleStateMBean().getRequiredBundles(arg0);
- }
-
- public long[] getRequiringBundles(long arg0) throws IOException
- {
- return getBundleStateMBean().getRequiringBundles(arg0);
- }
-
- public long[] getServicesInUse(long arg0) throws IOException
- {
- return getBundleStateMBean().getServicesInUse(arg0);
- }
-
- public int getStartLevel(long arg0) throws IOException
- {
- return getBundleStateMBean().getStartLevel(arg0);
- }
-
- public String getState(long arg0) throws IOException
- {
- return getBundleStateMBean().getState(arg0);
- }
-
- public String getSymbolicName(long arg0) throws IOException
- {
- return getBundleStateMBean().getSymbolicName(arg0);
- }
-
- public String getVersion(long arg0) throws IOException
- {
- return getBundleStateMBean().getVersion(arg0);
- }
-
- public boolean isFragment(long arg0) throws IOException
- {
- return getBundleStateMBean().isFragment(arg0);
- }
-
- public boolean isPersistentlyStarted(long arg0) throws IOException
- {
- return getBundleStateMBean().isPersistentlyStarted(arg0);
- }
-
- public boolean isRemovalPending(long arg0) throws IOException
- {
- return getBundleStateMBean().isRemovalPending(arg0);
- }
-
- public boolean isRequired(long arg0) throws IOException
- {
- return getBundleStateMBean().isRequired(arg0);
- }
-
- public TabularData listBundles() throws IOException
- {
- return getBundleStateMBean().listBundles();
- }
-
- private Bundle assertBundle(long bundleId)
- {
- Bundle bundle = context.getBundle(bundleId);
- if (bundle == null)
- throw new IllegalArgumentException("No such bundle: " + bundleId);
- return bundle;
- }
-
- /*
- * Represents key/value pair in BundleData headers
- */
- static class Header {
-
- private String key;
- private String value;
-
- String getKey() {
- return key;
- }
-
- String getValue() {
- return value;
- }
-
- private Header() {
- super();
- }
-
- Header(String key, String value) {
- this.key = key;
- this.value = value;
- }
-
- CompositeData toCompositeData() throws JMRuntimeException {
- CompositeData result = null;
- Map<String, Object> items = new HashMap<String, Object>();
- items.put(KEY, key);
- items.put(VALUE, value);
- try {
- result = new CompositeDataSupport(HEADER_TYPE, items);
- } catch (OpenDataException e) {
- throw new JMRuntimeException("Failed to create CompositeData for header [" + key + ":" + value + "] - "
- + e.getMessage());
- }
- return result;
- }
-
- static Header from(CompositeData compositeData) {
- if (compositeData == null) {
- throw new IllegalArgumentException("Argument compositeData cannot be null");
- }
- if (!compositeData.getCompositeType().equals(HEADER_TYPE)) {
- throw new IllegalArgumentException("Invalid CompositeType [" + compositeData.getCompositeType() + "]");
- }
- Header header = new Header();
- header.key = (String) compositeData.get(KEY);
- header.value = (String) compositeData.get(VALUE);
- return header;
- }
- }
-}
\ No newline at end of file
Copied: projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/BundleStateExt.java (from rev 101408, projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/BundleState.java)
===================================================================
--- projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/BundleStateExt.java (rev 0)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/BundleStateExt.java 2010-02-24 20:18:06 UTC (rev 101419)
@@ -0,0 +1,349 @@
+/*
+ * 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.File;
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.management.JMRuntimeException;
+import javax.management.MBeanServer;
+import javax.management.NotCompliantMBeanException;
+import javax.management.ObjectName;
+import javax.management.StandardMBean;
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeDataSupport;
+import javax.management.openmbean.OpenDataException;
+import javax.management.openmbean.TabularData;
+import javax.management.openmbean.TabularDataSupport;
+
+import org.jboss.osgi.jmx.BundleStateMBeanExt;
+import org.jboss.osgi.spi.management.ObjectNameFactory;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.jmx.JmxConstants;
+import org.osgi.jmx.framework.BundleStateMBean;
+import org.osgi.service.packageadmin.PackageAdmin;
+
+/**
+ * An extension to {@link BundleStateMBean}.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 23-Feb-2010
+ */
+public class BundleStateExt extends AbstractState implements BundleStateMBeanExt
+{
+ public BundleStateExt(BundleContext context, MBeanServer mbeanServer)
+ {
+ super(context, mbeanServer);
+ }
+
+ @Override
+ ObjectName getObjectName()
+ {
+ return ObjectNameFactory.create(OBJECTNAME);
+ }
+
+ @Override
+ StandardMBean getStandardMBean() throws NotCompliantMBeanException
+ {
+ return new StandardMBean(this, BundleStateMBeanExt.class);
+ }
+
+ @Override
+ public CompositeData getBundle(long bundleId) throws IOException
+ {
+ TabularData bundleList = listBundles();
+ CompositeData bundleData = bundleList.get(new Object[] { (Long)bundleId });
+ if (bundleData == null)
+ throw new IllegalArgumentException("No such bundle: " + bundleId);
+ return bundleData;
+ }
+
+ @Override
+ public String getDataFile(long bundleId, String filename) throws IOException
+ {
+ BundleContext context = assertBundleContext(bundleId);
+ File dataFile = context.getDataFile(filename);
+ return dataFile.getCanonicalPath();
+ }
+
+ @Override
+ public String getEntry(long bundleId, String path) throws IOException
+ {
+ Bundle bundle = assertBundle(bundleId);
+ URL entry = bundle.getEntry(path);
+ return entry.toExternalForm();
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public TabularData getHeaders(long bundleId, String locale) throws IOException
+ {
+ Bundle bundle = assertBundle(bundleId);
+ List<Header> headers = new ArrayList<Header>();
+ Dictionary<String, String> bundleHeaders = bundle.getHeaders(locale);
+ Enumeration<String> keys = bundleHeaders.keys();
+ while (keys.hasMoreElements())
+ {
+ String key = keys.nextElement();
+ headers.add(new Header(key, bundleHeaders.get(key)));
+ }
+ TabularData headerTable = new TabularDataSupport(HEADERS_TYPE);
+ for (Header header : headers)
+ {
+ headerTable.put(header.toCompositeData());
+ }
+ return headerTable;
+ }
+
+ @Override
+ public CompositeData getProperty(long bundleId, String key) throws IOException
+ {
+ BundleContext bundleContext = assertBundleContext(bundleId);
+ String value = bundleContext.getProperty(key);
+ if (value == null)
+ return null;
+
+ Map<String, Object> items = new HashMap<String, Object>();
+ items.put(KEY, key);
+ items.put(VALUE, value);
+ try
+ {
+ return new CompositeDataSupport(JmxConstants.PROPERTY_TYPE, items);
+ }
+ catch (OpenDataException ex)
+ {
+ throw new JMRuntimeException("Failed to create CompositeData for property [" + key + ":" + value + "] - " + ex.getMessage());
+ }
+ }
+
+ @Override
+ public String getResource(long bundleId, String name) throws IOException
+ {
+ Bundle bundle = assertBundle(bundleId);
+ URL entry = bundle.getResource(name);
+ return entry.toExternalForm();
+ }
+
+ @Override
+ public long loadClass(long bundleId, String name) throws ClassNotFoundException, IOException
+ {
+ Bundle bundle = assertBundle(bundleId);
+ Class<?> clazz = bundle.loadClass(name);
+ ServiceReference sref = context.getServiceReference(PackageAdmin.class.getName());
+ PackageAdmin service = (PackageAdmin)context.getService(sref);
+ Bundle exporter = service.getBundle(clazz);
+ if (exporter == null)
+ return 0;
+
+ return exporter.getBundleId();
+ }
+
+ public String[] getExportedPackages(long arg0) throws IOException
+ {
+ return getBundleStateMBean().getExportedPackages(arg0);
+ }
+
+ public long[] getFragments(long arg0) throws IOException
+ {
+ return getBundleStateMBean().getFragments(arg0);
+ }
+
+ public TabularData getHeaders(long arg0) throws IOException
+ {
+ return getBundleStateMBean().getHeaders(arg0);
+ }
+
+ public long[] getHosts(long arg0) throws IOException
+ {
+ return getBundleStateMBean().getHosts(arg0);
+ }
+
+ public String[] getImportedPackages(long arg0) throws IOException
+ {
+ return getBundleStateMBean().getImportedPackages(arg0);
+ }
+
+ public long getLastModified(long arg0) throws IOException
+ {
+ return getBundleStateMBean().getLastModified(arg0);
+ }
+
+ public String getLocation(long arg0) throws IOException
+ {
+ return getBundleStateMBean().getLocation(arg0);
+ }
+
+ public long[] getRegisteredServices(long arg0) throws IOException
+ {
+ return getBundleStateMBean().getRegisteredServices(arg0);
+ }
+
+ public long[] getRequiredBundles(long arg0) throws IOException
+ {
+ return getBundleStateMBean().getRequiredBundles(arg0);
+ }
+
+ public long[] getRequiringBundles(long arg0) throws IOException
+ {
+ return getBundleStateMBean().getRequiringBundles(arg0);
+ }
+
+ public long[] getServicesInUse(long arg0) throws IOException
+ {
+ return getBundleStateMBean().getServicesInUse(arg0);
+ }
+
+ public int getStartLevel(long arg0) throws IOException
+ {
+ return getBundleStateMBean().getStartLevel(arg0);
+ }
+
+ public String getState(long arg0) throws IOException
+ {
+ return getBundleStateMBean().getState(arg0);
+ }
+
+ public String getSymbolicName(long arg0) throws IOException
+ {
+ return getBundleStateMBean().getSymbolicName(arg0);
+ }
+
+ public String getVersion(long arg0) throws IOException
+ {
+ return getBundleStateMBean().getVersion(arg0);
+ }
+
+ public boolean isFragment(long arg0) throws IOException
+ {
+ return getBundleStateMBean().isFragment(arg0);
+ }
+
+ public boolean isPersistentlyStarted(long arg0) throws IOException
+ {
+ return getBundleStateMBean().isPersistentlyStarted(arg0);
+ }
+
+ public boolean isRemovalPending(long arg0) throws IOException
+ {
+ return getBundleStateMBean().isRemovalPending(arg0);
+ }
+
+ public boolean isRequired(long arg0) throws IOException
+ {
+ return getBundleStateMBean().isRequired(arg0);
+ }
+
+ public TabularData listBundles() throws IOException
+ {
+ return getBundleStateMBean().listBundles();
+ }
+
+ private Bundle assertBundle(long bundleId)
+ {
+ Bundle bundle = context.getBundle(bundleId);
+ if (bundle == null)
+ throw new IllegalArgumentException("No such bundle: " + bundleId);
+ return bundle;
+ }
+
+ private BundleContext assertBundleContext(long bundleId)
+ {
+ Bundle bundle = assertBundle(bundleId);
+ BundleContext bundleContext = bundle.getBundleContext();
+ return bundleContext;
+ }
+
+ /*
+ * Represents key/value pair in BundleData headers
+ */
+ static class Header
+ {
+
+ private String key;
+ private String value;
+
+ String getKey()
+ {
+ return key;
+ }
+
+ String getValue()
+ {
+ return value;
+ }
+
+ private Header()
+ {
+ super();
+ }
+
+ Header(String key, String value)
+ {
+ this.key = key;
+ this.value = value;
+ }
+
+ CompositeData toCompositeData() throws JMRuntimeException
+ {
+ CompositeData result = null;
+ Map<String, Object> items = new HashMap<String, Object>();
+ items.put(KEY, key);
+ items.put(VALUE, value);
+ try
+ {
+ result = new CompositeDataSupport(HEADER_TYPE, items);
+ }
+ catch (OpenDataException e)
+ {
+ throw new JMRuntimeException("Failed to create CompositeData for header [" + key + ":" + value + "] - " + e.getMessage());
+ }
+ return result;
+ }
+
+ static Header from(CompositeData compositeData)
+ {
+ if (compositeData == null)
+ {
+ throw new IllegalArgumentException("Argument compositeData cannot be null");
+ }
+ if (!compositeData.getCompositeType().equals(HEADER_TYPE))
+ {
+ throw new IllegalArgumentException("Invalid CompositeType [" + compositeData.getCompositeType() + "]");
+ }
+ Header header = new Header();
+ header.key = (String)compositeData.get(KEY);
+ header.value = (String)compositeData.get(VALUE);
+ return header;
+ }
+ }
+}
\ No newline at end of file
Deleted: projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/FrameworkState.java
===================================================================
--- projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/FrameworkState.java 2010-02-24 20:04:08 UTC (rev 101418)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/FrameworkState.java 2010-02-24 20:18:06 UTC (rev 101419)
@@ -1,217 +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.NotCompliantMBeanException;
-import javax.management.ObjectName;
-import javax.management.StandardMBean;
-import javax.management.openmbean.CompositeData;
-
-import org.jboss.osgi.jmx.FrameworkMBeanExt;
-import org.jboss.osgi.spi.management.ObjectNameFactory;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.jmx.framework.FrameworkMBean;
-import org.osgi.service.packageadmin.PackageAdmin;
-
-/**
- * An extension to {@link FrameworkMBean}.
- *
- * @author thomas.diesler(a)jboss.com
- * @since 23-Feb-2009
- */
-public class FrameworkState extends AbstractStateMBean implements FrameworkMBeanExt
-{
-
- public FrameworkState(BundleContext context, MBeanServer mbeanServer)
- {
- super(context, mbeanServer);
- }
-
- @Override
- ObjectName getObjectName()
- {
- return ObjectNameFactory.create(OBJECTNAME);
- }
-
- @Override
- StandardMBean getStandardMBean() throws NotCompliantMBeanException
- {
- return new StandardMBean(this, FrameworkMBeanExt.class);
- }
-
- @Override
- public void refreshAllPackages()
- {
- ServiceReference sref = context.getServiceReference(PackageAdmin.class.getName());
- PackageAdmin service = (PackageAdmin)context.getService(sref);
- service.refreshPackages(null);
- }
-
- @Override
- public boolean resolveAllBundles()
- {
- ServiceReference sref = context.getServiceReference(PackageAdmin.class.getName());
- PackageAdmin service = (PackageAdmin)context.getService(sref);
- return service.resolveBundles(null);
- }
-
- public int getFrameworkStartLevel() throws IOException
- {
- return getFrameworkMBean().getFrameworkStartLevel();
- }
-
- public int getInitialBundleStartLevel() throws IOException
- {
- return getFrameworkMBean().getInitialBundleStartLevel();
- }
-
- public long installBundle(String arg0, String arg1) throws IOException
- {
- return getFrameworkMBean().installBundle(arg0, arg1);
- }
-
- public long installBundle(String arg0) throws IOException
- {
- return getFrameworkMBean().installBundle(arg0);
- }
-
- public CompositeData installBundles(String[] arg0, String[] arg1) throws IOException
- {
- return getFrameworkMBean().installBundles(arg0, arg1);
- }
-
- public CompositeData installBundles(String[] arg0) throws IOException
- {
- return getFrameworkMBean().installBundles(arg0);
- }
-
- public void refreshPackages(long arg0) throws IOException
- {
- getFrameworkMBean().refreshPackages(arg0);
- }
-
- public CompositeData refreshPackages(long[] arg0) throws IOException
- {
- return getFrameworkMBean().refreshPackages(arg0);
- }
-
- public boolean resolveBundle(long arg0) throws IOException
- {
- return getFrameworkMBean().resolveBundle(arg0);
- }
-
- public boolean resolveBundles(long[] arg0) throws IOException
- {
- return getFrameworkMBean().resolveBundles(arg0);
- }
-
- public void restartFramework() throws IOException
- {
- getFrameworkMBean().restartFramework();
- }
-
- public void setBundleStartLevel(long arg0, int arg1) throws IOException
- {
- getFrameworkMBean().setBundleStartLevel(arg0, arg1);
- }
-
- public CompositeData setBundleStartLevels(long[] arg0, int[] arg1) throws IOException
- {
- return getFrameworkMBean().setBundleStartLevels(arg0, arg1);
- }
-
- public void setFrameworkStartLevel(int arg0) throws IOException
- {
- getFrameworkMBean().setFrameworkStartLevel(arg0);
- }
-
- public void setInitialBundleStartLevel(int arg0) throws IOException
- {
- getFrameworkMBean().setInitialBundleStartLevel(arg0);
- }
-
- public void shutdownFramework() throws IOException
- {
- getFrameworkMBean().shutdownFramework();
- }
-
- public void startBundle(long arg0) throws IOException
- {
- getFrameworkMBean().startBundle(arg0);
- }
-
- public CompositeData startBundles(long[] arg0) throws IOException
- {
- return getFrameworkMBean().startBundles(arg0);
- }
-
- public void stopBundle(long arg0) throws IOException
- {
- getFrameworkMBean().stopBundle(arg0);
- }
-
- public CompositeData stopBundles(long[] arg0) throws IOException
- {
- return getFrameworkMBean().stopBundles(arg0);
- }
-
- public void uninstallBundle(long arg0) throws IOException
- {
- getFrameworkMBean().uninstallBundle(arg0);
- }
-
- public CompositeData uninstallBundles(long[] arg0) throws IOException
- {
- return getFrameworkMBean().uninstallBundles(arg0);
- }
-
- public void updateBundle(long arg0, String arg1) throws IOException
- {
- getFrameworkMBean().updateBundle(arg0, arg1);
- }
-
- public void updateBundle(long arg0) throws IOException
- {
- getFrameworkMBean().updateBundle(arg0);
- }
-
- public CompositeData updateBundles(long[] arg0, String[] arg1) throws IOException
- {
- return getFrameworkMBean().updateBundles(arg0, arg1);
- }
-
- public CompositeData updateBundles(long[] arg0) throws IOException
- {
- return getFrameworkMBean().updateBundles(arg0);
- }
-
- public void updateFramework() throws IOException
- {
- getFrameworkMBean().updateFramework();
- }
-}
\ No newline at end of file
Copied: projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/FrameworkStateExt.java (from rev 101404, projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/FrameworkState.java)
===================================================================
--- projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/FrameworkStateExt.java (rev 0)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/FrameworkStateExt.java 2010-02-24 20:18:06 UTC (rev 101419)
@@ -0,0 +1,217 @@
+/*
+ * 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.NotCompliantMBeanException;
+import javax.management.ObjectName;
+import javax.management.StandardMBean;
+import javax.management.openmbean.CompositeData;
+
+import org.jboss.osgi.jmx.FrameworkMBeanExt;
+import org.jboss.osgi.spi.management.ObjectNameFactory;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.jmx.framework.FrameworkMBean;
+import org.osgi.service.packageadmin.PackageAdmin;
+
+/**
+ * An extension to {@link FrameworkMBean}.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 23-Feb-2009
+ */
+public class FrameworkStateExt extends AbstractState implements FrameworkMBeanExt
+{
+
+ public FrameworkStateExt(BundleContext context, MBeanServer mbeanServer)
+ {
+ super(context, mbeanServer);
+ }
+
+ @Override
+ ObjectName getObjectName()
+ {
+ return ObjectNameFactory.create(OBJECTNAME);
+ }
+
+ @Override
+ StandardMBean getStandardMBean() throws NotCompliantMBeanException
+ {
+ return new StandardMBean(this, FrameworkMBeanExt.class);
+ }
+
+ @Override
+ public void refreshAllPackages()
+ {
+ ServiceReference sref = context.getServiceReference(PackageAdmin.class.getName());
+ PackageAdmin service = (PackageAdmin)context.getService(sref);
+ service.refreshPackages(null);
+ }
+
+ @Override
+ public boolean resolveAllBundles()
+ {
+ ServiceReference sref = context.getServiceReference(PackageAdmin.class.getName());
+ PackageAdmin service = (PackageAdmin)context.getService(sref);
+ return service.resolveBundles(null);
+ }
+
+ public int getFrameworkStartLevel() throws IOException
+ {
+ return getFrameworkMBean().getFrameworkStartLevel();
+ }
+
+ public int getInitialBundleStartLevel() throws IOException
+ {
+ return getFrameworkMBean().getInitialBundleStartLevel();
+ }
+
+ public long installBundle(String arg0, String arg1) throws IOException
+ {
+ return getFrameworkMBean().installBundle(arg0, arg1);
+ }
+
+ public long installBundle(String arg0) throws IOException
+ {
+ return getFrameworkMBean().installBundle(arg0);
+ }
+
+ public CompositeData installBundles(String[] arg0, String[] arg1) throws IOException
+ {
+ return getFrameworkMBean().installBundles(arg0, arg1);
+ }
+
+ public CompositeData installBundles(String[] arg0) throws IOException
+ {
+ return getFrameworkMBean().installBundles(arg0);
+ }
+
+ public void refreshPackages(long arg0) throws IOException
+ {
+ getFrameworkMBean().refreshPackages(arg0);
+ }
+
+ public CompositeData refreshPackages(long[] arg0) throws IOException
+ {
+ return getFrameworkMBean().refreshPackages(arg0);
+ }
+
+ public boolean resolveBundle(long arg0) throws IOException
+ {
+ return getFrameworkMBean().resolveBundle(arg0);
+ }
+
+ public boolean resolveBundles(long[] arg0) throws IOException
+ {
+ return getFrameworkMBean().resolveBundles(arg0);
+ }
+
+ public void restartFramework() throws IOException
+ {
+ getFrameworkMBean().restartFramework();
+ }
+
+ public void setBundleStartLevel(long arg0, int arg1) throws IOException
+ {
+ getFrameworkMBean().setBundleStartLevel(arg0, arg1);
+ }
+
+ public CompositeData setBundleStartLevels(long[] arg0, int[] arg1) throws IOException
+ {
+ return getFrameworkMBean().setBundleStartLevels(arg0, arg1);
+ }
+
+ public void setFrameworkStartLevel(int arg0) throws IOException
+ {
+ getFrameworkMBean().setFrameworkStartLevel(arg0);
+ }
+
+ public void setInitialBundleStartLevel(int arg0) throws IOException
+ {
+ getFrameworkMBean().setInitialBundleStartLevel(arg0);
+ }
+
+ public void shutdownFramework() throws IOException
+ {
+ getFrameworkMBean().shutdownFramework();
+ }
+
+ public void startBundle(long arg0) throws IOException
+ {
+ getFrameworkMBean().startBundle(arg0);
+ }
+
+ public CompositeData startBundles(long[] arg0) throws IOException
+ {
+ return getFrameworkMBean().startBundles(arg0);
+ }
+
+ public void stopBundle(long arg0) throws IOException
+ {
+ getFrameworkMBean().stopBundle(arg0);
+ }
+
+ public CompositeData stopBundles(long[] arg0) throws IOException
+ {
+ return getFrameworkMBean().stopBundles(arg0);
+ }
+
+ public void uninstallBundle(long arg0) throws IOException
+ {
+ getFrameworkMBean().uninstallBundle(arg0);
+ }
+
+ public CompositeData uninstallBundles(long[] arg0) throws IOException
+ {
+ return getFrameworkMBean().uninstallBundles(arg0);
+ }
+
+ public void updateBundle(long arg0, String arg1) throws IOException
+ {
+ getFrameworkMBean().updateBundle(arg0, arg1);
+ }
+
+ public void updateBundle(long arg0) throws IOException
+ {
+ getFrameworkMBean().updateBundle(arg0);
+ }
+
+ public CompositeData updateBundles(long[] arg0, String[] arg1) throws IOException
+ {
+ return getFrameworkMBean().updateBundles(arg0, arg1);
+ }
+
+ public CompositeData updateBundles(long[] arg0) throws IOException
+ {
+ return getFrameworkMBean().updateBundles(arg0);
+ }
+
+ public void updateFramework() throws IOException
+ {
+ getFrameworkMBean().updateFramework();
+ }
+}
\ No newline at end of file
Modified: projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/JMXServiceActivator.java
===================================================================
--- projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/JMXServiceActivator.java 2010-02-24 20:04:08 UTC (rev 101418)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/JMXServiceActivator.java 2010-02-24 20:18:06 UTC (rev 101419)
@@ -56,10 +56,9 @@
private String jmxRmiPort;
private String rmiAdaptorPath;
private MBeanServer mbeanServer;
- private FrameworkState frameworkState;
- private ServiceState serviceState;
- private BundleState bundleState;
- private ManagedBundleTracker bundleTracker;
+ private FrameworkStateExt frameworkState;
+ private ServiceStateExt serviceState;
+ private BundleStateExt bundleState;
public void start(BundleContext context)
{
@@ -71,21 +70,17 @@
BundleContext sysContext = context.getBundle(0).getBundleContext();
// Register the FrameworkMBean
- frameworkState = new FrameworkState(sysContext, mbeanServer);
+ frameworkState = new FrameworkStateExt(sysContext, mbeanServer);
frameworkState.start();
// Register the ServiceStateMBean
- serviceState = new ServiceState(sysContext, mbeanServer);
+ serviceState = new ServiceStateExt(sysContext, mbeanServer);
serviceState.start();
// Register the BundleStateMBean
- bundleState = new BundleState(sysContext, mbeanServer);
+ bundleState = new BundleStateExt(sysContext, mbeanServer);
bundleState.start();
- // Start tracking the bundles
- bundleTracker = new ManagedBundleTracker(sysContext, mbeanServer);
- bundleTracker.open();
-
jmxHost = context.getProperty(JMXConstantsExt.REMOTE_JMX_HOST);
if (jmxHost == null)
jmxHost = "localhost";
@@ -114,9 +109,6 @@
// Unregister the BundleStateMBean
bundleState.stop();
- // Stop tracking the bundles
- bundleTracker.close();
-
if (jmxConnector != null)
{
jmxConnector.stop();
Deleted: projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/ManagedBundleTracker.java
===================================================================
--- projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/ManagedBundleTracker.java 2010-02-24 20:04:08 UTC (rev 101418)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/ManagedBundleTracker.java 2010-02-24 20:18:06 UTC (rev 101419)
@@ -1,118 +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.JMException;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-
-import org.jboss.logging.Logger;
-import org.jboss.osgi.spi.management.ManagedBundle;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleEvent;
-import org.osgi.util.tracker.BundleTracker;
-
-/**
- * Track and register/unregister bundles with the MBeanServer.
- *
- * @author thomas.diesler(a)jboss.com
- * @since 29-Oct-2009
- */
-public class ManagedBundleTracker extends BundleTracker
-{
- // Provide logging
- private static final Logger log = Logger.getLogger(ManagedBundleTracker.class);
-
- private BundleContext systemContext;
- private MBeanServer mbeanServer;
-
- public ManagedBundleTracker(BundleContext context, MBeanServer mbeanServer)
- {
- super(context, Bundle.INSTALLED | Bundle.RESOLVED | Bundle.ACTIVE | Bundle.UNINSTALLED, null);
- this.mbeanServer = mbeanServer;
- this.systemContext = context;
- }
-
- @Override
- public Object addingBundle(Bundle bundle, BundleEvent event)
- {
- Object retObject = super.addingBundle(bundle, event);
- register(bundle);
- return retObject;
- }
-
- @Override
- public void modifiedBundle(Bundle bundle, BundleEvent event, Object object)
- {
- if (event != null && event.getType() == BundleEvent.UNINSTALLED)
- unregister(bundle);
- }
-
- private ManagedBundle register(Bundle bundle)
- {
- if (log.isTraceEnabled())
- log.trace("register(" + bundle + ")");
-
- try
- {
- ManagedBundle mb = new ManagedBundle(systemContext, bundle);
- ObjectName oname = mb.getObjectName();
-
- if (mbeanServer.isRegistered(oname) == false)
- {
- log.debug("Register managed bundle: " + oname);
- mbeanServer.registerMBean(mb, oname);
- }
-
- return mb;
- }
- catch (JMException ex)
- {
- log.error("Cannot register managed bundle", ex);
- return null;
- }
- }
-
- private void unregister(Bundle bundle)
- {
- if (log.isTraceEnabled())
- log.trace("unregister(" + bundle + ")");
-
- try
- {
- ObjectName oname = ManagedBundle.getObjectName(bundle);
- if (mbeanServer.isRegistered(oname))
- {
- log.debug("Unregister managed bundle: " + oname);
- mbeanServer.unregisterMBean(oname);
- }
-
- }
- catch (JMException ex)
- {
- log.error("Cannot register managed bundle", ex);
- }
- }
-}
\ No newline at end of file
Deleted: projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/ServiceState.java
===================================================================
--- projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/ServiceState.java 2010-02-24 20:04:08 UTC (rev 101418)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/ServiceState.java 2010-02-24 20:18:06 UTC (rev 101419)
@@ -1,165 +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 java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.management.MBeanServer;
-import javax.management.NotCompliantMBeanException;
-import javax.management.ObjectName;
-import javax.management.StandardMBean;
-import javax.management.openmbean.CompositeData;
-import javax.management.openmbean.CompositeDataSupport;
-import javax.management.openmbean.OpenDataException;
-import javax.management.openmbean.TabularData;
-import javax.management.openmbean.TabularDataSupport;
-
-import org.jboss.osgi.jmx.ServiceStateMBeanExt;
-import org.jboss.osgi.spi.management.ObjectNameFactory;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.jmx.framework.ServiceStateMBean;
-
-/**
- * An extension to {@link ServiceStateMBean}.
- *
- * @author thomas.diesler(a)jboss.com
- * @since 23-Feb-2010
- */
-public class ServiceState extends AbstractStateMBean implements ServiceStateMBeanExt
-{
- public ServiceState(BundleContext context, MBeanServer mbeanServer)
- {
- super(context, mbeanServer);
- }
-
- @Override
- ObjectName getObjectName()
- {
- return ObjectNameFactory.create(OBJECTNAME);
- }
-
- @Override
- StandardMBean getStandardMBean() throws NotCompliantMBeanException
- {
- return new StandardMBean(this, ServiceStateMBeanExt.class);
- }
-
- @Override
- public CompositeData getService(String clazz) throws IOException
- {
- ServiceReference sref = context.getServiceReference(clazz);
- if (sref == null)
- return null;
-
- return getCompositeData(sref);
- }
-
- @Override
- public TabularData getServices(String clazz, String filter) throws IOException
- {
- ServiceReference[] srefs;
- try
- {
- srefs = context.getServiceReferences(clazz, filter);
- }
- catch (InvalidSyntaxException e)
- {
- throw new IllegalArgumentException("Invalid filter syntax: " + filter);
- }
-
- if (srefs == null)
- return null;
-
- TabularDataSupport tabularData = new TabularDataSupport(SERVICES_TYPE);
- for (ServiceReference sref : srefs)
- {
- CompositeDataSupport compData = getCompositeData(sref);
- tabularData.put(compData.get(IDENTIFIER), compData);
- }
-
- return tabularData;
- }
-
- private CompositeDataSupport getCompositeData(ServiceReference sref) throws IOException
- {
- Long serviceId = (Long)sref.getProperty(Constants.SERVICE_ID);
-
- List<Long> usingBundles = new ArrayList<Long>();
- for (Bundle aux : sref.getUsingBundles())
- usingBundles.add(aux.getBundleId());
-
- Map<String, Object> items = new HashMap<String, Object>();
- items.put(BUNDLE_IDENTIFIER, sref.getBundle().getBundleId());
- items.put(IDENTIFIER, serviceId);
- items.put(OBJECT_CLASS, sref.getProperty(Constants.OBJECTCLASS));
- items.put(USING_BUNDLES, usingBundles.toArray(new Long[usingBundles.size()]));
-
- // [TODO] Remove once ServiceType does not require this item any more
- items.put(PROPERTIES, getProperties(serviceId));
-
- CompositeDataSupport compData;
- try
- {
- compData = new CompositeDataSupport(SERVICE_TYPE, items);
- }
- catch (OpenDataException ex)
- {
- throw new IllegalStateException(ex);
- }
- return compData;
- }
-
- public long getBundleIdentifier(long arg0) throws IOException
- {
- return getServiceStateMBean().getBundleIdentifier(arg0);
- }
-
- public String[] getObjectClass(long arg0) throws IOException
- {
- return getServiceStateMBean().getObjectClass(arg0);
- }
-
- public TabularData getProperties(long arg0) throws IOException
- {
- return getServiceStateMBean().getProperties(arg0);
- }
-
- public long[] getUsingBundles(long arg0) throws IOException
- {
- return getServiceStateMBean().getUsingBundles(arg0);
- }
-
- public TabularData listServices() throws IOException
- {
- return getServiceStateMBean().listServices();
- }
-}
\ No newline at end of file
Copied: projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/ServiceStateExt.java (from rev 101404, projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/ServiceState.java)
===================================================================
--- projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/ServiceStateExt.java (rev 0)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/ServiceStateExt.java 2010-02-24 20:18:06 UTC (rev 101419)
@@ -0,0 +1,171 @@
+/*
+ * 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 java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.management.MBeanServer;
+import javax.management.NotCompliantMBeanException;
+import javax.management.ObjectName;
+import javax.management.StandardMBean;
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeDataSupport;
+import javax.management.openmbean.OpenDataException;
+import javax.management.openmbean.TabularData;
+import javax.management.openmbean.TabularDataSupport;
+
+import org.jboss.osgi.jmx.ServiceStateMBeanExt;
+import org.jboss.osgi.spi.management.ObjectNameFactory;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.jmx.framework.ServiceStateMBean;
+
+/**
+ * An extension to {@link ServiceStateMBean}.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 23-Feb-2010
+ */
+public class ServiceStateExt extends AbstractState implements ServiceStateMBeanExt
+{
+ public ServiceStateExt(BundleContext context, MBeanServer mbeanServer)
+ {
+ super(context, mbeanServer);
+ }
+
+ @Override
+ ObjectName getObjectName()
+ {
+ return ObjectNameFactory.create(OBJECTNAME);
+ }
+
+ @Override
+ StandardMBean getStandardMBean() throws NotCompliantMBeanException
+ {
+ return new StandardMBean(this, ServiceStateMBeanExt.class);
+ }
+
+ @Override
+ public CompositeData getService(String clazz) throws IOException
+ {
+ ServiceReference sref = context.getServiceReference(clazz);
+ if (sref == null)
+ return null;
+
+ return getCompositeData(sref);
+ }
+
+ @Override
+ public TabularData getServices(String clazz, String filter) throws IOException
+ {
+ ServiceReference[] srefs;
+ try
+ {
+ srefs = context.getServiceReferences(clazz, filter);
+ }
+ catch (InvalidSyntaxException e)
+ {
+ throw new IllegalArgumentException("Invalid filter syntax: " + filter);
+ }
+
+ if (srefs == null)
+ return null;
+
+ TabularDataSupport tabularData = new TabularDataSupport(SERVICES_TYPE);
+ for (ServiceReference sref : srefs)
+ {
+ CompositeDataSupport compData = getCompositeData(sref);
+ tabularData.put(compData.get(IDENTIFIER), compData);
+ }
+
+ return tabularData;
+ }
+
+ private CompositeDataSupport getCompositeData(ServiceReference sref) throws IOException
+ {
+ Long serviceId = (Long)sref.getProperty(Constants.SERVICE_ID);
+
+ // Get the array of using bundles identifiers
+ List<Long> usingIdentifiers = new ArrayList<Long>();
+ Bundle[] usingBundles = sref.getUsingBundles();
+ if (usingBundles != null)
+ {
+ for (Bundle aux : usingBundles)
+ usingIdentifiers.add(aux.getBundleId());
+ }
+ Long[] usingArr = usingIdentifiers.toArray(new Long[usingIdentifiers.size()]);
+
+ Map<String, Object> items = new HashMap<String, Object>();
+ items.put(BUNDLE_IDENTIFIER, sref.getBundle().getBundleId());
+ items.put(IDENTIFIER, serviceId);
+ items.put(OBJECT_CLASS, sref.getProperty(Constants.OBJECTCLASS));
+ items.put(USING_BUNDLES, usingArr);
+
+ // [TODO] Remove once ServiceType does not require this item any more
+ items.put(PROPERTIES, getProperties(serviceId));
+
+ CompositeDataSupport compData;
+ try
+ {
+ compData = new CompositeDataSupport(SERVICE_TYPE, items);
+ }
+ catch (OpenDataException ex)
+ {
+ throw new IllegalStateException(ex);
+ }
+ return compData;
+ }
+
+ public long getBundleIdentifier(long arg0) throws IOException
+ {
+ return getServiceStateMBean().getBundleIdentifier(arg0);
+ }
+
+ public String[] getObjectClass(long arg0) throws IOException
+ {
+ return getServiceStateMBean().getObjectClass(arg0);
+ }
+
+ public TabularData getProperties(long arg0) throws IOException
+ {
+ return getServiceStateMBean().getProperties(arg0);
+ }
+
+ public long[] getUsingBundles(long arg0) throws IOException
+ {
+ return getServiceStateMBean().getUsingBundles(arg0);
+ }
+
+ public TabularData listServices() throws IOException
+ {
+ return getServiceStateMBean().listServices();
+ }
+}
\ No newline at end of file
Deleted: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/management/ManagedBundle.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/management/ManagedBundle.java 2010-02-24 20:04:08 UTC (rev 101418)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/management/ManagedBundle.java 2010-02-24 20:18:06 UTC (rev 101419)
@@ -1,201 +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 static org.jboss.osgi.spi.OSGiConstants.DOMAIN_NAME;
-
-import java.io.File;
-import java.net.URL;
-import java.util.Dictionary;
-import java.util.Enumeration;
-import java.util.Hashtable;
-
-import javax.management.ObjectName;
-
-import org.jboss.logging.Logger;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.Version;
-import org.osgi.service.packageadmin.PackageAdmin;
-
-/**
- * The managed view of an OSGi Bundle
- *
- * @author thomas.diesler(a)jboss.com
- * @since 23-Jan-2009
- */
-public class ManagedBundle implements ManagedBundleMBean
-{
- // Provide logging
- private static final Logger log = Logger.getLogger(ManagedBundle.class);
-
- public static final String PROPERTY_ID = "id";
- public static final String PROPERTY_SYMBOLIC_NAME = "name";
- public static final String PROPERTY_VERSION = "version";
-
- private BundleContext systemContext;
- private Bundle bundle;
- private ObjectName oname;
-
- public ManagedBundle(BundleContext syscontext, Bundle bundle)
- {
- if (syscontext == null)
- throw new IllegalArgumentException("Null system context");
- if (bundle == null)
- throw new IllegalArgumentException("Null bundle");
-
- this.bundle = bundle;
- this.systemContext = syscontext;
- this.oname = getObjectName(bundle);
-
- if (log.isTraceEnabled())
- log.trace("new ManagedBundle[" + oname + "]");
- }
-
- public static ObjectName getObjectName(Bundle bundle)
- {
- if (bundle == null)
- throw new IllegalArgumentException("Null bundle");
-
- long id = bundle.getBundleId();
- String name = bundle.getSymbolicName();
- Version version = bundle.getVersion();
- return getObjectName(id, name, version);
- }
-
- public static ObjectName getObjectName(long id, String name, Version version)
- {
- String oname = DOMAIN_NAME + ":" + PROPERTY_ID + "=" + id + "," + PROPERTY_SYMBOLIC_NAME + "=" + name + "," + PROPERTY_VERSION + "=" + version;
- return ObjectNameFactory.create(oname);
- }
-
- @Override
- public ObjectName getObjectName()
- {
- return oname;
- }
-
- @Override
- public String getProperty(String key)
- {
- String value = bundle.getBundleContext().getProperty(key);
-
- if (log.isTraceEnabled())
- log.trace("getProperty[" + oname + "](" + key + ") => " + value);
-
- return value;
- }
-
- @Override
- public Dictionary<String, String> getHeaders()
- {
- return getHeaders(null);
- }
-
- @Override
- @SuppressWarnings("rawtypes")
- public Dictionary<String, String> getHeaders(String locale)
- {
- Hashtable<String, String> retHeaders = new Hashtable<String, String>();
- Dictionary bundleHeaders = bundle.getHeaders(locale);
- Enumeration keys = bundleHeaders.keys();
- while (keys.hasMoreElements())
- {
- String key = (String)keys.nextElement();
- String value = (String)bundleHeaders.get(key);
- retHeaders.put(key, value);
- }
-
- if (log.isTraceEnabled())
- log.trace("getHeaders[" + oname + "](" + locale + ") => " + retHeaders);
-
- return retHeaders;
- }
-
- @Override
- public String getEntry(String path)
- {
- URL url = bundle.getEntry(path);
- String entry = url != null ? url.toExternalForm() : null;
-
- if (log.isTraceEnabled())
- log.trace("getEntry[" + oname + "](" + path + ") => " + entry);
-
- return entry;
- }
-
- @Override
- public String getResource(String name)
- {
- URL url = bundle.getResource(name);
- String resource = url != null ? url.toExternalForm() : null;
-
- if (log.isTraceEnabled())
- log.trace("getResource[" + oname + "](" + name + ") => " + resource);
-
- return resource;
- }
-
- @Override
- public ObjectName loadClass(String name) throws ClassNotFoundException
- {
- Class<?> clazz = bundle.loadClass(name);
- Bundle providingBundle = getPackageAdmin().getBundle(clazz);
- ObjectName oname = providingBundle != null ? getObjectName(providingBundle) : null;
-
- if (log.isTraceEnabled())
- log.trace("loadClass[" + oname + "](" + name + ") => " + oname);
-
- return oname;
- }
-
- @Override
- public File getDataFile(String filename)
- {
- BundleContext context = bundle.getBundleContext();
- File dataFile = context.getDataFile(filename);
-
- if (log.isTraceEnabled())
- log.trace("getDataFile[" + oname + "](" + filename + ") => " + dataFile);
-
- return dataFile;
- }
-
- @Override
- public void update() throws BundleException
- {
- if (log.isTraceEnabled())
- log.trace("update[" + oname + "]");
-
- bundle.update();
- }
-
- private PackageAdmin getPackageAdmin()
- {
- ServiceReference sref = systemContext.getServiceReference(PackageAdmin.class.getName());
- return (PackageAdmin)systemContext.getService(sref);
- }
-}
\ No newline at end of file
Deleted: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/management/ManagedBundleMBean.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/management/ManagedBundleMBean.java 2010-02-24 20:04:08 UTC (rev 101418)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/management/ManagedBundleMBean.java 2010-02-24 20:18:06 UTC (rev 101419)
@@ -1,98 +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.io.File;
-import java.util.Dictionary;
-
-import javax.management.ObjectName;
-
-import org.osgi.framework.BundleException;
-
-/**
- * The managed view of an OSGi Bundle.
- *
- * Bundles are registered under the name
- *
- * jboss.osgi:name=[SymbolicName],id=[BundleId],version=[BundleVersion]
- *
- * @author thomas.diesler(a)jboss.com
- * @since 04-Mar-2009
- */
-public interface ManagedBundleMBean
-{
- /**
- * Get the bundles object name.
- */
- ObjectName getObjectName();
-
- /**
- * Returns the bundle manifest headers
- */
- Dictionary<String, String> getHeaders();
-
- /**
- * Returns this bundle's Manifest headers and values localized to the specified locale.
- */
- Dictionary<String, String> getHeaders(String locale);
-
- /**
- * Returns the value of the specified property from the BundleContext.
- */
- String getProperty(String key);
-
- /**
- * Loads the specified class using this bundle's class loader.
- *
- * @param name The name of the class to load
- * @return The object name of the bundle that is wired to this bundle class loader and contains the class.
- * @throws ClassNotFoundException If no such class can be found or if this bundle is a fragment bundle
- */
- ObjectName loadClass(String name) throws ClassNotFoundException;
-
- /**
- * Returns a string encoded URL to the entry at the specified path in this bundle.
- *
- * @param path The path name of the entry
- * @return A URL to the entry, or null if no entry could be found
- */
- String getEntry(String path);
-
- /**
- * Find the specified resource from this bundle's class loader.
- * @param name The name of the resource.
- * @return A string encoded URL to the named resource, or null if the resource could not be found
- */
- String getResource(String name);
-
- /**
- * Creates a File object for a file in the persistent storage area provided for the bundle by the Framework.
- */
- File getDataFile(String filename);
-
- /**
- * Update this bundle.
- */
- void update() throws BundleException;
-}
\ No newline at end of file
Modified: projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteBundle.java
===================================================================
--- projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteBundle.java 2010-02-24 20:04:08 UTC (rev 101418)
+++ projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteBundle.java 2010-02-24 20:18:06 UTC (rev 101419)
@@ -29,21 +29,26 @@
import java.net.URL;
import java.net.URLConnection;
import java.net.URLStreamHandler;
+import java.util.Collection;
import java.util.Dictionary;
+import java.util.Hashtable;
import javax.management.InstanceNotFoundException;
import javax.management.ObjectName;
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.TabularData;
import org.jboss.logging.Logger;
+import org.jboss.osgi.jmx.BundleStateMBeanExt;
import org.jboss.osgi.spi.management.MBeanProxy;
-import org.jboss.osgi.spi.management.ManagedBundle;
-import org.jboss.osgi.spi.management.ManagedBundleMBean;
+import org.jboss.osgi.spi.management.ObjectNameFactory;
import org.jboss.osgi.spi.util.UnmodifiableDictionary;
import org.jboss.osgi.testing.OSGiBundle;
import org.jboss.osgi.testing.OSGiRuntime;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
import org.osgi.framework.Version;
+import org.osgi.jmx.JmxConstants;
import org.osgi.jmx.framework.BundleStateMBean;
/**
@@ -60,8 +65,7 @@
private long bundleId;
private String location;
private String symbolicName;
- private ObjectName objectName;
- private ManagedBundleMBean bundleMBean;
+ private BundleStateMBeanExt bundleState;
private Dictionary<String, String> defaultHeaders;
private Dictionary<String, String> rawHeaders;
private Version version;
@@ -72,29 +76,41 @@
super(runtime);
this.bundleId = bundleId;
- BundleStateMBean bundleState = runtime.getBundleStateMBean();
+ ObjectName objectName = ObjectNameFactory.create(BundleStateMBeanExt.OBJECTNAME);
+ bundleState = MBeanProxy.get(runtime.getMBeanServer(), objectName, BundleStateMBeanExt.class);
try
{
symbolicName = bundleState.getSymbolicName(bundleId);
location = bundleState.getLocation(bundleId);
-
+
String versionStr = bundleState.getVersion(bundleId);
version = Version.parseVersion(versionStr);
+
+ // The getHeaders methods must continue to provide the manifest header
+ // information after the bundle enters the UNINSTALLED state.
+ defaultHeaders = getHeadersInternal(null);
+ rawHeaders = getHeadersInternal("");
}
catch (IOException ex)
{
throw new IllegalStateException("Cannot initialize remote bundle", ex);
}
-
- objectName = ManagedBundle.getObjectName(bundleId, symbolicName, version);
- bundleMBean = MBeanProxy.get(runtime.getMBeanServer(), objectName, ManagedBundleMBean.class);
-
- // The getHeaders methods must continue to provide the manifest header
- // information after the bundle enters the UNINSTALLED state.
- defaultHeaders = bundleMBean.getHeaders(null);
- rawHeaders = bundleMBean.getHeaders("");
}
+ @SuppressWarnings("unchecked")
+ private Dictionary<String, String> getHeadersInternal(String locale) throws IOException
+ {
+ Dictionary<String, String> defaultHeaders = new Hashtable<String, String>();
+ TabularData headers = bundleState.getHeaders(bundleId, null);
+ for (CompositeData aux : (Collection<CompositeData>)headers.values())
+ {
+ String key = (String)aux.get(JmxConstants.KEY);
+ String value = (String)aux.get(JmxConstants.VALUE);
+ defaultHeaders.put(key, value);
+ }
+ return new UnmodifiableDictionary(defaultHeaders);
+ }
+
@Override
public int getState()
{
@@ -117,7 +133,7 @@
return Bundle.STOPPING;
if ("UNINSTALLED".equals(state))
return Bundle.UNINSTALLED;
-
+
}
catch (Exception rte)
{
@@ -160,55 +176,102 @@
}
@Override
- @SuppressWarnings("unchecked")
public Dictionary<String, String> getHeaders(String locale)
{
if (locale == null)
- return new UnmodifiableDictionary(defaultHeaders);
+ {
+ return defaultHeaders;
+ }
else if (locale.length() == 0)
- return new UnmodifiableDictionary(rawHeaders);
+ {
+ return rawHeaders;
+ }
else
- return bundleMBean.getHeaders(locale);
+ {
+ try
+ {
+ return getHeadersInternal(locale);
+ }
+ catch (IOException ex)
+ {
+ throw new IllegalStateException("Cannot obtain headers for locale: " + locale, ex);
+ }
+ }
}
@Override
public String getProperty(String key)
{
assertNotUninstalled();
- return bundleMBean.getProperty(key);
+ try
+ {
+ CompositeData propData = bundleState.getProperty(bundleId, key);
+ if (propData == null)
+ return null;
+
+ return (String)propData.get(JmxConstants.VALUE);
+ }
+ catch (IOException ex)
+ {
+ throw new IllegalStateException("Cannot obtain property: " + key, ex);
+ }
}
@Override
public URL getEntry(String path)
{
assertNotUninstalled();
- return toURL(bundleMBean.getEntry(path), null);
+ try
+ {
+ return toURL(bundleState.getEntry(bundleId, path), null);
+ }
+ catch (IOException ex)
+ {
+ throw new IllegalStateException("Cannot getEntry: " + path, ex);
+ }
}
@Override
public URL getResource(String name)
{
assertNotUninstalled();
- return toURL(bundleMBean.getResource(name), null);
+ try
+ {
+ return toURL(bundleState.getResource(bundleId, name), null);
+ }
+ catch (IOException ex)
+ {
+ throw new IllegalStateException("Cannot getResource: " + name, ex);
+ }
}
@Override
public File getDataFile(String filename)
{
assertNotUninstalled();
- return bundleMBean.getDataFile(filename);
+ try
+ {
+ return new File(bundleState.getDataFile(bundleId, filename));
+ }
+ catch (IOException ex)
+ {
+ throw new IllegalStateException("Cannot getDataFile: " + filename, ex);
+ }
}
@Override
public OSGiBundle loadClass(String name) throws ClassNotFoundException
{
assertNotUninstalled();
- ObjectName providerBundle = bundleMBean.loadClass(name);
- if (providerBundle == null)
- return null;
-
- String bundleId = providerBundle.getKeyProperty(ManagedBundle.PROPERTY_ID);
- return getRuntime().getBundle(new Long(bundleId));
+ try
+ {
+ long exporterId = bundleState.loadClass(bundleId, name);
+ return getRuntime().getBundle(new Long(exporterId));
+ }
+ catch (IOException ex)
+ {
+ throw new IllegalStateException("Cannot loadClass: " + name, ex);
+ }
}
@Override
@@ -221,7 +284,7 @@
}
catch (IOException ex)
{
- throw new BundleException("Cannot start bundle: " + objectName, ex);
+ throw new BundleException("Cannot start bundle: " + bundleId, ex);
}
}
@@ -235,7 +298,7 @@
}
catch (IOException ex)
{
- throw new BundleException("Cannot stop bundle: " + objectName, ex);
+ throw new BundleException("Cannot stop bundle: " + bundleId, ex);
}
}
14 years, 3 months
JBoss-OSGI SVN: r101408 - in projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src: test/java/org/jboss/test/osgi/jmx and 1 other directory.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-02-24 11:27:47 -0500 (Wed, 24 Feb 2010)
New Revision: 101408
Modified:
projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/BundleState.java
projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/JMXConnectorService.java
projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/JMXServiceActivator.java
projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/test/java/org/jboss/test/osgi/jmx/BundleStateTestCase.java
Log:
Implement getHeaders(locale)
Modified: projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/BundleState.java
===================================================================
--- projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/BundleState.java 2010-02-24 16:25:16 UTC (rev 101407)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/BundleState.java 2010-02-24 16:27:47 UTC (rev 101408)
@@ -26,16 +26,24 @@
import java.io.File;
import java.io.IOException;
import java.net.URL;
+import java.util.ArrayList;
import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import javax.management.JMRuntimeException;
import javax.management.MBeanServer;
import javax.management.NotCompliantMBeanException;
import javax.management.ObjectName;
import javax.management.StandardMBean;
import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeDataSupport;
+import javax.management.openmbean.OpenDataException;
import javax.management.openmbean.TabularData;
+import javax.management.openmbean.TabularDataSupport;
-import org.jboss.logging.Logger;
import org.jboss.osgi.jmx.BundleStateMBeanExt;
import org.jboss.osgi.spi.management.ObjectNameFactory;
import org.osgi.framework.Bundle;
@@ -96,12 +104,24 @@
}
@Override
+ @SuppressWarnings("unchecked")
public TabularData getHeaders(long bundleId, String locale) throws IOException
{
Bundle bundle = assertBundle(bundleId);
- Dictionary<String, String> headers = bundle.getHeaders(locale);
- // TODO Auto-generated method stub
- return null;
+ List<Header> headers = new ArrayList<Header>();
+ Dictionary<String, String> bundleHeaders = bundle.getHeaders(locale);
+ Enumeration<String> keys = bundleHeaders.keys();
+ while (keys.hasMoreElements())
+ {
+ String key = keys.nextElement();
+ headers.add(new Header(key, bundleHeaders.get(key)));
+ }
+ TabularData headerTable = new TabularDataSupport(HEADERS_TYPE);
+ for (Header header : headers)
+ {
+ headerTable.put(header.toCompositeData());
+ }
+ return headerTable;
}
@Override
@@ -122,7 +142,7 @@
Bundle exporter = service.getBundle(clazz);
if (exporter == null)
return 0;
-
+
return exporter.getBundleId();
}
@@ -233,4 +253,57 @@
throw new IllegalArgumentException("No such bundle: " + bundleId);
return bundle;
}
+
+ /*
+ * Represents key/value pair in BundleData headers
+ */
+ static class Header {
+
+ private String key;
+ private String value;
+
+ String getKey() {
+ return key;
+ }
+
+ String getValue() {
+ return value;
+ }
+
+ private Header() {
+ super();
+ }
+
+ Header(String key, String value) {
+ this.key = key;
+ this.value = value;
+ }
+
+ CompositeData toCompositeData() throws JMRuntimeException {
+ CompositeData result = null;
+ Map<String, Object> items = new HashMap<String, Object>();
+ items.put(KEY, key);
+ items.put(VALUE, value);
+ try {
+ result = new CompositeDataSupport(HEADER_TYPE, items);
+ } catch (OpenDataException e) {
+ throw new JMRuntimeException("Failed to create CompositeData for header [" + key + ":" + value + "] - "
+ + e.getMessage());
+ }
+ return result;
+ }
+
+ static Header from(CompositeData compositeData) {
+ if (compositeData == null) {
+ throw new IllegalArgumentException("Argument compositeData cannot be null");
+ }
+ if (!compositeData.getCompositeType().equals(HEADER_TYPE)) {
+ throw new IllegalArgumentException("Invalid CompositeType [" + compositeData.getCompositeType() + "]");
+ }
+ Header header = new Header();
+ header.key = (String) compositeData.get(KEY);
+ header.value = (String) compositeData.get(VALUE);
+ return header;
+ }
+ }
}
\ No newline at end of file
Modified: projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/JMXConnectorService.java
===================================================================
--- projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/JMXConnectorService.java 2010-02-24 16:25:16 UTC (rev 101407)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/JMXConnectorService.java 2010-02-24 16:27:47 UTC (rev 101408)
@@ -37,7 +37,6 @@
import javax.management.remote.JMXServiceURL;
import org.jboss.logging.Logger;
-import org.osgi.framework.BundleContext;
/**
* A Service Activator that registers an MBeanServer
@@ -55,7 +54,7 @@
private boolean shutdownRegistry;
private Registry rmiRegistry;
- public JMXConnectorService(BundleContext context, MBeanServer mbeanServer, String host, int rmiPort) throws IOException
+ public JMXConnectorService(MBeanServer mbeanServer, String host, int rmiPort) throws IOException
{
// check to see if registry already created
rmiRegistry = LocateRegistry.getRegistry(host, rmiPort);
Modified: projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/JMXServiceActivator.java
===================================================================
--- projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/JMXServiceActivator.java 2010-02-24 16:25:16 UTC (rev 101407)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/JMXServiceActivator.java 2010-02-24 16:27:47 UTC (rev 101408)
@@ -56,8 +56,9 @@
private String jmxRmiPort;
private String rmiAdaptorPath;
private MBeanServer mbeanServer;
- private FrameworkState framework;
+ private FrameworkState frameworkState;
private ServiceState serviceState;
+ private BundleState bundleState;
private ManagedBundleTracker bundleTracker;
public void start(BundleContext context)
@@ -70,13 +71,17 @@
BundleContext sysContext = context.getBundle(0).getBundleContext();
// Register the FrameworkMBean
- framework = new FrameworkState(sysContext, mbeanServer);
- framework.start();
+ frameworkState = new FrameworkState(sysContext, mbeanServer);
+ frameworkState.start();
// Register the ServiceStateMBean
serviceState = new ServiceState(sysContext, mbeanServer);
serviceState.start();
+ // Register the BundleStateMBean
+ bundleState = new BundleState(sysContext, mbeanServer);
+ bundleState.start();
+
// Start tracking the bundles
bundleTracker = new ManagedBundleTracker(sysContext, mbeanServer);
bundleTracker.open();
@@ -101,11 +106,14 @@
public void stop(BundleContext context)
{
// Unregister the FrameworkMBean
- framework.stop();
+ frameworkState.stop();
// Unregister the ServiceStateMBean
serviceState.stop();
+ // Unregister the BundleStateMBean
+ bundleState.stop();
+
// Stop tracking the bundles
bundleTracker.close();
@@ -137,7 +145,7 @@
{
// Try to start the JMXConnector, this should fail if it is already running
// [TODO] is there a better way to check whether the connector is already running?
- jmxConnector = new JMXConnectorService(context, mbeanServer, jmxHost, Integer.parseInt(jmxRmiPort));
+ jmxConnector = new JMXConnectorService(mbeanServer, jmxHost, Integer.parseInt(jmxRmiPort));
jmxConnector.start();
}
catch (IOException ex)
Modified: projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/test/java/org/jboss/test/osgi/jmx/BundleStateTestCase.java
===================================================================
--- projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/test/java/org/jboss/test/osgi/jmx/BundleStateTestCase.java 2010-02-24 16:25:16 UTC (rev 101407)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/test/java/org/jboss/test/osgi/jmx/BundleStateTestCase.java 2010-02-24 16:27:47 UTC (rev 101408)
@@ -29,6 +29,7 @@
import javax.management.ObjectName;
import javax.management.openmbean.TabularData;
+import org.jboss.osgi.jmx.BundleStateMBeanExt;
import org.jboss.osgi.spi.management.ObjectNameFactory;
import org.junit.Test;
import org.osgi.framework.Bundle;
@@ -45,7 +46,7 @@
@Test
public void testMBeanAccess() throws Exception
{
- ObjectName oname = ObjectNameFactory.create(BundleStateMBean.OBJECTNAME);
+ ObjectName oname = ObjectNameFactory.create(BundleStateMBeanExt.OBJECTNAME);
assertTrue("Registerd " + oname, getMBeanServer().isRegistered(oname));
}
@@ -53,7 +54,6 @@
public void listBundles() throws Exception
{
Bundle[] bundles = getSystemContext().getBundles();
-
BundleStateMBean bundleState = getBundleStateMBean();
TabularData data = bundleState.listBundles();
assertEquals("Number of bundles", bundles.length, data.size());
14 years, 3 months
JBoss-OSGI SVN: r101406 - in projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle: src/main/java/org/jboss/osgi/jmx/internal and 1 other directory.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-02-24 11:01:57 -0500 (Wed, 24 Feb 2010)
New Revision: 101406
Added:
projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/DefaultSocketFactory.java
Modified:
projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/pom.xml
projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/JMXConnectorService.java
Log:
Remove dependency on jboss-common-core
Modified: projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/pom.xml
===================================================================
--- projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/pom.xml 2010-02-24 15:50:11 UTC (rev 101405)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/pom.xml 2010-02-24 16:01:57 UTC (rev 101406)
@@ -116,6 +116,7 @@
javax.management*,
javax.naming,
javax.naming.spi,
+ javax.net,
<!-- logging -->
org.jboss.logging;version="[2.1,3.0)",
@@ -131,7 +132,6 @@
org.osgi.util.tracker;version="[1.4,2.0)",
<!-- optional jndi support -->
- org.jboss.net.sockets;version="[2.2,3.0)";resolution:=optional,
org.jboss.osgi.jndi;version="[1.0,2.0)";resolution:=optional,
org.jnp.interfaces;version="[5.0,6.0)";resolution:=optional,
Added: projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/DefaultSocketFactory.java
===================================================================
--- projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/DefaultSocketFactory.java (rev 0)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/DefaultSocketFactory.java 2010-02-24 16:01:57 UTC (rev 101406)
@@ -0,0 +1,160 @@
+/*
+ * 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;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.net.InetAddress;
+import java.net.ServerSocket;
+import java.net.UnknownHostException;
+import java.rmi.server.RMIServerSocketFactory;
+import javax.net.ServerSocketFactory;
+
+/** An implementation of RMIServerSocketFactory that supports backlog and bind address settings
+ *
+ * @author Scott.Stark(a)jboss.org
+ * @version $Revision: 2787 $
+ */
+public class DefaultSocketFactory extends ServerSocketFactory implements RMIServerSocketFactory, Serializable
+{
+ static final long serialVersionUID = -7626239955727142958L;
+ private transient InetAddress bindAddress;
+ private int backlog = 200;
+
+ /** Create a socket factory that binds on any address with a default
+ * backlog of 200
+ */
+ public DefaultSocketFactory()
+ {
+ this(null, 200);
+ }
+
+ /** Create a socket factory with the given bind address
+ * @param bindAddress
+ */
+ public DefaultSocketFactory(InetAddress bindAddress)
+ {
+ this(bindAddress, 200);
+ }
+
+ /** Create a socket factory with the given backlog
+ * @param backlog
+ */
+ public DefaultSocketFactory(int backlog)
+ {
+ this(null, backlog);
+ }
+
+ /** Create a socket factory with the given bind address and backlog
+ * @param bindAddress
+ * @param backlog
+ */
+ public DefaultSocketFactory(InetAddress bindAddress, int backlog)
+ {
+ this.bindAddress = bindAddress;
+ this.backlog = backlog;
+ }
+
+ public String getBindAddress()
+ {
+ String address = null;
+ if (bindAddress != null)
+ address = bindAddress.getHostAddress();
+ return address;
+ }
+
+ public void setBindAddress(String host) throws UnknownHostException
+ {
+ bindAddress = InetAddress.getByName(host);
+ }
+
+ /**
+ * Create a server socket on the specified port (port 0 indicates
+ * an anonymous port).
+ * @param port the port number
+ * @return the server socket on the specified port
+ * @exception IOException if an I/O error occurs during server socket
+ * creation
+ * @since 1.2
+ */
+ public ServerSocket createServerSocket(int port) throws IOException
+ {
+ return createServerSocket(port, backlog, bindAddress);
+ }
+
+ /**
+ * @param port - the port to listen to
+ * @param backlog - how many connections are queued
+ * @return A ServerSocket
+ * @throws IOException
+ */
+ public ServerSocket createServerSocket(int port, int backlog) throws IOException
+ {
+ return createServerSocket(port, backlog, null);
+ }
+
+ /**
+ * @param port - the port to listen to
+ * @param backlog - how many connections are queued
+ * @param inetAddress - the network interface address to use
+ * @return the server socket
+ * @throws IOException
+ */
+ public ServerSocket createServerSocket(int port, int backlog, InetAddress inetAddress) throws IOException
+ {
+ ServerSocket activeSocket = new ServerSocket(port, backlog, bindAddress);
+ return activeSocket;
+ }
+
+ public boolean equals(Object obj)
+ {
+ boolean equals = obj instanceof DefaultSocketFactory;
+ if (equals && bindAddress != null)
+ {
+ DefaultSocketFactory dsf = (DefaultSocketFactory)obj;
+ InetAddress dsfa = dsf.bindAddress;
+ if (dsfa != null)
+ equals = bindAddress.equals(dsfa);
+ else
+ equals = false;
+ }
+ return equals;
+ }
+
+ public int hashCode()
+ {
+ int hashCode = getClass().getName().hashCode();
+ if (bindAddress != null)
+ hashCode += bindAddress.toString().hashCode();
+ return hashCode;
+ }
+
+ public String toString()
+ {
+ StringBuffer tmp = new StringBuffer(super.toString());
+ tmp.append('[');
+ tmp.append("bindAddress=");
+ tmp.append(bindAddress);
+ tmp.append(']');
+ return tmp.toString();
+ }
+}
Modified: projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/JMXConnectorService.java
===================================================================
--- projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/JMXConnectorService.java 2010-02-24 15:50:11 UTC (rev 101405)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/JMXConnectorService.java 2010-02-24 16:01:57 UTC (rev 101406)
@@ -37,7 +37,6 @@
import javax.management.remote.JMXServiceURL;
import org.jboss.logging.Logger;
-import org.jboss.net.sockets.DefaultSocketFactory;
import org.osgi.framework.BundleContext;
/**
14 years, 3 months
JBoss-OSGI SVN: r101405 - projects/jboss-osgi/projects/bundles/blueprint/trunk.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-02-24 10:50:11 -0500 (Wed, 24 Feb 2010)
New Revision: 101405
Modified:
projects/jboss-osgi/projects/bundles/blueprint/trunk/pom.xml
Log:
Fix jmx groupid
Modified: projects/jboss-osgi/projects/bundles/blueprint/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/bundles/blueprint/trunk/pom.xml 2010-02-24 15:20:14 UTC (rev 101404)
+++ projects/jboss-osgi/projects/bundles/blueprint/trunk/pom.xml 2010-02-24 15:50:11 UTC (rev 101405)
@@ -111,7 +111,7 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.jboss.osgi.bundles</groupId>
+ <groupId>org.jboss.osgi.jmx</groupId>
<artifactId>jboss-osgi-jmx</artifactId>
<version>${version.jboss.osgi.jmx}</version>
<scope>provided</scope>
14 years, 3 months
JBoss-OSGI SVN: r101402 - projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/management.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-02-24 10:00:04 -0500 (Wed, 24 Feb 2010)
New Revision: 101402
Removed:
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/management/ManagedServiceReference.java
Log:
Remove ManagedServiceReference
Deleted: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/management/ManagedServiceReference.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/management/ManagedServiceReference.java 2010-02-24 14:59:23 UTC (rev 101401)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/management/ManagedServiceReference.java 2010-02-24 15:00:04 UTC (rev 101402)
@@ -1,66 +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;
-
-import java.io.Serializable;
-import java.util.Map;
-import java.util.Set;
-
-import org.osgi.framework.ServiceReference;
-
-/**
- * The management view of an OSGi {@link ServiceReference}
- *
- * @author Thomas.Diesler(a)jboss.org
- * @since 25-Sep-2008
- */
-public class ManagedServiceReference implements Serializable
-{
- private static final long serialVersionUID = 1L;
-
- private Map<String, Object> props;
-
- public ManagedServiceReference(Map<String, Object> props)
- {
- this.props = props;
- }
-
- /**
- * Returns the property value to which the specified property key is mapped
- * in the properties Dictionary object of the service referenced by this
- * ServiceReference object.
- */
- public Object getProperty(String key)
- {
- return props.get(key);
- }
-
- /**
- * Returns an array of the keys in the properties Dictionary
- * object of the service referenced by this ServiceReference object.
- */
- public String[] getPropertyKeys()
- {
- Set<String> keySet = props.keySet();
- return keySet.toArray(new String[keySet.size()]);
- }
-}
14 years, 3 months
JBoss-OSGI SVN: r101401 - in projects/jboss-osgi/projects/bundles/jmx/trunk: jmx-api/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: 2010-02-24 09:59:23 -0500 (Wed, 24 Feb 2010)
New Revision: 101401
Added:
projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-api/src/main/java/org/jboss/osgi/jmx/BundleStateMBeanExt.java
projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/AbstractStateMBean.java
projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/BundleState.java
projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/FrameworkState.java
projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/ServiceState.java
Removed:
projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/FrameworkImpl.java
projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/ServiceStateImpl.java
Modified:
projects/jboss-osgi/projects/bundles/jmx/trunk/EEG-Feedback-JMX.txt
projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-api/src/main/java/org/jboss/osgi/jmx/FrameworkMBeanExt.java
projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/JMXServiceActivator.java
Log:
Add BundleStateMBeanExt
Modified: projects/jboss-osgi/projects/bundles/jmx/trunk/EEG-Feedback-JMX.txt
===================================================================
--- projects/jboss-osgi/projects/bundles/jmx/trunk/EEG-Feedback-JMX.txt 2010-02-24 14:46:52 UTC (rev 101400)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/EEG-Feedback-JMX.txt 2010-02-24 14:59:23 UTC (rev 101401)
@@ -1,15 +1,2 @@
$Id$
-------------------------------------------------------------------------------------------
-JMX FrameworkMBean does not allow to resolve/refresh all bundles
-https://www.osgi.org/members/bugzilla/show_bug.cgi?id=1586
-
-The signature and API docs of
-
-FrameworkMBean.refreshBundles(long[] bundleIdentifiers)
-FrameworkMBean.resolveBundles(long[] bundleIdentifiers)
-
-does not obviously allow to resolve/refresh all bundles.
-
-A client would be forced to collect all ids before making the call.
-PackageAdmin however uses a null paramter to mean 'all bundles'.
Added: projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-api/src/main/java/org/jboss/osgi/jmx/BundleStateMBeanExt.java
===================================================================
--- projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-api/src/main/java/org/jboss/osgi/jmx/BundleStateMBeanExt.java (rev 0)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-api/src/main/java/org/jboss/osgi/jmx/BundleStateMBeanExt.java 2010-02-24 14:59:23 UTC (rev 101401)
@@ -0,0 +1,101 @@
+/*
+ * 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.io.IOException;
+
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.TabularData;
+
+import org.osgi.jmx.framework.BundleStateMBean;
+
+/**
+ * An extension to {@link BundleStateMBean}.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 24-Feb-2010
+ */
+public interface BundleStateMBeanExt extends BundleStateMBean
+{
+ /** The default object name: jboss.osgi:service=jmx,type=BundleState */
+ String OBJECTNAME = "jboss.osgi:service=jmx,type=BundleState";
+
+ /**
+ * Answer the bundle state for a single bundle.
+ * Composite Data that is type by {@link BundleStateMBean#BUNDLE_TYPE}.
+ *
+ * @param bundleId the bundle identifier
+ * @return The composite bundle information
+ * @throws IOException if the operation fails
+ * @throws IllegalArgumentException if the bundle indicated does not exist
+ */
+ CompositeData getBundle(long bundleId) throws IOException;
+
+ /**
+ * Answer the headers for the bundle uniquely identified by the bundle id.
+ * The Tabular Data is typed by the {@link BundleStateMBean#HEADERS_TYPE}.
+ *
+ * @param bundleId the unique identifier of the bundle
+ * @param locale The locale name into which the header values are to be localized.
+ * @throws IOException if the operation fails
+ * @throws IllegalArgumentException if the bundle indicated does not exist
+ */
+ TabularData getHeaders(long bundleId, String locale) throws IOException;
+
+ /**
+ * Loads the specified class using the class loader of the bundle with the given identifier.
+ *
+ * @param bundleId the unique identifier of the bundle
+ * @param name The name of the class to load
+ * @return The bundle id of the bundle that loaded the class.
+ * @throws ClassNotFoundException If no such class can be found or if the given bundle is a fragment bundle
+ */
+ long loadClass(long bundleId, String name) throws ClassNotFoundException, IOException;
+
+ /**
+ * Returns a string encoded URL to the entry at the specified path in the given bundle.
+ *
+ * @param bundleId the unique identifier of the bundle
+ * @param path The path name of the entry
+ * @return A URL to the entry, or null if no entry could be found
+ */
+ String getEntry(long bundleId, String path) throws IOException;
+
+ /**
+ * Find the specified resource from the given bundle's class loader.
+ *
+ * @param bundleId the unique identifier of the bundle
+ * @param name The name of the resource.
+ * @return A string encoded URL to the named resource, or null if the resource could not be found
+ */
+ String getResource(long bundleId, String name) throws IOException;
+
+ /**
+ * Get the string encoded file path in the persistent storage area provided for the given bundle.
+ *
+ * @param bundleId the unique identifier of the bundle
+ * @param filename A relative name to the file to be accessed
+ */
+ String getDataFile(long bundleId, String filename) throws IOException;
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-api/src/main/java/org/jboss/osgi/jmx/BundleStateMBeanExt.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-api/src/main/java/org/jboss/osgi/jmx/FrameworkMBeanExt.java
===================================================================
--- projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-api/src/main/java/org/jboss/osgi/jmx/FrameworkMBeanExt.java 2010-02-24 14:46:52 UTC (rev 101400)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-api/src/main/java/org/jboss/osgi/jmx/FrameworkMBeanExt.java 2010-02-24 14:59:23 UTC (rev 101401)
@@ -25,7 +25,6 @@
//$Id$
-
/**
* An extension to {@link FrameworkMBean}.
*
Added: projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/AbstractStateMBean.java
===================================================================
--- projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/AbstractStateMBean.java (rev 0)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/AbstractStateMBean.java 2010-02-24 14:59:23 UTC (rev 101401)
@@ -0,0 +1,120 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.jmx.internal;
+
+//$Id$
+
+import javax.management.JMException;
+import javax.management.MBeanServer;
+import javax.management.NotCompliantMBeanException;
+import javax.management.ObjectName;
+import javax.management.StandardMBean;
+
+import org.jboss.logging.Logger;
+import org.jboss.osgi.spi.management.MBeanProxy;
+import org.jboss.osgi.spi.management.ObjectNameFactory;
+import org.osgi.framework.BundleContext;
+import org.osgi.jmx.framework.BundleStateMBean;
+import org.osgi.jmx.framework.FrameworkMBean;
+import org.osgi.jmx.framework.ServiceStateMBean;
+
+/**
+ * An extension to {@link BundleStateMBean}.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 23-Feb-2010
+ */
+abstract class AbstractStateMBean
+{
+ // Provide logging
+ private static final Logger log = Logger.getLogger(AbstractStateMBean.class);
+
+ protected MBeanServer mbeanServer;
+ protected BundleContext context;
+
+ AbstractStateMBean(BundleContext context, MBeanServer mbeanServer)
+ {
+ if (context == null)
+ throw new IllegalArgumentException("Null BundleContext");
+ if (mbeanServer == null)
+ throw new IllegalArgumentException("Null MBeanServer");
+
+ if (context.getBundle().getBundleId() != 0)
+ throw new IllegalArgumentException("Not the system bundle context: " + context);
+
+ this.context = context;
+ this.mbeanServer = mbeanServer;
+ }
+
+ void start()
+ {
+ ObjectName objectName = getObjectName();
+ try
+ {
+ log.debug("Register: " + objectName);
+ mbeanServer.registerMBean(getStandardMBean(), objectName);
+ }
+ catch (JMException ex)
+ {
+ log.warn("Cannot register: " + objectName);
+ }
+ }
+
+ void stop()
+ {
+ ObjectName objectName = getObjectName();
+ try
+ {
+ if (mbeanServer.isRegistered(objectName))
+ {
+ log.debug("Unregister: " + objectName);
+ mbeanServer.unregisterMBean(objectName);
+ }
+ }
+ catch (JMException ex)
+ {
+ log.warn("Cannot unregister: " + objectName);
+ }
+ }
+
+ abstract StandardMBean getStandardMBean() throws NotCompliantMBeanException;
+
+ abstract ObjectName getObjectName();
+
+ FrameworkMBean getFrameworkMBean()
+ {
+ ObjectName objectName = ObjectNameFactory.create(FrameworkMBean.OBJECTNAME);
+ return MBeanProxy.get(mbeanServer, objectName, FrameworkMBean.class);
+ }
+
+ BundleStateMBean getBundleStateMBean()
+ {
+ ObjectName objectName = ObjectNameFactory.create(BundleStateMBean.OBJECTNAME);
+ return MBeanProxy.get(mbeanServer, objectName, BundleStateMBean.class);
+ }
+
+ ServiceStateMBean getServiceStateMBean()
+ {
+ ObjectName objectName = ObjectNameFactory.create(ServiceStateMBean.OBJECTNAME);
+ return MBeanProxy.get(mbeanServer, objectName, ServiceStateMBean.class);
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/AbstractStateMBean.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/BundleState.java
===================================================================
--- projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/BundleState.java (rev 0)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/BundleState.java 2010-02-24 14:59:23 UTC (rev 101401)
@@ -0,0 +1,236 @@
+/*
+ * 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.File;
+import java.io.IOException;
+import java.net.URL;
+import java.util.Dictionary;
+
+import javax.management.MBeanServer;
+import javax.management.NotCompliantMBeanException;
+import javax.management.ObjectName;
+import javax.management.StandardMBean;
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.TabularData;
+
+import org.jboss.logging.Logger;
+import org.jboss.osgi.jmx.BundleStateMBeanExt;
+import org.jboss.osgi.spi.management.ObjectNameFactory;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.jmx.framework.BundleStateMBean;
+import org.osgi.service.packageadmin.PackageAdmin;
+
+/**
+ * An extension to {@link BundleStateMBean}.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 23-Feb-2010
+ */
+public class BundleState extends AbstractStateMBean implements BundleStateMBeanExt
+{
+ public BundleState(BundleContext context, MBeanServer mbeanServer)
+ {
+ super(context, mbeanServer);
+ }
+
+ @Override
+ ObjectName getObjectName()
+ {
+ return ObjectNameFactory.create(OBJECTNAME);
+ }
+
+ @Override
+ StandardMBean getStandardMBean() throws NotCompliantMBeanException
+ {
+ return new StandardMBean(this, BundleStateMBeanExt.class);
+ }
+
+ @Override
+ public CompositeData getBundle(long bundleId) throws IOException
+ {
+ TabularData bundleList = listBundles();
+ CompositeData bundleData = bundleList.get(new Object[] { (Long)bundleId });
+ if (bundleData == null)
+ throw new IllegalArgumentException("No such bundle: " + bundleId);
+ return bundleData;
+ }
+
+ @Override
+ public String getDataFile(long bundleId, String filename) throws IOException
+ {
+ Bundle bundle = assertBundle(bundleId);
+ File dataFile = bundle.getBundleContext().getDataFile(filename);
+ return dataFile.getCanonicalPath();
+ }
+
+ @Override
+ public String getEntry(long bundleId, String path) throws IOException
+ {
+ Bundle bundle = assertBundle(bundleId);
+ URL entry = bundle.getEntry(path);
+ return entry.toExternalForm();
+ }
+
+ @Override
+ public TabularData getHeaders(long bundleId, String locale) throws IOException
+ {
+ Bundle bundle = assertBundle(bundleId);
+ Dictionary<String, String> headers = bundle.getHeaders(locale);
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getResource(long bundleId, String name) throws IOException
+ {
+ Bundle bundle = assertBundle(bundleId);
+ URL entry = bundle.getResource(name);
+ return entry.toExternalForm();
+ }
+
+ @Override
+ public long loadClass(long bundleId, String name) throws ClassNotFoundException, IOException
+ {
+ Bundle bundle = assertBundle(bundleId);
+ Class<?> clazz = bundle.loadClass(name);
+ ServiceReference sref = context.getServiceReference(PackageAdmin.class.getName());
+ PackageAdmin service = (PackageAdmin)context.getService(sref);
+ Bundle exporter = service.getBundle(clazz);
+ if (exporter == null)
+ return 0;
+
+ return exporter.getBundleId();
+ }
+
+ public String[] getExportedPackages(long arg0) throws IOException
+ {
+ return getBundleStateMBean().getExportedPackages(arg0);
+ }
+
+ public long[] getFragments(long arg0) throws IOException
+ {
+ return getBundleStateMBean().getFragments(arg0);
+ }
+
+ public TabularData getHeaders(long arg0) throws IOException
+ {
+ return getBundleStateMBean().getHeaders(arg0);
+ }
+
+ public long[] getHosts(long arg0) throws IOException
+ {
+ return getBundleStateMBean().getHosts(arg0);
+ }
+
+ public String[] getImportedPackages(long arg0) throws IOException
+ {
+ return getBundleStateMBean().getImportedPackages(arg0);
+ }
+
+ public long getLastModified(long arg0) throws IOException
+ {
+ return getBundleStateMBean().getLastModified(arg0);
+ }
+
+ public String getLocation(long arg0) throws IOException
+ {
+ return getBundleStateMBean().getLocation(arg0);
+ }
+
+ public long[] getRegisteredServices(long arg0) throws IOException
+ {
+ return getBundleStateMBean().getRegisteredServices(arg0);
+ }
+
+ public long[] getRequiredBundles(long arg0) throws IOException
+ {
+ return getBundleStateMBean().getRequiredBundles(arg0);
+ }
+
+ public long[] getRequiringBundles(long arg0) throws IOException
+ {
+ return getBundleStateMBean().getRequiringBundles(arg0);
+ }
+
+ public long[] getServicesInUse(long arg0) throws IOException
+ {
+ return getBundleStateMBean().getServicesInUse(arg0);
+ }
+
+ public int getStartLevel(long arg0) throws IOException
+ {
+ return getBundleStateMBean().getStartLevel(arg0);
+ }
+
+ public String getState(long arg0) throws IOException
+ {
+ return getBundleStateMBean().getState(arg0);
+ }
+
+ public String getSymbolicName(long arg0) throws IOException
+ {
+ return getBundleStateMBean().getSymbolicName(arg0);
+ }
+
+ public String getVersion(long arg0) throws IOException
+ {
+ return getBundleStateMBean().getVersion(arg0);
+ }
+
+ public boolean isFragment(long arg0) throws IOException
+ {
+ return getBundleStateMBean().isFragment(arg0);
+ }
+
+ public boolean isPersistentlyStarted(long arg0) throws IOException
+ {
+ return getBundleStateMBean().isPersistentlyStarted(arg0);
+ }
+
+ public boolean isRemovalPending(long arg0) throws IOException
+ {
+ return getBundleStateMBean().isRemovalPending(arg0);
+ }
+
+ public boolean isRequired(long arg0) throws IOException
+ {
+ return getBundleStateMBean().isRequired(arg0);
+ }
+
+ public TabularData listBundles() throws IOException
+ {
+ return getBundleStateMBean().listBundles();
+ }
+
+ private Bundle assertBundle(long bundleId)
+ {
+ Bundle bundle = context.getBundle(bundleId);
+ if (bundle == null)
+ throw new IllegalArgumentException("No such bundle: " + bundleId);
+ return bundle;
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/BundleState.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Deleted: projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/FrameworkImpl.java
===================================================================
--- projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/FrameworkImpl.java 2010-02-24 14:46:52 UTC (rev 101400)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/FrameworkImpl.java 2010-02-24 14:59:23 UTC (rev 101401)
@@ -1,266 +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.JMException;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-import javax.management.StandardMBean;
-import javax.management.openmbean.CompositeData;
-
-import org.jboss.logging.Logger;
-import org.jboss.osgi.jmx.FrameworkMBeanExt;
-import org.jboss.osgi.spi.management.MBeanProxy;
-import org.jboss.osgi.spi.management.ObjectNameFactory;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.jmx.framework.FrameworkMBean;
-import org.osgi.service.packageadmin.PackageAdmin;
-
-/**
- * An extension to {@link FrameworkMBean}.
- *
- * @author thomas.diesler(a)jboss.com
- * @since 23-Feb-2009
- */
-public class FrameworkImpl implements FrameworkMBeanExt
-{
- // Provide logging
- private static final Logger log = Logger.getLogger(FrameworkImpl.class);
-
- private MBeanServer mbeanServer;
- private BundleContext context;
- private FrameworkMBean delegate;
-
- public FrameworkImpl(BundleContext context, MBeanServer mbeanServer)
- {
- if (context == null)
- throw new IllegalArgumentException("Null BundleContext");
- if (mbeanServer == null)
- throw new IllegalArgumentException("Null MBeanServer");
-
- if (context.getBundle().getBundleId() != 0)
- throw new IllegalArgumentException("Not the system bundle context: " + context);
-
- this.context = context;
- this.mbeanServer = mbeanServer;
- }
-
- @Override
- public void refreshAllPackages()
- {
- if (log.isTraceEnabled())
- log.trace("refreshPackages(null)");
-
- ServiceReference sref = context.getServiceReference(PackageAdmin.class.getName());
- PackageAdmin service = (PackageAdmin)context.getService(sref);
- service.refreshPackages(null);
- }
-
- @Override
- public boolean resolveAllBundles()
- {
- if (log.isTraceEnabled())
- log.trace("resolveBundles(null)");
-
- ServiceReference sref = context.getServiceReference(PackageAdmin.class.getName());
- PackageAdmin service = (PackageAdmin)context.getService(sref);
- return service.resolveBundles(null);
- }
-
- void start()
- {
- try
- {
- ObjectName objectName = ObjectNameFactory.create(FrameworkMBeanExt.OBJECTNAME);
- StandardMBean mbean = new StandardMBean(this, FrameworkMBeanExt.class);
- mbeanServer.registerMBean(mbean, objectName);
- }
- catch (JMException ex)
- {
- log.warn("Cannot register: " + FrameworkMBeanExt.OBJECTNAME);
- }
- }
-
- void stop()
- {
- try
- {
- ObjectName objectName = ObjectNameFactory.create(FrameworkMBeanExt.OBJECTNAME);
- if (mbeanServer.isRegistered(objectName))
- mbeanServer.unregisterMBean(objectName);
- }
- catch (JMException ex)
- {
- log.warn("Cannot register: " + FrameworkMBeanExt.OBJECTNAME);
- }
- }
-
- public int getFrameworkStartLevel() throws IOException
- {
- return getFrameworkMBean().getFrameworkStartLevel();
- }
-
- public int getInitialBundleStartLevel() throws IOException
- {
- return getFrameworkMBean().getInitialBundleStartLevel();
- }
-
- public long installBundle(String arg0, String arg1) throws IOException
- {
- return getFrameworkMBean().installBundle(arg0, arg1);
- }
-
- public long installBundle(String arg0) throws IOException
- {
- return getFrameworkMBean().installBundle(arg0);
- }
-
- public CompositeData installBundles(String[] arg0, String[] arg1) throws IOException
- {
- return getFrameworkMBean().installBundles(arg0, arg1);
- }
-
- public CompositeData installBundles(String[] arg0) throws IOException
- {
- return getFrameworkMBean().installBundles(arg0);
- }
-
- public void refreshPackages(long arg0) throws IOException
- {
- getFrameworkMBean().refreshPackages(arg0);
- }
-
- public CompositeData refreshPackages(long[] arg0) throws IOException
- {
- return getFrameworkMBean().refreshPackages(arg0);
- }
-
- public boolean resolveBundle(long arg0) throws IOException
- {
- return getFrameworkMBean().resolveBundle(arg0);
- }
-
- public boolean resolveBundles(long[] arg0) throws IOException
- {
- return getFrameworkMBean().resolveBundles(arg0);
- }
-
- public void restartFramework() throws IOException
- {
- getFrameworkMBean().restartFramework();
- }
-
- public void setBundleStartLevel(long arg0, int arg1) throws IOException
- {
- getFrameworkMBean().setBundleStartLevel(arg0, arg1);
- }
-
- public CompositeData setBundleStartLevels(long[] arg0, int[] arg1) throws IOException
- {
- return getFrameworkMBean().setBundleStartLevels(arg0, arg1);
- }
-
- public void setFrameworkStartLevel(int arg0) throws IOException
- {
- getFrameworkMBean().setFrameworkStartLevel(arg0);
- }
-
- public void setInitialBundleStartLevel(int arg0) throws IOException
- {
- getFrameworkMBean().setInitialBundleStartLevel(arg0);
- }
-
- public void shutdownFramework() throws IOException
- {
- getFrameworkMBean().shutdownFramework();
- }
-
- public void startBundle(long arg0) throws IOException
- {
- getFrameworkMBean().startBundle(arg0);
- }
-
- public CompositeData startBundles(long[] arg0) throws IOException
- {
- return getFrameworkMBean().startBundles(arg0);
- }
-
- public void stopBundle(long arg0) throws IOException
- {
- getFrameworkMBean().stopBundle(arg0);
- }
-
- public CompositeData stopBundles(long[] arg0) throws IOException
- {
- return getFrameworkMBean().stopBundles(arg0);
- }
-
- public void uninstallBundle(long arg0) throws IOException
- {
- getFrameworkMBean().uninstallBundle(arg0);
- }
-
- public CompositeData uninstallBundles(long[] arg0) throws IOException
- {
- return getFrameworkMBean().uninstallBundles(arg0);
- }
-
- public void updateBundle(long arg0, String arg1) throws IOException
- {
- getFrameworkMBean().updateBundle(arg0, arg1);
- }
-
- public void updateBundle(long arg0) throws IOException
- {
- getFrameworkMBean().updateBundle(arg0);
- }
-
- public CompositeData updateBundles(long[] arg0, String[] arg1) throws IOException
- {
- return getFrameworkMBean().updateBundles(arg0, arg1);
- }
-
- public CompositeData updateBundles(long[] arg0) throws IOException
- {
- return getFrameworkMBean().updateBundles(arg0);
- }
-
- public void updateFramework() throws IOException
- {
- getFrameworkMBean().updateFramework();
- }
-
- private FrameworkMBean getFrameworkMBean()
- {
- if (delegate == null)
- {
- ObjectName objectName = ObjectNameFactory.create(FrameworkMBean.OBJECTNAME);
- delegate = MBeanProxy.get(mbeanServer, objectName, FrameworkMBean.class);
- }
- return delegate;
- }
-}
\ No newline at end of file
Copied: projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/FrameworkState.java (from rev 101378, projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/FrameworkImpl.java)
===================================================================
--- projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/FrameworkState.java (rev 0)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/FrameworkState.java 2010-02-24 14:59:23 UTC (rev 101401)
@@ -0,0 +1,217 @@
+/*
+ * 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.NotCompliantMBeanException;
+import javax.management.ObjectName;
+import javax.management.StandardMBean;
+import javax.management.openmbean.CompositeData;
+
+import org.jboss.osgi.jmx.FrameworkMBeanExt;
+import org.jboss.osgi.spi.management.ObjectNameFactory;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.jmx.framework.FrameworkMBean;
+import org.osgi.service.packageadmin.PackageAdmin;
+
+/**
+ * An extension to {@link FrameworkMBean}.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 23-Feb-2009
+ */
+public class FrameworkState extends AbstractStateMBean implements FrameworkMBeanExt
+{
+
+ public FrameworkState(BundleContext context, MBeanServer mbeanServer)
+ {
+ super(context, mbeanServer);
+ }
+
+ @Override
+ ObjectName getObjectName()
+ {
+ return ObjectNameFactory.create(OBJECTNAME);
+ }
+
+ @Override
+ StandardMBean getStandardMBean() throws NotCompliantMBeanException
+ {
+ return new StandardMBean(this, FrameworkMBeanExt.class);
+ }
+
+ @Override
+ public void refreshAllPackages()
+ {
+ ServiceReference sref = context.getServiceReference(PackageAdmin.class.getName());
+ PackageAdmin service = (PackageAdmin)context.getService(sref);
+ service.refreshPackages(null);
+ }
+
+ @Override
+ public boolean resolveAllBundles()
+ {
+ ServiceReference sref = context.getServiceReference(PackageAdmin.class.getName());
+ PackageAdmin service = (PackageAdmin)context.getService(sref);
+ return service.resolveBundles(null);
+ }
+
+ public int getFrameworkStartLevel() throws IOException
+ {
+ return getFrameworkMBean().getFrameworkStartLevel();
+ }
+
+ public int getInitialBundleStartLevel() throws IOException
+ {
+ return getFrameworkMBean().getInitialBundleStartLevel();
+ }
+
+ public long installBundle(String arg0, String arg1) throws IOException
+ {
+ return getFrameworkMBean().installBundle(arg0, arg1);
+ }
+
+ public long installBundle(String arg0) throws IOException
+ {
+ return getFrameworkMBean().installBundle(arg0);
+ }
+
+ public CompositeData installBundles(String[] arg0, String[] arg1) throws IOException
+ {
+ return getFrameworkMBean().installBundles(arg0, arg1);
+ }
+
+ public CompositeData installBundles(String[] arg0) throws IOException
+ {
+ return getFrameworkMBean().installBundles(arg0);
+ }
+
+ public void refreshPackages(long arg0) throws IOException
+ {
+ getFrameworkMBean().refreshPackages(arg0);
+ }
+
+ public CompositeData refreshPackages(long[] arg0) throws IOException
+ {
+ return getFrameworkMBean().refreshPackages(arg0);
+ }
+
+ public boolean resolveBundle(long arg0) throws IOException
+ {
+ return getFrameworkMBean().resolveBundle(arg0);
+ }
+
+ public boolean resolveBundles(long[] arg0) throws IOException
+ {
+ return getFrameworkMBean().resolveBundles(arg0);
+ }
+
+ public void restartFramework() throws IOException
+ {
+ getFrameworkMBean().restartFramework();
+ }
+
+ public void setBundleStartLevel(long arg0, int arg1) throws IOException
+ {
+ getFrameworkMBean().setBundleStartLevel(arg0, arg1);
+ }
+
+ public CompositeData setBundleStartLevels(long[] arg0, int[] arg1) throws IOException
+ {
+ return getFrameworkMBean().setBundleStartLevels(arg0, arg1);
+ }
+
+ public void setFrameworkStartLevel(int arg0) throws IOException
+ {
+ getFrameworkMBean().setFrameworkStartLevel(arg0);
+ }
+
+ public void setInitialBundleStartLevel(int arg0) throws IOException
+ {
+ getFrameworkMBean().setInitialBundleStartLevel(arg0);
+ }
+
+ public void shutdownFramework() throws IOException
+ {
+ getFrameworkMBean().shutdownFramework();
+ }
+
+ public void startBundle(long arg0) throws IOException
+ {
+ getFrameworkMBean().startBundle(arg0);
+ }
+
+ public CompositeData startBundles(long[] arg0) throws IOException
+ {
+ return getFrameworkMBean().startBundles(arg0);
+ }
+
+ public void stopBundle(long arg0) throws IOException
+ {
+ getFrameworkMBean().stopBundle(arg0);
+ }
+
+ public CompositeData stopBundles(long[] arg0) throws IOException
+ {
+ return getFrameworkMBean().stopBundles(arg0);
+ }
+
+ public void uninstallBundle(long arg0) throws IOException
+ {
+ getFrameworkMBean().uninstallBundle(arg0);
+ }
+
+ public CompositeData uninstallBundles(long[] arg0) throws IOException
+ {
+ return getFrameworkMBean().uninstallBundles(arg0);
+ }
+
+ public void updateBundle(long arg0, String arg1) throws IOException
+ {
+ getFrameworkMBean().updateBundle(arg0, arg1);
+ }
+
+ public void updateBundle(long arg0) throws IOException
+ {
+ getFrameworkMBean().updateBundle(arg0);
+ }
+
+ public CompositeData updateBundles(long[] arg0, String[] arg1) throws IOException
+ {
+ return getFrameworkMBean().updateBundles(arg0, arg1);
+ }
+
+ public CompositeData updateBundles(long[] arg0) throws IOException
+ {
+ return getFrameworkMBean().updateBundles(arg0);
+ }
+
+ public void updateFramework() throws IOException
+ {
+ getFrameworkMBean().updateFramework();
+ }
+}
\ No newline at end of file
Modified: projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/JMXServiceActivator.java
===================================================================
--- projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/JMXServiceActivator.java 2010-02-24 14:46:52 UTC (rev 101400)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/JMXServiceActivator.java 2010-02-24 14:59:23 UTC (rev 101401)
@@ -56,8 +56,8 @@
private String jmxRmiPort;
private String rmiAdaptorPath;
private MBeanServer mbeanServer;
- private FrameworkImpl framework;
- private ServiceStateImpl serviceState;
+ private FrameworkState framework;
+ private ServiceState serviceState;
private ManagedBundleTracker bundleTracker;
public void start(BundleContext context)
@@ -70,11 +70,11 @@
BundleContext sysContext = context.getBundle(0).getBundleContext();
// Register the FrameworkMBean
- framework = new FrameworkImpl(sysContext, mbeanServer);
+ framework = new FrameworkState(sysContext, mbeanServer);
framework.start();
// Register the ServiceStateMBean
- serviceState = new ServiceStateImpl(sysContext, mbeanServer);
+ serviceState = new ServiceState(sysContext, mbeanServer);
serviceState.start();
// Start tracking the bundles
Copied: projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/ServiceState.java (from rev 101378, projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/ServiceStateImpl.java)
===================================================================
--- projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/ServiceState.java (rev 0)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/ServiceState.java 2010-02-24 14:59:23 UTC (rev 101401)
@@ -0,0 +1,165 @@
+/*
+ * 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 java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.management.MBeanServer;
+import javax.management.NotCompliantMBeanException;
+import javax.management.ObjectName;
+import javax.management.StandardMBean;
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeDataSupport;
+import javax.management.openmbean.OpenDataException;
+import javax.management.openmbean.TabularData;
+import javax.management.openmbean.TabularDataSupport;
+
+import org.jboss.osgi.jmx.ServiceStateMBeanExt;
+import org.jboss.osgi.spi.management.ObjectNameFactory;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.jmx.framework.ServiceStateMBean;
+
+/**
+ * An extension to {@link ServiceStateMBean}.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 23-Feb-2010
+ */
+public class ServiceState extends AbstractStateMBean implements ServiceStateMBeanExt
+{
+ public ServiceState(BundleContext context, MBeanServer mbeanServer)
+ {
+ super(context, mbeanServer);
+ }
+
+ @Override
+ ObjectName getObjectName()
+ {
+ return ObjectNameFactory.create(OBJECTNAME);
+ }
+
+ @Override
+ StandardMBean getStandardMBean() throws NotCompliantMBeanException
+ {
+ return new StandardMBean(this, ServiceStateMBeanExt.class);
+ }
+
+ @Override
+ public CompositeData getService(String clazz) throws IOException
+ {
+ ServiceReference sref = context.getServiceReference(clazz);
+ if (sref == null)
+ return null;
+
+ return getCompositeData(sref);
+ }
+
+ @Override
+ public TabularData getServices(String clazz, String filter) throws IOException
+ {
+ ServiceReference[] srefs;
+ try
+ {
+ srefs = context.getServiceReferences(clazz, filter);
+ }
+ catch (InvalidSyntaxException e)
+ {
+ throw new IllegalArgumentException("Invalid filter syntax: " + filter);
+ }
+
+ if (srefs == null)
+ return null;
+
+ TabularDataSupport tabularData = new TabularDataSupport(SERVICES_TYPE);
+ for (ServiceReference sref : srefs)
+ {
+ CompositeDataSupport compData = getCompositeData(sref);
+ tabularData.put(compData.get(IDENTIFIER), compData);
+ }
+
+ return tabularData;
+ }
+
+ private CompositeDataSupport getCompositeData(ServiceReference sref) throws IOException
+ {
+ Long serviceId = (Long)sref.getProperty(Constants.SERVICE_ID);
+
+ List<Long> usingBundles = new ArrayList<Long>();
+ for (Bundle aux : sref.getUsingBundles())
+ usingBundles.add(aux.getBundleId());
+
+ Map<String, Object> items = new HashMap<String, Object>();
+ items.put(BUNDLE_IDENTIFIER, sref.getBundle().getBundleId());
+ items.put(IDENTIFIER, serviceId);
+ items.put(OBJECT_CLASS, sref.getProperty(Constants.OBJECTCLASS));
+ items.put(USING_BUNDLES, usingBundles.toArray(new Long[usingBundles.size()]));
+
+ // [TODO] Remove once ServiceType does not require this item any more
+ items.put(PROPERTIES, getProperties(serviceId));
+
+ CompositeDataSupport compData;
+ try
+ {
+ compData = new CompositeDataSupport(SERVICE_TYPE, items);
+ }
+ catch (OpenDataException ex)
+ {
+ throw new IllegalStateException(ex);
+ }
+ return compData;
+ }
+
+ public long getBundleIdentifier(long arg0) throws IOException
+ {
+ return getServiceStateMBean().getBundleIdentifier(arg0);
+ }
+
+ public String[] getObjectClass(long arg0) throws IOException
+ {
+ return getServiceStateMBean().getObjectClass(arg0);
+ }
+
+ public TabularData getProperties(long arg0) throws IOException
+ {
+ return getServiceStateMBean().getProperties(arg0);
+ }
+
+ public long[] getUsingBundles(long arg0) throws IOException
+ {
+ return getServiceStateMBean().getUsingBundles(arg0);
+ }
+
+ public TabularData listServices() throws IOException
+ {
+ return getServiceStateMBean().listServices();
+ }
+}
\ No newline at end of file
Deleted: projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/ServiceStateImpl.java
===================================================================
--- projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/ServiceStateImpl.java 2010-02-24 14:46:52 UTC (rev 101400)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/ServiceStateImpl.java 2010-02-24 14:59:23 UTC (rev 101401)
@@ -1,210 +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 java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.management.JMException;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-import javax.management.StandardMBean;
-import javax.management.openmbean.CompositeData;
-import javax.management.openmbean.CompositeDataSupport;
-import javax.management.openmbean.OpenDataException;
-import javax.management.openmbean.TabularData;
-import javax.management.openmbean.TabularDataSupport;
-
-import org.jboss.logging.Logger;
-import org.jboss.osgi.jmx.FrameworkMBeanExt;
-import org.jboss.osgi.jmx.ServiceStateMBeanExt;
-import org.jboss.osgi.spi.management.MBeanProxy;
-import org.jboss.osgi.spi.management.ObjectNameFactory;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.jmx.framework.ServiceStateMBean;
-
-/**
- * An extension to {@link ServiceStateMBean}.
- *
- * @author thomas.diesler(a)jboss.com
- * @since 23-Feb-2010
- */
-public class ServiceStateImpl implements ServiceStateMBeanExt
-{
- // Provide logging
- private static final Logger log = Logger.getLogger(ServiceStateImpl.class);
-
- private MBeanServer mbeanServer;
- private BundleContext context;
- private ServiceStateMBean delegate;
-
- public ServiceStateImpl(BundleContext context, MBeanServer mbeanServer)
- {
- if (context == null)
- throw new IllegalArgumentException("Null BundleContext");
- if (mbeanServer == null)
- throw new IllegalArgumentException("Null MBeanServer");
-
- if (context.getBundle().getBundleId() != 0)
- throw new IllegalArgumentException("Not the system bundle context: " + context);
-
- this.context = context;
- this.mbeanServer = mbeanServer;
- }
-
- @Override
- public CompositeData getService(String clazz) throws IOException
- {
- ServiceReference sref = context.getServiceReference(clazz);
- if (sref == null)
- return null;
-
- return getCompositeData(sref);
- }
-
- @Override
- public TabularData getServices(String clazz, String filter) throws IOException
- {
- ServiceReference[] srefs;
- try
- {
- srefs = context.getServiceReferences(clazz, filter);
- }
- catch (InvalidSyntaxException e)
- {
- throw new IllegalArgumentException("Invalid filter syntax: " + filter);
- }
-
- if (srefs == null)
- return null;
-
- TabularDataSupport tabularData = new TabularDataSupport(SERVICES_TYPE);
- for (ServiceReference sref : srefs)
- {
- CompositeDataSupport compData = getCompositeData(sref);
- tabularData.put(compData.get(IDENTIFIER), compData);
- }
-
- return tabularData;
- }
-
- private CompositeDataSupport getCompositeData(ServiceReference sref) throws IOException
- {
- Long serviceId = (Long)sref.getProperty(Constants.SERVICE_ID);
-
- List<Long> usingBundles = new ArrayList<Long>();
- for (Bundle aux : sref.getUsingBundles())
- usingBundles.add(aux.getBundleId());
-
- Map<String, Object> items = new HashMap<String, Object>();
- items.put(BUNDLE_IDENTIFIER, sref.getBundle().getBundleId());
- items.put(IDENTIFIER, serviceId);
- items.put(OBJECT_CLASS, sref.getProperty(Constants.OBJECTCLASS));
- items.put(USING_BUNDLES, usingBundles.toArray(new Long[usingBundles.size()]));
-
- // [TODO] Remove once ServiceType does not require this item any more
- items.put(PROPERTIES, getProperties(serviceId));
-
- CompositeDataSupport compData;
- try
- {
- compData = new CompositeDataSupport(SERVICE_TYPE, items);
- }
- catch (OpenDataException ex)
- {
- throw new IllegalStateException(ex);
- }
- return compData;
- }
-
- void start()
- {
- try
- {
- ObjectName objectName = ObjectNameFactory.create(ServiceStateMBeanExt.OBJECTNAME);
- StandardMBean mbean = new StandardMBean(this, ServiceStateMBeanExt.class);
- mbeanServer.registerMBean(mbean, objectName);
- }
- catch (JMException ex)
- {
- log.warn("Cannot register: " + FrameworkMBeanExt.OBJECTNAME);
- }
- }
-
- void stop()
- {
- try
- {
- ObjectName objectName = ObjectNameFactory.create(ServiceStateMBeanExt.OBJECTNAME);
- if (mbeanServer.isRegistered(objectName))
- mbeanServer.unregisterMBean(objectName);
- }
- catch (JMException ex)
- {
- log.warn("Cannot register: " + FrameworkMBeanExt.OBJECTNAME);
- }
- }
-
- public long getBundleIdentifier(long arg0) throws IOException
- {
- return getServiceStateMBean().getBundleIdentifier(arg0);
- }
-
- public String[] getObjectClass(long arg0) throws IOException
- {
- return getServiceStateMBean().getObjectClass(arg0);
- }
-
- public TabularData getProperties(long arg0) throws IOException
- {
- return getServiceStateMBean().getProperties(arg0);
- }
-
- public long[] getUsingBundles(long arg0) throws IOException
- {
- return getServiceStateMBean().getUsingBundles(arg0);
- }
-
- public TabularData listServices() throws IOException
- {
- return getServiceStateMBean().listServices();
- }
-
- private ServiceStateMBean getServiceStateMBean()
- {
- if (delegate == null)
- {
- ObjectName objectName = ObjectNameFactory.create(ServiceStateMBean.OBJECTNAME);
- delegate = MBeanProxy.get(mbeanServer, objectName, ServiceStateMBean.class);
- }
- return delegate;
- }
-}
\ No newline at end of file
14 years, 3 months
JBoss-OSGI SVN: r101395 - projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/packageadmin.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-02-24 09:03:28 -0500 (Wed, 24 Feb 2010)
New Revision: 101395
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/packageadmin/PackageAdminImpl.java
Log:
typo
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/packageadmin/PackageAdminImpl.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/packageadmin/PackageAdminImpl.java 2010-02-24 14:01:55 UTC (rev 101394)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/packageadmin/PackageAdminImpl.java 2010-02-24 14:03:28 UTC (rev 101395)
@@ -393,7 +393,7 @@
if (foundExecEnv == false)
{
- String msg = "Cannot find any of the required execution environments " + reqExecEnvs + ", we have: " + fwExecEnvs;
+ String msg = "Cannot find required execution environment " + reqExecEnvs + ", we have: " + fwExecEnvs;
if (errorOnFail == true)
throw new BundleException(msg);
14 years, 3 months
JBoss-OSGI SVN: r101392 - projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/packageadmin.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2010-02-24 08:04:28 -0500 (Wed, 24 Feb 2010)
New Revision: 101392
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/packageadmin/PackageAdminImpl.java
Log:
[JBOSGI-267] Allow multiple bundles to change state at once
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/packageadmin/PackageAdminImpl.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/packageadmin/PackageAdminImpl.java 2010-02-24 12:58:50 UTC (rev 101391)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/packageadmin/PackageAdminImpl.java 2010-02-24 13:04:28 UTC (rev 101392)
@@ -320,9 +320,8 @@
// We can only return true if all bundles are resolvable.
boolean allResolved = resolvableBundles.containsAll(unresolvedBundles);
- // TODO [JBDEPLOY-226] Allow multiple deployments to change state at once
- resolveBundles(resolvableBundles);
-
+ // Advance the bundles to stage CLASSLOADER and check at the end
+ advanceBundlesToClassloader(resolvableBundles);
try
{
DeployerClient deployerClient = getBundleManager().getDeployerClient();
@@ -337,7 +336,7 @@
return allResolved;
}
- private void resolveBundles(List<OSGiBundleState> resolvableBundles)
+ private void advanceBundlesToClassloader(List<OSGiBundleState> resolvableBundles)
{
for (OSGiBundleState bundleState: resolvableBundles)
{
@@ -363,10 +362,6 @@
String fragUnitName = fragment.getDeploymentUnit().getName();
deployerClient.change(fragUnitName, DeploymentStages.CLASSLOADER);
}
-
- // bundleState.changeState(Bundle.RESOLVED);
- // for (OSGiFragmentState fragment : bundleState.getAttachedFragments())
- // fragment.changeState(Bundle.RESOLVED);
}
catch (DeploymentException ex)
{
14 years, 3 months