001: /*
002: * ChainBuilder ESB
003: * Visual Enterprise Integration
004: *
005: * Copyright (C) 2006 Bostech Corporation
006: *
007: * This program is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU General Public License as published by the
009: * Free Software Foundation; either version 2 of the License, or (at your option)
010: * any later version.
011: *
012: * This program is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
014: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
015: * for more details.
016: *
017: * You should have received a copy of the GNU General Public License along with
018: * this program; if not, write to the Free Software Foundation, Inc.,
019: * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020: *
021: *
022: * $Id: FileWsdl1Deployer.java 7279 2007-05-08 20:15:20Z mpreston $
023: */
024: package com.bostechcorp.cbesb.runtime.component.file;
025:
026: import javax.jbi.messaging.MessageExchange;
027: import javax.wsdl.extensions.ExtensibilityElement;
028: import javax.wsdl.extensions.ExtensionRegistry;
029:
030: import org.apache.commons.logging.Log;
031: import org.apache.commons.logging.LogFactory;
032: import com.bostechcorp.cbesb.runtime.ccsl.jbi.messaging.Wsdl1Deployer;
033: import com.bostechcorp.cbesb.runtime.ccsl.jbi.messaging.CbComponent;
034: import com.bostechcorp.cbesb.runtime.ccsl.jbi.messaging.CbEndpoint;
035: import com.bostechcorp.cbesb.runtime.component.file.wsdl.FileInput;
036: import com.bostechcorp.cbesb.runtime.component.file.wsdl.FileBinding;
037: import com.bostechcorp.cbesb.runtime.component.file.wsdl.FileInputExtension;
038: import com.bostechcorp.cbesb.runtime.component.file.wsdl.FileOutput;
039: import com.bostechcorp.cbesb.runtime.component.file.wsdl.FileOutputExtension;
040:
041: public class FileWsdl1Deployer extends Wsdl1Deployer {
042:
043: protected final transient Log logger = LogFactory
044: .getLog(getClass());
045:
046: public FileWsdl1Deployer(CbComponent component) {
047: super (component);
048: }
049:
050: protected CbEndpoint createEndpoint(
051: ExtensibilityElement[] portElement,
052: ExtensibilityElement[] bindingElement) {
053:
054: logger.debug("createEndpoint portElement=" + portElement);
055:
056: FileEndpoint endpoint = new FileEndpoint();
057: // if JBI extension is used, its value (role, defaultMep, defaultOperation) will no longer be used
058: if (portElement[0] instanceof FileInput) {
059: FileInput inputPortElement = (FileInput) portElement[0];
060: logger.debug("FileInput portElement=" + inputPortElement);
061: endpoint.setRole(MessageExchange.Role.CONSUMER);
062: endpoint.setDefaultMep(inputPortElement.getDefaultMep());
063: endpoint.setDefaultOperation(inputPortElement
064: .getDefaultOperation());
065: endpoint.setSourceDir(inputPortElement.getSourceDir());
066: endpoint.setStageDir(inputPortElement.getStageDir());
067: endpoint.setArchiveDir(inputPortElement.getArchiveDir());
068: endpoint.setHoldDir(inputPortElement.getHoldDir());
069:
070: if (inputPortElement.getScanInterval() != null
071: && !inputPortElement.getScanInterval().equals("")) {
072: endpoint.setMode(FileEndpoint.MODE_POLL);
073: endpoint.setPollInterval(Integer
074: .parseInt(inputPortElement.getScanInterval()));
075: } else {
076: endpoint.setMode(FileEndpoint.MODE_SCHEDULE);
077: endpoint
078: .setScheduleFile(inputPortElement.getSchedule());
079: endpoint.setSchedulerService(inputPortElement
080: .getSchedulerService());
081: endpoint.setSchedulerEndpoint(inputPortElement
082: .getSchedulerEndpoint());
083: }
084:
085: endpoint.setHold(inputPortElement.isHold());
086: endpoint.setFilePattern(inputPortElement.getFilePattern());
087: endpoint.setMatchMode(inputPortElement.getMatchMode());
088: endpoint.setTwoPass(inputPortElement.isTwoPass());
089: endpoint.setTwoPassInterval(inputPortElement
090: .getTwoPassInterval());
091: endpoint.setFileCompleteAction(inputPortElement
092: .getFileCompleteAction());
093: endpoint.setRecordsPerMessage(inputPortElement
094: .getRecordsPerMessage());
095: endpoint.setReadStyle(inputPortElement.getReadStyle());
096: endpoint.setRecordType(inputPortElement.getRecordType());
097: endpoint.setCharset(inputPortElement.getCharset());
098: endpoint.setArchiveFilePattern(inputPortElement
099: .getArchiveFilePattern());
100: endpoint.setReplyDir(inputPortElement.getReplyDir());
101: endpoint
102: .setReplyCharset(inputPortElement.getReplyCharset());
103: endpoint.setReplyWriteStyle(inputPortElement
104: .getReplyWriteStyle());
105: endpoint.setReplyFilePattern(inputPortElement
106: .getReplyFilePattern());
107: } else {
108: FileOutput outputPortElement = (FileOutput) portElement[0];
109: logger.debug("FileOutput portElement=" + outputPortElement);
110: endpoint.setRole(MessageExchange.Role.PROVIDER);
111: endpoint.setDefaultMep(outputPortElement.getDefaultMep());
112: endpoint.setDefaultOperation(outputPortElement
113: .getDefaultOperation());
114: endpoint.setDestDir(outputPortElement.getDestDir());
115: endpoint.setStageDir(outputPortElement.getStageDir());
116: endpoint.setCharset(outputPortElement.getCharset());
117: endpoint.setWriteStyle(outputPortElement.getWriteStyle());
118: endpoint.setFilePattern(outputPortElement.getFilePattern());
119: }
120: return endpoint;
121: }
122:
123: /* (non-Javadoc)
124: * @see org.apache.servicemix.common.wsdl.AbstractWsdlDeployer#filterPortElement(javax.wsdl.extensions.ExtensibilityElement)
125: */
126: protected boolean filterPortElement(ExtensibilityElement element) {
127: return (element instanceof FileInput)
128: || (element instanceof FileOutput);
129: }
130:
131: /* (non-Javadoc)
132: * @see org.apache.servicemix.common.wsdl.AbstractWsdlDeployer#filterBindingElement(javax.wsdl.extensions.ExtensibilityElement)
133: */
134: protected boolean filterBindingElement(ExtensibilityElement element) {
135: return element instanceof FileBinding;
136: }
137:
138: /* (non-Javadoc)
139: * @see org.apache.servicemix.common.wsdl.AbstractWsdlDeployer#registerExtensions(javax.wsdl.extensions.ExtensionRegistry)
140: */
141: protected void registerExtensions(ExtensionRegistry registry) {
142: super.registerExtensions(registry);
143: FileInputExtension.register(registry);
144: FileOutputExtension.register(registry);
145: }
146:
147: }
|