wiki/java

Standard set of libs

Executor

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:

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.

Message types

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