How to get all classpath

4 views
Skip to first unread message

jokoul webster

unread,
Feb 3, 2010, 11:30:50 AM2/3/10
to impala...@googlegroups.com
Hi Phil:
      For some reason,I wanna get all classpath of current application,for example,if I run from -Host module with Jetty,I wanna get all third-party jars and every module "bin" directories,and if I run my application with a war,I wanna get all third-party jars in WEB-INF/lib and WEB-INF/modules directory,in my previous projects I like to use BSH(bsh-1.3.0.jar) to iterate my classpath to get what I want,so if I use Impala which method or class could help me.thanks.
 
JK.Webster

Phil Zoio

unread,
Feb 3, 2010, 12:15:56 PM2/3/10
to impala...@googlegroups.com
Hi Jokoul

For web applications, try:

ModuleManagementFacade moduleManagementFacade =
WebServletUtils.getModuleManagementFacade(servletContext);
ModuleLocationResolver resolver =
moduleManagementFacade.getModuleLocationResolver();

final Application currentApplication =
moduleManagementFacade.getApplicationManager().getCurrentApplication();
final Set<String> moduleNames =
currentApplication.getModuleStateHolder().getRuntimeModules().keySet();

for (String moduleName : moduleNames) {

System.out.println(resolver.getApplicationModuleClassLocations(moduleName));
}

For standalone apps/tests: replace the first line with

ModuleManagementFacade moduleManagementFacade =
Impala.getFacade().getModuleManagementFacade();

Can't add anything extra with the third party locations though, as
Impala does not know anything about these, except that they are on the
classpath.

Cheers,
Phil

Reply all
Reply to author
Forward
0 new messages