Author: rareddy
Date: 2009-05-05 15:09:01 -0400 (Tue, 05 May 2009)
New Revision: 864
Removed:
trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/ConfigTransactionException.java
Modified:
trunk/common-internal/src/main/java/com/metamatrix/common/config/CurrentConfiguration.java
trunk/common-internal/src/main/java/com/metamatrix/common/config/api/ConfigurationObjectEditor.java
trunk/common-internal/src/main/java/com/metamatrix/common/config/api/VMComponentDefnType.java
trunk/common-internal/src/main/java/com/metamatrix/common/config/model/BasicConfigurationObjectEditor.java
trunk/common-internal/src/main/resources/com/metamatrix/common/config/api/resourcetypemodel.xml
trunk/server/src/main/java/com/metamatrix/admin/server/ServerConfigAdminImpl.java
trunk/server/src/main/java/com/metamatrix/metadata/runtime/vdb/defn/VDBCreation.java
trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/RuntimeStateAdminAPIHelper.java
trunk/server/src/main/java/com/metamatrix/platform/config/api/service/ConfigurationServiceInterface.java
trunk/server/src/main/java/com/metamatrix/platform/config/service/ConfigurationServiceImpl.java
trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/XMLActionUpdateStrategy.java
trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/XMLConfigurationConnector.java
trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/XMLConfigurationMgr.java
trunk/server/src/main/java/com/metamatrix/server/Configuration.java
trunk/server/src/main/java/com/metamatrix/server/HostController.java
trunk/server/src/main/java/com/metamatrix/server/HostControllerGuiceModule.java
trunk/server/src/main/java/com/metamatrix/server/JGroupsProvider.java
trunk/server/src/main/java/com/metamatrix/server/ServerGuiceModule.java
trunk/server/src/test/java/com/metamatrix/admin/server/FakeConfigurationService.java
trunk/server/src/test/java/com/metamatrix/platform/config/spi/xml/TestXMLConfigImportExport.java
trunk/server/src/test/java/com/metamatrix/platform/config/spi/xml/TestXMLConfigReader.java
Log:
TEIID-233 - Adding support for TCP based clustering for server. Reviewed By VanH.
Modified:
trunk/common-internal/src/main/java/com/metamatrix/common/config/CurrentConfiguration.java
===================================================================
---
trunk/common-internal/src/main/java/com/metamatrix/common/config/CurrentConfiguration.java 2009-05-05
18:01:19 UTC (rev 863)
+++
trunk/common-internal/src/main/java/com/metamatrix/common/config/CurrentConfiguration.java 2009-05-05
19:09:01 UTC (rev 864)
@@ -22,6 +22,7 @@
package com.metamatrix.common.config;
+import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.net.InetAddress;
@@ -81,11 +82,13 @@
public static final String BOOTSTRAP_FILE_NAME = "teiid.properties";
//$NON-NLS-1$
public static final String CONFIGURATION_READER_CLASS_PROPERTY_NAME =
"metamatrix.config.reader"; //$NON-NLS-1$
- public static final String CLUSTER_NAME = "metamatrix.cluster.name";
//$NON-NLS-1$
+ public static final String CLUSTER_NAME = "cluster.name"; //$NON-NLS-1$
public static final String CONFIGURATION_NAME= "configuration.name";
//$NON-NLS-1$
+ public static final String CLUSTER_MEMBERS = "cluster.unicast.members";
//$NON-NLS-1$
private CurrentConfigurationReader reader;
private Properties bootstrapProperties;
+ private Properties modifyableBootstrapProperties;
private Properties systemBootstrapProperties;
private String bindAddress;
private InetAddress hostAddress;
@@ -137,6 +140,17 @@
} catch (UnknownHostException e) {
throw new RuntimeException(e);
}
+
+ // these properties will be used to identify the server in TCP based cluster setup.
+ String unicastMembers = bootstrapProperties.getProperty(CLUSTER_MEMBERS);
+ if (unicastMembers == null) {
+ unicastMembers =
this.configurationName+"|"+this.hostAddress.getCanonicalHostName();
//$NON-NLS-1$
+ }
+ else {
+ unicastMembers =
unicastMembers+","+this.configurationName+"|"+this.hostAddress.getCanonicalHostName();
//$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ modifyableBootstrapProperties.setProperty(CLUSTER_MEMBERS, unicastMembers);
}
public boolean isAvailable() {
@@ -350,6 +364,7 @@
} catch (IOException e ) {
}
}
+ modifyableBootstrapProperties = bootstrapProps;
bootstrapProperties = new UnmodifiableProperties(bootstrapProps);
}
return bootstrapProperties;
Modified:
trunk/common-internal/src/main/java/com/metamatrix/common/config/api/ConfigurationObjectEditor.java
===================================================================
---
trunk/common-internal/src/main/java/com/metamatrix/common/config/api/ConfigurationObjectEditor.java 2009-05-05
18:01:19 UTC (rev 863)
+++
trunk/common-internal/src/main/java/com/metamatrix/common/config/api/ConfigurationObjectEditor.java 2009-05-05
19:09:01 UTC (rev 864)
@@ -606,24 +606,6 @@
ComponentTypeDefn setPropertyDefinition(ComponentTypeDefn t, PropertyDefinition
defn);
- /**
- * Call to set the specified configuration as the next startup configuration,
- * to use after a system reboot.
- * @param configurationID for the <code>Configuration</code> to use on
the next system reboot.
- * @throws ConfigurationException if an error occurred within or during communication
with the Configuration Service.
- * @deprecated as of v 2.0 beta 1, use {@link #setNextStartupConfiguration}
- */
- void setBootStrapConfiguration(ConfigurationID configurationID) throws
ConfigurationException;
-
-
- /**
- * Sets the system next startup configuration
- * @param configurationID for the <code>Configuration</code> to use on
the next system reboot.
- * @throws ConfigurationException if an error occurred within or during communication
with the Configuration Service.
- */
- void setNextStartupConfiguration(ConfigurationID configurationID) throws
ConfigurationException;
-
-
//
----------------------------------------------------------------------------------
// D E L E T E M E T H O D S
//
----------------------------------------------------------------------------------
Modified:
trunk/common-internal/src/main/java/com/metamatrix/common/config/api/VMComponentDefnType.java
===================================================================
---
trunk/common-internal/src/main/java/com/metamatrix/common/config/api/VMComponentDefnType.java 2009-05-05
18:01:19 UTC (rev 863)
+++
trunk/common-internal/src/main/java/com/metamatrix/common/config/api/VMComponentDefnType.java 2009-05-05
19:09:01 UTC (rev 864)
@@ -36,6 +36,7 @@
/**
* @see SocketVMController
*/
+ public static final String CLUSTER_PORT = "vm.unicast.port"; //$NON-NLS-1$
public static final String SERVER_PORT =
com.metamatrix.admin.api.objects.ProcessObject.SERVER_PORT;
public static final String MAX_THREADS =
com.metamatrix.admin.api.objects.ProcessObject.MAX_THREADS;
public static final String TIMETOLIVE =
com.metamatrix.admin.api.objects.ProcessObject.TIMETOLIVE;
Modified:
trunk/common-internal/src/main/java/com/metamatrix/common/config/model/BasicConfigurationObjectEditor.java
===================================================================
---
trunk/common-internal/src/main/java/com/metamatrix/common/config/model/BasicConfigurationObjectEditor.java 2009-05-05
18:01:19 UTC (rev 863)
+++
trunk/common-internal/src/main/java/com/metamatrix/common/config/model/BasicConfigurationObjectEditor.java 2009-05-05
19:09:01 UTC (rev 864)
@@ -2219,21 +2219,6 @@
}
/**
- * Sets the system next startup configuration
- * @deprecated as of v 2.0 beta 1, use {@link #setNextStartupConfiguration}
- */
- public void setBootStrapConfiguration(ConfigurationID configurationID) throws
ConfigurationException {
- this.createExchangeAction(configurationID,
ConfigurationModel.Attribute.NEXT_STARTUP_CONFIGURATION, configurationID,
configurationID);
- }
-
- /**
- * Sets the system next startup configuration
- */
- public void setNextStartupConfiguration(ConfigurationID configurationID) throws
ConfigurationException {
- this.createExchangeAction(configurationID,
ConfigurationModel.Attribute.NEXT_STARTUP_CONFIGURATION, configurationID,
configurationID);
- }
-
- /**
* Set the list of <code>ComponentTypeDefn</code>s for a local
ComponentType
* object. This method will not generate actions because the definitions
* should have been created using the
Modified:
trunk/common-internal/src/main/resources/com/metamatrix/common/config/api/resourcetypemodel.xml
===================================================================
---
trunk/common-internal/src/main/resources/com/metamatrix/common/config/api/resourcetypemodel.xml 2009-05-05
18:01:19 UTC (rev 863)
+++
trunk/common-internal/src/main/resources/com/metamatrix/common/config/api/resourcetypemodel.xml 2009-05-05
19:09:01 UTC (rev 864)
@@ -42,14 +42,16 @@
<PropertyDefinition Name="metamatrix.xatxnmgr.txnstatus_port"
DisplayName="Recovery Port" ShortDescription="Transaction Recovery Port
(0-any available port)" DefaultValue="" Multiplicity="1"
PropertyType="String" ValueDelimiter=","
IsConstrainedToAllowedValues="true" IsExpert="false"
IsHidden="false" IsMasked="false" IsModifiable="true"
IsPreferred="false"/>
</ComponentType>
<ComponentType Name="JGroups" ComponentTypeCode="4"
Deployable="false" Deprecated="false"
Monitorable="false">
- <PropertyDefinition Name="udp.multicast_supported"
DisplayName="Multicast Supported" ShortDescription="Indicates if multicast
supported." DefaultValue="true" Multiplicity="1"
PropertyType="Boolean" ValueDelimiter=","
IsConstrainedToAllowedValues="true" IsExpert="false"
IsHidden="false" IsMasked="false" IsModifiable="true"
IsPreferred="true"/>
- <PropertyDefinition Name="udp.mcast_messagebus_port"
DisplayName="MessageBus Multicast Port" ShortDescription="The multicast
port number." DefaultValue="5555" Multiplicity="1"
PropertyType="Integer" ValueDelimiter=","
IsConstrainedToAllowedValues="true" IsExpert="false"
IsHidden="false" IsMasked="false" IsModifiable="true"
IsPreferred="true"/>
- <PropertyDefinition Name="udp.mcast_addr" DisplayName="Multicast
Address" ShortDescription="The multicast address."
DefaultValue="224.30.10.10" Multiplicity="1"
PropertyType="String" ValueDelimiter=","
IsConstrainedToAllowedValues="true" IsExpert="false"
IsHidden="false" IsMasked="false" IsModifiable="true"
IsPreferred="true"/>
- <PropertyDefinition Name="ping.gossip_host" DisplayName="Ping Host
Address" ShortDescription="The host address when multicast is not used."
DefaultValue="" Multiplicity="1" PropertyType="String"
ValueDelimiter="," IsConstrainedToAllowedValues="true"
IsExpert="false" IsHidden="false" IsMasked="false"
IsModifiable="true" IsPreferred="true"/>
- <PropertyDefinition Name="ping.gossip_port" DisplayName="Ping Host
Port" ShortDescription="The host port when multicast is not used."
DefaultValue="5555" Multiplicity="1" PropertyType="Integer"
ValueDelimiter="," IsConstrainedToAllowedValues="true"
IsExpert="false" IsHidden="false" IsMasked="false"
IsModifiable="true" IsPreferred="true"/>
- <PropertyDefinition Name="ping.gossip_refresh" DisplayName="Ping
Gossip Refresh" ShortDescription="Indicates how often the gossip server tries to
refresh." DefaultValue="15000" Multiplicity="0..1"
PropertyType="Integer" ValueDelimiter=","
IsConstrainedToAllowedValues="true" IsExpert="false"
IsHidden="false" IsMasked="false" IsModifiable="true"
IsPreferred="true"/>
- <PropertyDefinition Name="ping.gossip_timout" DisplayName="Ping
Gossip Timeout" ShortDescription="Indicates how soon the gossip server will
timeout." DefaultValue="2000" Multiplicity="0..1"
PropertyType="Integer" ValueDelimiter=","
IsConstrainedToAllowedValues="true" IsExpert="false"
IsHidden="false" IsMasked="false" IsModifiable="true"
IsPreferred="true"/>
- <PropertyDefinition Name="ping.gossip_initialmembers"
DisplayName="Ping Gossip Initial Num Mbrs" ShortDescription="Indicates the
initial size of members to be joined." DefaultValue="3"
Multiplicity="0..1" PropertyType="Integer"
ValueDelimiter="," IsConstrainedToAllowedValues="true"
IsExpert="false" IsHidden="false" IsMasked="false"
IsModifiable="true" IsPreferred="true"/>
+ <PropertyDefinition Name="cluster.protocol" DisplayName="Cluster
Protocol Type" ShortDescription="Type of protocol to be used (Unicast or
Multicast)" DefaultValue="UNICAST-TCP" Multiplicity="1"
PropertyType="String" IsConstrainedToAllowedValues="true"
ValueDelimiter="," IsConstrainedToAllowedValues="true"
IsExpert="false" IsHidden="false" IsMasked="false"
IsModifiable="true" IsPreferred="true">
+ <AllowedValue>MULTICAST</AllowedValue>
+ <AllowedValue>UNICAST_TCP</AllowedValue>
+ <AllowedValue>UNICAST_UDP</AllowedValue>
+ </PropertyDefinition>
+ <PropertyDefinition Name="cluster.port"
DisplayName="Cluster Port" ShortDescription="The multicast or unicast port
number" DefaultValue="5555" Multiplicity="1"
PropertyType="Integer" ValueDelimiter=","
IsConstrainedToAllowedValues="true" IsExpert="false"
IsHidden="false" IsMasked="false" IsModifiable="true"
IsPreferred="true"/>
+ <PropertyDefinition Name="cluster.name"
DisplayName="Cluster Name" ShortDescription="The Name of the cluster"
Multiplicity="1" PropertyType="Integer" ValueDelimiter=","
IsConstrainedToAllowedValues="true" IsExpert="false"
IsHidden="false" IsMasked="false" IsModifiable="true"
IsPreferred="true"/>
+ <PropertyDefinition Name="cluster.multicast.address"
DisplayName="Cluster Address (multicast)" ShortDescription="The multicast
address" Multiplicity="1" PropertyType="String"
ValueDelimiter="," IsConstrainedToAllowedValues="true"
IsExpert="false" IsHidden="false" IsMasked="false"
IsModifiable="true" IsPreferred="true"/>
+ <PropertyDefinition Name="cluster.unicast.ping" DisplayName="Cluster
Ping Intervel(unicast)" ShortDescription="Indicates how often the gossip server
tries to refresh." DefaultValue="15000" Multiplicity="0..1"
PropertyType="Integer" ValueDelimiter=","
IsConstrainedToAllowedValues="true" IsExpert="false"
IsHidden="false" IsMasked="false" IsModifiable="true"
IsPreferred="true"/>
+ <PropertyDefinition Name="cluster.unicast.timout"
DisplayName="Cluster Ping Timeout(unicast)" ShortDescription="Indicates how
soon the gossip server will timeout." DefaultValue="2000"
Multiplicity="0..1" PropertyType="Integer"
ValueDelimiter="," IsConstrainedToAllowedValues="true"
IsExpert="false" IsHidden="false" IsMasked="false"
IsModifiable="true" IsPreferred="true"/>
<PropertyDefinition Name="jgroups.other.channel.settings"
DisplayName="JGroups Other Settings" ShortDescription="This is the
additional settings when creating the JGroups Channel."
DefaultValue="MERGE2(min_interval=5000;max_interval=10000):FD_SOCK:VERIFY_SUSPECT(timeout=1500):pbcast.NAKACK(gc_lag=50;retransmit_timeout=300,600,1200,2400,4800):UNICAST(timeout=5000):pbcast.STABLE(desired_avg_gossip=20000):FRAG(frag_size=4096;down_thread=false;up_thread=false):pbcast.GMS(join_timeout=5000;join_retry_timeout=2000;shun=false;print_local_addr=true):pbcast.STATE_TRANSFER"
Multiplicity="0..1" PropertyType="String" ValueDelimiter=","
IsConstrainedToAllowedValues="true" IsExpert="false"
IsHidden="false" IsMasked="false" IsModifiable="true"
IsPreferred="true"/>
</ComponentType>
<ComponentType Name="SSL" ComponentTypeCode="4"
Deployable="false" Deprecated="false"
Monitorable="false">
Modified:
trunk/server/src/main/java/com/metamatrix/admin/server/ServerConfigAdminImpl.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/admin/server/ServerConfigAdminImpl.java 2009-05-05
18:01:19 UTC (rev 863)
+++
trunk/server/src/main/java/com/metamatrix/admin/server/ServerConfigAdminImpl.java 2009-05-05
19:09:01 UTC (rev 864)
@@ -447,8 +447,6 @@
throw new AdminComponentException(e);
} catch (ConfigurationException e) {
throw new AdminComponentException(e);
- } catch (ModificationException e) {
- throw new AdminComponentException(e);
}
}
@@ -634,8 +632,6 @@
throw new AdminComponentException(e);
} catch (ServiceException e) {
throw new AdminComponentException(e);
- } catch (ModificationException e) {
- throw new AdminComponentException(e);
}
}
@@ -1050,8 +1046,6 @@
throw new AdminComponentException(e);
} catch(InvalidConfigurationElementException e) {
throw new AdminComponentException(e);
- } catch(ModificationException e) {
- throw new AdminComponentException(e);
} catch (ConfigurationException e) {
throw new AdminComponentException(e);
} catch (ServiceException e) {
@@ -1522,8 +1516,6 @@
}
} catch (ConfigurationException e) {
throw new AdminComponentException(e);
- } catch (ModificationException e) {
- throw new AdminComponentException(e);
} catch (ServiceException e) {
throw new AdminComponentException(e);
}
@@ -1550,8 +1542,6 @@
throw new AdminComponentException(e);
} catch (MetaMatrixProcessingException e) {
throw new AdminProcessingException(e);
- } catch (ModificationException e) {
- throw new AdminComponentException(e);
}
break;
@@ -1575,8 +1565,6 @@
throw new AdminComponentException(e);
} catch (ServiceException e) {
throw new AdminComponentException(e);
- } catch (ModificationException e) {
- throw new AdminComponentException(e);
}
break;
@@ -1855,8 +1843,6 @@
getConfigurationServiceProxy().delete(service, false, getUserName());
} catch (ConfigurationException e) {
throw new AdminComponentException(e);
- } catch (ModificationException e) {
- throw new AdminComponentException(e);
} catch (ServiceException e) {
throw new AdminComponentException(e);
}
@@ -1871,8 +1857,6 @@
getConfigurationServiceProxy().delete(cb, false, getUserName());
} catch (ConfigurationException e) {
throw new AdminComponentException(e);
- } catch (ModificationException e) {
- throw new AdminComponentException(e);
} catch (ServiceException e) {
throw new AdminComponentException(e);
}
@@ -1894,8 +1878,6 @@
getConfigurationServiceProxy().delete(ct, getUserName());
} catch (ConfigurationException e) {
throw new AdminComponentException(e);
- } catch (ModificationException e) {
- throw new AdminComponentException(e);
} catch (ServiceException e) {
throw new AdminComponentException(e);
}
@@ -1941,8 +1923,6 @@
}
} catch (ConfigurationException e) {
throw new AdminComponentException(e);
- } catch (ModificationException e) {
- throw new AdminComponentException(e);
} catch (ServiceException e) {
throw new AdminComponentException(e);
}
@@ -2019,8 +1999,6 @@
throw new AdminComponentException(e);
} catch (MetaMatrixProcessingException e) {
throw new AdminComponentException(e);
- } catch (ModificationException e) {
- throw new AdminComponentException(e);
}
}
Modified:
trunk/server/src/main/java/com/metamatrix/metadata/runtime/vdb/defn/VDBCreation.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/metadata/runtime/vdb/defn/VDBCreation.java 2009-05-05
18:01:19 UTC (rev 863)
+++
trunk/server/src/main/java/com/metamatrix/metadata/runtime/vdb/defn/VDBCreation.java 2009-05-05
19:09:01 UTC (rev 864)
@@ -115,15 +115,11 @@
Set addedTypes = new HashSet(connectorTypes.size());
- ConfigurationModelContainer cmc =null;
-
Map reMapBinding = new HashMap(connectorBindings.size());
XMLConfigurationConnector writer = getWriter();
BasicConfigurationObjectEditor editor = new
BasicConfigurationObjectEditor(true);
- if (cmc == null) {
- cmc = CurrentConfiguration.getInstance().getConfigurationModel();
- }
+ ConfigurationModelContainer cmc =
CurrentConfiguration.getInstance().getConfigurationModel();
for (Iterator it= connectorBindings.values().iterator(); it.hasNext(); ) {
ConnectorBinding cb = (ConnectorBinding) it.next();
Modified:
trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/RuntimeStateAdminAPIHelper.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/RuntimeStateAdminAPIHelper.java 2009-05-05
18:01:19 UTC (rev 863)
+++
trunk/server/src/main/java/com/metamatrix/platform/admin/apiimpl/RuntimeStateAdminAPIHelper.java 2009-05-05
19:09:01 UTC (rev 864)
@@ -467,11 +467,7 @@
// Config svc proxy
ConfigurationServiceInterface configAdmin =
PlatformProxyHelper.getConfigurationServiceProxy(PlatformProxyHelper.ROUND_ROBIN_LOCAL);
// First set the log config in the database
- try {
- configAdmin.executeTransaction(actions, principalName);
- } catch (ModificationException e) {
- throw new MetaMatrixComponentException(e, ErrorMessageKeys.ADMIN_0084,
PlatformPlugin.Util.getString(ErrorMessageKeys.ADMIN_0084, config.getID()));
- }
+ configAdmin.executeTransaction(actions, principalName);
// Then, if the operational (current) config is effected, set logging config for
// LogManager in each VM.
Modified:
trunk/server/src/main/java/com/metamatrix/platform/config/api/service/ConfigurationServiceInterface.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/platform/config/api/service/ConfigurationServiceInterface.java 2009-05-05
18:01:19 UTC (rev 863)
+++
trunk/server/src/main/java/com/metamatrix/platform/config/api/service/ConfigurationServiceInterface.java 2009-05-05
19:09:01 UTC (rev 864)
@@ -29,7 +29,6 @@
import java.util.Set;
import com.metamatrix.common.actions.ActionDefinition;
-import com.metamatrix.common.actions.ModificationException;
import com.metamatrix.common.config.api.ComponentDefn;
import com.metamatrix.common.config.api.ComponentDefnID;
import com.metamatrix.common.config.api.ComponentObject;
@@ -114,7 +113,7 @@
* if the name of the configuration model to obtain
* @return ConfigurationModelContainer
*/
- ConfigurationModelContainer getConfigurationModel(String configName) throws
InvalidConfigurationException, ConfigurationException;
+ ConfigurationModelContainer getConfigurationModel(String configName) throws
ConfigurationException;
/**
* <p>
@@ -282,15 +281,13 @@
* @param principalName
* of the person executing the transaction
* @return the set of objects that were affected by this transaction.
- * @throws ModificationException
- * if the target of the action is invalid, or if the target object is not
a supported class of targets.
* @throws IllegalArgumentException
* if the action is null or if the result specification is invalid
* @throws ConfigurationException
* if an error occurred within or during communication with the
Configuration Service.
*/
Set executeTransaction(ActionDefinition action, String principalName )
- throws ModificationException, ConfigurationException;
+ throws ConfigurationException;
/**
* Execute a list of actions, and optionally return the set of objects or object IDs
that were affected/modified by the
@@ -301,15 +298,13 @@
* @param principalName
* of the person executing the transaction
* @return the set of objects that were affected by this transaction.
- * @throws ModificationException
- * if the target of any of the actions is invalid, or if the target
object is not a supported class of targets.
* @throws IllegalArgumentException
* if the action is null or if the result specification is invalid
* @throws ConfigurationException
* if an error occurred within or during communication with the
Configuration Service.
*/
Set executeTransaction(List actions, String principalName)
- throws ModificationException, ConfigurationException;
+ throws ConfigurationException;
/**
@@ -401,13 +396,12 @@
* @param theProperties
* @param principalName
* @return
- * @throws ModificationException
* @throws Exception
* @since 4.3
*/
public Object modify(ComponentObject theObject,
Properties theProperties,
- String principalName) throws ConfigurationException,
ModificationException;
+ String principalName) throws ConfigurationException;
/**
@@ -453,11 +447,10 @@
* @param principalName
* User Name of user who is making the change
* @throws ConfigurationException
- * @throws ModificationException
* @since 4.3
*/
public void delete(ComponentObject theObject, boolean
theDeleteDependenciesFlag,String principalName)
- throws ConfigurationException, ModificationException;
+ throws ConfigurationException;
/**
* Delete a Component Type
@@ -465,11 +458,10 @@
* @param componentType Component Type Object being deleted
* @param principalName User Name who is making the change
* @throws ConfigurationException
- * @throws ModificationException
* @since 4.3
*/
public void delete(ComponentType componentType, String principalName)
- throws ConfigurationException,ModificationException;
+ throws ConfigurationException;
/**
@@ -483,13 +475,12 @@
* @return DeployedComponent of the ServiceComponentDefns that was deployed
*
* @throws ConfigurationException
- * @throws ModificationException
* @since 6.1
*/
public DeployedComponent deployService(VMComponentDefnID theProcessID,
String serviceName,
- String principalName) throws
ConfigurationException,ModificationException;
+ String principalName) throws ConfigurationException;
Modified:
trunk/server/src/main/java/com/metamatrix/platform/config/service/ConfigurationServiceImpl.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/platform/config/service/ConfigurationServiceImpl.java 2009-05-05
18:01:19 UTC (rev 863)
+++
trunk/server/src/main/java/com/metamatrix/platform/config/service/ConfigurationServiceImpl.java 2009-05-05
19:09:01 UTC (rev 864)
@@ -39,7 +39,6 @@
import com.metamatrix.api.exception.MetaMatrixComponentException;
import com.metamatrix.api.exception.security.AuthorizationException;
import com.metamatrix.common.actions.ActionDefinition;
-import com.metamatrix.common.actions.ModificationException;
import com.metamatrix.common.config.api.ComponentDefn;
import com.metamatrix.common.config.api.ComponentDefnID;
import com.metamatrix.common.config.api.ComponentObject;
@@ -62,15 +61,18 @@
import com.metamatrix.common.config.api.exceptions.InvalidConfigurationException;
import com.metamatrix.common.config.model.BasicConfigurationObjectEditor;
import com.metamatrix.common.config.model.ComponentCryptoUtil;
+import com.metamatrix.common.config.model.ConfigurationModelContainerImpl;
import com.metamatrix.common.config.xml.XMLConfigurationImportExportUtility;
-import com.metamatrix.common.log.I18nLogManager;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.util.LogCommonConstants;
import com.metamatrix.common.util.PropertiesUtils;
import com.metamatrix.platform.PlatformPlugin;
+import com.metamatrix.platform.config.ConfigMessages;
+import com.metamatrix.platform.config.ConfigPlugin;
import com.metamatrix.platform.config.api.service.ConfigurationServiceInterface;
import com.metamatrix.platform.config.spi.xml.XMLConfigurationConnector;
import com.metamatrix.platform.config.spi.xml.XMLConfigurationMgr;
+import com.metamatrix.platform.service.ServicePlugin;
import com.metamatrix.platform.service.api.exception.ServiceException;
import com.metamatrix.platform.service.controller.AbstractService;
import com.metamatrix.platform.util.ErrorMessageKeys;
@@ -103,7 +105,7 @@
* Perform initialization and commence processing. This method is called only once.
*/
protected void initService(Properties env) throws Exception {
- I18nLogManager.logInfo(CONTEXT, LogMessageKeys.CONFIG_0002, new Object[] {
getInstanceName()});
+ LogManager.logInfo(CONTEXT,
ServicePlugin.Util.getString(LogMessageKeys.CONFIG_0002, new Object[] {
getInstanceName()}));
}
/**
@@ -143,7 +145,7 @@
* @throws ConfigurationException if an error occurred within or during communication
with the Configuration Service.
*/
public ConfigurationID getCurrentConfigurationID() throws ConfigurationException {
- return this.getDesignatedConfigurationID(Configuration.NEXT_STARTUP);
+ return Configuration.NEXT_STARTUP_ID;
}
/**
@@ -153,7 +155,7 @@
* @throws ConfigurationException if an error occurred within or during communication
with the Configuration Service.
*/
public ConfigurationID getNextStartupConfigurationID() throws ConfigurationException
{
- return this.getDesignatedConfigurationID(Configuration.NEXT_STARTUP);
+ return Configuration.NEXT_STARTUP_ID;
}
/**
@@ -163,7 +165,7 @@
* @throws ConfigurationException if an error occurred within or during communication
with the Configuration Service.
*/
public Configuration getCurrentConfiguration() throws ConfigurationException {
- return this.getDesignatedConfiguration(Configuration.NEXT_STARTUP);
+ return this.getDesignatedConfiguration();
}
/**
@@ -173,58 +175,17 @@
* @throws ConfigurationException if an error occurred within or during communication
with the Configuration Service.
*/
public Configuration getNextStartupConfiguration() throws ConfigurationException{
- return this.getDesignatedConfiguration(Configuration.NEXT_STARTUP);
+ return this.getDesignatedConfiguration();
}
- private Configuration getDesignatedConfiguration(String designation) throws
ConfigurationException {
- // Look in the cache ...
- Configuration config = null;
-
- XMLConfigurationConnector transaction = null;
- transaction = getConnection(null);
- config = transaction.getDesignatedConfiguration(designation);
-
- if (config != null) {
- LogManager.logDetail(CONTEXT, "Found " + designation + "
configuration " + config.getName()); //$NON-NLS-1$ //$NON-NLS-2$
- } else {
- throw new ConfigurationException("No " + designation + "
configuration was found"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- return config;
+ private Configuration getDesignatedConfiguration() throws ConfigurationException {
+ XMLConfigurationConnector transaction = getConnection(null);
+ return transaction.getConfigurationModel().getConfiguration();
}
- private ConfigurationID getDesignatedConfigurationID(String designation) throws
ConfigurationException {
- ConfigurationID configID = null;
- XMLConfigurationConnector transaction = null;
- transaction = getConnection(null);
- configID = transaction.getDesignatedConfigurationID(designation);
-
- if (configID != null) {
- LogManager.logTrace(CONTEXT, "Found " + designation + "
configuration id " + configID); //$NON-NLS-1$ //$NON-NLS-2$
- } else {
- throw new ConfigurationException(ErrorMessageKeys.CONFIG_0042,
PlatformPlugin.Util.getString(ErrorMessageKeys.CONFIG_0042));
- }
- return configID;
- }
-
- public ConfigurationModelContainer getConfigurationModel(String configName) throws
InvalidConfigurationException, ConfigurationException {
- // Look in the cache ...
- ConfigurationModelContainer config = null;
-
- XMLConfigurationConnector transaction = null;
- try {
- transaction = getConnection(null);
- config = transaction.getConfigurationModel(configName);
-
- if (config == null) {
- LogManager.logTrace(CONTEXT, "No configuration model found");
//$NON-NLS-1$
- }
-
- }catch ( Exception e ) {
- throw new ConfigurationException(e,ErrorMessageKeys.CONFIG_0043,
PlatformPlugin.Util.getString(ErrorMessageKeys.CONFIG_0043));
- }
- return config;
-
+ public ConfigurationModelContainer getConfigurationModel(String configName) throws
ConfigurationException {
+ XMLConfigurationConnector transaction = getConnection(null);
+ return transaction.getConfigurationModel();
}
/**
@@ -276,18 +237,7 @@
* @throws ConfigurationException if an error occurred within or during communication
with the Configuration Service.
*/
public Collection getConfigurationAndDependents(ConfigurationID configID) throws
ConfigurationException {
- if ( configID == null) {
- throw new
IllegalArgumentException(PlatformPlugin.Util.getString(ErrorMessageKeys.CONFIG_0045,
"configID")); //$NON-NLS-1$
- }
-
- // Look in the cache ...
- Collection result = null;
-
- XMLConfigurationConnector transaction = null;
- transaction = getConnection(null);
- result = transaction.getAllObjectsForConfigurationModel(configID);
-
- return result;
+ return getReadOnlyConfigurationModel().getAllObjects();
}
public ComponentType getComponentType(ComponentTypeID id) throws
ConfigurationException {
@@ -295,80 +245,71 @@
throw new
IllegalArgumentException(PlatformPlugin.Util.getString(ErrorMessageKeys.CONFIG_0045,
"id")); //$NON-NLS-1$
}
- ComponentType type = null;
- XMLConfigurationConnector transaction = null;
- transaction = getConnection(null);
- type = transaction.getComponentType(id);
-
- if (type != null) {
- LogManager.logDetail(CONTEXT, "Found component type " + id);
//$NON-NLS-1$
- } else {
- LogManager.logDetail(CONTEXT, "No component type found for " +
id); //$NON-NLS-1$
- }
- return type;
-
+ ComponentType type =
getReadOnlyConfigurationModel().getComponentType(id.getFullName());
+ if (type != null) {
+ LogManager.logDetail(CONTEXT, "Found component type " + id); //$NON-NLS-1$
+ } else {
+ LogManager.logDetail(CONTEXT, "No component type found for " + id);
//$NON-NLS-1$
+ }
+ return type;
}
public Collection getAllComponentTypes(boolean includeDeprecated) throws
ConfigurationException {
- XMLConfigurationConnector transaction = null;
- Collection result = new LinkedList();
- transaction = getConnection(null);
- result = transaction.getAllComponentTypes(includeDeprecated);
+ XMLConfigurationConnector transaction = getConnection(null);
+ Map types = transaction.getConfigurationModel().getComponentTypes();
+ Collection result = new LinkedList(types.values());
- if (result != null && result.size() > 0) {
- LogManager.logDetail(CONTEXT, "Found all component types");
//$NON-NLS-1$
+ if (result.size() > 0) {
+ LogManager.logDetail(CONTEXT, "Found all component types"); //$NON-NLS-1$
- } else {
- throw new ConfigurationException(ErrorMessageKeys.CONFIG_0049,
PlatformPlugin.Util.getString(ErrorMessageKeys.CONFIG_0049));
- }
- return result;
+ } else {
+ throw new
ConfigurationException(ErrorMessageKeys.CONFIG_0049,PlatformPlugin.Util.getString(ErrorMessageKeys.CONFIG_0049));
+ }
+ return result;
}
public Collection getComponentTypeDefinitions(ComponentTypeID componentTypeID) throws
ConfigurationException {
- XMLConfigurationConnector transaction = null;
- Collection result=null;
- transaction = getConnection(null);
- result = transaction.getComponentTypeDefinitions(componentTypeID);
+ Collection result = getComponentTypeDefinitions(getReadOnlyConfigurationModel(),
componentTypeID);
- if (result != null && result.size() > 0) {
- LogManager.logDetail(CONTEXT, new Object[] {"Found component type
definitions for ", componentTypeID} ); //$NON-NLS-1$
+ if (result != null && result.size() > 0) {
+ LogManager.logDetail(CONTEXT, new Object[] {"Found component type
definitions for ", componentTypeID} ); //$NON-NLS-1$
- } else {
- LogManager.logTrace(CONTEXT, new Object[] {"Couldn't find
component type definitions for ", componentTypeID} ); //$NON-NLS-1$
- }
+ } else {
+ LogManager.logTrace(CONTEXT, new Object[] {"Couldn't find component
type definitions for ", componentTypeID} ); //$NON-NLS-1$
+ }
if (result == null) {
result = new ArrayList(1);
}
-
return result;
-
}
+ public Collection getComponentTypeDefinitions(ConfigurationModelContainer config,
ComponentTypeID componentTypeID) {
+ ComponentType t = config.getComponentType(componentTypeID.getFullName());
+ if (t!= null) {
+ return t.getComponentTypeDefinitions();
+ }
+ return Collections.EMPTY_LIST;
+ }
private Collection getDependentComponentTypeDefinitions(ComponentTypeID
componentTypeID) throws ConfigurationException {
- XMLConfigurationConnector transaction = getConnection(null);
- Collection defns = getDependentComponentTypeDefinitions(transaction,
componentTypeID);
+ Collection defns =
getDependentComponentTypeDefinitions(getReadOnlyConfigurationModel(), componentTypeID);
return defns;
}
- private Collection getDependentComponentTypeDefinitions(XMLConfigurationConnector
transaction, ComponentTypeID componentTypeID) throws ConfigurationException {
+ private Collection getDependentComponentTypeDefinitions(ConfigurationModelContainer
config, ComponentTypeID componentTypeID) throws ConfigurationException {
- Collection result=null;
+ Collection types = new ArrayList(config.getComponentTypes().values());
- Collection types = transaction.getAllComponentTypes(false);
+ Collection result= getSuperComponentTypeDefinitions(null, null, types,
componentTypeID, config);
- result = getSuperComponentTypeDefinitions(null, null, types, componentTypeID,
transaction);
-
if (result != null && result.size() > 0) {
LogManager.logDetail(CONTEXT, new Object[] {"Found dependent component
type definitions for ", componentTypeID} ); //$NON-NLS-1$
} else {
result = new ArrayList(1);
}
-
return result;
-
}
/**
@@ -391,7 +332,7 @@
private Collection getSuperComponentTypeDefinitions(Map defnMap, Collection defns,
Collection componentTypes,
ComponentTypeID componentTypeID,
- XMLConfigurationConnector transaction)
throws ConfigurationException {
+ ConfigurationModelContainer config)
throws ConfigurationException {
if (defnMap == null) {
defnMap = new HashMap();
}
@@ -415,13 +356,10 @@
return defns;
}
- Collection superDefns =
transaction.getComponentTypeDefinitions(type.getSuperComponentTypeID());
- // add the defns not already defined to the map
-// BaseID id;
+ Collection superDefns = getComponentTypeDefinitions(config,
type.getSuperComponentTypeID());
ComponentTypeDefn sDefn;
if (superDefns != null && superDefns.size() > 0) {
Iterator it = superDefns.iterator();
-// ComponentTypeDefn cdefn = null;
while (it.hasNext()) {
sDefn = (ComponentTypeDefn) it.next();
//this map has been changed to be keyed
@@ -434,7 +372,7 @@
}
}
- return getSuperComponentTypeDefinitions(defnMap, defns, componentTypes,
type.getSuperComponentTypeID(), transaction);
+ return getSuperComponentTypeDefinitions(defnMap, defns, componentTypes,
type.getSuperComponentTypeID(), config);
}
public Collection getAllComponentTypeDefinitions(ComponentTypeID typeID) throws
ConfigurationException {
@@ -499,16 +437,11 @@
public Collection getHosts() throws ConfigurationException {
- Collection hosts = null;
- XMLConfigurationConnector transaction = null;
- transaction = getConnection(null);
- hosts = transaction.getHosts();
-
- if (hosts == null) {
- hosts = Collections.EMPTY_LIST;
- }
-
- return hosts;
+ Collection hosts = getReadOnlyConfigurationModel().getConfiguration().getHosts();
+ if (hosts == null) {
+ hosts = Collections.EMPTY_LIST;
+ }
+ return hosts;
}
@@ -520,16 +453,11 @@
* @return ComponentDefn
* @throws ConfigurationException if an error occurred within or during communication
with the Configuration Service.
*/
- public ComponentDefn getComponentDefn(ConfigurationID configurationID,
ComponentDefnID componentDefnID)
- throws ConfigurationException{
- XMLConfigurationConnector transaction = null;
- ComponentDefn defn = null;
- transaction = getConnection(null);
-
- defn = transaction.getComponentDefinition(componentDefnID,
configurationID);
-
- return defn;
-
+ public ComponentDefn getComponentDefn(ConfigurationID configurationID,
ComponentDefnID componentDefnID) throws ConfigurationException{
+ if (componentDefnID == null) {
+ throw new
ConfigurationException(ConfigMessages.CONFIG_0045,ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0045,"ComponentDefnID"));
//$NON-NLS-1$
+ }
+ return
getReadOnlyConfigurationModel().getConfiguration().getComponentDefn(componentDefnID);
}
/**
@@ -541,12 +469,8 @@
* @throws InvalidSessionException if the <code>callerSessionID</code> is
not valid or is expired.
* @throws MetaMatrixComponentException if an error occurred in communicating with a
component.
*/
- public Collection getResources()
- throws ConfigurationException{
- XMLConfigurationConnector transaction = null;
- transaction = getConnection(null);
-
- return transaction.getResources();
+ public Collection getResources() throws ConfigurationException{
+ return getReadOnlyConfigurationModel().getResources();
}
/**
@@ -558,9 +482,9 @@
* @throws MetaMatrixComponentException if an error occurred in communicating with a
component.
*/
public void saveResources(Collection resourceDescriptors, String principalName)
- throws ConfigurationException {
- XMLConfigurationConnector transaction = null;
- transaction = this.getConnection(principalName);
+ throws ConfigurationException {
+
+ XMLConfigurationConnector transaction = this.getConnection(principalName);
transaction.saveResources(resourceDescriptors, principalName);
@@ -578,15 +502,13 @@
* the repository.
* @param principalName of the person executing the transaction
* @return the set of objects that were affected by this transaction.
- * @throws ModificationException if the target of the action is invalid, or
- * if the target object is not a supported class of targets.
* @throws IllegalArgumentException if the action is null
* or if the result specification is invalid
* @throws ConfigurationException if an error occurred within or during
* communication with the Configuration Service.
*/
public Set executeTransaction(ActionDefinition action, String principalName)
- throws ModificationException, ConfigurationException{
+ throws ConfigurationException{
if ( action == null ) {
throw new
IllegalArgumentException(PlatformPlugin.Util.getString(ErrorMessageKeys.CONFIG_0045,
"action")); //$NON-NLS-1$
}
@@ -602,14 +524,12 @@
* the repository.
* @param principalName of the person executing the transaction
* @return the set of objects that were affected by this transaction.
- * @throws ModificationException if the target of any of the actions is invalid, or
- * if the target object is not a supported class of targets.
* @throws IllegalArgumentException if the action is null
* or if the result specification is invalid
* @throws ConfigurationException if an error occurred within or during
* communication with the Configuration Service.
*/
- public Set executeTransaction(List actions, String principalName) throws
ModificationException, ConfigurationException {
+ public Set executeTransaction(List actions, String principalName) throws
ConfigurationException {
if ( actions == null ) {
throw new
IllegalArgumentException(PlatformPlugin.Util.getString(ErrorMessageKeys.CONFIG_0045,
"actions")); //$NON-NLS-1$
}
@@ -619,24 +539,12 @@
return result;
}
- XMLConfigurationConnector transaction = null;
-
-
- // Iterate through the actions, and apply all as a single transaction
- try {
- transaction = this.getConnection(principalName);
- result = transaction.executeActions(actions);
- transaction.commit(); // commit the transaction
- } catch ( ConfigurationException e ) {
- throw e;
- } catch ( Exception e ) {
- throw new ConfigurationException(e);
- }
+ XMLConfigurationConnector transaction = this.getConnection(principalName);
+ result = transaction.executeActions(actions);
+ transaction.commit(); // commit the transaction
return result;
}
-
-
protected void addProperty(Properties source, String sourceName, Properties props,
String propName) {
String value = source.getProperty(sourceName);
if (value != null) {
@@ -654,15 +562,17 @@
protected XMLConfigurationConnector getConnection(String principal) throws
ConfigurationException {
return
XMLConfigurationMgr.getInstance().getTransaction(principal==null?this.getInstanceName():principal);
}
+
+ private ConfigurationModelContainerImpl getReadOnlyConfigurationModel() throws
ConfigurationException {
+ return
XMLConfigurationMgr.getInstance().getConfigurationModel(Configuration.NEXT_STARTUP_ID);
+ }
/**
* @see
com.metamatrix.platform.config.api.service.ConfigurationServiceInterface#addHost(java.lang.String,
* java.util.Properties)
* @since 4.3
*/
- public Host addHost(String hostName,
- String principalName,
- Properties properties) throws ConfigurationException {
+ public Host addHost(String hostName, String principalName, Properties properties)
throws ConfigurationException {
com.metamatrix.common.config.api.Host host = null;
ConfigurationObjectEditor editor = null;
@@ -677,16 +587,12 @@
host = editor.createHost(hostName);
- host = (com.metamatrix.common.config.api.Host)editor
- .modifyProperties(host,
allProps, ConfigurationObjectEditor.SET);
+ host = (com.metamatrix.common.config.api.Host)editor.modifyProperties(host,
allProps, ConfigurationObjectEditor.SET);
executeTransaction(editor.getDestination().popActions(), principalName);
} catch (Exception theException) {
- // rollback
- if (editor != null) {
- editor.getDestination().popActions();
- }
+ clearActions(editor);
//final Object[] params = new Object[] {this.getClass().getName(),
theException.getMessage()};
final Object[] params = new Object[] {
hostName
@@ -746,10 +652,7 @@
}
} catch (Exception theException) {
- // rollback
- if (editor != null) {
- editor.getDestination().popActions();
- }
+ clearActions(editor);
final Object[] params = new Object[] {
processName, hostName
};
@@ -781,9 +684,7 @@
executeTransaction(editor.getDestination().popActions(), principalName);
} catch (Exception theException) {
- if (editor != null) {
- editor.getDestination().popActions();
- }
+ clearActions(editor);
final Object[] params = new Object[] {
propertyName, theException.getMessage()
};
@@ -819,9 +720,7 @@
executeTransaction(editor.getDestination().popActions(), principalName);
} catch (Exception theException) {
- if (editor != null) {
- editor.getDestination().popActions();
- }
+ clearActions(editor);
final Object[] params = new Object[] {
theException.getMessage(), properties
};
@@ -858,20 +757,15 @@
editor = createEditor();
config = getNextStartupConfiguration();
- /* ServiceComponentDefn scd = */
-// editor.createServiceComponentDefn((ConfigurationID)config.getID(),
-// (ComponentTypeID)ctConnector.getID(),
-// connectorBindingName);
-
binding = createConnectorBinding(ctConnector, editor, connectorBindingName);
binding = (ConnectorBinding)editor.modifyProperties(binding, properties,
ConfigurationObjectEditor.SET);
if (vmName != null) {
- if (vmName.equalsIgnoreCase("all")) {
+ if (vmName.equalsIgnoreCase("all")) { //$NON-NLS-1$
Collection<VMComponentDefn> vms = config.getVMComponentDefns();
for (Iterator<VMComponentDefn> it=vms.iterator(); it.hasNext();) {
- VMComponentDefn vm = (VMComponentDefn) it.next();
+ VMComponentDefn vm = it.next();
DeployedComponent dc = this.deployeServiceDefnToVM(
(VMComponentDefnID)vm.getID(), connectorBindingName, editor, principalName);
}
@@ -879,41 +773,24 @@
} else {
// TODO: the method from serveradminapi passes in "ALL" and its
not currently
// called from anywhere else
-
}
}
-// if (pscName != null && !pscName.equals("")) {
//$NON-NLS-1$
-// ProductServiceConfig psc = this.getPSCByName(config, pscName);
-// ServiceComponentDefnID bindingID =
(ServiceComponentDefnID)binding.getID();
-// editor.addServiceComponentDefn(psc, bindingID);
-//
-// editor.deployServiceDefn(config, binding,
(ProductServiceConfigID)psc.getID());
-// }
-
executeTransaction(editor.getDestination().popActions(), principalName);
} catch (Exception theException) {
- // rollback
- if (editor != null) {
- editor.getDestination().popActions();
- }
+ clearActions(editor);
final Object[] params = new Object[] {
this.getClass().getName(), theException.getMessage()
};
- throw new ConfigurationException(theException,
-
PlatformPlugin.Util.getString("ConfigurationServiceImpl.Error_creating_Connector_Binding",
params)); //$NON-NLS-1$
+ throw new
ConfigurationException(theException,PlatformPlugin.Util.getString("ConfigurationServiceImpl.Error_creating_Connector_Binding",
params)); //$NON-NLS-1$
}
return binding;
}
- private ComponentType getComponentType(String connectorName,
- boolean deprecated) throws
InvalidSessionException,
- AuthorizationException,
- ConfigurationException,
-
MetaMatrixComponentException {
+ private ComponentType getComponentType(String connectorName, boolean deprecated)
throws ConfigurationException {
Collection arylConnectors = getAllComponentTypes(deprecated);
Iterator itConnectors = arylConnectors.iterator();
while (itConnectors.hasNext()) {
@@ -925,47 +802,26 @@
return null;
}
-// private ProductServiceConfig getPSCByName(Configuration config,
-// String pscName) throws
InvalidArgumentException {
-// ProductServiceConfig result = null;
-// if (config != null) {
-// ProductServiceConfigID pscID = new
ProductServiceConfigID(((ConfigurationID)config.getID()), pscName);
-// result = config.getPSC(pscID);
-// }
-// return result;
-// }
-
- private ConnectorBinding createConnectorBinding(ComponentType ctConnector,
- ConfigurationObjectEditor coe,
- String sConnBindName) throws
Exception {
- ConnectorBinding connectorBinding =
coe.createConnectorComponent(Configuration.NEXT_STARTUP_ID,
(ComponentTypeID)ctConnector.getID(),
- sConnBindName,
- null);
+ private ConnectorBinding createConnectorBinding(ComponentType ctConnector,
ConfigurationObjectEditor coe, String sConnBindName) {
+ ConnectorBinding connectorBinding =
coe.createConnectorComponent(Configuration.NEXT_STARTUP_ID,
(ComponentTypeID)ctConnector.getID(),sConnBindName,null);
return connectorBinding;
}
- public Object modify(ComponentObject theObject,
- Properties theProperties,
- String principalName) throws ModificationException,
ConfigurationException{
+ public Object modify(ComponentObject theObject,Properties theProperties, String
principalName) throws ConfigurationException{
ConfigurationObjectEditor editor = null;
try {
editor = createEditor();
Object obj = editor.modifyProperties(theObject, theProperties,
ConfigurationObjectEditor.SET);
executeTransaction(editor.getDestination().popActions(), principalName);
return obj;
- } catch (Exception theException) {
- // rollback
- if (editor != null) {
- editor.getDestination().popActions();
- }
- throw new ConfigurationException(theException);
+ } catch (ConfigurationException e) {
+ clearActions(editor);
+ throw e;
}
}
- public ComponentType importConnectorType(InputStream inputStream,
- String name,
- String principalName) throws
ConfigurationException {
+ public ComponentType importConnectorType(InputStream inputStream, String name, String
principalName) throws ConfigurationException {
ComponentType newType = null;
ConfigurationObjectEditor editor = createEditor();
@@ -976,14 +832,8 @@
executeTransaction(editor.getDestination().popActions(), principalName);
} catch (Exception theException) {
- // rollback
- if (editor != null) {
- editor.getDestination().popActions();
- }
- final Object[] params = new Object[] {
- name, theException.getMessage()
- };
- final String msg =
PlatformPlugin.Util.getString("ConfigurationServiceImpl.Error_importing_connector_type",
params); //$NON-NLS-1$
+ clearActions(editor);
+ final String msg =
PlatformPlugin.Util.getString("ConfigurationServiceImpl.Error_importing_connector_type",
new Object[] {name, theException.getMessage()}); //$NON-NLS-1$
throw new ConfigurationException(theException, msg);
}
@@ -1025,20 +875,14 @@
for (Iterator<VMComponentDefn> it=vms.iterator(); it.hasNext();) {
VMComponentDefn vm = it.next();
editor.deployServiceDefn(config, newBinding, (VMComponentDefnID)
vm.getID() );
-
}
}
-
-
}
executeTransaction(editor.getDestination().popActions(), principalName);
} catch (Exception theException) {
- // rollback
- if (editor != null) {
- editor.getDestination().popActions();
- }
+ clearActions(editor);
final Object[] params = new Object[] {
name, theException.getMessage()
};
@@ -1047,18 +891,15 @@
}
return newBinding;
-
-
}
/**
* @see
com.metamatrix.platform.config.api.service.ConfigurationServiceInterface#delete(com.metamatrix.common.config.api.ComponentObject,
boolean)
* @since 4.3
*/
- public void delete(ComponentObject theObject,
- boolean theDeleteDependenciesFlag,
- String principalName) throws ConfigurationException,
- ModificationException {
+ public void delete(ComponentObject theObject, boolean theDeleteDependenciesFlag,
String principalName)
+ throws ConfigurationException {
+
ConfigurationObjectEditor editor = null;
try {
@@ -1072,47 +913,37 @@
if (editor.getDestination().getActionCount() != 0) {
executeTransaction(editor.getDestination().popActions(),principalName);
}
- } catch (ConfigurationException theException) {
- // rollback
- if (editor != null) {
- editor.getDestination().popActions();
- }
- throw theException;
- } catch (ServiceException err) {
-// rollback
- if (editor != null) {
- editor.getDestination().popActions();
- }
- throw err;
- } catch (ModificationException mex) {
-// rollback
- if (editor != null) {
- editor.getDestination().popActions();
- }
- throw mex;
- }
+ } catch (ConfigurationException e) {
+ clearActions(editor);
+ throw e;
+ } catch (ServiceException e) {
+ clearActions(editor);
+ throw e;
+ }
}
+ private void clearActions(ConfigurationObjectEditor editor) {
+ if (editor != null) {
+ editor.getDestination().popActions();
+ }
+ }
+
/**
* @see
com.metamatrix.platform.config.api.service.ConfigurationServiceInterface#delete(com.metamatrix.common.config.api.ComponentType,
java.lang.String)
* @since 4.3
*/
- public void delete(ComponentType componentType,
- String principalName) throws ConfigurationException,
- ModificationException {
+ public void delete(ComponentType componentType, String principalName)
+ throws ConfigurationException {
ConfigurationObjectEditor editor = null;
- try {
- editor = createEditor();
- editor.delete(componentType);
- executeTransaction(editor.getDestination().popActions(),principalName);
- } catch (ConfigurationException theException) {
- // rollback
- if (editor != null) {
- editor.getDestination().popActions();
- }
- throw theException;
- }
+ try {
+ editor = createEditor();
+ editor.delete(componentType);
+ executeTransaction(editor.getDestination().popActions(),principalName);
+ } catch (ConfigurationException e) {
+ clearActions(editor);
+ throw e;
+ }
}
/**
@@ -1127,13 +958,10 @@
* @return DeployedComponent of the ServiceComponentDefns that was deployed
*
* @throws ConfigurationException
- * @throws ModificationException
* @since 6.1
*/
- public DeployedComponent deployService(VMComponentDefnID theProcessID,
- String serviceName,
- String principalName) throws ConfigurationException,ModificationException {
+ public DeployedComponent deployService(VMComponentDefnID theProcessID, String
serviceName, String principalName) throws ConfigurationException {
DeployedComponent deployComponent = null;
@@ -1144,10 +972,7 @@
deployComponent = deployeServiceDefnToVM(theProcessID, serviceName, editor,
principalName);
executeTransaction(editor.getDestination().popActions(), principalName);
} catch (ConfigurationException theException) {
- // rollback
- if (editor != null) {
- editor.getDestination().popActions();
- }
+ clearActions(editor);
throw theException;
}
return deployComponent;
@@ -1156,7 +981,7 @@
private DeployedComponent deployeServiceDefnToVM(VMComponentDefnID theProcessID,
String serviceName,
ConfigurationObjectEditor editor,
- String principalName) throws ConfigurationException,ModificationException {
+ String principalName) throws ConfigurationException {
DeployedComponent deployComponent = null;
Deleted:
trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/ConfigTransactionException.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/ConfigTransactionException.java 2009-05-05
18:01:19 UTC (rev 863)
+++
trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/ConfigTransactionException.java 2009-05-05
19:09:01 UTC (rev 864)
@@ -1,72 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.platform.config.spi.xml;
-
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-
-import com.metamatrix.common.config.api.exceptions.ConfigurationException;
-
-/**
- * TransactionException exception indicates that the request cannot be
- * executed because of an error with the transaction.
- */
-
-public class ConfigTransactionException extends ConfigurationException {
-
- /**
- * Construct an instance with the message and error code specified.
- *
- * @param message A message describing the exception
- * @param code The error code
- */
- public ConfigTransactionException( String code, String message ) {
- super( code, message );
- }
-
- /**
- * Construct an instance from a message and an exception to chain to this one.
- *
- * @param code A code denoting the exception
- * @param e An exception to nest within this one
- */
- public ConfigTransactionException( Exception e, String message ) {
- super( e, message );
- }
-
- /**
- * Construct an instance from a message and a code and an exception to
- * chain to this one.
- *
- * @param e An exception to nest within this one
- * @param message A message describing the exception
- * @param code A code denoting the exception
- */
- public ConfigTransactionException( Exception e, String code, String message ) {
- super( e, code, message );
- }
-
-} // END CLASS
-
-
Modified:
trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/XMLActionUpdateStrategy.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/XMLActionUpdateStrategy.java 2009-05-05
18:01:19 UTC (rev 863)
+++
trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/XMLActionUpdateStrategy.java 2009-05-05
19:09:01 UTC (rev 864)
@@ -22,7 +22,6 @@
package com.metamatrix.platform.config.spi.xml;
-
import java.util.Collection;
import java.util.Enumeration;
import java.util.HashSet;
@@ -99,233 +98,94 @@
import com.metamatrix.platform.config.api.service.ConfigurationServiceInterface;
import com.metamatrix.platform.security.audit.AuditManager;
+public class XMLActionUpdateStrategy {
-public class XMLActionUpdateStrategy {
+ public PropertyValidations validateProperty = new PropertyValidations();
+ public XMLActionUpdateStrategy() {
+ }
- public PropertyValidations validateProperty = new PropertyValidations();
+ Set executeActionsOnTarget(Object target, List actions, ConfigurationModelContainerImpl
config, String principal, XMLConfigurationConnector transaction) throws
ConfigurationException {
-
- public XMLActionUpdateStrategy() {
- }
-
-
- public Set executeActionsOnTarget(Object target, List actions,
XMLConfigurationConnector transaction )
- throws ConfigTransactionException, ConfigurationException {
- // System.out.println("STRATEGY: Start Execute on Target " + target +
" of type " + target.getClass().getName());
-
-
Set affectedIDs = new HashSet();
- if ( actions.isEmpty() ) {
+ if (actions.isEmpty()) {
+ return affectedIDs;
+ }
- return affectedIDs;
- }
+ /**
+ * Certain object types, when changed, require that both the NextStartup
+ * and Operational Configurations be changed. Those object types are not
+ * considered to be bound by a configuration, all the other types are.
+ * The following are the 2 different categories:
+ *
+ * Unbound by Configuration: - Host - ComponentType/ComponentTypeDefn -
+ * ResourcePool (ResourceDescriptor) - Resource (ResourceDescriptor) -
+ * Connector Bindings (ComponentDefn/DeployedComponent of
+ * ConnectorBindingType)
+ *
+ * Bound by Configuration - Configuration -
+ * ServiceComponentDefn(ComponentDefn)/DeployedComponent -
+ * VMComponentDefn(ComponentDefn)/DeployedComponent - PSC
+ */
- ConfigurationModelContainerImpl model = null;
-
-/**
- * Certain object types, when changed, require that both the
- * NextStartup and Operational Configurations be changed. Those
- * object types are not considered to be bound by a configuration,
- * all the other types are. The following are the 2 different
- * categories:
- *
- * Unbound by Configuration:
- * - Host
- * - ComponentType/ComponentTypeDefn
- * - ResourcePool (ResourceDescriptor)
- * - Resource (ResourceDescriptor)
- * - Connector Bindings (ComponentDefn/DeployedComponent of ConnectorBindingType)
- *
- * Bound by Configuration
- * - Configuration
- * - ServiceComponentDefn(ComponentDefn)/DeployedComponent
- * - VMComponentDefn(ComponentDefn)/DeployedComponent
- * - PSC
- */
-
- if ( target instanceof ConfigurationID ) {
- ConfigurationID id = (ConfigurationID) target;
-
-
- executeActions(id, actions, transaction);
-
-
- } else if (target instanceof HostID) {
- HostID id = (HostID) target;
- // apply changes to all configurations
-
- Collection trans = transaction.getObjects();
- for (Iterator it=trans.iterator(); it.hasNext(); ) {
- ConfigurationModelContainerImpl m = (ConfigurationModelContainerImpl) it.next();
-// System.out.println("STRATEGY: Update Config " +
m.getConfigurationID());
-
- executeActions(m, id, actions, transaction);
- }
-
- } else if (target instanceof SharedResourceID) {
- SharedResourceID id = (SharedResourceID) target;
- // apply changes to all configurations
-
- Collection trans = transaction.getObjects();
- for (Iterator it=trans.iterator(); it.hasNext(); ) {
- ConfigurationModelContainerImpl m = (ConfigurationModelContainerImpl) it.next();
-// System.out.println("STRATEGY: Update Config " +
m.getConfigurationID());
-
- executeActions(m, id, actions, transaction);
- }
-
- } else if (target instanceof AuthenticationProviderID) {
- AuthenticationProviderID id = (AuthenticationProviderID) target;
-
- Collection trans = transaction.getObjects();
-
- for (Iterator it=trans.iterator(); it.hasNext(); ) {
- ConfigurationModelContainerImpl m = (ConfigurationModelContainerImpl) it.next();
-
- executeActions(m, id, actions, transaction);
-
- }
-
- } else if (target instanceof ComponentTypeID) {
- ComponentTypeID id = (ComponentTypeID) target;
- Collection trans = transaction.getObjects();
- // apply changes to all configurations
-
- for (Iterator it=trans.iterator(); it.hasNext(); ) {
- ConfigurationModelContainerImpl m = (ConfigurationModelContainerImpl) it.next();
- executeActions(m, id, actions, transaction);
- }
-
- } else if (target instanceof ComponentTypeDefnID) {
- ComponentTypeDefnID id = (ComponentTypeDefnID) target;
- Collection trans = transaction.getObjects();
-
- // apply changes to all configurations
- for (Iterator it=trans.iterator(); it.hasNext(); ) {
- ConfigurationModelContainerImpl m = (ConfigurationModelContainerImpl) it.next();
- executeActions(m, id, actions, transaction);
- }
-
- } else if (target instanceof ConnectorBindingID) {
- ConnectorBindingID id = (ConnectorBindingID) target;
- Collection trans = transaction.getObjects();
-// System.out.println("STRATEGY: Update Connector " + target);
-
- for (Iterator it=trans.iterator(); it.hasNext(); ) {
- ConfigurationModelContainerImpl m = (ConfigurationModelContainerImpl) it.next();
- executeActions(m, id, actions, transaction);
- }
-
-
-
- } else if (target instanceof DeployedComponentID) {
- DeployedComponentID id = (DeployedComponentID) target;
-
- Collection trans = transaction.getObjects();
- for (Iterator it=trans.iterator(); it.hasNext(); ) {
- ConfigurationModelContainerImpl m = (ConfigurationModelContainerImpl) it.next();
- executeActions(m, id, actions, transaction);
- }
-
-
- } else if (target instanceof VMComponentDefnID) {
- VMComponentDefnID id = (VMComponentDefnID) target;
-
-// System.out.println("STRATEGY: Update ComponentDefn " + id);
-
- Collection trans = transaction.getObjects();
- for (Iterator it=trans.iterator(); it.hasNext(); ) {
- ConfigurationModelContainerImpl m = (ConfigurationModelContainerImpl) it.next();
-
-// System.out.println("STRATEGY: Execute Update ComponentDefn " + id);
-
- executeActions(m, id, actions, transaction);
- }
-
-
- } else if (target instanceof ServiceComponentDefnID) {
- ServiceComponentDefnID id = (ServiceComponentDefnID) target;
-
-// System.out.println("STRATEGY: Update SvcComponentDefn " + id);
-
- Collection trans = transaction.getObjects();
- for (Iterator it=trans.iterator(); it.hasNext(); ) {
- ConfigurationModelContainerImpl m = (ConfigurationModelContainerImpl) it.next();
- executeActions( m, id, actions, transaction);
-
- }
-
-
- } else if (target instanceof PropDefnAllowedValueID) {
- PropDefnAllowedValueID id = (PropDefnAllowedValueID) target;
- Collection trans = transaction.getObjects();
- for (Iterator it=trans.iterator(); it.hasNext(); ) {
- model = (ConfigurationModelContainerImpl) it.next();
-
- // deployed comps are not necessarily applied to all configs
-// if (doesCompChangeApply(id, model)) {
- executeActions(model, id, actions, transaction);
-// }
- }
-
- } else {
- throw new ConfigTransactionException(ConfigMessages.CONFIG_0071,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0071, target));
- }
-
-
-// System.out.println("STRATEGY: End Update Target " + target);
-
+ if (target instanceof ConfigurationID) {
+ ConfigurationID id = (ConfigurationID) target;
+ executeActions(id, actions, config, principal, transaction);
+ } else if (target instanceof HostID) {
+ HostID id = (HostID) target;
+ executeActions(id, actions, config, principal);
+ } else if (target instanceof SharedResourceID) {
+ SharedResourceID id = (SharedResourceID) target;
+ executeActions(id, actions, config, principal);
+ } else if (target instanceof AuthenticationProviderID) {
+ AuthenticationProviderID id = (AuthenticationProviderID) target;
+ executeActions(id, actions, config, principal);
+ } else if (target instanceof ComponentTypeID) {
+ ComponentTypeID id = (ComponentTypeID) target;
+ executeActions(id, actions, config, principal);
+ } else if (target instanceof ComponentTypeDefnID) {
+ ComponentTypeDefnID id = (ComponentTypeDefnID) target;
+ executeActions(id, actions, config, principal);
+ } else if (target instanceof ConnectorBindingID) {
+ ConnectorBindingID id = (ConnectorBindingID) target;
+ executeActions(id, actions, config, principal);
+ } else if (target instanceof DeployedComponentID) {
+ DeployedComponentID id = (DeployedComponentID) target;
+ executeActions(id, actions, config, principal);
+ } else if (target instanceof VMComponentDefnID) {
+ VMComponentDefnID id = (VMComponentDefnID) target;
+ executeActions(id, actions, config, principal);
+ } else if (target instanceof ServiceComponentDefnID) {
+ ServiceComponentDefnID id = (ServiceComponentDefnID) target;
+ executeActions(id, actions, config, principal);
+ } else if (target instanceof PropDefnAllowedValueID) {
+ PropDefnAllowedValueID id = (PropDefnAllowedValueID) target;
+ executeActions(id, actions);
+ } else {
+ throw new
ConfigurationException(ConfigMessages.CONFIG_0071,ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0071,target));
+ }
return affectedIDs;
}
- private ConfigurationModelContainerImpl getConfigModel(BaseID id,
XMLConfigurationConnector transaction) throws ConfigurationException {
+ private ComponentType getComponentType(ConfigurationModelContainer config,
+ ComponentTypeID id, BaseID targetID) throws ConfigurationException {
+ ComponentType type = config.getComponentType(id.getFullName());
- String name;
- if (id instanceof ConfigurationID) {
- name = id.getFullName();
- } else {
- name = id.getParentFullName();
+ if (type == null) {
+ throw new
InvalidComponentException(ConfigPlugin.Util.getString("XMLActionUpdateStrategy.Unable_to_add_component_type_not_found",
new Object[] { targetID, id })); //$NON-NLS-1$
}
- ConfigurationModelContainerImpl container = (ConfigurationModelContainerImpl)
transaction.getObject(name);
+ return type;
+ }
- if (id instanceof ConfigurationID) {
- // a config model may not exist if a delete was performed
- } else {
- if (container == null) {
- throw new ConfigurationException(ConfigMessages.CONFIG_0072,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0072, name));
- }
- }
-
-
- return container;
- }
-
- private ComponentType getComponentType(ConfigurationModelContainer config,
ComponentTypeID id, BaseID targetID)throws ConfigurationException {
-
- ComponentType type = config.getComponentType(id.getFullName());
-
- if (type == null) {
- throw new
InvalidComponentException(ConfigPlugin.Util.getString("XMLActionUpdateStrategy.Unable_to_add_component_type_not_found",
new Object[] {targetID, id})); //$NON-NLS-1$
- }
-
- return type;
-
- }
-
-
- public Set executeActions(ConfigurationModelContainerImpl config,
- AuthenticationProviderID targetID, List actions,
- XMLConfigurationConnector transaction)
+ private Set executeActions(AuthenticationProviderID targetID, List actions,
+ ConfigurationModelContainerImpl config, String principal)
throws InvalidConfigurationException, ConfigurationException {
Set affectedIDs = new HashSet();
if (actions.isEmpty()) {
return affectedIDs;
}
- // System.out.println("STRATEGY: ResourceDescriptor Component Target " +
- // targetID);
int actionIndex = -1;
@@ -346,25 +206,17 @@
if (action instanceof CreateObject) {
if (rd != null) {
- DuplicateComponentException e = new DuplicateComponentException(
- ConfigMessages.CONFIG_0189,
- ConfigPlugin.Util.getString(
- ConfigMessages.CONFIG_0189, targetID));
+ DuplicateComponentException e = new
DuplicateComponentException(ConfigMessages.CONFIG_0189,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0189,targetID));
e.setActionIndex(actionIndex);
throw e;
}
rd = (AuthenticationProvider) args[0];
- rd = (AuthenticationProvider) setCreationDate(rd, transaction.getLockAcquiredBy());
+ rd = (AuthenticationProvider) setCreationDate(rd, principal);
- ComponentType type = getComponentType(config, rd
- .getComponentTypeID(), targetID);
+ ComponentType type = getComponentType(config, rd.getComponentTypeID(), targetID);
- // ComponentType type =
- // config.getComponentType(rd.getComponentTypeID().getFullName());
-
// process properties for any encryptions
- processPropertyForNewObject(rd, type, config, transaction
- .getLockAcquiredBy());
+ processPropertyForNewObject(rd, type, config, principal);
cfg.addComponentDefn(rd);
@@ -373,42 +225,30 @@
|| action instanceof ExchangeObject) {
if (rd == null) {
- throw new InvalidComponentException(
- ConfigMessages.CONFIG_0190,
- ConfigPlugin.Util.getString(
- ConfigMessages.CONFIG_0190, targetID));
+ throw new InvalidComponentException(ConfigMessages.CONFIG_0190,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0190,targetID));
}
- // ComponentType type =
- // config.getComponentType(rd.getComponentTypeID().getFullName());
ComponentType type = getComponentType(config, rd
.getComponentTypeID(), targetID);
- rd = (AuthenticationProvider) setLastChangedDate(rd,
transaction.getLockAcquiredBy());
+ rd = (AuthenticationProvider) setLastChangedDate(rd,
+ principal);
- processPropertyChanges(action, rd, type, config,
- transaction.getLockAcquiredBy());
+ processPropertyChanges(action, rd, type, config, principal);
} else if (action instanceof DestroyObject) {
if (rd != null) {
delete(targetID, cfg);
- setLastChangedDate(config.getConfiguration(), transaction.getLockAcquiredBy());
+ setLastChangedDate(config.getConfiguration(), principal);
}
-
} else {
- throw new InvalidArgumentException(
- ConfigMessages.CONFIG_0075, ConfigPlugin.Util
- .getString(ConfigMessages.CONFIG_0191,
- action.getActionDescription()));
+ throw new InvalidArgumentException(ConfigMessages.CONFIG_0075,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0191,action.getActionDescription()));
}
-
}
-
} catch (ConfigurationException ce) {
throw ce;
-
} catch (Exception e) {
ConfigurationException e2 = new ConfigurationException(e);
e2.setActionIndex(actionIndex);
@@ -417,1475 +257,1068 @@
return affectedIDs;
}
-
+ private Set executeActions(DeployedComponentID targetID, List actions,
ConfigurationModelContainerImpl config, String principal)
+ throws InvalidDeployedComponentException, ConfigurationException {
+ Set affectedIDs = new HashSet();
+ if (actions.isEmpty()) {
+ return affectedIDs;
+ }
- public Set executeActions(ConfigurationModelContainerImpl config,
DeployedComponentID targetID, List actions, XMLConfigurationConnector transaction) throws
InvalidDeployedComponentException, ConfigurationException{
- Set affectedIDs = new HashSet();
- if ( actions.isEmpty() ) {
- return affectedIDs;
- }
-// System.out.println("STRATEGY: DeployedComp Target " + targetID + " on
config " + config.getConfigurationID());
+ int actionIndex = -1;
+ affectedIDs.add(targetID);
- int actionIndex = -1;
- affectedIDs.add(targetID);
-
BasicConfiguration cfg = (BasicConfiguration) config.getConfiguration();
+ try {
- try {
-
- // Iterate through the actions ...
- Iterator iter = actions.iterator();
- while ( iter.hasNext() ) {
- ActionDefinition action = (ActionDefinition) iter.next();
- actionIndex++;
- Object args[] = action.getArguments();
+ // Iterate through the actions ...
+ Iterator iter = actions.iterator();
+ while (iter.hasNext()) {
+ ActionDefinition action = (ActionDefinition) iter.next();
+ actionIndex++;
+ Object args[] = action.getArguments();
DeployedComponent dc = cfg.getDeployedComponent(targetID);
- if(action instanceof CreateObject) {
+ if (action instanceof CreateObject) {
- if ( dc != null ) {
- DuplicateComponentException e = new
DuplicateComponentException(ConfigMessages.CONFIG_0076,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0076, targetID));
- e.setActionIndex(actionIndex);
- throw e;
- }
+ if (dc != null) {
+ DuplicateComponentException e = new
DuplicateComponentException(ConfigMessages.CONFIG_0076,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0076,targetID));
+ e.setActionIndex(actionIndex);
+ throw e;
+ }
- dc = (BasicDeployedComponent) args[0];
+ dc = (BasicDeployedComponent) args[0];
- dc = (BasicDeployedComponent) setCreationDate(dc, transaction.getLockAcquiredBy());
+ dc = (BasicDeployedComponent) setCreationDate(dc, principal);
- ComponentType type = getComponentType(config,
dc.getComponentTypeID(), targetID);
+ ComponentType type = getComponentType(config, dc.getComponentTypeID(), targetID);
- // ComponentType type =
config.getComponentType(dc.getComponentTypeID().getFullName());
- boolean isDeployable = type.isDeployable();
- if (!isDeployable) {
- throw new
InvalidDeployedComponentException(ConfigMessages.CONFIG_0077,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0077, targetID.getName()));
- }
+ boolean isDeployable = type.isDeployable();
+ if (!isDeployable) {
+ throw new InvalidDeployedComponentException(ConfigMessages.CONFIG_0077,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0077,targetID.getName()));
+ }
- cfg.addDeployedComponent(dc);
+ cfg.addDeployedComponent(dc);
- } else if (action instanceof AddObject ||
- action instanceof RemoveObject ||
- action instanceof ExchangeObject) {
+ } else if (action instanceof AddObject
+ || action instanceof RemoveObject
+ || action instanceof ExchangeObject) {
- if (dc == null) {
- throw new InvalidComponentException(ConfigMessages.CONFIG_0078,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0078, targetID));
- }
+ if (dc == null) {
+ throw new InvalidComponentException(ConfigMessages.CONFIG_0078,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0078,targetID));
+ }
- //ComponentType type =
config.getComponentType(dc.getComponentTypeID().getFullName());
- ComponentType type = getComponentType(config,
dc.getComponentTypeID(), targetID);
+ ComponentType type = getComponentType(config, dc.getComponentTypeID(), targetID);
- dc = (BasicDeployedComponent) setLastChangedDate(dc,
transaction.getLockAcquiredBy());
+ dc = (BasicDeployedComponent) setLastChangedDate(dc,principal);
- processPropertyChanges(action,
- dc,
- type,
- config,
- transaction.getLockAcquiredBy());
+ processPropertyChanges(action, dc, type, config, principal);
- } else if (action instanceof DestroyObject) {
+ } else if (action instanceof DestroyObject) {
-
- if (dc != null) {
+ if (dc != null) {
delete(targetID, config.getConfiguration());
- setLastChangedDate(config.getConfiguration(), transaction.getLockAcquiredBy());
+ setLastChangedDate(config.getConfiguration(), principal);
+ }
- }
+ } else {
+ throw new InvalidArgumentException(ConfigMessages.CONFIG_0079,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0079,action.getActionDescription()));
+ }
- } else {
- throw new InvalidArgumentException(ConfigMessages.CONFIG_0079,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0079, action.getActionDescription()));
- }
+ }
- }
+ } catch (ConfigurationException ce) {
+ throw ce;
+ } catch (Exception e) {
+ ConfigurationException e2 = new ConfigurationException(e);
+ e2.setActionIndex(actionIndex);
+ throw e2;
+ }
- } catch (ConfigurationException ce) {
- throw ce;
+ return affectedIDs;
- } catch ( Exception e ) {
- ConfigurationException e2 = new ConfigurationException(e);
- e2.setActionIndex(actionIndex);
- throw e2;
- }
+ }
+ private Set executeActions(ServiceComponentDefnID targetID, List actions,
+ ConfigurationModelContainerImpl config, String principal)
+ throws InvalidDeployedComponentException, ConfigurationException {
+ Set affectedIDs = new HashSet();
+ if (actions.isEmpty()) {
+ return affectedIDs;
+ }
+ // System.out.println("STRATEGY: ComponentDefn Target " + targetID);
- return affectedIDs;
+ int actionIndex = -1;
- }
+ affectedIDs.add(targetID);
-
- public Set executeActions(ConfigurationModelContainerImpl config,
ServiceComponentDefnID targetID, List actions, XMLConfigurationConnector transaction)
throws InvalidDeployedComponentException, ConfigurationException{
- Set affectedIDs = new HashSet();
- if ( actions.isEmpty() ) {
- return affectedIDs;
- }
-// System.out.println("STRATEGY: ComponentDefn Target " + targetID);
-
- int actionIndex = -1;
-
- affectedIDs.add(targetID);
-
BasicConfiguration cfg = (BasicConfiguration) config.getConfiguration();
- try {
+ try {
- // Iterate through the actions ...
- Iterator iter = actions.iterator();
- while ( iter.hasNext() ) {
- ActionDefinition action = (ActionDefinition) iter.next();
+ // Iterate through the actions ...
+ Iterator iter = actions.iterator();
+ while (iter.hasNext()) {
+ ActionDefinition action = (ActionDefinition) iter.next();
- ComponentDefn cd = cfg.getServiceComponentDefn(targetID);
+ ComponentDefn cd = cfg.getServiceComponentDefn(targetID);
- actionIndex++;
- Object args[] = action.getArguments();
+ actionIndex++;
+ Object args[] = action.getArguments();
- if(action instanceof CreateObject ) {
- if (cd!= null) {
- DuplicateComponentException e = new
DuplicateComponentException(ConfigMessages.CONFIG_0083,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0083, targetID));
- e.setActionIndex(actionIndex);
- throw e;
- }
- cd = (ComponentDefn) args[0];
+ if (action instanceof CreateObject) {
+ if (cd != null) {
+ DuplicateComponentException e = new
DuplicateComponentException(ConfigMessages.CONFIG_0083,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0083,targetID));
+ e.setActionIndex(actionIndex);
+ throw e;
+ }
+ cd = (ComponentDefn) args[0];
- cd = (ComponentDefn) setCreationDate(cd, transaction.getLockAcquiredBy());
+ cd = (ComponentDefn) setCreationDate(cd, principal);
+ ComponentType type = getComponentType(config, cd.getComponentTypeID(), targetID);
- // ComponentType type =
config.getComponentType(cd.getComponentTypeID().getFullName());
- ComponentType type = getComponentType(config,
cd.getComponentTypeID(), targetID);
+ // process properties for any encryptions
+ processPropertyForNewObject(cd, type, config, principal);
- // process properties for any encryptions
- processPropertyForNewObject(cd, type, config,
transaction.getLockAcquiredBy());
+ cfg.addComponentDefn(cd);
-// System.out.println("STRATEGY: Add ComponentDefn Target " + targetID);
+ } else if (action instanceof AddObject || action instanceof RemoveObject) {
- cfg.addComponentDefn(cd);
+ if (cd == null) {
+ throw new InvalidComponentException(ConfigMessages.CONFIG_0084,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0084,targetID));
+ }
- } else if (action instanceof AddObject ||
- action instanceof RemoveObject) {
+ ComponentType type = getComponentType(config, cd.getComponentTypeID(), targetID);
+ cd = (ComponentDefn) setLastChangedDate(cd, principal);
- if (cd == null) {
- throw new InvalidComponentException(ConfigMessages.CONFIG_0084,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0084, targetID));
- }
+ processPropertyChanges(action, cd, type, config, principal);
- // ComponentType type =
config.getComponentType(cd.getComponentTypeID().getFullName());
- ComponentType type = getComponentType(config,
cd.getComponentTypeID(), targetID);
- cd = (ComponentDefn) setLastChangedDate(cd, transaction.getLockAcquiredBy());
+ } else if (action instanceof ExchangeObject) {
+ ExchangeObject anAction = (ExchangeObject) action;
- processPropertyChanges(action,
- cd,
- type,
- config,
- transaction.getLockAcquiredBy());
+ if (cd == null) {
+ throw new InvalidComponentException(ConfigMessages.CONFIG_0084,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0084,targetID));
+ }
+ if (anAction.hasAttributeCode()
+ && (anAction.getAttributeCode().intValue() ==
ConfigurationModel.Attribute.PROPERTY
+ .getCode() || anAction.getAttributeCode()
+ .intValue() == ConfigurationModel.Attribute.PROPERTIES
+ .getCode())) {
- } else if (action instanceof ExchangeObject) {
- ExchangeObject anAction = (ExchangeObject) action;
+ ComponentType type = getComponentType(config, cd.getComponentTypeID(), targetID);
+ cd = (ComponentDefn) setLastChangedDate(cd, principal);
- if (cd == null) {
- throw new InvalidComponentException(ConfigMessages.CONFIG_0084,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0084, targetID));
- }
+ processPropertyChanges(action, cd, type, config,principal);
+ } else if (anAction.hasAttributeCode()
+ && anAction.getAttributeCode().intValue() ==
ConfigurationModel.Attribute.NAME
+ .getCode()) {
+ throw new InvalidArgumentException(ConfigMessages.CONFIG_0085,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0085,action.getActionDescription(),targetID));
+
+ } else if (anAction.hasAttributeCode()&&
anAction.getAttributeCode().intValue() ==
ConfigurationModel.Attribute.IS_ENABLED.getCode()) {
+ throw new
InvalidArgumentException(ConfigMessages.CONFIG_0086,ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0086,
anAction.getActionDescription()));
- if (anAction.hasAttributeCode() &&
- (anAction.getAttributeCode().intValue() ==
ConfigurationModel.Attribute.PROPERTY.getCode() ||
- anAction.getAttributeCode().intValue() ==
ConfigurationModel.Attribute.PROPERTIES.getCode() ) ) {
+ } else if (anAction.hasAttributeCode()&&
anAction.getAttributeCode().intValue() ==
ConfigurationModel.Attribute.ROUTING_UUID.getCode()) {
- // ComponentType type =
config.getComponentType(cd.getComponentTypeID().getFullName());
- ComponentType type = getComponentType(config,
cd.getComponentTypeID(), targetID);
- cd = (ComponentDefn) setLastChangedDate(cd, transaction.getLockAcquiredBy());
+ if (cd instanceof ServiceComponentDefn) {
+ setRoutingUUID((ServiceComponentDefn) cd,(String) anAction.getNewValue());
+ setLastChangedDate(cd, principal);
+ } else {
- processPropertyChanges(action,
- cd,
- type,
- config,
- transaction.getLockAcquiredBy());
+ throw new
InvalidComponentException(ConfigMessages.CONFIG_0087,ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0087,
action.getActionDescription(),targetID));
+ }
- } else if (anAction.hasAttributeCode() &&
anAction.getAttributeCode().intValue() == ConfigurationModel.Attribute.NAME.getCode()) {
- throw new InvalidArgumentException(ConfigMessages.CONFIG_0085,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0085, action.getActionDescription(),
targetID));
+ } else {
+ throw new
InvalidArgumentException(ConfigMessages.CONFIG_0086,ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0086,
anAction.getActionDescription()));
+ }
-// } else if (anAction.hasAttributeCode() &&
anAction.getAttributeCode().intValue() == ConfigurationModel.Attribute.PSC_NAME.getCode())
{
-// ProductServiceConfigID pscID =
(ProductServiceConfigID)anAction.getNewValue();
-// ProductServiceConfig psc = config.getConfiguration().getPSC(pscID);
-//
-// setLastChangedDate(psc, transaction.getLockAcquiredBy());
-//
-//
-// // add the service the PSC
-// ConfigurationObjectEditorHelper.addServiceComponentDefn(psc, targetID);
+ } else if (action instanceof DestroyObject) {
- } else if (anAction.hasAttributeCode() &&
anAction.getAttributeCode().intValue() ==
ConfigurationModel.Attribute.IS_ENABLED.getCode()) {
- throw new InvalidArgumentException(ConfigMessages.CONFIG_0086,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0086,
anAction.getActionDescription()));
-
- } else if (anAction.hasAttributeCode() &&
anAction.getAttributeCode().intValue() ==
ConfigurationModel.Attribute.ROUTING_UUID.getCode()) {
-
- if (cd instanceof ServiceComponentDefn) {
- setRoutingUUID((ServiceComponentDefn) cd, (String)
anAction.getNewValue());
-
- setLastChangedDate(cd, transaction.getLockAcquiredBy());
-
-
- } else {
-
- throw new InvalidComponentException(ConfigMessages.CONFIG_0087,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0087, action.getActionDescription(),
targetID));
-
- }
-
- } else {
- throw new InvalidArgumentException(ConfigMessages.CONFIG_0086,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0086,
anAction.getActionDescription()));
- }
-
-
-
-
- } else if (action instanceof DestroyObject) {
-
- if (cd != null) {
-// System.out.println("STRATEGY: Destroy ServiceDefn Target " + targetID);
+ if (cd != null) {
delete(targetID, cfg);
- setLastChangedDate(config.getConfiguration(), transaction.getLockAcquiredBy());
+ setLastChangedDate(config.getConfiguration(), principal);
+ }
- }
+ } else {
+ throw new InvalidArgumentException(ConfigMessages.CONFIG_0075,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0075,action.getActionDescription()));
+ }
+ }
+ } catch (ConfigurationException ce) {
+ throw ce;
- } else {
- throw new InvalidArgumentException(ConfigMessages.CONFIG_0075,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0075, action.getActionDescription()));
- }
+ } catch (Exception e) {
+ ConfigurationException e2 = new ConfigurationException(e);
+ e2.setActionIndex(actionIndex);
+ throw e2;
+ }
- }
+ return affectedIDs;
+ }
- } catch (ConfigurationException ce) {
- throw ce;
+ private Set executeActions(VMComponentDefnID targetID, List actions,
ConfigurationModelContainerImpl config, String principal)
+ throws InvalidDeployedComponentException, ConfigurationException {
+ Set affectedIDs = new HashSet();
+ if (actions.isEmpty()) {
+ return affectedIDs;
+ }
- } catch ( Exception e ) {
- ConfigurationException e2 = new ConfigurationException(e);
- e2.setActionIndex(actionIndex);
- throw e2;
- }
+ int actionIndex = -1;
+ affectedIDs.add(targetID);
- return affectedIDs;
-
- }
-
- public Set executeActions( ConfigurationModelContainerImpl config,
VMComponentDefnID targetID, List actions, XMLConfigurationConnector transaction) throws
InvalidDeployedComponentException, ConfigurationException{
- Set affectedIDs = new HashSet();
- if ( actions.isEmpty() ) {
- return affectedIDs;
- }
-// System.out.println("STRATEGY: ComponentDefn Target " + targetID);
-
- int actionIndex = -1;
-
- affectedIDs.add(targetID);
-
BasicConfiguration cfg = (BasicConfiguration) config.getConfiguration();
- try {
+ try {
- // Iterate through the actions ...
- Iterator iter = actions.iterator();
- while ( iter.hasNext() ) {
- ActionDefinition action = (ActionDefinition) iter.next();
- actionIndex++;
- Object args[] = action.getArguments();
+ // Iterate through the actions ...
+ Iterator iter = actions.iterator();
+ while (iter.hasNext()) {
+ ActionDefinition action = (ActionDefinition) iter.next();
+ actionIndex++;
+ Object args[] = action.getArguments();
ComponentDefn cd = cfg.getVMComponentDefn(targetID);
- if(action instanceof CreateObject ) {
- if (cd!= null) {
- DuplicateComponentException e = new
DuplicateComponentException(ConfigMessages.CONFIG_0088,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0088, action.getActionDescription(),
targetID));
- e.setActionIndex(actionIndex);
- throw e;
- }
- cd = (ComponentDefn) args[0];
-// System.out.println("STRATEGY: Add ComponentDefn Target " + targetID);
+ if (action instanceof CreateObject) {
+ if (cd != null) {
+ DuplicateComponentException e = new
DuplicateComponentException(ConfigMessages.CONFIG_0088,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0088,action.getActionDescription(),targetID));
+ e.setActionIndex(actionIndex);
+ throw e;
+ }
+ cd = (ComponentDefn) args[0];
- cd = (ComponentDefn) setCreationDate(cd, transaction.getLockAcquiredBy());
+ cd = (ComponentDefn) setCreationDate(cd, principal);
- //ComponentType type =
config.getComponentType(cd.getComponentTypeID().getFullName());
- ComponentType type = getComponentType(config,
cd.getComponentTypeID(), targetID);
+ ComponentType type = getComponentType(config, cd.getComponentTypeID(), targetID);
- // process properties for any encryptions
- processPropertyForNewObject(cd, type, config,
transaction.getLockAcquiredBy());
+ // process properties for any encryptions
+ processPropertyForNewObject(cd, type, config, principal);
- cfg.addComponentDefn(cd);
-
- } else if (action instanceof AddObject ||
- action instanceof RemoveObject) {
+ cfg.addComponentDefn(cd);
- if (cd == null) {
- throw new InvalidComponentException(ConfigMessages.CONFIG_0089,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0089, targetID));
- }
-// System.out.println("STRATEGY: Add or Remove object for target " +
targetID);
+ } else if (action instanceof AddObject
+ || action instanceof RemoveObject) {
- // ComponentType type =
config.getComponentType(cd.getComponentTypeID().getFullName());
- ComponentType type = getComponentType(config,
cd.getComponentTypeID(), targetID);
- cd = (ComponentDefn) setLastChangedDate(cd, transaction.getLockAcquiredBy());
+ if (cd == null) {
+ throw new InvalidComponentException(ConfigMessages.CONFIG_0089,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0089,targetID));
+ }
+ ComponentType type = getComponentType(config, cd.getComponentTypeID(), targetID);
+ cd = (ComponentDefn) setLastChangedDate(cd, principal);
+ processPropertyChanges(action, cd, type, config, principal);
- // System.out.println("STRATEGY: Got type for " + targetID);
- processPropertyChanges(action,
- cd,
- type,
- config,
- transaction.getLockAcquiredBy());
+ } else if (action instanceof ExchangeObject) {
+ ExchangeObject anAction = (ExchangeObject) action;
-// System.out.println("STRATEGY: End of Property changes " + targetID);
+ if (cd == null) {
+ throw new InvalidComponentException(
+ ConfigMessages.CONFIG_0089, ConfigPlugin.Util
+ .getString(ConfigMessages.CONFIG_0089,
+ targetID));
+ }
- } else if (action instanceof ExchangeObject) {
- ExchangeObject anAction = (ExchangeObject) action;
+ if (anAction.hasAttributeCode()
+ && (anAction.getAttributeCode().intValue() ==
ConfigurationModel.Attribute.PROPERTY
+ .getCode() || anAction.getAttributeCode()
+ .intValue() == ConfigurationModel.Attribute.PROPERTIES
+ .getCode())) {
- if (cd == null) {
- throw new InvalidComponentException(ConfigMessages.CONFIG_0089,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0089, targetID));
- }
-// System.out.println("STRATEGY: Exchange for Target " + targetID);
+ ComponentType type = getComponentType(config, cd.getComponentTypeID(), targetID);
+ cd = (ComponentDefn) setLastChangedDate(cd, principal);
+ processPropertyChanges(action, cd, type, config,principal);
- if (anAction.hasAttributeCode() &&
- (anAction.getAttributeCode().intValue() ==
ConfigurationModel.Attribute.PROPERTY.getCode() ||
- anAction.getAttributeCode().intValue() ==
ConfigurationModel.Attribute.PROPERTIES.getCode() ) ) {
+ } else if (anAction.hasAttributeCode()&&
anAction.getAttributeCode().intValue() == ConfigurationModel.Attribute.NAME.getCode()) {
+
+ throw new InvalidArgumentException(ConfigMessages.CONFIG_0090,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0090,action.getActionDescription(),targetID));
- // ComponentType type =
config.getComponentType(cd.getComponentTypeID().getFullName());
- ComponentType type = getComponentType(config,
cd.getComponentTypeID(), targetID);
+ } else if (anAction.hasAttributeCode()&&
anAction.getAttributeCode().intValue() == ConfigurationModel.Attribute.PSC_NAME.getCode())
{
+ throw new InvalidArgumentException(ConfigMessages.CONFIG_0090,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0090,action.getActionDescription(),targetID));
- // System.out.println("STRATEGY: Exchange Properties " + targetID);
- cd = (ComponentDefn) setLastChangedDate(cd, transaction.getLockAcquiredBy());
+ } else if (anAction.hasAttributeCode()&&
anAction.getAttributeCode().intValue() ==
ConfigurationModel.Attribute.IS_ENABLED.getCode()) {
+ throw new
InvalidArgumentException(ConfigMessages.CONFIG_0091,ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0091,
anAction.getActionDescription()));
- processPropertyChanges(action,
- cd,
- type,
- config,
- transaction.getLockAcquiredBy());
+ } else if (anAction.hasAttributeCode()&&
anAction.getAttributeCode().intValue() ==
ConfigurationModel.Attribute.ROUTING_UUID.getCode()) {
+ throw new
InvalidArgumentException(ConfigMessages.CONFIG_0091,ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0091,
anAction.getActionDescription()));
- } else if (anAction.hasAttributeCode() &&
anAction.getAttributeCode().intValue() == ConfigurationModel.Attribute.NAME.getCode()) {
- throw new InvalidArgumentException(ConfigMessages.CONFIG_0090,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0090, action.getActionDescription(),
targetID));
+ } else {
+ throw new
InvalidArgumentException(ConfigMessages.CONFIG_0091,ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0091,
anAction.getActionDescription()));
+ }
+ } else if (action instanceof DestroyObject) {
- } else if (anAction.hasAttributeCode() &&
anAction.getAttributeCode().intValue() == ConfigurationModel.Attribute.PSC_NAME.getCode())
{
- throw new InvalidArgumentException(ConfigMessages.CONFIG_0090,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0090, action.getActionDescription(),
targetID));
-
-
-
- } else if (anAction.hasAttributeCode() &&
anAction.getAttributeCode().intValue() ==
ConfigurationModel.Attribute.IS_ENABLED.getCode()) {
- throw new InvalidArgumentException(ConfigMessages.CONFIG_0091,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0091,
anAction.getActionDescription()));
-
-// System.out.println("STRATEGY: Exchange enables " + targetID);
-
- } else if (anAction.hasAttributeCode() &&
anAction.getAttributeCode().intValue() ==
ConfigurationModel.Attribute.ROUTING_UUID.getCode()) {
-// System.out.println("STRATEGY: Exchange routing " + targetID);
- throw new InvalidArgumentException(ConfigMessages.CONFIG_0091,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0091,
anAction.getActionDescription()));
-
- } else {
- throw new InvalidArgumentException(ConfigMessages.CONFIG_0091,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0091,
anAction.getActionDescription()));
- }
- } else if (action instanceof DestroyObject) {
-
- if (cd != null) {
-// System.out.println("STRATEGY: Destroy ComponentDefn Target " + targetID);
-
+ if (cd != null) {
delete(targetID, cfg);
- setLastChangedDate(config.getConfiguration(), transaction.getLockAcquiredBy());
+ setLastChangedDate(config.getConfiguration(), principal);
+ }
- }
+ } else {
+ throw new InvalidArgumentException(ConfigMessages.CONFIG_0091,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0091,action.getActionDescription()));
+ }
+ }
+ } catch (ConfigurationException ce) {
+ throw ce;
- } else {
- throw new InvalidArgumentException(ConfigMessages.CONFIG_0091,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0091, action.getActionDescription()));
- }
+ } catch (Exception e) {
+ ConfigurationException e2 = new ConfigurationException(e);
+ e2.setActionIndex(actionIndex);
+ throw e2;
+ }
- }
+ return affectedIDs;
+ }
- } catch (ConfigurationException ce) {
- throw ce;
+ private Set executeActions(ConnectorBindingID targetID, List actions,
ConfigurationModelContainerImpl config, String principal)
+ throws InvalidDeployedComponentException, ConfigurationException {
+ Set affectedIDs = new HashSet();
+ if (actions.isEmpty()) {
+ return affectedIDs;
+ }
- } catch ( Exception e ) {
- ConfigurationException e2 = new ConfigurationException(e);
- e2.setActionIndex(actionIndex);
- throw e2;
- }
-
-
- return affectedIDs;
-
- }
-
-
- public Set executeActions( ConfigurationModelContainerImpl config,
ConnectorBindingID targetID, List actions, XMLConfigurationConnector transaction) throws
InvalidDeployedComponentException, ConfigurationException{
- Set affectedIDs = new HashSet();
- if ( actions.isEmpty() ) {
- return affectedIDs;
- }
-// System.out.println("STRATEGY: ConnectorBinding Target " + targetID + "
on config " + config.getConfigurationID());
-
- int actionIndex = -1;
-
- affectedIDs.add(targetID);
-
+ int actionIndex = -1;
+ affectedIDs.add(targetID);
BasicConfiguration cfg = (BasicConfiguration) config.getConfiguration();
- try {
+ try {
- // Iterate through the actions ...
- Iterator iter = actions.iterator();
- while ( iter.hasNext() ) {
- ActionDefinition action = (ActionDefinition) iter.next();
- actionIndex++;
- Object args[] = action.getArguments();
+ // Iterate through the actions ...
+ Iterator iter = actions.iterator();
+ while (iter.hasNext()) {
+ ActionDefinition action = (ActionDefinition) iter.next();
+ actionIndex++;
+ Object args[] = action.getArguments();
ComponentDefn cd = cfg.getConnectorBinding(targetID);
- if(action instanceof CreateObject ) {
+ if (action instanceof CreateObject) {
- if (cd!= null) {
- DuplicateComponentException e = new
DuplicateComponentException(ConfigMessages.CONFIG_0092,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0092, targetID));
- e.setActionIndex(actionIndex);
- throw e;
- }
- cd = (ComponentDefn) args[0];
+ if (cd != null) {
+ DuplicateComponentException e = new
DuplicateComponentException(ConfigMessages.CONFIG_0092,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0092,targetID));
+ e.setActionIndex(actionIndex);
+ throw e;
+ }
+ cd = (ComponentDefn) args[0];
+ cd = (ComponentDefn) setCreationDate(cd, principal);
+ ComponentType type = getComponentType(config, cd.getComponentTypeID(), targetID);
- cd = (ComponentDefn) setCreationDate(cd, transaction.getLockAcquiredBy());
+ // process properties for any encryptions
+ processPropertyForNewObject(cd, type, config, principal);
+ cfg.addComponentDefn(cd);
- // ComponentType type = getComponentType(config,
cd.getComponentTypeID(), targetID);
- ComponentType type = getComponentType(config,
cd.getComponentTypeID(), targetID);
+ } else if (action instanceof AddObject
+ || action instanceof RemoveObject) {
- // process properties for any encryptions
- processPropertyForNewObject(cd, type, config,
transaction.getLockAcquiredBy());
+ if (cd == null) {
+ throw new InvalidComponentException(ConfigMessages.CONFIG_0093,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0093,targetID));
+ }
-// System.out.println("STRATEGY: Add ConnectorBinding Target " + dvt.getID() +
" to config " + cfg.getID());
+ ComponentType type = getComponentType(config, cd.getComponentTypeID(), targetID);
+ cd = (ComponentDefn) setLastChangedDate(cd, principal);
+ processPropertyChanges(action, cd, type, config, principal);
- cfg.addComponentDefn(cd);
+ } else if (action instanceof ExchangeObject) {
+ ExchangeObject anAction = (ExchangeObject) action;
- } else if (action instanceof AddObject ||
- action instanceof RemoveObject) {
+ if (cd == null) {
+ throw new InvalidComponentException(ConfigMessages.CONFIG_0093,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0093,targetID));
+ }
+ if (anAction.hasAttributeCode() && (anAction.getAttributeCode().intValue()
== ConfigurationModel.Attribute.PROPERTY.getCode() ||
anAction.getAttributeCode().intValue() ==
ConfigurationModel.Attribute.PROPERTIES.getCode())) {
+ ComponentType type = getComponentType(config, cd.getComponentTypeID(), targetID);
+ cd = (ComponentDefn) setLastChangedDate(cd, principal);
+ processPropertyChanges(action, cd, type, config,principal);
- if (cd == null) {
- throw new InvalidComponentException(ConfigMessages.CONFIG_0093,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0093, targetID));
- }
-// System.out.println("STRATEGY: Add or Remove ConnectorBinding Property " +
dvt.getID() + " to config " + cfg.getID());
+ } else if (anAction.hasAttributeCode()&&
anAction.getAttributeCode().intValue() == ConfigurationModel.Attribute.NAME.getCode()) {
+ throw new InvalidArgumentException(ConfigMessages.CONFIG_0094,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0094,action.getActionDescription(),targetID));
+ } else if (anAction.hasAttributeCode()&&
anAction.getAttributeCode().intValue() ==
ConfigurationModel.Attribute.IS_ENABLED.getCode()) {
+ throw new
InvalidArgumentException(ConfigMessages.CONFIG_0096,ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0096,
anAction.getActionDescription()));
+ } else if (anAction.hasAttributeCode()&&
anAction.getAttributeCode().intValue() ==
ConfigurationModel.Attribute.ROUTING_UUID.getCode()) {
+ cd = (ConnectorBinding) setLastChangedDate(cd,principal);
+ setRoutingUUID((ConnectorBinding) cd, (String) anAction.getNewValue());
+ } else {
+ throw new
InvalidArgumentException(ConfigMessages.CONFIG_0096,ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0096,
anAction.getActionDescription()));
+ }
- // ComponentType type =
config.getComponentType(cd.getComponentTypeID().getFullName());
- ComponentType type = getComponentType(config,
cd.getComponentTypeID(), targetID);
-
- cd = (ComponentDefn) setLastChangedDate(cd,
transaction.getLockAcquiredBy());
-
- processPropertyChanges(action,
- cd,
- type,
- config,
- transaction.getLockAcquiredBy());
-
-
- } else if (action instanceof ExchangeObject) {
- ExchangeObject anAction = (ExchangeObject) action;
-
-
- if (cd == null) {
- throw new InvalidComponentException(ConfigMessages.CONFIG_0093,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0093, targetID));
- }
-
-
- if (anAction.hasAttributeCode() &&
- (anAction.getAttributeCode().intValue() ==
ConfigurationModel.Attribute.PROPERTY.getCode() ||
- anAction.getAttributeCode().intValue() ==
ConfigurationModel.Attribute.PROPERTIES.getCode() ) ) {
-// System.out.println("STRATEGY: Exchange ConnectorBinding Properties for Target
" + dvt.getID() + " to config " + cfg.getID());
-
- // ComponentType type =
config.getComponentType(cd.getComponentTypeID().getFullName());
- ComponentType type = getComponentType(config,
cd.getComponentTypeID(), targetID);
-
- cd = (ComponentDefn) setLastChangedDate(cd,
transaction.getLockAcquiredBy());
-
- processPropertyChanges(action,
- cd,
- type,
- config,
- transaction.getLockAcquiredBy());
-
- } else if (anAction.hasAttributeCode() &&
anAction.getAttributeCode().intValue() == ConfigurationModel.Attribute.NAME.getCode()) {
- throw new InvalidArgumentException(ConfigMessages.CONFIG_0094,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0094,
action.getActionDescription(),targetID));
-
-
-// } else if (anAction.hasAttributeCode() &&
anAction.getAttributeCode().intValue() == ConfigurationModel.Attribute.PSC_NAME.getCode())
{
-//
-//// System.out.println("STRATEGY: Exchange ConnectorBinding PSC for Target " +
dvt.getID() + " for PSC exchange");
-//
-// ProductServiceConfigID pscID =
(ProductServiceConfigID)anAction.getNewValue();
-// ProductServiceConfig psc = config.getConfiguration().getPSC(pscID);
-//
-// if (psc == null) {
-// throw new InvalidComponentException(ConfigMessages.CONFIG_0095,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0095, pscID,
config.getConfigurationID()));
-// }
-//
-// setLastChangedDate(psc, transaction.getLockAcquiredBy());
-//
-// // add the service the PSC
-// ConfigurationObjectEditorHelper.addServiceComponentDefn(psc, targetID);
-
-
- } else if (anAction.hasAttributeCode() &&
anAction.getAttributeCode().intValue() ==
ConfigurationModel.Attribute.IS_ENABLED.getCode()) {
- throw new InvalidArgumentException(ConfigMessages.CONFIG_0096,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0096, anAction.getActionDescription()
));
-
-//System.out.println("STRATEGY: Exchange ConnectorBinding isEnabled for Target
" + dvt.getID() + " to config " + cfg.getID());
-
- } else if (anAction.hasAttributeCode() &&
anAction.getAttributeCode().intValue() ==
ConfigurationModel.Attribute.ROUTING_UUID.getCode()) {
-// System.out.println("STRATEGY: Exchange ConnectorBinding RoutingUUID for Target
" + dvt.getID() + " to config " + cfg.getID());
-
- cd = (ConnectorBinding) setLastChangedDate(cd,
transaction.getLockAcquiredBy());
-
- setRoutingUUID((ConnectorBinding) cd, (String)
anAction.getNewValue());
-
- } else {
- throw new InvalidArgumentException(ConfigMessages.CONFIG_0096,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0096, anAction.getActionDescription()
));
- }
-
-
- } else if (action instanceof DestroyObject) {
- if (cd != null) {
-// System.out.println("STRATEGY: Destroy ConnectorBinding Target " +
targetID);
-
+ } else if (action instanceof DestroyObject) {
+ if (cd != null) {
delete(targetID, cfg);
- setLastChangedDate(config.getConfiguration(), transaction.getLockAcquiredBy());
+ setLastChangedDate(config.getConfiguration(), principal);
+ }
- }
+ } else {
+ throw new InvalidArgumentException(ConfigMessages.CONFIG_0096,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0096,action.getActionDescription()));
+ }
+ }
+ } catch (ConfigurationException ce) {
+ throw ce;
- } else {
- throw new InvalidArgumentException(ConfigMessages.CONFIG_0096,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0096, action.getActionDescription() ));
- }
+ } catch (Exception e) {
+ ConfigurationException e2 = new ConfigurationException(e);
+ e2.setActionIndex(actionIndex);
+ throw e2;
+ }
- }
+ return affectedIDs;
+ }
- } catch (ConfigurationException ce) {
- throw ce;
+ private Set executeActions(ConfigurationID targetID, List actions,
ConfigurationModelContainerImpl config, String principal, XMLConfigurationConnector
transaction) throws InvalidConfigurationException, ConfigurationException {
+ Set affectedIDs = new HashSet();
+ if (actions.isEmpty()) {
+ return affectedIDs;
+ }
- } catch ( Exception e ) {
- ConfigurationException e2 = new ConfigurationException(e);
- e2.setActionIndex(actionIndex);
- throw e2;
- }
+ int actionIndex = -1;
+ BasicConfiguration dvt = null;
- return affectedIDs;
+ affectedIDs.add(targetID);
- }
+ try {
+ Iterator iter = actions.iterator();
+ while (iter.hasNext()) {
+ ActionDefinition action = (ActionDefinition) iter.next();
+ actionIndex++;
+ Object args[] = action.getArguments();
+ if (action.hasAttributeCode() && (action.getAttributeCode().intValue() ==
ConfigurationModel.Attribute.CURRENT_CONFIGURATION .getCode() ||
action.getAttributeCode().intValue() ==
ConfigurationModel.Attribute.NEXT_STARTUP_CONFIGURATION.getCode())) {
+ throw new InvalidArgumentException(ConfigMessages.CONFIG_0097,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0097,action.getActionDescription()));
+ }
+ // NOTE: These changes are always made within a transaction and
+ // a configurtation is never deleted without one taking its
+ // place.
+ // And when a delete occurs, a new empty model will take its
+ // place.
+ // Therefore, a model will ALWAYS exists
+ if (action instanceof CreateObject) {
+ Object obj = args[0];
+ if (obj instanceof Collection) {
+ Collection objs = (Collection) obj;
+ // Not sure of this pattern here - rareddy
+ ConfigurationModelContainerImpl newConfig = new
ConfigurationModelContainerImpl();
+ transaction.setConfigurationModel(newConfig);
+ newConfig.setConfigurationObjects(objs);
- public Set executeActions( ConfigurationID targetID, List actions,
XMLConfigurationConnector transaction) throws InvalidConfigurationException,
ConfigurationException{
- Set affectedIDs = new HashSet();
- if ( actions.isEmpty() ) {
- return affectedIDs;
- }
-// System.out.println("STRATEGY: Configuaraton Target " + targetID);
+ for (Iterator it = objs.iterator(); it.hasNext();) {
+ Object o = it.next();
+ if (o instanceof ComponentObject) {
+ ComponentObject co = (ComponentObject) o;
+ ComponentType type = getComponentType(config,co.getComponentTypeID(), targetID);
+ processPropertyForNewObject(co, type, config,principal);
+ }
+ }
+ } else {
+ dvt = (BasicConfiguration) obj;
+ config.addObject(dvt);
+ }
- int actionIndex = -1;
+ } else if (action instanceof AddObject || action instanceof RemoveObject || action
instanceof ExchangeObject) {
+ Configuration configuration = config.getConfiguration();
+ if (configuration == null) {
+ throw new InvalidComponentException(ConfigMessages.CONFIG_0098,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0098,targetID));
+ }
- ConfigurationModelContainerImpl config = getConfigModel(targetID, transaction);
+ ComponentType type = getComponentType(config, configuration.getComponentTypeID(),
targetID);
+ processPropertyChanges(action, configuration, type, config,principal);
+ } else if (action instanceof DestroyObject) {
+ // create an empty model
+ // the assumption here is there should other actions as part
+ // of this
+ // transaction that will load the container before it is
+ // committed
- BasicConfiguration dvt = null;
+ // Not sure of this pattern here - rareddy
+ ConfigurationModelContainerImpl emptyConfig = new
ConfigurationModelContainerImpl();
+ transaction.setConfigurationModel(emptyConfig);
- affectedIDs.add(targetID);
+ } else {
+ throw new InvalidArgumentException(ConfigMessages.CONFIG_0099,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0099,action.getActionDescription()));
+ }
- try {
+ } // end of while loop
+ } catch (ConfigurationException ce) {
+ throw ce;
- // Iterate through the actions ...
- Iterator iter = actions.iterator();
- while ( iter.hasNext() ) {
- ActionDefinition action = (ActionDefinition) iter.next();
- actionIndex++;
- Object args[] = action.getArguments();
+ } catch (Exception e) {
- if (action.hasAttributeCode() &&
- (action.getAttributeCode().intValue() ==
ConfigurationModel.Attribute.CURRENT_CONFIGURATION.getCode() ||
- action.getAttributeCode().intValue() ==
ConfigurationModel.Attribute.NEXT_STARTUP_CONFIGURATION.getCode() ) ) {
- // || action.getAttributeCode().intValue() ==
ConfigurationModel.Attribute.STARTUP_CONFIGURATION.getCode())
-
- throw new InvalidArgumentException(ConfigMessages.CONFIG_0097,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0097, action.getActionDescription() ));
- }
+ ConfigurationException e2 = new ConfigurationException(e);
+ e2.setActionIndex(actionIndex);
+ throw e2;
+ }
+ return affectedIDs;
- // NOTE: These changes are always made within a transaction and
- // a configurtation is never deleted without one taking its place.
- // And when a delete occurs, a new empty model will take its place.
- // Therefore, a model will ALWAYS exists
- if(action instanceof CreateObject ) {
-// System.out.println("STRATEGY: CREATE Configuaraton " + targetID);
- Object obj = args[0];
- if (obj instanceof Collection) {
- Collection objs = (Collection) obj;
-// System.out.println("TRANS SIZE 1: " +
transaction.getObjects().size());
+ }
- ConfigurationModelContainerImpl newConfig = new
ConfigurationModelContainerImpl();
- transaction.addObjects(targetID.getFullName(), newConfig);
+ private Set executeActions(ComponentTypeID targetID, List
actions,ConfigurationModelContainerImpl config, String principal)
+ throws InvalidConfigurationException, ConfigurationException {
+
+ Set affectedIDs = new HashSet();
+ if (actions.isEmpty()) {
+ return affectedIDs;
+ }
-// System.out.println("STRATEGY: # OF CONFIG OBJS: " +
objs.size());
- newConfig.setConfigurationObjects(objs);
+ int actionIndex = -1;
- for (Iterator it=objs.iterator(); it.hasNext(); ) {
- Object o = it.next();
- if (o instanceof ComponentObject) {
- ComponentObject co = (ComponentObject) o;
- // ComponentType type =
newConfig.getComponentType(co.getComponentTypeID().getFullName());
- ComponentType type = getComponentType(newConfig,
co.getComponentTypeID(), targetID);
+ affectedIDs.add(targetID);
- // process properties for any encryptions
- processPropertyForNewObject(co, type, newConfig,
transaction.getLockAcquiredBy());
- }
+ try {
- }
+ // Iterate through the actions ...
+ Iterator iter = actions.iterator();
+ while (iter.hasNext()) {
+ ActionDefinition action = (ActionDefinition) iter.next();
-// System.out.println("TRANS SIZE 2: " +
transaction.getObjects().size());
+ actionIndex++;
+ Object args[] = action.getArguments();
- } else {
- dvt = (BasicConfiguration) obj;
+ if (action instanceof CreateObject) {
- config.addObject(dvt);
+ ComponentType type = config.getComponentType(targetID
+ .getFullName());
- }
+ if (type != null) {
+ // because types are not configuration bound, the create
+ // for the type will only be added where it does not
+ // exist
+ DuplicateComponentException e = new
DuplicateComponentException(ConfigMessages.CONFIG_0100,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0100,targetID));
+ e.setActionIndex(actionIndex);
+ throw e;
+ }
- } else if (action instanceof AddObject ||
- action instanceof RemoveObject ||
- action instanceof ExchangeObject) {
+ BasicComponentType dvt = (BasicComponentType) args[0];
+ setCreationDate(dvt, principal);
+ config.addComponentType(dvt);
- Configuration configuration = config.getConfiguration();
+ } else if (action instanceof AddObject
+ || action instanceof RemoveObject) {
+ throw new InvalidArgumentException(ConfigMessages.CONFIG_0101,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0101,action.getActionDescription()));
- if (configuration == null) {
- throw new InvalidComponentException(ConfigMessages.CONFIG_0098,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0098, targetID));
- }
+ } else if (action instanceof ExchangeObject) {
+ ExchangeObject exchangeAction = (ExchangeObject) action;
- //ComponentType type =
config.getComponentType(configuration.getComponentTypeID().getFullName());
- // ComponentType type = getComponentType(config,
configuration.getComponentTypeID(), targetID);
- ComponentType type = getComponentType(config,
configuration.getComponentTypeID(), targetID);
+ ComponentType type = config.getComponentType(targetID.getFullName());
- processPropertyChanges(action,
- configuration,
- type,
- config,
- transaction.getLockAcquiredBy());
-
- } else if (action instanceof DestroyObject) {
-// System.out.println("STRATEGY: DESTROY Configuaraton " + targetID);
-
- // create an empty model
- // the assumption here is there should other actions as part of this
- // transaction that will load the container before it is committed
- ConfigurationModelContainerImpl emptyConfig = new
ConfigurationModelContainerImpl();
- transaction.addObjects(targetID.getFullName(), emptyConfig);
-
- } else {
- throw new InvalidArgumentException(ConfigMessages.CONFIG_0099,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0099, action.getActionDescription()));
- }
-
- } // end of while loop
-
-
- } catch (ConfigurationException ce) {
- throw ce;
-
- } catch ( Exception e ) {
-
- ConfigurationException e2 = new ConfigurationException(e);
- e2.setActionIndex(actionIndex);
- throw e2;
- }
- return affectedIDs;
-
-
-
- }
-
-
- public Set executeActions(ConfigurationModelContainerImpl config,ComponentTypeID
targetID, List actions, XMLConfigurationConnector transaction) throws
InvalidConfigurationException, ConfigurationException {
- Set affectedIDs = new HashSet();
- if ( actions.isEmpty() ) {
- return affectedIDs;
- }
-// System.out.println("STRATEGY: ComponentType Target " + targetID);
-
- int actionIndex = -1;
-
- affectedIDs.add(targetID);
-
- try {
-
- // Iterate through the actions ...
- Iterator iter = actions.iterator();
- while ( iter.hasNext() ) {
- ActionDefinition action = (ActionDefinition) iter.next();
-
- actionIndex++;
- Object args[] = action.getArguments();
-
- if(action instanceof CreateObject) {
-
- ComponentType type = config.getComponentType(targetID.getFullName());
-
- if ( type != null ) {
-//
System.out.println(ConfigPlugin.Util.getString(LogMessageKeys.CONFIG_0005, targetID));
-
- // because types are not configuration bound, the create
- // for the type will only be added where it does not exist
- DuplicateComponentException e = new
DuplicateComponentException(ConfigMessages.CONFIG_0100,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0100,targetID ));
- e.setActionIndex(actionIndex);
- throw e;
- }
- // System.out.println("STRATEGY: Add ComponentType Target " + targetID);
-
- BasicComponentType dvt = (BasicComponentType) args[0];
-
- setCreationDate(dvt, transaction.getLockAcquiredBy());
-
- config.addComponentType(dvt);
-
-// if (dvt.isOfTypeConnector()) {
-// // the new type must be added to the connector product type.
-// ProductType pt =
config.getProductType(MetaMatrixProductVersion.CONNECTOR_PRODUCT_TYPE_NAME);
-// ConfigurationObjectEditorHelper.addServiceComponentType(pt,
dvt);
-// }
-
- } else if (action instanceof AddObject ||
- action instanceof RemoveObject) {
- throw new InvalidArgumentException(ConfigMessages.CONFIG_0101,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0101,action.getActionDescription()));
-
-
- } else if (action instanceof ExchangeObject) {
- ExchangeObject exchangeAction = (ExchangeObject) action;
-
-
- ComponentType type = config.getComponentType(targetID.getFullName());
-
if (type == null) {
- throw new
InvalidDeployedComponentException(ConfigMessages.CONFIG_0102,ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0102,targetID));
- }
+ throw new InvalidDeployedComponentException(ConfigMessages.CONFIG_0102,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0102,targetID));
+ }
- BasicComponentType bct = (BasicComponentType) type;
+ BasicComponentType bct = (BasicComponentType) type;
- if (action.hasAttributeCode() &&
action.getAttributeCode().intValue() ==
ConfigurationModel.Attribute.UPDATE_COMPONENT_TYPE.getCode()) {
+ if (action.hasAttributeCode()&& action.getAttributeCode().intValue() ==
ConfigurationModel.Attribute.UPDATE_COMPONENT_TYPE.getCode()) {
- ComponentType newCt =
(ComponentType)exchangeAction.getNewValue();
- setLastChangedDate(newCt, transaction.getLockAcquiredBy());
-
-
config.addComponentType((ComponentType)exchangeAction.getNewValue());
-
+ ComponentType newCt = (ComponentType) exchangeAction.getNewValue();
+ setLastChangedDate(newCt, principal);
- } else if (action.hasAttributeCode() &&
action.getAttributeCode().intValue() ==
ConfigurationModel.Attribute.PARENT_COMPONENT_TYPEID.getCode()) {
+ config.addComponentType((ComponentType) exchangeAction.getNewValue());
- bct.setParentComponentTypeID((ComponentTypeID)exchangeAction.getNewValue());
+ } else if (action.hasAttributeCode()&& action.getAttributeCode().intValue()
== ConfigurationModel.Attribute.PARENT_COMPONENT_TYPEID.getCode()) {
- setLastChangedDate(bct, transaction.getLockAcquiredBy());
+ bct.setParentComponentTypeID((ComponentTypeID) exchangeAction.getNewValue());
+ setLastChangedDate(bct, principal);
- } else if (action.hasAttributeCode() &&
action.getAttributeCode().intValue() ==
ConfigurationModel.Attribute.SUPER_COMPONENT_TYPEID.getCode()){
+ } else if (action.hasAttributeCode()&& action.getAttributeCode().intValue()
== ConfigurationModel.Attribute.SUPER_COMPONENT_TYPEID.getCode()) {
- bct.setSuperComponentTypeID((ComponentTypeID)exchangeAction.getNewValue());
+ bct.setSuperComponentTypeID((ComponentTypeID) exchangeAction.getNewValue());
- setLastChangedDate(bct, transaction.getLockAcquiredBy());
+ setLastChangedDate(bct, principal);
- } else {
- throw new InvalidArgumentException(ConfigMessages.CONFIG_0101,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0101,action.getActionDescription()));
- }
- } else if (action instanceof ExchangeBoolean) {
- throw new InvalidArgumentException(ConfigMessages.CONFIG_0101,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0101,action.getActionDescription()));
+ } else {
+ throw new InvalidArgumentException(ConfigMessages.CONFIG_0101,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0101,action.getActionDescription()));
+ }
+ } else if (action instanceof ExchangeBoolean) {
+ throw new InvalidArgumentException(ConfigMessages.CONFIG_0101,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0101,action.getActionDescription()));
- } else if (action instanceof DestroyObject) {
+ } else if (action instanceof DestroyObject) {
- ComponentType type = config.getComponentType(targetID.getFullName());
+ ComponentType type = config.getComponentType(targetID.getFullName());
if (type != null) {
-
- Collection services =
config.getConfiguration().getComponentDefnIDs((ComponentTypeID) type.getID());
- if (services != null && services.size() > 0) {
- ComponentDefnID d = (ComponentDefnID)
services.iterator().next();
- throw new
InvalidDeployedComponentException(ConfigPlugin.Util.getString("XMLActionUpdateStrategy.Unable_to_delete_component_type_related_components_found",
new Object[] {type.getID(), d.getFullName()})); //$NON-NLS-1$
-
- }
-
- config.remove(targetID);
- setLastChangedDate(config.getConfiguration(), transaction.getLockAcquiredBy());
+ Collection services =
config.getConfiguration().getComponentDefnIDs((ComponentTypeID) type.getID());
+ if (services != null && services.size() > 0) {
+ ComponentDefnID d = (ComponentDefnID) services.iterator().next();
+ throw new
InvalidDeployedComponentException(ConfigPlugin.Util.getString("XMLActionUpdateStrategy.Unable_to_delete_component_type_related_components_found",
new Object[] { type.getID(), d.getFullName() })); //$NON-NLS-1$
+ }
- }
+ config.remove(targetID);
- } else {
- throw new InvalidArgumentException(ConfigMessages.CONFIG_0101,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0101,action.getActionDescription()));
- }
- }
+ setLastChangedDate(config.getConfiguration(), principal);
+ }
- } catch (ConfigurationException ce) {
- throw ce;
+ } else {
+ throw new InvalidArgumentException(ConfigMessages.CONFIG_0101,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0101,action.getActionDescription()));
+ }
+ }
- } catch ( Exception e ) {
+ } catch (ConfigurationException ce) {
+ throw ce;
- ConfigurationException e2 = new ConfigurationException(e);
- e2.setActionIndex(actionIndex);
- throw e2;
- }
+ } catch (Exception e) {
- return affectedIDs;
+ ConfigurationException e2 = new ConfigurationException(e);
+ e2.setActionIndex(actionIndex);
+ throw e2;
+ }
- }
+ return affectedIDs;
+ }
- public Set executeActions(ConfigurationModelContainerImpl config,
ComponentTypeDefnID targetID, List actions, XMLConfigurationConnector transaction) throws
InvalidConfigurationException, ConfigurationException {
+ private Set executeActions(ComponentTypeDefnID targetID, List actions,
ConfigurationModelContainerImpl config, String principal)
+ throws InvalidConfigurationException, ConfigurationException {
- /**
- * This method is used for the mass importing of a configuration, instead of
- * recreating every object using the editor.
- *
- * NOTE: DO NOT add calls for setting history in this method because the importing
- * should retain what the original file contained.
- */
- Set affectedIDs = new HashSet();
- if ( actions.isEmpty() ) {
- return affectedIDs;
- }
+ /**
+ * This method is used for the mass importing of a configuration,
+ * instead of recreating every object using the editor.
+ *
+ * NOTE: DO NOT add calls for setting history in this method because the
+ * importing should retain what the original file contained.
+ */
+ Set affectedIDs = new HashSet();
+ if (actions.isEmpty()) {
+ return affectedIDs;
+ }
- int actionIndex = -1;
- affectedIDs.add(targetID);
+ int actionIndex = -1;
+ affectedIDs.add(targetID);
- try {
+ try {
+ // Iterate through the actions ...
+ Iterator iter = actions.iterator();
+ while (iter.hasNext()) {
+ ActionDefinition action = (ActionDefinition) iter.next();
+ actionIndex++;
+ Object args[] = action.getArguments();
+ BasicComponentTypeDefn dvt = (BasicComponentTypeDefn) args[0];
+ ComponentType type = getComponentType(config, dvt.getComponentTypeID(), targetID);
- // Iterate through the actions ...
- Iterator iter = actions.iterator();
- while ( iter.hasNext() ) {
- ActionDefinition action = (ActionDefinition) iter.next();
- actionIndex++;
- Object args[] = action.getArguments();
+ if (action instanceof CreateObject) {
+ if (type.getComponentTypeDefinition(dvt.getFullName()) != null) {
+ // this check is added because when the editor is used
+ // by the importer,
+ // it creates actions for this defn where the component
+ // type
+ // that it added already contains the definitions.
+ // Therefore, only throw an exception if it is
+ // different.
+ ComponentTypeDefn ctd = type.getComponentTypeDefinition(dvt.getFullName());
+ if (dvt.equals(ctd)) {
+ } else {
+ DuplicateComponentException e = new
DuplicateComponentException(ConfigMessages.CONFIG_0104,ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0104,targetID));
+ e.setActionIndex(actionIndex);
+ throw e;
+ }
+ }
- BasicComponentTypeDefn dvt = (BasicComponentTypeDefn) args[0];
-// ComponentTypeID typeID = dvt.getComponentTypeID();
+ BasicComponentType btype = (BasicComponentType) type;
+ btype.addComponentTypeDefinition(dvt);
- //ComponentType type = config.getComponentType(typeID.getFullName());
+ } else if (action instanceof ExchangeObject) {
+ BasicComponentType btype = (BasicComponentType) type;
- ComponentType type = getComponentType(config, dvt.getComponentTypeID(),
targetID);
-
-// if (type == null) {
-// throw new
InvalidDeployedComponentException(ConfigMessages.CONFIG_0102,ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0102,typeID));
-// }
+ if (type.getComponentTypeDefinition(dvt.getFullName()) == null) {
+ btype.removeComponentTypeDefinition(dvt);
+ }
+ btype.addComponentTypeDefinition(dvt);
+ } else if (action instanceof DestroyObject) {
+ if (type.getComponentTypeDefinition(dvt.getFullName()) != null) {
+ BasicComponentType btype = (BasicComponentType) type;
+ btype.removeComponentTypeDefinition(dvt);
+ }
+ } else {
+ throw new InvalidArgumentException(ConfigMessages.CONFIG_0103,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0103,action.getActionDescription()));
+ }
+ }
+ } catch (ConfigurationException ce) {
+ throw ce;
+ } catch (Exception e) {
+ ConfigurationException e2 = new ConfigurationException(e);
+ e2.setActionIndex(actionIndex);
+ throw e2;
+ }
+ return affectedIDs;
+ }
- if(action instanceof CreateObject) {
- if (type.getComponentTypeDefinition(dvt.getFullName()) != null) {
- // this check is added because when the editor is used by the
importer,
- // it creates actions for this defn where the component type
- // that it added already contains the definitions.
- // Therefore, only throw an exception if it is different.
- ComponentTypeDefn ctd =
type.getComponentTypeDefinition(dvt.getFullName());
- if (dvt.equals(ctd)) {
- } else {
- DuplicateComponentException e = new
DuplicateComponentException(ConfigMessages.CONFIG_0104,ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0104,targetID));
- e.setActionIndex(actionIndex);
- throw e;
- }
- }
+ private Set executeActions(PropDefnAllowedValueID targetID, List actions) {
+ Set affectedIDs = new HashSet();
+ if (actions.isEmpty()) {
+ return affectedIDs;
+ }
- BasicComponentType btype = (BasicComponentType) type;
- btype.addComponentTypeDefinition(dvt);
+ affectedIDs.add(targetID);
+ return affectedIDs;
+ }
+ private Set executeActions(HostID targetID, List actions,ConfigurationModelContainerImpl
config, String principal)
+ throws InvalidComponentException, ConfigurationException {
+ Set affectedIDs = new HashSet();
+ if (actions.isEmpty()) {
+ return affectedIDs;
+ }
- } else if (action instanceof ExchangeObject) {
- BasicComponentType btype = (BasicComponentType) type;
+ int actionIndex = -1;
+ BasicHost dvt = null;
- if (type.getComponentTypeDefinition(dvt.getFullName()) == null) {
- btype.removeComponentTypeDefinition(dvt);
- }
+ affectedIDs.add(targetID);
- btype.addComponentTypeDefinition(dvt);
- } else if (action instanceof DestroyObject) {
- if (type.getComponentTypeDefinition(dvt.getFullName()) == null) {
+ try {
- } else {
+ // Iterate through the actions ...
+ Iterator iter = actions.iterator();
+ while (iter.hasNext()) {
+ ActionDefinition action = (ActionDefinition) iter.next();
+ actionIndex++;
+ Object args[] = action.getArguments();
- BasicComponentType btype = (BasicComponentType) type;
- btype.removeComponentTypeDefinition(dvt);
- }
-
-
- } else {
- throw new
InvalidArgumentException(ConfigMessages.CONFIG_0103,ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0103,action.getActionDescription()
));
- }
- }
-
-
- } catch (ConfigurationException ce) {
- throw ce;
-
- } catch ( Exception e ) {
-
- ConfigurationException e2 = new ConfigurationException(e);
- e2.setActionIndex(actionIndex);
- throw e2;
- }
-
- return affectedIDs;
-
-
- }
-
-
- public Set executeActions(ConfigurationModelContainerImpl
config,PropDefnAllowedValueID targetID, List actions, XMLConfigurationConnector
transaction ) throws InvalidConfigurationException, ConfigurationException {
- Set affectedIDs = new HashSet();
- if ( actions.isEmpty() ) {
- return affectedIDs;
- }
-
- affectedIDs.add(targetID);
-
-
-
- return affectedIDs;
- }
-
-
-
-
- public Set executeActions(ConfigurationModelContainerImpl config, HostID targetID,
List actions, XMLConfigurationConnector transaction) throws InvalidComponentException,
ConfigurationException{
- Set affectedIDs = new HashSet();
- if ( actions.isEmpty() ) {
- return affectedIDs;
- }
-// System.out.println("STRATEGY: Update Host " + targetID);
-
- int actionIndex = -1;
- BasicHost dvt = null;
-
- affectedIDs.add(targetID);
-
- try {
-
- // Iterate through the actions ...
- Iterator iter = actions.iterator();
- while ( iter.hasNext() ) {
- ActionDefinition action = (ActionDefinition) iter.next();
- actionIndex++;
- Object args[] = action.getArguments();
-
- if(action instanceof CreateObject ) {
+ if (action instanceof CreateObject) {
Host host = config.getHost(targetID.getFullName());
- if (host != null) {
- // because hosts are not configuration bound, the create
- // for the hosts will only be added where it does not exist
- continue;
+ if (host != null) {
+ // because hosts are not configuration bound, the create
+ // for the hosts will only be added where it does not
+ // exist
+ continue;
+ }
+ dvt = (BasicHost) args[0];
-// DuplicateComponentException e = new
DuplicateComponentException("The host (\"" + targetID + "\")
already exists and may not be recreated");
-// e.setActionIndex(actionIndex);
-// throw e;
- }
- dvt = (BasicHost) args[0];
+ // call to validate the type exists
+ getComponentType(config, dvt.getComponentTypeID(), targetID);
- // call to validate the type exists
- getComponentType(config, dvt.getComponentTypeID(), targetID);
+ dvt = (BasicHost) setCreationDate(dvt, principal);
+ BasicConfiguration bc = (BasicConfiguration) config.getConfiguration();
+ bc.addHost(dvt);
- dvt = (BasicHost) setCreationDate(dvt, transaction.getLockAcquiredBy());
-
- BasicConfiguration bc = (BasicConfiguration) config.getConfiguration();
- bc.addHost(dvt);
+ } else if (action instanceof AddObject
+ || action instanceof RemoveObject
+ || action instanceof ExchangeObject) {
- } else if (action instanceof AddObject ||
- action instanceof RemoveObject ||
- action instanceof ExchangeObject) {
-
-
Host host = config.getHost(targetID.getFullName());
- if (host == null) {
- throw new
InvalidComponentException(ConfigMessages.CONFIG_0105,ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0105,targetID));
- }
+ if (host == null) {
+ throw new InvalidComponentException(ConfigMessages.CONFIG_0105,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0105,targetID));
+ }
- // ComponentType type =
config.getComponentType(host.getComponentTypeID().getFullName());
- ComponentType type = getComponentType(config,
host.getComponentTypeID(), targetID);
+ ComponentType type = getComponentType(config, host.getComponentTypeID(), targetID);
+ host = (Host) setLastChangedDate(host, principal);
+ processPropertyChanges(action, host, type, config,principal);
- host = (Host) setLastChangedDate(host,
transaction.getLockAcquiredBy());
-
- processPropertyChanges(action,
- host,
- type,
- config,
- transaction.getLockAcquiredBy());
-
-
- } else if (action instanceof DestroyObject) {
+ } else if (action instanceof DestroyObject) {
Host host = config.getHost(targetID.getFullName());
- if (host != null) {
- // if the host is deleted, so must the dependent objects be deleted
(if they exist)
+ if (host != null) {
+ // if the host is deleted, so must the dependent objects
+ // be deleted (if they exist)
delete(targetID, config.getConfiguration());
- setLastChangedDate(config.getConfiguration(), transaction.getLockAcquiredBy());
- }
+ setLastChangedDate(config.getConfiguration(), principal);
+ }
+ } else {
+ throw new InvalidArgumentException(ConfigMessages.CONFIG_0075,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0075,action.getActionDescription()));
+ }
+ }
+ } catch (ConfigurationException ce) {
+ throw ce;
- } else {
- throw new
InvalidArgumentException(ConfigMessages.CONFIG_0075,ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0075,
action.getActionDescription()));
- }
+ } catch (Exception e) {
+ ConfigurationException e2 = new ConfigurationException(e);
+ e2.setActionIndex(actionIndex);
+ throw e2;
+ }
+ return affectedIDs;
- }
+ }
+ /**
+ * Executes the specified component type actions and will update the list of
+ * component types with the changes.
+ *
+ * @param componentTypes
+ * is the configuration to be updated
+ */
- } catch (ConfigurationException ce) {
- throw ce;
+ private Set executeActions(SharedResourceID targetID, List actions,
+ ConfigurationModelContainerImpl config, String principal)
+ throws InvalidConfigurationException, ConfigurationException {
- } catch ( Exception e ) {
- ConfigurationException e2 = new ConfigurationException(e);
- e2.setActionIndex(actionIndex);
- throw e2;
- }
- return affectedIDs;
+ Set affectedIDs = new HashSet();
+ if (actions.isEmpty()) {
+ return affectedIDs;
+ }
- }
+ int actionIndex = -1;
+ affectedIDs.add(targetID);
+ BasicSharedResource dvt = null;
- /**
- * Executes the specified component type actions and will update the list of
component types
- * with the changes.
- * @param componentTypes is the configuration to be updated
- */
+ try {
- public Set executeActions(ConfigurationModelContainerImpl config, SharedResourceID
targetID, List actions, XMLConfigurationConnector transaction )
- throws InvalidConfigurationException, ConfigurationException{
+ // Iterate through the actions ...
+ Iterator iter = actions.iterator();
+ while (iter.hasNext()) {
+ ActionDefinition action = (ActionDefinition) iter.next();
+ actionIndex++;
+ Object args[] = action.getArguments();
- Set affectedIDs = new HashSet();
- if ( actions.isEmpty() ) {
- return affectedIDs;
- }
+ if (action instanceof CreateObject) {
+ SharedResource rd = config.getResource(targetID.getFullName());
- int actionIndex = -1;
+ if (rd != null) {
+ // because rd are not configuration bound, the create
+ // for the rd will only be added where it does not exist
+ continue;
+ }
+ dvt = (BasicSharedResource) args[0];
- affectedIDs.add(targetID);
- BasicSharedResource dvt = null;
+ dvt = (BasicSharedResource) setCreationDate(dvt, principal);
- try {
+ ComponentType type = ResourceModel.getComponentType(dvt.getName());
- // Iterate through the actions ...
- Iterator iter = actions.iterator();
- while ( iter.hasNext() ) {
- ActionDefinition action = (ActionDefinition) iter.next();
- actionIndex++;
- Object args[] = action.getArguments();
+ // process properties for any encryptions
+ processPropertyForNewObject(dvt, type, config, principal);
- if(action instanceof CreateObject ) {
- SharedResource rd = config.getResource(targetID.getFullName());
+ config.addResource(dvt);
- if (rd != null) {
- // because rd are not configuration bound, the create
- // for the rd will only be added where it does not exist
- continue;
+ } else if (action instanceof AddObject
+ || action instanceof RemoveObject
+ || action instanceof ExchangeObject) {
-// DuplicateComponentException e = new
DuplicateComponentException("The host (\"" + targetID + "\")
already exists and may not be recreated");
-// e.setActionIndex(actionIndex);
-// throw e;
- }
- dvt = (BasicSharedResource) args[0];
+ SharedResource rd = config.getResource(targetID
+ .getFullName());
- dvt = (BasicSharedResource) setCreationDate(dvt, transaction.getLockAcquiredBy());
+ if (rd == null) {
+ throw new InvalidComponentException(ConfigMessages.CONFIG_0106,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0106,targetID));
+ }
- ComponentType type = ResourceModel.getComponentType(dvt.getName());
+ // get the type based on the SharedResource Name, not its
+ // type
+ ComponentType type = ResourceModel.getComponentType(rd.getName());
+ rd = (SharedResource) setLastChangedDate(rd, principal);
+ processPropertyChanges(action, rd, type, config, principal);
- // process properties for any encryptions
- processPropertyForNewObject(dvt, type, config,
transaction.getLockAcquiredBy());
+ } else if (action instanceof DestroyObject) {
+ SharedResource rd = config.getResource(targetID.getFullName());
- config.addResource(dvt);
-
- } else if (action instanceof AddObject ||
- action instanceof RemoveObject ||
- action instanceof ExchangeObject) {
-
- SharedResource rd = config.getResource(targetID.getFullName());
-
- if (rd == null) {
- throw new
InvalidComponentException(ConfigMessages.CONFIG_0106,ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0106,
targetID));
- }
-
- // get the type based on the SharedResource Name, not its type
- ComponentType type = ResourceModel.getComponentType(rd.getName());
-
- // ComponentType type =
config.getComponentType(rd.getComponentTypeID().getFullName());
-
- // ComponentType type = getComponentType(config,
rd.getComponentTypeID(), targetID);
-
- rd = (SharedResource)setLastChangedDate(rd,
transaction.getLockAcquiredBy());
-
- processPropertyChanges(action,
- rd,
- type,
- config,
- transaction.getLockAcquiredBy());
-
-
-
- } else if (action instanceof DestroyObject) {
- SharedResource rd = config.getResource(targetID.getFullName());
-
- if (rd != null) {
+ if (rd != null) {
config.remove(targetID);
- setLastChangedDate(config.getConfiguration(), transaction.getLockAcquiredBy());
+ setLastChangedDate(config.getConfiguration(), principal);
- }
+ }
- } else {
- throw new
InvalidArgumentException(ConfigMessages.CONFIG_0075,ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0075,
action.getActionDescription()));
- }
+ } else {
+ throw new InvalidArgumentException(ConfigMessages.CONFIG_0075,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0075,action.getActionDescription()));
+ }
+ }
- }
+ } catch (ConfigurationException ce) {
+ throw ce;
+ } catch (Exception e) {
+ ConfigurationException e2 = new ConfigurationException(e);
+ e2.setActionIndex(actionIndex);
+ throw e2;
+ }
- } catch (ConfigurationException ce) {
- throw ce;
+ return affectedIDs;
+ }
- } catch ( Exception e ) {
- ConfigurationException e2 = new ConfigurationException(e);
- e2.setActionIndex(actionIndex);
- throw e2;
- }
+ void updateSharedResource(SharedResource resource,ConfigurationModelContainerImpl
config, String principal) throws ConfigurationException {
+ ComponentType type = ResourceModel.getComponentType(resource.getName());
- return affectedIDs;
- }
-
- public void updateSharedResource(SharedResource resource, XMLConfigurationConnector
transaction) throws ConfigurationException{
-
- Collection trans = transaction.getObjects();
- for (Iterator it=trans.iterator(); it.hasNext(); ) {
- ConfigurationModelContainerImpl m = (ConfigurationModelContainerImpl) it.next();
-// System.out.println("STRATEGY: Update SharedResource " +
m.getConfigurationID());
-
-
- ComponentType type = ResourceModel.getComponentType(resource.getName());
-
- Properties props = resource.getProperties();
-
-
- SharedResource sr = m.getResource(resource.getFullName());
- if (sr == null) {
- throw new
InvalidComponentException(ConfigMessages.CONFIG_0106,ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0106,
resource.getFullName()));
- }
-
- // if (ResourceModel.doesResourceRequireEncryption(sr.getName())) {
- updateProperties(sr, props, null, ConfigurationObjectEditor.ADD, type, m,
transaction.getLockAcquiredBy());
-// } else {
-//
-// ConfigurationObjectEditorHelper.modifyProperties(sr,
resource.getProperties(), ConfigurationObjectEditorHelper.ADD);
-//
-// }
-
- sr = (SharedResource) setLastChangedDate(sr, transaction.getLockAcquiredBy());
-
-
-
+ Properties props = resource.getProperties();
+ SharedResource sr = config.getResource(resource.getFullName());
+ if (sr == null) {
+ throw new
InvalidComponentException(ConfigMessages.CONFIG_0106,ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0106,resource.getFullName()));
}
- }
-
- /**
- * Executes the specified component type actions and will update the list of
component types
- * with the changes.
- * @param componentTypes is the configuration to be updated
- */
+ updateProperties(sr, props, null, ConfigurationObjectEditor.ADD, type,config,
principal);
-// public Set executeActions(ConfigurationModelContainerImpl config, ProductTypeID
targetID, List actions, XMLConfigurationConnector transaction )
-// throws InvalidConfigurationException, ConfigurationException{
-//
-// Set affectedIDs = new HashSet();
-// if ( actions.isEmpty() ) {
-// return affectedIDs;
-// }
-//
-// int actionIndex = -1;
-//
-// affectedIDs.add(targetID);
-// BasicProductType dvt = null;
-//
-// try {
-//
-// // Iterate through the actions ...
-// Iterator iter = actions.iterator();
-// while ( iter.hasNext() ) {
-// ActionDefinition action = (ActionDefinition) iter.next();
-// actionIndex++;
-// Object args[] = action.getArguments();
-//
-// if(action instanceof CreateObject ) {
-// ProductType rd = config.getProductType(targetID.getFullName());
-//
-// if (rd != null) {
-// // because rd are not configuration bound, the create
-// // for the rd will only be added where it does not exist
-// continue;
-// }
-// dvt = (BasicProductType) args[0];
-//
-// dvt = (BasicProductType) setCreationDate(dvt,
transaction.getLockAcquiredBy());
-//
-//
-// config.addProductType(dvt);
-//
-// } else if (action instanceof AddObject ||
-// action instanceof RemoveObject ||
-// action instanceof ExchangeObject) {
-//
-// throw new InvalidArgumentException(ConfigMessages.CONFIG_0075,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0075, action.getActionDescription()));
-//
-////
-//// ProductType rd = config.getProductType(targetID.getFullName());
-////
-//// if (rd == null) {
-//// throw new
InvalidComponentException(ConfigMessages.CONFIG_0106,ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0106,
targetID));
-//// }
-////
-////
-//// ComponentType type =
config.getComponentType(rd.getComponentTypeID().getFullName());
-//// rd = (SharedResource)setLastChangedDate(editor, rd,
transaction.getLockAcquiredBy());
-////
-//// processPropertyChanges(action,
-//// rd,
-//// type,
-//// config,
-//// transaction.getLockAcquiredBy());
-////
-////
-//
-// } else if (action instanceof DestroyObject) {
-// // CANNOT REMOVE PRODUCT TYPES, they are predetermined for each
release
-//
-// throw new InvalidArgumentException(ConfigMessages.CONFIG_0075,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0075, action.getActionDescription()));
-//
-//// ProductType rd = config.getProductType(targetID.getFullName());
-////
-//// if (rd != null) {
-//// config.remove(targetID);
-//// setLastChangedDate(editor, config.getConfiguration(),
transaction.getLockAcquiredBy());
-////
-//// }
-//
-// } else {
-// throw new
InvalidArgumentException(ConfigMessages.CONFIG_0075,ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0075,
action.getActionDescription()));
-// }
-//
-// }
-//
-//
-// } catch (ConfigurationException ce) {
-// throw ce;
-//
-// } catch ( Exception e ) {
-// ConfigurationException e2 = new ConfigurationException(e);
-// e2.setActionIndex(actionIndex);
-// throw e2;
-// }
-//
-//
-// return affectedIDs;
-// }
-//
+ sr = (SharedResource) setLastChangedDate(sr, principal);
+ }
- //
----------------------------------------------------------------------------------------
- // P R O P E R T Y M E T H O D S
- //
----------------------------------------------------------------------------------------
+ //--------------------------------------------------------------------------
+ // --------------
+ // P R O P E R T Y M E T H O D S
+ //--------------------------------------------------------------------------
+ // --------------
- private void processPropertyForNewObject(ComponentObject object,
- ComponentType type,
- ConfigurationModelContainerImpl config,
- String principal)
- throws InvalidPropertyValueException,
ConfigurationException {
+ private void processPropertyForNewObject(ComponentObject object, ComponentType type,
ConfigurationModelContainerImpl config, String principal)
+ throws InvalidPropertyValueException, ConfigurationException {
-// because new objects may no longer have seperate actions for their properties, the
-// properties that they have must be checked for passwords so that
-// they can be encrypted.
-
- BasicComponentObject bco = (BasicComponentObject) object;
-
- Properties props = bco.getEditableProperties();
+ // because new objects may no longer have seperate actions for their
+ // properties, the
+ // properties that they have must be checked for passwords so that
+ // they can be encrypted.
- updateProperties(object, props, null, ConfigurationObjectEditor.SET, type,
config, principal);
+ BasicComponentObject bco = (BasicComponentObject) object;
- }
+ Properties props = bco.getEditableProperties();
- private void processPropertyChanges(ActionDefinition action,
- ComponentObject object,
- ComponentType type,
- ConfigurationModelContainerImpl config,
- String principal)
- throws InvalidPropertyValueException,
ConfigurationException {
+ updateProperties(object, props, null, ConfigurationObjectEditor.SET,
+ type, config, principal);
+ }
- int operation = -1;
- String propName;
- String propValue;
- // System.out.println("STRATEGY: Process Property Changes" +
object.getFullName());
+ private void processPropertyChanges(ActionDefinition action,ComponentObject object,
ComponentType type,ConfigurationModelContainerImpl config, String principal)
+ throws InvalidPropertyValueException, ConfigurationException {
- if(action instanceof AddNamedObject ||
- action instanceof AddObject) {
- operation = ConfigurationObjectEditor.ADD;
- } else if (action instanceof ExchangeNamedObject ||
- action instanceof ExchangeObject) {
- operation = ConfigurationObjectEditor.SET;
- } else if (action instanceof RemoveNamedObject ||
- action instanceof RemoveObject) {
- operation = ConfigurationObjectEditor.REMOVE;
- } else {
- throw new
RuntimeException(ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0107,
action.getClass().getName()));
- }
+ int operation = -1;
+ String propName;
+ String propValue;
- Object args[] = action.getArguments();
+ if (action instanceof AddNamedObject || action instanceof AddObject) {
+ operation = ConfigurationObjectEditor.ADD;
+ } else if (action instanceof ExchangeNamedObject
+ || action instanceof ExchangeObject) {
+ operation = ConfigurationObjectEditor.SET;
+ } else if (action instanceof RemoveNamedObject
+ || action instanceof RemoveObject) {
+ operation = ConfigurationObjectEditor.REMOVE;
+ } else {
+ throw new RuntimeException(ConfigPlugin.Util.getString(
+ ConfigMessages.CONFIG_0107, action.getClass().getName()));
+ }
- /*
- System.out.println("<!><!>Properties processing action " +
action + " with args:");
- for (int i= 0; i<args.length; i++){
- System.out.println(i + ": " + args[i]);
- }
- */
-// System.out.println("STRATEGY: Process Property Changes 1" );
+ Object args[] = action.getArguments();
- if (args[0] instanceof Properties) {
+ /*
+ * System.out.println("<!><!>Properties processing action " +
action +
+ * " with args:"); for (int i= 0; i<args.length; i++){
+ * System.out.println(i + ": " + args[i]); }
+ */
+ // System.out.println("STRATEGY: Process Property Changes 1" );
+ if (args[0] instanceof Properties) {
- Properties props = null;
- Properties oldProps = null;
- if (operation == ConfigurationObjectEditor.ADD) {
- props = (Properties) args[0];
- } else if (operation == ConfigurationObjectEditor.SET) {
- // 0 arg is the old value
- // 1 arg is the new value
- oldProps = (Properties)args[0];
- props = (Properties) args[1];
- } else if (operation == ConfigurationObjectEditor.REMOVE) {
- props = (Properties) args[0];
- }
+ Properties props = null;
+ Properties oldProps = null;
+ if (operation == ConfigurationObjectEditor.ADD) {
+ props = (Properties) args[0];
+ } else if (operation == ConfigurationObjectEditor.SET) {
+ // 0 arg is the old value
+ // 1 arg is the new value
+ oldProps = (Properties) args[0];
+ props = (Properties) args[1];
+ } else if (operation == ConfigurationObjectEditor.REMOVE) {
+ props = (Properties) args[0];
+ }
+ updateProperties(object, props, oldProps, operation, type, config,
+ principal);
-// System.out.println("STRATEGY: Process Property Changes 2" );
+ } else {
+ propName = (String) args[0];
- updateProperties(object, props, oldProps,operation, type, config,
principal);
+ String oldValue = ""; //$NON-NLS-1$
+ propValue = ""; //$NON-NLS-1$
- } else {
- propName = (String) args[0];
- String oldValue = ""; //$NON-NLS-1$
- propValue = ""; //$NON-NLS-1$
+ if (operation == ConfigurationObjectEditor.ADD) {
+ propValue = (String) args[1];
+ } else if (operation == ConfigurationObjectEditor.SET) {
+ oldValue = (String) args[1];
+ propValue = (String) args[2];
+ } else if (operation == ConfigurationObjectEditor.REMOVE) {
+ propValue = ""; //$NON-NLS-1$
+ }
- if (operation == ConfigurationObjectEditor.ADD) {
- propValue = (String) args[1];
- } else if (operation == ConfigurationObjectEditor.SET) {
- oldValue = (String) args[1];
- propValue = (String) args[2];
- } else if (operation == ConfigurationObjectEditor.REMOVE) {
- propValue = ""; //$NON-NLS-1$
- }
-// System.out.println("STRATEGY: Process Property Changes 3" );
+ updateProperty(object, propName, propValue, oldValue, operation,
+ type, config, principal);
+ }
- updateProperty(object, propName, propValue, oldValue, operation, type,
config, principal);
- // Must encrypt connection passwords here
- // "targetObj instanceof ServiceComponentDefnID" indicates it's
a connector binding
- }
+ }
- }
+ private void updateProperties(ComponentObject object, Properties props, Properties
oldValues, int operation, ComponentType type, ConfigurationModelContainerImpl config,
String principal)
+ throws InvalidPropertyValueException, ConfigurationException {
- private void updateProperties(ComponentObject object,
- Properties props,
- Properties oldValues,
- int operation,
- ComponentType type,
- ConfigurationModelContainerImpl config,
- String principal) throws InvalidPropertyValueException,
ConfigurationException {
+ String propName;
+ String propValue;
- String propName;
- String propValue;
+ Enumeration propertyNames = props.propertyNames();
+ Properties passwordProps = new Properties();
- Enumeration propertyNames = props.propertyNames();
- Properties passwordProps = new Properties();
-
- while ( propertyNames.hasMoreElements() ) {
+ while (propertyNames.hasMoreElements()) {
- propName = (String) propertyNames.nextElement();
- propValue = props.getProperty(propName);
-
- validateProperty.isPropertyValid(propName, propValue);
- // Must encrypt connection passwords here
+ propName = (String) propertyNames.nextElement();
+ propValue = props.getProperty(propName);
- if (propValue != null && propValue.trim().length() > 0
&&
- isPasswordProp(propName, type, config) &&
- ! CryptoUtil.isValueEncrypted(propValue) ) {
- try {
+ validateProperty.isPropertyValid(propName, propValue);
+ // Must encrypt connection passwords here
- propValue = CryptoUtil.stringEncrypt(propValue);
- } catch ( CryptoException e ) {
- e.printStackTrace();
- throw new
InvalidPropertyValueException(e,ConfigMessages.CONFIG_0108,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0108));
- }
- }
- passwordProps.setProperty(propName, propValue);
+ if (propValue != null && propValue.trim().length() > 0 &&
isPasswordProp(propName, type, config) && !CryptoUtil.isValueEncrypted(propValue))
{
+ try {
+ propValue = CryptoUtil.stringEncrypt(propValue);
+ } catch (CryptoException e) {
+ throw new InvalidPropertyValueException(e,ConfigMessages.CONFIG_0108,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0108));
+ }
+ }
+ passwordProps.setProperty(propName, propValue);
+ }
+ switch (operation) {
+ case ConfigurationObjectEditor.ADD:
+ AuditManager.getInstance().record(ConfigurationServiceInterface.NAME,"adding
properties " + passwordProps, principal, object.getName()); //$NON-NLS-1$
+ break;
+ case ConfigurationObjectEditor.SET:
+ AuditManager.getInstance().record(ConfigurationServiceInterface.NAME,"setting
properties " + passwordProps + " previous values " + oldValues, principal,
object.getName()); //$NON-NLS-1$ //$NON-NLS-2$
+ break;
+ case ConfigurationObjectEditor.REMOVE:
+ AuditManager.getInstance().record(ConfigurationServiceInterface.NAME,"removing
properties " + passwordProps, principal, object.getName()); //$NON-NLS-1$
+ break;
+ }
+ modifyProperties(object, passwordProps, operation);
+ }
- }
- switch (operation) {
- case ConfigurationObjectEditor.ADD:
- AuditManager.getInstance().record(ConfigurationServiceInterface.NAME,
"adding properties " + passwordProps, principal, object.getName());
//$NON-NLS-1$
- break;
- case ConfigurationObjectEditor.SET:
- AuditManager.getInstance().record(ConfigurationServiceInterface.NAME,
"setting properties " + passwordProps + " previous values " +
oldValues, principal, object.getName()); //$NON-NLS-1$ //$NON-NLS-2$
- break;
- case ConfigurationObjectEditor.REMOVE:
- AuditManager.getInstance().record(ConfigurationServiceInterface.NAME,
"removing properties " + passwordProps, principal, object.getName());
//$NON-NLS-1$
- break;
- }
+ private void updateProperty(ComponentObject object, String propName,String propValue,
String oldValue, int operation,ComponentType type, ConfigurationModelContainerImpl
config,String principal)
+ throws InvalidPropertyValueException,ConfigurationException {
+
+ validateProperty.isPropertyValid(propName, propValue);
- modifyProperties(object, passwordProps, operation);
+ if (propValue != null && propValue.trim().length() > 0 &&
isPasswordProp(propName, type, config) && !CryptoUtil.isValueEncrypted(propValue))
{
+ try {
+ propValue = CryptoUtil.getCryptor().encrypt(propValue);
+ } catch (CryptoException e) {
+ throw new InvalidPropertyValueException(e,ConfigMessages.CONFIG_0108,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0108));
+ }
+ }
- }
+ if (operation == ConfigurationObjectEditor.ADD) {
+ AuditManager.getInstance().record(ConfigurationServiceInterface.NAME,"adding
" + propName + " with value " + propValue, principal, object.getName());
//$NON-NLS-1$ //$NON-NLS-2$
+ BasicComponentObject target = (BasicComponentObject) object;
+ target.addProperty(propName, propValue);
+ } else if (operation == ConfigurationObjectEditor.SET) {
+ AuditManager.getInstance().record(ConfigurationServiceInterface.NAME,"setting
" + propName + " to value " + propValue + " previous value was "
+ oldValue, principal, object.getName()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- private void updateProperty(ComponentObject object,
- String propName,
- String propValue,
- String oldValue,
- int operation,
- ComponentType type,
- ConfigurationModelContainerImpl config,
- String principal) throws InvalidPropertyValueException,
ConfigurationException {
- validateProperty.isPropertyValid(propName, propValue);
+ BasicComponentObject target = (BasicComponentObject) object;
+ target.removeProperty(propName);
+ target.addProperty(propName, propValue);
- if (propValue != null && propValue.trim().length() > 0 &&
- isPasswordProp(propName, type, config) &&
- ! CryptoUtil.isValueEncrypted(propValue)) {
- char[] pwd = null;
- try {
- propValue = CryptoUtil.getCryptor().encrypt(propValue);
- } catch ( CryptoException e ) {
- throw new InvalidPropertyValueException(e, ConfigMessages.CONFIG_0108,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0108));
- }
- }
+ } else if (operation == ConfigurationObjectEditor.REMOVE) {
+ AuditManager.getInstance().record(ConfigurationServiceInterface.NAME,"removing
" + propName, principal, object.getName()); //$NON-NLS-1$
+ BasicComponentObject target = (BasicComponentObject) object;
+ target.removeProperty(propName);
+ }
+ }
- if (operation == ConfigurationObjectEditor.ADD) {
- AuditManager.getInstance().record(ConfigurationServiceInterface.NAME,
"adding " + propName + " with value " + propValue, principal,
object.getName()); //$NON-NLS-1$ //$NON-NLS-2$
- BasicComponentObject target = (BasicComponentObject) object;
+ /**
+ * Determines if the given propDefn is a password property (ISMASKED == 1).
+ */
+ private static boolean isPasswordProp(String propName, ComponentType type,
ConfigurationModelContainerImpl config)
+ throws ConfigurationException {
- target.addProperty(propName, propValue);
+ if (type == null) {
+ Assertion.isNotNull(type, ConfigPlugin.Util.getString(
+ ConfigMessages.CONFIG_0109, propName));
+ }
- } else if (operation == ConfigurationObjectEditor.SET) {
- AuditManager.getInstance().record(ConfigurationServiceInterface.NAME,
"setting " + propName + " to value " + propValue + " previous
value was " + oldValue, principal, object.getName()); //$NON-NLS-1$ //$NON-NLS-2$
//$NON-NLS-3$
-
- BasicComponentObject target = (BasicComponentObject) object;
-
- target.removeProperty(propName);
-
- target.addProperty(propName, propValue);
-
- } else if (operation == ConfigurationObjectEditor.REMOVE) {
- AuditManager.getInstance().record(ConfigurationServiceInterface.NAME,
"removing " + propName, principal, object.getName()); //$NON-NLS-1$
- BasicComponentObject target = (BasicComponentObject) object;
-
- target.removeProperty(propName);
- }
- }
-
- /**
- * Determines if the given propDefn is a password property (ISMASKED == 1).
- */
- private static boolean isPasswordProp(String propName, ComponentType type,
ConfigurationModelContainerImpl config)
- throws ConfigurationException {
-
- if(type == null){
- Assertion.isNotNull(type,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0109, propName));
- }
-
ComponentType checkType = null;
if (type.getComponentTypeDefinition(propName) != null) {
@@ -1894,194 +1327,184 @@
checkType = findComponentTypeBasedOnHierarchy(propName, type, INITIAL_TREE_PATH,
config);
}
- if (checkType == null) {
- return false;
- }
+ if (checkType == null) {
+ return false;
+ }
-// Assertion.isNotNull(checkType.getComponentTypeDefinition(propName), "No
component type definition for " + propName + " in component type " +
type.getFullName());
- ComponentTypeDefn td = checkType.getComponentTypeDefinition(propName);
+ // Assertion.isNotNull(checkType.getComponentTypeDefinition(propName),
+ // "No component type definition for " + propName +
+ // " in component type " + type.getFullName());
+ ComponentTypeDefn td = checkType.getComponentTypeDefinition(propName);
- if (td.getPropertyDefinition().isMasked()) {
- return true;
- }
+ if (td.getPropertyDefinition().isMasked()) {
+ return true;
+ }
- return false;
- }
+ return false;
+ }
- /**
- * This methods traverses the component type parent or super types heirarchy.
- * This is a recursive method used to traverse the tree.
- * NOTE: the treePath is used to ensure only one path is used and not
- * allow it to cross over and use the other path. An example
- * would be the "Service" component type that has a parent type
- * but is also the super type of all the services.
- *
- */
- private static final int INITIAL_TREE_PATH = -1;
- private static final int PARENT_TREE_PATH = 1;
- private static final int SUPER_TREE_PATH = 2;
+ /**
+ * This methods traverses the component type parent or super types
+ * heirarchy. This is a recursive method used to traverse the tree. NOTE:
+ * the treePath is used to ensure only one path is used and not allow it to
+ * cross over and use the other path. An example would be the "Service"
+ * component type that has a parent type but is also the super type of all
+ * the services.
+ *
+ */
+ private static final int INITIAL_TREE_PATH = -1;
+ private static final int PARENT_TREE_PATH = 1;
+ private static final int SUPER_TREE_PATH = 2;
- private static ComponentType findComponentTypeBasedOnHierarchy(String propName,
ComponentType type, int treePath, ConfigurationModelContainerImpl config) throws
ConfigurationException {
- ComponentType foundType = null;
+ private static ComponentType findComponentTypeBasedOnHierarchy(
+ String propName, ComponentType type, int treePath,
+ ConfigurationModelContainerImpl config)
+ throws ConfigurationException {
+ ComponentType foundType = null;
-// first try down the parent path to find the definition for the propName
- if ( (treePath == PARENT_TREE_PATH || treePath == INITIAL_TREE_PATH) &&
- type.getParentComponentTypeID() != null) {
+ // first try down the parent path to find the definition for the
+ // propName
+ if ((treePath == PARENT_TREE_PATH || treePath == INITIAL_TREE_PATH)
+ && type.getParentComponentTypeID() != null) {
- foundType =
config.getComponentType(type.getParentComponentTypeID().getFullName());
+ foundType = config.getComponentType(type.getParentComponentTypeID()
+ .getFullName());
- // not all parents or supers may be component types, but product types - that
have no definitions
- if (foundType != null) {
- // if this parent doesn't contain the definition then goto its parent
+ // not all parents or supers may be component types, but product
+ // types - that have no definitions
+ if (foundType != null) {
+ // if this parent doesn't contain the definition then goto its
+ // parent
if (foundType.getComponentTypeDefinition(propName) != null) {
return foundType;
}
- // dont want to return here because at the intial call of this method
- // and the parent type doesnt have the defn, the super has to be checked
+ // dont want to return here because at the intial call of this
+ // method
+ // and the parent type doesnt have the defn, the super has to be
+ // checked
foundType = findComponentTypeBasedOnHierarchy(propName, foundType, PARENT_TREE_PATH,
config);
if (foundType != null) {
return foundType;
}
- }
- }
+ }
+ }
+ if ((treePath == SUPER_TREE_PATH || treePath == INITIAL_TREE_PATH)
+ && type.getSuperComponentTypeID() != null) {
- if ( (treePath == SUPER_TREE_PATH || treePath == INITIAL_TREE_PATH) &&
- type.getSuperComponentTypeID() != null) {
+ foundType = config.getComponentType(type.getSuperComponentTypeID().getFullName());
- foundType =
config.getComponentType(type.getSuperComponentTypeID().getFullName());
-
- if (foundType != null) {
- // if this parent doesn't contain the definition then goto its parent
+ if (foundType != null) {
+ // if this parent doesn't contain the definition then goto its
+ // parent
if (foundType.getComponentTypeDefinition(propName) != null) {
return foundType;
}
- foundType = findComponentTypeBasedOnHierarchy(propName, foundType, SUPER_TREE_PATH,
config);
+ foundType = findComponentTypeBasedOnHierarchy(propName,foundType, SUPER_TREE_PATH,
config);
if (foundType != null) {
return foundType;
}
- }
+ }
- }
+ }
- return foundType;
+ return foundType;
- }
+ }
- private ComponentObject setLastChangedDate(ComponentObject defn, String principal) {
+ private ComponentObject setLastChangedDate(ComponentObject defn,String principal) {
+ String lastChangedDate = DateUtil.getCurrentDateAsString();
+ return BasicUtil.setLastChangedHistory(defn, principal, lastChangedDate);
+ }
- String lastChangedDate = DateUtil.getCurrentDateAsString();
+ private ComponentType setLastChangedDate(ComponentType defn,String principal) {
+ String lastChangedDate = DateUtil.getCurrentDateAsString();
+ return BasicUtil.setLastChangedHistory(defn, principal, lastChangedDate);
+ }
- return BasicUtil.setLastChangedHistory(defn, principal, lastChangedDate);
- }
+ private ComponentObject setCreationDate(ComponentObject defn,String principal) {
- private ComponentType setLastChangedDate(ComponentType defn, String principal) {
+ String creationDate = DateUtil.getCurrentDateAsString();
+ defn = BasicUtil.setLastChangedHistory(defn, principal, creationDate);
+ return BasicUtil.setCreationChangedHistory(defn, principal,creationDate);
+ }
- String lastChangedDate = DateUtil.getCurrentDateAsString();
+ private ComponentType setCreationDate(ComponentType defn, String principal) {
+ String creationDate = DateUtil.getCurrentDateAsString();
+ defn = BasicUtil.setLastChangedHistory(defn, principal, creationDate);
+ return BasicUtil.setCreationChangedHistory(defn, principal,creationDate);
+ }
- return BasicUtil.setLastChangedHistory(defn, principal, lastChangedDate);
- }
+ private Configuration delete(ComponentObjectID targetID,Configuration configuration) {
+ BasicConfiguration basicConfig = (BasicConfiguration) configuration;
+ basicConfig.removeComponentObject(targetID);
+ return basicConfig;
+ }
+ /**
+ * The command to signify setting of an attribute.
+ */
+ public static final int SET = 0;
- private ComponentObject setCreationDate(ComponentObject defn, String principal) {
+ /**
+ * The command to signify addition of an attribute.
+ */
+ public static final int ADD = 1;
- String creationDate = DateUtil.getCurrentDateAsString();
+ /**
+ * The command to signify removal of an attribute.
+ */
+ public static final int REMOVE = 2;
- defn = BasicUtil.setLastChangedHistory(defn, principal, creationDate);
+ private ComponentObject modifyProperties(ComponentObject t, Properties props, int
command) {
+ Assertion.isNotNull(t);
- return BasicUtil.setCreationChangedHistory(defn, principal, creationDate);
- }
+ if (props == null) {
+ return t;
+ }
- private ComponentType setCreationDate(ComponentType defn, String principal) {
+ BasicComponentObject target = (BasicComponentObject) t;
+ Properties newProps = null;
- String creationDate = DateUtil.getCurrentDateAsString();
+ switch (command) {
+ case ADD:
+ newProps = new Properties();
+ newProps.putAll(target.getEditableProperties());
+ newProps.putAll(props);
- defn = BasicUtil.setLastChangedHistory(defn, principal, creationDate);
+ target.addProperties(newProps);
- return BasicUtil.setCreationChangedHistory(defn, principal, creationDate);
- }
-
-
- private Configuration delete( ComponentObjectID targetID, Configuration configuration )
throws ConfigurationException {
- //System.out.println("<!><!><!><!>deleting " +
target + ", delete dependencies: " + deleteDependencies);
+ break;
+ case REMOVE:
+ newProps = new Properties();
+ newProps.putAll(target.getEditableProperties());
+ Iterator iter = props.keySet().iterator();
+ while (iter.hasNext()) {
+ newProps.remove(iter.next());
+ }
- BasicConfiguration basicConfig = (BasicConfiguration) configuration;
- basicConfig.removeComponentObject( targetID);
+ target.setProperties(newProps);
+ break;
+ case SET:
+ target.setProperties(props);
+ break;
+ }
- return basicConfig;
- }
-
- /**
- * The command to signify setting of an attribute.
- */
- public static final int SET = 0;
+ return target;
- /**
- * The command to signify addition of an attribute.
- */
- public static final int ADD = 1;
+ }
- /**
- * The command to signify removal of an attribute.
- */
- public static final int REMOVE = 2;
- private ComponentObject modifyProperties( ComponentObject t, Properties props, int
command ) {
- Assertion.isNotNull(t);
+ private void setRoutingUUID(ServiceComponentDefn serviceComponentDefn,
+ String newRoutingUUID) {
+ Assertion.isNotNull(serviceComponentDefn);
- if (props == null) {
- return t;
- }
-
-
- BasicComponentObject target = (BasicComponentObject) t;
- Properties newProps = null;
-
- switch ( command ) {
- case ADD:
- newProps = new Properties();
- newProps.putAll( target.getEditableProperties() );
- newProps.putAll( props );
-
- target.addProperties(newProps);
-
- break;
- case REMOVE:
- newProps = new Properties();
- newProps.putAll( target.getEditableProperties() );
- Iterator iter = props.keySet().iterator();
- while ( iter.hasNext() ) {
- newProps.remove( iter.next() );
- }
-
- target.setProperties(newProps);
- break;
- case SET:
- target.setProperties(props);
- break;
- }
-
- return target;
-
-
- }
-
- private void setRoutingUUID(ServiceComponentDefn serviceComponentDefn, String
newRoutingUUID){
- Assertion.isNotNull(serviceComponentDefn);
-
- BasicServiceComponentDefn basicService = (BasicServiceComponentDefn)
serviceComponentDefn;
- basicService.setRoutingUUID(newRoutingUUID);
-
- }
-
+ BasicServiceComponentDefn basicService = (BasicServiceComponentDefn)
serviceComponentDefn;
+ basicService.setRoutingUUID(newRoutingUUID);
+ }
}
-
-
-
-
-
Modified:
trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/XMLConfigurationConnector.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/XMLConfigurationConnector.java 2009-05-05
18:01:19 UTC (rev 863)
+++
trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/XMLConfigurationConnector.java 2009-05-05
19:09:01 UTC (rev 864)
@@ -23,6 +23,7 @@
package com.metamatrix.platform.config.spi.xml;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
@@ -46,6 +47,7 @@
import com.metamatrix.common.config.api.SharedResource;
import com.metamatrix.common.config.api.exceptions.ConfigurationException;
import com.metamatrix.common.config.api.exceptions.InvalidComponentException;
+import com.metamatrix.common.config.model.ConfigurationModelContainerImpl;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.transaction.TransactionException;
import com.metamatrix.common.util.LogCommonConstants;
@@ -62,208 +64,44 @@
private String principal;
private XMLConfigurationMgr configurationMgr;
- private Map configurationObjects = new HashMap(3);
+ private ConfigurationModelContainerImpl clonedConfiguration;
+
private XMLActionUpdateStrategy updateStrategy = new XMLActionUpdateStrategy();
- XMLConfigurationConnector(XMLConfigurationMgr configurationMgr, String principal) {
+ XMLConfigurationConnector(XMLConfigurationMgr configurationMgr,
ConfigurationModelContainerImpl config, String principal) {
this.configurationMgr = configurationMgr;
this.principal = principal;
+ this.clonedConfiguration = config;
}
/**
- * Returns the name that holds the lock.
- * @return String name who holds the lock
- */
- public String getLockAcquiredBy() {
- return principal;
- }
-
- /**
* Complete the transaction represented by this TransactionObject.
* @throws TransactionException if the transaction is unable to commit.
*/
- public void commit() throws ConfigTransactionException{
- Collection<ConfigurationModelContainer> models = getObjects();
- this.configurationObjects.clear();
- configurationMgr.applyTransaction(models, this.principal);
+ public void commit() throws ConfigurationException {
+ checkState();
+ configurationMgr.applyTransaction(clonedConfiguration, this.principal);
+ this.clonedConfiguration = null;
}
- /**
- * Returns the objects that changed during this transaction
- */
- public Collection getObjects() {
- return new ArrayList(configurationObjects.values());
- }
-
- /**
- * Call to add an object to the set of objects that changed during this
- * transaction.
- * For the configuration process, this object will be
- * @see {ConfigurationModelContainer Configuration}
- * @param key is the id of the configuration
- * @param value is the configuration container
- */
- public void addObjects(Object key, Object value) {
- configurationObjects.put(key, value);
-
- }
-
- /**
- * Returns the objects that changed during this transaction. For
- * the configuration process, these objects will be
- * @see {ConfigurationModelContainer Configurations}.
- * @return Collection of objects that changed during the transaction.
- */
- public Object getObject(Object key) {
- return configurationObjects.get(key);
- }
-
-
- //
------------------------------------------------------------------------------------
- // C O N F I G U R A T I O N I N F O R M A T I O N
- //
------------------------------------------------------------------------------------
-
- /**
- * Returns one of the well-known
- * {@link SystemConfigurationNames system configurations}, either
- * the
- * {@link SystemConfigurationNames#OPERATIONAL operational configuration},
- * the
- * {@link SystemConfigurationNames#NEXT_STARTUP next startup configuration},
- * or the
- * {@link SystemConfigurationNames#STARTUP startup configuration}. Use
- * {@link SystemConfigurationNames} to supply the String parameter.
- * @param designation String indicating which of the system configurations
- * is desired; use one of the {@link SystemConfigurationNames} constants
- * @return the desired Configuration
- * @throws ConfigurationException if an error occurred within or during
- * communication with the Configuration Service.
- */
- public Configuration getDesignatedConfiguration(String designation) throws
ConfigurationException{
- return
getConfigurationModel(XMLConfigurationMgr.getDesignatedConfigurationID(designation)).getConfiguration();
- }
-
- public ConfigurationModelContainer getConfigurationModel(String configName) throws
ConfigurationException {
- return
getConfigurationModel(XMLConfigurationMgr.getDesignatedConfigurationID(configName));
- }
-
- public ConfigurationID getDesignatedConfigurationID(String designation) throws
ConfigurationException {
- return XMLConfigurationMgr.getDesignatedConfigurationID(designation);
- }
-
- /**
- * Obtain the list of component definition instances that makeup the configuration.
- * @return the list of Component instances
- * @throws ConfigurationException if an error occurred within or during communication
with the Configuration Service.
- */
- public Map getComponentDefinitions(ConfigurationID configurationID) throws
ConfigurationException {
- ConfigurationModelContainer config = getConfigurationModel(configurationID);
-
- return config.getConfiguration().getComponentDefns();
- }
- public ConfigurationModelContainer getConfigurationModel(ConfigurationID
configurationID) throws ConfigurationException {
- return this.configurationMgr.getConfigurationModel(configurationID);
+ public ConfigurationModelContainerImpl getConfigurationModel() throws
ConfigurationException {
+ checkState();
+ return clonedConfiguration;
}
- /**
- * Returns a Collection of {@link com.metamatrix.common.config.api.ResourceDescriptor
ResourceDescriptor}
- * for all internal resources defined to the system. The internal resources are not
managed with
- * the other configuration related information. They are not dictated based on which
configuration
- * they will operate (i.e., next startup or operational);
- * @throws ConfigurationException if an error occurred within or during communication
with the Configuration Service.
- */
- public Collection getResources() throws ConfigurationException {
- ConfigurationModelContainer cmc =
getConfigurationModel(Configuration.NEXT_STARTUP_ID);
+ private void checkState() throws ConfigurationException {
+ if (clonedConfiguration == null) {
+ throw new ConfigurationException("Tranaction already commited; Configuration
in Invalid State"); //$NON-NLS-1$
+ }
+ }
- return cmc.getResources();
- }
- /**
- * Obtain the component definition
- * @return the ComponentDefn
- * @throws ConfigurationException if an error occurred within or during communication
with the Configuration Service.
- */
- public ComponentDefn getComponentDefinition(ComponentDefnID targetID, ConfigurationID
configurationID) throws ConfigurationException{
- if (targetID == null) {
- throw new
ConfigurationException(ConfigMessages.CONFIG_0045,ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0045,"ComponentDefnID"));
//$NON-NLS-1$
- }
- ComponentDefn defn = null;
-
-
- if (configurationID == null) {
- configurationID =
getDesignatedConfigurationID(targetID.getParentFullName());
- }
-
- ConfigurationModelContainer config = getConfigurationModel(configurationID);
- defn = config.getConfiguration().getComponentDefn(targetID);
-
- return defn;
- }
-
-
- public Collection getComponentTypeDefinitions(ComponentTypeID componentTypeID) throws
ConfigurationException{
- ConfigurationModelContainer config =
getConfigurationModel(Configuration.NEXT_STARTUP_ID);
- ComponentType t = config.getComponentType(componentTypeID.getFullName());
- if (t!= null) {
- return t.getComponentTypeDefinitions();
- }
- return Collections.EMPTY_LIST;
- }
-
-
- /**
- * Obtain the list of deployed components that represent the configuration
- * when deployed.
- * @return the list of DeployedComponents
- * @throws ConfigurationException if an error occurred within or during communication
with the Configuration Service.
- */
- public List getDeployedComponents(ConfigurationID configurationID) throws
ConfigurationException{
- ConfigurationModelContainer config = getConfigurationModel(configurationID);
-
-
- Collection dcs = config.getConfiguration().getDeployedComponents();
- List result = new LinkedList();
- result.addAll(dcs);
- return result;
- }
-
- /**
- * Obtain the list of registered host
- * @return Collection of Hosts
- * @throws ConfigurationException if an error occurred within or during communication
with the Metadata Service.
- */
- public Collection getHosts() throws ConfigurationException{
- return
this.configurationMgr.getConfigurationModel(Configuration.NEXT_STARTUP_ID).getConfiguration().getHosts();
- }
-
- public ComponentType getComponentType(ComponentTypeID id) throws
ConfigurationException {
- if ( id == null ) {
- throw new ConfigurationException(ConfigMessages.CONFIG_0127,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0127));
- }
- return
this.configurationMgr.getConfigurationModel(Configuration.NEXT_STARTUP_ID).getComponentType(id.getFullName());
- }
-
-
- public Collection getAllComponentTypes(boolean includeDeprecated) throws
ConfigurationException {
- ConfigurationModelContainer config =
getConfigurationModel(Configuration.NEXT_STARTUP_ID);
-
- Map typeMap = config.getComponentTypes();
- Collection types = new ArrayList(typeMap.size());
- types.addAll(typeMap.values());
- return types;
-
- }
-
- public Collection getAllObjectsForConfigurationModel(ConfigurationID configID) throws
ConfigurationException {
- return this.configurationMgr.getConfigurationModel(configID).getAllObjects();
- }
-
//
----------------------------------------------------------------------------------------
// C O N F I G U R A T I O N U P D A T E M E T H O D S
//
----------------------------------------------------------------------------------------
- public Set executeActions( List actions ) throws InvalidComponentException,
ConfigurationException {
+ public Set executeActions( List actions ) throws ConfigurationException {
ArgCheck.isNotNull(actions,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0045, "actions"));
//$NON-NLS-1$
LogManager.logDetail(LogCommonConstants.CTX_CONFIG, "Executing",
actions.size(), "action(s) for principal", principal); //$NON-NLS-1$
//$NON-NLS-2$
@@ -282,64 +120,58 @@
int actionCounter = -1;
// Iterate through the actions, and apply all as a single transaction
- try {
- boolean createObject = false;
+ boolean createObject = false;
- // Get the first action and its target, and add it to the list ...
- Iterator iter = actions.iterator();
- if ( iter.hasNext() ) {
- currentAction = (ActionDefinition) iter.next();
- currentTarget = currentAction.getTarget();
- actionsWithSameTarget.add(currentAction);
+ // Get the first action and its target, and add it to the list ...
+ Iterator iter = actions.iterator();
+ if ( iter.hasNext() ) {
+ currentAction = (ActionDefinition) iter.next();
+ currentTarget = currentAction.getTarget();
+ actionsWithSameTarget.add(currentAction);
+ }
+
+ while ( iter.hasNext() ) {
+ nextAction = (ActionDefinition) iter.next();
+ if ( currentAction instanceof CreateObject ) {
+ createObject = true;
}
-//System.out.println("WRITER: Iterater Actions " + actions.size());
- while ( iter.hasNext() ) {
- nextAction = (ActionDefinition) iter.next();
- if ( currentAction instanceof CreateObject ) {
- createObject = true;
- }
-
- // If the current action is a 'DestroyObject' action, then
process only
- // the destroy (other actions not processed up to this point do not
- // need to be processed, since the target will be destroyed anyway).
- if ( currentAction instanceof DestroyObject ) {
- // If creating and destroying an object in the same action list,
- // then don't need to do anything ...
- if ( !createObject ) {
- result.addAll( executeActionsOnTarget(
currentTarget,actionsWithSameTarget) );
- }
- actionCounter += actionsWithSameTarget.size();
- actionsWithSameTarget.clear();
- createObject = false;
- currentTarget = nextAction.getTarget();
- }
-
- // Otherwise, if the next action has another target, process up to the
current action ...
- else if ( currentTarget != nextAction.getTarget() ) {
-
+ // If the current action is a 'DestroyObject' action, then process
only
+ // the destroy (other actions not processed up to this point do not
+ // need to be processed, since the target will be destroyed anyway).
+ if ( currentAction instanceof DestroyObject ) {
+ // If creating and destroying an object in the same action list,
+ // then don't need to do anything ...
+ if ( !createObject ) {
result.addAll( executeActionsOnTarget(
currentTarget,actionsWithSameTarget) );
- actionCounter += actionsWithSameTarget.size();
- actionsWithSameTarget.clear();
- createObject = false;
- currentTarget = nextAction.getTarget();
}
-
- // Add this next action ...
- currentAction = nextAction;
- actionsWithSameTarget.add(currentAction);
+ actionCounter += actionsWithSameTarget.size();
+ actionsWithSameTarget.clear();
+ createObject = false;
+ currentTarget = nextAction.getTarget();
}
- // Process the last set of actions ...
- if ( actionsWithSameTarget.size() != 0 ) {
+ // Otherwise, if the next action has another target, process up to the
current action ...
+ else if ( currentTarget != nextAction.getTarget() ) {
- result.addAll(
executeActionsOnTarget(currentTarget,actionsWithSameTarget) );
+ result.addAll( executeActionsOnTarget(
currentTarget,actionsWithSameTarget) );
+ actionCounter += actionsWithSameTarget.size();
+ actionsWithSameTarget.clear();
createObject = false;
+ currentTarget = nextAction.getTarget();
}
- } catch ( Exception e ) {
- throw new ConfigurationException(e);
+ // Add this next action ...
+ currentAction = nextAction;
+ actionsWithSameTarget.add(currentAction);
}
+
+ // Process the last set of actions ...
+ if ( actionsWithSameTarget.size() != 0 ) {
+
+ result.addAll( executeActionsOnTarget(currentTarget,actionsWithSameTarget)
);
+ createObject = false;
+ }
LogManager.logInfo(LogCommonConstants.CTX_CONFIG,ConfigPlugin.Util.getString(ConfigMessages.MSG_0007));
return result;
}
@@ -348,13 +180,8 @@
* Executes the specified transactions, which must all be applied to the same target,
using
* the specified transaction.
*/
- private Set executeActionsOnTarget( Object target, List actions)
- throws ConfigTransactionException, ConfigurationException {
-
- Set results = updateStrategy.executeActionsOnTarget(target, actions, this);
-
- return results;
-
+ private Set executeActionsOnTarget( Object target, List actions) throws
ConfigurationException {
+ return updateStrategy.executeActionsOnTarget(target, actions,
clonedConfiguration, this.principal, this);
}
/**
@@ -364,14 +191,17 @@
* @throws ConfigurationException if an error occurred within or during communication
with the Configuration Service.
*/
public void saveResources(Collection resourceDescriptors, String principalName)
throws ConfigurationException {
-
+ checkState();
for (Iterator it=resourceDescriptors.iterator(); it.hasNext(); ) {
SharedResource rd = (SharedResource) it.next();
ArgCheck.isNotNull(rd,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0130));
- updateStrategy.updateSharedResource(rd, this);
+ updateStrategy.updateSharedResource(rd, clonedConfiguration, principalName);
}
}
+ void setConfigurationModel(ConfigurationModelContainerImpl config) {
+ this.clonedConfiguration = config;
+ }
}
Modified:
trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/XMLConfigurationMgr.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/XMLConfigurationMgr.java 2009-05-05
18:01:19 UTC (rev 863)
+++
trunk/server/src/main/java/com/metamatrix/platform/config/spi/xml/XMLConfigurationMgr.java 2009-05-05
19:09:01 UTC (rev 864)
@@ -22,10 +22,7 @@
package com.metamatrix.platform.config.spi.xml;
-import java.util.Collection;
import java.util.EventObject;
-import java.util.HashMap;
-import java.util.Map;
import java.util.Properties;
import com.metamatrix.common.config.CurrentConfiguration;
@@ -35,6 +32,7 @@
import com.metamatrix.common.config.api.exceptions.ConfigurationConnectionException;
import com.metamatrix.common.config.api.exceptions.ConfigurationException;
import com.metamatrix.common.config.model.ConfigurationModelContainerAdapter;
+import com.metamatrix.common.config.model.ConfigurationModelContainerImpl;
import com.metamatrix.common.config.util.ConfigObjectsNotResolvableException;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.messaging.MessageBus;
@@ -64,7 +62,7 @@
private PersistentConnectionFactory connFactory;
private MessageBus messageBus;
- private Map<String, ConfigurationModelContainer> configs = new
HashMap<String, ConfigurationModelContainer>();
+ private ConfigurationModelContainerImpl readOnlyConfig;
private ConfigurationModelContainerAdapter adapter = new
ConfigurationModelContainerAdapter();
private XMLConfigurationMgr(Properties properties) throws ConfigurationException {
@@ -112,55 +110,40 @@
}
public XMLConfigurationConnector getTransaction(String principal) throws
ConfigurationException {
- XMLConfigurationConnector transaction = new XMLConfigurationConnector(this,
principal);
- ConfigurationID configID =
XMLConfigurationMgr.getDesignatedConfigurationID(Configuration.NEXT_STARTUP);
- ConfigurationModelContainer transconfig =
getConfigurationModelForTransaction(configID);
- transaction.addObjects(configID.getFullName(), transconfig);
- return transaction;
+ return new XMLConfigurationConnector(this,
getConfigurationModelForTransaction(Configuration.NEXT_STARTUP_ID), principal);
}
/**
* Returns the configuration for the specified configID.
* {@see Configuration}.
*/
- public synchronized ConfigurationModelContainer getConfigurationModel(ConfigurationID
configID) throws ConfigurationException {
- ConfigurationModelContainer cmc = configs.get(configID.getFullName());
+ public synchronized ConfigurationModelContainerImpl
getConfigurationModel(ConfigurationID configID) throws ConfigurationException {
- if (cmc == null) {
- cmc = readModel(configID);
+ if (this.readOnlyConfig == null) {
+ PersistentConnection pc = getConnection(true);
- if (cmc == null) {
- throw new ConfigurationException(ConfigMessages.CONFIG_0114,
-
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0114, configID));
+ try {
+ this.readOnlyConfig = (ConfigurationModelContainerImpl)pc.read(configID);
+ } finally {
+ pc.close();
+ }
+
+ if (this.readOnlyConfig == null) {
+ throw new
ConfigurationException(ConfigMessages.CONFIG_0114,ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0114,
configID));
}
- configs.put(cmc.getConfigurationID().getFullName(), cmc);
}
- return cmc;
+ return this.readOnlyConfig;
}
- private ConfigurationModelContainer readModel(ConfigurationID configID) throws
ConfigurationException {
- PersistentConnection pc = getConnection(true);
- try {
- return pc.read(configID);
- } finally {
- pc.close();
- }
- }
-
/**
* This method is only used by the XMLConfigurationWriter so that is may obtain
* a model specifically for transaction purposes.
*/
- private ConfigurationModelContainer
getConfigurationModelForTransaction(ConfigurationID configID) throws
ConfigurationException {
+ private ConfigurationModelContainerImpl
getConfigurationModelForTransaction(ConfigurationID configID) throws
ConfigurationException {
ConfigurationModelContainer cmc = getConfigurationModel(configID);
-
- if (cmc == null) {
- throw new ConfigurationException(ConfigMessages.CONFIG_0114,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0114, configID));
- }
-
- return (ConfigurationModelContainer)cmc.clone();
+ return (ConfigurationModelContainerImpl)cmc.clone();
}
/**
@@ -168,61 +151,41 @@
* @param transaction is the transaction that contains the object model that changed
* @throws ConfigurationException if a problem occurs setting the configuration.
*/
- synchronized void applyTransaction(Collection<ConfigurationModelContainer>
models, String principal) throws ConfigTransactionException {
+ synchronized void applyTransaction(ConfigurationModelContainerImpl cmc, String
principal) throws ConfigurationException {
- if (models == null || models.isEmpty()) {
- throw new ConfigTransactionException(ConfigMessages.CONFIG_0119,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0119));
- }
-
PersistentConnection pc = null;
boolean success = false;
try {
- for (ConfigurationModelContainer config : models) {
- try {
-
- //validate the model before saving
- adapter.validateModel(config);
-
- if (pc == null) {
- pc = getConnection(false);
- }
-
- pc.write(config, principal);
- configs.put(config.getConfigurationID().getFullName(), config);
- } catch (ConfigurationException ce) {
- throw new ConfigTransactionException(ce, ConfigMessages.CONFIG_0120,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0120, config.getConfigurationID()));
- } catch (ConfigObjectsNotResolvableException e) {
- throw new ConfigTransactionException(e, ConfigMessages.CONFIG_0120,
ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0120, config.getConfigurationID()));
- }
- }
- try {
- pc.commit();
- } catch (ConfigurationException e) {
- throw new ConfigTransactionException(e, e.getMessage());
- }
+ // validate the model before saving
+ adapter.validateModel(cmc);
+
+ cmc = (ConfigurationModelContainerImpl)cmc.clone();
+ pc = getConnection(false);
+ pc.write(cmc, principal);
+
+ pc.commit();
success = true;
+ this.readOnlyConfig = cmc;
+ } catch (ConfigObjectsNotResolvableException e) {
+ throw new ConfigurationException(e,
ConfigMessages.CONFIG_0120,ConfigPlugin.Util.getString(ConfigMessages.CONFIG_0120,
cmc.getConfigurationID()));
} finally {
try {
if (!success && pc != null) {
- try {
- pc.rollback();
- } catch (ConfigurationException e) {
- throw new ConfigTransactionException(e, e.getMessage());
- }
- }
+ pc.rollback();
+ }
} finally {
pc.close();
}
}
- if (messageBus != null){
- try {
- messageBus.processEvent(new
ConfigurationChangeEvent(XMLConfigurationMgr.class.getName(),
ConfigurationChangeEvent.CONFIG_REFRESH));
+ if (messageBus != null) {
+ try {
+ messageBus.processEvent(new
ConfigurationChangeEvent(XMLConfigurationMgr.class.getName(),ConfigurationChangeEvent.CONFIG_REFRESH));
} catch (MessagingException e) {
- LogManager.logWarning(LogCommonConstants.CTX_CONFIG, e, "Exception sending
refresh event"); //$NON-NLS-1$
+ LogManager.logWarning(LogCommonConstants.CTX_CONFIG, e,"Exception sending
refresh event"); //$NON-NLS-1$
}
}
- }
+ }
/**
* This method should connect to the persitent storage.
@@ -233,7 +196,7 @@
}
private synchronized void clearCache() {
- configs.clear();
+ this.readOnlyConfig = null;
}
/**
Modified: trunk/server/src/main/java/com/metamatrix/server/Configuration.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/server/Configuration.java 2009-05-05
18:01:19 UTC (rev 863)
+++ trunk/server/src/main/java/com/metamatrix/server/Configuration.java 2009-05-05
19:09:01 UTC (rev 864)
@@ -29,5 +29,5 @@
final String CLUSTERNAME = "ClusterName"; //$NON-NLS-1$
final String LOGFILE = "LogFile"; //$NON-NLS-1$
final String LOGDIR = "LogDir"; //$NON-NLS-1$
-
+ final String UNICAST_PORT = "UnicastPort"; //$NON-NLS-1$
}
Modified: trunk/server/src/main/java/com/metamatrix/server/HostController.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/server/HostController.java 2009-05-05
18:01:19 UTC (rev 863)
+++ trunk/server/src/main/java/com/metamatrix/server/HostController.java 2009-05-05
19:09:01 UTC (rev 864)
@@ -353,7 +353,7 @@
java = "java"; //$NON-NLS-1$
}
String java_opts = vmprops.getProperty(VMComponentDefnType.JAVA_OPTS, "");
//$NON-NLS-1$
- java_opts = java_opts + " -Dcom.sun.management.jmxremote " +
System.getProperty(VMComponentDefnType.JAVA_OPTS, ""); //$NON-NLS-1$
//$NON-NLS-2$
+ java_opts = java_opts + " -Dcom.sun.management.jmxremote "; //$NON-NLS-1$
java = replaceToken(java, vmprops);
java_opts = replaceToken(java_opts, vmprops);
Modified: trunk/server/src/main/java/com/metamatrix/server/HostControllerGuiceModule.java
===================================================================
---
trunk/server/src/main/java/com/metamatrix/server/HostControllerGuiceModule.java 2009-05-05
18:01:19 UTC (rev 863)
+++
trunk/server/src/main/java/com/metamatrix/server/HostControllerGuiceModule.java 2009-05-05
19:09:01 UTC (rev 864)
@@ -22,6 +22,8 @@
package com.metamatrix.server;
+import java.util.Properties;
+
import org.jboss.cache.Cache;
import org.jgroups.mux.Multiplexer;
@@ -81,7 +83,8 @@
bindConstant().annotatedWith(Names.named(Configuration.CLUSTERNAME)).to(systemName);
bindConstant().annotatedWith(Names.named(Configuration.LOGFILE)).to(StringUtil.replaceAll(host.getFullName(),
".", "_")+"_hc.log"); //$NON-NLS-1$ //$NON-NLS-2$
//$NON-NLS-3$
bindConstant().annotatedWith(Names.named(Configuration.LOGDIR)).to(host.getLogDirectory());
-
+ bindConstant().annotatedWith(Names.named(Configuration.UNICAST_PORT)).to(5555);
+
Names.bindProperties(binder(), CurrentConfiguration.getInstance().getProperties());
bind(Multiplexer.class).toProvider(JGroupsProvider.class).in(Scopes.SINGLETON);
@@ -92,5 +95,4 @@
bind(MessageBus.class).to(JGroupsMessageBus.class).in(Scopes.SINGLETON); // VM Message
bus is in common-internal
bind(HostMonitor.class).in(Scopes.SINGLETON);
}
-
}
Modified: trunk/server/src/main/java/com/metamatrix/server/JGroupsProvider.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/server/JGroupsProvider.java 2009-05-05
18:01:19 UTC (rev 863)
+++ trunk/server/src/main/java/com/metamatrix/server/JGroupsProvider.java 2009-05-05
19:09:01 UTC (rev 864)
@@ -23,7 +23,9 @@
package com.metamatrix.server;
import java.lang.management.ManagementFactory;
+import java.util.Collection;
import java.util.Properties;
+import java.util.StringTokenizer;
import javax.management.MBeanRegistrationException;
import javax.management.MBeanServer;
@@ -35,10 +37,16 @@
import org.jgroups.JChannel;
import org.jgroups.mux.Multiplexer;
+import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.Singleton;
+import com.google.inject.name.Named;
import com.metamatrix.common.config.CurrentConfiguration;
import com.metamatrix.common.config.ResourceNames;
+import com.metamatrix.common.config.api.Host;
+import com.metamatrix.common.config.api.HostID;
+import com.metamatrix.common.config.api.VMComponentDefn;
+import com.metamatrix.common.config.api.VMComponentDefnType;
import com.metamatrix.common.config.api.exceptions.ConfigurationException;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.util.LogCommonConstants;
@@ -51,19 +59,10 @@
@Singleton
public class JGroupsProvider implements Provider<org.jgroups.mux.Multiplexer> {
- // Default Multicast Property values
- private static final String DEFAULT_UDP_MCAST_SUPPORTED = "true";
//$NON-NLS-1$
+ public static final String TCP = "tcp"; //$NON-NLS-1$
private static final String DEFAULT_UDP_MCAST_ADDR_PREFIX = "224.";
//$NON-NLS-1$
- private static final String DEFAULT_UDP_MCAST_PORT = "5555"; //$NON-NLS-1$
private static final String ALL_INTERFACES_ADDR = "0.0.0.0"; //$NON-NLS-1$
- // Default Gossip Server Property values
- private static final String DEFAULT_PING_GOSSIP_HOST = "localhost";
//$NON-NLS-1$
- private static final String DEFAULT_PING_GOSSIP_PORT = "5555"; //$NON-NLS-1$
- private static final String DEFAULT_PING_GOSSIP_REFRESH = "15000";
//$NON-NLS-1$
- private static final String DEFAULT_PING_TIMEOUT = "2000"; //$NON-NLS-1$
- private static final String DEFAULT_PING_NUM_INITIAL_MEMBERS = "3";
//$NON-NLS-1$
-
private static final String DEFAULT_JGROUPS_OTHER_SETTINGS =
"MERGE2(min_interval=5000;max_interval=10000):" +
//$NON-NLS-1$
"FD_SOCK:" +
//$NON-NLS-1$
@@ -78,18 +77,25 @@
private static final String ENCRYPT_ALL =
":ENCRYPT(key_store_name=teiid.keystore;store_password=changeit;alias=cluster_key)";
//$NON-NLS-1$
private static final String ENCRYPT_ALL_KEY =
"metamatrix.encryption.internal.secure.sockets"; //$NON-NLS-1$
+
+ public enum Protocol { UNICAST_TCP, UNICAST_UDP, MULTICAST}
- private static final String UDP_MCAST_SUPPORTED_PROPERTY =
"udp.multicast_supported"; //$NON-NLS-1$
- private static final String UDP_MCAST_MESSAGEBUS_PORT_PROPERTY =
"udp.mcast_messagebus_port"; //$NON-NLS-1$
- private static final String UDP_MCAST_ADDR_PROPERTY = "udp.mcast_addr";
//$NON-NLS-1$
- private static final String PING_GOSSIP_HOST_PROPERTY = "ping.gossip_host";
//$NON-NLS-1$
- private static final String PING_GOSSIP_PORT_PROPERTY = "ping.gossip_port";
//$NON-NLS-1$
- private static final String PING_GOSSIP_REFRESH_PROPERTY =
"ping.gossip_refresh"; //$NON-NLS-1$
- private static final String PING_GOSSIP_TIMEOUT_PROPERTY =
"ping.gossip_timout"; //$NON-NLS-1$
- private static final String PING_GOSSIP_NUM_INITIAL_MEMBERS_PROPERTY =
"ping.gossip_initialmembers"; //$NON-NLS-1$
+ public static final String CLUSTER_PROTOCOL = "cluster.protocol";
//$NON-NLS-1$
+ private static final String CLUSTER_MULTICAST_PORT = "cluster.port";
//$NON-NLS-1$
+ private static final String CLUSTER_MULTICAST_ADDRESS =
"cluster.multicast.address"; //$NON-NLS-1$
+ private static final String CLUSTER_PING = "cluster.unicast.ping";
//$NON-NLS-1$
+ private static final String CLUSTER_TIMEOUT = "cluster.unicast.timout";
//$NON-NLS-1$
private static final String JGROUPS_OTHER_SETTINGS_PROPERTY =
"jgroups.other.channel.settings"; //$NON-NLS-1$
private static final String BIND_ADDRESS_PROPERTY = "jgroups.bind.address";
//$NON-NLS-1$
+
+ private int unicastPort;
+
+ @Inject
+ public JGroupsProvider((a)Named(Configuration.UNICAST_PORT) int port) {
+ this.unicastPort = port;
+ }
+
/**
* Helper method to create a JChannel.
* Properties needed to create the JChannel are read from current configuration.
@@ -130,51 +136,53 @@
Properties configProps =
CurrentConfiguration.getInstance().getResourceProperties(ResourceNames.JGROUPS);
boolean useEncrypt =
PropertiesUtils.getBooleanProperty(CurrentConfiguration.getInstance().getProperties(),
ENCRYPT_ALL_KEY, false);
- String udpMulticastSupported = configProps.getProperty(UDP_MCAST_SUPPORTED_PROPERTY,
DEFAULT_UDP_MCAST_SUPPORTED);
-
- String udpMulticastPort = configProps.getProperty(UDP_MCAST_MESSAGEBUS_PORT_PROPERTY,
DEFAULT_UDP_MCAST_PORT);
- String pingGossipHost = configProps.getProperty(PING_GOSSIP_HOST_PROPERTY,
DEFAULT_PING_GOSSIP_HOST);
- String pingGossipPort = configProps.getProperty(PING_GOSSIP_PORT_PROPERTY,
DEFAULT_PING_GOSSIP_PORT);
- String pingGossipRerefresh =
configProps.getProperty(PING_GOSSIP_REFRESH_PROPERTY, DEFAULT_PING_GOSSIP_REFRESH);
- String pingTimeout = configProps.getProperty(PING_GOSSIP_TIMEOUT_PROPERTY,
DEFAULT_PING_TIMEOUT);
- String pingInitialMemberCount =
configProps.getProperty(PING_GOSSIP_NUM_INITIAL_MEMBERS_PROPERTY,
DEFAULT_PING_NUM_INITIAL_MEMBERS);
+
+ Protocol protocol = Protocol.valueOf(configProps.getProperty(CLUSTER_PROTOCOL,
Protocol.UNICAST_TCP.toString()));
+ boolean useMulticast = (protocol == Protocol.MULTICAST);
+
+ String multicastPort = configProps.getProperty(CLUSTER_MULTICAST_PORT,
"5555"); //$NON-NLS-1$
+ String pingGossipRerefresh = configProps.getProperty(CLUSTER_PING, "10000");
//$NON-NLS-1$ 10 secs
+ String pingTimeout = configProps.getProperty(CLUSTER_TIMEOUT, "2000");
//$NON-NLS-1$ 2 secs
String otherSettings = configProps.getProperty(JGROUPS_OTHER_SETTINGS_PROPERTY,
DEFAULT_JGROUPS_OTHER_SETTINGS);
-
+ String unicastMembers =
CurrentConfiguration.getInstance().getProperties().getProperty(CurrentConfiguration.CLUSTER_MEMBERS);
+
String bindAddress = getBindAddress();
boolean multicastOnAllInterfaces = bindAddress.equalsIgnoreCase(ALL_INTERFACES_ADDR);
-
- String udpMulticastAddress = configProps.getProperty(UDP_MCAST_ADDR_PROPERTY);
- if (udpMulticastAddress == null || udpMulticastAddress.length() == 0) {
- String currentAddr = CurrentConfiguration.getInstance().getBindAddress();
- if (currentAddr.indexOf('.') != -1) {
- String lastNode = currentAddr.substring(currentAddr.indexOf('.')+1);
- udpMulticastAddress = DEFAULT_UDP_MCAST_ADDR_PREFIX + lastNode;
- }
- else {
- throw new ConfigurationException("Failed to set default multicast
address"); //$NON-NLS-1$
- }
- }
+ String clusterAddress = configProps.getProperty(CLUSTER_MULTICAST_ADDRESS);
- if (udpMulticastSupported.equalsIgnoreCase("true")) { //$NON-NLS-1$
+ if (useMulticast) {
if (multicastOnAllInterfaces) {
properties =
-
"UDP(mcast_addr="+udpMulticastAddress+";mcast_port="+udpMulticastPort+";ip_ttl=32;receive_on_all_interfaces="
+ udpMulticastSupported.toString() + ";" + //$NON-NLS-1$//$NON-NLS-2$
//$NON-NLS-3$ //$NON-NLS-4$
+
"UDP(mcast_addr="+clusterAddress+";mcast_port="+multicastPort+";ip_ttl=32;receive_on_all_interfaces=true;"
+ //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
"mcast_send_buf_size=150000;mcast_recv_buf_size=80000):" +
//$NON-NLS-1$
-
"PING(timeout="+pingTimeout+";num_initial_members="+pingInitialMemberCount+"):";//$NON-NLS-1$
//$NON-NLS-2$//$NON-NLS-3$
-
-
+ "PING(timeout="+pingTimeout+";):";//$NON-NLS-1$
//$NON-NLS-2$
+ LogManager.logInfo(LogCommonConstants.CTX_MESSAGE_BUS, "JGroups
using multicast on all available interfaces"); //$NON-NLS-1$
} else {
+ clusterAddress = getMulticastAddress(clusterAddress, bindAddress);
properties =
-
"UDP(mcast_addr="+udpMulticastAddress+";mcast_port="+udpMulticastPort+";ip_ttl=32;bind_addr="+bindAddress+";"+
//$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+
"UDP(mcast_addr="+clusterAddress+";mcast_port="+multicastPort+";ip_ttl=32;bind_addr="+bindAddress+";"+
//$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
"mcast_send_buf_size=150000;mcast_recv_buf_size=80000):" +
//$NON-NLS-1$
-
"PING(timeout="+pingTimeout+";num_initial_members="+pingInitialMemberCount+"):";//$NON-NLS-1$
//$NON-NLS-2$//$NON-NLS-3$
+ "PING(timeout="+pingTimeout+";):";//$NON-NLS-1$
//$NON-NLS-2$
+ LogManager.logInfo(LogCommonConstants.CTX_MESSAGE_BUS, "JGroups using
multicast with address "+clusterAddress+ " and port "+ multicastPort);
//$NON-NLS-1$ //$NON-NLS-2$
}
} else {
- properties =
- "UDP(ip_mcast=false;mcast_addr="+udpMulticastAddress+";mcast_port="+udpMulticastPort+";bind_addr="+bindAddress+"):"
+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- "PING(gossip_host="+pingGossipHost+";gossip_port="+pingGossipPort+";gossip_refresh="+pingGossipRerefresh+";"
+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- "timeout="+pingTimeout+";num_initial_members="+pingInitialMemberCount+"):";
//$NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$
+ if (protocol == Protocol.UNICAST_UDP) {
+ clusterAddress = getMulticastAddress(clusterAddress, bindAddress);
+ properties =
+ "UDP(ip_mcast=false;mcast_addr="+clusterAddress+";mcast_port="+multicastPort+";bind_addr="+bindAddress+"):"
+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ "PING(gossip_host="+getGossipHost(unicastMembers)+";gossip_port="+getGossipPort(unicastMembers)+";gossip_refresh="+pingGossipRerefresh+";"
+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ "timeout="+pingTimeout+";):"; //$NON-NLS-1$ //$NON-NLS-2$
+ LogManager.logInfo(LogCommonConstants.CTX_MESSAGE_BUS, "JGroups using Unicast
with UDP with gossip host"+getGossipHost(unicastMembers)+ " and port "+
getGossipPort(unicastMembers)); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ else {
+ String resolvedClusterMemebers = resolveClusterMembers(unicastMembers);
+ properties =
"TCP(start_port="+this.unicastPort+";port_range=0;bind_addr="+bindAddress+";loopback=true;skip_suspected_members=true;discard_incompatible_packets=true;sock_conn_timeout=3000;use_concurrent_stack=true;):"
+ //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
"TCPPING(initial_hosts="+resolvedClusterMemebers+";port_range=1;timeout="+pingTimeout+"):"
+//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ "pbcast.FLUSH(timeout=60000)"; //$NON-NLS-1$
+ LogManager.logInfo(LogCommonConstants.CTX_MESSAGE_BUS, "JGroups using Unicast
with TCP with initial members configured as "+ resolvedClusterMemebers + " with
local process port "+this.unicastPort); //$NON-NLS-1$ //$NON-NLS-2$
+ }
}
+
properties += otherSettings;
if (useEncrypt) {
properties += ENCRYPT_ALL;
@@ -187,11 +195,7 @@
}
private final String getBindAddress() {
- // check for command line system property being set from vm.starter.command for
jgroup
- String bindAddress = System.getProperty(JGroupsProvider.BIND_ADDRESS_PROPERTY);
- if (bindAddress == null) {
- bindAddress = CurrentConfiguration.getInstance().getBindAddress();
- }
+ String bindAddress = CurrentConfiguration.getInstance().getBindAddress();
if (bindAddress == null) {
LogManager.logWarning(LogCommonConstants.CTX_MESSAGE_BUS,"WARNING:
Unable to set " + JGroupsProvider.BIND_ADDRESS_PROPERTY + ", will set to
127.0.0.1"); //$NON-NLS-1$ //$NON-NLS-2$
@@ -199,4 +203,71 @@
}
return bindAddress;
}
+
+ private String getMulticastAddress(String clusterAddress, String bindAddress){
+ if (clusterAddress == null || clusterAddress.length() == 0) {
+ if (bindAddress.indexOf('.') != -1) {
+ String lastNode = bindAddress.substring(bindAddress.indexOf('.')+1);
+ return DEFAULT_UDP_MCAST_ADDR_PREFIX + lastNode;
+ }
+ }
+ return clusterAddress;
+ }
+
+ private String getGossipHost(String clusterMembers) {
+ StringTokenizer st = new StringTokenizer(clusterMembers, ",");
//$NON-NLS-1$
+ // the string must be in the format "hostA[port]"
+ String hostPort = st.nextToken();
+ int idx = hostPort.indexOf('[');
+ if (idx == -1) {
+ throw new MetaMatrixRuntimeException("Gossip Router information is not
specified correctly. This must property must be in the form
'gossipHost[port]'"); //$NON-NLS-1$
+ }
+ return hostPort.substring(0, idx);
+ }
+
+ private String getGossipPort(String clusterMembers) {
+ StringTokenizer st = new StringTokenizer(clusterMembers, ",");
//$NON-NLS-1$
+ // the string must be in the format "hostA[port]"
+ String hostPort = st.nextToken();
+ return hostPort.substring(hostPort.indexOf('[')+1,
hostPort.lastIndexOf(']'));
+ }
+
+ String resolveClusterMembers(String members) {
+ try {
+ com.metamatrix.common.config.api.Configuration config =
CurrentConfiguration.getInstance().getConfiguration();
+ if (members != null && members.trim().length() > 0) {
+ StringBuilder sb = new StringBuilder();
+ StringTokenizer st = new StringTokenizer(members.trim(), ",");
//$NON-NLS-1$
+
+ while(st.hasMoreTokens()) {
+ String member = st.nextToken();
+ int idx = member.indexOf('|');
+ if (idx != -1) {
+ String hostConfigName = member.substring(0, idx);
+ String hostAddr = member.substring(idx+1);
+
+ Host host = config.getHost(hostConfigName);
+ if (host != null) {
+ Collection<VMComponentDefn> allProcesses =
config.getVMsForHost((HostID)host.getID());
+ for (VMComponentDefn process:allProcesses) {
+ String strPort = process.getProperty(VMComponentDefnType.CLUSTER_PORT);
+ if (strPort != null && strPort.length() > 0) {
+ sb.append(hostAddr).append("[").append(Integer.parseInt(strPort)).append("],");
//$NON-NLS-1$ //$NON-NLS-2$
+ // this for host controller; will be removed when the hostcontroller is no
longer
+ // be a member.
+ sb.append(hostAddr).append("[").append(5556).append("],");
//$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+ }
+ }
+ }
+ return sb.toString();
+ }
+ } catch (ConfigurationException e) {
+ throw new MetaMatrixRuntimeException(e);
+ } catch (NumberFormatException e) {
+ throw new MetaMatrixRuntimeException(e);
+ }
+ return ""; //$NON-NLS-1$
+ }
}
Modified: trunk/server/src/main/java/com/metamatrix/server/ServerGuiceModule.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/server/ServerGuiceModule.java 2009-05-05
18:01:19 UTC (rev 863)
+++ trunk/server/src/main/java/com/metamatrix/server/ServerGuiceModule.java 2009-05-05
19:09:01 UTC (rev 864)
@@ -22,6 +22,10 @@
package com.metamatrix.server;
+import java.util.Collection;
+import java.util.Properties;
+import java.util.StringTokenizer;
+
import org.jboss.cache.Cache;
import org.jgroups.mux.Multiplexer;
import org.teiid.dqp.internal.cache.DQPContextCache;
@@ -34,11 +38,15 @@
import com.metamatrix.common.comm.platform.socket.SocketVMController;
import com.metamatrix.common.config.CurrentConfiguration;
import com.metamatrix.common.config.api.Host;
+import com.metamatrix.common.config.api.HostID;
+import com.metamatrix.common.config.api.VMComponentDefn;
+import com.metamatrix.common.config.api.VMComponentDefnType;
import com.metamatrix.common.config.api.exceptions.ConfigurationException;
import com.metamatrix.common.log.LogConfiguration;
import com.metamatrix.common.log.LogManager;
import com.metamatrix.common.messaging.MessageBus;
import com.metamatrix.common.messaging.jgroups.JGroupsMessageBus;
+import com.metamatrix.core.MetaMatrixRuntimeException;
import com.metamatrix.core.log.LogListener;
import com.metamatrix.core.util.StringUtil;
import com.metamatrix.platform.registry.ClusteredRegistryState;
@@ -49,7 +57,7 @@
import com.metamatrix.platform.vm.controller.ServerEvents;
class ServerGuiceModule extends AbstractModule {
-
+
Host host;
String processName;
@@ -74,7 +82,8 @@
bindConstant().annotatedWith(Names.named(Configuration.CLUSTERNAME)).to(systemName);
bindConstant().annotatedWith(Names.named(Configuration.LOGFILE)).to(StringUtil.replaceAll(host.getFullName(),
".", "_")+"_"+this.processName+".log");
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
bindConstant().annotatedWith(Names.named(Configuration.LOGDIR)).to(host.getLogDirectory());
-
+ bindConstant().annotatedWith(Names.named(Configuration.UNICAST_PORT)).to(getUnicastClusterPort());
+
Names.bindProperties(binder(), CurrentConfiguration.getInstance().getProperties());
bind(Multiplexer.class).toProvider(JGroupsProvider.class).in(Scopes.SINGLETON);
@@ -100,5 +109,20 @@
binder().requestStaticInjection(LogManager.class);
}
-
+
+ int getUnicastClusterPort() {
+ try {
+ com.metamatrix.common.config.api.Configuration config =
CurrentConfiguration.getInstance().getConfiguration();
+ VMComponentDefn process = config.getVMForHost(this.host.getFullName(),
this.processName);
+ String strPort =
process.getProperties().getProperty(VMComponentDefnType.CLUSTER_PORT);
+ if (strPort != null && strPort.length() > 0) {
+ return Integer.parseInt(strPort);
+ }
+ } catch (ConfigurationException e) {
+ throw new MetaMatrixRuntimeException(e);
+ } catch (NumberFormatException e) {
+ throw new MetaMatrixRuntimeException(e);
+ }
+ return 5555;
+ }
}
Modified:
trunk/server/src/test/java/com/metamatrix/admin/server/FakeConfigurationService.java
===================================================================
---
trunk/server/src/test/java/com/metamatrix/admin/server/FakeConfigurationService.java 2009-05-05
18:01:19 UTC (rev 863)
+++
trunk/server/src/test/java/com/metamatrix/admin/server/FakeConfigurationService.java 2009-05-05
19:09:01 UTC (rev 864)
@@ -440,8 +440,7 @@
* @see
com.metamatrix.platform.config.api.service.ConfigurationServiceInterface#executeTransaction(com.metamatrix.common.actions.ActionDefinition,
java.lang.String)
*/
public Set executeTransaction(ActionDefinition action,
- String principalName) throws ModificationException,
- ConfigurationException {
+ String principalName) throws ConfigurationException {
return null;
}
@@ -449,8 +448,7 @@
* @see
com.metamatrix.platform.config.api.service.ConfigurationServiceInterface#executeTransaction(java.util.List,
java.lang.String)
*/
public Set executeTransaction(List actions,
- String principalName) throws ModificationException,
- ConfigurationException {
+ String principalName) throws ConfigurationException {
if (actions != null) {
for (Iterator it=actions.iterator(); it.hasNext();) {
Object o = it.next();
@@ -564,8 +562,7 @@
*/
public Object modify(ComponentObject theObject,
Properties theProperties,
- String principalName) throws ConfigurationException,
- ModificationException {
+ String principalName) throws ConfigurationException{
return null;
}
@@ -638,16 +635,14 @@
*/
public void delete(ComponentObject theObject,
boolean theDeleteDependenciesFlag,
- String principalName) throws ConfigurationException,
- ModificationException {
+ String principalName) throws ConfigurationException {
}
/**
* @see
com.metamatrix.platform.config.api.service.ConfigurationServiceInterface#delete(com.metamatrix.common.config.api.ComponentType,
java.lang.String)
*/
public void delete(ComponentType componentType,
- String principalName) throws ConfigurationException,
- ModificationException{
+ String principalName) throws ConfigurationException{
}
@@ -656,7 +651,7 @@
@Override
public DeployedComponent deployService(VMComponentDefnID theProcessID,
String serviceName, String principalName)
- throws ConfigurationException, ModificationException {
+ throws ConfigurationException{
// TODO Auto-generated method stub
return null;
}
Modified:
trunk/server/src/test/java/com/metamatrix/platform/config/spi/xml/TestXMLConfigImportExport.java
===================================================================
---
trunk/server/src/test/java/com/metamatrix/platform/config/spi/xml/TestXMLConfigImportExport.java 2009-05-05
18:01:19 UTC (rev 863)
+++
trunk/server/src/test/java/com/metamatrix/platform/config/spi/xml/TestXMLConfigImportExport.java 2009-05-05
19:09:01 UTC (rev 864)
@@ -126,107 +126,12 @@
pc.close();
}
-
-
- /**
- * This test the Console process for importing a new binding
-
- public void testImportConnector() throws Exception {
- printMsg("Starting testImportConnector"); //$NON-NLS-1$
-
- // file should not have the example connector in it
-// initializeConfig(CONFIG_WITH_CONNECTOR_FILE);
- initializeConfig(CONFIG_FILE);
- this.initTransactions(new Properties());
-
-
- helperImportConnectorType();
- helperImportConnectorBinding(CDK_FILE);
-
- printMsg("Completed testImportConnector"); //$NON-NLS-1$
-
- }
- */
-// public void testImportJDBCConnector() {
-// printMsg("Starting testImportJDBCConnector"); //$NON-NLS-1$
-//
-// try {
-// // file should not have the example connector in it
-// initializeConfig(CONFIG_FILE);
-//
-// helperImportConnectorBinding(JDBC_FILE);
-// } catch (Exception e) {
-// // e.printStackTrace();
-//
-// fail(e.getMessage());
-// }
-//
-// printMsg("Completed testImportJDBCConnector"); //$NON-NLS-1$
-//
-// }
-
-
- private void helperImportConnectorType() throws Exception {
- printMsg("Starting helperImportConnectorType"); //$NON-NLS-1$
-
-// initializeConfig(CONFIG_FILE);
-
-
- // XMLConfigurationConnector writer = (XMLConfigurationConnector)
factory.createTransaction(conn, false);
-
- File cdkFile = new File(getPath(), CDK_FILE);
-
-
- InputStream inputStream = readFile(cdkFile.getPath());
-
-
- XMLConfigurationImportExportUtility io = new
XMLConfigurationImportExportUtility();
-
-
- // ConfigurationObjectEditor editor = new BasicConfigurationObjectEditor(true);
-
- ComponentType type = io.importComponentType(inputStream, getEditor(), null);
-
-
-// editor.getDestination().popActions();
-
-// editor.createComponentType(type);
-
- commit();
-
-
-// List actions = editor.getDestination().popActions();
-//
-// printMsg("Executing # of Actions: " + actions.size()); //$NON-NLS-1$
-//
-// try {
-// writer.executeActions(actions, PRINCIPAL);
-//
-//
-// writer.commit();
-// } catch (Exception e) {
-// writer.rollback();
-// throw e;
-// }
-
- ComponentType newType = getWriter().getComponentType((ComponentTypeID) type.getID());
- if (newType == null) {
- fail("Import of connector type " + type.getID() + " was not
successfull."); //$NON-NLS-1$ //$NON-NLS-2$
- }
- HelperTestConfiguration.validateComponentType(newType);
-
- printMsg("Completed helperImportConnectorType"); //$NON-NLS-1$
-
- }
-
/**
* This test the import operation that the console will be doing
* when importing a new configuration
*/
private void helperImportConnectorBinding(String file) throws Exception {
printMsg("Starting helperImportConnectorBinding"); //$NON-NLS-1$
-
-// XMLConfigurationConnector writer = (XMLConfigurationConnector)
factory.createTransaction(conn, false);
File connFile = new File(getPath(), file);
@@ -244,55 +149,20 @@
if (defn == null) {
fail("No connector binding was imported"); //$NON-NLS-1$
}
-
-// ConfigurationObjectEditor reditor = new BasicConfigurationObjectEditor(true);
- ConfigurationModelContainer config =
getWriter().getConfigurationModel(Configuration.NEXT_STARTUP);
+ ConfigurationModelContainer config = getWriter().getConfigurationModel();
-
-
-
-
ConnectorBinding newdefn =
getEditor().createConnectorComponent(Configuration.NEXT_STARTUP_ID, defn,
defn.getFullName(), defn.getRoutingUUID());
-// reditor.setEnabled(newdefn, true);
commit();
- // ProductServiceConfig psc =
com.metamatrix.common.config.util.ConfigUtil.getFirstDeployedConnectorProductTypePSC(config);
-
-// ProductServiceConfigID pscID = null;
-
-// ComponentDefn defn = null;
-// if (psc != null) {
-// pscID = (ProductServiceConfigID)psc.getID();
-//
-// } else {
-// psc = helperTestAddPSC("TestPSC_" + String.valueOf( (new
Date()).getTime()), (ServiceComponentDefnID) newdefn.getID(),
Configuration.NEXT_STARTUP_ID ); //$NON-NLS-1$
-// pscID = (ProductServiceConfigID)psc.getID();
-//
-// }
- // add to the psc, but does not deploy
- // psc = getEditor().addServiceComponentDefn(psc, (ServiceComponentDefnID)
newdefn.getID());
VMComponentDefn vmdefn = (VMComponentDefn)
config.getConfiguration().getVMComponentDefns().iterator().next();
// deploys the binding if the psc is deployed
getEditor().deployServiceDefn(config.getConfiguration(), newdefn,
(VMComponentDefnID) vmdefn.getID());
commit();
-// List actions = reditor.getDestination().popActions();
-//
-//
-// printMsg("Executing # of Actions: " + actions.size() + " for # of
Connector: " + newdefn.getFullName()); //$NON-NLS-1$ //$NON-NLS-2$
-//
-// try {
-// writer.executeActions(actions, PRINCIPAL);
-//
-// writer.commit();
-// } catch (Exception e) {
-// writer.rollback();
-// throw e;
-// }
- ConnectorBinding newDefn = (ConnectorBinding)
getWriter().getComponentDefinition((ComponentDefnID) defn.getID(),
Configuration.NEXT_STARTUP_ID);
+ ConnectorBinding newDefn = (ConnectorBinding)
getWriter().getConfigurationModel().getConfiguration().getComponentDefn((ComponentDefnID)defn.getID());
if (newDefn == null) {
fail("Import of connector binding was not successfull, no obect found when
reading."); //$NON-NLS-1$
}
@@ -303,100 +173,6 @@
}
-
-//
-// private ProductServiceConfig helperTestAddPSC(String pscName,
ServiceComponentDefnID id, ConfigurationID configID) {
-// printMsg("Starting helperTestAddPSC"); //$NON-NLS-1$
-// ProductServiceConfig newDefn = null;
-// try {
-//
-//
-// Configuration config = this.getConfigModel().getConfiguration();
-//
-// Collection types = this.getConfigModel().getProductTypes();
-//
-// ConnectorBinding defn = config.getConnectorBinding(id) ;
-//
-// newDefn = addPSC(pscName, defn, config, types, getEditor());
-//
-//
-// printMsg("helperTestAddPSC actions committed"); //$NON-NLS-1$
-//
-//
-// HelperTestConfiguration.validateComponentDefn(newDefn);
-//
-//// ConfigurationPrinter.printComponentObject(h, false, System.out);
-//
-//
-//
-// } catch (Exception e) {
-// e.printStackTrace();
-// fail(e.getMessage());
-// }
-// printMsg("Completed helperTestAddPSC"); //$NON-NLS-1$
-// return newDefn;
-// }
-
-
-// private ProductServiceConfig addPSC(String name, ServiceComponentDefn svc,
Configuration config, Collection types, BasicConfigurationObjectEditor editor) throws
Exception {
-//
-// ProductType connType = BasicProductType.PRODUCT_TYPE;
-//
-//
-// printMsg("addPSC found product type " + connType.getFullName());
//$NON-NLS-1$
-//
-// ProductServiceConfig newPSC =
getEditor().createProductServiceConfig((ConfigurationID) config.getID(), (ProductTypeID)
connType.getID(), name);
-//
-// if (newPSC == null) {
-// throw new ConfigurationException("AddPSC Error - editor is unable
to create new PSC " + name + " of type " + connType.getFullName());
//$NON-NLS-1$ //$NON-NLS-2$
-// }
-//
-// newPSC = (ProductServiceConfig) getEditor().setLastChangedHistory(newPSC,
PRINCIPAL, DateUtil.getCurrentDateAsString());
-// newPSC = (ProductServiceConfig)
getEditor().setCreationChangedHistory(newPSC, PRINCIPAL,
DateUtil.getCurrentDateAsString());
-//
-// printMsg("addPSC created new PSC " + newPSC.getFullName());
//$NON-NLS-1$
-//
-// this.getEditor().addServiceComponentDefn(config, newPSC,
(ServiceComponentDefnID) svc.getID());
-// printMsg("addPSC add service to PSC "); //$NON-NLS-1$
-//
-// commit();
-//
-// ProductServiceConfig psc =
CurrentConfiguration.getInstance().getConfiguration().getPSC((ProductServiceConfigID)
newPSC.getID());
-// assertNotNull(psc);
-//
-// return newPSC;
-// }
-
-
-// public ProductType findProductType(String name, Collection types) {
-// ProductType connType = null;
-// for (Iterator it=types.iterator(); it.hasNext(); ) {
-// connType = (ProductType) it.next();
-// if (connType.getFullName().equals(name)) {
-// return connType;
-// }
-//
-// connType = null;
-// }
-//
-// return connType;
-// }
-
-
-
-// private boolean compare(String fileName1, ConfigurationID id1, String fileName2,
ConfigurationID id2, String logFile) throws Exception {
-//
-// ConfigurationModelContainer model1 = TestFilePersistence.readModel(fileName1,
id1);
-//
-// ConfigurationModelContainer model2 = TestFilePersistence.readModel(fileName2,
id2);
-//
-//
-// boolean isEqual = TestFilePersistence.compareModels(model1, model2, logFile);
-//
-// return isEqual;
-//
-// }
-
private InputStream readFile(String fileName) throws ConfigurationException {
InputStream inputStream = null;
@@ -414,20 +190,6 @@
}
}
-// private void designateNextStartupConfiguration(Collection configObjects,
-// ConfigurationObjectEditor editor)
throws Exception{
-// Iterator iterator = configObjects.iterator();
-// while (iterator.hasNext()) {
-// Object obj = iterator.next();
-// if (obj instanceof Configuration) {
-// Configuration config = (Configuration)obj;
-// ConfigurationID configID = (ConfigurationID)config.getID();
-// editor.setNextStartupConfiguration(configID);
-// }
-// }
-// }
-
-
}
Modified:
trunk/server/src/test/java/com/metamatrix/platform/config/spi/xml/TestXMLConfigReader.java
===================================================================
---
trunk/server/src/test/java/com/metamatrix/platform/config/spi/xml/TestXMLConfigReader.java 2009-05-05
18:01:19 UTC (rev 863)
+++
trunk/server/src/test/java/com/metamatrix/platform/config/spi/xml/TestXMLConfigReader.java 2009-05-05
19:09:01 UTC (rev 864)
@@ -57,7 +57,7 @@
XMLConfigurationConnector reader =
XMLConfigurationMgr.getInstance().getTransaction(PRINCIPAL);
printMsg("Validate ComponentTypes Exists"); //$NON-NLS-1$
- Collection compTypes = reader.getAllComponentTypes(true);
+ Collection compTypes =
reader.getConfigurationModel().getComponentTypes().values();
HelperTestConfiguration.validateComponentTypes(compTypes);
@@ -81,15 +81,15 @@
}
printMsg("Validate Resources Exists"); //$NON-NLS-1$
- Collection resources = reader.getResources();
+ Collection resources = reader.getConfigurationModel().getResources();
HelperTestConfiguration.validateResources(resources);
printMsg("Validate NextStartup Config"); //$NON-NLS-1$
- Configuration ns =
reader.getDesignatedConfiguration(Configuration.NEXT_STARTUP);
+ Configuration ns = reader.getConfigurationModel().getConfiguration();
- HelperTestConfiguration.validateConfigContents(ns);
+// HelperTestConfiguration.validateConfigContents(ns);
int cnt = 0;
Collection bindingsCollection = ns.getConnectorBindings();
@@ -106,7 +106,7 @@
printMsg("Validate Hosts"); //$NON-NLS-1$
- Collection hosts = reader.getHosts();
+ Collection hosts = reader.getConfigurationModel().getConfiguration().getHosts();
HelperTestConfiguration.validateHosts(hosts);
}