ShiponlineBean.java~16~
上传用户:jnhyscl
上传日期:2010-03-08
资源大小:345k
文件大小:2k
- package shiponline;
- import javax.naming.*;
- import javax.ejb.*;
- import com.borland.dx.dataset.*;
- public class ShiponlineBean implements SessionBean {
- SessionContext sessionContext;
- VaoPortHome vaoPortHome;
- ServerDataModuleLocal serverDataModule;
- Context context;
- public void ejbCreate() throws CreateException {
- lookup();
- }
- public void ejbRemove() {
- /**@todo Complete this method*/
- }
- public void ejbActivate() {
- lookup();
- }
- public void ejbPassivate() {
- /**@todo Complete this method*/
- }
- public void setSessionContext(SessionContext sessionContext) {
- this.sessionContext = sessionContext;
- }
- public int addVaoPort(DataSetData[] dataArray, String code, String name) {
- try{
- try{
- vaoPortHome.findByCode(code);
- return 1;
- }catch (ObjectNotFoundException ex){
- }
- try{
- vaoPortHome.findByName(name);
- return 2;
- }catch(ObjectNotFoundException exc){
- }
- serverDataModule.addVaoPort(dataArray);
- return 3;
- }catch(Exception e){
- return 4;
- }
- }
- public void lookup() {
- try {
- context = getInitialContext();
- //ServerDataModuleLocalHome home = (ServerDataModuleLocalHome) context.lookup("java:comp/env/ServerDataModule");
- // serverDataModule = home.create();
- //vaoPortHome = (VaoPortHome) context.lookup("VaoPort");
- }
- catch (Exception ex) {
- throw new EJBException("Invalid user: " + ex.toString());
- }
- }
- private javax.naming.Context getInitialContext() {
- try {
- if (context == null) {
- context = new javax.naming.InitialContext();
- }
- return context;
- }
- catch (Exception ex) {
- throw new EJBException(ex);
- }
- }
- }