Пример #1
0
 /**
  * Creates a new instance of ImapServer
  *
  * @param port The port server will connect to.
  * @param address The address the server will bind to.
  * @param request The request class that will handle the in bound requests.
  */
 public TCPServer(int port, String address, Class request) throws ServerException {
   this.port = port;
   this.address = address;
   this.request = request;
   try {
     Configuration config = ConfigurationFactory.getInstance().getConfig(TCPServer.class);
     tcpTimeout = config.getLong(TCP_TIMEOUT, DEFAULT_TCP_TIMEOUT);
   } catch (Exception ex) {
     log.error(
         "Failed to setup a tcp server ["
             + port
             + "]["
             + address
             + "] because : "
             + ex.getMessage(),
         ex);
     throw new ServerException(
         "Failed to setup a tcp server ["
             + port
             + "]["
             + address
             + "] because : "
             + ex.getMessage(),
         ex);
   }
 }
Пример #2
0
  /** Creates a new instance of Main */
  public Runner() throws CoadException {
    // Validate the class loader
    System.out.println("Check the class loader");
    if (!(this.getClass().getClassLoader() instanceof com.rift.coad.BaseClassLoader)) {
      log.error("Invalid class loader");
      System.exit(-1);
    }
    System.out.println("Try and init");
    try {
      Configuration config = ConfigurationFactory.getInstance().getConfig(Runner.class);

      // instanciate the user permissions
      log.info("Init the master class loader");
      MasterClassLoader.init();

      // instanciate the user permissions
      log.info("Init thread permissions");
      permissionContainer = new ThreadsPermissionContainer();
      ThreadsPermissionContainerAccessor.init(permissionContainer);
      log.info("Init session manager");
      SessionManager.init(permissionContainer);
      log.info("Init user store");
      userStoreManager = new UserStoreManager();
      UserStoreManagerAccessor.init(userStoreManager);
      log.info("Init user session manager");
      sessionManager = new UserSessionManager(permissionContainer, userStoreManager);
      sessionManager.startCleanup();
      UserSessionManagerAccessor.init(sessionManager);
      log.info("Init login module");
      LoginManager.init(sessionManager, userStoreManager);

      // add a user to the session for the current thread
      log.info("Init roles");
      RoleManager.getInstance().startBackgroundThread();

      // setup a default user for the current thread
      log.info("Init the default user for the runner");
      Long threadId = new Long(Thread.currentThread().getId());
      permissionContainer.putSession(
          threadId,
          new ThreadPermissionSession(
              threadId, userStoreManager.getUserInfo(config.getString(RUNNER_USER))));

      // instanciate the thread manager
      log.info("Init thread group");
      threadGroup = new CoadunationThreadGroup(sessionManager, userStoreManager);

      // init the interceptor factory
      log.info("Init the interceptor factory");
      InterceptorFactory.init(permissionContainer, sessionManager, userStoreManager);

      // setup the current thread class loader
      log.info("Init the naming director");
      NamingDirector.init(threadGroup);

      log.info("Init the transaction director");
      TransactionDirector.init();

      // instanciate the cache registry
      log.info("Init the cache registry");
      CacheRegistry.init(threadGroup);

      // instanciate the database sources
      log.info("Init data stources");
      DBSourceManager.init();

      // instanciate the bean manager
      log.info("Init coadunation beans");
      beanManager = new BeanManager(permissionContainer, threadGroup);
      BeanConnector.init(beanManager);

      // instanciate the jmx bean manager
      log.info("Init JMX Beans");
      jmxBeanManager = new JMXBeanManager(permissionContainer, threadGroup);
      JMXBeanConnector.init(jmxBeanManager);

      // instanciate the axis engine
      log.info("Init AXIS");
      AxisManager.init();

      // instanciate the web service manager
      log.info("Init Web Service management");
      webServiceManager = new WebServiceManager();
      WebServiceConnector.init(webServiceManager);

      // instanciate the thread manager
      log.info("Init Deployment Loader");
      deploymentManager =
          new DeploymentManager(threadGroup, beanManager, jmxBeanManager, webServiceManager);

      // instanciate the http daemon
      log.info("Init Web Service HTTPD");
      httpDaemon = new HttpDaemon(threadGroup);

    } catch (Exception ex) {
      System.out.println("Failed to start coadunation : " + ex.getMessage());
      ex.printStackTrace(System.out);
      log.error("Failed to start coadunation : " + ex.getMessage(), ex);
      throw new CoadException("Failed start the Coadunation base because : " + ex.getMessage(), ex);
    }
  }