summaryrefslogtreecommitdiffstats
path: root/sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/apis/requestcontext/src/main/java/org/apache
diff options
context:
space:
mode:
Diffstat (limited to 'sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/apis/requestcontext/src/main/java/org/apache')
-rw-r--r--sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/AComponent.java35
-rw-r--r--sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/BCallback.java27
-rw-r--r--sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/BComponent.java35
-rw-r--r--sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/impl/AComponentImpl.java102
-rw-r--r--sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/impl/BComponentImpl.java61
5 files changed, 260 insertions, 0 deletions
diff --git a/sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/AComponent.java b/sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/AComponent.java
new file mode 100644
index 0000000000..6fec5cada3
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/AComponent.java
@@ -0,0 +1,35 @@
+/*
+ * 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.vtest.javaapi.apis.requestcontext;
+
+/**
+ * Simple Service A.
+ */
+public interface AComponent {
+
+ public String getName();
+
+ public boolean isJAASSubject();
+ public String getServiceName();
+ public String getCallbackResult();
+ public String getServiceReferenceName();
+ public String getCallbackServiceReferenceName();
+
+}
diff --git a/sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/BCallback.java b/sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/BCallback.java
new file mode 100644
index 0000000000..4dd2088f90
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/BCallback.java
@@ -0,0 +1,27 @@
+/*
+ * 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.vtest.javaapi.apis.requestcontext;
+
+public interface BCallback {
+
+ public String getCallbackName();
+ public void processResults(String result);
+
+}
diff --git a/sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/BComponent.java b/sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/BComponent.java
new file mode 100644
index 0000000000..34f709d175
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/BComponent.java
@@ -0,0 +1,35 @@
+/*
+ * 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.vtest.javaapi.apis.requestcontext;
+
+import org.osoa.sca.annotations.Callback;
+
+/**
+ * Simple Service B.
+ */
+@Callback(BCallback.class)
+public interface BComponent {
+
+ public String getName();
+
+ public void testCallback();
+ public String getServiceReferenceName();
+
+}
diff --git a/sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/impl/AComponentImpl.java b/sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/impl/AComponentImpl.java
new file mode 100644
index 0000000000..c6fa589ed4
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/impl/AComponentImpl.java
@@ -0,0 +1,102 @@
+/*
+ * 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.vtest.javaapi.apis.requestcontext.impl;
+
+import javax.security.auth.Subject;
+
+import org.apache.tuscany.sca.vtest.javaapi.apis.requestcontext.AComponent;
+import org.apache.tuscany.sca.vtest.javaapi.apis.requestcontext.BCallback;
+import org.apache.tuscany.sca.vtest.javaapi.apis.requestcontext.BComponent;
+import org.osoa.sca.CallableReference;
+import org.osoa.sca.ComponentContext;
+import org.osoa.sca.ServiceReference;
+import org.osoa.sca.annotations.Context;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Service;
+
+@Service(AComponent.class)
+public class AComponentImpl implements AComponent, BCallback {
+
+ private static Object monitor = new Object();
+ private static String returnMessage = null;
+ private static CallableReference<BCallback> cbCR;
+
+ protected ComponentContext componentContext;
+
+ @Reference
+ protected BComponent bReference;
+
+ public String getName() {
+ return "ComponentA";
+ }
+
+ @Context
+ public void setComponentContext(ComponentContext context) {
+ this.componentContext = context;
+ }
+
+ public boolean isJAASSubject() {
+ return componentContext.getRequestContext().getSecuritySubject() instanceof Subject;
+ }
+
+ public String getServiceName() {
+ return componentContext.getRequestContext().getServiceName();
+ }
+
+ public String getCallbackResult() {
+ ServiceReference<BComponent> bSR = componentContext.getServiceReference(BComponent.class, "bReference");
+ String cbID = "ComponentACallBack";
+ bSR.setCallbackID(cbID);
+ bSR.getService().testCallback();
+
+ // Wait for 30s max.
+ int count = 0;
+ synchronized(monitor) {
+ while (returnMessage == null && count++ < 30) {
+ try {
+ monitor.wait(1000L);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ return returnMessage;
+ }
+
+ public void processResults(String result) {
+ returnMessage = result;
+ cbCR = componentContext.getRequestContext().getServiceReference();
+ }
+
+ public String getServiceReferenceName() {
+ CallableReference<AComponent> aCR = componentContext.getRequestContext().getServiceReference();
+ return aCR.getService().getName();
+ }
+
+ public String getCallbackServiceReferenceName() {
+ return cbCR.getService().getCallbackName();
+ }
+
+ public String getCallbackName() {
+ return "CallBackB";
+ }
+
+}
diff --git a/sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/impl/BComponentImpl.java b/sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/impl/BComponentImpl.java
new file mode 100644
index 0000000000..33ff829357
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.6.2/vtest/java-api/apis/requestcontext/src/main/java/org/apache/tuscany/sca/vtest/javaapi/apis/requestcontext/impl/BComponentImpl.java
@@ -0,0 +1,61 @@
+/*
+ * 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.vtest.javaapi.apis.requestcontext.impl;
+
+import org.apache.tuscany.sca.vtest.javaapi.apis.requestcontext.BCallback;
+import org.apache.tuscany.sca.vtest.javaapi.apis.requestcontext.BComponent;
+import org.junit.Assert;
+import org.osoa.sca.CallableReference;
+import org.osoa.sca.ComponentContext;
+import org.osoa.sca.annotations.Callback;
+import org.osoa.sca.annotations.Context;
+import org.osoa.sca.annotations.Service;
+
+@Service(BComponent.class)
+public class BComponentImpl implements BComponent {
+
+ protected ComponentContext componentContext;
+
+ @Callback
+ protected BCallback callback;
+
+ @Context
+ public void setComponentContext(ComponentContext context) {
+ this.componentContext = context;
+ }
+
+ public String getName() {
+ return "ComponentB";
+ }
+
+ public void testCallback() {
+ callback = componentContext.getRequestContext().getCallback();
+ callback.processResults("CallBackFromB");
+
+ CallableReference<BCallback> bCR = componentContext.getRequestContext().getCallbackReference();
+ Assert.assertEquals("ComponentACallBack", bCR.getCallbackID());
+ }
+
+ public String getServiceReferenceName() {
+ CallableReference<BComponent> bCR = componentContext.getRequestContext().getServiceReference();
+ return bCR.getService().getName();
+ }
+
+}