DevOps Automation

 View Only

Tokenizing values in snippet files

By Laurel Dickson-Bull posted Mon July 25, 2022 10:37 AM

  

This article was originaly published in 2016.09.28

The WebSphere Application Server – Configure plug-in stores WebSphere Application Server configuration information in a series of JSON files. You can divide the JSON files into smaller, manageable pieces and use the small JSON files, or snippets, to create and modify configuration data. You can then tokenize values in JSON snippets, and use processes to replace the tokenized values with IBM UrbanCode Deploy properties. By keeping component artifacts managed in a source control system, you can build a library of JSON snippets that users can apply to WebSphere Application Server configurations.

The snippet files can contain tokenized values, such as the values shown in the following code. In this example, tokenized values start and end with the at symbol (@).

   {
        "name": "@NAME@",
        "path": "/@websphere.cell@/JDBC Providers/@NAME@",
        "teamMappings": [],
        "inheritTeam": "true",
        "description": "Discovered WebSphereJDBCProvider",
        "roleName": "WebSphereJDBCProvider",
        "roleProperties": {
            "websphere.jdbcprovider.xa": "@XA@",
            "websphere.jdbcprovider.name": "@NAME@",
            "websphere.jdbcprovider.classpath": "@CLASSPATH@",
            "websphere.jdbcprovider.providertype": "@PROVIDERTYPE@",
            "websphere.jdbcprovider.implementationclassname": "@IMPLEMENTATIONCLASSNAME@",
            "websphere.jdbcprovider.nativepath": "@NATIVEPATH@",
            "websphere.jdbcprovider.description": "@DESCRIPTION@",
            "websphere.jdbcprovider.isolatedclassloader": "@ISOLATE@"
        }
    }

To easily tokenize values in a snippet, use the WebSphere – Templatize Snippet Configuration Data step. This step can replace values such as the cell name, server name, and so on with tokens. Additionally, the User Defined Tokenization property of this step runs a find-and-replace operation on text in your configuration data. You can easily use the User Defined Tokenization field to convert values to tokens in your configuration data.

The following diagram shows a process that retrieves a snippet from source control, replaces the tokenized values, and then checks in the snippet to source control and updates the component version.

IBM UrbanCode Deploy properties (environment properties, component properties, resource properties, and so on) are used to replace the tokenized values. The following examples show the use of component process properties:


When the process runs, you are prompted to enter values for the component process properties, as shown in the following screen capture:

 

In this example, the tokenized values in a copy of the JDBCProvider.json snippet are replaced, and then the snippet is moved to cell directory under the cell component artifact.

Instead of replacing all values as shown in the previous process, you can leave some values tokenized, and then use properties to set those values when the Apply process runs. For example, if the JVM heap size property changes for different environments, you can leave the JVM heap size tokenized in the snippet. In the Apply process, replace the token with a corresponding property.


#WebSphereApplicationServer(WAS)
#UrbanCodeDeploy
#json
0 comments
9 views

Permalink