From 3336ce7cd343c5b5ec51c1762f3133d044cff3be Mon Sep 17 00:00:00 2001 From: slaws Date: Thu, 23 Oct 2008 15:42:42 +0000 Subject: Merge the runtime wire changes to add a binding invocation wire with the jms binding changes to exploit the binding wire. Still early days so see the ongoing conversation on the ML. This function is only enabled if you include a wire format in a jms service binding element. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@707394 13f79535-47bb-0310-9956-ffa450edef68 --- .../tuscany/sca/invocation/BindingInterceptor.java | 46 ------- .../DefaultProviderFactoryExtensionPoint.java | 147 +++++++++++++++++++++ .../provider/OperationSelectorProviderFactory.java | 53 ++++++++ .../OperationSelectortProviderFactory.java | 53 -------- .../sca/provider/ServiceBindingProviderRRB.java | 3 +- 5 files changed, 201 insertions(+), 101 deletions(-) delete mode 100644 java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/BindingInterceptor.java create mode 100644 java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/OperationSelectorProviderFactory.java delete mode 100644 java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/OperationSelectortProviderFactory.java (limited to 'java/sca/modules/core-spi/src/main') diff --git a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/BindingInterceptor.java b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/BindingInterceptor.java deleted file mode 100644 index 9aad2dd458..0000000000 --- a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/BindingInterceptor.java +++ /dev/null @@ -1,46 +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.sca.invocation; - -/** - * TODO RRB experiment to allow the request and respose side of the - * invoke to be called independently - * Synchronous mediation associated with a client- or target- side wire. - * - * @version $Rev$ $Date$ - */ -public interface BindingInterceptor extends Invoker { - - /** - * Process a synchronous request - * - * @param msg The request Message for the wire - * @return The response Message from the wire - */ - Message invokeRequest(Message msg); - - /** - * Process a synchronous response - * - * @param msg The request Message for the wire - * @return The response Message from the wire - */ - Message invokeResponse(Message msg); - -} diff --git a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultProviderFactoryExtensionPoint.java b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultProviderFactoryExtensionPoint.java index dfc3ddb468..1edf612780 100644 --- a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultProviderFactoryExtensionPoint.java +++ b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultProviderFactoryExtensionPoint.java @@ -113,6 +113,8 @@ public class DefaultProviderFactoryExtensionPoint implements ProviderFactoryExte loadProviderFactories(BindingProviderFactory.class); loadProviderFactories(ImplementationProviderFactory.class); loadProviderFactories(PolicyProviderFactory.class); + loadProviderFactories(WireFormatProviderFactory.class); + loadProviderFactories(OperationSelectorProviderFactory.class); loaded = true; } @@ -171,6 +173,26 @@ public class DefaultProviderFactoryExtensionPoint implements ProviderFactoryExte new LazyPolicyProviderFactory(registry, modelTypeName, factoryDeclaration); factoryExtensionPoint.addProviderFactory(factory); factories.add(factory); + } else if (factoryClass == WireFormatProviderFactory.class) { + + // Load a wire format provider factory + String modelTypeName = attributes.get("model"); + + // Create a provider factory wrapper and register it + WireFormatProviderFactory factory = + new LazyWireFormatProviderFactory(registry, modelTypeName, factoryDeclaration); + factoryExtensionPoint.addProviderFactory(factory); + factories.add(factory); + } else if (factoryClass == OperationSelectorProviderFactory.class) { + + // Load a wire format provider factory + String modelTypeName = attributes.get("model"); + + // Create a provider factory wrapper and register it + OperationSelectorProviderFactory factory = + new LazyOperationSelectorProviderFactory(registry, modelTypeName, factoryDeclaration); + factoryExtensionPoint.addProviderFactory(factory); + factories.add(factory); } } return factories; @@ -356,7 +378,132 @@ public class DefaultProviderFactoryExtensionPoint implements ProviderFactoryExte } return modelType; } + } + /** + * A wrapper around a wire format provider factory allowing lazy + * loading and initialization of wire format providers. + */ + private class LazyWireFormatProviderFactory implements WireFormatProviderFactory { + + private ExtensionPointRegistry registry; + private String modelTypeName; + private ServiceDeclaration providerClass; + private WireFormatProviderFactory factory; + private Class modelType; + + private LazyWireFormatProviderFactory(ExtensionPointRegistry registry, + String modelTypeName, + ServiceDeclaration providerClass) { + this.registry = registry; + this.modelTypeName = modelTypeName; + this.providerClass = providerClass; + } + + @SuppressWarnings("unchecked") + private WireFormatProviderFactory getFactory() { + if (factory == null) { + try { + Class factoryClass = + (Class)providerClass.loadClass(); + Constructor constructor = + factoryClass.getConstructor(ExtensionPointRegistry.class); + factory = constructor.newInstance(registry); + } catch (Exception e) { + throw new IllegalStateException(e); + } + } + return factory; + } + + @SuppressWarnings("unchecked") + public WireFormatProvider createReferenceWireFormatProvider(RuntimeComponent component, + RuntimeComponentReference reference, + Binding binding){ + return getFactory().createReferenceWireFormatProvider(component, reference, binding); + } + + @SuppressWarnings("unchecked") + public WireFormatProvider createServiceWireFormatProvider(RuntimeComponent component, + RuntimeComponentService service, + Binding binding){ + return getFactory().createServiceWireFormatProvider(component, service, binding); + } + + public Class getModelType() { + if (modelType == null) { + try { + + modelType = providerClass.loadClass(modelTypeName); + } catch (Exception e) { + throw new IllegalStateException(e); + } + } + return modelType; + } } + /** + * A wrapper around a operation selector provider factory allowing lazy + * loading and initialization of operation selector providers. + */ + private class LazyOperationSelectorProviderFactory implements OperationSelectorProviderFactory { + + private ExtensionPointRegistry registry; + private String modelTypeName; + private ServiceDeclaration providerClass; + private OperationSelectorProviderFactory factory; + private Class modelType; + + private LazyOperationSelectorProviderFactory(ExtensionPointRegistry registry, + String modelTypeName, + ServiceDeclaration providerClass) { + this.registry = registry; + this.modelTypeName = modelTypeName; + this.providerClass = providerClass; + } + + @SuppressWarnings("unchecked") + private OperationSelectorProviderFactory getFactory() { + if (factory == null) { + try { + Class factoryClass = + (Class)providerClass.loadClass(); + Constructor constructor = + factoryClass.getConstructor(ExtensionPointRegistry.class); + factory = constructor.newInstance(registry); + } catch (Exception e) { + throw new IllegalStateException(e); + } + } + return factory; + } + + @SuppressWarnings("unchecked") + public OperationSelectorProvider createReferenceOperationSelectorProvider(RuntimeComponent component, + RuntimeComponentReference reference, + Binding binding){ + return getFactory().createReferenceOperationSelectorProvider(component, reference, binding); + } + + @SuppressWarnings("unchecked") + public OperationSelectorProvider createServiceOperationSelectorProvider(RuntimeComponent component, + RuntimeComponentService service, + Binding binding){ + return getFactory().createServiceOperationSelectorProvider(component, service, binding); + } + + public Class getModelType() { + if (modelType == null) { + try { + + modelType = providerClass.loadClass(modelTypeName); + } catch (Exception e) { + throw new IllegalStateException(e); + } + } + return modelType; + } + } + } diff --git a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/OperationSelectorProviderFactory.java b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/OperationSelectorProviderFactory.java new file mode 100644 index 0000000000..183b38cb33 --- /dev/null +++ b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/OperationSelectorProviderFactory.java @@ -0,0 +1,53 @@ +/* + * 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.provider; + +import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.assembly.OperationSelector; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentReference; +import org.apache.tuscany.sca.runtime.RuntimeComponentService; + +/** + * @version $Rev$ $Date$ + */ +public interface OperationSelectorProviderFactory extends ProviderFactory { + /** + * Create wire format provider for a given reference binding + * @param component + * @param reference + * @param binding + * @return + */ + OperationSelectorProvider createReferenceOperationSelectorProvider(RuntimeComponent component, + RuntimeComponentReference reference, + Binding binding); + + /** + * Create policy provider for a given service binding + * @param component + * @param service + * @param binding + * @return + */ + OperationSelectorProvider createServiceOperationSelectorProvider(RuntimeComponent component, + RuntimeComponentService service, + Binding binding); +} diff --git a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/OperationSelectortProviderFactory.java b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/OperationSelectortProviderFactory.java deleted file mode 100644 index 21d36e5078..0000000000 --- a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/OperationSelectortProviderFactory.java +++ /dev/null @@ -1,53 +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.sca.provider; - -import org.apache.tuscany.sca.assembly.Binding; -import org.apache.tuscany.sca.assembly.OperationSelector; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentReference; -import org.apache.tuscany.sca.runtime.RuntimeComponentService; - -/** - * @version $Rev$ $Date$ - */ -public interface OperationSelectortProviderFactory extends ProviderFactory { - /** - * Create wire format provider for a given reference binding - * @param component - * @param reference - * @param binding - * @return - */ - PolicyProvider createReferenceOperationSelectorProvider(RuntimeComponent component, - RuntimeComponentReference reference, - Binding binding); - - /** - * Create policy provider for a given service binding - * @param component - * @param service - * @param binding - * @return - */ - PolicyProvider createServiceOperationSelectorProvider(RuntimeComponent component, - RuntimeComponentService service, - Binding binding); -} diff --git a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ServiceBindingProviderRRB.java b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ServiceBindingProviderRRB.java index cad31cb2b7..e23a37360a 100644 --- a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ServiceBindingProviderRRB.java +++ b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ServiceBindingProviderRRB.java @@ -34,7 +34,6 @@ import org.apache.tuscany.sca.runtime.RuntimeWire; */ public interface ServiceBindingProviderRRB extends ServiceBindingProvider { - void configureServiceBindingRequestChain(List bindingRequestChain, RuntimeWire runtimeWire); - void configureServiceBindingResponseChain(List bindingResponseChain, RuntimeWire runtimeWire); + void configureBindingChain(RuntimeWire runtimeWire); } -- cgit v1.2.3