org.springframework.boot.context.embedded.jetty.JettyServerCustomizer#org.eclipse.jetty.util.ArrayUtil源码实例Demo

下面列出了org.springframework.boot.context.embedded.jetty.JettyServerCustomizer#org.eclipse.jetty.util.ArrayUtil 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: lucene-solr   文件: HttpServer2.java
/**
 * Add an internal servlet in the server, with initialization parameters.
 * Note: This method is to be used for adding servlets that facilitate
 * internal communication and not for user facing functionality. For
 * servlets added using this method, filters (except internal Kerberos
 * filters) are not enabled.
 *
 * @param name The name of the servlet (can be passed as null)
 * @param pathSpec The path spec for the servlet
 * @param clazz The servlet class
 * @param params init parameters
 */
public void addInternalServlet(String name, String pathSpec,
                               Class<? extends HttpServlet> clazz, Map<String, String> params) {
  // Jetty doesn't like the same path spec mapping to different servlets, so
  // if there's already a mapping for this pathSpec, remove it and assume that
  // the newest one is the one we want
  final ServletHolder sh = new ServletHolder(clazz);
  sh.setName(name);
  sh.setInitParameters(params);
  final ServletMapping[] servletMappings =
      webAppContext.getServletHandler().getServletMappings();
  for (int i = 0; i < servletMappings.length; i++) {
    if (servletMappings[i].containsPathSpec(pathSpec)) {
      if (LOG.isDebugEnabled()) {
        LOG.debug("Found existing {} servlet at path {}; will replace mapping with {} servlet"
            , servletMappings[i].getServletName(), pathSpec, sh.getName());
      }
      ServletMapping[] newServletMappings =
          ArrayUtil.removeFromArray(servletMappings, servletMappings[i]);
      webAppContext.getServletHandler()
          .setServletMappings(newServletMappings);
      break;
    }
  }
  webAppContext.addServlet(sh, pathSpec);
}
 
源代码2 项目: hadoop-ozone   文件: HttpServer2.java
/**
 * Add an internal servlet in the server, specifying whether or not to
 * protect with Kerberos authentication.
 * Note: This method is to be used for adding servlets that facilitate
 * internal communication and not for user facing functionality. For
 * servlets added using this method, filters (except internal Kerberos
 * filters) are not enabled.
 *
 * @param name The name of the servlet (can be passed as null)
 * @param pathSpec The path spec for the servlet
 * @param clazz The servlet class
 * @param requireAuth Require Kerberos authenticate to access servlet
 */
public void addInternalServlet(String name, String pathSpec,
    Class<? extends HttpServlet> clazz, boolean requireAuth) {
  ServletHolder holder = new ServletHolder(clazz);
  if (name != null) {
    holder.setName(name);
  }
  // Jetty doesn't like the same path spec mapping to different servlets, so
  // if there's already a mapping for this pathSpec, remove it and assume that
  // the newest one is the one we want
  final ServletMapping[] servletMappings =
      webAppContext.getServletHandler().getServletMappings();
  for (int i = 0; i < servletMappings.length; i++) {
    if (servletMappings[i].containsPathSpec(pathSpec)) {
      if (LOG.isDebugEnabled()) {
        LOG.debug("Found existing " + servletMappings[i].getServletName() +
            " servlet at path " + pathSpec + "; will replace mapping" +
            " with " + holder.getName() + " servlet");
      }
      ServletMapping[] newServletMappings =
          ArrayUtil.removeFromArray(servletMappings, servletMappings[i]);
      webAppContext.getServletHandler()
          .setServletMappings(newServletMappings);
      break;
    }
  }
  webAppContext.addServlet(holder, pathSpec);

  if (requireAuth && UserGroupInformation.isSecurityEnabled()) {
    LOG.info("Adding Kerberos (SPNEGO) filter to {}", name);
    ServletHandler handler = webAppContext.getServletHandler();
    FilterMapping fmap = new FilterMapping();
    fmap.setPathSpec(pathSpec);
    fmap.setFilterName(SPNEGO_FILTER);
    fmap.setDispatches(FilterMapping.ALL);
    handler.addFilterMapping(fmap);
  }
}
 
源代码3 项目: hadoop-ozone   文件: HttpServer2.java
/**
 * Add an internal servlet in the server, with initialization parameters.
 * Note: This method is to be used for adding servlets that facilitate
 * internal communication and not for user facing functionality. For
 * servlets added using this method, filters (except internal Kerberos
 * filters) are not enabled.
 *
 * @param name The name of the servlet (can be passed as null)
 * @param pathSpec The path spec for the servlet
 * @param clazz The servlet class
 * @param params init parameters
 */
public void addInternalServlet(String name, String pathSpec,
    Class<? extends HttpServlet> clazz, Map<String, String> params) {
  // Jetty doesn't like the same path spec mapping to different servlets, so
  // if there's already a mapping for this pathSpec, remove it and assume that
  // the newest one is the one we want
  final ServletHolder sh = new ServletHolder(clazz);
  sh.setName(name);
  sh.setInitParameters(params);
  final ServletMapping[] servletMappings =
      webAppContext.getServletHandler().getServletMappings();
  for (int i = 0; i < servletMappings.length; i++) {
    if (servletMappings[i].containsPathSpec(pathSpec)) {
      if (LOG.isDebugEnabled()) {
        LOG.debug("Found existing " + servletMappings[i].getServletName() +
            " servlet at path " + pathSpec + "; will replace mapping" +
            " with " + sh.getName() + " servlet");
      }
      ServletMapping[] newServletMappings =
          ArrayUtil.removeFromArray(servletMappings, servletMappings[i]);
      webAppContext.getServletHandler()
          .setServletMappings(newServletMappings);
      break;
    }
  }
  webAppContext.addServlet(sh, pathSpec);
}
 
源代码4 项目: lucene-solr   文件: HttpServer2.java
/**
 * Add an internal servlet in the server, specifying whether or not to
 * protect with Kerberos authentication.
 * Note: This method is to be used for adding servlets that facilitate
 * internal communication and not for user facing functionality. For
 * servlets added using this method, filters (except internal Kerberos
 * filters) are not enabled.
 *
 * @param name The name of the servlet (can be passed as null)
 * @param pathSpec The path spec for the servlet
 * @param clazz The servlet class
 * @param requireAuth Require Kerberos authenticate to access servlet
 */
public void addInternalServlet(String name, String pathSpec,
                               Class<? extends HttpServlet> clazz, boolean requireAuth) {
  ServletHolder holder = new ServletHolder(clazz);
  if (name != null) {
    holder.setName(name);
  }
  // Jetty doesn't like the same path spec mapping to different servlets, so
  // if there's already a mapping for this pathSpec, remove it and assume that
  // the newest one is the one we want
  final ServletMapping[] servletMappings =
      webAppContext.getServletHandler().getServletMappings();
  for (int i = 0; i < servletMappings.length; i++) {
    if (servletMappings[i].containsPathSpec(pathSpec)) {
      if (LOG.isDebugEnabled()) {
        LOG.debug("Found existing {} servlet at path {}; will replace mapping with {} servlet"
            , servletMappings[i].getServletName()
            , pathSpec
            , holder.getName());
      }
      ServletMapping[] newServletMappings =
          ArrayUtil.removeFromArray(servletMappings, servletMappings[i]);
      webAppContext.getServletHandler()
          .setServletMappings(newServletMappings);
      break;
    }
  }
  webAppContext.addServlet(holder, pathSpec);

  if(requireAuth && UserGroupInformation.isSecurityEnabled()) {
    LOG.info("Adding Kerberos (SPNEGO) filter to {}", name);
    ServletHandler handler = webAppContext.getServletHandler();
    FilterMapping fmap = new FilterMapping();
    fmap.setPathSpec(pathSpec);
    fmap.setFilterName(SPNEGO_FILTER);
    fmap.setDispatches(FilterMapping.ALL);
    handler.addFilterMapping(fmap);
  }
}
 
源代码5 项目: knox   文件: HttpServer2.java
/**
 * Add an internal servlet in the server, specifying whether or not to
 * protect with Kerberos authentication.
 * Note: This method is to be used for adding servlets that facilitate
 * internal communication and not for user facing functionality. For
 * servlets added using this method, filters (except internal Kerberos
 * filters) are not enabled.
 *
 * @param name The name of the servlet (can be passed as null)
 * @param pathSpec The path spec for the servlet
 * @param clazz The servlet class
 * @param requireAuth Require Kerberos authenticate to access servlet
 */
public void addInternalServlet(String name, String pathSpec,
                               Class<? extends HttpServlet> clazz, boolean requireAuth) {
  ServletHolder holder = new ServletHolder(clazz);
  if (name != null) {
    holder.setName(name);
  }
  // Jetty doesn't like the same path spec mapping to different servlets, so
  // if there's already a mapping for this pathSpec, remove it and assume that
  // the newest one is the one we want
  final ServletMapping[] servletMappings =
      webAppContext.getServletHandler().getServletMappings();
  for (ServletMapping servletMapping : servletMappings) {
    if (servletMapping.containsPathSpec(pathSpec)) {
      if (LOG.isDebugEnabled()) {
        LOG.debug("Found existing " + servletMapping.getServletName() +
                      " servlet at path " + pathSpec + "; will replace mapping" +
                      " with " + holder.getName() + " servlet");
      }
      ServletMapping[] newServletMappings =
          ArrayUtil.removeFromArray(servletMappings, servletMapping);
      webAppContext.getServletHandler()
          .setServletMappings(newServletMappings);
      break;
    }
  }
  webAppContext.addServlet(holder, pathSpec);

  if(requireAuth && UserGroupInformation.isSecurityEnabled()) {
    LOG.info("Adding Kerberos (SPNEGO) filter to " + name);
    ServletHandler handler = webAppContext.getServletHandler();
    FilterMapping fmap = new FilterMapping();
    fmap.setPathSpec(pathSpec);
    fmap.setFilterName(SPNEGO_FILTER);
    fmap.setDispatches(FilterMapping.ALL);
    handler.addFilterMapping(fmap);
  }
}
 
源代码6 项目: knox   文件: HttpServer2.java
/**
 * Add an internal servlet in the server, with initialization parameters.
 * Note: This method is to be used for adding servlets that facilitate
 * internal communication and not for user facing functionality. For
 * servlets added using this method, filters (except internal Kerberos
 * filters) are not enabled.
 *
 * @param name The name of the servlet (can be passed as null)
 * @param pathSpec The path spec for the servlet
 * @param clazz The servlet class
 * @param params init parameters
 */
public void addInternalServlet(String name, String pathSpec,
                               Class<? extends HttpServlet> clazz, Map<String, String> params) {
  // Jetty doesn't like the same path spec mapping to different servlets, so
  // if there's already a mapping for this pathSpec, remove it and assume that
  // the newest one is the one we want
  final ServletHolder sh = new ServletHolder(clazz);
  sh.setName(name);
  sh.setInitParameters(params);
  final ServletMapping[] servletMappings =
      webAppContext.getServletHandler().getServletMappings();
  for (ServletMapping servletMapping : servletMappings) {
    if (servletMapping.containsPathSpec(pathSpec)) {
      if (LOG.isDebugEnabled()) {
        LOG.debug("Found existing " + servletMapping.getServletName() +
                      " servlet at path " + pathSpec + "; will replace mapping" +
                      " with " + sh.getName() + " servlet");
      }
      ServletMapping[] newServletMappings =
          ArrayUtil.removeFromArray(servletMappings, servletMapping);
      webAppContext.getServletHandler()
          .setServletMappings(newServletMappings);
      break;
    }
  }
  webAppContext.addServlet(sh, pathSpec);
}
 
源代码7 项目: knox   文件: HttpServer2.java
/**
 * Add an internal servlet in the server, specifying whether or not to
 * protect with Kerberos authentication.
 * Note: This method is to be used for adding servlets that facilitate
 * internal communication and not for user facing functionality. For
 * servlets added using this method, filters (except internal Kerberos
 * filters) are not enabled.
 *
 * @param name The name of the servlet (can be passed as null)
 * @param pathSpec The path spec for the servlet
 * @param clazz The servlet class
 * @param requireAuth Require Kerberos authenticate to access servlet
 */
public void addInternalServlet(String name, String pathSpec,
                               Class<? extends HttpServlet> clazz, boolean requireAuth) {
  ServletHolder holder = new ServletHolder(clazz);
  if (name != null) {
    holder.setName(name);
  }
  // Jetty doesn't like the same path spec mapping to different servlets, so
  // if there's already a mapping for this pathSpec, remove it and assume that
  // the newest one is the one we want
  final ServletMapping[] servletMappings =
      webAppContext.getServletHandler().getServletMappings();
  for (ServletMapping servletMapping : servletMappings) {
    if (servletMapping.containsPathSpec(pathSpec)) {
      if (LOG.isDebugEnabled()) {
        LOG.debug("Found existing " + servletMapping.getServletName() +
                      " servlet at path " + pathSpec + "; will replace mapping" +
                      " with " + holder.getName() + " servlet");
      }
      ServletMapping[] newServletMappings =
          ArrayUtil.removeFromArray(servletMappings, servletMapping);
      webAppContext.getServletHandler()
          .setServletMappings(newServletMappings);
      break;
    }
  }
  webAppContext.addServlet(holder, pathSpec);

  if(requireAuth && UserGroupInformation.isSecurityEnabled()) {
    LOG.info("Adding Kerberos (SPNEGO) filter to " + name);
    ServletHandler handler = webAppContext.getServletHandler();
    FilterMapping fmap = new FilterMapping();
    fmap.setPathSpec(pathSpec);
    fmap.setFilterName(SPNEGO_FILTER);
    fmap.setDispatches(FilterMapping.ALL);
    handler.addFilterMapping(fmap);
  }
}
 
源代码8 项目: knox   文件: HttpServer2.java
/**
 * Add an internal servlet in the server, with initialization parameters.
 * Note: This method is to be used for adding servlets that facilitate
 * internal communication and not for user facing functionality. For
 * servlets added using this method, filters (except internal Kerberos
 * filters) are not enabled.
 *
 * @param name The name of the servlet (can be passed as null)
 * @param pathSpec The path spec for the servlet
 * @param clazz The servlet class
 * @param params init parameters
 */
public void addInternalServlet(String name, String pathSpec,
                               Class<? extends HttpServlet> clazz, Map<String, String> params) {
  // Jetty doesn't like the same path spec mapping to different servlets, so
  // if there's already a mapping for this pathSpec, remove it and assume that
  // the newest one is the one we want
  final ServletHolder sh = new ServletHolder(clazz);
  sh.setName(name);
  sh.setInitParameters(params);
  final ServletMapping[] servletMappings =
      webAppContext.getServletHandler().getServletMappings();
  for (ServletMapping servletMapping : servletMappings) {
    if (servletMapping.containsPathSpec(pathSpec)) {
      if (LOG.isDebugEnabled()) {
        LOG.debug("Found existing " + servletMapping.getServletName() +
                      " servlet at path " + pathSpec + "; will replace mapping" +
                      " with " + sh.getName() + " servlet");
      }
      ServletMapping[] newServletMappings =
          ArrayUtil.removeFromArray(servletMappings, servletMapping);
      webAppContext.getServletHandler()
          .setServletMappings(newServletMappings);
      break;
    }
  }
  webAppContext.addServlet(sh, pathSpec);
}
 
源代码9 项目: hadoop-ozone   文件: HttpServer2.java
/**
 * Add the given handler to the front of the list of handlers.
 *
 * @param handler The handler to add
 */
public void addHandlerAtFront(Handler handler) {
  Handler[] h = ArrayUtil.prependToArray(
      handler, this.handlers.getHandlers(), Handler.class);
  handlers.setHandlers(h);
}
 
源代码10 项目: lucene-solr   文件: HttpServer2.java
/**
 * Add the given handler to the front of the list of handlers.
 *
 * @param handler The handler to add
 */
public void addHandlerAtFront(Handler handler) {
  Handler[] h = ArrayUtil.prependToArray(
      handler, this.handlers.getHandlers(), Handler.class);
  handlers.setHandlers(h);
}
 
源代码11 项目: knox   文件: HttpServer2.java
/**
 * Add the given handler to the front of the list of handlers.
 *
 * @param handler The handler to add
 */
public void addHandlerAtFront(Handler handler) {
  Handler[] h = ArrayUtil.prependToArray(
      handler, this.handlers.getHandlers(), Handler.class);
  handlers.setHandlers(h);
}
 
源代码12 项目: knox   文件: HttpServer2.java
/**
 * Add the given handler to the front of the list of handlers.
 *
 * @param handler The handler to add
 */
public void addHandlerAtFront(Handler handler) {
  Handler[] h = ArrayUtil.prependToArray(
      handler, this.handlers.getHandlers(), Handler.class);
  handlers.setHandlers(h);
}
 
/**
 * Initialize the WebAppContext for use by the VmRuntime.
 *
 * This method initializes the WebAppContext by setting the context path and application folder.
 * It will also parse the appengine-web.xml file provided to set System Properties and session
 * manager accordingly.
 *
 * @param appengineWebXmlFile The appengine-web.xml file path (relative to appDir).
 * @throws AppEngineConfigException If there was a problem finding or parsing the
 *         appengine-web.xml configuration.
 * @throws IOException If the runtime was unable to find/read appDir.
 */
public void init(String appengineWebXmlFile)
    throws AppEngineConfigException, IOException {

  String appDir=getBaseResource().getFile().getCanonicalPath();  
  defaultEnvironment = VmApiProxyEnvironment.createDefaultContext(
      System.getenv(), metadataCache, VmRuntimeUtils.getApiServerAddress(), wallclockTimer,
      VmRuntimeUtils.ONE_DAY_IN_MILLIS, appDir);
  ApiProxy.setEnvironmentForCurrentThread(defaultEnvironment);
  if (ApiProxy.getEnvironmentFactory() == null) {
    // Need the check above since certain unit tests initialize the context multiple times.
    ApiProxy.setEnvironmentFactory(new VmEnvironmentFactory(defaultEnvironment));
  }

  isDevMode = defaultEnvironment.getPartition().equals("dev");
  AppEngineWebXml appEngineWebXml = null;
  File appWebXml = new File(appDir, appengineWebXmlFile);
  if (appWebXml.exists()) {
    AppEngineWebXmlReader appEngineWebXmlReader
            = new AppEngineWebXmlReader(appDir, appengineWebXmlFile);
    appEngineWebXml = appEngineWebXmlReader.readAppEngineWebXml();
  }
  VmRuntimeUtils.installSystemProperties(defaultEnvironment, appEngineWebXml);
  VmRuntimeLogHandler.init();
  VmRuntimeFileLogHandler.init();

  for (String systemClass : SYSTEM_CLASSES) {
    addSystemClass(systemClass);
  }
  if (appEngineWebXml == null) {
    // No need to configure the session manager.
    return;
  }
  AbstractSessionManager sessionManager;
  if (appEngineWebXml.getSessionsEnabled()) {
    sessionManager = new SessionManager(createSessionStores(appEngineWebXml));
    getSessionHandler().setSessionManager(sessionManager);
  }

  setProtectedTargets(ArrayUtil.addToArray(getProtectedTargets(), "/app.yaml", String.class));
}