fy"> new Session (ByteBuffer.wrap (result.toString (). getBytes ()), session.getChannel ());// Return new Session
}
}com.gmail.dosofredriver.ajax.serviceserver.service.worker;com.gmail.dosofredriver.ajax.serviceserver.server.session.Session;com.gmail.dosofredriver.ajax.serviceserver.server.session.SessionController;com.gmail.dosofredriver.ajax.serviceserver.service.Service;com.gmail.dosofredriver.ajax.serviceserver.util.logger.ServerLogger;java.util.concurrent.ExecutorService;java.util.concurrent.Executors;java.util.concurrent.TimeUnit;java.util.logging.Level;
/ **
* Date: 06.03.13
* Time: 21:04
*
* @ author DoSOfRR
* / class Worker {static final int DEFAULT_POOL_SIZE=8; volatile boolean stopFlag=false; ExecutorService executor; ServerLogger logger; boolean isLogged=false; Worker () {(DEFAULT_POOL_SIZE);
} Worker (int pool_size) {(pool_size);
} void init (int pool_size) {= Executors.newFixedThreadPool (pool_size);
} void start () throws InterruptedException {(isLogged) {. log (Level.INFO, «Worker started.»);
}=false; (! stopFlag) {Session session=SessionController.getInstance (). getSession ();. execute (new Runnable () {
@ Overridevoid run () {{SessionController.getInstance (). response (Service.service (session));
} catch (Exception e) {(isLogged) {. log (Level.SEVERE, «An error occupied while parsing request!», e);. getChannel (). close ();// Note try to use AutoCloseable
}
}
}
});
}
} void stop () throws InterruptedException {= true;. awaitTermination (10, TimeUnit.SECONDS);// Note хуй · н ° ?т поч?му т ° скі р ° ± від ° ющі? висять: (isLogged) {. Log (Level.INFO, «Worker was manually stopped.»);
}
} void setLogger (ServerLogger logger) {(logger == null) {new NullPointerException («Logger can not be null!");
}. logger=logger;=true;
}
} com.gmail.dosofredriver.ajax.serviceserver.service.annotations;
/ **
* This exception for controller implementation error.
* Controller class must be annotated with ServiceClass annotation.
* / class IsNotAnnotatedException extends Throwable {String message; IsNotAnnotatedException () {= «Given class or method is not annotated!»;
} IsNotAnnotatedException (Throwable ex) {(ex);=«Given class or method is not annotated!»;
} IsNotAnnotatedException (String message) {. message=message;
} IsNotAnnotatedException (String message, Throwable ex) {(ex);. message=message;
}
} com.gmail.dosofredriver.ajax.serviceserver.service.annotations;
/ **
* This annotation is used as marker for all methods that should be invoked by
* Service class.