A File control performs an operation on a file. Each File control is customized to perform certain operations.
This topic describes how to create a new File control and provides an example of the File control's declaration in the JCX file.
For information on how to add control instances to business processes, see Using Controls in Business Processes.
Note: If the Controls tab is not visible in WebLogic Workshop, click View —> Windows —> Data Palette from the menu bar.
You can use an existing control by selecting Use a File control already defined by a JCX file and entering a filename in the JCX file field.
A directory name is the absolute path name for the directory; it includes the drive specification as well as the path specification. For example, the following are valid directory names:
C:\directory (Windows)
/directory (Unix)
\\servername\sharename\directory (Win32 UNC)
You can also enter a period (.), which specifies the current working directory. When you enter a forward slash (/) in the directory-name field, it is interpreted as follows:
The directory-name field is required. Leaving the directory-name field empty results in an error.
Note: When writing files locally, if the specified directory does not already exist, it is created and the file is written into the new directory.
The file-mask field is optional when inserting a control, but this property must then be set dynamically before performing a file operation.
You can define a line by specifying either its record size or a delimiter string:
Warning: If the specified delimiter string does not exist in a file being processed, application behavior is unpredictable.
If no record size or string delimiter is specified, the file is processed one line at a time. A line is considered to be terminated by any one of a line feed ('\n'), a carriage return ('\r'), or a carriage return followed immediately by a linefeed. This style of file processing can be used with any size file.
Note: You cannot define a line by specifying both a record size and a string delimiter.
To learn about the methods available on the File control, see the FileControl Interface.
When you create a new File control, its declaration appears in the JCX file. The following code snippet is an example of what the declaration looks like when you choose the The directory contains large files to be processed option:
import weblogic.jws.*; import com.bea.control.*; import java.io.*; import com.bea.data.RawData; import com.bea.xml.XmlObject; ... /** * @jc:file directory-name="C:\directory" * file-mask="tax_file.txt" * */ public interface TaxFileControl extends FileControl,com.bea.control.ControlExtension { /** * @jc:file-operation io-type="readline" * record-size="80" */ RawData readLine(); }
The actual attributes that are present on the @jc:file and @jc:file-operation annotations depend on the values you entered in the Insert Control dialog.
The @jc:file annotation controls the behavior of the File control. All of the attributes of the @jc:file annotation are optional and have default values.
To learn more, see @jc:file Annotation.
The File control, named TaxControlFile in the example above, is declared as an extension of FileControl. The @jc:file-operation annotations indicate that the file operation is readline (read tax_file.txt record by record) and specifies the record size.