aspose file tools*
The moose likes Servlets and the fly likes Describe Rishi's problem in detail Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Describe Rishi Watch "Describe Rishi New topic
Author

Describe Rishi's problem in detail

roshan ingole
Greenhorn

Joined: Aug 18, 2001
Posts: 12
Hello Friends ...
Here I want to discuss about one architecture and some problems related to this.

This Architecture is very Similar to Front Contoller. http://java.sun.com/j2ee/blueprints/design_patterns/index.html from this link you will get detail information of this architecture.
I am going to describe this architecture which we are using ....

<-Presentation Tier->|<----Business Logic Tier ---->|<--DB Tier->
client(s)----------->|MainServlet-->java class(s)-->|DBServer
According to above fig.
I. In this architecture we are using only one servlet, and main functionality of this servlet is Authorization, Authentication, Serverside Validation and if all conditions are get satisfied then it allows to call respected java classes.
Means by creating Instances of all those.
II. Here one thing is that all Business logic is in Java classes and logics related to Controller like Session Management, Connection Pooling, Logging are in MainServlet.
III.MainServlet is act as a Gateway to this web application.
IV. Here some java classes are also present, which will act as interface between Application and DB. And some for logging information, and some for generating Template (mainly for patching purpose).
Now after seeing this type of Architecture you may have some queries in mind, those may be
1. Why only one servlet, and why to use remaining all Java classes, if there is a facility just like Servlet Chaining or Servlet despatcher provided by Servlet itself?.
<ANS> I suppose it is due to maintainance under consideration. And also to get Basic Functionality of OOPs.
2. Why there is need of GATEWAY?
<ANS> It gives me very controlled hold on application, as session management carried out in one and only one servlet, I don't have to manage all sessions in all servlets, if in case I am using those instead of java classes.
Again all Authentication code and Authorization code is present in GATEWAY I don't require to write it again in all servlet to check authorization. If I keep all servlets instead of Java classes and if I remove that GATEWAY, then I have to write same code again and again.
2. Ok now here some queries from my side ...
[FIRST] If I have only one servlets and in that to get the functionality from all classes I require their instances .... so question arises here in three ways with the context of instance of those classes ..
*** If I create those instances in init() method of servlet then that instance is globally available. But in case of multithreading this case is not feasible. Because to control concurrent request from more than one thread to instance variables of that object, I have to make it Synchronize. Then only one thread can use it at a time, and another have to wait, which is not feasible in case of Web Application b'cos may be it affects performance.
*** So another way is to make the instance in doGet or doPost. Due to this for each thread one instance will be created. Each time for each request to create a instance what will be the case related to performance, I don't know.
*** To avoid this to create instance for each request, I can keep pool for those instances, just like we generally did in connection pool.
##These all are points, which are in my mind. But friends I want to know one thing is that in this Architecture if I will use Servlets instead of Java classes and keeping GATEWAY as it is, then where it will be advantageous and why?
##Either am I loosing some functionality which Servlet provides me and this architecture will not able to give those?
##What will be the effect on Performance, Scalability, Portability.
##If in future I want to go for Multiple Application Servers or Distributed Application then either this is good choice, or what kind of changes I have to make in this applicaion?
##What will be the case with MainServlet(GATEWAY)-->SubGateways(which are servlets)-->*.Java Classes, this kind of architecture?
I need all kind of suggestions related to this architecture, I hope techies definitely come with a good solution...
-Roshan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Describe Rishi's problem in detail