ClientDataModule.java~27~
上传用户:jnhyscl
上传日期:2010-03-08
资源大小:345k
文件大小:3k
- package dm;
- /**
- * <p>Title: </p>
- * <p>Description: </p>
- * <p>Copyright: Copyright (c) 2003</p>
- * <p>Company: </p>
- * @author not attributable
- * @version 1.0
- */
- import shiponline.*;
- import com.borland.dx.dataset.*;
- import com.borland.dx.ejb.*;
- import javax.naming.*;
- import java.util.*;
- public class ClientDataModule implements DataModule {
- private static ClientDataModule myDM;
- SessionBeanConnection sessionBeanConnection = new SessionBeanConnection();
- EjbClientDataSet portDataSet = new EjbClientDataSet();
- ParameterRow portIdParameter = new ParameterRow();
- Column searchItemColumn = new Column();
- Column priceColumn = new Column();
- Column ejbPrimaryKeyColumn = new Column();
- Apps apps;
- AppsHome appsHome;
- public ClientDataModule() {
- try {
- System.out.println("hhhhhhhhhhhhhh" + sessionBeanConnection.toString());
- jbInit();
- }
- catch(Exception e) {
- e.printStackTrace();
- }
- }
- private void jbInit() {
- try{
- javax.naming.Context context =getInitialContext();
- portDataSet.setSessionBeanConnection(sessionBeanConnection);
- portDataSet.setExecuteOnOpen(false);
- // portDataSet.setMethodName("Port");
- appsHome=(AppsHome)context.lookup("java:comp/env/Apps");
- apps = appsHome.create();
- //apps = (Apps) sessionBeanConnection.getSessionBeanRemote();
- portIdParameter.setColumns(new Column [] { new Column("PORTID", "PORTID", Variant.INT)});
- //portDataSet.setParameterRow(portIdParameter);
- if(!portDataSet.isOpen()){
- portDataSet.open();
- }else{
- portDataSet.empty();
- }
- }catch(Exception e) {
- System.out.println("gggggggggggggggggggg" + e);
- }
- }
- public static ClientDataModule getDataModule() {
- if (myDM == null) {
- myDM = new ClientDataModule();
- }
- return myDM;
- }
- public com.borland.dx.ejb.SessionBeanConnection getSessionBeanConnection() {
- return sessionBeanConnection;
- }
- public void setPortDataSet(EjbClientDataSet ds){
- this.portDataSet=ds;
- }
- public EjbClientDataSet getPortDataSet() {
- return portDataSet;
- }
- public void addNewPort() throws Exception{
- DataSetData[] ds = apps.addNewPort();
- ds[0].loadDataSet(this.portDataSet);
- }
- private Context getInitialContext() throws Exception {
- String hostname="fanhua02";
- String url = "iiop://fanhua02:9090";
- String user ="Guest";
- String password ="GuestPassword";
- Properties properties = null;
- try {
- properties = new Properties();
- properties.put(Context.INITIAL_CONTEXT_FACTORY, "com.sybase.ejb.InitialContextFactory");
- properties.put(Context.PROVIDER_URL, url);
- properties.put(Context.SECURITY_PRINCIPAL, user);
- properties.put(Context.SECURITY_CREDENTIALS, password);
- Thread curr=Thread.currentThread();
- ClassLoader l=curr.getContextClassLoader();
- ClassLoader c=l;
- java.net.URL classPath = new java.net.URL("http",hostname,8080,"/classes/");
- curr.setContextClassLoader(java.net.URLClassLoader.newInstance(new java.net.URL[]{classPath},l));
- return new InitialContext(properties);
- }
- catch(Exception e) {
- throw e;
- }
- }
- }