getEJBWithPathClasses

@param classes
@param ejb
@param ejbInterfaceName
@param appClassloader
559659
private void getEJBWithPathClasses(Set<String> classeNames, EJBEndpoint ejb, String ejbInterfaceName, ClassLoader appClassloader) {
        final String methodName = "getEJBWithPathClasses";
        if (tc.isEntryEnabled())
            Tr.entry(tc, methodName, classeNames, ejb, ejbInterfaceName);
        if (classeNames == null) {
            if (tc.isEntryEnabled())
                Tr.exit(tc, methodName, Collections.emptySet());
        }

        Class<Path> pathClass = Path.class;
        final String ejbClassName = (ejbInterfaceName == null) ? ejb.getClassName() : ejbInterfaceName;
        Class<?> c = null;
        try {
            c = appClassloader.loadClass(ejbClassName);
        } catch (ClassNotFoundException e) {

            if (tc.isDebugEnabled()) {
                Tr.debug(tc, "getEJBWithPathClasses() exit - due to Class Not Found for " + ejbClassName + ": " + e);
            }
        }

        if (c != null && c.getAnnotation(pathClass) != null) {
            classeNames.add(ejbClassName);
        }

        if (tc.isEntryEnabled())
            Tr.exit(tc, methodName, classeNames);
    }
871592
public static ClassLoader[] getClassLoaders(ClassLoader... classLoaders) {

		if (classLoaders != null && classLoaders.length > 0) {
			return classLoaders;
		}

		final ClassLoader ctxClassLoader = Thread.currentThread()
				.getContextClassLoader();
		final ClassLoader staticClassLoader = ClassLoaderUtils.class
				.getClassLoader();

		if (ctxClassLoader == null) {
			if (staticClassLoader == null) {
				return new ClassLoader[] {};
			} else {
				return new ClassLoader[] { staticClassLoader };
			}
		} else {
			if (staticClassLoader == null) {
				return new ClassLoader[] { ctxClassLoader };
			} else {
				return new ClassLoader[] { ctxClassLoader, staticClassLoader };
			}
		}
	}
407518
public void scanJars() throws IOException {

        ClassLoader webappLoader = Thread.currentThread().getContextClassLoader();

        ClassLoader parentLoader = webappLoader.getParent();

        ResourceDelegatingBundleClassLoader classLoader = null;
        if (webappLoader instanceof ResourceDelegatingBundleClassLoader) {
            classLoader = (ResourceDelegatingBundleClassLoader) webappLoader;
        } else if (parentLoader instanceof ResourceDelegatingBundleClassLoader) {
            classLoader = (ResourceDelegatingBundleClassLoader) parentLoader;
        } else if (isTomcatWebLoader()) {
            ClassLoader parent = ((org.apache.catalina.loader.WebappClassLoader) webappLoader).getParent();
            if (parent instanceof ResourceDelegatingBundleClassLoader) {
                classLoader = (ResourceDelegatingBundleClassLoader) parent;
            }
        }

        List<Bundle> bundles = classLoader == null ? Collections.<Bundle>emptyList() : classLoader.getBundles();
        for (Bundle bundle : bundles) {
            Collection<Enumeration<URL>> enumerations;
            BundleWiring bundleWiring = bundle.adapt(BundleWiring.class);
            if (bundleWiring == null) {
                Enumeration<URL> urls = bundle.findEntries("META-INF", "*.tld", true);
                enumerations = Collections.singleton(urls);
            } else {
                Collection<String> resources = bundleWiring.listResources("META-INF", "*.tld",
                        BundleWiring.LISTRESOURCES_RECURSE);
                enumerations = new ArrayList<>(resources.size());
                for (String resource : resources) {
                    Enumeration<URL> urls = bundle.getResources(resource);
                    enumerations.add(urls);
                }
            }
            for (Enumeration<URL> urls : enumerations) {
                if (urls != null) {
                    while (urls.hasMoreElements()) {
                        URL url = urls.nextElement();
                        LOG.info("found TLD {}", url);
                        TldResourcePath tldResourcePath = new TldResourcePath(url, null, null);
                        try {
                            parseTld(tldResourcePath);
                        } catch (SAXException e) {
                            throw new IOException(e);
                        }
                    }
                }
            }
        }
    }
258990
private void initScriptClasses(Set<Class<?>> classes)throws Exception
	{
		Set<Class<? extends S>> scriptClass=findScriptClass(classes);
		Set<Class<? extends S>> instanceAbleScript = findInstanceAbleScript(scriptClass);
		Map<String, Class<? extends S>> nameMap_ = new HashMap<String, Class<? extends S>>();
		Map<Integer, Class<? extends S>> idMap_ = new HashMap<Integer, Class<? extends S>>();
		for(Class<? extends S> clazz:instanceAbleScript)
		{
			registScript(clazz, nameMap_, idMap_);
		}
		this.idMap.clear();
		this.nameMap.clear();
		this.idMap.putAll(idMap_);
		this.nameMap.putAll(nameMap_);
		_log.info("loadScriptClass complete,id mapping size:"+idMap.size()+",name mapping size:"+nameMap.size());
	}
226666
private Map<String, IEsjpSelect> getEsjpSelect(final List<Instance> _instances)
        throws Exception
    {
        final Map<String, IEsjpSelect> ret = new HashMap<>();
        if (!_instances.isEmpty()) {
            for (final Entry<String, AbstractSelect> entry : getAlias2Selects().entrySet()) {
                if (entry.getValue() instanceof ExecSelect) {
                    final Class<?> clazz = Class.forName(entry.getValue().getSelect(), false, EFapsClassLoader
                                    .getInstance());
                    final IEsjpSelect esjp = (IEsjpSelect) clazz.newInstance();
                    final List<String> parameters = ((ExecSelect) entry.getValue()).getParameters();
                    if (parameters.isEmpty()) {
                        esjp.initialize(_instances);
                    } else {
                        esjp.initialize(_instances, parameters.toArray(new String[parameters.size()]));
                    }
                    ret.put(entry.getKey(), esjp);
                }
            }
        }
        return ret;
    }
473662
private List<Class<?>> loadServiceClasses(ClassLoader loader)
            throws MojoExecutionException {
        List<Class<?>> serviceClasses = new ArrayList<Class<?>>();
        for (String serviceClassName : getServices()) {
            try {
                Class<?> serviceClass = loader.loadClass(serviceClassName);
                serviceClasses.add(serviceClass);
            } catch (ClassNotFoundException ex) {
                throw new MojoExecutionException("Could not load class: " + serviceClassName, ex);
            }
        }
        return serviceClasses;
    }
623213
private Map<Method, ArrayList<EJBMethodInfoImpl>> createEJBMethodInfoMap(final BeanMetaData bmd, final Method[] allMethodsOfEJB) {
        final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();

        if (isTraceOn && tc.isEntryEnabled()) {
            Tr.entry(tc, "createEJBMethodInfoMap: " + bmd.enterpriseBeanName);
        }

        final HashMap<Method, ArrayList<EJBMethodInfoImpl>> map = new HashMap<Method, ArrayList<EJBMethodInfoImpl>>();

        // Determine which public methods of the EJB are business methods
        // and populate the EJBMethodInfo map with entries for each business method.
        if (bmd.isMessageDrivenBean()) {
            // As described section 5.4.9 Message Listener Interceptor Methods for Message-Driven
            // Beans, the AroundInvoke business method interceptor methods are supported for
            // message-driven beans. These interceptor methods may be defined on the bean class
            // or on a interceptor class and apply to the handling of the invocation of the
            // bean's message listener method(s).  Therefore, only the methods of the
            // message listener interface need to be processed.
            EJBMethodInfoImpl[] methodInfos = bmd.localMethodInfos;
            for (Method method : allMethodsOfEJB) {
                EJBMethodInfoImpl info = findMethodInEJBMethodInfoArray(methodInfos, method); //d494984.1
                if (info != null) {
                    ArrayList<EJBMethodInfoImpl> list = new ArrayList<EJBMethodInfoImpl>();
                    list.add(info);
                    map.put(method, list);
                }
            }
        } else if (bmd.isSessionBean() || bmd.isManagedBean()) {
            // As described in section 4.3.9 Business Method Delegation, the session bean's
            // business interface, component interface, or web service endpoint defines the
            // business methods callable by a client.  Therefore, only process methods
            // of business, component, and webservices interfaces.
            EJBMethodInfoImpl[] localInfos = bmd.localMethodInfos;
            EJBMethodInfoImpl[] remoteInfos = bmd.methodInfos;
            EJBMethodInfoImpl[] webServiceInfos = bmd.wsEndpointMethodInfos;

            for (Method method : allMethodsOfEJB) {
                ArrayList<EJBMethodInfoImpl> list = new ArrayList<EJBMethodInfoImpl>();
                if (localInfos != null) {
                    EJBMethodInfoImpl info = findMethodInEJBMethodInfoArray(localInfos, method); //d494984.1
                    if (info != null) {
                        list.add(info);
                    }
                }
                if (remoteInfos != null) {
                    EJBMethodInfoImpl info = findMethodInEJBMethodInfoArray(remoteInfos, method); //d494984.1
                    if (info != null) {
                        list.add(info);
                    }
                }
                if (webServiceInfos != null) {
                    EJBMethodInfoImpl info = findMethodInEJBMethodInfoArray(webServiceInfos, method); //d494984.1
                    if (info != null) {
                        list.add(info);
                    }
                }
                if (!list.isEmpty()) {
                    map.put(method, list);
                }
            }
        }

        if (isTraceOn && tc.isEntryEnabled()) {
            Tr.exit(tc, "createEJBMethodInfoMap: " + bmd.enterpriseBeanName);
        }
        return map;
    }
998216
@Override
    public T addClasses(Class<?>... classes) throws IllegalArgumentException {
        Validate.notNull(classes, "Classes must be specified");

        for (final Class<?> clazz : classes) {
            Asset resource = new ClassAsset(clazz);
            ArchivePath location = new BasicPath(getClassesPath(), AssetUtil.getFullPathForClassResource(clazz));
            add(resource, location);

            // SHRINKWRAP-335, account for classes loaded from the
            // Bootstrap CL (some JDK impls may return null on class.getClassLoader)
            final ClassLoader loadingCl = clazz.getClassLoader();
            final ClassLoader adjustedCl = loadingCl == null ? ClassLoader.getSystemClassLoader() : loadingCl;

            // Get all inner classes and add them
            addPackages(false, new Filter<ArchivePath>() {
                /**
                 * path = /package/MyClass$Test.class <br/>
                 * clazz = /package/MyClass.class <br/>
                 *
                 *
                 * @param path
                 *            The added classes
                 * @return
                 */
                @Override
                public boolean include(ArchivePath path) {
                    ArchivePath classArchivePath = AssetUtil.getFullPathForClassResource(clazz);
                    String expression = classArchivePath.get().replace(".class", "\\$.*");
                    return path.get().matches(expression);
                };
            }, adjustedCl,
            // Assumes a null package is a class in the default package
                clazz.getPackage() == null ? DEFAULT_PACKAGE_NAME : clazz.getPackage().getName());
        }
        return covarientReturn();
    }
222304
private void getEJBApplicationSubclasses(Set<Class<?>> classes, EJBEndpoint ejb, ClassLoader appClassloader) {
        final String methodName = "getEJBApplicationSubclasses";
        if (tc.isEntryEnabled()) {
            Tr.entry(tc, methodName);
        }

        if (classes == null) {
            if (tc.isEntryEnabled())
                Tr.exit(tc, methodName, Collections.emptySet());
            return;
        }

        Class<Application> appClass = Application.class;

        final String ejbClassName = ejb.getClassName();
        Class<?> c = null;
        try {
            c = appClassloader.loadClass(ejbClassName);
        } catch (ClassNotFoundException e) {

            if (tc.isDebugEnabled()) {
                Tr.debug(tc, methodName + " exit - due to Class Not Found for " + ejbClassName + ": " + e);
            }

        }

        if (c != null && appClass.isAssignableFrom(c)) {
            classes.add(c);
        }

        if (tc.isEntryEnabled())
            Tr.exit(tc, methodName, classes);

    }
1182381
private void loadClasspathInfo()
  {
    List<IDirectory> javaClassPath = _module.getJavaClassPath();
    IDirectory[] paths = javaClassPath.toArray(new IDirectory[javaClassPath.size()]);
    for (int i = paths.length - 1; i >= 0; i--) {
      IDirectory path = paths[i];
      addClassNames(path, path, _filter);
    }
  }
267109
@SuppressWarnings("unchecked")
    protected List<T> getEnabledListeners(Class<? extends T>... classes) {
        List<T> listeners = new ArrayList<T>();
        for (Class<? extends T> clazz : classes) {
            Set<Bean<?>> beans = getBeanManager().getBeans(clazz);
            if (!beans.isEmpty()) {
                Bean<T> bean = (Bean<T>) getBeanManager().resolve(beans);
                CreationalContext<T> context = getBeanManager().createCreationalContext(bean);
                listeners.add((T) getBeanManager().getReference(bean, clazz, context));
            }
        }
        return listeners;
    }
718542
List<String> buildClassPath(String appClassPath) throws IOException {
    String sparkHome = getSparkHome();

    Set<String> cp = new LinkedHashSet<>();
    addToClassPath(cp, appClassPath);

    addToClassPath(cp, getConfDir());

    boolean prependClasses = !isEmpty(getenv("SPARK_PREPEND_CLASSES"));
    boolean isTesting = "1".equals(getenv("SPARK_TESTING"));
    if (prependClasses || isTesting) {
      String scala = getScalaVersion();
      List<String> projects = Arrays.asList(
        "common/kvstore",
        "common/network-common",
        "common/network-shuffle",
        "common/network-yarn",
        "common/sketch",
        "common/tags",
        "common/unsafe",
        "core",
        "examples",
        "graphx",
        "launcher",
        "mllib",
        "repl",
        "resource-managers/mesos",
        "resource-managers/yarn",
        "sql/catalyst",
        "sql/core",
        "sql/hive",
        "sql/hive-thriftserver",
        "streaming"
      );
      if (prependClasses) {
        if (!isTesting) {
          System.err.println(
            "NOTE: SPARK_PREPEND_CLASSES is set, placing locally compiled Spark classes ahead of " +
            "assembly.");
        }
        for (String project : projects) {
          addToClassPath(cp, String.format("%s/%s/target/scala-%s/classes", sparkHome, project,
            scala));
        }
      }
      if (isTesting) {
        for (String project : projects) {
          addToClassPath(cp, String.format("%s/%s/target/scala-%s/test-classes", sparkHome,
            project, scala));
        }
      }

      // Add this path to include jars that are shaded in the final deliverable created during
      // the maven build. These jars are copied to this directory during the build.
      addToClassPath(cp, String.format("%s/core/target/jars/*", sparkHome));
      addToClassPath(cp, String.format("%s/mllib/target/jars/*", sparkHome));
    }

    // Add Spark jars to the classpath. For the testing case, we rely on the test code to set and
    // propagate the test classpath appropriately. For normal invocation, look for the jars
    // directory under SPARK_HOME.
    boolean isTestingSql = "1".equals(getenv("SPARK_SQL_TESTING"));
    String jarsDir = findJarsDir(getSparkHome(), getScalaVersion(), !isTesting && !isTestingSql);
    if (jarsDir != null) {
      addToClassPath(cp, join(File.separator, jarsDir, "*"));
    }

    addToClassPath(cp, getenv("HADOOP_CONF_DIR"));
    addToClassPath(cp, getenv("YARN_CONF_DIR"));
    addToClassPath(cp, getenv("SPARK_DIST_CLASSPATH"));
    return new ArrayList<>(cp);
  }
241006
@SuppressWarnings("rawtypes")
	public List<ServletDefinition> initJawrSpringServlets(ServletContext servletContext) throws ServletException{
		
		List<ServletDefinition> jawrServletDefinitions = new ArrayList<ServletDefinition>();
		ContextLoader contextLoader = new ContextLoader();
		WebApplicationContext applicationCtx = contextLoader.initWebApplicationContext(servletContext);
		Map<?, ?> jawrControllersMap = applicationCtx.getBeansOfType(JawrSpringController.class);
		
		Iterator<?> entrySetIterator = jawrControllersMap.entrySet().iterator();
		while(entrySetIterator.hasNext()){
			
			JawrSpringController jawrController = (JawrSpringController) ((Map.Entry) entrySetIterator.next()).getValue();
			Map<String, Object> initParams = new HashMap<String, Object>();
			initParams.putAll(jawrController.getInitParams());
			ServletConfig servletConfig = new MockServletConfig(SPRING_DISPATCHER_SERVLET,servletContext, initParams);
			MockJawrSpringServlet servlet = new MockJawrSpringServlet(jawrController, servletConfig);
			ServletDefinition servletDefinition = new ServletDefinition(servlet, servletConfig) ;
			jawrServletDefinitions.add(servletDefinition);
		}
		
		contextLoader.closeWebApplicationContext(servletContext);
		return jawrServletDefinitions;
	}
110546
private static Collection<Class> scanEntityClasses(String... persistenceXmlFiles) {
        DDLGenerator.Profile profile = new DDLGenerator.Profile(null);
        profile.addPersistenceFile(persistenceXmlFiles);
        return profile.getEntityClasses();
    }
469555
public static List<String> getClasses(String... packageNames) {
		List<String> classes = new ArrayList<>();
		for (String packageName : packageNames) {
			String packagePath = packageName.replace('.', '/');
			URL url = Conf.class.getResource("/" + packagePath);
			if (url == null) {
				return classes;
			}
			if (url.getProtocol().equals("jar")) {
				String path = url.getPath();
				int i = path.lastIndexOf('!');
				if (i >= 0) {
					path = path.substring(0, i);
				}
				try (JarFile jar = new JarFile(new File(new URL(path).toURI()))) {
					Enumeration<JarEntry> e = jar.entries();
					while (e.hasMoreElements()) {
						path = e.nextElement().getName();
						if (path.startsWith(packagePath) && path.endsWith(".class")) {
							classes.add(path.substring(0, path.length() - 6).replace('/', '.'));
						}
					}
				} catch (IOException | URISyntaxException e) {
					throw new RuntimeException(e);
				}
			} else {
				try {
					String root = new File(url.toURI()).getPath();
					root = root.substring(0, root.length() - packagePath.length());
					search(classes, root, packagePath);
				} catch (URISyntaxException e) {
					throw new RuntimeException(e);
				}
			}
		}
		return classes;
	}
1350486
private void processEJBModulePersistenceXml(JPAApplInfo applInfo, ContainerInfo module, ClassLoader appClassloader) {
        final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
        if (isTraceOn && tc.isEntryEnabled())
            Tr.entry(tc, "processEJBModulePersistenceXml : " + applInfo.getApplName() +
                         "#" + module.getName());

        String archiveName = module.getName();
        Container ejbContainer = module.getContainer();
        ClassLoader ejbClassLoader = appClassloader;

        // ------------------------------------------------------------------------
        // JPA 2.0 Specification - 8.2 Persistence Unit Packaging
        //
        // A persistence unit is defined by a persistence.xml file. The jar file or
        // directory whose META-INF directory contains the persistence.xml file is
        // termed the root of the persistence unit. In Java EE environments, the
        // root of a persistence unit may be one of the following:
        //
        // -> an EJB-JAR file
        // ------------------------------------------------------------------------

        // Obtain persistence.xml in META-INF
        Entry pxml = ejbContainer.getEntry("META-INF/persistence.xml");
        if (pxml != null) {
            String appName = applInfo.getApplName();
            URL puRoot = getPXmlRootURL(appName, archiveName, pxml);
            applInfo.addPersistenceUnits(new OSGiJPAPXml(applInfo, archiveName, JPAPuScope.EJB_Scope, puRoot, ejbClassLoader, pxml));
        }

        if (isTraceOn && tc.isEntryEnabled())
            Tr.exit(tc, "processEJBModulePersistenceXml : " + applInfo.getApplName() +
                        "#" + module.getName());
    }
931813
public void processEJB(EJBEndpoint ejb, String ejbInterfaceName, ClassLoader appClassloader, Set<Class<?>> AllApplicationClasses, Set<String> AllPathProviderClassNames) {

        getEJBApplicationSubclasses(AllApplicationClasses, ejb, appClassloader);
        getEJBWithProviderClasses(AllPathProviderClassNames, ejb, ejbInterfaceName, appClassloader);
        getEJBWithPathClasses(AllPathProviderClassNames, ejb, ejbInterfaceName, appClassloader);

    }