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
008: * it under the terms of the GNU General Public License as published by
009: * the Free Software Foundation; either version 2 of the License, or
010: * (at your option) 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
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * General Public License for more details.
016: *
017: * You should have received a copy of the GNU General Public License
018: * along with this program; if not, write to the Free Software
019: * Foundation, Inc.,59 Temple Place, Suite 330, Boston, MA 02111-1307
020: * USA
021: *
022: * $Id: EmailWsdl1Deployer.java 8272 2007-07-13 08:35:49Z ecostezki $
023: *
024: */
025: package com.bostechcorp.cbesb.runtime.component.email;
026:
027: import javax.jbi.messaging.MessageExchange;
028: import javax.wsdl.extensions.ExtensibilityElement;
029: import javax.wsdl.extensions.ExtensionRegistry;
030:
031: import org.apache.commons.logging.Log;
032: import org.apache.commons.logging.LogFactory;
033:
034: import com.bostechcorp.cbesb.runtime.ccsl.jbi.messaging.CbComponent;
035: import com.bostechcorp.cbesb.runtime.ccsl.jbi.messaging.CbEndpoint;
036: import com.bostechcorp.cbesb.runtime.ccsl.jbi.messaging.Wsdl1Deployer;
037: import com.bostechcorp.cbesb.runtime.component.email.wsdl.EmailBinding;
038: import com.bostechcorp.cbesb.runtime.component.email.wsdl.EmailInput;
039: import com.bostechcorp.cbesb.runtime.component.email.wsdl.EmailInputExtension;
040: import com.bostechcorp.cbesb.runtime.component.email.wsdl.EmailOutput;
041: import com.bostechcorp.cbesb.runtime.component.email.wsdl.EmailOutputExtension;
042:
043: /**
044: *
045: */
046: public class EmailWsdl1Deployer extends Wsdl1Deployer {
047:
048: protected final transient Log logger = LogFactory
049: .getLog(getClass());
050:
051: public EmailWsdl1Deployer(CbComponent component) {
052: super (component);
053: }
054:
055: @Override
056: protected CbEndpoint createEndpoint(
057: ExtensibilityElement[] portElement,
058: ExtensibilityElement[] bindingElement) {
059: logger.debug("createEndpoint portElement=" + portElement[0]);
060:
061: EmailEndpoint endpoint = new EmailEndpoint();
062: if (portElement[0] instanceof EmailInput) {
063: EmailInput inputPortElement = (EmailInput) portElement[0];
064: logger.debug("EmailInput portElement=" + inputPortElement);
065: endpoint.setRole(MessageExchange.Role.CONSUMER);
066: endpoint.setDefaultMep(inputPortElement.getDefaultMep());
067: endpoint.setRecordType(inputPortElement.getRecordType());
068: endpoint.setCharset(inputPortElement.getCharset());
069: endpoint.setHost(inputPortElement.getHost());
070: endpoint.setPort(inputPortElement.getPort());
071: endpoint.setUser(inputPortElement.getUser());
072: endpoint.setPassword(inputPortElement.getPassword());
073: endpoint.setAttachmentDir(inputPortElement
074: .getAttachmentDir());
075:
076: endpoint.setProtocol(inputPortElement.getProtocol());
077: endpoint.setInboxFolder(inputPortElement.getInboxFolder());
078:
079: if (inputPortElement.getPollingInterval() != null
080: && !inputPortElement.getPollingInterval()
081: .equals("")) {
082: endpoint.setMode(EmailEndpoint.MODE_POLL);
083: endpoint
084: .setPollInterval(Integer
085: .parseInt(inputPortElement
086: .getPollingInterval()));
087: } else {
088: endpoint.setMode(EmailEndpoint.MODE_SCHEDULE);
089: endpoint
090: .setScheduleFile(inputPortElement.getSchedule());
091: endpoint.setSchedulerService(inputPortElement
092: .getSchedulerService());
093: endpoint.setSchedulerEndpoint(inputPortElement
094: .getSchedulerEndpoint());
095: }
096:
097: endpoint.setUseSSL(inputPortElement.getUseSSL());
098: endpoint
099: .setReplyCharset(inputPortElement.getReplyCharset());
100: endpoint.setReplyHost(inputPortElement.getReplyHost());
101: endpoint.setReplyPort(inputPortElement.getReplyPort());
102: endpoint.setReplyUser(inputPortElement.getReplyUser());
103: endpoint.setReplyPassword(inputPortElement
104: .getReplyPassword());
105: endpoint.setReplyUseSSL(inputPortElement.getReplyUseSSL());
106: } else {
107: EmailOutput outputPortElement = (EmailOutput) portElement[0];
108: logger
109: .debug("EmailOutput portElement="
110: + outputPortElement);
111: endpoint.setRole(MessageExchange.Role.PROVIDER);
112: endpoint.setDefaultMep(outputPortElement.getDefaultMep());
113: endpoint.setCharset(outputPortElement.getCharset());
114: endpoint.setHost(outputPortElement.getHost());
115: endpoint.setPort(outputPortElement.getPort());
116: endpoint.setUser(outputPortElement.getUser());
117: endpoint.setPassword(outputPortElement.getPassword());
118: endpoint.setFrom(outputPortElement.getFrom());
119: endpoint.setTo(outputPortElement.getTo());
120: endpoint.setCc(outputPortElement.getCc());
121: endpoint.setBcc(outputPortElement.getBcc());
122: endpoint.setSubject(outputPortElement.getSubject());
123: endpoint.setUseSSL(outputPortElement.getUseSSL());
124: }
125: return endpoint;
126: }
127:
128: @Override
129: protected boolean filterBindingElement(ExtensibilityElement element) {
130: return element instanceof EmailBinding;
131: }
132:
133: @Override
134: protected boolean filterPortElement(ExtensibilityElement element) {
135: return (element instanceof EmailInput)
136: || (element instanceof EmailOutput);
137: }
138:
139: @Override
140: protected void registerExtensions(ExtensionRegistry registry) {
141: super.registerExtensions(registry);
142: EmailInputExtension.register(registry);
143: EmailOutputExtension.register(registry);
144: }
145: }
|