clerezza-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject [1/2] git commit: CLEREZZA-885: Introducing General Purpose TcProvider marker
Date Sun, 02 Mar 2014 13:29:07 GMT
Repository: clerezza
Updated Branches:
  refs/heads/master aa0cc3489 -> cf4ea9c4c


CLEREZZA-885: Introducing General Purpose TcProvider marker

Project: http://git-wip-us.apache.org/repos/asf/clerezza/repo
Commit: http://git-wip-us.apache.org/repos/asf/clerezza/commit/659b7806
Tree: http://git-wip-us.apache.org/repos/asf/clerezza/tree/659b7806
Diff: http://git-wip-us.apache.org/repos/asf/clerezza/diff/659b7806

Branch: refs/heads/master
Commit: 659b78065a81813a8bbf6e8a68342651c60890c5
Parents: aa0cc34
Author: retobg <reto@apache.org>
Authored: Sat Mar 1 20:24:14 2014 +0100
Committer: retobg <reto@apache.org>
Committed: Sat Mar 1 20:24:14 2014 +0100

----------------------------------------------------------------------
 rdf.core/pom.xml                                | 21 +++++++-
 .../clerezza/rdf/core/access/TcManager.java     | 53 +++++++++++++++-----
 .../rdf/core/serializedform/Parser.java         | 14 +++---
 .../rdf/core/serializedform/Serializer.java     | 14 +++---
 .../clerezza/rdf/core/sparql/QueryParser.java   |  6 +--
 5 files changed, 79 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/clerezza/blob/659b7806/rdf.core/pom.xml
----------------------------------------------------------------------
diff --git a/rdf.core/pom.xml b/rdf.core/pom.xml
index 87416b4..9e13bcc 100644
--- a/rdf.core/pom.xml
+++ b/rdf.core/pom.xml
@@ -40,9 +40,15 @@
             <groupId>org.osgi</groupId>
             <artifactId>org.osgi.compendium</artifactId>
         </dependency>
-        <dependency>
+        <!-- <dependency>
             <groupId>org.apache.felix</groupId>
             <artifactId>org.apache.felix.scr.annotations</artifactId>
+            <version>1.9.6</version>
+        </dependency> -->
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.scr.ds-annotations</artifactId>
+            <version>1.2.4</version>
         </dependency>
         <dependency>
             <groupId>org.apache.clerezza</groupId>
@@ -104,6 +110,19 @@
                     </instructions>
                 </configuration>
             </plugin>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-scr-plugin</artifactId>
+                <version>1.15.0</version>
+                <executions>
+                    <execution>
+                        <id>generate-scr-scrdescriptor</id>
+                        <goals>
+                            <goal>scr</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
         </plugins>
     </build>
 </project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/clerezza/blob/659b7806/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/TcManager.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/TcManager.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/TcManager.java
index 7ff32c9..e8d76d3 100644
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/TcManager.java
+++ b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/access/TcManager.java
@@ -48,14 +48,13 @@ import org.apache.clerezza.rdf.core.sparql.query.ConstructQuery;
 import org.apache.clerezza.rdf.core.sparql.query.DescribeQuery;
 import org.apache.clerezza.rdf.core.sparql.query.Query;
 import org.apache.clerezza.rdf.core.sparql.query.SelectQuery;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Reference;
-import org.apache.felix.scr.annotations.ReferenceCardinality;
-import org.apache.felix.scr.annotations.ReferencePolicy;
-import org.apache.felix.scr.annotations.Service;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.ServiceRegistration;
 import org.osgi.service.component.ComponentContext;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Reference;
+import org.osgi.service.component.annotations.ReferenceCardinality;
+import org.osgi.service.component.annotations.ReferencePolicy;
 
 /**
  * This class implements
@@ -98,20 +97,16 @@ import org.osgi.service.component.ComponentContext;
  * @author reto, mir, hasan
  *
  */
-@Component
-@Service(TcManager.class)
-@Reference(name = "weightedTcProvider", policy = ReferencePolicy.DYNAMIC,
-        referenceInterface = WeightedTcProvider.class,
-        cardinality = ReferenceCardinality.MANDATORY_MULTIPLE)
+//immedia is set to true as this should register the graph services (even if manager service
is not required)
+@Component(service = TcManager.class, immediate = true)
 public class TcManager extends TcProviderMultiplexer {
 
+    public final static String GENERAL_PURPOSE_TC = "general.purpose.tc";
     private static volatile TcManager instance;
     private TcAccessController tcAccessController = new TcAccessController(this);
     private Map<UriRef, ServiceRegistration> serviceRegistrations = Collections
             .synchronizedMap(new HashMap<UriRef, ServiceRegistration>());
     
-    @Reference(policy = ReferencePolicy.DYNAMIC,
-            cardinality = ReferenceCardinality.OPTIONAL_UNARY)
     protected QueryEngine queryEngine;
 
     private ComponentContext componentContext;
@@ -471,6 +466,8 @@ public class TcManager extends TcProviderMultiplexer {
      *
      * @param provider the provider to be registered
      */
+    @Reference(policy = ReferencePolicy.DYNAMIC, 
+            cardinality = ReferenceCardinality.MULTIPLE)
     protected void bindWeightedTcProvider(WeightedTcProvider provider) {
         addWeightedTcProvider(provider);
     }
@@ -484,6 +481,38 @@ public class TcManager extends TcProviderMultiplexer {
             WeightedTcProvider provider) {
         removeWeightedTcProvider(provider);
     }
+    
+    /**
+     * Registers a provider
+     *
+     * @param provider the provider to be registered
+     */
+    @Reference(policy = ReferencePolicy.DYNAMIC, 
+            cardinality = ReferenceCardinality.AT_LEAST_ONE,
+            target = "("+TcManager.GENERAL_PURPOSE_TC+"=true)")
+    protected void bindGpWeightedTcProvider(WeightedTcProvider provider) {
+        addWeightedTcProvider(provider);
+    }
+
+    /**
+     * Unregister a provider
+     *
+     * @param provider the provider to be deregistered
+     */
+    protected void unbindGpWeightedTcProvider(
+            WeightedTcProvider provider) {
+        removeWeightedTcProvider(provider);
+    }
+    
+    @Reference(policy = ReferencePolicy.DYNAMIC,
+            cardinality = ReferenceCardinality.OPTIONAL)
+    protected void bindQueryEngine(QueryEngine queryEngine) {
+        this.queryEngine = queryEngine;
+    }
+    
+    protected void unbindQueryEngine(QueryEngine queryEngine) {
+        this.queryEngine = null;
+    }
 
     @Override
     protected void mGraphAppears(UriRef name) {

http://git-wip-us.apache.org/repos/asf/clerezza/blob/659b7806/rdf.core/src/main/java/org/apache/clerezza/rdf/core/serializedform/Parser.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/serializedform/Parser.java
b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/serializedform/Parser.java
index 6312219..62096d7 100644
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/serializedform/Parser.java
+++ b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/serializedform/Parser.java
@@ -22,7 +22,6 @@ import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -34,6 +33,11 @@ import org.apache.clerezza.rdf.core.MGraph;
 import org.apache.clerezza.rdf.core.UriRef;
 import org.apache.clerezza.rdf.core.impl.SimpleMGraph;
 
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Reference;
+import org.osgi.service.component.annotations.ReferenceCardinality;
+import org.osgi.service.component.annotations.ReferencePolicy;
+
 /**
  * This singleton class provides a method <code>parse</code> to transform 
  * serialized RDF forms into {@link Graph}s.
@@ -48,12 +52,8 @@ import org.apache.clerezza.rdf.core.impl.SimpleMGraph;
  * 
  * @author reto
  * 
- * @scr.component
- * @scr.service interface="org.apache.clerezza.rdf.core.serializedform.Parser"
- * @scr.reference name="parsingProvider"
- *     cardinality="0..n" policy="dynamic"
- *     interface="org.apache.clerezza.rdf.core.serializedform.ParsingProvider"
  */
+@Component(service = Parser.class)
 public class Parser {
 
     /**
@@ -204,6 +204,8 @@ public class Parser {
      *
      * @param provider the provider to be registered
      */
+    @Reference(policy = ReferencePolicy.DYNAMIC, 
+            cardinality = ReferenceCardinality.MULTIPLE)
     public void bindParsingProvider(ParsingProvider provider) {
         providerList.add(provider);
         refreshProviderMap();

http://git-wip-us.apache.org/repos/asf/clerezza/blob/659b7806/rdf.core/src/main/java/org/apache/clerezza/rdf/core/serializedform/Serializer.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/serializedform/Serializer.java
b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/serializedform/Serializer.java
index b5b42b3..1a4c8a9 100644
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/serializedform/Serializer.java
+++ b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/serializedform/Serializer.java
@@ -30,6 +30,11 @@ import java.util.ServiceLoader;
 
 import org.apache.clerezza.rdf.core.TripleCollection;
 
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Reference;
+import org.osgi.service.component.annotations.ReferenceCardinality;
+import org.osgi.service.component.annotations.ReferencePolicy;
+
 /**
  * This singleton class provides a method <code>serialize</code> to transform
a
  * {@link Graph} into serialized RDF forms.
@@ -44,13 +49,8 @@ import org.apache.clerezza.rdf.core.TripleCollection;
  * 
  * @author mir
  * 
- * @scr.component
- * @scr.service interface="org.apache.clerezza.rdf.core.serializedform.Serializer"
- * @scr.reference 
- *                name="serializingProvider"
- *                cardinality="0..n" policy="dynamic"
- *                interface="org.apache.clerezza.rdf.core.serializedform.SerializingProvider"
  */
+@Component(service = Serializer.class)
 public class Serializer {
 
     /**
@@ -150,6 +150,8 @@ public class Serializer {
      * @param provider
      *            the provider to be registered
      */
+    @Reference(policy = ReferencePolicy.DYNAMIC, 
+            cardinality = ReferenceCardinality.MULTIPLE)
     public void bindSerializingProvider(SerializingProvider provider) {
         providerList.add(provider);
         refreshProviderMap();

http://git-wip-us.apache.org/repos/asf/clerezza/blob/659b7806/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/QueryParser.java
----------------------------------------------------------------------
diff --git a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/QueryParser.java b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/QueryParser.java
index 7df232a..8d76c48 100644
--- a/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/QueryParser.java
+++ b/rdf.core/src/main/java/org/apache/clerezza/rdf/core/sparql/QueryParser.java
@@ -19,9 +19,8 @@
 package org.apache.clerezza.rdf.core.sparql;
 
 import java.io.StringReader;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Service;
 import org.apache.clerezza.rdf.core.sparql.query.Query;
+import org.osgi.service.component.annotations.Component;
 
 /**
  * This class implements an OSGi service to provide a method to parse a
@@ -30,8 +29,7 @@ import org.apache.clerezza.rdf.core.sparql.query.Query;
  * @author hasan
  */
 
-@Component
-@Service(QueryParser.class)
+@Component(service = QueryParser.class)
 public class QueryParser {
 
     private static volatile QueryParser instance;


Mime
View raw message