Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // imports omitted for brevity
- /**
- * A POJO that can add a configured list of file endpoints to the inbound router of a service.
- *
- * @author <a href="mailto:david@dossot.net">David Dossot</a>
- */
- public class InboundFileEndpointConfigurer implements MuleContextAware {
- private MuleContext muleContext;
- private Service targetService;
- private Connector connector;
- public void setMuleContext(MuleContext muleContext) {
- this.muleContext = muleContext;
- }
- // other setters omitted
- public void initialize() {
- MuleRegistry registry = muleContext.getRegistry();
- EndpointFactory endpointFactory = registry.lookupEndpointFactory();
- InboundRouterCollection inboundRouter = targetService.getInboundRouter();
- // iterate over configuration
- {
- // get inDir & moveToDir from configuration
- addFileEndpointToInboundRouter(endpointFactory,
- inboundRouter,
- inDir,
- moveToDir);
- }
- }
- private void addFileEndpointToInboundRouter(EndpointFactory endpointFactory,
- InboundRouterCollection inboundRouter, String inDir, String moveToDir) {
- try {
- InboundEndpoint endpoint =
- endpointFactory.getInboundEndpoint("file://" + inDir
- + "?connector=" + connector.getName()
- + "&moveToDirectory=" + moveToDir);
- inboundRouter.addEndpoint(endpoint);
- } catch (MuleException me) {
- throw new RuntimeException("impossible to configure endpoint on: " + inDir, me);
- }
- }
- }
Add Comment
Please, Sign In to add comment