ServerDataModuleBean.java~2~
上传用户:jnhyscl
上传日期:2010-03-08
资源大小:345k
文件大小:3k
- package shiponline;
- import javax.ejb.*;
- import com.borland.dx.dataset.*;
- import com.borland.dx.ejb.*;
- public class ServerDataModuleBean implements SessionBean {
- SessionContext sessionContext;
- LocalEntityBeanProvider vaoPortProvider = new LocalEntityBeanProvider();
- LocalEntityBeanResolver vaoPortResolver = new LocalEntityBeanResolver();
- TableDataSet portDataSet = new TableDataSet();
- VaoPortHome vaoPortHome;
- public void ejbCreate() throws CreateException {
- /**@todo Complete this method*/
- }
- public void ejbRemove() {
- /**@todo Complete this method*/
- }
- public void ejbActivate() {
- /**@todo Complete this method*/
- }
- public void ejbPassivate() {
- /**@todo Complete this method*/
- }
- public void setSessionContext(SessionContext sessionContext) {
- this.sessionContext = sessionContext;
- try {
- javax.naming.Context context = new javax.naming.InitialContext();
- vaoPortHome = (VaoPortHome) context.lookup("VaoPort");
- vaoPortProvider.setEjbLocal(VaoPort.class);
- vaoPortProvider.setEjbLocalHome(vaoPortHome);
- vaoPortResolver.setEjbLocal(VaoPort.class);
- vaoPortResolver.setEjbLocalHome(vaoPortHome);
- }
- catch (Exception ex) {
- throw new EJBException(ex);
- }
- }
- public VaoPort newVaoPort() {
- /**@todo Complete this method*/
- return null;
- }
- public void addVaoPort(DataSetData[] dataArray) {
- VaoPort newVaoPort=null;
- try{
- newVaoPort = vaoPortHome.create(new Integer(1));
- }catch(Exception e){
- e.printStackTrace();
- }
- resolveVaoPort(dataArray);
- }
- public ServerDataModuleBean() {
- try {
- jbInit();
- }
- catch(Exception e) {
- e.printStackTrace();
- }
- }
- private void jbInit() throws Exception {
- vaoPortResolver.addLocalEntityBeanCreateListener(new com.borland.dx.ejb.LocalEntityBeanCreateListener(){
- public void create(LocalEntityBeanCreateEvent e) {
- VaoPort vaoPort = newVaoPort();
- e.getLocalEntityBeanResolver().storeDataRowToEntityBean(e.getDataRow(),vaoPort);
- }
- });
- vaoPortProvider.addLocalEntityBeanFindListener(new com.borland.dx.ejb.LocalEntityBeanFindListener(){
- public void findEntityBeans(LocalEntityBeanFindEvent e) {
- try {
- ReadWriteRow paramRow = e.getLocalEntityBeanProvider().getParameterRow();
- if ( paramRow != null ) {
- Integer portid = new Integer(paramRow.getInt(0));
- e.setEntityBeanLocal(vaoPortHome.findByPrimaryKey(portid));
- }
- }catch (Exception ex) {
- ex.printStackTrace();
- }
- }});
- portDataSet.setProvider(vaoPortProvider);
- portDataSet.setResolver(vaoPortResolver);
- }
- public DataSetData[] resolveVaoPort(DataSetData[] dataSetDataArray) {
- return EntityBeanConnection.saveChanges(dataSetDataArray, new DataSet [] {portDataSet});
- }
- }