You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by is...@apache.org on 2006/11/10 16:56:06 UTC
svn commit: r473377 - in /incubator/tuscany/java/sca:
commands/launcher/src/main/resources/META-INF/tuscany/
kernel/core/src/main/java/org/apache/tuscany/core/component/event/
kernel/core/src/main/java/org/apache/tuscany/core/component/scope/
kernel/co...
Author: isilval
Date: Fri Nov 10 07:56:05 2006
New Revision: 473377
URL: http://svn.apache.org/viewvc?view=rev&rev=473377
Log:
Initial implementation of conversational scope container using non-persistent tracking of instances
Added:
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/ConversationEnd.java
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/ConversationStart.java
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/ConversationalEvent.java
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainer.java
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/ConversationalScopeObjectFactory.java
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/BasicConversationalScopeTestCase.java
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeInstanceLifecycleTestCase.java
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeRestartTestCase.java
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeComponent.java
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeComponentImpl.java
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeDestroyOnlyComponent.java
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeInitDestroyComponent.java
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeInitOnlyComponent.java
Modified:
incubator/tuscany/java/sca/commands/launcher/src/main/resources/META-INF/tuscany/system.scdl
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ScopeProcessor.java
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/ScopeRegistryTestCase.java
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ScopeProcessorTestCase.java
incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Scope.java
incubator/tuscany/java/sca/runtime/webapp-host/src/main/resources/META-INF/tuscany/webapp.scdl
Modified: incubator/tuscany/java/sca/commands/launcher/src/main/resources/META-INF/tuscany/system.scdl
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/commands/launcher/src/main/resources/META-INF/tuscany/system.scdl?view=diff&rev=473377&r1=473376&r2=473377
==============================================================================
--- incubator/tuscany/java/sca/commands/launcher/src/main/resources/META-INF/tuscany/system.scdl (original)
+++ incubator/tuscany/java/sca/commands/launcher/src/main/resources/META-INF/tuscany/system.scdl Fri Nov 10 07:56:05 2006
@@ -79,8 +79,13 @@
<component name="scope.module">
<system:implementation.system class="org.apache.tuscany.core.component.scope.ModuleScopeObjectFactory"/>
</component>
+
<component name="scope.stateless">
<system:implementation.system class="org.apache.tuscany.core.component.scope.StatelessScopeObjectFactory"/>
+ </component>
+
+ <component name="scope.conversational">
+ <system:implementation.system class="org.apache.tuscany.core.component.scope.ConversationalScopeObjectFactory"/>
</component>
<!-- include loader configuration -->
Added: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/ConversationEnd.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/ConversationEnd.java?view=auto&rev=473377
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/ConversationEnd.java (added)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/ConversationEnd.java Fri Nov 10 07:56:05 2006
@@ -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.core.component.event;
+
+/**
+ * Propagated when a conversation session is expired
+ *
+ * @version $$Rev: 430937 $$ $$Date: 2006-08-11 21:17:56 -0400 (Fri, 11 Aug 2006) $$
+ */
+public class ConversationEnd extends ConversationalEvent {
+
+ public ConversationEnd(Object source, Object id) {
+ super(source, id);
+ }
+}
Added: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/ConversationStart.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/ConversationStart.java?view=auto&rev=473377
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/ConversationStart.java (added)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/ConversationStart.java Fri Nov 10 07:56:05 2006
@@ -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.core.component.event;
+
+/**
+ * Propagated when a conversation session has started
+ *
+ * @version $$Rev: 430937 $$ $$Date: 2006-08-11 21:17:56 -0400 (Fri, 11 Aug 2006) $$
+ */
+public class ConversationStart extends ConversationalEvent {
+
+ public ConversationStart(Object source, Object id) {
+ super(source, id);
+ }
+}
Added: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/ConversationalEvent.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/ConversationalEvent.java?view=auto&rev=473377
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/ConversationalEvent.java (added)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/event/ConversationalEvent.java Fri Nov 10 07:56:05 2006
@@ -0,0 +1,39 @@
+/*
+ * 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.core.component.event;
+
+/**
+ * A base implementation of conversational session events in the runtime
+ *
+ * @version $$Rev: 430937 $$ $$Date: 2006-08-11 21:17:56 -0400 (Fri, 11 Aug 2006) $$
+ */
+public class ConversationalEvent extends AbstractEvent {
+
+ private Object id;
+
+ public ConversationalEvent(Object source, Object id) {
+ super(source);
+ assert id != null : "Conversation id was null";
+ this.id = id;
+ }
+
+ public Object getId() {
+ return id;
+ }
+}
Added: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainer.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainer.java?view=auto&rev=473377
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainer.java (added)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/ConversationalScopeContainer.java Fri Nov 10 07:56:05 2006
@@ -0,0 +1,143 @@
+/*
+ * 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.core.component.scope;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.tuscany.core.component.event.ConversationEnd;
+import org.apache.tuscany.core.component.event.ConversationStart;
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.TargetException;
+import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.event.Event;
+import org.apache.tuscany.spi.model.Scope;
+
+/**
+ * A scope context which manages atomic component instances keyed on a conversation session
+ *
+ * @version $Rev: 452655 $ $Date: 2006-10-03 18:09:02 -0400 (Tue, 03 Oct 2006) $
+ */
+public class ConversationalScopeContainer extends AbstractScopeContainer {
+
+ public static final Object CONVERSATIONAL_IDENTIFIER = new Object();
+
+ private final Map<AtomicComponent, Map<Object, InstanceWrapper>> contexts;
+ private final Map<Object, List<InstanceWrapper>> destroyQueues;
+
+ public ConversationalScopeContainer() {
+ this(null);
+ }
+
+ public ConversationalScopeContainer(WorkContext workContext) {
+ super("Conversational Scope", workContext);
+ contexts = new ConcurrentHashMap<AtomicComponent, Map<Object, InstanceWrapper>>();
+ destroyQueues = new ConcurrentHashMap<Object, List<InstanceWrapper>>();
+ }
+
+ public Scope getScope() {
+ return Scope.CONVERSATIONAL;
+ }
+
+ public void onEvent(Event event) {
+ checkInit();
+ if (event instanceof ConversationStart) {
+ Object key = ((ConversationStart) event).getId();
+ workContext.setIdentifier(CONVERSATIONAL_IDENTIFIER, key);
+ for (Map.Entry<AtomicComponent, Map<Object, InstanceWrapper>> entry : contexts.entrySet()) {
+ if (entry.getKey().isEagerInit()) {
+ getInstance(entry.getKey(), key);
+ }
+ }
+ } else if (event instanceof ConversationEnd) {
+ Object key = ((ConversationEnd) event).getId();
+ shutdownInstances(key);
+ workContext.clearIdentifier(key);
+ }
+ }
+
+ public synchronized void start() {
+ if (lifecycleState != UNINITIALIZED && lifecycleState != STOPPED) {
+ throw new IllegalStateException("Scope must be in UNINITIALIZED or STOPPED state [" + lifecycleState + "]");
+ }
+ lifecycleState = RUNNING;
+ }
+
+ public synchronized void stop() {
+ contexts.clear();
+ synchronized (destroyQueues) {
+ destroyQueues.clear();
+ }
+ lifecycleState = STOPPED;
+ }
+
+ public void register(AtomicComponent component) {
+ contexts.put(component, new ConcurrentHashMap<Object, InstanceWrapper>());
+ component.addListener(this);
+ }
+
+ protected InstanceWrapper getInstanceWrapper(AtomicComponent component) throws TargetException {
+ Object key = workContext.getIdentifier(CONVERSATIONAL_IDENTIFIER);
+ assert key != null : "Conversational session id not bound in work component";
+ return getInstance(component, key);
+ }
+
+ private InstanceWrapper getInstance(AtomicComponent component, Object key) {
+ Map<Object, InstanceWrapper> wrappers = contexts.get(component);
+ assert wrappers != null : "Component [" + component + "] not registered";
+ InstanceWrapper ctx = wrappers.get(key);
+ if (ctx == null) {
+ ctx = new InstanceWrapperImpl(component, component.createInstance());
+ ctx.start();
+ wrappers.put(key, ctx);
+ List<InstanceWrapper> destroyQueue = destroyQueues.get(key);
+ if (destroyQueue == null) {
+ destroyQueue = new ArrayList<InstanceWrapper>();
+ destroyQueues.put(key, destroyQueue);
+ }
+ synchronized (destroyQueue) {
+ destroyQueue.add(ctx);
+ }
+ }
+
+ return ctx;
+ }
+
+ private void shutdownInstances(Object key) {
+ List<InstanceWrapper> destroyQueue = destroyQueues.remove(key);
+ if (destroyQueue != null) {
+ for (Map<Object, InstanceWrapper> map : contexts.values()) {
+ map.remove(key);
+ }
+ ListIterator<InstanceWrapper> iter = destroyQueue.listIterator(destroyQueue.size());
+ synchronized (destroyQueue) {
+ while (iter.hasPrevious()) {
+ try {
+ iter.previous().stop();
+ } catch (TargetException e) {
+ // TODO send a monitoring event
+ }
+ }
+ }
+ }
+ }
+}
Added: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/ConversationalScopeObjectFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/ConversationalScopeObjectFactory.java?view=auto&rev=473377
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/ConversationalScopeObjectFactory.java (added)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/scope/ConversationalScopeObjectFactory.java Fri Nov 10 07:56:05 2006
@@ -0,0 +1,47 @@
+/*
+ * 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.core.component.scope;
+
+import org.apache.tuscany.spi.ObjectCreationException;
+import org.apache.tuscany.spi.ObjectFactory;
+import org.apache.tuscany.spi.annotation.Autowire;
+import org.apache.tuscany.spi.component.ScopeRegistry;
+import org.apache.tuscany.spi.model.Scope;
+import org.osoa.sca.annotations.Init;
+
+/**
+ * Creates a new Session Scope context
+ *
+ * @version $$Rev: 450456 $$ $$Date: 2006-09-27 10:28:36 -0400 (Wed, 27 Sep 2006) $$
+ */
+public class ConversationalScopeObjectFactory implements ObjectFactory<ConversationalScopeContainer> {
+
+ public ConversationalScopeObjectFactory(@Autowire ScopeRegistry registry) {
+ registry.registerFactory(Scope.CONVERSATIONAL, this);
+ }
+
+ @Init(eager = true)
+ public void init() {
+ }
+
+
+ public ConversationalScopeContainer getInstance() throws ObjectCreationException {
+ return new ConversationalScopeContainer();
+ }
+}
Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ScopeProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ScopeProcessor.java?view=diff&rev=473377&r1=473376&r2=473377
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ScopeProcessor.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ScopeProcessor.java Fri Nov 10 07:56:05 2006
@@ -51,6 +51,8 @@
scope = Scope.MODULE;
} else if ("SESSION".equals(name)) {
scope = Scope.SESSION;
+ } else if ("CONVERSATIONAL".equals(name)) {
+ scope = Scope.CONVERSATIONAL;
} else if ("REQUEST".equals(name)) {
scope = Scope.REQUEST;
} else if ("COMPOSITE".equals(name)) {
Added: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/BasicConversationalScopeTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/BasicConversationalScopeTestCase.java?view=auto&rev=473377
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/BasicConversationalScopeTestCase.java (added)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/BasicConversationalScopeTestCase.java Fri Nov 10 07:56:05 2006
@@ -0,0 +1,118 @@
+/*
+ * 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.core.component.scope;
+
+import org.apache.tuscany.core.component.WorkContextImpl;
+import org.apache.tuscany.core.component.event.ConversationEnd;
+import org.apache.tuscany.core.implementation.PojoConfiguration;
+import org.apache.tuscany.core.implementation.system.component.SystemAtomicComponentImpl;
+import org.apache.tuscany.core.injection.EventInvoker;
+import org.apache.tuscany.core.injection.MethodEventInvoker;
+import org.apache.tuscany.core.injection.PojoObjectFactory;
+import org.apache.tuscany.core.mock.component.ConversationalScopeInitDestroyComponent;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.component.SystemAtomicComponent;
+import org.apache.tuscany.spi.component.WorkContext;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $$Rev: 471111 $$ $$Date: 2006-11-03 23:06:48 -0500 (Fri, 03 Nov 2006) $$
+ */
+public class BasicConversationalScopeTestCase extends TestCase {
+
+ private EventInvoker<Object> initInvoker;
+ private EventInvoker<Object> destroyInvoker;
+ private PojoObjectFactory<?> factory;
+
+ public void testLifecycleManagement() throws Exception {
+ WorkContext workContext = new WorkContextImpl();
+ ConversationalScopeContainer scopeContext = new ConversationalScopeContainer(workContext);
+ scopeContext.start();
+ SystemAtomicComponent atomicContext = createContext(scopeContext);
+ // start the request
+ Object conversation = new Object();
+ workContext.setIdentifier(ConversationalScopeContainer.CONVERSATIONAL_IDENTIFIER, conversation);
+ ConversationalScopeInitDestroyComponent o1 =
+ (ConversationalScopeInitDestroyComponent) scopeContext.getInstance(atomicContext);
+ assertTrue(o1.isInitialized());
+ assertFalse(o1.isDestroyed());
+ ConversationalScopeInitDestroyComponent o2 =
+ (ConversationalScopeInitDestroyComponent) scopeContext.getInstance(atomicContext);
+ assertSame(o1, o2);
+ scopeContext.onEvent(new ConversationEnd(this, conversation));
+ assertTrue(o1.isDestroyed());
+ scopeContext.stop();
+ }
+
+ public void testModuleIsolation() throws Exception {
+ WorkContext workContext = new WorkContextImpl();
+ ConversationalScopeContainer scopeContext = new ConversationalScopeContainer(workContext);
+ scopeContext.start();
+
+ SystemAtomicComponent atomicContext = createContext(scopeContext);
+
+ Object conversation1 = new Object();
+ workContext.setIdentifier(ConversationalScopeContainer.CONVERSATIONAL_IDENTIFIER, conversation1);
+ ConversationalScopeInitDestroyComponent o1 =
+ (ConversationalScopeInitDestroyComponent) scopeContext.getInstance(atomicContext);
+ assertTrue(o1.isInitialized());
+ assertFalse(o1.isDestroyed());
+
+ Object conversation2 = new Object();
+ workContext.setIdentifier(ConversationalScopeContainer.CONVERSATIONAL_IDENTIFIER, conversation2);
+ ConversationalScopeInitDestroyComponent o2 =
+ (ConversationalScopeInitDestroyComponent) scopeContext.getInstance(atomicContext);
+ assertNotSame(o1, o2);
+
+ scopeContext.onEvent(new ConversationEnd(this, conversation1));
+ assertTrue(o1.isDestroyed());
+ assertFalse(o2.isDestroyed());
+ scopeContext.onEvent(new ConversationEnd(this, conversation2));
+ assertTrue(o2.isDestroyed());
+ scopeContext.stop();
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ factory = new PojoObjectFactory<ConversationalScopeInitDestroyComponent>(
+ ConversationalScopeInitDestroyComponent.class.getConstructor((Class[]) null));
+ initInvoker = new MethodEventInvoker<Object>(
+ ConversationalScopeInitDestroyComponent.class.getMethod("init", (Class[]) null));
+ destroyInvoker = new MethodEventInvoker<Object>(
+ ConversationalScopeInitDestroyComponent.class.getMethod("destroy", (Class[]) null));
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ private SystemAtomicComponent createContext(ScopeContainer scopeContainer) {
+ PojoConfiguration configuration = new PojoConfiguration();
+ configuration.setScopeContainer(scopeContainer);
+ configuration.addServiceInterface(ConversationalScopeInitDestroyComponent.class);
+ configuration.setInstanceFactory(factory);
+ configuration.setInitInvoker(initInvoker);
+ configuration.setDestroyInvoker(destroyInvoker);
+ configuration.setName("foo");
+ SystemAtomicComponentImpl context = new SystemAtomicComponentImpl(configuration);
+ context.start();
+ return context;
+ }
+}
Added: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeInstanceLifecycleTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeInstanceLifecycleTestCase.java?view=auto&rev=473377
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeInstanceLifecycleTestCase.java (added)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeInstanceLifecycleTestCase.java Fri Nov 10 07:56:05 2006
@@ -0,0 +1,164 @@
+/*
+ * 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.core.component.scope;
+
+import org.apache.tuscany.core.component.WorkContextImpl;
+import org.apache.tuscany.core.component.event.ConversationEnd;
+import org.apache.tuscany.core.component.event.ConversationStart;
+import org.apache.tuscany.core.mock.component.ConversationalScopeDestroyOnlyComponent;
+import org.apache.tuscany.core.mock.component.ConversationalScopeInitDestroyComponent;
+import org.apache.tuscany.core.mock.component.ConversationalScopeInitOnlyComponent;
+import org.apache.tuscany.core.mock.component.OrderedEagerInitPojo;
+import org.apache.tuscany.core.mock.component.OrderedInitPojo;
+import org.apache.tuscany.core.mock.component.OrderedInitPojoImpl;
+import org.apache.tuscany.core.mock.factories.MockFactory;
+import org.apache.tuscany.spi.component.SystemAtomicComponent;
+import org.apache.tuscany.spi.component.WorkContext;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+/**
+ * Lifecycle unit tests for the conversational scope container
+ *
+ * @version $Rev: 451895 $ $Date: 2006-10-02 02:58:18 -0400 (Mon, 02 Oct 2006) $
+ */
+public class ConversationalScopeInstanceLifecycleTestCase extends TestCase {
+
+ public void testInitDestroy() throws Exception {
+ WorkContext ctx = new WorkContextImpl();
+ ConversationalScopeContainer scope = new ConversationalScopeContainer(ctx);
+ scope.start();
+
+ SystemAtomicComponent initDestroyContext = MockFactory.createAtomicComponent("InitDestroy",
+ scope,
+ ConversationalScopeInitDestroyComponent.class);
+ initDestroyContext.start();
+
+ SystemAtomicComponent initOnlyContext = MockFactory.createAtomicComponent("InitOnly",
+ scope,
+ ConversationalScopeInitOnlyComponent.class);
+ initOnlyContext.start();
+
+ SystemAtomicComponent destroyOnlyContext = MockFactory.createAtomicComponent("DestroyOnly",
+ scope,
+ ConversationalScopeDestroyOnlyComponent.class);
+ destroyOnlyContext.start();
+
+ Object conversation = new Object();
+ ctx.setIdentifier(ConversationalScopeContainer.CONVERSATIONAL_IDENTIFIER, conversation);
+ scope.onEvent(new ConversationStart(this, conversation));
+ ConversationalScopeInitDestroyComponent initDestroy =
+ (ConversationalScopeInitDestroyComponent) scope.getInstance(initDestroyContext);
+ Assert.assertNotNull(initDestroy);
+
+ ConversationalScopeInitOnlyComponent initOnly =
+ (ConversationalScopeInitOnlyComponent) scope.getInstance(initOnlyContext);
+ Assert.assertNotNull(initOnly);
+
+ ConversationalScopeDestroyOnlyComponent destroyOnly =
+ (ConversationalScopeDestroyOnlyComponent) scope.getInstance(destroyOnlyContext);
+ Assert.assertNotNull(destroyOnly);
+
+ Assert.assertTrue(initDestroy.isInitialized());
+ Assert.assertTrue(initOnly.isInitialized());
+ Assert.assertFalse(initDestroy.isDestroyed());
+ Assert.assertFalse(destroyOnly.isDestroyed());
+
+ // expire module
+ scope.onEvent(new ConversationEnd(this, conversation));
+
+ Assert.assertTrue(initDestroy.isDestroyed());
+ Assert.assertTrue(destroyOnly.isDestroyed());
+
+ scope.stop();
+ }
+
+ public void testDestroyOrder() throws Exception {
+ WorkContext ctx = new WorkContextImpl();
+ ConversationalScopeContainer scope = new ConversationalScopeContainer(ctx);
+ scope.start();
+
+ SystemAtomicComponent oneCtx =
+ MockFactory.createAtomicComponent("one", scope, OrderedInitPojoImpl.class);
+ scope.register(oneCtx);
+ SystemAtomicComponent twoCtx =
+ MockFactory.createAtomicComponent("two", scope, OrderedInitPojoImpl.class);
+ scope.register(twoCtx);
+ SystemAtomicComponent threeCtx =
+ MockFactory.createAtomicComponent("three", scope, OrderedInitPojoImpl.class);
+ scope.register(threeCtx);
+
+ Object conversation = new Object();
+ ctx.setIdentifier(ConversationalScopeContainer.CONVERSATIONAL_IDENTIFIER, conversation);
+ scope.onEvent(new ConversationStart(this, conversation));
+ OrderedInitPojo one = (OrderedInitPojo) scope.getInstance(oneCtx);
+ Assert.assertNotNull(one);
+ Assert.assertEquals(1, one.getNumberInstantiated());
+ Assert.assertEquals(1, one.getInitOrder());
+
+ OrderedInitPojo two = (OrderedInitPojo) scope.getInstance(twoCtx);
+ Assert.assertNotNull(two);
+ Assert.assertEquals(2, two.getNumberInstantiated());
+ Assert.assertEquals(2, two.getInitOrder());
+
+ OrderedInitPojo three = (OrderedInitPojo) scope.getInstance(threeCtx);
+ Assert.assertNotNull(three);
+ Assert.assertEquals(3, three.getNumberInstantiated());
+ Assert.assertEquals(3, three.getInitOrder());
+
+ // expire module
+ scope.onEvent(new ConversationEnd(this, conversation));
+ Assert.assertEquals(0, one.getNumberInstantiated());
+ scope.stop();
+ }
+
+ public void testEagerInitDestroyOrder() throws Exception {
+ WorkContext ctx = new WorkContextImpl();
+ ConversationalScopeContainer scope = new ConversationalScopeContainer(ctx);
+ scope.start();
+
+ SystemAtomicComponent oneCtx =
+ MockFactory.createAtomicComponent("one", scope, OrderedEagerInitPojo.class);
+ scope.register(oneCtx);
+ SystemAtomicComponent twoCtx =
+ MockFactory.createAtomicComponent("two", scope, OrderedEagerInitPojo.class);
+ scope.register(twoCtx);
+ SystemAtomicComponent threeCtx =
+ MockFactory.createAtomicComponent("three", scope, OrderedEagerInitPojo.class);
+ scope.register(threeCtx);
+
+ Object conversation = new Object();
+ ctx.setIdentifier(ConversationalScopeContainer.CONVERSATIONAL_IDENTIFIER, conversation);
+ scope.onEvent(new ConversationStart(this, conversation));
+ OrderedEagerInitPojo one = (OrderedEagerInitPojo) scope.getInstance(oneCtx);
+ Assert.assertNotNull(one);
+
+ OrderedEagerInitPojo two = (OrderedEagerInitPojo) scope.getInstance(twoCtx);
+ Assert.assertNotNull(two);
+
+ OrderedEagerInitPojo three = (OrderedEagerInitPojo) scope.getInstance(threeCtx);
+ Assert.assertNotNull(three);
+
+ // expire module
+ scope.onEvent(new ConversationEnd(this, conversation));
+ Assert.assertEquals(0, one.getNumberInstantiated());
+ scope.stop();
+ }
+}
Added: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeRestartTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeRestartTestCase.java?view=auto&rev=473377
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeRestartTestCase.java (added)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/ConversationalScopeRestartTestCase.java Fri Nov 10 07:56:05 2006
@@ -0,0 +1,105 @@
+/*
+ * 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.core.component.scope;
+
+import java.lang.reflect.Constructor;
+
+import org.apache.tuscany.core.component.WorkContextImpl;
+import org.apache.tuscany.core.component.event.ConversationEnd;
+import org.apache.tuscany.core.component.event.ConversationStart;
+import org.apache.tuscany.core.implementation.PojoConfiguration;
+import org.apache.tuscany.core.implementation.system.component.SystemAtomicComponentImpl;
+import org.apache.tuscany.core.injection.MethodEventInvoker;
+import org.apache.tuscany.core.injection.PojoObjectFactory;
+import org.apache.tuscany.spi.component.SystemAtomicComponent;
+import org.apache.tuscany.spi.component.WorkContext;
+
+import junit.framework.TestCase;
+
+/**
+ * Verifies the scope container properly disposes resources and can be restarted
+ *
+ * @version $$Rev: 471111 $$ $$Date: 2006-11-03 23:06:48 -0500 (Fri, 03 Nov 2006) $$
+ */
+public class ConversationalScopeRestartTestCase extends TestCase {
+
+ public void testRestart() throws Exception {
+ WorkContext ctx = new WorkContextImpl();
+ ConversationalScopeContainer scope = new ConversationalScopeContainer(ctx);
+ scope.start();
+ MethodEventInvoker<Object> initInvoker = new MethodEventInvoker<Object>(
+ ConversationalScopeRestartTestCase.InitDestroyOnce.class.getMethod("init"));
+ MethodEventInvoker<Object> destroyInvoker =
+ new MethodEventInvoker<Object>(InitDestroyOnce.class.getMethod("destroy"));
+ PojoConfiguration configuration = new PojoConfiguration();
+ configuration.setScopeContainer(scope);
+ configuration.addServiceInterface(ConversationalScopeRestartTestCase.InitDestroyOnce.class);
+ configuration.setInitInvoker(initInvoker);
+ configuration.setDestroyInvoker(destroyInvoker);
+ Constructor<InitDestroyOnce> ctr = InitDestroyOnce.class.getConstructor((Class<?>[]) null);
+ configuration.setInstanceFactory(new PojoObjectFactory<InitDestroyOnce>(ctr));
+ configuration.setName("InitDestroy");
+ SystemAtomicComponent context = new SystemAtomicComponentImpl(configuration);
+ context.start();
+
+ Object conversation = new Object();
+ ctx.setIdentifier(ConversationalScopeContainer.CONVERSATIONAL_IDENTIFIER, conversation);
+ scope.onEvent(new ConversationStart(this, conversation));
+ Object instance = context.getServiceInstance();
+ assertSame(instance, context.getServiceInstance());
+
+ scope.onEvent(new ConversationEnd(this, conversation));
+ scope.stop();
+ context.stop();
+
+ scope.start();
+ scope.onEvent(new ConversationStart(this, conversation));
+ context.start();
+ assertNotSame(instance, context.getServiceInstance());
+ scope.onEvent(new ConversationEnd(this, conversation));
+ scope.stop();
+ context.stop();
+ }
+
+ public static class InitDestroyOnce {
+
+ private boolean initialized;
+ private boolean destroyed;
+
+ public InitDestroyOnce() {
+ }
+
+ public void init() {
+ if (!initialized) {
+ initialized = true;
+ } else {
+ fail("Scope did not clean up properly - Init called more than once");
+ }
+ }
+
+ public void destroy() {
+ if (!destroyed) {
+ destroyed = true;
+ } else {
+ fail("Scope did not clean up properly - Destroyed called more than once");
+ }
+ }
+
+ }
+}
Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/ScopeRegistryTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/ScopeRegistryTestCase.java?view=diff&rev=473377&r1=473376&r2=473377
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/ScopeRegistryTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/component/scope/ScopeRegistryTestCase.java Fri Nov 10 07:56:05 2006
@@ -38,6 +38,7 @@
ScopeRegistry scopeRegistry = new ScopeRegistryImpl(workContext);
scopeRegistry.registerFactory(Scope.REQUEST, new RequestScopeObjectFactory());
scopeRegistry.registerFactory(Scope.SESSION, new HttpSessionScopeObjectFactory(scopeRegistry));
+ scopeRegistry.registerFactory(Scope.CONVERSATIONAL, new ConversationalScopeObjectFactory(scopeRegistry));
ScopeContainer request = scopeRegistry.getScopeContainer(Scope.REQUEST);
assertTrue(request instanceof RequestScopeContainer);
assertSame(request, scopeRegistry.getScopeContainer(Scope.REQUEST));
@@ -45,6 +46,10 @@
assertTrue(session instanceof HttpSessionScopeContainer);
assertSame(session, scopeRegistry.getScopeContainer(Scope.SESSION));
assertNotSame(request, session);
+ ScopeContainer conversation = scopeRegistry.getScopeContainer(Scope.CONVERSATIONAL);
+ assertTrue(conversation instanceof ConversationalScopeContainer);
+ assertSame(conversation, scopeRegistry.getScopeContainer(Scope.CONVERSATIONAL));
+ assertNotSame(session, conversation);
}
public void testDeregisterFactory() throws Exception {
@@ -59,6 +64,15 @@
} catch (ScopeNotFoundException e) {
// expected
}
+ ConversationalScopeObjectFactory convFactory = new ConversationalScopeObjectFactory(scopeRegistry);
+ scopeRegistry.registerFactory(Scope.CONVERSATIONAL, convFactory);
+ scopeRegistry.deregisterFactory(Scope.CONVERSATIONAL);
+ try {
+ scopeRegistry.getScopeContainer(Scope.CONVERSATIONAL);
+ fail();
+ } catch (ScopeNotFoundException e) {
+ // expected
+ }
}
public void testScopeNotRegistered() throws Exception {
@@ -72,6 +86,12 @@
}
try {
scopeRegistry.getScopeContainer(Scope.SESSION);
+ fail();
+ } catch (ScopeNotFoundException e) {
+ // expected
+ }
+ try {
+ scopeRegistry.getScopeContainer(Scope.CONVERSATIONAL);
fail();
} catch (ScopeNotFoundException e) {
// expected
Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ScopeProcessorTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ScopeProcessorTestCase.java?view=diff&rev=473377&r1=473376&r2=473377
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ScopeProcessorTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ScopeProcessorTestCase.java Fri Nov 10 07:56:05 2006
@@ -53,6 +53,14 @@
assertEquals(Scope.SESSION, type.getImplementationScope());
}
+ public void testConversationalScope() throws ProcessingException {
+ ScopeProcessor processor = new ScopeProcessor();
+ PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+ processor.visitClass(parent, Conversation.class, type, null);
+ assertEquals(Scope.CONVERSATIONAL, type.getImplementationScope());
+ }
+
public void testRequestScope() throws ProcessingException {
ScopeProcessor processor = new ScopeProcessor();
PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
@@ -96,6 +104,10 @@
@org.osoa.sca.annotations.Scope("SESSION")
private class Session {
+ }
+
+ @org.osoa.sca.annotations.Scope("CONVERSATIONAL")
+ private class Conversation {
}
@org.osoa.sca.annotations.Scope("REQUEST")
Added: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeComponent.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeComponent.java?view=auto&rev=473377
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeComponent.java (added)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeComponent.java Fri Nov 10 07:56:05 2006
@@ -0,0 +1,29 @@
+/*
+ * 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.core.mock.component;
+
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * @version $Rev: 430937 $ $Date: 2006-08-11 21:17:56 -0400 (Fri, 11 Aug 2006) $
+ */
+@Scope("CONVERSATIONAL")
+public interface ConversationalScopeComponent {
+
+}
Added: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeComponentImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeComponentImpl.java?view=auto&rev=473377
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeComponentImpl.java (added)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeComponentImpl.java Fri Nov 10 07:56:05 2006
@@ -0,0 +1,30 @@
+/*
+ * 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.core.mock.component;
+
+import org.osoa.sca.annotations.Scope;
+
+/**
+ * @version $Rev: 430937 $ $Date: 2006-08-11 21:17:56 -0400 (Fri, 11 Aug 2006) $
+ */
+@Scope("CONVERSATIONAL")
+public class ConversationalScopeComponentImpl
+ implements ConversationalScopeComponent {
+
+}
Added: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeDestroyOnlyComponent.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeDestroyOnlyComponent.java?view=auto&rev=473377
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeDestroyOnlyComponent.java (added)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeDestroyOnlyComponent.java Fri Nov 10 07:56:05 2006
@@ -0,0 +1,38 @@
+/*
+ * 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.core.mock.component;
+
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.Scope;
+
+@Scope("CONVERSATIONAL")
+public class ConversationalScopeDestroyOnlyComponent
+ extends ConversationalScopeComponentImpl {
+
+ boolean destroyed;
+
+ public boolean isDestroyed() {
+ return destroyed;
+ }
+
+ @Destroy
+ public void destroy() {
+ destroyed = true;
+ }
+}
Added: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeInitDestroyComponent.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeInitDestroyComponent.java?view=auto&rev=473377
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeInitDestroyComponent.java (added)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeInitDestroyComponent.java Fri Nov 10 07:56:05 2006
@@ -0,0 +1,38 @@
+/*
+ * 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.core.mock.component;
+
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.Scope;
+
+@Scope("CONVERSATIONAL")
+public class ConversationalScopeInitDestroyComponent
+ extends ConversationalScopeInitOnlyComponent {
+
+ private boolean destroyed;
+
+ public boolean isDestroyed() {
+ return destroyed;
+ }
+
+ @Destroy
+ public void destroy() {
+ destroyed = true;
+ }
+}
Added: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeInitOnlyComponent.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeInitOnlyComponent.java?view=auto&rev=473377
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeInitOnlyComponent.java (added)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/component/ConversationalScopeInitOnlyComponent.java Fri Nov 10 07:56:05 2006
@@ -0,0 +1,38 @@
+/*
+ * 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.core.mock.component;
+
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Scope;
+
+@Scope("CONVERSATIONAL")
+public class ConversationalScopeInitOnlyComponent
+ extends ConversationalScopeComponentImpl {
+
+ private boolean initialized;
+
+ public boolean isInitialized() {
+ return initialized;
+ }
+
+ @Init
+ public void init() {
+ initialized = true;
+ }
+}
Modified: incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Scope.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Scope.java?view=diff&rev=473377&r1=473376&r2=473377
==============================================================================
--- incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Scope.java (original)
+++ incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Scope.java Fri Nov 10 07:56:05 2006
@@ -25,6 +25,7 @@
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 CONVERSATIONAL = new Scope("CONVERSATIONAL");
public static final Scope MODULE = new Scope("MODULE");
public static final Scope COMPOSITE = new Scope("COMPOSITE");
public static final Scope UNDEFINED = new Scope("UNDEFINED");
Modified: incubator/tuscany/java/sca/runtime/webapp-host/src/main/resources/META-INF/tuscany/webapp.scdl
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/webapp-host/src/main/resources/META-INF/tuscany/webapp.scdl?view=diff&rev=473377&r1=473376&r2=473377
==============================================================================
--- incubator/tuscany/java/sca/runtime/webapp-host/src/main/resources/META-INF/tuscany/webapp.scdl (original)
+++ incubator/tuscany/java/sca/runtime/webapp-host/src/main/resources/META-INF/tuscany/webapp.scdl Fri Nov 10 07:56:05 2006
@@ -79,12 +79,17 @@
<component name="scope.module">
<system:implementation.system class="org.apache.tuscany.core.component.scope.ModuleScopeObjectFactory"/>
</component>
+
<component name="scope.stateless">
<system:implementation.system class="org.apache.tuscany.core.component.scope.StatelessScopeObjectFactory"/>
</component>
<component name="scope.httpsession">
<system:implementation.system class="org.apache.tuscany.core.component.scope.HttpSessionScopeObjectFactory"/>
+ </component>
+
+ <component name="scope.conversational">
+ <system:implementation.system class="org.apache.tuscany.core.component.scope.ConversationalScopeObjectFactory"/>
</component>
<!-- include loader configuration -->
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org