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: JdbcEndpoint.java 9749 2007-10-26 11:05:37Z lzheng $
022: */
023:
024: package com.bostechcorp.cbesb.runtime.component.jdbc;
025:
026: import java.util.ArrayList;
027: import java.util.List;
028:
029: import javax.jbi.messaging.MessageExchange;
030:
031: import com.bostechcorp.cbesb.runtime.ccsl.jbi.messaging.IComponentProcessor;
032: import com.bostechcorp.cbesb.runtime.ccsl.jbi.messaging.LifeCycleEndpoint;
033: import com.bostechcorp.cbesb.runtime.component.jdbc.processors.JdbcProviderProcessor;
034:
035: public class JdbcEndpoint extends LifeCycleEndpoint {
036:
037: private String driver;
038: private String url;
039: private String user;
040: private String password;
041: private String requestHandler;
042: private String execHandler;
043: private boolean autoCommit;
044: private int connectionRetries;
045: private int connectionInterval;
046: private int transactionTimeout;
047: private int defaultPageSize;
048:
049: /**
050: * @return the autoCommit
051: */
052: public boolean isAutoCommit() {
053: return autoCommit;
054: }
055:
056: /**
057: * @param autoCommit the autoCommit to set
058: */
059: public void setAutoCommit(boolean autoCommit) {
060: this .autoCommit = autoCommit;
061: }
062:
063: /**
064: * @return the connectionInterval
065: */
066: public int getConnectionInterval() {
067: return connectionInterval;
068: }
069:
070: /**
071: * @param connectionInterval the connectionInterval to set
072: */
073: public void setConnectionInterval(int connectionInterval) {
074: this .connectionInterval = connectionInterval;
075: }
076:
077: /**
078: * @return the connectionRetries
079: */
080: public int getConnectionRetries() {
081: return connectionRetries;
082: }
083:
084: /**
085: * @param connectionRetries the connectionRetries to set
086: */
087: public void setConnectionRetries(int connectionRetries) {
088: this .connectionRetries = connectionRetries;
089: }
090:
091: /**
092: * @return the defaultPageSize
093: */
094: public int getDefaultPageSize() {
095: return defaultPageSize;
096: }
097:
098: /**
099: * @param defaultPageSize the defaultPageSize to set
100: */
101: public void setDefaultPageSize(int defaultPageSize) {
102: this .defaultPageSize = defaultPageSize;
103: }
104:
105: /**
106: * @return the driver
107: */
108: public String getDriver() {
109: return driver;
110: }
111:
112: /**
113: * @param driver the driver to set
114: */
115: public void setDriver(String driver) {
116: this .driver = driver;
117: }
118:
119: /**
120: * @return the execHandler
121: */
122: public String getExecHandler() {
123: return execHandler;
124: }
125:
126: /**
127: * @param execHandler the execHandler to set
128: */
129: public void setExecHandler(String execHandler) {
130: this .execHandler = execHandler;
131: }
132:
133: /**
134: * @return the requestHandler
135: */
136: public String getRequestHandler() {
137: return requestHandler;
138: }
139:
140: /**
141: * @param requestHandler the requestHandler to set
142: */
143: public void setRequestHandler(String requestHandler) {
144: this .requestHandler = requestHandler;
145: }
146:
147: /**
148: * @return the password
149: */
150: public String getPassword() {
151: return password;
152: }
153:
154: /**
155: * @param password the password to set
156: */
157: public void setPassword(String password) {
158: this .password = password;
159: }
160:
161: /**
162: * @return the transactionTimeout
163: */
164: public int getTransactionTimeout() {
165: return transactionTimeout;
166: }
167:
168: /**
169: * @param transactionTimeout the transactionTimeout to set
170: */
171: public void setTransactionTimeout(int transactionTimeout) {
172: this .transactionTimeout = transactionTimeout;
173: }
174:
175: /**
176: * @return the url
177: */
178: public String getUrl() {
179: return url;
180: }
181:
182: /**
183: * @param url the url to set
184: */
185: public void setUrl(String url) {
186: this .url = url;
187: }
188:
189: /**
190: * @return the user
191: */
192: public String getUser() {
193: return user;
194: }
195:
196: /**
197: * @param user the user to set
198: */
199: public void setUser(String user) {
200: this .user = user;
201: }
202:
203: public void processAsConsumer(MessageExchange exchange)
204: throws Exception {
205:
206: Exception e = new Exception(
207: "JDBCConfig component doesn't support Consumer role ");
208: exchange.setError(e);
209: channel.send(exchange);
210: throw e;
211:
212: }
213:
214: protected IComponentProcessor createProviderProcessor()
215: throws Exception {
216: return new JdbcProviderProcessor(this );
217: }
218:
219: protected IComponentProcessor createConsumerProcessor() {
220: return null;
221: }
222:
223: /**********************************************************************************
224: * These attributes and methods customize the LifeCycleEndpoint for this component
225: ***********************************************************************************/
226:
227: /*
228: * The display parameters are general information for the admin console to display.
229: */
230: public String[] getDisplayParameterTitles() {
231: return new String[] { JdbcPropertiesEnumeration.DRIVER.name(),
232: JdbcPropertiesEnumeration.URL.name(),
233: JdbcPropertiesEnumeration.USER.name(),
234: JdbcPropertiesEnumeration.AUTO_COMMIT.name(),
235: JdbcPropertiesEnumeration.CONNECTION_INTERVAL.name() };
236: }
237:
238: /*
239: * The values returned here correspond to the titles above.
240: */
241: public String[] getDisplayParameters() {
242: return new String[] {
243: JdbcPropertiesEnumeration.DRIVER.getValue(this ),
244: JdbcPropertiesEnumeration.URL.getValue(this ),
245: JdbcPropertiesEnumeration.USER.getValue(this ),
246: JdbcPropertiesEnumeration.AUTO_COMMIT.getValue(this ),
247: JdbcPropertiesEnumeration.CONNECTION_INTERVAL
248: .getValue(this ) };
249: }
250:
251: /*
252: * This returns a list of properties that can be read.
253: */
254: public String[] getGetableProperties() {
255: JdbcPropertiesEnumeration[] fps = JdbcPropertiesEnumeration
256: .values();
257: List<String> result = new ArrayList<String>();
258: for (int i = 0; i < fps.length; i++) {
259: result.add(fps[i].name());
260: }
261: String[] sr = new String[result.size()];
262: return result.toArray(sr);
263: }
264:
265: /*
266: * This gets one property from the list above.
267: */
268: public String getProperty(int index) {
269: return JdbcPropertiesEnumeration.values()[index].getValue(this );
270: }
271:
272: /*
273: * This gets one property from the list above.
274: */
275: public String getProperty(String property) {
276: return JdbcPropertiesEnumeration.valueOf(property).getValue(
277: this );
278: }
279:
280: /*
281: * This returns a list of properties that can be set.
282: */
283: public String[] getSetableProperties() {
284: JdbcPropertiesEnumeration[] fps = JdbcPropertiesEnumeration
285: .values();
286: List<String> result = new ArrayList<String>();
287: for (int i = 0; i < fps.length; i++) {
288: if (fps[i].isSetable())
289: result.add(fps[i].name());
290: }
291: String[] sr = new String[result.size()];
292: return result.toArray(sr);
293: }
294:
295: /*
296: * This sets one property from the list above.
297: */
298: public void setProperty(int index, String value) {
299: JdbcPropertiesEnumeration.values()[index].setValue(this , value);
300: }
301:
302: /*
303: * This sets one property from the list above.
304: */
305: public void setProperty(String property, String value) {
306: JdbcPropertiesEnumeration.valueOf(property).setValue(this ,
307: value);
308: }
309:
310: /**************************************************
311: * Done with LifeCycleEndpoint methods
312: ***************************************************/
313:
314: }
|