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 2475 2006-10-24 19:59:05Z fling $
022: */
023:
024: package com.bostechcorp.cbesb.runtime.component.script;
025:
026: import java.util.ArrayList;
027: import java.util.List;
028:
029: import com.bostechcorp.cbesb.runtime.ccsl.jbi.messaging.CbEmbeddedSchedulerConsumerProcessor;
030: import com.bostechcorp.cbesb.runtime.ccsl.jbi.messaging.IComponentProcessor;
031: import com.bostechcorp.cbesb.runtime.ccsl.jbi.messaging.ScheduledEndpointProcessor;
032: import com.bostechcorp.cbesb.runtime.component.script.processors.ScriptConsumerHandler;
033: import com.bostechcorp.cbesb.runtime.component.script.processors.ScriptProviderProcessor;
034:
035: public class ScriptEndpoint extends ScheduledEndpointProcessor {
036:
037: private String triggerTime;
038: private String type;
039: private String scriptClass;
040:
041: public ScriptEndpoint() {
042: this .handler = new ScriptConsumerHandler(this );
043: }
044:
045: public String getTriggerTime() {
046: return triggerTime;
047: }
048:
049: public void setTriggerTime(String triggerTime) {
050: this .triggerTime = triggerTime;
051: }
052:
053: public String getType() {
054: return type;
055: }
056:
057: public void setType(String type) {
058: this .type = type;
059: }
060:
061: public String getScriptClass() {
062: return scriptClass;
063: }
064:
065: public void setScriptClass(String scriptClass1) {
066: scriptClass = scriptClass1;
067: }
068:
069: protected IComponentProcessor createProviderProcessor() {
070: ScriptProviderProcessor provider = new ScriptProviderProcessor(
071: this );
072: provider.setMessageExchangeFactory(exchangeFactory);
073: provider.setChannel(channel);
074:
075: return provider;
076: }
077:
078: protected IComponentProcessor createConsumerProcessor() {
079: // ScriptConsumerProcessor consumer = new ScriptConsumerProcessor(this);
080: // consumer.setMessageExchangeFactory(exchangeFactory);
081: // consumer.setChannel(channel);
082: //
083: // return consumer;
084: return new CbEmbeddedSchedulerConsumerProcessor(this );
085: }
086:
087: /**********************************************************************************
088: * These attributes and methods customize the LifeCycleEndpoint for this component
089: ***********************************************************************************/
090:
091: /*
092: * The display parameters are general information for the admin console to display.
093: */
094: public String[] getDisplayParameterTitles() {
095: return new String[] {
096: ScriptPropertiesEnumeration.TRIGGER_TIME.name(),
097: ScriptPropertiesEnumeration.TYPE.name(),
098: ScriptPropertiesEnumeration.SCRIPT_CLASS.name() };
099:
100: }
101:
102: /*
103: * The values returned here correspond to the titles above.
104: */
105: public String[] getDisplayParameters() {
106: return new String[] {
107: ScriptPropertiesEnumeration.TRIGGER_TIME.getValue(this ),
108: ScriptPropertiesEnumeration.TYPE.getValue(this ),
109: ScriptPropertiesEnumeration.SCRIPT_CLASS.getValue(this ) };
110: }
111:
112: /*
113: * This returns a list of properties that can be read.
114: */
115: public String[] getGetableProperties() {
116: ScriptPropertiesEnumeration[] fps = ScriptPropertiesEnumeration
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 ScriptPropertiesEnumeration.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 ScriptPropertiesEnumeration.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: ScriptPropertiesEnumeration[] fps = ScriptPropertiesEnumeration
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: ScriptPropertiesEnumeration.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: ScriptPropertiesEnumeration.valueOf(property).setValue(this ,
170: value);
171: }
172:
173: /**************************************************
174: * Done with LifeCycleEndpoint methods
175: ***************************************************/
176:
177: }
|