aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mnutt...@apache.org
Subject svn commit: r1599198 - /aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/ApplicationServiceModeller.java
Date Mon, 02 Jun 2014 12:55:02 GMT
Author: mnuttall
Date: Mon Jun  2 12:55:01 2014
New Revision: 1599198

URL: http://svn.apache.org/r1599198
Log:
Aries-1196: Service dependency model may create filters with null objectClass. From a patch
by Tom Watson. 

Modified:
    aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/ApplicationServiceModeller.java

Modified: 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=1599198&r1=1599197&r2=1599198&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/ApplicationServiceModeller.java
(original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/internal/ApplicationServiceModeller.java
Mon Jun  2 12:55:01 2014
@@ -51,26 +51,39 @@ public class ApplicationServiceModeller 
                         .build());
             }
             for (ImportedService service : elements.getReferences()) {
-                StringBuilder builder = new StringBuilder("(&(")
+                StringBuilder builder = new StringBuilder();
+                String serviceInterface = service.getInterface();
+                String filter = service.getFilter();
+
+                if (serviceInterface != null && filter != null) {
+                	builder.append("(&");
+                }
+                if (serviceInterface != null) {
+                	builder.append('(')
                         .append(ServiceNamespace.CAPABILITY_OBJECTCLASS_ATTRIBUTE)
                         .append('=')
-                        .append(service.getInterface())
+                        .append(serviceInterface)
                         .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());
+                if (serviceInterface != null && filter != null) {
+                	builder.append(')');
+                }
+                if (builder.length() > 0) {
+	                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) {



Mime
View raw message