diff options
author | dims <dims@13f79535-47bb-0310-9956-ffa450edef68> | 2008-06-17 00:23:01 +0000 |
---|---|---|
committer | dims <dims@13f79535-47bb-0310-9956-ffa450edef68> | 2008-06-17 00:23:01 +0000 |
commit | bdd0a41aed7edf21ec2a65cfa17a86af2ef8c48a (patch) | |
tree | 38a92061c0793434c4be189f1d70c3458b6bc41d /sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/WireImpl.java |
Move Tuscany from Incubator to top level.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@668359 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/WireImpl.java')
-rw-r--r-- | sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/WireImpl.java | 159 |
1 files changed, 159 insertions, 0 deletions
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 new file mode 100644 index 0000000000..7f748a15db --- /dev/null +++ b/sandbox/rfeng/minicore/src/main/java/org/apache/tuscany/core/wire/WireImpl.java @@ -0,0 +1,159 @@ +/* + * 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); + } + +} |