Sparrowcontainer is a pure Java Application Server that for real-time application. It provides a Thread Pooling framework for your resources to minimize the impact of garage collection. You can implement your long, timely logic into Thread to minimize your request response time and maximize the throughput of your application. This version has a simple HTTP stack for web services or XML/HTTP that implement the Thread Pooling Model for prove of concept.
I built this container is because I faced a challenge in the past. In one of my past project in a company, I need to design and implemented a Proxy Server as a real time application. The application received request XML/HTTP, do some logic and immediate proxy the request to another server. The basic requirement of the Proxy Server is 20 req/sec and non-stop running 24x7. During that period, I use the traditional J2EE technology, I choose Tomcat + JBoss at the beginning and use the common design architecture: Servlet->Stateless Session Bean->Message Driven Bean. The application is fine when run for few minutes, but when my client did the load test. The application stopped response periodically by Garage Collection. During Garage Collection, the hundred of HTTP Request is stuck up and Tomcat CRASH with "OutofMemoryException". I then change to use Jetty+Jboss, the situation is better at least Jetty will not crash when the Http Server is overloaded. However, my client was very dissatisfactory on the periodically stop of application by Garage Collection. I tried to use pooled my application object as much as I can or use static method for stateless logic, the situation is slightly better but the stop still come out around every 5 minutes. I and my client finally only accept this kind of performance fluctuation because we cannot find out a short cut to solve this situation at that moment. Recently, I have read 2 books "Expert One-on-One J2EE Development without EJB" and adapt springframework into company project and I thanks to springframework to bring up my mind to do this project. I found that my past project actually is a simple stateless HTTP request with high throughput and I actually not need a complicate Application Server. What I need is a simple small foot prints Http Stack, a pooling framework and some other database connectivity and is fulfilled my client expectation. Also my client do not know to spend money in Giga byte of memory as they will ask why you not use C in your project and why use Java. C is most case use less memory and most Java Application Server ask you for Giga byte of memory to diversified the effect of Garage Collection.
1. You only need a Simple HttpServer and your request is stateless or no session related.
2. You have many very long and timely business and you want to run in different Thread to decrease your response time
and maximum your server throughput
3. You cannot offer Giga byte of memory on your hardware
4. You want to minimize the impact of Garage Collection or you implement a real-time application that not allow stop
5. You can to take the challenge with me :-p
1. You request is session related.
2. Your application needs Servlet/J2EE compliance.
3. You not sure your logic can run tidy under Threading environment.
4. Your application is tightly couple with existing application server / framework.
5. Your Project Team Leader not allow you use new Technology.
1. ThreadModel: This is simple Thread Model. You purely extends ThreadModel and override execute(). The container will use the pooled Thread to run your logic. The steps is simple. First, implement your Object as method above, then use org.sparrowcontainer.core.thread.DefaultBeanFactoryBuilder and initThreadPool according to your need. The factory for individual Object class is only need to init Once. Then you can use org.sparrowcontainer.core.thread.BeanFactory to get the pooled Object. The container will self retain the Object back to pool after execute()
2. AsyncThreadModel: This is similar to ThreadModel. You purely extends AsyncThreadModel and override executeRetur(). The main different to ThreadModel is AsyncThreadModel can return an Object after executeReturn(). You can an Object return after executeRetur() by getReturn(). During, execute time of executeReturn(), the can implement your other business logic and then finally use getReturn() to hook back the result returned from the AsyncThreadModel. The implementation steps is same as ThreadModel but you must use getReturn() to trigger to get back the return Object and the container use this as the trigger to return the Object and Thread back to pool
3. Callback and CallbackSubscriber: You can add a Callback into above models to notify your logic once the Thread is completed running. If you have many Threads and Callbacks, you can subscribe a CallbackSubscriber into the Callback as a central point to manage those Callbacks has been notified.
The sparrowcontainer has implmeneted a simple HTTP Stack for your HTTP based application. The design is very alike Servlet format and erase of use. 1. A web.xml to provide your Http implementation class definition and URL pattern. The Http naming is http://ip:port/applicationCtx/url-pattern. The applicationCtx is the name of your war file trimmed the ".war". 2. sparrow-web.xml for you to configure the pooling instance of the Http Implementation class 3. Jar your application like J2EE servlet war file into "yourapp.war" and put into the deploy folder and can run. "yourapp" will be the applicationCtx of your application
The JAR distributable should be placed in the classpath of the application
Example: run.bat