Standard set of libs
- Guava - Google Common Libraries
- slf4j - Simple logging facade for Java
- log4j - Apache Logging Services
- Apache Commons - The Apache Commons
- freemarker - Java Template Engine
- Hibernate - Java ORM Library
- dom4j - Old XML Library
Executor
Notes
A way to embed clean up operations into long running systems.
Runtime.getRuntime().addShutdownHook(Thread)
HttpServlet
What is the lifetime/timeline of a HttpServlet?
It seems as if the lifetime is dependent on the web container. Tomcat is different from WebSphere for example.
It is possible to spawn services via
<servlet>
<servlet-name>Master Servlet</servlet-name>
<servlet-class>com.example.ServiceSpawn</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
ArrayBlockingQueue
Perform an experiment with the ArrayBlockingQueue.
How would the mechanism be used to implement:
- Synchronous Service Processes
- Asynchronous Event Processes
- Supervisor Processes
All concurrent processes would have its own queue that would be able to receive responses if a process thread, a request if a service thread, or a message if an event thread.
Supervisor threads are a special type of event thread. The concept is that if a subordinate worker (event or service) thread crashes or has any information to relay then a message would just be sent to the supervisor and the appropriate action would be taken.
- Exit on subordinate crash
- Respawn on subordinate crash
- Log message
Message types
put()for event receiversput(timeout)for service receivers?poll()when receiving eventspoll(timeout)when receiving responses
Process class would be an extension of the Runnable interface.
class Process extends Runnable {
protected Thread thread;
protected BlockingQueue<Message> queue;
protected Process supervisor;
};
Simple Java Framework for Tomcat
What would be the components of a simple Java MVC framework?
Notes
ServerSocket the accept()ing socket
Socket the connect()ing socket
StringBuffer quickly append string fragments
BufferedReader get readLine()
InetSocketAddress build connection/bind address
java.nio.ByteBuffer general purpose buffer