You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by me...@apache.org on 2007/01/06 15:25:08 UTC
svn commit: r493478 - in /incubator/tuscany/java/sca/kernel/core/src:
main/java/org/apache/tuscany/core/bootstrap/
main/java/org/apache/tuscany/core/builder/
main/java/org/apache/tuscany/core/launcher/
test/java/org/apache/tuscany/core/bootstrap/ test/...
Author: meerajk
Date: Sat Jan 6 06:25:07 2007
New Revision: 493478
URL: http://svn.apache.org/viewvc?view=rev&rev=493478
Log:
Modified builder registry and default bootstrapper to
accept the primodila management service.
Modified:
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/bootstrap/DefaultBootstrapper.java
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/BuilderRegistryImpl.java
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/launcher/LauncherImpl.java
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/bootstrap/BootstrapperTestCase.java
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/BuilderRegistryTestCase.java
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/deployer/BootstrapDeployerTestCase.java
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeBuilderTestCase.java
Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/bootstrap/DefaultBootstrapper.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/bootstrap/DefaultBootstrapper.java?view=diff&rev=493478&r1=493477&r2=493478
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/bootstrap/DefaultBootstrapper.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/bootstrap/DefaultBootstrapper.java Sat Jan 6 06:25:07 2007
@@ -35,6 +35,7 @@
import org.apache.tuscany.spi.implementation.java.Introspector;
import org.apache.tuscany.spi.loader.LoaderRegistry;
import org.apache.tuscany.spi.loader.PropertyObjectFactory;
+import org.apache.tuscany.spi.services.management.ManagementService;
import org.apache.tuscany.core.builder.BuilderRegistryImpl;
import org.apache.tuscany.core.builder.ConnectorImpl;
@@ -81,29 +82,36 @@
import org.apache.tuscany.host.MonitorFactory;
/**
- * A default implementation of a Bootstrapper. Please see the documentation on the individual methods for how the
- * primordial components are created.
- *
+ * A default implementation of a Bootstrapper. Please see the documentation on
+ * the individual methods for how the primordial components are created.
+ *
* @version $Rev$ $Date$
*/
public class DefaultBootstrapper implements Bootstrapper {
private final MonitorFactory monitorFactory;
private final XMLInputFactory xmlFactory;
+ private final ManagementService managementService;
/**
* Create a default bootstrapper.
- *
- * @param monitorFactory the MonitorFactory to be used to create monitors for the primordial components
- * @param xmlFactory the XMLInputFactory to be used by the components to load XML artifacts
- */
- public DefaultBootstrapper(MonitorFactory monitorFactory, XMLInputFactory xmlFactory) {
+ *
+ * @param monitorFactory the MonitorFactory to be used to create monitors
+ * for the primordial components
+ * @param xmlFactory the XMLInputFactory to be used by the components to
+ * load XML artifacts
+ * @param managementService management service used by the runtime.
+ */
+ public DefaultBootstrapper(MonitorFactory monitorFactory,
+ XMLInputFactory xmlFactory,
+ ManagementService managementService) {
this.monitorFactory = monitorFactory;
this.xmlFactory = xmlFactory;
+ this.managementService = managementService;
}
/**
* Returns the MonitorFactory being used by this bootstrapper.
- *
+ *
* @return the MonitorFactory being used by this bootstrapper
*/
public MonitorFactory getMonitorFactory() {
@@ -111,9 +119,11 @@
}
/**
- * Create the RuntimeComponent that will form the root of the component tree. Returns an new instance of a {@link
- * DefaultRuntime} with the system and application root components initialized with default composite components.
- *
+ * Create the RuntimeComponent that will form the root of the component
+ * tree. Returns an new instance of a {@link DefaultRuntime} with the system
+ * and application root components initialized with default composite
+ * components.
+ *
* @return a newly created root for the component tree
*/
public RuntimeComponent createRuntime() {
@@ -128,8 +138,9 @@
}
/**
- * Create primordial deployer that can be used to load the system definition.
- *
+ * Create primordial deployer that can be used to load the system
+ * definition.
+ *
* @return the primordial deployer
*/
public Deployer createDeployer() {
@@ -142,9 +153,10 @@
}
/**
- * Create a basic ScopeRegistry containing the ScopeContainers that are available to components in the system
- * definition. The implementation returned only support COMPOSITE scope.
- *
+ * Create a basic ScopeRegistry containing the ScopeContainers that are
+ * available to components in the system definition. The implementation
+ * returned only support COMPOSITE scope.
+ *
* @param workContext the WorkContext the scopes should use
* @return a new ScopeRegistry
*/
@@ -155,15 +167,32 @@
}
/**
- * Create a Loader that can be used to parse an XML file containing the SCDL for the system definition. The
- * following Implementation types are supported: <ul> <li>SystemImplementation</li>
- * <li>SystemCompositeImplementation</li> </ul> and the following SCDL elements are supported: <ul>
- * <li>composite</li> <li>component</li> <li>componentType</li> <li>interface.java</li> <li>property</li>
- * <li>reference</li> <li>service</li> <li>implementation.system</li> <li>binding.system</li> </ul> Note the Java
- * component type and the WSDL interface type are not supported.
- *
- * @param propertyFactory the StAXPropertyFactory to be used for parsing Property values
- * @param introspector the Introspector to be used to inspect component implementations
+ * Create a Loader that can be used to parse an XML file containing the SCDL
+ * for the system definition. The following Implementation types are
+ * supported:
+ * <ul>
+ * <li>SystemImplementation</li>
+ * <li>SystemCompositeImplementation</li>
+ * </ul>
+ * and the following SCDL elements are supported:
+ * <ul>
+ * <li>composite</li>
+ * <li>component</li>
+ * <li>componentType</li>
+ * <li>interface.java</li>
+ * <li>property</li>
+ * <li>reference</li>
+ * <li>service</li>
+ * <li>implementation.system</li>
+ * <li>binding.system</li>
+ * </ul>
+ * Note the Java component type and the WSDL interface type are not
+ * supported.
+ *
+ * @param propertyFactory the StAXPropertyFactory to be used for parsing
+ * Property values
+ * @param introspector the Introspector to be used to inspect component
+ * implementations
* @return a new StAX XML loader
*/
public LoaderRegistry createLoader(PropertyObjectFactory propertyFactory, Introspector introspector) {
@@ -171,10 +200,9 @@
new LoaderRegistryImpl(monitorFactory.getMonitor(LoaderRegistryImpl.Monitor.class));
// register component type loaders
- loaderRegistry.registerLoader(SystemImplementation.class,
- new SystemComponentTypeLoader(introspector));
+ loaderRegistry.registerLoader(SystemImplementation.class, new SystemComponentTypeLoader(introspector));
loaderRegistry.registerLoader(SystemCompositeImplementation.class,
- new SystemCompositeComponentTypeLoader(loaderRegistry));
+ new SystemCompositeComponentTypeLoader(loaderRegistry));
// register element loaders
registerLoader(loaderRegistry, new ComponentLoader(loaderRegistry, propertyFactory));
@@ -182,7 +210,7 @@
registerLoader(loaderRegistry, new CompositeLoader(loaderRegistry, null));
registerLoader(loaderRegistry, new IncludeLoader(loaderRegistry));
registerLoader(loaderRegistry,
- new InterfaceJavaLoader(loaderRegistry, new JavaInterfaceProcessorRegistryImpl()));
+ new InterfaceJavaLoader(loaderRegistry, new JavaInterfaceProcessorRegistryImpl()));
registerLoader(loaderRegistry, new PropertyLoader(loaderRegistry));
registerLoader(loaderRegistry, new ReferenceLoader(loaderRegistry));
registerLoader(loaderRegistry, new ServiceLoader(loaderRegistry));
@@ -192,8 +220,9 @@
}
/**
- * Create new Introspector for extracting a ComponentType definition from a Java class.
- *
+ * Create new Introspector for extracting a ComponentType definition from a
+ * Java class.
+ *
* @return a new Introspector
*/
public Introspector createIntrospector(JavaInterfaceProcessorRegistry registry) {
@@ -215,8 +244,9 @@
}
/**
- * Create a new Connector that can be used to wire primordial components together.
- *
+ * Create a new Connector that can be used to wire primordial components
+ * together.
+ *
* @return a new Connector
*/
public Connector createConnector() {
@@ -224,25 +254,29 @@
}
/**
- * Helper method for registering a loader with the registry. The Loader is registered once for the QName returned by
- * its {@link LoaderExtension#getXMLType()} method.
- *
+ * Helper method for registering a loader with the registry. The Loader is
+ * registered once for the QName returned by its
+ * {@link LoaderExtension#getXMLType()} method.
+ *
* @param registry the LoaderRegistry to register with
- * @param loader the Loader to register
+ * @param loader the Loader to register
*/
protected void registerLoader(LoaderRegistry registry, LoaderExtension<?> loader) {
registry.registerLoader(loader.getXMLType(), loader);
}
/**
- * Create a Builder that can be used to build the components in the system definition. The default implementation
- * only supports implementations from the system programming model.
- *
- * @param scopeRegistry the ScopeRegistry defining the component scopes that will be supported
+ * Create a Builder that can be used to build the components in the system
+ * definition. The default implementation only supports implementations from
+ * the system programming model.
+ *
+ * @param scopeRegistry the ScopeRegistry defining the component scopes that
+ * will be supported
* @return a new Builder
*/
private Builder createBuilder(ScopeRegistry scopeRegistry) {
- BuilderRegistryImpl builderRegistry = new BuilderRegistryImpl(scopeRegistry, new JDKWireService());
+ BuilderRegistryImpl builderRegistry =
+ new BuilderRegistryImpl(scopeRegistry, new JDKWireService(), managementService);
SystemCompositeBuilder builder = new SystemCompositeBuilder(builderRegistry, createConnector());
builderRegistry.register(SystemCompositeImplementation.class, builder);
builderRegistry.register(SystemImplementation.class, new SystemComponentBuilder());
@@ -250,4 +284,4 @@
return builderRegistry;
}
-}
\ No newline at end of file
+}
Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/BuilderRegistryImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/BuilderRegistryImpl.java?view=diff&rev=493478&r1=493477&r2=493478
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/BuilderRegistryImpl.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/BuilderRegistryImpl.java Sat Jan 6 06:25:07 2007
@@ -47,6 +47,7 @@
import org.apache.tuscany.spi.model.ComponentType;
import org.apache.tuscany.spi.model.Implementation;
import org.apache.tuscany.spi.model.ServiceContract;
+import org.apache.tuscany.spi.services.management.ManagementService;
import org.apache.tuscany.spi.wire.WireService;
import org.apache.tuscany.core.implementation.composite.ReferenceImpl;
@@ -61,17 +62,20 @@
public class BuilderRegistryImpl implements BuilderRegistry {
protected WireService wireService;
protected ScopeRegistry scopeRegistry;
+ private ManagementService managementService;
- private final Map<Class<? extends Implementation<?>>,
- ComponentBuilder<? extends Implementation<?>>> componentBuilders =
+ private final Map<Class<? extends Implementation<?>>, ComponentBuilder<? extends Implementation<?>>> componentBuilders =
new HashMap<Class<? extends Implementation<?>>, ComponentBuilder<? extends Implementation<?>>>();
- private final Map<Class<? extends BindingDefinition>,
- BindingBuilder<? extends BindingDefinition>> bindingBuilders =
+ private final Map<Class<? extends BindingDefinition>, BindingBuilder<? extends BindingDefinition>> bindingBuilders =
new HashMap<Class<? extends BindingDefinition>, BindingBuilder<? extends BindingDefinition>>();
- public BuilderRegistryImpl(@Autowire ScopeRegistry scopeRegistry, @Autowire WireService wireService) {
+ public BuilderRegistryImpl(@Autowire
+ ScopeRegistry scopeRegistry, @Autowire
+ WireService wireService, @Autowire
+ ManagementService managementService) {
this.scopeRegistry = scopeRegistry;
this.wireService = wireService;
+ this.managementService = managementService;
}
public <I extends Implementation<?>> void register(Class<I> implClass, ComponentBuilder<I> builder) {
@@ -92,7 +96,7 @@
DeploymentContext context) throws BuilderException {
Class<?> implClass = componentDefinition.getImplementation().getClass();
//noinspection SuspiciousMethodCalls
- ComponentBuilder<I> componentBuilder = (ComponentBuilder<I>) componentBuilders.get(implClass);
+ ComponentBuilder<I> componentBuilder = (ComponentBuilder<I>)componentBuilders.get(implClass);
try {
if (componentBuilder == null) {
String name = implClass.getName();
@@ -103,11 +107,14 @@
if (component != null) {
component.setDefaultPropertyValues(componentDefinition.getPropertyValues());
}
+ if (managementService != null && component instanceof CompositeComponent) {
+ ((CompositeComponent)component).setManagementService(managementService);
+ }
ComponentType<?, ?, ?> componentType = componentDefinition.getImplementation().getComponentType();
assert componentType != null : "Component type must be set";
// create wires for the component
if (wireService != null && component instanceof AtomicComponent) {
- wireService.createWires((AtomicComponent) component, componentDefinition);
+ wireService.createWires((AtomicComponent)component, componentDefinition);
}
return component;
} catch (BuilderException e) {
Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/launcher/LauncherImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/launcher/LauncherImpl.java?view=diff&rev=493478&r1=493477&r2=493478
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/launcher/LauncherImpl.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/launcher/LauncherImpl.java Sat Jan 6 06:25:07 2007
@@ -35,6 +35,7 @@
import org.apache.tuscany.spi.loader.LoaderException;
import org.apache.tuscany.spi.model.ComponentDefinition;
import org.apache.tuscany.spi.model.CompositeImplementation;
+import org.apache.tuscany.spi.services.management.ManagementService;
import org.apache.tuscany.api.TuscanyException;
import org.apache.tuscany.core.bootstrap.Bootstrapper;
@@ -79,7 +80,8 @@
}
XMLInputFactory xmlFactory = XMLInputFactory.newInstance("javax.xml.stream.XMLInputFactory", systemClassLoader);
- Bootstrapper bootstrapper = new DefaultBootstrapper(monitor, xmlFactory);
+ ManagementService managementService = null;
+ Bootstrapper bootstrapper = new DefaultBootstrapper(monitor, xmlFactory, managementService);
Deployer bootDeployer = bootstrapper.createDeployer();
// create and start the core runtime
Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/bootstrap/BootstrapperTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/bootstrap/BootstrapperTestCase.java?view=diff&rev=493478&r1=493477&r2=493478
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/bootstrap/BootstrapperTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/bootstrap/BootstrapperTestCase.java Sat Jan 6 06:25:07 2007
@@ -37,6 +37,6 @@
protected void setUp() throws Exception {
super.setUp();
- bootstrapper = new DefaultBootstrapper(new NullMonitorFactory(), null);
+ bootstrapper = new DefaultBootstrapper(new NullMonitorFactory(), null, null);
}
}
Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/BuilderRegistryTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/BuilderRegistryTestCase.java?view=diff&rev=493478&r1=493477&r2=493478
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/BuilderRegistryTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/BuilderRegistryTestCase.java Sat Jan 6 06:25:07 2007
@@ -61,7 +61,7 @@
public void testRegistration() throws Exception {
MockBuilder builder = new MockBuilder();
- BuilderRegistry registry = new BuilderRegistryImpl(null, null);
+ BuilderRegistry registry = new BuilderRegistryImpl(null, null, null);
registry.register(CompositeImplementation.class, builder);
CompositeImplementation implementation = new CompositeImplementation();
ComponentDefinition<CompositeImplementation> componentDefinition =
@@ -78,7 +78,7 @@
);
EasyMock.expectLastCall().times(2);
EasyMock.replay(wireService);
- BuilderRegistry registry = new BuilderRegistryImpl(null, wireService);
+ BuilderRegistry registry = new BuilderRegistryImpl(null, wireService, null);
ServiceBinding binding = EasyMock.createNiceMock(ServiceBinding.class);
EasyMock.replay(binding);
BindingBuilder<MockBindingDefinition> builder = EasyMock.createMock(BindingBuilder.class);
@@ -105,7 +105,7 @@
);
EasyMock.expectLastCall().times(2);
EasyMock.replay(wireService);
- BuilderRegistry registry = new BuilderRegistryImpl(null, wireService);
+ BuilderRegistry registry = new BuilderRegistryImpl(null, wireService, null);
ReferenceBinding binding = EasyMock.createNiceMock(ReferenceBinding.class);
EasyMock.replay(binding);
BindingBuilder<MockBindingDefinition> builder = EasyMock.createMock(BindingBuilder.class);
@@ -130,7 +130,7 @@
wireService.createWires(EasyMock.isA(AtomicComponent.class),
EasyMock.isA(ComponentDefinition.class));
EasyMock.replay(wireService);
- BuilderRegistry registry = new BuilderRegistryImpl(null, wireService);
+ BuilderRegistry registry = new BuilderRegistryImpl(null, wireService, null);
AtomicComponent component = EasyMock.createNiceMock(AtomicComponent.class);
EasyMock.replay(component);
Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/deployer/BootstrapDeployerTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/deployer/BootstrapDeployerTestCase.java?view=diff&rev=493478&r1=493477&r2=493478
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/deployer/BootstrapDeployerTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/deployer/BootstrapDeployerTestCase.java Sat Jan 6 06:25:07 2007
@@ -161,7 +161,7 @@
protected void setUp() throws Exception {
super.setUp();
XMLInputFactory xmlFactory = XMLInputFactory.newInstance();
- Bootstrapper bootstrapper = new DefaultBootstrapper(new NullMonitorFactory(), xmlFactory);
+ Bootstrapper bootstrapper = new DefaultBootstrapper(new NullMonitorFactory(), xmlFactory, null);
deployer = (DeployerImpl) bootstrapper.createDeployer();
deploymentContext = new RootDeploymentContext(null, xmlFactory, null, null);
implementation = new SystemCompositeImplementation();
Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeBuilderTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeBuilderTestCase.java?view=diff&rev=493478&r1=493477&r2=493478
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeBuilderTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeBuilderTestCase.java Sat Jan 6 06:25:07 2007
@@ -72,7 +72,7 @@
CompositeBuilder builder = new CompositeBuilder();
WireService wireService = new JDKWireService();
builder.setWireService(wireService);
- BuilderRegistryImpl builderRegistry = new BuilderRegistryImpl(null, wireService);
+ BuilderRegistryImpl builderRegistry = new BuilderRegistryImpl(null, wireService, null);
JavaComponentBuilder jBuilder = new JavaComponentBuilder();
jBuilder.setWireService(wireService);
builderRegistry.register(JavaImplementation.class, jBuilder);
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org