开发者

Implement the business logic in an app server with spring

Is posibl开发者_StackOverflow社区e implement the business logic in an App Server remote using pojos instead of either EJB or Servlets???. The main idea is apply a model of 3 layers where the clients may be both web browsers and desktop applications, and they share the business logic in an App Server.

this would be the architecture

browser----- >Web Server -------->|App Server(Business Logic common)|------->|RDBMS common|

desktop App(Swing for example)->|App Server(Business Logic common)|------->|RDBMS common|


You can use Spring instead of EJBs. And I recommend it!

But both alternatives will handle enterprise features such as transaction handling and security for you in an excellent way.

Using Spring or not, you still need a Servlet container for your web pages. The Servlet container can start the Spring container if you configure the Servlet container's web.xml file correct.

A transaction handling example with Spring:

@Transactional
public void execute(..) {..}

And with EJB 3.x:

@TransactionAttribute
public void execute(..) {..}

As you see, both alternatives offers you to add enterprise features declaratively.

Updated after reading HenryOS's comment:

It's possible to have all the business logic on one server.

One solution can be to use Web Services between the clients (WEB server and the fat Swing clients). It's a quite nice and loosely coupled solution.

If you need more speed, you can consider using Google's Protocol Buffer or similar technology instead.

An interesting thing is that with Web Services or Protocol Buffer, you still need a web container like Tomcat or Jetty on the server with business logic, since it must provide the web services for the clients. All Web Services frameworks like Spring WS, CXF and Apache Axis 2 uses a Servlet.

When it comes to layers, I will recommend two layers on the WEB server, since you only present and retrieve data before sending it to the business server. On the business server I will recommend three layers. The top layer to handle Web Services, business layer in the middle and an integration layer against the database and other enterprise systems at the bottom.

Finally, if you're using CXF or Spring WS together with JAXB, then all your classes on the business server can be written as POJOs! It applies to several other well written Web Service frameworks as well.

I hope this answers your question!

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜