Author: jmarino
Date: Sun Nov 26 11:31:33 2006
New Revision: 479410
URL: http://svn.apache.org/viewvc?view=rev&rev=479410
Log:
move processing of conversational annotation to implementation processor from
interface processor
Added:
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ConversationProcessor.java
(with props)
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InvalidConversationalImplementation.java
(with props)
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConversationProcessorTestCase.java
(with props)
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConvertTimeMillisTestCase.java
(with props)
Removed:
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/idl/java/ConvertTimeMillisTestCase.java
Modified:
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/idl/java/JavaInterfaceProcessorRegistryImpl.java
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/idl/java/ConversationalIntrospectionTestCase.java
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/integration/conversation/BasicConversationInvocationTestCase.java
incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ComponentType.java
incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ServiceContract.java
Modified:
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/idl/java/JavaInterfaceProcessorRegistryImpl.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/idl/java/JavaInterfaceProcessorRegistryImpl.java?view=diff&rev=479410&r1=479409&r2=479410
==============================================================================
---
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/idl/java/JavaInterfaceProcessorRegistryImpl.java
(original)
+++
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/idl/java/JavaInterfaceProcessorRegistryImpl.java
Sun Nov 26 11:31:33 2006
@@ -26,7 +26,6 @@
import java.util.Map;
import org.osoa.sca.annotations.Callback;
-import org.osoa.sca.annotations.Conversation;
import org.osoa.sca.annotations.EndConversation;
import org.osoa.sca.annotations.OneWay;
import org.osoa.sca.annotations.Remotable;
@@ -43,7 +42,6 @@
import org.apache.tuscany.spi.model.Operation;
import static org.apache.tuscany.spi.model.Operation.CONVERSATION_END;
import static org.apache.tuscany.spi.model.Operation.NO_CONVERSATION;
-import static org.apache.tuscany.spi.model.ServiceContract.UNDEFINED;
import static org.apache.tuscany.core.util.JavaIntrospectionHelper.getBaseName;
@@ -56,11 +54,6 @@
public static final String IDL_INPUT = "idl:input";
private static final String UNKNOWN_DATABINDING = null;
- 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";
private List<JavaInterfaceProcessor> processors = new
ArrayList<JavaInterfaceProcessor>();
@@ -103,39 +96,6 @@
} else {
contract.setInteractionScope(InteractionScope.NONCONVERSATIONAL);
}
- Conversation conversation = type.getAnnotation(Conversation.class);
- if (conversation != null && !conversational) {
- InvalidConversationalContractException e = new
InvalidConversationalContractException(
- "Service is marked with @Conversation but the scope is not
@Scope(\"CONVERSATION\")");
- e.setIdentifier(type.getName());
- throw e;
- } else if (conversation != null) {
- long maxAge = UNDEFINED;
- long maxIdleTime = UNDEFINED;
- try {
- String maxAgeVal = conversation.maxAge();
- if (maxAgeVal != null && maxAgeVal.length() > 0) {
- maxAge = convertTimeMillis(maxAgeVal);
- }
- } catch (NumberFormatException e) {
- InvalidConversationalContractException e2 =
- new InvalidConversationalContractException("Invalid
maximum age", e);
- e2.setIdentifier(type.getName());
- }
- try {
- String maxIdleTimeVal = conversation.maxIdleTime();
- if (maxIdleTimeVal != null && maxIdleTimeVal.length() > 0) {
- maxIdleTime = convertTimeMillis(maxIdleTimeVal);
- }
- } catch (NumberFormatException e) {
- InvalidConversationalContractException e2 =
- new InvalidConversationalContractException("Invalid
maximum idle time", e);
- e2.setIdentifier(type.getName());
- }
-
- contract.setMaxAge(maxAge);
- contract.setMaxIdleTime(maxIdleTime);
- }
contract.setOperations(getOperations(type, remotable, conversational));
if (callback != null) {
@@ -199,38 +159,6 @@
operations.put(name, operation);
}
return operations;
- }
-
-
- protected 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
}
}
Added:
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ConversationProcessor.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ConversationProcessor.java?view=auto&rev=479410
==============================================================================
---
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ConversationProcessor.java
(added)
+++
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ConversationProcessor.java
Sun Nov 26 11:31:33 2006
@@ -0,0 +1,128 @@
+/*
+ * 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.implementation.processor;
+
+import org.osoa.sca.annotations.Conversation;
+import org.osoa.sca.annotations.Scope;
+
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import
org.apache.tuscany.spi.implementation.java.ImplementationProcessorExtension;
+import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
+import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
+import org.apache.tuscany.spi.implementation.java.JavaMappedService;
+import org.apache.tuscany.spi.implementation.java.PojoComponentType;
+import org.apache.tuscany.spi.implementation.java.ProcessingException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ConversationProcessor extends ImplementationProcessorExtension {
+ 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 <T> void visitClass(CompositeComponent parent,
+ Class<T> clazz,
+ PojoComponentType<JavaMappedService,
JavaMappedReference, JavaMappedProperty<?>> type,
+ DeploymentContext context) throws
ProcessingException {
+
+ Conversation conversation = clazz.getAnnotation(Conversation.class);
+ if (conversation == null) {
+ return;
+ }
+ Scope scope = clazz.getAnnotation(Scope.class);
+ if (scope == null) {
+ // implicitly assume conversation
+
type.setImplementationScope(org.apache.tuscany.spi.model.Scope.CONVERSATION);
+ } else if (scope != null &&
!"CONVERSATION".equals(scope.value().toUpperCase())) {
+ InvalidConversationalImplementation e = new
InvalidConversationalImplementation(
+ "Service is marked with @Conversation but the scope is not
@Scope(\"CONVERSATION\")");
+ e.setIdentifier(clazz.getName());
+ throw e;
+ } else if (conversation != null) {
+ long maxAge;
+ long maxIdleTime;
+ String maxAgeVal = conversation.maxAge();
+ String maxIdleTimeVal = conversation.maxIdleTime();
+ if (maxAgeVal.length() > 0 && maxIdleTimeVal.length() > 0) {
+ InvalidConversationalImplementation e =
+ new InvalidConversationalImplementation("Max idle time and
age both specified");
+ e.setIdentifier(clazz.getName());
+ throw e;
+ }
+ try {
+ if (maxAgeVal.length() > 0) {
+ maxAge = convertTimeMillis(maxAgeVal);
+ type.setMaxAge(maxAge);
+ }
+ } catch (NumberFormatException e) {
+ InvalidConversationalImplementation e2 =
+ new InvalidConversationalImplementation("Invalid maximum
age", e);
+ e2.setIdentifier(clazz.getName());
+ throw e2;
+ }
+ try {
+ if (maxIdleTimeVal.length() > 0) {
+ maxIdleTime = convertTimeMillis(maxIdleTimeVal);
+ type.setMaxIdleTime(maxIdleTime);
+ }
+ } catch (NumberFormatException e) {
+ InvalidConversationalImplementation e2 =
+ new InvalidConversationalImplementation("Invalid maximum
idle time", e);
+ e2.setIdentifier(clazz.getName());
+ throw e2;
+ }
+ }
+
+ }
+
+ protected 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
+ }
+}
Propchange:
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ConversationProcessor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/ConversationProcessor.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InvalidConversationalImplementation.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InvalidConversationalImplementation.java?view=auto&rev=479410
==============================================================================
---
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InvalidConversationalImplementation.java
(added)
+++
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InvalidConversationalImplementation.java
Sun Nov 26 11:31:33 2006
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.implementation.processor;
+
+import org.apache.tuscany.spi.implementation.java.ProcessingException;
+
+/**
+ * Raised when an implementation specifies improper conversational metadata
+ *
+ * @version $Rev$ $Date$
+ */
+public class InvalidConversationalImplementation extends ProcessingException {
+ public InvalidConversationalImplementation() {
+ }
+
+ public InvalidConversationalImplementation(String message) {
+ super(message);
+ }
+
+ public InvalidConversationalImplementation(String message, Throwable
cause) {
+ super(message, cause);
+ }
+
+ public InvalidConversationalImplementation(Throwable cause) {
+ super(cause);
+ }
+}
Propchange:
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InvalidConversationalImplementation.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/processor/InvalidConversationalImplementation.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified:
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/idl/java/ConversationalIntrospectionTestCase.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/idl/java/ConversationalIntrospectionTestCase.java?view=diff&rev=479410&r1=479409&r2=479410
==============================================================================
---
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/idl/java/ConversationalIntrospectionTestCase.java
(original)
+++
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/idl/java/ConversationalIntrospectionTestCase.java
Sun Nov 26 11:31:33 2006
@@ -18,7 +18,6 @@
*/
package org.apache.tuscany.core.idl.java;
-import org.osoa.sca.annotations.Conversation;
import org.osoa.sca.annotations.EndConversation;
import org.osoa.sca.annotations.Scope;
@@ -27,7 +26,6 @@
import static org.apache.tuscany.spi.model.InteractionScope.CONVERSATIONAL;
import static org.apache.tuscany.spi.model.InteractionScope.NONCONVERSATIONAL;
import org.apache.tuscany.spi.model.Operation;
-import static org.apache.tuscany.spi.model.ServiceContract.UNDEFINED;
import junit.framework.TestCase;
@@ -39,8 +37,6 @@
public void testServiceContractConversationalInformationIntrospection()
throws Exception {
JavaServiceContract contract = registry.introspect(Foo.class);
- assertEquals(UNDEFINED, contract.getMaxAge());
- assertEquals(UNDEFINED, contract.getMaxIdleTime());
assertEquals(CONVERSATIONAL, contract.getInteractionScope());
int seq =
contract.getOperations().get("operation").getConversationSequence();
assertEquals(Operation.CONVERSATION_CONTINUE, seq);
@@ -48,11 +44,6 @@
assertEquals(Operation.CONVERSATION_END, seq);
}
- public void testServiceContractConversationAnnotation() throws Exception {
- JavaServiceContract contract =
registry.introspect(FooConversation.class);
- assertEquals(100000, contract.getMaxAge());
- }
-
public void testBadServiceContract() throws Exception {
try {
registry.introspect(BadFoo.class);
@@ -62,19 +53,8 @@
}
}
- public void testBadConversationAnnotation() throws Exception {
- try {
- registry.introspect(BadFooConversation.class);
- fail();
- } catch (InvalidConversationalContractException e) {
- //expected
- }
- }
-
public void testNonConversationalInformationIntrospection() throws
Exception {
JavaServiceContract contract =
registry.introspect(NonConversationalFoo.class);
- assertEquals(UNDEFINED, contract.getMaxAge());
- assertEquals(UNDEFINED, contract.getMaxIdleTime());
assertEquals(NONCONVERSATIONAL, contract.getInteractionScope());
int seq =
contract.getOperations().get("operation").getConversationSequence();
assertEquals(Operation.NO_CONVERSATION, seq);
@@ -88,21 +68,11 @@
void endOperation();
}
- @Scope("CONVERSATION")
- @Conversation(maxAge = "100")
- private interface FooConversation {
- }
-
-
private interface BadFoo {
void operation();
@EndConversation
void endOperation();
- }
-
- @Conversation(maxAge = "100")
- private interface BadFooConversation {
}
private interface NonConversationalFoo {
Added:
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConversationProcessorTestCase.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConversationProcessorTestCase.java?view=auto&rev=479410
==============================================================================
---
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConversationProcessorTestCase.java
(added)
+++
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConversationProcessorTestCase.java
Sun Nov 26 11:31:33 2006
@@ -0,0 +1,120 @@
+/*
+ * 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.implementation.processor;
+
+import org.osoa.sca.annotations.Conversation;
+import org.osoa.sca.annotations.Scope;
+
+import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
+import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
+import org.apache.tuscany.spi.implementation.java.JavaMappedService;
+import org.apache.tuscany.spi.implementation.java.PojoComponentType;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ConversationProcessorTestCase extends TestCase {
+ private ConversationProcessor processor = new ConversationProcessor();
+
+ public void testMaxIdleTime() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference,
JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference,
JavaMappedProperty<?>>();
+ processor.visitClass(null, FooMaxIdle.class, type, null);
+ assertEquals(10000L, type.getMaxIdleTime());
+ assertEquals(-1, type.getMaxAge());
+ }
+
+ public void testMaxAge() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference,
JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference,
JavaMappedProperty<?>>();
+ processor.visitClass(null, FooMaxAge.class, type, null);
+ assertEquals(10000L, type.getMaxAge());
+ assertEquals(-1, type.getMaxIdleTime());
+ }
+
+ public void testBadFooBoth() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference,
JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference,
JavaMappedProperty<?>>();
+ try {
+ processor.visitClass(null, BadFooBoth.class, type, null);
+ fail();
+ } catch (InvalidConversationalImplementation e) {
+ // expected
+ }
+ }
+
+ public void testImplicitScope() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference,
JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference,
JavaMappedProperty<?>>();
+ processor.visitClass(null, ImplicitFooScope.class, type, null);
+ assertEquals(org.apache.tuscany.spi.model.Scope.CONVERSATION,
type.getImplementationScope());
+ }
+
+ public void testBadFooScope() throws Exception {
+ PojoComponentType<JavaMappedService, JavaMappedReference,
JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference,
JavaMappedProperty<?>>();
+ try {
+ processor.visitClass(null, BadFooScope.class, type, null);
+ fail();
+ } catch (InvalidConversationalImplementation e) {
+ // expected
+ }
+ }
+
+ public void testJustConversation() throws Exception {
+ // TODO do we want these semantics
+ PojoComponentType<JavaMappedService, JavaMappedReference,
JavaMappedProperty<?>> type =
+ new PojoComponentType<JavaMappedService, JavaMappedReference,
JavaMappedProperty<?>>();
+ processor.visitClass(null, FooJustConversation.class, type, null);
+ assertEquals(org.apache.tuscany.spi.model.Scope.CONVERSATION,
type.getImplementationScope());
+ assertEquals(-1, type.getMaxAge());
+ assertEquals(-1, type.getMaxIdleTime());
+ }
+
+ @Scope("CONVERSATION")
+ @Conversation(maxIdleTime = "10 seconds")
+ private class FooMaxIdle {
+ }
+
+ @Scope("CONVERSATION")
+ @Conversation(maxAge = "10 seconds")
+ private class FooMaxAge {
+ }
+
+ @Scope("CONVERSATION")
+ @Conversation(maxAge = "10 seconds", maxIdleTime = "10 seconds")
+ private class BadFooBoth {
+ }
+
+ @Conversation(maxAge = "10 seconds")
+ private class ImplicitFooScope {
+ }
+
+ @Scope("STATELESS")
+ @Conversation(maxAge = "10 seconds")
+ private class BadFooScope {
+ }
+
+ @Conversation
+ private class FooJustConversation {
+ }
+
+}
Propchange:
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConversationProcessorTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConversationProcessorTestCase.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConvertTimeMillisTestCase.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConvertTimeMillisTestCase.java?view=auto&rev=479410
==============================================================================
---
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConvertTimeMillisTestCase.java
(added)
+++
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConvertTimeMillisTestCase.java
Sun Nov 26 11:31:33 2006
@@ -0,0 +1,110 @@
+/*
+ * 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.implementation.processor;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ConvertTimeMillisTestCase extends TestCase {
+ private MockProcessor registy;
+
+ public void testConvertSeconds() throws Exception {
+ assertEquals(10000L, registy.convertTimeMillis("10 seconds"));
+ assertEquals(10000L, registy.convertTimeMillis("10 SECONDS"));
+ try {
+ registy.convertTimeMillis("10seconds");
+ fail();
+ } catch (NumberFormatException e) {
+ // expected
+ }
+ }
+
+ public void testConvertMinutes() throws Exception {
+ assertEquals(600000L, registy.convertTimeMillis("10 minutes"));
+ assertEquals(600000L, registy.convertTimeMillis("10 MINUTES"));
+ try {
+ registy.convertTimeMillis("10minutes");
+ fail();
+ } catch (NumberFormatException e) {
+ // expected
+ }
+ }
+
+ public void testConvertHours() throws Exception {
+ assertEquals(36000000L, registy.convertTimeMillis("10 hours"));
+ assertEquals(36000000L, registy.convertTimeMillis("10 HOURS"));
+ try {
+ registy.convertTimeMillis("10hours");
+ fail();
+ } catch (NumberFormatException e) {
+ // expected
+ }
+ }
+
+ public void testConvertDays() throws Exception {
+ assertEquals(864000000L, registy.convertTimeMillis("10 days"));
+ assertEquals(864000000L, registy.convertTimeMillis("10 DAYS"));
+ try {
+ registy.convertTimeMillis("10days");
+ fail();
+ } catch (NumberFormatException e) {
+ // expected
+ }
+ }
+
+ public void testConvertYears() throws Exception {
+ assertEquals(315569260000L, registy.convertTimeMillis("10 years"));
+ assertEquals(315569260000L, registy.convertTimeMillis("10 YEARS"));
+ try {
+ registy.convertTimeMillis("10years");
+ fail();
+ } catch (NumberFormatException e) {
+ // expected
+ }
+ }
+
+ public void testConvertDefault() throws Exception {
+ assertEquals(10000L, registy.convertTimeMillis("10 "));
+ assertEquals(10000L, registy.convertTimeMillis("10"));
+ }
+
+ public void testInvalid() throws Exception {
+ try {
+ registy.convertTimeMillis("foo");
+ fail();
+ } catch (NumberFormatException e) {
+ // expected
+ }
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ registy = new MockProcessor();
+ }
+
+ private class MockProcessor extends ConversationProcessor {
+
+ @Override
+ protected long convertTimeMillis(String expr) throws
NumberFormatException {
+ return super.convertTimeMillis(expr);
+ }
+ }
+}
Propchange:
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConvertTimeMillisTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConvertTimeMillisTestCase.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified:
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/integration/conversation/BasicConversationInvocationTestCase.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/integration/conversation/BasicConversationInvocationTestCase.java?view=diff&rev=479410&r1=479409&r2=479410
==============================================================================
---
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/integration/conversation/BasicConversationInvocationTestCase.java
(original)
+++
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/integration/conversation/BasicConversationInvocationTestCase.java
Sun Nov 26 11:31:33 2006
@@ -84,8 +84,8 @@
}
}
// verify the instance was persisted
- // continue the conversation
assertEquals(targetInstance, store.readRecord(target, "12345A"));
+ // continue the conversation
for (Map.Entry<Operation<?>, OutboundInvocationChain> entry :
owire.getInvocationChains().entrySet()) {
if ("operation2".equals(entry.getKey().getName())) {
MessageImpl msg = new MessageImpl();
Modified:
incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ComponentType.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ComponentType.java?view=diff&rev=479410&r1=479409&r2=479410
==============================================================================
---
incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ComponentType.java
(original)
+++
incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ComponentType.java
Sun Nov 26 11:31:33 2006
@@ -22,31 +22,31 @@
import java.util.Map;
/**
- * <p>The definition of the configurable aspects of an implementation in terms
of the services it exposes,
- * the services it references, and properties that can be used to configure
it.</p>
- * <p>A service represents an addressable interface provided by the
implementation. Such a service
- * may be the target of a wire from another component.</p>
- * <p>A reference represents a requirement that an implementation has on a
service provided by another
- * component or by a resource outside the SCA system. Such a reference may be
the source of a wire to another
- * component.</p>
- * <p>A property allows the behaviour of the implementation to be configured
through externally set values.</p>
- * <p>A component type may also declare that it wishes to be initialized upon
activation of the scope that
- * contains it and may specify an order relative to other eagerly initializing
components. For example, an
- * implementation that pre-loads some form of cache could declare that it
should be eagerly initialized at
- * the start of the scope so that the cache load occured on startup rather
than first use.</p>
+ * <p>The definition of the configurable aspects of an implementation in terms
of the services it exposes, the services
+ * it references, and properties that can be used to configure it.</p> <p>A
service represents an addressable interface
+ * provided by the implementation. Such a service may be the target of a wire
from another component.</p> <p>A reference
+ * represents a requirement that an implementation has on a service provided
by another component or by a resource
+ * outside the SCA system. Such a reference may be the source of a wire to
another component.</p> <p>A property allows
+ * the behaviour of the implementation to be configured through externally set
values.</p> <p>A component type may also
+ * declare that it wishes to be initialized upon activation of the scope that
contains it and may specify an order
+ * relative to other eagerly initializing components. For example, an
implementation that pre-loads some form of cache
+ * could declare that it should be eagerly initialized at the start of the
scope so that the cache load occured on
+ * startup rather than first use.</p>
*
* @version $Rev$ $Date$
*/
public class ComponentType<S extends ServiceDefinition, R extends
ReferenceDefinition, P extends Property<?>>
- extends ModelObject {
+ extends ModelObject {
private int initLevel;
+ private long maxAge = -1;
+ private long maxIdleTime = -1;
private final Map<String, S> services = new HashMap<String, S>();
private final Map<String, R> references = new HashMap<String, R>();
private final Map<String, P> properties = new HashMap<String, P>();
/**
- * Returns the default initialization level for components of this type.
- * A value greater than zero indicates that components should be eagerly
initialized.
+ * Returns the default initialization level for components of this type. A
value greater than zero indicates that
+ * components should be eagerly initialized.
*
* @return the default initialization level
*/
@@ -55,8 +55,8 @@
}
/**
- * Sets the default initialization level for components of this type.
- * A value greater than zero indicates that components should be eagerly
initialized.
+ * Sets the default initialization level for components of this type. A
value greater than zero indicates that
+ * components should be eagerly initialized.
*
* @param initLevel default initialization level for components of this
type
*/
@@ -74,8 +74,8 @@
}
/**
- * Obsolete method for indicating that this component should be eagerly
initialized.
- * If true, sets the init level to 50; if false, sets it to zero.
+ * Obsolete method for indicating that this component should be eagerly
initialized. If true, sets the init level to
+ * 50; if false, sets it to zero.
*
* @param eagerInit flag indicating that this component should be eagerly
initialized
*/
@@ -85,6 +85,38 @@
}
/**
+ * Returns the idle time allowed between operations in milliseconds if the
service is conversational
+ *
+ * @return the idle time allowed between operations in milliseconds if the
service is conversational
+ */
+ public long getMaxIdleTime() {
+ return maxIdleTime;
+ }
+
+ /**
+ * Sets the idle time allowed between operations in milliseconds if the
service is conversational
+ */
+ public void setMaxIdleTime(long maxIdleTime) {
+ this.maxIdleTime = maxIdleTime;
+ }
+
+ /**
+ * Returns the maximum age a conversation may remain active in
milliseconds if the service is conversational
+ *
+ * @return the maximum age a conversation may remain active in
milliseconds if the service is conversational
+ */
+ public long getMaxAge() {
+ return maxAge;
+ }
+
+ /**
+ * Sets the maximum age a conversation may remain active in milliseconds
if the service is conversational
+ */
+ public void setMaxAge(long maxAge) {
+ this.maxAge = maxAge;
+ }
+
+ /**
* Returns a live Map of the services provided by the implementation.
*
* @return a live Map of the services provided by the implementation
@@ -94,8 +126,7 @@
}
/**
- * Add a service to those provided by the implementation.
- * Any existing service with the same name is replaced.
+ * Add a service to those provided by the implementation. Any existing
service with the same name is replaced.
*
* @param service a service provided by the implementation
*/
@@ -113,8 +144,8 @@
}
/**
- * Add a reference to a service consumed by the implementation.
- * Any existing reference with the same name is replaced.
+ * Add a reference to a service consumed by the implementation. Any
existing reference with the same name is
+ * replaced.
*
* @param reference a reference to a service consumed by the implementation
*/
@@ -132,8 +163,8 @@
}
/**
- * Add a property that can be used to configure the implementation.
- * Any existing property with the same name is replaced.
+ * Add a property that can be used to configure the implementation. Any
existing property with the same name is
+ * replaced.
*
* @param property a property that can be used to configure the
implementation
*/
Modified:
incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ServiceContract.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ServiceContract.java?view=diff&rev=479410&r1=479409&r2=479410
==============================================================================
---
incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ServiceContract.java
(original)
+++
incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ServiceContract.java
Sun Nov 26 11:31:33 2006
@@ -28,8 +28,6 @@
* @version $Rev$ $Date$
*/
public abstract class ServiceContract<T> extends ModelObject {
- public static final long UNDEFINED = -1;
-
protected InteractionScope interactionScope;
protected boolean remotable;
protected Class<?> interfaceClass;
@@ -40,8 +38,6 @@
protected Map<String, Operation<T>> callbackOperations;
protected String dataBinding;
protected Map<String, Object> metaData;
- protected long maxIdleTime = UNDEFINED;
- protected long maxAge = UNDEFINED;
protected ServiceContract() {
}
@@ -172,38 +168,6 @@
public void setDataBinding(String dataBinding) {
this.dataBinding = dataBinding;
- }
-
- /**
- * Returns the idle time allowed between operations in milliseconds if the
service is conversational
- *
- * @return the idle time allowed between operations in milliseconds if the
service is conversational
- */
- public long getMaxIdleTime() {
- return maxIdleTime;
- }
-
- /**
- * Sets the idle time allowed between operations in milliseconds if the
service is conversational
- */
- public void setMaxIdleTime(long maxIdleTime) {
- this.maxIdleTime = maxIdleTime;
- }
-
- /**
- * Returns the maximum age a conversation may remain active in
milliseconds if the service is conversational
- *
- * @return the maximum age a conversation may remain active in
milliseconds if the service is conversational
- */
- public long getMaxAge() {
- return maxAge;
- }
-
- /**
- * Sets the maximum age a conversation may remain active in milliseconds
if the service is conversational
- */
- public void setMaxAge(long maxAge) {
- this.maxAge = maxAge;
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]