Guest User

Untitled

a guest
May 24th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. // imports omitted for brevity
  2. /**
  3. * A POJO that can add a configured list of file endpoints to the inbound router of a service.
  4. *
  5. * @author <a href="mailto:david@dossot.net">David Dossot</a>
  6. */
  7. public class InboundFileEndpointConfigurer implements MuleContextAware {
  8.  
  9. private MuleContext muleContext;
  10. private Service targetService;
  11. private Connector connector;
  12.  
  13. public void setMuleContext(MuleContext muleContext) {
  14. this.muleContext = muleContext;
  15. }
  16.  
  17. // other setters omitted
  18.  
  19. public void initialize() {
  20. MuleRegistry registry = muleContext.getRegistry();
  21. EndpointFactory endpointFactory = registry.lookupEndpointFactory();
  22. InboundRouterCollection inboundRouter = targetService.getInboundRouter();
  23.  
  24. // iterate over configuration
  25. {
  26. // get inDir & moveToDir from configuration
  27.  
  28. addFileEndpointToInboundRouter(endpointFactory,
  29. inboundRouter,
  30. inDir,
  31. moveToDir);
  32. }
  33. }
  34.  
  35. private void addFileEndpointToInboundRouter(EndpointFactory endpointFactory,
  36. InboundRouterCollection inboundRouter, String inDir, String moveToDir) {
  37.  
  38. try {
  39. InboundEndpoint endpoint =
  40. endpointFactory.getInboundEndpoint("file://" + inDir
  41. + "?connector=" + connector.getName()
  42. + "&moveToDirectory=" + moveToDir);
  43.  
  44. inboundRouter.addEndpoint(endpoint);
  45. } catch (MuleException me) {
  46. throw new RuntimeException("impossible to configure endpoint on: " + inDir, me);
  47. }
  48. }
  49.  
  50. }
Add Comment
Please, Sign In to add comment