/** * Indicates whether the specified annotation is present. * * @param annotationType * the annotation type to look for. * @return {@code true} if the annotation is present; {@code false} * otherwise. * @see java.lang.reflect.AnnotatedElement#isAnnotationPresent(java.lang.Class) */ public boolean isAnnotationPresent(Class<? extends Annotation> annotationType) { return getAnnotation(annotationType) != null; }
private boolean parseMethodAuthFlag(final Method actionMethod) { if (actionMethod.getAnnotation(Auth.class) != null) { return true; } final Class declaringClass = actionMethod.getDeclaringClass(); if (declaringClass.getAnnotation(Auth.class) != null) { return true; } if (declaringClass.getPackage().getAnnotation(Auth.class) != null) { return true; } return false; }
public Annotations<A> onPackageHierarchyOf(final Class type) { Package pck = type.getPackage(); String packageName = pck.getName(); while (true) { if (pck != null) { A a = pck.getAnnotation(annotationClass); if (a != null) { annotations.add(a); } } int ndx = packageName.lastIndexOf('.'); if (ndx == -1) { break; } packageName = packageName.substring(0, ndx); pck = Packages.of(type.getClassLoader(), packageName); } return this; }
public <A extends Annotation> A getPackageAnnotation(Class<A> a, Class clazz, Locatable srcPos) { Package p = clazz.getPackage(); if(p==null) return null; Map<Package,Annotation> cache = packageCache.get(a); if(cache==null) { cache = new HashMap<Package,Annotation>(); packageCache.put(a,cache); } if(cache.containsKey(p)) return (A)cache.get(p); else { A ann = LocatableAnnotation.create(p.getAnnotation(a),srcPos); cache.put(p,ann); return ann; } }
private static Ignore findAnnotation(Package testPackage) { if (testPackage == null) { return null; } Ignore result = testPackage.getAnnotation(Ignore.class); if (result != null) { return result; } String[] parts = testPackage.getName().split("\\."); String[] parentParts = Arrays.copyOf(parts, parts.length - 1); String parentPackageName = Strings.join(".", parentParts); if (parentPackageName.isEmpty()) { return null; } return findAnnotation(Package.getPackage(parentPackageName)); } }
Package outputClassPackage = outputClass.getPackage(); if (outputClassPackage != null && outputClassPackage.isAnnotationPresent(XmlSchema.class)) { XmlSchema annotation = outputClassPackage.getAnnotation(XmlSchema.class); namespaceUri = annotation.namespace();
private static Ignore findAnnotation(Package testPackage) { if (testPackage == null) { return null; } Ignore result = testPackage.getAnnotation(Ignore.class); if (result != null) { return result; } String[] parts = testPackage.getName().split("\\."); String[] parentParts = Arrays.copyOf(parts, parts.length - 1); String parentPackageName = Strings.join(".", parentParts); if (parentPackageName.isEmpty()) { return null; } return findAnnotation(Package.getPackage(parentPackageName)); } }
Package outputClassPackage = outputClass.getPackage(); if (outputClassPackage != null && outputClassPackage.isAnnotationPresent(XmlSchema.class)) { XmlSchema annotation = outputClassPackage.getAnnotation(XmlSchema.class); namespaceUri = annotation.namespace();
MadvocAction madvocActionAnnotation = actionPackage.getAnnotation(MadvocAction.class);
private static LinkELProvider findLinkELProvider(Method m){ if(m.isAnnotationPresent(LinkELProvider.class)) return m.getAnnotation(LinkELProvider.class); Class<?> c = m.getDeclaringClass(); if(c.isAnnotationPresent(LinkELProvider.class)) return c.getAnnotation(LinkELProvider.class); Package p = c.getPackage(); if(p != null && p.isAnnotationPresent(LinkELProvider.class)) return p.getAnnotation(LinkELProvider.class); return null; }
public <A extends Annotation> A getPackageAnnotation(Class<A> a, Class clazz, Locatable srcPos) { Package p = clazz.getPackage(); if(p==null) return null; Map<Package,Annotation> cache = packageCache.get(a); if(cache==null) { cache = new HashMap<Package,Annotation>(); packageCache.put(a,cache); } if(cache.containsKey(p)) return (A)cache.get(p); else { A ann = LocatableAnnotation.create(p.getAnnotation(a),srcPos); cache.put(p,ann); return ann; } }
public List<ResourceInterceptor> getResourceInterceptorsForMethod(Method m) { // First check the method InterceptorChain chain = m.getAnnotation(InterceptorChain.class); if (chain == null) { // Next check the class chain = m.getDeclaringClass().getAnnotation(InterceptorChain.class); if (chain == null) { // Finally, check the package chain = m.getDeclaringClass().getPackage().getAnnotation(InterceptorChain.class); } } if (chain != null) { return buildFromClass(chain.value()); } else { // Return default interceptor list return new ArrayList<ResourceInterceptor>(defaultResourceInterceptors.values()); } }
private boolean requiresWebSudo() { final Method m = abstractMethod.getMethod(); if (null != m && m.getAnnotation(WebSudoRequired.class) != null) { return true; } if (null != m && m.getAnnotation(WebSudoNotRequired.class) != null) { return false; } final AbstractResource resource = abstractMethod.getResource(); if (resource.isAnnotationPresent(WebSudoRequired.class)) { return true; } if (resource.isAnnotationPresent(WebSudoNotRequired.class)) { return false; } final Package p = abstractMethod.getResource().getResourceClass().getPackage(); if (p.getAnnotation(WebSudoRequired.class) != null) { return true; } if (p.getAnnotation(WebSudoNotRequired.class) != null) { return false; } return false; } }
Package pkg = memberClass.getPackage(); if (pkg != null) { return memberClass.getPackage().getAnnotation(annotationClass);
protected final void initConfiguration(JaxWsImplementorInfo ii) { if (ii.isWebServiceProvider()) { jaxWsConfiguration = new WebServiceProviderConfiguration(); jaxWsConfiguration.setServiceFactory(this); getServiceConfigurations().add(0, jaxWsConfiguration); setWrapped(false); setDataBinding(new SourceDataBinding()); setMethodDispatcher(new JAXWSProviderMethodDispatcher(implInfo)); } else { jaxWsConfiguration = new JaxWsServiceConfiguration(); jaxWsConfiguration.setServiceFactory(this); getServiceConfigurations().add(0, jaxWsConfiguration); Class<?> seiClass = ii.getEndpointClass(); if (seiClass != null && seiClass.getPackage() != null) { XmlSchema schema = seiClass.getPackage().getAnnotation(XmlSchema.class); if (schema != null && XmlNsForm.QUALIFIED.equals(schema.elementFormDefault())) { setQualifyWrapperSchema(true); } } setMethodDispatcher(new JAXWSMethodDispatcher(implInfo)); } loadWSFeatureAnnotation(ii.getSEIClass(), ii.getImplementorClass()); }
static XmlAccessType getXmlAccessType(Class<?> cls) { XmlAccessorType accessorType = cls.getAnnotation(XmlAccessorType.class); if (accessorType == null && cls.getPackage() != null) { accessorType = cls.getPackage().getAnnotation(XmlAccessorType.class); } return accessorType != null ? accessorType.value() : XmlAccessType.PUBLIC_MEMBER; }
public static <T> String getNamespaceForClass(final Class<T> clazz) { final XmlSchema schema = clazz.getPackage().getAnnotation(XmlSchema.class); if (schema != null) { final String namespace = schema.namespace(); if (namespace != null && !"".equals(namespace)) { return namespace; } } return null; }
public static String getPackageNamespace(Class<?> cls) { Package p = cls.getPackage(); if (p != null) { javax.xml.bind.annotation.XmlSchema schemaAnn = p.getAnnotation(javax.xml.bind.annotation.XmlSchema.class); if (schemaAnn != null) { return schemaAnn.namespace(); } } return null; }
public static String getPackageNamespace(Class<?> cls) { Package p = cls.getPackage(); if (p != null) { javax.xml.bind.annotation.XmlSchema schemaAnn = p.getAnnotation(javax.xml.bind.annotation.XmlSchema.class); if (schemaAnn != null) { return schemaAnn.namespace(); } } return null; }
public static String getPackageNamespace(Class<?> cls) { Package p = cls.getPackage(); if (p != null) { javax.xml.bind.annotation.XmlSchema schemaAnn = p.getAnnotation(javax.xml.bind.annotation.XmlSchema.class); if (schemaAnn != null) { return schemaAnn.namespace(); } } return null; }