📄 testclient.java
字号:
package xian.bin.test;import xian.bin.user.*;import javax.naming.*;import java.util.*;import javax.rmi.PortableRemoteObject;public class TestClient extends Object { private UserHome userHome = null; //Construct the EJB test client public TestClient() { initialize(); } public void initialize() { try { //get naming context Context context = getInitialContext(); //look up jndi name Object ref = context.lookup("User"); //look up jndi name and cast to Home interface userHome = (UserHome) PortableRemoteObject.narrow(ref, UserHome.class); } catch(Exception e) { e.printStackTrace(); } } private Context getInitialContext() throws Exception { String url = "t3://815-L21115b001: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 UserHome getHome() { return userHome; } //Main method public static void main(String[] args) throws Exception{ TestClient client = new TestClient(); User user=client.getHome().create(); Iterator it=user.getAllUserInfo().iterator(); while(it.hasNext()){ UserDTO dto=(UserDTO)it.next(); System.out.println("AAAAAAAAAAAAAAA"+dto.getRealName()); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -