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