Skip to content

Instantly share code, notes, and snippets.

@ddossot
Created May 1, 2010 01:34
Show Gist options
  • Save ddossot/385954 to your computer and use it in GitHub Desktop.
Save ddossot/385954 to your computer and use it in GitHub Desktop.
// 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:[email protected]">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);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment