You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by jb...@apache.org on 2006/05/22 18:31:38 UTC
svn commit: r408705 - in /incubator/tuscany/sandbox/jboynes/sca:
core2/src/main/java/org/apache/tuscany/core/bootstrap/
core2/src/main/java/org/apache/tuscany/core/builder/
core2/src/main/java/org/apache/tuscany/core/deployer/
core2/src/test/java/org/a...
Author: jboynes
Date: Mon May 22 09:31:38 2006
New Revision: 408705
URL: http://svn.apache.org/viewvc?rev=408705&view=rev
Log:
start of deployer/bootstrap
Added:
incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/bootstrap/
incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/bootstrap/DefaultBootstrapper.java (with props)
incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/bootstrap/DefaultRuntime.java (with props)
incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/deployer/
incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/deployer/DeployerImpl.java (with props)
incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/bootstrap/
incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/bootstrap/BootstrapperTestCase.java (with props)
incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/bootstrap/
incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/bootstrap/ContextNames.java (with props)
incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/bootstrap/RuntimeContext.java (with props)
incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/deployer/
incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/deployer/Deployer.java (with props)
Modified:
incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/builder/BuilderRegistryImpl.java
Added: incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/bootstrap/DefaultBootstrapper.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/bootstrap/DefaultBootstrapper.java?rev=408705&view=auto
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/bootstrap/DefaultBootstrapper.java (added)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/bootstrap/DefaultBootstrapper.java Mon May 22 09:31:38 2006
@@ -0,0 +1,44 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation or its licensors as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.core.bootstrap;
+
+import org.apache.tuscany.core.builder.BuilderRegistryImpl;
+import org.apache.tuscany.model.Component;
+import org.apache.tuscany.model.CompositeImplementation;
+import org.apache.tuscany.spi.builder.BuilderRegistry;
+import org.apache.tuscany.spi.context.CompositeContext;
+import org.apache.tuscany.spi.context.Context;
+import org.apache.tuscany.spi.deployer.Deployer;
+import org.apache.tuscany.spi.bootstrap.ContextNames;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class DefaultBootstrapper {
+ private final BuilderRegistry builderRegistry;
+
+ public DefaultBootstrapper() {
+ builderRegistry = new BuilderRegistryImpl();
+ }
+
+ public Context<Deployer> createDeployer(CompositeContext<?> parent) {
+ CompositeImplementation impl = new CompositeImplementation();
+ Component<CompositeImplementation> deployerComposite = new Component<CompositeImplementation>(impl);
+ deployerComposite.setName(ContextNames.TUSCANY_DEPLOYER);
+ return builderRegistry.build(parent, deployerComposite);
+ }
+}
Propchange: incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/bootstrap/DefaultBootstrapper.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/bootstrap/DefaultBootstrapper.java
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/bootstrap/DefaultRuntime.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/bootstrap/DefaultRuntime.java?rev=408705&view=auto
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/bootstrap/DefaultRuntime.java (added)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/bootstrap/DefaultRuntime.java Mon May 22 09:31:38 2006
@@ -0,0 +1,50 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation or its licensors as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.core.bootstrap;
+
+import org.apache.tuscany.core.system.context.SystemCompositeContext;
+import org.apache.tuscany.core.system.context.SystemCompositeContextImpl;
+import org.apache.tuscany.spi.bootstrap.RuntimeContext;
+import org.apache.tuscany.spi.context.CompositeContext;
+import org.apache.tuscany.spi.deployer.Deployer;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class DefaultRuntime extends SystemCompositeContextImpl<Void> implements RuntimeContext<SystemCompositeContext> {
+ private final CompositeContext rootContext;
+ private final SystemCompositeContext systemContext;
+ private final Deployer deployer;
+
+ public DefaultRuntime(SystemCompositeContext systemContext, CompositeContext rootContext) {
+ this.systemContext = systemContext;
+ this.rootContext = rootContext;
+ deployer = null;
+ }
+
+ public CompositeContext getRootContext() {
+ return rootContext;
+ }
+
+ public SystemCompositeContext getSystemContext() {
+ return systemContext;
+ }
+
+ public Deployer getDeployer() {
+ return deployer;
+ }
+}
Propchange: incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/bootstrap/DefaultRuntime.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/bootstrap/DefaultRuntime.java
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Modified: incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/builder/BuilderRegistryImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/builder/BuilderRegistryImpl.java?rev=408705&r1=408704&r2=408705&view=diff
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/builder/BuilderRegistryImpl.java (original)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/builder/BuilderRegistryImpl.java Mon May 22 09:31:38 2006
@@ -91,6 +91,12 @@
public <I extends Implementation<?>> Context build(CompositeContext parent, Component<I> component) {
Class<I> implClass = (Class<I>) component.getImplementation().getClass();
ComponentBuilder<I> componentBuilder = (ComponentBuilder<I>) componentBuilders.get(implClass);
+ if (componentBuilder == null) {
+ BuilderConfigException e = new BuilderConfigException("No builder registered for implementation");
+ e.setIdentifier(implClass.getName());
+ e.addContextName(component.getName());
+ throw e;
+ }
ComponentContext context = componentBuilder.build(parent, component);
ComponentType componentType = component.getImplementation().getComponentType();
Added: incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/deployer/DeployerImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/deployer/DeployerImpl.java?rev=408705&view=auto
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/deployer/DeployerImpl.java (added)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/deployer/DeployerImpl.java Mon May 22 09:31:38 2006
@@ -0,0 +1,73 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation or its licensors as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.core.deployer;
+
+import org.apache.tuscany.model.Component;
+import org.apache.tuscany.model.Implementation;
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.builder.BuilderRegistry;
+import org.apache.tuscany.spi.context.CompositeContext;
+import org.apache.tuscany.spi.context.Context;
+import org.apache.tuscany.spi.deployer.Deployer;
+import org.apache.tuscany.spi.loader.LoaderRegistry;
+
+/**
+ * Default implementation of Deployer.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DeployerImpl implements Deployer {
+ private LoaderRegistry loaderRegistry;
+ private BuilderRegistry builderRegistry;
+
+ @Autowire
+ public void setLoaderRegistry(LoaderRegistry loaderRegistry) {
+ this.loaderRegistry = loaderRegistry;
+ }
+
+ @Autowire
+ public void setBuilderRegistry(BuilderRegistry builderRegistry) {
+ this.builderRegistry = builderRegistry;
+ }
+
+ public <I extends Implementation<?>> void deploy(CompositeContext<?> parent, Component<I> component) {
+ load(component);
+ Context<?> context = build(parent, component);
+ parent.registerContext(context);
+ }
+
+ /**
+ * Load the component type information for the component being deployed.
+ * For a typical deployment this will result in the SCDL definition being loaded.
+ *
+ * @param component the component being deployed
+ */
+ protected <I extends Implementation<?>> void load(Component<I> component) {
+ loaderRegistry.loadComponentType(component.getImplementation());
+ }
+
+ /**
+ * Build the runtime context for a loaded component.
+ *
+ * @param parent the context that will be the parent of the new sub-context
+ * @param component the component being deployed
+ * @return the new runtime context
+ */
+ protected <I extends Implementation<?>> Context<?> build(CompositeContext<?> parent, Component<I> component) {
+ return builderRegistry.build(parent, component);
+ }
+}
Propchange: incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/deployer/DeployerImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/deployer/DeployerImpl.java
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/bootstrap/BootstrapperTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/bootstrap/BootstrapperTestCase.java?rev=408705&view=auto
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/bootstrap/BootstrapperTestCase.java (added)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/bootstrap/BootstrapperTestCase.java Mon May 22 09:31:38 2006
@@ -0,0 +1,47 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation or its licensors as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.core.bootstrap;
+
+import junit.framework.TestCase;
+import org.apache.tuscany.core.system.context.SystemCompositeContext;
+import org.apache.tuscany.spi.deployer.Deployer;
+
+/**
+ * // TODO the implementation needs a Composite builder which we don't have yet
+ *
+ * @version $Rev$ $Date$
+ */
+public class BootstrapperTestCase extends TestCase {
+ private DefaultBootstrapper bootstrapper;
+
+ public void testDeployerBootstrap() {
+/*
+ SystemCompositeContext<Deployer> context = (SystemCompositeContext<Deployer>) bootstrapper.createDeployer(null);
+ assertEquals("tuscany.deployer", context.getName());
+ // todo this should work
+// Deployer deployer = context.getService();
+// assertNotNull(deployer);
+ Deployer deployer = context.resolveExternalInstance(Deployer.class);
+ assertNotNull(deployer);
+*/
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ bootstrapper = new DefaultBootstrapper();
+ }
+}
Propchange: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/bootstrap/BootstrapperTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/bootstrap/BootstrapperTestCase.java
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/bootstrap/ContextNames.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/bootstrap/ContextNames.java?rev=408705&view=auto
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/bootstrap/ContextNames.java (added)
+++ incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/bootstrap/ContextNames.java Mon May 22 09:31:38 2006
@@ -0,0 +1,42 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation or its licensors as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.spi.bootstrap;
+
+/**
+ * Class that defines the names of well known contexts.
+ *
+ * @version $Rev$ $Date$
+ */
+public final class ContextNames {
+ private ContextNames() {
+ }
+
+ /**
+ * The name of the context that forms the root of the application context tree.
+ */
+ public static final String TUSCANY_ROOT = "tuscany.root";
+
+ /**
+ * The name of the context that form the root of the system context tree.
+ */
+ public static final String TUSCANY_SYSTEM = "tuscany.system";
+
+ /**
+ * The name of the context that contains the deployer.
+ */
+ public static final String TUSCANY_DEPLOYER = "tuscany.deployer";
+}
Propchange: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/bootstrap/ContextNames.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/bootstrap/ContextNames.java
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/bootstrap/RuntimeContext.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/bootstrap/RuntimeContext.java?rev=408705&view=auto
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/bootstrap/RuntimeContext.java (added)
+++ incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/bootstrap/RuntimeContext.java Mon May 22 09:31:38 2006
@@ -0,0 +1,52 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation or its licensors as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.spi.bootstrap;
+
+import org.apache.tuscany.spi.context.CompositeContext;
+import org.apache.tuscany.spi.deployer.Deployer;
+
+/**
+ * Interface that represents the Tuscany runtime.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface RuntimeContext<S extends CompositeContext> extends CompositeContext<Void> {
+ /**
+ * Returns the context that forms the root of the user component tree.
+ * All user components will managed by contexts that are children of this root.
+ *
+ * @return the root of the user component tree
+ */
+ CompositeContext getRootContext();
+
+ /**
+ * Returns the context that forms the root of the system component tree.
+ * All system components, components that provide system services needed by the
+ * Tuscany runtime itself, will be managed by contexts that are children of this root.
+ *
+ * @return the root of the system component tree
+ */
+ S getSystemContext();
+
+ /**
+ * Returns the deployer for this runtime.
+ * This interface can be used to deploy new SCA bundles to the runtime.
+ *
+ * @return the deployer for this runtime
+ */
+ Deployer getDeployer();
+}
Propchange: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/bootstrap/RuntimeContext.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/bootstrap/RuntimeContext.java
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Added: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/deployer/Deployer.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/deployer/Deployer.java?rev=408705&view=auto
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/deployer/Deployer.java (added)
+++ incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/deployer/Deployer.java Mon May 22 09:31:38 2006
@@ -0,0 +1,38 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation or its licensors as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tuscany.spi.deployer;
+
+import java.net.URL;
+
+import org.apache.tuscany.spi.context.CompositeContext;
+import org.apache.tuscany.model.Component;
+import org.apache.tuscany.model.Implementation;
+
+/**
+ * Interface that can be used to deploy SCA bundles to a runtime.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Deployer {
+ /**
+ * Deploy a component as a child of the supplied parent.
+ *
+ * @param parent the parent context
+ * @param component the component definition
+ */
+ <I extends Implementation<?>> void deploy(CompositeContext<?> parent, Component<I> component);
+}
Propchange: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/deployer/Deployer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/jboynes/sca/spi/src/main/java/org/apache/tuscany/spi/deployer/Deployer.java
------------------------------------------------------------------------------
svn:keywords = Rev,Date
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org