001: //** Copyright Statement ***************************************************
002: //The Salmon Open Framework for Internet Applications (SOFIA)
003: // Copyright (C) 1999 - 2002, Salmon LLC
004: //
005: // This program is free software; you can redistribute it and/or
006: // modify it under the terms of the GNU General Public License version 2
007: // as published by the Free Software Foundation;
008: //
009: // This program is distributed in the hope that it will be useful,
010: // but WITHOUT ANY WARRANTY; without even the implied warranty of
011: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
012: // GNU General Public License for more details.
013: //
014: // You should have received a copy of the GNU General Public License
015: // along with this program; if not, write to the Free Software
016: // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
017: //
018: // For more information please visit http://www.salmonllc.com
019: //** End Copyright Statement ***************************************************
020: package com.salmonllc.sql;
021:
022: import javax.servlet.http.HttpServletRequest;
023:
024: /**
025: * This class is used to combine the functionality of a DataStoreProxy with a BanDataStore. It allows data from EJB value objects to be delivered to Swing applets and web start applications via HTTP HTTPS
026: **/
027: public abstract class ProxyBeanDataStoreAdaptor extends DataStore
028: implements Remotable {
029: BeanDataStore _beanDs;
030:
031: public ProxyBeanDataStoreAdaptor() {
032: super (null);
033: _beanDs = new BeanDataStore(getBeanClass());
034:
035: DSDataStoreDescriptor d = _beanDs.getDescriptor();
036:
037: try {
038: for (int i = 0; i < d.getColumnCount(); i++)
039: d.getColumn(i).setColumn(_beanDs.getColumnName(i));
040: } catch (DataStoreException e) {
041: }
042:
043: setProperties(_beanDs.getProperties());
044:
045: }
046:
047: /**
048: * Override the standard retrieve method in the datastore
049: */
050: public void retrieve(String criteria) {
051: reset();
052: loadData(criteria);
053: setRows(_beanDs.getRows());
054: }
055:
056: /**
057: * Override the reset method of the datastore
058: */
059: public void reset() {
060: super .reset();
061: _beanDs.reset();
062: }
063:
064: /**
065: * Override the standard update method in the proxy
066: */
067: public void update() {
068: _beanDs.setRows(getRows());
069: updateData();
070: }
071:
072: /**
073: * Returns the underlying bean datastore used by this class. Instead of directly setting or getting values from this datastore, you should instead use the internal bean datastore
074: */
075: public BeanDataStore getBeanDataStore() {
076: return _beanDs;
077: }
078:
079: /**
080: *Implementation of the Remotable interface. This method is called before each request, you can return true to allow the request and false to deny it.
081: */
082: public abstract boolean request(String reqType,
083: HttpServletRequest req, boolean sessionValid,
084: String userID, String password, String criteria)
085: throws DataStoreException;
086:
087: /**
088: * This method must return the class of the bean used for the BeanDataStore
089: */
090: public abstract Class getBeanClass();
091:
092: /**
093: * This method must be implemented for the DataStore to return data from the proxy. In it you should load your bean value objects from the EJB server and move them into the BeanDataStore using getBeanDataStore().insertRow() for each bean you want to send back to the client
094: * @param criteria an arbitrary selection criteria string sent from the client
095: */
096: public abstract void loadData(String criteria);
097:
098: /**
099: * This method must be implemented to send data from the client proxy back to the EJB server. It should get the data from the BeanDataStore using getBeanDataStore().getBeans() and move the data back to the EJB server through EJB method calls.
100: *
101: */
102: public abstract void updateData();
103:
104: }
|