/** * Entry point from the service wrapper - starts a connection handler for a given client. * * @param userName the user name of the incoming connection * @param inputPipeName the pipe created for sending data from C++ to Java * @param outputPipeName the pipe created for sending data from Java to C++ * @param languageID the identifier of the bound language. Language specific factories will be * used if present, otherwise the default factories will be used. * @param debug true if the bound language is a debug build * @return true if the connection started okay */ public static synchronized boolean svcAccept( final String userName, final String inputPipeName, final String outputPipeName, final String languageID, final boolean debug) { try { s_logger.info("Accepted {} connection from {}", languageID, userName); s_logger.debug("Using pipes IN:{} OUT:{}", inputPipeName, outputPipeName); final Pair<ClientFactory, SessionContextFactory> factories = s_springContext.getLanguageFactories(languageID); final SessionContext sessionContext = factories.getSecond().createSessionContext(userName, debug); final Client client = factories.getFirst().createClient(inputPipeName, outputPipeName, sessionContext); s_activeConnections++; s_executorService.submit( new Runnable() { @Override public void run() { client.run(); s_logger.info("Session for {} disconnected", userName); clientDisconnected(); } }); return true; } catch (Throwable t) { s_logger.error("Exception thrown", t); return false; } }
/** * Entry point from the service wrapper - stops the service. * * @return true if the service stopped cleanly */ public static boolean svcStop() { try { s_logger.info("Waiting for client threads to stop"); s_executorService.shutdown(); s_executorService.awaitTermination(Long.MAX_VALUE, TimeUnit.MILLISECONDS); s_logger.info("Stopping application context"); s_springContext.stop(); s_logger.info("OpenGamma Language Integration service stopped"); return true; } catch (Throwable t) { s_logger.error("Exception thrown", t); return false; } }