See: Component Descriptions
- Socket Server Wrapper Library - The "kernel" class of the Sambuca Framework (SambucaHttpServer.java) HAS_A reusable
ServerSocket wrapper object of class SocketServer. This class wraps all low level Server Socket operations leveraging a single
thread to "poll" sockets that are ready to be read from using Socket Channels. When a Socket is ready to be read from
the Socket Server's "main" thread passes it to a Pool of Worker Threads (See Worker Pool Library). When a worker is available
it will process the socket's incoming data and also provide the execution thread to perform any Server Side Processing which may or
may not produce writes by the server on the Socket, sending data back to the client.
- Worker Pool Library - The Worker Pool Library (Main Class is WorkerPool.java) is an abstraction around Threads (a thread pool)
using Semaphores. Each "worker" in the pool is considered a resource. The Worker itself (Worker.java) is an interface.
Users of the Worker Pool MUST implement their own Worker class which will be used by a worker thread once it is obtained from the Worker Pool
for Processing. In the case of the Socket Server Wrapper Library, there is a Socket Worker implementation which performs basic work on a socket.
- Socket Worker Implementation - The Socket Worker (SocketWorker.java) is an implementation of the Worker.java interface. Since the
Socket Server Wrapper Library is a generic Socket wrapper framework, the Socket Worker actually does not do much processing at all. It simply
acts as the execution entry point for processing a "read event" from a socket. The actual "business logic" is performed
by the Socket Processor Implementation.
- Socket Processor - A Socket Processor (SocketProcessor.java) is an interface which is MUST be implemented by the user of the
Socket Server Wrapper Library. It contains methods which the Socket Worker will call to perform actual "business logic" upon
a "read event" on a Socket.
- HTTP Socket Processor - The HTTP Socket Processor is a Socket Processor (SocketProcess.java) class implementation. In the case of the
Sambuca HTTP Server the implementation of the Socket Process is actually an HTTP Protocol based processing class (SambucaHttpServerProcessor).
The primary job of this class is to process incoming HTTP Requests an create SambucaHttpRequest and SambucaHttpResponse objects
(See HTTP Request and HTTP Request descriptions respectively for more information) which will be passed to the User Defined Service Handler
implementation for HTTP Request "business logic" processing (See Service Handler Interface and User Defined Service
Handler for more information).
- HTTP Request - The HTTP Request class (SambucaHttpRequest.java) is a data structure which wraps an incoming HTTP Request. It is similar to a
HttpServletRequest in the Java Servlet/JSP framework but the Sambuca implementation is much more basic at this time.
- HTTP Response - The HTTP Response class (SambucaHttpResponse.java) is an object which wraps a Socket for writing a response to
the client which initiated a corresponding HTTP Request.
- Service Handler Factory - The Service Handler Factory (ServiceHandlerFactory.java) is an interface that users of the Sambuca
Framework MUST implement and pass to their instance of the Sambuca HTTP Server (SambucaHttpServer.java) setHandlerFactory(ServiceHandlerFactory) method.
Class implementing this interface have only one job to perform, which is to correctly instanicate instances of the User Defined Service Handler
Implementation whenever the Sambuca HTTP Server requires one. Note: For performance considerations, Service Handler implementations should NOT
be singletons.
- Service Handler Interface - The Service Handler Interface (ServiceHandler.java) is the interface who's class implementations
are returned to the Sambuca Http Server by the Service Handler Factory. The implementation of a Service Handler contains the
"business logic" or at least the entry point of the business logic that will be executed by the HTTP Socket Processor once
a complete incoming HTTP Request is read and parsed off the network.
- User Defined Service Handler - User Defined Service Handler implementations contain all the "business logic"
for processing incoming HTTP Requests received by the Sambuca HTTP Server. The Sambuca HTTP Framework comes packaged with a demo
User Defined Service Handler implementation which acts as a Simple File based Web Server (SimpleDirServiceHandler.java) The SimpleDirServiceHandler
Service Handler implementation and corresponding Service Handler Factory (SimpleDirServiceHandlerFactory.java) and the "main" class
(SambucaHttpServerDemo.java) can be used to demo the Sambuca HTTP Server Framework.