summaryrefslogtreecommitdiffstats
path: root/sandbox/jboynes/sca-client/src/test/java/sample
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox/jboynes/sca-client/src/test/java/sample')
-rw-r--r--sandbox/jboynes/sca-client/src/test/java/sample/HelloCallback.java8
-rw-r--r--sandbox/jboynes/sca-client/src/test/java/sample/HelloService.java8
-rw-r--r--sandbox/jboynes/sca-client/src/test/java/sample/client/BasicClient.java38
-rw-r--r--sandbox/jboynes/sca-client/src/test/java/sample/client/ReallyBasicClient.java34
4 files changed, 88 insertions, 0 deletions
diff --git a/sandbox/jboynes/sca-client/src/test/java/sample/HelloCallback.java b/sandbox/jboynes/sca-client/src/test/java/sample/HelloCallback.java
new file mode 100644
index 0000000000..9efa48d500
--- /dev/null
+++ b/sandbox/jboynes/sca-client/src/test/java/sample/HelloCallback.java
@@ -0,0 +1,8 @@
+package sample;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface HelloCallback {
+ String getLocale();
+}
diff --git a/sandbox/jboynes/sca-client/src/test/java/sample/HelloService.java b/sandbox/jboynes/sca-client/src/test/java/sample/HelloService.java
new file mode 100644
index 0000000000..cea12771a8
--- /dev/null
+++ b/sandbox/jboynes/sca-client/src/test/java/sample/HelloService.java
@@ -0,0 +1,8 @@
+package sample;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface HelloService {
+ String hello(String message);
+}
diff --git a/sandbox/jboynes/sca-client/src/test/java/sample/client/BasicClient.java b/sandbox/jboynes/sca-client/src/test/java/sample/client/BasicClient.java
new file mode 100644
index 0000000000..6565a6a5f7
--- /dev/null
+++ b/sandbox/jboynes/sca-client/src/test/java/sample/client/BasicClient.java
@@ -0,0 +1,38 @@
+package sample.client;
+
+import org.osoa.sca.ComponentContext;
+import org.osoa.sca.ServiceReference;
+import sample.HelloService;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class BasicClient {
+ private ComponentContext context;
+
+ public void useComponentDirectly() {
+ HelloService helloService = context.getService(HelloService.class, "helloService");
+ helloService.hello("World");
+ }
+
+ public void useComponentViaReference() {
+ ServiceReference<HelloService> ref = context.getServiceReference(HelloService.class, "helloService");
+ HelloService helloService = ref.getService();
+ helloService.hello("World");
+
+ ServiceReference<HelloService> ref2 = context.cast(helloService);
+ }
+
+ public void useReferenceDirectly() {
+ HelloService helloService = context.getService(HelloService.class, "helloReference");
+ helloService.hello("World");
+ }
+
+ public void useReferenceViaReference() {
+ ServiceReference<HelloService> ref = context.getServiceReference(HelloService.class, "helloReference");
+ HelloService helloService = ref.getService();
+ helloService.hello("World");
+
+ ServiceReference<HelloService> ref2 = context.cast(helloService);
+ }
+}
diff --git a/sandbox/jboynes/sca-client/src/test/java/sample/client/ReallyBasicClient.java b/sandbox/jboynes/sca-client/src/test/java/sample/client/ReallyBasicClient.java
new file mode 100644
index 0000000000..f2ef857166
--- /dev/null
+++ b/sandbox/jboynes/sca-client/src/test/java/sample/client/ReallyBasicClient.java
@@ -0,0 +1,34 @@
+package sample.client;
+
+import org.osoa.sca.ComponentContext;
+import sample.HelloService;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ReallyBasicClient {
+ /**
+ * <composite name="impl2">
+ * <component name="comp2a">
+ * <implementation.unmanaged/>
+ * <reference name="helloService" target="hello"/>
+ * </component>
+ *
+ * <component name="hello">
+ * <implementation.java class="sample.HelloServiceImpl"/>
+ * </component>
+ * </composite>
+ */
+ public static void main(String[] args) {
+ ComponentContext context = getComponentContext();
+
+ // access a service through its reference
+ HelloService helloService = context.getService(HelloService.class, "helloService");
+ helloService.hello("World");
+ }
+
+ public static ComponentContext getComponentContext() {
+ // implementation defined mechanism to retrieve appropriate ComponentContext
+ throw new UnsupportedOperationException();
+ }
+}