camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From afbagwe <afba...@sandia.gov>
Subject Blueprint beans with enum input params not working
Date Tue, 23 May 2017 15:59:57 GMT
Maybe I'm completely wrong in how I'm going about this, but I've encountered
two issues when trying to use an Enum type in a bean defined in a blueprint
Camel route.So here's the setup...
public enum MyEventType { LOW, HIGH; }public interface AlertSystem{   &lt;E
extends Enum&lt;E&gt;&gt; void postEvent(E eventType, String text);}
In the implementing class MyAlertSystem implements AlertSystem ...
public &lt;E extends Enum&lt;E&gt;&gt; void postEvent(E eventType, String
text){    if(eventType == LOW) { // do something }    else if (eventType ==
HIGH) { // do something }    else { // do something }}
Then I make a bean out of class in my blueprint...
&lt;bean id="myAlertSystem" class="com.example.sys.MyAlertSystem"/&gt;
And finally I try to use the bean in the camel route. This is where the
problems occur.If I do this and run a test on it:
&lt;to
uri="bean:myAlertSystem?method=postEvent(${type:com.example.sys.MyEventType.LOW},
${body})"/&gt;
I get the following error message:
ParameterBindingException : Error during parameter binding on method: public
void com.example.sys.MyAlertSystem.postEvent(java.lang.Enum,
java.lang.String) at parameter #0 with type: class java.lang.Enum with value
type: class java.lang.String and value: LOW
I read this as meaning that the binding step is trying to interpret my enum
parameter as a String.I also tried this way:
&lt;bean ref="myAlertSystem"
method="postEvent(${type:com.example.sys.MyEventType.LOW}, ${body})"/&gt;
But this approach completely failed. In my CamelBlueprintTestSupport class
having this in a route didn't produce an error message, but it caused a long
pause in the test execution and endpoint assertion failures when run.
My only current workaround to this is to change the interface to accept a
String instead of an Enum. Then if I use the same type syntax to pass it a
constant (by redefining MyEventType to a normal class with constant Strings
in it), everything works.
I've gone over the Camel pages on bean usage as well as the syntax to access
Enums in the Simple language. But I can't see what I'm doing wrong.I'm using
Camel 2.18.3 and Blueprint core 1.8.0 in IntelliJ to do my development work.



--
View this message in context: http://camel.465427.n5.nabble.com/Blueprint-beans-with-enum-input-params-not-working-tp5800090.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message