SessionBean.java~44~
上传用户:jnhyscl
上传日期:2010-03-08
资源大小:345k
文件大小:2k
- package web;
- /**
- * <p>Title: </p>
- * <p>Description: </p>
- * <p>Copyright: Copyright (c) 2003</p>
- * <p>Company: </p>
- * @author not attributable
- * @version 1.0
- */
- import javax.rmi.*;
- import javax.naming.*;
- import com.borland.dx.dataset.*;
- import dm.*;
- import java.util.*;
- import java.rmi.*;
- import shiponline.*;
- public class SessionBean {
- private Apps apps;
- private ClientDataModule clientDataModule;
- public SessionBean() {
- try {
- jbInit();
- Context context = getInitialContext();
- Object object = context.lookup("Apps");
- AppsHome home = (AppsHome) PortableRemoteObject.narrow(object, AppsHome.class);
- apps = home.create();
- clientDataModule.getSessionBeanConnection().setSessionBeanRemote(apps);
- }
- catch (Exception ex) {
- System.out.print("ylf"+ex);
- }
- }
- public Apps getApps() {
- return apps;
- }
- private void jbInit() throws Exception {
- clientDataModule = new ClientDataModule();
- }
- public ClientDataModule getClientDataModule() {
- return clientDataModule;
- }
- public void addNewPort()throws Exception {
- clientDataModule.addNewPort();
- }
- public int addVaoPort(String code, String name) {
- try {
- DataSetData dataSetData = DataSetData.extractDataSetChanges(
- clientDataModule.getPortDataSet());
- return apps.addVaoPort(new DataSetData[] {dataSetData}
- , code, name);
- }
- catch (Exception ex) {
- ex.printStackTrace();
- return 4;
- }
- }
- 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;
- }
- }
- }