Removing dead code and some unused caching from BundleState
diff --git a/org.eclipse.gemini.mgmt.tests/src/org/eclipse/gemini/mgmt/framework/BundleStateTest.java b/org.eclipse.gemini.mgmt.tests/src/org/eclipse/gemini/mgmt/framework/BundleStateTest.java
index a191ecf..2e07690 100644
--- a/org.eclipse.gemini.mgmt.tests/src/org/eclipse/gemini/mgmt/framework/BundleStateTest.java
+++ b/org.eclipse.gemini.mgmt.tests/src/org/eclipse/gemini/mgmt/framework/BundleStateTest.java
@@ -36,9 +36,9 @@
 import org.osgi.jmx.framework.BundleStateMBean;

 

 import org.eclipse.gemini.mgmt.Activator;

-import org.eclipse.gemini.mgmt.codec.Util;

-import org.eclipse.gemini.mgmt.framework.codec.OSGiBundle;

+import org.eclipse.gemini.mgmt.framework.internal.OSGiBundle;

 import org.eclipse.gemini.mgmt.framework.BundleState;

+import org.eclipse.gemini.mgmt.internal.Util;

 

 public class BundleStateTest {

 	

@@ -147,8 +147,8 @@
 			assertEquals(state, stateToString(bundle.getState()));

 			assertEquals(lastModified, bundle.getLastModified());

 			assertEquals(persistenlyStarted, Util.isBundlePersistentlyStarted(bundle));

-			assertEquals(removalPending, Util.isRemovalPending(bundle.getBundleId(), bc));

-			assertEquals(required, Util.isRequired(bundle.getBundleId(), bc));

+			assertEquals(removalPending, Util.isRemovalPending(bundle));

+			assertEquals(required, Util.isRequired(bundle));

 			assertEquals(fragment, Util.isBundleFragment(bundle));

 

 			long[] rs = new long[registeredServices.length];

@@ -268,7 +268,7 @@
 			assertEquals(state, stateToString(bundle.getState()));

 			assertEquals(lastModified, bundle.getLastModified());

 			assertEquals(persistenlyStarted, Util.isBundlePersistentlyStarted(bundle));

-			assertEquals(removalPending, Util.isRemovalPending(bundle.getBundleId(), bc));

+			assertEquals(removalPending, Util.isRemovalPending(bundle));

 

 			long[] rs = new long[registeredServices.length];

 			for (int i = 0; i < registeredServices.length; i++) {

diff --git a/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/configurationadmin/ConfigAdminManager.java b/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/configurationadmin/ConfigAdminManager.java
index 6d96ea8..e504d4a 100644
--- a/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/configurationadmin/ConfigAdminManager.java
+++ b/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/configurationadmin/ConfigAdminManager.java
@@ -15,7 +15,7 @@
 

 package org.eclipse.gemini.mgmt.configurationadmin;

 

-import static org.eclipse.gemini.mgmt.codec.OSGiProperties.*;

+import static org.eclipse.gemini.mgmt.internal.OSGiProperties.*;

 

 import java.io.IOException;

 import java.util.ArrayList;

diff --git a/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/BundleState.java b/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/BundleState.java
index 71a0bba..e8ac09a 100644
--- a/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/BundleState.java
+++ b/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/BundleState.java
@@ -28,20 +28,25 @@
 import org.osgi.jmx.framework.BundleStateMBean;

 

 import org.eclipse.gemini.mgmt.Monitor;

-import org.eclipse.gemini.mgmt.codec.Util;

-import org.eclipse.gemini.mgmt.framework.codec.OSGiBundle;

-import org.eclipse.gemini.mgmt.framework.codec.OSGiBundleEvent;

+import org.eclipse.gemini.mgmt.framework.internal.OSGiBundle;

+import org.eclipse.gemini.mgmt.framework.internal.OSGiBundleEvent;

+import org.eclipse.gemini.mgmt.internal.Util;

 

 /** 

  * 

  */

 public final class BundleState extends Monitor implements CustomBundleStateMBean {

 	

-	protected BundleListener bundleListener;

-	protected BundleContext bundleContext;

+	private BundleListener bundleListener;

 	

-	public BundleState(BundleContext bc) {

-		this.bundleContext = bc;

+	private BundleContext bundleContext;

+	

+	/**

+	 * 

+	 * @param bundleContext

+	 */

+	public BundleState(BundleContext bundleContext) {

+		this.bundleContext = bundleContext;

 	}

 

 	/**

@@ -51,7 +56,7 @@
 		try {

 			ArrayList<OSGiBundle> bundles = new ArrayList<OSGiBundle>();

 			for (Bundle bundle : bundleContext.getBundles()) {

-				bundles.add(new OSGiBundle(bundleContext, bundle));

+				bundles.add(new OSGiBundle(bundle));

 			}

 			TabularData table = OSGiBundle.tableFrom(bundles);

 			return table;

@@ -70,7 +75,7 @@
 		try {

 			ArrayList<OSGiBundle> bundles = new ArrayList<OSGiBundle>();

 			for (Bundle bundle : bundleContext.getBundles()) {

-				bundles.add(new OSGiBundle(bundleContext, bundle));

+				bundles.add(new OSGiBundle(bundle));

 			}

 			TabularData table = OSGiBundle.tableFrom(bundles, mask);

 			return table;

@@ -202,14 +207,14 @@
 	 * {@inheritDoc}

 	 */

 	public boolean isRemovalPending(long bundleId) throws IOException {

-		return Util.isRemovalPending(bundleId, bundleContext);

+		return Util.isRemovalPending(getBundle(bundleId));

 	}

 

 	/**

 	 * {@inheritDoc}

 	 */

 	public boolean isRequired(long bundleId) throws IOException {

-		return Util.isRequired(bundleId, bundleContext);

+		return Util.isRequired(getBundle(bundleId));

 	}

 

 	private Bundle getBundle(long bundleId) throws IOException {

@@ -228,7 +233,7 @@
 		bundleContext.addBundleListener(bundleListener);

 	}

 

-	protected BundleListener getBundleListener() {

+	private BundleListener getBundleListener() {

 		return new BundleListener() {

 			public void bundleChanged(BundleEvent bundleEvent) {

 				Notification notification = new Notification(BundleStateMBean.EVENT, objectName, sequenceNumber++);

diff --git a/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/BundleWiringState.java b/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/BundleWiringState.java
index fc784a1..81f7e76 100644
--- a/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/BundleWiringState.java
+++ b/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/BundleWiringState.java
@@ -34,6 +34,10 @@
 
 	private final BundleContext bundleContext;
 
+	/**
+	 * 
+	 * @param bundleContext
+	 */
 	public BundleWiringState(BundleContext bundleContext) {
 		this.bundleContext = bundleContext;
 	}
diff --git a/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/Framework.java b/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/Framework.java
index b18c40f..9a25864 100644
--- a/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/Framework.java
+++ b/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/Framework.java
@@ -32,8 +32,8 @@
 import org.osgi.framework.startlevel.FrameworkStartLevel;

 import org.osgi.framework.wiring.FrameworkWiring;

 

-import org.eclipse.gemini.mgmt.framework.codec.BundleBatchActionResult;

-import org.eclipse.gemini.mgmt.framework.codec.BundleBatchInstallResult;

+import org.eclipse.gemini.mgmt.framework.internal.BundleBatchActionResult;

+import org.eclipse.gemini.mgmt.framework.internal.BundleBatchInstallResult;

 

 import org.osgi.jmx.framework.FrameworkMBean;

 

diff --git a/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/PackageState.java b/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/PackageState.java
index 17e4008..3832dc6 100644
--- a/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/PackageState.java
+++ b/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/PackageState.java
@@ -30,16 +30,22 @@
 import org.osgi.service.packageadmin.ExportedPackage;

 import org.osgi.service.packageadmin.PackageAdmin;

 

-import org.eclipse.gemini.mgmt.framework.codec.OSGiPackage;

+import org.eclipse.gemini.mgmt.framework.internal.OSGiPackage;

 

 /** 

  * 

  */

+@SuppressWarnings("deprecation")

 public final class PackageState implements PackageStateMBean {

 	

 	private BundleContext bundleContext;

+	

 	private PackageAdmin admin;

 	

+	/**

+	 * 

+	 * @param bundleContext

+	 */

 	public PackageState(BundleContext bundleContext) {

 		this.bundleContext = bundleContext;

 		this.admin = (PackageAdmin) bundleContext.getService(bundleContext.getServiceReference(PackageAdmin.class));

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 834f7f1..4e6f166 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
@@ -26,10 +26,10 @@
 import javax.management.openmbean.TabularData;

 

 import org.eclipse.gemini.mgmt.Monitor;

-import org.eclipse.gemini.mgmt.codec.OSGiProperties;

-import org.eclipse.gemini.mgmt.codec.Util;

-import org.eclipse.gemini.mgmt.framework.codec.OSGiService;

-import org.eclipse.gemini.mgmt.framework.codec.OSGiServiceEvent;

+import org.eclipse.gemini.mgmt.framework.internal.OSGiService;

+import org.eclipse.gemini.mgmt.framework.internal.OSGiServiceEvent;

+import org.eclipse.gemini.mgmt.internal.OSGiProperties;

+import org.eclipse.gemini.mgmt.internal.Util;

 import org.osgi.framework.AllServiceListener;

 import org.osgi.framework.Bundle;

 import org.osgi.framework.BundleContext;

@@ -56,29 +56,29 @@
 	 * 

 	 * @param bundleContext

 	 */

-	public ServiceState(BundleContext bc) {

-		this.bundleContext = bc;

+	public ServiceState(BundleContext bundleContext) {

+		this.bundleContext = bundleContext;

 	}

 

 	/**

 	 * {@inheritDoc}

 	 */

 	public long getBundleIdentifier(long serviceId) throws IOException {

-		return ref(serviceId).getBundle().getBundleId();

+		return getServiceReference(serviceId).getBundle().getBundleId();

 	}

 

 	/**

 	 * {@inheritDoc}

 	 */

 	public TabularData getProperties(long serviceId) throws IOException {

-		return OSGiProperties.tableFrom(ref(serviceId));

+		return OSGiProperties.tableFrom(getServiceReference(serviceId));

 	}

 

 	/**

 	 * {@inheritDoc}

 	 */

 	public String[] getObjectClass(long serviceId) throws IOException {

-		return (String[]) ref(serviceId).getProperty(OBJECTCLASS);

+		return (String[]) getServiceReference(serviceId).getProperty(OBJECTCLASS);

 	}

 

 	/**

@@ -101,7 +101,7 @@
 	 * {@inheritDoc}

 	 */

 	public long[] getUsingBundles(long serviceId) throws IOException {

-		return Util.getBundlesUsingBundles(ref(serviceId));

+		return Util.getBundlesUsingBundles(getServiceReference(serviceId));

 	}

 

 	/**

@@ -188,39 +188,7 @@
 		}

 	}

 	

-	//End methods for the MBean

-	

-

-	/**

-	 * {@inheritDoc}

-	 */

-	@Override

-	protected void addListener() {

-		serviceListener = this.getServiceListener();

-		bundleContext.addServiceListener(serviceListener);

-	}

-

-	/**

-	 * {@inheritDoc}

-	 */

-	@Override

-	protected void removeListener() {

-		if (serviceListener != null) {

-			bundleContext.removeServiceListener(serviceListener);

-		}

-	}

-

-	protected ServiceListener getServiceListener() {

-		return new AllServiceListener() {

-			public void serviceChanged(ServiceEvent serviceEvent) {

-				Notification notification = new Notification(ServiceStateMBean.EVENT, objectName, sequenceNumber++);

-				notification.setUserData(new OSGiServiceEvent(serviceEvent).asCompositeData());

-				sendNotification(notification);

-			}

-		};

-	}

-	

-	protected ServiceReference<?> ref(long serviceId) throws IOException {

+	private ServiceReference<?> getServiceReference(long serviceId) throws IOException {

 		Filter filter;

 		try {

 			filter = bundleContext.createFilter("(" + Constants.SERVICE_ID + "=" + serviceId + ")");

@@ -236,5 +204,35 @@
 		tracker.close();

 		return serviceReference;

 	}

+	

+	//End methods for the MBean

+	

+

+	/**

+	 * {@inheritDoc}

+	 */

+	protected void addListener() {

+		serviceListener = this.getServiceListener();

+		bundleContext.addServiceListener(serviceListener);

+	}

+

+	/**

+	 * {@inheritDoc}

+	 */

+	protected void removeListener() {

+		if (serviceListener != null) {

+			bundleContext.removeServiceListener(serviceListener);

+		}

+	}

+

+	private ServiceListener getServiceListener() {

+		return new AllServiceListener() {

+			public void serviceChanged(ServiceEvent serviceEvent) {

+				Notification notification = new Notification(ServiceStateMBean.EVENT, objectName, sequenceNumber++);

+				notification.setUserData(new OSGiServiceEvent(serviceEvent).asCompositeData());

+				sendNotification(notification);

+			}

+		};

+	}

 

 }

diff --git a/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/codec/OSGiServiceEvent.java b/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/codec/OSGiServiceEvent.java
deleted file mode 100644
index 9892858..0000000
--- a/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/codec/OSGiServiceEvent.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*******************************************************************************

- * Copyright (c) 2010 Oracle.

- * 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:

- *     Hal Hildebrand - Initial JMX support 

- ******************************************************************************/

-

-package org.eclipse.gemini.mgmt.framework.codec;

-

-import java.util.HashMap;

-import java.util.Map;

-

-import javax.management.openmbean.CompositeData;

-import javax.management.openmbean.CompositeDataSupport;

-import javax.management.openmbean.OpenDataException;

-

-import org.osgi.framework.Constants;

-import org.osgi.framework.ServiceEvent;

-import org.osgi.jmx.framework.ServiceStateMBean;

-

-/**

- * <p>

- * This class represents the CODEC for the composite data representing a OSGi

- * <link>ServiceEvent</link>

- * <p>

- * It serves as both the documentation of the type structure and as the

- * codification of the mechanism to convert to/from the CompositeData.

- * <p>

- * The structure of the composite data is:

- * <table border="1">

- * <tr>

- * <td>Identifier</td>

- * <td>String</td>

- * </tr>

- * <tr>

- * <td>BundleIdentifier</td>

- * <td>long</td>

- * </tr>

- * <tr>

- * <td>BundleLocation</td>

- * <td>String</td>

- * </tr>

- * <tr>

- * <td>ObjectClass</td>

- * <td>Array of String</td>

- * </tr>

- * <tr>

- * <td>EventType</td>

- * <td>int</td>

- * </tr>

- * </table>

- */

-public final class OSGiServiceEvent {

-

-	private long bundleId;

-	private int eventType;

-	private String[] interfaces;

-	private String location;

-	private String symbolicName;

-	private long serviceId;

-	

-	/**

-	 * Construct an OSGiServiceEvent from the CompositeData representing the

-	 * event

-	 * 

-	 * @param data

-	 *            = the CompositeData representation of the event

-	 */

-	public OSGiServiceEvent(CompositeData data) {

-		serviceId = (Long) data.get(ServiceStateMBean.IDENTIFIER);

-		bundleId = (Long) data.get(ServiceStateMBean.BUNDLE_IDENTIFIER);

-		location = (String) data.get(ServiceStateMBean.BUNDLE_LOCATION);

-		symbolicName = (String) data.get(ServiceStateMBean.BUNDLE_SYMBOLIC_NAME);

-		interfaces = (String[]) data.get(ServiceStateMBean.OBJECT_CLASS);

-		eventType = (Integer) data.get(ServiceStateMBean.EVENT);

-	}

-

-	/**

-	 * Construct and OSGiServiceEvent

-	 * 

-	 * @param serviceId

-	 * @param bundleId

-	 * @param location

-	 * @param symbolicName

-	 * @param interfaces

-	 * @param eventType

-	 */

-	public OSGiServiceEvent(long serviceId, long bundleId, String location, String symbolicName, String[] interfaces, int eventType) {

-		this.serviceId = serviceId;

-		this.bundleId = bundleId;

-		this.location = location;

-		this.symbolicName = symbolicName;

-		this.interfaces = interfaces;

-		this.eventType = eventType;

-	}

-

-	/**

-	 * 

-	 * Construct and OSGiServiceEvent from the original

-	 * <link>ServiceEvent</link>

-	 * 

-	 * @param event

-	 */

-	@SuppressWarnings("boxing")

-	public OSGiServiceEvent(ServiceEvent event) {

-		this((Long) event.getServiceReference().getProperty(Constants.SERVICE_ID), 

-			 event.getServiceReference().getBundle().getBundleId(), 

-			 event.getServiceReference().getBundle().getLocation(), 

-			 event.getServiceReference().getBundle().getSymbolicName(), 

-			 (String[]) event.getServiceReference().getProperty(Constants.OBJECTCLASS), event.getType());

-	}

-

-	/**

-	 * Answer the receiver encoded as CompositeData

-	 * 

-	 * @return the CompositeData encoding of the receiver.

-	 */

-	@SuppressWarnings("boxing")

-	public CompositeData asCompositeData() {

-		Map<String, Object> items = new HashMap<String, Object>();

-		items.put(ServiceStateMBean.IDENTIFIER, serviceId);

-		items.put(ServiceStateMBean.BUNDLE_IDENTIFIER, bundleId);

-		items.put(ServiceStateMBean.BUNDLE_LOCATION, location);

-		items.put(ServiceStateMBean.BUNDLE_SYMBOLIC_NAME, symbolicName);

-		items.put(ServiceStateMBean.IDENTIFIER, serviceId);

-		items.put(ServiceStateMBean.OBJECT_CLASS, interfaces);

-		items.put(ServiceStateMBean.EVENT, eventType);

-

-		try {

-			return new CompositeDataSupport(ServiceStateMBean.SERVICE_EVENT_TYPE, items);

-		} catch (OpenDataException e) {

-			throw new IllegalStateException("Cannot form service event open data", e);

-		}

-	}

-

-	/**

-	 * @return the identifier of the bundle the service belongs to

-	 */

-	public long getBundleId() {

-		return bundleId;

-	}

-

-	/**

-	 * @return the type of the event

-	 */

-	public int getEventType() {

-		return eventType;

-	}

-

-	/**

-	 * @return the interfaces the service implements

-	 */

-	public String[] getInterfaces() {

-		return interfaces;

-	}

-

-	/**

-	 * @return the location of the bundle the service belongs to

-	 */

-	public String getLocation() {

-		return location;

-	}

-

-	/**

-	 * @return the identifier of the service

-	 */

-	public long getServiceId() {

-		return serviceId;

-	}

-

-}

diff --git a/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/codec/BundleBatchActionResult.java b/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/internal/BundleBatchActionResult.java
similarity index 97%
rename from org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/codec/BundleBatchActionResult.java
rename to org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/internal/BundleBatchActionResult.java
index e1a3c89..b8152d4 100644
--- a/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/codec/BundleBatchActionResult.java
+++ b/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/internal/BundleBatchActionResult.java
@@ -13,9 +13,9 @@
  *     Hal Hildebrand - Initial JMX support 

  ******************************************************************************/

 

-package org.eclipse.gemini.mgmt.framework.codec;

+package org.eclipse.gemini.mgmt.framework.internal;

 

-import static org.eclipse.gemini.mgmt.codec.Util.LongArrayFrom;

+import static org.eclipse.gemini.mgmt.internal.Util.LongArrayFrom;

 

 import java.util.HashMap;

 import java.util.Map;

diff --git a/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/codec/BundleBatchInstallResult.java b/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/internal/BundleBatchInstallResult.java
similarity index 97%
rename from org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/codec/BundleBatchInstallResult.java
rename to org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/internal/BundleBatchInstallResult.java
index 16ed038..d459014 100644
--- a/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/codec/BundleBatchInstallResult.java
+++ b/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/internal/BundleBatchInstallResult.java
@@ -13,9 +13,9 @@
  *     Hal Hildebrand - Initial JMX support 

  ******************************************************************************/

 

-package org.eclipse.gemini.mgmt.framework.codec;

+package org.eclipse.gemini.mgmt.framework.internal;

 

-import static org.eclipse.gemini.mgmt.codec.Util.LongArrayFrom;

+import static org.eclipse.gemini.mgmt.internal.Util.LongArrayFrom;

 

 import java.io.IOException;

 import java.util.HashMap;

diff --git a/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/codec/BundleBatchResult.java b/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/internal/BundleBatchResult.java
similarity index 97%
rename from org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/codec/BundleBatchResult.java
rename to org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/internal/BundleBatchResult.java
index 1a638ab..84fc9cb 100644
--- a/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/codec/BundleBatchResult.java
+++ b/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/internal/BundleBatchResult.java
@@ -13,7 +13,7 @@
  *     Hal Hildebrand - Initial JMX support 

  ******************************************************************************/

 

-package org.eclipse.gemini.mgmt.framework.codec;

+package org.eclipse.gemini.mgmt.framework.internal;

 

 /**

  * Abstract supertype to represent the result of an operation on multiple bundles. 

diff --git a/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/codec/OSGiBundle.java b/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/internal/OSGiBundle.java
similarity index 73%
rename from org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/codec/OSGiBundle.java
rename to org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/internal/OSGiBundle.java
index 6feaaeb..ea651e2 100644
--- a/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/codec/OSGiBundle.java
+++ b/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/internal/OSGiBundle.java
@@ -13,15 +13,7 @@
  *     Hal Hildebrand - Initial JMX support 

  ******************************************************************************/

 

-package org.eclipse.gemini.mgmt.framework.codec;

-

-import static org.eclipse.gemini.mgmt.codec.Util.LongArrayFrom;

-import static org.eclipse.gemini.mgmt.codec.Util.getBundleFragments;

-import static org.eclipse.gemini.mgmt.codec.Util.getBundleHeaders;

-import static org.eclipse.gemini.mgmt.codec.Util.getBundleState;

-import static org.eclipse.gemini.mgmt.codec.Util.isBundleFragment;

-import static org.eclipse.gemini.mgmt.codec.Util.isBundlePersistentlyStarted;

-import static org.eclipse.gemini.mgmt.codec.Util.serviceIds;

+package org.eclipse.gemini.mgmt.framework.internal;

 

 import java.io.IOException;

 import java.util.ArrayList;

@@ -38,15 +30,12 @@
 import javax.management.openmbean.TabularData;

 import javax.management.openmbean.TabularDataSupport;

 

+import org.eclipse.gemini.mgmt.framework.CustomBundleStateMBean;

+import org.eclipse.gemini.mgmt.internal.Util;

 import org.osgi.framework.Bundle;

-import org.osgi.framework.BundleContext;

-

 import org.osgi.jmx.Item;

 import org.osgi.jmx.framework.BundleStateMBean;

 

-import org.eclipse.gemini.mgmt.codec.Util;

-import org.eclipse.gemini.mgmt.framework.CustomBundleStateMBean;

-

 

 /**

  * <p>

@@ -138,30 +127,8 @@
  */

 public final class OSGiBundle {

 	

-	private String[] exportedPackages;

-	private Boolean fragment;

-	private long[] fragments;

-	private Map<String, String> headers;

-	private long[] hosts;

-	private long identifier;

-	private String[] importedPackages;

-	private long lastModified;

-	private String location;

-	private Boolean persistentlyStarted;

-	private long[] registeredServices;

-	private Boolean removalPending;

-	private Boolean required;

-	private long[] requiredBundles;

-	private long[] requiringBundles;

-	private long[] servicesInUse;

-	private int startLevel;

-	private String state;

-	private String symbolicName;

-	private String version;

-	

 	private static final String[] HEADER_PROPERTY_ITEM_NAMES = new String[] {BundleStateMBean.KEY, BundleStateMBean.VALUE };

 	

-	private BundleContext bundleContext;

 	private Bundle bundle;

 

 	/**

@@ -176,8 +143,7 @@
 	 * @param b

 	 *            - the Bundle to represent

 	 */

-	public OSGiBundle(BundleContext bc, Bundle b) {

-		this.bundleContext = bc;

+	public OSGiBundle(Bundle b) {

 		this.bundle = b;

 	}

 

@@ -342,15 +308,15 @@
 		items.put(BundleStateMBean.REMOVAL_PENDING, isRemovalPending());

 		items.put(BundleStateMBean.REQUIRED, isRequired());

 		items.put(BundleStateMBean.FRAGMENT, isFragment());

-		items.put(BundleStateMBean.REGISTERED_SERVICES, LongArrayFrom(getRegisteredServices()));

-		items.put(BundleStateMBean.SERVICES_IN_USE, LongArrayFrom(getServicesInUse()));

+		items.put(BundleStateMBean.REGISTERED_SERVICES, Util.LongArrayFrom(getRegisteredServices()));

+		items.put(BundleStateMBean.SERVICES_IN_USE, Util.LongArrayFrom(getServicesInUse()));

 		items.put(BundleStateMBean.HEADERS, headerTable(getHeaders()));

 		items.put(BundleStateMBean.EXPORTED_PACKAGES, getExportedPackages());

 		items.put(BundleStateMBean.IMPORTED_PACKAGES, getImportedPackages());

-		items.put(BundleStateMBean.FRAGMENTS, LongArrayFrom(getFragments()));

-		items.put(BundleStateMBean.HOSTS, LongArrayFrom(getHosts()));

-		items.put(BundleStateMBean.REQUIRING_BUNDLES, LongArrayFrom(getRequiringBundles()));

-		items.put(BundleStateMBean.REQUIRED_BUNDLES, LongArrayFrom(getRequiredBundles()));

+		items.put(BundleStateMBean.FRAGMENTS, Util.LongArrayFrom(getFragments()));

+		items.put(BundleStateMBean.HOSTS, Util.LongArrayFrom(getHosts()));

+		items.put(BundleStateMBean.REQUIRING_BUNDLES, Util.LongArrayFrom(getRequiringBundles()));

+		items.put(BundleStateMBean.REQUIRED_BUNDLES, Util.LongArrayFrom(getRequiredBundles()));

 		try {

 			return new CompositeDataSupport(BundleStateMBean.BUNDLE_TYPE, items);

 		} catch (OpenDataException e) {

@@ -399,10 +365,10 @@
 			items.put(BundleStateMBean.FRAGMENT, isFragment());

 		}

 		if((mask | CustomBundleStateMBean.REGISTERED_SERVICES) == mask) {

-			items.put(BundleStateMBean.REGISTERED_SERVICES, LongArrayFrom(getRegisteredServices()));

+			items.put(BundleStateMBean.REGISTERED_SERVICES, Util.LongArrayFrom(getRegisteredServices()));

 		}

 		if((mask | CustomBundleStateMBean.SERVICES_IN_USE) == mask) {

-			items.put(BundleStateMBean.SERVICES_IN_USE, LongArrayFrom(getServicesInUse()));

+			items.put(BundleStateMBean.SERVICES_IN_USE, Util.LongArrayFrom(getServicesInUse()));

 		}

 		if((mask | CustomBundleStateMBean.HEADERS) == mask) {

 			items.put(BundleStateMBean.HEADERS, headerTable(getHeaders()));

@@ -414,16 +380,16 @@
 			items.put(BundleStateMBean.IMPORTED_PACKAGES, getImportedPackages());

 		}

 		if((mask | CustomBundleStateMBean.FRAGMENTS) == mask) {

-			items.put(BundleStateMBean.FRAGMENTS, LongArrayFrom(getFragments()));

+			items.put(BundleStateMBean.FRAGMENTS, Util.LongArrayFrom(getFragments()));

 		}

 		if((mask | CustomBundleStateMBean.HOSTS) == mask) {

-			items.put(BundleStateMBean.HOSTS, LongArrayFrom(getHosts()));

+			items.put(BundleStateMBean.HOSTS, Util.LongArrayFrom(getHosts()));

 		}

 		if((mask | CustomBundleStateMBean.REQUIRING_BUNDLES) == mask) {

-			items.put(BundleStateMBean.REQUIRING_BUNDLES, LongArrayFrom(getRequiringBundles()));

+			items.put(BundleStateMBean.REQUIRING_BUNDLES, Util.LongArrayFrom(getRequiringBundles()));

 		}

 		if((mask | CustomBundleStateMBean.REQUIRED_BUNDLES) == mask) {

-			items.put(BundleStateMBean.REQUIRED_BUNDLES, LongArrayFrom(getRequiredBundles()));

+			items.put(BundleStateMBean.REQUIRED_BUNDLES, Util.LongArrayFrom(getRequiredBundles()));

 		}

 

 		try {

@@ -438,205 +404,145 @@
 	 *         <packageName>;<version>

 	 * 

 	 */

-	public String[] getExportedPackages() {

-		if (exportedPackages == null) {

-			exportedPackages = Util.getBundleExportedPackages(bundle);			

-		}

-		return exportedPackages;

+	private String[] getExportedPackages() {

+		return Util.getBundleExportedPackages(bundle);

 	}

 

 	/**

 	 * @return the list of identifiers of the bundle fragments which use this

 	 *         bundle as a host

 	 */

-	public long[] getFragments() {

-		if (fragments == null) {

-			fragments = getBundleFragments(bundle);			

-		}

-		return fragments;

+	private long[] getFragments() {

+		return  Util.getBundleFragments(bundle);			

 	}

 

 	/**

 	 * @return the map of headers for this bundle

 	 */

-	public Map<String, String> getHeaders() {

-		if (headers == null) {

-			headers = getBundleHeaders(bundle);

-		}

-		return headers;

+	private Map<String, String> getHeaders() {

+		return Util.getBundleHeaders(bundle);

 	}

 

 	/**

 	 * @return list of identifiers of the bundles which host this fragment

 	 */

-	public long[] getHosts() {

-		if (hosts == null) {

-			hosts = Util.getBundleHosts(bundle);

-		}

-		return hosts;

+	private long[] getHosts() {

+		return Util.getBundleHosts(bundle);

 	}

 

 	/**

 	 * @return the identifier of this bundle

 	 */

-	public long getIdentifier() {

-		if (identifier == 0) {

-			identifier = bundle.getBundleId();

-		}

-		return identifier;

+	private long getIdentifier() {

+		return bundle.getBundleId();

 	}

 

 	/**

 	 * @return The list of imported packages by this bundle, in the form of

 	 *         <packageName>;<version>

 	 */

-	public String[] getImportedPackages() {

-		if (importedPackages == null) {

-			importedPackages = Util.getBundleImportedPackages(bundle);

-		}

-		return importedPackages;

+	private String[] getImportedPackages() {

+		return Util.getBundleImportedPackages(bundle);

 	}

 

 	/**

 	 * @return the last modified time of this bundle

 	 */

-	public long getLastModified() {

-		if (lastModified == 0) {

-			lastModified = bundle.getLastModified();

-		}

-		return lastModified;

+	private long getLastModified() {

+		return bundle.getLastModified();

 	}

 

 	/**

 	 * @return the name of this bundle

 	 */

-	public String getLocation() {

-		if (location == null) {

-			location = bundle.getLocation();

-		}

-		return location;

+	private String getLocation() {

+		return bundle.getLocation();

 	}

 

 	/**

 	 * @return the list of identifiers of the services registered by this bundle

 	 */

-	public long[] getRegisteredServices() {

-		if (registeredServices == null) {

-			registeredServices = serviceIds(bundle.getRegisteredServices());

-		}

-		return registeredServices;

+	private long[] getRegisteredServices() {

+		return Util.serviceIds(bundle.getRegisteredServices());

 	}

 

 	/**

 	 * @return the list of identifiers of bundles required by this bundle

 	 * @throws IOException 

 	 */

-	public long[] getRequiredBundles() throws IOException {

-		if (requiredBundles == null) {

-			requiredBundles = Util.getRequiredBundles(bundle);

-		}

-		return requiredBundles;

+	private long[] getRequiredBundles() throws IOException {

+		return Util.getRequiredBundles(bundle);

 	}

 

 	/**

 	 * @return the list of identifiers of bundles which require this bundle

 	 * @throws IOException 

 	 */

-	public long[] getRequiringBundles() throws IOException {

-		if (requiringBundles == null) {

-			requiringBundles = Util.getRequiringBundles(bundle);

-		}

-		return requiringBundles;

+	private long[] getRequiringBundles() throws IOException {

+		return Util.getRequiringBundles(bundle);

 	}

 

 	/**

 	 * @return the list of identifiers of services in use by this bundle

 	 */

-	public long[] getServicesInUse() {

-		if (servicesInUse == null) {

-			servicesInUse = serviceIds(bundle.getServicesInUse());

-		}

-		return servicesInUse;

+	private long[] getServicesInUse() {

+		return Util.serviceIds(bundle.getServicesInUse());

 	}

 

 	/**

 	 * @return the start level of this bundle

 	 */

-	public int getStartLevel() {

-		if (startLevel == 0) {

-			startLevel = Util.getBundleStartLevel(bundle);

-		}

-		return startLevel;

+	private int getStartLevel() {

+		return Util.getBundleStartLevel(bundle);

 	}

 

 	/**

 	 * @return the state of this bundle

 	 */

-	public String getState() {

-		if (state == null) {

-			state = getBundleState(bundle);

-		}

-		return state;

+	private String getState() {

+		return Util.getBundleState(bundle);

 	}

 

 	/**

 	 * @return the symbolic name of this bundle

 	 */

-	public String getSymbolicName() {

-		if (symbolicName == null) {

-			symbolicName = bundle.getSymbolicName();

-		}

-		return symbolicName;

+	private String getSymbolicName() {

+		return bundle.getSymbolicName();

 	}

 

 	/**

 	 * @return the version of this bundle

 	 */

-	public String getVersion() {

-		if (version == null) {

-			version = bundle.getVersion().toString();

-		}

-		return version;

+	private String getVersion() {

+		return bundle.getVersion().toString();

 	}

 

 	/**

 	 * @return true if this bundle represents a fragment

 	 */

-	public boolean isFragment() {

-		if (fragment == null) {

-			fragment = isBundleFragment(bundle);

-		}

-		return fragment;

+	private boolean isFragment() {

+		return Util.isBundleFragment(bundle);

 	}

 

 	/**

 	 * @return true if this bundle is persistently started

 	 */

-	public boolean isPersistentlyStarted() {

-		if (persistentlyStarted == null) {

-			persistentlyStarted = isBundlePersistentlyStarted(bundle);

-		}

-		return persistentlyStarted;

+	private boolean isPersistentlyStarted() {

+		return Util.isBundlePersistentlyStarted(bundle);

 	}

 

 	/**

 	 * @return true if this bundle is pending removal

 	 */

-	public boolean isRemovalPending() {

-		if (removalPending == null) {

-			removalPending = Util.isRemovalPending(bundle.getBundleId(), bundleContext);

-		}

-		return removalPending;

+	private boolean isRemovalPending() {

+		return Util.isRemovalPending(bundle);

 	}

 

 	/**

 	 * @return true if this bundle is required

 	 */

-	public boolean isRequired() {

-		if (required == null) {

-			required = Util.isRequired(bundle.getBundleId(), bundleContext);

-		}

-		return required;

+	private boolean isRequired() {

+		return Util.isRequired(bundle);

 	}

 	

 }

diff --git a/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/codec/OSGiBundleEvent.java b/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/internal/OSGiBundleEvent.java
similarity index 64%
rename from org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/codec/OSGiBundleEvent.java
rename to org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/internal/OSGiBundleEvent.java
index 8a26136..b02494b 100644
--- a/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/codec/OSGiBundleEvent.java
+++ b/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/internal/OSGiBundleEvent.java
@@ -13,7 +13,7 @@
  *     Hal Hildebrand - Initial JMX support 

  ******************************************************************************/

 

-package org.eclipse.gemini.mgmt.framework.codec;

+package org.eclipse.gemini.mgmt.framework.internal;

 

 import java.util.HashMap;

 import java.util.Map;

@@ -70,36 +70,10 @@
 	 *            - the event to represent

 	 */

 	public OSGiBundleEvent(BundleEvent event) {

-		this(event.getBundle().getBundleId(), event.getBundle().getLocation(), event.getBundle().getSymbolicName(), event.getType());

-	}

-

-	/**

-	 * Construct an OSGiBundleEvent from the CompositeData representing the

-	 * event

-	 * 

-	 * @param data

-	 *            - the CompositeData representing the event.

-	 */

-	public OSGiBundleEvent(CompositeData data) {

-		bundleId = (Long) data.get(BundleStateMBean.IDENTIFIER);

-		location = (String) data.get(BundleStateMBean.LOCATION);

-		symbolicName = (String) data.get(BundleStateMBean.SYMBOLIC_NAME);

-		eventType = (Integer) data.get(BundleStateMBean.EVENT);

-	}

-

-	/**

-	 * Construct the OSGiBundleEvent

-	 * 

-	 * @param bundleId

-	 * @param location

-	 * @param symbolicName

-	 * @param eventType

-	 */

-	public OSGiBundleEvent(long bundleId, String location, String symbolicName, int eventType) {

-		this.bundleId = bundleId;

-		this.location = location;

-		this.symbolicName = symbolicName;

-		this.eventType = eventType;

+		this.bundleId = event.getBundle().getBundleId();

+		this.location = event.getBundle().getLocation();

+		this.symbolicName = event.getBundle().getSymbolicName();

+		this.eventType =  event.getType();

 	}

 

 	/**

@@ -120,32 +94,32 @@
 		}

 	}

 

-	/**

-	 * @return the identifier of the bundle for this event

-	 */

-	public long getBundleId() {

-		return bundleId;

-	}

-

-	/**

-	 * @return the type of the event

-	 */

-	public int getEventType() {

-		return eventType;

-	}

-

-	/**

-	 * @return the location of the bundle for this event

-	 */

-	public String getLocation() {

-		return location;

-	}

-

-	/**

-	 * @return the symbolic name of the bundle for this event

-	 */

-	public String getSymbolicName() {

-		return symbolicName;

-	}

+//	/**

+//	 * @return the identifier of the bundle for this event

+//	 */

+//	public long getBundleId() {

+//		return bundleId;

+//	}

+//

+//	/**

+//	 * @return the type of the event

+//	 */

+//	public int getEventType() {

+//		return eventType;

+//	}

+//

+//	/**

+//	 * @return the location of the bundle for this event

+//	 */

+//	public String getLocation() {

+//		return location;

+//	}

+//

+//	/**

+//	 * @return the symbolic name of the bundle for this event

+//	 */

+//	public String getSymbolicName() {

+//		return symbolicName;

+//	}

 

 }

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/internal/OSGiPackage.java
similarity index 82%
rename from org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/codec/OSGiPackage.java
rename to org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/internal/OSGiPackage.java
index d505a83..af702af 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/internal/OSGiPackage.java
@@ -13,9 +13,9 @@
  *     Hal Hildebrand - Initial JMX support 

  ******************************************************************************/

 

-package org.eclipse.gemini.mgmt.framework.codec;

+package org.eclipse.gemini.mgmt.framework.internal;

 

-import static org.eclipse.gemini.mgmt.codec.Util.LongArrayFrom;

+import static org.eclipse.gemini.mgmt.internal.Util.LongArrayFrom;

 

 import java.util.HashMap;

 import java.util.Map;

@@ -123,7 +123,7 @@
 	 * 

 	 * @return the CompositeData encoding of the receiver.

 	 */

-	public CompositeData asCompositeData() {

+	private CompositeData asCompositeData() {

 		Map<String, Object> items = new HashMap<String, Object>();

 		items.put(PackageStateMBean.NAME, name);

 		items.put(PackageStateMBean.VERSION, version);

@@ -137,40 +137,40 @@
 			throw new IllegalStateException("Cannot form package open data", e);

 		}

 	}

-

-	/**

-	 * @return the identifier of the exporting bundles

-	 */

-	public long[] getExportingBundles() {

-		return exportingBundles;

-	}

-

-	/**

-	 * @return the list of identifiers of the bundles importing this package

-	 */

-	public long[] getImportingBundles() {

-		return importingBundles;

-	}

-

-	/**

-	 * @return the name of the package

-	 */

-	public String getName() {

-		return name;

-	}

-

-	/**

-	 * @return the version of the package

-	 */

-	public String getVersion() {

-		return version;

-	}

-

-	/**

-	 * @return true if the package is pending removal

-	 */

-	public boolean isRemovalPending() {

-		return removalPending;

-	}

+//

+//	/**

+//	 * @return the identifier of the exporting bundles

+//	 */

+//	public long[] getExportingBundles() {

+//		return exportingBundles;

+//	}

+//

+//	/**

+//	 * @return the list of identifiers of the bundles importing this package

+//	 */

+//	public long[] getImportingBundles() {

+//		return importingBundles;

+//	}

+//

+//	/**

+//	 * @return the name of the package

+//	 */

+//	public String getName() {

+//		return name;

+//	}

+//

+//	/**

+//	 * @return the version of the package

+//	 */

+//	public String getVersion() {

+//		return version;

+//	}

+//

+//	/**

+//	 * @return true if the package is pending removal

+//	 */

+//	public boolean isRemovalPending() {

+//		return removalPending;

+//	}

 	

 }

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/internal/OSGiService.java
similarity index 89%
rename from org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/codec/OSGiService.java
rename to org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/internal/OSGiService.java
index 3adbf6d..34b9619 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/internal/OSGiService.java
@@ -13,11 +13,11 @@
  *     Hal Hildebrand - Initial JMX support 

  ******************************************************************************/

 

-package org.eclipse.gemini.mgmt.framework.codec;

+package org.eclipse.gemini.mgmt.framework.internal;

 

 import static org.osgi.framework.Constants.OBJECTCLASS;

 import static org.osgi.framework.Constants.SERVICE_ID;

-import static org.eclipse.gemini.mgmt.codec.Util.LongArrayFrom;

+import static org.eclipse.gemini.mgmt.internal.Util.LongArrayFrom;

 

 import java.io.IOException;

 import java.util.ArrayList;

@@ -34,7 +34,7 @@
 import javax.management.openmbean.TabularDataSupport;

 

 import org.osgi.framework.ServiceReference;

-import org.eclipse.gemini.mgmt.codec.Util;

+import org.eclipse.gemini.mgmt.internal.Util;

 import org.osgi.jmx.Item;

 import org.osgi.jmx.framework.ServiceStateMBean;

 

@@ -184,32 +184,32 @@
 		}

 	}

 

-	/**

-	 * @return the identifier of the bundle the service belongs to

-	 */

-	public long getBundle() {

-		return bundle;

-	}

-

-	/**

-	 * @return the identifier of the service

-	 */

-	public long getIdentifier() {

-		return identifier;

-	}

-

-	/**

-	 * @return the interfaces implemented by the service

-	 */

-	public String[] getInterfaces() {

-		return interfaces;

-	}

-

-	/**

-	 * @return the identifiers of the bundles which are using the service

-	 */

-	public long[] getUsingBundles() {

-		return usingBundles;

-	}

+//	/**

+//	 * @return the identifier of the bundle the service belongs to

+//	 */

+//	public long getBundle() {

+//		return bundle;

+//	}

+//

+//	/**

+//	 * @return the identifier of the service

+//	 */

+//	public long getIdentifier() {

+//		return identifier;

+//	}

+//

+//	/**

+//	 * @return the interfaces implemented by the service

+//	 */

+//	public String[] getInterfaces() {

+//		return interfaces;

+//	}

+//

+//	/**

+//	 * @return the identifiers of the bundles which are using the service

+//	 */

+//	public long[] getUsingBundles() {

+//		return usingBundles;

+//	}

 

 }

diff --git a/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/internal/OSGiServiceEvent.java b/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/internal/OSGiServiceEvent.java
new file mode 100644
index 0000000..ceb94de
--- /dev/null
+++ b/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/framework/internal/OSGiServiceEvent.java
@@ -0,0 +1,148 @@
+/*******************************************************************************

+ * Copyright (c) 2010 Oracle.

+ * 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:

+ *     Hal Hildebrand - Initial JMX support 

+ ******************************************************************************/

+

+package org.eclipse.gemini.mgmt.framework.internal;

+

+import java.util.HashMap;

+import java.util.Map;

+

+import javax.management.openmbean.CompositeData;

+import javax.management.openmbean.CompositeDataSupport;

+import javax.management.openmbean.OpenDataException;

+

+import org.osgi.framework.Constants;

+import org.osgi.framework.ServiceEvent;

+import org.osgi.jmx.framework.ServiceStateMBean;

+

+/**

+ * <p>

+ * This class represents the CODEC for the composite data representing a OSGi

+ * <link>ServiceEvent</link>

+ * <p>

+ * It serves as both the documentation of the type structure and as the

+ * codification of the mechanism to convert to/from the CompositeData.

+ * <p>

+ * The structure of the composite data is:

+ * <table border="1">

+ * <tr>

+ * <td>Identifier</td>

+ * <td>String</td>

+ * </tr>

+ * <tr>

+ * <td>BundleIdentifier</td>

+ * <td>long</td>

+ * </tr>

+ * <tr>

+ * <td>BundleLocation</td>

+ * <td>String</td>

+ * </tr>

+ * <tr>

+ * <td>ObjectClass</td>

+ * <td>Array of String</td>

+ * </tr>

+ * <tr>

+ * <td>EventType</td>

+ * <td>int</td>

+ * </tr>

+ * </table>

+ */

+public final class OSGiServiceEvent {

+

+	private long bundleId;

+	

+	private int eventType;

+	

+	private String[] interfaces;

+	

+	private String location;

+	

+	private String symbolicName;

+	

+	private long serviceId;

+

+	/**

+	 * 

+	 * Construct and OSGiServiceEvent from the original

+	 * <link>ServiceEvent</link>

+	 * 

+	 * @param event

+	 */

+	public OSGiServiceEvent(ServiceEvent event) {

+		this.serviceId = (Long) event.getServiceReference().getProperty(Constants.SERVICE_ID);

+		this.bundleId = event.getServiceReference().getBundle().getBundleId();

+		this.location = event.getServiceReference().getBundle().getLocation();

+		this.symbolicName = event.getServiceReference().getBundle().getSymbolicName();

+		this.interfaces = (String[]) event.getServiceReference().getProperty(Constants.OBJECTCLASS);

+		this.eventType = event.getType();

+	}

+

+	/**

+	 * Answer the receiver encoded as CompositeData

+	 * 

+	 * @return the CompositeData encoding of the receiver.

+	 */

+	public CompositeData asCompositeData() {

+		Map<String, Object> items = new HashMap<String, Object>();

+		items.put(ServiceStateMBean.IDENTIFIER, serviceId);

+		items.put(ServiceStateMBean.BUNDLE_IDENTIFIER, bundleId);

+		items.put(ServiceStateMBean.BUNDLE_LOCATION, location);

+		items.put(ServiceStateMBean.BUNDLE_SYMBOLIC_NAME, symbolicName);

+		items.put(ServiceStateMBean.IDENTIFIER, serviceId);

+		items.put(ServiceStateMBean.OBJECT_CLASS, interfaces);

+		items.put(ServiceStateMBean.EVENT, eventType);

+

+		try {

+			return new CompositeDataSupport(ServiceStateMBean.SERVICE_EVENT_TYPE, items);

+		} catch (OpenDataException e) {

+			throw new IllegalStateException("Cannot form service event open data", e);

+		}

+	}

+//

+//	/**

+//	 * @return the identifier of the bundle the service belongs to

+//	 */

+//	public long getBundleId() {

+//		return bundleId;

+//	}

+//

+//	/**

+//	 * @return the type of the event

+//	 */

+//	public int getEventType() {

+//		return eventType;

+//	}

+//

+//	/**

+//	 * @return the interfaces the service implements

+//	 */

+//	public String[] getInterfaces() {

+//		return interfaces;

+//	}

+//

+//	/**

+//	 * @return the location of the bundle the service belongs to

+//	 */

+//	public String getLocation() {

+//		return location;

+//	}

+//

+//	/**

+//	 * @return the identifier of the service

+//	 */

+//	public long getServiceId() {

+//		return serviceId;

+//	}

+

+}

diff --git a/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/codec/OSGiProperties.java b/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/internal/OSGiProperties.java
similarity index 99%
rename from org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/codec/OSGiProperties.java
rename to org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/internal/OSGiProperties.java
index 8cf2774..175d537 100644
--- a/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/codec/OSGiProperties.java
+++ b/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/internal/OSGiProperties.java
@@ -13,7 +13,7 @@
  *     Hal Hildebrand - Initial JMX support 

  ******************************************************************************/

 

-package org.eclipse.gemini.mgmt.codec;

+package org.eclipse.gemini.mgmt.internal;

 

 import java.math.BigDecimal;

 import java.math.BigInteger;

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/internal/Util.java
similarity index 95%
rename from org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/codec/Util.java
rename to org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/internal/Util.java
index 77f0373..0c3849f 100644
--- a/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/codec/Util.java
+++ b/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/internal/Util.java
@@ -13,7 +13,7 @@
  *     Hal Hildebrand - Initial JMX support 

  ******************************************************************************/

 

-package org.eclipse.gemini.mgmt.codec;

+package org.eclipse.gemini.mgmt.internal;

 

 import static org.osgi.framework.Constants.SERVICE_ID;

 

@@ -27,7 +27,6 @@
 

 

 import org.osgi.framework.Bundle;

-import org.osgi.framework.BundleContext;

 import org.osgi.framework.Constants;

 import org.osgi.framework.ServiceReference;

 import org.osgi.framework.wiring.BundleRevision;

@@ -246,8 +245,8 @@
 	 * @param bc

 	 * @return true if the bundle is required

 	 */

-	public static boolean isRequired(long bundleId, BundleContext bc) {

-		BundleWiring wiring = bc.getBundle(bundleId).adapt(BundleWiring.class);

+	public static boolean isRequired(Bundle bundle) {

+		BundleWiring wiring = bundle.adapt(BundleWiring.class);

 		return wiring.getProvidedWires(BundleRevision.BUNDLE_NAMESPACE).size() > 0;

 	}

 

@@ -258,8 +257,8 @@
 	 * @param bc

 	 * @return true if the bundle is pending removal

 	 */

-	public static boolean isRemovalPending(long bundleId, BundleContext bc) {

-        BundleWiring wiring = bc.getBundle(bundleId).adapt(BundleWiring.class);

+	public static boolean isRemovalPending(Bundle bundle) {

+        BundleWiring wiring = bundle.adapt(BundleWiring.class);

         return (!wiring.isCurrent()) && wiring.isInUse();

 	}

 

diff --git a/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/provisioning/Provisioning.java b/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/provisioning/Provisioning.java
index 0588087..096982d 100644
--- a/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/provisioning/Provisioning.java
+++ b/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/provisioning/Provisioning.java
@@ -15,9 +15,6 @@
 

 package org.eclipse.gemini.mgmt.provisioning;

 

-import static org.eclipse.gemini.mgmt.codec.OSGiProperties.propertiesFrom;

-import static org.eclipse.gemini.mgmt.codec.OSGiProperties.tableFrom;

-

 import java.io.IOException;

 import java.io.InputStream;

 import java.net.URL;

@@ -25,6 +22,7 @@
 

 import javax.management.openmbean.TabularData;

 

+import org.eclipse.gemini.mgmt.internal.OSGiProperties;

 import org.osgi.jmx.service.provisioning.ProvisioningServiceMBean;

 import org.osgi.service.provisioning.ProvisioningService;

 

@@ -56,7 +54,7 @@
 	 * {@inheritDoc}

 	 */

 	public void addInformation(TabularData info) throws IOException {

-		provisioning.addInformation(propertiesFrom(info));

+		provisioning.addInformation(OSGiProperties.propertiesFrom(info));

 	}

 

 	/**

@@ -64,14 +62,14 @@
 	 */

 	@SuppressWarnings("unchecked")

 	public TabularData listInformation() throws IOException {

-		return tableFrom(provisioning.getInformation());

+		return OSGiProperties.tableFrom(provisioning.getInformation());

 	}

 

 	/**

 	 * {@inheritDoc}

 	 */

 	public void setInformation(TabularData info) throws IOException {

-		provisioning.setInformation(propertiesFrom(info));

+		provisioning.setInformation(OSGiProperties.propertiesFrom(info));

 	}

 

 }

diff --git a/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/useradmin/UserManager.java b/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/useradmin/UserManager.java
index c216c21..f453745 100644
--- a/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/useradmin/UserManager.java
+++ b/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/useradmin/UserManager.java
@@ -24,11 +24,11 @@
 
 import org.osgi.framework.InvalidSyntaxException;
 import org.eclipse.gemini.mgmt.Monitor;
-import org.eclipse.gemini.mgmt.codec.OSGiProperties;
-import org.eclipse.gemini.mgmt.useradmin.codec.OSGiAuthorization;
-import org.eclipse.gemini.mgmt.useradmin.codec.OSGiGroup;
-import org.eclipse.gemini.mgmt.useradmin.codec.OSGiRole;
-import org.eclipse.gemini.mgmt.useradmin.codec.OSGiUser;
+import org.eclipse.gemini.mgmt.internal.OSGiProperties;
+import org.eclipse.gemini.mgmt.useradmin.internal.OSGiAuthorization;
+import org.eclipse.gemini.mgmt.useradmin.internal.OSGiGroup;
+import org.eclipse.gemini.mgmt.useradmin.internal.OSGiRole;
+import org.eclipse.gemini.mgmt.useradmin.internal.OSGiUser;
 import org.osgi.jmx.service.useradmin.UserAdminMBean;
 import org.osgi.service.useradmin.Group;
 import org.osgi.service.useradmin.Role;
diff --git a/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/useradmin/codec/OSGiAuthorization.java b/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/useradmin/internal/OSGiAuthorization.java
similarity index 97%
rename from org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/useradmin/codec/OSGiAuthorization.java
rename to org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/useradmin/internal/OSGiAuthorization.java
index c6a857a..51de097 100644
--- a/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/useradmin/codec/OSGiAuthorization.java
+++ b/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/useradmin/internal/OSGiAuthorization.java
@@ -13,7 +13,7 @@
  *     Hal Hildebrand - Initial JMX support 

  ******************************************************************************/

 

-package org.eclipse.gemini.mgmt.useradmin.codec;

+package org.eclipse.gemini.mgmt.useradmin.internal;

 

 import java.util.HashMap;

 import java.util.Map;

diff --git a/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/useradmin/codec/OSGiGroup.java b/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/useradmin/internal/OSGiGroup.java
similarity index 97%
rename from org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/useradmin/codec/OSGiGroup.java
rename to org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/useradmin/internal/OSGiGroup.java
index ca0f108..ce9b4eb 100644
--- a/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/useradmin/codec/OSGiGroup.java
+++ b/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/useradmin/internal/OSGiGroup.java
@@ -13,7 +13,7 @@
  *     Hal Hildebrand - Initial JMX support 

  ******************************************************************************/

 

-package org.eclipse.gemini.mgmt.useradmin.codec;

+package org.eclipse.gemini.mgmt.useradmin.internal;

 

 import java.util.HashMap;

 import java.util.Map;

diff --git a/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/useradmin/codec/OSGiRole.java b/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/useradmin/internal/OSGiRole.java
similarity index 97%
rename from org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/useradmin/codec/OSGiRole.java
rename to org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/useradmin/internal/OSGiRole.java
index e62d742..0b125c3 100644
--- a/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/useradmin/codec/OSGiRole.java
+++ b/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/useradmin/internal/OSGiRole.java
@@ -13,7 +13,7 @@
  *     Hal Hildebrand - Initial JMX support 

  ******************************************************************************/

 

-package org.eclipse.gemini.mgmt.useradmin.codec;

+package org.eclipse.gemini.mgmt.useradmin.internal;

 

 import java.util.HashMap;

 import java.util.Map;

diff --git a/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/useradmin/codec/OSGiUser.java b/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/useradmin/internal/OSGiUser.java
similarity index 96%
rename from org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/useradmin/codec/OSGiUser.java
rename to org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/useradmin/internal/OSGiUser.java
index 6e132fc..30801f5 100644
--- a/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/useradmin/codec/OSGiUser.java
+++ b/org.eclipse.gemini.mgmt/src/org/eclipse/gemini/mgmt/useradmin/internal/OSGiUser.java
@@ -13,7 +13,7 @@
  *     Hal Hildebrand - Initial JMX support 

  ******************************************************************************/

 

-package org.eclipse.gemini.mgmt.useradmin.codec;

+package org.eclipse.gemini.mgmt.useradmin.internal;

 

 import java.util.HashMap;

 import java.util.Map;