📄 prod_view_searchtestclient1.java~1~
字号:
package product;import javax.naming.*;import java.util.Properties;import javax.rmi.PortableRemoteObject;import java.awt.Image;import java.util.Collection;public class prod_view_searchTestClient1 extends Object { private static final String ERROR_NULL_REMOTE = "Remote interface reference is null. It must be created by calling one of the Home interface methods first."; private static final int MAX_OUTPUT_LINE_LENGTH = 100; private boolean logging = true; private prod_view_searchRemoteHome prod_view_searchRemoteHomeObject = null; private prod_view_searchRemote prod_view_searchRemoteObject = null; //Construct the EJB test client public prod_view_searchTestClient1() { initialize(); } public void initialize() { long startTime = 0; if (logging) { log("Initializing bean access."); startTime = System.currentTimeMillis(); } try { //get naming context Context context = getInitialContext(); //look up jndi name Object ref = context.lookup("prod_view_searchRemote"); //look up jndi name and cast to Home interface prod_view_searchRemoteHomeObject = (prod_view_searchRemoteHome) PortableRemoteObject.narrow(ref, prod_view_searchRemoteHome.class); if (logging) { long endTime = System.currentTimeMillis(); log("Succeeded initializing bean access through Home interface."); log("Execution time: " + (endTime - startTime) + " ms."); } } catch(Exception e) { if (logging) { log("Failed initializing bean access."); } e.printStackTrace(); } } private Context getInitialContext() throws Exception { String url = "t3://j-af3d73a001034: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) { log("Unable to connect to WebLogic server at " + url); log("Please make sure that the server is running."); throw e; } } //---------------------------------------------------------------------------- // Methods that use Home interface methods to generate a Remote interface reference //---------------------------------------------------------------------------- public prod_view_searchRemote create(String id, String tid, String name, String spec, String model, String unit, String remark, float tax, int amount, int maxlow, float bprice, String sprice, String state, String depositary, Image image) { long startTime = 0; if (logging) { log("Calling create(" + id + ", " + tid + ", " + name + ", " + spec + ", " + model + ", " + unit + ", " + remark + ", " + tax + ", " + amount + ", " + maxlow + ", " + bprice + ", " + sprice + ", " + state + ", " + depositary + ", " + image + ")"); startTime = System.currentTimeMillis(); } try { prod_view_searchRemoteObject = prod_view_searchRemoteHomeObject.create(id, tid, name, spec, model, unit, remark, tax, amount, maxlow, bprice, sprice, state, depositary, image); if (logging) { long endTime = System.currentTimeMillis(); log("Succeeded: create(" + id + ", " + tid + ", " + name + ", " + spec + ", " + model + ", " + unit + ", " + remark + ", " + tax + ", " + amount + ", " + maxlow + ", " + bprice + ", " + sprice + ", " + state + ", " + depositary + ", " + image + ")"); log("Execution time: " + (endTime - startTime) + " ms."); } } catch(Exception e) { if (logging) { log("Failed: create(" + id + ", " + tid + ", " + name + ", " + spec + ", " + model + ", " + unit + ", " + remark + ", " + tax + ", " + amount + ", " + maxlow + ", " + bprice + ", " + sprice + ", " + state + ", " + depositary + ", " + image + ")"); } e.printStackTrace(); } if (logging) { log("Return value from create(" + id + ", " + tid + ", " + name + ", " + spec + ", " + model + ", " + unit + ", " + remark + ", " + tax + ", " + amount + ", " + maxlow + ", " + bprice + ", " + sprice + ", " + state + ", " + depositary + ", " + image + "): " + prod_view_searchRemoteObject + "."); } return prod_view_searchRemoteObject; } public Collection find_name(String type, String content) { Collection returnValue = null; long startTime = 0; if (logging) { log("Calling find_name(" + type + ", " + content + ")"); startTime = System.currentTimeMillis(); } try { returnValue = prod_view_searchRemoteHomeObject.find_name(type, content); if (logging) { long endTime = System.currentTimeMillis(); log("Succeeded: find_name(" + type + ", " + content + ")"); log("Execution time: " + (endTime - startTime) + " ms."); } } catch(Exception e) { if (logging) { log("Failed: find_name(" + type + ", " + content + ")"); } e.printStackTrace(); } if (logging) { log("Return value from find_name(" + type + ", " + content + "): " + returnValue + "."); } return returnValue; } public Collection find_spec(String type, String content) { Collection returnValue = null; long startTime = 0; if (logging) { log("Calling find_spec(" + type + ", " + content + ")"); startTime = System.currentTimeMillis(); } try { returnValue = prod_view_searchRemoteHomeObject.find_spec(type, content); if (logging) { long endTime = System.currentTimeMillis(); log("Succeeded: find_spec(" + type + ", " + content + ")"); log("Execution time: " + (endTime - startTime) + " ms."); } } catch(Exception e) { if (logging) { log("Failed: find_spec(" + type + ", " + content + ")"); } e.printStackTrace(); } if (logging) { log("Return value from find_spec(" + type + ", " + content + "): " + returnValue + "."); } return returnValue; } public Collection find_id(String type, String id) { Collection returnValue = null; long startTime = 0; if (logging) { log("Calling find_id(" + type + ", " + id + ")"); startTime = System.currentTimeMillis(); } try { returnValue = prod_view_searchRemoteHomeObject.find_id(type, id); if (logging) { long endTime = System.currentTimeMillis(); log("Succeeded: find_id(" + type + ", " + id + ")"); log("Execution time: " + (endTime - startTime) + " ms."); } } catch(Exception e) { if (logging) { log("Failed: find_id(" + type + ", " + id + ")"); } e.printStackTrace(); } if (logging) { log("Return value from find_id(" + type + ", " + id + "): " + returnValue + "."); } return returnValue; } public Collection find_model(String type, String content) { Collection returnValue = null; long startTime = 0; if (logging) { log("Calling find_model(" + type + ", " + content + ")"); startTime = System.currentTimeMillis(); } try { returnValue = prod_view_searchRemoteHomeObject.find_model(type, content); if (logging) { long endTime = System.currentTimeMillis(); log("Succeeded: find_model(" + type + ", " + content + ")"); log("Execution time: " + (endTime - startTime) + " ms."); } } catch(Exception e) { if (logging) { log("Failed: find_model(" + type + ", " + content + ")"); } e.printStackTrace(); } if (logging) { log("Return value from find_model(" + type + ", " + content + "): " + returnValue + "."); } return returnValue; } public prod_view_searchRemote findByPrimaryKey(prod_view_searchPK pk) { long startTime = 0; if (logging) { log("Calling findByPrimaryKey(" + pk + ")"); startTime = System.currentTimeMillis(); } try { prod_view_searchRemoteObject = prod_view_searchRemoteHomeObject.findByPrimaryKey(pk); if (logging) { long endTime = System.currentTimeMillis(); log("Succeeded: findByPrimaryKey(" + pk + ")"); log("Execution time: " + (endTime - startTime) + " ms."); } } catch(Exception e) { if (logging) { log("Failed: findByPrimaryKey(" + pk + ")"); } e.printStackTrace(); } if (logging) { log("Return value from findByPrimaryKey(" + pk + "): " + prod_view_searchRemoteObject + "."); } return prod_view_searchRemoteObject; } //---------------------------------------------------------------------------- // Methods that use Remote interface methods to access data through the bean //---------------------------------------------------------------------------- public String getId() { String returnValue = ""; if (prod_view_searchRemoteObject == null) { System.out.println("Error in getId(): " + ERROR_NULL_REMOTE); return returnValue; } long startTime = 0; if (logging) { log("Calling getId()"); startTime = System.currentTimeMillis(); } try { returnValue = prod_view_searchRemoteObject.getId(); if (logging) { long endTime = System.currentTimeMillis(); log("Succeeded: getId()"); log("Execution time: " + (endTime - startTime) + " ms."); } } catch(Exception e) { if (logging) { log("Failed: getId()"); } e.printStackTrace(); } if (logging) { log("Return value from getId(): " + returnValue + "."); } return returnValue; } public String getTid() { String returnValue = ""; if (prod_view_searchRemoteObject == null) { System.out.println("Error in getTid(): " + ERROR_NULL_REMOTE); return returnValue; } long startTime = 0; if (logging) { log("Calling getTid()"); startTime = System.currentTimeMillis(); } try { returnValue = prod_view_searchRemoteObject.getTid(); if (logging) { long endTime = System.currentTimeMillis(); log("Succeeded: getTid()"); log("Execution time: " + (endTime - startTime) + " ms."); } } catch(Exception e) { if (logging) { log("Failed: getTid()"); } e.printStackTrace(); } if (logging) { log("Return value from getTid(): " + returnValue + "."); } return returnValue; } public String getName() { String returnValue = ""; if (prod_view_searchRemoteObject == null) { System.out.println("Error in getName(): " + ERROR_NULL_REMOTE); return returnValue; } long startTime = 0; if (logging) { log("Calling getName()"); startTime = System.currentTimeMillis(); } try { returnValue = prod_view_searchRemoteObject.getName(); if (logging) { long endTime = System.currentTimeMillis(); log("Succeeded: getName()"); log("Execution time: " + (endTime - startTime) + " ms."); } } catch(Exception e) { if (logging) { log("Failed: getName()"); } e.printStackTrace(); } if (logging) { log("Return value from getName(): " + returnValue + "."); } return returnValue; } public String getSpec() { String returnValue = ""; if (prod_view_searchRemoteObject == null) { System.out.println("Error in getSpec(): " + ERROR_NULL_REMOTE); return returnValue; } long startTime = 0; if (logging) { log("Calling getSpec()"); startTime = System.currentTimeMillis(); } try { returnValue = prod_view_searchRemoteObject.getSpec(); if (logging) { long endTime = System.currentTimeMillis(); log("Succeeded: getSpec()"); log("Execution time: " + (endTime - startTime) + " ms."); } } catch(Exception e) { if (logging) { log("Failed: getSpec()"); } e.printStackTrace(); } if (logging) { log("Return value from getSpec(): " + returnValue + "."); } return returnValue; } public String getModel() { String returnValue = ""; if (prod_view_searchRemoteObject == null) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -