- Common ways to obtain Remote
private void myMethod () {Remote r =
Class klass;klass.getAnnotation(Remote.class)
Class klass;(Remote) klass.getAnnotation(Remote.class)
- Smart code suggestions by Codota
}
private List<Class> remoteAndLocalIfaces(final Class<?> resourceClass) { final List<Class> allLocalOrRemoteIfaces = new LinkedList<>(); if (resourceClass.isAnnotationPresent(Remote.class)) { allLocalOrRemoteIfaces.addAll(Arrays.asList(resourceClass.getAnnotation(Remote.class).value())); } if (resourceClass.isAnnotationPresent(Local.class)) { allLocalOrRemoteIfaces.addAll(Arrays.asList(resourceClass.getAnnotation(Local.class).value())); } for (Class<?> i : resourceClass.getInterfaces()) { if (i.isAnnotationPresent(Remote.class) || i.isAnnotationPresent(Local.class)) { allLocalOrRemoteIfaces.add(i); } } return allLocalOrRemoteIfaces; }
private Collection<Class<?>> getRemoteBusinessInterfaces(final DeploymentUnit deploymentUnit, final Class<?> sessionBeanClass) throws DeploymentUnitProcessingException { final Remote remoteViewAnnotation = sessionBeanClass.getAnnotation(Remote.class); if (remoteViewAnnotation == null) { Collection<Class<?>> interfaces = getBusinessInterfacesFromInterfaceAnnotations(sessionBeanClass, Remote.class); if (!interfaces.isEmpty()) { return interfaces; } return Collections.emptySet(); } Class<?>[] remoteViews = remoteViewAnnotation.value(); if (remoteViews == null || remoteViews.length == 0) { Set<Class<?>> interfaces = getPotentialBusinessInterfaces(sessionBeanClass); // For version < 3.2, the EJB spec didn't allow more than one implementing interfaces to be considered as remote when the bean class had the @Remote annotation without any explicit value. // EJB 3.2 allows it (core spec, section 4.9.7) if (interfaces.size() != 1 && !isEjbVersionGreaterThanOrEqualTo32(deploymentUnit)) { throw EjbLogger.ROOT_LOGGER.beanWithRemoteAnnotationImplementsMoreThanOneInterface(sessionBeanClass); } return interfaces; } return Arrays.asList(remoteViews); }
@Override public boolean matches(MethodDescription targetMethod) { final AnnotationList declaredAnnotationsOfType = targetMethod.getDeclaringType().asErasure().getDeclaredAnnotations(); if (declaredAnnotationsOfType.isAnnotationPresent(Remote.class)) { final Class[] remoteInterfaces = declaredAnnotationsOfType.ofType(Remote.class).loadSilent().value(); if (!new TypeList.ForLoadedTypes(remoteInterfaces).filter(isDeclaredInInterfaceHierarchy(targetMethod)).isEmpty()) { return true; } } return false; } }
private List<Class> remoteAndLocalIfaces(final Class<?> resourceClass) { final List<Class> allLocalOrRemoteIfaces = new LinkedList<Class>(); if (resourceClass.isAnnotationPresent(Remote.class)) { allLocalOrRemoteIfaces.addAll(Arrays.asList(resourceClass.getAnnotation(Remote.class).value())); } if (resourceClass.isAnnotationPresent(Local.class)) { allLocalOrRemoteIfaces.addAll(Arrays.asList(resourceClass.getAnnotation(Local.class).value())); } for (Class<?> i : resourceClass.getInterfaces()) { if (i.isAnnotationPresent(Remote.class) || i.isAnnotationPresent(Local.class)) { allLocalOrRemoteIfaces.add(i); } } return allLocalOrRemoteIfaces; }
private List<Class> remoteAndLocalIfaces(final Class<?> resourceClass) { final List<Class> allLocalOrRemoteIfaces = new LinkedList<Class>(); if (resourceClass.isAnnotationPresent(Remote.class)) { allLocalOrRemoteIfaces.addAll(Arrays.asList(resourceClass.getAnnotation(Remote.class).value())); } if (resourceClass.isAnnotationPresent(Local.class)) { allLocalOrRemoteIfaces.addAll(Arrays.asList(resourceClass.getAnnotation(Local.class).value())); } for (Class<?> i : resourceClass.getInterfaces()) { if (i.isAnnotationPresent(Remote.class) || i.isAnnotationPresent(Local.class)) { allLocalOrRemoteIfaces.add(i); } } return allLocalOrRemoteIfaces; }
private List<Class> remoteAndLocalIfaces(final Class<?> resourceClass) { final List<Class> allLocalOrRemoteIfaces = new LinkedList<Class>(); if (resourceClass.isAnnotationPresent(Remote.class)) { allLocalOrRemoteIfaces.addAll(Arrays.asList(resourceClass.getAnnotation(Remote.class).value())); } if (resourceClass.isAnnotationPresent(Local.class)) { allLocalOrRemoteIfaces.addAll(Arrays.asList(resourceClass.getAnnotation(Local.class).value())); } for (Class<?> i : resourceClass.getInterfaces()) { if (i.isAnnotationPresent(Remote.class) || i.isAnnotationPresent(Local.class)) { allLocalOrRemoteIfaces.add(i); } } return allLocalOrRemoteIfaces; }
/** * {@link Remote}アノテーションで指定されたビジネスインターフェースを検出します。 */ protected void detectRemoteBusinessInterfaces() { final Remote remote = beanClass.getAnnotation(Remote.class); if (remote != null) { for (final Class<?> type : remote.value()) { if (isBusinessInterface(type)) { businessInterfaces.add(type); } } } for (final Class<?> type : beanClass.getInterfaces()) { final Remote annotation = type.getAnnotation(Remote.class); if (annotation != null) { businessInterfaces.add(type); } } }
@Override public Method getInvocableMethod(Method method) { final Class<?> declaringClass = method.getDeclaringClass(); final List<Class> interfaces = new LinkedList<Class>(); if (declaringClass.isAnnotationPresent(Remote.class)) { interfaces.addAll(Arrays.asList(declaringClass.getAnnotation(Remote.class).value())); } if (declaringClass.isAnnotationPresent(Local.class)) { interfaces.addAll(Arrays.asList(declaringClass.getAnnotation(Local.class).value())); } for (Class<?> i : declaringClass.getInterfaces()) { if (i.isAnnotationPresent(Remote.class) || i.isAnnotationPresent(Local.class)) { interfaces.add(i); } } for (Class iface : interfaces) { try { final Method interfaceMethod = iface.getDeclaredMethod(method.getName(), method.getParameterTypes()); if (interfaceMethod != null) { return interfaceMethod; } } catch (Exception e) { LOGGER.log(Level.WARNING, e.getMessage(), e); } } return method; }
@Override public Method getInvocableMethod(Method method) { final Class<?> declaringClass = method.getDeclaringClass(); final List<Class> interfaces = new LinkedList<Class>(); if (declaringClass.isAnnotationPresent(Remote.class)) { interfaces.addAll(Arrays.asList(declaringClass.getAnnotation(Remote.class).value())); } if (declaringClass.isAnnotationPresent(Local.class)) { interfaces.addAll(Arrays.asList(declaringClass.getAnnotation(Local.class).value())); } for (Class<?> i : declaringClass.getInterfaces()) { if (i.isAnnotationPresent(Remote.class) || i.isAnnotationPresent(Local.class)) { interfaces.add(i); } } for (Class iface : interfaces) { try { final Method interfaceMethod = iface.getDeclaredMethod(method.getName(), method.getParameterTypes()); if (interfaceMethod != null) { return interfaceMethod; } } catch (Exception e) { LOGGER.log(Level.WARNING, e.getMessage(), e); } } return method; }
private Collection<Class<?>> getRemoteBusinessInterfaces(Class<?> sessionBeanClass) throws DeploymentUnitProcessingException { final Remote remoteViewAnnotation = sessionBeanClass.getAnnotation(Remote.class); if (remoteViewAnnotation == null) { Collection<Class<?>> interfaces = getBusinessInterfacesFromInterfaceAnnotations(sessionBeanClass, Remote.class); if (!interfaces.isEmpty()) { return interfaces; } return Collections.emptySet(); } Class<?>[] remoteViews = remoteViewAnnotation.value(); if (remoteViews == null || remoteViews.length == 0) { Set<Class<?>> interfaces = getPotentialBusinessInterfaces(sessionBeanClass); if (interfaces.size() != 1) throw MESSAGES.beanWithRemoteAnnotationImplementsMoreThanOneInterface(sessionBeanClass); return interfaces; } return Arrays.asList(remoteViews); }
public void process(SessionBeanMetaData metaData, Class<?> type) { Remote remote = finder.getAnnotation(type, Remote.class); if(remote == null) return; if(type.isInterface()) { addBusinessInterface(metaData, type); } else { if(remote.value() == null || remote.value().length == 0) { Class<?> businessInterface = ClassHelper.getDefaultInterface(type); addBusinessInterface(metaData, businessInterface); } else { for(Class<?> businessInterface : remote.value()) { addBusinessInterface(metaData, businessInterface); } } } } }
public void process(SessionBeanMetaData metaData, Class<?> type) { Remote remote = finder.getAnnotation(type, Remote.class); if(remote == null) return; if(type.isInterface()) { addBusinessInterface(metaData, type); } else { if(remote.value() == null || remote.value().length == 0) { Class<?> businessInterface = ClassHelper.getDefaultInterface(type); addBusinessInterface(metaData, businessInterface); } else { for(Class<?> businessInterface : remote.value()) { addBusinessInterface(metaData, businessInterface); } } } }
public void process(JBossSessionBeanMetaData metaData, Class<?> type) { Remote remote = finder.getAnnotation(type, Remote.class); if(remote == null) return; if(type.isInterface()) { addBusinessInterface(metaData, type); } else { if(remote.value() == null || remote.value().length == 0) { Class<?> businessInterface = ClassHelper.getDefaultInterface(type); addBusinessInterface(metaData, businessInterface); } else { for(Class<?> businessInterface : remote.value()) { addBusinessInterface(metaData, businessInterface); } } } }
return remote.value()[0];
for (Class<?> i : clazz.getAnnotation(Remote.class).value()) scannedClasses.put(i, clazz);
if (remoteAnnotation != null) Class[] remotes = remoteAnnotation.value(); for (int i = 0; i < remotes.length; ++i)
if (remoteAnnotation != null) for (final Class<?> clazz : remoteAnnotation.value())
if (remoteAnnotation != null) for (final Class<?> clazz : remoteAnnotation.value())
for (Class<?> remoteClass : remote.value())
@Override public boolean matches(MethodDescription.InDefinedShape targetMethod) { final AnnotationList declaredAnnotationsOfType = targetMethod.getDeclaringType().getDeclaredAnnotations(); if (declaredAnnotationsOfType.isAnnotationPresent(Remote.class)) { final Class[] remoteInterfaces = declaredAnnotationsOfType.ofType(Remote.class).loadSilent().value(); if (!new TypeList.ForLoadedTypes(remoteInterfaces).filter(isDeclaredInInterfaceHierarchy(targetMethod)).isEmpty()) { return true; } } return false; } }