public Object newInstance(String className) throws InstantiationException, IllegalAccessException, InvocationTargetException, ClassNotFoundException { Class clazz = ClassUtils.classForName(className); return clazz.newInstance(); }
private InputSource createClassloaderInputSource(String publicId, String systemId) { InputStream inStream = ClassUtils.getResourceAsStream(systemId); if (inStream == null) { // there is no such entity return null; } InputSource is = new InputSource(inStream); is.setPublicId(publicId); is.setSystemId(systemId); //the next line was removed - encoding should be determined automatically out of the inputStream //encoding should be determined automatically out of the inputStream //DEFAULT_ENCODING was ISO-8859-1 //is.setEncoding(DEFAULT_ENCODING); return is; }
public static Object newInstance(String type) throws FacesException { if (type == null) return null; return newInstance(simpleClassForName(type)); }
private Object createClass(String className, ExternalContext externalContext) throws InstantiationException, IllegalAccessException, InvocationTargetException, ClassNotFoundException { Class<?> clazz = ClassUtils.classForName(className); try { return ClassUtils.newInstance(clazz, new Class<?>[]{ ExternalContext.class }, externalContext); } catch (NoSuchMethodException e) { return ClassUtils.newInstance(clazz); } }
private void initializeList(FacesContext facesContext, ListEntries listEntries, List<? super Object> list) { Application application = facesContext.getApplication(); Class<?> valueClass = (listEntries.getValueClass() == null) ? String.class : ClassUtils.simpleJavaTypeToClass(listEntries.getValueClass()); ExpressionFactory expFactory = application.getExpressionFactory(); ELContext elContext = facesContext.getELContext(); for (Iterator<? extends ListEntry> iterator = listEntries.getListEntries(); iterator.hasNext();) { ListEntry entry = iterator.next(); if (entry.isNullValue()) { list.add(null); } else { Object value = entry.getValue(); if (ContainerUtils.isValueReference((String) value)) { ValueExpression valueExpression = expFactory.createValueExpression(elContext, (String) value, Object.class); value = valueExpression.getValue(elContext); } list.add(coerceToType(facesContext, value, valueClass)); } } }
public static Object newInstance(String type, Class expectedType) throws FacesException { return newInstance(type, expectedType == null ? null : new Class[] {expectedType}); }
/** * @param resource Name of resource(s) to find in classpath * @param defaultObject The default object to use to determine the class loader (if none associated with current thread.) * @return Iterator over URL Objects */ public static Iterator getResources(String resource, Object defaultObject) { try { Enumeration resources = getCurrentLoader(defaultObject).getResources(resource); List lst = new ArrayList(); while (resources.hasMoreElements()) { lst.add(resources.nextElement()); } return lst.iterator(); } catch (IOException e) { log.log(Level.SEVERE, e.getMessage(), e); throw new FacesException(e); } }
public Class getManagedBeanClass() { if (beanClassName == null) { return null; } if (beanClass == null) { beanClass = ClassUtils.simpleClassForName(beanClassName); } return beanClass; }
/** * Returns the ClassLoader to use when looking up resources under the top level package. By default, this is the * context class loader. * * @return the ClassLoader used to lookup resources */ protected ClassLoader getClassLoader() { return ClassUtils.getContextClassLoader(); }
/** * Creates ApplicationObjects like NavigationHandler or StateManager and creates * the right wrapping chain of the ApplicationObjects known as the decorator pattern. * @param <T> * @param interfaceClass The class from which the implementation has to inherit from. * @param classNamesIterator All the class names of the actual ApplicationObject implementations * from the faces-config.xml. * @param defaultObject The default implementation for the given ApplicationObject. * @return */ public static <T> T buildApplicationObject(Class<T> interfaceClass, Collection<String> classNamesIterator, T defaultObject) { return buildApplicationObject(interfaceClass, null, null, classNamesIterator, defaultObject); }
URL url = ClassUtils.getResource(STANDARD_FACES_CONFIG_RESOURCE); if (url != null) InputStream stream = ClassUtils.getResourceAsStream(STANDARD_FACES_CONFIG_RESOURCE); if (stream == null) throw new FacesException("Standard faces config " + STANDARD_FACES_CONFIG_RESOURCE + " not found");
/** * This method fixes MYFACES-208 */ private void feedClassloaderConfigurations() { try { Iterator it = ClassUtils.getResources(FACES_CONFIG_RESOURCE, this); while (it.hasNext()) { URL url = (URL) it.next(); InputStream stream = openStreamWithoutCache(url); String systemId = url.toExternalForm(); if (log.isInfoEnabled()) log.info("Reading config " + systemId); getDispenser().feed(getUnmarshaller().getFacesConfig(stream, systemId)); stream.close(); } } catch (Throwable e) { throw new FacesException(e); } }
/** * Same as {@link #javaTypeToClass(String)}, but throws a RuntimeException * (FacesException) instead of a ClassNotFoundException. * * @return the corresponding Class * @throws NullPointerException if type is null * @throws FacesException if class not found */ public static Class simpleJavaTypeToClass(String type) { try { return javaTypeToClass(type); } catch (ClassNotFoundException e) { log.log(Level.SEVERE, "Class " + type + " not found", e); throw new FacesException(e); } }
private void initializeList(FacesContext facesContext, ListEntries listEntries, List list) { Application application = facesContext.getApplication(); Class valueClass = listEntries.getValueClass() == null ? String.class : ClassUtils.simpleJavaTypeToClass(listEntries.getValueClass()); ExpressionFactory expFactory = application.getExpressionFactory(); ELContext elContext = facesContext.getELContext(); for (Iterator iterator = listEntries.getListEntries(); iterator.hasNext();) { ListEntry entry = (ListEntry) iterator.next(); if (entry.isNullValue()) { list.add(null); } else { Object value = entry.getValue(); if (ContainerUtils.isValueReference((String) value)) { ValueExpression valueExpression = expFactory.createValueExpression(elContext, (String) value, Object.class); value = valueExpression.getValue(elContext); } list.add(coerceToType(facesContext, value, valueClass)); } } }
public static Object newInstance(String type, Class expectedType) throws FacesException { return newInstance(type, expectedType == null ? null : new Class[] {expectedType}); }
private Object createClass(String className, ExternalContext externalContext) throws InstantiationException, IllegalAccessException, InvocationTargetException, ClassNotFoundException { Class<?> clazz = ClassUtils.classForName(className); try { return ClassUtils.newInstance(clazz, new Class<?>[]{ ExternalContext.class }, externalContext); } catch (NoSuchMethodException e) { return ClassUtils.newInstance(clazz); } }
/** * @param resource Name of resource(s) to find in classpath * @param defaultObject The default object to use to determine the class loader (if none associated with current thread.) * @return Iterator over URL Objects */ public static Iterator getResources(String resource, Object defaultObject) { try { Enumeration resources = getCurrentLoader(defaultObject).getResources(resource); List lst = new ArrayList(); while (resources.hasMoreElements()) { lst.add(resources.nextElement()); } return lst.iterator(); } catch (IOException e) { log.error(e.getMessage(), e); throw new FacesException(e); } }
public Class<?> getManagedBeanClass() { if (beanClassName == null) { return null; } if (beanClass == null) { beanClass = ClassUtils.simpleClassForName(beanClassName); } return beanClass; }
/** * Returns the ClassLoader to use when looking up resources under the top level package. By default, this is the * context class loader. * * @return the ClassLoader used to lookup resources */ protected ClassLoader getClassLoader() { return ClassUtils.getContextClassLoader(); }
/** * Creates ApplicationObjects like NavigationHandler or StateManager and creates * the right wrapping chain of the ApplicationObjects known as the decorator pattern. * @param <T> * @param interfaceClass The class from which the implementation has to inherit from. * @param classNamesIterator All the class names of the actual ApplicationObject implementations * from the faces-config.xml. * @param defaultObject The default implementation for the given ApplicationObject. * @return */ public static <T> T buildApplicationObject(Class<T> interfaceClass, Collection<String> classNamesIterator, T defaultObject) { return buildApplicationObject(interfaceClass, null, null, classNamesIterator, defaultObject); }