Author: vhalbert(a)redhat.com
Date: 2009-04-15 15:36:14 -0400 (Wed, 15 Apr 2009)
New Revision: 779
Modified:
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/model/BasicDeployedComponent.java
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLConfig_ElementNames.java
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLHelperImpl.java
branches/remove_psc/common-internal/src/test/java/com/metamatrix/common/config/xml/TestXMLConfigurationImportExportUtility.java
branches/remove_psc/common-internal/src/test/resources/config-original.xml
Log:
Teiid 323 - the import/export of the configuration needed to add the properties for the
deployed service so that is supports the enabled option in the console
Modified:
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/model/BasicDeployedComponent.java
===================================================================
---
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/model/BasicDeployedComponent.java 2009-04-15
17:35:54 UTC (rev 778)
+++
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/model/BasicDeployedComponent.java 2009-04-15
19:36:14 UTC (rev 779)
@@ -51,6 +51,8 @@
*/
public class BasicDeployedComponent extends BasicComponentObject implements
DeployedComponent, Serializable {
+ private static final String ENABLED="component.enabled";
+
private ConfigurationID configurationID;
/**
@@ -72,8 +74,6 @@
* @clientCardinality 1
*/
private VMComponentDefnID vmComponentID;
-
- private boolean isEnabled;
/**
* Constructor takes a <code>ComponentID, HostID, </code> and
<code> Collection </code> of system components to declare a component as being
deployed.
@@ -107,14 +107,22 @@
if (deployedComponent.getServiceComponentDefnID() != null) {
this.componentID = deployedComponent.getServiceComponentDefnID();
}
+ this.addProperties(deployedComponent.getEditableProperties());
}
+
+
public boolean isEnabled() {
- return this.isEnabled;
+ String enabled = this.getProperty(ENABLED);
+ if (enabled == null || enabled.trim().length() == 0) {
+ return true;
+ }
+ return (new Boolean(enabled).booleanValue());
+
}
public void setIsEnabled(boolean enable) {
- this.isEnabled = enable;
+ this.addProperty(ENABLED, new Boolean(enable).toString());
}
/**
Modified:
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLConfig_ElementNames.java
===================================================================
---
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLConfig_ElementNames.java 2009-04-15
17:35:54 UTC (rev 778)
+++
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLConfig_ElementNames.java 2009-04-15
19:36:14 UTC (rev 779)
@@ -302,179 +302,84 @@
}
-
- /**
- * This is the class that represents the ConfigurationInfo Element which contains
- * all of the XML elements that represent a ConfigurationInfo object.
- */
- public static class ConfigurationInfo {
-
- /**
- * This is the name of the ServiceComponentDefnID Element.
- */
- public static final String ELEMENT = "ConfigurationInfo"; //$NON-NLS-1$
-
- /**
- * This class defines the Attributes of the Element class that
- * contains it.
- */
- public static class Attributes {
- public static final String LAST_CHANGED_DATE = "LastChangedDate";
//$NON-NLS-1$
- public static final String CREATION_DATE = "CreationDate";
//$NON-NLS-1$
- }
- }
/**
* This is the class that represents the LogConfiguration Element which contains
* all of the XML elements that represent a LogConfiguration object.
*/
- public static class LogConfiguration {
-
- /**
- * This is the name of the LogConfiguration Element.
- */
- public static final String ELEMENT = "LogConfiguration"; //$NON-NLS-1$
-
- }
+// public static class LogConfiguration {
+//
+// /**
+// * This is the name of the LogConfiguration Element.
+// */
+// public static final String ELEMENT = "LogConfiguration"; //$NON-NLS-1$
+//
+// }
/**
* This is the class that represents the VMComponentDefns Element which contains
* all of the XML elements that represent a VMComponentDefns object.
*/
- public static class VMComponentDefns {
-
- /**
- * This is the name of the VMComponentDefns Element.
- */
- public static final String ELEMENT = Configuration.ELEMENT + DELIMITER
+"VMComponentDefns"; //$NON-NLS-1$
-
- /**
- * This is the class that represents the VMComponentDefn Element which contains
- * all of the XML elements that represent a VMComponentDefn object.
- */
- public static class VMComponentDefn {
-
- /**
- * This is the name of the VMComponentDefn Element.
- */
- public static final String ELEMENT = "VMComponentDefn"; //$NON-NLS-1$
-
- /**
- * This class defines the Attributes of the Element class that
- * contains it. Note that this class just inherits its attributes
- * from its configuration object superclass.
- */
- public static class Attributes extends ComponentObject.Attributes{
- }
- }
- }
+// public static class VMComponentDefns {
+//
+// /**
+// * This is the name of the VMComponentDefns Element.
+// */
+// public static final String ELEMENT = Configuration.ELEMENT + DELIMITER
+"VMComponentDefns"; //$NON-NLS-1$
+//
+// /**
+// * This is the class that represents the VMComponentDefn Element which contains
+// * all of the XML elements that represent a VMComponentDefn object.
+// */
+// public static class VMComponentDefn {
+//
+// /**
+// * This is the name of the VMComponentDefn Element.
+// */
+// public static final String ELEMENT = "VMComponentDefn";
//$NON-NLS-1$
+//
+// /**
+// * This class defines the Attributes of the Element class that
+// * contains it. Note that this class just inherits its attributes
+// * from its configuration object superclass.
+// */
+// public static class Attributes extends ComponentObject.Attributes{
+// }
+// }
+// }
- /**
- * This is the class that represents the ProductServiceConfigID Element which
contains
- * all of the XML elements that represent a ProductServiceConfigID object.
- */
- // public static final class ProductServiceConfigID{
- //
- // /**
- // * This is the name of the ProductServiceConfigID Element.
- // */
- // public static final String ELEMENT =
"ProductServiceConfigID"; //$NON-NLS-1$
- //
- // /**
- // * This class defines the Attributes of the Element class that
- // * contains it. Note that this class just inherits its attributes
- // * from its configuration object superclass.
- // */
- // public static class Attributes extends ID.Attributes {
- // }
- // }
/**
* This is the class that represents the VMComponentDefnID Element which
contains
* all of the XML elements that represent a VMComponentDefnID object.
*/
- public static final class VMComponentDefnID{
-
- /**
- * This is the name of the VMComponentDefnID Element.
- */
- public static final String ELEMENT = "VMComponentDefnID";
//$NON-NLS-1$
-
- /**
- * This class defines the Attributes of the Element class that
- * contains it. Note that this class just inherits its attributes
- * from its configuration object superclass.
- */
- public static class Attributes extends ID.Attributes {
- }
- }
+// public static final class VMComponentDefnID{
+//
+// /**
+// * This is the name of the VMComponentDefnID Element.
+// */
+// public static final String ELEMENT = "VMComponentDefnID";
//$NON-NLS-1$
+//
+// /**
+// * This class defines the Attributes of the Element class that
+// * contains it. Note that this class just inherits its attributes
+// * from its configuration object superclass.
+// */
+// public static class Attributes extends ID.Attributes {
+// }
+// }
- /**
- * This is the class that represents the VMComponentDefnID Element which contains
- * all of the XML elements that represent a VMComponentDefnID object.
- */
-// public static final class ServiceComponentDefnID{
-//
-// /**
-// * This is the name of the ServiceComponentDefnID Element.
-// */
-// public static final String ELEMENT = "ServiceComponentDefnID";
//$NON-NLS-1$
-//
-// /**
-// * This class defines the Attributes of the Element class that
-// * contains it. Note that this class just inherits its attributes
-// * from its configuration object superclass.
-// */
-// public static class Attributes extends ID.Attributes {
-// }
-// }
/**
- * This is the class that represents the DeployedComponents Element which
contains
- * all of the XML elements that represent a DeployedComponents object.
- */
-// public static class DeployedComponents {
-//
-// /**
-// * This is the name of the DeployedComponents Element.
-// */
-// public static final String ELEMENT = Configuration.ELEMENT +
DELIMITER + "DeployedComponents"; //$NON-NLS-1$
-//
-// /**
-// * This is the class that represents the DeployedComponent Element
which contains
-// * all of the XML elements that represent a DeployedComponent
object.
-// */
-// public static class DeployedComponent {
-//
-// /**
-// * This is the name of the DeployedComponent Element.
-// */
-// public static final String ELEMENT =
"DeployedComponent"; //$NON-NLS-1$
-//
-// /**
-// * This class defines the Attributes of the Element class that
-// * contains it. Note that this class just inherits its
attributes
-// * from its configuration object superclass.
-// */
-// public static class Attributes extends
ComponentObject.Attributes{
-// public static final String HOST_ID = "HostID";
//$NON-NLS-1$
-// // public static final String PRODUCT_SERVICE_CONFIG_ID =
"ProductServiceConfigID"; //$NON-NLS-1$
-// public static final String SERVICE_COMPONENT_DEFN_ID =
"ServiceComponentDefnID"; //$NON-NLS-1$
-// public static final String VM_COMPONENT_DEFN_ID =
"VMComponentDefnID"; //$NON-NLS-1$
-// }
-// }
-// }
-
- /**
- * This is the class that represents the DeployedComponentID Element which contains
- * all of the XML elements that represent a DeployedComponentID object.
+ * This is the class that represents the HostID Element which contains
+ * all of the XML elements that represent a HostID object.
*/
-// public static final class DeployedComponentID{
+// public static final class HostID {
//
// /**
-// * This is the name of the DeployedComponentID Element.
+// * This is the name of the HostID Element.
// */
-// public static final String ELEMENT = "DeployedComponentID";
//$NON-NLS-1$
+// public static final String ELEMENT = "HostID"; //$NON-NLS-1$
//
// /**
// * This class defines the Attributes of the Element class that
@@ -485,26 +390,6 @@
// }
// }
- /**
- * This is the class that represents the HostID Element which contains
- * all of the XML elements that represent a HostID object.
- */
- public static final class HostID {
-
- /**
- * This is the name of the HostID Element.
- */
- public static final String ELEMENT = "HostID"; //$NON-NLS-1$
-
- /**
- * This class defines the Attributes of the Element class that
- * contains it. Note that this class just inherits its attributes
- * from its configuration object superclass.
- */
- public static class Attributes extends ID.Attributes {
- }
- }
-
public static class DeployedService {
/**
@@ -539,33 +424,8 @@
public static class Attributes extends ComponentObject.Attributes{
}
- }
-
- /**
- * This is the class that represents the DeployedComponent Element which
contains
- * all of the XML elements that represent a DeployedComponent object.
- */
- public static class xDeployedComponent {
-
- /**
- * This is the name of the DeployedComponent Element.
- */
- public static final String ELEMENT = "DeployedService";
//$NON-NLS-1$
-
- /**
- * This class defines the Attributes of the Element class that
- * contains it. Note that this class just inherits its attributes
- * from its configuration object superclass.
- */
- public static class Attributes extends ComponentObject.Attributes{
- public static final String HOST_ID = "HostID";
//$NON-NLS-1$
- // public static final String PRODUCT_SERVICE_CONFIG_ID =
"ProductServiceConfigID"; //$NON-NLS-1$
- public static final String SERVICE_COMPONENT_DEFN_ID =
"ServiceComponentDefnID"; //$NON-NLS-1$
- public static final String VM_COMPONENT_DEFN_ID =
"VMComponentDefnID"; //$NON-NLS-1$
- }
- }
+ }
-
}
@@ -574,22 +434,22 @@
* This is the class that represents the ComponentTypeID Element which contains
* all of the XML elements that represent a ComponentTypeID object.
*/
- public static class ComponentTypeID {
-
- /**
- * This is the name of the ComponentTypeID Element.
- */
- public static final String ELEMENT = "ComponentTypeID"; //$NON-NLS-1$
-
- /**
- * This class defines the Attributes of the Element class that
- * contains it. Note that this class just inherits its attributes
- * from its configuration object superclass.
- */
- public static class Attributes extends ID.Attributes {
- }
-
- }
+// public static class ComponentTypeID {
+//
+// /**
+// * This is the name of the ComponentTypeID Element.
+// */
+// public static final String ELEMENT = "ComponentTypeID"; //$NON-NLS-1$
+//
+// /**
+// * This class defines the Attributes of the Element class that
+// * contains it. Note that this class just inherits its attributes
+// * from its configuration object superclass.
+// */
+// public static class Attributes extends ID.Attributes {
+// }
+//
+// }
Modified:
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLHelperImpl.java
===================================================================
---
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLHelperImpl.java 2009-04-15
17:35:54 UTC (rev 778)
+++
branches/remove_psc/common-internal/src/main/java/com/metamatrix/common/config/xml/XMLHelperImpl.java 2009-04-15
19:36:14 UTC (rev 779)
@@ -512,12 +512,12 @@
return hostElement;
}
- public Element createDeployedVMElementx(DeployedComponent vm) {
- Assertion.isNotNull(vm);
-
- Element hostElement =
createComponentObjectElement(XMLConfig_ElementNames.Configuration.Host.ELEMENT, vm,
true);
- return hostElement;
- }
+// public Element createDeployedVMElementx(DeployedComponent vm) {
+// Assertion.isNotNull(vm);
+//
+// Element hostElement =
createComponentObjectElement(XMLConfig_ElementNames.Configuration.Host.ELEMENT, vm,
true);
+// return hostElement;
+// }
// public final boolean is42ConfigurationCompatible(Element root) throws
InvalidConfigurationElementException{
// Element headerElement = root.getChild(XMLConfig_ElementNames.Header.ELEMENT);
@@ -1049,7 +1049,11 @@
// this will add the changed history information
if (componentObject instanceof DeployedComponent) {
- // don't write the properties for the deployed component
+ Properties props = componentObject.getProperties();
+ if (props != null && ! props.isEmpty()) {
+ Element properties = createPropertiesElement( props);
+ componentObjectElement.addContent(properties);
+ }
} else {
Element properties = createPropertiesElement(
componentObject.getProperties());
componentObjectElement.addContent(properties);
@@ -1871,7 +1875,8 @@
}
ServiceComponentDefnID svcid = null;
- if (type.getComponentTypeCode() == ComponentType.CONNECTOR_COMPONENT_TYPE_CODE)
{
+ if (type.isOfTypeConnector()) {
+ // type.getComponentTypeCode() == ComponentType.CONNECTOR_COMPONENT_TYPE_CODE)
{
svcid = new ConnectorBindingID(configID, name);
@@ -1883,8 +1888,8 @@
}
component = editor.createDeployedServiceComponent(name, configID, hostID,vmID,
svcid, (ComponentTypeID) type.getID());
+ component = (DeployedComponent)addProperties(element, component, editor);
-
component = (DeployedComponent) setDateHistory(component, element, editor);
@@ -2291,7 +2296,9 @@
if
(!propertiesElement.getName().equals(XMLConfig_ElementNames.Properties.ELEMENT)) {
propertiesElement =
propertiesElement.getChild(XMLConfig_ElementNames.Properties.ELEMENT);
- }
+ }
+
+
Properties props = null;
if (propertiesElement == null) {
Modified:
branches/remove_psc/common-internal/src/test/java/com/metamatrix/common/config/xml/TestXMLConfigurationImportExportUtility.java
===================================================================
---
branches/remove_psc/common-internal/src/test/java/com/metamatrix/common/config/xml/TestXMLConfigurationImportExportUtility.java 2009-04-15
17:35:54 UTC (rev 778)
+++
branches/remove_psc/common-internal/src/test/java/com/metamatrix/common/config/xml/TestXMLConfigurationImportExportUtility.java 2009-04-15
19:36:14 UTC (rev 779)
@@ -27,6 +27,7 @@
import java.io.FileOutputStream;
import java.io.InputStream;
import java.util.Collection;
+import java.util.Iterator;
import java.util.Properties;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
@@ -39,10 +40,12 @@
import com.metamatrix.common.config.api.ConnectorArchive;
import com.metamatrix.common.config.api.ConnectorBinding;
import com.metamatrix.common.config.api.ConnectorBindingType;
+import com.metamatrix.common.config.api.DeployedComponent;
import com.metamatrix.common.config.api.ExtensionModule;
import com.metamatrix.common.config.api.VMComponentDefn;
import com.metamatrix.common.config.model.BasicConfigurationObjectEditor;
import com.metamatrix.common.config.model.BasicConnectorArchive;
+import com.metamatrix.common.config.model.BasicDeployedComponent;
import com.metamatrix.common.config.model.BasicExtensionModule;
import com.metamatrix.common.config.model.ConfigurationModelContainerAdapter;
import com.metamatrix.common.config.util.ConfigurationImportExportUtility;
@@ -403,6 +406,22 @@
fail("Didnt find 6 deployed services for VM " + vm.getName());
}
+ boolean isenabled = false;
+ for (Iterator<DeployedComponent> it=depsvcs.iterator(); it.hasNext();)
{
+ DeployedComponent dc = it.next();
+ if (!dc.isEnabled()) {
+ if (dc.getName().equalsIgnoreCase("QueryService")) {
+ isenabled = true;
+ BasicDeployedComponent bdc = (BasicDeployedComponent) dc;
+ bdc.setIsEnabled(true);
+ }
+
+ }
+ }
+ if (! isenabled) {
+ fail("Did not find the QueryService deployed service that wase
enabled");
+ }
+
String fileToExport = UnitTestUtil.getTestScratchPath() +
("/exported_config.xml");
cma.writeConfigurationModel(fileToExport, configModel,
"TestCase");
@@ -411,7 +430,23 @@
// try reloading what was written to confirm
configModel = cma.readConfigurationModel(fileToExport,
Configuration.NEXT_STARTUP_ID);
+ depsvcs = configModel.getConfiguration().getDeployedServicesForVM(vm);
+ if (depsvcs == null || depsvcs.size() != 6) {
+ fail("Didnt find 6 deployed services for VM " + vm.getName());
+ }
+
+ isenabled = false;
+ for (Iterator<DeployedComponent> it=depsvcs.iterator(); it.hasNext();)
{
+ DeployedComponent dc = it.next();
+ if ( dc.getName().equalsIgnoreCase("QueryService")) {
+ if (!dc.isEnabled()) {
+ fail("Update to change enabled status to true did not work");
+ }
+ }
+
+ }
+
}
}
Modified: branches/remove_psc/common-internal/src/test/resources/config-original.xml
===================================================================
--- branches/remove_psc/common-internal/src/test/resources/config-original.xml 2009-04-15
17:35:54 UTC (rev 778)
+++ branches/remove_psc/common-internal/src/test/resources/config-original.xml 2009-04-15
19:36:14 UTC (rev 779)
@@ -77,9 +77,17 @@
</Properties>
<DeployedService Name="MembershipService"
ComponentType="MembershipService" LastChangedBy="ConfigurationStartup"
CreatedBy="ConfigurationStartup" />
<DeployedService Name="SessionService"
ComponentType="SessionService" LastChangedBy="ConfigurationStartup"
CreatedBy="ConfigurationStartup" />
- <DeployedService Name="AuthorizationService"
ComponentType="AuthorizationService"
LastChangedBy="ConfigurationStartup" CreatedBy="ConfigurationStartup"
/>
+ <DeployedService Name="AuthorizationService"
ComponentType="AuthorizationService"
LastChangedBy="ConfigurationStartup" CreatedBy="ConfigurationStartup"
>
+ <Properties>
+ <Property
Name="component.enabled">true</Property>
+ </Properties>
+ </DeployedService>
<DeployedService Name="ConfigurationService"
ComponentType="ConfigurationService"
LastChangedBy="ConfigurationStartup" CreatedBy="ConfigurationStartup"
/>
- <DeployedService Name="QueryService"
ComponentType="QueryService" LastChangedBy="ConfigurationStartup"
CreatedBy="ConfigurationStartup" />
+ <DeployedService Name="QueryService"
ComponentType="QueryService" LastChangedBy="ConfigurationStartup"
CreatedBy="ConfigurationStartup" >
+ <Properties>
+ <Property Name="component.enabled">false</Property>
+ </Properties>
+ </DeployedService>
<DeployedService Name="RuntimeMetadataService"
ComponentType="RuntimeMetadataService"
LastChangedBy="ConfigurationStartup" CreatedBy="ConfigurationStartup"
/>
</Process>
</Host>
@@ -172,8 +180,10 @@
</ComponentType>
<ComponentType Name="Host" ComponentTypeCode="7"
Deployable="true" Deprecated="false" Monitorable="false"
ParentComponentType="Configuration"
LastChangedBy="ConfigurationStartup"
LastChangedDate="2008-10-31T10:26:19.950-06:00"
CreatedBy="ConfigurationStartup"
CreationDate="2008-10-31T10:26:19.950-06:00">
</ComponentType>
- <ComponentType Name="DeployedComponent"
ComponentTypeCode="8" Deployable="false" Deprecated="false"
Monitorable="false" LastChangedBy="ConfigurationStartup"
LastChangedDate="2008-10-31T10:26:19.970-06:00"
CreatedBy="ConfigurationStartup"
CreationDate="2008-10-31T10:26:19.970-06:00" />
- <ComponentType Name="VM" ComponentTypeCode="5"
Deployable="true" Deprecated="false" Monitorable="false"
ParentComponentType="Host" LastChangedBy="ConfigurationStartup"
LastChangedDate="2008-10-31T10:26:19.944-06:00"
CreatedBy="ConfigurationStartup"
CreationDate="2008-10-31T10:26:19.944-06:00">
+ <ComponentType Name="DeployedComponent"
ComponentTypeCode="8" Deployable="false" Deprecated="false"
Monitorable="false" LastChangedBy="ConfigurationStartup"
LastChangedDate="2008-10-31T10:26:19.970-06:00"
CreatedBy="ConfigurationStartup"
CreationDate="2008-10-31T10:26:19.970-06:00" >
+ <PropertyDefinition Name="component.enabled"
DisplayName="Enabled Flag" ShortDescription="The enabled flag allows for
disabling of the service or connector from starting without have to remove it from
deployment." DefaultValue="true" Multiplicity="1"
PropertyType="Boolean" />
+ </ComponentType>
+ <ComponentType Name="VM" ComponentTypeCode="5"
Deployable="true" Deprecated="false" Monitorable="false"
ParentComponentType="Host" LastChangedBy="ConfigurationStartup"
LastChangedDate="2008-10-31T10:26:19.944-06:00"
CreatedBy="ConfigurationStartup"
CreationDate="2008-10-31T10:26:19.944-06:00">
<PropertyDefinition Name="vm.starter.cmd.java_opts"
DisplayName="Java Options" ShortDescription="These are the java options
passed in before the main class" DefaultValue="-server
-Djava.io.tmpdir=${metamatrix.host.dir}/data/tmp -ms${vm.starter.minHeapSize}m
-mx${vm.starter.maxHeapSize}m" />
<PropertyDefinition Name="vm.enabled" DisplayName="Start
Enabled Flag" ShortDescription="The enabled flag allows for disabling the VM
from starting without have to remove it from deployment."
DefaultValue="true" Multiplicity="1" PropertyType="Boolean"
/>
<PropertyDefinition Name="vm.timetolive"
DisplayName="Socket Worker Thread Time-To-Live (ms)"
ShortDescription="Time-to-live (in milliseconds) for threads used to do work on
client requests." DefaultValue="30000" />