Created
May 1, 2010 01:34
-
-
Save ddossot/385954 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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