[jboss-osgi-commits] JBoss-OSGI SVN: r99346 - in projects/jboss-osgi/projects/runtime/framework/trunk: src/main/java/org/jboss/osgi/framework/bundle and 5 other directories.

jboss-osgi-commits at lists.jboss.org jboss-osgi-commits at lists.jboss.org
Wed Jan 13 11:44:20 EST 2010


Author: alesj
Date: 2010-01-13 11:44:19 -0500 (Wed, 13 Jan 2010)
New Revision: 99346

Added:
   projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/FilterParserAndMatcher.java
   projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans2/
   projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans2/META-INF/
   projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans2/META-INF/MANIFEST.MF
   projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans2/META-INF/jboss-beans.xml
Removed:
   projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans2/META-INF/
   projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans2/META-INF/MANIFEST.MF
   projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans2/META-INF/jboss-beans.xml
Modified:
   projects/jboss-osgi/projects/runtime/framework/trunk/pom.xml
   projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java
   projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/service/ServiceMixUnitTestCase.java
   projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans1/META-INF/MANIFEST.MF
Log:
Update MC libs and bring back the service-mix test.

Modified: projects/jboss-osgi/projects/runtime/framework/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/pom.xml	2010-01-13 16:41:46 UTC (rev 99345)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/pom.xml	2010-01-13 16:44:19 UTC (rev 99346)
@@ -49,8 +49,8 @@
     <version.drools>5.0.1</version.drools>
     <version.jboss.aop>2.1.0.CR3</version.jboss.aop>
     <version.jboss.classloading>2.0.8.GA</version.jboss.classloading>
-    <version.jboss.deployers>2.2.0-SNAPSHOT</version.jboss.deployers>
-    <version.jboss.kernel>2.2.0-SNAPSHOT</version.jboss.kernel>
+    <version.jboss.deployers>2.2.0.Alpha1</version.jboss.deployers>
+    <version.jboss.kernel>2.2.0.Alpha1</version.jboss.kernel>
     <version.jboss.osgi.apache.xerces>2.9.1.SP3</version.jboss.osgi.apache.xerces>
     <version.jboss.osgi.common>1.0.3</version.jboss.osgi.common>
     <version.jboss.osgi.common.core>2.2.13.GA</version.jboss.osgi.common.core>

Added: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/FilterParserAndMatcher.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/FilterParserAndMatcher.java	                        (rev 0)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/FilterParserAndMatcher.java	2010-01-13 16:44:19 UTC (rev 99346)
@@ -0,0 +1,90 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file in the
+* distribution for a full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.osgi.framework.bundle;
+
+import java.util.Dictionary;
+import java.util.Set;
+
+import org.jboss.beans.metadata.api.model.QualifierContent;
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.kernel.spi.qualifier.QualifierMatcher;
+import org.jboss.kernel.spi.qualifier.QualifierParser;
+import org.jboss.metadata.spi.MetaData;
+import org.jboss.metadata.spi.scope.CommonLevels;
+import org.osgi.framework.Filter;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.InvalidSyntaxException;
+
+/**
+ * OSGi filter parsing and matching.
+ *
+ * @author <a href="ales.justin at jboss.org">Ales Justin</a>
+ */
+class FilterParserAndMatcher implements QualifierParser, QualifierMatcher<Filter>
+{
+   static final FilterParserAndMatcher INSTANCE = new FilterParserAndMatcher();
+
+   private FilterParserAndMatcher()
+   {
+   }
+
+   public Class<Filter> getHandledType()
+   {
+      return Filter.class;
+   }
+
+   public QualifierContent getHandledContent()
+   {
+      return QualifierContent.getContent("filter");
+   }
+
+   public boolean matches(ControllerContext context, Set<Object> suppliedQualifiers, Filter filter)
+   {
+      MetaData metaData = context.getScopeInfo().getMetaData();
+      if (metaData == null)
+         return false;
+
+      MetaData instanceMD = metaData.getScopeMetaData(CommonLevels.INSTANCE);
+      if (instanceMD == null)
+         return false;
+      
+      Dictionary dictionary = instanceMD.getMetaData(Dictionary.class);
+      return dictionary != null && filter.match(dictionary);
+   }
+
+   public Object parseWanted(ClassLoader cl, Object rawQualifier)
+   {
+      try
+      {
+         return FrameworkUtil.createFilter(String.valueOf(rawQualifier));
+      }
+      catch (InvalidSyntaxException e)
+      {
+         throw new IllegalArgumentException(e);
+      }
+   }
+
+   public Object parseSupplied(ClassLoader cl, Object rawQualifier)
+   {
+      return parseWanted(cl, rawQualifier);
+   }
+}
\ No newline at end of file

Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java	2010-01-13 16:41:46 UTC (rev 99345)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java	2010-01-13 16:44:19 UTC (rev 99346)
@@ -46,8 +46,8 @@
 import java.util.concurrent.Executors;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.jar.Attributes;
+import java.util.jar.Attributes.Name;
 import java.util.jar.Manifest;
-import java.util.jar.Attributes.Name;
 
 import org.jboss.dependency.spi.Controller;
 import org.jboss.dependency.spi.ControllerContext;
@@ -68,9 +68,10 @@
 import org.jboss.deployers.vfs.spi.client.VFSDeploymentFactory;
 import org.jboss.kernel.Kernel;
 import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.kernel.spi.qualifier.QualifierMatchers;
 import org.jboss.logging.Logger;
 import org.jboss.metadata.plugins.loader.memory.MemoryMetaDataLoader;
-import org.jboss.metadata.spi.loader.MutableMetaDataLoader;
+import org.jboss.metadata.spi.MutableMetaData;
 import org.jboss.metadata.spi.repository.MutableMetaDataRepository;
 import org.jboss.metadata.spi.retrieval.MetaDataRetrieval;
 import org.jboss.metadata.spi.retrieval.MetaDataRetrievalFactory;
@@ -150,6 +151,8 @@
    private MainDeployerStructure deployerStructure;
    /** The deployment registry */
    private DeploymentRegistry registry;
+   /** The previous context tracker */
+   private ContextTracker previousTracker;
    /** The instance metadata factory */
    private MetaDataRetrievalFactory factory;
    /** The executor */
@@ -264,23 +267,37 @@
          retrieval = new MemoryMetaDataLoader(ScopeKey.DEFAULT_SCOPE);
          repository.addMetaDataRetrieval(retrieval);
       }
-      if (retrieval != null && retrieval instanceof MutableMetaDataLoader)
+      if (retrieval != null && retrieval instanceof MutableMetaData)
       {
-         MutableMetaDataLoader mmdl = (MutableMetaDataLoader)retrieval;
+         MutableMetaData mmd = (MutableMetaData)retrieval;
          if (register)
          {
-            mmdl.addMetaData(systemBundle, ContextTracker.class);
+            previousTracker = mmd.addMetaData(systemBundle, ContextTracker.class);
          }
          else
          {
-            mmdl.removeMetaData(ContextTracker.class);
-            if (mmdl.isEmpty())
-               repository.removeMetaDataRetrieval(mmdl.getScope());
+            if (previousTracker == null)
+            {
+               mmd.removeMetaData(ContextTracker.class);
+               if (retrieval.isEmpty())
+                  repository.removeMetaDataRetrieval(retrieval.getScope());
+            }
+            else
+            {
+               mmd.addMetaData(previousTracker, ContextTracker.class);
+            }
          }
       }
 
+      // osgi ldap filter parsing and matching
+      FilterParserAndMatcher fpm = FilterParserAndMatcher.INSTANCE;
+      QualifierMatchers matchers = QualifierMatchers.getInstance();
+
       if (register)
       {
+         matchers.addParser(fpm);
+         matchers.addMatcher(fpm);
+
          MetaDataRetrievalFactory mdrFactory = factory;
          if (mdrFactory == null)
          {
@@ -296,6 +313,9 @@
       else
       {
          repository.removeMetaDataRetrievalFactory(CommonLevels.INSTANCE);
+
+         matchers.removeParser(fpm.getHandledContent());
+         matchers.removeMatcher(fpm.getHandledType());
       }
    }
 

Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/service/ServiceMixUnitTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/service/ServiceMixUnitTestCase.java	2010-01-13 16:41:46 UTC (rev 99345)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/service/ServiceMixUnitTestCase.java	2010-01-13 16:44:19 UTC (rev 99346)
@@ -460,6 +460,47 @@
       }
    }
 
+   public void testServiceInjection() throws Throwable
+   {
+      Bundle bundle = installBundle(assembleBundle("simple2", "/bundles/service/service-bundle2", A.class));
+      try
+      {
+         bundle.start();
+         BundleContext bundleContext1 = bundle.getBundleContext();
+         assertNotNull(bundleContext1);
+
+         Class<?> aClass = bundle.loadClass(A.class.getName());
+         Object a = aClass.newInstance();
+         Hashtable<String, Object> table = new Hashtable<String, Object>();
+         table.put("a", "b");
+         ServiceRegistration reg1 = bundleContext1.registerService(A.class.getName(), a, table);
+         assertNotNull(reg1);
+
+         AssembledDirectory mix = createAssembledDirectory("beans1", "");
+         addPath(mix, "/bundles/service/service-beans2", "");
+         addPackage(mix, C.class);
+         Deployment deployment = assertDeploy(mix);
+         try
+         {
+            checkComplete();
+
+            Bundle beans = getBundle(getDeploymentUnit(deployment));
+            beans.start();
+
+            Object c = getBean("C");
+            assertEquals(a, getter(c, "getA", "C"));
+         }
+         finally
+         {
+            undeploy(deployment);
+         }
+      }
+      finally
+      {
+         uninstall(bundle);
+      }
+   }
+
    public void testFiltering() throws Throwable
    {
       Deployment bean = addBean("beanA", A.class);

Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans1/META-INF/MANIFEST.MF
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans1/META-INF/MANIFEST.MF	2010-01-13 16:41:46 UTC (rev 99345)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans1/META-INF/MANIFEST.MF	2010-01-13 16:44:19 UTC (rev 99346)
@@ -2,6 +2,6 @@
 Implementation-Title: JBoss OSGi tests
 Implementation-Version: test
 Implementation-Vendor: jboss.org
-Bundle-Name: Service1
-Bundle-SymbolicName: org.jboss.test.osgi.service1
+Bundle-Name: Beans1
+Bundle-SymbolicName: org.jboss.test.osgi.beans1
 Export-Package: org.jboss.test.osgi.service.support.a

Copied: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans2 (from rev 99343, projects/jboss-osgi/projects/runtime/framework/branches/alesj/src/test/resources/bundles/service/service-beans2)

Copied: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans2/META-INF (from rev 99343, projects/jboss-osgi/projects/runtime/framework/branches/alesj/src/test/resources/bundles/service/service-beans2/META-INF)

Deleted: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans2/META-INF/MANIFEST.MF
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/branches/alesj/src/test/resources/bundles/service/service-beans2/META-INF/MANIFEST.MF	2010-01-13 14:51:43 UTC (rev 99343)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans2/META-INF/MANIFEST.MF	2010-01-13 16:44:19 UTC (rev 99346)
@@ -1,8 +0,0 @@
-Manifest-Version: 1.0
-Implementation-Title: JBoss OSGi tests
-Implementation-Version: test
-Implementation-Vendor: jboss.org
-Bundle-Name: Beans2
-Bundle-SymbolicName: org.jboss.test.osgi.beans2
-Export-Package: org.jboss.test.osgi.service.support.c
-Import-Package: org.jboss.test.osgi.service.support.a

Copied: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans2/META-INF/MANIFEST.MF (from rev 99343, projects/jboss-osgi/projects/runtime/framework/branches/alesj/src/test/resources/bundles/service/service-beans2/META-INF/MANIFEST.MF)
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans2/META-INF/MANIFEST.MF	                        (rev 0)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans2/META-INF/MANIFEST.MF	2010-01-13 16:44:19 UTC (rev 99346)
@@ -0,0 +1,8 @@
+Manifest-Version: 1.0
+Implementation-Title: JBoss OSGi tests
+Implementation-Version: test
+Implementation-Vendor: jboss.org
+Bundle-Name: Beans2
+Bundle-SymbolicName: org.jboss.test.osgi.beans2
+Export-Package: org.jboss.test.osgi.service.support.c
+Import-Package: org.jboss.test.osgi.service.support.a

Deleted: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans2/META-INF/jboss-beans.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/branches/alesj/src/test/resources/bundles/service/service-beans2/META-INF/jboss-beans.xml	2010-01-13 14:51:43 UTC (rev 99343)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans2/META-INF/jboss-beans.xml	2010-01-13 16:44:19 UTC (rev 99346)
@@ -1,11 +0,0 @@
-<deployment xmlns="urn:jboss:bean-deployer:2.0">
-
-  <bean name="C" class="org.jboss.test.osgi.service.support.c.C">
-    <property name="a">
-      <inject>
-        <qualifier content="filter" type="required">(a=b)</qualifier>
-      </inject>
-    </property>
-  </bean>
-
-</deployment>
\ No newline at end of file

Copied: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans2/META-INF/jboss-beans.xml (from rev 99343, projects/jboss-osgi/projects/runtime/framework/branches/alesj/src/test/resources/bundles/service/service-beans2/META-INF/jboss-beans.xml)
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans2/META-INF/jboss-beans.xml	                        (rev 0)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-beans2/META-INF/jboss-beans.xml	2010-01-13 16:44:19 UTC (rev 99346)
@@ -0,0 +1,11 @@
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+  <bean name="C" class="org.jboss.test.osgi.service.support.c.C">
+    <property name="a">
+      <inject>
+        <qualifier content="filter" type="required">(a=b)</qualifier>
+      </inject>
+    </property>
+  </bean>
+
+</deployment>
\ No newline at end of file



More information about the jboss-osgi-commits mailing list