This content has been marked as final.
Show 2 replies
-
1. Re: Camel file binding get FileEndpoint
kcbabo Jan 16, 2013 8:40 AM (in response to hamid1982)The FileEndpoint is not passed into the bean implementation. You can inject an @Context reference which will allow you to query context properties inside your bean service. More info on that can be found in the docs here:
https://docs.jboss.org/author/display/SWITCHYARD/Bean+Services
To give you an idea of which context properties are available to your implementation, here's a snip of a message trace from the camel-binding quickstart (which uses File gateway):
Exchange Context -> CamelBatchIndex : 0 CamelBatchSize : 1 CamelToEndpoint : switchyard://GreetingService?namespace=urn%3Aswitchyard-quickstart%3Acamel-binding%3A0.1.0 CamelCreatedTimestamp : Wed Jan 16 08:30:50 EST 2013 CamelBatchComplete : true CamelFileExchangeFile : GenericFile[test.txt] Message Context -> org.switchyard.contentType : java:java.lang.String org.switchyard.messageId : a2ae79c6-88dd-4cec-a9b3-8cd08163cafb
-
2. Re: Camel file binding get FileEndpoint
splatch Jan 16, 2013 8:49 AM (in response to kcbabo)As workaround you can use:
@ApplicationScoped class Factory { @Produces @Named("file") public FileComponent create() { return new FileComponent(); } } @Service(SomeInterface.class) class ServiceImpl implements SomeInterface { @Inject FileComponent component; // somewhere { FileEndpoint endpoint = (FileEndpoint) component.getCamelContext().getEndpoint("file-endpoint-uri"); } }
This however, is solution which can be assigned to 'dirty hack' category. Why you require endpoint instance inside your bean service?