aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r1587513 - in /aries/trunk/subsystem: subsystem-bundle/ subsystem-core/ subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/ subsystem-core/src/test/java/org/apache/aries/subsystem/core/archive/
Date Tue, 15 Apr 2014 11:04:40 GMT
Author: gnodet
Date: Tue Apr 15 11:04:40 2014
New Revision: 1587513

URL: http://svn.apache.org/r1587513
Log:
[ARIES-1172] Make subsystems independent of application modeller

Added:
    aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/ApplicationServiceModeller.java
    aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/ServiceModeller.java
Modified:
    aries/trunk/subsystem/subsystem-bundle/pom.xml
    aries/trunk/subsystem/subsystem-core/pom.xml
    aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/Activator.java
    aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/BundleResource.java
    aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/BundleRevisionResource.java
    aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/InstallAction.java
    aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/RawSubsystemResource.java
    aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemResource.java
    aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemUri.java
    aries/trunk/subsystem/subsystem-core/src/test/java/org/apache/aries/subsystem/core/archive/BundleRequiredExecutionEnvironmentHeaderTest.java

Modified: aries/trunk/subsystem/subsystem-bundle/pom.xml
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-bundle/pom.xml?rev=1587513&r1=1587512&r2=1587513&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-bundle/pom.xml (original)
+++ aries/trunk/subsystem/subsystem-bundle/pom.xml Tue Apr 15 11:04:40 2014
@@ -45,6 +45,7 @@
     	<aries.osgi.import>
     		org.osgi.service.repository;version="[1.0,2)",
     		org.osgi.service.subsystem;version="[1.0,2)",
+            org.apache.aries.application.*;resolution:=optional,
     		*
     	</aries.osgi.import>
         <aries.osgi.export.pkg>
@@ -66,7 +67,7 @@
         <dependency>
             <groupId>org.apache.aries.subsystem</groupId>
             <artifactId>org.apache.aries.subsystem.core</artifactId>
-            <version>1.0.0</version>
+            <version>1.0.1-SNAPSHOT</version>
         </dependency>
         <dependency>
             <groupId>org.apache.aries</groupId>

Modified: aries/trunk/subsystem/subsystem-core/pom.xml
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/pom.xml?rev=1587513&r1=1587512&r2=1587513&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/pom.xml (original)
+++ aries/trunk/subsystem/subsystem-core/pom.xml Tue Apr 15 11:04:40 2014
@@ -46,6 +46,7 @@
     		org.osgi.service.repository;version="[1.0,2)",
     		org.osgi.service.subsystem;version="[1.0,2)",
     		org.apache.aries.subsystem;version="[1.0,2)",
+            org.apache.aries.application.*;resolution:=optional,
     		*
     	</aries.osgi.import>
         <aries.osgi.export.pkg />

Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/Activator.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/Activator.java?rev=1587513&r1=1587512&r2=1587513&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/Activator.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/Activator.java
Tue Apr 15 11:04:40 2014
@@ -13,16 +13,12 @@
  */
 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;
-
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Dictionary;
 import java.util.HashSet;
 import java.util.Hashtable;
 
-import org.apache.aries.application.modelling.ModelledResourceManager;
 import org.apache.aries.util.filesystem.IDirectoryFinder;
 import org.eclipse.equinox.region.RegionDigraph;
 import org.osgi.framework.BundleActivator;
@@ -47,9 +43,13 @@ import org.slf4j.LoggerFactory;
  * activator will create and register the SubsystemAdmin service.
  */
 public class Activator implements BundleActivator, ServiceTrackerCustomizer<Object, Object>
{
-	private static final Logger logger = LoggerFactory.getLogger(Activator.class);
-	
-	private static Activator instance;
+    private static final Logger logger = LoggerFactory.getLogger(Activator.class);
+    public static final String MODELLED_RESOURCE_MANAGER = "org.apache.aries.application.modelling.ModelledResourceManager";
+
+    public static final String LOG_ENTRY = "Method entry: {}, args {}";
+    public static final String LOG_EXIT = "Method exit: {}, returning {}";
+
+    private static Activator instance;
 	
 	public static synchronized Activator getInstance() {
 		logger.debug(LOG_ENTRY, "getInstance");
@@ -69,7 +69,8 @@ public class Activator implements Bundle
 	private BundleEventHook bundleEventHook;
 	private volatile BundleContext bundleContext;
 	private volatile Coordinator coordinator;
-	private volatile ModelledResourceManager modelledResourceManager;
+    private volatile Object modelledResourceManager;
+    private volatile ServiceModeller serviceModeller;
 	private volatile SubsystemServiceRegistrar registrar;
 	private volatile RegionDigraph regionDigraph;
 	private volatile Resolver resolver;
@@ -89,11 +90,11 @@ public class Activator implements Bundle
 		return coordinator;
 	}
 	
-	public ModelledResourceManager getModelledResourceManager() {
-		return modelledResourceManager;
-	}
-	
-	public RegionDigraph getRegionDigraph() {
+    public ServiceModeller getServiceModeller() {
+        return serviceModeller;
+    }
+
+    public RegionDigraph getRegionDigraph() {
 		return regionDigraph;
 	}
 	
@@ -176,13 +177,13 @@ public class Activator implements Bundle
 		}
 	}
 	
-	private Object findAlternateServiceFor(Object service) {
+	private <T> T findAlternateServiceFor(Class<T> service) {
 		Object[] services = serviceTracker.getServices();
 		if (services == null)
 			return null;
 		for (Object alternate : services)
-			if (alternate.getClass().equals(service.getClass()))
-					return alternate;
+			if (service.isInstance(alternate))
+					return service.cast(alternate);
 		return null;
 	}
 	
@@ -201,7 +202,7 @@ public class Activator implements Bundle
 				.append(org.osgi.framework.Constants.OBJECTCLASS).append('=')
 				.append(Repository.class.getName()).append(")(")
 				.append(org.osgi.framework.Constants.OBJECTCLASS).append('=')
-				.append(ModelledResourceManager.class.getName()).append(")(")
+				.append(MODELLED_RESOURCE_MANAGER).append(")(")
 				.append(org.osgi.framework.Constants.OBJECTCLASS).append('=')
 				.append(IDirectoryFinder.class.getName()).append("))").toString();
 	}
@@ -242,8 +243,19 @@ public class Activator implements Bundle
 			regionDigraph = (RegionDigraph) service;
 		else if (service instanceof Resolver && resolver == null)
 			resolver = (Resolver) service;
-		else if (service instanceof ModelledResourceManager && modelledResourceManager
== null)
-			modelledResourceManager = (ModelledResourceManager) service;
+		else {
+            try {
+                Class clazz = getClass().getClassLoader().loadClass(MODELLED_RESOURCE_MANAGER);
+                if (clazz.isInstance(service) && serviceModeller == null) {
+                    modelledResourceManager = service;
+                    serviceModeller = new ApplicationServiceModeller(service);
+                }
+            } catch (ClassNotFoundException e) {
+                // ignore
+            } catch (NoClassDefFoundError e) {
+                // ignore
+            }
+        }
 		// Activation is harmless if already active or all required services
 		// have not yet been found.
 		activate();
@@ -260,7 +272,7 @@ public class Activator implements Bundle
 	public synchronized void removedService(ServiceReference<Object> reference, Object
service) {
 		if (service instanceof Coordinator) {
 			if (service.equals(coordinator)) {
-				Coordinator coordinator = (Coordinator)findAlternateServiceFor(this.coordinator);
+				Coordinator coordinator = findAlternateServiceFor(Coordinator.class);
 				if (coordinator == null)
 					deactivate();
 				this.coordinator = coordinator;
@@ -268,7 +280,7 @@ public class Activator implements Bundle
 		}
 		else if (service instanceof RegionDigraph) {
 			if (service.equals(regionDigraph)) {
-				RegionDigraph regionDigraph = (RegionDigraph)findAlternateServiceFor(this.regionDigraph);
+				RegionDigraph regionDigraph = findAlternateServiceFor(RegionDigraph.class);
 				if (regionDigraph == null)
 					deactivate();
 				this.regionDigraph = regionDigraph;
@@ -276,24 +288,35 @@ public class Activator implements Bundle
 		}
 		else if (service instanceof Resolver) {
 			if (service.equals(resolver)) {
-				Resolver resolver = (Resolver)findAlternateServiceFor(this.resolver);
+				Resolver resolver = findAlternateServiceFor(Resolver.class);
 				if (resolver == null)
 					deactivate();
 				this.resolver = resolver;
 			}
 		}
-		else if (service instanceof ModelledResourceManager) {
-			if (service.equals(modelledResourceManager)) {
-				ModelledResourceManager modelledResourceManager = (ModelledResourceManager)findAlternateServiceFor(this.modelledResourceManager);
-				if (modelledResourceManager == null)
-					deactivate();
-				this.modelledResourceManager = modelledResourceManager;
-			}
-		}
 		else if (service instanceof IDirectoryFinder)
 			finders.remove(service);
-		else
+		else if (service instanceof Repository)
 			repositories.remove(service);
+        else {
+            if (service.equals(modelledResourceManager)) {
+                try {
+                    Class clazz = getClass().getClassLoader().loadClass(MODELLED_RESOURCE_MANAGER);
+                    Object manager = findAlternateServiceFor(clazz);
+                    if (manager == null) {
+                        modelledResourceManager = null;
+                        serviceModeller = null;
+                    } else {
+                        modelledResourceManager = service;
+                        serviceModeller = new ApplicationServiceModeller(service);
+                    }
+                } catch (ClassNotFoundException e) {
+                    // ignore
+                } catch (NoClassDefFoundError e) {
+                    // ignore
+                }
+            }
+        }
 	}
 	
 	/* End ServiceTrackerCustomizer methods */

Added: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/ApplicationServiceModeller.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/ApplicationServiceModeller.java?rev=1587513&view=auto
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/ApplicationServiceModeller.java
(added)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/ApplicationServiceModeller.java
Tue Apr 15 11:04:40 2014
@@ -0,0 +1,95 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.aries.subsystem.core.internal;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.aries.application.modelling.ExportedService;
+import org.apache.aries.application.modelling.ImportedService;
+import org.apache.aries.application.modelling.ModelledResourceManager;
+import org.apache.aries.application.modelling.ModellerException;
+import org.apache.aries.application.modelling.ParsedServiceElements;
+import org.apache.aries.util.filesystem.IDirectory;
+import org.osgi.namespace.service.ServiceNamespace;
+import org.osgi.resource.Capability;
+import org.osgi.resource.Namespace;
+import org.osgi.resource.Requirement;
+import org.osgi.resource.Resource;
+import org.osgi.service.subsystem.SubsystemException;
+
+public class ApplicationServiceModeller implements ServiceModeller {
+
+    private final ModelledResourceManager manager;
+
+    public ApplicationServiceModeller(Object manager) {
+        this.manager = (ModelledResourceManager) manager;
+    }
+
+    @Override
+    public ServiceModel computeRequirementsAndCapabilities(Resource resource, IDirectory
directory) throws SubsystemException {
+        try {
+            ServiceModelImpl model = new ServiceModelImpl();
+            ParsedServiceElements elements = manager.getServiceElements(directory);
+            for (ExportedService service : elements.getServices()) {
+                model.capabilities.add(new BasicCapability.Builder()
+                        .namespace(ServiceNamespace.SERVICE_NAMESPACE)
+                        .attribute(ServiceNamespace.CAPABILITY_OBJECTCLASS_ATTRIBUTE, new
ArrayList<String>(service.getInterfaces()))
+                        .attributes(service.getServiceProperties())
+                        .resource(resource)
+                        .build());
+            }
+            for (ImportedService service : elements.getReferences()) {
+                StringBuilder builder = new StringBuilder("(&(")
+                        .append(ServiceNamespace.CAPABILITY_OBJECTCLASS_ATTRIBUTE)
+                        .append('=')
+                        .append(service.getInterface())
+                        .append(')');
+                String filter = service.getFilter();
+                if (filter != null)
+                    builder.append(filter);
+                builder.append(')');
+                model.requirements.add(new BasicRequirement.Builder()
+                        .namespace(ServiceNamespace.SERVICE_NAMESPACE)
+                        .directive(Namespace.REQUIREMENT_FILTER_DIRECTIVE, builder.toString())
+                        .directive(
+                                Namespace.REQUIREMENT_RESOLUTION_DIRECTIVE,
+                                service.isOptional() ? Namespace.RESOLUTION_OPTIONAL : Namespace.RESOLUTION_MANDATORY)
+                        .directive(
+                                Namespace.REQUIREMENT_CARDINALITY_DIRECTIVE,
+                                service.isMultiple() ? Namespace.CARDINALITY_MULTIPLE : Namespace.CARDINALITY_SINGLE)
+                        .resource(resource)
+                        .build());
+            }
+            return model;
+        } catch (ModellerException e) {
+            throw new SubsystemException(e);
+        }
+    }
+
+    static class ServiceModelImpl implements ServiceModel {
+        final List<Requirement> requirements = new ArrayList<Requirement>();
+        final List<Capability> capabilities = new ArrayList<Capability>();
+        @Override
+        public List<Requirement> getServiceRequirements() {
+            return requirements;
+        }
+
+        @Override
+        public List<Capability> getServiceCapabilities() {
+            return capabilities;
+        }
+    }
+
+}

Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/BundleResource.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/BundleResource.java?rev=1587513&r1=1587512&r2=1587513&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/BundleResource.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/BundleResource.java
Tue Apr 15 11:04:40 2014
@@ -19,17 +19,11 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.net.MalformedURLException;
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 import java.util.jar.JarEntry;
 import java.util.jar.JarOutputStream;
 
-import org.apache.aries.application.modelling.ExportedService;
-import org.apache.aries.application.modelling.ImportedService;
-import org.apache.aries.application.modelling.ModelledResourceManager;
-import org.apache.aries.application.modelling.ModellerException;
-import org.apache.aries.application.modelling.ParsedServiceElements;
 import org.apache.aries.subsystem.core.archive.BundleManifest;
 import org.apache.aries.subsystem.core.archive.BundleRequiredExecutionEnvironmentHeader;
 import org.apache.aries.subsystem.core.archive.BundleSymbolicNameHeader;
@@ -67,7 +61,7 @@ public class BundleResource implements R
 	private final BundleManifest manifest;
 	private final List<Requirement> requirements = new ArrayList<Requirement>();
 	
-	public BundleResource(IFile content) throws ModellerException {
+	public BundleResource(IFile content) {
 		this.content = content;
 		IDirectory dir = content.isDirectory() ? content.convert() : content.convertNested();
 		manifest = computeManifest(dir);
@@ -164,41 +158,6 @@ public class BundleResource implements R
 		capabilities.add(new OsgiIdentityCapability(this, manifest));
 	}
 	
-	private void computeOsgiServiceCapabilities(Collection<ExportedService> services)
{
-		for (ExportedService service : services)
-			capabilities.add(new BasicCapability.Builder()
-					.namespace(ServiceNamespace.SERVICE_NAMESPACE)
-					.attribute(ServiceNamespace.CAPABILITY_OBJECTCLASS_ATTRIBUTE, new ArrayList<String>(service.getInterfaces()))
-					.attributes(service.getServiceProperties())
-					.resource(this)
-					.build());
-	}
-	
-	private void computeOsgiServiceRequirements(Collection<ImportedService> services)
{
-		for (ImportedService service : services) {
-			StringBuilder builder = new StringBuilder("(&(")
-					.append(ServiceNamespace.CAPABILITY_OBJECTCLASS_ATTRIBUTE)
-					.append('=')
-					.append(service.getInterface())
-					.append(')');
-			String filter = service.getFilter();
-			if (filter != null)
-				builder.append(filter);
-			builder.append(')');
-			requirements.add(new BasicRequirement.Builder()
-					.namespace(ServiceNamespace.SERVICE_NAMESPACE)
-					.directive(Namespace.REQUIREMENT_FILTER_DIRECTIVE, builder.toString())
-					.directive(
-							Namespace.REQUIREMENT_RESOLUTION_DIRECTIVE, 
-							service.isOptional() ? Namespace.RESOLUTION_OPTIONAL : Namespace.RESOLUTION_MANDATORY)
-					.directive(
-							Namespace.REQUIREMENT_CARDINALITY_DIRECTIVE, 
-							service.isMultiple() ? Namespace.CARDINALITY_MULTIPLE : Namespace.CARDINALITY_SINGLE)
-					.resource(this)
-					.build());
-		}
-	}
-	
 	private void computeOsgiWiringBundleCapability() {
 		// TODO The osgi.wiring.bundle capability should not be provided for fragments. Nor should
the host capability.
 		BundleSymbolicNameHeader bsnh = (BundleSymbolicNameHeader)manifest.getHeader(BundleSymbolicNameHeader.NAME);
@@ -225,19 +184,19 @@ public class BundleResource implements R
 			requirements.addAll(iph.toRequirements(this));
 	}
 	
-	private void computeRequirementsAndCapabilities(IDirectory directory) throws ModellerException
{
+	private void computeRequirementsAndCapabilities(IDirectory directory) {
 		// Compute all requirements and capabilities other than those related
 		// to services.
 		computeRequirementsOtherThanService();
 		computeCapabilitiesOtherThanService();
 		// Compute service requirements and capabilities if the optional
 		// ModelledResourceManager service is present.
-		ModelledResourceManager manager = getModelledResourceManager();
-		if (manager == null)
+		ServiceModeller modeller = getServiceModeller();
+		if (modeller == null)
 			return;
-		ParsedServiceElements elements = manager.getServiceElements(directory);
-		computeOsgiServiceRequirements(elements.getReferences());
-		computeOsgiServiceCapabilities(elements.getServices());
+        ServiceModeller.ServiceModel model = modeller.computeRequirementsAndCapabilities(this,
directory);
+        capabilities.addAll(model.getServiceCapabilities());
+        requirements.addAll(model.getServiceRequirements());
 	}
 	
 	private void computeRequirementsOtherThanService() {
@@ -266,8 +225,8 @@ public class BundleResource implements R
 		return name.substring(index + 1);
 	}
 
-	private ModelledResourceManager getModelledResourceManager() {
-		return Activator.getInstance().getModelledResourceManager();
+	private ServiceModeller getServiceModeller() {
+		return Activator.getInstance().getServiceModeller();
 	}
 
 	private void jar(JarOutputStream out, String prefix, IDirectory directory) throws IOException
{

Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/BundleRevisionResource.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/BundleRevisionResource.java?rev=1587513&r1=1587512&r2=1587513&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/BundleRevisionResource.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/BundleRevisionResource.java
Tue Apr 15 11:04:40 2014
@@ -14,28 +14,18 @@
 package org.apache.aries.subsystem.core.internal;
 
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 
-import org.apache.aries.application.modelling.ExportedService;
-import org.apache.aries.application.modelling.ImportedService;
-import org.apache.aries.application.modelling.ModelledResourceManager;
-import org.apache.aries.application.modelling.ModellerException;
-import org.apache.aries.application.modelling.ParsedServiceElements;
 import org.osgi.framework.wiring.BundleRevision;
 import org.osgi.namespace.service.ServiceNamespace;
 import org.osgi.resource.Capability;
-import org.osgi.resource.Namespace;
 import org.osgi.resource.Requirement;
 import org.osgi.resource.Resource;
-import org.osgi.service.subsystem.SubsystemException;
 
 public class BundleRevisionResource implements Resource {
 	private final BundleRevision revision;
 	
-	private volatile ParsedServiceElements elements;
-	
 	public BundleRevisionResource(BundleRevision revision) {
 		if (revision == null)
 			throw new NullPointerException();
@@ -72,77 +62,24 @@ public class BundleRevisionResource impl
 		return revision.getRequirements(namespace);
 	}
 	
-	private ParsedServiceElements computeParsedServiceElements() {
-		Activator activator = Activator.getInstance();
-		ModelledResourceManager manager = activator.getModelledResourceManager();
-		if (manager == null)
-			return null;
-		BundleDirectory directory = new BundleDirectory(revision.getBundle());
-		try {
-			return manager.getServiceElements(directory);
-		}
-		catch (ModellerException e) {
-			throw new SubsystemException(e);
-		}
-	}
-	
 	private List<Capability> computeServiceCapabilities() {
-		ParsedServiceElements elements = getParsedServiceElements();
-		if (elements == null)
-			return Collections.emptyList();
-		Collection<? extends ExportedService> services = elements.getServices();
-		if (services.isEmpty())
-			return Collections.emptyList();
-		List<Capability> result = new ArrayList<Capability>(services.size());
-		for (ExportedService service : services)
-			result.add(new BasicCapability.Builder()
-					.namespace(ServiceNamespace.SERVICE_NAMESPACE)
-					.attribute(ServiceNamespace.CAPABILITY_OBJECTCLASS_ATTRIBUTE, new ArrayList<String>(service.getInterfaces()))
-					.attributes(service.getServiceProperties())
-					.resource(this)
-					.build());
-		return result;
+        Activator activator = Activator.getInstance();
+        ServiceModeller modeller = activator.getServiceModeller();
+        if (modeller == null)
+            return null;
+        ServiceModeller.ServiceModel model =
+                modeller.computeRequirementsAndCapabilities(this, new BundleDirectory(revision.getBundle()));
+        return model.getServiceCapabilities();
 	}
 	
 	private List<Requirement> computeServiceRequirements() {
-		ParsedServiceElements elements = getParsedServiceElements();
-		if (elements == null)
-			return Collections.emptyList();
-		Collection<? extends ImportedService> services = elements.getReferences();
-		if (services.isEmpty())
-			return Collections.emptyList();
-		List<Requirement> result = new ArrayList<Requirement>(services.size());
-		for (ImportedService service : services) {
-			StringBuilder builder = new StringBuilder("(&(")
-					.append(ServiceNamespace.CAPABILITY_OBJECTCLASS_ATTRIBUTE)
-					.append('=')
-					.append(service.getInterface())
-					.append(')');
-			String filter = service.getFilter();
-			if (filter != null)
-				builder.append('(').append(filter).append(')');
-			builder.append(')');
-			result.add(new BasicRequirement.Builder()
-					.namespace(ServiceNamespace.SERVICE_NAMESPACE)
-					.directive(Namespace.REQUIREMENT_FILTER_DIRECTIVE, builder.toString())
-					.directive(
-							Namespace.REQUIREMENT_RESOLUTION_DIRECTIVE, 
-							service.isOptional() ? Namespace.RESOLUTION_OPTIONAL : Namespace.RESOLUTION_MANDATORY)
-					.resource(this)
-					.build());
-		}
-		return result;
+        Activator activator = Activator.getInstance();
+        ServiceModeller modeller = activator.getServiceModeller();
+        if (modeller == null)
+            return null;
+        ServiceModeller.ServiceModel model =
+                modeller.computeRequirementsAndCapabilities(this, new BundleDirectory(revision.getBundle()));
+        return model.getServiceRequirements();
 	}
 
-	private ParsedServiceElements getParsedServiceElements() {
-		ParsedServiceElements result = elements;
-		if (result == null) {
-			synchronized (this) {
-				result = elements;
-				if (result == null)
-					elements = result = computeParsedServiceElements();
-			}
-		}
-		return result;
-	}
 }

Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/InstallAction.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/InstallAction.java?rev=1587513&r1=1587512&r2=1587513&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/InstallAction.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/InstallAction.java
Tue Apr 15 11:04:40 2014
@@ -19,7 +19,6 @@ import java.security.AccessControlContex
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 
-import org.apache.aries.application.modelling.ModellerException;
 import org.apache.aries.util.filesystem.IDirectory;
 import org.osgi.framework.BundleException;
 import org.osgi.framework.InvalidSyntaxException;
@@ -110,7 +109,7 @@ public class InstallAction implements Pr
 		
 	}
 	
-	private SubsystemResource createSubsystemResource(String location, IDirectory content, BasicSubsystem
parent) throws URISyntaxException, IOException, ResolutionException, BundleException, InvalidSyntaxException,
ModellerException {
+	private SubsystemResource createSubsystemResource(String location, IDirectory content, BasicSubsystem
parent) throws URISyntaxException, IOException, ResolutionException, BundleException, InvalidSyntaxException
{
 		final SubsystemResource result = new SubsystemResource(location, content, parent);
 		return result;
 	}

Modified: 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=1587513&r1=1587512&r2=1587513&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/RawSubsystemResource.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/RawSubsystemResource.java
Tue Apr 15 11:04:40 2014
@@ -29,7 +29,6 @@ import java.util.jar.Manifest;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import org.apache.aries.application.modelling.ModellerException;
 import org.apache.aries.subsystem.core.archive.DeploymentManifest;
 import org.apache.aries.subsystem.core.archive.Header;
 import org.apache.aries.subsystem.core.archive.ImportPackageHeader;
@@ -113,7 +112,7 @@ public class RawSubsystemResource implem
 	private final Resource fakeImportServiceResource;
 	private final SubsystemManifest subsystemManifest;
 	
-	public RawSubsystemResource(String location, IDirectory content) throws URISyntaxException,
IOException, ResolutionException, ModellerException {
+	public RawSubsystemResource(String location, IDirectory content) throws URISyntaxException,
IOException, ResolutionException {
 		id = SubsystemIdentifier.getNextId();
 		this.location = new Location(location);
 		if (content == null)
@@ -389,7 +388,7 @@ public class RawSubsystemResource implem
 		return new DependencyCalculator(resources).calculateDependencies();
 	}
 	
-	private Collection<Resource> computeResources(IDirectory directory) throws IOException,
URISyntaxException, ResolutionException, ModellerException {
+	private Collection<Resource> computeResources(IDirectory directory) throws IOException,
URISyntaxException, ResolutionException {
 		List<IFile> files = directory.listFiles();
 		if (files.isEmpty())
 			return Collections.emptyList();

Added: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/ServiceModeller.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/ServiceModeller.java?rev=1587513&view=auto
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/ServiceModeller.java
(added)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/ServiceModeller.java
Tue Apr 15 11:04:40 2014
@@ -0,0 +1,33 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.aries.subsystem.core.internal;
+
+import java.util.List;
+
+import org.apache.aries.util.filesystem.IDirectory;
+import org.osgi.resource.Capability;
+import org.osgi.resource.Requirement;
+import org.osgi.resource.Resource;
+import org.osgi.service.subsystem.SubsystemException;
+
+public interface ServiceModeller {
+
+    public static interface ServiceModel {
+        List<Requirement> getServiceRequirements();
+        List<Capability> getServiceCapabilities();
+    }
+
+    ServiceModel computeRequirementsAndCapabilities(Resource resource, IDirectory directory)
throws SubsystemException;
+
+}

Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemResource.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemResource.java?rev=1587513&r1=1587512&r2=1587513&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemResource.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemResource.java
Tue Apr 15 11:04:40 2014
@@ -24,7 +24,6 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.aries.application.modelling.ModellerException;
 import org.apache.aries.subsystem.core.archive.Attribute;
 import org.apache.aries.subsystem.core.archive.DeployedContentHeader;
 import org.apache.aries.subsystem.core.archive.DeploymentManifest;
@@ -88,7 +87,7 @@ public class SubsystemResource implement
 	private final Collection<Resource> sharedContent = new HashSet<Resource>();
 	private final Collection<Resource> sharedDependencies = new HashSet<Resource>();
 	
-	public SubsystemResource(String location, IDirectory content, BasicSubsystem parent) throws
URISyntaxException, IOException, ResolutionException, BundleException, InvalidSyntaxException,
ModellerException {
+	public SubsystemResource(String location, IDirectory content, BasicSubsystem parent) throws
URISyntaxException, IOException, ResolutionException, BundleException, InvalidSyntaxException
{
 		this(new RawSubsystemResource(location, content), parent);
 	}
 	

Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemUri.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemUri.java?rev=1587513&r1=1587512&r2=1587513&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemUri.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/SubsystemUri.java
Tue Apr 15 11:04:40 2014
@@ -80,7 +80,8 @@ public class SubsystemUri {
 	public Version getVersion() {
 		return version;
 	}
-	
+
+    @SuppressWarnings("deprecation")
 	public String toString() {
 		StringBuilder builder = new StringBuilder("subsystem://");
 		if (url != null) {

Modified: aries/trunk/subsystem/subsystem-core/src/test/java/org/apache/aries/subsystem/core/archive/BundleRequiredExecutionEnvironmentHeaderTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/test/java/org/apache/aries/subsystem/core/archive/BundleRequiredExecutionEnvironmentHeaderTest.java?rev=1587513&r1=1587512&r2=1587513&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/test/java/org/apache/aries/subsystem/core/archive/BundleRequiredExecutionEnvironmentHeaderTest.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/test/java/org/apache/aries/subsystem/core/archive/BundleRequiredExecutionEnvironmentHeaderTest.java
Tue Apr 15 11:04:40 2014
@@ -73,6 +73,7 @@ public class BundleRequiredExecutionEnvi
 	}
 	
 	@Test
+    @SuppressWarnings("deprecation")
 	public void testHeaderWithMultipleClauses() {
 		String value = "CDC-1.0/Foundation-1.0,OSGi/Minimum-1.2,J2SE-1.4,JavaSE-1.6,AA/BB-1.7,V1-1.5/V2-1.6,MyEE-badVersion";
 		String filter = "(|" +



Mime
View raw message