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: * $Id: ParserEndpoint.java 12131 2008-02-28 18:42:39Z mpreston $
022: */
023:
024: package com.bostechcorp.cbesb.runtime.component.parser;
025:
026: import java.util.ArrayList;
027: import java.util.List;
028:
029: import javax.jbi.messaging.MessageExchange;
030:
031: //import org.apache.servicemix.common.ExchangeProcessor;
032: import com.bostechcorp.cbesb.runtime.ccsl.jbi.messaging.*;
033:
034: import com.bostechcorp.cbesb.runtime.ccsl.jbi.messaging.IComponentProcessor;
035: import com.bostechcorp.cbesb.runtime.component.parser.processors.ParserProviderProcessor;
036:
037: public class ParserEndpoint extends LifeCycleEndpoint {
038:
039: private String parserType;
040: private String msgDef;
041:
042: /**
043: * @return the msgDef
044: */
045: public String getMsgDef() {
046: return msgDef;
047: }
048:
049: /**
050: * @param msgDef the msgDef to set
051: */
052: public void setMsgDef(String msgDefFile) {
053: this .msgDef = msgDefFile;
054: }
055:
056: /**
057: * @return the parserType
058: */
059: public String getParserType() {
060: return parserType;
061: }
062:
063: /**
064: * @param parserType the parserType to set
065: */
066: public void setParserType(String parserType) {
067: this .parserType = parserType;
068: }
069:
070: public void processAsConsumer(MessageExchange exchange)
071: throws Exception {
072:
073: Exception e = new Exception(
074: "Parser component doesn't support Consumer role ");
075: exchange.setError(e);
076: channel.send(exchange);
077: throw e;
078:
079: }
080:
081: protected IComponentProcessor createProviderProcessor() {
082: return new ParserProviderProcessor(this );
083: }
084:
085: protected IComponentProcessor createConsumerProcessor() {
086: return null;
087: }
088:
089: /**********************************************************************************
090: * These attributes and methods customize the LifeCycleEndpoint for this component
091: ***********************************************************************************/
092:
093: /*
094: * The display parameters are general information for the admin console to display.
095: */
096: public String[] getDisplayParameterTitles() {
097:
098: return new String[] {
099: ParserPropertiesEnumeration.PARSER_TYPE.name(),
100: ParserPropertiesEnumeration.MSG_DEF.name() };
101: }
102:
103: /*
104: * The values returned here correspond to the titles above.
105: */
106: public String[] getDisplayParameters() {
107: return new String[] {
108: ParserPropertiesEnumeration.PARSER_TYPE.getValue(this ),
109: ParserPropertiesEnumeration.MSG_DEF.getValue(this ) };
110: }
111:
112: /*
113: * This returns a list of properties that can be read.
114: */
115: public String[] getGetableProperties() {
116: ParserPropertiesEnumeration[] fps = ParserPropertiesEnumeration
117: .values();
118: List<String> result = new ArrayList<String>();
119: for (int i = 0; i < fps.length; i++) {
120: result.add(fps[i].name());
121: }
122: String[] sr = new String[result.size()];
123: return result.toArray(sr);
124: }
125:
126: /*
127: * This gets one property from the list above.
128: */
129: public String getProperty(int index) {
130: return ParserPropertiesEnumeration.values()[index]
131: .getValue(this );
132: }
133:
134: /*
135: * This gets one property from the list above.
136: */
137: public String getProperty(String property) {
138: return ParserPropertiesEnumeration.valueOf(property).getValue(
139: this );
140: }
141:
142: /*
143: * This returns a list of properties that can be set.
144: */
145: public String[] getSetableProperties() {
146: ParserPropertiesEnumeration[] fps = ParserPropertiesEnumeration
147: .values();
148: List<String> result = new ArrayList<String>();
149: for (int i = 0; i < fps.length; i++) {
150: if (fps[i].isSetable())
151: result.add(fps[i].name());
152: }
153: String[] sr = new String[result.size()];
154: return result.toArray(sr);
155: }
156:
157: /*
158: * This sets one property from the list above.
159: */
160: public void setProperty(int index, String value) {
161: ParserPropertiesEnumeration.values()[index].setValue(this ,
162: value);
163: }
164:
165: /*
166: * This sets one property from the list above.
167: */
168: public void setProperty(String property, String value) {
169: ParserPropertiesEnumeration.valueOf(property).setValue(this ,
170: value);
171: }
172:
173: /**************************************************
174: * Done with LifeCycleEndpoint methods
175: ***************************************************/
176:
177: }
|