diff options
Diffstat (limited to 'tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding')
7 files changed, 0 insertions, 426 deletions
diff --git a/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooBinding.java b/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooBinding.java deleted file mode 100644 index 49c59bc718..0000000000 --- a/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooBinding.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * - * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. - * - * Licensed 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.container.java.mock.binding.foo; - -import org.apache.tuscany.model.assembly.AssemblyContext; -import org.apache.tuscany.model.assembly.AssemblyVisitor; -import org.apache.tuscany.model.assembly.Binding; - -/** - * Represents a mock binding that echoes back a single parameter - * - * @version $Rev$ $Date$ - */ -public class FooBinding implements Binding { - - public FooBinding() { - } - - public String getURI() { - return null; - } - - public void setURI(String value) { - } - - public void initialize(AssemblyContext modelContext) { - } - - public void freeze() { - } - - public boolean accept(AssemblyVisitor visitor) { - return true; - } - - private Object contextFactory; - - public void setContextFactory(Object factory) { - contextFactory = factory; - } - - public Object getContextFactory() { - System.out.println("retting"); - return contextFactory; - } - -} diff --git a/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooBindingBuilder.java b/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooBindingBuilder.java deleted file mode 100644 index 558a8ce2cf..0000000000 --- a/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooBindingBuilder.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * - * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. - * - * Licensed 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.container.java.mock.binding.foo; - -import org.apache.tuscany.core.builder.BuilderException; -import org.apache.tuscany.core.builder.ContextFactoryBuilder; -import org.apache.tuscany.core.builder.ContextFactoryBuilderRegistry; -import org.apache.tuscany.core.builder.ObjectFactory; -import org.apache.tuscany.core.extension.EntryPointContextFactory; -import org.apache.tuscany.core.injection.ObjectCreationException; -import org.apache.tuscany.core.message.MessageFactory; -import org.apache.tuscany.core.system.annotation.Autowire; -import org.apache.tuscany.core.wire.SourceWireFactory; -import org.apache.tuscany.core.wire.TargetWireFactory; -import org.apache.tuscany.core.wire.service.WireFactoryService; -import org.apache.tuscany.model.assembly.AssemblyObject; -import org.apache.tuscany.model.assembly.ConfiguredService; -import org.apache.tuscany.model.assembly.EntryPoint; -import org.apache.tuscany.model.assembly.ExternalService; -import org.apache.tuscany.model.assembly.Service; -import org.osoa.sca.annotations.Init; -import org.osoa.sca.annotations.Scope; - -/** - * Creates a <code>ContextFactoryBuilder</code> for an entry point or external service configured with the {@link FooBinding} - * - * @version $Rev$ $Date$ - */ -@Scope("MODULE") -public class FooBindingBuilder implements ContextFactoryBuilder { - private ContextFactoryBuilderRegistry builderRegistry; - - private MessageFactory messageFactory; - - private WireFactoryService wireFactoryService; - - public FooBindingBuilder(WireFactoryService wireFactoryService) { - this.wireFactoryService = wireFactoryService; - } - - public FooBindingBuilder() { - } - - @Init(eager = true) - public void init() { - builderRegistry.register(this); - } - - @Autowire - public void setBuilderRegistry(ContextFactoryBuilderRegistry builderRegistry) { - this.builderRegistry = builderRegistry; - } - - @Autowire - public void setWireFactoryService(WireFactoryService wireFactoryService) { - this.wireFactoryService = wireFactoryService; - } - - - /** - * Sets the factory used to construct wire messages - * - * @param msgFactory - */ - @Autowire - public void setMessageFactory(MessageFactory msgFactory) { - this.messageFactory = msgFactory; - } - - public void build(AssemblyObject object) throws BuilderException { - if (object instanceof EntryPoint) { - EntryPoint ep = (EntryPoint) object; - if (ep.getBindings().size() < 1 || !(ep.getBindings().get(0) instanceof FooBinding)) { - return; - } - EntryPointContextFactory contextFactory = new FooEntryPointContextFactory(ep.getName(), messageFactory); - ConfiguredService configuredService = ep.getConfiguredService(); - Service service = configuredService.getPort(); - SourceWireFactory wireFactory = wireFactoryService.createSourceFactory(ep.getConfiguredReference()).get(0); - contextFactory.addSourceWireFactory(service.getName(), wireFactory); - ep.setContextFactory(contextFactory); - } else if (object instanceof ExternalService) { - ExternalService es = (ExternalService) object; - if (es.getBindings().size() < 1 || !(es.getBindings().get(0) instanceof FooBinding)) { - return; - } - FooExternalServiceContextFactory contextFactory = new FooExternalServiceContextFactory(es.getName(), - new FooClientFactory()); - ConfiguredService configuredService = es.getConfiguredService(); - Service service = configuredService.getPort(); - TargetWireFactory wireFactory = wireFactoryService.createTargetFactory(configuredService); - contextFactory.addTargetWireFactory(service.getName(), wireFactory); - es.setContextFactory(contextFactory); - } - } - - private static class FooClientFactory implements ObjectFactory { - - public Object getInstance() throws ObjectCreationException { - return new FooClient(); - } - } -} diff --git a/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooBindingWireBuilder.java b/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooBindingWireBuilder.java deleted file mode 100644 index e2592024f8..0000000000 --- a/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooBindingWireBuilder.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * - * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. - * - * Licensed 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.container.java.mock.binding.foo; - -import org.apache.tuscany.core.builder.BuilderConfigException; -import org.apache.tuscany.core.builder.WireBuilder; -import org.apache.tuscany.core.context.ScopeContext; -import org.apache.tuscany.core.runtime.RuntimeContext; -import org.apache.tuscany.core.system.annotation.Autowire; -import org.apache.tuscany.core.wire.SourceInvocationConfiguration; -import org.apache.tuscany.core.wire.SourceWireFactory; -import org.apache.tuscany.core.wire.TargetInvocationConfiguration; -import org.apache.tuscany.core.wire.TargetInvoker; -import org.apache.tuscany.core.wire.TargetWireFactory; -import org.osoa.sca.annotations.Init; - -public class FooBindingWireBuilder implements WireBuilder { - - public FooBindingWireBuilder() { - super(); - } - - private RuntimeContext runtimeContext; - - @Autowire - public void setRuntimeContext(RuntimeContext context) { - runtimeContext = context; - } - - @Init(eager = true) - public void init() { - runtimeContext.addBuilder(this); - } - - - public void connect(SourceWireFactory sourceFactory, TargetWireFactory targetFactory, Class targetType, boolean downScope, - ScopeContext targetScopeContext) throws BuilderConfigException { - if (!FooExternalServiceContextFactory.class.isAssignableFrom(targetType)) { - return; - } - for (SourceInvocationConfiguration sourceInvocationConfig : sourceFactory.getConfiguration().getInvocationConfigurations() - .values()) { - FooExternalServiceTargetInvoker invoker = new FooExternalServiceTargetInvoker(sourceFactory.getConfiguration().getTargetName() - .getPartName()); - sourceInvocationConfig.setTargetInvoker(invoker); - } - - } - - public void completeTargetChain(TargetWireFactory targetFactory, Class targetType, ScopeContext targetScopeContext) - throws BuilderConfigException { - if (FooExternalServiceContextFactory.class.isAssignableFrom(targetType)) { - for (TargetInvocationConfiguration targetInvocationConfig : targetFactory.getConfiguration().getInvocationConfigurations() - .values()) { - TargetInvoker invoker = new FooExternalServiceTargetInvoker(targetFactory.getConfiguration().getTargetName().getQualifiedName()); - targetInvocationConfig.setTargetInvoker(invoker); - } - - } - } - -} diff --git a/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooClient.java b/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooClient.java deleted file mode 100644 index 9f67eb7786..0000000000 --- a/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooClient.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * - * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. - * - * Licensed 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.container.java.mock.binding.foo; - -import java.lang.reflect.Array; - -import org.apache.tuscany.core.context.TargetException; - -/** - * A mock client for a transport binding - * - * @version $Rev$ $Date$ - */ -public class FooClient { - - public FooClient() { - } - - public Object invoke(Object msg) { - if (msg!=null && msg.getClass().isArray() && Array.getLength(msg) == 1){ - return Array.get(msg,0); - }else{ - throw new TargetException("This binding only understands operations with a single parameter"); - } - } -} diff --git a/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooEntryPointContextFactory.java b/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooEntryPointContextFactory.java deleted file mode 100644 index 69d81f66be..0000000000 --- a/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooEntryPointContextFactory.java +++ /dev/null @@ -1,31 +0,0 @@ -/** - * - * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. - * - * Licensed 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.container.java.mock.binding.foo; - -import org.apache.tuscany.core.extension.EntryPointContextFactory; -import org.apache.tuscany.core.message.MessageFactory; - -/** - * - * - * @version $Rev$ $Date$ - */ -public class FooEntryPointContextFactory extends EntryPointContextFactory { - - public FooEntryPointContextFactory(String name, MessageFactory msgFactory) { - super(name, msgFactory); - } - -} - diff --git a/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooExternalServiceContextFactory.java b/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooExternalServiceContextFactory.java deleted file mode 100644 index c7f67e2ff2..0000000000 --- a/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooExternalServiceContextFactory.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * - * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. - * - * Licensed 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.container.java.mock.binding.foo; - -import org.apache.tuscany.core.builder.ObjectFactory; -import org.apache.tuscany.core.extension.ExternalServiceContextFactory; - -/** - * Creates instances of {@link org.apache.tuscany.core.context.ExternalServiceContext} configured with the appropriate - * wire chains and bindings. This implementation serves as a marker for - * {@link org.apache.tuscany.container.java.mock.binding.foo.FooBindingWireBuilder} - * - * @version $Rev$ $Date$ - */ -public class FooExternalServiceContextFactory extends ExternalServiceContextFactory { - - public FooExternalServiceContextFactory(String name, ObjectFactory objectFactory) { - super(name, objectFactory); - } - -} diff --git a/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooExternalServiceTargetInvoker.java b/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooExternalServiceTargetInvoker.java deleted file mode 100644 index ecc9655a10..0000000000 --- a/tags/java-M1-20060518/java/sca/containers/container.java/src/test/java/org/apache/tuscany/container/java/mock/binding/foo/FooExternalServiceTargetInvoker.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * - * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. - * - * Licensed 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.container.java.mock.binding.foo; - -import org.apache.tuscany.core.context.ExternalServiceContext; -import org.apache.tuscany.core.message.Message; -import org.apache.tuscany.core.wire.Interceptor; -import org.apache.tuscany.core.wire.TargetInvoker; - -import java.lang.reflect.InvocationTargetException; - -/** - * Responsible for invoking a mock transport binding client configured for an external service over a wire - * - * @version $Rev$ $Date$ - */ -public class FooExternalServiceTargetInvoker implements TargetInvoker { - - private String name; - private ExternalServiceContext context; - - public FooExternalServiceTargetInvoker(String esName) { - assert (esName != null) : "No external service name specified"; - name = esName; // name is not used; it is included for illustration - } - - public Object invokeTarget(Object payload) throws InvocationTargetException { - FooClient client = new FooClient(); - if (payload != null) { - return client.invoke(payload); - } else { - return client.invoke(null); - } - } - - public boolean isCacheable() { - return false; - } - - public Message invoke(Message msg) { - try { - Object resp = invokeTarget(msg.getBody()); - msg.setBody(resp); - } catch (InvocationTargetException e) { - msg.setBody(e.getCause()); - } catch (Throwable e) { - msg.setBody(e); - } - return msg; - } - - public void setNext(Interceptor next) { - throw new UnsupportedOperationException(); - } - - public Object clone() throws CloneNotSupportedException { - try { - FooExternalServiceTargetInvoker invoker = (FooExternalServiceTargetInvoker) super.clone(); - invoker.context = this.context; - invoker.name = this.name; - return invoker; - } catch (CloneNotSupportedException e) { - return null; // will not happen - } - } - -} |