We can create and edit a customization file in which we can only replace
Proxy Service/Business Service artifacts and some JCA properties like JCA Always Use JCA File Flag, JCA Connection Mode.
But in real time scenarios, we are required to modify JCA properties such as PhysicalDirectory/LogicalDirectory/JNDI Location which is not possible using OSB customization file
Using "maven-replacer-plugin:replacer" we can build plugin to replace tokens within a file with a given value and fully supports regular expressions.
Plugin artifactId was renamed to "replacer" from
"maven-replacer-plugin" due to a naming policy change from the Maven
team.
This plugin is typically used to change configuration within
a project during a maven build. It also can perform some advanced text
replacement functions, such as providing a separate token/value file to keep
your build script concise, writing resulting text after replacement to a
separate file and token matching with regular expressions. There is even
support for making exact document node replacements via X-Path.
Simple
example usage:
<build>
<plugins>
...
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.3</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<file>target/${project.artifactId}/somefile.txt</file>
<replacements>
<replacement>
<token>SOME TOKEN</token>
<value>SOME VALUE</value>
</replacement>
</replacements>
</configuration>
</plugin>
</plugins>
</build>
<plugins>
...
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.3</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<file>target/${project.artifactId}/somefile.txt</file>
<replacements>
<replacement>
<token>SOME TOKEN</token>
<value>SOME VALUE</value>
</replacement>
</replacements>
</configuration>
</plugin>
</plugins>
</build>
I have create a sample Service Bus Project FileDebatching which will read the file
in chunks from a location (will configure using JCA FileAdapter ) and writes
into another location
For the Read File, I have the Physical Directory location as
C:\TestFiles\ChunkFile\FileChunck\INPUT
Now, I will deploy the composite using Maven. Below are the plugin
properties available in project pom.xml.
JCA File Properties in Service Bus Console after the deployment
Now using maven-replacer-plugin:replacer
plugin we will replace the PhysicalDirectory location.
Go into the Project pom.xml then add the replacer plugin with the file
name and token which is to be replaced.
I have fileService_file.jca file inside
Resources location
Below is pom.xml
plugin details added with replacer token
<file>Resources/fileService_file.jca</file>
<replacements>
<replacement>
<token>C:\\TestFiles\\ChunkFile\\FileChunck\\INPUT</token>
<value>C:\\TestFiles\\ChunkFile\\FileChunck\\IN</value>
</replacement>
Redeploy the Service again
Now in Service bus Console
Note: The Replacer will replace the token in fileService_file.jca file
and then deploy the service, so the file is modified with the new token.
No comments:
Post a Comment