camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From javamonkey79 <javamonke...@gmail.com>
Subject evaluating bean expressions in custom language
Date Tue, 28 May 2013 21:41:58 GMT
Is there a standard way to evaluate bean expressions\OGNL in custom
languages?

For example:

I have a custom language expression like this:

							<language language="e4x">
								${someString}.indexOf('"'+message['PV1']['PV1.3']['PV1.3.1']+'"') !=
-1
							</language>

And in my Expression code I have something like this:
		Matcher matcher = BEAN_PATTERN.matcher( _expressionString );
		while ( matcher.find() ) {
			String beanName = matcher.group( 1 );

			_logger.debug( "found bean with name: [{}]", beanName );

			Object lookupByName = exchange.getContext().getRegistry().lookupByName(
beanName );
			if ( lookupByName == null ) {
				throw new ExpressionEvaluationException( this, "failed to lookup bean
with name: " + beanName, exchange,
					new IllegalArgumentException() );
			}

			expressionString = expressionString.replaceFirst( String.format(
"\\$\\{%s\\}", beanName ), lookupByName.toString() );
		}

But this seems very wrong, as there is probably code in Camel to do this
already. It is also fairly limited, as I am only able to do String
replacement rather than full on OGNL.




--
View this message in context: http://camel.465427.n5.nabble.com/evaluating-bean-expressions-in-custom-language-tp5733377.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message