summaryrefslogtreecommitdiffstats
path: root/tags/java/sca/1.5.1/itest/osgi-implementation/src/main/java/conversation/service
diff options
context:
space:
mode:
Diffstat (limited to 'tags/java/sca/1.5.1/itest/osgi-implementation/src/main/java/conversation/service')
-rw-r--r--tags/java/sca/1.5.1/itest/osgi-implementation/src/main/java/conversation/service/ConversationalService.java65
-rw-r--r--tags/java/sca/1.5.1/itest/osgi-implementation/src/main/java/conversation/service/ConversationalServiceActivator.java76
-rw-r--r--tags/java/sca/1.5.1/itest/osgi-implementation/src/main/java/conversation/service/ConversationalServiceFactory.java52
-rw-r--r--tags/java/sca/1.5.1/itest/osgi-implementation/src/main/java/conversation/service/ConversationalServiceStatefulImpl.java121
-rw-r--r--tags/java/sca/1.5.1/itest/osgi-implementation/src/main/java/conversation/service/ConversationalServiceStatelessImpl.java127
5 files changed, 441 insertions, 0 deletions
diff --git a/tags/java/sca/1.5.1/itest/osgi-implementation/src/main/java/conversation/service/ConversationalService.java b/tags/java/sca/1.5.1/itest/osgi-implementation/src/main/java/conversation/service/ConversationalService.java
new file mode 100644
index 0000000000..bcd24ef0b1
--- /dev/null
+++ b/tags/java/sca/1.5.1/itest/osgi-implementation/src/main/java/conversation/service/ConversationalService.java
@@ -0,0 +1,65 @@
+/*
+ * 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 conversation.service;
+
+import org.osoa.sca.annotations.Callback;
+import org.osoa.sca.annotations.Conversational;
+import org.osoa.sca.annotations.EndsConversation;
+import org.osoa.sca.annotations.Remotable;
+
+import conversation.client.ConversationalCallback;
+
+
+/**
+ * The service interface used when testing conversations
+ *
+ * @version $Rev$ $Date$
+ */
+@Remotable
+@Conversational
+@Callback(ConversationalCallback.class)
+public interface ConversationalService {
+
+ public void init();
+
+ public void destroy();
+
+ public void initializeCount(int count);
+
+ public void incrementCount();
+
+ public int retrieveCount();
+
+ public void businessException() throws Exception;
+
+ public void initializeCountCallback(int count);
+
+ public void incrementCountCallback();
+
+ public int retrieveCountCallback();
+
+ public void businessExceptionCallback() throws Exception;
+
+ @EndsConversation
+ public String endConversation();
+
+ public String endConversationCallback();
+
+ public String getCalls();
+}
diff --git a/tags/java/sca/1.5.1/itest/osgi-implementation/src/main/java/conversation/service/ConversationalServiceActivator.java b/tags/java/sca/1.5.1/itest/osgi-implementation/src/main/java/conversation/service/ConversationalServiceActivator.java
new file mode 100644
index 0000000000..903f8bf229
--- /dev/null
+++ b/tags/java/sca/1.5.1/itest/osgi-implementation/src/main/java/conversation/service/ConversationalServiceActivator.java
@@ -0,0 +1,76 @@
+/*
+ * 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 conversation.service;
+
+import java.util.Hashtable;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.ServiceListener;
+
+
+/*
+ * OSGi bundle activator for conversation tests
+ */
+public class ConversationalServiceActivator implements BundleActivator, ServiceListener {
+
+
+ private BundleContext bundleContext;
+
+
+ public void start(BundleContext bc) throws Exception {
+
+ System.out.println("Started OSGiConversationServiceActivator ");
+
+ this.bundleContext = bc;
+
+ bc.addServiceListener(this);
+
+ Hashtable<String, Object> serviceProps;
+
+ serviceProps = new Hashtable<String, Object>();
+
+ serviceProps = new Hashtable<String, Object>();
+ serviceProps.put("component.name", "ConversationalServiceStateful");
+ Object statefulService =
+ new ConversationalServiceFactory(ConversationalServiceStatefulImpl.class);
+ bundleContext.registerService(ConversationalService.class.getName(), statefulService, serviceProps);
+
+ serviceProps = new Hashtable<String, Object>();
+ serviceProps.put("component.name", "ConversationalServiceStateless");
+ ConversationalServiceStatelessImpl statelessService = new ConversationalServiceStatelessImpl();
+ bundleContext.registerService(ConversationalService.class.getName(), statelessService, serviceProps);
+
+
+ }
+
+
+
+ public void stop(BundleContext bc) {
+ }
+
+ public void serviceChanged(ServiceEvent event) {
+
+ if (event.getType() == ServiceEvent.REGISTERED) {
+
+ }
+ }
+
+}
diff --git a/tags/java/sca/1.5.1/itest/osgi-implementation/src/main/java/conversation/service/ConversationalServiceFactory.java b/tags/java/sca/1.5.1/itest/osgi-implementation/src/main/java/conversation/service/ConversationalServiceFactory.java
new file mode 100644
index 0000000000..fe8bd23f07
--- /dev/null
+++ b/tags/java/sca/1.5.1/itest/osgi-implementation/src/main/java/conversation/service/ConversationalServiceFactory.java
@@ -0,0 +1,52 @@
+/*
+ * 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 conversation.service;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.ServiceFactory;
+import org.osgi.framework.ServiceRegistration;
+
+
+public class ConversationalServiceFactory implements ServiceFactory {
+
+ private Class<?> clazz;
+
+ public ConversationalServiceFactory(Class<?> clazz) {
+ this.clazz = clazz;
+ }
+
+ public Object getService(Bundle bundle, ServiceRegistration reg) {
+
+ try {
+ return clazz.newInstance();
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+
+ }
+
+ public void ungetService(Bundle bundle, ServiceRegistration reg, Object obj) {
+
+ }
+
+
+
+}
diff --git a/tags/java/sca/1.5.1/itest/osgi-implementation/src/main/java/conversation/service/ConversationalServiceStatefulImpl.java b/tags/java/sca/1.5.1/itest/osgi-implementation/src/main/java/conversation/service/ConversationalServiceStatefulImpl.java
new file mode 100644
index 0000000000..ec30d641ac
--- /dev/null
+++ b/tags/java/sca/1.5.1/itest/osgi-implementation/src/main/java/conversation/service/ConversationalServiceStatefulImpl.java
@@ -0,0 +1,121 @@
+/*
+ * 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 conversation.service;
+
+import org.osoa.sca.annotations.Callback;
+import org.osoa.sca.annotations.ConversationAttributes;
+import org.osoa.sca.annotations.ConversationID;
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+
+import conversation.client.ConversationalCallback;
+
+
+/**
+ * The service used when testing stateful conversations
+ *
+ * @version $Rev$ $Date$
+ */
+@Service(ConversationalService.class)
+@Scope("CONVERSATION")
+@ConversationAttributes(maxAge="10 minutes",
+ maxIdleTime="5 minutes",
+ singlePrincipal=false)
+public class ConversationalServiceStatefulImpl implements ConversationalService {
+
+ @ConversationID
+ protected String conversationId;
+
+ @Callback
+ protected ConversationalCallback conversationalCallback;
+
+ // local count - accumulates during the conversation
+ private int count = 0;
+
+ // a static member variable that records the number of times this service is called
+ public static StringBuffer calls = new StringBuffer();
+
+ @Init
+ public void init(){
+ calls.append("init,");
+ }
+
+ @Destroy
+ public void destroy(){
+ calls.append("destroy,");
+ }
+
+ public void initializeCount(int count){
+ calls.append("initializeCount,");
+ this.count = count;
+ }
+
+ public void incrementCount(){
+ calls.append("incrementCount,");
+ count++;
+ }
+
+ public int retrieveCount(){
+ calls.append("retrieveCount,");
+ return count;
+ }
+
+ public void businessException() throws Exception {
+ throw new Exception("Business Exception");
+ }
+
+ public void initializeCountCallback(int count){
+ calls.append("initializeCountCallback,");
+ this.count = count;
+ conversationalCallback.initializeCount(count);
+ }
+
+ public void incrementCountCallback(){
+ calls.append("incrementCountCallback,");
+ count++;
+ conversationalCallback.incrementCount();
+ }
+
+ public int retrieveCountCallback(){
+ calls.append("retrieveCountCallback,");
+ return conversationalCallback.retrieveCount();
+ }
+
+ public void businessExceptionCallback() throws Exception {
+ calls.append("businessExceptionCallback,");
+ conversationalCallback.businessException();
+ }
+
+ public String endConversation(){
+ calls.append("endConversation,");
+ count = 0;
+ return conversationId;
+ }
+
+ public String endConversationCallback(){
+ calls.append("endConversationCallback,");
+ return conversationalCallback.endConversation();
+ }
+
+ public String getCalls() {
+ return calls.toString();
+ }
+}
diff --git a/tags/java/sca/1.5.1/itest/osgi-implementation/src/main/java/conversation/service/ConversationalServiceStatelessImpl.java b/tags/java/sca/1.5.1/itest/osgi-implementation/src/main/java/conversation/service/ConversationalServiceStatelessImpl.java
new file mode 100644
index 0000000000..34baca71d1
--- /dev/null
+++ b/tags/java/sca/1.5.1/itest/osgi-implementation/src/main/java/conversation/service/ConversationalServiceStatelessImpl.java
@@ -0,0 +1,127 @@
+/*
+ * 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 conversation.service;
+
+import java.util.HashMap;
+
+import org.osoa.sca.annotations.Callback;
+import org.osoa.sca.annotations.ConversationID;
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+
+import conversation.client.ConversationalCallback;
+
+
+/**
+ * The service used when testing stateful conversations
+ *
+ * @version $Rev$ $Date$
+ */
+@Service(ConversationalService.class)
+@Scope("STATELESS")
+public class ConversationalServiceStatelessImpl implements ConversationalService {
+
+ @ConversationID
+ protected String conversationId;
+
+ @Callback
+ protected ConversationalCallback conversationalCallback;
+
+ // static area in which to hold conversational data
+ private static HashMap<String, Integer> conversationalState = new HashMap<String, Integer>();
+
+ // a static member variable that records the number of times this service is called
+ public static StringBuffer calls = new StringBuffer();
+
+ @Init
+ public void init(){
+ calls.append("init,");
+ }
+
+ @Destroy
+ public void destroy(){
+ calls.append("destroy,");
+ }
+
+ public void initializeCount(int count){
+ calls.append("initializeCount,");
+ Integer conversationalCount = new Integer(count);
+ conversationalState.put(conversationId, conversationalCount);
+ }
+
+ public void incrementCount(){
+ calls.append("incrementCount,");
+ Integer conversationalCount = conversationalState.get(conversationId);
+ conversationalCount++;
+ conversationalState.put(conversationId, conversationalCount);
+ }
+
+ public int retrieveCount(){
+ calls.append("retrieveCount,");
+ Integer count = conversationalState.get(conversationId);
+ if (count != null){
+ return count.intValue();
+ } else {
+ return -999;
+ }
+ }
+
+ public void businessException() throws Exception {
+ throw new Exception("Business Exception");
+ }
+
+ public void initializeCountCallback(int count){
+ calls.append("initializeCountCallback,");
+ initializeCount(count);
+ conversationalCallback.initializeCount(count);
+ }
+
+ public void incrementCountCallback(){
+ calls.append("incrementCountCallback,");
+ incrementCount();
+ conversationalCallback.incrementCount();
+ }
+
+ public int retrieveCountCallback(){
+ calls.append("retrieveCountCallback,");
+ return conversationalCallback.retrieveCount();
+ }
+
+ public void businessExceptionCallback() throws Exception {
+ calls.append("businessExceptionCallback,");
+ conversationalCallback.businessException();
+ }
+
+ public String endConversation(){
+ calls.append("endConversation,");
+ conversationalState.remove(conversationId);
+ return conversationId;
+ }
+
+ public String endConversationCallback(){
+ calls.append("endConversationCallback,");
+ return conversationalCallback.endConversation();
+ }
+
+ public String getCalls() {
+ return calls.toString();
+ }
+}