+

Search Tips   |   Advanced Search

Create, modify, and delete configuration objects using one properties file

We can specify to create, modify, and delete objects in one properties file. You run the applyConfigProperties command to apply the configuration changes. Using the PropertiesBasedConfiguration (AdminTask), we can use properties files to create, modify, and delete configuration objects from the environment.

To delete an entire object, in the header of the properties section, specify DELETE=true or DELTEPROP=true, then run applyConfigProperties. With this approach, we do not need to run the deleteConfigProperties command to delete an object.

See also: Apply portable properties files across multiple environments

  1. Start the wsadmin scripting tool.

  2. Extract a properties file for the subtype of interest from your configuration.

    Use the extractConfigProperties command to extract the properties file for the resource of interest. The following example extracts the properties for the JDBCProvider resource to the derby.props file:

      AdminTask.extractConfigProperties('[-propertiesFileName derby.props -configData Server=server1 -filterMechanism SELECTED_SUBTYPES -selectedSubTypes [JDBCProvider]]')

    The command generates a template file similar to...

      #
      # SubSection 1.0
      #
      # JDBCProvider attributes
      ResourceType=JDBCProvider
      ImplementingResourceType=JDBCProvider
      ResourceId=Cell=!{cellName}:ServerCluster=!{clusterName}:JDBCProvider=Derby JDBC Provider (XA)
      #
      #Properties
      classpath={${DERBY_JDBC_DRIVER_PATH}/derby.jar}
      name=Derby JDBC Provider (XA) # required
      implementationClassName=org.apache.derby.jdbc.EmbeddedXADataSource
      # required
      isolatedClassLoader=false
      #boolean,default(false)
      nativepath={}
      description=Built-in Derby JDBC Provider (XA)
      providerType=Derby JDBC Provider (XA) #readonly
      xa=true # boolean,default(false)

  3. Edit the extracted properties file to specify that it create, modify, or delete configuration objects.

    • To create a new object, specify unique properties for an object.

      The following example creates a new DataSource object, DefaultDatasource_1, which does not exist in the configuration:

        #
        # Create a new object
        #
        ResourceType=DataSource
        ImplementingResourceType=GenericType
        ResourceId=Cell=!{cellName}:Node=!{nodeName}:Server=!{serverName}:JDBCProvider=Derby JDBC Provider:DataSource=jndiName#DefaultDatasource_1
        #
        #
        #Properties
        #
        name=Default Datasource1 # required
        jndiName=DefaultDatasource_1
        manageCachedHandles=false #boolean,default(false)
        provider=Derby JDBC Provider #ObjectName(JDBCProvider),readonly
        description=Datasource for the WebSphere Default Application
        logMissingTransactionContext=true #boolean,default(true)

    • To modify an existing object, change one or more object properties.

      The following example changes the description property of the DefaultDatasource_1 object by adding _1 to the end of the description:

        #
        # Modify a property
        #
        ResourceType=DataSource
        ImplementingResourceType=GenericType
        ResourceId=Cell=!{cellName}:Node=!{nodeName}:Server=!{serverName}:JDBCProvider=Derby JDBC Provider:DataSource=jndiName#DefaultDatasource_1
        #
        #
        #Properties
        #
        description=Datasource for the WebSphere Default Application_1

    • To delete an existing object property, specify DELETEPROP=true in the header of the properties file.

      The following example deletes the description property:

        #
        # Delete a property
        #
        ResourceType=DataSource
        ImplementingResourceType=GenericType
        ResourceId=Cell=!{cellName}:Node=!{nodeName}:Server=!{serverName}:JDBCProvider=Derby JDBC Provider:DataSource=jndiName#DefaultDatasource_1
        DELETEPROP=true
        #
        #
        #Properties
        #
        description=Datasource for the WebSphere Default Application_1

    • To delete an existing object, specify DELETE=true in the header of the properties file.

      The following example deletes the DefaultDatasource object:

        # # Delete an existing object
        #
        ResourceType=DataSource
        ImplementingResourceType=GenericType
        ResourceId=Cell=!{cellName}:Node=!{nodeName}:Server=!{serverName}:JDBCProvider=Derby JDBC Provider:DataSource=jndiName#DefaultDatasource
        DELETE=true
        #
        #
        #Properties
        #
        name=Default Datasource
        # required
        jndiName=DefaultDatasource

  4. Run the applyConfigProperties command to apply the properties file and change the configuration.

      AdminTask.applyConfigProperties('[-propertiesFileName derby.props]')

    The command automatically validates the properties file, then applies the changes to the configuration.

    Avoid trouble: If we run the applyConfigProperties command before we add the DELETE=true attribute and value to the properties file, the command resets each property to the default value. The system completely removes properties that do not have default values.gotcha


Results

The administrative command runs and applies the properties file.


What to do next

Save the changes to the configuration.


Related tasks

Apply portable properties files across multiple environments
  • Extracting properties files
  • Apply properties files
  • Validating properties files
  • Create server, cluster, application, or authorization group objects using properties files and wsadmin scripting
  • Delete server, cluster, application, or authorization group objects using properties files
  • Extracting properties files to troubleshoot the environment
  • Use properties files to manage system configuration
  • PropertiesBasedConfiguration (AdminTask)
  • Properties file syntax