⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fileconnector.java

📁 提供ESB 应用mule源代码 提供ESB 应用mule源代码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            }            catch (IOException e)            {                logger.warn("Failed to close file output stream on stop: " + e);            }        }    }    /**     * @return Returns the moveToDirectoryName.     */    public String getMoveToDirectory()    {        return moveToDirectoryName;    }    /**     * @param dir The moveToDirectoryName to set.     */    public void setMoveToDirectory(String dir)    {        this.moveToDirectoryName = dir;    }    /**     * @return Returns the outputAppend.     */    public boolean isOutputAppend()    {        return outputAppend;    }    /**     * @param outputAppend The outputAppend to set.     */    public void setOutputAppend(boolean outputAppend)    {        this.outputAppend = outputAppend;    }    /**     * @return Returns the outputPattern.     */    public String getOutputPattern()    {        return outputPattern;    }    /**     * @param outputPattern The outputPattern to set.     */    public void setOutputPattern(String outputPattern)    {        this.outputPattern = outputPattern;    }    /**     * @return Returns the outputStream.     */    public FileOutputStream getOutputStream()    {        return outputStream;    }    /**     * @param outputStream The outputStream to set.     */    public void setOutputStream(FileOutputStream outputStream)    {        this.outputStream = outputStream;    }    /**     * @return Returns the pollingFrequency.     */    public long getPollingFrequency()    {        return pollingFrequency;    }    /**     * @param pollingFrequency The pollingFrequency to set.     */    public void setPollingFrequency(long pollingFrequency)    {        this.pollingFrequency = pollingFrequency;    }    /**     * @return Returns the fileAge.     */    public long getFileAge()    {        return fileAge;    }    public boolean getCheckFileAge()    {        return checkFileAge;    }    /**     * @param fileAge The fileAge in milliseconds to set.     */    public void setFileAge(long fileAge)    {        this.fileAge = fileAge;        this.checkFileAge = true;    }    /**     * @return Returns the writeToDirectory.     */    public String getWriteToDirectory()    {        return writeToDirectoryName;    }    /**     * @param dir The writeToDirectory to set.     */    public void setWriteToDirectory(String dir) throws IOException    {        this.writeToDirectoryName = dir;        if (writeToDirectoryName != null)        {            File writeToDirectory = FileUtils.openDirectory(writeToDirectoryName);            if (!(writeToDirectory.canRead()) || !writeToDirectory.canWrite())            {                throw new IOException(                        "Error on initialization, Write To directory does not exist or is not read/write");            }        }    }    /**     * @return Returns the readFromDirectory.     */    public String getReadFromDirectory()    {        return readFromDirectoryName;    }    /**     * @param dir The readFromDirectory to set.     */    public void setReadFromDirectory(String dir) throws IOException    {        this.readFromDirectoryName = dir;        if (readFromDirectoryName != null)        {            File readFromDirectory = FileUtils.openDirectory((readFromDirectoryName));            if (!readFromDirectory.canRead())            {                throw new IOException(                        "Error on initialization, read from directory does not exist or is not readable");            }        }    }    public boolean isSerialiseObjects()    {        return serialiseObjects;    }    public void setSerialiseObjects(boolean serialiseObjects)    {        // set serialisable transformers on the connector if this is set        if (serialiseObjects)        {            if (serviceOverrides == null)            {                serviceOverrides = new Properties();            }            serviceOverrides.setProperty(MuleProperties.CONNECTOR_INBOUND_TRANSFORMER,                    ByteArrayToSerializable.class.getName());            serviceOverrides.setProperty(MuleProperties.CONNECTOR_OUTBOUND_TRANSFORMER,                    SerializableToByteArray.class.getName());        }        this.serialiseObjects = serialiseObjects;    }    public boolean isAutoDelete()    {        return autoDelete;    }    public void setAutoDelete(boolean autoDelete)    {        this.autoDelete = autoDelete;    }    public String getMoveToPattern()    {        return moveToPattern;    }    public void setMoveToPattern(String moveToPattern)    {        this.moveToPattern = moveToPattern;    }    /**     * Well get the output stream (if any) for this type of transport. Typically this     * will be called only when Streaming is being used on an outbound endpoint     *     * @param endpoint the endpoint that releates to this Dispatcher     * @param message  the current message being processed     * @return the output stream to use for this request or null if the transport     *         does not support streaming     * @throws org.mule.api.MuleException     */    public OutputStream getOutputStream(ImmutableEndpoint endpoint, MuleMessage message)            throws MuleException    {        String address = endpoint.getEndpointURI().getAddress();        String writeToDirectory = message.getStringProperty(FileConnector.PROPERTY_WRITE_TO_DIRECTORY, null);        if (writeToDirectory == null)        {            writeToDirectory = getWriteToDirectory();        }        if (writeToDirectory != null)        {            address = getFilenameParser().getFilename(message, writeToDirectory);        }        String filename;        String outPattern = (String) endpoint.getProperty(FileConnector.PROPERTY_OUTPUT_PATTERN);        if (outPattern == null)        {            outPattern = message.getStringProperty(FileConnector.PROPERTY_OUTPUT_PATTERN, null);        }        if (outPattern == null)        {            outPattern = getOutputPattern();        }        try        {            if (outPattern != null)            {                filename = generateFilename(message, outPattern);            }            else            {                filename = message.getStringProperty(FileConnector.PROPERTY_FILENAME, null);                if (filename == null)                {                    filename = generateFilename(message, null);                }            }            if (filename == null)            {                throw new IOException("Filename is null");            }            File file = FileUtils.createFile(address + "/" + filename);            if (logger.isInfoEnabled())            {                logger.info("Writing file to: " + file.getAbsolutePath());            }            return new FileOutputStream(file, isOutputAppend());        }        catch (IOException e)        {            throw new DispatchException(CoreMessages.streamingFailedNoStream(), message,                    endpoint, e);        }    }    private String generateFilename(MuleMessage message, String pattern)    {        if (pattern == null)        {            pattern = getOutputPattern();        }        return getFilenameParser().getFilename(message, pattern);    }    public boolean isStreaming()    {        return streaming;    }    public void setStreaming(boolean streaming)    {        this.streaming = streaming;    }    public MessageAdapter getMessageAdapter(Object message) throws MessagingException    {        if (isStreaming())        {            // TODO Shouldn't we have a way to specify MessageAdaptor for streaming            // in service descriptor            // See MULE-3209, MULE-3199            return new FileMessageAdapter(message);        }        else        {            return super.getMessageAdapter(message);        }    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -