[jboss-osgi-commits] JBoss-OSGI SVN: r90690 - in projects/jboss-osgi/trunk: blueprint/impl and 4 other directories.
jboss-osgi-commits at lists.jboss.org
jboss-osgi-commits at lists.jboss.org
Tue Jun 30 08:09:28 EDT 2009
Author: thomas.diesler at jboss.com
Date: 2009-06-30 08:09:27 -0400 (Tue, 30 Jun 2009)
New Revision: 90690
Added:
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/ManagerFactory.java
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/ReferenceManager.java
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/ReferenceMetadataImpl.java
Removed:
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/ServiceReferenceManager.java
projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/context/
Modified:
projects/jboss-osgi/trunk/blueprint/impl/pom.xml
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/AbstractManager.java
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/BeanManager.java
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/BlueprintContainerImpl.java
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/ServiceManager.java
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/BeanPropertyImpl.java
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/ComponentFactory.java
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/ServiceReferenceMetadataImpl.java
projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/container/BlueprintContainerTestCase.java
projects/jboss-osgi/trunk/pom.xml
Log:
Add BP support for <reference>
Modified: projects/jboss-osgi/trunk/blueprint/impl/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/blueprint/impl/pom.xml 2009-06-30 09:25:55 UTC (rev 90689)
+++ projects/jboss-osgi/trunk/blueprint/impl/pom.xml 2009-06-30 12:09:27 UTC (rev 90690)
@@ -72,10 +72,12 @@
org.jboss.osgi.common.log;version=1.0,
org.jboss.osgi.spi;version=1.0,
org.jboss.osgi.spi.service;version=1.0,
+ org.jboss.reflect.spi,
org.jboss.util.xml,
org.jboss.xb.*,
org.osgi.framework,
- org.osgi.service.log,
+ org.osgi.service.log,
+ org.osgi.util.tracker,
org.w3c.dom,
</Import-Package>
</instructions>
Modified: projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/AbstractManager.java
===================================================================
--- projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/AbstractManager.java 2009-06-30 09:25:55 UTC (rev 90689)
+++ projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/AbstractManager.java 2009-06-30 12:09:27 UTC (rev 90690)
@@ -34,10 +34,7 @@
import org.jboss.osgi.spi.service.MicrocontainerService;
import org.osgi.framework.ServiceReference;
import org.osgi.service.blueprint.container.BlueprintContainer;
-import org.osgi.service.blueprint.reflect.BeanMetadata;
import org.osgi.service.blueprint.reflect.ComponentMetadata;
-import org.osgi.service.blueprint.reflect.ServiceMetadata;
-import org.osgi.service.blueprint.reflect.ServiceReferenceMetadata;
import org.osgi.service.log.LogService;
/**
@@ -147,23 +144,4 @@
return controller;
}
-
- static AbstractManager createManager(BlueprintContext context, BlueprintContainer container, ComponentMetadata comp)
- {
- AbstractManager manager = null;
-
- if (comp instanceof BeanMetadata)
- manager = new BeanManager(context, container, (BeanMetadata)comp);
-
- else if (comp instanceof ServiceMetadata)
- manager = new ServiceManager(context, container, (ServiceMetadata)comp);
-
- else if (comp instanceof ServiceReferenceMetadata)
- manager = new ServiceReferenceManager(context, container, (ServiceReferenceMetadata)comp);
-
- if (manager == null)
- throw new IllegalArgumentException("Unsupported component type: " + comp);
-
- return manager;
- }
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/BeanManager.java
===================================================================
--- projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/BeanManager.java 2009-06-30 09:25:55 UTC (rev 90689)
+++ projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/BeanManager.java 2009-06-30 12:09:27 UTC (rev 90690)
@@ -23,15 +23,21 @@
//$Id$
+import org.jboss.beans.metadata.plugins.AbstractValueMetaData;
import org.jboss.beans.metadata.plugins.builder.BeanMetaDataBuilderFactory;
import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.ValueMetaData;
import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
import org.jboss.osgi.blueprint.BlueprintContext;
import org.jboss.osgi.blueprint.reflect.BeanMetadataImpl;
+import org.jboss.osgi.blueprint.reflect.ReferenceMetadataImpl;
+import org.jboss.reflect.spi.TypeInfo;
import org.osgi.service.blueprint.container.BlueprintContainer;
import org.osgi.service.blueprint.reflect.BeanMetadata;
import org.osgi.service.blueprint.reflect.BeanProperty;
import org.osgi.service.blueprint.reflect.Metadata;
+import org.osgi.service.blueprint.reflect.ReferenceMetadata;
+import org.osgi.util.tracker.ServiceTracker;
/**
* A bean manager provides regular Java objects as component
@@ -55,13 +61,13 @@
*/
public class BeanManager extends AbstractManager
{
- private BeanMetadataImpl beanMetadata;
- private BeanMetaData kernelBeanMetaData;
+ private BeanMetadataImpl bpBeanMetadata;
+ private BeanMetaData mcBeanMetadata;
public BeanManager(BlueprintContext context, BlueprintContainer container, BeanMetadata compMetadata)
{
super(context, container, compMetadata);
- this.beanMetadata = (BeanMetadataImpl)compMetadata;
+ this.bpBeanMetadata = (BeanMetadataImpl)compMetadata;
}
@Override
@@ -70,27 +76,29 @@
super.install();
// Install the kernel bean
- installKernelBean(getKernelBeanMetaData(beanMetadata));
+ installKernelBean(getMicrocontainerBeanMetaData(bpBeanMetadata));
}
@Override
public void shutdown()
{
- if (kernelBeanMetaData != null)
- uninstallKernelBean(kernelBeanMetaData);
+ if (mcBeanMetadata != null)
+ uninstallKernelBean(mcBeanMetadata);
super.shutdown();
}
- public BeanMetaData getKernelBeanMetaData(BeanMetadataImpl compMetadata)
+ public BeanMetaData getMicrocontainerBeanMetaData(BeanMetadataImpl compMetadata)
{
- if (kernelBeanMetaData == null)
+ if (mcBeanMetadata == null)
{
String key = compMetadata.getKey();
String clazz = compMetadata.getClassName();
BeanMetaDataBuilder builder = BeanMetaDataBuilderFactory.createBuilder(key, clazz);
- for (BeanProperty prop : beanMetadata.getProperties())
+ mcBeanMetadata = builder.getBeanMetaData();
+
+ for (BeanProperty prop : bpBeanMetadata.getProperties())
{
String name = prop.getName();
Metadata value = prop.getValue();
@@ -99,16 +107,47 @@
BeanMetadataImpl beanValue = (BeanMetadataImpl)value;
BlueprintContainerImpl impl = (BlueprintContainerImpl)container;
BeanManager beanManager = (BeanManager)impl.getComponentManager(beanValue.getKey());
- BeanMetaData valueMetaData = beanManager.getKernelBeanMetaData(beanValue);
+ BeanMetaData valueMetaData = beanManager.getMicrocontainerBeanMetaData(beanValue);
builder.addPropertyMetaData(name, valueMetaData);
}
+ else if (value instanceof ReferenceMetadata)
+ {
+ ReferenceMetadataImpl refValue = (ReferenceMetadataImpl)value;
+ BlueprintContainerImpl impl = (BlueprintContainerImpl)container;
+ ReferenceManager refManager = (ReferenceManager)impl.getComponentManager(refValue.getKey());
+ ValueMetaData valueMetaData = new ServiceValueMetaData(refManager.getServiceTracker());
+ builder.addPropertyMetaData(name, valueMetaData);
+ }
else
{
- //throw new IllegalStateException("Unsupported property value: " + value);
+ throw new IllegalStateException("Unsupported property value: " + value);
}
}
- kernelBeanMetaData = builder.getBeanMetaData();
}
- return kernelBeanMetaData;
+ return mcBeanMetadata;
}
+
+ /**
+ * A {@link ValueMetaData} implementation that gets its underlying value
+ * from a {@link ServiceTracker}
+ */
+ private class ServiceValueMetaData extends AbstractValueMetaData
+ {
+ private static final long serialVersionUID = 1L;
+ private ServiceTracker tracker;
+
+ private ServiceValueMetaData(ServiceTracker tracker)
+ {
+ this.tracker = tracker;
+
+ if (tracker == null)
+ throw new IllegalArgumentException("Underlying ServiceTracker cannot be null");
+ }
+
+ @Override
+ public Object getValue(TypeInfo info, ClassLoader cl)
+ {
+ return tracker.getService();
+ }
+ }
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/BlueprintContainerImpl.java
===================================================================
--- projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/BlueprintContainerImpl.java 2009-06-30 09:25:55 UTC (rev 90689)
+++ projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/BlueprintContainerImpl.java 2009-06-30 12:09:27 UTC (rev 90690)
@@ -175,9 +175,11 @@
private void createManagers(BlueprintMetadata bpMetadata)
{
+ ManagerFactory factory = new ManagerFactory(context, this);
+
for (ComponentMetadata comp : bpMetadata.getComponents())
{
- AbstractManager manager = AbstractManager.createManager(context, this, comp);
+ AbstractManager manager = factory.createManager(comp);
String key = manager.getId();
if (key == null)
Added: projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/ManagerFactory.java
===================================================================
--- projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/ManagerFactory.java (rev 0)
+++ projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/ManagerFactory.java 2009-06-30 12:09:27 UTC (rev 90690)
@@ -0,0 +1,68 @@
+/*
+ * 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.blueprint.container;
+
+//$Id: AbstractManager.java 90472 2009-06-19 15:11:39Z thomas.diesler at jboss.com $
+
+import org.jboss.osgi.blueprint.BlueprintContext;
+import org.osgi.service.blueprint.container.BlueprintContainer;
+import org.osgi.service.blueprint.reflect.BeanMetadata;
+import org.osgi.service.blueprint.reflect.ComponentMetadata;
+import org.osgi.service.blueprint.reflect.ReferenceMetadata;
+import org.osgi.service.blueprint.reflect.ServiceMetadata;
+
+/**
+ * Construct a component manager from the given component metadata.
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 17-Jun-2009
+ */
+public class ManagerFactory
+{
+ protected BlueprintContext context;
+ protected BlueprintContainer container;
+
+ public ManagerFactory(BlueprintContext context, BlueprintContainer container)
+ {
+ this.context = context;
+ this.container = container;
+ }
+
+ public AbstractManager createManager(ComponentMetadata comp)
+ {
+ AbstractManager manager = null;
+
+ if (comp instanceof BeanMetadata)
+ manager = new BeanManager(context, container, (BeanMetadata)comp);
+
+ else if (comp instanceof ServiceMetadata)
+ manager = new ServiceManager(context, container, (ServiceMetadata)comp);
+
+ else if (comp instanceof ReferenceMetadata)
+ manager = new ReferenceManager(context, container, (ReferenceMetadata)comp);
+
+ if (manager == null)
+ throw new IllegalArgumentException("Unsupported component type: " + comp);
+
+ return manager;
+ }
+}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/ReferenceManager.java (from rev 90669, projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/ServiceReferenceManager.java)
===================================================================
--- projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/ReferenceManager.java (rev 0)
+++ projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/ReferenceManager.java 2009-06-30 12:09:27 UTC (rev 90690)
@@ -0,0 +1,69 @@
+/*
+ * 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.blueprint.container;
+
+//$Id$
+
+import org.jboss.osgi.blueprint.BlueprintContext;
+import org.jboss.osgi.blueprint.reflect.ReferenceMetadataImpl;
+import org.osgi.service.blueprint.container.BlueprintContainer;
+import org.osgi.service.blueprint.reflect.ReferenceMetadata;
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ * Reference managers track a service in the OSGi service registry.
+ * When activated, they provide a ServiceReference object or a proxy
+ * to a service object.
+ *
+ * A reference is satisfied when its selection matches a service in the
+ * registry.
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 17-Jun-2009
+ */
+public class ReferenceManager extends AbstractManager
+{
+ private ReferenceMetadataImpl refMetadata;
+ private ServiceTracker tracker;
+
+ public ReferenceManager(BlueprintContext context, BlueprintContainer container, ReferenceMetadata compMetadata)
+ {
+ super(context, container, compMetadata);
+ this.refMetadata = (ReferenceMetadataImpl)compMetadata;
+ }
+
+ public ServiceTracker getServiceTracker()
+ {
+ if (tracker == null)
+ {
+ String intfName = refMetadata.getInterface();
+ tracker = new ServiceTracker(context.getBundleContext(), intfName, null);
+ tracker.open();
+ }
+ return tracker;
+ }
+
+ public Object getService()
+ {
+ return getServiceTracker().getService();
+ }
+}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/ServiceManager.java
===================================================================
--- projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/ServiceManager.java 2009-06-30 09:25:55 UTC (rev 90689)
+++ projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/ServiceManager.java 2009-06-30 12:09:27 UTC (rev 90690)
@@ -61,7 +61,10 @@
// Create the anonymous bean manager
Target target = serviceMetadata.getServiceComponent();
if (target instanceof BeanMetadata)
- anonymousBean = (BeanManager)AbstractManager.createManager(context, container, (BeanMetadata)target);
+ {
+ ManagerFactory factory = new ManagerFactory(context, container);
+ anonymousBean = (BeanManager)factory.createManager((BeanMetadata)target);
+ }
}
@Override
Deleted: projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/ServiceReferenceManager.java
===================================================================
--- projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/ServiceReferenceManager.java 2009-06-30 09:25:55 UTC (rev 90689)
+++ projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/ServiceReferenceManager.java 2009-06-30 12:09:27 UTC (rev 90690)
@@ -1,51 +0,0 @@
-/*
- * 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.blueprint.container;
-
-//$Id$
-
-import org.jboss.osgi.blueprint.BlueprintContext;
-import org.jboss.osgi.blueprint.reflect.ServiceReferenceMetadataImpl;
-import org.osgi.service.blueprint.container.BlueprintContainer;
-import org.osgi.service.blueprint.reflect.ServiceReferenceMetadata;
-
-/**
- * Reference managers track a service in the OSGi service registry.
- * When activated, they provide a ServiceReference object or a proxy
- * to a service object.
- *
- * A reference is satisfied when its selection matches a service in the
- * registry.
- *
- * @author thomas.diesler at jboss.com
- * @since 17-Jun-2009
- */
-public class ServiceReferenceManager extends AbstractManager
-{
- private ServiceReferenceMetadataImpl srefMetadata;
-
- public ServiceReferenceManager(BlueprintContext context, BlueprintContainer container, ServiceReferenceMetadata compMetadata)
- {
- super(context, container, compMetadata);
- this.srefMetadata = (ServiceReferenceMetadataImpl)compMetadata;
- }
-}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/BeanPropertyImpl.java
===================================================================
--- projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/BeanPropertyImpl.java 2009-06-30 09:25:55 UTC (rev 90689)
+++ projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/BeanPropertyImpl.java 2009-06-30 12:09:27 UTC (rev 90690)
@@ -59,11 +59,10 @@
{
value = blueprint.getComponent(ref);
}
+
+ if (value == null)
+ throw new IllegalStateException("Cannot obtain value for property: " + getName());
}
-
- //if (value == null)
- // throw new IllegalStateException("Cannot obtain value for property: " + getName());
-
return value;
}
}
Modified: projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/ComponentFactory.java
===================================================================
--- projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/ComponentFactory.java 2009-06-30 09:25:55 UTC (rev 90689)
+++ projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/ComponentFactory.java 2009-06-30 12:09:27 UTC (rev 90690)
@@ -26,8 +26,8 @@
import org.jboss.osgi.blueprint.BlueprintContext;
import org.jboss.osgi.blueprint.parser.xb.TBean;
import org.jboss.osgi.blueprint.parser.xb.TComponent;
+import org.jboss.osgi.blueprint.parser.xb.TReference;
import org.jboss.osgi.blueprint.parser.xb.TService;
-import org.jboss.osgi.blueprint.parser.xb.TServiceReference;
import org.osgi.service.blueprint.reflect.ComponentMetadata;
/**
@@ -66,8 +66,8 @@
else if (tComp instanceof TService)
comp = new ServiceMetadataImpl(context, blueprint, (TService)tComp);
- else if (tComp instanceof TServiceReference)
- comp = new ServiceReferenceMetadataImpl(context, blueprint, (TServiceReference)tComp);
+ else if (tComp instanceof TReference)
+ comp = new ReferenceMetadataImpl(context, blueprint, (TReference)tComp);
if (comp == null)
throw new IllegalArgumentException("Unsupported component type: " + tComp);
Added: projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/ReferenceMetadataImpl.java
===================================================================
--- projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/ReferenceMetadataImpl.java (rev 0)
+++ projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/ReferenceMetadataImpl.java 2009-06-30 12:09:27 UTC (rev 90690)
@@ -0,0 +1,58 @@
+/*
+ * 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.blueprint.reflect;
+
+// $Id: ServiceReferenceMetadataImpl.java 90472 2009-06-19 15:11:39Z thomas.diesler at jboss.com $
+
+import org.jboss.osgi.blueprint.BlueprintContext;
+import org.jboss.osgi.blueprint.parser.xb.TReference;
+import org.osgi.service.blueprint.reflect.ReferenceMetadata;
+
+/**
+ * Service reference that will bind to a single matching service in the service
+ * registry.
+ *
+ * Defines the <code>reference</code> element.
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 30-Jun-2009
+ */
+public class ReferenceMetadataImpl extends ServiceReferenceMetadataImpl implements ReferenceMetadata
+{
+ private TReference tReference;
+
+ public ReferenceMetadataImpl(BlueprintContext context, BlueprintMetadata blueprint, TReference tReference)
+ {
+ super(context, blueprint, tReference);
+ this.tReference = tReference;
+ }
+
+ public long getTimeout()
+ {
+ return tReference.getTimeout();
+ }
+
+ public String toString()
+ {
+ return "Reference[id=" + getId() + "]";
+ }
+}
Modified: projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/ServiceReferenceMetadataImpl.java
===================================================================
--- projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/ServiceReferenceMetadataImpl.java 2009-06-30 09:25:55 UTC (rev 90689)
+++ projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/ServiceReferenceMetadataImpl.java 2009-06-30 12:09:27 UTC (rev 90690)
@@ -39,7 +39,7 @@
* @author thomas.diesler at jboss.com
* @since 13-May-2009
*/
-public class ServiceReferenceMetadataImpl extends ComponentMetadataImpl implements ServiceReferenceMetadata
+public abstract class ServiceReferenceMetadataImpl extends ComponentMetadataImpl implements ServiceReferenceMetadata
{
private TServiceReference tService;
@@ -85,6 +85,6 @@
public String toString()
{
- return "Reference[id=" + getId() + "]";
+ return "ServiceReference[id=" + getId() + "]";
}
}
Modified: projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/container/BlueprintContainerTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/container/BlueprintContainerTestCase.java 2009-06-30 09:25:55 UTC (rev 90689)
+++ projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/container/BlueprintContainerTestCase.java 2009-06-30 12:09:27 UTC (rev 90690)
@@ -45,6 +45,7 @@
import org.jboss.osgi.spi.testing.OSGiRuntime;
import org.jboss.osgi.spi.testing.OSGiTestHelper;
import org.jboss.test.osgi.blueprint.container.bundle.BeanA;
+import org.jboss.test.osgi.blueprint.container.bundle.BeanB;
import org.jboss.test.osgi.blueprint.container.bundle.ServiceA;
import org.jboss.test.osgi.blueprint.container.bundle.ServiceB;
import org.junit.AfterClass;
@@ -56,8 +57,8 @@
import org.osgi.service.blueprint.container.BlueprintContainer;
import org.osgi.service.blueprint.reflect.BeanMetadata;
import org.osgi.service.blueprint.reflect.ComponentMetadata;
+import org.osgi.service.blueprint.reflect.ReferenceMetadata;
import org.osgi.service.blueprint.reflect.ServiceMetadata;
-import org.osgi.service.blueprint.reflect.ServiceReferenceMetadata;
/**
* BlueprintContainer API tests
@@ -169,6 +170,12 @@
ServiceB serviceB = (ServiceB)context.getService(srefB);
assertNotNull("Service available", serviceB);
+ BeanB beanB = (BeanB)serviceB;
+ BeanA beanA = beanB.getBeanA();
+ assertNotNull("BeanA available", beanA);
+
+ MBeanServer mbeanServer = beanA.getMbeanServer();
+ assertNotNull("MBeanServer available", mbeanServer);
}
@Test
@@ -265,12 +272,12 @@
assumeNotNull(context);
BlueprintContainer bpContainer = getBlueprintContainer();
- Collection<ServiceReferenceMetadata> srefsMetadata = bpContainer.getMetadata(ServiceReferenceMetadata.class);
+ Collection<ReferenceMetadata> srefsMetadata = bpContainer.getMetadata(ReferenceMetadata.class);
- assertNotNull("ServiceReferenceMetadata not null", srefsMetadata);
- assertEquals("ServiceReferenceMetadata size", 1, srefsMetadata.size());
+ assertNotNull("ReferenceMetadata not null", srefsMetadata);
+ assertEquals("ReferenceMetadata size", 1, srefsMetadata.size());
- ServiceReferenceMetadata srefMetadata = srefsMetadata.iterator().next();
+ ReferenceMetadata srefMetadata = srefsMetadata.iterator().next();
assertEquals("mbeanService", srefMetadata.getId());
String interfaceName = srefMetadata.getInterface();
Modified: projects/jboss-osgi/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/pom.xml 2009-06-30 09:25:55 UTC (rev 90689)
+++ projects/jboss-osgi/trunk/pom.xml 2009-06-30 12:09:27 UTC (rev 90690)
@@ -29,7 +29,7 @@
<version.args4j>2.0.12</version.args4j>
<version.apache.felix.configadmin>1.0.10</version.apache.felix.configadmin>
<version.apache.felix.core>1.2.0</version.apache.felix.core>
- <version.apache.felix.http.jetty>1.0.0</version.apache.felix.http.jetty>
+ <version.apache.felix.http.jetty>1.0.1</version.apache.felix.http.jetty>
<version.apache.felix.log>1.0.0</version.apache.felix.log>
<version.apache.felix.metatype>1.0.2</version.apache.felix.metatype>
<version.izpack>4.2.0</version.izpack>
More information about the jboss-osgi-commits
mailing list