views:

73

answers:

1

Is posible 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|

+5  A: 

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!

Espen
first to anything, thx for your response... and i understand what do you say, but my question is whether it's posible to have a business logic without servlets/JSP/EJB.. i.e. only pojos.i want to have the servlets/JSP(Presentation layer for web browser) in the web server, and on another Server(App Server) the business logic common(Sevice Object,Data access object and domain objects) for be used by Application Client Desktop(directly) and Web browser(through to servlets/jsp)
HenryOS
thank you for reply so soon.so.. to finish.. if i need provide business logic's service to either JSP/Servlets(on Web Servers) or to Application desktop client, the ONLY WAY is to implement web services means servlets and therefore a web container on the app server???
HenryOS