[jboss-osgi-commits] JBoss-OSGI SVN: r89364 - in projects/jboss-osgi/projects/bundles/blueprint/trunk/impl: .settings and 2 other directories.

jboss-osgi-commits at lists.jboss.org jboss-osgi-commits at lists.jboss.org
Mon May 25 08:04:08 EDT 2009


Author: thomas.diesler at jboss.com
Date: 2009-05-25 08:04:08 -0400 (Mon, 25 May 2009)
New Revision: 89364

Added:
   projects/jboss-osgi/projects/bundles/blueprint/trunk/impl/.classpath
   projects/jboss-osgi/projects/bundles/blueprint/trunk/impl/.project
   projects/jboss-osgi/projects/bundles/blueprint/trunk/impl/.settings/
   projects/jboss-osgi/projects/bundles/blueprint/trunk/impl/.settings/org.eclipse.jdt.core.prefs
   projects/jboss-osgi/projects/bundles/blueprint/trunk/impl/.settings/org.maven.ide.eclipse.prefs
Modified:
   projects/jboss-osgi/projects/bundles/blueprint/trunk/impl/
   projects/jboss-osgi/projects/bundles/blueprint/trunk/impl/pom.xml
   projects/jboss-osgi/projects/bundles/blueprint/trunk/impl/src/main/java/org/jboss/osgi/blueprint/extender/BlueprintExtender.java
   projects/jboss-osgi/projects/bundles/blueprint/trunk/impl/src/main/java/org/jboss/osgi/blueprint/parser/BlueprintParser.java
Log:
Register BlueprintContext


Property changes on: projects/jboss-osgi/projects/bundles/blueprint/trunk/impl
___________________________________________________________________
Name: svn:ignore
   + target


Added: projects/jboss-osgi/projects/bundles/blueprint/trunk/impl/.classpath
===================================================================
--- projects/jboss-osgi/projects/bundles/blueprint/trunk/impl/.classpath	                        (rev 0)
+++ projects/jboss-osgi/projects/bundles/blueprint/trunk/impl/.classpath	2009-05-25 12:04:08 UTC (rev 89364)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" output="target/classes" path="src/main/java"/>
+	<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+	<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+	<classpathentry kind="output" path="target/classes"/>
+</classpath>

Added: projects/jboss-osgi/projects/bundles/blueprint/trunk/impl/.project
===================================================================
--- projects/jboss-osgi/projects/bundles/blueprint/trunk/impl/.project	                        (rev 0)
+++ projects/jboss-osgi/projects/bundles/blueprint/trunk/impl/.project	2009-05-25 12:04:08 UTC (rev 89364)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>jboss-osgi-blueprint-impl</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.maven.ide.eclipse.maven2Builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>org.maven.ide.eclipse.maven2Nature</nature>
+	</natures>
+</projectDescription>

Added: projects/jboss-osgi/projects/bundles/blueprint/trunk/impl/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- projects/jboss-osgi/projects/bundles/blueprint/trunk/impl/.settings/org.eclipse.jdt.core.prefs	                        (rev 0)
+++ projects/jboss-osgi/projects/bundles/blueprint/trunk/impl/.settings/org.eclipse.jdt.core.prefs	2009-05-25 12:04:08 UTC (rev 89364)
@@ -0,0 +1,5 @@
+#Mon May 25 10:32:34 CEST 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.source=1.5

Added: projects/jboss-osgi/projects/bundles/blueprint/trunk/impl/.settings/org.maven.ide.eclipse.prefs
===================================================================
--- projects/jboss-osgi/projects/bundles/blueprint/trunk/impl/.settings/org.maven.ide.eclipse.prefs	                        (rev 0)
+++ projects/jboss-osgi/projects/bundles/blueprint/trunk/impl/.settings/org.maven.ide.eclipse.prefs	2009-05-25 12:04:08 UTC (rev 89364)
@@ -0,0 +1,9 @@
+#Mon May 25 10:32:27 CEST 2009
+activeProfiles=
+eclipse.preferences.version=1
+fullBuildGoals=process-test-resources
+includeModules=false
+resolveWorkspaceProjects=true
+resourceFilterGoals=process-resources resources\:testResources
+skipCompilerPlugin=true
+version=1

Modified: projects/jboss-osgi/projects/bundles/blueprint/trunk/impl/pom.xml
===================================================================
--- projects/jboss-osgi/projects/bundles/blueprint/trunk/impl/pom.xml	2009-05-25 12:03:30 UTC (rev 89363)
+++ projects/jboss-osgi/projects/bundles/blueprint/trunk/impl/pom.xml	2009-05-25 12:04:08 UTC (rev 89364)
@@ -63,6 +63,7 @@
               org.osgi.service.blueprint.*
             </Export-Package>
             <Import-Package>
+              org.apache.xerces.dom,
               org.jboss.osgi.spi,
               org.jboss.osgi.common.log, 
               org.jboss.xb.*,

Modified: projects/jboss-osgi/projects/bundles/blueprint/trunk/impl/src/main/java/org/jboss/osgi/blueprint/extender/BlueprintExtender.java
===================================================================
--- projects/jboss-osgi/projects/bundles/blueprint/trunk/impl/src/main/java/org/jboss/osgi/blueprint/extender/BlueprintExtender.java	2009-05-25 12:03:30 UTC (rev 89363)
+++ projects/jboss-osgi/projects/bundles/blueprint/trunk/impl/src/main/java/org/jboss/osgi/blueprint/extender/BlueprintExtender.java	2009-05-25 12:04:08 UTC (rev 89364)
@@ -33,7 +33,7 @@
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleEvent;
-import org.osgi.framework.BundleListener;
+import org.osgi.framework.SynchronousBundleListener;
 import org.osgi.service.blueprint.context.BlueprintContext;
 import org.osgi.service.log.LogService;
 
@@ -43,18 +43,17 @@
  * @author thomas.diesler at jboss.com
  * @since 13-May-2009
  */
-public class BlueprintExtender implements BundleListener
+public class BlueprintExtender implements SynchronousBundleListener
 {
    private static final String HEADER_BUNDLE_BLUEPRINT = "Bundle-Blueprint";
 
    private LogService log;
+   private BundleContext context;
    
-   // A 
-   // private Map<String, Blueprint> compDefRegistry = new HashMap<String, Blueprint>(); 
-
    public BlueprintExtender(BundleContext context)
    {
       this.log = new LogServiceTracker(context);
+      this.context = context;
    }
 
    @SuppressWarnings("unchecked")
@@ -63,7 +62,7 @@
       Bundle bundle = event.getBundle();
       Blueprint bpMetadata = null;
       
-      if (event.getType() == BundleEvent.STARTED)
+      if (event.getType() == BundleEvent.STARTING)
       {
          // If a Bundle-Blueprint manifest header is defined, then this header contains a list of paths. 
          // If this header is not defined, then resources ending in .xml in the bundle’s
@@ -99,7 +98,7 @@
       if (bpMetadata != null)
       {
          BlueprintContext bpContext = new BlueprintContextImpl(bpMetadata);
-         bundle.getBundleContext().registerService(BlueprintContext.class.getName(), bpContext, null);
+         context.registerService(BlueprintContext.class.getName(), bpContext, null);
       }
    }
 

Modified: projects/jboss-osgi/projects/bundles/blueprint/trunk/impl/src/main/java/org/jboss/osgi/blueprint/parser/BlueprintParser.java
===================================================================
--- projects/jboss-osgi/projects/bundles/blueprint/trunk/impl/src/main/java/org/jboss/osgi/blueprint/parser/BlueprintParser.java	2009-05-25 12:03:30 UTC (rev 89363)
+++ projects/jboss-osgi/projects/bundles/blueprint/trunk/impl/src/main/java/org/jboss/osgi/blueprint/parser/BlueprintParser.java	2009-05-25 12:04:08 UTC (rev 89364)
@@ -25,6 +25,7 @@
 
 import java.net.URL;
 
+import org.apache.xerces.dom.DOMXSImplementationSourceImpl;
 import org.jboss.osgi.blueprint.BlueprintException;
 import org.jboss.osgi.blueprint.reflect.Blueprint;
 import org.jboss.xb.binding.JBossXBException;
@@ -39,33 +40,61 @@
  * @author thomas.diesler at jboss.com
  * @since 13-May-2009
  */
-public class BlueprintParser 
+public class BlueprintParser
 {
    private static SchemaBinding schemaBinding;
-   
+
    public BlueprintParser()
    {
       if (schemaBinding == null)
       {
-         ClassLoader resourceLoader = getClass().getClassLoader();
-         URL schemaXSD = resourceLoader.getResource("schema/blueprint-jbxb.xsd");
-         if (schemaXSD == null)
-            throw new BlueprintException("Cannot get blueprint schema from: " + resourceLoader);
-         
-         schemaBinding = XsdBinder.bind(schemaXSD.toExternalForm());
+         // https://jira.jboss.org/jira/browse/JBXB-202
+         // Inconsistent initialization of XSImplementation
+         // 
+         // Please provide an JBossXB initialization entry point that is public and does not make an assumption on the availability of the TCCL
+         //
+         ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
+         try
+         {
+            ClassLoader bundleCL = getClass().getClassLoader();
+            Thread.currentThread().setContextClassLoader(bundleCL);
+
+            // Make sure we import and can load the XSImplementation
+            // This is the code that is used in JBossXB Util.getXSImplementation()
+            bundleCL.loadClass(DOMXSImplementationSourceImpl.class.getName());
+
+            ClassLoader resourceLoader = getClass().getClassLoader();
+            URL schemaXSD = resourceLoader.getResource("schema/blueprint-jbxb.xsd");
+            if (schemaXSD == null)
+               throw new BlueprintException("Cannot get blueprint schema from: " + resourceLoader);
+
+            schemaBinding = XsdBinder.bind(schemaXSD.toExternalForm());
+         }
+         catch (ClassNotFoundException ex)
+         {
+            throw new IllegalStateException("Cannot load: " + DOMXSImplementationSourceImpl.class.getName());
+         }
+         finally
+         {
+            Thread.currentThread().setContextClassLoader(ctxLoader);
+         }
       }
    }
 
-   /**
-    * Parse a blueprint descriptor 
+   /*
+    * * Parse a blueprint descriptor
     */
-   public Blueprint parse(URL xmlURL)  
+   public Blueprint parse(URL xmlURL)
    {
       if (xmlURL == null)
          throw new IllegalArgumentException("Cannot parse null descriptor URL");
-      
+
+      ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
       try
       {
+         ClassLoader bundleCL = getClass().getClassLoader();
+         Thread.currentThread().setContextClassLoader(bundleCL);
+
          Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
          return (Blueprint)unmarshaller.unmarshal(xmlURL.toExternalForm(), schemaBinding);
       }
@@ -73,5 +102,9 @@
       {
          throw new BlueprintException("Cannot parse blueprint descriptor: " + xmlURL, ex);
       }
+      finally
+      {
+         Thread.currentThread().setContextClassLoader(ctxLoader);
+      }
    }
 }
\ No newline at end of file




More information about the jboss-osgi-commits mailing list