diff options
Diffstat (limited to 'tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context')
66 files changed, 0 insertions, 4626 deletions
diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/AtomicContext.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/AtomicContext.java deleted file mode 100644 index 7d4b990ab5..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/AtomicContext.java +++ /dev/null @@ -1,55 +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.context; - -/** - * A runtime entity that manages an atomic (i.e. leaf-type) artifact. - * - * @version $Rev$ $Date$ - */ -public interface AtomicContext extends Context { - - /** - * Returns whether the context should be eagerly initialized - */ - public boolean isEagerInit(); - - /** - * Notifies the context of an initialization event - * @throws TargetException - */ - public void init() throws TargetException; - - /** - * Notifies the context of a destroy event - * @throws TargetException - */ - public void destroy() throws TargetException; - - /** - * Returns whether the context should be called back when its scope ends - */ - public boolean isDestroyable(); - - /** - * Returns the target instance associated with the context. A target instance is the actual - * object a request is dispatched to sans proxy wire chain. - * @throws TargetException - */ - public Object getTargetInstance() throws TargetException; - -} diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/AutowireContext.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/AutowireContext.java deleted file mode 100644 index 7fa459e76d..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/AutowireContext.java +++ /dev/null @@ -1,47 +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.context; - -/** - * A specialization of a CompositeContext that is able to automatically resolve references - * for its children using EntryPoint or Service interfaces exposed by it or, recursively, any - * of it parents. - * - * @version $Rev$ $Date$ - */ -public interface AutowireContext extends CompositeContext { - - /** - * Invoked by child contexts to return an an autowire target. Resolved targets may be entry points or - * components in the parent or its ancestors, or entry points in a sibling context - * - * @param instanceInterface the type of service being requested - * @return a reference to the requested service or null if none can be found - * @throws AutowireResolutionException if an error occurs attempting to resolve an autowire - */ - <T> T resolveInstance(Class<T> instanceInterface) throws AutowireResolutionException; - - /** - * Invoked by a parent context to return an autowire target in a child. Resolved targets must be entry points. - * For example, given a parent P and two siblings, A and B, A would request an autowire by invoking - * {@link #resolveInstance(Class<T>)} on P, which in turn could invoke the present method on B in order to resolve - * a target. - * - * @param instanceInterface the type of service being requested - * @return a reference to the requested service or null if none can be found - * @throws AutowireResolutionException if an error occurs attempting to resolve an autowire - */ - <T> T resolveExternalInstance(Class<T> instanceInterface) throws AutowireResolutionException; - -} diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/AutowireResolutionException.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/AutowireResolutionException.java deleted file mode 100644 index 4da4206a94..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/AutowireResolutionException.java +++ /dev/null @@ -1,40 +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.context; - -/** - * Denotes an exception while resolving an automatic wire - * - * @version $Rev$ $Date$ - */ -public class AutowireResolutionException extends TargetException { - - public AutowireResolutionException() { - super(); - } - - public AutowireResolutionException(String message) { - super(message); - } - - public AutowireResolutionException(String message, Throwable cause) { - super(message, cause); - } - - public AutowireResolutionException(Throwable cause) { - super(cause); - } - -} - diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/CompositeContext.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/CompositeContext.java deleted file mode 100644 index abd23feb38..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/CompositeContext.java +++ /dev/null @@ -1,91 +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.context; - -import org.apache.tuscany.core.config.ConfigurationException; -import org.apache.tuscany.model.assembly.Composite; -import org.apache.tuscany.model.assembly.Part; -import org.apache.tuscany.model.assembly.Extensible; -import org.apache.tuscany.model.assembly.AssemblyContext; - -import java.util.List; - -/** - * A context which contains child component contexts. - * - * @version $Rev$ $Date$ - */ -public interface CompositeContext extends Context { - - public String getURI(); - - public void setURI(String uri); - - /** - * TODO remove this method - * @deprecated - */ - public void setAssemblyContext(AssemblyContext context); - - /** - * Returns the parent context, or null if the context does not have one - */ - public CompositeContext getParent(); - - /** - * Sets the parent context - */ - public void setParent(CompositeContext parent); - - /** - * Adds runtime artifacts represented by the set of model objects to the composite context by merging them with - * existing artifacts. Implementing classes may support only a subset of {@link Part} types. - * - * @see org.apache.tuscany.model.assembly.Component - * @see org.apache.tuscany.model.assembly.ModuleComponent - * @see org.apache.tuscany.model.assembly.AtomicComponent - * @see org.apache.tuscany.model.assembly.EntryPoint - * @see org.apache.tuscany.model.assembly.ExternalService - */ - public void registerModelObjects(List<? extends Extensible> models) throws ConfigurationException; - - /** - * Adds a runtime artifact represented by the model object to the composite context by merging it with existing - * artifacts. Implementing classes may support only a subset of {@link Part} types. - * - * @see org.apache.tuscany.model.assembly.Component - * @see org.apache.tuscany.model.assembly.ModuleComponent - * @see org.apache.tuscany.model.assembly.AtomicComponent - * @see org.apache.tuscany.model.assembly.EntryPoint - * @see org.apache.tuscany.model.assembly.ExternalService - */ - public void registerModelObject(Extensible model) throws ConfigurationException; - - /** - * Returns the child context associated with a given name - */ - public Context getContext(String name); - - /** - * Returns the composite managed by this composite context - */ - @Deprecated - public Composite getComposite(); - - public void removeContext(String name); - -} diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/ConfigurationContext.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/ConfigurationContext.java deleted file mode 100644 index 558de7609f..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/ConfigurationContext.java +++ /dev/null @@ -1,30 +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.context; - -import org.apache.tuscany.core.builder.ContextFactoryBuilder; -import org.apache.tuscany.core.builder.WireBuilder; - -/** - * Offers configuration services in the runtime. A ConfigurationContext is able to configure a model and then buildSource the - * runtime representation corresponding to that model in the live system. - * <p> - * Configuration contexts will typically be hierarchical, delegating to their parent <b>after</b> performing an - * operation. The parent ConfigurationContext will typically be injected into an implementation of this interface during - * registration. - * - * @version $Rev$ $Date$ - */ -public interface ConfigurationContext extends ContextFactoryBuilder, WireBuilder { -} diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/Context.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/Context.java deleted file mode 100644 index df313d8000..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/Context.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.context; - -/** - * An entity that provides an execution context for a runtime artifact or artifacts. A <code>Context</code> may - * be a composite, managing child contexts or it may be an atomic, i.e. leaf, context. - * - * @version $Rev$ $Date$ - */ -public interface Context extends EventPublisher, Lifecycle { - /** - * Returns the instance associated with the requested name, which may be in a atomic or composite form. Atomic (i.e. - * leaf) contexts will return an instance associated with the service name part of the compound name, which may be - * null. - * <p/> - * Composite contexts will return an instance (likely a proxy) of a contained entry point context. In this case, the - * port name on the qualified name will correspond to the composite context name and the part name will be used to - * retrieve the contained entry point context. The latter may be null. If the contained context is not an entry - * point context, an exception will be thrown. - * - * @param qName a qualified name of the requested instance - * @return the implementation instance or a proxy to it - * @throws TargetException - * if an error occurs retrieving the instance or the requested component is not an entry - * point. - * @see CompositeContext - * @see org.apache.tuscany.model.assembly.EntryPoint - */ - public Object getInstance(QualifiedName qName) throws TargetException; - -} diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/ContextInitException.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/ContextInitException.java deleted file mode 100644 index e024a98b0e..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/ContextInitException.java +++ /dev/null @@ -1,43 +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.context; - -/** - * Denotes an error encountered while initializing an instance context - * - * @version $Rev$ $Date$ - */ -public class ContextInitException extends ContextRuntimeException { - - public ContextInitException() { - super(); - } - - public ContextInitException(String message) { - super(message); - } - - public ContextInitException(String message, Throwable cause) { - super(message, cause); - } - - public ContextInitException(Throwable cause) { - super(cause); - } - -} - diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/ContextRuntimeException.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/ContextRuntimeException.java deleted file mode 100644 index 0d35f145dc..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/ContextRuntimeException.java +++ /dev/null @@ -1,39 +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.context; - -/** - * An unchecked exception encountered by an {@link org.apache.tuscany.core.context.Context} - * - * @version $Rev$ $Date$ - */ -public class ContextRuntimeException extends CoreRuntimeException { - - public ContextRuntimeException() { - super(); - } - - public ContextRuntimeException(String message) { - super(message); - } - - public ContextRuntimeException(String message, Throwable cause) { - super(message, cause); - } - - public ContextRuntimeException(Throwable cause) { - super(cause); - } - -} diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/CoreRuntimeException.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/CoreRuntimeException.java deleted file mode 100644 index 63e6f18e99..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/CoreRuntimeException.java +++ /dev/null @@ -1,43 +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.context; - -import org.apache.tuscany.common.TuscanyRuntimeException; - -/** - * The root exception for the runtime package. Exceptions occurring in the runtime are generally non-recoverable - * - * @version $Rev$ $Date$ - */ -public abstract class CoreRuntimeException extends TuscanyRuntimeException { - - public CoreRuntimeException() { - super(); - } - - public CoreRuntimeException(String message) { - super(message); - } - - public CoreRuntimeException(String message, Throwable cause) { - super(message, cause); - } - - public CoreRuntimeException(Throwable cause) { - super(cause); - } -} diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/DuplicateNameException.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/DuplicateNameException.java deleted file mode 100644 index 81a334d3c8..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/DuplicateNameException.java +++ /dev/null @@ -1,39 +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.context; - -/** - * Denotes an attempt to add a context with a name equal to an existing context - * - * @version $Rev$ $Date$ - */ -public class DuplicateNameException extends ContextRuntimeException { - - public DuplicateNameException() { - super(); - } - - public DuplicateNameException(String message) { - super(message); - } - - public DuplicateNameException(String message, Throwable cause) { - super(message, cause); - } - - public DuplicateNameException(Throwable cause) { - super(cause); - } - -} diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/EntryPointContext.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/EntryPointContext.java deleted file mode 100644 index 63feabc43c..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/EntryPointContext.java +++ /dev/null @@ -1,69 +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.context; - -import org.apache.tuscany.core.wire.SourceWireFactory; - -/** - * The runtime artifact representing an entry point, <code>EntryPointContext</code> manages wire handler - * instances that expose service operations offered by a component in the parent composite. The wire handler - * instance is responsible for dispatching the request down an wire chain to the target instance. The wire - * chain may contain {@link org.apache.tuscany.core.wire.Interceptor}s and - * {@link org.apache.tuscany.core.wire.MessageHandler}s that implement policies or perform mediations on the - * wire. - * <p> - * Entry point contexts are used by transport binding artifacts to invoke an operation on a service. The transport - * binding uses an {@link java.lang.reflect.InvocationHandler} instance obtained from the <code>EntryPointContext</code> - * to perform the wire as in: - * - * <pre> - * CompositeContext compositeContext = ... - * EntryPointContext ctx = (EntryPointContext) compositeContext.getContext("source"); - * Assert.assertNotNull(ctx); - * InvocationHandler handler = (InvocationHandler) ctx.getHandler(); - * Object response = handler.invoke(null, operation, new Object[] { param }); - * </pre> - * - * The <code>Proxy</code> instance passed to <code>InvocationHandler</code> may be null as the client is invoking - * directly on the handler. - * <p> - * Alternatively, the following will return a proxy implementing the service interface exposed by the entry point: - * - * <pre> - * CompositeContext compositeContext = ... - * EntryPointContext ctx = (EntryPointContext) compositeContext.getContext("source"); - * Assert.assertNotNull(ctx); - * HelloWorld proxy = (Helloworld) ctx.getInstance(null); // service name not necessary - * </pre> - * - * The proxy returned will be backed by the entry point wire chain. - * - * @version $Rev$ $Date$ - */ -public interface EntryPointContext extends Context { - - /** - * Returns the handler responsible for flowing a request through the entry point - * @throws TargetException - */ - public Object getHandler() throws TargetException; - - /** - * Returns the service interface configured for the entry poitn - */ - public Class getServiceInterface(); -} diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/EventContext.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/EventContext.java deleted file mode 100644 index 36b0f98928..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/EventContext.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.context; - -/** - * Implementations are responsible for tracking scope keys associated with the current request. - * - * @version $Rev$ $Date$ - */ -public interface EventContext { - - /** - * Returns the unique key for the given identifier associated with the current request - */ - public Object getIdentifier(Object type); - - /** - * Sets the unique key for the given identifier associated with the current request - */ - public void setIdentifier(Object type, Object identifier); - - /** - * Clears the unique key for the given identifier associated with the current request - */ - public void clearIdentifier(Object type); - - /** - * Clears all identifiers associated with the current request - */ - public void clearIdentifiers(); - -} diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/EventException.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/EventException.java deleted file mode 100644 index aaf26aee69..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/EventException.java +++ /dev/null @@ -1,43 +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.context; - -/** - * Denotes an error encountered while firing a module event - * - * @version $Rev$ $Date$ - */ -public class EventException extends CoreRuntimeException { - - public EventException(String message, Throwable cause) { - super(message, cause); - } - - public EventException(String message) { - super(message); - } - - public EventException(Throwable cause) { - super(cause); - } - - public EventException() { - super(); - } - -} - diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/EventFilter.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/EventFilter.java deleted file mode 100644 index ee1334bef2..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/EventFilter.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.context; - -import org.apache.tuscany.core.context.event.Event; - -import java.util.EventObject; - -/** - * Evaluates whether a {@link RuntimeEventListener} is applicable to a given runtime event - * - * @version $$Rev$$ $$Date$$ - */ -public interface EventFilter { - - /** - * Performs the actual evaluation on an event - */ - public boolean match(Event event); - -} diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/EventPublisher.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/EventPublisher.java deleted file mode 100644 index c7ccf88e25..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/EventPublisher.java +++ /dev/null @@ -1,44 +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.context; - -import org.apache.tuscany.core.context.event.Event; - -/** - * Publishes events in the runtime - * - * @version $$Rev$$ $$Date$$ - */ -public interface EventPublisher { - - public void publish(Event object); - - /** - * Registers a listener to receive notifications for the context - */ - public void addListener(RuntimeEventListener listener); - - /** - * Registers a listener to receive notifications for the context - */ - public void addListener(EventFilter filter, RuntimeEventListener listener); - - - /** - * Removes a previously registered listener - */ - public void removeListener(RuntimeEventListener listener); - - -} diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/ExternalServiceContext.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/ExternalServiceContext.java deleted file mode 100644 index f7b4a6c572..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/ExternalServiceContext.java +++ /dev/null @@ -1,30 +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.context; - -/** - * Manages an external service - * - * @version $Rev$ $Date$ - */ -public interface ExternalServiceContext extends Context { - - /** - * Returns the handler responsible for flowing a request through the external service - * @throws TargetException - */ - public Object getHandler() throws TargetException; - -} - diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/InvalidNameException.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/InvalidNameException.java deleted file mode 100644 index 65c709e569..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/InvalidNameException.java +++ /dev/null @@ -1,43 +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.context; - -/** - * Denotes an invalid name - * - * @version $Rev$ $Date$ - */ -public class InvalidNameException extends ContextRuntimeException { - - public InvalidNameException() { - super(); - } - - public InvalidNameException(String message) { - super(message); - } - - public InvalidNameException(String message, Throwable cause) { - super(message, cause); - } - - public InvalidNameException(Throwable cause) { - super(cause); - } - -} - diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/Lifecycle.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/Lifecycle.java deleted file mode 100644 index 6572841cf0..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/Lifecycle.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * - * 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.context; - -/** - * @version $Rev$ $Date$ - */ -public interface Lifecycle { - /* A configuration error state */ - int CONFIG_ERROR = -1; - /* Has not been initialized */ - int UNINITIALIZED = 0; - /* In the process of being configured and initialized */ - int INITIALIZING = 1; - /* Instantiated and configured */ - int INITIALIZED = 2; - /* Started */ - int STARTED = 4; - /* Configured and initialized */ - int RUNNING = 4; - /* In the process of being shutdown */ - int STOPPING = 5; - /* Has been shutdown and removed from the module */ - int STOPPED = 6; - /* In an error state */ - int ERROR = 7; - - /** - * Returns the lifecycle state - * - * @see #UNINITIALIZED - * @see #INITIALIZING - * @see #INITIALIZED - * @see #RUNNING - * @see #STOPPING - * @see #STOPPED - */ - int getLifecycleState(); - - /** - * Starts the Lifecycle. - * - * @throws CoreRuntimeException - */ - void start() throws CoreRuntimeException; - - /** - * Stops the Lifecycle. - * - * @throws CoreRuntimeException - */ - void stop() throws CoreRuntimeException; - - /** - * Returns the name of the Lifecycle. - * @return the name of the Lifecycle - */ - String getName(); - - /** - * Sets the name of the Lifecycle. - * @param name the name of the Lifecycle - */ - void setName(String name); -} diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/MissingContextFactoryException.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/MissingContextFactoryException.java deleted file mode 100644 index fd4d613e34..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/MissingContextFactoryException.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * - * Copyright 2006 The Apache Software Foundation - * - * 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.context; - -import org.apache.tuscany.core.config.ConfigurationException; - -/** - * - * @version $Rev$ $Date$ - */ -public class MissingContextFactoryException extends ConfigurationException { - private static final long serialVersionUID = 5140433835245354247L; - - public MissingContextFactoryException() { - } - - public MissingContextFactoryException(String message) { - super(message); - } - - public MissingContextFactoryException(String message, Throwable cause) { - super(message, cause); - } - - public MissingContextFactoryException(Throwable cause) { - super(cause); - } -} diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/MissingImplementationException.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/MissingImplementationException.java deleted file mode 100644 index 787e9cae20..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/MissingImplementationException.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * - * Copyright 2006 The Apache Software Foundation - * - * 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.context; - -import org.apache.tuscany.core.config.ConfigurationException; - -/** - * - * @version $Rev$ $Date$ - */ -public class MissingImplementationException extends ConfigurationException { - private static final long serialVersionUID = 7274481740916067128L; - - public MissingImplementationException() { - } - - public MissingImplementationException(String message) { - super(message); - } - - public MissingImplementationException(String message, Throwable cause) { - super(message, cause); - } - - public MissingImplementationException(Throwable cause) { - super(cause); - } -} diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/MissingScopeException.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/MissingScopeException.java deleted file mode 100644 index 53108e6e6b..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/MissingScopeException.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * - * Copyright 2006 The Apache Software Foundation - * - * 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.context; - -import org.apache.tuscany.core.config.ConfigurationException; - -/** - * - * @version $Rev$ $Date$ - */ -public class MissingScopeException extends ConfigurationException { - private static final long serialVersionUID = -6999184494724096056L; - - public MissingScopeException() { - } - - public MissingScopeException(String message) { - super(message); - } - - public MissingScopeException(String message, Throwable cause) { - super(message, cause); - } - - public MissingScopeException(Throwable cause) { - super(cause); - } -} diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/ProxyConfigurationException.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/ProxyConfigurationException.java deleted file mode 100644 index 2d15118c1c..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/ProxyConfigurationException.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * - * Copyright 2006 The Apache Software Foundation - * - * 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.context; - -import org.apache.tuscany.core.config.ConfigurationException; - -/** - * - * @version $Rev$ $Date$ - */ -public class ProxyConfigurationException extends ConfigurationException { - private static final long serialVersionUID = -5860342620108741058L; - - public ProxyConfigurationException() { - } - - public ProxyConfigurationException(String message) { - super(message); - } - - public ProxyConfigurationException(String message, Throwable cause) { - super(message, cause); - } - - public ProxyConfigurationException(Throwable cause) { - super(cause); - } -} diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/QualifiedName.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/QualifiedName.java deleted file mode 100644 index a9a0baeff9..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/QualifiedName.java +++ /dev/null @@ -1,84 +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.context; - -/** - * An evaluated name consisting of a part/port pair. In the runtime, a part generally 'contains' or 'provides' ports - * such as a module component/entry point or a component/service pair. - * - * @version $Rev$ $Date$ - */ -public class QualifiedName { - - private String qName; - - private String partName; - - private String portName; - - public static final String NAME_SEPARATOR = "/"; - - /** - * Constructs a new qualified name in the form of part/port where part is the parent context and port represents a - * child, which is either a service in the case of an atomic context or a contained context in the case of a composite. - * - * @throws InvalidNameException if the name is in an invalid format - */ - public QualifiedName(String qualifiedName) throws InvalidNameException { - if (qualifiedName == null){ - return; - } - int pos = qualifiedName.indexOf(QualifiedName.NAME_SEPARATOR); - switch (pos) { - case -1: - partName = qualifiedName; - break; - case 0: - throw new InvalidNameException(qualifiedName); - default: - partName = qualifiedName.substring(0, pos); - portName = qualifiedName.substring(pos + 1); - break; - } - qName = qualifiedName; - } - - /** - * Returns the parsed part name - */ - public String getPartName() { - return partName; - } - - /** - * Returns the parsed port name if the original is of the compound for part/port - */ - public String getPortName() { - return portName; - } - - /** - * Returns the full part/port name pair - */ - public String getQualifiedName() { - return qName; - } - - public String toString() { - return qName; - } -} diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/RuntimeEventListener.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/RuntimeEventListener.java deleted file mode 100644 index 89cc51f3fc..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/RuntimeEventListener.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.context; - -import org.apache.tuscany.core.context.event.Event; - -import java.util.EventListener; -import java.util.EventObject; - -/** - * Listeners observe events fired in the SCA runtime. - * - * @version $Rev$ $Date$ - */ -public interface RuntimeEventListener extends EventListener { - - public void onEvent(Event event); -} diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/ScopeAwareContext.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/ScopeAwareContext.java deleted file mode 100644 index d57d59cb58..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/ScopeAwareContext.java +++ /dev/null @@ -1,31 +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.context; - -import org.apache.tuscany.model.assembly.Scope; - -import java.util.Map; - -/** - * Denotes a composite context that supports scopes - * - * @version $Rev$ $Date$ - */ -public interface ScopeAwareContext extends CompositeContext { - - /** - * Returns an immutable collection of scopes keyed by type for the composite context - */ - public Map<Scope, ScopeContext> getScopeContexts(); -} diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/ScopeContext.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/ScopeContext.java deleted file mode 100644 index c582bde2b4..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/ScopeContext.java +++ /dev/null @@ -1,74 +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.context; - -import org.apache.tuscany.core.builder.ContextFactory; - -import java.util.List; - -/** - * Manages the lifecycle and visibility of <code>Context</code>s. - * - * @see org.apache.tuscany.core.context.Context - * - * @version $Rev$ $Date$ - */ -public interface ScopeContext extends Lifecycle, RuntimeEventListener { - - public Object getInstance(QualifiedName qName) throws TargetException; - - /** - * Returns whether implementation instances may be held for the duration of an wire - */ - public boolean isCacheable(); - - /** - * Registers the context factory used to construct instance contexts for the scope - */ - public void registerFactories(List<ContextFactory<Context>> configurations); - - /** - * Adds a context factory to the scope - */ - public void registerFactory(ContextFactory<Context> configuration); - - /** - * Returns a context bound to the given name or null if the component does not exist. The returned context is bound - * to a key determined from the thread context. - */ - public Context getContext(String name); - - /** - * Returns a context bound to the given name and scoped to the given key or null if the context does not exist - */ - public Context getContextByKey(String name, Object key); - - /** - * Removes a context with the given name, determining the scope key from the thread context - * - * @throws ScopeRuntimeException - */ - public void removeContext(String name) throws ScopeRuntimeException; - - /** - * Removes a context bound to the given name and scope key - * - * @throws ScopeRuntimeException - */ - public void removeContextByKey(String name, Object key) throws ScopeRuntimeException; - -}
\ No newline at end of file diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/ScopeIdentifier.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/ScopeIdentifier.java deleted file mode 100644 index d25477f71c..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/ScopeIdentifier.java +++ /dev/null @@ -1,33 +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.context; - -/** - * Implementations enable lazy retrieval of a scope id associated with a request, i.e. an id (and presumably a context) do not - * have to be generated if the scope is never accessed. Identifiers are associated with the current request thread and keyed on - * scope type. - * - * @version $Rev$ $Date$ - * @see org.apache.tuscany.core.context.EventContext - */ -public interface ScopeIdentifier { - - /** - * Returns the scope id for the request. - */ - public Object getIdentifier(); -} diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/ScopeInitializationException.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/ScopeInitializationException.java deleted file mode 100644 index 6ef5bfe9dd..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/ScopeInitializationException.java +++ /dev/null @@ -1,42 +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.context; - -/** - * Denotes an initialization exception thrown by a scope container - * - * @version $Rev$ $Date$ - */ -public class ScopeInitializationException extends ScopeRuntimeException { - - public ScopeInitializationException() { - super(); - } - - public ScopeInitializationException(String message) { - super(message); - } - - public ScopeInitializationException(String message, Throwable cause) { - super(message, cause); - } - - public ScopeInitializationException(Throwable cause) { - super(cause); - } - -} diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/ScopeRuntimeException.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/ScopeRuntimeException.java deleted file mode 100644 index 5022f7589d..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/ScopeRuntimeException.java +++ /dev/null @@ -1,43 +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.context; - -/** - * Denotes a general runtime exception encountered by a scope container - * - * @version $Rev$ $Date$ - */ -public class ScopeRuntimeException extends CoreRuntimeException { - - public ScopeRuntimeException() { - super(); - } - - public ScopeRuntimeException(String message) { - super(message); - } - - public ScopeRuntimeException(String message, Throwable cause) { - super(message, cause); - } - - public ScopeRuntimeException(Throwable cause) { - super(cause); - } - -} - diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/ScopeStrategy.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/ScopeStrategy.java deleted file mode 100644 index c01df8ff9e..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/ScopeStrategy.java +++ /dev/null @@ -1,43 +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.context; - -import org.apache.tuscany.model.assembly.Scope; - -import java.util.Map; - -/** - * Implementations provide scope container creation facilities and scope semantics to the runtime - * - * @version $Rev$ $Date$ - */ -public interface ScopeStrategy { - - /* Denotes an undefined scope */ - public static final int SCOPE_NOT_FOUND = -3; - - /** - * Creates and returns new instances of configured scope containers - */ - public Map<Scope, ScopeContext> getScopeContexts(EventContext eventContext); - - /** - * Determines whether a wire proceeds from a source of higher scope to a target of lesser scope - */ - public boolean downScopeReference(Scope sourceScope, Scope targetScope); - -} diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/ServiceNotFoundException.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/ServiceNotFoundException.java deleted file mode 100644 index ee8c9f91b8..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/ServiceNotFoundException.java +++ /dev/null @@ -1,42 +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.context; - -import org.osoa.sca.ServiceRuntimeException; - -/** - * Denotes the specific case where a service was not found at runtime - * - * @version $Rev$ $Date$ - */ -public class ServiceNotFoundException extends ServiceRuntimeException { - - public ServiceNotFoundException() { - super(); - } - - public ServiceNotFoundException(String message) { - super(message); - } - - public ServiceNotFoundException(Throwable cause) { - super(cause); - } - - public ServiceNotFoundException(String message, Throwable cause) { - super(message, cause); - } - -} - diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/SystemCompositeContext.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/SystemCompositeContext.java deleted file mode 100644 index 7e3b4b8045..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/SystemCompositeContext.java +++ /dev/null @@ -1,37 +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.context; - -import org.apache.tuscany.core.config.ConfigurationException; - -/** - * Marker type for system composite contexts - * - * @version $Rev$ $Date$ - */ -public interface SystemCompositeContext extends AutowireContext, ScopeAwareContext, ConfigurationContext { - - /** - * Register a simple Java Object as a system component. - * This is primarily intended for use by bootstrap code to create the initial - * configuration components. - * - * @param name the name of the resulting component - * @param service - * @param instance the Object that will become the component's implementation - * @throws ConfigurationException - */ - void registerJavaObject(String name, Class<?> service, Object instance) throws ConfigurationException; -} - diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/TargetException.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/TargetException.java deleted file mode 100644 index dd39d06aa1..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/TargetException.java +++ /dev/null @@ -1,42 +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.context; - -/** - * Denotes an error while performing an operation on a target component implementation instance or proxy - * - * @version $Rev$ $Date$ - */ -public class TargetException extends CoreRuntimeException { - - public TargetException() { - super(); - } - - public TargetException(String message) { - super(message); - } - - public TargetException(String message, Throwable cause) { - super(message, cause); - } - - public TargetException(Throwable cause) { - super(cause); - } - -} diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/event/AbstractEvent.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/event/AbstractEvent.java deleted file mode 100644 index cef0c25a63..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/event/AbstractEvent.java +++ /dev/null @@ -1,33 +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.context.event; - -/** - * A basic implementation of a runtime event - * - * @version $$Rev$$ $$Date$$ - */ -public abstract class AbstractEvent implements Event{ - - protected transient Object source; - - public AbstractEvent(Object source) { - assert (source !=null): "Source id was null"; - this.source = source; - } - - public Object getSource() { - return source; - } -} diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/event/AbstractRequestEvent.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/event/AbstractRequestEvent.java deleted file mode 100644 index c038f141b5..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/event/AbstractRequestEvent.java +++ /dev/null @@ -1,43 +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.context.event; - -/** - * Base implementation of a request event - * - * @version $$Rev$$ $$Date$$ - */ -public abstract class AbstractRequestEvent extends AbstractEvent implements RequestEvent { - - private Object id; - - /** - * Creates a new event - * @param source the source of the event - * @param id the id of the request associated with the event - */ - public AbstractRequestEvent(Object source, Object id) { - super(source); - assert (id !=null): "Request id was null"; - this.id = id; - } - - public Object getId(){ - return id; - } - -} diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/event/Event.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/event/Event.java deleted file mode 100644 index 5b370b8c73..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/event/Event.java +++ /dev/null @@ -1,28 +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.context.event; - -/** - * Represents an event that is propagated in the runtime - * - * @version $$Rev$$ $$Date$$ - */ -public interface Event { - - /** - * Returns the source of the event - */ - public Object getSource(); - -} diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/event/HttpSessionBound.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/event/HttpSessionBound.java deleted file mode 100644 index 8af7042ad3..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/event/HttpSessionBound.java +++ /dev/null @@ -1,33 +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.context.event; - - -/** - * An event propagated when an HTTP session is bound to the current request - * - * @version $$Rev$$ $$Date$$ - */ -public class HttpSessionBound extends HttpSessionEvent implements SessionBound { - - /** - * Creates a new event - * @param source the source of the event - * @param id the id of the HTTP session associated with the event or possibly a lazy wrapper - */ - public HttpSessionBound(Object source, Object id) { - super(source,id); - } - -} diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/event/HttpSessionEnd.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/event/HttpSessionEnd.java deleted file mode 100644 index 3b2aff1353..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/event/HttpSessionEnd.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.context.event; - -/** - * Propagated when an HTTP-based session is expired - * - * @version $$Rev$$ $$Date$$ - */ -public class HttpSessionEnd extends HttpSessionEvent implements SessionEnd { - - /** - * Creates a new event - * @param source the source of the event - * @param id the id of the HTTP session being ended - */ - public HttpSessionEnd(Object source, Object id) { - super(source,id); - } - - } diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/event/HttpSessionEvent.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/event/HttpSessionEvent.java deleted file mode 100644 index ecfbefa808..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/event/HttpSessionEvent.java +++ /dev/null @@ -1,47 +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.context.event; - -/** - * A base implementation of HTTP-based session events in the runtime - * - * @version $$Rev$$ $$Date$$ - */ -public abstract class HttpSessionEvent implements SessionEvent { - - // FIXME this needs to be made private and not directly referenced in the runtime - public static final Object HTTP_IDENTIFIER = new Object(); - - private Object id; - protected transient Object source; - - public HttpSessionEvent(Object source, Object id) { - assert (source !=null): "Source id was null"; - assert (id !=null): "Session id was null"; - this.source = source; - this.id = id; - } - - public Object getSource() { - return source; - } - - public Object getId(){ - return id; - } - - public Object getSessionTypeIdentifier(){ - return HTTP_IDENTIFIER; - } -} diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/event/InstanceCreated.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/event/InstanceCreated.java deleted file mode 100644 index d157b4b1e1..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/event/InstanceCreated.java +++ /dev/null @@ -1,27 +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.context.event; - -/** - * An event propagated upon the creation of an instance belonging to a {@link org.apache.tuscany.core.context.Context} - * - * @version $$Rev$$ $$Date$$ - */ -public class InstanceCreated extends AbstractEvent { - - public InstanceCreated(Object source) { - super(source); - } - -} diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/event/ModuleEvent.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/event/ModuleEvent.java deleted file mode 100644 index 48de538048..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/event/ModuleEvent.java +++ /dev/null @@ -1,23 +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.context.event; - -/** - * Implemented by runtime events associated with a module, e.g. lifecycle events - * - * @version $$Rev$$ $$Date$$ - */ -public interface ModuleEvent extends Event{ - -} diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/event/ModuleStart.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/event/ModuleStart.java deleted file mode 100644 index d953ddd65f..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/event/ModuleStart.java +++ /dev/null @@ -1,26 +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.context.event; - -/** - * Propagated when a module starts - * - * @version $$Rev$$ $$Date$$ - */ -public class ModuleStart extends AbstractEvent implements ModuleEvent { - - public ModuleStart(Object source) { - super(source); - } -} diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/event/ModuleStop.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/event/ModuleStop.java deleted file mode 100644 index fb3c31bdff..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/event/ModuleStop.java +++ /dev/null @@ -1,29 +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.context.event; - -/** - * Propagated when a module stops - * - * @version $$Rev$$ $$Date$$ - */ -public class ModuleStop extends AbstractEvent implements ModuleEvent{ - - public ModuleStop(Object source) { - super(source); - } -} diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/event/RequestEnd.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/event/RequestEnd.java deleted file mode 100644 index 1cbe024be3..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/event/RequestEnd.java +++ /dev/null @@ -1,33 +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.context.event; - -/** - * Propagated when a request completes or is ended - * - * @version $$Rev$$ $$Date$$ - */ -public class RequestEnd extends AbstractRequestEvent{ - - /** - * Creates a new event - * @param source the source of the event - * @param id the id of the completed/ended request - */ - public RequestEnd(Object source, Object id) { - super(source,id); - } - - -} diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/event/RequestEvent.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/event/RequestEvent.java deleted file mode 100644 index 0b7e1b8005..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/event/RequestEvent.java +++ /dev/null @@ -1,26 +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.context.event; - -/** - * Implemented by runtime events associated request - * @version $$Rev$$ $$Date$$ - */ -public interface RequestEvent { - - /** - * Returns the id of the request the event is associated with - */ - public Object getId(); - -} diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/event/RequestStart.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/event/RequestStart.java deleted file mode 100644 index 8c07a3d607..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/event/RequestStart.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.context.event; - -/** - * Propagated when a request is started in the runtime - * - * @version $$Rev$$ $$Date$$ - */ -public class RequestStart extends AbstractRequestEvent { - - /** - * Creates a new event - * @param source the source of the event - * @param id the id of the request being started - */ - public RequestStart(Object source, Object id) { - super(source,id); - } - -} diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/event/SessionBound.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/event/SessionBound.java deleted file mode 100644 index 5d977911be..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/event/SessionBound.java +++ /dev/null @@ -1,23 +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.context.event; - -/** - * Propagated when a generic session is associated with the current request. - * - * @version $$Rev$$ $$Date$$ - */ -public interface SessionBound extends SessionEvent { - -} diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/event/SessionEnd.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/event/SessionEnd.java deleted file mode 100644 index 809d63bd0f..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/event/SessionEnd.java +++ /dev/null @@ -1,23 +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.context.event; - -/** - * Propagated when a session ended or expired - * - * @version $$Rev$$ $$Date$$ - */ -public interface SessionEnd extends SessionEvent{ - -} diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/event/SessionEvent.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/event/SessionEvent.java deleted file mode 100644 index 7eaff1de24..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/event/SessionEvent.java +++ /dev/null @@ -1,34 +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.context.event; - -/** - * Implemented by runtime events associated with a session. There may be multiple session types in the runtime such as - * HTTP-based or conversational. - * - * @version $$Rev$$ $$Date$$ - */ -public interface SessionEvent extends Event { - - /** - * Returns the unique key identifying the session type the event is associated with, e.g. an HTTP-based or conversational - * session - */ - public Object getSessionTypeIdentifier(); - - /** - * Returns the session id associated with the event - */ - public Object getId(); -} diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/event/SessionStart.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/event/SessionStart.java deleted file mode 100644 index cfe490e2ff..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/event/SessionStart.java +++ /dev/null @@ -1,26 +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.context.event; - -/** - * Propagated when a session starts - * - * @version $$Rev$$ $$Date$$ - */ -public interface SessionStart extends SessionEvent{ - -} diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/filter/TrueFilter.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/filter/TrueFilter.java deleted file mode 100644 index 35601646f2..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/filter/TrueFilter.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.context.filter; - -import org.apache.tuscany.core.context.EventFilter; -import org.apache.tuscany.core.context.event.Event; - -/** - * An event filter that always returns a true condition - * - * @version $$Rev$$ $$Date$$ - */ -public class TrueFilter implements EventFilter { - - public boolean match(Event event) { - return true; - } -} diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/impl/AbstractCompositeContext.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/impl/AbstractCompositeContext.java deleted file mode 100644 index c9e563302c..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/impl/AbstractCompositeContext.java +++ /dev/null @@ -1,852 +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.context.impl; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.EnumMap; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.TimeUnit; - -import org.apache.tuscany.common.TuscanyRuntimeException; -import org.apache.tuscany.core.builder.BuilderConfigException; -import org.apache.tuscany.core.builder.ContextFactory; -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.ContextInitException; -import org.apache.tuscany.core.context.CoreRuntimeException; -import org.apache.tuscany.core.context.DuplicateNameException; -import org.apache.tuscany.core.context.EntryPointContext; -import org.apache.tuscany.core.context.EventContext; -import org.apache.tuscany.core.context.EventException; -import org.apache.tuscany.core.context.Lifecycle; -import org.apache.tuscany.core.context.MissingContextFactoryException; -import org.apache.tuscany.core.context.MissingImplementationException; -import org.apache.tuscany.core.context.MissingScopeException; -import org.apache.tuscany.core.context.ProxyConfigurationException; -import org.apache.tuscany.core.context.QualifiedName; -import org.apache.tuscany.core.context.ScopeAwareContext; -import org.apache.tuscany.core.context.ScopeContext; -import org.apache.tuscany.core.context.ScopeStrategy; -import org.apache.tuscany.core.context.TargetException; -import org.apache.tuscany.core.context.event.Event; -import org.apache.tuscany.core.context.event.RequestEnd; -import org.apache.tuscany.core.context.event.SessionBound; -import org.apache.tuscany.core.context.event.SessionEvent; -import org.apache.tuscany.core.context.scope.DefaultScopeStrategy; -import org.apache.tuscany.core.system.annotation.Autowire; -import org.apache.tuscany.core.system.annotation.ParentContext; -import org.apache.tuscany.core.system.assembly.SystemBinding; -import org.apache.tuscany.core.wire.InvocationConfiguration; -import org.apache.tuscany.core.wire.SourceWireFactory; -import org.apache.tuscany.core.wire.TargetWireFactory; -import org.apache.tuscany.core.wire.WireConfiguration; -import org.apache.tuscany.core.wire.WireFactory; -import org.apache.tuscany.core.wire.WireFactoryInitException; -import org.apache.tuscany.model.assembly.AssemblyContext; -import org.apache.tuscany.model.assembly.AssemblyObject; -import org.apache.tuscany.model.assembly.Binding; -import org.apache.tuscany.model.assembly.Component; -import org.apache.tuscany.model.assembly.Composite; -import org.apache.tuscany.model.assembly.EntryPoint; -import org.apache.tuscany.model.assembly.Extensible; -import org.apache.tuscany.model.assembly.ExternalService; -import org.apache.tuscany.model.assembly.Implementation; -import org.apache.tuscany.model.assembly.Module; -import org.apache.tuscany.model.assembly.ModuleComponent; -import org.apache.tuscany.model.assembly.Scope; -import org.apache.tuscany.model.assembly.Service; -import org.apache.tuscany.model.assembly.impl.AssemblyFactoryImpl; - -/** - * The base implementation of a composite context - * - * @version $Rev$ $Date$ - */ -@SuppressWarnings({"FieldAccessedSynchronizedAndUnsynchronized", "RawUseOfParameterizedType", "NonPrivateFieldAccessedInSynchronizedContext"}) -public abstract class AbstractCompositeContext extends AbstractContext implements AutowireContext, ScopeAwareContext, ConfigurationContext { - - public static final int DEFAULT_WAIT = 1000 * 60; - - protected AssemblyContext assemblyContext; - - protected CompositeContext parentContext; - - // The parent configuration context, if one exists - @Autowire - protected ConfigurationContext configurationContext; - - // The logical model representing the module assembly - // protected ModuleComponent moduleComponent; - protected Module module; - - protected Map<String, ContextFactory<Context>> configurations = new HashMap<String, ContextFactory<Context>>(); - - // Factory for scope contexts - protected ScopeStrategy scopeStrategy; - - // The event context for associating context events to threads - protected EventContext eventContext; - - // The scopes for this context - protected Map<Scope, ScopeContext> scopeContexts; - - protected Map<Scope, ScopeContext> immutableScopeContexts; - - // A component context name to scope context index - protected Map<String, ScopeContext> scopeIndex; - - // Blocking latch to ensure the module is initialized exactly once prior to servicing requests - protected CountDownLatch initializeLatch = new CountDownLatch(1); - - protected final Object lock = new Object(); - - // Indicates whether the module context has been initialized - protected boolean initialized; - - // a mapping of service type to component name - private final Map<Class, NameToScope> autowireInternal = new ConcurrentHashMap<Class, NameToScope>(); - private final Map<Class, NameToScope> autowireExternal = new ConcurrentHashMap<Class, NameToScope>(); - - private AutowireContext autowireContext; - - public AbstractCompositeContext() { - scopeIndex = new ConcurrentHashMap<String, ScopeContext>(); - // FIXME the factory should be injected - module = new AssemblyFactoryImpl().createModule(); - scopeStrategy = new DefaultScopeStrategy(); - } - - public AbstractCompositeContext(String name, CompositeContext parent, ScopeStrategy strategy, EventContext ctx, ConfigurationContext configCtx) { - super(name); - if (strategy == null) { - strategy = new DefaultScopeStrategy(); - } - this.scopeStrategy = strategy; - this.eventContext = ctx; - this.configurationContext = configCtx; - scopeIndex = new ConcurrentHashMap<String, ScopeContext>(); - parentContext = parent; - // FIXME the factory should be injected - module = new AssemblyFactoryImpl().createModule(); - } - - public void setAssemblyContext(AssemblyContext assemblyContext) { - this.assemblyContext = assemblyContext; - } - - private String uri; - - public String getURI() { - return uri; - } - - public void setURI(String uri) { - this.uri = uri; - } - - - public void start() { - synchronized (lock) { - try { - if (lifecycleState == STOPPED) { - throw new IllegalStateException("Context cannot be restarted - create a new one"); - } else if (lifecycleState != UNINITIALIZED) { - throw new IllegalStateException("Context not in UNINITIALIZED state"); - } - - lifecycleState = INITIALIZING; - initializeScopes(); - - Map<Scope, List<ContextFactory<Context>>> configurationsByScope = new EnumMap<Scope, List<ContextFactory<Context>>>(Scope.class); - if (configurations != null) { - for (ContextFactory<Context> contextFactory : configurations.values()) { - // FIXME scopes are defined at the interface level - Scope sourceScope = contextFactory.getScope(); - wireSource(contextFactory); - buildTarget(contextFactory); - scopeIndex.put(contextFactory.getName(), scopeContexts.get(sourceScope)); - List<ContextFactory<Context>> list = configurationsByScope.get(sourceScope); - if (list == null) { - list = new ArrayList<ContextFactory<Context>>(); - configurationsByScope.put(sourceScope, list); - } - list.add(contextFactory); - } - } - for (EntryPoint ep : module.getEntryPoints()) { - registerAutowire(ep); - } - for (Component component : module.getComponents()) { - if (component instanceof ModuleComponent) { - registerAutowire((ModuleComponent) component); - } else { - registerAutowire(component); - } - } - for (ExternalService es : module.getExternalServices()) { - registerAutowire(es); - } - for (Map.Entry<Scope, List<ContextFactory<Context>>> entries : configurationsByScope.entrySet()) - { - // register configurations with scope contexts - ScopeContext scope = scopeContexts.get(entries.getKey()); - scope.registerFactories(entries.getValue()); - } - initializeWireFactories(); - for (ScopeContext scope : scopeContexts.values()) { - // register scope contexts as a listeners for events in the composite context - addListener(scope); - scope.start(); - } - lifecycleState = RUNNING; - } catch (WireFactoryInitException e) { - lifecycleState = ERROR; - ContextInitException cie = new ContextInitException(e); - cie.addContextName(getName()); - throw cie; - } catch (CoreRuntimeException e) { - lifecycleState = ERROR; - e.addContextName(getName()); - throw e; - } finally { - initialized = true; - // release the latch and allow requests to be processed - initializeLatch.countDown(); - } - } - } - - public void stop() { - if (lifecycleState == STOPPED) { - return; - } - // need to block a start until reset is complete - initializeLatch = new CountDownLatch(1); //xcv - lifecycleState = STOPPING; - initialized = false; - if (scopeContexts != null) { - for (ScopeContext scopeContext : scopeContexts.values()) { - if (scopeContext.getLifecycleState() == Lifecycle.RUNNING) { - scopeContext.stop(); - } - } - } - scopeContexts = null; - scopeIndex.clear(); - // allow initialized to be called - initializeLatch.countDown(); - lifecycleState = STOPPED; - - } - - public void setModule(Module module) { - assert (module != null) : "Module cannot be null"; - name = module.getName(); - this.module = module; - } - - public void setEventContext(EventContext eventContext) { - this.eventContext = eventContext; - } - - public void setConfigurationContext(ConfigurationContext context) { - this.configurationContext = context; - } - - public CompositeContext getParent() { - return parentContext; - } - - @ParentContext - public void setParent(CompositeContext parent) { - parentContext = parent; - } - - public void registerModelObjects(List<? extends Extensible> models) throws ConfigurationException { - assert (models != null) : "Model object collection was null"; - for (Extensible model : models) { - registerModelObject(model); - } - } - - public void registerModelObject(Extensible model) throws ConfigurationException { - assert (model != null) : "Model object was null"; - initializeScopes(); - if (configurationContext != null) { - try { - configurationContext.build(model); - } catch (BuilderConfigException e) { - e.addContextName(getName()); - throw e; - } - } - ContextFactory<Context> configuration; - if (model instanceof Module) { - // merge new module definition with the existing one - Module oldModule = module; - Module newModule = (Module) model; - module = newModule; - for (Component component : newModule.getComponents()) { - Implementation componentImplementation = component.getImplementation(); - if (componentImplementation == null) { - ConfigurationException e = new MissingImplementationException("Component implementation not set"); - e.addContextName(component.getName()); - e.addContextName(getName()); - throw e; - } - configuration = (ContextFactory<Context>) component.getContextFactory(); - if (configuration == null) { - ConfigurationException e = new MissingContextFactoryException("Context factory not set"); - e.addContextName(component.getName()); - e.addContextName(getName()); - throw e; - } - registerConfiguration(configuration); - if (component instanceof ModuleComponent) { - registerAutowire((ModuleComponent) component); - } else { - registerAutowire(component); - } - } - for (EntryPoint ep : newModule.getEntryPoints()) { - configuration = (ContextFactory<Context>) ep.getContextFactory(); - if (configuration == null) { - ConfigurationException e = new MissingContextFactoryException("Context factory not set"); - e.setIdentifier(ep.getName()); - e.addContextName(getName()); - throw e; - } - registerConfiguration(configuration); - registerAutowire(ep); - } - for (ExternalService service : newModule.getExternalServices()) { - configuration = (ContextFactory<Context>) service.getContextFactory(); - if (configuration == null) { - ConfigurationException e = new MissingContextFactoryException("Context factory not set"); - e.setIdentifier(service.getName()); - e.addContextName(getName()); - throw e; - } - registerConfiguration(configuration); - registerAutowire(service); - } - if (lifecycleState == RUNNING) { - for (Component component : newModule.getComponents()) { - ContextFactory<Context> contextFactory = (ContextFactory<Context>) component.getContextFactory(); - wireSource(contextFactory); - buildTarget(contextFactory); - contextFactory.prepare(this); - try { - if (contextFactory.getSourceWireFactories() != null) { - for (SourceWireFactory sourceWireFactory : contextFactory.getSourceWireFactories()) - { - sourceWireFactory.initialize(); - } - } - if (contextFactory.getTargetWireFactories() != null) { - for (TargetWireFactory targetWireFactory : contextFactory.getTargetWireFactories() - .values()) { - targetWireFactory.initialize(); - } - } - } catch (WireFactoryInitException e) { - ProxyConfigurationException ce = new ProxyConfigurationException(e); - ce.addContextName(getName()); - throw ce; - } - - } - for (EntryPoint ep : newModule.getEntryPoints()) { - ContextFactory<Context> contextFactory = (ContextFactory<Context>) ep.getContextFactory(); - wireSource(contextFactory); - buildTarget(contextFactory); - contextFactory.prepare(this); - try { - if (contextFactory.getSourceWireFactories() != null) { - for (SourceWireFactory sourceWireFactory : contextFactory.getSourceWireFactories()) - { - sourceWireFactory.initialize(); - } - } - if (contextFactory.getTargetWireFactories() != null) { - for (TargetWireFactory targetWireFactory : contextFactory.getTargetWireFactories() - .values()) { - targetWireFactory.initialize(); - } - } - } catch (WireFactoryInitException e) { - ProxyConfigurationException ce = new ProxyConfigurationException(e); - ce.addContextName(getName()); - throw ce; - } - - } - for (ExternalService es : newModule.getExternalServices()) { - ContextFactory<Context> contextFactory = (ContextFactory<Context>) es.getContextFactory(); - wireSource(contextFactory); - buildTarget(contextFactory); - contextFactory.prepare(this); - try { - if (contextFactory.getSourceWireFactories() != null) { - for (SourceWireFactory sourceWireFactory : contextFactory.getSourceWireFactories()) - { - sourceWireFactory.initialize(); - } - } - if (contextFactory.getTargetWireFactories() != null) { - for (WireFactory targetWireFactory : contextFactory.getTargetWireFactories() - .values()) { - targetWireFactory.initialize(); - } - } - } catch (WireFactoryInitException e) { - ProxyConfigurationException ce = new ProxyConfigurationException(e); - ce.addContextName(getName()); - throw ce; - } - - } - - } - // merge existing module component assets - module.getComponents().addAll(oldModule.getComponents()); - module.getEntryPoints().addAll(oldModule.getEntryPoints()); - module.getExternalServices().addAll(oldModule.getExternalServices()); - } else { - if (model instanceof Component) { - Component component = (Component) model; - module.getComponents().add(component); - configuration = (ContextFactory<Context>) component.getContextFactory(); - if (configuration == null) { - ConfigurationException e = new MissingContextFactoryException("Context factory not set"); - e.setIdentifier(component.getName()); - e.addContextName(getName()); - throw e; - } - registerConfiguration(configuration); - if (component instanceof ModuleComponent) { - registerAutowire((ModuleComponent) component); - } else { - registerAutowire(component); - } - } else if (model instanceof EntryPoint) { - EntryPoint ep = (EntryPoint) model; - module.getEntryPoints().add(ep); - configuration = (ContextFactory<Context>) ep.getContextFactory(); - if (configuration == null) { - ConfigurationException e = new MissingContextFactoryException("Context factory not set"); - e.setIdentifier(ep.getName()); - e.addContextName(getName()); - throw e; - } - registerConfiguration(configuration); - registerAutowire(ep); - } else if (model instanceof ExternalService) { - ExternalService service = (ExternalService) model; - module.getExternalServices().add(service); - configuration = (ContextFactory<Context>) service.getContextFactory(); - if (configuration == null) { - ConfigurationException e = new MissingContextFactoryException("Context factory not set"); - e.setIdentifier(service.getName()); - e.addContextName(getName()); - throw e; - } - registerConfiguration(configuration); - registerAutowire(service); - } else { - BuilderConfigException e = new BuilderConfigException("Unknown model type"); - e.setIdentifier(model.getClass().getName()); - e.addContextName(getName()); - throw e; - } - } - } - - protected void registerConfiguration(ContextFactory<Context> factory) throws ConfigurationException { - factory.prepare(this); - if (lifecycleState == RUNNING) { - if (scopeIndex.get(factory.getName()) != null) { - throw new DuplicateNameException(factory.getName()); - } - try { - ScopeContext scope = scopeContexts.get(factory.getScope()); - if (scope == null) { - ConfigurationException e = new MissingScopeException("Component has an unknown scope"); - e.addContextName(factory.getName()); - e.addContextName(getName()); - throw e; - } - scope.registerFactory(factory); - scopeIndex.put(factory.getName(), scope); - } catch (TuscanyRuntimeException e) { - e.addContextName(getName()); - throw e; - } - configurations.put(factory.getName(), factory); // xcv - } else { - if (configurations.get(factory.getName()) != null) { - throw new DuplicateNameException(factory.getName()); - } - configurations.put(factory.getName(), factory); - } - - } - - public void fireEvent(int eventType, Object message) throws EventException { - throw new UnsupportedOperationException(); - } - - public void publish(Event event) { - checkInit(); - if (event instanceof SessionBound) { - SessionEvent sessionEvent = ((SessionBound) event); - // update context - eventContext.setIdentifier(sessionEvent.getSessionTypeIdentifier(), sessionEvent.getId()); - } else if (event instanceof RequestEnd) { - // be very careful with pooled threads, ensuring threadlocals are cleaned up - eventContext.clearIdentifiers(); - } - super.publish(event); - } - - public Context getContext(String componentName) { - checkInit(); - assert (componentName != null) : "Name was null"; - ScopeContext scope = scopeIndex.get(componentName); - if (scope == null) { - return null; - } - return scope.getContext(componentName); - - } - - public Object getInstance(QualifiedName qName) throws TargetException { - assert (qName != null) : "Name was null "; - // use the port name to get the context since entry points ports - ScopeContext scope = scopeIndex.get(qName.getPortName()); - if (scope == null) { - return null; - } - Context ctx = scope.getContext(qName.getPortName()); - if (!(ctx instanceof EntryPointContext)) { - TargetException e = new TargetException("Target not an entry point"); - e.setIdentifier(qName.getQualifiedName()); - e.addContextName(name); - throw e; - } - return ctx.getInstance(null); - } - - public Map<Scope, ScopeContext> getScopeContexts() { - initializeScopes(); - return immutableScopeContexts; - } - - /** - * Blocks until the module context has been initialized - */ - protected void checkInit() { - if (lifecycleState == STOPPED) { - throw new IllegalStateException("Context cannot be restarted - create a new one"); - } - if (!initialized) { - try { - /* block until the module has initialized */ - boolean success = initializeLatch.await(DEFAULT_WAIT, TimeUnit.MILLISECONDS); - if (!success) { - throw new ContextInitException("Timeout waiting for module context to initialize"); - } - } catch (InterruptedException e) { // should not happen - } - } - - } - - protected void initializeScopes() { - if (scopeContexts == null) { - scopeContexts = scopeStrategy.getScopeContexts(eventContext); - immutableScopeContexts = Collections.unmodifiableMap(scopeContexts); - } - } - - /** - * Iterates through references and delegates to the configuration context to wire them to their targets - */ - protected void wireSource(ContextFactory<Context> source) { - Scope sourceScope = source.getScope(); - if (source.getSourceWireFactories() != null) { - for (SourceWireFactory<?> sourceFactory : source.getSourceWireFactories()) { - WireConfiguration wireConfiguration = sourceFactory.getConfiguration(); - QualifiedName targetName = wireConfiguration.getTargetName(); - ContextFactory<?> target = configurations.get(targetName.getPartName()); - if (target == null) { - ContextInitException e = new ContextInitException("Target not found"); - e.setIdentifier(targetName.getPartName()); - e.addContextName(source.getName()); - e.addContextName(name); - throw e; - } - // get the proxy chain for the target - TargetWireFactory targetFactory = target.getTargetWireFactory(targetName.getPortName()); - if (targetFactory == null) { - ContextInitException e = new ContextInitException("No proxy factory found for service"); - e.setIdentifier(wireConfiguration.getTargetName().getPortName()); - e.addContextName(target.getName()); - e.addContextName(source.getName()); - e.addContextName(name); - throw e; - } - try { - boolean downScope = scopeStrategy.downScopeReference(sourceScope, target.getScope()); - configurationContext.connect(sourceFactory, targetFactory, target.getClass(), downScope, scopeContexts - .get(target.getScope())); - } catch (BuilderConfigException e) { - e.addContextName(target.getName()); - e.addContextName(source.getName()); - e.addContextName(name); - throw e; - } - - } - } - // wire invokers when the proxy only contains the target chain - if (source.getTargetWireFactories() != null) { - for (TargetWireFactory targetFactory : source.getTargetWireFactories().values()) { - try { - configurationContext.completeTargetChain(targetFactory, source.getClass(), scopeContexts.get(sourceScope)); - } catch (BuilderConfigException e) { - e.addContextName(source.getName()); - e.addContextName(name); - throw e; - } - } - } - } - - /** - * Signals to target side of reference configurations to initialize - */ - protected void buildTarget(ContextFactory<?> target) { - Map<String, TargetWireFactory> targetProxyFactories = target.getTargetWireFactories(); - if (targetProxyFactories != null) { - for (TargetWireFactory<?> targetFactory : targetProxyFactories.values()) { - for (InvocationConfiguration iConfig : targetFactory - .getConfiguration().getInvocationConfigurations().values()) { - iConfig.build(); - } - } - } - } - - protected void initializeWireFactories() throws WireFactoryInitException { - for (ContextFactory<?> config : configurations.values()) { - List<SourceWireFactory> sourceProxyFactories = config.getSourceWireFactories(); - if (sourceProxyFactories != null) { - for (WireFactory<?> sourceWireFactory : sourceProxyFactories) { - sourceWireFactory.initialize(); - } - } - if (sourceProxyFactories != null) { - Map<String, TargetWireFactory> targetWireFactories = config.getTargetWireFactories(); - for (TargetWireFactory<?> targetWireFactory : targetWireFactories.values()) { - targetWireFactory.initialize(); - } - } - } - } - - public Composite getComposite() { - return module; - } - - @Autowire - public void setAutowireContext(AutowireContext context) { - autowireContext = context; - } - - public <T> T resolveInstance(Class<T> instanceInterface) throws AutowireResolutionException { - if (ConfigurationContext.class.equals(instanceInterface)) { - return instanceInterface.cast(this); - } else if (AutowireContext.class.equals(instanceInterface)) { - return instanceInterface.cast(this); - } else if (AssemblyContext.class.equals(instanceInterface)) { - return instanceInterface.cast(assemblyContext); - } - - NameToScope nts = autowireInternal.get(instanceInterface); - if (nts != null) { - try { - return instanceInterface.cast(nts.getScopeContext().getInstance(nts.getName())); - } catch (TargetException e) { - AutowireResolutionException ae = new AutowireResolutionException("Autowire instance not found", e); - ae.addContextName(getName()); - throw ae; - } - } else if (autowireContext != null) { - try { - // resolve to parent - return autowireContext.resolveInstance(instanceInterface); - } catch (AutowireResolutionException e) { - e.addContextName(getName()); - throw e; - } - } else { - return null; - } - } - - public <T> T resolveExternalInstance(Class<T> instanceInterface) throws AutowireResolutionException { - NameToScope nts = autowireExternal.get(instanceInterface); - if (nts != null) { - try { - return instanceInterface.cast(nts.getScopeContext().getInstance(nts.getName())); - } catch (TargetException e) { - AutowireResolutionException ae = new AutowireResolutionException("Autowire instance not found", e); - ae.addContextName(getName()); - throw ae; - } - } else { - return null; - } - } - - private void registerAutowire(ExternalService service) { - } - - private void registerAutowire(ModuleComponent component) { - for (EntryPoint ep : component.getImplementation().getEntryPoints()) { - for (Binding binding : ep.getBindings()) { - if (binding instanceof SystemBinding) { - Class interfaze = ep.getConfiguredService().getPort().getServiceContract().getInterface(); - ScopeContext scope = scopeContexts.get(Scope.AGGREGATE); - String qname = component.getName() + QualifiedName.NAME_SEPARATOR + ep.getName(); - registerAutowireInternal(interfaze, qname, scope); - } - } - } - } - - private void registerAutowire(Component component) { - for (Service service : component.getImplementation().getComponentType().getServices()) { - Class interfaze = service.getServiceContract().getInterface(); - ScopeContext scopeCtx = scopeContexts.get(service.getServiceContract().getScope()); - registerAutowireInternal(interfaze, component.getName(), scopeCtx); - } - } - - protected void registerAutowireInternal(Class<?> interfaze, String name, ScopeContext scopeContext) { - assert interfaze != null; - if (autowireInternal.containsKey(interfaze)) { - return; - } - QualifiedName qname = new QualifiedName(name); - NameToScope nts = new NameToScope(qname, scopeContext); - autowireInternal.put(interfaze, nts); - } - - private void registerAutowire(EntryPoint ep) { - for (Binding binding : ep.getBindings()) { - if (binding instanceof SystemBinding) { - Class interfaze = ep.getConfiguredService().getPort().getServiceContract().getInterface(); - ScopeContext scope = scopeContexts.get(((ContextFactory) ep.getContextFactory()).getScope()); - registerAutowireExternal(interfaze, ep.getName(), scope); - } - } - } - - protected void registerAutowireExternal(Class<?> interfaze, String name, ScopeContext scopeContext) { - assert interfaze != null; - if (autowireExternal.containsKey(interfaze)) { - return; - } - QualifiedName qname = new QualifiedName(name); - NameToScope nts = new NameToScope(qname, scopeContext); - autowireExternal.put(interfaze, nts); - } - - protected static class NameToScope { - - private final QualifiedName qName; - - private final ScopeContext scope; - - public NameToScope(QualifiedName name, ScopeContext scope) { - this.qName = name; - this.scope = scope; - } - - public QualifiedName getName() { - return qName; - } - - public ScopeContext getScopeContext() { - return scope; - } - } - - - public void build(AssemblyObject model) throws BuilderConfigException { - if (configurationContext != null) { - try { - configurationContext.build(model); - } catch (BuilderConfigException e) { - e.addContextName(getName()); - throw e; - } - } - } - - public void connect(SourceWireFactory sourceFactory, TargetWireFactory targetFactory, Class targetType, boolean downScope, - ScopeContext targetScopeContext) throws BuilderConfigException { - if (configurationContext != null) { - try { - configurationContext.connect(sourceFactory, targetFactory, targetType, downScope, targetScopeContext); - } catch (BuilderConfigException e) { - e.addContextName(getName()); - throw e; - } - } - } - - public void completeTargetChain(TargetWireFactory targetFactory, Class targetType, ScopeContext targetScopeContext) - throws BuilderConfigException { - if (configurationContext != null) { - try { - configurationContext.completeTargetChain(targetFactory, targetType, targetScopeContext); - } catch (BuilderConfigException e) { - e.addContextName(getName()); - throw e; - } - } - } - - - public void removeContext(String name){ - configurations.remove(name); - ScopeContext ctx = scopeIndex.remove(name); - if (ctx != null){ - ctx.removeContext(name); - } - - } -} diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/impl/AbstractContext.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/impl/AbstractContext.java deleted file mode 100644 index 680267d53e..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/impl/AbstractContext.java +++ /dev/null @@ -1,45 +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.context.impl; - -import org.apache.tuscany.core.context.Context; -import org.apache.tuscany.core.context.RuntimeEventListener; -import org.apache.tuscany.core.context.EventFilter; -import org.apache.tuscany.core.context.event.Event; -import org.apache.tuscany.core.context.filter.TrueFilter; - -import java.util.List; -import java.util.Map; -import java.util.concurrent.CopyOnWriteArrayList; -import java.util.concurrent.ConcurrentHashMap; - -/** - * Functionality common to all <code>Context<code> implementations - * - * @version $Rev$ $Date$ - */ -public abstract class AbstractContext extends AbstractLifecycle implements Context { - - public AbstractContext() { - } - - public AbstractContext(String name) { - super(name); - } - - -} diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/impl/AbstractLifecycle.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/impl/AbstractLifecycle.java deleted file mode 100644 index ddeebe361f..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/impl/AbstractLifecycle.java +++ /dev/null @@ -1,129 +0,0 @@ -/** - * - * 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.context.impl; - -import java.util.List; -import java.util.Map; -import java.util.concurrent.CopyOnWriteArrayList; -import java.util.concurrent.ConcurrentHashMap; - -import org.apache.tuscany.core.context.RuntimeEventListener; -import org.apache.tuscany.core.context.EventFilter; -import org.apache.tuscany.core.context.Lifecycle; -import org.apache.tuscany.core.context.filter.TrueFilter; -import org.apache.tuscany.core.context.event.Event; - -/** - * @version $Rev$ $Date$ - */ -public class AbstractLifecycle { - private static final EventFilter TRUE_FILTER = new TrueFilter(); - protected String name; - protected int lifecycleState = Lifecycle.UNINITIALIZED; - // Listeners for context events - private Map<EventFilter, List<RuntimeEventListener>> listeners; - - public AbstractLifecycle(String name) { - this.name = name; - } - - public AbstractLifecycle() { - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public int getLifecycleState() { - return lifecycleState; - } - - public void addListener(RuntimeEventListener listener) { - addListener(TRUE_FILTER, listener); - } - - public void removeListener(RuntimeEventListener listener) { - assert (listener != null) : "Listener cannot be null"; - synchronized(getListeners()){ - for (List<RuntimeEventListener> currentList :getListeners().values() ) { - for(RuntimeEventListener current : currentList){ - if (current == listener){ - currentList.remove(current); - return; - } - } - } - } - } - - public void addListener(EventFilter filter, RuntimeEventListener listener){ - assert (listener != null) : "Listener cannot be null"; - synchronized (getListeners()){ - List<RuntimeEventListener> list = getListeners().get(filter); - if (list == null){ - list = new CopyOnWriteArrayList<RuntimeEventListener>(); - listeners.put(filter,list); - } - list.add(listener); - } - } - - public void publish(Event event){ - assert(event != null): "Event object was null"; - for(Map.Entry<EventFilter,List<RuntimeEventListener>> entry :getListeners().entrySet()){ - if(entry.getKey().match(event)){ - for(RuntimeEventListener listener : entry.getValue()){ - listener.onEvent(event); - } - } - } - } - - protected Map<EventFilter, List<RuntimeEventListener>> getListeners(){ - if (listeners == null) { - listeners = new ConcurrentHashMap<EventFilter, List<RuntimeEventListener>>(); - } - return listeners; - } - - public String toString() { - switch (lifecycleState) { - case (Lifecycle.CONFIG_ERROR): - return "Context [" + name + "] in state [CONFIG_ERROR]"; - case (Lifecycle.ERROR): - return "Context [" + name + "] in state [ERROR]"; - case (Lifecycle.INITIALIZING): - return "Context [" + name + "] in state [INITIALIZING]"; - case (Lifecycle.INITIALIZED): - return "Context [" + name + "] in state [INITIALIZED]"; - case (Lifecycle.RUNNING): - return "Context [" + name + "] in state [RUNNING]"; - case (Lifecycle.STOPPING): - return "Context [" + name + "] in state [STOPPING]"; - case (Lifecycle.STOPPED): - return "Context [" + name + "] in state [STOPPED]"; - case (Lifecycle.UNINITIALIZED): - return "Context [" + name + "] in state [UNINITIALIZED]"; - default: - return "Context [" + name + "] in state [UNKNOWN]"; - } - } -} diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/impl/CompositeContextImpl.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/impl/CompositeContextImpl.java deleted file mode 100644 index ec3d1bc9c0..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/impl/CompositeContextImpl.java +++ /dev/null @@ -1,113 +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.context.impl; - -import org.osoa.sca.ModuleContext; -import org.osoa.sca.RequestContext; -import org.osoa.sca.ServiceReference; -import org.osoa.sca.ServiceUnavailableException; - -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.Context; -import org.apache.tuscany.core.context.EventContext; -import org.apache.tuscany.core.context.QualifiedName; -import org.apache.tuscany.core.context.ScopeContext; -import org.apache.tuscany.core.context.ScopeStrategy; -import org.apache.tuscany.core.context.ServiceNotFoundException; -import org.apache.tuscany.core.context.TargetException; -import org.apache.tuscany.core.system.annotation.Autowire; - -/** - * The standard implementation of an composite context. Autowiring is performed by delegating to the parent context. - * - * @version $Rev$ $Date$ - */ -public class CompositeContextImpl extends AbstractCompositeContext implements ModuleContext { - - @Autowire - public void setScopeStrategy(ScopeStrategy scopeStrategy) { - if (scopeStrategy != null) { - this.scopeStrategy = scopeStrategy; - } - } - - public CompositeContextImpl() { - super(); - eventContext = new EventContextImpl(); - } - - public CompositeContextImpl(String name, CompositeContext parent, ScopeStrategy strategy, EventContext ctx, - ConfigurationContext configCtx) { - super(name, parent, strategy, ctx, configCtx); - } - - public CompositeContextImpl(String name, CompositeContext parent, AutowireContext autowireContext, ScopeStrategy strategy, - EventContext ctx, ConfigurationContext configCtx) { - super(name, parent, strategy, ctx, configCtx); - setAutowireContext(autowireContext); - } - - // ---------------------------------- - // ModuleContext methods - // ---------------------------------- - - public Object locateService(String qualifiedName) throws ServiceUnavailableException { - checkInit(); - QualifiedName qName = new QualifiedName(qualifiedName); - ScopeContext scope = scopeIndex.get(qName.getPartName()); - if (scope == null) { - throw new ServiceNotFoundException(qualifiedName); - } - Context ctx = scope.getContext(qName.getPartName()); - try { - Object o = ctx.getInstance(qName); - if (o == null) { - throw new ServiceNotFoundException(qualifiedName); - } - return o; - } catch (TargetException e) { - e.addContextName(getName()); - throw new ServiceNotFoundException(e); - } - } - - public ServiceReference createServiceReference(String serviceName) { - throw new UnsupportedOperationException(); - } - - public RequestContext getRequestContext() { - throw new UnsupportedOperationException(); - } - - public ServiceReference createServiceReferenceForSession(Object self) { - throw new UnsupportedOperationException(); - } - - public ServiceReference createServiceReferenceForSession(Object self, String serviceName) { - throw new UnsupportedOperationException(); - } - - public ServiceReference newSession(String serviceName) { - throw new UnsupportedOperationException(); - } - - public ServiceReference newSession(String serviceName, Object sessionId) { - throw new UnsupportedOperationException(); - } -} diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/impl/EntryPointContextImpl.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/impl/EntryPointContextImpl.java deleted file mode 100644 index d1ad7a5548..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/impl/EntryPointContextImpl.java +++ /dev/null @@ -1,90 +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.context.impl; - -import org.apache.tuscany.core.context.QualifiedName; -import org.apache.tuscany.core.context.TargetException; -import org.apache.tuscany.core.context.EntryPointContext; -import org.apache.tuscany.core.context.ContextInitException; -import org.apache.tuscany.core.context.CoreRuntimeException; -import org.apache.tuscany.core.wire.jdk.JDKInvocationHandler; -import org.apache.tuscany.core.wire.ProxyCreationException; -import org.apache.tuscany.core.wire.SourceWireFactory; -import org.apache.tuscany.core.message.MessageFactory; - -import java.lang.reflect.InvocationHandler; - -/** - * The default implementation of an entry point context - * - * @version $Rev$ $Date$ - */ -public class EntryPointContextImpl extends AbstractContext implements EntryPointContext { - - private SourceWireFactory<?> sourceWireFactory; - - - private InvocationHandler invocationHandler; - - // a proxy implementing the service exposed by the entry point backed by the invocation handler - private Object proxy; - - /** - * Creates a new entry point - * - * @param name the entry point name - * @param sourceWireFactory the proxy factory containing the invocation chains for the entry point - * @param messageFactory a factory for generating invocation messages - * @throws ContextInitException if an error occurs creating the entry point - */ - public EntryPointContextImpl(String name, SourceWireFactory sourceWireFactory, MessageFactory messageFactory) - throws ContextInitException { - super(name); - assert (sourceWireFactory != null) : "Proxy factory was null"; - assert (messageFactory != null) : "Message factory was null"; - this.sourceWireFactory = sourceWireFactory; - invocationHandler = new JDKInvocationHandler(messageFactory, sourceWireFactory.getConfiguration() - .getInvocationConfigurations()); - } - - public Object getInstance(QualifiedName qName) throws TargetException { - if (proxy == null) { - try { - proxy = sourceWireFactory.createProxy(); - } catch (ProxyCreationException e) { - TargetException te = new TargetException(e); - te.addContextName(getName()); - throw te; - } - } - return proxy; - } - - public void start() throws ContextInitException { - lifecycleState = RUNNING; - } - - public void stop() throws CoreRuntimeException { - lifecycleState = STOPPED; - } - - public Object getHandler() throws TargetException { - return invocationHandler; - } - - public Class getServiceInterface() { - return sourceWireFactory.getBusinessInterface(); - } - -} diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/impl/EventContextImpl.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/impl/EventContextImpl.java deleted file mode 100644 index 6888e66f20..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/impl/EventContextImpl.java +++ /dev/null @@ -1,81 +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.context.impl; - -import org.apache.tuscany.core.context.EventContext; -import org.apache.tuscany.core.context.ScopeIdentifier; - -import java.util.HashMap; -import java.util.Map; - -/** - * An implementation of an {@link org.apache.tuscany.core.context.EventContext} that handles event-to-thread associations using an - * <code>InheritableThreadLocal</code> - * - * @version $Rev$ $Date$ - */ -public class EventContextImpl implements EventContext { - - // @TODO design a proper propagation strategy for creating new threads - /* - * a map ( associated with the current thread) of scope identifiers keyed on the event context id type. the scope identifier - * may be a {@link ScopeIdentifier} or an opaque id - */ - private ThreadLocal<Map> eventContext = new InheritableThreadLocal<Map>(); - - public Object getIdentifier(Object type) { - Map map = eventContext.get(); - if (map == null) { - return null; - } - Object currentId = map.get(type); - if (currentId instanceof ScopeIdentifier) { - currentId = ((ScopeIdentifier) currentId).getIdentifier(); - // once we have accessed the id, replace the lazy wrapper - map.put(type, currentId); - } - return currentId; - } - - public void setIdentifier(Object type, Object identifier) { - Map map = eventContext.get(); - if (map == null) { - map = new HashMap(); - eventContext.set(map); - } - map.put(type, identifier); - } - - public void clearIdentifier(Object type) { - if (type == null) { - return; - } - Map map = eventContext.get(); - if (map != null) { - map.remove(type); - } - } - - public void clearIdentifiers() { - eventContext.remove(); - } - - public EventContextImpl() { - super(); - } - -} diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/impl/ExternalServiceContextImpl.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/impl/ExternalServiceContextImpl.java deleted file mode 100644 index 0ab44fa8fc..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/impl/ExternalServiceContextImpl.java +++ /dev/null @@ -1,75 +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.context.impl; - -import org.apache.tuscany.core.builder.ObjectFactory; -import org.apache.tuscany.core.context.QualifiedName; -import org.apache.tuscany.core.context.TargetException; -import org.apache.tuscany.core.context.CoreRuntimeException; -import org.apache.tuscany.core.context.ExternalServiceContext; -import org.apache.tuscany.core.wire.ProxyCreationException; -import org.apache.tuscany.core.wire.TargetWireFactory; - -/** - * The default implementation of an external service context - * - * @version $Rev$ $Date$ - */ -public class ExternalServiceContextImpl extends AbstractContext implements ExternalServiceContext { - - private TargetWireFactory<?> targetWireFactory; - - private ObjectFactory targetInstanceFactory; - - /** - * Creates an external service context - * - * @param name the name of the external service - * @param targetWireFactory the factory which creates proxies implementing the configured service interface for the - * external service. There is always only one proxy factory as an external service is configured with one - * service - * @param targetInstanceFactory the object factory that creates an artifact capabile of communicating over the - * binding transport configured on the external service. The object factory may implement a caching strategy. - */ - public ExternalServiceContextImpl(String name, TargetWireFactory targetWireFactory, ObjectFactory targetInstanceFactory) { - super(name); - assert (targetInstanceFactory != null) : "Target instance factory was null"; - this.targetWireFactory = targetWireFactory; - this.targetInstanceFactory = targetInstanceFactory; - } - - public void start() throws CoreRuntimeException { - lifecycleState = RUNNING; - } - - public void stop() throws CoreRuntimeException { - lifecycleState = STOPPED; - } - - - public Object getInstance(QualifiedName qName) throws TargetException { - try { - return targetWireFactory.createProxy(); - // TODO do we cache the proxy, (assumes stateful capabilities will be provided in an interceptor) - } catch (ProxyCreationException e) { - TargetException te = new TargetException(e); - te.addContextName(getName()); - throw te; - } - } - - public Object getHandler() throws TargetException { - return targetInstanceFactory.getInstance(); - } -} diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/scope/AbstractScopeContext.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/scope/AbstractScopeContext.java deleted file mode 100644 index 7eed472101..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/scope/AbstractScopeContext.java +++ /dev/null @@ -1,74 +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.context.scope; - -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import org.apache.tuscany.core.builder.ContextFactory; -import org.apache.tuscany.core.context.Context; -import org.apache.tuscany.core.context.EventContext; -import org.apache.tuscany.core.context.QualifiedName; -import org.apache.tuscany.core.context.ScopeContext; -import org.apache.tuscany.core.context.TargetException; -import org.apache.tuscany.core.context.impl.AbstractLifecycle; - -/** - * Implements functionality common to scope contexts. - * - * @version $Rev$ $Date$ - */ -public abstract class AbstractScopeContext extends AbstractLifecycle implements ScopeContext { - - // The collection of runtime configurations for the scope - protected Map<String, ContextFactory<Context>> contextFactories = new ConcurrentHashMap<String, ContextFactory<Context>>(); - - // The event context the scope container is associated with - protected EventContext eventContext; - - public AbstractScopeContext(EventContext eventContext) { - assert (eventContext != null) : "Event context was null"; - this.eventContext = eventContext; - } - - public void registerFactories(List<ContextFactory<Context>> configurations) { - for (ContextFactory<Context> configuration : configurations) { - contextFactories.put(configuration.getName(), configuration); - } - } - - public Object getInstance(QualifiedName qName) throws TargetException { - Context context = getContext(qName.getPartName()); - if (context == null) { - TargetException e = new TargetException("Target not found"); - e.setIdentifier(qName.getQualifiedName()); - throw e; - } - return context.getInstance(qName); - } - - protected void checkInit() { - if (getLifecycleState() != RUNNING) { - throw new IllegalStateException("Scope not running [" + getLifecycleState() + "]"); - } - } - - protected EventContext getEventContext() { - return eventContext; - } -} diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/scope/AbstractScopeStrategy.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/scope/AbstractScopeStrategy.java deleted file mode 100644 index f89d09196d..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/scope/AbstractScopeStrategy.java +++ /dev/null @@ -1,67 +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.context.scope; - -import org.apache.tuscany.core.context.ScopeStrategy; -import org.apache.tuscany.model.assembly.Scope; - -/** - * Implements basic scope strategy functionality - * - * @version $Rev$ $Date$ - */ -public abstract class AbstractScopeStrategy implements ScopeStrategy { - - public AbstractScopeStrategy() { - } - - /** - * Determines legal scope references according to standard SCA scope rules - * - * @param pReferrer the scope of the component making the reference - * @param pReferee the scope of the component being referred to - */ - public boolean downScopeReference(Scope pReferrer, Scope pReferee) { - if (pReferrer == Scope.UNDEFINED || pReferee == Scope.UNDEFINED) { - return false; - } - if (pReferee == pReferrer){ - return false; - }else if(pReferrer == Scope.INSTANCE){ - return false; - }else if(pReferee == Scope.INSTANCE){ - return true; - }else if (pReferrer == Scope.REQUEST && pReferee == Scope.SESSION){ - return false; - }else if (pReferrer == Scope.REQUEST && pReferee == Scope.MODULE){ - return false; -// }else if (pReferrer == Scope.SESSION && pReferee == Scope.REQUEST){ -// return true; - }else if (pReferrer == Scope.SESSION && pReferee == Scope.MODULE){ - return false; -// }else if (pReferrer == Scope.MODULE){ -// return true; - }else{ - return true; - } - //FIXME Jim this does not work with enumerations, what does it mean to have a scope <0? -// } else if ((pReferrer < 0) || (pReferee < 0)) { -// return false; -// } -// -// return (pReferrer > pReferee); -// return pReferrer != pReferee; - } - -} diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/scope/CompositeScopeContext.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/scope/CompositeScopeContext.java deleted file mode 100644 index 7468ff9dd6..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/scope/CompositeScopeContext.java +++ /dev/null @@ -1,156 +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.context.scope; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import org.apache.tuscany.core.builder.ContextFactory; -import org.apache.tuscany.core.context.CompositeContext; -import org.apache.tuscany.core.context.Context; -import org.apache.tuscany.core.context.EventContext; -import org.apache.tuscany.core.context.QualifiedName; -import org.apache.tuscany.core.context.ScopeContext; -import org.apache.tuscany.core.context.ScopeInitializationException; -import org.apache.tuscany.core.context.ScopeRuntimeException; -import org.apache.tuscany.core.context.TargetException; -import org.apache.tuscany.core.context.event.Event; -import org.apache.tuscany.core.context.event.ModuleStart; -import org.apache.tuscany.core.context.event.ModuleStop; -import org.apache.tuscany.core.context.impl.AbstractLifecycle; - -/** - * Manages the lifecycle of composite component contexts, i.e. contexts which contain child contexts - * - * @see org.apache.tuscany.core.context.CompositeContext - * @version $Rev$ $Date$ - */ -public class CompositeScopeContext extends AbstractLifecycle implements ScopeContext { - - private List<ContextFactory<Context>> configs = new ArrayList<ContextFactory<Context>>(); - - // Composite component contexts in this scope keyed by name - private Map<String, CompositeContext> contexts = new ConcurrentHashMap<String, CompositeContext>(); - - // indicates if a module start event has been previously propagated so child contexts added after can be notified - private boolean moduleScopeStarted; - - public CompositeScopeContext(EventContext eventContext) { - assert (eventContext != null) : "Event context was null"; - setName("Composite Scope"); - } - - public void start() throws ScopeInitializationException { - for (ContextFactory<Context> configuration : configs) { - Context context = configuration.createContext(); - if (!(context instanceof CompositeContext)) { - ScopeInitializationException e = new ScopeInitializationException("Context not an composite type"); - e.addContextName(context.getName()); - throw e; - } - CompositeContext compositeCtx = (CompositeContext) context; - compositeCtx.start(); - contexts.put(compositeCtx.getName(), compositeCtx); - } - lifecycleState = RUNNING; - } - - public void stop() throws ScopeRuntimeException { - for (CompositeContext context : contexts.values()) { - context.stop(); - } - } - - public void registerFactories(List<ContextFactory<Context>> configurations) { - this.configs = configurations; - } - - public void registerFactory(ContextFactory<Context> configuration) { - assert (configuration != null) : "Configuration was null"; - configs.add(configuration); - if (getLifecycleState() == RUNNING) { - Context context = configuration.createContext(); - if (!(context instanceof CompositeContext)) { - ScopeInitializationException e = new ScopeInitializationException("Context not an composite type"); - e.setIdentifier(context.getName()); - throw e; - } - CompositeContext compositeCtx = (CompositeContext) context; - compositeCtx.start(); - if (moduleScopeStarted) { - compositeCtx.publish(new ModuleStart(this)); - } - contexts.put(compositeCtx.getName(), compositeCtx); - } - } - - public boolean isCacheable() { - return false; - } - - public Object getInstance(QualifiedName qName) throws TargetException { - Context context = getContext(qName.getPartName()); - if (context == null) { - TargetException e = new TargetException("Component not found"); - e.setIdentifier(qName.getQualifiedName()); - throw e; - } - return context.getInstance(qName); - } - - public Context getContext(String ctxName) { - checkInit(); - return contexts.get(ctxName); - } - - public Context getContextByKey(String ctxName, Object key) { - return getContext(ctxName); - } - - public void removeContext(String ctxName) throws ScopeRuntimeException { - Context context = contexts.remove(ctxName); - if (context != null) { - context.stop(); - } - } - - public void removeContextByKey(String ctxName, Object key) throws ScopeRuntimeException { - throw new UnsupportedOperationException(); - } - - public void onEvent(Event event){ - if (event instanceof ModuleStart) { - // track module starting so that composite contexts registered after the event are notified properly - moduleScopeStarted = true; - } else if (event instanceof ModuleStop) { - moduleScopeStarted = false; - publish(event); - } - // propagate events to child contexts - for (CompositeContext context : contexts.values()) { - context.publish(event); - } - } - - private void checkInit() { - if (getLifecycleState()!= RUNNING) { - throw new IllegalStateException("Scope not running [" + getLifecycleState() + "]"); - } - } -} diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/scope/DefaultScopeStrategy.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/scope/DefaultScopeStrategy.java deleted file mode 100644 index 1f386fd35f..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/scope/DefaultScopeStrategy.java +++ /dev/null @@ -1,52 +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.context.scope; - -import org.apache.tuscany.core.context.EventContext; -import org.apache.tuscany.core.context.ScopeContext; -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 the default module scopes: stateless, request, session, - * and module. - * - * @version $Rev$ $Date$ - */ -public class DefaultScopeStrategy extends AbstractScopeStrategy { - - public DefaultScopeStrategy() { - } - - public Map<Scope,ScopeContext> getScopeContexts(EventContext eventContext) { - ScopeContext moduleScope = new ModuleScopeContext(eventContext); - ScopeContext sessionScope = new SessionScopeContext(eventContext); - ScopeContext requestScope = new RequestScopeContext(eventContext); - ScopeContext statelessScope = new StatelessScopeContext(eventContext); - ScopeContext aggregrateScope = new CompositeScopeContext(eventContext); - Map<Scope,ScopeContext> scopes = new HashMap<Scope,ScopeContext>(); - scopes.put(Scope.MODULE,moduleScope); - scopes.put(Scope.SESSION,sessionScope); - scopes.put(Scope.REQUEST,requestScope); - scopes.put(Scope.INSTANCE,statelessScope); - scopes.put(Scope.AGGREGATE,aggregrateScope); - return scopes; - } - -} diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/scope/ModuleScopeContext.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/scope/ModuleScopeContext.java deleted file mode 100644 index dbb342bb5a..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/scope/ModuleScopeContext.java +++ /dev/null @@ -1,194 +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.context.scope; - -import org.apache.tuscany.core.builder.ContextFactory; -import org.apache.tuscany.core.context.AtomicContext; -import org.apache.tuscany.core.context.Context; -import org.apache.tuscany.core.context.CoreRuntimeException; -import org.apache.tuscany.core.context.EventContext; -import org.apache.tuscany.core.context.TargetException; -import org.apache.tuscany.core.context.Lifecycle; -import org.apache.tuscany.core.context.event.InstanceCreated; -import org.apache.tuscany.core.context.event.Event; -import org.apache.tuscany.core.context.event.ModuleStart; -import org.apache.tuscany.core.context.event.ModuleStop; - -import java.util.Map; -import java.util.List; -import java.util.ArrayList; -import java.util.ListIterator; -import java.util.concurrent.ConcurrentHashMap; - -/** - * Manages contexts whose implementations are module scoped. This scope contexts eagerly starts contexts when - * a {@link ModuleStart} event is received. If a contained context has an implementation marked to eagerly initialized, - * the an instance will be created at that time as well. Contained contexts are shutdown when a {@link ModuleStop} - * event is received in reverse order to which their implementation instances were created. - * - * @version $Rev$ $Date$ - */ -public class ModuleScopeContext extends AbstractScopeContext { - - // Component contexts in this scope keyed by name - private Map<String, Context> contexts; - - // the queue of contexts to destroy, in the order that their instances were created - private List<Context> destroyQueue; - - public ModuleScopeContext(EventContext eventContext) { - super(eventContext); - setName("Module Scope"); - } - - public void onEvent(Event event) { - if (event instanceof ModuleStart) { - lifecycleState = RUNNING; - initComponentContexts(); - } else if (event instanceof ModuleStop) { - shutdownContexts(); - } else if (event instanceof InstanceCreated) { - checkInit(); - if (event.getSource() instanceof Context) { - Context context = (Context) event.getSource(); - // Queue the context to have its implementation instance released if destroyable - destroyQueue.add(context); - } - } - } - - public synchronized void start() { - if (lifecycleState != UNINITIALIZED) { - throw new IllegalStateException("Scope must be in UNINITIALIZED state [" + lifecycleState + "]"); - } - } - - public synchronized void stop() { - if (lifecycleState != RUNNING) { - throw new IllegalStateException("Scope in wrong state [" + lifecycleState + "]"); - } - contexts = null; - destroyQueue = null; - lifecycleState = STOPPED; - } - - public boolean isCacheable() { - return true; - } - - public void registerFactory(ContextFactory<Context> configuration) { - contextFactories.put(configuration.getName(), configuration); - if (lifecycleState == RUNNING) { - contexts.put(configuration.getName(), configuration.createContext()); - } - } - - public Context getContext(String ctxName) { - checkInit(); - initComponentContexts(); - return contexts.get(ctxName); - } - - public Context getContextByKey(String ctxName, Object key) { - checkInit(); - initComponentContexts(); - return contexts.get(ctxName); - } - - public void removeContext(String ctxName) { - checkInit(); - if (contexts == null){ - return; - } - Context context = contexts.remove(ctxName); - if (context != null) { - destroyQueue.remove(context); - } - } - - public void removeContextByKey(String ctxName, Object key){ - removeContext(ctxName); - } - - /** - * Notifies contexts of a shutdown in reverse order to which they were started - */ - private synchronized void shutdownContexts() { - if (destroyQueue == null || destroyQueue.size() == 0) { - return; - } - // shutdown destroyable instances in reverse instantiation order - ListIterator<Context> iter = destroyQueue.listIterator(destroyQueue.size()); - while(iter.hasPrevious()){ - Lifecycle context = iter.previous(); - if (context.getLifecycleState() == RUNNING) { - try { - if (context instanceof AtomicContext){ - ((AtomicContext)context).destroy(); - } - } catch (TargetException e) { - // TODO send a monitoring event - } - } - } - if (contexts == null){ - return; - } - for(Lifecycle context: contexts.values()) { - try { - if (context.getLifecycleState() == RUNNING) { - context.stop(); - } - } catch (CoreRuntimeException e){ - // TODO send monitoring event - } - } - contexts = null; - destroyQueue = null; - } - - /** - * Creates and starts components contexts in the module scope. Implementations marked to eagerly initialize will - * also be notified to do so. - * - * @throws CoreRuntimeException - */ - private synchronized void initComponentContexts() throws CoreRuntimeException { - if (contexts == null) { - contexts = new ConcurrentHashMap<String, Context>(); - destroyQueue = new ArrayList<Context>(); - for (ContextFactory<Context> config : contextFactories.values()) { - Context context = config.createContext(); - context.start(); - contexts.put(context.getName(), context); - } - // Initialize eager contexts. Note this cannot be done when we initially create each context since a component may - // contain a forward reference to a component which has not been instantiated - for (Context context : contexts.values()) { - if (context instanceof AtomicContext) { - AtomicContext atomic = (AtomicContext) context; - if (atomic.isEagerInit()) { - // perform silent creation and manual shutdown registration - atomic.init(); - destroyQueue.add(context); - } - } - context.addListener(this); - } - } - } -}
\ No newline at end of file diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/scope/RequestScopeContext.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/scope/RequestScopeContext.java deleted file mode 100644 index 67ce176af5..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/scope/RequestScopeContext.java +++ /dev/null @@ -1,228 +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.context.scope; - -import org.apache.tuscany.core.builder.ContextFactory; -import org.apache.tuscany.core.context.Context; -import org.apache.tuscany.core.context.CoreRuntimeException; -import org.apache.tuscany.core.context.EventContext; -import org.apache.tuscany.core.context.AtomicContext; -import org.apache.tuscany.core.context.TargetException; -import org.apache.tuscany.core.context.Lifecycle; -import org.apache.tuscany.core.context.event.InstanceCreated; -import org.apache.tuscany.core.context.event.Event; -import org.apache.tuscany.core.context.event.RequestEnd; -import org.apache.tuscany.core.context.event.RequestStart; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.ListIterator; -import java.util.concurrent.ConcurrentHashMap; - -/** - * An implementation of a request-scoped component container. This scope contexts eagerly starts contexts when - * a {@link org.apache.tuscany.core.context.event.RequestStart} event is received. If a contained context has an implementation marked to eagerly initialized, - * the an instance will be created at that time as well. Contained contexts are shutdown when a {@link org.apache.tuscany.core.context.event.RequestEnd} - * event is received in reverse order to which their implementation instances were created. - * - * @version $Rev$ $Date$ - */ -public class RequestScopeContext extends AbstractScopeContext { - - // A collection of service component contexts keyed by thread. Note this could have been implemented with a ThreadLocal but - // using a Map allows finer-grained concurrency. - private Map<Object, Map<String, Context>> contexts; - - // stores ordered lists of contexts to shutdown for each thread. - private Map<Object, List<Context>> destroyQueues; - - public RequestScopeContext(EventContext eventContext) { - super(eventContext); - setName("Request Scope"); - } - - public void onEvent(Event event){ - if (event instanceof RequestStart){ - getContexts(); // eager load - }else if (event instanceof RequestEnd){ - checkInit(); - getEventContext().clearIdentifiers(); // clean up current context for pooled threads - shutdownContexts(); - cleanupRequestContexts(); - }else if (event instanceof InstanceCreated){ - checkInit(); - assert(event.getSource() instanceof Context): "Context must be passed on created event"; - Context context = (Context)event.getSource(); - List<Context> collection = destroyQueues.get(Thread.currentThread()); - collection.add(context); - } - } - - public synchronized void start() { - if (lifecycleState != UNINITIALIZED) { - throw new IllegalStateException("Scope must be in UNINITIALIZED state [" + lifecycleState + "]"); - } - contexts = new ConcurrentHashMap<Object, Map<String, Context>>(); - destroyQueues = new ConcurrentHashMap<Object, List<Context>>(); - lifecycleState = RUNNING; - } - - public synchronized void stop() { - if (lifecycleState != RUNNING) { - throw new IllegalStateException("Scope in wrong state [" + lifecycleState + "]"); - } - contexts = null; - destroyQueues = null; - lifecycleState = STOPPED; - } - - public boolean isCacheable() { - return true; - } - - public void registerFactory(ContextFactory<Context> configuration) { - contextFactories.put(configuration.getName(), configuration); - } - - public Context getContext(String ctxName) { - checkInit(); - Map<String, Context> contexts = getContexts(); - Context ctx = contexts.get(ctxName); - if (ctx == null){ - // check to see if the configuration was added after the request was started - ContextFactory<Context> configuration = contextFactories.get(ctxName); - if (configuration != null) { - ctx = configuration.createContext(); - //ctx.addListener(this); - ctx.start(); - contexts.put(ctx.getName(), ctx); - } - } - return ctx; - } - - public Context getContextByKey(String ctxName, Object key) { - checkInit(); - if (key == null) { - return null; - } - Map<String, Context> components = contexts.get(key); - if (components == null) { - return null; - } - return components.get(ctxName); - } - - public void removeContext(String ctxName) { - removeContextByKey(ctxName, Thread.currentThread()); - } - - public void removeContextByKey(String ctxName, Object key) { - checkInit(); - if (key == null || ctxName == null) { - return; - } - Map components = contexts.get(key); - if (components == null) { - return; - } - components.remove(ctxName); - } - - - - private void cleanupRequestContexts() { - // TODO uninitialize all request-scoped components - contexts.remove(Thread.currentThread()); - destroyQueues.remove(Thread.currentThread()); - } - - /** - * Initializes ServiceComponentContexts for the current request. - * <p> - * TODO This eagerly creates all component contexts, even if the component is never accessed during the request. This method - * should be profiled to determine if lazy initialization is more performant - * <p> - * TODO Eager initialization is not performed for request-scoped components - */ - - private Map<String, Context> getContexts() throws CoreRuntimeException { - Map<String, Context> requestContexts = this.contexts.get(Thread.currentThread()); - if (requestContexts == null) { - requestContexts = new ConcurrentHashMap<String, Context>(); - List<Context> shutdownQueue = new ArrayList<Context>(); - for (ContextFactory<Context> config : contextFactories.values()) { - Context context = config.createContext(); - context.start(); - requestContexts.put(context.getName(), context); - } - // initialize eager components. Note this cannot be done when we initially create each context since a component may - // contain a forward reference to a component which has not been instantiated - for (Context context : requestContexts.values()) { - if (context instanceof AtomicContext) { - AtomicContext atomic = (AtomicContext) context; - if (atomic.isEagerInit()) { - atomic.init(); // Notify the instance - synchronized(shutdownQueue){ - shutdownQueue.add(context); - } - } - } - context.addListener(this); - } - contexts.put(Thread.currentThread(), requestContexts); - destroyQueues.put(Thread.currentThread(), shutdownQueue); - } - return requestContexts; - } - - private void shutdownContexts() { - List<Context> destroyQueue = destroyQueues.remove(Thread.currentThread()); - if (destroyQueue == null || destroyQueue.size() == 0) { - return; - } - synchronized(destroyQueue){ - // shutdown destroyable instances in reverse instantiation order - ListIterator<Context> iter = destroyQueue.listIterator(destroyQueue.size()); - while(iter.hasPrevious()){ - Lifecycle context = iter.previous(); - if (context.getLifecycleState() == RUNNING) { - try { - if (context instanceof AtomicContext){ - ((AtomicContext)context).destroy(); - } - } catch (TargetException e) { - // TODO send a monitoring event - } - } - } - } - // shutdown contexts - Map<String,Context> currentContexts = contexts.remove(Thread.currentThread()); - if (currentContexts == null){ - return; - } - for (Lifecycle context: currentContexts.values()){ - if (context.getLifecycleState() == RUNNING) { - context.stop(); - } - } - - } - -}
\ No newline at end of file diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/scope/SessionScopeContext.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/scope/SessionScopeContext.java deleted file mode 100644 index c5785d25f7..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/scope/SessionScopeContext.java +++ /dev/null @@ -1,258 +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.context.scope; - -import org.apache.tuscany.core.builder.ContextFactory; -import org.apache.tuscany.core.context.AtomicContext; -import org.apache.tuscany.core.context.Context; -import org.apache.tuscany.core.context.CoreRuntimeException; -import org.apache.tuscany.core.context.EventContext; -import org.apache.tuscany.core.context.ScopeRuntimeException; -import org.apache.tuscany.core.context.TargetException; -import org.apache.tuscany.core.context.Lifecycle; -import org.apache.tuscany.core.context.event.Event; -import org.apache.tuscany.core.context.event.HttpSessionEvent; -import org.apache.tuscany.core.context.event.InstanceCreated; -import org.apache.tuscany.core.context.event.SessionEnd; -import org.apache.tuscany.core.context.event.SessionStart; - -import java.util.ArrayList; -import java.util.List; -import java.util.ListIterator; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -/** - * An implementation of an session-scoped component container. This scope contexts eagerly starts contexts when a - * {@link org.apache.tuscany.core.context.event.SessionStart} event is received. If a contained context has an implementation - * marked to eagerly initialized, the an instance will be created at that time as well. Contained contexts are shutdown when a - * {@link org.apache.tuscany.core.context.event.SessionEnd} event is received in reverse order to which their implementation - * instances were created. - * TODO this implementation needs to be made generic so that it supports a range of session types, i.e. not tied to HTTP - * session scope - * - * @version $Rev$ $Date$ - */ -public class SessionScopeContext extends AbstractScopeContext { - - // The collection of service component contexts keyed by session - private Map<Object, Map<String, Context>> contexts; - - // Stores ordered lists of contexts to shutdown keyed by session - private Map<Object, List<Context>> destroyQueues; - - public SessionScopeContext(EventContext eventContext) { - super(eventContext); - setName("Session Scope"); - } - - public synchronized void start() { - if (lifecycleState != UNINITIALIZED) { - throw new IllegalStateException("Scope container must be in UNINITIALIZED state"); - } - contexts = new ConcurrentHashMap<Object, Map<String, Context>>(); - destroyQueues = new ConcurrentHashMap<Object, List<Context>>(); - lifecycleState = RUNNING; - } - - public synchronized void stop() { - if (lifecycleState != RUNNING) { - throw new IllegalStateException("Scope container in wrong state"); - } - contexts = null; - contexts = null; - destroyQueues = null; - lifecycleState = STOPPED; - } - - public void onEvent(Event event) { - if (event instanceof SessionStart) { - checkInit(); - Object key = ((SessionEnd) event).getId(); - getSessionContexts(key); - }else if (event instanceof SessionEnd) { - checkInit(); - Object key = ((SessionEnd) event).getId(); - shutdownContexts(key); - destroyComponentContext(key); - } else if (event instanceof InstanceCreated) { - checkInit(); - Object sessionKey = getEventContext().getIdentifier(HttpSessionEvent.HTTP_IDENTIFIER); - List<Context> shutdownQueue = destroyQueues.get(sessionKey); - Context context = (Context) event.getSource(); - assert(shutdownQueue != null): "Shutdown queue not found for key"; - shutdownQueue.add(context); - } - } - - public boolean isCacheable() { - return true; - } - - public void registerFactory(ContextFactory<Context> configuration) { - contextFactories.put(configuration.getName(), configuration); - } - - public Context getContext(String ctxName) { - assert(ctxName != null): "No context name specified"; - checkInit(); - Map<String, Context> ctxs = getSessionContexts(); - Context context = ctxs.get(ctxName); - if (context == null) { - // the configuration was added after the session had started, so create a context now and start it - ContextFactory<Context> configuration = contextFactories.get(ctxName); - if (configuration != null) { - context = configuration.createContext(); - context.start(); - if (context instanceof AtomicContext) { - ((AtomicContext) context).init(); - } - - ctxs.put(context.getName(), context); - List<Context> shutdownQueue = destroyQueues.get(getEventContext().getIdentifier(HttpSessionEvent.HTTP_IDENTIFIER)); - synchronized (shutdownQueue) { - shutdownQueue.add(context); - } - context.addListener(this); - } - } - return context; - } - - public Context getContextByKey(String ctxName, Object key) { - checkInit(); - assert(ctxName != null): "No context name specified"; - assert(key != null): "No key specified"; - Map ctxs = contexts.get(key); - if (ctxs == null) { - return null; - } - return (Context) ctxs.get(ctxName); - } - - public void removeContext(String ctxName) { - checkInit(); - Object key = getEventContext().getIdentifier(HttpSessionEvent.HTTP_IDENTIFIER); - removeContextByKey(ctxName, key); - } - - public void removeContextByKey(String ctxName, Object key) { - checkInit(); - assert(ctxName != null): "No context name specified"; - assert(key != null): "No key specified"; - Map components = contexts.get(key); - if (components == null) { - return; - } - components.remove(ctxName); - Map<String, Context> definitions = contexts.get(key); - Context ctx = definitions.get(ctxName); - if (ctx != null) { - destroyQueues.get(key).remove(ctx); - } - definitions.remove(ctxName); - } - - /** - * Returns and, if necessary, creates a context for the current sesion - */ - private Map<String, Context> getSessionContexts() throws CoreRuntimeException { - Object key = getEventContext().getIdentifier(HttpSessionEvent.HTTP_IDENTIFIER); - return getSessionContexts(key); - } - - /** - * Returns and, if necessary, creates a context for the given session key - */ - private Map<String, Context> getSessionContexts(Object key) throws CoreRuntimeException { - if (key == null) { - throw new ScopeRuntimeException("Session key not set in request context"); - } - Map<String, Context> m = contexts.get(key); - if (m != null) { - return m; // already created, return - } - Map<String, Context> sessionContext = new ConcurrentHashMap<String, Context>(contextFactories.size()); - for (ContextFactory<Context> config : contextFactories.values()) { - Context context = config.createContext(); - context.start(); - sessionContext.put(context.getName(), context); - } - - List<Context> shutdownQueue = new ArrayList<Context>(); - contexts.put(key, sessionContext); - destroyQueues.put(key, shutdownQueue); - // initialize eager components. Note this cannot be done when we initially create each context since a component may - // contain a forward reference to a component which has not been instantiated - for (Context context : sessionContext.values()) { - if (context instanceof AtomicContext) { - AtomicContext atomic = (AtomicContext) context; - if (atomic.isEagerInit()) { - atomic.init(); // Notify the instance - synchronized (shutdownQueue) { - shutdownQueue.add(context); - } - } - } - context.addListener(this); - } - return sessionContext; - } - - /** - * Removes the components associated with an expiring context - */ - private void destroyComponentContext(Object key) { - contexts.remove(key); - destroyQueues.remove(key); - } - - - private synchronized void shutdownContexts(Object key) { - List<Context> destroyQueue = destroyQueues.remove(key); - if (destroyQueue == null || destroyQueue.size() == 0) { - return; - } - // shutdown destroyable instances in reverse instantiation order - ListIterator<Context> iter = destroyQueue.listIterator(destroyQueue.size()); - synchronized (destroyQueue) { - while (iter.hasPrevious()) { - Lifecycle context = iter.previous(); - if (context.getLifecycleState() == RUNNING) { - try { - if (context instanceof AtomicContext) { - ((AtomicContext) context).destroy(); - } - } catch (TargetException e) { - // TODO send a monitoring event - } - } - } - } - // shutdown contexts - Map<String, Context> currentContexts = contexts.remove(Thread.currentThread()); - if (currentContexts == null) { - return; - } - for (Lifecycle context : currentContexts.values()) { - if (context.getLifecycleState() == RUNNING) { - context.stop(); - } - } - } - -}
\ No newline at end of file diff --git a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/scope/StatelessScopeContext.java b/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/scope/StatelessScopeContext.java deleted file mode 100644 index 46bf58b548..0000000000 --- a/tags/java-M1-final/java/sca/core/src/main/java/org/apache/tuscany/core/context/scope/StatelessScopeContext.java +++ /dev/null @@ -1,132 +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.context.scope; - -import org.apache.tuscany.core.builder.ContextFactory; -import org.apache.tuscany.core.context.EventContext; -import org.apache.tuscany.core.context.Context; -import org.apache.tuscany.core.context.CoreRuntimeException; -import org.apache.tuscany.core.context.Lifecycle; -import org.apache.tuscany.core.context.event.Event; -import org.apache.tuscany.core.context.event.ModuleStop; - -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -/** - * A container that manages stateless components. - * - * @version $Rev$ $Date$ - */ -public class StatelessScopeContext extends AbstractScopeContext { - - // Component contexts keyed by name - private Map<String, Context> contexts; - - public StatelessScopeContext(EventContext eventContext) { - super(eventContext); - setName("Stateless Scope"); - } - - public synchronized void start() { - if (lifecycleState != UNINITIALIZED) { - throw new IllegalStateException("Scope must be in UNINITIALIZED state [" + lifecycleState + "]"); - } - lifecycleState = RUNNING; - } - - public synchronized void stop() { - if (lifecycleState != RUNNING) { - throw new IllegalStateException("Scope in wrong state [" + lifecycleState + "]"); - } - contexts = null; - lifecycleState = STOPPED; - } - - public void registerFactory(ContextFactory<Context> configuration) { - contextFactories.put(configuration.getName(), configuration); - if (contexts != null) { - contexts.put(configuration.getName(), configuration.createContext()); - } - } - - public void onEvent(Event event){ - if (event instanceof ModuleStop) { - shutdownContexts(); - } - } - - public boolean isCacheable() { - return true; - } - - public Context getContext(String ctxName) { - prepare(); - return contexts.get(ctxName); - } - - public Context getContextByKey(String ctxName, Object key) { - return getContext(ctxName); - } - - public void removeContext(String ctxName) { - if (contexts == null){ - return; - } - contexts.remove(ctxName); - } - - public void removeContextByKey(String ctxName, Object key) { - removeContext(ctxName); - } - - private void prepare() throws CoreRuntimeException { - if (lifecycleState != RUNNING) { - throw new IllegalStateException("Scope not in INITIALIZED state [" + lifecycleState + "]"); - } - if (contexts == null) { - contexts = new ConcurrentHashMap<String, Context> (); - for (ContextFactory<Context> config : contextFactories.values()) { - for (int i = 0; i < contextFactories.size(); i++) { - Context context = config.createContext(); - context.start(); - contexts.put(context.getName(), context); - } - - } - } - } - - private void shutdownContexts(){ - if (contexts == null){ - return; - } - for(Lifecycle context: contexts.values()) { - try { - if (context.getLifecycleState() == RUNNING) { - context.stop(); - } - } catch (CoreRuntimeException e){ - // TODO send monitoring event - } - - } - contexts = null; - } - - -}
\ No newline at end of file |