[jboss-cvs] JBossAS SVN: r96604 - projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Nov 19 18:40:31 EST 2009


Author: alesj
Date: 2009-11-19 18:40:30 -0500 (Thu, 19 Nov 2009)
New Revision: 96604

Added:
   projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiScopeInfo.java
Modified:
   projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiServiceState.java
Log:
Fix scope info usage.

Copied: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiScopeInfo.java (from rev 96603, projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiServiceState.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiScopeInfo.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiScopeInfo.java	2009-11-19 23:40:30 UTC (rev 96604)
@@ -0,0 +1,51 @@
+/*
+* 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 org.jboss.dependency.plugins.AbstractScopeInfo;
+import org.jboss.metadata.spi.scope.ScopeKey;
+import org.jboss.metadata.spi.scope.Scope;
+import org.jboss.metadata.spi.scope.CommonLevels;
+
+/**
+ * OSGi ScopeInfo
+ *
+ * @author <a href="ales.justin at jboss.org">Ales Justin</a>
+ */
+public class OSGiScopeInfo extends AbstractScopeInfo
+{
+   public OSGiScopeInfo(Object name, String className)
+   {
+      super(name, className);
+   }
+
+   /**
+    * Add class scope.
+    *
+    * @param clazz the class
+    */
+   void update(Class<?> clazz)
+   {
+      ScopeKey key = getScope();
+      key.addScope(new Scope(CommonLevels.CLASS, clazz));
+   }
+}
\ No newline at end of file

Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiServiceState.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiServiceState.java	2009-11-19 23:12:27 UTC (rev 96603)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiServiceState.java	2009-11-19 23:40:30 UTC (rev 96604)
@@ -34,7 +34,6 @@
 
 import org.jboss.beans.info.spi.BeanInfo;
 import org.jboss.dependency.plugins.AbstractControllerContext;
-import org.jboss.dependency.plugins.AbstractScopeInfo;
 import org.jboss.dependency.spi.dispatch.InvokeDispatchContext;
 import org.jboss.kernel.Kernel;
 import org.jboss.kernel.spi.config.KernelConfigurator;
@@ -188,10 +187,14 @@
    protected void initOSGiScopeInfo()
    {
       String className = null;
+
       Object target = serviceOrFactory;
-      if (target != null)
+      if (target != null && target instanceof ServiceFactory == false)
          className = target.getClass().getName();
-      setScopeInfo(new AbstractScopeInfo(getName(), className));
+      else if (clazzes.length == 1)
+         className = clazzes[0];
+
+      setScopeInfo(new OSGiScopeInfo(getName(), className));
    }
 
    @Override
@@ -258,6 +261,12 @@
       return beanInfo;
    }
 
+   @Override
+   public OSGiScopeInfo getScopeInfo()
+   {
+      return (OSGiScopeInfo)super.getScopeInfo();
+   }
+
    /**
     * Get the service.
     * 
@@ -286,6 +295,7 @@
             {
                service = checkObjClass(serviceFactory.getService(bundleState.getBundle(), getRegistration()));
                serviceCache.put(bundleState, service);
+               getScopeInfo().update(service.getClass());
             }
             catch (Throwable t)
             {




More information about the jboss-cvs-commits mailing list