六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 68|回复: 0

Customized Utility 2: JarClassSearcher

[复制链接]

升级  82%

9

主题

9

主题

9

主题

童生

Rank: 1

积分
41
 楼主| 发表于 2013-2-4 14:24:44 | 显示全部楼层 |阅读模式
      In some occasion we offen need to know a Class belongs to which jar in lots of jars, for example: if we want to know org.jboss.security.SecurityAssociation refered jar under JBOSS_HOME, we all know there are quite a lot number of jars existed in JBOSS_HOME, So it's obviously impossiable to do this work manually. JarClassSearcher can help us to complete this work automatically.
 
Functionality:
      JarClassSearcher utility can help you find a Class belongs to which jars, the jars position you should defined through JarClassSearcher.xml's 'searcher.folder' attribute, the Class name which you want to search you also need to define in JarClassSearcher.xml file.  The search result can be show both Console and File(Opational).
 
Utility Consists:
      JarClassSearcher consists of Three part:
      1. Runnable lib folder(contain all jar files);
      2. Configuration file(JarClassSearcher.xml) ;
      3. Executable script file both Windows and Linux(run.cmd and run.sh).
the figure below has a detailed instrcution.

 JarClassSearcher.xml contains three attributes:
 
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"><properties><entry key="searcher.folder">C:\\jboss-eap-4.3\\jboss-as</entry><entry key="searcher.class">org.jboss.security.SecurityAssociation</entry><entry key="result.file">true</entry></properties>       searcher.folder: the jars folder
       searcher.class: class name you what to search
       result.file: whether save the search result to file.
 
How to use?
      I will implement this section with the purpose of solving s problem. at the beginning I will give the problem first, in http://kylinsoong.iteye.com/blog/1019829 part two, when EJB  our Client(J2SE environment) Look up Remote Service, throw a error:java.lang.NoSuchMethodError, to solve this problem we should know class 'org.jboss.security.SecurityAssociation' exists which jars first. so JarClassSearcher on his way.
1. Use a file editor tool to editor JarClassSearcher.xml to define the folder all jars exists, the class name we want to search, whether need to save to file, the belows show the jars folder is JBOSS_HOME, the class name is 'org.jboss.security.SecurityAssociation' , we need to save the result to file. 

 2. Start a command line, navigate to JarClassSearcher folder and execute 'run.cmd' if you are in Windows system;

 3. check the result:

 the result also can be found in file

 the result show org.jboss.security.SecurityAssociation has been found 5 times, and position as result showed.
 
Supplement Claims:
      JarClassSearcher.xml searcher.class attribute also support other pattern, if we want to search  org.jboss.security.SecurityAssociation, we can set the searcher.class as following:
org.jboss.security.SecurityAssociation.javaorg.jboss.security.SecurityAssociation.classorg/jboss/security/SecurityAssociationorg\jboss\security\SecurityAssociationSecurityAssociationSecurityAssociation.javaSecurityAssociation.class no matter which formats you have set, the result is the same.
 
Ending
      The attached file 'JarClassSearcher.rar' contain both JarClassSearcher utility and src code.  
 
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表