generated from root/miduo_server
海外登录
parent
213e323fc7
commit
c7577dd4d3
|
@ -92,31 +92,10 @@ public class GetUserController extends HttpServlet {
|
||||||
}*/
|
}*/
|
||||||
LOGGER.info("the opendId = {},token={},platform={}",openId,token,platform);
|
LOGGER.info("the opendId = {},token={},platform={}",openId,token,platform);
|
||||||
try {
|
try {
|
||||||
if(!KTSDKConstans.appsecret.equals(admin)){
|
boolean vertify = vertify(response, request, admin, platform, pid, openId, token);
|
||||||
if(isTestLan==1){ //test
|
if(!vertify){
|
||||||
boolean result = loginVerfifyByTestLan(openId, token);
|
|
||||||
if(!result){
|
|
||||||
response.sendError(400, "verify fail");
|
|
||||||
LOGGER.error("test verify fail");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}else if(!"3".equals(platform)){//正式 切不是pc
|
|
||||||
String sub_channel = request.getParameter("sub_channel");
|
|
||||||
boolean result =false;
|
|
||||||
if(sub_channel!=null&&!sub_channel.equals("")){
|
|
||||||
if(sub_channel.equals("1000")){
|
|
||||||
result = loginVerfify(pid, openId, token,MHTSDKConstans.rhappid);
|
|
||||||
}else {
|
|
||||||
result = loginVerfify(pid, openId, token,MHTSDKConstans.rhappidOnline);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!result){
|
|
||||||
response.sendError(400, "verify fail");
|
|
||||||
LOGGER.error("verify fail");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
response.setCharacterEncoding("UTF-8");
|
response.setCharacterEncoding("UTF-8");
|
||||||
response.setContentType("application/json; charset=utf-8");
|
response.setContentType("application/json; charset=utf-8");
|
||||||
DBObject dbObject = new BasicDBObject();
|
DBObject dbObject = new BasicDBObject();
|
||||||
|
@ -159,6 +138,40 @@ public class GetUserController extends HttpServlet {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean vertify(HttpServletResponse response,HttpServletRequest request,String admin,String platform,String pid,String openId,String token){
|
||||||
|
try {
|
||||||
|
if(!KTSDKConstans.appsecret.equals(admin)) {
|
||||||
|
if (isTestLan == 1) { //test
|
||||||
|
boolean result = loginVerfifyByTestLan(openId, token);
|
||||||
|
if (!result) {
|
||||||
|
response.sendError(400, "verify fail");
|
||||||
|
LOGGER.error("test verify fail");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!"3".equals(platform)) {//正式 切不是pc
|
||||||
|
String sub_channel = request.getParameter("sub_channel");
|
||||||
|
boolean result = false;
|
||||||
|
if (sub_channel != null && !sub_channel.equals("")) {
|
||||||
|
if (sub_channel.equals("1000")) {
|
||||||
|
result = loginVerfify(pid, openId, token, MHTSDKConstans.rhappid);
|
||||||
|
} else {
|
||||||
|
result = loginVerfify(pid, openId, token, MHTSDKConstans.rhappidOnline);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!result) {
|
||||||
|
response.sendError(400, "verify fail");
|
||||||
|
LOGGER.error("verify fail");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public void doPost(HttpServletRequest request, HttpServletResponse response)
|
public void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||||
throws ServletException, IOException {
|
throws ServletException, IOException {
|
||||||
this.doGet(request, response);
|
this.doGet(request, response);
|
||||||
|
|
|
@ -0,0 +1,98 @@
|
||||||
|
package com.ljsd.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.ljsd.plat.PlatProcess;
|
||||||
|
import com.ljsd.redis.RedisKey;
|
||||||
|
import com.ljsd.util.BaseGlobal;
|
||||||
|
import com.ljsd.util.HttpUtils;
|
||||||
|
import com.ljsd.util.KTSDKConstans;
|
||||||
|
import com.ljsd.util.MHTSDKConstans;
|
||||||
|
import com.mongodb.BasicDBObject;
|
||||||
|
import com.mongodb.DBObject;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import javax.servlet.ServletException;
|
||||||
|
import javax.servlet.http.HttpServlet;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class GetUserHwController extends GetUserController {
|
||||||
|
private final static String _COLLECTION_NAME = "user_info";
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(GetUserHwController.class);
|
||||||
|
public static int isTestLan=0;
|
||||||
|
|
||||||
|
public static void initLanState(){
|
||||||
|
Properties properties = BaseGlobal.getInstance().properties;
|
||||||
|
isTestLan = Integer.parseInt(properties.getProperty("isTestLan"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public GetUserHwController() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void destroy() {
|
||||||
|
super.destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean vertify(HttpServletResponse response, HttpServletRequest request, String admin, String platform, String pid, String openId, String token) {
|
||||||
|
try {
|
||||||
|
if(!KTSDKConstans.appsecret.equals(admin)) {
|
||||||
|
if (isTestLan == 1) { //test
|
||||||
|
boolean result = loginVerfifyByTestLan(openId, token);
|
||||||
|
if (!result) {
|
||||||
|
response.sendError(400, "verify fail");
|
||||||
|
LOGGER.error("test verify fail");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (!"3".equals(platform)) {//正式 切不是pc
|
||||||
|
boolean result = false;
|
||||||
|
if(platform.equals("1")){
|
||||||
|
String sub_channel = request.getParameter("sub_channel");
|
||||||
|
if (sub_channel != null && !sub_channel.equals("")) {
|
||||||
|
PlatProcess hwios;
|
||||||
|
if (sub_channel.equals("1000")) {
|
||||||
|
hwios = BaseGlobal.getInstance().getHandlers("HWTEST");
|
||||||
|
} else {
|
||||||
|
hwios = BaseGlobal.getInstance().getHandlers("HWGP");
|
||||||
|
}
|
||||||
|
result = hwios.loginVerfify(pid, openId, token);
|
||||||
|
}
|
||||||
|
|
||||||
|
}else if(platform.equals("2")){
|
||||||
|
PlatProcess hwios = BaseGlobal.getInstance().getHandlers("HWIOS");
|
||||||
|
result = hwios.loginVerfify(pid, openId, token);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!result) {
|
||||||
|
response.sendError(400, "verify fail");
|
||||||
|
LOGGER.error("verify fail");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||||
|
throws ServletException, IOException {
|
||||||
|
this.doGet(request, response);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
// boolean mht = loginVerfify("MHT", "2318137", "be385683efe228aadac0c8b5822a6fba");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,75 @@
|
||||||
|
package com.ljsd.plat;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.ljsd.util.HttpUtils;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description: des
|
||||||
|
* Author: zsx
|
||||||
|
* CreateDate: 2020/8/10 16:35
|
||||||
|
*/
|
||||||
|
public abstract class AbstractMHTPlat implements PlatProcess {
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractMHTPlat.class);
|
||||||
|
private String happid;
|
||||||
|
private String appkey;
|
||||||
|
private String name;
|
||||||
|
private String loginVertifyUrl;
|
||||||
|
public AbstractMHTPlat() {
|
||||||
|
init();
|
||||||
|
loginVertifyUrl = " http://interface.18183g.top/interface/user-login/checkLogin";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getVertifyUrl() {
|
||||||
|
return loginVertifyUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean loginVerfify(String channelName, String openId, String token) {
|
||||||
|
try{
|
||||||
|
String loginUrl =getVertifyUrl();
|
||||||
|
Map<String, String> params = new HashMap<String, String>();
|
||||||
|
params.put("sid", token);
|
||||||
|
params.put("appId", getAppkey());
|
||||||
|
params.put("channelId", "MHT");
|
||||||
|
String loginResult = HttpUtils.doPost(loginUrl,params);
|
||||||
|
if(loginResult == null || loginResult.isEmpty()){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return parseLoginResult(loginResult);
|
||||||
|
}catch(Exception e){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAppkey() {
|
||||||
|
return appkey;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static boolean parseLoginResult(String orderResult){
|
||||||
|
try {
|
||||||
|
JSONObject jsonObject = JSONObject.parseObject(orderResult);
|
||||||
|
int state = jsonObject.getIntValue("code");
|
||||||
|
if(state != 200){
|
||||||
|
String content = jsonObject.getString("message");
|
||||||
|
LOGGER.info("parseLoginResult content={}",content);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
package com.ljsd.plat;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.ljsd.util.HttpUtils;
|
||||||
|
import com.ljsd.util.MHTSDKConstans;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description: des
|
||||||
|
* Author: zsx
|
||||||
|
* CreateDate: 2020/8/10 16:35
|
||||||
|
*/
|
||||||
|
public class MHTGPPlat extends AbstractMHTPlat {
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(MHTGPPlat.class);
|
||||||
|
private String rhappid;
|
||||||
|
private String appkey;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "HWGP";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init() {
|
||||||
|
rhappid = "346450436349889";
|
||||||
|
appkey = "02c13b5e54da94aef0150db87b9862bb";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
package com.ljsd.plat;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.ljsd.util.HttpUtils;
|
||||||
|
import com.ljsd.util.MHTSDKConstans;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description: des
|
||||||
|
* Author: zsx
|
||||||
|
* CreateDate: 2020/8/10 16:35
|
||||||
|
*/
|
||||||
|
public class MHTHyTestPlat extends AbstractMHTPlat {
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(MHTHyTestPlat.class);
|
||||||
|
private String rhappid;
|
||||||
|
private String appkey;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "HWTEST";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init() {
|
||||||
|
rhappid = "3192205470869872";
|
||||||
|
appkey = "2c2ab86233c7266e9360b69506734b3f";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
package com.ljsd.plat;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.ljsd.util.HttpUtils;
|
||||||
|
import com.ljsd.util.MHTSDKConstans;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description: des
|
||||||
|
* Author: zsx
|
||||||
|
* CreateDate: 2020/8/10 16:35
|
||||||
|
*/
|
||||||
|
public class MHTIOSPlat extends AbstractMHTPlat {
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(MHTIOSPlat.class);
|
||||||
|
private String rhappid;
|
||||||
|
private String appkey;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "HWIOS";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init() {
|
||||||
|
rhappid = "346450436349889";
|
||||||
|
appkey = "98ea7849bb70a99025dfc58b5f57762b";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.ljsd.plat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description: des
|
||||||
|
* Author: zsx
|
||||||
|
* CreateDate: 2020/8/10 15:59
|
||||||
|
*/
|
||||||
|
public interface PlatProcess {
|
||||||
|
|
||||||
|
void init();
|
||||||
|
|
||||||
|
String getName();
|
||||||
|
|
||||||
|
boolean loginVerfify(String channelName, String openId, String token);
|
||||||
|
|
||||||
|
String getVertifyUrl();
|
||||||
|
|
||||||
|
}
|
|
@ -1,14 +1,16 @@
|
||||||
package com.ljsd.util;
|
package com.ljsd.util;
|
||||||
|
|
||||||
import com.ljsd.controller.GetUserController;
|
import com.ljsd.controller.GetUserController;
|
||||||
|
import com.ljsd.plat.PlatProcess;
|
||||||
import com.ljsd.redis.RedisApp;
|
import com.ljsd.redis.RedisApp;
|
||||||
|
|
||||||
import java.util.Properties;
|
import java.util.*;
|
||||||
|
|
||||||
public class BaseGlobal {
|
public class BaseGlobal {
|
||||||
public Properties properties = new Properties();
|
public Properties properties = new Properties();
|
||||||
public MyMongoDBPool mongoDBPool;
|
public MyMongoDBPool mongoDBPool;
|
||||||
public RedisApp redisApp;
|
public RedisApp redisApp;
|
||||||
|
private Map<String, PlatProcess> handlers = new HashMap<>();
|
||||||
|
|
||||||
private BaseGlobal() {
|
private BaseGlobal() {
|
||||||
}
|
}
|
||||||
|
@ -29,6 +31,49 @@ public class BaseGlobal {
|
||||||
public void init() {
|
public void init() {
|
||||||
mongoDBPool = new MyMongoDBPool();
|
mongoDBPool = new MyMongoDBPool();
|
||||||
redisApp = new RedisApp();
|
redisApp = new RedisApp();
|
||||||
|
initHandler("com.ljsd.plat");
|
||||||
GetUserController.initLanState();
|
GetUserController.initLanState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void initHandler(String pck) {
|
||||||
|
List<Class<?>> handlers = new LinkedList<>();
|
||||||
|
try {
|
||||||
|
try {
|
||||||
|
ClassLoaderHelper.findLocalClass(pck, PlatProcess.class, Thread.currentThread().getContextClassLoader(), handlers);
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
ClassLoaderHelper.findClassJar(pck, PlatProcess.class, Thread.currentThread().getContextClassLoader(), handlers);
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
handlers.forEach(hand ->
|
||||||
|
{
|
||||||
|
PlatProcess baseHandler = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
baseHandler = (PlatProcess) hand.newInstance();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
if (null != baseHandler) {
|
||||||
|
addHandler(baseHandler);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (RuntimeException e2) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addHandler(PlatProcess handler) {
|
||||||
|
if(null!=handler.getName()){
|
||||||
|
handlers.put(handler.getName(), handler);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlatProcess getHandlers(String name) {
|
||||||
|
return handlers.get(name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,162 @@
|
||||||
|
package com.ljsd.util;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.lang.reflect.Modifier;
|
||||||
|
import java.net.JarURLConnection;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.Enumeration;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.jar.JarEntry;
|
||||||
|
import java.util.jar.JarFile;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description: des
|
||||||
|
* Author: zsx
|
||||||
|
* CreateDate: 2019/10/8 17:23
|
||||||
|
*/
|
||||||
|
public class ClassLoaderHelper {
|
||||||
|
|
||||||
|
final static ConcurrentHashMap<String, Class<?>> CLS_CACHE = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
public static Class<?> forName(String clsname) throws ClassNotFoundException{
|
||||||
|
Class<?> cls = CLS_CACHE.get(clsname);
|
||||||
|
if(null == cls){
|
||||||
|
cls = Class.forName(clsname);
|
||||||
|
CLS_CACHE.put(clsname, cls);
|
||||||
|
}
|
||||||
|
return cls;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取指定接口的某个包下的所有实现类(不包括接口和抽象类)
|
||||||
|
*/
|
||||||
|
public static void findLocalClass(String packName, Class<?> classinterface, ClassLoader classLoader, List<Class<?>> classes)
|
||||||
|
{
|
||||||
|
URI url;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
url = classLoader.getResource(packName.replace(".", "/")).toURI();
|
||||||
|
}
|
||||||
|
catch(URISyntaxException e1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
File file = new File(url);
|
||||||
|
file.listFiles((subfile) ->
|
||||||
|
{
|
||||||
|
if(subfile.isDirectory())
|
||||||
|
{
|
||||||
|
findLocalClass(packName + "." + subfile.getName(), classinterface,classLoader,classes);
|
||||||
|
}
|
||||||
|
if(subfile.getName().endsWith(".class"))
|
||||||
|
{
|
||||||
|
Class<?> clazz = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
String classname = packName + "." + subfile.getName().replace(".class", "");
|
||||||
|
clazz = classLoader.loadClass(classname);
|
||||||
|
}
|
||||||
|
catch(ClassNotFoundException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
if(clazz == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(ClassLoaderHelper.filter(clazz, classinterface))
|
||||||
|
{
|
||||||
|
classes.add(clazz);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 过滤接口和抽象类
|
||||||
|
*/
|
||||||
|
public static boolean filter(Class<?> clazz, Class<?> filterclass)
|
||||||
|
{
|
||||||
|
if(clazz.isInterface())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(Modifier.isAbstract(clazz.getModifiers()))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return filterclass.isAssignableFrom(clazz);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* jar包查找
|
||||||
|
*/
|
||||||
|
public static void findClassJar(final String packName, Class<?> classinterface, ClassLoader classLoader, List<Class<?>> classes)
|
||||||
|
{
|
||||||
|
String pathName = packName.replace(".", "/");
|
||||||
|
JarFile jarFile;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
URL url = classLoader.getResource(pathName);
|
||||||
|
JarURLConnection jarURLConnection = (JarURLConnection)url.openConnection();
|
||||||
|
jarFile = jarURLConnection.getJarFile();
|
||||||
|
}
|
||||||
|
catch(IOException |NullPointerException e)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Enumeration<JarEntry> jarEntries = jarFile.entries();
|
||||||
|
while(jarEntries.hasMoreElements())
|
||||||
|
{
|
||||||
|
JarEntry jarEntry = jarEntries.nextElement();
|
||||||
|
String jarEntryName = jarEntry.getName();
|
||||||
|
if(jarEntryName.contains(pathName) && !jarEntryName.equals(pathName + "/"))
|
||||||
|
{
|
||||||
|
if(jarEntry.isDirectory())
|
||||||
|
{
|
||||||
|
String clazzName = jarEntry.getName().replace("/", ".");
|
||||||
|
int endIndex = clazzName.lastIndexOf(".");
|
||||||
|
String prefix = null;
|
||||||
|
if(endIndex > 0)
|
||||||
|
{
|
||||||
|
prefix = clazzName.substring(0, endIndex);
|
||||||
|
}
|
||||||
|
findClassJar(prefix, classinterface,classLoader,classes);
|
||||||
|
}
|
||||||
|
if(jarEntry.getName().endsWith(".class"))
|
||||||
|
{
|
||||||
|
Class<?> clazz = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
clazz = classLoader.loadClass(jarEntry.getName().replace("/", ".").replace(".class", ""));
|
||||||
|
}
|
||||||
|
catch(ClassNotFoundException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
if(clazz == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(filter(clazz, classinterface))
|
||||||
|
{
|
||||||
|
classes.add(clazz);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -80,6 +80,17 @@
|
||||||
<url-pattern>/getUserInfo</url-pattern>
|
<url-pattern>/getUserInfo</url-pattern>
|
||||||
</servlet-mapping>
|
</servlet-mapping>
|
||||||
|
|
||||||
|
<servlet>
|
||||||
|
<servlet-name>getHwUserInfo</servlet-name>
|
||||||
|
<servlet-class>com.ljsd.controller.GetUserHwController</servlet-class>
|
||||||
|
</servlet>
|
||||||
|
|
||||||
|
<servlet-mapping>
|
||||||
|
<servlet-name>getHwUserInfo</servlet-name>
|
||||||
|
<url-pattern>/getHwUserInfo</url-pattern>
|
||||||
|
</servlet-mapping>
|
||||||
|
|
||||||
|
|
||||||
<servlet>
|
<servlet>
|
||||||
<servlet-name>registerUser</servlet-name>
|
<servlet-name>registerUser</servlet-name>
|
||||||
<servlet-class>com.ljsd.controller.UserRegisterController</servlet-class>
|
<servlet-class>com.ljsd.controller.UserRegisterController</servlet-class>
|
||||||
|
|
Loading…
Reference in New Issue