[jboss-cvs] JBossAS SVN: r101529 - in projects/jboss-osgi/projects: bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Feb 26 06:55:50 EST 2010
Author: thomas.diesler at jboss.com
Date: 2010-02-26 06:55:48 -0500 (Fri, 26 Feb 2010)
New Revision: 101529
Added:
projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-api/src/main/java/org/jboss/osgi/jmx/PackageStateMBeanExt.java
projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/PackageStateExt.java
Removed:
projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/OSGiPackageAdmin.java
projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedPackageAdmin.java
projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemotePackageAdmin.java
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-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/FrameworkStateExt.java
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/OSGiRuntime.java
projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedRuntime.java
projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiRuntimeImpl.java
projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteRuntime.java
Log:
Migrate OSGiPackageAdmin to FrameworkMBean
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-26 11:52:33 UTC (rev 101528)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-api/src/main/java/org/jboss/osgi/jmx/FrameworkMBeanExt.java 2010-02-26 11:55:48 UTC (rev 101529)
@@ -21,6 +21,8 @@
*/
package org.jboss.osgi.jmx;
+import java.io.IOException;
+
import org.osgi.jmx.framework.FrameworkMBean;
//$Id$
@@ -37,18 +39,18 @@
String OBJECTNAME = "jboss.osgi:service=jmx,type=Framework";
/**
- * Refresh packages through the PackageAdmin service
+ * Force the update, replacement or removal of the packages identified by the list of bundles.
*
* JMX FrameworkMBean does not allow to resolve/refresh all bundles
- * https://www.osgi.org/members/bugzilla/show_bug.cgi?id=1586
+ * https://issues.apache.org/jira/browse/ARIES-177
*/
- void refreshAllPackages();
+ void refreshBundles(long[] bundleIdentifiers) throws IOException;
/**
- * Resolve bundles through the PackageAdmin service
+ * Force the update, replacement or removal of the packages identified by the specified bundle.
*
* JMX FrameworkMBean does not allow to resolve/refresh all bundles
- * https://www.osgi.org/members/bugzilla/show_bug.cgi?id=1586
+ * https://issues.apache.org/jira/browse/ARIES-177
*/
- boolean resolveAllBundles();
+ void refreshBundle(long bundleIdentifier) throws IOException;
}
\ No newline at end of file
Added: projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-api/src/main/java/org/jboss/osgi/jmx/PackageStateMBeanExt.java
===================================================================
--- projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-api/src/main/java/org/jboss/osgi/jmx/PackageStateMBeanExt.java (rev 0)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-api/src/main/java/org/jboss/osgi/jmx/PackageStateMBeanExt.java 2010-02-26 11:55:48 UTC (rev 101529)
@@ -0,0 +1,38 @@
+/*
+ * 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 org.osgi.jmx.framework.PackageStateMBean;
+
+/**
+ * An extension to {@link PackageStateMBean}.
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 24-Feb-2010
+ */
+public interface PackageStateMBeanExt extends PackageStateMBean
+{
+ /** The default object name: jboss.osgi:service=jmx,type=PackageState */
+ String OBJECTNAME = "jboss.osgi:service=jmx,type=PackageState";
+}
\ 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/PackageStateMBeanExt.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: 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/AbstractState.java 2010-02-26 11:52:33 UTC (rev 101528)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/AbstractState.java 2010-02-26 11:55:48 UTC (rev 101529)
@@ -35,6 +35,7 @@
import org.osgi.framework.BundleContext;
import org.osgi.jmx.framework.BundleStateMBean;
import org.osgi.jmx.framework.FrameworkMBean;
+import org.osgi.jmx.framework.PackageStateMBean;
import org.osgi.jmx.framework.ServiceStateMBean;
/**
@@ -117,4 +118,10 @@
ObjectName objectName = ObjectNameFactory.create(ServiceStateMBean.OBJECTNAME);
return MBeanProxy.get(mbeanServer, objectName, ServiceStateMBean.class);
}
+
+ PackageStateMBean getPackageStateMBean()
+ {
+ ObjectName objectName = ObjectNameFactory.create(PackageStateMBean.OBJECTNAME);
+ return MBeanProxy.get(mbeanServer, objectName, PackageStateMBean.class);
+ }
}
\ No newline at end of file
Modified: 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/FrameworkStateExt.java 2010-02-26 11:52:33 UTC (rev 101528)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/FrameworkStateExt.java 2010-02-26 11:55:48 UTC (rev 101529)
@@ -65,21 +65,43 @@
}
@Override
- public void refreshAllPackages()
+ public void refreshBundles(long[] bundleIdentifiers) throws IOException
{
- ServiceReference sref = context.getServiceReference(PackageAdmin.class.getName());
- PackageAdmin service = (PackageAdmin)context.getService(sref);
- service.refreshPackages(null);
+ // https://issues.apache.org/jira/browse/ARIES-177
+ if (bundleIdentifiers == null)
+ {
+ ServiceReference sref = context.getServiceReference(PackageAdmin.class.getName());
+ PackageAdmin service = (PackageAdmin)context.getService(sref);
+ service.refreshPackages(null);
+ return;
+ }
+
+ getFrameworkMBean().refreshPackages(bundleIdentifiers);
}
@Override
- public boolean resolveAllBundles()
+ public void refreshBundle(long bundleIdentifier) throws IOException
{
- ServiceReference sref = context.getServiceReference(PackageAdmin.class.getName());
- PackageAdmin service = (PackageAdmin)context.getService(sref);
- return service.resolveBundles(null);
+ getFrameworkMBean().refreshPackages(bundleIdentifier);
}
+ public boolean resolveBundles(long[] bundleIdentifiers) throws IOException
+ {
+ // https://issues.apache.org/jira/browse/ARIES-177
+ if (bundleIdentifiers == null)
+ {
+ ServiceReference sref = context.getServiceReference(PackageAdmin.class.getName());
+ PackageAdmin service = (PackageAdmin)context.getService(sref);
+ return service.resolveBundles(null);
+ }
+ return getFrameworkMBean().resolveBundles(bundleIdentifiers);
+ }
+
+ public boolean resolveBundle(long arg0) throws IOException
+ {
+ return getFrameworkMBean().resolveBundle(arg0);
+ }
+
public int getFrameworkStartLevel() throws IOException
{
return getFrameworkMBean().getFrameworkStartLevel();
@@ -110,26 +132,19 @@
return getFrameworkMBean().installBundles(arg0);
}
- public void refreshPackages(long arg0) throws IOException
+ @Deprecated
+ public void refreshPackages(long bundleIdentifier) throws IOException
{
- getFrameworkMBean().refreshPackages(arg0);
+ refreshBundle(bundleIdentifier);
}
- public CompositeData refreshPackages(long[] arg0) throws IOException
+ @Deprecated
+ public CompositeData refreshPackages(long[] bundleIdentifiers) throws IOException
{
- return getFrameworkMBean().refreshPackages(arg0);
+ refreshBundles(bundleIdentifiers);
+ return null;
}
- 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();
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-26 11:52:33 UTC (rev 101528)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/JMXServiceActivator.java 2010-02-26 11:55:48 UTC (rev 101529)
@@ -59,6 +59,7 @@
private FrameworkStateExt frameworkState;
private ServiceStateExt serviceState;
private BundleStateExt bundleState;
+ private PackageStateExt packageState;
public void start(BundleContext context)
{
@@ -81,6 +82,10 @@
bundleState = new BundleStateExt(sysContext, mbeanServer);
bundleState.start();
+ // Register the PackageStateMBean
+ packageState = new PackageStateExt(sysContext, mbeanServer);
+ packageState.start();
+
jmxHost = context.getProperty(JMXConstantsExt.REMOTE_JMX_HOST);
if (jmxHost == null)
jmxHost = "localhost";
@@ -109,6 +114,9 @@
// Unregister the BundleStateMBean
bundleState.stop();
+ // Unregister the PackageStateMBean
+ packageState.stop();
+
if (jmxConnector != null)
{
jmxConnector.stop();
Added: projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/PackageStateExt.java
===================================================================
--- projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/PackageStateExt.java (rev 0)
+++ projects/jboss-osgi/projects/bundles/jmx/trunk/jmx-bundle/src/main/java/org/jboss/osgi/jmx/internal/PackageStateExt.java 2010-02-26 11:55:48 UTC (rev 101529)
@@ -0,0 +1,83 @@
+/*
+ * 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.TabularData;
+
+import org.jboss.osgi.jmx.ObjectNameFactory;
+import org.jboss.osgi.jmx.PackageStateMBeanExt;
+import org.osgi.framework.BundleContext;
+import org.osgi.jmx.framework.BundleStateMBean;
+
+/**
+ * An extension to {@link BundleStateMBean}.
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 23-Feb-2010
+ */
+public class PackageStateExt extends AbstractState implements PackageStateMBeanExt
+{
+ public PackageStateExt(BundleContext context, MBeanServer mbeanServer)
+ {
+ super(context, mbeanServer);
+ }
+
+ @Override
+ ObjectName getObjectName()
+ {
+ return ObjectNameFactory.create(OBJECTNAME);
+ }
+
+ @Override
+ StandardMBean getStandardMBean() throws NotCompliantMBeanException
+ {
+ return new StandardMBean(this, PackageStateMBeanExt.class);
+ }
+
+ public long getExportingBundle(String arg0, String arg1) throws IOException
+ {
+ return getPackageStateMBean().getExportingBundle(arg0, arg1);
+ }
+
+ public long[] getImportingBundles(String arg0, String arg1) throws IOException
+ {
+ return getPackageStateMBean().getImportingBundles(arg0, arg1);
+ }
+
+ public boolean isRemovalPending(String arg0, String arg1) throws IOException
+ {
+ return getPackageStateMBean().isRemovalPending(arg0, arg1);
+ }
+
+ public TabularData listPackages() throws IOException
+ {
+ return getPackageStateMBean().listPackages();
+ }
+}
\ 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/PackageStateExt.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Deleted: projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/OSGiPackageAdmin.java
===================================================================
--- projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/OSGiPackageAdmin.java 2010-02-26 11:52:33 UTC (rev 101528)
+++ projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/OSGiPackageAdmin.java 2010-02-26 11:55:48 UTC (rev 101529)
@@ -1,55 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.osgi.testing;
-
-//$Id$
-
-import org.osgi.service.packageadmin.PackageAdmin;
-
-/**
- * An abstraction of the OSGi {@link PackageAdmin} service.
- *
- * @author Thomas.Diesler at jboss.org
- * @since 25-Sep-2008
- */
-public interface OSGiPackageAdmin
-{
- /**
- * Forces the update (replacement) or removal of packages exported by the specified bundles.
- *
- * @see {@link PackageAdmin#refreshPackages(org.osgi.framework.Bundle[])}
- *
- * @param bundles The bundles whose exported packages are to be updated or removed,
- * or null for all bundles updated or uninstalled since the last call to this method.
- */
- void refreshPackages(OSGiBundle[] bundles);
-
- /**
- * Resolve the specified bundles.
- *
- * @see {@link PackageAdmin#resolveBundles(org.osgi.framework.Bundle[])}
- *
- * @param bundles The bundles to resolve or null to resolve all unresolved bundles installed in the Framework.
- * @return true if all specified bundles are resolved
- */
- boolean resolveBundles(OSGiBundle[] bundles);
-}
Modified: projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/OSGiRuntime.java
===================================================================
--- projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/OSGiRuntime.java 2010-02-26 11:52:33 UTC (rev 101528)
+++ projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/OSGiRuntime.java 2010-02-26 11:55:48 UTC (rev 101529)
@@ -21,6 +21,8 @@
*/
package org.jboss.osgi.testing;
+import java.io.IOException;
+
import javax.management.MBeanServerConnection;
import javax.naming.InitialContext;
import javax.naming.NamingException;
@@ -32,7 +34,6 @@
import org.osgi.jmx.framework.FrameworkMBean;
import org.osgi.jmx.framework.PackageStateMBean;
import org.osgi.jmx.framework.ServiceStateMBean;
-import org.osgi.service.packageadmin.PackageAdmin;
/**
* An abstraction of an OSGi Runtime.
@@ -61,27 +62,27 @@
* Install an {@link OSGiBundle} from the given location.
*/
OSGiBundle installBundle(String location) throws BundleException;
-
+
/**
* Get the FrameworkMBean
*/
- FrameworkMBean getFrameworkMBean();
+ FrameworkMBean getFrameworkMBean() throws IOException;
/**
* Get the BundleStateMBean
*/
- BundleStateMBean getBundleStateMBean();
-
+ BundleStateMBean getBundleStateMBean() throws IOException;
+
/**
- * Get the PackageStateMBean
+ * Get the ServiceStateMBean
*/
- PackageStateMBean getPackageStateMBean();
-
+ ServiceStateMBean getServiceStateMBean() throws IOException;
+
/**
- * Get the ServiceStateMBean
+ * Get the PackageStateMBean
*/
- ServiceStateMBean getServiceStateMBean();
-
+ PackageStateMBean getPackageStateMBean() throws IOException;
+
/**
* Get the array of installed {@link OSGiBundle}s
*/
@@ -106,18 +107,13 @@
OSGiBundle getBundle(long bundleId);
/**
- * Get an abstraction of the {@link PackageAdmin}.
- */
- OSGiPackageAdmin getPackageAdmin();
-
- /**
* Returns a ServiceReference object for a service that implements and was registered
* under the specified class.
*
* @return A ServiceReference object, or null if no services are registered which implement the named class.
*/
OSGiServiceReference getServiceReference(String clazz);
-
+
/**
* Returns a ServiceReference object for a service that implements and was registered
* under the specified class.
@@ -126,14 +122,14 @@
* @return A ServiceReference object, or null if no services are registered which implement the named class.
*/
OSGiServiceReference getServiceReference(String clazz, long timeout);
-
+
/**
* Returns an array of ServiceReference objects.
* The returned array of ServiceReference objects contains services that were registered under the specified
* class and match the specified filter criteria.
*/
OSGiServiceReference[] getServiceReferences(String clazz, String filter);
-
+
/**
* Get the initial naming context for this {@link OSGiRuntime}
*/
Deleted: projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedPackageAdmin.java
===================================================================
--- projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedPackageAdmin.java 2010-02-26 11:52:33 UTC (rev 101528)
+++ projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedPackageAdmin.java 2010-02-26 11:55:48 UTC (rev 101529)
@@ -1,69 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.osgi.testing.internal;
-
-import org.jboss.osgi.testing.OSGiBundle;
-import org.jboss.osgi.testing.OSGiPackageAdmin;
-import org.osgi.framework.Bundle;
-import org.osgi.service.packageadmin.PackageAdmin;
-
-/**
- * An embedded implementation of the {@link OSGiPackageAdmin}
- *
- * @author Thomas.Diesler at jboss.org
- * @since 25-Sep-2008
- */
-public class EmbeddedPackageAdmin implements OSGiPackageAdmin
-{
- private PackageAdmin delegate;
-
- public EmbeddedPackageAdmin(PackageAdmin packAdmin)
- {
- this.delegate = packAdmin;
- }
-
- public boolean resolveBundles(OSGiBundle[] bundles)
- {
- Bundle[] bundleArr = getBundles(bundles);
- return delegate.resolveBundles(bundleArr);
- }
-
- public void refreshPackages(OSGiBundle[] bundles)
- {
- Bundle[] bundleArr = getBundles(bundles);
- delegate.refreshPackages(bundleArr);
- }
-
- private Bundle[] getBundles(OSGiBundle[] bundles)
- {
- Bundle[] bundleArr = null;
- if (bundles != null)
- {
- bundleArr = new Bundle[bundles.length];
- for (int i=0; i < bundles.length; i++)
- {
- bundleArr[i] = ((EmbeddedBundle)bundles[i]).getBundle();
- }
- }
- return bundleArr;
- }
-}
Modified: projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedRuntime.java
===================================================================
--- projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedRuntime.java 2010-02-26 11:52:33 UTC (rev 101528)
+++ projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/EmbeddedRuntime.java 2010-02-26 11:55:48 UTC (rev 101529)
@@ -37,7 +37,6 @@
import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
import org.jboss.osgi.spi.util.BundleInfo;
import org.jboss.osgi.testing.OSGiBundle;
-import org.jboss.osgi.testing.OSGiPackageAdmin;
import org.jboss.osgi.testing.OSGiRuntime;
import org.jboss.osgi.testing.OSGiServiceReference;
import org.jboss.osgi.testing.OSGiTestHelper;
@@ -47,7 +46,6 @@
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.launch.Framework;
-import org.osgi.service.packageadmin.PackageAdmin;
/**
* An embedded implementation of the {@link OSGiRuntime}
@@ -179,14 +177,6 @@
return server;
}
- public OSGiPackageAdmin getPackageAdmin()
- {
- BundleContext context = getSystemContext();
- ServiceReference sref = context.getServiceReference(PackageAdmin.class.getName());
- PackageAdmin packAdmin = (PackageAdmin)context.getService(sref);
- return new EmbeddedPackageAdmin(packAdmin);
- }
-
public boolean isRemoteRuntime()
{
return false;
Modified: projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiRuntimeImpl.java
===================================================================
--- projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiRuntimeImpl.java 2010-02-26 11:52:33 UTC (rev 101528)
+++ projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/OSGiRuntimeImpl.java 2010-02-26 11:55:48 UTC (rev 101529)
@@ -23,7 +23,6 @@
import java.io.File;
import java.io.IOException;
-import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -36,13 +35,18 @@
import java.util.jar.JarFile;
import java.util.jar.Manifest;
+import javax.management.MBeanServerConnection;
import javax.management.ObjectName;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.jboss.logging.Logger;
+import org.jboss.osgi.jmx.BundleStateMBeanExt;
+import org.jboss.osgi.jmx.FrameworkMBeanExt;
import org.jboss.osgi.jmx.MBeanProxy;
import org.jboss.osgi.jmx.ObjectNameFactory;
+import org.jboss.osgi.jmx.PackageStateMBeanExt;
+import org.jboss.osgi.jmx.ServiceStateMBeanExt;
import org.jboss.osgi.spi.capability.Capability;
import org.jboss.osgi.spi.util.BundleInfo;
import org.jboss.osgi.testing.OSGiBundle;
@@ -71,11 +75,6 @@
private OSGiTestHelper helper;
private Map<String, OSGiBundle> bundles = new LinkedHashMap<String, OSGiBundle>();
private List<Capability> capabilities = new ArrayList<Capability>();
-
- private ServiceStateMBean serviceState;
- private PackageStateMBean packageState;
- private BundleStateMBean bundleState;
- private FrameworkMBean framework;
public OSGiRuntimeImpl(OSGiTestHelper helper)
{
@@ -121,7 +120,7 @@
log.debug("Skip bundle: " + location);
}
}
-
+
// Start the capability bundles
for (OSGiBundle bundle : installed)
{
@@ -181,56 +180,48 @@
log.debug("End Shutdown");
}
- public FrameworkMBean getFrameworkMBean()
+ public FrameworkMBean getFrameworkMBean() throws IOException
{
- if (framework == null)
- {
- ObjectName objectName = ObjectNameFactory.create(FrameworkMBean.OBJECTNAME);
- framework = MBeanProxy.get(getMBeanServer(), objectName, FrameworkMBean.class);
- }
- return framework;
- }
+ MBeanServerConnection server = getMBeanServer();
+ ObjectName objectName = ObjectNameFactory.create(FrameworkMBeanExt.OBJECTNAME);
+ if (server.isRegistered(objectName))
+ return MBeanProxy.get(server, objectName, FrameworkMBeanExt.class);
- public BundleStateMBean getBundleStateMBean()
- {
- if (bundleState == null)
- {
- ObjectName objectName = ObjectNameFactory.create(BundleStateMBean.OBJECTNAME);
- bundleState = MBeanProxy.get(getMBeanServer(), objectName, BundleStateMBean.class);
- }
- return bundleState;
+ objectName = ObjectNameFactory.create(FrameworkMBean.OBJECTNAME);
+ return MBeanProxy.get(server, objectName, FrameworkMBean.class);
}
-
- public PackageStateMBean getPackageStateMBean()
- {
- if (packageState == null)
- {
- ObjectName objectName = ObjectNameFactory.create(PackageStateMBean.OBJECTNAME);
- packageState = MBeanProxy.get(getMBeanServer(), objectName, PackageStateMBean.class);
- }
- return packageState;
- }
- public ServiceStateMBean getServiceStateMBean()
+ public BundleStateMBean getBundleStateMBean() throws IOException
{
- if (serviceState == null)
- {
- ObjectName objectName = ObjectNameFactory.create(ServiceStateMBean.OBJECTNAME);
- serviceState = MBeanProxy.get(getMBeanServer(), objectName, ServiceStateMBean.class);
- }
- return serviceState;
+ MBeanServerConnection server = getMBeanServer();
+ ObjectName objectName = ObjectNameFactory.create(BundleStateMBeanExt.OBJECTNAME);
+ if (server.isRegistered(objectName))
+ return MBeanProxy.get(server, objectName, BundleStateMBeanExt.class);
+
+ objectName = ObjectNameFactory.create(BundleStateMBean.OBJECTNAME);
+ return MBeanProxy.get(server, objectName, BundleStateMBean.class);
}
- void deploy(URL archiveURL) throws Exception
+ public PackageStateMBean getPackageStateMBean() throws IOException
{
- //DeployerServiceClient deployer = new DeployerServiceClient(this, DeployerService.MBEAN_DEPLOYER_SERVICE);
- //deployer.deploy(archiveURL);
+ MBeanServerConnection server = getMBeanServer();
+ ObjectName objectName = ObjectNameFactory.create(PackageStateMBeanExt.OBJECTNAME);
+ if (server.isRegistered(objectName))
+ return MBeanProxy.get(server, objectName, PackageStateMBeanExt.class);
+
+ objectName = ObjectNameFactory.create(PackageStateMBean.OBJECTNAME);
+ return MBeanProxy.get(server, objectName, PackageStateMBean.class);
}
- void undeploy(URL archiveURL) throws Exception
+ public ServiceStateMBean getServiceStateMBean() throws IOException
{
- //DeployerServiceClient deployer = new DeployerServiceClient(this, DeployerService.MBEAN_DEPLOYER_SERVICE);
- //deployer.undeploy(archiveURL);
+ MBeanServerConnection server = getMBeanServer();
+ ObjectName objectName = ObjectNameFactory.create(ServiceStateMBeanExt.OBJECTNAME);
+ if (server.isRegistered(objectName))
+ return MBeanProxy.get(getMBeanServer(), objectName, ServiceStateMBeanExt.class);
+
+ objectName = ObjectNameFactory.create(ServiceStateMBean.OBJECTNAME);
+ return MBeanProxy.get(server, objectName, ServiceStateMBean.class);
}
public InitialContext getInitialContext() throws NamingException
Deleted: projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemotePackageAdmin.java
===================================================================
--- projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemotePackageAdmin.java 2010-02-26 11:52:33 UTC (rev 101528)
+++ projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemotePackageAdmin.java 2010-02-26 11:55:48 UTC (rev 101529)
@@ -1,106 +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.testing.internal;
-
-import java.io.IOException;
-
-import javax.management.ObjectName;
-
-import org.jboss.osgi.jmx.FrameworkMBeanExt;
-import org.jboss.osgi.jmx.MBeanProxy;
-import org.jboss.osgi.jmx.ObjectNameFactory;
-import org.jboss.osgi.testing.OSGiBundle;
-import org.jboss.osgi.testing.OSGiPackageAdmin;
-import org.jboss.osgi.testing.OSGiRuntime;
-import org.osgi.jmx.framework.FrameworkMBean;
-
-/**
- * A remote implementation of the {@link OSGiPackageAdmin}
- *
- * @author Thomas.Diesler at jboss.org
- * @since 25-Sep-2008
- */
-public class RemotePackageAdmin implements OSGiPackageAdmin
-{
- private OSGiRuntime runtime;
-
- public RemotePackageAdmin(OSGiRuntime runtime)
- {
- this.runtime = runtime;
- }
-
- public boolean resolveBundles(OSGiBundle[] bundles)
- {
- // JMX FrameworkMBean does not allow to resolve/refresh all bundles
- // https://www.osgi.org/members/bugzilla/show_bug.cgi?id=1586
- if (bundles == null)
- {
- ObjectName objectName = ObjectNameFactory.create(FrameworkMBeanExt.OBJECTNAME);
- FrameworkMBeanExt mbeanProxy = MBeanProxy.get(runtime.getMBeanServer(), objectName, FrameworkMBeanExt.class);
- return mbeanProxy.resolveAllBundles();
- }
-
- FrameworkMBean framework = runtime.getFrameworkMBean();
- try
- {
- long[] ids = getBundleIds(bundles);
- return framework.resolveBundles(ids);
- }
- catch (IOException ex)
- {
- throw new IllegalStateException("Cannot resolve bundles", ex);
- }
- }
-
- public void refreshPackages(OSGiBundle[] bundles)
- {
- // JMX FrameworkMBean does not allow to resolve/refresh all bundles
- // https://www.osgi.org/members/bugzilla/show_bug.cgi?id=1586
- if (bundles == null)
- {
- ObjectName objectName = ObjectNameFactory.create(FrameworkMBeanExt.OBJECTNAME);
- FrameworkMBeanExt mbeanProxy = MBeanProxy.get(runtime.getMBeanServer(), objectName, FrameworkMBeanExt.class);
- mbeanProxy.refreshAllPackages();
- return;
- }
-
- FrameworkMBean framework = runtime.getFrameworkMBean();
- try
- {
- long[] ids = getBundleIds(bundles);
- framework.refreshPackages(ids);
- }
- catch (IOException ex)
- {
- throw new IllegalStateException("Cannot resolve bundles", ex);
- }
- }
-
- private long[] getBundleIds(OSGiBundle[] bundles)
- {
- long[] ids = new long[bundles.length];
- for (int i = 0; i < bundles.length; i++)
- ids[i] = bundles[i].getBundleId();
-
- return ids;
- }
-}
Modified: projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteRuntime.java
===================================================================
--- projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteRuntime.java 2010-02-26 11:52:33 UTC (rev 101528)
+++ projects/jboss-osgi/projects/testing/trunk/src/main/java/org/jboss/osgi/testing/internal/RemoteRuntime.java 2010-02-26 11:55:48 UTC (rev 101529)
@@ -44,7 +44,6 @@
import org.jboss.osgi.jmx.ServiceStateMBeanExt;
import org.jboss.osgi.spi.util.BundleInfo;
import org.jboss.osgi.testing.OSGiBundle;
-import org.jboss.osgi.testing.OSGiPackageAdmin;
import org.jboss.osgi.testing.OSGiRuntime;
import org.jboss.osgi.testing.OSGiServiceReference;
import org.jboss.osgi.testing.OSGiTestHelper;
@@ -213,11 +212,6 @@
return mbeanServer;
}
- public OSGiPackageAdmin getPackageAdmin()
- {
- return new RemotePackageAdmin(this);
- }
-
public boolean isRemoteRuntime()
{
return true;
More information about the jboss-cvs-commits
mailing list