diff options
Diffstat (limited to 'sca-java-1.x/tags/0.99-incubating/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/provider')
3 files changed, 187 insertions, 0 deletions
diff --git a/sca-java-1.x/tags/0.99-incubating/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/provider/BPELImplementationProvider.java b/sca-java-1.x/tags/0.99-incubating/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/provider/BPELImplementationProvider.java new file mode 100644 index 0000000000..e95bb80438 --- /dev/null +++ b/sca-java-1.x/tags/0.99-incubating/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/provider/BPELImplementationProvider.java @@ -0,0 +1,75 @@ +/*
+ * 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.bpel.provider;
+
+import org.apache.tuscany.sca.implementation.bpel.BPELImplementation;
+import org.apache.tuscany.sca.implementation.bpel.ode.EmbeddedODEServer;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.provider.ImplementationProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+/**
+ * The model representing a sample CRUD implementation in an SCA assembly model.
+ * The sample CRUD implementation is not a full blown implementation, it only
+ * supports a subset of what a component implementation can support: - a single
+ * fixed service (as opposed to a list of services typed by different
+ * interfaces) - a directory attribute used to specify where a CRUD component is
+ * going to persist resources - no references or properties - no policy intents
+ * or policy sets
+ */
+public class BPELImplementationProvider implements ImplementationProvider {
+
+ private RuntimeComponent component;
+ private BPELImplementation implementation;
+ private EmbeddedODEServer odeServer;
+
+ /**
+ * Constructs a new CRUD implementation.
+ */
+ public BPELImplementationProvider(RuntimeComponent component, BPELImplementation implementation,
+ EmbeddedODEServer odeServer) {
+ this.component = component;
+ this.implementation = implementation;
+ this.odeServer = odeServer;
+ }
+
+ public Invoker createInvoker(RuntimeComponentService service, Operation operation) {
+ BPELInvoker invoker = new BPELInvoker(operation);
+ return invoker;
+ }
+
+ public Invoker createCallbackInvoker(Operation operation) {
+ BPELInvoker invoker = new BPELInvoker(operation);
+ return invoker;
+ }
+
+ public void start() {
+ System.out.println("Starting " + component.getName() + " " + component.getClass().getName());
+ if (!odeServer.isInitialized()) odeServer.init();
+
+ odeServer.getBpelServer().register(implementation.getProcessConf());
+ }
+
+ public void stop() {
+ System.out.println("Stopping " + component.getName() + " " + component.getClass().getName());
+ }
+
+}
diff --git a/sca-java-1.x/tags/0.99-incubating/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/provider/BPELImplementationProviderFactory.java b/sca-java-1.x/tags/0.99-incubating/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/provider/BPELImplementationProviderFactory.java new file mode 100644 index 0000000000..33112dbc0c --- /dev/null +++ b/sca-java-1.x/tags/0.99-incubating/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/provider/BPELImplementationProviderFactory.java @@ -0,0 +1,50 @@ +/*
+ * 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.bpel.provider;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.implementation.bpel.BPELImplementation;
+import org.apache.tuscany.sca.implementation.bpel.ode.EmbeddedODEServer;
+import org.apache.tuscany.sca.provider.ImplementationProvider;
+import org.apache.tuscany.sca.provider.ImplementationProviderFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+/**
+ * The model representing a sample CRUD implementation in an SCA assembly model.
+ */
+public class BPELImplementationProviderFactory implements ImplementationProviderFactory<BPELImplementation> {
+
+ private EmbeddedODEServer odeServer;
+
+ /**
+ * Constructs a new CRUD implementation.
+ * @param odeServer the server instance passed to the implementation provider
+ */
+ public BPELImplementationProviderFactory(ExtensionPointRegistry extensionPoints) {
+ this.odeServer = new EmbeddedODEServer();
+ }
+
+ public ImplementationProvider createImplementationProvider(RuntimeComponent component, BPELImplementation implementation) {
+ return new BPELImplementationProvider(component, implementation, odeServer);
+ }
+
+ public Class<BPELImplementation> getModelType() {
+ return BPELImplementation.class;
+ }
+}
diff --git a/sca-java-1.x/tags/0.99-incubating/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/provider/BPELInvoker.java b/sca-java-1.x/tags/0.99-incubating/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/provider/BPELInvoker.java new file mode 100644 index 0000000000..b786f00266 --- /dev/null +++ b/sca-java-1.x/tags/0.99-incubating/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/provider/BPELInvoker.java @@ -0,0 +1,62 @@ +/*
+ * 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.bpel.provider;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+
+/**
+ * Implements a target invoker for CRUD component implementations.
+ *
+ * The target invoker is responsible for dispatching invocations to the particular
+ * component implementation logic. In this example we are simply delegating the
+ * CRUD operation invocations to the corresponding methods on our fake
+ * resource manager.
+ */
+public class BPELInvoker implements Invoker {
+ private Operation operation;
+
+ public BPELInvoker(Operation operation) {
+ this.operation = operation;
+ }
+
+ public Message invoke(Message msg) {
+ try {
+ Object[] args = msg.getBody();
+ Object resp = doTheWork(args);
+ msg.setBody(resp);
+ } catch (InvocationTargetException e) {
+ msg.setFaultBody(e.getCause());
+ }
+ return msg;
+ }
+
+ public Object doTheWork(Object[] args) throws InvocationTargetException {
+ if (operation.getName().equals("invokeProcess")) {
+ return args[0];
+ } else {
+ return null;
+ }
+ }
+
+}
|