简体   繁体   中英

how to access method from one ear to another ear on same app server

i have deployed two EARs on one server. i want to access one method in one java class in EAR to another java class in second EAR.

what are different ways to achieve this. which one is best way to do.

Thanks

I would simply use a Stateless Session Bean to expose this method to another (remote) Java application.

Exposing your method as a web serices would also work... but I don't really see the point of using web services between two Java applications. The marshalling of objects to XML and of XML to objects would consume CPU cycles for nothing if there is no need for a language agnostic protocol (which is the case between two Java applications).

Expose it as a web service and consume it in the other app.

Your application server may allow sharing the JNDI context, and thus you can obtain the required class by JNDI lookup, but I wouldn't recommend. This would mean your two ears will have to always live within the same app server (or cluster).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM