private JarFile getJarFile(URL url) throws IOException { URLConnection conn = url.openConnection(); conn.setUseCaches(false); conn.setDefaultUseCaches(false); JarFile jarFile; if (conn instanceof JarURLConnection) { jarFile = ((JarURLConnection) conn).getJarFile(); } else { jarFile = _getAlternativeJarFile(url); } return jarFile; }
protected Collection<Class<?>> getAnnotatedMetaInfClasses(ExternalContext ctx, Set<URL> urls) { if (urls != null && !urls.isEmpty()) { List<Class<?>> list = new ArrayList<Class<?>>(); for (URL url : urls) { try { JarFile jarFile = getJarFile(url); if (jarFile != null) { archiveClasses(ctx, jarFile, list); } } catch(IOException e) { log.log(Level.SEVERE, "cannot scan jar file for annotations:"+url, e); } } return list; } return Collections.emptyList(); }
@Override public Set<URL> getBaseUrls() throws IOException { Set<URL> urlSet = new HashSet<URL>(); //This usually happens when maven-jetty-plugin is used //Scan jars looking for paths including META-INF/faces-config.xml Enumeration<URL> resources = getClassLoader().getResources(FACES_CONFIG_IMPLICIT); while (resources.hasMoreElements()) { urlSet.add(resources.nextElement()); } //Scan files inside META-INF ending with .faces-config.xml URL[] urls = Classpath.search(getClassLoader(), META_INF_PREFIX, FACES_CONFIG_SUFFIX); Collections.addAll(urlSet, urls); return urlSet; }
classes = getAnnotatedWebInfClasses(ctx); processClass(map, clazz); classes = getAnnotatedMetaInfClasses(ctx, provider.getBaseUrls()); processClass(map, clazz); URL url = getClassLoader().getResource(STANDARD_FACES_CONFIG_RESOURCE); if (url == null) classes = getAnnotatedMyfacesImplClasses(ctx, url); for (Class<?> clazz : classes) processClass(map, clazz);
classes = getAnnotatedWebInfClasses(ctx); processClass(map, clazz); classes = getGAEAnnotatedMetaInfClasses(ctx, jarAnnotationFilesToScanParam); classes = getAnnotatedMetaInfClasses(ctx, provider.getBaseUrls(ctx)); processClass(map, clazz);
protected Collection<Class<?>> getAnnotatedWebInfClasses(ExternalContext ctx) throws IOException { String scanPackages = ctx.getInitParameter(SCAN_PACKAGES); if (scanPackages != null) { try { return packageClasses(ctx, scanPackages); } catch (ClassNotFoundException e) { throw new FacesException(e); } catch (IOException e) { throw new FacesException(e); } } else { return webClasses(ctx); } }
ClassLoader loader = getClassLoader(); if (path.endsWith("/")) webClasses(externalContext, path, list);
.getJarFile(); archiveClasses(externalContext, jarFile, list);
Enumeration<URL> resources = getClassLoader().getResources(FACES_CONFIG_IMPLICIT); while (resources.hasMoreElements()) context, getClassLoader(), jarFilesToScanParam, META_INF_PREFIX, FACES_CONFIG_SUFFIX); if (urlsGAE != null) return getBaseUrls();
/** * <p>Return a list of the classes defined under the * <code>/WEB-INF/classes</code> directory of this web * application. If there are no such classes, a zero-length list * will be returned.</p> * * @param externalContext <code>ExternalContext</code> instance for * this application * * @exception ClassNotFoundException if a located class cannot be loaded */ private List<Class<?>> webClasses(ExternalContext externalContext) { List<Class<?>> list = new ArrayList<Class<?>>(); webClasses(externalContext, WEB_CLASSES_PREFIX, list); return list; }
private AnnotationProvider resolveAnnotationProviderFromService( ExternalContext externalContext) throws ClassNotFoundException, NoClassDefFoundError, InstantiationException, IllegalAccessException, InvocationTargetException, PrivilegedActionException { List<String> classList = (List<String>) externalContext.getApplicationMap().get(ANNOTATION_PROVIDER_LIST); if (classList == null) { classList = ServiceProviderFinderFactory.getServiceProviderFinder(externalContext).getServiceProviderList(ANNOTATION_PROVIDER); externalContext.getApplicationMap().put(ANNOTATION_PROVIDER_LIST, classList); } return ClassUtils.buildApplicationObject(AnnotationProvider.class, classList, new DefaultAnnotationProvider()); } }
classes = getAnnotatedWebInfClasses(ctx); processClass(map, clazz); classes = getAnnotatedMetaInfClasses(ctx, provider.getBaseUrls()); processClass(map, clazz); URL url = getClassLoader().getResource(STANDARD_FACES_CONFIG_RESOURCE); if (url == null) classes = getAnnotatedMyfacesImplClasses(ctx, url); for (Class<?> clazz : classes) processClass(map, clazz);
protected Collection<Class<?>> getAnnotatedWebInfClasses(ExternalContext ctx) throws IOException { String scanPackages = ctx.getInitParameter(SCAN_PACKAGES); if (scanPackages != null) { try { return packageClasses(ctx, scanPackages); } catch (ClassNotFoundException e) { throw new FacesException(e); } catch (IOException e) { throw new FacesException(e); } } else { return webClasses(ctx); } }
ClassLoader loader = getClassLoader(); if (path.endsWith("/")) webClasses(externalContext, path, list);
.getJarFile(); archiveClasses(externalContext, jarFile, list);
/** * <p>Return a list of the classes defined under the * <code>/WEB-INF/classes</code> directory of this web * application. If there are no such classes, a zero-length list * will be returned.</p> * * @param externalContext <code>ExternalContext</code> instance for * this application * * @exception ClassNotFoundException if a located class cannot be loaded */ private List<Class<?>> webClasses(ExternalContext externalContext) { List<Class<?>> list = new ArrayList<Class<?>>(); webClasses(externalContext, WEB_CLASSES_PREFIX, list); return list; }
private AnnotationProvider resolveAnnotationProviderFromService( ExternalContext externalContext) throws ClassNotFoundException, NoClassDefFoundError, InstantiationException, IllegalAccessException, InvocationTargetException, PrivilegedActionException { List<String> classList = (List<String>) externalContext.getApplicationMap().get(ANNOTATION_PROVIDER_LIST); if (classList == null) { classList = ServiceProviderFinderFactory.getServiceProviderFinder(externalContext). getServiceProviderList(ANNOTATION_PROVIDER); externalContext.getApplicationMap().put(ANNOTATION_PROVIDER_LIST, classList); } return ClassUtils.buildApplicationObject(AnnotationProvider.class, classList, new DefaultAnnotationProvider()); } }
protected Collection<Class<?>> getAnnotatedWebInfClasses(ExternalContext ctx) throws IOException { String scanPackages = ctx.getInitParameter(SCAN_PACKAGES); if (scanPackages != null) { try { return packageClasses(ctx, scanPackages); } catch (ClassNotFoundException e) { throw new FacesException(e); } catch (IOException e) { throw new FacesException(e); } } else { return webClasses(ctx); } }
protected Collection<Class<?>> getAnnotatedMetaInfClasses(ExternalContext ctx, Set<URL> urls) { if (urls != null && !urls.isEmpty()) { List<Class<?>> list = new ArrayList<Class<?>>(); for (URL url : urls) { try { JarFile jarFile = getJarFile(url); if (jarFile != null) { archiveClasses(jarFile, list); } } catch(IOException e) { log.log(Level.SEVERE, "cannot scan jar file for annotations:"+url, e); } } return list; } return Collections.emptyList(); }
ClassLoader loader = getClassLoader(); if (path.endsWith("/")) webClasses(externalContext, path, list);