summaryrefslogtreecommitdiffstats
path: root/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire')
-rw-r--r--sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/CallbackInterfaceInterceptor.java60
-rw-r--r--sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/IncompatibleServiceContractExceptionFormatter.java94
-rw-r--r--sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/InvocationChainImpl.java105
-rw-r--r--sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/InvokerInterceptor.java60
-rw-r--r--sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/NoMethodForOperationException.java42
-rw-r--r--sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/NonBlockingInterceptor.java193
-rw-r--r--sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/NonBlockingInterceptorBuilder.java55
-rw-r--r--sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/OptimizedWireObjectFactory.java49
-rw-r--r--sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/ProxyServiceExtension.java115
-rw-r--r--sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/WireImpl.java159
-rw-r--r--sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/WireObjectFactory.java85
-rw-r--r--sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/WireObjectFactory2.java65
-rw-r--r--sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/WireUtils.java116
13 files changed, 0 insertions, 1198 deletions
diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/CallbackInterfaceInterceptor.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/CallbackInterfaceInterceptor.java
deleted file mode 100644
index c0bf7780f5..0000000000
--- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/CallbackInterfaceInterceptor.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.wire;
-
-import org.osoa.sca.NoRegisteredCallbackException;
-
-import org.apache.tuscany.spi.wire.Interceptor;
-import org.apache.tuscany.spi.wire.Message;
-
-/**
- * An interceptor applied to the forward direction of a wire that ensures the callback target implements the required
- * service contract. This is required as callback targets may be set dynamically by service implementations.
- *
- * @version $Rev$ $Date$
- */
-public class CallbackInterfaceInterceptor implements Interceptor {
- private boolean invokingServiceImplements;
- private Interceptor next;
-
- public CallbackInterfaceInterceptor(boolean invokingServiceImplements) {
- this.invokingServiceImplements = invokingServiceImplements;
- }
-
- public Message invoke(Message msg) {
- // TODO check in the context if a callback object is set, if so invoke next since the setCallback will
- // perform the check
- if (!invokingServiceImplements) {
- throw new NoRegisteredCallbackException("Callback target does not implement the callback interface");
- }
- return next.invoke(msg);
- }
-
- public void setNext(Interceptor next) {
- this.next = next;
- }
-
- public Interceptor getNext() {
- return next;
- }
-
- public boolean isOptimizable() {
- return false;
- }
-}
diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/IncompatibleServiceContractExceptionFormatter.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/IncompatibleServiceContractExceptionFormatter.java
deleted file mode 100644
index d5fca62e1b..0000000000
--- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/IncompatibleServiceContractExceptionFormatter.java
+++ /dev/null
@@ -1,94 +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.wire;
-
-import java.io.PrintWriter;
-
-import org.osoa.sca.annotations.Destroy;
-import org.osoa.sca.annotations.EagerInit;
-import org.osoa.sca.annotations.Reference;
-
-import org.apache.tuscany.spi.model.Operation;
-import org.apache.tuscany.spi.model.ServiceContract;
-import org.apache.tuscany.spi.wire.IncompatibleServiceContractException;
-
-import org.apache.tuscany.host.monitor.ExceptionFormatter;
-import org.apache.tuscany.host.monitor.FormatterRegistry;
-
-/**
- * Formats {@link org.apache.tuscany.spi.wire.IncompatibleServiceContractException} for JDK logging
- *
- * @version $Rev$ $Date$
- */
-@EagerInit
-public class IncompatibleServiceContractExceptionFormatter implements ExceptionFormatter {
- private FormatterRegistry factory;
-
- public IncompatibleServiceContractExceptionFormatter(@Reference FormatterRegistry factory) {
- this.factory = factory;
- factory.register(this);
- }
-
- public boolean canFormat(Class<?> type) {
- return IncompatibleServiceContractException.class.isAssignableFrom(type);
- }
-
- @Destroy
- public void destroy() {
- factory.unregister(this);
- }
-
- public PrintWriter write(PrintWriter writer, Throwable exception) {
- assert exception instanceof IncompatibleServiceContractException;
- IncompatibleServiceContractException e = (IncompatibleServiceContractException) exception;
- e.appendBaseMessage(writer);
- ServiceContract<?> source = e.getSource();
- String sourceContractName = null;
- if (source != null) {
- sourceContractName = source.getInterfaceName();
- }
- Operation<?> sourceOperation = e.getSourceOperation();
- String sourceOpName = null;
- if (sourceOperation != null) {
- sourceOpName = sourceOperation.getName();
- }
- if (sourceOpName == null) {
- writer.write("\nSource Contract: " + sourceContractName);
- } else {
- writer.write("\nSource Contract: " + sourceContractName + "/" + sourceOpName);
- }
- ServiceContract<?> target = e.getTarget();
- String targetContractName = null;
- if (target != null) {
- targetContractName = target.getInterfaceName();
- }
- Operation<?> targetOperation = e.getTargetOperation();
- String targetOpName = null;
- if (targetOperation != null) {
- targetOpName = targetOperation.getName();
- }
- if (targetOpName == null) {
- writer.write("\nTarget Contract: " + targetContractName + "\n");
- } else {
- writer.write("\nTarget Contract: " + targetContractName + "/" + targetOpName + "\n");
-
- }
- return writer;
- }
-}
diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/InvocationChainImpl.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/InvocationChainImpl.java
deleted file mode 100644
index 921b4e37fa..0000000000
--- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/InvocationChainImpl.java
+++ /dev/null
@@ -1,105 +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.wire;
-
-import org.apache.tuscany.spi.model.Operation;
-import org.apache.tuscany.spi.model.physical.PhysicalOperationDefinition;
-import org.apache.tuscany.spi.wire.Interceptor;
-import org.apache.tuscany.spi.wire.InvocationChain;
-import org.apache.tuscany.spi.wire.TargetInvoker;
-
-/**
- * Default implementation of an invocation chain
- *
- * @version $Rev$ $Date$
- */
-public class InvocationChainImpl implements InvocationChain {
- protected Operation operation;
- protected PhysicalOperationDefinition physicalOperation;
- protected TargetInvoker targetInvoker;
- protected Interceptor interceptorChainHead;
- protected Interceptor interceptorChainTail;
-
- public InvocationChainImpl(PhysicalOperationDefinition operation) {
- this.physicalOperation = operation;
- }
-
- public InvocationChainImpl(Operation operation) {
- assert operation != null;
- this.operation = operation;
- }
-
- public Operation getOperation() {
- return operation;
- }
-
- public PhysicalOperationDefinition getPhysicalOperation() {
- return physicalOperation;
- }
-
- public void setTargetInvoker(TargetInvoker invoker) {
- this.targetInvoker = invoker;
- }
-
- public TargetInvoker getTargetInvoker() {
- return targetInvoker;
- }
-
- public void addInterceptor(Interceptor interceptor) {
- if (interceptorChainHead == null) {
- interceptorChainHead = interceptor;
- } else {
- interceptorChainTail.setNext(interceptor);
- }
- interceptorChainTail = interceptor;
- }
-
- public void addInterceptor(int index, Interceptor interceptor) {
- int i = 0;
- Interceptor next = interceptorChainHead;
- Interceptor prev = null;
- while (next != null && i < index) {
- prev = next;
- next = next.getNext();
- i++;
- }
- if (i == index) {
- if (prev != null) {
- prev.setNext(interceptor);
- } else {
- interceptorChainHead = interceptor;
- }
- interceptor.setNext(next);
- if (next == null) {
- interceptorChainTail = interceptor;
- }
- } else {
- throw new ArrayIndexOutOfBoundsException(index);
- }
- }
-
- public Interceptor getHeadInterceptor() {
- return interceptorChainHead;
- }
-
- public Interceptor getTailInterceptor() {
- return interceptorChainTail;
- }
-
-}
diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/InvokerInterceptor.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/InvokerInterceptor.java
deleted file mode 100644
index 10cc254451..0000000000
--- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/InvokerInterceptor.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.wire;
-
-import org.apache.tuscany.spi.wire.Interceptor;
-import org.apache.tuscany.spi.wire.InvocationRuntimeException;
-import org.apache.tuscany.spi.wire.Message;
-import org.apache.tuscany.spi.wire.TargetInvoker;
-
-/**
- * Serves as a tail interceptor on a target wire chain. This implementation dispatches to the target invoker passed
- * inside the wire message. Target invokers are passed from the source in order to allow for caching of target
- * instances.
- *
- * @version $Rev$ $Date$
- * @Deprecated
- * @see org.apache.tuscany.spi.wire.TargetInvoker
- */
-public class InvokerInterceptor implements Interceptor {
-
- public InvokerInterceptor() {
- }
-
- public Message invoke(Message msg) throws InvocationRuntimeException {
- TargetInvoker invoker = msg.getTargetInvoker();
- if (invoker == null) {
- throw new InvocationRuntimeException("No target invoker specified on message");
- }
- return invoker.invoke(msg);
- }
-
- public void setNext(Interceptor next) {
- throw new IllegalStateException("This interceptor must be the last one in an target interceptor chain");
- }
-
- public Interceptor getNext() {
- return null;
- }
-
- public boolean isOptimizable() {
- return true;
- }
-
-}
diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/NoMethodForOperationException.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/NoMethodForOperationException.java
deleted file mode 100644
index aec281d190..0000000000
--- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/NoMethodForOperationException.java
+++ /dev/null
@@ -1,42 +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.wire;
-
-import org.apache.tuscany.spi.wire.ProxyCreationException;
-
-/**
- * Thrown when an {@link org.apache.tuscany.spi.model.Operation} cannot be mapped to a method on an interface
- * @version $Rev$ $Date$
- */
-public class NoMethodForOperationException extends ProxyCreationException {
- public NoMethodForOperationException() {
- }
-
- public NoMethodForOperationException(String message) {
- super(message);
- }
-
- public NoMethodForOperationException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public NoMethodForOperationException(Throwable cause) {
- super(cause);
- }
-}
diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/NonBlockingInterceptor.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/NonBlockingInterceptor.java
deleted file mode 100644
index d4848cde71..0000000000
--- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/NonBlockingInterceptor.java
+++ /dev/null
@@ -1,193 +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.wire;
-
-import java.net.URI;
-import java.util.LinkedList;
-
-import org.osoa.sca.ServiceRuntimeException;
-
-import org.apache.tuscany.spi.component.WorkContext;
-import org.apache.tuscany.spi.model.Scope;
-import org.apache.tuscany.spi.services.work.WorkScheduler;
-import org.apache.tuscany.spi.wire.Interceptor;
-import org.apache.tuscany.spi.wire.Message;
-import org.apache.tuscany.spi.wire.TargetInvoker;
-import org.apache.tuscany.spi.wire.Wire;
-
-/**
- * Adds non-blocking behavior to an invocation chain
- *
- * @version $$Rev$$ $$Date$$
- */
-public class NonBlockingInterceptor implements Interceptor {
-
- private static final Message RESPONSE = new ImmutableMessage();
-
- private WorkScheduler workScheduler;
- private WorkContext workContext;
- private Interceptor next;
-
- public NonBlockingInterceptor(WorkScheduler workScheduler, WorkContext workContext) {
- this.workScheduler = workScheduler;
- this.workContext = workContext;
- }
-
- public NonBlockingInterceptor(WorkScheduler workScheduler, WorkContext workContext, Interceptor next) {
- this.workScheduler = workScheduler;
- this.workContext = workContext;
- this.next = next;
- }
-
- public Message invoke(final Message msg) {
- // Retrieve conversation id to transfer to new thread
- // Notice that we cannot clear the conversation id from the current thread
- final Object conversationID = workContext.getIdentifier(Scope.CONVERSATION);
- // Schedule the invocation of the next interceptor in a new Work instance
- try {
- workScheduler.scheduleWork(new Runnable() {
- public void run() {
- workContext.setCorrelationId(null);
- // if we got a conversation id, transfer it to new thread
- if (conversationID != null) {
- workContext.setIdentifier(Scope.CONVERSATION, conversationID);
- }
- next.invoke(msg);
- }
- });
- } catch (Exception e) {
- throw new ServiceRuntimeException(e);
- }
- return RESPONSE;
- }
-
- public Interceptor getNext() {
- return next;
- }
-
- public void setNext(Interceptor next) {
- this.next = next;
- }
-
- public boolean isOptimizable() {
- return false;
- }
-
- /**
- * A dummy message passed back on an invocation
- */
- private static class ImmutableMessage implements Message {
-
- public Object getBody() {
- return null;
- }
-
- public void setBody(Object body) {
- if (body != null) {
- throw new UnsupportedOperationException();
- }
- }
-
- public WorkContext getWorkContext() {
- throw new UnsupportedOperationException();
- }
-
- public void setWorkContext(WorkContext workContext) {
- throw new UnsupportedOperationException();
- }
-
- public void setTargetInvoker(TargetInvoker invoker) {
- throw new UnsupportedOperationException();
- }
-
- public TargetInvoker getTargetInvoker() {
- return null;
- }
-
- public Message getRelatedCallbackMessage() {
- return null;
- }
-
- public URI getFromAddress() {
- return null;
- }
-
- public void setFromAddress(URI fromAddress) {
- throw new UnsupportedOperationException();
- }
-
- public void pushCallbackUri(URI fromAddress) {
- throw new UnsupportedOperationException();
- }
-
- public LinkedList<URI> getCallbackUris() {
- return null;
- }
-
- public void setCallbackUris(LinkedList<URI> uris) {
- throw new UnsupportedOperationException();
- }
-
- public void pushCallbackWire(Wire wire) {
-
- }
-
- public LinkedList<Wire> getCallbackWires() {
- return null;
- }
-
- public void setCallbackWires(LinkedList<Wire> wires) {
-
- }
-
- public Object getMessageId() {
- return null;
- }
-
- public void setMessageId(Object messageId) {
- throw new UnsupportedOperationException();
- }
-
- public Object getCorrelationId() {
- return null;
- }
-
- public void setCorrelationId(Object correlationId) {
- throw new UnsupportedOperationException();
- }
-
- public boolean isFault() {
- return false;
- }
-
- public void setBodyWithFault(Object fault) {
- throw new UnsupportedOperationException();
- }
-
- public short getConversationSequence() {
- return TargetInvoker.NONE;
- }
-
- public void setConversationSequence(short sequence) {
-
- }
-
- }
-
-}
diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/NonBlockingInterceptorBuilder.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/NonBlockingInterceptorBuilder.java
deleted file mode 100644
index 8afcf8f6ad..0000000000
--- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/NonBlockingInterceptorBuilder.java
+++ /dev/null
@@ -1,55 +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.wire;
-
-import javax.xml.namespace.QName;
-
-import org.osoa.sca.annotations.Reference;
-
-import org.apache.tuscany.spi.builder.BuilderException;
-import org.apache.tuscany.spi.component.WorkContext;
-import org.apache.tuscany.spi.extension.InterceptorBuilderExtension;
-import org.apache.tuscany.spi.model.physical.PhysicalInterceptorDefinition;
-import org.apache.tuscany.spi.services.work.WorkScheduler;
-import org.apache.tuscany.spi.wire.Interceptor;
-
-/**
- * Creates a non-blocking interceptor
- *
- * @version $Rev$ $Date$
- */
-public class NonBlockingInterceptorBuilder extends InterceptorBuilderExtension {
- public static final QName QNAME = new QName("http://tuscany.apache.org/xmlns/sca/system/2.0-alpha", "nonblocking");
- private WorkContext workContext;
- private WorkScheduler scheduler;
-
- public NonBlockingInterceptorBuilder(@Reference(required = true)WorkContext workContext,
- @Reference(required = true)WorkScheduler scheduler) {
- this.workContext = workContext;
- this.scheduler = scheduler;
- }
-
- public Interceptor build(PhysicalInterceptorDefinition definition) throws BuilderException {
- return new NonBlockingInterceptor(scheduler, workContext);
- }
-
- protected QName getName() {
- return QNAME;
- }
-}
diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/OptimizedWireObjectFactory.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/OptimizedWireObjectFactory.java
deleted file mode 100644
index ab958234bd..0000000000
--- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/OptimizedWireObjectFactory.java
+++ /dev/null
@@ -1,49 +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.wire;
-
-import org.apache.tuscany.spi.ObjectCreationException;
-import org.apache.tuscany.spi.ObjectFactory;
-import org.apache.tuscany.spi.component.TargetResolutionException;
-import org.apache.tuscany.spi.wire.Wire;
-
-/**
- * Returns a target instance directly from a wire
- *
- * @version $Rev$ $Date$
- * @Deprecated
- */
-public class OptimizedWireObjectFactory<B> implements ObjectFactory<B> {
- private final Class<B> type;
- private Wire wire;
-
- public OptimizedWireObjectFactory(Class<B> type, Wire factory) {
- this.wire = factory;
- this.type = type;
- }
-
- public B getInstance() throws ObjectCreationException {
- try {
- return type.cast(wire.getTargetInstance());
- } catch (TargetResolutionException e) {
- throw new ObjectCreationException(e);
- }
- }
-
-}
diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/ProxyServiceExtension.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/ProxyServiceExtension.java
deleted file mode 100644
index 7c8cf0db3a..0000000000
--- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/ProxyServiceExtension.java
+++ /dev/null
@@ -1,115 +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.wire;
-
-import org.apache.tuscany.spi.component.WorkContext;
-import org.apache.tuscany.spi.model.Operation;
-import org.apache.tuscany.spi.model.ServiceContract;
-import org.apache.tuscany.spi.wire.IncompatibleServiceContractException;
-import org.apache.tuscany.spi.wire.ProxyService;
-
-/**
- * Base class for wire service extensions
- *
- * @version $Rev$ $Date$
- */
-public abstract class ProxyServiceExtension implements ProxyService {
- protected WorkContext context;
-
- protected ProxyServiceExtension(WorkContext context) {
- this.context = context;
- }
-
- public boolean checkCompatibility(ServiceContract<?> source,
- ServiceContract<?> target,
- boolean ignoreCallback,
- boolean silent)
- throws IncompatibleServiceContractException {
- if (source == target) {
- // Shortcut for performance
- return true;
- }
- if (source.isRemotable() != target.isRemotable()) {
- if (!silent) {
- throw new IncompatibleServiceContractException("Remotable settings do not match", source, target);
- } else {
- return false;
- }
- }
- if (source.isConversational() != target.isConversational()) {
- if (!silent) {
- throw new IncompatibleServiceContractException("Interaction scopes do not match", source, target);
- } else {
- return false;
- }
- }
-
- for (Operation<?> operation : source.getOperations().values()) {
- Operation<?> targetOperation = target.getOperations().get(operation.getName());
- if (targetOperation == null) {
- if (!silent) {
- throw new IncompatibleServiceContractException("Operation not found on target", source, target);
- } else {
- return false;
- }
- }
- if (!operation.equals(targetOperation)) {
- if (!silent) {
- throw new IncompatibleServiceContractException("Target operations are not compatible", source,
- target);
- } else {
- return false;
- }
- }
- }
-
- if (ignoreCallback) {
- return true;
- }
-
- for (Operation<?> operation : source.getCallbackOperations().values()) {
- Operation<?> targetOperation = target.getCallbackOperations().get(operation.getName());
- if (targetOperation == null) {
- if (!silent) {
- throw new IncompatibleServiceContractException("Callback operation not found on target",
- source,
- target,
- null,
- targetOperation);
- } else {
- return false;
- }
- }
- if (!operation.equals(targetOperation)) {
- if (!silent) {
- throw new IncompatibleServiceContractException("Target callback operation is not compatible",
- source,
- target,
- operation,
- targetOperation);
- } else {
- return false;
- }
- }
- }
- return true;
- }
-
-
-}
diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/WireImpl.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/WireImpl.java
deleted file mode 100644
index 7f748a15db..0000000000
--- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/WireImpl.java
+++ /dev/null
@@ -1,159 +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.wire;
-
-import java.net.URI;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import javax.xml.namespace.QName;
-
-import org.apache.tuscany.spi.component.AtomicComponent;
-import org.apache.tuscany.spi.component.TargetResolutionException;
-import org.apache.tuscany.spi.model.Operation;
-import org.apache.tuscany.spi.model.ServiceContract;
-import org.apache.tuscany.spi.model.physical.PhysicalOperationDefinition;
-import org.apache.tuscany.spi.wire.InvocationChain;
-import org.apache.tuscany.spi.wire.Wire;
-
-/**
- * Default implementation of a Wire
- *
- * @version $Rev$ $Date$
- */
-public class WireImpl implements Wire {
- private URI sourceUri;
- private URI targetUri;
- private QName bindingType;
- private ServiceContract sourceContract;
- private ServiceContract targetContract;
- private boolean optimizable;
- private Map<Operation<?>, InvocationChain> chains = new HashMap<Operation<?>, InvocationChain>();
- private Map<Operation<?>, InvocationChain> callbackChains = new HashMap<Operation<?>, InvocationChain>();
- private Map<PhysicalOperationDefinition, InvocationChain> pChains =
- new HashMap<PhysicalOperationDefinition, InvocationChain>();
- private Map<PhysicalOperationDefinition, InvocationChain> pCallbackChains =
- new HashMap<PhysicalOperationDefinition, InvocationChain>();
- private AtomicComponent target;
-
- /**
- * Creates a wire with a local binding
- */
- public WireImpl() {
- }
-
- /**
- * Creates a wire with the given binding type
- *
- * @param bindingType the binding type
- */
- public WireImpl(QName bindingType) {
- this.bindingType = bindingType;
- }
-
- public URI getSourceUri() {
- return sourceUri;
- }
-
- public void setSourceUri(URI sourceUri) {
- this.sourceUri = sourceUri;
- }
-
- public URI getTargetUri() {
- return targetUri;
- }
-
- public void setTargetUri(URI targetUri) {
- this.targetUri = targetUri;
- }
-
- public QName getBindingType() {
- return bindingType;
- }
-
-
- public ServiceContract getSourceContract() {
- return sourceContract;
- }
-
- public void setSourceContract(ServiceContract contract) {
- this.sourceContract = contract;
- }
-
-
- public ServiceContract getTargetContract() {
- return targetContract;
- }
-
- public void setTargetContract(ServiceContract contract) {
- this.targetContract = contract;
- }
-
- public boolean isOptimizable() {
- return optimizable;
- }
-
- public void setOptimizable(boolean optimizable) {
- this.optimizable = optimizable;
- }
-
- public Object getTargetInstance() throws TargetResolutionException {
- if (target == null) {
- return null;
- }
- return target.getTargetInstance();
- }
-
- public void setTarget(AtomicComponent target) {
- this.target = target;
- }
-
- public Map<Operation<?>, InvocationChain> getInvocationChains() {
- return Collections.unmodifiableMap(chains);
- }
-
- public void addInvocationChain(Operation<?> operation, InvocationChain chain) {
- chains.put(operation, chain);
- }
-
- public void addInvocationChain(PhysicalOperationDefinition operation, InvocationChain chain) {
- pChains.put(operation, chain);
- }
-
- public Map<PhysicalOperationDefinition, InvocationChain> getPhysicalInvocationChains() {
- return Collections.unmodifiableMap(pChains);
- }
-
- public Map<Operation<?>, InvocationChain> getCallbackInvocationChains() {
- return Collections.unmodifiableMap(callbackChains);
- }
-
- public void addCallbackInvocationChain(Operation<?> operation, InvocationChain chain) {
- callbackChains.put(operation, chain);
- }
-
- public Map<PhysicalOperationDefinition, InvocationChain> getCallbackPhysicalInvocationChains() {
- return Collections.unmodifiableMap(pCallbackChains);
- }
-
- public void addCallbackInvocationChain(PhysicalOperationDefinition operation, InvocationChain chain) {
- pCallbackChains.put(operation, chain);
- }
-
-}
diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/WireObjectFactory.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/WireObjectFactory.java
deleted file mode 100644
index 3d14138d56..0000000000
--- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/WireObjectFactory.java
+++ /dev/null
@@ -1,85 +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.wire;
-
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.tuscany.spi.ObjectCreationException;
-import org.apache.tuscany.spi.ObjectFactory;
-import org.apache.tuscany.spi.component.TargetResolutionException;
-import org.apache.tuscany.spi.wire.ChainHolder;
-import org.apache.tuscany.spi.wire.Wire;
-import org.apache.tuscany.spi.wire.ProxyService;
-
-/**
- * Uses a wire to return an object instance
- * @Deprecated
- *
- * @version $Rev$ $Date$
- */
-public class WireObjectFactory<T> implements ObjectFactory<T> {
- private Class<T> interfaze;
- private Wire wire;
- private ProxyService proxyService;
- // the cache of proxy interface method to operation mappings
- private Map<Method, ChainHolder> mappings;
- private boolean optimizable;
-
- /**
- * Constructor.
- *
- * @param interfaze the interface to inject on the client
- * @param wire the backing wire
- * @param proxyService the wire service to create the proxy
- * @throws NoMethodForOperationException
- */
- public WireObjectFactory(Class<T> interfaze, Wire wire, ProxyService proxyService)
- throws NoMethodForOperationException {
- this.interfaze = interfaze;
- this.wire = wire;
- this.proxyService = proxyService;
- this.mappings = WireUtils.createInterfaceToWireMapping(interfaze, wire);
- if (wire.isOptimizable()
- && wire.getSourceContract().getInterfaceClass() != null
- && interfaze.isAssignableFrom(wire.getSourceContract().getInterfaceClass())) {
- optimizable = true;
- }
- }
-
- public T getInstance() throws ObjectCreationException {
- if (optimizable) {
- try {
- return interfaze.cast(wire.getTargetInstance());
- } catch (TargetResolutionException e) {
- throw new ObjectCreationException(e);
- }
- } else {
- // clone the cached mappings
- Map<Method, ChainHolder> newChains = new HashMap<Method, ChainHolder>(mappings.size());
- for (Map.Entry<Method, ChainHolder> entry : mappings.entrySet()) {
- newChains.put(entry.getKey(), entry.getValue().clone());
- }
- return interfaze.cast(proxyService.createProxy(interfaze, wire, newChains));
- }
- }
-
-
-}
diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/WireObjectFactory2.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/WireObjectFactory2.java
deleted file mode 100644
index b5fab62d2f..0000000000
--- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/WireObjectFactory2.java
+++ /dev/null
@@ -1,65 +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.wire;
-
-import java.lang.reflect.Method;
-import java.util.Map;
-
-import org.apache.tuscany.spi.ObjectCreationException;
-import org.apache.tuscany.spi.ObjectFactory;
-import org.apache.tuscany.spi.wire.InvocationChain;
-import org.apache.tuscany.spi.wire.ProxyService;
-import org.apache.tuscany.spi.wire.Wire;
-
-/**
- * Uses a wire to return an object instance
- *
- * @version $Rev$ $Date$
- */
-public class WireObjectFactory2<T> implements ObjectFactory<T> {
- private Class<T> interfaze;
- private boolean conversational;
- private Wire wire;
- private ProxyService proxyService;
- // the cache of proxy interface method to operation mappings
- private Map<Method, InvocationChain> mappings;
-
- /**
- * Constructor.
- *
- * @param interfaze the interface to inject on the client
- * @param conversational if the wire is conversational
- * @param wire the backing wire
- * @param proxyService the wire service to create the proxy
- * @throws NoMethodForOperationException if a method matching the operation cannot be found
- */
- public WireObjectFactory2(Class<T> interfaze, boolean conversational, Wire wire, ProxyService proxyService)
- throws NoMethodForOperationException {
- this.interfaze = interfaze;
- this.conversational = conversational;
- this.wire = wire;
- this.proxyService = proxyService;
- this.mappings = WireUtils.createInterfaceToWireMapping2(interfaze, wire);
- }
-
- public T getInstance() throws ObjectCreationException {
- return interfaze.cast(proxyService.createProxy2(interfaze, conversational, wire));
- }
-}
-
diff --git a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/WireUtils.java b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/WireUtils.java
deleted file mode 100644
index 8b839dc8df..0000000000
--- a/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/WireUtils.java
+++ /dev/null
@@ -1,116 +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.wire;
-
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.Map;
-
-import static org.apache.tuscany.spi.idl.java.JavaIDLUtils.findMethod;
-import static org.apache.tuscany.spi.idl.java.JavaIDLUtils.findMethod2;
-import org.apache.tuscany.spi.model.Operation;
-import org.apache.tuscany.spi.model.physical.PhysicalOperationDefinition;
-import org.apache.tuscany.spi.wire.ChainHolder;
-import org.apache.tuscany.spi.wire.Interceptor;
-import org.apache.tuscany.spi.wire.InvocationChain;
-import org.apache.tuscany.spi.wire.ProxyCreationException;
-import org.apache.tuscany.spi.wire.Wire;
-
-/**
- * Utilities for operating on wires
- *
- * @version $Rev$ $Date$
- */
-public final class WireUtils {
-
- private WireUtils() {
- }
-
-
- /**
- * Maps methods on an interface to operations on a wire
- *
- * @param interfaze the interface to map from
- * @param wire the wire to map to
- * @return a collection of method to operation mappings
- * @throws NoMethodForOperationException
- * @Deprecated
- */
- public static Map<Method, ChainHolder> createInterfaceToWireMapping(Class<?> interfaze, Wire wire)
- throws NoMethodForOperationException {
- Map<Operation<?>, InvocationChain> invocationChains = wire.getInvocationChains();
-
- Map<Method, ChainHolder> chains = new HashMap<Method, ChainHolder>(invocationChains.size());
- for (Map.Entry<Operation<?>, InvocationChain> entry : invocationChains.entrySet()) {
- Operation operation = entry.getKey();
- try {
- Method method = findMethod(interfaze, operation);
- chains.put(method, new ChainHolder(entry.getValue()));
- } catch (NoSuchMethodException e) {
- throw new NoMethodForOperationException(operation.getName());
- }
- }
- return chains;
- }
-
- public static Map<Method, InvocationChain> createInterfaceToWireMapping2(Class<?> interfaze, Wire wire)
- throws NoMethodForOperationException {
- Map<PhysicalOperationDefinition, InvocationChain> invocationChains = wire.getPhysicalInvocationChains();
-
- Map<Method, InvocationChain> chains = new HashMap<Method, InvocationChain>(invocationChains.size());
- for (Map.Entry<PhysicalOperationDefinition, InvocationChain> entry : invocationChains.entrySet()) {
- PhysicalOperationDefinition operation = entry.getKey();
- try {
- Method method = findMethod2(interfaze, operation);
- chains.put(method, entry.getValue());
- } catch (NoSuchMethodException e) {
- throw new NoMethodForOperationException(operation.getName());
- } catch (ClassNotFoundException e) {
- throw new ProxyCreationException(e);
- }
- }
- return chains;
- }
-
- /**
- * Determines if the given wire is optimizable, i.e. its invocation chains may be bypassed during an invocation.
- * This is typically calculated during the connect phase to optimize away invocation chains.
- *
- * @param wire the wire
- * @return true if the wire is optimizable
- */
- public static boolean isOptimizable(Wire wire) {
- for (InvocationChain chain : wire.getInvocationChains().values()) {
- if (chain.getHeadInterceptor() != null) {
- Interceptor current = chain.getHeadInterceptor();
- if (current == null) {
- break;
- }
- while (current != null) {
- if (!current.isOptimizable()) {
- return false;
- }
- current = current.getNext();
- }
- }
- }
- // if there is a callback, the wire is never optimizable since the callback target needs to be disambiguated
- return wire.getCallbackInvocationChains().isEmpty();
- }
-}