diff options
Diffstat (limited to 'tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/runtime')
4 files changed, 0 insertions, 361 deletions
diff --git a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeContext.java b/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeContext.java deleted file mode 100644 index 16e1fc6483..0000000000 --- a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeContext.java +++ /dev/null @@ -1,62 +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.core.builder.WireBuilder; -import org.apache.tuscany.core.context.AutowireContext; -import org.apache.tuscany.core.context.CompositeContext; -import org.apache.tuscany.core.context.ConfigurationContext; -import org.apache.tuscany.core.context.SystemCompositeContext; - -/** - * 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 composite context containing all system components in the runtime */ - public static final String SYSTEM = "tuscany.system"; - - /* the symbolic name of the composite 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 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 - */ - public SystemCompositeContext getSystemContext(); - - /** - * Adds a wire builder to the runtime - */ - @Deprecated - public void addBuilder(WireBuilder builder); - -} diff --git a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeContextImpl.java b/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeContextImpl.java deleted file mode 100644 index 0ebc063b90..0000000000 --- a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeContextImpl.java +++ /dev/null @@ -1,221 +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.List; - -import org.apache.tuscany.common.monitor.MonitorFactory; -import org.apache.tuscany.core.builder.BuilderConfigException; -import org.apache.tuscany.core.builder.ContextFactoryBuilderRegistry; -import org.apache.tuscany.core.builder.HierarchicalWireBuilder; -import org.apache.tuscany.core.builder.WireBuilder; -import org.apache.tuscany.core.builder.impl.AssemblyVisitorImpl; -import org.apache.tuscany.core.builder.impl.ContextFactoryBuilderRegistryImpl; -import org.apache.tuscany.core.config.ConfigurationException; -import org.apache.tuscany.core.context.AutowireContext; -import org.apache.tuscany.core.context.AutowireResolutionException; -import org.apache.tuscany.core.context.CompositeContext; -import org.apache.tuscany.core.context.ConfigurationContext; -import org.apache.tuscany.core.context.Context; -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.ScopeContext; -import org.apache.tuscany.core.context.SystemCompositeContext; -import org.apache.tuscany.core.context.TargetException; -import org.apache.tuscany.core.context.impl.AbstractContext; -import org.apache.tuscany.core.context.impl.CompositeContextImpl; -import org.apache.tuscany.core.context.impl.EventContextImpl; -import org.apache.tuscany.core.system.context.SystemCompositeContextImpl; -import org.apache.tuscany.core.system.context.SystemScopeStrategy; -import org.apache.tuscany.core.wire.SourceWireFactory; -import org.apache.tuscany.core.wire.TargetWireFactory; -import org.apache.tuscany.model.assembly.AssemblyContext; -import org.apache.tuscany.model.assembly.AssemblyObject; -import org.apache.tuscany.model.assembly.Composite; -import org.apache.tuscany.model.assembly.Extensible; - -/** - * Implementation of a <code>RuntimeContext</code> that forms the foundation for a Tuscany environment. - * - * @version $Rev$ $Date$ - */ -public class RuntimeContextImpl extends AbstractContext implements RuntimeContext { - - // the top-level wire builder in the runtime - private final HierarchicalWireBuilder wireBuilder; - - //private final List<RuntimeEventListener> listeners = new ArrayList<RuntimeEventListener>(1); - - private final CompositeContext rootContext; - - private final SystemCompositeContext systemContext; - - private final MonitorFactory monitorFactory; - - private final ContextFactoryBuilderRegistryImpl builderRegistry; - - public RuntimeContextImpl(MonitorFactory monitorFactory, ContextFactoryBuilderRegistry builderRegistry, HierarchicalWireBuilder wireBuilder) { - super(RUNTIME); - this.monitorFactory = monitorFactory; - this.builderRegistry = (ContextFactoryBuilderRegistryImpl) builderRegistry; - this.wireBuilder = wireBuilder; - - rootContext = new CompositeContextImpl(ROOT, this, this, new RuntimeScopeStrategy(), new EventContextImpl(), this); - systemContext = new SystemCompositeContextImpl(SYSTEM, this, this, new SystemScopeStrategy(), new EventContextImpl(), this); - } - - 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(WireBuilder builder) { - assert (builder != null) : "Builder was null"; - wireBuilder.addWireBuilder(builder); - } - - public Context getContext(String ctxName) { - checkRunning(); - if (ROOT.equals(ctxName)) { - return rootContext; - } else if (SYSTEM.equals(ctxName)) { - return systemContext; - } - return rootContext.getContext(ctxName); - } - - public CompositeContext getRootContext() { - checkRunning(); - return rootContext; - } - - public SystemCompositeContext getSystemContext() { - checkRunning(); - return systemContext; - } - - public void registerModelObject(Extensible model) throws ConfigurationException { - assert (model != null) : "Model was null"; - // note do not configure or buildSource model object since the root context will perform a call back - rootContext.registerModelObject(model); - } - - public void registerModelObjects(List<? extends Extensible> models) throws ConfigurationException { - for (Extensible model : models) { - registerModelObject(model); - } - } - - public CompositeContext getParent() { - return null; // there is no parent - } - - public void setParent(CompositeContext parent) { - throw new UnsupportedOperationException(); - } - - public String getURI() { - return null; - } - - public void setURI(String uri) { - } - - public void setAssemblyContext(AssemblyContext context) { - - } - - //TODO remove - public void fireEvent(int pEventType, Object pMessage) throws EventException { - throw new UnsupportedOperationException(); - } - - public Object locateService(QualifiedName serviceName) { - return null; - } - - public Object locateInstance(QualifiedName serviceName) { - return null; - } - - public Object getInstance(QualifiedName qName) throws TargetException { - return getSystemContext().getInstance(qName); - } - - public synchronized void build(AssemblyObject model) throws BuilderConfigException { - AssemblyVisitorImpl visitor = new AssemblyVisitorImpl(builderRegistry.getBuilders()); - visitor.start(model); - } - - public void connect(SourceWireFactory sourceFactory, TargetWireFactory targetFactory, Class targetType, boolean downScope, - ScopeContext targetScopeContext) throws BuilderConfigException { - wireBuilder.connect(sourceFactory, targetFactory, targetType, downScope, targetScopeContext); - } - - public void completeTargetChain(TargetWireFactory targetFactory, Class targetType, ScopeContext targetScopeContext) - throws BuilderConfigException { - wireBuilder.completeTargetChain(targetFactory, targetType, targetScopeContext); - } - - 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 if (ContextFactoryBuilderRegistry.class.equals(instanceInterface)) { - return instanceInterface.cast(builderRegistry); - } else { - // autowire to system components - return instanceInterface.cast(getSystemContext().resolveExternalInstance(instanceInterface)); - } - } - - public <T> T resolveExternalInstance(Class<T> instanceInterface) throws AutowireResolutionException { - return systemContext.resolveExternalInstance(instanceInterface); - } - - public Composite getComposite() { - return systemContext.getComposite(); - } - - public void removeContext(String name) { - - } - - private void checkRunning() { - if (lifecycleState != RUNNING) { - throw new IllegalStateException("Context must be in RUNNING state"); - } - } - -} diff --git a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeMonitor.java b/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeMonitor.java deleted file mode 100644 index c1b87d6a13..0000000000 --- a/tags/java-M1-20060522/java/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-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeScopeStrategy.java b/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeScopeStrategy.java deleted file mode 100644 index 5051c2674d..0000000000 --- a/tags/java-M1-20060522/java/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 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.CompositeScopeContext; -import org.apache.tuscany.model.assembly.Scope; - -import java.util.HashMap; -import java.util.Map; - -/** - * 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> getScopeContexts(EventContext eventContext) { - ScopeContext aggregrateScope = new CompositeScopeContext(eventContext); - Map<Scope, ScopeContext> scopes = new HashMap<Scope, ScopeContext>(); - scopes.put(Scope.AGGREGATE, aggregrateScope); - return scopes; - } - -} |