Instanciate the request processor (factory method)
@param urlPrefix Url prefix (null allowed)
@param manager Manager (null allowed)
@param pluginClasses Plugin classes (null allowed)
497126
public static SimonConsoleRequestProcessor create(String urlPrefix, Manager manager, String pluginClasses) {
		SimonConsoleRequestProcessor requestProcessor = new SimonConsoleRequestProcessor(urlPrefix);
		if (manager != null) {
			// Defaults to global manager
			requestProcessor.setManager(manager);
		}
		if (pluginClasses != null) {
			requestProcessor.getPluginManager().addPlugins(pluginClasses);
		}
		requestProcessor.initActionBindings();
		return requestProcessor;
	}
1020466
synchronized void activateLazily() {
        if (cacheManager != null)
            return; // lazy initialization has already completed

        final boolean trace = TraceComponent.isAnyTracingEnabled();
        
        Properties vendorProperties = new Properties();
        
        String uriValue = (String) configurationProperties.get("uri");
        final URI uri;
        if (uriValue != null)
            try {
                uri = new URI(uriValue);
            } catch (URISyntaxException e) {
                throw new IllegalArgumentException(Tr.formatMessage(tc, "INCORRECT_URI_SYNTAX", e), e);
            }
        else
            uri = null;
        
        for (Map.Entry<String, Object> entry : configurationProperties.entrySet()) {
            String key = entry.getKey();
            Object value = entry.getValue();

            //properties start with properties.0.
            if (key.length () > TOTAL_PREFIX_LENGTH && key.charAt(BASE_PREFIX_LENGTH) == '.' && key.startsWith(BASE_PREFIX)) {
                key = key.substring(TOTAL_PREFIX_LENGTH);
                if (!key.equals("config.referenceType")) 
                    vendorProperties.setProperty(key, (String) value);
            }
        }

        // load JCache provider from configured library, which is either specified as a libraryRef or via a bell
        final ClassLoader cl = library.getClassLoader();

        try {
            AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
                ClassLoader loader = new CachingProviderClassLoader(cl);

                if (trace && tc.isDebugEnabled())
                    CacheHashMap.tcInvoke("Caching", "getCachingProvider", loader);

                cachingProvider = Caching.getCachingProvider(loader);

                tcCachingProvider = "CachingProvider" + Integer.toHexString(System.identityHashCode(cachingProvider));

                if (trace && tc.isDebugEnabled()) {
                    CacheHashMap.tcReturn("Caching", "getCachingProvider", tcCachingProvider, cachingProvider);
                    Tr.debug(this, tc, "caching provider class is " + cachingProvider.getClass().getName());
                    CacheHashMap.tcInvoke(tcCachingProvider, "getCacheManager", uri, null, vendorProperties);
                }

                cacheManager = cachingProvider.getCacheManager(uri, null, vendorProperties);

                return null;
            });

            tcCacheManager = "CacheManager" + Integer.toHexString(System.identityHashCode(cacheManager));

            if (trace && tc.isDebugEnabled()) {
                CacheHashMap.tcReturn(tcCachingProvider, "getCacheManager", tcCacheManager, cacheManager);
                CacheHashMap.tcInvoke(tcCachingProvider, "isSupported", "STORE_BY_REFERENCE");
            }

            supportsStoreByReference = cachingProvider.isSupported(OptionalFeature.STORE_BY_REFERENCE);

            if (trace && tc.isDebugEnabled())
                CacheHashMap.tcReturn(tcCachingProvider, "isSupported", supportsStoreByReference);
        } catch (CacheException x) {
            if (library.getFiles().isEmpty()) {
                Tr.error(tc, "ERROR_CONFIG_EMPTY_LIBRARY", library.id(), Tr.formatMessage(tc, "SESSION_CACHE_CONFIG_MESSAGE", RuntimeUpdateListenerImpl.sampleConfig));
            }
            throw x;
        } catch (Error | RuntimeException x) {
            // deactivate will not be invoked if activate fails, so ensure CachingProvider is closed on error paths
            if (cachingProvider != null) {
                CacheHashMap.tcInvoke(tcCachingProvider, "close");
                cachingProvider.close();
                CacheHashMap.tcReturn(tcCachingProvider, "close");
            }
            throw x;
        }
    }
954377
private void loadFacesInitPluginsJDK5()
    {

        String plugins = (String) _servletContext.getInitParameter(FACES_INIT_PLUGINS);
        if (plugins == null)
        {
            return;
        }
        log.info("MyFaces Plugins found");
        String[] pluginEntries = plugins.split(",");
        List<StartupListener> listeners = new ArrayList<StartupListener>(pluginEntries.length);
        for (String pluginEntry : pluginEntries)
        {
            try
            {
                Class pluginClass = null;
                pluginClass = ClassUtils.getContextClassLoader().loadClass(pluginEntry);
                if (pluginClass == null)
                {
                    pluginClass = this.getClass().getClassLoader().loadClass(pluginEntry);
                }
                listeners.add((StartupListener) pluginClass.newInstance());
            }
            catch (ClassNotFoundException e)
            {
                log.log(Level.SEVERE, e.getMessage(), e);
            }
            catch (InstantiationException e)
            {
                log.log(Level.SEVERE, e.getMessage(), e);
            }
            catch (IllegalAccessException e)
            {
                log.log(Level.SEVERE, e.getMessage(), e);
            }
        }
        // StartupListener[] listeners1 = listeners.toArray(new StartupListener[listeners.size()]);
        _servletContext.setAttribute(FACES_INIT_PLUGINS, listeners);

    }
282422
private RequestDispatcher createDispatcher(String pDispatcherClass,
                                               Converters pConverters,
                                               ServerHandle pServerHandle,
                                               Restrictor pRestrictor,
                                               Configuration pConfig) {
        try {
            Class clazz = ClassUtil.classForName(pDispatcherClass, getClass().getClassLoader());
            if (clazz == null) {
                throw new IllegalArgumentException("Couldn't lookup dispatcher " + pDispatcherClass);
            }
            try {
                Constructor constructor = clazz.getConstructor(Converters.class,
                                                               ServerHandle.class,
                                                               Restrictor.class,
                                                               Configuration.class);
                return (RequestDispatcher)
                    constructor.newInstance(pConverters,
                                            pServerHandle,
                                            pRestrictor,
                                            pConfig);
            } catch (NoSuchMethodException exp) {
                // Try without configuration as fourth parameter
                Constructor constructor = clazz.getConstructor(Converters.class,
                                                               ServerHandle.class,
                                                               Restrictor.class);
                return (RequestDispatcher)
                    constructor.newInstance(pConverters,
                                            pServerHandle,
                                            pRestrictor);
            }
        } catch (NoSuchMethodException e) {
            throw new IllegalArgumentException("Class " + pDispatcherClass + " has invalid constructor: " + e,e);
        } catch (IllegalAccessException e) {
            throw new IllegalArgumentException("Constructor of " + pDispatcherClass + " couldn't be accessed: " + e,e);
        } catch (InvocationTargetException e) {
            throw new IllegalArgumentException(e);
        } catch (InstantiationException e) {
            throw new IllegalArgumentException(pDispatcherClass + " couldn't be instantiated: " + e,e);
        }
    }
862511
function (manager) {
  this.config = {};
  this.manager = manager;
  this.debug = manager.debug;
  this.binder = new ProxyBinder(this.manager);
  this.api = this.manager.api;
  this.manifests = {};
  this.providers = {};

  this.id = 'ModuleInternal';
  this.pendingPorts = 0;
  this.requests = {};
  this.unboundPorts = {};

  util.handleEvents(this);
}
1156471
private void processComponentJar(URL jarFileURL, WorkList workList, List<String> implicitClasspath) {
        LOG.debug("Processing {}", jarFileURL);

        if (!jarFileURL.toString().endsWith(".zip") && !jarFileURL.toString().endsWith(".jar")) {
            return;
        }

        try {
            URL manifestURL = new URL("jar:" + jarFileURL.toString() + "!/META-INF/MANIFEST.MF");

            InputStream in = null;
            try {
                in = manifestURL.openStream();
                Manifest manifest = new Manifest(in);

                Attributes mainAttrs = manifest.getMainAttributes();
                String classPath = mainAttrs.getValue("Class-Path");
                if (classPath != null) {
                    String[] fileList = classPath.split("\\s+");

                    for (String jarFile : fileList) {
                        URL referencedURL = workList.createRelativeURL(jarFileURL, jarFile);
                        if (workList.add(new WorkListItem(referencedURL))) {
                            implicitClasspath.add(referencedURL.toString());
                            LOG.debug("Implicit jar: {}", referencedURL);
                        }
                    }
                }
            } finally {
                if (in != null) {
                    in.close();
                }
            }
        } catch (IOException ignore) {
            // Ignore
        }
    }
350012
@DependsOn("applicationContextProvider")
	@Bean
	public WebServerFactoryCustomizer<ConfigurableServletWebServerFactory> rewriteWebServerFactoryCustomizer() {
		return factory -> factory.addInitializers(servletContext -> {
			servletContext.addListener(new RewriteServletContextListener());
			servletContext.addListener(new RewriteServletRequestListener());

			FilterRegistration.Dynamic rewriteFilterRegistration = servletContext.addFilter("OCPsoft Rewrite Filter", RewriteFilter.class);
			rewriteFilterRegistration.setAsyncSupported(true);
			rewriteFilterRegistration.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), false, "/*");
		});
	}
672472
public <T> RestBuilder addProvider(Class<T> clazz, Class<? extends ContextProvider<T>> provider) {

		Assert.notNull(clazz, "Missing provided class type!");
		Assert.notNull(provider, "Missing context provider!");
		registeredProviders.put(clazz, provider);
		return this;
	}
1152444
@Override
	protected void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) {
		beanFactory.addBeanPostProcessor(
				new WebApplicationContextServletContextAwareProcessor(this));
		beanFactory.ignoreDependencyInterface(ServletContextAware.class);
		registerWebApplicationScopes();
	}
951402
public void identifyClasses(final String pluginDirectory) throws Exception {
        methodInformation.clear();
        jarInformation.clear();
        try {
            new FileTraversal() {
                public void onDirectory(final File d) {
                }

                public void onFile(final File f) {
                    try {
                        // loads class files
                        if (f.getName().endsWith(".class")) {
                            // get the class name for this path
                            String className = f.getAbsolutePath();
                            className = className.replace(pluginDirectory, "");
                            className = getClassNameFromPath(className);

                            logger.info("Storing plugin information: {}, {}", className,
                                        f.getName());

                            ClassInformation classInfo = new ClassInformation();
                            classInfo.pluginPath = pluginDirectory;
                            classInformation.put(className, classInfo);
                        } else if (f.getName().endsWith(".jar")) {
                            // loads JAR packages
                            // open up jar and discover files
                            // look for anything with /proxy/ in it
                            // this may discover things we don't need but that is OK
                            try {
                                jarInformation.add(f.getAbsolutePath());
                                JarFile jarFile = new JarFile(f);
                                Enumeration<?> enumer = jarFile.entries();

                                // Use the Plugin-Name manifest entry to match with the provided pluginName
                                String pluginPackageName = jarFile.getManifest().getMainAttributes().getValue("plugin-package");
                                if (pluginPackageName == null) {
                                    return;
                                }

                                while (enumer.hasMoreElements()) {
                                    Object element = enumer.nextElement();
                                    String elementName = element.toString();

                                    if (!elementName.endsWith(".class")) {
                                        continue;
                                    }

                                    String className = getClassNameFromPath(elementName);
                                    if (className.contains(pluginPackageName)) {
                                        logger.info("Storing plugin information: {}, {}", className,
                                                    f.getAbsolutePath());

                                        ClassInformation classInfo = new ClassInformation();
                                        classInfo.pluginPath = f.getAbsolutePath();
                                        classInformation.put(className, classInfo);
                                    }
                                }
                            } catch (Exception e) {

                            }
                        }
                    } catch (Exception e) {
                        logger.warn("Exception caught: {}, {}", e.getMessage(), e.getCause());
                    }
                }
            }.traverse(new File(pluginDirectory));
        } catch (IOException e) {
            throw new Exception("Could not identify all plugins: " + e.getMessage());
        }
    }
1082443
@Override
	public synchronized void initialize(Manager manager) {
		if (this.manager != null) {
			throw new IllegalStateException("Callback was already initialized");
		}
		this.manager = manager;
		for (Callback callback : callbacks) {
			try {
				callback.initialize(manager);
			} catch (Exception e) {
				onManagerWarning("Callback initialization error", e);
			}
		}
	}
424010
public static HOTPProvider instantiateProvider(boolean allowTestProvider) {
        HOTPProvider resultProvider = null;
        ServiceLoader<HOTPProvider> loader = ServiceLoader.load(HOTPProvider.class);
        Iterator<HOTPProvider> iterator = loader.iterator();
        if (iterator.hasNext()) {
            while (iterator.hasNext()) {
                HOTPProvider provider = iterator.next();
                if (!"com.payneteasy.superfly.spring.TestHOTPProvider".equals(provider.getClass().getName())
                        || allowTestProvider) {
                    resultProvider = provider;
                    break;
                }
            }
        }
        return resultProvider;
    }
634013
@SuppressWarnings("rawtypes")
    public static void inject(final IPluginInterface plugin, final IJNRPEExecutionContext context) {

        try {
            Class clazz = plugin.getClass();
            inject(clazz, plugin, context);
            while (IPluginInterface.class.isAssignableFrom(clazz.getSuperclass())) {
                clazz = clazz.getSuperclass();
                inject(clazz, plugin, context);
            }
        } catch (Exception e) {
            throw new Error(e.getMessage(), e);
        }

    }
289011
private void executeRequest(HttpMethod httpMethodProxyRequest,
                                HttpServletRequest httpServletRequest,
                                PluginResponse httpServletResponse,
                                History history) throws Exception {
        int intProxyResponseCode = 999;
        // Create a default HttpClient
        HttpClient httpClient = new HttpClient();
        HttpState state = new HttpState();

        try {
            httpMethodProxyRequest.setFollowRedirects(false);
            ArrayList<String> headersToRemove = getRemoveHeaders();

            httpClient.getParams().setSoTimeout(60000);

            httpServletRequest.setAttribute("com.groupon.odo.removeHeaders", headersToRemove);

            // exception handling for httpclient
            HttpMethodRetryHandler noretryhandler = new HttpMethodRetryHandler() {
                public boolean retryMethod(
                    final HttpMethod method,
                    final IOException exception,
                    int executionCount) {
                    return false;
                }
            };

            httpMethodProxyRequest.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, noretryhandler);

            intProxyResponseCode = httpClient.executeMethod(httpMethodProxyRequest.getHostConfiguration(), httpMethodProxyRequest, state);
        } catch (Exception e) {
            // Return a gateway timeout
            httpServletResponse.setStatus(504);
            httpServletResponse.setHeader(Constants.HEADER_STATUS, "504");
            httpServletResponse.flushBuffer();
            return;
        }
        logger.info("Response code: {}, {}", intProxyResponseCode,
                    HttpUtilities.getURL(httpMethodProxyRequest.getURI().toString()));

        // Pass the response code back to the client
        httpServletResponse.setStatus(intProxyResponseCode);

        // Pass response headers back to the client
        Header[] headerArrayResponse = httpMethodProxyRequest.getResponseHeaders();
        for (Header header : headerArrayResponse) {
            // remove transfer-encoding header.  The http libraries will handle this encoding
            if (header.getName().toLowerCase().equals("transfer-encoding")) {
                continue;
            }

            httpServletResponse.setHeader(header.getName(), header.getValue());
        }

        // there is no data for a HTTP 304 or 204
        if (intProxyResponseCode != HttpServletResponse.SC_NOT_MODIFIED &&
            intProxyResponseCode != HttpServletResponse.SC_NO_CONTENT) {
            // Send the content to the client
            httpServletResponse.resetBuffer();
            httpServletResponse.getOutputStream().write(httpMethodProxyRequest.getResponseBody());
        }

        // copy cookies to servlet response
        for (Cookie cookie : state.getCookies()) {
            javax.servlet.http.Cookie servletCookie = new javax.servlet.http.Cookie(cookie.getName(), cookie.getValue());

            if (cookie.getPath() != null) {
                servletCookie.setPath(cookie.getPath());
            }

            if (cookie.getDomain() != null) {
                servletCookie.setDomain(cookie.getDomain());
            }

            // convert expiry date to max age
            if (cookie.getExpiryDate() != null) {
                servletCookie.setMaxAge((int) ((cookie.getExpiryDate().getTime() - System.currentTimeMillis()) / 1000));
            }

            servletCookie.setSecure(cookie.getSecure());

            servletCookie.setVersion(cookie.getVersion());

            if (cookie.getComment() != null) {
                servletCookie.setComment(cookie.getComment());
            }

            httpServletResponse.addCookie(servletCookie);
        }
    }
1283860
static EntityManager createProxy(final HibernateEntityManagerFactory factory) {
        final EntityManagerInterceptor handler = new EntityManagerInterceptor(factory);

        final Enhancer e = new Enhancer();

        // make sure we're Serializable and have a write replace method
        e.setInterfaces(new Class[] { EntityManager.class, Serializable.class, IWriteReplace.class });
        e.setSuperclass(Object.class);
        e.setCallback(handler);
        e.setNamingPolicy(new DefaultNamingPolicy() {
            @Override
            public String getClassName(final String prefix,
                                       final String source,
                                       final Object key,
                                       final Predicate names) {
                return super.getClassName("CROQUET_ENTITY_MANAGER_PROXY_" + prefix, source, key, names);
            }
        });

        LOG.trace("Created proxy for an EntityManager");

        return (EntityManager)e.create();
    }
961885
public <P extends PluginRepository<?, ?>> P getPluginManager(Class<?> pluginType) {
        return (P) pluginRepositories.get(pluginType);
    }
613570
static URLClassLoader createURLCLassLoader(final URL[] urls, final ClassLoader parent)
   {
      return (URLClassLoader)AccessController.doPrivileged(new PrivilegedAction<Object>() 
      {
         public Object run()
         {
            return new URLClassLoader(urls, parent);
         }
      });
   }