`
kylinsoong
  • 浏览: 236148 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

Customized Utility 2: JarClassSearcher

阅读更多

      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.java
org.jboss.security.SecurityAssociation.class
org/jboss/security/SecurityAssociation
org\jboss\security\SecurityAssociation
SecurityAssociation
SecurityAssociation.java
SecurityAssociation.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.  

 

  • 大小: 8.9 KB
  • 大小: 8.1 KB
  • 大小: 4.2 KB
  • 大小: 8.9 KB
  • 大小: 7.7 KB
0
5
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics