From f860c2f35b2f94e379d2ff7d5c13f54cd4a3132a Mon Sep 17 00:00:00 2001 From: lresende Date: Wed, 11 Nov 2009 23:06:42 +0000 Subject: Moving 1.x branches git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835119 13f79535-47bb-0310-9956-ffa450edef68 --- .../tuscany/sca/scope/AbstractLifecycle.java | 77 ++++++++++++++++++ .../tuscany/sca/scope/CoreRuntimeException.java | 45 +++++++++++ .../apache/tuscany/sca/scope/InstanceWrapper.java | 45 +++++++++++ .../org/apache/tuscany/sca/scope/Lifecycle.java | 69 ++++++++++++++++ .../tuscany/sca/scope/PersistenceException.java | 43 ++++++++++ .../java/org/apache/tuscany/sca/scope/Scope.java | 63 +++++++++++++++ .../apache/tuscany/sca/scope/ScopeContainer.java | 93 ++++++++++++++++++++++ .../tuscany/sca/scope/ScopeContainerFactory.java | 32 ++++++++ .../apache/tuscany/sca/scope/ScopeIdentifier.java | 35 ++++++++ .../tuscany/sca/scope/ScopeNotFoundException.java | 31 ++++++++ .../apache/tuscany/sca/scope/ScopeRegistry.java | 43 ++++++++++ .../sca/scope/ScopedImplementationProvider.java | 64 +++++++++++++++ .../tuscany/sca/scope/ScopedRuntimeComponent.java | 40 ++++++++++ .../sca/scope/TargetDestructionException.java | 44 ++++++++++ .../sca/scope/TargetInitializationException.java | 44 ++++++++++ .../sca/scope/TargetInvocationException.java | 45 +++++++++++ .../sca/scope/TargetInvokerCreationException.java | 44 ++++++++++ .../tuscany/sca/scope/TargetNotFoundException.java | 44 ++++++++++ .../sca/scope/TargetResolutionException.java | 44 ++++++++++ 19 files changed, 945 insertions(+) create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/AbstractLifecycle.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/CoreRuntimeException.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/InstanceWrapper.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/Lifecycle.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/PersistenceException.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/Scope.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/ScopeContainer.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/ScopeContainerFactory.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/ScopeIdentifier.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/ScopeNotFoundException.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/ScopeRegistry.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/ScopedImplementationProvider.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/ScopedRuntimeComponent.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/TargetDestructionException.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/TargetInitializationException.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/TargetInvocationException.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/TargetInvokerCreationException.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/TargetNotFoundException.java create mode 100644 sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/TargetResolutionException.java (limited to 'sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope') diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/AbstractLifecycle.java b/sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/AbstractLifecycle.java new file mode 100644 index 0000000000..e5f88d91c6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/AbstractLifecycle.java @@ -0,0 +1,77 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.sca.scope; + +/** + * Base class providing a simple implementation of Lifecycle. + * + * @version $Rev$ $Date$ + */ +public abstract class AbstractLifecycle implements Lifecycle { + protected volatile int lifecycleState = UNINITIALIZED; + + public int getLifecycleState() { + return lifecycleState; + } + + /** + * Set the current state of the Lifecycle. + * + * @param lifecycleState the new state + */ + protected void setLifecycleState(int lifecycleState) { + this.lifecycleState = lifecycleState; + } + + public void start() { + setLifecycleState(RUNNING); + } + + public void stop() { + setLifecycleState(STOPPED); + } + + /** + * Returns the current lifecycle as a String (for example, "RUNNING"). + * + * @return the current lifecycle as a String + */ + public String toString() { + switch (lifecycleState) { + case Lifecycle.CONFIG_ERROR: + return "CONFIG_ERROR"; + case Lifecycle.ERROR: + return "ERROR"; + case Lifecycle.INITIALIZING: + return "INITIALIZING"; + case Lifecycle.INITIALIZED: + return "INITIALIZED"; + case Lifecycle.RUNNING: + return "RUNNING"; + case Lifecycle.STOPPING: + return "STOPPING"; + case Lifecycle.STOPPED: + return "STOPPED"; + case Lifecycle.UNINITIALIZED: + return "UNINITIALIZED"; + default: + return "UNKNOWN"; + } + } +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/CoreRuntimeException.java b/sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/CoreRuntimeException.java new file mode 100644 index 0000000000..ac3e51a982 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/CoreRuntimeException.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.sca.scope; + + +/** + * The root exception for the runtime package. Exceptions occurring in the runtime are generally non-recoverable + * + * @version $Rev$ $Date$ + */ +public abstract class CoreRuntimeException extends RuntimeException { + + public CoreRuntimeException() { + super(); + } + + public CoreRuntimeException(String message, Throwable cause) { + super(message, cause); + } + + public CoreRuntimeException(String message) { + super(message); + } + + public CoreRuntimeException(Throwable cause) { + super(cause); + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/InstanceWrapper.java b/sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/InstanceWrapper.java new file mode 100644 index 0000000000..a952e2e72b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/InstanceWrapper.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.sca.scope; + + +/** + * Provides lifecycle management for an implementation instance associated with + * a component for use by the component's associated {@link org.apache.tuscany.sca.scope.ScopeContainer} + * + * @version $Rev$ $Date$ + */ +public interface InstanceWrapper { + + /** + * @return + */ + T getInstance(); + + /** + * @throws TargetInitializationException + */ + void start() throws TargetInitializationException; + + /** + * @throws TargetDestructionException + */ + void stop() throws TargetDestructionException; + +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/Lifecycle.java b/sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/Lifecycle.java new file mode 100644 index 0000000000..02075cad01 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/Lifecycle.java @@ -0,0 +1,69 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.sca.scope; + +/** + * Implementations adhere to runtime lifecycle semantics + * + * @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; + /* Configured and initialized */ + int RUNNING = 4; + /* In the process of being shutdown */ + int STOPPING = 5; + /* Has been shutdown and removed from the composite */ + 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; +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/PersistenceException.java b/sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/PersistenceException.java new file mode 100644 index 0000000000..54fba1ee03 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/PersistenceException.java @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.sca.scope; + +/** + * Raised when an error persisting a component implementation instance is encountered + * + * @version $Rev$ $Date$ + */ +public class PersistenceException extends Exception { + private static final long serialVersionUID = -908468170919651248L; + + public PersistenceException() { + } + + public PersistenceException(String message) { + super(message); + } + + public PersistenceException(String message, Throwable cause) { + super(message, cause); + } + + public PersistenceException(Throwable cause) { + super(cause); + } +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/Scope.java b/sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/Scope.java new file mode 100644 index 0000000000..9b3f208cb3 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/Scope.java @@ -0,0 +1,63 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.sca.scope; + +/** + * The default implementation scopes supported by assemblies. + * + * @version $Rev$ $Date$ + */ +public class Scope { + public static final Scope STATELESS = new Scope("STATELESS"); + public static final Scope REQUEST = new Scope("REQUEST"); + public static final Scope SESSION = new Scope("SESSION"); + public static final Scope CONVERSATION = new Scope("CONVERSATION"); + public static final Scope COMPOSITE = new Scope("COMPOSITE"); + public static final Scope SYSTEM = new Scope("SYSTEM"); + public static final Scope UNDEFINED = new Scope("UNDEFINED"); + + private String scope; + + public Scope(String scope) { + this.scope = scope.toUpperCase().intern(); + } + + public String getScope() { + return scope; + } + + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + final Scope scope1 = (Scope) o; + return !(scope != null ? scope != scope1.scope.intern() : scope1.scope != null); + } + + public int hashCode() { + return scope != null ? scope.hashCode() : 0; + } + + public String toString() { + return scope; + } +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/ScopeContainer.java b/sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/ScopeContainer.java new file mode 100644 index 0000000000..30482fae90 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/ScopeContainer.java @@ -0,0 +1,93 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.sca.scope; + +import org.apache.tuscany.sca.event.RuntimeEventListener; +import org.apache.tuscany.sca.runtime.RuntimeComponent; + + +/** + * Manages the lifecycle and visibility of instances associated with a an {@link RuntimeComponent}. + * + * @version $Rev$ $Date$ + * @param the type of IDs that this container uses to identify its contexts. + * For example, for COMPOSITE scope this could be the URI of the composite component, + * or for HTTP Session scope it might be the HTTP session ID. + */ +public interface ScopeContainer extends Lifecycle, RuntimeEventListener { + + /** + * Returns the Scope that this container supports. + * + * @return the Scope that this container supports + */ + Scope getScope(); + + /** + * Start a new context with the supplied ID. + * + * @param contextId an ID that uniquely identifies the context. + */ + void startContext(KEY contextId); + + /** + * Stop the context with the supplied ID. + * + * @param contextId an ID that uniquely identifies the context. + */ + void stopContext(KEY contextId); + + /** + * Returns an instance wrapper associated with the current scope context, creating one if necessary + * @param contextId the id for the scope context + * + * @return the wrapper for the target instance + * @throws TargetResolutionException if there was a problem instantiating the target instance + */ + InstanceWrapper getWrapper(KEY contextId) throws TargetResolutionException; + + /** + * Returns an implementation instance associated with the current scope context. + * If no instance is found, a {@link TargetNotFoundException} is thrown. + * @param contextId the id for the scope context + * + * @return the wrapper for the target instance + * @throws TargetResolutionException if there was a problem instantiating the target instance + */ + InstanceWrapper getAssociatedWrapper(KEY contextId) + throws TargetResolutionException; + + /** + * Return a wrapper after use (for example, after invoking the instance). + * @param wrapper the wrapper for the target instance being returned + * @param contextId the id for the scope context + * + * @throws TargetDestructionException if there was a problem returning the target instance + */ + void returnWrapper(InstanceWrapper wrapper, KEY contextId) + throws TargetDestructionException; + + /** + * Removes a component implementation instance associated with the current context from persistent storage + * + * @param component the owning component + * @throws PersistenceException if there was a problem removing the instance + */ + void remove() throws PersistenceException; +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/ScopeContainerFactory.java b/sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/ScopeContainerFactory.java new file mode 100644 index 0000000000..b6acae7382 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/ScopeContainerFactory.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.sca.scope; + +import org.apache.tuscany.sca.runtime.RuntimeComponent; + +/** + * Factory to create ScopeContainer for components + * + * @version $Rev$ $Date$ + */ +public interface ScopeContainerFactory { + ScopeContainer createScopeContainer(RuntimeComponent component); + Scope getScope(); +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/ScopeIdentifier.java b/sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/ScopeIdentifier.java new file mode 100644 index 0000000000..77e7d76842 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/ScopeIdentifier.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.sca.scope; + +/** + * 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.sca.factory.component.WorkContext + */ +public interface ScopeIdentifier { + + /** + * Returns the scope id for the request. + */ + Object getIdentifier(); +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/ScopeNotFoundException.java b/sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/ScopeNotFoundException.java new file mode 100644 index 0000000000..40a251c6f2 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/ScopeNotFoundException.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.sca.scope; + +/** + * @version $Rev$ $Date$ + */ +public class ScopeNotFoundException extends Exception { + + private static final long serialVersionUID = -3447306764458851441L; + + public ScopeNotFoundException(String scope) { + super("Scope not found: " + scope); + } +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/ScopeRegistry.java b/sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/ScopeRegistry.java new file mode 100644 index 0000000000..f3319ee093 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/ScopeRegistry.java @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.sca.scope; + +import org.apache.tuscany.sca.runtime.RuntimeComponent; + + +/** + * Manages {@link ScopeContainer}s in the runtime + * + * @version $$Rev$$ $$Date$$ + */ +public interface ScopeRegistry { + + /** + * Returns the scope container for the given scope or null if one not found + * + * @param scope the scope + * @return the scope container for the given scope or null if one not found + */ + ScopeContainer getScopeContainer(RuntimeComponent component); + + /** + * @param factory + */ + void register(ScopeContainerFactory factory); +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/ScopedImplementationProvider.java b/sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/ScopedImplementationProvider.java new file mode 100644 index 0000000000..8b9c50b070 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/ScopedImplementationProvider.java @@ -0,0 +1,64 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.sca.scope; + +import org.apache.tuscany.sca.provider.ImplementationProvider; + +/** + * A component implementation can implement this interface to provide scope + * management for the components + * + * @version $Rev$ $Date$ + */ +public interface ScopedImplementationProvider extends ImplementationProvider { + /** + * Get the scope for the component implementation + * + * @return The scope for the component implementation, if null is returned, + * STATELESS will be used + */ + Scope getScope(); + + /** + * Indicate if the component needs to be eagerly initialized + * + * @return true if the component is marked to be eagerly initialized, false + * otherwise + */ + boolean isEagerInit(); + + /** + * @return the maxAge + */ + long getMaxAge(); + + /** + * @return the maxIdleTime + */ + long getMaxIdleTime(); + + /** + * Create a wrapper for the component instance for the scope management + * + * @return A wrapper for the component instance + */ + InstanceWrapper createInstanceWrapper(); + +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/ScopedRuntimeComponent.java b/sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/ScopedRuntimeComponent.java new file mode 100644 index 0000000000..6c33683bde --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/ScopedRuntimeComponent.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.sca.scope; + +import org.apache.tuscany.sca.runtime.RuntimeComponent; + +/** + * Scoped runtime component + * + * @version $Rev$ $Date$ + */ +public interface ScopedRuntimeComponent extends RuntimeComponent { + /** + * Set the associated scope container + * @param scopeContainer + */ + void setScopeContainer(ScopeContainer scopeContainer); + /** + * Get the assoicated scope container + * @return + */ + ScopeContainer getScopeContainer(); +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/TargetDestructionException.java b/sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/TargetDestructionException.java new file mode 100644 index 0000000000..6b251295f5 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/TargetDestructionException.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.sca.scope; + +/** + * Denotes an error destroying a target + * + * @version $Rev$ $Date$ + */ +public class TargetDestructionException extends TargetResolutionException { + private static final long serialVersionUID = -6126684147851674709L; + + public TargetDestructionException() { + super(); + } + + public TargetDestructionException(String message, Throwable cause) { + super(message, cause); + } + + public TargetDestructionException(String message) { + super(message); + } + + public TargetDestructionException(Throwable cause) { + super(cause); + } +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/TargetInitializationException.java b/sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/TargetInitializationException.java new file mode 100644 index 0000000000..17cd21967f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/TargetInitializationException.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.sca.scope; + +/** + * Denotes an error initializing a target + * + * @version $Rev$ $Date$ + */ +public class TargetInitializationException extends TargetResolutionException { + private static final long serialVersionUID = -6228778208649752698L; + + public TargetInitializationException() { + super(); + } + + public TargetInitializationException(String message, Throwable cause) { + super(message, cause); + } + + public TargetInitializationException(String message) { + super(message); + } + + public TargetInitializationException(Throwable cause) { + super(cause); + } +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/TargetInvocationException.java b/sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/TargetInvocationException.java new file mode 100644 index 0000000000..f9bfa0a788 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/TargetInvocationException.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.sca.scope; + +/** + * Raised when an error is encountered during a target invocation + * + * @version $Rev$ $Date$ + */ +public class TargetInvocationException extends Exception { + + private static final long serialVersionUID = -6553427708442761743L; + + public TargetInvocationException() { + super(); + } + + public TargetInvocationException(String message, Throwable cause) { + super(message, cause); + } + + public TargetInvocationException(String message) { + super(message); + } + + public TargetInvocationException(Throwable cause) { + super(cause); + } +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/TargetInvokerCreationException.java b/sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/TargetInvokerCreationException.java new file mode 100644 index 0000000000..a20d030ee8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/TargetInvokerCreationException.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.sca.scope; + +/** + * Denotes an error creating a target invoker + * + * @version $Rev$ $Date$ + * @Deprecated + */ +public abstract class TargetInvokerCreationException extends Exception { + + public TargetInvokerCreationException() { + super(); + } + + public TargetInvokerCreationException(String message, Throwable cause) { + super(message, cause); + } + + public TargetInvokerCreationException(String message) { + super(message); + } + + public TargetInvokerCreationException(Throwable cause) { + super(cause); + } +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/TargetNotFoundException.java b/sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/TargetNotFoundException.java new file mode 100644 index 0000000000..4dd63f58f0 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/TargetNotFoundException.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.sca.scope; + +/** + * Thrown when a target of an operation cannot be found + * + * @version $$Rev$$ $$Date$$ + */ +public class TargetNotFoundException extends TargetResolutionException { + private static final long serialVersionUID = 5541830480658471186L; + + public TargetNotFoundException() { + super(); + } + + public TargetNotFoundException(String message, Throwable cause) { + super(message, cause); + } + + public TargetNotFoundException(String message) { + super(message); + } + + public TargetNotFoundException(Throwable cause) { + super(cause); + } +} diff --git a/sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/TargetResolutionException.java b/sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/TargetResolutionException.java new file mode 100644 index 0000000000..284ab8b6c7 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.90/modules/core/src/main/java/org/apache/tuscany/sca/scope/TargetResolutionException.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.sca.scope; + +/** + * Denotes an error retrieving a target instance + * + * @version $Rev$ $Date$ + */ +public class TargetResolutionException extends Exception { + private static final long serialVersionUID = 2912513650522019405L; + + public TargetResolutionException() { + super(); + } + + public TargetResolutionException(String message, Throwable cause) { + super(message, cause); + } + + public TargetResolutionException(String message) { + super(message); + } + + public TargetResolutionException(Throwable cause) { + super(cause); + } +} -- cgit v1.2.3