[jboss-user] [EJB3] - Re: Get ear name
Sverker Abrahamsson
do-not-reply at jboss.com
Mon Jan 3 07:53:39 EST 2011
Sverker Abrahamsson [http://community.jboss.org/people/sverker] created the discussion
"Re: Get ear name"
To view the discussion, visit: http://community.jboss.org/message/578341#578341
--------------------------------------------------------------
I did a workaround. In pom.xml the application.finalName property is defined to the name the ear will have and is used in build section finalName tag. I have a mbean which is configured via a *-service.xml file deployed in the ear. In there I have an attribute definition like this:
<attribute name="EarName">${application.finalName}</attribute>
Maven will replace the macro with the property value. Then I have a ServiceLocator singleton class which is used by all clients to lookup the services, it has a method like this:
private static String getEarName() {
if(earName == null) {
// This will lookup the name of the ear from our mbean
MBeanServer mBeanServer = MBeanServerLocator.locateJBoss();
try {
earName = (String) mBeanServer.invoke( new ObjectName("com.limetransit.sms:service=LimeManagement"),
"getEarName",
new Object[] {},
new String[] {}
);
} catch(Exception e) {
e.printStackTrace();
}
}
return earName + "/";
}
May not be the most beautiful solution but it works at least...
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/578341#578341]
Start a new discussion in EJB3 at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2029]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20110103/7e7576b9/attachment.html
More information about the jboss-user
mailing list