diff options
Diffstat (limited to 'tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/runtime')
4 files changed, 0 insertions, 447 deletions
diff --git a/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeContext.java b/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeContext.java deleted file mode 100644 index 5bf71a09f9..0000000000 --- a/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeContext.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * - * Copyright 2005 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.runtime; - -import org.apache.tuscany.common.monitor.MonitorFactory; -import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder; -import org.apache.tuscany.core.builder.WireBuilder; -import org.apache.tuscany.core.context.AggregateContext; -import org.apache.tuscany.core.context.AutowireContext; -import org.apache.tuscany.core.context.ConfigurationContext; -import org.apache.tuscany.core.context.SystemAggregateContext; -import org.apache.tuscany.model.scdl.loader.SCDLModelLoader; - -/** - * Represents a top-level component context in the runtime, that is the bootstrap context. - * This context serves as the ultimate root of the context hierarchy. Under it are two - * separate trees: the rootContext for user components and the systemContext for - * system components (those that comprise the runtime itself). - * - * @version $Rev$ $Date$ - */ -public interface RuntimeContext extends AutowireContext, ConfigurationContext { - - /* the symbolic name of the runtime bootstrap context */ - public static final String RUNTIME = "tuscany.runtime"; - - /* the symbolic name of the aggregate context containing all system components in the runtime */ - public static final String SYSTEM = "tuscany.system"; - - /* the symbolic name of the aggregate context containing all user components in the runtime */ - public static final String ROOT = "tuscany.root"; - - /** - * 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 - */ - public AggregateContext 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 - */ - public SystemAggregateContext getSystemContext(); - - /** - * Adds a configuration builder to the runtime - */ - @Deprecated - public void addBuilder(RuntimeConfigurationBuilder builder); - - /** - * Adds a wire builder to the runtime - */ - @Deprecated - public void addBuilder(WireBuilder builder); - - /** - * Adds an SCDL model loader to the runtime - */ - @Deprecated - public void addLoader(SCDLModelLoader loader); - - /** - * Returns the monitor factory in use by the runtime - */ - @Deprecated - public MonitorFactory getMonitorFactory(); - -} diff --git a/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeContextImpl.java b/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeContextImpl.java deleted file mode 100644 index 044958b9bf..0000000000 --- a/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeContextImpl.java +++ /dev/null @@ -1,286 +0,0 @@ -/** - * - * Copyright 2005 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.runtime; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.tuscany.common.monitor.MonitorFactory; -import org.apache.tuscany.common.monitor.impl.NullMonitorFactory; -import org.apache.tuscany.core.builder.BuilderConfigException; -import org.apache.tuscany.core.builder.HierarchicalWireBuilder; -import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder; -import org.apache.tuscany.core.builder.WireBuilder; -import org.apache.tuscany.core.builder.impl.AssemblyVisitor; -import org.apache.tuscany.core.builder.impl.DefaultWireBuilder; -import org.apache.tuscany.core.config.ConfigurationException; -import org.apache.tuscany.core.context.AbstractContext; -import org.apache.tuscany.core.context.AggregateContext; -import org.apache.tuscany.core.context.AutowireContext; -import org.apache.tuscany.core.context.AutowireResolutionException; -import org.apache.tuscany.core.context.ConfigurationContext; -import org.apache.tuscany.core.context.CoreRuntimeException; -import org.apache.tuscany.core.context.EventException; -import org.apache.tuscany.core.context.QualifiedName; -import org.apache.tuscany.core.context.RuntimeEventListener; -import org.apache.tuscany.core.context.ScopeContext; -import org.apache.tuscany.core.context.SystemAggregateContext; -import org.apache.tuscany.core.context.TargetException; -import org.apache.tuscany.core.context.impl.AggregateContextImpl; -import org.apache.tuscany.core.context.impl.EventContextImpl; -import org.apache.tuscany.core.invocation.spi.ProxyFactory; -import org.apache.tuscany.core.system.context.SystemAggregateContextImpl; -import org.apache.tuscany.core.system.context.SystemScopeStrategy; -import org.apache.tuscany.model.assembly.Aggregate; -import org.apache.tuscany.model.assembly.Extensible; -import org.apache.tuscany.model.scdl.loader.SCDLModelLoader; - -/** - * Implementation of a RuntimeContext that forms the foundation for a Tuscany environment. - * - * @version $Rev$ $Date$ - */ -public class RuntimeContextImpl extends AbstractContext implements RuntimeContext { - - private final List<RuntimeConfigurationBuilder> builders; - - private final List<SCDLModelLoader> loaders; - - // the top-level wire builder in the runtime - private final HierarchicalWireBuilder wireBuilder; - - private final List<RuntimeEventListener> listeners = new ArrayList(1); - - private final AggregateContext rootContext; - - private final SystemAggregateContext systemContext; - - private final MonitorFactory monitorFactory; - - /** - * Default constructor that creates a runtime with a NullMonitorFactory and no builders. - */ - public RuntimeContextImpl() { - this(new NullMonitorFactory(), null, null, null); - } - - /** - * Constructor for creating a runtime with a specified MonitorFactory and pre-defined builders. - * - * @param monitorFactory the default {@link MonitorFactory} for this runtime - * @param builders a list of builders automatically made available; may be null - * @param wireBuilder the top-level hierarchical wire builder for the runtime; if not specified, a default - * implementation will be used - */ - public RuntimeContextImpl(MonitorFactory monitorFactory, List<SCDLModelLoader> loaders, - List<RuntimeConfigurationBuilder> builders, HierarchicalWireBuilder wireBuilder) { - super(RUNTIME); - this.monitorFactory = monitorFactory; - this.builders = (builders == null) ? new ArrayList(1) : builders; - this.loaders = (loaders == null) ? new ArrayList(1) : loaders; - this.wireBuilder = (wireBuilder == null) ? new DefaultWireBuilder() : wireBuilder; - - rootContext = new AggregateContextImpl(ROOT, this, this, new RuntimeScopeStrategy(), new EventContextImpl(), this, monitorFactory); - systemContext = new SystemAggregateContextImpl(SYSTEM, this, this, new SystemScopeStrategy(), new EventContextImpl(), this, monitorFactory); - } - - /** - * Specialized constructor that allows the default implementations of the root and system contexts to be - * overridden. - * - * @param monitorFactory the default {@link MonitorFactory} for this runtime - * @param rootContext the context to use for the root of the user context tree - * @param systemContext the context to use for the root of the system context tree - * @param builders a list of builders automatically made available; may be null - * @param wireBuilder the top-level hierarchical wire builder for the runtime; if not specified, a default - * implementation will be used - */ - public RuntimeContextImpl(MonitorFactory monitorFactory, AggregateContext rootContext, SystemAggregateContext systemContext, - List<SCDLModelLoader> loaders, List<RuntimeConfigurationBuilder> builders, HierarchicalWireBuilder wireBuilder) { - super(RUNTIME); - this.rootContext = rootContext; - this.systemContext = systemContext; - this.monitorFactory = monitorFactory; - this.loaders = (loaders == null) ? new ArrayList(1) : loaders; - this.builders = (builders == null) ? new ArrayList(1) : builders; - this.wireBuilder = (wireBuilder == null) ? new DefaultWireBuilder() : wireBuilder; - } - - public void start() throws CoreRuntimeException { - if (lifecycleState == RUNNING) { - return; - } - systemContext.start(); - rootContext.start(); - lifecycleState = RUNNING; - } - - public void stop() throws CoreRuntimeException { - if (lifecycleState == STOPPED) { - return; - } - rootContext.stop(); - systemContext.stop(); - lifecycleState = STOPPED; - } - - public void addBuilder(RuntimeConfigurationBuilder builder) { - assert (builder != null) : "Builder was null"; - builders.add(builder); - } - - public void addBuilder(WireBuilder builder) { - assert (builder != null) : "Builder was null"; - wireBuilder.addWireBuilder(builder); - } - - public void addLoader(SCDLModelLoader loader) { - assert (loader != null) : "Loader was null"; - loaders.add(loader); - } - - public AggregateContext getContext(String ctxName) { - checkRunning(); - if (ROOT.equals(ctxName)) { - return rootContext; - } else if (SYSTEM.equals(ctxName)) { - return systemContext; - } - return (AggregateContext) rootContext.getContext(ctxName); - } - - public AggregateContext getRootContext() { - checkRunning(); - return rootContext; - } - - public SystemAggregateContext getSystemContext() { - checkRunning(); - return systemContext; - } - - public MonitorFactory getMonitorFactory() { - return monitorFactory; - } - - public void registerModelObject(Extensible model) throws ConfigurationException { - assert (model != null) : "Model was null"; - // note do not configure or build model object since the root context will perform a call back - rootContext.registerModelObject(model); - } - - public void registerModelObjects(List<Extensible> models) throws ConfigurationException { - for (Extensible model : models) { - registerModelObject(model); - } - } - - public void registerListener(RuntimeEventListener listener) { - assert (listener != null) : "Listener cannot be null"; - listeners.add(listener); - } - - public void fireEvent(int eventType, Object message) throws EventException { - checkRunning(); - for (RuntimeEventListener listener : listeners) { - listener.onEvent(eventType, message); - } - } - - public AggregateContext getParent() { - return null; // there is no parent - } - - public Object locateService(String serviceName) { - return null; - } - - public Object locateInstance(String serviceName) { - return null; - } - - public Object getInstance(QualifiedName qName) throws TargetException { - return getSystemContext().getInstance(qName); - } - - public Object getInstance(QualifiedName qName, boolean notify) throws TargetException { - return getInstance(qName); - } - - // ---------------------------------- - // ConfigurationContext methods - // ---------------------------------- - - public synchronized void build(AggregateContext parent, Extensible model) throws BuilderConfigException { - AssemblyVisitor visitor = new AssemblyVisitor(parent, builders); - visitor.start(model); - } - - public void configure(Extensible model) throws ConfigurationException { - } - - public void wire(ProxyFactory sourceFactory, ProxyFactory targetFactory, Class targetType, boolean downScope, - ScopeContext targetScopeContext) throws BuilderConfigException { - wireBuilder.connect(sourceFactory, targetFactory, targetType, downScope, targetScopeContext); - } - - public void wire(ProxyFactory targetFactory, Class targetType, ScopeContext targetScopeContext) throws BuilderConfigException { - wireBuilder.completeTargetChain(targetFactory, targetType, targetScopeContext); - } - - // ---------------------------------- - // AutowireContext methods - // ---------------------------------- - - public <T> T resolveInstance(Class<T> instanceInterface) throws AutowireResolutionException { - if (MonitorFactory.class.equals(instanceInterface)) { - return instanceInterface.cast(monitorFactory); - } else if (ConfigurationContext.class.equals(instanceInterface)) { - return instanceInterface.cast(this); - } else if (AutowireContext.class.equals(instanceInterface)) { - return instanceInterface.cast(this); - } else if (RuntimeContext.class.equals(instanceInterface)) { - return instanceInterface.cast(this); - } else { - // autowire to system components - return instanceInterface.cast(getSystemContext().resolveInstance(instanceInterface)); - } - } - - // ---------------------------------- - // InstanceContext methods - // ---------------------------------- - - public Object getImplementationInstance() throws TargetException { - return this; - } - - public Object getImplementationInstance(boolean notify) throws TargetException { - return this; - } - - public Aggregate getAggregate() { - return systemContext.getAggregate(); - } - - // ---------------------------------- - // Private methods - // ---------------------------------- - - private void checkRunning() { - if (lifecycleState != RUNNING) { - throw new IllegalStateException("Context must be in RUNNING state"); - } - } -} diff --git a/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeMonitor.java b/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeMonitor.java deleted file mode 100644 index c1b87d6a13..0000000000 --- a/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeMonitor.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * - * Copyright 2005 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.runtime; - -import org.apache.tuscany.common.TuscanyException; -import org.apache.tuscany.common.TuscanyRuntimeException; - - -/** - * Serves as a top-level error logging monitor - * - * @version $Rev$ $Date$ - */ -public interface RuntimeMonitor { - - public void log(TuscanyRuntimeException e); - - public void log(TuscanyException e); - -} - diff --git a/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeScopeStrategy.java b/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeScopeStrategy.java deleted file mode 100644 index 77ddd78d15..0000000000 --- a/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeScopeStrategy.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * - * Copyright 2005 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.runtime; - -import java.util.HashMap; -import java.util.Map; - -import org.apache.tuscany.core.context.EventContext; -import org.apache.tuscany.core.context.ScopeContext; -import org.apache.tuscany.core.context.scope.AbstractScopeStrategy; -import org.apache.tuscany.core.context.scope.AggregateScopeContext; -import org.apache.tuscany.model.assembly.Scope; - -/** - * Implements a {@link org.apache.tuscany.core.context.ScopeStrategy} for a runtime context. Specifically, a runtime - * context has only one scope, {@link org.apache.tuscany.model.assembly.Scope#AGGREGATE} - * - * @version $Rev$ $Date$ - */ -public class RuntimeScopeStrategy extends AbstractScopeStrategy { - - public RuntimeScopeStrategy() { - } - - public Map<Scope, ScopeContext> createScopes(EventContext eventContext) { - ScopeContext aggregrateScope = new AggregateScopeContext(eventContext); - Map<Scope, ScopeContext> scopes = new HashMap(); - scopes.put(Scope.AGGREGATE, aggregrateScope); - return scopes; - } - -} |