You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by th...@apache.org on 2011/12/08 15:45:38 UTC
svn commit: r1211916 -
/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/server/Server.java
Author: thomasm
Date: Thu Dec 8 14:45:38 2011
New Revision: 1211916
URL: http://svn.apache.org/viewvc?rev=1211916&view=rev
Log:
Removing trailing spaces
Modified:
jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/server/Server.java
Modified: jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/server/Server.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/server/Server.java?rev=1211916&r1=1211915&r2=1211916&view=diff
==============================================================================
--- jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/server/Server.java (original)
+++ jackrabbit/sandbox/microkernel/src/main/java/org/apache/jackrabbit/mk/server/Server.java Thu Dec 8 14:45:38 2011
@@ -40,26 +40,26 @@ public class Server {
/** java.net.ServerSocket's default backlog size. */
private static final int BACKLOG = 50;
-
+
private final ServerSocketFactory ssFactory;
-
+
private AtomicReference<MicroKernel> mkref;
-
+
private AtomicBoolean started = new AtomicBoolean();
-
+
private AtomicBoolean stopped = new AtomicBoolean();
-
+
private ServerSocket ss;
-
+
private ExecutorService es;
-
+
private int port;
-
+
private InetAddress addr;
-
+
/**
* Create a new instance of this class.
- *
+ *
* @param mk micro kernel
*/
public Server(MicroKernel mk) {
@@ -69,17 +69,17 @@ public class Server {
/**
* Create a new instance of this class.
- *
+ *
* @param mk micro kernel
*/
public Server(MicroKernel mk, ServerSocketFactory ssFactory) {
this.mkref = new AtomicReference<MicroKernel>(mk);
this.ssFactory = ssFactory;
}
-
+
/**
* Set port number to listen to.
- *
+ *
* @param port port numbern
* @throws IllegalStateException if the server is already started
*/
@@ -89,7 +89,7 @@ public class Server {
}
this.port = port;
}
-
+
/**
* Set bind address.
*/
@@ -99,10 +99,10 @@ public class Server {
}
this.addr = addr;
}
-
+
/**
* Start this server.
- *
+ *
* @throws IOException if an I/O error occurs
*/
public void start() throws IOException {
@@ -111,14 +111,14 @@ public class Server {
}
ss = createServerSocket();
es = createExecutorService();
-
+
new Thread(new Runnable() {
public void run() {
accept();
}
}, "Acceptor").start();
}
-
+
void accept() {
try {
while (!stopped.get()) {
@@ -133,18 +133,18 @@ public class Server {
/* ignore */
}
}
-
+
private ServerSocket createServerSocket() throws IOException {
return ssFactory.createServerSocket(port, BACKLOG, addr);
}
-
+
private ExecutorService createExecutorService() {
return Executors.newFixedThreadPool(10);
}
-
+
/**
* Process a connection attempt by a client.
- *
+ *
* @param socket client socket
*/
void process(Socket socket) {
@@ -155,7 +155,6 @@ public class Server {
}
HttpProcessor processor = new HttpProcessor(socket, new Servlet() {
- @Override
public void service(Request request, Response response)
throws IOException {
Server.this.service(request, response);
@@ -172,10 +171,10 @@ public class Server {
e.printStackTrace();
}
}
-
+
/**
* Service a request.
- *
+ *
* @param request request
* @param response response
* @throws IOException if an I/O error occurs
@@ -187,10 +186,10 @@ public class Server {
FileServlet.INSTANCE.service(request, response);
}
}
-
+
/**
* Return the server's local socket address.
- *
+ *
* @return socket address or <code>null</code> if the server is not started
*/
public InetSocketAddress getAddress() {
@@ -199,7 +198,7 @@ public class Server {
}
return (InetSocketAddress) ss.getLocalSocketAddress();
}
-
+
/**
* Stop this server.
*/
@@ -222,16 +221,16 @@ public class Server {
}
}
}
-
+
public static void main(String[] args) throws Exception {
if (args.length == 0) {
- System.out.println(String.format("usage: %s microkernel-url [port] [bindaddr]",
+ System.out.println(String.format("usage: %s microkernel-url [port] [bindaddr]",
Server.class.getName()));
return;
}
-
+
MicroKernel mk = MicroKernelFactory.getInstance(args[0]);
-
+
final Server server = new Server(mk);
if (args.length >= 2) {
server.setPort(Integer.parseInt(args[1]));
@@ -242,7 +241,7 @@ public class Server {
server.setBindAddress(InetAddress.getByName(args[2]));
}
server.start();
-
+
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
public void run() {
server.stop();