summaryrefslogtreecommitdiffstats
path: root/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local')
-rw-r--r--sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/AbstractLocalTargetInvoker.java78
-rw-r--r--sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalBindingBuilder.java52
-rw-r--r--sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalBindingDefinition.java39
-rw-r--r--sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalBindingLoader.java70
-rw-r--r--sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalCallbackTargetInvoker.java69
-rw-r--r--sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalReferenceBinding.java62
-rw-r--r--sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalServiceBinding.java60
-rw-r--r--sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalTargetInvoker.java79
8 files changed, 0 insertions, 509 deletions
diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/AbstractLocalTargetInvoker.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/AbstractLocalTargetInvoker.java
deleted file mode 100644
index 4a06bc8c74..0000000000
--- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/AbstractLocalTargetInvoker.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * 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.binding.local;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.apache.tuscany.spi.wire.Interceptor;
-import org.apache.tuscany.spi.wire.InvocationChain;
-import org.apache.tuscany.spi.wire.InvocationRuntimeException;
-import org.apache.tuscany.spi.wire.Message;
-import org.apache.tuscany.spi.wire.TargetInvoker;
-import org.apache.tuscany.spi.component.WorkContext;
-
-/**
- * Base class for dispatching to a composite reference using the local binding
- *
- * @version $Rev$ $Date$
- */
-public abstract class AbstractLocalTargetInvoker implements TargetInvoker {
- protected boolean cacheable;
-
- public boolean isCacheable() {
- return cacheable;
- }
-
- public void setCacheable(boolean cacheable) {
- this.cacheable = cacheable;
- }
-
- public boolean isOptimizable() {
- return isCacheable(); // we only need to check if the scopes are correct
- }
-
- public Object invokeTarget(final Object payload, short sequence, WorkContext workContext) throws InvocationTargetException {
- throw new InvocationTargetException(new UnsupportedOperationException());
- }
-
- protected Message invoke(InvocationChain chain, TargetInvoker invoker, Message msg) throws Throwable {
- Interceptor headInterceptor = chain.getHeadInterceptor();
- if (headInterceptor == null) {
- try {
- // short-circuit the dispatch and invoke the target directly
- if (invoker == null) {
- String name = chain.getOperation().getName();
- throw new AssertionError("No target invoker [" + name + "]");
- }
- return invoker.invoke(msg);
- } catch (InvocationRuntimeException e) {
- // the cause was thrown by the target so throw it
- throw e.getCause();
- }
- } else {
- msg.setTargetInvoker(invoker);
- return headInterceptor.invoke(msg);
- }
- }
-
- @Override
- public AbstractLocalTargetInvoker clone() throws CloneNotSupportedException {
- return (AbstractLocalTargetInvoker) super.clone();
- }
-}
diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalBindingBuilder.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalBindingBuilder.java
deleted file mode 100644
index 63a9147b29..0000000000
--- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalBindingBuilder.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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.binding.local;
-
-import org.apache.tuscany.spi.builder.BuilderException;
-import org.apache.tuscany.spi.component.ReferenceBinding;
-import org.apache.tuscany.spi.component.ServiceBinding;
-import org.apache.tuscany.spi.deployer.DeploymentContext;
-import org.apache.tuscany.spi.extension.BindingBuilderExtension;
-import org.apache.tuscany.spi.model.ReferenceDefinition;
-import org.apache.tuscany.spi.model.ServiceDefinition;
-
-/**
- * Creates runtime artifacts for the local binding
- *
- * @version $Rev$ $Date$
- */
-public class LocalBindingBuilder extends BindingBuilderExtension<LocalBindingDefinition> {
-
- protected Class<LocalBindingDefinition> getBindingType() {
- return LocalBindingDefinition.class;
- }
-
- public ServiceBinding build(ServiceDefinition serviceDefinition,
- LocalBindingDefinition bindingDefinition,
- DeploymentContext context) throws BuilderException {
- return new LocalServiceBinding(serviceDefinition.getUri());
- }
-
-
- public ReferenceBinding build(ReferenceDefinition referenceDefinition,
- LocalBindingDefinition bindingDefinition,
- DeploymentContext context) throws BuilderException {
- return new LocalReferenceBinding(referenceDefinition.getUri(), bindingDefinition.getTargetUri());
- }
-}
diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalBindingDefinition.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalBindingDefinition.java
deleted file mode 100644
index 9317a47457..0000000000
--- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalBindingDefinition.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.binding.local;
-
-import java.net.URI;
-
-import org.apache.tuscany.spi.model.BindingDefinition;
-
-
-/**
- * Represents the local by-reference binding
- *
- * @version $Rev$ $Date$
- */
-public class LocalBindingDefinition extends BindingDefinition {
-
- public LocalBindingDefinition() {
- }
-
- public LocalBindingDefinition(URI targetUri) {
- super(targetUri);
- }
-}
diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalBindingLoader.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalBindingLoader.java
deleted file mode 100644
index 3442f1ca4c..0000000000
--- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalBindingLoader.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * 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.binding.local;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-
-import org.osoa.sca.annotations.Reference;
-
-import org.apache.tuscany.spi.deployer.DeploymentContext;
-import org.apache.tuscany.spi.extension.LoaderExtension;
-import org.apache.tuscany.spi.loader.LoaderException;
-import org.apache.tuscany.spi.loader.LoaderRegistry;
-import org.apache.tuscany.spi.model.ModelObject;
-import org.apache.tuscany.spi.wire.Wire;
-
-/**
- * Loader responsible for handling the local binding
- *
- * @version $Rev$ $Date$
- */
-public class LocalBindingLoader extends LoaderExtension<LocalBindingDefinition> {
-
- /**
- * Constructor specifies the registry to register with.
- *
- * @param registry the LoaderRegistry this loader should register with
- */
- public LocalBindingLoader(@Reference LoaderRegistry registry) {
- super(registry);
- }
-
- public QName getXMLType() {
- return Wire.LOCAL_BINDING;
- }
-
- public LocalBindingDefinition load(
- ModelObject object,
- XMLStreamReader reader,
- DeploymentContext deploymentContext) throws XMLStreamException, LoaderException {
- String uri = reader.getAttributeValue(null, "uri");
- if (uri != null) {
- try {
- return new LocalBindingDefinition(new URI(uri));
- } catch (URISyntaxException e) {
- throw new LoaderException(e);
- }
- }
- return new LocalBindingDefinition();
- }
-}
diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalCallbackTargetInvoker.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalCallbackTargetInvoker.java
deleted file mode 100644
index c505ee99ab..0000000000
--- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalCallbackTargetInvoker.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * 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.binding.local;
-
-import java.util.Map;
-
-import org.apache.tuscany.spi.model.Operation;
-import org.apache.tuscany.spi.wire.InvocationChain;
-import org.apache.tuscany.spi.wire.InvocationRuntimeException;
-import org.apache.tuscany.spi.wire.Message;
-import org.apache.tuscany.spi.wire.MessageImpl;
-import org.apache.tuscany.spi.wire.TargetInvoker;
-import org.apache.tuscany.spi.wire.Wire;
-
-/**
- * Dispatches a callback invocation to the callback instance
- *
- * @version $Rev$ $Date$
- */
-public class LocalCallbackTargetInvoker extends AbstractLocalTargetInvoker {
- private Operation operation;
- private Wire wire;
-
- public LocalCallbackTargetInvoker(Operation operation, Wire wire) {
- assert operation != null : "Operation method cannot be null";
- this.operation = operation;
- this.wire = wire;
- }
-
- public Message invoke(Message msg) throws InvocationRuntimeException {
- try {
- return invoke(operation, msg);
- } catch (Throwable e) {
- Message faultMsg = new MessageImpl();
- faultMsg.setBodyWithFault(e);
- return faultMsg;
- }
- }
-
- private Message invoke(Operation operation, Message msg) throws Throwable {
- //TODO optimize as this is slow in local invocations
- Map<Operation<?>, InvocationChain> chains = wire.getCallbackInvocationChains();
- InvocationChain chain = chains.get(operation);
- TargetInvoker invoker = chain.getTargetInvoker();
- return invoke(chain, invoker, msg);
- }
-
- @Override
- public LocalCallbackTargetInvoker clone() throws CloneNotSupportedException {
- return (LocalCallbackTargetInvoker) super.clone();
- }
-
-}
diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalReferenceBinding.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalReferenceBinding.java
deleted file mode 100644
index b70df0e23a..0000000000
--- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalReferenceBinding.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * 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.binding.local;
-
-import java.net.URI;
-import javax.xml.namespace.QName;
-
-import org.apache.tuscany.spi.CoreRuntimeException;
-import org.apache.tuscany.spi.component.TargetInvokerCreationException;
-import org.apache.tuscany.spi.extension.ReferenceBindingExtension;
-import org.apache.tuscany.spi.model.Operation;
-import org.apache.tuscany.spi.model.physical.PhysicalOperationDefinition;
-import org.apache.tuscany.spi.wire.TargetInvoker;
-import org.apache.tuscany.spi.wire.Wire;
-
-/**
- * The runtime representaion of the local reference binding
- *
- * @version $Rev$ $Date$
- * @Deprecated
- */
-public class LocalReferenceBinding extends ReferenceBindingExtension {
-
- public LocalReferenceBinding(URI name, URI targetUri) throws CoreRuntimeException {
- super(name, targetUri);
- }
-
- public QName getBindingType() {
- return Wire.LOCAL_BINDING;
- }
-
- public TargetInvoker createTargetInvoker(String name, Operation operation)
- throws TargetInvokerCreationException {
- if (operation.isCallback()) {
- return new LocalCallbackTargetInvoker(operation, wire);
- } else {
- return new LocalTargetInvoker(operation, wire);
- }
- }
-
- public TargetInvoker createTargetInvoker(String targetName, PhysicalOperationDefinition operation)
- throws TargetInvokerCreationException {
- return null;
- }
-
-}
diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalServiceBinding.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalServiceBinding.java
deleted file mode 100644
index 543a0f53b4..0000000000
--- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalServiceBinding.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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.binding.local;
-
-import java.net.URI;
-import javax.xml.namespace.QName;
-
-import org.apache.tuscany.spi.CoreRuntimeException;
-import org.apache.tuscany.spi.component.TargetInvokerCreationException;
-import org.apache.tuscany.spi.extension.ServiceBindingExtension;
-import org.apache.tuscany.spi.model.Operation;
-import org.apache.tuscany.spi.model.physical.PhysicalOperationDefinition;
-import org.apache.tuscany.spi.wire.TargetInvoker;
-import org.apache.tuscany.spi.wire.Wire;
-
-/**
- * The runtime representaion of the local service binding
- *
- * @version $Rev$ $Date$
- */
-public class LocalServiceBinding extends ServiceBindingExtension {
-
- public LocalServiceBinding(URI name) throws CoreRuntimeException {
- super(name);
- }
-
- public QName getBindingType() {
- return Wire.LOCAL_BINDING;
- }
-
- public TargetInvoker createTargetInvoker(String name, Operation operation)
- throws TargetInvokerCreationException {
- if (operation.isCallback()) {
- return new LocalCallbackTargetInvoker(operation, getWire());
- } else {
- return new LocalTargetInvoker(operation, getWire());
- }
- }
-
- public TargetInvoker createTargetInvoker(String targetName, PhysicalOperationDefinition operation)
- throws TargetInvokerCreationException {
- return null;
- }
-}
diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalTargetInvoker.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalTargetInvoker.java
deleted file mode 100644
index b89a70a9e0..0000000000
--- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/binding/local/LocalTargetInvoker.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * 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.binding.local;
-
-import java.net.URI;
-
-import org.apache.tuscany.spi.model.Operation;
-import org.apache.tuscany.spi.util.UriHelper;
-import org.apache.tuscany.spi.wire.InvocationChain;
-import org.apache.tuscany.spi.wire.InvocationRuntimeException;
-import org.apache.tuscany.spi.wire.Message;
-import org.apache.tuscany.spi.wire.MessageImpl;
-import org.apache.tuscany.spi.wire.TargetInvoker;
-import org.apache.tuscany.spi.wire.Wire;
-
-/**
- * Dispatches an invocation through a composite service or reference using the local binding
- *
- * @version $Rev$ $Date$
- */
-public class LocalTargetInvoker extends AbstractLocalTargetInvoker {
- private InvocationChain chain;
- private URI fromAddress;
- private boolean contractHasCallback;
-
- public LocalTargetInvoker(Operation operation, Wire wire) {
- assert operation != null;
- chain = wire.getInvocationChains().get(operation);
- assert chain != null;
- if (wire.getSourceUri() != null) {
- fromAddress = URI.create(UriHelper.getBaseName(wire.getSourceUri()));
- }
- contractHasCallback = !wire.getCallbackInvocationChains().isEmpty();
- }
-
- @Override
- public LocalTargetInvoker clone() throws CloneNotSupportedException {
- return (LocalTargetInvoker) super.clone();
- }
-
- public Message invoke(Message msg) throws InvocationRuntimeException {
- try {
- TargetInvoker invoker = chain.getTargetInvoker();
- assert invoker != null;
- // Pushing the from address only needs to happen in the outbound (forward) direction for callbacks
- if (contractHasCallback) {
- //JFM do we need this?
- msg.pushCallbackUri(fromAddress);
- }
-
- return invoke(chain, invoker, msg);
- } catch (Throwable e) {
- Message faultMsg = new MessageImpl();
- faultMsg.setBodyWithFault(e);
- return faultMsg;
- }
- }
-
-
- public boolean isOptimizable() {
- return true;
- }
-}