You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by javamonkey79 <ja...@gmail.com> on 2013/05/28 23:41:58 UTC

evaluating bean expressions in custom language

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.

Re: evaluating bean expressions in custom language

Posted by Claus Ibsen <cl...@gmail.com>.
No how a language syntax is for evaluating bean expressions is
different. eg how groovy, javascript, mvel, ognl, simple, Spring EL,
et all do it.




On Wed, May 29, 2013 at 6:04 PM, javamonkey79 <ja...@gmail.com> wrote:
> I have built a camel language component - that is what this is for. I'm
> asking if there is a standard way to evaluate bean expressions in language
> components.
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/evaluating-bean-expressions-in-custom-language-tp5733377p5733424.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
www.camelone.org: The open source integration conference.

Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: evaluating bean expressions in custom language

Posted by javamonkey79 <ja...@gmail.com>.
I have built a camel language component - that is what this is for. I'm
asking if there is a standard way to evaluate bean expressions in language
components.



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

Re: evaluating bean expressions in custom language

Posted by Claus Ibsen <cl...@gmail.com>.
You can build you own Camel language component.

On Tue, May 28, 2013 at 11:41 PM, javamonkey79 <ja...@gmail.com> wrote:
> 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.



-- 
Claus Ibsen
-----------------
www.camelone.org: The open source integration conference.

Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen