[jboss-cvs] JBossAS SVN: r89505 - in projects/jboss-osgi/trunk: spi/src/main/java/org/jboss/osgi/spi/testing and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu May 28 18:46:29 EDT 2009


Author: thomas.diesler at jboss.com
Date: 2009-05-28 18:46:29 -0400 (Thu, 28 May 2009)
New Revision: 89505

Added:
   projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/management/ManagedServiceReference.java
   projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/OSGiServiceReference.java
   projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/EmbeddedServiceReference.java
   projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteServiceReference.java
Modified:
   projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/management/ManagedFramework.java
   projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/management/ManagedFrameworkMBean.java
   projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/OSGiRuntime.java
   projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/EmbeddedRuntime.java
   projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java
   projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteFramework.java
   projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/RemotePackageAdmin.java
   projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteRuntime.java
   projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/microcontainer/MicrocontainerTestCase.java
Log:
Add test support for ServiceReferences

Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/management/ManagedFramework.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/management/ManagedFramework.java	2009-05-28 22:38:40 UTC (rev 89504)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/management/ManagedFramework.java	2009-05-28 22:46:29 UTC (rev 89505)
@@ -23,9 +23,12 @@
 
 //$Id$
 
+import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 import javax.management.MBeanServer;
@@ -36,6 +39,7 @@
 import org.jboss.osgi.spi.Constants;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
+import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.packageadmin.PackageAdmin;
 
@@ -90,6 +94,44 @@
       return names;
    }
 
+   public ManagedServiceReference getServiceReference(String clazz)
+   {
+      ManagedServiceReference manref = null;
+      ServiceReference sref = systemContext.getServiceReference(clazz);
+      if (sref != null)
+      {
+         Map<String, Object> props = new HashMap<String, Object>();
+         for (String key : sref.getPropertyKeys())
+            props.put(key, sref.getProperty(key));
+         
+         manref = new ManagedServiceReference(clazz, props);
+      }
+      return manref;
+   }
+
+   public ManagedServiceReference[] getServiceReferences(String clazz, String filter) throws InvalidSyntaxException
+   {
+      List<ManagedServiceReference> foundRefs = new ArrayList<ManagedServiceReference>();
+      ServiceReference[] srefs = systemContext.getServiceReferences(clazz, filter);
+      if (srefs != null)
+      {
+         for (ServiceReference sref : srefs)
+         {
+            Map<String, Object> props = new HashMap<String, Object>();
+            for (String key : sref.getPropertyKeys())
+               props.put(key, sref.getProperty(key));
+            
+            foundRefs.add(new ManagedServiceReference(clazz, props));
+         }
+      }
+      
+      ManagedServiceReference[] manrefs = null;
+      if (foundRefs.size() > 0)
+         manrefs = foundRefs.toArray(new ManagedServiceReference[foundRefs.size()]);
+      
+      return manrefs;
+   }
+
    public void refreshPackages(String[] symbolicNames)
    {
       ServiceReference sref = systemContext.getServiceReference(PackageAdmin.class.getName());

Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/management/ManagedFrameworkMBean.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/management/ManagedFrameworkMBean.java	2009-05-28 22:38:40 UTC (rev 89504)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/management/ManagedFrameworkMBean.java	2009-05-28 22:46:29 UTC (rev 89505)
@@ -27,6 +27,8 @@
 
 import javax.management.ObjectName;
 
+import org.osgi.framework.InvalidSyntaxException;
+
 /**
  * The managed view of an OSGi Framework
  * 
@@ -49,6 +51,20 @@
    ObjectName getBundle(String symbolicName);
    
    /**
+    * Returns a ServiceReference object for a service that implements and was registered 
+    * under the specified class.
+    */
+   ManagedServiceReference getServiceReference(String clazz);
+   
+   /**
+    * Returns an array of ManagedServiceReference objects. 
+    * The returned array of ManagedServiceReference objects contains services 
+    * that were registered under the specified class, match the specified filter criteria, 
+    * and the packages for the class names under which the services were registered.
+    */
+   ManagedServiceReference[] getServiceReferences(String clazz, String filter) throws InvalidSyntaxException;
+   
+   /**
     * Refresh packages through the PackageAdmin service
     */
    void refreshPackages(String[] symbolicNames);

Added: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/management/ManagedServiceReference.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/management/ManagedServiceReference.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/management/ManagedServiceReference.java	2009-05-28 22:46:29 UTC (rev 89505)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.spi.management;
+
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * [TODO]
+ * 
+ * @author Thomas.Diesler at jboss.org
+ * @since 25-Sep-2008
+ */
+public class ManagedServiceReference
+{
+   private String className;
+   private Map<String, Object> props;
+   
+   public ManagedServiceReference(String className, Map<String, Object> props)
+   {
+      this.className = className;
+   }
+
+   public Object getProperty(String key)
+   {
+      return props.get(key);
+   }
+
+   public String[] getPropertyKeys()
+   {
+      Set<String> keySet = props.keySet();
+      return keySet.toArray(new String[keySet.size()]);
+   }
+}


Property changes on: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/management/ManagedServiceReference.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/OSGiRuntime.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/OSGiRuntime.java	2009-05-28 22:38:40 UTC (rev 89504)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/OSGiRuntime.java	2009-05-28 22:46:29 UTC (rev 89505)
@@ -22,14 +22,13 @@
 package org.jboss.osgi.spi.testing;
 
 import javax.management.MBeanServerConnection;
-import javax.management.ObjectName;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
 
 import org.jboss.osgi.spi.logging.LogEntryCache;
-import org.jboss.osgi.spi.management.MBeanProxyException;
 import org.jboss.osgi.spi.testing.capability.Capability;
 import org.osgi.framework.BundleException;
+import org.osgi.framework.InvalidSyntaxException;
 
 /**
  * [TODO]
@@ -50,23 +49,25 @@
    OSGiBundle installBundle(String location) throws BundleException;
 
    OSGiBundle[] getBundles();
-   
+
    OSGiBundle getBundle(String symbolicName, String version);
-   
+
    OSGiPackageAdmin getPackageAdmin();
+
+   OSGiServiceReference getServiceReference(String clazz);
    
+   OSGiServiceReference[] getServiceReferences(String clazz, String filter) throws InvalidSyntaxException;
+   
    InitialContext getInitialContext() throws NamingException;
-   
-   <T> T getMBeanProxy(Class<T> mbeanInterface, ObjectName objectName) throws MBeanProxyException;
-   
+
    MBeanServerConnection getMBeanServer();
-   
+
    void deploy(String location) throws Exception;
-   
+
    void undeploy(String location) throws Exception;
-   
+
    String getServerHost();
-   
+
    void shutdown();
 
 }

Added: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/OSGiServiceReference.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/OSGiServiceReference.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/OSGiServiceReference.java	2009-05-28 22:46:29 UTC (rev 89505)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.spi.testing;
+
+
+/**
+ * [TODO]
+ * 
+ * @author Thomas.Diesler at jboss.org
+ * @since 25-Sep-2008
+ */
+public interface OSGiServiceReference
+{
+   Object getProperty(String key);
+   
+   String[] getPropertyKeys();
+}


Property changes on: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/OSGiServiceReference.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/EmbeddedRuntime.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/EmbeddedRuntime.java	2009-05-28 22:38:40 UTC (rev 89504)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/EmbeddedRuntime.java	2009-05-28 22:46:29 UTC (rev 89505)
@@ -38,6 +38,7 @@
 import org.jboss.osgi.spi.logging.LogEntryCache;
 import org.jboss.osgi.spi.testing.OSGiBundle;
 import org.jboss.osgi.spi.testing.OSGiPackageAdmin;
+import org.jboss.osgi.spi.testing.OSGiServiceReference;
 import org.jboss.osgi.spi.testing.OSGiTestHelper;
 import org.jboss.osgi.spi.testing.capability.Capability;
 import org.osgi.framework.Bundle;
@@ -80,6 +81,18 @@
       return bundleArr;
    }
    
+   public OSGiServiceReference getServiceReference(String clazz)
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
+   public OSGiServiceReference[] getServiceReferences(String clazz, String filter)
+   {
+      // TODO Auto-generated method stub
+      return null;
+   }
+
    @Override
    public void addCapability(Capability capability) throws BundleException
    {

Added: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/EmbeddedServiceReference.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/EmbeddedServiceReference.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/EmbeddedServiceReference.java	2009-05-28 22:46:29 UTC (rev 89505)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.spi.testing.internal;
+
+import org.jboss.osgi.spi.testing.OSGiServiceReference;
+import org.osgi.framework.ServiceReference;
+
+/**
+ * [TODO]
+ * 
+ * @author Thomas.Diesler at jboss.org
+ * @since 25-Sep-2008
+ */
+public class EmbeddedServiceReference implements OSGiServiceReference
+{
+   private ServiceReference sref;
+   
+   public EmbeddedServiceReference(ServiceReference sref)
+   {
+      this.sref = sref;
+   }
+
+   public Object getProperty(String key)
+   {
+      return sref.getProperty(key);
+   }
+
+   public String[] getPropertyKeys()
+   {
+      return sref.getPropertyKeys();
+   }
+
+}


Property changes on: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/EmbeddedServiceReference.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java	2009-05-28 22:38:40 UTC (rev 89504)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java	2009-05-28 22:46:29 UTC (rev 89505)
@@ -34,8 +34,6 @@
 
 import org.jboss.logging.Logger;
 import org.jboss.osgi.spi.logging.LogEntryCache;
-import org.jboss.osgi.spi.management.MBeanProxy;
-import org.jboss.osgi.spi.management.MBeanProxyException;
 import org.jboss.osgi.spi.testing.OSGiBundle;
 import org.jboss.osgi.spi.testing.OSGiRuntime;
 import org.jboss.osgi.spi.testing.OSGiTestHelper;
@@ -172,11 +170,6 @@
       getMBeanServer().invoke(oname, method, new Object[] { archiveURL }, new String[] { "java.net.URL" });
    }
 
-   public <T> T getMBeanProxy(Class<T> mbeanInterface, ObjectName objectName) throws MBeanProxyException
-   {
-      return MBeanProxy.get(mbeanInterface, objectName, getMBeanServer());
-   }
-
    public InitialContext getInitialContext() throws NamingException
    {
       return helper.getInitialContext();

Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteFramework.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteFramework.java	2009-05-28 22:38:40 UTC (rev 89504)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteFramework.java	2009-05-28 22:46:29 UTC (rev 89505)
@@ -26,6 +26,8 @@
 import java.util.Set;
 
 import org.jboss.osgi.spi.management.ManagedBundleMBean;
+import org.jboss.osgi.spi.management.ManagedServiceReference;
+import org.osgi.framework.InvalidSyntaxException;
 
 /**
  * The supported functionality of a remote OSGi Framework
@@ -44,4 +46,18 @@
     * Get the installed bundle 
     */
    ManagedBundleMBean getBundle(String symbolicName);
+
+   /**
+    * Returns a ServiceReference object for a service that implements and was registered 
+    * under the specified class.
+    */
+   ManagedServiceReference getServiceReference(String clazz);
+   
+   /**
+    * Returns an array of ManagedServiceReference objects. 
+    * The returned array of ManagedServiceReference objects contains services 
+    * that were registered under the specified class, match the specified filter criteria, 
+    * and the packages for the class names under which the services were registered.
+    */
+   ManagedServiceReference[] getServiceReferences(String clazz, String filter) throws InvalidSyntaxException;
 }
\ No newline at end of file

Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/RemotePackageAdmin.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/RemotePackageAdmin.java	2009-05-28 22:38:40 UTC (rev 89504)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/RemotePackageAdmin.java	2009-05-28 22:46:29 UTC (rev 89505)
@@ -21,6 +21,7 @@
  */
 package org.jboss.osgi.spi.testing.internal;
 
+import org.jboss.osgi.spi.management.MBeanProxy;
 import org.jboss.osgi.spi.management.MBeanProxyException;
 import org.jboss.osgi.spi.management.ManagedFrameworkMBean;
 import org.jboss.osgi.spi.testing.OSGiBundle;
@@ -54,7 +55,7 @@
       }
       try
       {
-         ManagedFrameworkMBean mbeanProxy = runtime.getMBeanProxy(ManagedFrameworkMBean.class, ManagedFrameworkMBean.MBEAN_MANAGED_FRAMEWORK);
+         ManagedFrameworkMBean mbeanProxy = MBeanProxy.get(ManagedFrameworkMBean.class, ManagedFrameworkMBean.MBEAN_MANAGED_FRAMEWORK, runtime.getMBeanServer());
          mbeanProxy.refreshPackages(bundleArr);
       }
       catch (MBeanProxyException ex)

Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteRuntime.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteRuntime.java	2009-05-28 22:38:40 UTC (rev 89504)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteRuntime.java	2009-05-28 22:46:29 UTC (rev 89505)
@@ -42,8 +42,10 @@
 import org.jboss.osgi.spi.management.MBeanProxyException;
 import org.jboss.osgi.spi.management.ManagedBundleMBean;
 import org.jboss.osgi.spi.management.ManagedFrameworkMBean;
+import org.jboss.osgi.spi.management.ManagedServiceReference;
 import org.jboss.osgi.spi.testing.OSGiBundle;
 import org.jboss.osgi.spi.testing.OSGiPackageAdmin;
+import org.jboss.osgi.spi.testing.OSGiServiceReference;
 import org.jboss.osgi.spi.testing.OSGiTestHelper;
 import org.jboss.osgi.spi.testing.capability.Capability;
 import org.jboss.osgi.spi.testing.capability.ConfigAdminCapability;
@@ -55,6 +57,7 @@
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleException;
 import org.osgi.framework.Constants;
+import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.log.LogReaderService;
 import org.osgi.util.tracker.ServiceTracker;
@@ -150,6 +153,27 @@
       }
    }
 
+   public OSGiServiceReference getServiceReference(String clazz)
+   {
+      ManagedServiceReference manref = getRemoteFramework().getServiceReference(clazz);
+      return manref != null ? new RemoteServiceReference(manref) : null;
+   }
+
+   public OSGiServiceReference[] getServiceReferences(String clazz, String filter) throws InvalidSyntaxException
+   {
+      OSGiServiceReference[] srefs = null;
+      
+      ManagedServiceReference[] manrefs = getRemoteFramework().getServiceReferences(clazz, filter);
+      if (manrefs != null)
+      {
+         srefs = new OSGiServiceReference[manrefs.length];
+         for(int i=0; i < manrefs.length; i++)
+            srefs[i] = new RemoteServiceReference(manrefs[i]);
+      }
+      
+      return srefs;
+   }
+
    public void startLogEntryTracking(final LogEntryCache logEntryCache)
    {
       super.startLogEntryTracking(logEntryCache);
@@ -223,10 +247,17 @@
       return new RemotePackageAdmin(this);
    }
 
-   private RemoteFramework getRemoteFramework() throws Exception
+   private RemoteFramework getRemoteFramework() 
    {
-      if (managedFramework == null)
-         managedFramework = MBeanProxy.get(ManagedFrameworkMBean.class, ManagedFrameworkMBean.MBEAN_MANAGED_FRAMEWORK, getMBeanServer());
+      try
+      {
+         if (managedFramework == null)
+            managedFramework = MBeanProxy.get(ManagedFrameworkMBean.class, ManagedFrameworkMBean.MBEAN_MANAGED_FRAMEWORK, getMBeanServer());
+      }
+      catch (MBeanProxyException ex)
+      {
+         throw new RemoteFrameworkException(ex);
+      }
 
       return new RemoteFramework()
       {
@@ -263,6 +294,16 @@
             }
             return remBundles;
          }
+
+         public ManagedServiceReference getServiceReference(String clazz)
+         {
+            return managedFramework.getServiceReference(clazz);
+         }
+
+         public ManagedServiceReference[] getServiceReferences(String clazz, String filter) throws InvalidSyntaxException
+         {
+            return managedFramework.getServiceReferences(clazz, filter);
+         }
       };
    }
 }

Added: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteServiceReference.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteServiceReference.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteServiceReference.java	2009-05-28 22:46:29 UTC (rev 89505)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.spi.testing.internal;
+
+import org.jboss.osgi.spi.management.ManagedServiceReference;
+import org.jboss.osgi.spi.testing.OSGiServiceReference;
+
+/**
+ * [TODO]
+ * 
+ * @author Thomas.Diesler at jboss.org
+ * @since 25-Sep-2008
+ */
+public class RemoteServiceReference implements OSGiServiceReference
+{
+   private ManagedServiceReference sref;
+   
+   public RemoteServiceReference(ManagedServiceReference sref)
+   {
+      this.sref = sref;
+   }
+
+   public Object getProperty(String key)
+   {
+      return sref.getProperty(key);
+   }
+
+   public String[] getPropertyKeys()
+   {
+      return sref.getPropertyKeys();
+   }
+
+}


Property changes on: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteServiceReference.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/microcontainer/MicrocontainerTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/microcontainer/MicrocontainerTestCase.java	2009-05-28 22:38:40 UTC (rev 89504)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/microcontainer/MicrocontainerTestCase.java	2009-05-28 22:46:29 UTC (rev 89505)
@@ -37,6 +37,7 @@
 import javax.management.ObjectName;
 
 import org.jboss.osgi.microcontainer.MicrocontainerServiceMBean;
+import org.jboss.osgi.spi.management.MBeanProxy;
 import org.jboss.osgi.spi.management.ManagedFrameworkMBean;
 import org.jboss.osgi.spi.testing.OSGiRuntime;
 import org.jboss.osgi.spi.testing.OSGiTest;
@@ -76,7 +77,7 @@
    @Test
    public void testServiceAccess() throws Exception
    {
-      MicrocontainerServiceMBean mcService = runtime.getMBeanProxy(MicrocontainerServiceMBean.class, MBEAN_MICROCONTAINER_SERVICE);
+      MicrocontainerServiceMBean mcService = MBeanProxy.get(MicrocontainerServiceMBean.class, MBEAN_MICROCONTAINER_SERVICE, runtime.getMBeanServer());
       List<String> registeredBeans = mcService.getRegisteredBeans();
       assertTrue("BundleContext registered with MC", registeredBeans.contains(BEAN_SYSTEM_BUNDLE_CONTEXT));
       assertTrue("MBeanServer registered with MC", registeredBeans.contains(BEAN_MBEAN_SERVER));
@@ -89,10 +90,10 @@
    @Test
    public void testBundleDeployment() throws Exception
    {
-      MicrocontainerServiceMBean mcService = runtime.getMBeanProxy(MicrocontainerServiceMBean.class, MBEAN_MICROCONTAINER_SERVICE);
+      MicrocontainerServiceMBean mcService = MBeanProxy.get(MicrocontainerServiceMBean.class, MBEAN_MICROCONTAINER_SERVICE, runtime.getMBeanServer());
       mcService.deploy(getTestArchiveURL("example-mcservice-bundleA.jar"));
 
-      ManagedFrameworkMBean frameworkMBean = runtime.getMBeanProxy(ManagedFrameworkMBean.class, MBEAN_MANAGED_FRAMEWORK);
+      ManagedFrameworkMBean frameworkMBean = MBeanProxy.get(ManagedFrameworkMBean.class, MBEAN_MANAGED_FRAMEWORK, runtime.getMBeanServer());
       Set<ObjectName> bundles = frameworkMBean.getBundles();
       assertTrue("Managed bundle registered", bundles.toString().indexOf("jboss.osgi:bundle=example-mcservice-bundleA") > 0);
 
@@ -102,10 +103,10 @@
    @Test
    public void testBeansDeployment() throws Exception
    {
-      MicrocontainerServiceMBean mcService = runtime.getMBeanProxy(MicrocontainerServiceMBean.class, MBEAN_MICROCONTAINER_SERVICE);
+      MicrocontainerServiceMBean mcService = MBeanProxy.get(MicrocontainerServiceMBean.class, MBEAN_MICROCONTAINER_SERVICE, runtime.getMBeanServer());
       mcService.deploy(getTestArchiveURL("example-mcservice-bundleB.jar"));
 
-      ManagedFrameworkMBean frameworkMBean = runtime.getMBeanProxy(ManagedFrameworkMBean.class, MBEAN_MANAGED_FRAMEWORK);
+      ManagedFrameworkMBean frameworkMBean = MBeanProxy.get(ManagedFrameworkMBean.class, MBEAN_MANAGED_FRAMEWORK, runtime.getMBeanServer());
       Set<ObjectName> bundles = frameworkMBean.getBundles();
       assertTrue("Managed bundle registered", bundles.toString().indexOf("jboss.osgi:bundle=example-mcservice-bundleB") > 0);
 




More information about the jboss-cvs-commits mailing list