/** * Get the component class. * * @return the component class */ public Class<?> getComponentClass() { return classIndex.getModuleClass(); }
public ClassIndex classIndex(final String className) throws ClassNotFoundException { ClassIndex classIndex = index.get(className); if (classIndex == null) { final ClassLoader oldTccl = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged(); try { WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(module.getClassLoader()); final Class<?> clazz = Class.forName(className, false, module.getClassLoader()); index.put(className, classIndex = new ClassIndex(clazz, deploymentReflectionIndex)); } finally { WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(oldTccl); } } return classIndex; }
/** * Get the set of currently known component methods. This is an identity set. * * @return the set of methods */ public Set<Method> getDefinedComponentMethods() { return classIndex.getClassMethods(); }
private void handleInterceptorClass(final Class<?> clazz, final MethodIdentifier methodIdentifier, final Map<String, List<InterceptorFactory>> classMap, final boolean changeMethod, final boolean lifecycleMethod) throws DeploymentUnitProcessingException { if (methodIdentifier != null) { final Method method = ClassReflectionIndexUtil.findRequiredMethod(deploymentReflectionIndex, clazz, methodIdentifier); if (isNotOverriden(clazz, method, interceptorClass.getModuleClass(), deploymentReflectionIndex)) { final InterceptorFactory interceptorFactory = new ManagedReferenceLifecycleMethodInterceptorFactory(contextKey, method, changeMethod, lifecycleMethod); List<InterceptorFactory> factories = classMap.get(interceptorClassName); if (factories == null) { classMap.put(interceptorClassName, factories = new ArrayList<InterceptorFactory>()); } factories.add(interceptorFactory); } } } }.run();
/** * Adds a timeout interceptor factory to every method on the component. * * @param factory The interceptor factory to add * @param priority The interceptors relative order */ public void addTimeoutViewInterceptor(InterceptorFactory factory, int priority) { for (Method method : classIndex.getClassMethods()) { OrderedItemContainer<InterceptorFactory> interceptors = timeoutInterceptors.get(method); if (interceptors == null) { timeoutInterceptors.put(method, interceptors = new OrderedItemContainer<InterceptorFactory>()); } interceptors.add(factory, priority); } }
public ClassIndex classIndex(final String className) throws ClassNotFoundException { ClassIndex classIndex = index.get(className); if (classIndex == null) { final ClassLoader oldTccl = SecurityActions.getContextClassLoader(); try { SecurityActions.setContextClassLoader(module.getClassLoader()); final Class<?> clazz = Class.forName(className, false, module.getClassLoader()); index.put(className, classIndex = new ClassIndex(clazz, deploymentReflectionIndex)); } finally { SecurityActions.setContextClassLoader(oldTccl); } } return classIndex; }
private void processComponentConfig(final EEApplicationClasses applicationClasses, final DeploymentClassIndex classIndex, final DeploymentReflectionIndex deploymentReflectionIndex, final ComponentDescription description) throws DeploymentUnitProcessingException { final Class<?> componentClass; try { componentClass = classIndex.classIndex(description.getComponentClassName()).getModuleClass(); } catch (ClassNotFoundException e) { //just ignore the class for now. //if it is an optional component this is ok, if it is not an optional component //it will fail at configure time anyway return; } handleAnnotations(applicationClasses, deploymentReflectionIndex, componentClass, description); }
/** * Adds an interceptor factory to every method on the component. * * @param factory The interceptor factory to add * @param priority The interceptors relative order * @param publicOnly If true then then interceptor is only added to public methods */ public void addComponentInterceptor(InterceptorFactory factory, int priority, boolean publicOnly) { for (Method method : classIndex.getClassMethods()) { if (publicOnly && !Modifier.isPublic(method.getModifiers())) { continue; } OrderedItemContainer<InterceptorFactory> interceptors = componentInterceptors.get(method); if (interceptors == null) { componentInterceptors.put(method, interceptors = new OrderedItemContainer<InterceptorFactory>()); } interceptors.add(factory, priority); } }
final DeploymentClassIndex index = phaseContext.getDeploymentUnit().getAttachment(org.jboss.as.server.deployment.Attachments.CLASS_INDEX); try { type = index.classIndex(targetTypeName).getModuleClass(); } catch (ClassNotFoundException e) { throw new RuntimeException(e);
configuration.addTimeoutViewInterceptor(new SecurityContextInterceptorFactory(), InterceptorOrder.View.SECURITY_CONTEXT); for (final Method method : configuration.getClassIndex().getClassMethods()) { configuration.addTimeoutViewInterceptor(method, new ImmediateInterceptorFactory(new ComponentDispatcherInterceptor(method)), InterceptorOrder.View.COMPONENT_DISPATCHER);
/** * Handles setting up the ejbCreate and ejbRemove methods for stateless session beans and MDB's * * @param component The component * @param classIndex The class index * @param reflectionIndex The reflection index */ private void handleStatelessSessionBean(final EJBComponentDescription component, final DeploymentClassIndex classIndex, final DeploymentReflectionIndex reflectionIndex) throws ClassNotFoundException, DeploymentUnitProcessingException { final ClassIndex componentClass = classIndex.classIndex(component.getComponentClassName()); final MethodIdentifier ejbCreateId = MethodIdentifier.getIdentifier(void.class, "ejbCreate"); final Method ejbCreate = ClassReflectionIndexUtil.findMethod(reflectionIndex, componentClass.getModuleClass(), ejbCreateId); if (ejbCreate != null) { final InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder(); builder.setPostConstruct(ejbCreateId); component.addInterceptorMethodOverride(ejbCreate.getDeclaringClass().getName(), builder.build()); } final MethodIdentifier ejbRemoveId = MethodIdentifier.getIdentifier(void.class, "ejbRemove"); final Method ejbRemove = ClassReflectionIndexUtil.findMethod(reflectionIndex, componentClass.getModuleClass(), ejbRemoveId); if (ejbRemove != null) { final InterceptorClassDescription.Builder builder = InterceptorClassDescription.builder(); builder.setPreDestroy(ejbRemoveId); component.addInterceptorMethodOverride(ejbRemove.getDeclaringClass().getName(), builder.build()); } }
ejbObjectClass = classIndex.classIndex(ejbObjectView.getViewClassName()).getModuleClass(); } catch (ClassNotFoundException e) { throw MESSAGES.failedToLoadViewClassForComponent(e, componentDescription.getComponentName());
final InterceptorClassDescriptionTraversal interceptorClassDescriptionTraversal = new InterceptorClassDescriptionTraversal(interceptorClassIndex.getModuleClass(), applicationClasses, deploymentUnit, ejbComponentDescription); interceptorClassDescriptionTraversal.run();
final Class<?> pkClass; try { ejbObjectClass = classIndex.classIndex(createdView.getViewClassName()).getModuleClass(); pkClass = classIndex.classIndex(componentDescription.getPrimaryKeyType()).getModuleClass(); } catch (ClassNotFoundException e) { throw MESSAGES.failedToLoadViewClassForComponent(e, componentDescription.getComponentName());
@Override public void configure(final DeploymentPhaseContext context, final ComponentDescription description, final ComponentConfiguration configuration) throws DeploymentUnitProcessingException { final Class<?> componentClass = configuration.getComponentClass(); final DeploymentUnit deploymentUnit = context.getDeploymentUnit(); final ModuleClassLoader classLoader = deploymentUnit.getAttachment(Attachments.MODULE).getClassLoader(); //get the interceptors so they can be injected as well final Set<Class<?>> interceptorClasses = new HashSet<Class<?>>(); for (InterceptorDescription interceptorDescription : description.getAllInterceptors()) { try { final ClassIndex index = classIndex.classIndex(interceptorDescription.getInterceptorClassName()); interceptorClasses.add(index.getModuleClass()); } catch (ClassNotFoundException e) { throw WeldMessages.MESSAGES.couldNotLoadInterceptorClass(interceptorDescription.getInterceptorClassName(), e); } } addWeldIntegration(context.getServiceTarget(), configuration, description, componentClass, beanName, weldBootstrapService, weldStartService, interceptorClasses, classLoader, description.getBeanDeploymentArchiveId()); configuration.addPostConstructInterceptor(new WeldInjectionInterceptor.Factory(configuration, interceptorClasses), InterceptorOrder.ComponentPostConstruct.WELD_INJECTION); //add a context key for weld interceptor replication if (description instanceof StatefulComponentDescription) { configuration.getInterceptorContextKeys().add(SerializedCdiInterceptorsKey.class); } } });
final Object contextKey = interceptorClass.getModuleClass(); configuration.getInterceptorContextKeys().add(contextKey); final ClassReflectionIndex<?> interceptorIndex = deploymentReflectionIndex.getClassIndex(interceptorClass.getModuleClass()); final Constructor<?> constructor = interceptorIndex.getConstructor(EMPTY_CLASS_ARRAY); if (constructor == null) { new ClassDescriptionTraversal(interceptorClass.getModuleClass(), applicationClasses) { @Override public void handle(final Class<?> clazz, EEModuleClassDescription classDescription) throws DeploymentUnitProcessingException {
if (appClientData != null && appClientData.getCallbackHandler() != null && !appClientData.getCallbackHandler().isEmpty()) { try { final Class<?> callbackClass = classIndex.classIndex(appClientData.getCallbackHandler()).getModuleClass(); callbackHandler = new RealmCallbackWrapper((CallbackHandler) callbackClass.newInstance()); } catch (ClassNotFoundException e) {
try { final ClassIndex index = classIndex.classIndex(exception.getKey()); applicationExceptions.addApplicationException(index.getModuleClass(), exception.getValue()); } catch (ClassNotFoundException e) { ROOT_LOGGER.debug("Could not load application exception class", e); applicationExceptions.addApplicationException(index.getModuleClass(), new ApplicationExceptionDetails(exceptionClassName, inherited, rollback)); } catch (ClassNotFoundException e) { throw MESSAGES.failToLoadAppExceptionClassInEjbJarXml(exceptionClassName,e);
builder.setAroundInvoke(methodIdentifier); if (aroundInvoke.getClassName() == null || aroundInvoke.getClassName().isEmpty()) { final String className = ClassReflectionIndexUtil.findRequiredMethod(reflectionIndex, componentClass.getModuleClass(), methodIdentifier).getDeclaringClass().getName(); component.addInterceptorMethodOverride(className, builder.build()); } else { builder.setPostConstruct(methodIdentifier); if (postConstruct.getClassName() == null || postConstruct.getClassName().isEmpty()) { final String className = ClassReflectionIndexUtil.findRequiredMethod(reflectionIndex, componentClass.getModuleClass(), methodIdentifier).getDeclaringClass().getName(); component.addInterceptorMethodOverride(className, builder.build()); } else { builder.setPreDestroy(methodIdentifier); if (preDestroy.getClassName() == null || preDestroy.getClassName().isEmpty()) { final String className = ClassReflectionIndexUtil.findRequiredMethod(reflectionIndex, componentClass.getModuleClass(), methodIdentifier).getDeclaringClass().getName(); component.addInterceptorMethodOverride(className, builder.build()); } else { builder.setPrePassivate(methodIdentifier); if (prePassivate.getClassName() == null || prePassivate.getClassName().isEmpty()) { final String className = ClassReflectionIndexUtil.findRequiredMethod(reflectionIndex, componentClass.getModuleClass(), methodIdentifier).getDeclaringClass().getName(); component.addInterceptorMethodOverride(className, builder.build()); } else { builder.setPostActivate(methodIdentifier); if (postActivate.getClassName() == null || postActivate.getClassName().isEmpty()) { final String className = ClassReflectionIndexUtil.findRequiredMethod(reflectionIndex, componentClass.getModuleClass(), methodIdentifier).getDeclaringClass().getName(); component.addInterceptorMethodOverride(className, builder.build()); } else {
try { final ClassIndex interceptorClass = classIndex.classIndex(interceptor.getInterceptorClassName()); classConfigurations.add(interceptorClass.getModuleClass()); } catch (ClassNotFoundException e) { throw MESSAGES.cannotLoadInterceptor(e, interceptor.getInterceptorClassName(), componentConfiguration.getComponentClass());