开发者

How to access deploy information of my EAR

开发者 https://www.devze.com 2023-02-13 09:02 出处:网络
HI, I am deploying an EAR file into my JBOSS 5.1. I want to be able to access the EAR application name which is stored in the deployment file \"application.xml\" under \'display-name\'.

HI,

I am deploying an EAR file into my JBOSS 5.1. I want to be able to access the EAR application name which is stored in the deployment file "application.xml" under 'display-name'.

I want to deeploy an admin-webapp how read this information and display all module deployed of my EAR

I think application.xml it's the correct place to search this information开发者_如何转开发...

I tryed:

InputStream in = new MyController().getClass().getResourceAsStream("META-INF/application.xml");

but dont work! return null...

Suggestion? (code please)


Add slash in the beginning of your path:

InputStream in = new MyController().getClass().getResourceAsStream("/META-INF/application.xml");

It should work.

But I think that better solution is to use JMX. It provides you higher level API to access the app server resources including deployed applications. The disadvantage of this approach is that I am afraid that your code will be JBoss specific.


I solved :

    ClassLoader loader = getClass().getClassLoader();
    URL url = loader.getResource("META-INF/application.xml");
    BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
    while (true) {
        String line = reader.readLine();
        System.out.println(line);
        if (line == null) {
            break;
        }
    }

In this way I solved the problem and I print content for sample...

but I search an highlevel API to access the app server resources...

What's best way?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号