aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jwr...@apache.org
Subject svn commit: r1406875 [2/2] - in /aries/trunk/subsystem: subsystem-api/ subsystem-api/src/main/java/org/apache/ subsystem-api/src/main/java/org/apache/aries/ subsystem-api/src/main/java/org/apache/aries/subsystem/ subsystem-bundle/ subsystem-core/src/ma...
Date Thu, 08 Nov 2012 00:33:53 GMT
Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemServiceRegistrar.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemServiceRegistrar.java?rev=1406875&r1=1406874&r2=1406875&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemServiceRegistrar.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemServiceRegistrar.java
Thu Nov  8 00:33:51 2012
@@ -22,6 +22,7 @@ import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.Map;
 
+import org.apache.aries.subsystem.AriesSubsystem;
 import org.eclipse.equinox.region.Region;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceRegistration;
@@ -30,7 +31,7 @@ import org.osgi.service.subsystem.Subsys
 
 public class SubsystemServiceRegistrar {
 	private final BundleContext context;
-	private final Map<Subsystem, ServiceRegistration<Subsystem>> map = new HashMap<Subsystem,
ServiceRegistration<Subsystem>>();
+	private final Map<Subsystem, ServiceRegistration<?>> map = new HashMap<Subsystem,
ServiceRegistration<?>>();
 	
 	public SubsystemServiceRegistrar(BundleContext context) {
 		if (context == null)
@@ -38,8 +39,8 @@ public class SubsystemServiceRegistrar {
 		this.context = context;
 	}
 	
-	public synchronized void addRegion(AriesSubsystem subsystem, Region region) {
-		ServiceRegistration<Subsystem> registration = map.get(subsystem);
+	public synchronized void addRegion(BasicSubsystem subsystem, Region region) {
+		ServiceRegistration<?> registration = map.get(subsystem);
 		if (registration == null)
 			throw new IllegalStateException("Subsystem '" + subsystem + "' is not registered");
 		Collection<String> currentRegions = (Collection<String>)registration.getReference().getProperty(Constants.SubsystemServicePropertyRegions);
@@ -54,23 +55,25 @@ public class SubsystemServiceRegistrar {
 		registration.setProperties(properties);
 	}
 	
-	public synchronized Subsystem getSubsystemService(AriesSubsystem subsystem) {
-		ServiceRegistration<Subsystem> registration = map.get(subsystem);
+	public synchronized Subsystem getSubsystemService(BasicSubsystem subsystem) {
+		ServiceRegistration<?> registration = map.get(subsystem);
 		if (registration == null)
 			return null;
-		return Activator.getInstance().getBundleContext().getService(registration.getReference());
+		return (Subsystem)Activator.getInstance().getBundleContext().getService(registration.getReference());
 	}
 	
-	public synchronized void register(AriesSubsystem child, AriesSubsystem parent) {
+	public synchronized void register(BasicSubsystem child, BasicSubsystem parent) {
 		if (map.containsKey(child))
 			return;
 		Dictionary<String, Object> properties = properties(child, parent);
-		ServiceRegistration<Subsystem> registration = context.registerService(Subsystem.class,
child, properties);
+		ServiceRegistration<?> registration = context.registerService(
+				new String[] {Subsystem.class.getName(), AriesSubsystem.class.getName()}, 
+				child, properties);
 		map.put(child, registration);
 	}
 	
-	public synchronized void removeRegion(AriesSubsystem subsystem, Region region) {
-		ServiceRegistration<Subsystem> registration = map.get(subsystem);
+	public synchronized void removeRegion(BasicSubsystem subsystem, Region region) {
+		ServiceRegistration<?> registration = map.get(subsystem);
 		if (registration == null)
 			return;
 		Collection<String> regions = (Collection<String>)registration.getReference().getProperty(Constants.SubsystemServicePropertyRegions);
@@ -85,29 +88,29 @@ public class SubsystemServiceRegistrar {
 	}
 	
 	public synchronized void unregister(Subsystem subsystem) {
-		ServiceRegistration<Subsystem> registration = map.remove(subsystem);
+		ServiceRegistration<?> registration = map.remove(subsystem);
 		if (registration == null)
 			throw new IllegalStateException("Subsystem '" + subsystem + "' is not registered");
 		registration.unregister();
 	}
 	
 	public synchronized void unregisterAll() {
-		for (Iterator<ServiceRegistration<Subsystem>> i = map.values().iterator();
i.hasNext();) {
-			ServiceRegistration<Subsystem> registration = i.next();
+		for (Iterator<ServiceRegistration<?>> i = map.values().iterator(); i.hasNext();)
{
+			ServiceRegistration<?> registration = i.next();
 			registration.unregister();
 			i.remove();
 		}
 	}
 	
-	public synchronized void update(AriesSubsystem subsystem) {
-		ServiceRegistration<Subsystem> registration = map.get(subsystem);
+	public synchronized void update(BasicSubsystem subsystem) {
+		ServiceRegistration<?> registration = map.get(subsystem);
 		if (registration == null)
 			throw new IllegalStateException("Subsystem '" + subsystem + "' is not registered");
 		Dictionary<String, Object> properties = properties(subsystem, registration);
 		registration.setProperties(properties);
 	}
 	
-	private Dictionary<String, Object> properties(AriesSubsystem subsystem) {
+	private Dictionary<String, Object> properties(BasicSubsystem subsystem) {
 		Dictionary<String, Object> result = new Hashtable<String, Object>();
 		result.put(SubsystemConstants.SUBSYSTEM_ID_PROPERTY, subsystem.getSubsystemId());
 		result.put(SubsystemConstants.SUBSYSTEM_SYMBOLICNAME_PROPERTY, subsystem.getSymbolicName());
@@ -118,7 +121,7 @@ public class SubsystemServiceRegistrar {
 		return result;
 	}
 	
-	private Dictionary<String, Object> properties(AriesSubsystem child, AriesSubsystem
parent) {
+	private Dictionary<String, Object> properties(BasicSubsystem child, BasicSubsystem
parent) {
 		Dictionary<String, Object> result = properties(child);
 		if (parent == null)
 			return result;
@@ -130,7 +133,7 @@ public class SubsystemServiceRegistrar {
 		return result;
 	}
 	
-	private Dictionary<String, Object> properties(AriesSubsystem subsystem, ServiceRegistration<Subsystem>
registration) {
+	private Dictionary<String, Object> properties(BasicSubsystem subsystem, ServiceRegistration<?>
registration) {
 		Dictionary<String, Object> result = properties(subsystem);
 		Collection<String> regions = (Collection<String>)registration.getReference().getProperty(Constants.SubsystemServicePropertyRegions);
 		if (regions == null)

Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/Subsystems.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/Subsystems.java?rev=1406875&r1=1406874&r2=1406875&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/Subsystems.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/Subsystems.java
Thu Nov  8 00:33:51 2012
@@ -34,20 +34,20 @@ import org.osgi.service.subsystem.Subsys
 import org.osgi.service.subsystem.SubsystemException;
 
 public class Subsystems {
-	private AriesSubsystem root;
+	private BasicSubsystem root;
 	private volatile SubsystemGraph graph;
 	
-	private final Map<Long, AriesSubsystem> idToSubsystem = new HashMap<Long, AriesSubsystem>();
-	private final Map<String, AriesSubsystem> locationToSubsystem = new HashMap<String,
AriesSubsystem>();
+	private final Map<Long, BasicSubsystem> idToSubsystem = new HashMap<Long, BasicSubsystem>();
+	private final Map<String, BasicSubsystem> locationToSubsystem = new HashMap<String,
BasicSubsystem>();
 	private final ResourceReferences resourceReferences = new ResourceReferences();
-	private final Map<AriesSubsystem, Set<Resource>> subsystemToConstituents = new
HashMap<AriesSubsystem, Set<Resource>>();
+	private final Map<BasicSubsystem, Set<Resource>> subsystemToConstituents = new
HashMap<BasicSubsystem, Set<Resource>>();
 	
-	public void addChild(AriesSubsystem parent, AriesSubsystem child, boolean referenceCount)
{
+	public void addChild(BasicSubsystem parent, BasicSubsystem child, boolean referenceCount)
{
 		graph.add(parent, child);
 		child.addedParent(parent, referenceCount);
 	}
 	
-	public void addConstituent(AriesSubsystem subsystem, Resource constituent, boolean referenced)
{
+	public void addConstituent(BasicSubsystem subsystem, Resource constituent, boolean referenced)
{
 		synchronized (subsystemToConstituents) {
 			Set<Resource> constituents = subsystemToConstituents.get(subsystem);
 			if (constituents == null) {
@@ -59,11 +59,11 @@ public class Subsystems {
 		subsystem.addedConstituent(constituent, referenced);
 	}
 	
-	public void addReference(AriesSubsystem subsystem, Resource resource) {
+	public void addReference(BasicSubsystem subsystem, Resource resource) {
 		resourceReferences.addReference(subsystem, resource);
 	}
 	
-	public void addSubsystem(AriesSubsystem subsystem) {
+	public void addSubsystem(BasicSubsystem subsystem) {
 		synchronized (idToSubsystem) {
 			synchronized (locationToSubsystem) {
 				addIdToSubsystem(subsystem);
@@ -72,11 +72,11 @@ public class Subsystems {
 		}
 	}
 	
-	public Collection<Subsystem> getChildren(AriesSubsystem parent) {
+	public Collection<Subsystem> getChildren(BasicSubsystem parent) {
 		return graph.getChildren(parent);
 	}
 	
-	public Collection<Resource> getConstituents(AriesSubsystem subsystem) {
+	public Collection<Resource> getConstituents(BasicSubsystem subsystem) {
 		synchronized (subsystemToConstituents) {
 			Collection<Resource> result = subsystemToConstituents.get(subsystem);
 			if (result == null)
@@ -85,15 +85,15 @@ public class Subsystems {
 		}
 	}
 	
-	public Collection<Subsystem> getParents(AriesSubsystem child) {
+	public Collection<Subsystem> getParents(BasicSubsystem child) {
 		return graph.getParents(child);
 	}
 	
-	public Collection<Resource> getResourcesReferencedBy(AriesSubsystem subsystem) {
+	public Collection<Resource> getResourcesReferencedBy(BasicSubsystem subsystem) {
 		return resourceReferences.getResources(subsystem);
 	}
 	
-	public synchronized AriesSubsystem getRootSubsystem() {
+	public synchronized BasicSubsystem getRootSubsystem() {
 		if (root == null) {
 			File file = Activator.getInstance().getBundleContext().getDataFile("");
 			File[] fileArray = file.listFiles();
@@ -120,7 +120,7 @@ public class Subsystems {
 				}
 				Coordination coordination = Utils.createCoordination();
 				try {
-					root = new AriesSubsystem(resource);
+					root = new BasicSubsystem(resource);
 					// TODO This initialization is a bit brittle. The root subsystem
 					// must be gotten before anything else will be able to use the
 					// graph. At the very least, throw IllegalStateException where
@@ -145,10 +145,10 @@ public class Subsystems {
 			else {
 				// There are persisted subsystems.
 				Coordination coordination = Utils.createCoordination();
-				Collection<AriesSubsystem> subsystems = new ArrayList<AriesSubsystem>(fileList.size());
+				Collection<BasicSubsystem> subsystems = new ArrayList<BasicSubsystem>(fileList.size());
 				try {
 					for (File f : fileList) {
-						AriesSubsystem s = new AriesSubsystem(f);
+						BasicSubsystem s = new BasicSubsystem(f);
 						subsystems.add(s);
 						addSubsystem(s);
 					}
@@ -165,26 +165,26 @@ public class Subsystems {
 		return root;
 	}
 	
-	public AriesSubsystem getSubsystemById(long id) {
+	public BasicSubsystem getSubsystemById(long id) {
 		synchronized (idToSubsystem) {
 			return idToSubsystem.get(id);
 		}
 	}
 	
-	public AriesSubsystem getSubsystemByLocation(String location) {
+	public BasicSubsystem getSubsystemByLocation(String location) {
 		synchronized (locationToSubsystem) {
 			return locationToSubsystem.get(location);
 		}
 	}
 	
-	public Collection<AriesSubsystem> getSubsystems() {
-		return new ArrayList<AriesSubsystem>(idToSubsystem.values());
+	public Collection<BasicSubsystem> getSubsystems() {
+		return new ArrayList<BasicSubsystem>(idToSubsystem.values());
 	}
 	
-	public Collection<AriesSubsystem> getSubsystemsByConstituent(Resource constituent)
{
-		ArrayList<AriesSubsystem> result = new ArrayList<AriesSubsystem>();
+	public Collection<BasicSubsystem> getSubsystemsByConstituent(Resource constituent)
{
+		ArrayList<BasicSubsystem> result = new ArrayList<BasicSubsystem>();
 		synchronized (subsystemToConstituents) {
-			for (AriesSubsystem subsystem : subsystemToConstituents.keySet())
+			for (BasicSubsystem subsystem : subsystemToConstituents.keySet())
 				if (getConstituents(subsystem).contains(constituent))
 					result.add(subsystem);
 		}
@@ -192,19 +192,19 @@ public class Subsystems {
 		return result;
 	}
 	
-	public Collection<AriesSubsystem> getSubsystemsReferencing(Resource resource) {
+	public Collection<BasicSubsystem> getSubsystemsReferencing(Resource resource) {
 		return resourceReferences.getSubsystems(resource);
 	}
 	
-	public void removeChild(AriesSubsystem child) {
+	public void removeChild(BasicSubsystem child) {
 		graph.remove(child);
 	}
 	
-	public void removeChild(AriesSubsystem parent, AriesSubsystem child) {
+	public void removeChild(BasicSubsystem parent, BasicSubsystem child) {
 		graph.remove(parent, child);
 	}
 	
-	public void removeConstituent(AriesSubsystem subsystem, Resource constituent) {
+	public void removeConstituent(BasicSubsystem subsystem, Resource constituent) {
 		synchronized (subsystemToConstituents) {
 			Set<Resource> constituents = subsystemToConstituents.get(subsystem);
 			if (constituents != null) {
@@ -216,11 +216,11 @@ public class Subsystems {
 		subsystem.removedContent(constituent);
 	}
 	
-	public void removeReference(AriesSubsystem subsystem, Resource resource) {
+	public void removeReference(BasicSubsystem subsystem, Resource resource) {
 		resourceReferences.removeReference(subsystem, resource);
 	}
 	
-	public void removeSubsystem(AriesSubsystem subsystem) {
+	public void removeSubsystem(BasicSubsystem subsystem) {
 		synchronized (idToSubsystem) {
 			synchronized (locationToSubsystem) {
 				removeLocationToSubsystem(subsystem);
@@ -229,22 +229,22 @@ public class Subsystems {
 		}
 	}
 	
-	private void addIdToSubsystem(AriesSubsystem subsystem) {
+	private void addIdToSubsystem(BasicSubsystem subsystem) {
 		long id = subsystem.getSubsystemId();
 		idToSubsystem.put(id, subsystem);
 	}
 	
-	private void addLocationToSubsystem(AriesSubsystem subsystem) {
+	private void addLocationToSubsystem(BasicSubsystem subsystem) {
 		String location = subsystem.getLocation();
 		locationToSubsystem.put(location, subsystem);
 	}
 	
-	private void removeIdToSubsystem(AriesSubsystem subsystem) {
+	private void removeIdToSubsystem(BasicSubsystem subsystem) {
 		long id = subsystem.getSubsystemId();
 		idToSubsystem.remove(id);
 	}
 	
-	private void removeLocationToSubsystem(AriesSubsystem subsystem) {
+	private void removeLocationToSubsystem(BasicSubsystem subsystem) {
 		String location = subsystem.getLocation();
 		locationToSubsystem.remove(location);
 	}

Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SystemRepository.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SystemRepository.java?rev=1406875&r1=1406874&r2=1406875&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SystemRepository.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SystemRepository.java
Thu Nov  8 00:33:51 2012
@@ -24,9 +24,9 @@ import org.osgi.resource.Resource;
 import org.osgi.service.repository.Repository;
 
 public class SystemRepository implements Repository {
-	private final AriesSubsystem root;
+	private final BasicSubsystem root;
 	
-	public SystemRepository(AriesSubsystem root) {
+	public SystemRepository(BasicSubsystem root) {
 		this.root = root;
 	}
 
@@ -45,7 +45,7 @@ public class SystemRepository implements
 		return result;
 	}
 	
-	private void findProviders(Requirement requirement, Collection<Capability> capabilities,
AriesSubsystem subsystem) {
+	private void findProviders(Requirement requirement, Collection<Capability> capabilities,
BasicSubsystem subsystem) {
 		// Need to examine capabilities offered by the subsystem itself.
 		// For example, the requirement might be an osgi.identity
 		// requirement for a preferred provider that's a subsystem.
@@ -53,8 +53,8 @@ public class SystemRepository implements
 			if (ResourceHelper.matches(requirement, capability))
 				capabilities.add(capability);
 		for (Resource constituent : subsystem.getConstituents()) {
-			if (constituent instanceof AriesSubsystem)
-				findProviders(requirement, capabilities, (AriesSubsystem)constituent);
+			if (constituent instanceof BasicSubsystem)
+				findProviders(requirement, capabilities, (BasicSubsystem)constituent);
 			else
 				for (Capability capability : constituent.getCapabilities(requirement.getNamespace()))
 					if (ResourceHelper.matches(requirement, capability))

Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/TargetRegion.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/TargetRegion.java?rev=1406875&r1=1406874&r2=1406875&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/TargetRegion.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/TargetRegion.java
Thu Nov  8 00:33:51 2012
@@ -22,11 +22,11 @@ import org.osgi.service.subsystem.Subsys
 public class TargetRegion {
 	Collection<Subsystem> region = new HashSet<Subsystem>();
 
-	public TargetRegion(AriesSubsystem subsystem) {
+	public TargetRegion(BasicSubsystem subsystem) {
 		// Find the scoped subsystem that controls the region.
-		AriesSubsystem controllingScopedSubsystem = subsystem;
+		BasicSubsystem controllingScopedSubsystem = subsystem;
 		while (controllingScopedSubsystem.isFeature())
-			controllingScopedSubsystem = (AriesSubsystem)subsystem.getParents().iterator().next();
+			controllingScopedSubsystem = (BasicSubsystem)subsystem.getParents().iterator().next();
 		// The scoped subsystem controlling the region is part of the region.
 		region.add(controllingScopedSubsystem);
 		// All children of the scoped subsystem are part of the region. If the
@@ -54,24 +54,24 @@ public class TargetRegion {
 		return null;
 	}
 	
-	private void addChildrenToRegion(AriesSubsystem controllingScopedSubsystem) {
+	private void addChildrenToRegion(BasicSubsystem controllingScopedSubsystem) {
 		for (Subsystem child : controllingScopedSubsystem.getChildren()) {
 			region.add(child);
 			// If the child is a feature, all of its children that are features
 			// must be added as well.
-			if (((AriesSubsystem)child).isFeature())
-				addFeatureDescendentsToRegion((AriesSubsystem)child);
+			if (((BasicSubsystem)child).isFeature())
+				addFeatureDescendentsToRegion((BasicSubsystem)child);
 		}
 	}
 	
-	private void addFeatureDescendentsToRegion(AriesSubsystem parent) {
+	private void addFeatureDescendentsToRegion(BasicSubsystem parent) {
 		for (Subsystem child : parent.getChildren())
 			// If the descendant is not a feature, skip it.
-			if (((AriesSubsystem)child).isFeature()) {
+			if (((BasicSubsystem)child).isFeature()) {
 				region.add(child);
 				// All descendants that are features and part of an unbroken
 				// line of features must be added.
-				addFeatureDescendentsToRegion((AriesSubsystem)child);
+				addFeatureDescendentsToRegion((BasicSubsystem)child);
 			}
 	}
 }

Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/ThreadLocalSubsystem.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/ThreadLocalSubsystem.java?rev=1406875&r1=1406874&r2=1406875&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/ThreadLocalSubsystem.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/ThreadLocalSubsystem.java
Thu Nov  8 00:33:51 2012
@@ -14,15 +14,15 @@
 package org.apache.aries.subsystem.core.internal;
 
 public class ThreadLocalSubsystem {
-	private static ThreadLocal<AriesSubsystem> subsystem = new ThreadLocal<AriesSubsystem>();
+	private static ThreadLocal<BasicSubsystem> subsystem = new ThreadLocal<BasicSubsystem>();
 	
-	public static AriesSubsystem get() {
-		AriesSubsystem result = (AriesSubsystem)subsystem.get();
+	public static BasicSubsystem get() {
+		BasicSubsystem result = (BasicSubsystem)subsystem.get();
 		subsystem.remove();
 		return result;
 	}
 	
-	public static void set(AriesSubsystem value) {
+	public static void set(BasicSubsystem value) {
 		subsystem.set(value);
 	}
 }

Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/UninstallAction.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/UninstallAction.java?rev=1406875&r1=1406874&r2=1406875&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/UninstallAction.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/UninstallAction.java
Thu Nov  8 00:33:51 2012
@@ -18,7 +18,7 @@ import java.util.EnumSet;
 import org.osgi.service.subsystem.Subsystem.State;
 
 public class UninstallAction extends AbstractAction {
-	public UninstallAction(AriesSubsystem requestor, AriesSubsystem target, boolean disableRootCheck)
{
+	public UninstallAction(BasicSubsystem requestor, BasicSubsystem target, boolean disableRootCheck)
{
 		super(requestor, target, disableRootCheck);
 	}
 	

Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/Utils.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/Utils.java?rev=1406875&r1=1406874&r2=1406875&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/Utils.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/Utils.java
Thu Nov  8 00:33:51 2012
@@ -31,44 +31,44 @@ public class Utils {
 	private static final Logger logger = LoggerFactory.getLogger(Utils.class);
 	
 	public static Coordination createCoordination() {
-		return Activator.getInstance().getCoordinator().begin(AriesSubsystem.ROOT_SYMBOLIC_NAME
+ "-0", 0);
+		return Activator.getInstance().getCoordinator().begin(BasicSubsystem.ROOT_SYMBOLIC_NAME
+ "-0", 0);
 	}
 	
-	public static Coordination createCoordination(AriesSubsystem subsystem) {
+	public static Coordination createCoordination(BasicSubsystem subsystem) {
 		return Activator.getInstance().getCoordinator().begin(subsystem.getSymbolicName() + '-'
+ subsystem.getSubsystemId(), 0);
 	}
 	
-	public static AriesSubsystem findFirstSubsystemAcceptingDependenciesStartingFrom(AriesSubsystem
subsystem) {
+	public static BasicSubsystem findFirstSubsystemAcceptingDependenciesStartingFrom(BasicSubsystem
subsystem) {
 		// The following loop is guaranteed to end once the root subsystem has
 		// been reached.
 		while (!isAcceptDependencies(subsystem))
-			subsystem = (AriesSubsystem)subsystem.getParents().iterator().next();
+			subsystem = (BasicSubsystem)subsystem.getParents().iterator().next();
 		return subsystem;
 	}
 	
-	public static AriesSubsystem findScopedSubsystemInRegion(AriesSubsystem subsystem) {
+	public static BasicSubsystem findScopedSubsystemInRegion(BasicSubsystem subsystem) {
 		while (!subsystem.isScoped())
-			subsystem = (AriesSubsystem)subsystem.getParents().iterator().next();
+			subsystem = (BasicSubsystem)subsystem.getParents().iterator().next();
 		return subsystem;
 	}
 	
 	public static int getActiveUseCount(Resource resource) {
 		int result = 0;
-		for (AriesSubsystem subsystem : Activator.getInstance().getSubsystems().getSubsystemsReferencing(resource))
+		for (BasicSubsystem subsystem : Activator.getInstance().getSubsystems().getSubsystemsReferencing(resource))
 			if (Subsystem.State.ACTIVE.equals(subsystem.getState()))
 				result++;
 		return result;
 	}
 	
 	public static long getId(Resource resource) {
-		if (resource instanceof AriesSubsystem)
-			return ((AriesSubsystem)resource).getSubsystemId();
+		if (resource instanceof BasicSubsystem)
+			return ((BasicSubsystem)resource).getSubsystemId();
 		if (resource instanceof BundleRevision)
 			return ((BundleRevision)resource).getBundle().getBundleId();
 		return -1;
 	}
 	
-	public static void installResource(Resource resource, AriesSubsystem subsystem) {
+	public static void installResource(Resource resource, BasicSubsystem subsystem) {
 		Coordination coordination = Utils.createCoordination(subsystem);
 		try {
 			ResourceInstaller.newInstance(coordination, resource, subsystem).install();
@@ -86,7 +86,7 @@ public class Utils {
 		}
 	}
 	
-	public static boolean isAcceptDependencies(AriesSubsystem subsystem) {
+	public static boolean isAcceptDependencies(BasicSubsystem subsystem) {
 		return subsystem.getSubsystemManifest().getSubsystemTypeHeader().getProvisionPolicyDirective().isAcceptDependencies();
 	}
 	
@@ -103,7 +103,7 @@ public class Utils {
 	 * returns true only if the resource is "true" content of the subsystem and,
 	 * therefore, uses the Subsystem-Content header from the subsystem manifest.
 	 */
-	public static boolean isContent(AriesSubsystem subsystem, Resource resource) {
+	public static boolean isContent(BasicSubsystem subsystem, Resource resource) {
 		SubsystemManifest subsystemManifest = subsystem.getSubsystemManifest();
 		if (subsystemManifest == null)
 			return false;
@@ -113,7 +113,7 @@ public class Utils {
 		return subsystemContentHeader.contains(resource);
 	}
 	
-	public static boolean isDependency(AriesSubsystem subsystem, Resource resource) {
+	public static boolean isDependency(BasicSubsystem subsystem, Resource resource) {
 		DeploymentManifest manifest = subsystem.getDeploymentManifest();
 		if (manifest == null)
 			return false;
@@ -133,7 +133,7 @@ public class Utils {
 	}
 	
 	public static boolean isSharedResource(Resource resource) {
-		return resource instanceof AriesSubsystem || resource instanceof BundleRevision;
+		return resource instanceof BasicSubsystem || resource instanceof BundleRevision;
 	}
 	
 	public static boolean isSubsystem(Resource resource) {

Modified: aries/trunk/subsystem/subsystem-itests/pom.xml
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/pom.xml?rev=1406875&r1=1406874&r2=1406875&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/pom.xml (original)
+++ aries/trunk/subsystem/subsystem-itests/pom.xml Thu Nov  8 00:33:51 2012
@@ -214,6 +214,12 @@
             </exclusions>
         </dependency>
         <dependency>
+        	<groupId>org.easymock</groupId>
+        	<artifactId>easymock</artifactId>
+        	<version>3.0</version>
+        	<scope>test</scope>
+        </dependency>
+        <dependency>
             <groupId>org.osgi</groupId>
             <artifactId>org.osgi.core</artifactId>
             <scope>test</scope>

Added: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/AriesSubsystemTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/AriesSubsystemTest.java?rev=1406875&view=auto
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/AriesSubsystemTest.java
(added)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/AriesSubsystemTest.java
Thu Nov  8 00:33:51 2012
@@ -0,0 +1,151 @@
+package org.apache.aries.subsystem.itests;
+
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.aries.subsystem.AriesSubsystem;
+import org.apache.aries.subsystem.core.internal.BasicRequirement;
+import org.apache.aries.util.filesystem.FileSystem;
+import org.apache.aries.util.filesystem.IDirectory;
+import org.easymock.EasyMock;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.junit.MavenConfiguredJUnit4TestRunner;
+import org.osgi.framework.namespace.PackageNamespace;
+import org.osgi.resource.Requirement;
+import org.osgi.resource.Resource;
+import org.osgi.service.subsystem.Subsystem;
+import org.osgi.service.subsystem.SubsystemConstants;
+import org.osgi.service.subsystem.SubsystemException;
+
+import aQute.lib.osgi.Constants;
+
+@RunWith(MavenConfiguredJUnit4TestRunner.class)
+public class AriesSubsystemTest extends SubsystemTest {
+	/*
+	 * Subsystem-SymbolicName: application.a.esa
+	 * Subsystem-Content: bundle.a.jar
+	 */
+	private static final String APPLICATION_A = "application.a.esa";
+	/*
+	 * Bundle-SymbolicName: bundle.a.jar
+	 * Import-Package: org.osgi.framework
+	 */
+	private static final String BUNDLE_A = "bundle.a.jar";
+	/*
+	 * Subsystem-SymbolicName: composite.a.esa
+	 * Subsystem-Type: osgi.subsystem.composite
+	 */
+	private static final String COMPOSITE_A = "composite.a.esa";
+	
+	private static void createApplicationA() throws IOException {
+		createApplicationAManifest();
+		createSubsystem(APPLICATION_A, BUNDLE_A);
+	}
+	
+	private static void createApplicationAManifest() throws IOException {
+		Map<String, String> attributes = new HashMap<String, String>();
+		attributes.put(SubsystemConstants.SUBSYSTEM_SYMBOLICNAME, APPLICATION_A);
+		createManifest(APPLICATION_A + ".mf", attributes);
+	}
+	
+	private static void createBundleA() throws IOException {
+		Map<String, String> headers = new HashMap<String, String>();
+		headers.put(Constants.IMPORT_PACKAGE, "org.osgi.framework");
+		createBundle(BUNDLE_A, headers);
+	}
+	
+	private static void createCompositeA() throws IOException {
+		createCompositeAManifest();
+		createSubsystem(COMPOSITE_A);
+	}
+	
+	private static void createCompositeAManifest() throws IOException {
+		Map<String, String> attributes = new HashMap<String, String>();
+		attributes.put(SubsystemConstants.SUBSYSTEM_SYMBOLICNAME, COMPOSITE_A);
+		attributes.put(SubsystemConstants.SUBSYSTEM_TYPE, SubsystemConstants.SUBSYSTEM_TYPE_COMPOSITE);
+		createManifest(COMPOSITE_A + ".mf", attributes);
+	}
+	
+	private static boolean createdTestFiles;
+	@Before
+	public static void createTestFiles() throws Exception {
+		if (createdTestFiles)
+			return;
+		createBundleA();
+		createApplicationA();
+		createCompositeA();
+		createdTestFiles = true;
+	}
+	
+	public void setUp() throws Exception {
+		super.setUp();
+	}
+	
+	@Test
+	public void testAddRequirements() throws Exception {
+		Subsystem compositeA = installSubsystemFromFile(COMPOSITE_A);
+		try {
+			try {
+				installSubsystemFromFile(compositeA, APPLICATION_A);
+				fail("Subsystem should not have installed");
+			} catch (SubsystemException e) {
+				// Okay.
+			}
+			Requirement requirement = new BasicRequirement.Builder()
+					.namespace(PackageNamespace.PACKAGE_NAMESPACE)
+					.directive(
+							PackageNamespace.REQUIREMENT_FILTER_DIRECTIVE, 
+							"(osgi.wiring.package=org.osgi.framework)")
+					.resource(EasyMock.createMock(Resource.class))
+					.build();
+			((AriesSubsystem)compositeA).addRequirements(Collections.singleton(requirement));
+			try {
+				installSubsystemFromFile(compositeA, APPLICATION_A);
+			} catch (SubsystemException e) {
+				fail("Subsystem should have installed");
+			}
+		} finally {
+			uninstallSubsystemSilently(compositeA);
+		}
+	}
+	
+	@Test
+	public void testInstallIDirectory() {
+		File file = new File(COMPOSITE_A);
+		IDirectory directory = FileSystem.getFSRoot(file);
+		try {
+			AriesSubsystem compositeA = getRootAriesSubsystem().install(COMPOSITE_A, directory);
+			uninstallSubsystemSilently(compositeA);
+		}
+		catch (Exception e) {
+			fail("Installation from IDirectory should have succeeded");
+		}
+	}
+	
+	@Test
+	public void testServiceRegistrations() {
+		Subsystem root1 = null;
+		try {
+			root1 = getRootSubsystem();
+		}
+		catch (Exception e) {
+			fail(Subsystem.class.getName() + " service not registered");
+		}
+		AriesSubsystem root2 = null;
+		try {
+			root2 = getRootAriesSubsystem();
+		}
+		catch (Exception e) {
+			fail(AriesSubsystem.class.getName() + " service not registered");
+		}
+		assertSame("Services should be the same instance", root1, root2);
+	}
+}

Modified: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/SubsystemTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/SubsystemTest.java?rev=1406875&r1=1406874&r2=1406875&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/SubsystemTest.java
(original)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/SubsystemTest.java
Thu Nov  8 00:33:51 2012
@@ -39,6 +39,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 
+import org.apache.aries.subsystem.AriesSubsystem;
 import org.apache.aries.subsystem.core.archive.ProvisionPolicyDirective;
 import org.apache.aries.subsystem.core.archive.SubsystemTypeHeader;
 import org.apache.aries.subsystem.core.internal.BundleResource;
@@ -199,6 +200,7 @@ public abstract class SubsystemTest exte
 				mavenBundle("org.eclipse.equinox",          "org.eclipse.equinox.event").version("1.2.200.v20120522-2049"),
 				mavenBundle("org.eclipse.equinox",          "org.eclipse.equinox.region").version("1.1.0.v20120522-1841"),
 				mavenBundle("org.osgi",                     "org.osgi.enterprise").version("5.0.0"),
+				mavenBundle("org.easymock",					"easymock").versionAsInProject(),
 //				org.ops4j.pax.exam.container.def.PaxRunnerOptions.vmOption("-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=7777"),
 				PaxRunnerOptions.rawPaxRunnerOption("config", "classpath:ss-runner.properties"),
 				equinox().version("3.8.0.V20120529-1548"));
@@ -601,6 +603,10 @@ public abstract class SubsystemTest exte
 		return bc.getBundle();
 	}
 	
+	protected AriesSubsystem getRootAriesSubsystem() {
+		return getOsgiService(AriesSubsystem.class);
+	}
+	
 	protected Subsystem getRootSubsystem() {
 		return getOsgiService(Subsystem.class);
 	}



Mime
View raw message