[jboss-cvs] JBossAS SVN: r90405 - in projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint: extender and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Jun 18 06:11:14 EDT 2009
Author: thomas.diesler at jboss.com
Date: 2009-06-18 06:11:14 -0400 (Thu, 18 Jun 2009)
New Revision: 90405
Added:
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/ServiceManager.java
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/ServiceReferenceManager.java
Removed:
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/ComponentFactory.java
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/extender/BlueprintExtender.java
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/BlueprintMetadata.java
Log:
Add BP managers
Added: 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 (rev 0)
+++ projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/AbstractManager.java 2009-06-18 10:11:14 UTC (rev 90405)
@@ -0,0 +1,94 @@
+/*
+ * 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.osgi.framework.BundleContext;
+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;
+
+/**
+ * For each of the ComponentMetadata objects, the Blueprint Container has a
+ * corresponding component manager. For example, a BeanMetadata object
+ * relates to a Bean Manager. There are the following types of managers:
+ *
+ * • Bean Managers – Can provide general objects that are properly configured
+ * • Service Managers – Can register services
+ * • Service Reference Managers – Provide proxies to one or more services.
+ * • Environment Managers – Holding environment values like the Blueprint Bundle object
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 17-Jun-2009
+ */
+public abstract class AbstractManager
+{
+ protected BundleContext context;
+ private ComponentMetadata component;
+
+ public AbstractManager(BundleContext context, ComponentMetadata component)
+ {
+ this.context = context;
+ this.component = component;
+ }
+
+ public String getId()
+ {
+ return component.getId();
+ }
+
+ public ComponentMetadata getComponentMetadata()
+ {
+ return component;
+ }
+
+ public void activate()
+ {
+ // do nothing
+ }
+
+ public void shutdown()
+ {
+ // do nothing
+ }
+
+ static AbstractManager createManager(BundleContext context, ComponentMetadata comp)
+ {
+ AbstractManager manager = null;
+
+ if (comp instanceof BeanMetadata)
+ manager = new BeanManager(context, (BeanMetadata)comp);
+
+ else if (comp instanceof ServiceMetadata)
+ manager = new ServiceManager(context, (ServiceMetadata)comp);
+
+ else if (comp instanceof ServiceReferenceMetadata)
+ manager = new ServiceReferenceManager(context, (ServiceReferenceMetadata)comp);
+
+ if (manager == null)
+ throw new IllegalArgumentException("Unsupported component type: " + comp);
+
+ return manager;
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/AbstractManager.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: 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 (rev 0)
+++ projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/BeanManager.java 2009-06-18 10:11:14 UTC (rev 90405)
@@ -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.container;
+
+//$Id$
+
+import org.osgi.framework.BundleContext;
+import org.osgi.service.blueprint.reflect.BeanMetadata;
+
+/**
+ * A bean manager provides regular Java objects as component
+ * instances. It has the following features:
+ *
+ * • Construction via class name, static factory method, or a factory
+ * method on a target. A target is a reference to a top level or inlined,
+ * manager of type bean or service reference, or a referral to a top level
+ * manager.
+ *
+ * • Can have arguments for a constructor or factory method.
+ *
+ * • Has properties that are configured.
+ *
+ * • Manages a singleton or creates objects on demand depending on its scope.
+ *
+ * • Life cycle callbacks for end of initialization and destruction.
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 17-Jun-2009
+ */
+public class BeanManager extends AbstractManager
+{
+ private BeanMetadata beanMetadata;
+
+ public BeanManager(BundleContext context, BeanMetadata beanMetadata)
+ {
+ super(context, beanMetadata);
+ this.beanMetadata = beanMetadata;
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/BeanManager.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
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-18 09:51:05 UTC (rev 90404)
+++ projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/BlueprintContainerImpl.java 2009-06-18 10:11:14 UTC (rev 90405)
@@ -23,7 +23,12 @@
//$Id: BlueprintContextImpl.java 90313 2009-06-17 10:37:51Z thomas.diesler at jboss.com $
+import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
import java.util.Properties;
import java.util.Set;
@@ -34,6 +39,7 @@
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
import org.osgi.service.blueprint.container.BlueprintContainer;
+import org.osgi.service.blueprint.container.NoSuchComponentException;
import org.osgi.service.blueprint.reflect.ComponentMetadata;
/**
@@ -68,7 +74,7 @@
private BundleContext context;
private Bundle bundle;
- private BlueprintMetadata bpMetadata;
+ private Map<String, AbstractManager> managers = new LinkedHashMap<String, AbstractManager>();
public BlueprintContainerImpl(BundleContext context, Bundle bundle)
{
@@ -78,13 +84,35 @@
public void initialize()
{
- BlueprintParser bpParser = new BlueprintParser(context);
- bpMetadata = bpParser.getBlueprintMetadata(bundle);
- bpMetadata.initialize();
+ // The Blueprint Container parses the definitions into metadata objects.
+ BlueprintMetadata bpMetadata = getBlueprintMetadata();
+ // For each of the ComponentMetadata objects, the Blueprint Container
+ // has a corresponding component manager.
+ createManagers(bpMetadata);
+
+ // If the Blueprint Container has successfully activated the eager managers, it
+ // will register a Blueprint Container service.
registerBlueprintContainerService();
}
+ /*
+ * When the Blueprint Container must be destroyed because the Blueprint
+ * bundle has stopped, there is a failure, or the Blueprint extender is stopped,
+ * then the Blueprint Container service is unregistered and all managers are
+ * deactivated. This will unregister any services and listeners, which release
+ * the component instances. Then all component instances are destroyed in
+ * reverse dependency order. That is, a component instance is destroyed when
+ * no other component instances depends on it.
+ */
+ public void shutdown()
+ {
+ for (AbstractManager manager : managers.values())
+ {
+ manager.shutdown();
+ }
+ }
+
public BundleContext getBundleContext()
{
return bundle.getBundleContext();
@@ -97,17 +125,29 @@
public Set<String> getComponentIds()
{
- return bpMetadata.getComponentIds();
+ return Collections.unmodifiableSet(managers.keySet());
}
public ComponentMetadata getComponentMetadata(String name)
{
- return bpMetadata.getComponentMetadata(name);
+ AbstractManager manager = managers.get(name);
+ if (manager == null)
+ throw new NoSuchComponentException(name);
+
+ return manager.getComponentMetadata();
}
+ @SuppressWarnings("unchecked")
public <T extends ComponentMetadata> Collection<T> getMetadata(Class<T> type)
{
- return bpMetadata.getMetadata(type);
+ List<T> compMetadata = new ArrayList<T>();
+ for (AbstractManager manager : managers.values())
+ {
+ ComponentMetadata comp = manager.getComponentMetadata();
+ if (type.isAssignableFrom(comp.getClass()))
+ compMetadata.add((T)comp);
+ }
+ return Collections.unmodifiableList(compMetadata);
}
public Object getComponentInstance(String id)
@@ -125,4 +165,21 @@
props.setProperty(PROPERTY_BLUEPRINT_BUNDLE_VERSION, version);
context.registerService(BlueprintContainer.class.getName(), this, props);
}
+
+ private void createManagers(BlueprintMetadata bpMetadata)
+ {
+ for (ComponentMetadata comp : bpMetadata.getComponents())
+ {
+ AbstractManager manager = AbstractManager.createManager(context, comp);
+ managers.put(manager.getId(), manager);
+ }
+ }
+
+ private BlueprintMetadata getBlueprintMetadata()
+ {
+ BlueprintParser bpParser = new BlueprintParser(context);
+ BlueprintMetadata bpMetadata = bpParser.getBlueprintMetadata(bundle);
+ bpMetadata.initialize();
+ return bpMetadata;
+ }
}
\ No newline at end of file
Added: 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 (rev 0)
+++ projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/ServiceManager.java 2009-06-18 10:11:14 UTC (rev 90405)
@@ -0,0 +1,48 @@
+/*
+ * 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.osgi.framework.BundleContext;
+import org.osgi.service.blueprint.reflect.ServiceMetadata;
+
+/**
+ * Service managers maintain the registration of an OSGi service
+ * object. Service managers provide a proxied ServiceRegistration object.
+ *
+ * A service manager is enabled if all the mandatory service references in its
+ * dependencies are satisfied.
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 17-Jun-2009
+ */
+public class ServiceManager extends AbstractManager
+{
+ private ServiceMetadata serviceMetadata;
+
+ public ServiceManager(BundleContext context, ServiceMetadata serviceMetadata)
+ {
+ super(context, serviceMetadata);
+ this.serviceMetadata = serviceMetadata;
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/ServiceManager.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: 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 (rev 0)
+++ projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/ServiceReferenceManager.java 2009-06-18 10:11:14 UTC (rev 90405)
@@ -0,0 +1,49 @@
+/*
+ * 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.osgi.framework.BundleContext;
+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 ServiceReferenceMetadata srefMetadata;
+
+ public ServiceReferenceManager(BundleContext context, ServiceReferenceMetadata srefMetadata)
+ {
+ super(context, srefMetadata);
+ this.srefMetadata = srefMetadata;
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/container/ServiceReferenceManager.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/extender/BlueprintExtender.java
===================================================================
--- projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/extender/BlueprintExtender.java 2009-06-18 09:51:05 UTC (rev 90404)
+++ projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/extender/BlueprintExtender.java 2009-06-18 10:11:14 UTC (rev 90405)
@@ -23,12 +23,19 @@
//$Id$
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
import java.util.Enumeration;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
import org.jboss.osgi.blueprint.container.BlueprintContainerImpl;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleEvent;
+import org.osgi.framework.Constants;
import org.osgi.framework.SynchronousBundleListener;
/**
@@ -40,6 +47,7 @@
public class BlueprintExtender implements SynchronousBundleListener
{
private BundleContext context;
+ private Map<String, BlueprintContainerImpl> containers = new LinkedHashMap<String, BlueprintContainerImpl>();
public BlueprintExtender(BundleContext context)
{
@@ -50,27 +58,38 @@
public void bundleChanged(BundleEvent event)
{
Bundle bundle = event.getBundle();
+ String key = getBundleKey(bundle);
+ int eventType = event.getType();
- boolean hasBlueprintMetadata = false;
-
- if (event.getType() == BundleEvent.STARTING)
+ if (eventType == 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
// OSGI-INF/blueprint directory must be used. These are the resources that
// would be found by calling the Bundle findEntries("OSGI-INF/blueprint", "*.xml", false) method.
+
+ boolean hasBlueprintMetadata = false;
String descriptorPaths = (String)bundle.getHeaders().get(BlueprintContainerImpl.HEADER_BUNDLE_BLUEPRINT);
hasBlueprintMetadata = (descriptorPaths != null);
Enumeration foundEntries = bundle.findEntries("OSGI-INF/blueprint", "*.xml", false);
hasBlueprintMetadata |= (foundEntries != null);
+
+ if (hasBlueprintMetadata == true)
+ {
+ BlueprintContainerImpl container = new BlueprintContainerImpl(context, bundle);
+ container.initialize();
+
+ containers.put(key, container);
+ }
}
-
- if (hasBlueprintMetadata == true)
+
+ else if (eventType == BundleEvent.STOPPED)
{
- BlueprintContainerImpl bpContainer = new BlueprintContainerImpl(context, bundle);
- bpContainer.initialize();
+ BlueprintContainerImpl container = containers.remove(key);
+ if (container != null)
+ container.shutdown();
}
}
@@ -79,6 +98,18 @@
*/
public void stop()
{
- // currently does nothing
+ Collection<BlueprintContainerImpl> values = containers.values();
+ List<BlueprintContainerImpl> list = new ArrayList<BlueprintContainerImpl>(values);
+ Collections.reverse(list);
+
+ for (BlueprintContainerImpl container : list)
+ container.shutdown();
}
+
+ private String getBundleKey(Bundle bundle)
+ {
+ String symbolicName = bundle.getSymbolicName();
+ String version = (String)bundle.getHeaders().get(Constants.BUNDLE_VERSION);
+ return symbolicName + "-" + version;
+ }
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/BlueprintMetadata.java
===================================================================
--- projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/BlueprintMetadata.java 2009-06-18 09:51:05 UTC (rev 90404)
+++ projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/BlueprintMetadata.java 2009-06-18 10:11:14 UTC (rev 90405)
@@ -24,18 +24,18 @@
// $Id$
import java.util.ArrayList;
-import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
-import java.util.Set;
+import org.jboss.osgi.blueprint.parser.xb.TBean;
import org.jboss.osgi.blueprint.parser.xb.TBlueprint;
import org.jboss.osgi.blueprint.parser.xb.TComponent;
+import org.jboss.osgi.blueprint.parser.xb.TService;
+import org.jboss.osgi.blueprint.parser.xb.TServiceReference;
import org.jboss.osgi.spi.NotImplementedException;
import org.osgi.framework.BundleContext;
-import org.osgi.service.blueprint.container.NoSuchComponentException;
import org.osgi.service.blueprint.reflect.ComponentMetadata;
/**
@@ -66,40 +66,19 @@
public void initialize()
{
- ComponentFactory factory = new ComponentFactory(context);
for (TComponent tComp : tBlueprint.getComponents())
{
- ComponentMetadata comp = factory.newComponent(tComp);
+ ComponentMetadata comp = createComponent(tComp);
components.put(comp.getId(), comp);
}
}
- public Set<String> getComponentIds()
+ public List<ComponentMetadata> getComponents()
{
- return Collections.unmodifiableSet(components.keySet());
+ ArrayList<ComponentMetadata> list = new ArrayList<ComponentMetadata>(components.values());
+ return Collections.unmodifiableList(list);
}
- public ComponentMetadata getComponentMetadata(String name)
- {
- ComponentMetadata compMetadata = components.get(name);
- if (compMetadata == null)
- throw new NoSuchComponentException(name);
-
- return compMetadata;
- }
-
- @SuppressWarnings("unchecked")
- public <T extends ComponentMetadata> Collection<T> getMetadata(Class<T> type)
- {
- List<T> compMetadata = new ArrayList<T>();
- for (ComponentMetadata comp : components.values())
- {
- if (type.isAssignableFrom(comp.getClass()))
- compMetadata.add((T)comp);
- }
- return Collections.unmodifiableList(compMetadata);
- }
-
// Merge this Blueprint meta data with the given other, which may be null.
public BlueprintMetadata merge(BlueprintMetadata other)
{
@@ -108,4 +87,26 @@
throw new NotImplementedException("Blueprint metadata merge not yet implemented");
}
+
+ private ComponentMetadata createComponent(TComponent tComp)
+ {
+ ComponentMetadata comp = null;
+
+ if (tComp.getId() == null)
+ tComp.setId(".anonymousId#" + (components.size() + 1));
+
+ if (tComp instanceof TBean)
+ comp = new BeanMetadataImpl(context, (TBean)tComp);
+
+ else if (tComp instanceof TService)
+ comp = new ServiceMetadataImpl(context, (TService)tComp);
+
+ else if (tComp instanceof TServiceReference)
+ comp = new ServiceReferenceMetadataImpl(context, (TServiceReference)tComp);
+
+ if (comp == null)
+ throw new IllegalArgumentException("Unsupported component type: " + tComp);
+
+ return comp;
+ }
}
Deleted: 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-18 09:51:05 UTC (rev 90404)
+++ projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/reflect/ComponentFactory.java 2009-06-18 10:11:14 UTC (rev 90405)
@@ -1,88 +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.reflect;
-
-// $Id$
-
-import org.jboss.osgi.blueprint.parser.xb.TBean;
-import org.jboss.osgi.blueprint.parser.xb.TComponent;
-import org.jboss.osgi.blueprint.parser.xb.TService;
-import org.jboss.osgi.blueprint.parser.xb.TServiceReference;
-import org.osgi.framework.BundleContext;
-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;
-
-/**
- * A factory for blueprint metadata objects
- *
- * @author thomas.diesler at jboss.com
- * @since 18-Jun-2009
- */
-class ComponentFactory
-{
- private BundleContext context;
- private int anonymousID;
-
- ComponentFactory(BundleContext context)
- {
- this.context = context;
- }
-
- ComponentMetadata newComponent(TComponent tComp)
- {
- ComponentMetadata comp;
-
- if (tComp.getId() == null)
- tComp.setId(".anonymousId#" + (++anonymousID));
-
- if (tComp instanceof TBean)
- comp = newBeanMetadata((TBean)tComp);
-
- else if (tComp instanceof TService)
- comp = newServiceMetadata((TService)tComp);
-
- else if (tComp instanceof TServiceReference)
- comp = newServiceReferenceMetadata((TServiceReference)tComp);
-
- else
- throw new IllegalArgumentException("Unsupported component type: " + tComp);
-
- return comp;
- }
-
- private BeanMetadata newBeanMetadata(TBean tComp)
- {
- return new BeanMetadataImpl(context, tComp);
- }
-
- private ServiceMetadata newServiceMetadata(TService tComp)
- {
- return new ServiceMetadataImpl(context, tComp);
- }
-
- private ServiceReferenceMetadata newServiceReferenceMetadata(TServiceReference tComp)
- {
- return new ServiceReferenceMetadataImpl(context, tComp);
- }
-}
More information about the jboss-cvs-commits
mailing list