@Override public Field lookup(ClassReflectionIndex index) { return index.getField(name); } }, 0, Integer.MAX_VALUE);
/** * 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(); }
/** * Get the component class. * * @return the component class */ public Class<?> getComponentClass() { return classIndex.getIndexedClass(); }
private String inferRemoteInterfaceFromHome(final String homeClassName, final Module module, final DeploymentReflectionIndex deploymentReflectionIndex, final SessionBeanComponentDescription description) throws ClassNotFoundException, DeploymentUnitProcessingException { final Class<?> homeClass = module.getClassLoader().loadClass(homeClassName); final ClassReflectionIndex index = deploymentReflectionIndex.getClassIndex(homeClass); Class<?> remote = null; for (final Method method : (Iterable<Method>)index.getMethods()) { if (method.getName().startsWith("create")) { if (remote != null && remote != method.getReturnType()) { throw EjbLogger.ROOT_LOGGER.multipleCreateMethod(homeClass); } remote = method.getReturnType(); } } if(remote == null) { throw EjbLogger.ROOT_LOGGER.couldNotDetermineRemoteInterfaceFromHome(homeClassName, description.getEJBName()); } return remote.getName(); }
private Method translateMethod(final DeploymentReflectionIndex deploymentReflectionIndex, final OperationAnalysis op) { final Method nonMethod = op.getMethod(); return deploymentReflectionIndex.getClassIndex(nonMethod.getDeclaringClass()).getMethod(nonMethod); }
private Method findRealMethodForBridgeMethod(final Method componentMethod, final ComponentConfiguration componentConfiguration, final DeploymentReflectionIndex reflectionIndex, final MethodIdentifier methodIdentifier) { final ClassReflectionIndex classIndex = reflectionIndex.getClassIndex(componentMethod.getDeclaringClass()); //the non-bridge method will be on the same class as the bridge method final Collection<Method> methods = classIndex.getAllMethods(componentMethod.getName(), componentMethod.getParameterTypes().length); for(final Method method : methods) { if ((BRIDGE & method.getModifiers()) == 0) { if(componentMethod.getReturnType().isAssignableFrom(method.getReturnType())) { boolean ok = true; for(int i = 0; i < method.getParameterTypes().length; ++i) { if(!componentMethod.getParameterTypes()[i].isAssignableFrom(method.getParameterTypes()[i])) { ok = false; break; } } if(ok) { return method; } } } } return null; } }
public Method getMethod(final DeploymentReflectionIndex reflectionIndex, final Class<?> clazz) throws DeploymentUnitProcessingException { final ClassReflectionIndex classIndex = reflectionIndex.getClassIndex(clazz); Collection<Method> methods = null; final String paramType = getDeclaredValueClassName(); final String name = getName(); final String className = getClassName(); if (paramType != null) { // find the methods with the specific name and the param types methods = ClassReflectionIndexUtil.findMethods(reflectionIndex, classIndex, name, paramType); } // either paramType is not set, or we may need to find autoboxing methods // e.g. setMyBoolean(boolean) for a Boolean if (methods == null || methods.isEmpty()) { // find all the methods with the specific name and which accept just 1 parameter. methods = ClassReflectionIndexUtil.findAllMethods(reflectionIndex, classIndex, name, 1); } Iterator<Method> iterator = methods.iterator(); if (!iterator.hasNext()) { throw EeLogger.ROOT_LOGGER.methodNotFound(name, paramType, className); } Method method = iterator.next(); if (iterator.hasNext()) { throw EeLogger.ROOT_LOGGER.multipleMethodsFound(name, paramType, className); } return method; } }
private Field getField(final DeploymentUnit deploymentUnit) throws DeploymentUnitProcessingException { final String name = getName(); final String className = getClassName(); final Module module = deploymentUnit.getAttachment(MODULE); final ModuleClassLoader classLoader = module.getClassLoader(); final DeploymentReflectionIndex reflectionIndex = deploymentUnit.getAttachment(REFLECTION_INDEX); final ClassReflectionIndex classIndex; try { classIndex = reflectionIndex.getClassIndex(Class.forName(className, false, classLoader)); } catch (ClassNotFoundException e) { throw new DeploymentUnitProcessingException(e); } final Field field = classIndex.getField(name); if (field == null) { throw EeLogger.ROOT_LOGGER.fieldNotFound(name); } return field; } }
protected boolean isNotOverriden(final Class<?> clazz, final Method method, final Class<?> actualClass, final DeploymentReflectionIndex deploymentReflectionIndex) throws DeploymentUnitProcessingException { return Modifier.isPrivate(method.getModifiers()) || ClassReflectionIndexUtil.findRequiredMethod(deploymentReflectionIndex, actualClass, method).getDeclaringClass() == clazz; } }
public Constructor<T> lookup(ClassReflectionIndex index) { final Constructor ctor = index.getConstructor(parameterTypes); if (ctor == null) throw PojoLogger.ROOT_LOGGER.ctorNotFound(Arrays.toString(parameterTypes), beanClass.getName()); return ctor; } }, 0, 1);
/** * Get temp bean info. * * @param clazz the class * @return bean info */ @SuppressWarnings({"unchecked"}) protected static BeanInfo getTempBeanInfo(Class<?> clazz) { return new DefaultBeanInfo(DeploymentReflectionIndex.create(), clazz); }
private String inferLocalInterfaceFromLocalHome(final String localHomeClassName, final Module module, final DeploymentReflectionIndex deploymentReflectionIndex, final SessionBeanComponentDescription description) throws ClassNotFoundException, DeploymentUnitProcessingException { final Class<?> localHomeClass = module.getClassLoader().loadClass(localHomeClassName); final ClassReflectionIndex index = deploymentReflectionIndex.getClassIndex(localHomeClass); Class<?> localClass = null; for (final Method method : (Iterable<Method>)index.getMethods()) { if (method.getName().startsWith("create")) { if (localClass != null && localClass != method.getReturnType()) { throw EjbLogger.ROOT_LOGGER.multipleCreateMethod(localHomeClass); } localClass = method.getReturnType(); } } if (localClass == null) { throw EjbLogger.ROOT_LOGGER.couldNotDetermineLocalInterfaceFromLocalHome(localHomeClassName, description.getEJBName()); } return localClass.getName(); }
@Override protected void handleDeploymentDescriptor(final DeploymentUnit deploymentUnit, final DeploymentReflectionIndex deploymentReflectionIndex, final Class<?> componentClass, final StatefulComponentDescription description) throws DeploymentUnitProcessingException { final DeploymentReflectionIndex reflectionIndex = deploymentUnit.getAttachment(Attachments.REFLECTION_INDEX); //if we implement SessionSynchronization we can ignore any DD information if (SessionSynchronization.class.isAssignableFrom(componentClass)) { final ClassReflectionIndex classIndex = reflectionIndex.getClassIndex(SessionSynchronization.class); description.setAfterBegin(classIndex.getMethod(void.class, "afterBegin")); description.setAfterCompletion(classIndex.getMethod(void.class, "afterCompletion", boolean.class)); description.setBeforeCompletion(classIndex.getMethod(void.class,"beforeCompletion")); return; } SessionBeanMetaData data = description.getDescriptorData(); if (data instanceof SessionBean31MetaData) { SessionBean31MetaData metaData = (SessionBean31MetaData) data; if (metaData.getAfterBeginMethod() != null) description.setAfterBegin(MethodResolutionUtils.resolveMethod(metaData.getAfterBeginMethod(), componentClass,reflectionIndex)); if (metaData.getAfterCompletionMethod() != null) description.setAfterCompletion(MethodResolutionUtils.resolveMethod(metaData.getAfterCompletionMethod(), componentClass,reflectionIndex)); if (metaData.getBeforeCompletionMethod() != null) description.setBeforeCompletion(MethodResolutionUtils.resolveMethod(metaData.getBeforeCompletionMethod(), componentClass,reflectionIndex)); } } }
private boolean isNotOverriden(final Class<?> clazz, final Method method, final Class<?> actualClass, final DeploymentReflectionIndex deploymentReflectionIndex) throws DeploymentUnitProcessingException { return Modifier.isPrivate(method.getModifiers()) || ClassReflectionIndexUtil.findRequiredMethod(deploymentReflectionIndex, actualClass, method).getDeclaringClass() == clazz; }
/** * 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 : (Iterable<Method>)classIndex.getClassMethods()) { OrderedItemContainer<InterceptorFactory> interceptors = timeoutInterceptors.get(method); if (interceptors == null) { timeoutInterceptors.put(method, interceptors = new OrderedItemContainer<InterceptorFactory>()); } interceptors.add(factory, priority); } }
@Override public void configure(final DeploymentPhaseContext context, final ComponentConfiguration componentConfiguration, final ViewDescription description, final ViewConfiguration configuration) throws DeploymentUnitProcessingException { final DeploymentReflectionIndex index = context.getDeploymentUnit().getAttachment(org.jboss.as.server.deployment.Attachments.REFLECTION_INDEX); ClassReflectionIndex classIndex = index.getClassIndex(WriteReplaceInterface.class); for (Method method : (Collection<Method>)classIndex.getMethods()) { configuration.addClientInterceptor(method, StatelessWriteReplaceInterceptor.factory(configuration.getViewServiceName().getCanonicalName()), InterceptorOrder.Client.WRITE_REPLACE); } } });
private boolean isNotOverriden(final Method method, final Class<?> actualClass, final DeploymentReflectionIndex deploymentReflectionIndex) throws DeploymentUnitProcessingException { return Modifier.isPrivate(method.getModifiers()) || ClassReflectionIndexUtil.findRequiredMethod(deploymentReflectionIndex, actualClass, method).getDeclaringClass() == method.getDeclaringClass(); } }
@Override public void configure(final DeploymentPhaseContext context, final ComponentConfiguration componentConfiguration, final ViewDescription description, final ViewConfiguration configuration) throws DeploymentUnitProcessingException { final DeploymentReflectionIndex index = context.getDeploymentUnit().getAttachment(org.jboss.as.server.deployment.Attachments.REFLECTION_INDEX); ClassReflectionIndex classIndex = index.getClassIndex(WriteReplaceInterface.class); for (Method method : classIndex.getMethods()) { configuration.addClientInterceptor(method, StatelessWriteReplaceInterceptor.factory(configuration.getViewServiceName().getCanonicalName()), InterceptorOrder.Client.WRITE_REPLACE); } } });
private InterceptorFactory createInterceptorFactory(final Class<?> clazz, final MethodIdentifier methodIdentifier, final Constructor<?> interceptorClassConstructor) throws DeploymentUnitProcessingException { if (methodIdentifier == null) { return null; } final Method method = ClassReflectionIndexUtil.findRequiredMethod(deploymentReflectionIndex, clazz, methodIdentifier); if (isNotOverriden(clazz, method, this.interceptorClass, deploymentReflectionIndex)) { return this.createInterceptorFactoryForContainerInterceptor(method, interceptorClassConstructor); } return null; }
@Override public void configure(final DeploymentPhaseContext context, final ComponentConfiguration componentConfiguration, final ViewDescription description, final ViewConfiguration configuration) throws DeploymentUnitProcessingException { final DeploymentReflectionIndex index = context.getDeploymentUnit().getAttachment(org.jboss.as.server.deployment.Attachments.REFLECTION_INDEX); ClassReflectionIndex classIndex = index.getClassIndex(WriteReplaceInterface.class); for (Method method : (Collection<Method>)classIndex.getMethods()) { configuration.addClientInterceptor(method, new StatefulWriteReplaceInterceptor.Factory(configuration.getViewServiceName().getCanonicalName()), InterceptorOrder.Client.WRITE_REPLACE); } } });