servletlocator.java

来自「该HttpProxy用于从Applet或Swing界面中访问Ejb和服务端的Ja」· Java 代码 · 共 94 行

JAVA
94
字号
/**
 * @作者: 胡俊
 * @创建时间: 2008-03-05
 * @更新时间: 2008-03-05
 * @描述: 
 * 
 */
package com.nari.pmos.proxy.client;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;

/**
 * @author hujun
 * 
 * TODO To change the template for this generated type comment go to Window -
 * Preferences - Java - Code Style - Code Templates
 */
public class ServletLocator {
	private String httpURL = "";

	private String jsessionID = "";

	private String usrAccount = "";

	private String usrPwd = "";

	public String getUrl() {
		return httpURL;
	};

	public void setUrl(String url) {
		this.httpURL = url;
	};

	public void setUsrAccount(String account) {
		usrAccount = account;
	};

	public void setUsrPwd(String pwd) {
		usrPwd = pwd;
	};

	public void setHttpURL(String httpURL) {
		this.httpURL = httpURL;
	}

	public void setJsessionID(String jsessionID) {
		this.jsessionID = jsessionID;
	}

	// =========================================================
	// 创建ejb代理(兼容旧版本)
	public Object locateProxy(Class classInterface) throws Exception {
		return locateEjb(classInterface);
	}

	// 创建ejb代理
	public Object locateEjb(Class classInterface) throws Exception {
		// 创建句柄
		InvocationHandler handler = new HttpProxyHandler(classInterface,
				jsessionID, "ejb", httpURL, usrAccount, usrPwd);

		// 创建远程代理
		Object proxy = Proxy.newProxyInstance(classInterface.getClassLoader(),
				new Class[] { classInterface }, handler);
		return proxy;
	}

	public Object locateBean(Class classInterface) throws Exception {
		// 创建句柄
		InvocationHandler handler = new HttpProxyHandler(classInterface,
				jsessionID, "bean", httpURL, usrAccount, usrPwd);

		// 创建远程代理
		Object proxy = Proxy.newProxyInstance(classInterface.getClassLoader(),
				new Class[] { classInterface }, handler);

		return proxy;
	}

	public Object locateFrameBean(Class classInterface) throws Exception {
		// 创建句柄
		InvocationHandler handler = new HttpProxyHandler(classInterface,
				jsessionID, "frm_bean", httpURL, usrAccount, usrPwd);

		// 创建远程代理
		Object proxy = Proxy.newProxyInstance(classInterface.getClassLoader(),
				new Class[] { classInterface }, handler);

		return proxy;
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?