SessionBMPClient.java
资源名称:MyStore.rar [点击查看]
上传用户:hgs128
上传日期:2007-02-03
资源大小:166k
文件大小:2k
源码类别:
百货/超市行业
开发平台:
WINDOWS
- /*
- * Created on 1999-5-17
- */
- package testClient;
- import java.rmi.RemoteException;
- import java.util.Hashtable;
- import javax.ejb.CreateException;
- import javax.naming.InitialContext;
- import javax.naming.NamingException;
- import bmp.CustomerData;
- import bmp.ManagerData;
- /**
- * @author 28-9
- *
- * TODO To change the template for this generated type comment go to
- * Window - Preferences - Java - Code Generation - Code and Comments
- */
- public class SessionBMPClient {
- private stateless.StoreAccessHome getHome() throws NamingException {
- return (stateless.StoreAccessHome) getContext().lookup(
- stateless.StoreAccessHome.JNDI_NAME);
- }
- private InitialContext getContext() throws NamingException {
- Hashtable props = new Hashtable();
- props.put(InitialContext.INITIAL_CONTEXT_FACTORY,
- "org.jnp.interfaces.NamingContextFactory");
- props.put(InitialContext.PROVIDER_URL, "jnp://127.0.0.1:1099");
- // This establishes the security for authorization/authentication
- // props.put(InitialContext.SECURITY_PRINCIPAL,"username");
- // props.put(InitialContext.SECURITY_CREDENTIALS,"password");
- InitialContext initialContext = new InitialContext(props);
- return initialContext;
- }
- public void testBean() {
- try {
- stateless.StoreAccess myBean = getHome().create();
- //--------------------------------------
- //This is the place you make your calls.
- //System.out.println(myBean.callYourMethod());
- System.out.println("Request from client : ");
- String userID = myBean.loginUser("danny", "swdandy");
- System.out.println("Reply from Server: Your userid is " + userID );
- CustomerData cd = myBean.getCustomerData(userID);
- System.out.println ("Andy your details with MyStore are " + cd );
- System.out.println("Request from client : ");
- String mgrID = myBean.loginUser("RUSTY","PASSWD");
- System.out.println("Reply from Server: Your mgrid is " + mgrID );
- ManagerData md = myBean.getManagerData(mgrID);
- System.out.println ("Rusty your details with MyStore are " + md );
- } catch (RemoteException e) {
- e.printStackTrace();
- } catch (CreateException e) {
- e.printStackTrace();
- } catch (NamingException e) {
- e.printStackTrace();
- }
- }
- public static void main(String[] args) {
- SessionBMPClient test = new SessionBMPClient();
- test.testBean();
- }
- }