From 60dec33a9010d5c51976ecb6092ded0a4d3cd6d6 Mon Sep 17 00:00:00 2001 From: Jokser Date: Sun, 1 Mar 2015 05:43:26 +0600 Subject: [PATCH 1/2] [SWITCHYARD-2580] Make it possible to don't startup service bindings automatically - Changes in config. --- .../config/model/composite/BindingModel.java | 23 ++++++- .../model/composite/ExtensionsModel.java | 17 +++++ .../model/composite/v1/V1BindingModel.java | 56 +++++++++++++++-- .../model/composite/v1/V1ExtensionsModel.java | 17 +++++ .../model/switchyard/ManagementModel.java | 44 +++++++++++++ .../model/switchyard/ThrottlingModel.java | 2 +- .../switchyard/v1/V1ManagementModel.java | 63 +++++++++++++++++++ .../switchyard/v1/V1SwitchYardMarshaller.java | 8 +-- .../model/switchyard/v1/switchyard_1_0.xsd | 16 +++-- .../model/switchyard/v1/switchyard_1_1.xsd | 14 ++++- .../model/switchyard/v2/switchyard_2_0.xsd | 16 +++-- .../switchyard/AutoStartupBindingsTests.java | 57 +++++++++++++++++ .../switchyard/SwitchYardModelTests.java | 3 +- ...utoStartupBindingsTestBindingAttribute.xml | 25 ++++++++ .../AutoStartupBindingsTestDomainProperty.xml | 30 +++++++++ ...AutoStartupBindingsTestServiceProperty.xml | 28 +++++++++ .../AutoStartupBindingsTestTrue.xml | 25 ++++++++ .../SwitchYardModelTests-Complete.xml | 6 +- .../SwitchYardModelTests-Fragment.xml | 5 +- .../SwitchYardModelTests-Incomplete.xml | 1 + 20 files changed, 431 insertions(+), 25 deletions(-) create mode 100644 config/src/main/java/org/switchyard/config/model/switchyard/ManagementModel.java create mode 100644 config/src/main/java/org/switchyard/config/model/switchyard/v1/V1ManagementModel.java create mode 100644 config/src/test/java/org/switchyard/config/model/switchyard/AutoStartupBindingsTests.java create mode 100644 config/src/test/resources/org/switchyard/config/model/switchyard/AutoStartupBindingsTestBindingAttribute.xml create mode 100644 config/src/test/resources/org/switchyard/config/model/switchyard/AutoStartupBindingsTestDomainProperty.xml create mode 100644 config/src/test/resources/org/switchyard/config/model/switchyard/AutoStartupBindingsTestServiceProperty.xml create mode 100644 config/src/test/resources/org/switchyard/config/model/switchyard/AutoStartupBindingsTestTrue.xml diff --git a/config/src/main/java/org/switchyard/config/model/composite/BindingModel.java b/config/src/main/java/org/switchyard/config/model/composite/BindingModel.java index 27c7b25ec..3ea15e01a 100644 --- a/config/src/main/java/org/switchyard/config/model/composite/BindingModel.java +++ b/config/src/main/java/org/switchyard/config/model/composite/BindingModel.java @@ -27,7 +27,13 @@ public interface BindingModel extends TypedModel { /** The "binding" name. */ - public static final String BINDING = "binding"; + public static final String BINDING = "binding"; + + /** The "autoStartup" name. */ + public static final String AUTO_STARTUP = "autoStartup"; + + /** The "disableAutoStartupBindings" domain property */ + public static final String DISABLE_AUTO_STARTUP_BINDINGS = "disableAutoStartupBindings"; /** * Gets the name attribute of this Model (not the name of the wrapped Configuration). @@ -106,4 +112,19 @@ public interface BindingModel extends TypedModel { * @return this BindingModel (useful for chaining) */ public BindingModel setMessageComposer(MessageComposerModel model); + + /** + * Should this binding startup automatically after deployment? + * @return true if should, false in other case + */ + public boolean isAutoStartup(); + + /** + * Sets the autoStartup attribute + * + * @param autoStartup the autoStartup attribute + * @return this BindingModel (useful for chaining) + */ + public BindingModel setAutoStartup(boolean autoStartup); + } diff --git a/config/src/main/java/org/switchyard/config/model/composite/ExtensionsModel.java b/config/src/main/java/org/switchyard/config/model/composite/ExtensionsModel.java index a411b2b54..eb1bd84d6 100644 --- a/config/src/main/java/org/switchyard/config/model/composite/ExtensionsModel.java +++ b/config/src/main/java/org/switchyard/config/model/composite/ExtensionsModel.java @@ -14,6 +14,7 @@ package org.switchyard.config.model.composite; import org.switchyard.config.model.Model; +import org.switchyard.config.model.switchyard.ManagementModel; import org.switchyard.config.model.switchyard.ThrottlingModel; /** @@ -38,4 +39,20 @@ public interface ExtensionsModel extends Model { * @return this ExtensionsModel (useful for chaining) */ public ExtensionsModel setThrottling(ThrottlingModel throttling); + + /** + * Gets the child management model. + * + * @return the child management model. + */ + public ManagementModel getManagement(); + + /** + * Sets the child management model. + * + * @param management child management model + * @return this ExtensionModel (useful for chaining) + */ + public ExtensionsModel setManagement(ManagementModel management); + } diff --git a/config/src/main/java/org/switchyard/config/model/composite/v1/V1BindingModel.java b/config/src/main/java/org/switchyard/config/model/composite/v1/V1BindingModel.java index a61c930a5..3a2223f65 100644 --- a/config/src/main/java/org/switchyard/config/model/composite/v1/V1BindingModel.java +++ b/config/src/main/java/org/switchyard/config/model/composite/v1/V1BindingModel.java @@ -26,10 +26,7 @@ import org.switchyard.config.model.Model; import org.switchyard.config.model.composer.ContextMapperModel; import org.switchyard.config.model.composer.MessageComposerModel; -import org.switchyard.config.model.composite.BindingModel; -import org.switchyard.config.model.composite.CompositeReferenceModel; -import org.switchyard.config.model.composite.CompositeServiceModel; -import org.switchyard.config.model.composite.SCANamespace; +import org.switchyard.config.model.composite.*; import org.switchyard.config.model.selector.OperationSelectorModel; /** @@ -178,6 +175,57 @@ public BindingModel setMessageComposer(MessageComposerModel model) { return this; } + /** + * {@inheritDoc} + */ + @Override + public boolean isAutoStartup() { + // In case of reference binding this attribute does not make sense + if (isReferenceBinding()) + return true; + + //First retrieve disableAutoStartupBindings domain property + boolean disableAutoStartupBindings = false; + try { + String domainProperty = ((CompositeServiceModel) getModelParent()) + .getComposite() + .getSwitchYard() + .getDomain() + .getProperties() + .getProperty(DISABLE_AUTO_STARTUP_BINDINGS) + .getValue(); + + disableAutoStartupBindings = Boolean.valueOf(domainProperty); + } catch (NullPointerException ignored) { } // In case when some of models or domain property are not defined. + + if (disableAutoStartupBindings) + return false; + + // Next retrieve autoStartupBindings attribute from Management extension + boolean autoStartupBindings = true; + try { + autoStartupBindings = ((CompositeServiceModel) getModelParent()) + .getExtensions() + .getManagement() + .isAutoStartupBindings(); + } catch (NullPointerException ignored) { } // In case when some of Extensions/Management models are not defined. + + if (!autoStartupBindings) + return false; + + String autoStartup = getModelAttribute(AUTO_STARTUP); + return autoStartup == null || "true".equals(autoStartup); + } + + /** + * {@inheritDoc} + */ + @Override + public BindingModel setAutoStartup(boolean autoStartup) { + setModelAttribute(AUTO_STARTUP, String.valueOf(autoStartup)); + return this; + } + @Override public boolean isServiceBinding() { return (getModelParent() instanceof CompositeServiceModel); diff --git a/config/src/main/java/org/switchyard/config/model/composite/v1/V1ExtensionsModel.java b/config/src/main/java/org/switchyard/config/model/composite/v1/V1ExtensionsModel.java index a3d727b1c..d5c8b176f 100644 --- a/config/src/main/java/org/switchyard/config/model/composite/v1/V1ExtensionsModel.java +++ b/config/src/main/java/org/switchyard/config/model/composite/v1/V1ExtensionsModel.java @@ -21,6 +21,7 @@ import org.switchyard.config.model.Descriptor; import org.switchyard.config.model.composite.ExtensionsModel; import org.switchyard.config.model.composite.SCANamespace; +import org.switchyard.config.model.switchyard.ManagementModel; import org.switchyard.config.model.switchyard.ThrottlingModel; /** @@ -29,6 +30,7 @@ public class V1ExtensionsModel extends BaseModel implements ExtensionsModel { private ThrottlingModel _throttling; + private ManagementModel _management; /** * Constructs a new V1ExtensionsModel. @@ -61,4 +63,19 @@ public ExtensionsModel setThrottling(ThrottlingModel throttling) { return this; } + @Override + public ManagementModel getManagement() { + if (_management == null) { + _management = (ManagementModel) getFirstChildModel(ManagementModel.MANAGEMENT); + } + return _management; + } + + @Override + public ExtensionsModel setManagement(ManagementModel management) { + setChildModel(management); + _management = management; + return this; + } + } diff --git a/config/src/main/java/org/switchyard/config/model/switchyard/ManagementModel.java b/config/src/main/java/org/switchyard/config/model/switchyard/ManagementModel.java new file mode 100644 index 000000000..1eddd582f --- /dev/null +++ b/config/src/main/java/org/switchyard/config/model/switchyard/ManagementModel.java @@ -0,0 +1,44 @@ +/* + * Copyright 2013 Red Hat Inc. and/or its affiliates and other contributors. + * + * 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.switchyard.config.model.switchyard; + +import org.switchyard.config.model.Model; + +/** + * Additional service management configuration model + */ +public interface ManagementModel extends Model { + + /** The "management" name. */ + public static final String MANAGEMENT = "management"; + + /** The "autoStartupBindings" attribute. */ + public static final String AUTO_STARTUP_BINDINGS = "autoStartupBindings"; + + /** + * Should service bindings startup automatically after deployment + * + * @return true if should, false in other case + */ + public boolean isAutoStartupBindings(); + + /** + * Sets the autoStartupBindings attribute + * + * @param autoStartupBindings the autoStartupBindings attribute + * @return this ManagementModel (useful for chaining) + */ + public ManagementModel setAutoStartupBindings(boolean autoStartupBindings); + +} diff --git a/config/src/main/java/org/switchyard/config/model/switchyard/ThrottlingModel.java b/config/src/main/java/org/switchyard/config/model/switchyard/ThrottlingModel.java index 663a44f1f..b67cea02d 100644 --- a/config/src/main/java/org/switchyard/config/model/switchyard/ThrottlingModel.java +++ b/config/src/main/java/org/switchyard/config/model/switchyard/ThrottlingModel.java @@ -50,7 +50,7 @@ public interface ThrottlingModel extends Model { /** * Sets the maxRequests attribute. - * @param maxRequests the timePeriod attribute + * @param maxRequests the maxRequests attribute * @return this ThrottlingModel (useful for chaining) */ public ThrottlingModel setMaxRequests(int maxRequests); diff --git a/config/src/main/java/org/switchyard/config/model/switchyard/v1/V1ManagementModel.java b/config/src/main/java/org/switchyard/config/model/switchyard/v1/V1ManagementModel.java new file mode 100644 index 000000000..fdbfa9970 --- /dev/null +++ b/config/src/main/java/org/switchyard/config/model/switchyard/v1/V1ManagementModel.java @@ -0,0 +1,63 @@ +/* + * Copyright 2013 Red Hat Inc. and/or its affiliates and other contributors. + * + * 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.switchyard.config.model.switchyard.v1; + +import org.switchyard.config.Configuration; +import org.switchyard.config.model.BaseModel; +import org.switchyard.config.model.Descriptor; +import org.switchyard.config.model.composite.CompositeServiceModel; +import org.switchyard.config.model.composite.ExtensionsModel; +import org.switchyard.config.model.switchyard.ManagementModel; + +/** + * A version 1 ManagementModel + */ +public class V1ManagementModel extends BaseModel implements ManagementModel { + + /** + * Constructs a new V1ManagementModel. + * @param namespace namespace + */ + protected V1ManagementModel(String namespace, String name) { + super(namespace, name); + } + + /** + * Constructs a new V1ManagementModel with the specified Configuration and Descriptor. + * @param config the Configuration + * @param desc the Descriptor + */ + protected V1ManagementModel(Configuration config, Descriptor desc) { + super(config, desc); + } + + /** + * {@inheritDoc} + */ + @Override + public boolean isAutoStartupBindings() { + String autoStartupBindings = getModelAttribute(AUTO_STARTUP_BINDINGS); + return autoStartupBindings == null || "true".equals(autoStartupBindings); + } + + /** + * {@inheritDoc} + */ + @Override + public ManagementModel setAutoStartupBindings(boolean autoStartupBindings) { + setModelAttribute(AUTO_STARTUP_BINDINGS, String.valueOf(autoStartupBindings)); + return this; + } + +} diff --git a/config/src/main/java/org/switchyard/config/model/switchyard/v1/V1SwitchYardMarshaller.java b/config/src/main/java/org/switchyard/config/model/switchyard/v1/V1SwitchYardMarshaller.java index 7ebae4b2d..ea1708b62 100644 --- a/config/src/main/java/org/switchyard/config/model/switchyard/v1/V1SwitchYardMarshaller.java +++ b/config/src/main/java/org/switchyard/config/model/switchyard/v1/V1SwitchYardMarshaller.java @@ -42,11 +42,7 @@ import org.switchyard.config.model.selector.v1.V1RegexOperationSelectorModel; import org.switchyard.config.model.selector.v1.V1StaticOperationSelectorModel; import org.switchyard.config.model.selector.v1.V1XPathOperationSelectorModel; -import org.switchyard.config.model.switchyard.ArtifactModel; -import org.switchyard.config.model.switchyard.ArtifactsModel; -import org.switchyard.config.model.switchyard.EsbInterfaceModel; -import org.switchyard.config.model.switchyard.SwitchYardModel; -import org.switchyard.config.model.switchyard.ThrottlingModel; +import org.switchyard.config.model.switchyard.*; import org.switchyard.config.model.transform.TransformsModel; import org.switchyard.config.model.transform.v1.V1TransformsModel; import org.switchyard.config.model.validate.ValidatesModel; @@ -107,6 +103,8 @@ public Model read(Configuration config) { return new V1ResourceDetailModel(config, desc); } else if (name.equals(ThrottlingModel.THROTTLING)) { return new V1ThrottlingModel(config, desc); + } else if (name.equals(ManagementModel.MANAGEMENT)) { + return new V1ManagementModel(config, desc); } else if (name.equals(INTERFACE_ESB)) { return new V1EsbInterfaceModel(config, desc); } else if (name.startsWith(OperationSelectorModel.OPERATION_SELECTOR)) { diff --git a/config/src/main/resources/org/switchyard/config/model/switchyard/v1/switchyard_1_0.xsd b/config/src/main/resources/org/switchyard/config/model/switchyard/v1/switchyard_1_0.xsd index a995a07cd..b4a735290 100644 --- a/config/src/main/resources/org/switchyard/config/model/switchyard/v1/switchyard_1_0.xsd +++ b/config/src/main/resources/org/switchyard/config/model/switchyard/v1/switchyard_1_0.xsd @@ -12,7 +12,7 @@ - See the License for the specific language governing permissions and - limitations under the License. --> - - + + + @@ -259,7 +261,13 @@ - + + + + + + + @@ -268,7 +276,7 @@ - + diff --git a/config/src/main/resources/org/switchyard/config/model/switchyard/v1/switchyard_1_1.xsd b/config/src/main/resources/org/switchyard/config/model/switchyard/v1/switchyard_1_1.xsd index 822419fe3..c7c4645b3 100644 --- a/config/src/main/resources/org/switchyard/config/model/switchyard/v1/switchyard_1_1.xsd +++ b/config/src/main/resources/org/switchyard/config/model/switchyard/v1/switchyard_1_1.xsd @@ -36,7 +36,9 @@ - + + + @@ -259,7 +261,13 @@ - + + + + + + + @@ -268,7 +276,7 @@ - + diff --git a/config/src/main/resources/org/switchyard/config/model/switchyard/v2/switchyard_2_0.xsd b/config/src/main/resources/org/switchyard/config/model/switchyard/v2/switchyard_2_0.xsd index aea103fb6..6031f3e18 100644 --- a/config/src/main/resources/org/switchyard/config/model/switchyard/v2/switchyard_2_0.xsd +++ b/config/src/main/resources/org/switchyard/config/model/switchyard/v2/switchyard_2_0.xsd @@ -36,7 +36,9 @@ - + + + @@ -260,17 +262,23 @@ - + + + + + + + - + - + diff --git a/config/src/test/java/org/switchyard/config/model/switchyard/AutoStartupBindingsTests.java b/config/src/test/java/org/switchyard/config/model/switchyard/AutoStartupBindingsTests.java new file mode 100644 index 000000000..68dc0c0bc --- /dev/null +++ b/config/src/test/java/org/switchyard/config/model/switchyard/AutoStartupBindingsTests.java @@ -0,0 +1,57 @@ +package org.switchyard.config.model.switchyard; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.switchyard.config.model.ModelPuller; +import org.switchyard.config.model.composite.BindingModel; +import org.switchyard.config.model.composite.CompositeServiceModel; + +/** + * Test auto startup bindings behavior + */ +public class AutoStartupBindingsTests { + + private static final String TEST_WHEN_TRUE = "/org/switchyard/config/model/switchyard/AutoStartupBindingsTestTrue.xml"; + private static final String TEST_DOMAIN_PROPERTY = "/org/switchyard/config/model/switchyard/AutoStartupBindingsTestDomainProperty.xml"; + private static final String TEST_SERVICE_PROPERTY = "/org/switchyard/config/model/switchyard/AutoStartupBindingsTestServiceProperty.xml"; + private static final String TEST_BINDING_ATTRIBUTE = "/org/switchyard/config/model/switchyard/AutoStartupBindingsTestBindingAttribute.xml"; + + private ModelPuller _puller; + + @Before + public void before() throws Exception { + _puller = new ModelPuller(); + } + + @Test + public void testWhenAutoStartupIsTrue() throws Exception { + SwitchYardModel model = _puller.pull(TEST_WHEN_TRUE, getClass()); + checkBindingsAutoStartupValue(model, true); + } + + @Test + public void testDomainProperty() throws Exception { + SwitchYardModel model = _puller.pull(TEST_DOMAIN_PROPERTY, getClass()); + checkBindingsAutoStartupValue(model, false); + } + + @Test + public void testServiceProperty() throws Exception { + SwitchYardModel model = _puller.pull(TEST_SERVICE_PROPERTY, getClass()); + checkBindingsAutoStartupValue(model, false); + } + + @Test + public void testBindingAttribute() throws Exception { + SwitchYardModel model = _puller.pull(TEST_BINDING_ATTRIBUTE, getClass()); + checkBindingsAutoStartupValue(model, false); + } + + private void checkBindingsAutoStartupValue(SwitchYardModel model, boolean expectedValue) { + for (CompositeServiceModel service : model.getComposite().getServices()) + for (BindingModel binding : service.getBindings()) + Assert.assertEquals(expectedValue, binding.isAutoStartup()); + } + +} diff --git a/config/src/test/java/org/switchyard/config/model/switchyard/SwitchYardModelTests.java b/config/src/test/java/org/switchyard/config/model/switchyard/SwitchYardModelTests.java index 53fba110c..0f67a3958 100644 --- a/config/src/test/java/org/switchyard/config/model/switchyard/SwitchYardModelTests.java +++ b/config/src/test/java/org/switchyard/config/model/switchyard/SwitchYardModelTests.java @@ -40,6 +40,7 @@ import org.switchyard.config.model.domain.SecuritiesModel; import org.switchyard.config.model.domain.SecurityModel; import org.switchyard.config.model.property.PropertiesModel; +import org.switchyard.config.model.property.PropertyModel; import org.switchyard.config.model.switchyard.test.java.JavaTransformModel; import org.switchyard.config.model.switchyard.test.smooks.SmooksConfigModel; import org.switchyard.config.model.switchyard.test.smooks.SmooksTransformModel; @@ -126,7 +127,7 @@ public void testReadComplete() throws Exception { Assert.assertEquals("TestDomain", domain.getName()); // Verify property configuration PropertiesModel props = domain.getProperties(); - Assert.assertEquals(8, props.getProperties().size()); + Assert.assertEquals(9, props.getProperties().size()); Assert.assertEquals("bar", props.getPropertyValue("foo")); Assert.assertEquals("fish", props.getPropertyValue("tuna")); Assert.assertEquals(System.getProperty("user.name"), props.getPropertyValue("userName")); diff --git a/config/src/test/resources/org/switchyard/config/model/switchyard/AutoStartupBindingsTestBindingAttribute.xml b/config/src/test/resources/org/switchyard/config/model/switchyard/AutoStartupBindingsTestBindingAttribute.xml new file mode 100644 index 000000000..f0b795076 --- /dev/null +++ b/config/src/test/resources/org/switchyard/config/model/switchyard/AutoStartupBindingsTestBindingAttribute.xml @@ -0,0 +1,25 @@ + + + + + ${soapServiceName:SOAPService}/${soapPortName:SOAPPort} + ${soapWsdlName}.wsdl + + + + + + + + + + \ No newline at end of file diff --git a/config/src/test/resources/org/switchyard/config/model/switchyard/AutoStartupBindingsTestDomainProperty.xml b/config/src/test/resources/org/switchyard/config/model/switchyard/AutoStartupBindingsTestDomainProperty.xml new file mode 100644 index 000000000..295d8a919 --- /dev/null +++ b/config/src/test/resources/org/switchyard/config/model/switchyard/AutoStartupBindingsTestDomainProperty.xml @@ -0,0 +1,30 @@ + + + + + ${soapServiceName:SOAPService}/${soapPortName:SOAPPort} + ${soapWsdlName}.wsdl + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/config/src/test/resources/org/switchyard/config/model/switchyard/AutoStartupBindingsTestServiceProperty.xml b/config/src/test/resources/org/switchyard/config/model/switchyard/AutoStartupBindingsTestServiceProperty.xml new file mode 100644 index 000000000..c1d3e14b9 --- /dev/null +++ b/config/src/test/resources/org/switchyard/config/model/switchyard/AutoStartupBindingsTestServiceProperty.xml @@ -0,0 +1,28 @@ + + + + + ${soapServiceName:SOAPService}/${soapPortName:SOAPPort} + ${soapWsdlName}.wsdl + + + + + + + + + + + + + \ No newline at end of file diff --git a/config/src/test/resources/org/switchyard/config/model/switchyard/AutoStartupBindingsTestTrue.xml b/config/src/test/resources/org/switchyard/config/model/switchyard/AutoStartupBindingsTestTrue.xml new file mode 100644 index 000000000..59aa176e3 --- /dev/null +++ b/config/src/test/resources/org/switchyard/config/model/switchyard/AutoStartupBindingsTestTrue.xml @@ -0,0 +1,25 @@ + + + + + ${soapServiceName:SOAPService}/${soapPortName:SOAPPort} + ${soapWsdlName}.wsdl + + + + + + + + + + \ No newline at end of file diff --git a/config/src/test/resources/org/switchyard/config/model/switchyard/SwitchYardModelTests-Complete.xml b/config/src/test/resources/org/switchyard/config/model/switchyard/SwitchYardModelTests-Complete.xml index d2abd2d9c..e688c9428 100644 --- a/config/src/test/resources/org/switchyard/config/model/switchyard/SwitchYardModelTests-Complete.xml +++ b/config/src/test/resources/org/switchyard/config/model/switchyard/SwitchYardModelTests-Complete.xml @@ -32,10 +32,13 @@ name="m1app"> - + ${soapServiceName:SOAPService}/${soapPortName:SOAPPort} ${soapWsdlName}.wsdl + + + @@ -79,6 +82,7 @@ + diff --git a/config/src/test/resources/org/switchyard/config/model/switchyard/SwitchYardModelTests-Fragment.xml b/config/src/test/resources/org/switchyard/config/model/switchyard/SwitchYardModelTests-Fragment.xml index 2a888f77f..92cdd6116 100644 --- a/config/src/test/resources/org/switchyard/config/model/switchyard/SwitchYardModelTests-Fragment.xml +++ b/config/src/test/resources/org/switchyard/config/model/switchyard/SwitchYardModelTests-Fragment.xml @@ -20,10 +20,13 @@ name="m1app"> - + ${soapServiceName:SOAPService}/${soapPortName:SOAPPort} ${soapWsdlName}.wsdl + + + diff --git a/config/src/test/resources/org/switchyard/config/model/switchyard/SwitchYardModelTests-Incomplete.xml b/config/src/test/resources/org/switchyard/config/model/switchyard/SwitchYardModelTests-Incomplete.xml index 4376256ee..c9212a34f 100644 --- a/config/src/test/resources/org/switchyard/config/model/switchyard/SwitchYardModelTests-Incomplete.xml +++ b/config/src/test/resources/org/switchyard/config/model/switchyard/SwitchYardModelTests-Incomplete.xml @@ -71,6 +71,7 @@ + From 34e0dd18cdc85779b4f08d643b93a256a239e11c Mon Sep 17 00:00:00 2001 From: Jokser Date: Sun, 1 Mar 2015 05:44:07 +0600 Subject: [PATCH 2/2] [SWITCHYARD-2580] Make it possible to don't startup service bindings automatically - Changes in deploy. --- .../deploy/internal/Deployment.java | 7 +++-- .../deploy/components/MockActivator.java | 2 +- .../deploy/internal/DeploymentTest.java | 21 +++++++++++++ .../switchyard-config-autostartup-01.xml | 31 +++++++++++++++++++ 4 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 deploy/base/src/test/resources/switchyard-config-autostartup-01.xml diff --git a/deploy/base/src/main/java/org/switchyard/deploy/internal/Deployment.java b/deploy/base/src/main/java/org/switchyard/deploy/internal/Deployment.java index 5b42e8f0b..4ad45b76e 100644 --- a/deploy/base/src/main/java/org/switchyard/deploy/internal/Deployment.java +++ b/deploy/base/src/main/java/org/switchyard/deploy/internal/Deployment.java @@ -630,8 +630,11 @@ private void deployServiceBindings() { Activation activation = new Activation(activator, service.getQName(), binding, handler); activation.addReference(reference); _serviceBindings.add(activation); - - handler.start(); + + _log.debug("Binding " + binding.getName() + " autoStartup is " + binding.isAutoStartup()); + + if (binding.isAutoStartup()) + handler.start(); } } } diff --git a/deploy/base/src/test/java/org/switchyard/deploy/components/MockActivator.java b/deploy/base/src/test/java/org/switchyard/deploy/components/MockActivator.java index b37d7209c..a03ae13ba 100644 --- a/deploy/base/src/test/java/org/switchyard/deploy/components/MockActivator.java +++ b/deploy/base/src/test/java/org/switchyard/deploy/components/MockActivator.java @@ -42,7 +42,7 @@ public MockActivator() { @Override public ServiceHandler activateBinding(QName serviceName, BindingModel config) { _activateBindingCalled = true; - return _handler; + return new MockServiceHandler(); } @Override diff --git a/deploy/base/src/test/java/org/switchyard/deploy/internal/DeploymentTest.java b/deploy/base/src/test/java/org/switchyard/deploy/internal/DeploymentTest.java index c464cdf76..236733f53 100644 --- a/deploy/base/src/test/java/org/switchyard/deploy/internal/DeploymentTest.java +++ b/deploy/base/src/test/java/org/switchyard/deploy/internal/DeploymentTest.java @@ -37,8 +37,10 @@ import org.switchyard.common.type.Classes; import org.switchyard.config.model.composite.BindingModel; import org.switchyard.config.model.composite.ComponentImplementationModel; +import org.switchyard.config.model.composite.CompositeServiceModel; import org.switchyard.config.model.switchyard.EsbInterfaceModel; import org.switchyard.deploy.ActivatorLoader; +import org.switchyard.deploy.Lifecycle; import org.switchyard.deploy.ServiceDomainManager; import org.switchyard.deploy.components.MockActivator; import org.switchyard.deploy.components.config.MockBindingModel; @@ -373,6 +375,25 @@ public void componentServiceMultiplePromotions() throws Exception { Assert.assertEquals(1, testsvcs.size()); } + /** + * Test checks binding state after deployment in case when it's marked with autoStartup=false + * @throws Exception + */ + @Test + public void testAutoStartupBindings() throws Exception { + InputStream swConfigStream = Classes.getResourceAsStream("/switchyard-config-autostartup-01.xml", getClass()); + Deployment deployment = new Deployment(swConfigStream); + swConfigStream.close(); + + MockDomain serviceDomain = new MockDomain(); + deployment.init(serviceDomain, ActivatorLoader.createActivators(serviceDomain)); + deployment.start(); + + Lifecycle.State bindingState = deployment.getGatwayLifecycle(new QName("urn:test:config-autostartup:1.0", "TestService"), "binding1") + .getState(); + Assert.assertEquals(Lifecycle.State.NONE, bindingState); + } + @Test public void testDuplicateReference() throws Exception { deployWithFail("/naming/duplicate-reference.xml"); diff --git a/deploy/base/src/test/resources/switchyard-config-autostartup-01.xml b/deploy/base/src/test/resources/switchyard-config-autostartup-01.xml new file mode 100644 index 000000000..3b83b24ec --- /dev/null +++ b/deploy/base/src/test/resources/switchyard-config-autostartup-01.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + +