public static Class<?> tryToLoadClassForName(String proxyClassName, Class<?> targetClass) { if (MAGIC_IN_PROGRESS.get()) { return null; } return org.apache.deltaspike.core.util.ClassUtils.tryToLoadClassForName(proxyClassName, targetClass); }
/** * Tries to load a class based on the given name and interface or abstract class. * @param name name of the concrete class * @param targetType target type (interface or abstract class) * @param <T> current type * @return loaded class or null if it isn't in the classpath */ public static <T> Class<T> tryToLoadClassForName(String name, Class<T> targetType) { return (Class<T>) tryToLoadClassForName(name); }
/** * Tries to load a class based on the given name and interface or abstract class. * @param name name of the concrete class * @param targetType target type (interface or abstract class) * @param classLoader The {@link ClassLoader}. * @param <T> current type * @return loaded class or null if it isn't in the classpath */ public static <T> Class<T> tryToLoadClassForName(String name, Class<T> targetType, ClassLoader classLoader) { return (Class<T>) tryToLoadClassForName(name, classLoader); }
/** * @return true if JSF 2.2+ is available and the delegation mode isn't deactivated via config, false otherwise */ public static boolean isViewScopeDelegationEnabled() { return ClassUtils.tryToLoadClassForName("javax.faces.view.ViewScoped") != null && JsfBaseConfig.ScopeCustomization.ViewDelegation.DELEGATE_TO_JSF; }
/** * @return true if JSF 2.2+ is available and the delegation mode isn't deactivated via config, false otherwise */ public static boolean isViewScopeDelegationEnabled() { return ClassUtils.tryToLoadClassForName("javax.faces.view.ViewScoped") != null && JsfBaseConfig.ScopeCustomization.ViewDelegation.DELEGATE_TO_JSF; }
/** * Tries to load a class based on the given name and interface or abstract class. * @param name name of the concrete class * @param targetType target type (interface or abstract class) * @param <T> current type * @return loaded class or null if it isn't in the classpath */ public static <T> Class<T> tryToLoadClassForName(String name, Class<T> targetType) { return (Class<T>) tryToLoadClassForName(name); }
/** * Tries to load a class based on the given name and interface or abstract class. * @param name name of the concrete class * @param targetType target type (interface or abstract class) * @param classLoader The {@link ClassLoader}. * @param <T> current type * @return loaded class or null if it isn't in the classpath */ public static <T> Class<T> tryToLoadClassForName(String name, Class<T> targetType, ClassLoader classLoader) { return (Class<T>) tryToLoadClassForName(name, classLoader); }
/** * Tries to load a class based on the given name and interface or abstract class. * @param name name of the concrete class * @param targetType target type (interface or abstract class) * @param <T> current type * @return loaded class or null if it isn't in the classpath */ public static <T> Class<T> tryToLoadClassForName(String name, Class<T> targetType) { return (Class<T>) tryToLoadClassForName(name); }
public FolderLiteral(boolean virtual) { if (virtual) { this.name = null; } else { this.name = ""; } final String customDefaultFolderNameBuilderClassName = JsfBaseConfig.ViewConfigCustomization.CUSTOM_DEFAULT_FOLDER_NAME_BUILDER; if (customDefaultFolderNameBuilderClassName != null) { this.folderNameBuilder = ClassUtils.tryToLoadClassForName(customDefaultFolderNameBuilderClassName); } else { this.folderNameBuilder = DefaultFolderNameBuilder.class; } }
@Override public void start() { String configuredAdapterClassName = SchedulerBaseConfig.JobCustomization.RUNNABLE_ADAPTER_CLASS_NAME; this.runnableAdapter = ClassUtils.tryToLoadClassForName(configuredAdapterClassName, Job.class); super.start(); }
private <T> Class<T> resolveAlreadyDefinedProxyClass(Class<T> targetClass) { Class<T> proxyClass = ClassUtils.tryToLoadClassForName(constructProxyClassName(targetClass), targetClass, targetClass.getClassLoader()); return proxyClass; }
protected void init(@Observes BeforeBeanDiscovery beforeBeanDiscovery) { this.isActivated = ClassDeactivationUtils.isActivated(getClass()); if (this.isActivated) { String jobClassName = SchedulerBaseConfig.JobCustomization.JOB_CLASS_NAME; this.jobClass = ClassUtils.tryToLoadClassForName(jobClassName); if (this.jobClass == null) { this.isActivated = false; } } }
/** * @return a new instance of {@link javax.annotation.Priority} with the given value * if the annotation-class is available in a cdi 1.1+ based environment, null otherwise */ public static Annotation getPriorityAnnotationInstance(int priorityValue) { Annotation priorityAnnotationInstance = null; Class<? extends Annotation> priorityAnnotationClass = ClassUtils.tryToLoadClassForName("javax.annotation.Priority"); //check for @Priority and CDI v1.1+ if (priorityAnnotationClass != null && ClassUtils.tryToLoadClassForName("javax.enterprise.inject.spi.AfterTypeDiscovery") != null) { Map<String, Object> defaultValueMap = new HashMap<String, Object>(); defaultValueMap.put("value", priorityValue); priorityAnnotationInstance = AnnotationInstanceProvider.of(priorityAnnotationClass, defaultValueMap); } return priorityAnnotationInstance; } }
@PostConstruct protected void init() { Map<String, Class> values = new HashMap<String, Class>(); values.put("value", RequestScoped.class); Class<? extends Annotation> initializedAnnotationClass = ClassUtils.tryToLoadClassForName("javax.enterprise.context.Initialized"); if (initializedAnnotationClass != null) { this.initializedAnnotationInstance = AnnotationInstanceProvider.of(initializedAnnotationClass, values); } Class<? extends Annotation> destroyedAnnotationClass = ClassUtils.tryToLoadClassForName("javax.enterprise.context.Destroyed"); if (destroyedAnnotationClass != null) { this.destroyedAnnotationInstance = AnnotationInstanceProvider.of(destroyedAnnotationClass, values); } }
/** * Default constructor which initializes the scope mapping */ public MappedJsf2ScopeExtension() { this.mappedJsfScopes.put(javax.faces.bean.ApplicationScoped.class, javax.enterprise.context.ApplicationScoped.class); this.mappedJsfScopes.put(javax.faces.bean.SessionScoped.class, javax.enterprise.context.SessionScoped.class); this.mappedJsfScopes.put(javax.faces.bean.RequestScoped.class, javax.enterprise.context.RequestScoped.class); if (JsfUtils.isViewScopeDelegationEnabled()) { this.mappedJsfScopes.put(javax.faces.bean.ViewScoped.class, ClassUtils.tryToLoadClassForName("javax.faces.view.ViewScoped")); } }
/** * Default constructor which initializes the scope mapping */ public MappedJsf2ScopeExtension() { this.mappedJsfScopes.put(javax.faces.bean.ApplicationScoped.class, javax.enterprise.context.ApplicationScoped.class); this.mappedJsfScopes.put(javax.faces.bean.SessionScoped.class, javax.enterprise.context.SessionScoped.class); this.mappedJsfScopes.put(javax.faces.bean.RequestScoped.class, javax.enterprise.context.RequestScoped.class); if (JsfUtils.isViewScopeDelegationEnabled()) { this.mappedJsfScopes.put(javax.faces.bean.ViewScoped.class, ClassUtils.tryToLoadClassForName("javax.faces.view.ViewScoped")); } }
/** * Constructor for wrapping the given {@link LifecycleFactory} * * @param wrapped lifecycle-factory which should be wrapped */ public DeltaSpikeLifecycleFactoryWrapper(LifecycleFactory wrapped) { this.wrapped = wrapped; this.deactivated = !ClassDeactivationUtils.isActivated(getClass()); boolean jsfVersionWithClientWindowDetected = ClassUtils.tryToLoadClassForName(JsfModuleConfig.CLIENT_WINDOW_CLASS_NAME) != null; if (jsfVersionWithClientWindowDetected && ClassUtils.tryToLoadClassForName( "org.apache.deltaspike.jsf.impl.listener.request.JsfClientWindowAwareLifecycleWrapper") == null) { jsfVersionWithClientWindowDetected = false; JsfUtils.logWrongModuleUsage(getClass().getName()); } this.jsfVersionWithClientWindowDetected = jsfVersionWithClientWindowDetected; }
@PostConstruct protected void init() { Map<String, Class> values = new HashMap<String, Class>(); values.put("value", RequestScoped.class); Class<? extends Annotation> initializedAnnotationClass = ClassUtils.tryToLoadClassForName("javax.enterprise.context.Initialized"); if (initializedAnnotationClass != null) { this.initializedAnnotationInstance = AnnotationInstanceProvider.of(initializedAnnotationClass, values); } Class<? extends Annotation> destroyedAnnotationClass = ClassUtils.tryToLoadClassForName("javax.enterprise.context.Destroyed"); if (destroyedAnnotationClass != null) { this.destroyedAnnotationInstance = AnnotationInstanceProvider.of(destroyedAnnotationClass, values); } }
/** * Constructor for wrapping the given {@link LifecycleFactory} * * @param wrapped lifecycle-factory which should be wrapped */ public DeltaSpikeLifecycleFactoryWrapper(LifecycleFactory wrapped) { this.wrapped = wrapped; this.deactivated = !ClassDeactivationUtils.isActivated(getClass()); boolean jsfVersionWithClientWindowDetected = ClassUtils.tryToLoadClassForName(JsfModuleConfig.CLIENT_WINDOW_CLASS_NAME) != null; if (jsfVersionWithClientWindowDetected && ClassUtils.tryToLoadClassForName( "org.apache.deltaspike.jsf.impl.listener.request.JsfClientWindowAwareLifecycleWrapper") == null) { jsfVersionWithClientWindowDetected = false; JsfUtils.logWrongModuleUsage(getClass().getName()); } this.jsfVersionWithClientWindowDetected = jsfVersionWithClientWindowDetected; }
@Override public void execute(JobExecutionContext context) throws JobExecutionException { Class<? extends Runnable> jobClass = ClassUtils.tryToLoadClassForName(context.getJobDetail().getKey().getName(), Runnable.class); Runnable runnableBean = BeanProvider.getContextualReference(jobClass); try { runnableBean.run(); } catch (Throwable t) { //just in this case to reduce the implementation(s) of runnable (annotated with @Scheduled) //to an absolute minimum. //(custom implementations of org.quartz.Job need to do it on their own) this.beanManager.fireEvent(new ExceptionToCatchEvent(t)); } } }