incubator-aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lin...@apache.org
Subject svn commit: r942760 - in /incubator/aries/trunk/blueprint: ./ blueprint-bundle/ blueprint-core/ blueprint-core/src/main/java/org/apache/aries/blueprint/ blueprint-core/src/main/java/org/apache/aries/blueprint/container/
Date Mon, 10 May 2010 14:49:51 GMT
Author: linsun
Date: Mon May 10 14:49:51 2010
New Revision: 942760

URL: http://svn.apache.org/viewvc?rev=942760&view=rev
Log:
[blueprint annotation] add blueprint annotation code into the build & modify the blueprint
extender to check for blueprint annotation when blueprint definition XML is not provided

Modified:
    incubator/aries/trunk/blueprint/blueprint-bundle/pom.xml
    incubator/aries/trunk/blueprint/blueprint-core/pom.xml
    incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/BlueprintConstants.java
    incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintExtender.java
    incubator/aries/trunk/blueprint/pom.xml

Modified: incubator/aries/trunk/blueprint/blueprint-bundle/pom.xml
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/blueprint/blueprint-bundle/pom.xml?rev=942760&r1=942759&r2=942760&view=diff
==============================================================================
--- incubator/aries/trunk/blueprint/blueprint-bundle/pom.xml (original)
+++ incubator/aries/trunk/blueprint/blueprint-bundle/pom.xml Mon May 10 14:49:51 2010
@@ -45,6 +45,7 @@
             net.sf.cglib*;resolution:=optional,
             org.objectweb.asm*;version="[3.1,4)";resolution:=optional,
             org.osgi.service.cm;version="[1.2.0,2.0.0)",
+            org.apache.aries.blueprint.annotation.service;resolution:=optional,
             *
         </aries.osgi.import>
         <!--

Modified: incubator/aries/trunk/blueprint/blueprint-core/pom.xml
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/blueprint/blueprint-core/pom.xml?rev=942760&r1=942759&r2=942760&view=diff
==============================================================================
--- incubator/aries/trunk/blueprint/blueprint-core/pom.xml (original)
+++ incubator/aries/trunk/blueprint/blueprint-core/pom.xml Mon May 10 14:49:51 2010
@@ -44,6 +44,7 @@
         org.apache.aries.util.tracker;resolution:=optional,
         org.osgi.service.event*;resolution:=optional,
         org.osgi.service.framework;resolution:=optional,
+        org.apache.aries.blueprint.annotation.service;resolution:=optional,
         *
       </aries.osgi.import>
       <aries.osgi.export.service>
@@ -57,6 +58,11 @@
           <artifactId>org.apache.aries.blueprint.api</artifactId>
       </dependency>
       <dependency>
+          <groupId>org.apache.aries.blueprint</groupId>
+          <artifactId>org.apache.aries.blueprint.annotation.api</artifactId>
+          <version>${version}</version>
+      </dependency>
+      <dependency>
           <groupId>org.apache.aries</groupId>
           <artifactId>org.apache.aries.util</artifactId>
       </dependency>

Modified: incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/BlueprintConstants.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/BlueprintConstants.java?rev=942760&r1=942759&r2=942760&view=diff
==============================================================================
--- incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/BlueprintConstants.java
(original)
+++ incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/BlueprintConstants.java
Mon May 10 14:49:51 2010
@@ -22,6 +22,8 @@ public interface BlueprintConstants  {
    
     public static final String BUNDLE_BLUEPRINT_HEADER = "Bundle-Blueprint";
     
+    public static final String BUNDLE_BLUEPRINT_ANNOTATION_HEADER = "Bundle-Blueprint-Annotation";
+    
     public static final String TIMEOUT_DIRECTIVE = "blueprint.timeout";
     
     public static final String GRACE_PERIOD = "blueprint.graceperiod";

Modified: incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintExtender.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintExtender.java?rev=942760&r1=942759&r2=942760&view=diff
==============================================================================
--- incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintExtender.java
(original)
+++ incubator/aries/trunk/blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/BlueprintExtender.java
Mon May 10 14:49:51 2010
@@ -34,6 +34,7 @@ import java.util.concurrent.ScheduledExe
 
 import org.apache.aries.blueprint.BlueprintConstants;
 import org.apache.aries.blueprint.ParserService;
+import org.apache.aries.blueprint.annotation.service.BlueprintAnnotationScanner;
 import org.apache.aries.blueprint.namespace.NamespaceHandlerRegistryImpl;
 import org.apache.aries.blueprint.utils.HeaderParser;
 import org.apache.aries.blueprint.utils.HeaderParser.PathElement;
@@ -50,6 +51,7 @@ import org.osgi.service.blueprint.contai
 import org.osgi.service.blueprint.container.BlueprintEvent;
 import org.osgi.util.tracker.BundleTracker;
 import org.osgi.util.tracker.BundleTrackerCustomizer;
+import org.osgi.util.tracker.ServiceTracker;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -69,6 +71,7 @@ public class BlueprintExtender implement
     private NamespaceHandlerRegistry handlers;
     private RecursiveBundleTracker bt;
     private ServiceRegistration parserServiceReg;
+    private ServiceTracker st;
 
     public void start(BundleContext context) {
         LOGGER.debug("Starting blueprint extender...");
@@ -208,6 +211,7 @@ public class BlueprintExtender implement
         try {
             List<Object> pathList = new ArrayList<Object>();
             String blueprintHeader = (String) bundle.getHeaders().get(BlueprintConstants.BUNDLE_BLUEPRINT_HEADER);
+            String blueprintHeaderAnnotation = (String) bundle.getHeaders().get(BlueprintConstants.BUNDLE_BLUEPRINT_ANNOTATION_HEADER);
             if (blueprintHeader == null) {
                 blueprintHeader = "OSGI-INF/blueprint/";
             } 
@@ -233,7 +237,26 @@ public class BlueprintExtender implement
                         addEntry(bundle, name, pathList);
                     }                    
                 }
-            }            
+            }
+            
+            if (pathList.isEmpty() && blueprintHeaderAnnotation.trim().equalsIgnoreCase("true"))
{
+                LOGGER.debug("Scanning bundle {} for blueprint annotations", bundle.getSymbolicName());
+                ServiceReference sr = this.context.getServiceReference("org.apache.aries.blueprint.annotation.service.BlueprintAnnotationScanner");
+                           
+                if (sr != null) {
+                    BlueprintAnnotationScanner bas = (BlueprintAnnotationScanner)this.context.getService(sr);
+                    // try to generate the blueprint definition XML
+                    URL url = bas.createBlueprintModel(bundle);
+                        
+                    if (url != null) {
+                        pathList.add(url);
+                    }
+                    
+                    this.context.ungetService(sr);
+                }
+             
+            }
+            
             if (!pathList.isEmpty()) {
                 LOGGER.debug("Found blueprint application in bundle {} with paths: {}", bundle.getSymbolicName(),
pathList);
                 // Check compatibility
@@ -250,13 +273,13 @@ public class BlueprintExtender implement
                 }
 
             } else {
-                LOGGER.debug("No blueprint application found in bundle {}", bundle.getSymbolicName());
+                LOGGER.debug("No blueprint application found in bundle {}", bundle.getSymbolicName());
  
             }
         } catch (Throwable t) {
             eventDispatcher.blueprintEvent(new BlueprintEvent(BlueprintEvent.FAILURE, bundle,
context.getBundle(), t));
         }
     }
-    
+
     private boolean isCompatible(Bundle bundle) {
         // Check compatibility
         boolean compatible;

Modified: incubator/aries/trunk/blueprint/pom.xml
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/blueprint/pom.xml?rev=942760&r1=942759&r2=942760&view=diff
==============================================================================
--- incubator/aries/trunk/blueprint/pom.xml (original)
+++ incubator/aries/trunk/blueprint/pom.xml Mon May 10 14:49:51 2010
@@ -149,6 +149,10 @@
         <module>blueprint-cm</module>
         <module>blueprint-bundle</module>
         <module>blueprint-sample</module>
+        <module>blueprint-annotation-api</module>
+        <module>blueprint-annotation-impl</module>
+        <module>blueprint-sample-annotation</module>
+        <module>blueprint-annotation-itest</module>
         <module>blueprint-testbundlea</module>
         <module>blueprint-testbundleb</module>
         <module>blueprint-itests</module>



Mime
View raw message