📄 enterprise1testclient1.java~3~
字号:
package cmp2bean;import javax.naming.*;import java.util.Properties;import javax.rmi.PortableRemoteObject;public class Enterprise1TestClient1 extends Object { private Enterprise1Home enterprise1Home = null; private Enterprise1 enterprise1 = null; //Construct the EJB test client public Enterprise1TestClient1() { initialize(); } public void initialize() { try { //get naming context Context context = getInitialContext(); //look up jndi name Object ref = context.lookup("Enterprise2"); //look up jndi name and cast to Home interface enterprise1Home = (Enterprise1Home) PortableRemoteObject.narrow(ref, Enterprise1Home.class); enterprise1 = enterprise1Home.create(); enterprise1.displayPerson("Si"); String first="f01"; String last="f01"; String email="klk";enterprise1.insertPerson(first,last.email); } catch(Exception e) { e.printStackTrace(); } } private Context getInitialContext() throws Exception { String url = "t3://localhost:7001"; String user = null; String password = null; Properties properties = null; try { properties = new Properties(); properties.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory"); properties.put(Context.PROVIDER_URL, url); if (user != null) { properties.put(Context.SECURITY_PRINCIPAL, user); properties.put(Context.SECURITY_CREDENTIALS, password == null ? "" : password); } return new InitialContext(properties); } catch(Exception e) { System.out.println("Unable to connect to WebLogic server at " + url); System.out.println("Please make sure that the server is running."); throw e; } } //---------------------------------------------------------------------------- // Utility Methods //---------------------------------------------------------------------------- public Enterprise1Home getHome() { return enterprise1Home; } //Main method public static void main(String[] args) { Enterprise1TestClient1 client = new Enterprise1TestClient1(); // Use the getHome() method of the client object to call Home interface // methods that will return a Remote interface reference. Then // use that Remote interface reference to access the EJB. }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -