Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DAO on different application server

I'm developing a new application based on Spring MVC and Hibernate for data access. I want the data access layer to be running on a separate application server, preferably JBOSS.

I want the data access layer to be running behind a firewall.

How can I achieve this?

Right now I'm concerned about hibernate lazy initialization in this scenario. Would there really be any problems with Hibernate lazy initialization?

like image 530
varun Avatar asked Mar 19 '13 06:03

varun


2 Answers

There could be some performance penalties to this approach - the IO will be a bottleneck. However, Spring Remoting allows you to easily achieve this.

  • Create an interface for you DAO.
  • Implement the concrete implementation.
  • Use spring remoting to export the interface.
  • Inject the interface - from your apps point of view its just something that implements the interface. It doesn't care the the calls are being fired off to the remote server.

The mechanism for achieving this is called DynamicProxies - a Java SE feature. DynamicProxies allow you to provide a class that responds to the method calls on an interface at runtime. In this case the method calls are dispatched across to the corresponding methods on the remote server.

Both the service layer and DAO layer servers should be behind the firewall on the same domain.

like image 66
Jasper Blues Avatar answered Nov 16 '22 17:11

Jasper Blues


From the UI, use REST web services to fetch the data from application server (hosting the DAO's and Transactional services). Annotate the entity classes with @Proxy(lazy=false) to avoid lazy loads of entities. For the server to validate the clients (web application querying the business layer behind firewall), use client identity certificates, you can use Bouncy Castle CMS APIs to validate the identity, trust and message integrity. If you have SSL offloaders in network, use detached signatures in http(s) headers.

like image 1
maggu Avatar answered Nov 16 '22 16:11

maggu