Exemple #1
0
  protected void activate() {
    try {
      logger.debug("Starting up proxy servlet at /" + PROXY_ALIAS);

      Hashtable<String, String> props = new Hashtable<String, String>();
      httpService.registerServlet("/" + PROXY_ALIAS, this, props, createHttpContext());
    } catch (NamespaceException e) {
      logger.error("Error during servlet startup: {}", e.getMessage());
    } catch (ServletException e) {
      logger.error("Error during servlet startup: {}", e.getMessage());
    }
  }
  /** {@inheritDoc} */
  @Override
  public final Object addingService(ServiceReference reference) {
    final Object svcObject = super.addingService(reference);

    System.out.println("TCP server [" + svcObject + "]");
    if (svcObject != null) {
      boolean changed = false;

      if (svcObject instanceof HttpService) {
        if (this.httpService == null) {
          changed = true;
        }

        this.httpService = (HttpService) svcObject;
      } else if (svcObject instanceof Driver) {
        if (this.driver == null) {
          changed = true;
        }

        this.driver = (Driver) svcObject;
      }

      if (changed && this.httpService != null && this.driver != null) {
        final HttpContext context = this.httpService.createDefaultHttpContext();

        try {
          this.eventDispatcher.start(this.driver);
        } catch (IOException e) {
          if (logger.isLoggable(Level.WARNING)) {
            logger.log(
                Level.WARNING,
                "Could not start event dispatcher due to an IO error [" + e.getMessage() + "]",
                e);
          }
        }

        for (final AbstractHandler handler : this.handlers) {
          handler.register(this.httpService, context, this.driver);
        }

        try {
          this.httpService.registerResources("/mobile", "/mobile", context);
        } catch (NamespaceException e) {
          e.printStackTrace();
        }
      }
    }

    return svcObject;
  }
 @SuppressWarnings("rawtypes")
 @Activate
 protected void activate(ComponentContext context) {
   Dictionary props = context.getProperties();
   noUserRedirectLocationFormat =
       PropertiesUtil.toString(
           props.get(NO_USER_REDIRECT_LOCATION_FORMAT), DEFAULT_NO_USER_REDIRECT_FORMAT);
   registrationPath = PropertiesUtil.toString(props.get(REGISTRATION_PATH), "/system/trustedauth");
   defaultDestination = PropertiesUtil.toString(props.get(DEFAULT_DESTINATION), "/dev");
   try {
     httpService.registerServlet(registrationPath, this, null, null);
     LOGGER.info("Registered {} at {} ", this, registrationPath);
   } catch (ServletException e) {
     LOGGER.error(e.getMessage(), e);
   } catch (NamespaceException e) {
     LOGGER.error(e.getMessage(), e);
   }
 }