aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jwr...@apache.org
Subject svn commit: r1294912 - in /aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core: archive/ internal/
Date Wed, 29 Feb 2012 00:16:42 GMT
Author: jwross
Date: Wed Feb 29 00:16:41 2012
New Revision: 1294912

URL: http://svn.apache.org/viewvc?rev=1294912&view=rev
Log:
ARIES-825: Update subsystems to latest Subsystem, Resolver, and Repository APIs.

Initial support for Subsystem-ExportService header in composites.

Added:
    aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/SubsystemExportServiceCapability.java
Modified:
    aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/DeploymentManifest.java
    aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/Grammar.java
    aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/HeaderFactory.java
    aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/SubsystemExportServiceHeader.java
    aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/SubsystemImportServiceHeader.java
    aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/SubsystemImportServiceRequirement.java
    aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/SubsystemManifest.java
    aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/AriesSubsystem.java

Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/DeploymentManifest.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/DeploymentManifest.java?rev=1294912&r1=1294911&r2=1294912&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/DeploymentManifest.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/DeploymentManifest.java
Wed Feb 29 00:16:41 2012
@@ -39,6 +39,7 @@ public class DeploymentManifest {
 	public static final String PROVISION_RESOURCE = SubsystemConstants.PROVISION_RESOURCE;
 	public static final String REQUIRE_BUNDLE = Constants.REQUIRE_BUNDLE;
 	public static final String REQUIRE_CAPABILITY = Constants.REQUIRE_CAPABILITY;
+	public static final String SUBSYSTEM_EXPORTSERVICE = SubsystemConstants.SUBSYSTEM_EXPORTSERVICE;
 	public static final String SUBSYSTEM_IMPORTSERVICE = SubsystemConstants.SUBSYSTEM_IMPORTSERVICE;
 	public static final String SUBSYSTEM_SYMBOLICNAME = SubsystemConstants.SUBSYSTEM_SYMBOLICNAME;
 	public static final String SUBSYSTEM_VERSION = SubsystemConstants.SUBSYSTEM_VERSION;
@@ -137,6 +138,9 @@ public class DeploymentManifest {
 				header = subsystemManifest.getProvideCapabilityHeader();
 				if (header != null)
 					headers.put(PROVIDE_CAPABILITY, header);
+				header = subsystemManifest.getSubsystemExportServiceHeader();
+				if (header != null)
+					headers.put(SUBSYSTEM_EXPORTSERVICE, header);
 				// TODO Compute additional headers for a composite. 
 			}
 			// Features require no additional headers.
@@ -184,6 +188,10 @@ public class DeploymentManifest {
 		return (RequireCapabilityHeader)getHeaders().get(REQUIRE_CAPABILITY);
 	}
 	
+	public SubsystemExportServiceHeader getSubsystemExportServiceHeader() {
+		return (SubsystemExportServiceHeader)getHeaders().get(SUBSYSTEM_EXPORTSERVICE);
+	}
+	
 	public SubsystemImportServiceHeader getSubsystemImportServiceHeader() {
 		return (SubsystemImportServiceHeader)getHeaders().get(SUBSYSTEM_IMPORTSERVICE);
 	}

Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/Grammar.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/Grammar.java?rev=1294912&r1=1294911&r2=1294912&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/Grammar.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/Grammar.java
Wed Feb 29 00:16:41 2012
@@ -132,6 +132,11 @@ public interface Grammar {
 	public static final String CAPABILITY = NAMESPACE + "(?:;\\s*(?:(?:" + DIRECTIVE + ")|(?:"
+ TYPED_ATTR + ")))*";
 	public static final String PROVIDE_CAPABILITY = CAPABILITY + "(?:,\\s*(?:" + CAPABILITY
+ "))*";
 	
+	public static final String OBJECTCLASS = PACKAGENAME;
+	public static final String SERVICE = OBJECTCLASS + "(?:;\\s*(?:" + PARAMETER + "))*";
+	public static final String SUBSYSTEM_EXPORTSERVICE = SERVICE + "(?:,\\s*(?:" + SERVICE +
"))*";
+	public static final String SUBSYSTEM_IMPORTSERVICE = SERVICE + "(?:,\\s*(?:" + SERVICE +
"))*";
+	
 	/*
 	 * number ::= digit+
 	 * version ::= major( '.' minor ( '.' micro ( '.' qualifier )? )? )?

Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/HeaderFactory.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/HeaderFactory.java?rev=1294912&r1=1294911&r2=1294912&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/HeaderFactory.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/HeaderFactory.java
Wed Feb 29 00:16:41 2012
@@ -103,6 +103,8 @@ public class HeaderFactory {
 			return new RequireBundleHeader(value);
 		if (ProvideCapabilityHeader.NAME.equals(name))
 			return new ProvideCapabilityHeader(value);
+		if (SubsystemExportServiceHeader.NAME.equals(name))
+			return new SubsystemExportServiceHeader(value);
 		return new GenericHeader(name, value);
 			
 	}

Added: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/SubsystemExportServiceCapability.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/SubsystemExportServiceCapability.java?rev=1294912&view=auto
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/SubsystemExportServiceCapability.java
(added)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/SubsystemExportServiceCapability.java
Wed Feb 29 00:16:41 2012
@@ -0,0 +1,52 @@
+package org.apache.aries.subsystem.core.archive;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.aries.subsystem.core.resource.AbstractCapability;
+import org.osgi.framework.Constants;
+import org.osgi.resource.Namespace;
+import org.osgi.resource.Resource;
+
+public class SubsystemExportServiceCapability extends AbstractCapability {
+	public static final String DIRECTIVE_FILTER = Namespace.REQUIREMENT_FILTER_DIRECTIVE;
+	// TODO Replace value with ServiceNamspace.SERVICE_NAMESPACE constant when available.
+	public static final String NAMESPACE = "osgi.service";
+	
+	private final Map<String, Object> attributes = new HashMap<String, Object>();
+	private final Map<String, String> directives = new HashMap<String, String>();
+	private final Resource resource;
+	
+	public SubsystemExportServiceCapability(SubsystemExportServiceHeader.Clause clause, Resource
resource) {
+		StringBuilder builder = new StringBuilder("(&(")
+				.append(Constants.OBJECTCLASS).append('=')
+				.append(clause.getObjectClass()).append(')');
+		Directive filter = clause
+				.getDirective(SubsystemImportServiceHeader.Clause.DIRECTIVE_FILTER);
+		if (filter != null)
+			builder.append(filter.getValue());
+		directives.put(DIRECTIVE_FILTER, builder.append(')').toString());
+		this.resource = resource;
+	}
+
+	@Override
+	public Map<String, Object> getAttributes() {
+		return Collections.unmodifiableMap(attributes);
+	}
+
+	@Override
+	public Map<String, String> getDirectives() {
+		return Collections.unmodifiableMap(directives);
+	}
+
+	@Override
+	public String getNamespace() {
+		return NAMESPACE;
+	}
+
+	@Override
+	public Resource getResource() {
+		return resource;
+	}
+}

Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/SubsystemExportServiceHeader.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/SubsystemExportServiceHeader.java?rev=1294912&r1=1294911&r2=1294912&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/SubsystemExportServiceHeader.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/SubsystemExportServiceHeader.java
Wed Feb 29 00:16:41 2012
@@ -24,39 +24,27 @@ import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import org.osgi.framework.Constants;
-import org.osgi.resource.Resource;
 import org.osgi.service.subsystem.SubsystemConstants;
 
 public class SubsystemExportServiceHeader implements Header<SubsystemExportServiceHeader.Clause>
{
 	public static class Clause implements org.apache.aries.subsystem.core.archive.Clause {
-		public static final String ATTRIBUTE_VERSION = Constants.VERSION_ATTRIBUTE;
-		public static final String DIRECTIVE_EXCLUDE = Constants.EXCLUDE_DIRECTIVE;
-		public static final String DIRECTIVE_INCLUDE = Constants.INCLUDE_DIRECTIVE;
-		public static final String DIRECTIVE_MANDATORY = Constants.MANDATORY_DIRECTIVE;
-		public static final String DIRECTIVE_USES = Constants.USES_DIRECTIVE;
+		public static final String DIRECTIVE_FILTER = Constants.FILTER_DIRECTIVE;
 		
-		private static final Pattern PATTERN_PACKAGENAME = Pattern.compile('(' + Grammar.PACKAGENAME
+ ")(?=;|\\z)");
-		private static final Pattern PATTERN_PACKAGENAMES = Pattern.compile('(' + Grammar.PACKAGENAMES
+ ")(?=;|\\z)");
+		private static final Pattern PATTERN_OBJECTCLASS = Pattern.compile('(' + Grammar.OBJECTCLASS
+ ")(?=;|\\z)");
 		private static final Pattern PATTERN_PARAMETER = Pattern.compile('(' + Grammar.PARAMETER
+ ")(?=;|\\z)");
 		
 		private static void fillInDefaults(Map<String, Parameter> parameters) {
-			Parameter parameter = parameters.get(ATTRIBUTE_VERSION);
-			if (parameter == null)
-				parameters.put(ATTRIBUTE_VERSION, VersionAttribute.DEFAULT);
+			// No defaults.
 		}
 		
-		private final Collection<String> packageNames = new HashSet<String>();
 		private final String path;
 		private final Map<String, Parameter> parameters = new HashMap<String, Parameter>();
 		
 		public Clause(String clause) {
-			Matcher main = PATTERN_PACKAGENAMES.matcher(clause);
+			Matcher main = PATTERN_OBJECTCLASS.matcher(clause);
 			if (!main.find())
-				throw new IllegalArgumentException("Missing package names path: " + clause);
+				throw new IllegalArgumentException("Missing objectClass path: " + clause);
 			path = main.group();
-			Matcher path = PATTERN_PACKAGENAME.matcher(this.path);
-			while (path.find())
-				packageNames.add(main.group());
 			main.usePattern(PATTERN_PARAMETER);
 			while (main.find()) {
 				Parameter parameter = ParameterFactory.create(main.group());
@@ -107,8 +95,8 @@ public class SubsystemExportServiceHeade
 			return directives;
 		}
 		
-		public Collection<String> getPackageNames() {
-			return Collections.unmodifiableCollection(packageNames);
+		public String getObjectClass() {
+			return path;
 		}
 
 		@Override
@@ -126,13 +114,6 @@ public class SubsystemExportServiceHeade
 			return path;
 		}
 		
-		public Collection<ExportPackageCapability> toCapabilities(Resource resource) {
-			Collection<ExportPackageCapability> result = new ArrayList<ExportPackageCapability>(packageNames.size());
-			for (String packageName : packageNames)
-				result.add(new ExportPackageCapability(packageName, parameters.values(), resource));
-			return result;
-		}
-		
 		@Override
 		public String toString() {
 			StringBuilder builder = new StringBuilder()
@@ -146,8 +127,7 @@ public class SubsystemExportServiceHeade
 	
 	public static final String NAME = SubsystemConstants.SUBSYSTEM_EXPORTSERVICE;
 	
-	// TODO Subsystem-ExportService currently does not have its own grammar, but it's similar
to Provide-Capability.
-	private static final Pattern PATTERN = Pattern.compile('(' + Grammar.CAPABILITY + ")(?=,|\\z)");
+	private static final Pattern PATTERN = Pattern.compile('(' + Grammar.SERVICE + ")(?=,|\\z)");
 	
 	private final Set<Clause> clauses = new HashSet<Clause>();
 	
@@ -174,13 +154,6 @@ public class SubsystemExportServiceHeade
 		return toString();
 	}
 	
-	public Collection<ExportPackageCapability> toCapabilities(Resource resource) {
-		Collection<ExportPackageCapability> result = new ArrayList<ExportPackageCapability>();
-		for (Clause clause : clauses)
-			result.addAll(clause.toCapabilities(resource));
-		return result;
-	}
-	
 	@Override
 	public String toString() {
 		StringBuilder builder = new StringBuilder();

Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/SubsystemImportServiceHeader.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/SubsystemImportServiceHeader.java?rev=1294912&r1=1294911&r2=1294912&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/SubsystemImportServiceHeader.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/SubsystemImportServiceHeader.java
Wed Feb 29 00:16:41 2012
@@ -88,6 +88,10 @@ public class SubsystemImportServiceHeade
 			directives.trimToSize();
 			return directives;
 		}
+		
+		public String getObjectClass() {
+			return path;
+		}
 
 		@Override
 		public Parameter getParameter(String name) {
@@ -104,10 +108,6 @@ public class SubsystemImportServiceHeade
 			return path;
 		}
 		
-		public String getServiceName() {
-			return path;
-		}
-		
 		@Override
 		public String toString() {
 			StringBuilder builder = new StringBuilder()

Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/SubsystemImportServiceRequirement.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/SubsystemImportServiceRequirement.java?rev=1294912&r1=1294911&r2=1294912&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/SubsystemImportServiceRequirement.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/SubsystemImportServiceRequirement.java
Wed Feb 29 00:16:41 2012
@@ -25,7 +25,7 @@ public class SubsystemImportServiceRequi
 			SubsystemImportServiceHeader.Clause clause, Resource resource) {
 		StringBuilder builder = new StringBuilder("(&(")
 				.append(Constants.OBJECTCLASS).append('=')
-				.append(clause.getServiceName()).append(')');
+				.append(clause.getObjectClass()).append(')');
 		Directive filter = clause
 				.getDirective(SubsystemImportServiceHeader.Clause.DIRECTIVE_FILTER);
 		if (filter != null)

Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/SubsystemManifest.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/SubsystemManifest.java?rev=1294912&r1=1294911&r2=1294912&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/SubsystemManifest.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/SubsystemManifest.java
Wed Feb 29 00:16:41 2012
@@ -134,6 +134,10 @@ public class SubsystemManifest {
 		return (SubsystemContentHeader)getHeaders().get(SUBSYSTEM_CONTENT);
 	}
 	
+	public SubsystemExportServiceHeader getSubsystemExportServiceHeader() {
+		return (SubsystemExportServiceHeader)getHeaders().get(SUBSYSTEM_EXPORTSERVICE);
+	}
+	
 	public SubsystemImportServiceHeader getSubsystemImportServiceHeader() {
 		return (SubsystemImportServiceHeader)getHeaders().get(SUBSYSTEM_IMPORTSERVICE);
 	}

Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/AriesSubsystem.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/AriesSubsystem.java?rev=1294912&r1=1294911&r2=1294912&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/AriesSubsystem.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/AriesSubsystem.java
Wed Feb 29 00:16:41 2012
@@ -60,6 +60,8 @@ import org.apache.aries.subsystem.core.a
 import org.apache.aries.subsystem.core.archive.RequireCapabilityHeader;
 import org.apache.aries.subsystem.core.archive.RequireCapabilityRequirement;
 import org.apache.aries.subsystem.core.archive.SubsystemArchive;
+import org.apache.aries.subsystem.core.archive.SubsystemExportServiceCapability;
+import org.apache.aries.subsystem.core.archive.SubsystemExportServiceHeader;
 import org.apache.aries.subsystem.core.archive.SubsystemImportServiceHeader;
 import org.apache.aries.subsystem.core.archive.SubsystemImportServiceRequirement;
 import org.apache.aries.subsystem.core.archive.SubsystemManifest;
@@ -1052,6 +1054,7 @@ public class AriesSubsystem implements S
 		if (isComposite()) {
 			setExportIsolationPolicy(builder, getDeploymentManifest().getExportPackageHeader());
 			setExportIsolationPolicy(builder, getDeploymentManifest().getProvideCapabilityHeader());
+			setExportIsolationPolicy(builder, getDeploymentManifest().getSubsystemExportServiceHeader());
 			// TODO Implement export isolation policy for composites.
 		}
 		RegionFilter regionFilter = builder.build();
@@ -1091,6 +1094,19 @@ public class AriesSubsystem implements S
 			builder.allow(policy, filter.toString());
 		}
 	}
+	
+	private void setExportIsolationPolicy(RegionFilterBuilder builder, SubsystemExportServiceHeader
header) throws InvalidSyntaxException {
+		if (header == null)
+			return;
+		String policy = RegionFilter.VISIBLE_SERVICE_NAMESPACE;
+		for (SubsystemExportServiceHeader.Clause clause : header.getClauses()) {
+			SubsystemExportServiceCapability capability = new SubsystemExportServiceCapability(clause,
this);
+			String filter = capability.getDirectives().get(SubsystemExportServiceCapability.DIRECTIVE_FILTER);
+			if (LOGGER.isDebugEnabled())
+				LOGGER.debug("Allowing " + policy + " of " + filter);
+			builder.allow(policy, filter.toString());
+		}
+	}
 
 	private void setImportIsolationPolicy() throws BundleException, IOException, InvalidSyntaxException
{
 		if (isRoot())



Mime
View raw message