@Override public Method lookup(ClassReflectionIndex index) { Collection<Method> methods = index.getMethods(name, parameterTypes); int size = methods.size(); switch (size) { case 0: return null; case 1: return methods.iterator().next(); default: throw PojoLogger.ROOT_LOGGER.ambiguousMatch(methods, name, beanClass.getName()); } } }, 0, Integer.MAX_VALUE);
static Method getGetter(final List<ClassReflectionIndex> classHierarchy, final String propertyName) { final String getterName = "get" + Character.toUpperCase(propertyName.charAt(0)) + propertyName.substring(1); final String iserName = "is" + Character.toUpperCase(propertyName.charAt(0)) + propertyName.substring(1); for (final ClassReflectionIndex classIndex : classHierarchy) { final Iterator<Method> methods = classIndex.getMethods().iterator(); Method method = null; String methodName = null; while (methods.hasNext()) { method = methods.next(); methodName = method.getName(); if ((getterName.equals(methodName) || iserName.equals(methodName)) && method.getParameterTypes().length == 0) { return method; } } } final String className = classHierarchy.get(0).getIndexedClass().getName(); throw SarLogger.ROOT_LOGGER.propertyMethodNotFound("Get", propertyName, className); }
static Method getSetter(final List<ClassReflectionIndex> classHierarchy, final String propertyName) { final String setterName = "set" + Character.toUpperCase(propertyName.charAt(0)) + propertyName.substring(1); for (final ClassReflectionIndex classIndex : classHierarchy) { final Iterator<Method> methods = classIndex.getMethods().iterator(); Method method = null; String methodName = null; while (methods.hasNext()) { method = methods.next(); methodName = method.getName(); if (setterName.equals(methodName) && method.getParameterTypes().length == 1) { return method; } } } final String className = classHierarchy.get(0).getIndexedClass().getName(); throw SarLogger.ROOT_LOGGER.propertyMethodNotFound("Set", propertyName, className); }
/** * Find method info * * @param classInfo the class info * @param name the method name * @param paramTypes the parameter types * @param isStatic must the method be static * @param isPublic must the method be public * @param strict is strict about method modifiers * @return the method info or null if not found */ @SuppressWarnings("unchecked") private static Method locateMethod(ClassReflectionIndex classInfo, String name, String[] paramTypes, boolean isStatic, boolean isPublic, boolean strict) { Collection<Method> methods = classInfo.getMethods(); if (methods != null) { for (Method method : methods) { if (name.equals(method.getName()) && equals(paramTypes, method.getParameterTypes()) && (strict == false || (Modifier.isStatic(method.getModifiers()) == isStatic && Modifier.isPublic(method.getModifiers()) == isPublic))) return method; } } return null; }
static Method getMethod(final List<ClassReflectionIndex> classHierarchy, final String methodName, final Class<?>[] types, final boolean fail) { for (final ClassReflectionIndex classIndex : classHierarchy) { final Collection<Method> methods = classIndex.getMethods(methodName, types); if (methods.size() == 1) { return methods.iterator().next(); } } if (fail) { final String className = classHierarchy.get(0).getIndexedClass().getName(); throw SarLogger.ROOT_LOGGER.methodNotFound(methodName, parameterList(types), className); } else { return null; } }
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 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(); }
for (Method method : (Iterable<Method>)classIndex.getMethods()) {
@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); } } });
@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); } } });
@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); } } });
final ClassReflectionIndex index = deploymentReflectionIndex.getClassIndex(clazz); for (Method method : (Iterable<Method>)index.getMethods()) { if (method.getName().startsWith("ejbCreate")) {
@Override public Collection<Method> getDeclaredMethods() { return index.getMethods(); }
@Override public Collection<Method> getDeclaredMethods() { return index.getMethods(); }
@Override public Method lookup(ClassReflectionIndex index) { Collection<Method> methods = index.getMethods(name, parameterTypes); int size = methods.size(); switch (size) { case 0: return null; case 1: return methods.iterator().next(); default: throw PojoLogger.ROOT_LOGGER.ambiguousMatch(methods, name, beanClass.getName()); } } }, 0, Integer.MAX_VALUE);
Collection<Method> endpointInterfaceDefinedWebMethods() { return deploymentReflectionIndex.getClassIndex(endpointInterfaceClass).getMethods(); }
protected Method resolveEjbHomeBusinessMethod(final Class<?> componentClass, final DeploymentReflectionIndex index, final Method method, final String ejbName) throws DeploymentUnitProcessingException { final String name = "ejbHome" + Character.toUpperCase(method.getName().charAt(0)) + method.getName().substring(1); Class<?> clazz = componentClass; while (clazz != Object.class) { final ClassReflectionIndex<?> classIndex = index.getClassIndex(clazz); Collection<Method> methods = classIndex.getMethods(name, method.getParameterTypes()); if (!methods.isEmpty()) { return methods.iterator().next(); } clazz = clazz.getSuperclass(); } throw MESSAGES.failToResolveMethodForHomeInterface("ejbHome", method, ejbName); }
@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<WriteReplaceInterface> classIndex = index.getClassIndex(WriteReplaceInterface.class); for (Method method : classIndex.getMethods()) { configuration.addClientInterceptor(method, new StatefulWriteReplaceInterceptor.Factory(configuration.getViewServiceName().getCanonicalName()), InterceptorOrder.Client.WRITE_REPLACE); } } });
@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<WriteReplaceInterface> classIndex = index.getClassIndex(WriteReplaceInterface.class); for (Method method : classIndex.getMethods()) { configuration.addClientInterceptor(method, StatelessWriteReplaceInterceptor.factory(configuration.getViewServiceName().getCanonicalName()), InterceptorOrder.Client.WRITE_REPLACE); } } });
@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<WriteReplaceInterface> classIndex = index.getClassIndex(WriteReplaceInterface.class); for (Method method : classIndex.getMethods()) { configuration.addClientInterceptor(method, StatelessWriteReplaceInterceptor.factory(configuration.getViewServiceName().getCanonicalName()), InterceptorOrder.Client.WRITE_REPLACE); } } });