You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by bu...@apache.org on 2013/03/19 21:17:04 UTC
svn commit: r1458494 -
/uima/uima-as/trunk/uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/client/BaseUIMAAsynchronousEngine_impl.java
Author: burn
Date: Tue Mar 19 20:17:04 2013
New Revision: 1458494
URL: http://svn.apache.org/r1458494
Log:
UIMA-2755 - placeholders in JMS service descriptors can replace part of the value
Modified:
uima/uima-as/trunk/uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/client/BaseUIMAAsynchronousEngine_impl.java
Modified: uima/uima-as/trunk/uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/client/BaseUIMAAsynchronousEngine_impl.java
URL: http://svn.apache.org/viewvc/uima/uima-as/trunk/uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/client/BaseUIMAAsynchronousEngine_impl.java?rev=1458494&r1=1458493&r2=1458494&view=diff
==============================================================================
--- uima/uima-as/trunk/uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/client/BaseUIMAAsynchronousEngine_impl.java (original)
+++ uima/uima-as/trunk/uimaj-as-activemq/src/main/java/org/apache/uima/adapter/jms/client/BaseUIMAAsynchronousEngine_impl.java Tue Mar 19 20:17:04 2013
@@ -554,18 +554,25 @@ public class BaseUIMAAsynchronousEngine_
* @throws ResourceInitializationException
*/
private String replacePlaceholder(String aPlaceholder) throws ResourceInitializationException {
- // find placeholder starting and endpoint positions
- int startPos = aPlaceholder.indexOf("{");
- int endPos = aPlaceholder.indexOf("}");
+ // find placeholder starting and ending positions
+ // If no '${' or following '}' leave as-is
+ int startPos = aPlaceholder.indexOf("${");
+ if (startPos < 0) {
+ return aPlaceholder;
+ }
+ int endPos = aPlaceholder.indexOf("}", startPos);
+ if (endPos < 0) {
+ return aPlaceholder;
+ }
// extract the name
- String placeholder = aPlaceholder.substring(startPos+1, endPos);
+ String placeholder = aPlaceholder.substring(startPos+2, endPos);
// using the name, find the broker URL. This property must exist or exception is thrown
String url = System.getProperty(placeholder);
// the property is missing
if ( url == null ) {
- throw new ResourceInitializationException(new Exception("UIMA AS Client Initialization Exception. Value for placeholder:"+placeholder+" is not defined in the environment. Set System property:"+placeholder+" to the broker URL."));
+ throw new ResourceInitializationException(new Exception("UIMA AS Client Initialization Exception. Value for placeholder:"+placeholder+" is not defined in the system properties."));
}
- return url;
+ return aPlaceholder.substring(0, startPos) + url + aPlaceholder.substring(endPos+1);
}
/**
* Initialize the uima ee client. Takes initialization parameters from the
@@ -621,26 +628,15 @@ public class BaseUIMAAsynchronousEngine_
asynchManager = new AsynchAECasManager_impl(rm);
brokerURI = (String) anApplicationContext.get(UimaAsynchronousEngine.ServerUri);
-
- // Check if a placeholder is passed in instead of actual Broker URL. The placeholder
- // has this syntax ${placeholderName}. A system property with placeholderName
- // must exist for successful placeholder resolution.
- if ( brokerURI.startsWith("${")) {
- // resolve placeholder
- // throws ResourceInitializationException if placeholder is not defined in
- // System properties
- brokerURI = replacePlaceholder(brokerURI);
- }
String endpoint = (String) anApplicationContext.get(UimaAsynchronousEngine.Endpoint);
- // Check if a placeholder is passed in instead of actual service endpoint. The placeholder
- // has this syntax ${placeholderName}. A system property with placeholderName
- // must exist for successful placeholder resolution.
- if ( endpoint.startsWith("${")) {
- // resolve placeholder
- // throws ResourceInitializationException if placeholder is not defined in
- // System properties
- endpoint = replacePlaceholder(endpoint);
- }
+
+ // Check if a placeholder is passed in instead of actual broker URL or endpoint.
+ // The placeholder has the syntax ${placeholderName} and may be imbedded in text.
+ // A system property with placeholderName must exist for successful placeholder resolution.
+ // Throws ResourceInitializationException if placeholder is not in the System properties.
+ brokerURI = replacePlaceholder(brokerURI);
+ endpoint = replacePlaceholder(endpoint);
+
clientSideJmxStats.setEndpointName(endpoint);
int casPoolSize = 1;