# Directory Scanner

## Contents
Overview Directory to Scan Directory for Output Completed Directory Working Directory Policy to Use

## Overview
The Directory Scanner allows you to scan a certain directory on the file system for files containing XML messages. Once the messages have been read, they can be passed into the core message pipeline where the full collection of message processing filters can act on them. The Directory Scanner is typically used in cases where an external application is dropping XML files (perhaps by FTP) on to the file system so that they can be validated, modified, and potentially routed onwards over HTTP, JMS, or simply stored back to another directory where the application can pick them up again. This sort of protocol mediation is very useful in cases where legacy systems are involved. Instead of making drastic changes to the legacy system by adding an HTTP engine to it, for example, the Enterprise Gateway can be used to pull the files from the file system and then route them onwards over HTTP to another back-end system. The added benefit here, of course, is that messages are exposed to the full compliment of message processing filters made available by the Enterprise Gateway. This ensures that only properly validated messages will be routed on to the target system. To add a new Directory Scanner, right-click the name of the Process in the tree view of the Policy Studio (for example, "Oracle Enterprise Gateway"), and select the Directory Scanner -> Add menu option. The following sections describe how to configure the fields on the Directory Scanner Settings dialog.
## Directory to Scan
The fields configured in this section determine what files to scan, where to scan for them, and when to scan. Name: Enter or browse to the directory that the Enterprise Gateway will scan for XML files. File Name Pattern: If you only want to scan certain files based on some pattern, you can enter the pattern here. For example, if you only want to scan for files with a particular file extension, you can enter the file extension here. Similarly, if a particular naming scheme is used when dropping the files into the directory specified above, you can enter a pattern here to only scan for these files. Poll Rate: The poll rate entered here (in milliseconds) determines how often the Enterprise Gateway scans the directory for new XML files.
## Directory for Output
Once the Directory Scanner has finished scanning the files it will move them to another directory to avoid processing them again. The fields configured in this section determine where processed files will be placed and what they will be called. Name: Enter the name of the directory to place the processed files. This may either be the response from the Web Service (after the policy has routed it onwards and received a response) or a modified message in cases where the policy has inserted a security token into the message or converted the message using an XSLT conversion, for example. File Prefix: If you would like to save processed files into the directory above with a prefix added to the filename, enter the prefix here. For example, you may want to prepend "_PROCESSED" to all processed files. File Suffix: Similarly you can add a suffix to the output files by entering the suffix in this field.
## Completed Directory
Processed files will be removed from the source directory and placed into this directory post-processing to avoid re-processing the same files over and over again.
## Working Directory
Files will be moved to the "temporary" directory specified here during processing. This is necessary in cases where the poll rate is quite low and there is a chance that the file may be scanned again before it is processed fully and moved to the completed directory.
## Policy to Use
The messages contained within the scanned XML files will be passed into the policy selected here. If the policy routes messages to a Web Service, the response from the service will be placed in the output directory specified above. Similarly, if the policy modifies the request by signing it or adding a security token to it, for example, the updated message will also be placed in the output directory.