aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jwr...@apache.org
Subject svn commit: r1335243 [2/2] - in /aries/trunk/subsystem: subsystem-core/ subsystem-core/src/main/java/org/apache/aries/subsystem/core/ subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/ subsystem-core/src/main/java/org/apache/aries/su...
Date Mon, 07 May 2012 20:37:59 GMT
Added: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/RawSubsystemResource.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/RawSubsystemResource.java?rev=1335243&view=auto
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/RawSubsystemResource.java (added)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/RawSubsystemResource.java Mon May  7 20:37:56 2012
@@ -0,0 +1,319 @@
+package org.apache.aries.subsystem.core.internal;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.jar.Manifest;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.aries.subsystem.core.archive.DeploymentManifest;
+import org.apache.aries.subsystem.core.archive.Header;
+import org.apache.aries.subsystem.core.archive.ImportPackageHeader;
+import org.apache.aries.subsystem.core.archive.RequireBundleHeader;
+import org.apache.aries.subsystem.core.archive.RequireCapabilityHeader;
+import org.apache.aries.subsystem.core.archive.SubsystemContentHeader;
+import org.apache.aries.subsystem.core.archive.SubsystemManifest;
+import org.apache.aries.subsystem.core.archive.SubsystemSymbolicNameHeader;
+import org.apache.aries.subsystem.core.archive.SubsystemVersionHeader;
+import org.apache.aries.util.filesystem.FileSystem;
+import org.apache.aries.util.filesystem.IDirectory;
+import org.apache.aries.util.filesystem.IFile;
+import org.apache.aries.util.manifest.ManifestProcessor;
+import org.osgi.framework.Version;
+import org.osgi.framework.namespace.BundleNamespace;
+import org.osgi.framework.namespace.PackageNamespace;
+import org.osgi.resource.Capability;
+import org.osgi.resource.Requirement;
+import org.osgi.resource.Resource;
+import org.osgi.service.repository.Repository;
+import org.osgi.service.resolver.ResolutionException;
+import org.osgi.service.subsystem.SubsystemConstants;
+
+public class RawSubsystemResource implements Resource {
+	private static final Pattern PATTERN = Pattern.compile("([^@]+)(?:@(.+))?.esa");
+	
+	private static SubsystemManifest computeExistingSubsystemManifest(IDirectory directory) throws IOException {
+		Manifest manifest = ManifestProcessor.obtainManifestFromAppDir(directory, "OSGI-INF/SUBSYSTEM.MF");
+		if (manifest == null)
+			return null;
+		return new SubsystemManifest(manifest);
+	}
+	
+	private static SubsystemManifest computeNewSubsystemManifest() {
+		return new SubsystemManifest.Builder().build();
+	}
+	
+	private static SubsystemManifest computeSubsystemManifest(IDirectory directory) throws IOException {
+		SubsystemManifest result = computeExistingSubsystemManifest(directory);
+		if (result == null)
+			result = computeNewSubsystemManifest();
+		return result;
+	}
+	
+	private static String convertFileToLocation(IFile file) throws MalformedURLException {
+		String result = convertFileNameToLocation(file.getName());
+		if (result == null)
+			result = file.toURL().toString();
+		return result;
+	}
+	
+	private static String convertFileNameToLocation(String fileName) {
+		Matcher matcher = PATTERN.matcher(fileName);
+		if (!matcher.matches())
+			return null;
+		String version = matcher.group(2);
+		return new SubsystemUri(matcher.group(1), version == null ? null
+				: Version.parseVersion(version), null).toString();
+	}
+	
+	private final List<Capability> capabilities;
+	private final DeploymentManifest deploymentManifest;
+	private final IDirectory directory;
+	private final Repository localRepository;
+	private final Location location;
+	private final List<Requirement> requirements;
+	private final Collection<Resource> resources;
+	private final SubsystemManifest subsystemManifest;
+	
+	public RawSubsystemResource(String location, InputStream content) throws URISyntaxException, IOException, UnsupportedOperationException, ResolutionException {
+		this.location = new Location(location);
+		if (content == null)
+			content = this.location.open();
+		directory = FileSystem.getFSRoot(content);
+		resources = computeResources();
+		localRepository = computeLocalRepository();
+		SubsystemManifest manifest = computeSubsystemManifest(directory);
+		manifest = computeSubsystemManifestBeforeRequirements(manifest);
+		requirements = computeRequirements(manifest);
+		subsystemManifest = computeSubsystemManifestAfterRequirements(manifest);
+		capabilities = computeCapabilities();
+		deploymentManifest = computeDeploymentManifest();
+	}
+
+	@Override
+	public List<Capability> getCapabilities(String namespace) {
+		if (namespace == null)
+			return Collections.unmodifiableList(capabilities);
+		ArrayList<Capability> result = new ArrayList<Capability>(capabilities.size());
+		for (Capability capability : capabilities)
+			if (namespace.equals(capability.getNamespace()))
+				result.add(capability);
+		result.trimToSize();
+		return Collections.unmodifiableList(result);
+	}
+	
+	public DeploymentManifest getDeploymentManifest() {
+		return deploymentManifest;
+	}
+	
+	public Repository getLocalRepository() {
+		return localRepository;
+	}
+	
+	public Location getLocation() {
+		return location;
+	}
+
+	@Override
+	public List<Requirement> getRequirements(String namespace) {
+		if (namespace == null)
+			return Collections.unmodifiableList(requirements);
+		ArrayList<Requirement> result = new ArrayList<Requirement>(requirements.size());
+		for (Requirement requirement : requirements)
+			if (namespace.equals(requirement.getNamespace()))
+				result.add(requirement);
+		result.trimToSize();
+		return Collections.unmodifiableList(result);
+	}
+	
+	public Collection<Resource> getResources() {
+		return Collections.unmodifiableCollection(resources);
+	}
+	
+	public SubsystemManifest getSubsystemManifest() {
+		return subsystemManifest;
+	}
+	
+	private void addHeader(SubsystemManifest.Builder builder, Header<?> header) {
+		if (header == null)
+			return;
+		builder.header(header);
+	}
+	
+	private void addImportPackageHeader(SubsystemManifest.Builder builder) {
+		addHeader(builder, computeImportPackageHeader());
+	}
+	
+	private void addRequireBundleHeader(SubsystemManifest.Builder builder) {
+		addHeader(builder, computeRequireBundleHeader());
+	}
+	
+	private void addRequireCapabilityHeader(SubsystemManifest.Builder builder) {
+		addHeader(builder, computeRequireCapabilityHeader());
+	}
+	
+	private void addSubsystemContentHeader(SubsystemManifest.Builder builder, SubsystemManifest manifest) {
+		SubsystemContentHeader header = computeSubsystemContentHeader(manifest);
+		if (header == null)
+			return;
+		addHeader(builder, header);
+	}
+	
+	private void addSubsystemSymbolicNameHeader(SubsystemManifest.Builder builder, SubsystemManifest manifest) {
+		addHeader(builder, computeSubsystemSymbolicNameHeader(manifest));
+	}
+	
+	private void addSubsystemVersionHeader(SubsystemManifest.Builder builder, SubsystemManifest manifest) {
+		addHeader(builder, computeSubsystemVersionHeader(manifest));
+	}
+	
+	private List<Capability> computeCapabilities() {
+		return subsystemManifest.toCapabilities(this);
+	}
+	
+	private DeploymentManifest computeDeploymentManifest() throws IOException {
+		return computeExistingDeploymentManifest();
+	}
+	
+	private DeploymentManifest computeExistingDeploymentManifest() throws IOException {
+		Manifest manifest = ManifestProcessor.obtainManifestFromAppDir(directory, "OSGI-INF/DEPLOYMENT.MF");
+		if (manifest == null)
+			return null;
+		return new DeploymentManifest(manifest);
+	}
+	
+	private ImportPackageHeader computeImportPackageHeader() {
+		if (requirements.isEmpty())
+			return null;
+		ArrayList<ImportPackageHeader.Clause> clauses = new ArrayList<ImportPackageHeader.Clause>(requirements.size());
+		for (Requirement requirement : requirements) {
+			if (!PackageNamespace.PACKAGE_NAMESPACE.equals(requirement.getNamespace()))
+				continue;
+			clauses.add(new ImportPackageHeader.Clause(requirement));
+		}
+		if (clauses.isEmpty())
+			return null;
+		clauses.trimToSize();
+		return new ImportPackageHeader(clauses);
+	}
+	
+	private Repository computeLocalRepository() {
+		return new LocalRepository(resources);
+	}
+	
+	private RequireBundleHeader computeRequireBundleHeader() {
+		if (requirements.isEmpty())
+			return null;
+		ArrayList<RequireBundleHeader.Clause> clauses = new ArrayList<RequireBundleHeader.Clause>(requirements.size());
+		for (Requirement requirement : requirements) {
+			if (!BundleNamespace.BUNDLE_NAMESPACE.equals(requirement.getNamespace()))
+				continue;
+			clauses.add(new RequireBundleHeader.Clause(requirement));
+		}
+		if (clauses.isEmpty())
+			return null;
+		clauses.trimToSize();
+		return new RequireBundleHeader(clauses);
+	}
+	
+	private RequireCapabilityHeader computeRequireCapabilityHeader() {
+		if (requirements.isEmpty())
+			return null;
+		ArrayList<RequireCapabilityHeader.Clause> clauses = new ArrayList<RequireCapabilityHeader.Clause>();
+		for (Requirement requirement : requirements) {
+			if (requirement.getNamespace().startsWith("osgi."))
+				continue;
+			clauses.add(new RequireCapabilityHeader.Clause(requirement));
+		}
+		if (clauses.isEmpty())
+			return null;
+		clauses.trimToSize();
+		return new RequireCapabilityHeader(clauses);
+	}
+	
+	private List<Requirement> computeRequirements(SubsystemManifest manifest) throws ResolutionException {
+		if (isComposite(manifest))
+			return manifest.toRequirements(this);
+		SubsystemContentHeader header = manifest.getSubsystemContentHeader();
+		if (header == null)
+			return Collections.emptyList();
+		// TODO Need the system repository in here. Preferred provider as well?
+		LocalRepository localRepo = new LocalRepository(resources);
+		RepositoryServiceRepository serviceRepo = new RepositoryServiceRepository(Activator.getInstance().getBundleContext());
+		CompositeRepository compositeRepo = new CompositeRepository(localRepo, serviceRepo);
+		List<Requirement> requirements = header.toRequirements();
+		List<Resource> resources = new ArrayList<Resource>(requirements.size());
+		for (Requirement requirement : requirements) {
+			Collection<Capability> capabilities = compositeRepo.findProviders(requirement);
+			if (capabilities.isEmpty())
+				continue;
+			resources.add(capabilities.iterator().next().getResource());
+		}
+		return new DependencyCalculator(resources).calculateDependencies();
+	}
+	
+	private Collection<Resource> computeResources() throws IOException, URISyntaxException, UnsupportedOperationException, ResolutionException {
+		List<IFile> files = directory.listFiles();
+		if (files.isEmpty())
+			return Collections.emptyList();
+		ArrayList<Resource> result = new ArrayList<Resource>(files.size());
+		for (IFile file : directory.listFiles()) {
+			String name = file.getName();
+			if (name.endsWith(".jar"))
+				result.add(BundleResource.newInstance(file.toURL()));
+			else if (name.endsWith(".esa"))
+				result.add(new RawSubsystemResource(convertFileToLocation(file), file.open()));
+		}
+		result.trimToSize();
+		return result;
+	}
+	
+	private SubsystemContentHeader computeSubsystemContentHeader(SubsystemManifest manifest) {
+		SubsystemContentHeader header = manifest.getSubsystemContentHeader();
+		if (header == null && !resources.isEmpty())
+			header = new SubsystemContentHeader(resources);
+		return header;
+	}
+	
+	private SubsystemManifest computeSubsystemManifestAfterRequirements(SubsystemManifest manifest) {
+		if (isComposite(manifest))
+			return manifest;
+		SubsystemManifest.Builder builder = new SubsystemManifest.Builder().manifest(manifest);
+		addImportPackageHeader(builder);
+		addRequireBundleHeader(builder);
+		addRequireCapabilityHeader(builder);
+		return builder.build();
+	}
+	
+	private SubsystemManifest computeSubsystemManifestBeforeRequirements(SubsystemManifest manifest) {
+		SubsystemManifest.Builder builder = new SubsystemManifest.Builder().manifest(manifest);
+		addSubsystemSymbolicNameHeader(builder, manifest);
+		addSubsystemVersionHeader(builder, manifest);
+		addSubsystemContentHeader(builder, manifest);
+		return builder.build();
+	}
+	
+	private SubsystemSymbolicNameHeader computeSubsystemSymbolicNameHeader(SubsystemManifest manifest) {
+		SubsystemSymbolicNameHeader header = manifest.getSubsystemSymbolicNameHeader();
+		if (header == null)
+			header = new SubsystemSymbolicNameHeader(location.getSymbolicName());
+		return header;
+	}
+	
+	private SubsystemVersionHeader computeSubsystemVersionHeader(SubsystemManifest manifest) {
+		SubsystemVersionHeader header = manifest.getSubsystemVersionHeader();
+		if (header.getVersion().equals(Version.emptyVersion) && location.getVersion() != null)
+			header = new SubsystemVersionHeader(location.getVersion());
+		return header;
+	}
+	
+	private boolean isComposite(SubsystemManifest manifest) {
+		return SubsystemConstants.SUBSYSTEM_TYPE_COMPOSITE.equals(manifest.getSubsystemTypeHeader().getType());
+	}
+}

Added: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/Region.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/Region.java?rev=1335243&view=auto
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/Region.java (added)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/Region.java Mon May  7 20:37:56 2012
@@ -0,0 +1,41 @@
+package org.apache.aries.subsystem.core.internal;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+
+import org.osgi.resource.Capability;
+import org.osgi.resource.Requirement;
+import org.osgi.service.repository.Repository;
+
+public class Region implements Repository {
+	private final AriesSubsystem scopedSubsystem;
+	private final Collection<AriesSubsystem> subsystems = new HashSet<AriesSubsystem>();
+	
+	public Region(AriesSubsystem scopedSubsystem) {
+		if (!scopedSubsystem.isApplication() || !scopedSubsystem.isComposite())
+			throw new IllegalArgumentException("A region may only start with a scoped subsystem");
+		this.scopedSubsystem = scopedSubsystem;
+		subsystems.add(scopedSubsystem);
+	}
+
+	@Override
+	public Map<Requirement, Collection<Capability>> findProviders(
+			Collection<? extends Requirement> requirements) {
+		Map<Requirement, Collection<Capability>> result = new HashMap<Requirement, Collection<Capability>>();
+		for (Requirement requirement : requirements)
+			result.put(requirement, findProviders(requirement));
+		return result;
+	}
+	
+	public Collection<Capability> findProviders(Requirement requirement) {
+		Collection<Capability> result = new HashSet<Capability>();
+		findProviders(requirement, result);
+		return result;
+	}
+	
+	private void findProviders(Requirement requirement, Collection<Capability> capabilities) {
+		
+	}
+}

Copied: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/ResourceHelper.java (from r1330054, aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/ResourceHelper.java)
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/ResourceHelper.java?p2=aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/ResourceHelper.java&p1=aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/ResourceHelper.java&r1=1330054&r2=1335243&rev=1335243&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/ResourceHelper.java (original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/ResourceHelper.java Mon May  7 20:37:56 2012
@@ -11,7 +11,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.aries.subsystem.core;
+package org.apache.aries.subsystem.core.internal;
 
 import static org.apache.aries.application.utils.AppConstants.LOG_ENTRY;
 import static org.apache.aries.application.utils.AppConstants.LOG_EXIT;

Copied: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemResource.java (from r1330565, aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/resource/tmp/SubsystemResource.java)
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemResource.java?p2=aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemResource.java&p1=aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/resource/tmp/SubsystemResource.java&r1=1330565&r2=1335243&rev=1335243&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/resource/tmp/SubsystemResource.java (original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemResource.java Mon May  7 20:37:56 2012
@@ -1,356 +1,340 @@
-package org.apache.aries.subsystem.core.resource.tmp;
+package org.apache.aries.subsystem.core.internal;
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.net.MalformedURLException;
 import java.net.URISyntaxException;
-import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.HashSet;
 import java.util.List;
-import java.util.jar.Manifest;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
+import java.util.Map;
 
+import org.apache.aries.subsystem.core.archive.DeployedContentHeader;
 import org.apache.aries.subsystem.core.archive.DeploymentManifest;
-import org.apache.aries.subsystem.core.archive.Header;
-import org.apache.aries.subsystem.core.archive.ImportPackageHeader;
-import org.apache.aries.subsystem.core.archive.RequireBundleHeader;
-import org.apache.aries.subsystem.core.archive.RequireCapabilityHeader;
+import org.apache.aries.subsystem.core.archive.ProvisionResourceHeader;
 import org.apache.aries.subsystem.core.archive.SubsystemContentHeader;
 import org.apache.aries.subsystem.core.archive.SubsystemManifest;
-import org.apache.aries.subsystem.core.archive.SubsystemSymbolicNameHeader;
-import org.apache.aries.subsystem.core.archive.SubsystemTypeHeader;
-import org.apache.aries.subsystem.core.archive.SubsystemVersionHeader;
-import org.apache.aries.subsystem.core.internal.Activator;
-import org.apache.aries.subsystem.core.internal.RepositoryServiceRepository;
-import org.apache.aries.subsystem.core.internal.SubsystemUri;
-import org.apache.aries.subsystem.core.resource.BundleResource;
-import org.apache.aries.subsystem.core.resource.CompositeRepository;
-import org.apache.aries.subsystem.core.resource.DependencyCalculator;
-import org.apache.aries.subsystem.core.resource.LocalRepository;
-import org.apache.aries.util.filesystem.FileSystem;
-import org.apache.aries.util.filesystem.IDirectory;
-import org.apache.aries.util.filesystem.IFile;
-import org.apache.aries.util.manifest.ManifestProcessor;
-import org.osgi.framework.Version;
-import org.osgi.framework.namespace.BundleNamespace;
-import org.osgi.framework.namespace.PackageNamespace;
+import org.osgi.framework.wiring.BundleRevision;
 import org.osgi.resource.Capability;
 import org.osgi.resource.Requirement;
 import org.osgi.resource.Resource;
+import org.osgi.resource.Wire;
+import org.osgi.resource.Wiring;
+import org.osgi.service.repository.Repository;
+import org.osgi.service.resolver.HostedCapability;
 import org.osgi.service.resolver.ResolutionException;
+import org.osgi.service.resolver.ResolveContext;
+import org.osgi.service.subsystem.SubsystemConstants;
 import org.osgi.service.subsystem.SubsystemException;
 
-public abstract class SubsystemResource implements Resource {
-	protected static class Location {
-		private final String symbolicName;
-		private final URL url;
-		private final String value;
-		private final Version version;
-		
-		public Location(String location) throws MalformedURLException, URISyntaxException {
-			value = location;
-			SubsystemUri uri = null;
-			if (location.startsWith("subsystem://"))
-				uri = new SubsystemUri(location);
-			symbolicName = uri == null ? null : uri.getSymbolicName();
-			url = uri == null ? null : uri.getURL();
-			version = uri == null ? null : uri.getVersion();
-		}
-		
-		public String getSymbolicName() {
-			return symbolicName;
-		}
-		
-		public String getValue() {
-			return value;
-		}
-		
-		public Version getVersion() {
-			return version;
-		}
-		
-		public InputStream open() throws IOException {
-			return url == null ? new URL(value).openStream() : url.openStream();
-		}
+public class SubsystemResource implements Resource {
+	private final DeploymentManifest deploymentManifest;
+	private final Collection<Resource> installableContent = new HashSet<Resource>();
+	private final Collection<Resource> installableDependencies = new HashSet<Resource>();
+	private final Collection<Resource> mandatoryResources = new HashSet<Resource>();
+	private final Collection<Resource> optionalResources = new HashSet<Resource>();
+	private final AriesSubsystem parent;
+	private final Repository preferredProviderRepository;
+	private final RawSubsystemResource resource;
+	private final Collection<Resource> sharedContent = new HashSet<Resource>();
+	private final Collection<Resource> sharedDependencies = new HashSet<Resource>();
+	
+	public SubsystemResource(String location, InputStream content, AriesSubsystem parent) throws UnsupportedOperationException, URISyntaxException, IOException, ResolutionException {
+		this(new RawSubsystemResource(location, content), parent);
+	}
+	
+	public SubsystemResource(RawSubsystemResource resource, AriesSubsystem parent) throws IOException {
+		this.parent = parent;
+		this.resource = resource;
+		preferredProviderRepository = new PreferredProviderRepository(this);
+		deploymentManifest = computeDeploymentManifest();
 	}
-	
-	protected static final Pattern PATTERN = Pattern.compile("([^@]+)(?:@(.+))?.esa");
-	
-	public static SubsystemResource newInstance(String location, InputStream content) throws IOException, URISyntaxException, ResolutionException {
-		Location loc = new Location(location);
-		if (content == null)
-			content = loc.open();
-		IDirectory directory = FileSystem.getFSRoot(content);
-		SubsystemManifest manifest = computeSubsystemManifest(directory);
-		String type = manifest.getSubsystemTypeHeader().getType();
-		// TODO Make an enum out of the types?
-		if (SubsystemTypeHeader.TYPE_APPLICATION.equals(type))
-			return new ApplicationResource(loc, directory, manifest);
-		if (SubsystemTypeHeader.TYPE_COMPOSITE.equals(type))
-			return new CompositeResource(loc, directory, manifest);
-		if (SubsystemTypeHeader.TYPE_FEATURE.equals(type))
-			return new FeatureResource(loc, directory, manifest);
-		throw new SubsystemException("Unsupported subsystem type: " + type);
-	}
-	
-	protected static SubsystemManifest computeExistingSubsystemManifest(IDirectory directory) throws IOException {
-		Manifest manifest = ManifestProcessor.obtainManifestFromAppDir(directory, "OSGI-INF/SUBSYSTEM.MF");
-		if (manifest == null)
-			return null;
-		return new SubsystemManifest(manifest);
+
+	@Override
+	public List<Capability> getCapabilities(String namespace) {
+		return resource.getCapabilities(namespace);
 	}
 	
-	protected static SubsystemManifest computeNewSubsystemManifest() {
-		return new SubsystemManifest.Builder().build();
+	public DeploymentManifest getDeploymentManifest() {
+		return deploymentManifest;
 	}
 	
-	protected static SubsystemManifest computeSubsystemManifest(IDirectory directory) throws IOException {
-		SubsystemManifest result = computeExistingSubsystemManifest(directory);
-		if (result == null)
-			result = computeNewSubsystemManifest();
-		return result;
+	public Collection<Resource> getInstallableContent() {
+		return installableContent;
 	}
 	
-	protected static String convertFileToLocation(IFile file) throws MalformedURLException {
-		String result = convertFileNameToLocation(file.getName());
-		if (result == null)
-			result = file.toURL().toString();
-		return result;
+	public Collection<Resource> getInstallableDependencies() {
+		return installableDependencies;
 	}
 	
-	protected static String convertFileNameToLocation(String fileName) {
-		Matcher matcher = PATTERN.matcher(fileName);
-		if (!matcher.matches())
-			return null;
-		String version = matcher.group(2);
-		return new SubsystemUri(matcher.group(1), version == null ? null
-				: Version.parseVersion(version), null).toString();
-	}
-	
-	protected final List<Capability> capabilities;
-	protected final DeploymentManifest deploymentManifest;
-	protected final IDirectory directory;
-	protected final Location location;
-	protected final List<Requirement> requirements;
-	protected final Collection<Resource> resources;
-	protected final SubsystemManifest subsystemManifest;
-	
-	public SubsystemResource(Location location, IDirectory directory, SubsystemManifest manifest) throws IOException, URISyntaxException, ResolutionException {
-		this.location = location;
-		this.directory = directory;
-		resources = computeResources();
-		manifest = computeSubsystemManifestBeforeRequirements(manifest);
-		requirements = computeRequirements(manifest);
-		subsystemManifest = computeSubsystemManifestAfterRequirements(manifest);
-		capabilities = computeCapabilities();
-		deploymentManifest = computeDeploymentManifest();
-	}
-
-	@Override
-	public List<Capability> getCapabilities(String namespace) {
-		if (namespace == null)
-			return Collections.unmodifiableList(capabilities);
-		ArrayList<Capability> result = new ArrayList<Capability>(capabilities.size());
-		for (Capability capability : capabilities)
-			if (namespace.equals(capability.getNamespace()))
-				result.add(capability);
-		result.trimToSize();
-		return Collections.unmodifiableList(result);
+	public Repository getLocalRepository() {
+		return resource.getLocalRepository();
 	}
 	
-	public DeploymentManifest getDeploymentManifest() {
-		return deploymentManifest;
+	public String getLocation() {
+		return resource.getLocation().getValue();
 	}
 	
-	public String getLocation() {
-		return location.getValue();
+	public AriesSubsystem getParent() {
+		return parent;
 	}
 
 	@Override
 	public List<Requirement> getRequirements(String namespace) {
-		if (namespace == null)
-			return Collections.unmodifiableList(requirements);
-		ArrayList<Requirement> result = new ArrayList<Requirement>(requirements.size());
-		for (Requirement requirement : requirements)
-			if (namespace.equals(requirement.getNamespace()))
-				result.add(requirement);
-		result.trimToSize();
-		return Collections.unmodifiableList(result);
+		return resource.getRequirements(namespace);
 	}
 	
 	public Collection<Resource> getResources() {
-		return resources;
+		return resource.getResources();
 	}
 	
-	public SubsystemManifest getSubsystemManifest() {
-		return subsystemManifest;
+	public Collection<Resource> getSharedContent() {
+		return sharedContent;
 	}
 	
-	protected void addHeader(SubsystemManifest.Builder builder, Header<?> header) {
-		if (header == null)
-			return;
-		builder.header(header);
+	public Collection<Resource> getSharedDependencies() {
+		return sharedDependencies;
+	}
+	
+	public SubsystemManifest getSubsystemManifest() {
+		return resource.getSubsystemManifest();
 	}
 	
-	protected void addImportPackageHeader(SubsystemManifest.Builder builder) {
-		addHeader(builder, computeImportPackageHeader());
+	private void addContentResource(Resource resource) {
+		if (resource == null)
+			return;
+		if (isMandatory(resource))
+			mandatoryResources.add(resource);
+		else
+			optionalResources.add(resource);
+		if (isInstallable(resource))
+			installableContent.add(resource);
+		else
+			sharedContent.add(resource);
+	}
+	
+	private boolean addDependencies(Repository repository, Requirement requirement, List<Capability> capabilities) {
+		Map<Requirement, Collection<Capability>> m = repository.findProviders(Collections.singleton(requirement));
+		if (m.containsKey(requirement)) {
+			Collection<Capability> cc = m.get(requirement);
+			// TODO The following check only needs to be done on capabilities from the system repository.
+			addValidCapabilities(cc, capabilities);
+		}
+		return !capabilities.isEmpty();
 	}
 	
-	protected void addRequireBundleHeader(SubsystemManifest.Builder builder) {
-		addHeader(builder, computeRequireBundleHeader());
+	private boolean addDependenciesFromContentRepository(Requirement requirement, List<Capability> capabilities) {
+		Repository repository = new ContentRepository(installableContent, sharedContent);
+		return addDependencies(repository, requirement, capabilities);
 	}
 	
-	protected void addRequireCapabilityHeader(SubsystemManifest.Builder builder) {
-		addHeader(builder, computeRequireCapabilityHeader());
+	private boolean addDependenciesFromLocalRepository(Requirement requirement, List<Capability> capabilities) {
+		Repository repository = resource.getLocalRepository();
+		return addDependencies(repository, requirement, capabilities);
 	}
 	
-	protected void addSubsystemContentHeader(SubsystemManifest.Builder builder, SubsystemManifest manifest) {
-		SubsystemContentHeader header = computeSubsystemContentHeader(manifest);
-		if (header == null)
-			return;
-		addHeader(builder, header);
+	private boolean addDependenciesFromPreferredProviderRepository(Requirement requirement, List<Capability> capabilities) {
+		return addDependencies(preferredProviderRepository, requirement, capabilities);
 	}
 	
-	protected void addSubsystemSymbolicNameHeader(SubsystemManifest.Builder builder, SubsystemManifest manifest) {
-		addHeader(builder, computeSubsystemSymbolicNameHeader(manifest));
+	private boolean addDependenciesFromRepositoryServiceRepositories(Requirement requirement, List<Capability> capabilities) {
+		Repository repository = new RepositoryServiceRepository();
+		return addDependencies(repository, requirement, capabilities);
 	}
 	
-	protected void addSubsystemVersionHeader(SubsystemManifest.Builder builder, SubsystemManifest manifest) {
-		addHeader(builder, computeSubsystemVersionHeader(manifest));
+	private boolean addDependenciesFromSystemRepository(Requirement requirement, List<Capability> capabilities) {
+		Repository repository = Activator.getInstance().getSystemRepository();
+		return addDependencies(repository, requirement, capabilities);
 	}
 	
-	protected List<Capability> computeCapabilities() {
-		return subsystemManifest.toCapabilities(this);
+	private void addDependency(Resource resource) {
+		if (resource == null)
+			return;
+		if (isInstallable(resource))
+			installableDependencies.add(resource);
+		else
+			sharedDependencies.add(resource);
 	}
 	
-	protected DeploymentManifest computeExistingDeploymentManifest() throws IOException {
-		Manifest manifest = ManifestProcessor.obtainManifestFromAppDir(directory, "OSGI-INF/DEPLOYMENT.MF");
-		if (manifest == null)
-			return null;
-		return new DeploymentManifest(manifest);
+	private void addValidCapabilities(Collection<Capability> from, Collection<Capability> to) {
+		for (Capability c : from)
+			if (isValid(c))
+				to.add(c);
 	}
 	
-	protected DeploymentManifest computeDeploymentManifest() throws IOException {
-		return computeExistingDeploymentManifest();
+	private DeploymentManifest computeExistingDeploymentManifest() throws IOException {
+		return resource.getDeploymentManifest();
 	}
 	
-	protected ImportPackageHeader computeImportPackageHeader() {
-		if (requirements.isEmpty())
+	private DeployedContentHeader computeDeployedContentHeader() {
+		Collection<Resource> resources = new HashSet<Resource>();
+		SubsystemContentHeader contentHeader = resource.getSubsystemManifest().getSubsystemContentHeader();
+		if (contentHeader == null)
 			return null;
-		ArrayList<ImportPackageHeader.Clause> clauses = new ArrayList<ImportPackageHeader.Clause>(requirements.size());
-		for (Requirement requirement : requirements) {
-			if (!PackageNamespace.PACKAGE_NAMESPACE.equals(requirement.getNamespace()))
+		for (SubsystemContentHeader.Content content : contentHeader.getContents()) {
+			OsgiIdentityRequirement requirement = new OsgiIdentityRequirement(
+					content.getName(), content.getVersionRange(),
+					content.getType(), false);
+			Resource resource = findContent(requirement);
+			if (resource == null) {
+				if (content.isMandatory())
+					throw new SubsystemException("Resource does not exist: "+ requirement);
 				continue;
-			clauses.add(new ImportPackageHeader.Clause(requirement));
+			}
+			resources.add(resource);
+			addContentResource(resource);
 		}
-		if (clauses.isEmpty())
-			return null;
-		clauses.trimToSize();
-		return new ImportPackageHeader(clauses);
+		return DeployedContentHeader.newInstance(resources);
 	}
 	
-	protected RequireBundleHeader computeRequireBundleHeader() {
-		if (requirements.isEmpty())
-			return null;
-		ArrayList<RequireBundleHeader.Clause> clauses = new ArrayList<RequireBundleHeader.Clause>(requirements.size());
-		for (Requirement requirement : requirements) {
-			if (!BundleNamespace.BUNDLE_NAMESPACE.equals(requirement.getNamespace()))
-				continue;
-			clauses.add(new RequireBundleHeader.Clause(requirement));
-		}
-		if (clauses.isEmpty())
-			return null;
-		clauses.trimToSize();
-		return new RequireBundleHeader(clauses);
+	private DeploymentManifest computeDeploymentManifest() throws IOException {
+		DeploymentManifest result = computeExistingDeploymentManifest();
+		if (result != null)
+			return result;
+		result = new DeploymentManifest.Builder().manifest(resource.getSubsystemManifest())
+				.header(computeDeployedContentHeader())
+				.header(computeProvisionResourceHeader()).build();
+		return result;
 	}
 	
-	protected RequireCapabilityHeader computeRequireCapabilityHeader() {
-		if (requirements.isEmpty())
-			return null;
-		ArrayList<RequireCapabilityHeader.Clause> clauses = new ArrayList<RequireCapabilityHeader.Clause>();
-		for (Requirement requirement : requirements) {
-			if (requirement.getNamespace().startsWith("osgi."))
-				continue;
-			clauses.add(new RequireCapabilityHeader.Clause(requirement));
+	private ProvisionResourceHeader computeProvisionResourceHeader() {
+		SubsystemContentHeader contentHeader = resource.getSubsystemManifest().getSubsystemContentHeader();
+		// TODO This does not validate that all content bundles were found.
+		Map<Resource, List<Wire>> resolution;
+		try {
+			resolution = Activator.getInstance().getResolver().resolve(createResolveContext());
+		}
+		catch (ResolutionException e) {
+			throw new SubsystemException(e);
+		}
+		Collection<Resource> provisionResource = new HashSet<Resource>();
+		for (Resource resource : resolution.keySet()) {
+			if (!contentHeader.contains(resource)) {
+				provisionResource.add(resource);
+				addDependency(resource);
+			}
 		}
-		if (clauses.isEmpty())
+		if (provisionResource.isEmpty())
 			return null;
-		clauses.trimToSize();
-		return new RequireCapabilityHeader(clauses);
+		return ProvisionResourceHeader.newInstance(provisionResource);
 	}
 	
-	protected List<Requirement> computeRequirements(SubsystemManifest manifest) throws ResolutionException {
-		SubsystemContentHeader header = manifest.getSubsystemContentHeader();
-		if (header == null)
-			return Collections.emptyList();
-		// TODO Need the system repository in here. Preferred provider as well?
-		LocalRepository localRepo = new LocalRepository(resources);
-		RepositoryServiceRepository serviceRepo = new RepositoryServiceRepository(Activator.getInstance().getBundleContext());
-		CompositeRepository compositeRepo = new CompositeRepository(localRepo, serviceRepo);
-		List<Requirement> requirements = header.toRequirements();
-		List<Resource> resources = new ArrayList<Resource>(requirements.size());
-		for (Requirement requirement : requirements) {
-			Collection<Capability> capabilities = compositeRepo.findProviders(requirement);
-			if (capabilities.isEmpty())
-				continue;
-			resources.add(capabilities.iterator().next().getResource());
+	private ResolveContext createResolveContext() {
+		return new ResolveContext() {
+			@Override
+			public List<Capability> findProviders(Requirement requirement) {
+				List<Capability> result = new ArrayList<Capability>();
+				if (addDependenciesFromContentRepository(requirement, result))
+					return result;
+				if (addDependenciesFromPreferredProviderRepository(requirement, result))
+					return result;
+				if (addDependenciesFromSystemRepository(requirement, result))
+					return result;
+				if (addDependenciesFromLocalRepository(requirement, result))
+					return result;
+				if (addDependenciesFromRepositoryServiceRepositories(requirement, result))
+					return result;
+				return result;
+			}
+			
+			@Override
+			public Collection<Resource> getMandatoryResources() {
+				return SubsystemResource.this.mandatoryResources;
+			}
+			
+			@Override
+			public Collection<Resource> getOptionalResources() {
+				return SubsystemResource.this.optionalResources;
+			}
+
+			@Override
+			public int insertHostedCapability(List<Capability> capabilities,
+					HostedCapability hostedCapability) {
+				capabilities.add(hostedCapability);
+				return capabilities.size() - 1;
+			}
+
+			@Override
+			public boolean isEffective(Requirement requirement) {
+				return true;
+			}
+
+			@Override
+			public Map<Resource, Wiring> getWirings() {
+				return Collections.emptyMap();
+			}
+		};
+	}
+	
+	private Resource findContent(OsgiIdentityRequirement requirement) {
+		Map<Requirement, Collection<Capability>> map;
+		if (isUnscoped()) {
+			map = Activator.getInstance().getSystemRepository().findProviders(Collections.singleton(requirement));
+			if (map.containsKey(requirement)) {
+				Collection<Capability> capabilities = map.get(requirement);
+				for (Capability capability : capabilities) {
+					Collection<AriesSubsystem> subsystems = AriesSubsystem.getSubsystems(capability.getResource());
+					if (!subsystems.isEmpty())
+						if (subsystems.iterator().next().getRegion().equals(parent.getRegion()))
+							return capability.getResource();
+				}
+			}
+		}
+		map = resource.getLocalRepository().findProviders(Collections.singleton(requirement));
+		if (map.containsKey(requirement)) {
+			Collection<Capability> capabilities = map.get(requirement);
+			if (!capabilities.isEmpty())
+				return capabilities.iterator().next().getResource();
 		}
-		return new DependencyCalculator(resources).calculateDependencies();
+		Collection<Capability> capabilities = new RepositoryServiceRepository().findProviders(requirement);
+		if (!capabilities.isEmpty())
+			return capabilities.iterator().next().getResource();
+		return null;
 	}
 	
-	protected Collection<Resource> computeResources() throws IOException, URISyntaxException, UnsupportedOperationException, ResolutionException {
-		List<IFile> files = directory.listFiles();
-		if (files.isEmpty())
-			return Collections.emptyList();
-		ArrayList<Resource> result = new ArrayList<Resource>(files.size());
-		for (IFile file : directory.listFiles()) {
-			String name = file.getName();
-			if (name.endsWith(".jar"))
-				result.add(BundleResource.newInstance(file.toURL()));
-			else if (name.endsWith(".esa"))
-				result.add(SubsystemResource.newInstance(convertFileToLocation(file), file.open()));
-		}
-		result.trimToSize();
-		return result;
+	private AriesSubsystem findFirstSubsystemAcceptingDependencies() {
+		AriesSubsystem subsystem = parent;
+		while (!isAcceptDependencies(subsystem))
+			subsystem = (AriesSubsystem)subsystem.getParents().iterator().next();
+		return subsystem;
 	}
 	
-	protected SubsystemContentHeader computeSubsystemContentHeader(SubsystemManifest manifest) {
-		Header<?> header = manifest.getSubsystemContentHeader();
-		if (header == null && !resources.isEmpty())
-			header = new SubsystemContentHeader(resources);
-		return (SubsystemContentHeader)header;
-	}
-	
-	protected SubsystemManifest computeSubsystemManifestAfterRequirements(SubsystemManifest manifest) {
-		SubsystemManifest.Builder builder = new SubsystemManifest.Builder().manifest(manifest);
-		addImportPackageHeader(builder);
-		addRequireBundleHeader(builder);
-		addRequireCapabilityHeader(builder);
-		return builder.build();
-	}
-	
-	protected SubsystemManifest computeSubsystemManifestBeforeRequirements(SubsystemManifest manifest) {
-		SubsystemManifest.Builder builder = new SubsystemManifest.Builder().manifest(manifest);
-		addSubsystemSymbolicNameHeader(builder, manifest);
-		addSubsystemVersionHeader(builder, manifest);
-		addSubsystemContentHeader(builder, manifest);
-		return builder.build();
+	private boolean isAcceptDependencies(AriesSubsystem subsystem) {
+		return subsystem.getArchive().getSubsystemManifest().getSubsystemTypeHeader().getProvisionPolicyDirective().isAcceptDependencies();
 	}
 	
-	protected SubsystemSymbolicNameHeader computeSubsystemSymbolicNameHeader(SubsystemManifest manifest) {
-		SubsystemSymbolicNameHeader header = manifest.getSubsystemSymbolicNameHeader();
+	private boolean isInstallable(Resource resource) {
+		return !isShared(resource);
+	}
+	
+	private boolean isMandatory(Resource resource) {
+		SubsystemContentHeader header = this.resource.getSubsystemManifest().getSubsystemContentHeader();
 		if (header == null)
-			header = new SubsystemSymbolicNameHeader(location.getSymbolicName());
-		return header;
+			return false;
+		return header.isMandatory(resource);
+	}
+	
+	private boolean isShared(Resource resource) {
+		return resource instanceof AriesSubsystem || resource instanceof BundleRevision;
+	}
+	
+	private boolean isScoped() {
+		String type = resource.getSubsystemManifest().getSubsystemTypeHeader().getType();
+		return SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION.equals(type) ||
+				SubsystemConstants.SUBSYSTEM_TYPE_COMPOSITE.equals(type);
+	}
+	
+	private boolean isUnscoped() {
+		return !isScoped();
 	}
 	
-	protected SubsystemVersionHeader computeSubsystemVersionHeader(SubsystemManifest manifest) {
-		SubsystemVersionHeader header = manifest.getSubsystemVersionHeader();
-		if (header.getVersion().equals(Version.emptyVersion) && location.getVersion() != null)
-			header = new SubsystemVersionHeader(location.getVersion());
-		return header;
+	private boolean isValid(Capability capability) {
+		AriesSubsystem subsystem;
+		if (isInstallable(capability.getResource()))
+			subsystem = findFirstSubsystemAcceptingDependencies();
+		else
+			subsystem = AriesSubsystem.getSubsystems(capability.getResource()).iterator().next();
+		return new SharingPolicyValidator(subsystem.getRegion(), parent.getRegion()).isValid(capability);
 	}
 }

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=1335243&r1=1335242&r2=1335243&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 Mon May  7 20:37:56 2012
@@ -5,18 +5,16 @@ import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
 
-import org.apache.aries.subsystem.core.ResourceHelper;
 import org.osgi.resource.Capability;
 import org.osgi.resource.Requirement;
 import org.osgi.resource.Resource;
 import org.osgi.service.repository.Repository;
-import org.osgi.service.subsystem.Subsystem;
 
 public class SystemRepository implements Repository {
-	private final AriesSubsystem subsystem;
+	private final AriesSubsystem root;
 	
-	public SystemRepository(AriesSubsystem subsystem) {
-		this.subsystem = subsystem;
+	public SystemRepository(AriesSubsystem root) {
+		this.root = root;
 	}
 
 	@Override
@@ -30,54 +28,17 @@ public class SystemRepository implements
 	
 	public Collection<Capability> findProviders(Requirement requirement) {
 		Collection<Capability> result = new HashSet<Capability>();
-		findProviders(requirement, result);
+		findProviders(requirement, result, root);
 		return result;
 	}
 	
-	private void findProviders(Requirement requirement, Collection<Capability> capabilities) {
-		AriesSubsystem subsystem = this.subsystem;
-		if (requirement instanceof OsgiIdentityRequirement) {
-			// We only want to return providers from the same region as the subsystem.
-			// Find the one and only one scoped subsystem in the region, which
-			// will be either the current subsystem or one of its parents.
-			do {
-				subsystem = (AriesSubsystem)subsystem.getParents().iterator().next();
-			} while (!(subsystem.isApplication() || subsystem.isComposite()));
-			// Now search the one and only one scoped parent within the same region
-			// and all children that are also in the same region for a provider.
-			findProviders(subsystem, requirement, capabilities);
-			return;
-		}
-		while (!subsystem.getParents().isEmpty())
-			subsystem = (AriesSubsystem)subsystem.getParents().iterator().next();
-		findProviders(subsystem, requirement, capabilities);
-	}
-	
-	private void findProviders(AriesSubsystem subsystem, Requirement requirement, Collection<Capability> capabilities) {
-		// Because constituent providers are already provisioned resources, the
-		// sharing policy check must be between the requiring subsystem and the
-		// offering subsystem, not the subsystem the resource would be
-		// provisioned to as in the other methods.
-		SharingPolicyValidator validator = new SharingPolicyValidator(subsystem.getRegion(), this.subsystem.getRegion());
-		for (Resource resource : subsystem.getConstituents()) {
-			for (Capability capability : resource.getCapabilities(requirement.getNamespace())) {
-				// Filter out capabilities offered by dependencies that will be
-				// or already are provisioned to an out of scope region. This
-				// filtering does not apply to osgi.identity requirements within
-				// the same region.
-				if (!(requirement instanceof OsgiIdentityRequirement) && !validator.isValid(capability))
-					continue;
+	private void findProviders(Requirement requirement, Collection<Capability> capabilities, AriesSubsystem subsystem) {
+		for (Resource constituent : subsystem.getConstituents()) {
+			if (constituent instanceof AriesSubsystem)
+				findProviders(requirement, capabilities, (AriesSubsystem)constituent);
+			for (Capability capability : constituent.getCapabilities(requirement.getNamespace()))
 				if (ResourceHelper.matches(requirement, capability))
 					capabilities.add(capability);
-			}
-		}
-		for (Subsystem child : subsystem.getChildren()) {
-			// If the requirement is osgi.identity and the child is not in the
-			// same region as the parent, we do not want to search it.
-			if (requirement instanceof OsgiIdentityRequirement
-					&& !subsystem.getRegion().equals(((AriesSubsystem)child).getRegion()))
-				continue;
-			findProviders((AriesSubsystem)child, requirement, capabilities);
 		}
 	}
 }

Modified: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/ApplicationTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/ApplicationTest.java?rev=1335243&r1=1335242&r2=1335243&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/ApplicationTest.java (original)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/ApplicationTest.java Mon May  7 20:37:56 2012
@@ -219,7 +219,7 @@ public class ApplicationTest extends Sub
 	    	}
     	}
     	finally {
-    		b.uninstall();
+    		uninstallSilently(b);
     	}
     }
     
@@ -238,7 +238,7 @@ public class ApplicationTest extends Sub
 	    	}
     	}
     	finally {
-    		b.uninstall();
+    		uninstallSilently(b);
     	}
     }
     

Modified: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/FeatureTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/FeatureTest.java?rev=1335243&r1=1335242&r2=1335243&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/FeatureTest.java (original)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/FeatureTest.java Mon May  7 20:37:56 2012
@@ -25,7 +25,7 @@ import java.util.Collection;
 
 import junit.framework.AssertionFailedError;
 
-import org.apache.aries.subsystem.core.ResourceHelper;
+import org.apache.aries.subsystem.core.internal.ResourceHelper;
 import org.apache.aries.subsystem.itests.util.Utils;
 import org.apache.aries.unittest.fixture.ArchiveFixture;
 import org.apache.aries.unittest.fixture.ArchiveFixture.ZipFixture;

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=1335243&r1=1335242&r2=1335243&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 Mon May  7 20:37:56 2012
@@ -39,11 +39,11 @@ import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 
-import org.apache.aries.subsystem.core.ResourceHelper;
 import org.apache.aries.subsystem.core.archive.ProvisionPolicyDirective;
 import org.apache.aries.subsystem.core.archive.SubsystemTypeHeader;
+import org.apache.aries.subsystem.core.internal.BundleResource;
+import org.apache.aries.subsystem.core.internal.ResourceHelper;
 import org.apache.aries.subsystem.core.internal.SubsystemIdentifier;
-import org.apache.aries.subsystem.core.resource.BundleResource;
 import org.apache.aries.subsystem.itests.obr.felix.RepositoryAdminRepository;
 import org.apache.aries.subsystem.itests.util.RepositoryGenerator;
 import org.apache.aries.subsystem.itests.util.TestRepository;
@@ -53,7 +53,6 @@ import org.apache.aries.unittest.fixture
 import org.apache.aries.unittest.fixture.ArchiveFixture.ManifestFixture;
 import org.apache.aries.unittest.fixture.ArchiveFixture.ZipFixture;
 import org.apache.felix.bundlerepository.RepositoryAdmin;
-import org.apache.felix.resolver.ResolverImpl;
 import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.container.def.PaxRunnerOptions;
 import org.osgi.framework.Bundle;
@@ -69,7 +68,6 @@ import org.osgi.framework.namespace.Iden
 import org.osgi.resource.Resource;
 import org.osgi.service.repository.Repository;
 import org.osgi.service.repository.RepositoryContent;
-import org.osgi.service.resolver.Resolver;
 import org.osgi.service.subsystem.Subsystem;
 import org.osgi.service.subsystem.Subsystem.State;
 import org.osgi.service.subsystem.SubsystemConstants;
@@ -701,6 +699,15 @@ public abstract class SubsystemTest exte
 		}
 	}
 	
+	protected void uninstallSilently(Bundle bundle) {
+		if (bundle == null)
+			return;
+		try {
+			bundle.uninstall();
+		}
+		catch (Exception e) {}
+	}
+	
 	protected void uninstallSubsystem(Subsystem subsystem) throws Exception {
 		assertState(EnumSet.of(State.INSTALLED, State.RESOLVED), subsystem);
 		subsystemEvents.clear();

Modified: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/obr/felix/FelixCapabilityAdapter.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/obr/felix/FelixCapabilityAdapter.java?rev=1335243&r1=1335242&r2=1335243&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/obr/felix/FelixCapabilityAdapter.java (original)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/obr/felix/FelixCapabilityAdapter.java Mon May  7 20:37:56 2012
@@ -16,7 +16,7 @@ package org.apache.aries.subsystem.itest
 import java.util.Collections;
 import java.util.Map;
 
-import org.apache.aries.subsystem.core.resource.AbstractCapability;
+import org.apache.aries.subsystem.core.internal.AbstractCapability;
 import org.osgi.framework.wiring.BundleRevision;
 import org.osgi.resource.Resource;
 

Modified: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/obr/felix/FelixRepositoryAdapter.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/obr/felix/FelixRepositoryAdapter.java?rev=1335243&r1=1335242&r2=1335243&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/obr/felix/FelixRepositoryAdapter.java (original)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/obr/felix/FelixRepositoryAdapter.java Mon May  7 20:37:56 2012
@@ -26,8 +26,8 @@ import java.util.Map;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import org.apache.aries.subsystem.core.ResourceHelper;
 import org.apache.aries.subsystem.core.internal.OsgiIdentityCapability;
+import org.apache.aries.subsystem.core.internal.ResourceHelper;
 import org.osgi.framework.Constants;
 import org.osgi.framework.namespace.IdentityNamespace;
 import org.osgi.resource.Capability;

Modified: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/obr/felix/FelixResourceAdapter.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/obr/felix/FelixResourceAdapter.java?rev=1335243&r1=1335242&r2=1335243&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/obr/felix/FelixResourceAdapter.java (original)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/obr/felix/FelixResourceAdapter.java Mon May  7 20:37:56 2012
@@ -18,9 +18,9 @@ import java.net.URL;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.apache.aries.subsystem.core.ResourceHelper;
 import org.apache.aries.subsystem.core.internal.OsgiContentCapability;
 import org.apache.aries.subsystem.core.internal.OsgiIdentityCapability;
+import org.apache.aries.subsystem.core.internal.ResourceHelper;
 import org.osgi.framework.namespace.IdentityNamespace;
 import org.osgi.framework.wiring.BundleRevision;
 import org.osgi.resource.Capability;

Modified: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/obr/felix/OsgiRequirementAdapter.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/obr/felix/OsgiRequirementAdapter.java?rev=1335243&r1=1335242&r2=1335243&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/obr/felix/OsgiRequirementAdapter.java (original)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/obr/felix/OsgiRequirementAdapter.java Mon May  7 20:37:56 2012
@@ -16,7 +16,7 @@ package org.apache.aries.subsystem.itest
 import static org.apache.aries.application.utils.AppConstants.LOG_ENTRY;
 import static org.apache.aries.application.utils.AppConstants.LOG_EXIT;
 
-import org.apache.aries.subsystem.core.ResourceHelper;
+import org.apache.aries.subsystem.core.internal.ResourceHelper;
 import org.apache.felix.bundlerepository.Capability;
 import org.apache.felix.bundlerepository.Requirement;
 import org.osgi.framework.Constants;

Modified: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/obr/felix/OsgiResourceAdapter.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/obr/felix/OsgiResourceAdapter.java?rev=1335243&r1=1335242&r2=1335243&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/obr/felix/OsgiResourceAdapter.java (original)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/obr/felix/OsgiResourceAdapter.java Mon May  7 20:37:56 2012
@@ -18,7 +18,7 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.Map;
 
-import org.apache.aries.subsystem.core.ResourceHelper;
+import org.apache.aries.subsystem.core.internal.ResourceHelper;
 import org.apache.felix.bundlerepository.Capability;
 import org.apache.felix.bundlerepository.Requirement;
 import org.apache.felix.bundlerepository.Resource;

Modified: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/util/RepositoryDescriptorGenerator.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/util/RepositoryDescriptorGenerator.java?rev=1335243&r1=1335242&r2=1335243&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/util/RepositoryDescriptorGenerator.java (original)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/util/RepositoryDescriptorGenerator.java Mon May  7 20:37:56 2012
@@ -27,7 +27,7 @@ import javax.xml.parsers.ParserConfigura
 
 import org.apache.aries.application.Content;
 import org.apache.aries.application.management.BundleInfo;
-import org.apache.aries.subsystem.core.ResourceHelper;
+import org.apache.aries.subsystem.core.internal.ResourceHelper;
 import org.apache.aries.util.manifest.ManifestHeaderProcessor;
 import org.apache.felix.bundlerepository.Resource;
 import org.osgi.framework.Constants;

Modified: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/util/RepositoryGenerator.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/util/RepositoryGenerator.java?rev=1335243&r1=1335242&r2=1335243&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/util/RepositoryGenerator.java (original)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/util/RepositoryGenerator.java Mon May  7 20:37:56 2012
@@ -30,7 +30,7 @@ import javax.xml.transform.stream.Stream
 
 import org.apache.aries.application.Content;
 import org.apache.aries.application.management.BundleInfo;
-import org.apache.aries.subsystem.core.ResourceHelper;
+import org.apache.aries.subsystem.core.internal.ResourceHelper;
 import org.apache.aries.subsystem.itests.obr.felix.FelixResourceAdapter;
 import org.apache.aries.subsystem.itests.obr.felix.OsgiResourceAdapter;
 import org.apache.felix.bundlerepository.Capability;

Modified: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/util/TestRepository.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/util/TestRepository.java?rev=1335243&r1=1335242&r2=1335243&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/util/TestRepository.java (original)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/util/TestRepository.java Mon May  7 20:37:56 2012
@@ -6,7 +6,7 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.aries.subsystem.core.ResourceHelper;
+import org.apache.aries.subsystem.core.internal.ResourceHelper;
 import org.osgi.resource.Capability;
 import org.osgi.resource.Requirement;
 import org.osgi.resource.Resource;



Mime
View raw message