Final changes to pass the Enterprise Spec CT 5.0
diff --git a/org.eclipse.gemini.management/src/main/java/org/eclipse/gemini/management/framework/Framework.java b/org.eclipse.gemini.management/src/main/java/org/eclipse/gemini/management/framework/Framework.java
index 7b39509..e3bf9ab 100644
--- a/org.eclipse.gemini.management/src/main/java/org/eclipse/gemini/management/framework/Framework.java
+++ b/org.eclipse.gemini.management/src/main/java/org/eclipse/gemini/management/framework/Framework.java
@@ -22,6 +22,7 @@
 import java.util.ArrayList;

 import java.util.Arrays;

 import java.util.Collection;

+import java.util.Collections;

 import java.util.HashSet;

 import java.util.List;

 

@@ -523,17 +524,18 @@
 	 */

 	public CompositeData refreshBundlesAndWait(long[] bundleIdentifiers) throws IOException {

 		Collection<Bundle> bundles;

+		StandardFrameworkListener standardFrameworkListener = new StandardFrameworkListener();

 		if(bundleIdentifiers == null){

-			bundles = this.frameworkWiring.getRemovalPendingBundles();

+			bundles = Arrays.asList(this.bundleContext.getBundles());

+			this.frameworkWiring.refreshBundles(null, standardFrameworkListener);

+

 		} else {

 			bundles = this.getBundles(bundleIdentifiers);

-		}

-		StandardFrameworkListener standardFrameworkListener = new StandardFrameworkListener();

-		this.frameworkWiring.refreshBundles(bundles, standardFrameworkListener);

-		

+			this.frameworkWiring.refreshBundles(bundles, standardFrameworkListener);

+		}		

 		boolean operationResult = standardFrameworkListener.getResult();

 		ArrayList<Long> completedBundles = new ArrayList<Long>();

-		boolean result = true;

+		boolean result = true;		

 		for (Bundle bundle : bundles) {

 			if(bundle.getState() >= Bundle.RESOLVED){

 				completedBundles.add(bundle.getBundleId());

diff --git a/org.eclipse.gemini.management/src/main/java/org/eclipse/gemini/management/framework/internal/OSGiBundle.java b/org.eclipse.gemini.management/src/main/java/org/eclipse/gemini/management/framework/internal/OSGiBundle.java
index 7b3be2c..735e4a8 100644
--- a/org.eclipse.gemini.management/src/main/java/org/eclipse/gemini/management/framework/internal/OSGiBundle.java
+++ b/org.eclipse.gemini.management/src/main/java/org/eclipse/gemini/management/framework/internal/OSGiBundle.java
@@ -26,7 +26,6 @@
 

 import javax.management.openmbean.CompositeData;

 import javax.management.openmbean.CompositeDataSupport;

-import javax.management.openmbean.CompositeType;

 import javax.management.openmbean.OpenDataException;

 import javax.management.openmbean.TabularData;

 import javax.management.openmbean.TabularDataSupport;

@@ -38,7 +37,6 @@
 import org.osgi.framework.wiring.BundleRevision;

 import org.osgi.framework.wiring.BundleWire;

 import org.osgi.framework.wiring.BundleWiring;

-import org.osgi.jmx.Item;

 import org.osgi.jmx.framework.BundleStateMBean;

 

 

@@ -66,146 +64,38 @@
 

 	public static TabularData tableFrom(List<OSGiBundle> bundles, String... bundleTypeItems) throws IOException {

 		List<String> bundleTypes = Arrays.asList(bundleTypeItems);

-		CompositeType computeBundleType = OSGiBundle.computeBundleType(bundleTypes);

-		TabularDataSupport table = new TabularDataSupport(Item.tabularType("BUNDLES", "A list of bundles", computeBundleType, new String[] { BundleStateMBean.IDENTIFIER }));

+		TabularDataSupport table = new TabularDataSupport(BundleStateMBean.BUNDLES_TYPE);

 		for (OSGiBundle bundle : bundles) {

-			table.put(bundle.asCompositeData(computeBundleType, bundleTypes));

+			table.put(bundle.asCompositeData(bundleTypes));

 		}

 		return table;

 	}

 	

-	private static CompositeType computeBundleType(List<String> bundleTypes) {

-		List<Item> bundleTypeItems = new ArrayList<Item>();

-		bundleTypeItems.add(BundleStateMBean.IDENTIFIER_ITEM);

-		if(bundleTypes.contains(BundleStateMBean.LOCATION)) {

-			bundleTypeItems.add(BundleStateMBean.LOCATION_ITEM);

-		}

-		if(bundleTypes.contains(BundleStateMBean.SYMBOLIC_NAME)) {

-			bundleTypeItems.add(BundleStateMBean.SYMBOLIC_NAME_ITEM);

-		}

-		if(bundleTypes.contains(BundleStateMBean.VERSION)) {

-			bundleTypeItems.add(BundleStateMBean.VERSION_ITEM);

-		}

-		if(bundleTypes.contains(BundleStateMBean.START_LEVEL)) {

-			bundleTypeItems.add(BundleStateMBean.START_LEVEL_ITEM);

-		}

-		if(bundleTypes.contains(BundleStateMBean.STATE)) {

-			bundleTypeItems.add(BundleStateMBean.STATE_ITEM);

-		}

-		if(bundleTypes.contains(BundleStateMBean.LAST_MODIFIED)) {

-			bundleTypeItems.add(BundleStateMBean.LAST_MODIFIED_ITEM);

-		}

-		if(bundleTypes.contains(BundleStateMBean.PERSISTENTLY_STARTED)) {

-			bundleTypeItems.add(BundleStateMBean.PERSISTENTLY_STARTED_ITEM);

-		}

-		if(bundleTypes.contains(BundleStateMBean.ACTIVATION_POLICY_USED)) {

-			bundleTypeItems.add(BundleStateMBean.ACTIVATION_POLICY_USED_ITEM);

-		}

-		if(bundleTypes.contains(BundleStateMBean.REMOVAL_PENDING)) {

-			bundleTypeItems.add(BundleStateMBean.REMOVAL_PENDING_ITEM);

-		}

-		if(bundleTypes.contains(BundleStateMBean.REQUIRED)) {

-			bundleTypeItems.add(BundleStateMBean.REQUIRED_ITEM);

-		}

-		if(bundleTypes.contains(BundleStateMBean.FRAGMENT)) {

-			bundleTypeItems.add(BundleStateMBean.FRAGMENT_ITEM);

-		}

-		if(bundleTypes.contains(BundleStateMBean.REGISTERED_SERVICES)) {

-			bundleTypeItems.add(BundleStateMBean.REGISTERED_SERVICES_ITEM);

-		}

-		if(bundleTypes.contains(BundleStateMBean.SERVICES_IN_USE)) {

-			bundleTypeItems.add(BundleStateMBean.SERVICES_IN_USE_ITEM);

-		}

-		if(bundleTypes.contains(BundleStateMBean.HEADERS)) {

-			bundleTypeItems.add(BundleStateMBean.HEADERS_ITEM);

-		}

-		if(bundleTypes.contains(BundleStateMBean.EXPORTED_PACKAGES)) {

-			bundleTypeItems.add(BundleStateMBean.EXPORTED_PACKAGES_ITEM);

-		}

-		if(bundleTypes.contains(BundleStateMBean.IMPORTED_PACKAGES)) {

-			bundleTypeItems.add(BundleStateMBean.IMPORTED_PACKAGES_ITEM);

-		}

-		if(bundleTypes.contains(BundleStateMBean.FRAGMENTS)) {

-			bundleTypeItems.add(BundleStateMBean.FRAGMENTS_ITEM);

-		}

-		if(bundleTypes.contains(BundleStateMBean.HOSTS)) {

-			bundleTypeItems.add(BundleStateMBean.HOSTS_ITEM);

-		}

-		if(bundleTypes.contains(BundleStateMBean.REQUIRING_BUNDLES)) {

-			bundleTypeItems.add(BundleStateMBean.REQUIRING_BUNDLES_ITEM);

-		}

-		if(bundleTypes.contains(BundleStateMBean.REQUIRED_BUNDLES)) {

-			bundleTypeItems.add(BundleStateMBean.REQUIRED_BUNDLES_ITEM);

-		}

-		CompositeType currentCompositeType = Item.compositeType("BUNDLE", "This type encapsulates OSGi bundles", bundleTypeItems.toArray(new Item[]{}));

-		return currentCompositeType;

-	}

-	

-	private CompositeData asCompositeData(CompositeType computeBundleType, List<String> bundleTypes) throws IOException {

+	private CompositeData asCompositeData(List<String> bundleTypes) throws IOException {

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

 		items.put(BundleStateMBean.IDENTIFIER, getIdentifier());

-		if(bundleTypes.contains(BundleStateMBean.LOCATION)) {

-			items.put(BundleStateMBean.LOCATION, getLocation());

-		}

-		if(bundleTypes.contains(BundleStateMBean.SYMBOLIC_NAME)) {

-			items.put(BundleStateMBean.SYMBOLIC_NAME, getSymbolicName());

-		}

-		if(bundleTypes.contains(BundleStateMBean.VERSION)) {

-			items.put(BundleStateMBean.VERSION, getVersion());

-		}

-		if(bundleTypes.contains(BundleStateMBean.START_LEVEL)) {

-			items.put(BundleStateMBean.START_LEVEL, getStartLevel());

-		}

-		if(bundleTypes.contains(BundleStateMBean.STATE)) {

-			items.put(BundleStateMBean.STATE, getState());

-		}

-		if(bundleTypes.contains(BundleStateMBean.LAST_MODIFIED)) {

-			items.put(BundleStateMBean.LAST_MODIFIED, getLastModified());

-		}

-		if(bundleTypes.contains(BundleStateMBean.PERSISTENTLY_STARTED)) {

-			items.put(BundleStateMBean.PERSISTENTLY_STARTED, isPersistentlyStarted());

-		}

-		if(bundleTypes.contains(BundleStateMBean.ACTIVATION_POLICY_USED)) {

-			items.put(BundleStateMBean.ACTIVATION_POLICY_USED, isActivationPolicyUsed());

-		}

-		if(bundleTypes.contains(BundleStateMBean.REMOVAL_PENDING)) {

-			items.put(BundleStateMBean.REMOVAL_PENDING, isRemovalPending());

-		}

-		if(bundleTypes.contains(BundleStateMBean.REQUIRED)) {

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

-		}

-		if(bundleTypes.contains(BundleStateMBean.FRAGMENT)) {

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

-		}

-		if(bundleTypes.contains(BundleStateMBean.REGISTERED_SERVICES)) {

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

-		}

-		if(bundleTypes.contains(BundleStateMBean.SERVICES_IN_USE)) {

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

-		}

-		if(bundleTypes.contains(BundleStateMBean.HEADERS)) {

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

-		}

-		if(bundleTypes.contains(BundleStateMBean.EXPORTED_PACKAGES)) {

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

-		}

-		if(bundleTypes.contains(BundleStateMBean.IMPORTED_PACKAGES)) {

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

-		}

-		if(bundleTypes.contains(BundleStateMBean.FRAGMENTS)) {

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

-		}

-		if(bundleTypes.contains(BundleStateMBean.HOSTS)) {

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

-		}

-		if(bundleTypes.contains(BundleStateMBean.REQUIRING_BUNDLES)) {

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

-		}

-		if(bundleTypes.contains(BundleStateMBean.REQUIRED_BUNDLES)) {

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

-		}

+		items.put(BundleStateMBean.LOCATION, 				bundleTypes.contains(BundleStateMBean.LOCATION) ? 				getLocation() : null);

+		items.put(BundleStateMBean.SYMBOLIC_NAME, 			bundleTypes.contains(BundleStateMBean.SYMBOLIC_NAME) ? 			getSymbolicName() : null);

+		items.put(BundleStateMBean.VERSION, 				bundleTypes.contains(BundleStateMBean.VERSION) ? 				getVersion() : null);

+		items.put(BundleStateMBean.START_LEVEL, 			bundleTypes.contains(BundleStateMBean.START_LEVEL) ? 			getStartLevel() : null);

+		items.put(BundleStateMBean.STATE, 					bundleTypes.contains(BundleStateMBean.STATE) ? 					getState() : null);

+		items.put(BundleStateMBean.LAST_MODIFIED, 			bundleTypes.contains(BundleStateMBean.LAST_MODIFIED) ? 			getLastModified() : null);

+		items.put(BundleStateMBean.PERSISTENTLY_STARTED, 	bundleTypes.contains(BundleStateMBean.PERSISTENTLY_STARTED) ? 	isPersistentlyStarted() : null);

+		items.put(BundleStateMBean.ACTIVATION_POLICY_USED, 	bundleTypes.contains(BundleStateMBean.ACTIVATION_POLICY_USED) ? isActivationPolicyUsed() : null);

+		items.put(BundleStateMBean.REMOVAL_PENDING, 		bundleTypes.contains(BundleStateMBean.REMOVAL_PENDING) ? 		isRemovalPending() : null);

+		items.put(BundleStateMBean.REQUIRED, 				bundleTypes.contains(BundleStateMBean.REQUIRED) ? 				isRequired() : null);

+		items.put(BundleStateMBean.FRAGMENT, 				bundleTypes.contains(BundleStateMBean.FRAGMENT) ? 				isFragment() : null);

+		items.put(BundleStateMBean.REGISTERED_SERVICES, 	bundleTypes.contains(BundleStateMBean.REGISTERED_SERVICES) ? 	getRegisteredServices() : null);

+		items.put(BundleStateMBean.SERVICES_IN_USE, 		bundleTypes.contains(BundleStateMBean.SERVICES_IN_USE) ? 		getServicesInUse() : null);

+		items.put(BundleStateMBean.HEADERS, 				bundleTypes.contains(BundleStateMBean.HEADERS) ? 				getHeaders() : null);

+		items.put(BundleStateMBean.EXPORTED_PACKAGES, 		bundleTypes.contains(BundleStateMBean.EXPORTED_PACKAGES) ? 		getExportedPackages() : null);

+		items.put(BundleStateMBean.IMPORTED_PACKAGES, 		bundleTypes.contains(BundleStateMBean.IMPORTED_PACKAGES) ? 		getImportedPackages() : null);

+		items.put(BundleStateMBean.FRAGMENTS, 				bundleTypes.contains(BundleStateMBean.FRAGMENTS) ? 				getFragments() : null);

+		items.put(BundleStateMBean.HOSTS, 					bundleTypes.contains(BundleStateMBean.HOSTS) ? 					getHosts() : null);

+		items.put(BundleStateMBean.REQUIRING_BUNDLES, 		bundleTypes.contains(BundleStateMBean.REQUIRING_BUNDLES) ? 		getRequiringBundles() : null);

+		items.put(BundleStateMBean.REQUIRED_BUNDLES, 		bundleTypes.contains(BundleStateMBean.REQUIRED_BUNDLES) ? 		getRequiredBundles() : null);

 		try {

-			return new CompositeDataSupport(computeBundleType, items);

+			return new CompositeDataSupport(BundleStateMBean.BUNDLE_TYPE, items);

 		} catch (OpenDataException e) {

 			throw new IllegalStateException("Cannot form bundle open data", e);

 		}

diff --git a/org.eclipse.gemini.management/src/main/java/org/eclipse/gemini/management/framework/internal/OSGiBundleEvent.java b/org.eclipse.gemini.management/src/main/java/org/eclipse/gemini/management/framework/internal/OSGiBundleEvent.java
index d470925..878e3b5 100644
--- a/org.eclipse.gemini.management/src/main/java/org/eclipse/gemini/management/framework/internal/OSGiBundleEvent.java
+++ b/org.eclipse.gemini.management/src/main/java/org/eclipse/gemini/management/framework/internal/OSGiBundleEvent.java
@@ -94,32 +94,4 @@
 		}

 	}

 

-//	/**

-//	 * @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.management/src/main/java/org/eclipse/gemini/management/framework/internal/OSGiService.java b/org.eclipse.gemini.management/src/main/java/org/eclipse/gemini/management/framework/internal/OSGiService.java
index 4b0a03b..1ad274d 100644
--- a/org.eclipse.gemini.management/src/main/java/org/eclipse/gemini/management/framework/internal/OSGiService.java
+++ b/org.eclipse.gemini.management/src/main/java/org/eclipse/gemini/management/framework/internal/OSGiService.java
@@ -19,7 +19,6 @@
 import static org.osgi.framework.Constants.SERVICE_ID;

 

 import java.io.IOException;

-import java.util.ArrayList;

 import java.util.Arrays;

 import java.util.HashMap;

 import java.util.List;

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

 import javax.management.openmbean.CompositeData;

 import javax.management.openmbean.CompositeDataSupport;

-import javax.management.openmbean.CompositeType;

 import javax.management.openmbean.OpenDataException;

 import javax.management.openmbean.TabularData;

 import javax.management.openmbean.TabularDataSupport;

@@ -35,7 +33,7 @@
 import org.eclipse.gemini.management.internal.OSGiProperties;

 import org.osgi.framework.Bundle;

 import org.osgi.framework.ServiceReference;

-import org.osgi.jmx.Item;

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

 import org.osgi.jmx.framework.ServiceStateMBean;

 

 /**

@@ -150,32 +148,12 @@
 	 */

 	public static TabularData tableFrom(List<OSGiService> services, String... serviceTypeItems) throws IOException {

 		List<String> serviceTypes = Arrays.asList(serviceTypeItems);

-		CompositeType computeServiceType = OSGiService.computeServiceType(serviceTypes);

-		TabularDataSupport table = new TabularDataSupport(Item.tabularType("SERVICES", "The table of all services", computeServiceType, ServiceStateMBean.IDENTIFIER));

+		TabularDataSupport table = new TabularDataSupport(ServiceStateMBean.SERVICES_TYPE);

 		for (OSGiService service : services) {

-			table.put(service.asCompositeData(computeServiceType, serviceTypes));

+			table.put(service.asCompositeData(serviceTypes));

 		}

 		return table;

 	}

-	

-	private static CompositeType computeServiceType(List<String> serviceTypes) {

-		List<Item> serviceTypeItems = new ArrayList<Item>();

-		serviceTypeItems.add(ServiceStateMBean.IDENTIFIER_ITEM);

-		if(serviceTypes.contains(ServiceStateMBean.BUNDLE_IDENTIFIER)){

-			serviceTypeItems.add(ServiceStateMBean.BUNDLE_IDENTIFIER_ITEM);

-		}

-		if(serviceTypes.contains(ServiceStateMBean.OBJECT_CLASS)){

-			serviceTypeItems.add(ServiceStateMBean.OBJECT_CLASS_ITEM);

-		}

-		if(serviceTypes.contains(ServiceStateMBean.USING_BUNDLES)){

-			serviceTypeItems.add(ServiceStateMBean.USING_BUNDLES_ITEM);

-		}

-		if(serviceTypes.contains(ServiceStateMBean.PROPERTIES)){

-			serviceTypeItems.add(ServiceStateMBean.PROPERTIES_ITEM);

-		}

-		CompositeType currentCompositeType = Item.compositeType("SERVICE", "This type encapsulates an OSGi service", serviceTypeItems.toArray(new Item[]{}));

-		return currentCompositeType;

-	}

 

 	/**

 	 * Answer the receiver encoded as CompositeData

@@ -203,23 +181,16 @@
 	 * 

 	 * @return the CompositeData encoding of the receiver.

 	 */

-	private CompositeData asCompositeData(CompositeType computeServiceType, List<String> serviceTypes) {

+	private CompositeData asCompositeData(List<String> serviceTypes) {

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

 		items.put(ServiceStateMBean.IDENTIFIER, identifier);

-		if(serviceTypes.contains(ServiceStateMBean.BUNDLE_IDENTIFIER)){

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

-		}

-		if(serviceTypes.contains(ServiceStateMBean.OBJECT_CLASS)){

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

-		}

-		if(serviceTypes.contains(ServiceStateMBean.USING_BUNDLES)){

-			items.put(ServiceStateMBean.USING_BUNDLES, usingBundles);

-		}

-		if(serviceTypes.contains(ServiceStateMBean.PROPERTIES)){

-			items.put(ServiceStateMBean.PROPERTIES, properties);

-		}

+		

+		items.put(ServiceStateMBean.BUNDLE_IDENTIFIER, 	serviceTypes.contains(ServiceStateMBean.BUNDLE_IDENTIFIER) ? bundle : null);

+		items.put(ServiceStateMBean.OBJECT_CLASS, 		serviceTypes.contains(ServiceStateMBean.OBJECT_CLASS) ? 		interfaces : null);

+		items.put(ServiceStateMBean.USING_BUNDLES, 		serviceTypes.contains(ServiceStateMBean.USING_BUNDLES) ? 	usingBundles : null);

+		items.put(ServiceStateMBean.PROPERTIES, 		serviceTypes.contains(ServiceStateMBean.PROPERTIES) ? 		properties : null);

 		try {

-			return new CompositeDataSupport(computeServiceType, items);

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

 		} catch (OpenDataException e) {

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

 		}

diff --git a/org.eclipse.gemini.management/src/main/java/org/eclipse/gemini/management/framework/internal/OSGiServiceEvent.java b/org.eclipse.gemini.management/src/main/java/org/eclipse/gemini/management/framework/internal/OSGiServiceEvent.java
index 00b4377..fe60d8b 100644
--- a/org.eclipse.gemini.management/src/main/java/org/eclipse/gemini/management/framework/internal/OSGiServiceEvent.java
+++ b/org.eclipse.gemini.management/src/main/java/org/eclipse/gemini/management/framework/internal/OSGiServiceEvent.java
@@ -109,40 +109,5 @@
 			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;

-//	}

 

 }