diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2009-06-22 07:47:06 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2009-06-22 07:47:06 +0000 |
commit | 0a6f3a62200c9465126fcf9e191556988d344d2f (patch) | |
tree | 1c4c1c39022a9ab5c45c240d6b1e5e3c699068ff /java/sca/modules/implementation-java/src | |
parent | f116d5feccb9694aab9476bc7213649a524d16ae (diff) |
Remove all conversational related code from SCA API and code that uses it as per the public review spec's
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@787158 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/implementation-java/src')
6 files changed, 0 insertions, 575 deletions
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaImplementationActivator.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaImplementationActivator.java index 39484b8840..f72b40d794 100644 --- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaImplementationActivator.java +++ b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaImplementationActivator.java @@ -29,8 +29,6 @@ import org.apache.tuscany.sca.implementation.java.introspect.impl.AllowsPassByRe import org.apache.tuscany.sca.implementation.java.introspect.impl.ComponentNameProcessor; import org.apache.tuscany.sca.implementation.java.introspect.impl.ConstructorProcessor; import org.apache.tuscany.sca.implementation.java.introspect.impl.ContextProcessor; -import org.apache.tuscany.sca.implementation.java.introspect.impl.ConversationIDProcessor; -import org.apache.tuscany.sca.implementation.java.introspect.impl.ConversationProcessor; import org.apache.tuscany.sca.implementation.java.introspect.impl.DestroyProcessor; import org.apache.tuscany.sca.implementation.java.introspect.impl.EagerInitProcessor; import org.apache.tuscany.sca.implementation.java.introspect.impl.HeuristicPojoProcessor; @@ -62,8 +60,6 @@ public class JavaImplementationActivator implements ModuleActivator { new AllowsPassByReferenceProcessor(assemblyFactory), new ComponentNameProcessor(assemblyFactory), new ContextProcessor(assemblyFactory), - new ConversationIDProcessor(assemblyFactory), - new ConversationProcessor(assemblyFactory), new DestroyProcessor(assemblyFactory), new EagerInitProcessor(assemblyFactory), new InitProcessor(assemblyFactory), new PropertyProcessor(assemblyFactory), new ReferenceProcessor(assemblyFactory, javaFactory), diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConversationIDProcessor.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConversationIDProcessor.java deleted file mode 100644 index ef94104cbd..0000000000 --- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConversationIDProcessor.java +++ /dev/null @@ -1,72 +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.implementation.java.introspect.impl; - -import java.lang.reflect.Field; -import java.lang.reflect.Method; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.implementation.java.IntrospectionException; -import org.apache.tuscany.sca.implementation.java.JavaElementImpl; -import org.apache.tuscany.sca.implementation.java.JavaImplementation; -import org.apache.tuscany.sca.implementation.java.JavaResourceImpl; -import org.apache.tuscany.sca.implementation.java.introspect.BaseJavaClassVisitor; -import org.apache.tuscany.sca.implementation.java.introspect.JavaIntrospectionHelper; -import org.oasisopen.sca.annotation.ConversationID; - -/** - * Processes {@link @ConversationID} annotations on a component implementation and adds - * a {@link JavaMappedProperty} to the component type which will be used to - * inject the appropriate conversationId - * - * @version $Rev$ $Date$ - */ -public class ConversationIDProcessor extends BaseJavaClassVisitor { - - public ConversationIDProcessor(AssemblyFactory factory) { - super(factory); - } - - @Override - public void visitMethod(Method method, JavaImplementation type) throws IntrospectionException { - if (method.getAnnotation(ConversationID.class) == null) { - return; - } - if (method.getParameterTypes().length != 1) { - throw new IllegalContextException("ConversationID setter must have one parameter", method); - } - String name = JavaIntrospectionHelper.toPropertyName(method.getName()); - JavaElementImpl element = new JavaElementImpl(method, 0); - element.setName(name); - element.setClassifer(org.apache.tuscany.sca.implementation.java.introspect.impl.Resource.class); - JavaResourceImpl resource = new JavaResourceImpl(element); - type.getResources().put(resource.getName(), resource); - } - - @Override - public void visitField(Field field, JavaImplementation type) throws IntrospectionException { - if (field.getAnnotation(ConversationID.class) == null) { - return; - } - JavaElementImpl element = new JavaElementImpl(field); - element.setClassifer(org.apache.tuscany.sca.implementation.java.introspect.impl.Resource.class); - JavaResourceImpl resource = new JavaResourceImpl(element); - type.getResources().put(resource.getName(), resource); - } -} diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConversationProcessor.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConversationProcessor.java deleted file mode 100644 index 2fb657159b..0000000000 --- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConversationProcessor.java +++ /dev/null @@ -1,133 +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.implementation.java.introspect.impl; - -import java.lang.reflect.Field; -import java.lang.reflect.Method; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.implementation.java.IntrospectionException; -import org.apache.tuscany.sca.implementation.java.JavaImplementation; -import org.apache.tuscany.sca.implementation.java.introspect.BaseJavaClassVisitor; -import org.oasisopen.sca.annotation.ConversationAttributes; -import org.oasisopen.sca.annotation.ConversationID; -import org.oasisopen.sca.annotation.Scope; - -/** - * @version $Rev$ $Date$ - */ -public class ConversationProcessor extends BaseJavaClassVisitor { - private static final String SECONDS = " SECONDS"; - private static final String MINUTES = " MINUTES"; - private static final String HOURS = " HOURS"; - private static final String DAYS = " DAYS"; - private static final String YEARS = " YEARS"; - - public ConversationProcessor(AssemblyFactory factory) { - super(factory); - } - - @Override - public <T> void visitClass(Class<T> clazz, JavaImplementation type) throws IntrospectionException { - - ConversationAttributes conversation = clazz.getAnnotation(ConversationAttributes.class); - if (conversation == null) { - return; - } - Scope scope = clazz.getAnnotation(Scope.class); - if (scope == null) { - // implicitly assume conversation - type.setJavaScope(org.apache.tuscany.sca.implementation.java.JavaScopeImpl.CONVERSATION); - } else if (conversation != null) { - long maxAge; - long maxIdleTime; - String maxAgeVal = conversation.maxAge(); - String maxIdleTimeVal = conversation.maxIdleTime(); - try { - if (maxAgeVal.length() > 0) { - maxAge = convertTimeMillis(maxAgeVal); - type.setMaxAge(maxAge); - } - } catch (NumberFormatException e) { - throw new InvalidConversationalImplementationException("Invalid maximum age", e); - } - try { - if (maxIdleTimeVal.length() > 0) { - maxIdleTime = convertTimeMillis(maxIdleTimeVal); - type.setMaxIdleTime(maxIdleTime); - } - } catch (NumberFormatException e) { - throw new InvalidConversationalImplementationException("Invalid maximum idle time", e); - } - } - - } - - @Override - public void visitMethod(Method method, - JavaImplementation type) throws IntrospectionException { - ConversationID conversationID = method.getAnnotation(ConversationID.class); - if (conversationID == null) { - return; - } - type.addConversationIDMember(method); - } - - @Override - public void visitField(Field field, - JavaImplementation type) throws IntrospectionException { - ConversationID conversationID = field.getAnnotation(ConversationID.class); - if (conversationID == null) { - return; - } - type.addConversationIDMember(field); - } - - static long convertTimeMillis(String expr) throws NumberFormatException { - expr = expr.trim().toUpperCase(); - int i = expr.lastIndexOf(SECONDS); - if (i >= 0) { - String units = expr.substring(0, i); - return Long.parseLong(units) * 1000; - } - i = expr.lastIndexOf(MINUTES); - if (i >= 0) { - String units = expr.substring(0, i); - return Long.parseLong(units) * 60000; - } - - i = expr.lastIndexOf(HOURS); - if (i >= 0) { - String units = expr.substring(0, i); - return Long.parseLong(units) * 3600000; - } - i = expr.lastIndexOf(DAYS); - if (i >= 0) { - String units = expr.substring(0, i); - return Long.parseLong(units) * 86400000; - } - i = expr.lastIndexOf(YEARS); - if (i >= 0) { - String units = expr.substring(0, i); - return Long.parseLong(units) * 31556926000L; - } - return Long.parseLong(expr) * 1000; // assume seconds if no suffix - // specified - } -} diff --git a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConversationIDProcessorTestCase.java b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConversationIDProcessorTestCase.java deleted file mode 100644 index 9bff2aa556..0000000000 --- a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConversationIDProcessorTestCase.java +++ /dev/null @@ -1,99 +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.implementation.java.introspect.impl; - -import static org.junit.Assert.assertNotNull; - -import java.lang.reflect.Field; -import java.lang.reflect.Method; - -import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory; -import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory; -import org.apache.tuscany.sca.implementation.java.JavaImplementation; -import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory; -import org.junit.Before; -import org.junit.Test; -import org.oasisopen.sca.annotation.ConversationID; - -/** - * Test the ConversationIDProcessor - * - * @version $Rev$ $Date$ - */ -public class ConversationIDProcessorTestCase { - private ConversationIDProcessor processor; - private JavaImplementationFactory javaImplementationFactory; - - @Test - public void testConversationIDMethod() throws Exception { - Method method = Foo.class.getMethod("setConversationID", String.class); - JavaImplementation type = javaImplementationFactory.createJavaImplementation(); - processor.visitMethod(method, type); - assertNotNull(type.getResources().get("conversationID")); - } - - @Test - public void testConversationIDField() throws Exception { - Field field = Foo.class.getDeclaredField("cid"); - JavaImplementation type = javaImplementationFactory.createJavaImplementation(); - processor.visitField(field, type); - assertNotNull(type.getResources().get("cid")); - } - - @Test - public void testConversationIDMethodNotString() throws Exception { - Method method = Foo.class.getMethod("setConversationID", Long.class); - JavaImplementation type = javaImplementationFactory.createJavaImplementation(); - processor.visitMethod(method, type); - assertNotNull(type.getResources().get("conversationID")); - } - - @Test - public void testConversationIDFieldNotString() throws Exception { - Field field = Foo.class.getDeclaredField("longCID"); - JavaImplementation type = javaImplementationFactory.createJavaImplementation(); - processor.visitField(field, type); - assertNotNull(type.getResources().get("longCID")); - } - - @Before - public void setUp() throws Exception { - javaImplementationFactory = new DefaultJavaImplementationFactory(); - processor = new ConversationIDProcessor(new DefaultAssemblyFactory()); - } - - private class Foo { - - @ConversationID - protected String cid; - - @ConversationID - public void setConversationID(String cid) { - - } - - @ConversationID - protected Long longCID; - - @ConversationID - public void setConversationID(Long cid) { - - } - } -} diff --git a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConversationProcessorTestCase.java b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConversationProcessorTestCase.java deleted file mode 100644 index 9978cd456d..0000000000 --- a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConversationProcessorTestCase.java +++ /dev/null @@ -1,153 +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.implementation.java.introspect.impl; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import java.lang.reflect.Field; -import java.lang.reflect.Method; - -import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory; -import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory; -import org.apache.tuscany.sca.implementation.java.JavaImplementation; -import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory; -import org.junit.Test; -import org.oasisopen.sca.annotation.ConversationAttributes; -import org.oasisopen.sca.annotation.ConversationID; -import org.oasisopen.sca.annotation.Scope; - -/** - * @version $Rev$ $Date$ - */ -public class ConversationProcessorTestCase { - private ConversationProcessor processor = new ConversationProcessor(new DefaultAssemblyFactory()); - private JavaImplementationFactory javaImplementationFactory = new DefaultJavaImplementationFactory(); - - @Test - public void testMaxIdleTime() throws Exception { - JavaImplementation type = javaImplementationFactory.createJavaImplementation(); - processor.visitClass(FooMaxIdle.class, type); - assertEquals(10000L, type.getMaxIdleTime()); - assertEquals(-1, type.getMaxAge()); - } - - @Test - public void testMaxAge() throws Exception { - JavaImplementation type = javaImplementationFactory.createJavaImplementation(); - processor.visitClass(FooMaxAge.class, type); - assertEquals(10000L, type.getMaxAge()); - assertEquals(-1, type.getMaxIdleTime()); - } - - @Test - public void testImplicitScope() throws Exception { - JavaImplementation type = javaImplementationFactory.createJavaImplementation(); - processor.visitClass(ImplicitFooScope.class, type); - assertEquals(org.apache.tuscany.sca.implementation.java.JavaScopeImpl.CONVERSATION, type.getJavaScope()); - } - - /* TUSCANY-1999 - apply conversation properties to all scopes - public void testBadFooScope() throws Exception { - JavaImplementation type = javaImplementationFactory.createJavaImplementation(); - try { - processor.visitClass(BadFooScope.class, type); - fail(); - } catch (InvalidConversationalImplementation e) { - // expected - } - } - */ - - @Test - public void testBadFooBoth() throws Exception { - JavaImplementation type = javaImplementationFactory.createJavaImplementation(); - processor.visitClass(BadFooBoth.class, type); - assertEquals(10000L, type.getMaxAge()); - assertEquals(10000L, type.getMaxIdleTime()); - } - - @Test - public void testJustConversation() throws Exception { - // TODO do we want these semantics - JavaImplementation type = javaImplementationFactory.createJavaImplementation(); - processor.visitClass(FooJustConversation.class, type); - assertEquals(org.apache.tuscany.sca.implementation.java.JavaScopeImpl.CONVERSATION, type.getJavaScope()); - assertEquals(-1, type.getMaxAge()); - assertEquals(-1, type.getMaxIdleTime()); - } - - @Test - public void testSetConversationIDField() throws Exception { - JavaImplementation type = javaImplementationFactory.createJavaImplementation(); - Field field = FooWithConversationIDField.class.getDeclaredField("conversationID"); - processor.visitField(field, type); - assertNotNull(type.getConversationIDMembers()); - assertEquals(field, type.getConversationIDMembers().get(0)); - } - - @Test - public void testSetConversationIDMethod() throws Exception { - JavaImplementation type = javaImplementationFactory.createJavaImplementation(); - Method method = FooWithConversationIDMethod.class.getDeclaredMethods()[0]; - processor.visitMethod(method, type); - assertNotNull(type.getConversationIDMembers()); - assertEquals(method, type.getConversationIDMembers().get(0)); - } - - @Scope("CONVERSATION") - @ConversationAttributes(maxIdleTime = "10 seconds") - private class FooMaxIdle { - } - - @Scope("CONVERSATION") - @ConversationAttributes(maxAge = "10 seconds") - private class FooMaxAge { - } - - @Scope("CONVERSATION") - @ConversationAttributes(maxAge = "10 seconds", maxIdleTime = "10 seconds") - private class BadFooBoth { - } - - @ConversationAttributes(maxAge = "10 seconds") - private class ImplicitFooScope { - } - - @Scope("STATELESS") - @ConversationAttributes(maxAge = "10 seconds") - private class BadFooScope { - } - - @ConversationAttributes - private class FooJustConversation { - } - - private class FooWithConversationIDField { - - @ConversationID - String conversationID; - } - - private class FooWithConversationIDMethod { - @ConversationID - void setConversationID(String conversationID) { - } - } -} diff --git a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConvertTimeMillisTestCase.java b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConvertTimeMillisTestCase.java deleted file mode 100644 index 4e5a2dfee6..0000000000 --- a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConvertTimeMillisTestCase.java +++ /dev/null @@ -1,114 +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.implementation.java.introspect.impl; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; - -import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory; -import org.junit.Test; - -/** - * @version $Rev$ $Date$ - */ -public class ConvertTimeMillisTestCase { - - @Test - public void testConvertSeconds() throws Exception { - assertEquals(10000L, MockProcessor.convertTimeMillis("10 seconds")); - assertEquals(10000L, MockProcessor.convertTimeMillis("10 SECONDS")); - try { - MockProcessor.convertTimeMillis("10seconds"); - fail(); - } catch (NumberFormatException e) { - // expected - } - } - - @Test - public void testConvertMinutes() throws Exception { - assertEquals(600000L, MockProcessor.convertTimeMillis("10 minutes")); - assertEquals(600000L, MockProcessor.convertTimeMillis("10 MINUTES")); - try { - MockProcessor.convertTimeMillis("10minutes"); - fail(); - } catch (NumberFormatException e) { - // expected - } - } - - @Test - public void testConvertHours() throws Exception { - assertEquals(36000000L, MockProcessor.convertTimeMillis("10 hours")); - assertEquals(36000000L, MockProcessor.convertTimeMillis("10 HOURS")); - try { - MockProcessor.convertTimeMillis("10hours"); - fail(); - } catch (NumberFormatException e) { - // expected - } - } - - @Test - public void testConvertDays() throws Exception { - assertEquals(864000000L, MockProcessor.convertTimeMillis("10 days")); - assertEquals(864000000L, MockProcessor.convertTimeMillis("10 DAYS")); - try { - MockProcessor.convertTimeMillis("10days"); - fail(); - } catch (NumberFormatException e) { - // expected - } - } - - @Test - public void testConvertYears() throws Exception { - assertEquals(315569260000L, MockProcessor.convertTimeMillis("10 years")); - assertEquals(315569260000L, MockProcessor.convertTimeMillis("10 YEARS")); - try { - MockProcessor.convertTimeMillis("10years"); - fail(); - } catch (NumberFormatException e) { - // expected - } - } - - @Test - public void testConvertDefault() throws Exception { - assertEquals(10000L, MockProcessor.convertTimeMillis("10 ")); - assertEquals(10000L, MockProcessor.convertTimeMillis("10")); - } - - @Test - public void testInvalid() throws Exception { - try { - MockProcessor.convertTimeMillis("foo"); - fail(); - } catch (NumberFormatException e) { - // expected - } - } - - private class MockProcessor extends ConversationProcessor { - - public MockProcessor() { - super(new DefaultAssemblyFactory()); - } - } -} |