List of usage examples for org.apache.commons.io FileUtils iterateFiles
public static Iterator iterateFiles(File directory, String[] extensions, boolean recursive)
From source file:org.apache.synapse.config.xml.MultiXMLConfigurationBuilder.java
private static void createTasks(SynapseConfiguration synapseConfig, String rootDirPath, Properties properties) { File tasksDir = new File(rootDirPath, TASKS_DIR); if (tasksDir.exists()) { if (log.isDebugEnabled()) { log.debug("Loading tasks from : " + tasksDir.getPath()); }// ww w.j a v a 2 s. c o m Iterator taskDefinitions = FileUtils.iterateFiles(tasksDir, extensions, false); while (taskDefinitions.hasNext()) { File file = (File) taskDefinitions.next(); try { OMElement document = getOMElement(file); Startup startup = SynapseXMLConfigurationFactory.defineStartup(synapseConfig, document, properties); startup.setFileName(file.getName()); synapseConfig.getArtifactDeploymentStore().addArtifact(file.getAbsolutePath(), startup.getName()); } catch (Exception e) { String msg = "Task configuration cannot be built from : " + file.getName(); handleConfigurationError(SynapseConstants.FAIL_SAFE_MODE_TASKS, msg, e); } } } }
From source file:org.apache.synapse.config.xml.MultiXMLConfigurationBuilder.java
private static void createSequences(SynapseConfiguration synapseConfig, String rootDirPath, Properties properties) {//from ww w . ja va2 s .co m File sequencesDir = new File(rootDirPath, SEQUENCES_DIR); if (sequencesDir.exists()) { if (log.isDebugEnabled()) { log.debug("Loading sequences from : " + sequencesDir.getPath()); } Iterator sequences = FileUtils.iterateFiles(sequencesDir, extensions, false); while (sequences.hasNext()) { File file = (File) sequences.next(); try { OMElement document = getOMElement(file); Mediator seq = SynapseXMLConfigurationFactory.defineSequence(synapseConfig, document, properties); if (seq != null && seq instanceof SequenceMediator) { SequenceMediator sequence = (SequenceMediator) seq; sequence.setFileName(file.getName()); synapseConfig.getArtifactDeploymentStore().addArtifact(file.getAbsolutePath(), sequence.getName()); } } catch (Exception e) { String msg = "Sequence configuration cannot be built from : " + file.getName(); handleConfigurationError(SynapseConstants.FAIL_SAFE_MODE_SEQUENCES, msg, e); } } } }
From source file:org.apache.synapse.config.xml.MultiXMLConfigurationBuilder.java
private static void createTemplates(SynapseConfiguration synapseConfig, String rootDirPath, Properties properties) {/* ww w .j a v a 2s . c o m*/ File templatesDir = new File(rootDirPath, TEMPLATES_DIR); if (templatesDir.exists()) { if (log.isDebugEnabled()) { log.debug("Loading template from : " + templatesDir.getPath()); } Iterator templates = FileUtils.iterateFiles(templatesDir, extensions, false); while (templates.hasNext()) { File file = (File) templates.next(); try { OMElement document = getOMElement(file); OMElement element = document .getFirstChildWithName(new QName(SynapseConstants.SYNAPSE_NAMESPACE, "sequence")); if (element != null) { TemplateMediator mediator = (TemplateMediator) SynapseXMLConfigurationFactory .defineMediatorTemplate(synapseConfig, document, properties); if (mediator != null) { mediator.setFileName(file.getName()); synapseConfig.getArtifactDeploymentStore().addArtifact(file.getAbsolutePath(), mediator.getName()); } } else { element = document .getFirstChildWithName(new QName(SynapseConstants.SYNAPSE_NAMESPACE, "endpoint")); if (element != null) { Template endpointTemplate = SynapseXMLConfigurationFactory .defineEndpointTemplate(synapseConfig, document, properties); if (endpointTemplate != null) { endpointTemplate.setFileName(file.getName()); synapseConfig.getArtifactDeploymentStore().addArtifact(file.getAbsolutePath(), endpointTemplate.getName()); } } } } catch (Exception e) { String msg = "Template configuration cannot be built from : " + file.getName(); handleConfigurationError(SynapseConstants.FAIL_SAFE_MODE_TEMPLATES, msg, e); } } } }
From source file:org.apache.synapse.config.xml.MultiXMLConfigurationBuilder.java
private static void createEndpoints(SynapseConfiguration synapseConfig, String rootDirPath, Properties properties) {//from www . ja v a2 s . com File endpointsDir = new File(rootDirPath, ENDPOINTS_DIR); if (endpointsDir.exists()) { if (log.isDebugEnabled()) { log.debug("Loading endpoints from : " + endpointsDir.getPath()); } Iterator endpoints = FileUtils.iterateFiles(endpointsDir, extensions, false); while (endpoints.hasNext()) { File file = (File) endpoints.next(); try { OMElement document = getOMElement(file); Endpoint endpoint = SynapseXMLConfigurationFactory.defineEndpoint(synapseConfig, document, properties); if (endpoint != null) { endpoint.setFileName(file.getName()); synapseConfig.getArtifactDeploymentStore().addArtifact(file.getAbsolutePath(), endpoint.getName()); } } catch (Exception e) { String msg = "Endpoint configuration cannot be built from : " + file.getName(); handleConfigurationError(SynapseConstants.FAIL_SAFE_MODE_EP, msg, e); } } } }
From source file:org.apache.synapse.config.xml.MultiXMLConfigurationBuilder.java
private static void createEventSources(SynapseConfiguration synapseConfig, String rootDirPath, Properties properties) {/*from w w w.j ava 2 s .c om*/ File eventsDir = new File(rootDirPath, EVENTS_DIR); if (eventsDir.exists()) { if (log.isDebugEnabled()) { log.debug("Loading event sources from : " + eventsDir.getPath()); } Iterator events = FileUtils.iterateFiles(eventsDir, extensions, false); while (events.hasNext()) { File file = (File) events.next(); try { OMElement document = getOMElement(file); SynapseEventSource eventSource = SynapseXMLConfigurationFactory.defineEventSource(synapseConfig, document, properties); if (eventSource != null) { eventSource.setFileName(file.getName()); synapseConfig.getArtifactDeploymentStore().addArtifact(file.getAbsolutePath(), eventSource.getName()); } } catch (Exception e) { String msg = "Event source configuration cannot be built from : " + file.getName(); handleConfigurationError(SynapseConstants.FAIL_SAFE_MODE_EVENT_SOURCE, msg, e); } } } }
From source file:org.apache.synapse.config.xml.MultiXMLConfigurationBuilder.java
private static void createExecutors(SynapseConfiguration synapseConfig, String rootDirPath, Properties properties) {/*from w ww . ja v a 2 s .com*/ File executorsDir = new File(rootDirPath, EXECUTORS_DIR); if (executorsDir.exists()) { if (log.isDebugEnabled()) { log.debug("Loading event sources from : " + executorsDir.getPath()); } Iterator executors = FileUtils.iterateFiles(executorsDir, extensions, false); while (executors.hasNext()) { File file = (File) executors.next(); try { OMElement document = getOMElement(file); PriorityExecutor executor = SynapseXMLConfigurationFactory.defineExecutor(synapseConfig, document, properties); if (executor != null) { executor.setFileName(file.getName()); synapseConfig.getArtifactDeploymentStore().addArtifact(file.getAbsolutePath(), executor.getName()); } } catch (Exception e) { String msg = "Executor configuration cannot be built from : " + file.getName(); handleConfigurationError(SynapseConstants.FAIL_SAFE_MODE_EXECUTORS, msg, e); } } } }
From source file:org.apache.synapse.config.xml.MultiXMLConfigurationBuilder.java
private static void createMessageStores(SynapseConfiguration synapseConfig, String rootDirPath, Properties properties) {/*from w w w .java 2 s . com*/ File messageStoresDir = new File(rootDirPath, MESSAGE_STORE_DIR); if (messageStoresDir.exists()) { if (log.isDebugEnabled()) { log.debug("Loading Message Stores from :" + messageStoresDir.getPath()); } Iterator messageStores = FileUtils.iterateFiles(messageStoresDir, extensions, false); while (messageStores.hasNext()) { File file = (File) messageStores.next(); try { OMElement document = getOMElement(file); MessageStore messageStore = SynapseXMLConfigurationFactory.defineMessageStore(synapseConfig, document, properties); if (messageStore != null) { messageStore.setFileName(file.getName()); synapseConfig.getArtifactDeploymentStore().addArtifact(file.getAbsolutePath(), messageStore.getName()); } } catch (Exception e) { String msg = "Message store configuration cannot be built from : " + file.getName(); handleConfigurationError(SynapseConstants.FAIL_SAFE_MODE_MESSAGE_STORES, msg, e); } } } }
From source file:org.apache.synapse.config.xml.MultiXMLConfigurationBuilder.java
private static void createMessageProcessors(SynapseConfiguration synapseConfig, String rootDirPath, Properties properties) {//w w w . j a v a2s . c o m File messageProcessorDir = new File(rootDirPath, MESSAGE_PROCESSOR_DIR); if (messageProcessorDir.exists()) { if (log.isDebugEnabled()) { log.debug("Loading Message Processors from :" + messageProcessorDir.getPath()); } Iterator messageProcessors = FileUtils.iterateFiles(messageProcessorDir, extensions, false); while (messageProcessors.hasNext()) { File file = (File) messageProcessors.next(); try { OMElement document = getOMElement(file); MessageProcessor messageProcessor = SynapseXMLConfigurationFactory .defineMessageProcessor(synapseConfig, document, properties); if (messageProcessor != null) { messageProcessor.setFileName(file.getName()); synapseConfig.getArtifactDeploymentStore().addArtifact(file.getAbsolutePath(), messageProcessor.getName()); } } catch (Exception e) { String msg = "Message processor configuration cannot be built from : " + file.getName(); handleConfigurationError(SynapseConstants.FAIL_SAFE_MODE_MESSAGE_PROCESSORS, msg, e); } } } }
From source file:org.apache.synapse.config.xml.MultiXMLConfigurationBuilder.java
private static void createSynapseImports(SynapseConfiguration synapseConfig, String root, Properties properties) {/*from w w w. j a v a2 s .c o m*/ File synImportsDir = new File(root, SYNAPSE_IMPORTS_DIR); if (synImportsDir.exists()) { if (log.isDebugEnabled()) { log.debug("Loading Synapse Imports from :" + synImportsDir.getPath()); } Iterator synImports = FileUtils.iterateFiles(synImportsDir, extensions, false); while (synImports.hasNext()) { File file = (File) synImports.next(); try { OMElement document = getOMElement(file); SynapseImport synImp = SynapseXMLConfigurationFactory.defineImport(synapseConfig, document, properties); if (synImp != null) { synImp.setFileName(file.getName()); synapseConfig.getArtifactDeploymentStore().addArtifact(file.getAbsolutePath(), synImp.getName()); } } catch (Exception e) { String msg = "Import configuration cannot be built from : " + file.getName(); handleConfigurationError(SynapseConstants.FAIL_SAFE_MODE_IMPORTS, msg, e); } } } }
From source file:org.apache.synapse.config.xml.MultiXMLConfigurationBuilder.java
private static void createAPIs(SynapseConfiguration synapseConfig, String rootDirPath, Properties properties) { File apiDir = new File(rootDirPath, REST_API_DIR); if (apiDir.exists()) { if (log.isDebugEnabled()) { log.debug("Loading APIs from :" + apiDir.getPath()); }/*from ww w.j av a 2 s. c o m*/ Iterator apiIterator = FileUtils.iterateFiles(apiDir, extensions, false); while (apiIterator.hasNext()) { File file = (File) apiIterator.next(); try { OMElement document = getOMElement(file); API api = SynapseXMLConfigurationFactory.defineAPI(synapseConfig, document, properties); if (api != null) { api.setFileName(file.getName()); synapseConfig.getArtifactDeploymentStore().addArtifact(file.getAbsolutePath(), api.getName()); } } catch (Exception e) { String msg = "API configuration cannot be built from : " + file.getName(); handleConfigurationError(SynapseConstants.FAIL_SAFE_MODE_API, msg, e); } } } }