⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 servletlocator.java

📁 该HttpProxy用于从Applet或Swing界面中访问Ejb和服务端的JavaBean。
💻 JAVA
字号:
/**
 * @作者: 胡俊
 * @创建时间: 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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -