summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2009-09-25 23:37:29 +0000
committerlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2009-09-25 23:37:29 +0000
commitf59132e231b314eb0085d456dc900cd017da823c (patch)
tree8a247ddc25a33e4a19ebe2900ede53fad0e322f9
parent6e55b9d5cf7afffdb3b5860f735a75ae02964984 (diff)
TUSCANY-3280 - Removing support for obsolet scopes as in latest JAVACAA 1.1 draft spec and throwing exception when invalid scope is found
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@819068 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/DefaultScopeRegistry.java5
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/Scope.java6
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/HttpSessionScopeContainer.java74
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/HttpSessionScopeContainerFactory.java44
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/RequestScopeContainer.java79
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/RequestScopeContainerFactory.java40
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/ScopeRegistryImpl.java2
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaScopeImpl.java6
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ScopeProcessor.java15
-rw-r--r--java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ScopeProcessorTestCase.java6
10 files changed, 16 insertions, 261 deletions
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/DefaultScopeRegistry.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/DefaultScopeRegistry.java
index 931a530f36..2ea724ccf6 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/DefaultScopeRegistry.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/DefaultScopeRegistry.java
@@ -20,7 +20,6 @@
package org.apache.tuscany.sca.core.scope;
import org.apache.tuscany.sca.core.scope.impl.CompositeScopeContainerFactory;
-import org.apache.tuscany.sca.core.scope.impl.RequestScopeContainerFactory;
import org.apache.tuscany.sca.core.scope.impl.ScopeRegistryImpl;
import org.apache.tuscany.sca.core.scope.impl.StatelessScopeContainerFactory;
@@ -33,9 +32,7 @@ public class DefaultScopeRegistry extends ScopeRegistryImpl implements ScopeRegi
public DefaultScopeRegistry() {
ScopeContainerFactory[] factories =
- new ScopeContainerFactory[] {new CompositeScopeContainerFactory(), new StatelessScopeContainerFactory(),
- new RequestScopeContainerFactory(),
- };
+ new ScopeContainerFactory[] {new CompositeScopeContainerFactory(), new StatelessScopeContainerFactory()};
for (ScopeContainerFactory f : factories) {
register(f);
}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/Scope.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/Scope.java
index 0a20d793f7..0a7f2ef64f 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/Scope.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/Scope.java
@@ -25,12 +25,8 @@ package org.apache.tuscany.sca.core.scope;
*/
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");
+ public static final Scope INVALID = new Scope("INVALID");
private String scope;
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/HttpSessionScopeContainer.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/HttpSessionScopeContainer.java
deleted file mode 100644
index bfe197255d..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/HttpSessionScopeContainer.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * 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.core.scope.impl;
-
-import org.apache.tuscany.sca.core.factory.InstanceWrapper;
-import org.apache.tuscany.sca.core.scope.AbstractScopeContainer;
-import org.apache.tuscany.sca.core.scope.Scope;
-import org.apache.tuscany.sca.core.scope.TargetResolutionException;
-import org.apache.tuscany.sca.runtime.RuntimeComponent;
-
-/**
- * A scope context which manages atomic component instances keyed on HTTP
- * session
- *
- * @version $Rev$ $Date$
- */
-public class HttpSessionScopeContainer extends AbstractScopeContainer<Object> {
-
- public HttpSessionScopeContainer(RuntimeComponent component) {
- super(Scope.SESSION, component);
- }
-
- @Override
- public synchronized void start() {
- if (lifecycleState != UNINITIALIZED && lifecycleState != STOPPED) {
- throw new IllegalStateException("Scope must be in UNINITIALIZED or STOPPED state [" + lifecycleState + "]");
- }
- lifecycleState = RUNNING;
- }
-
- @Override
- public synchronized void stop() {
- lifecycleState = STOPPED;
- }
-
- protected InstanceWrapper getInstanceWrapper(boolean create) throws TargetResolutionException {
-// Object key = workContext.getIdentifier(Scope.SESSION);
- // FIXME: Need to fix this
- Object key ="http-session-id";
- assert key != null : "HTTP session key not bound in work context";
- InstanceWrapper ctx = wrappers.get(key);
- if (ctx == null && !create) {
- return null;
- }
- if (ctx == null) {
- ctx = super.createInstanceWrapper();
- ctx.start();
- wrappers.put(key, ctx);
- }
- return ctx;
- }
-
- @Override
- public InstanceWrapper getWrapper(Object contextId) throws TargetResolutionException {
- return getInstanceWrapper(true);
- }
-
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/HttpSessionScopeContainerFactory.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/HttpSessionScopeContainerFactory.java
deleted file mode 100644
index d6aaa4cc84..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/HttpSessionScopeContainerFactory.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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.core.scope.impl;
-
-import org.apache.tuscany.sca.core.scope.Scope;
-import org.apache.tuscany.sca.core.scope.ScopeContainer;
-import org.apache.tuscany.sca.core.scope.ScopeContainerFactory;
-import org.apache.tuscany.sca.runtime.RuntimeComponent;
-
-/**
- * @version $Rev$ $Date$
- */
-public class HttpSessionScopeContainerFactory implements ScopeContainerFactory {
-
- public HttpSessionScopeContainerFactory() {
- super();
- }
-
- public ScopeContainer createScopeContainer(RuntimeComponent component) {
- return new HttpSessionScopeContainer(component);
- }
-
- public Scope getScope() {
- return Scope.SESSION;
- }
-
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/RequestScopeContainer.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/RequestScopeContainer.java
deleted file mode 100644
index 7519af2341..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/RequestScopeContainer.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * 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.core.scope.impl;
-
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.apache.tuscany.sca.core.factory.InstanceWrapper;
-import org.apache.tuscany.sca.core.scope.AbstractScopeContainer;
-import org.apache.tuscany.sca.core.scope.Scope;
-import org.apache.tuscany.sca.core.scope.TargetResolutionException;
-import org.apache.tuscany.sca.runtime.RuntimeComponent;
-
-/**
- * A scope context which manages atomic component instances keyed on the current
- * request context
- *
- * @version $Rev$ $Date$
- */
-public class RequestScopeContainer extends AbstractScopeContainer<Thread> {
- private final Map<Thread, InstanceWrapper> contexts;
-
- public RequestScopeContainer(RuntimeComponent component) {
- super(Scope.REQUEST, component);
- contexts = new ConcurrentHashMap<Thread, InstanceWrapper>();
- }
-
- @Override
- public synchronized void start() {
- if (lifecycleState != UNINITIALIZED && lifecycleState != STOPPED) {
- throw new IllegalStateException("Scope must be in UNINITIALIZED or STOPPED state [" + lifecycleState + "]");
- }
- lifecycleState = RUNNING;
- }
-
- @Override
- public synchronized void stop() {
- contexts.clear();
- // synchronized (destroyQueues) {
- // destroyQueues.clear();
- // }
- lifecycleState = STOPPED;
- }
-
- protected InstanceWrapper getInstanceWrapper(boolean create) throws TargetResolutionException {
- InstanceWrapper ctx = wrappers.get(Thread.currentThread());
- if (ctx == null && !create) {
- return null;
- }
- if (ctx == null) {
- ctx = super.createInstanceWrapper();
- ctx.start();
- wrappers.put(Thread.currentThread(), ctx);
- }
- return ctx;
- }
-
- @Override
- public InstanceWrapper getWrapper(Thread contextId) throws TargetResolutionException {
- return getInstanceWrapper(true);
- }
-
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/RequestScopeContainerFactory.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/RequestScopeContainerFactory.java
deleted file mode 100644
index 9d1cf88d96..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/RequestScopeContainerFactory.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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.core.scope.impl;
-
-import org.apache.tuscany.sca.core.scope.Scope;
-import org.apache.tuscany.sca.core.scope.ScopeContainer;
-import org.apache.tuscany.sca.core.scope.ScopeContainerFactory;
-import org.apache.tuscany.sca.runtime.RuntimeComponent;
-
-/**
- * @version $Rev$ $Date$
- */
-public class RequestScopeContainerFactory implements ScopeContainerFactory {
-
- public ScopeContainer createScopeContainer(RuntimeComponent component) {
- return new RequestScopeContainer(component);
- }
-
- public Scope getScope() {
- return Scope.REQUEST;
- }
-
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/ScopeRegistryImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/ScopeRegistryImpl.java
index f11295c9fa..9884c5f053 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/ScopeRegistryImpl.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/ScopeRegistryImpl.java
@@ -56,6 +56,8 @@ public class ScopeRegistryImpl implements ScopeRegistry {
Scope scope = provider.getScope();
if (scope == null) {
scope = Scope.STATELESS;
+ } else if (scope.equals(Scope.INVALID)) {
+ return null;
}
ScopeContainerFactory factory = scopeCache.get(scope);
ScopeContainer container = factory.createScopeContainer(component);
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaScopeImpl.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaScopeImpl.java
index b3ee8e8b2b..c977736630 100644
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaScopeImpl.java
+++ b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaScopeImpl.java
@@ -25,12 +25,8 @@ package org.apache.tuscany.sca.implementation.java;
*/
public class JavaScopeImpl {
public static final JavaScopeImpl STATELESS = new JavaScopeImpl("STATELESS");
- public static final JavaScopeImpl REQUEST = new JavaScopeImpl("REQUEST");
- public static final JavaScopeImpl SESSION = new JavaScopeImpl("SESSION");
- public static final JavaScopeImpl CONVERSATION = new JavaScopeImpl("CONVERSATION");
public static final JavaScopeImpl COMPOSITE = new JavaScopeImpl("COMPOSITE");
- public static final JavaScopeImpl SYSTEM = new JavaScopeImpl("SYSTEM");
- public static final JavaScopeImpl UNDEFINED = new JavaScopeImpl("UNDEFINED");
+ public static final JavaScopeImpl INVALID = new JavaScopeImpl("INVALID");
private String scope;
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ScopeProcessor.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ScopeProcessor.java
index 4bfdb9af9e..66be4f1f1e 100644
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ScopeProcessor.java
+++ b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ScopeProcessor.java
@@ -44,19 +44,20 @@ public class ScopeProcessor extends BaseJavaClassVisitor {
type.setJavaScope(JavaScopeImpl.STATELESS);
return;
}
+
String name = annotation.value();
JavaScopeImpl scope;
if ("COMPOSITE".equals(name)) {
scope = JavaScopeImpl.COMPOSITE;
- } else if ("SESSION".equals(name)) {
- scope = JavaScopeImpl.SESSION;
- } else if ("CONVERSATION".equals(name)) {
- scope = JavaScopeImpl.CONVERSATION;
- } else if ("REQUEST".equals(name)) {
- scope = JavaScopeImpl.REQUEST;
+ } else if ("STATELESS".equals(name)) {
+ scope = JavaScopeImpl.STATELESS;
} else {
- scope = new JavaScopeImpl(name);
+ scope = JavaScopeImpl.INVALID;
}
type.setJavaScope(scope);
+
+ if (type.getJavaScope().equals(JavaScopeImpl.INVALID)) {
+ throw new IntrospectionException("Invalid scope :" + name + " for " + type.getName());
+ }
}
}
diff --git a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ScopeProcessorTestCase.java b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ScopeProcessorTestCase.java
index fe5eee55de..4e05deae82 100644
--- a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ScopeProcessorTestCase.java
+++ b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ScopeProcessorTestCase.java
@@ -50,7 +50,7 @@ public class ScopeProcessorTestCase {
ScopeProcessor processor = new ScopeProcessor(new DefaultAssemblyFactory());
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
processor.visitClass(Session.class, type);
- assertEquals(JavaScopeImpl.SESSION, type.getJavaScope());
+ assertEquals(JavaScopeImpl.INVALID, type.getJavaScope());
}
@Test
@@ -58,7 +58,7 @@ public class ScopeProcessorTestCase {
ScopeProcessor processor = new ScopeProcessor(new DefaultAssemblyFactory());
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
processor.visitClass(Conversation.class, type);
- assertEquals(JavaScopeImpl.CONVERSATION, type.getJavaScope());
+ assertEquals(JavaScopeImpl.INVALID, type.getJavaScope());
}
@Test
@@ -66,7 +66,7 @@ public class ScopeProcessorTestCase {
ScopeProcessor processor = new ScopeProcessor(new DefaultAssemblyFactory());
JavaImplementation type = javaImplementationFactory.createJavaImplementation();
processor.visitClass(Request.class, type);
- assertEquals(JavaScopeImpl.REQUEST, type.getJavaScope());
+ assertEquals(JavaScopeImpl.INVALID, type.getJavaScope());
}
@Test