365711 Adding the initial custom MBean interface
diff --git a/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/codec/Util.java b/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/codec/Util.java
index f96120f..1561096 100644
--- a/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/codec/Util.java
+++ b/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/codec/Util.java
@@ -40,16 +40,15 @@
*
*/
public class Util {
+
/**
- * Answer the bundle ids of the bundles
*
- * @param bundles
- * @return the bundle ids of the bundles
+ * @param serviceRef
+ * @return
+ * @throws IOException
*/
- public static long[] bundleIds(Bundle[] bundles) {
- if (bundles == null) {
- return new long[0];
- }
+ public static long[] getBundlesUsingBundles(ServiceReference<?> serviceRef) {
+ Bundle[] bundles = serviceRef.getUsingBundles();
long[] ids = new long[bundles.length];
for (int i = 0; i < bundles.length; i++) {
ids[i] = bundles[i].getBundleId();
@@ -64,7 +63,7 @@
* @return
* @throws IOException
*/
- public static long[] getRequiredBundles(Bundle bundle) throws IOException {
+ public static long[] getRequiredBundles(Bundle bundle) {
BundleWiring wiring = bundle.adapt(BundleWiring.class);
List<BundleWire> consumedWires = wiring.getRequiredWires(BundleRevision.BUNDLE_NAMESPACE);
long[] providerWires = new long[consumedWires.size()];
@@ -82,7 +81,7 @@
* @return
* @throws IOException
*/
- public static long[] getRequiringBundles(Bundle bundle) throws IOException {
+ public static long[] getRequiringBundles(Bundle bundle) {
BundleWiring wiring = bundle.adapt(BundleWiring.class);
List<BundleWire> providedWirings = wiring.getProvidedWires(BundleRevision.BUNDLE_NAMESPACE);
long[] consumerWirings = new long[providedWirings.size()];
diff --git a/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/CustomServiceStateMBean.java b/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/CustomServiceStateMBean.java
new file mode 100644
index 0000000..ba2f446
--- /dev/null
+++ b/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/CustomServiceStateMBean.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2011 VMware.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * and Apache License v2.0 which accompanies this distribution.
+ * The Eclipse Public License is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * and the Apache License v2.0 is available at
+ * http://www.opensource.org/licenses/apache2.0.php.
+ * You may elect to redistribute this code under either of these licenses.
+ *
+ * Contributors:
+ * Christopher Frost - VMware
+ ******************************************************************************/
+package org.eclipse.gemini.mgmt.framework;
+
+import org.osgi.jmx.framework.ServiceStateMBean;
+
+/**
+ * @author cgfrost
+ *
+ */
+public interface CustomServiceStateMBean extends ServiceStateMBean {
+
+}
diff --git a/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/ServiceState.java b/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/ServiceState.java
index 1120bd6..4560e13 100644
--- a/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/ServiceState.java
+++ b/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/ServiceState.java
@@ -48,7 +48,7 @@
/**
*
*/
-public class ServiceState extends Monitor implements ServiceStateMBean {
+public class ServiceState extends Monitor implements CustomServiceStateMBean {
protected ServiceListener serviceListener;
@@ -104,12 +104,7 @@
* {@inheritDoc}
*/
public long[] getUsingBundles(long serviceId) throws IOException {
- Bundle[] bundles = ref(serviceId).getUsingBundles();
- long[] ids = new long[bundles.length];
- for (int i = 0; i < bundles.length; i++) {
- ids[i] = bundles[i].getBundleId();
- }
- return ids;
+ return Util.getBundlesUsingBundles(ref(serviceId));
}
/**
@@ -192,7 +187,7 @@
}
long[] usingBundles;
if(serviceTypeNames.contains(ServiceStateMBean.USING_BUNDLES)){
- usingBundles = Util.bundleIds(reference.getUsingBundles());
+ usingBundles = Util.getBundlesUsingBundles(reference);
} else {
usingBundles = null;
}
diff --git a/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/codec/OSGiPackage.java b/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/codec/OSGiPackage.java
index 88fa5e8..2c22dff 100644
--- a/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/codec/OSGiPackage.java
+++ b/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/codec/OSGiPackage.java
@@ -27,7 +27,7 @@
import javax.management.openmbean.TabularData;
import javax.management.openmbean.TabularDataSupport;
-import org.eclipse.gemini.mgmt.codec.Util;
+import org.osgi.framework.Bundle;
import org.osgi.jmx.framework.PackageStateMBean;
import org.osgi.service.packageadmin.ExportedPackage;
@@ -78,10 +78,27 @@
* - the <link>ExporetedPackage</link>
*/
public OSGiPackage(ExportedPackage pkg) {
- this(pkg.getName(), pkg.getVersion().toString(), pkg.isRemovalPending(), new long[] { pkg.getExportingBundle().getBundleId() }, Util.bundleIds(pkg.getImportingBundles()));
+ this(pkg.getName(), pkg.getVersion().toString(), pkg.isRemovalPending(), new long[] { pkg.getExportingBundle().getBundleId() }, OSGiPackage.bundleIds(pkg.getImportingBundles()));
}
/**
+ * Answer the bundle ids of the bundles
+ *
+ * @param bundles
+ * @return the bundle ids of the bundles
+ */
+ private static long[] bundleIds(Bundle[] bundles) {
+ if (bundles == null) {
+ return new long[0];
+ }
+ long[] ids = new long[bundles.length];
+ for (int i = 0; i < bundles.length; i++) {
+ ids[i] = bundles[i].getBundleId();
+ }
+ return ids;
+ }
+
+ /**
* Construct and OSGiPackage from the supplied data
*
* @param name
diff --git a/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/codec/OSGiService.java b/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/codec/OSGiService.java
index d76bb07..7d739c0 100644
--- a/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/codec/OSGiService.java
+++ b/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/codec/OSGiService.java
@@ -74,12 +74,13 @@
*
* @param reference
* - the reference of the service
+ * @throws
*/
public OSGiService(ServiceReference<?> reference) {
this.identifier = (Long) reference.getProperty(SERVICE_ID);
this.interfaces = (String[]) reference.getProperty(OBJECTCLASS);
this.bundle = reference.getBundle().getBundleId();
- this.usingBundles = Util.bundleIds(reference.getUsingBundles());
+ this.usingBundles = Util.getBundlesUsingBundles(reference);
}
/**