private String getOverridenPrimaryJcrType(Method method) { String overridenPrimaryJcrType = this.primaryJcrType; if (method.isAnnotationPresent(Node.class)) { overridenPrimaryJcrType = method.getAnnotation(Node.class).jcrType(); } else if (method.getDeclaringClass().isAnnotationPresent(Node.class)) { overridenPrimaryJcrType = method.getDeclaringClass().getAnnotation(Node.class).jcrType(); } return overridenPrimaryJcrType; }
private String getOverridenPrimaryJcrType(Method method) { String overridenPrimaryJcrType = this.primaryJcrType; if (method.isAnnotationPresent(Node.class)) { overridenPrimaryJcrType = method.getAnnotation(Node.class).jcrType(); } else if (method.getDeclaringClass().isAnnotationPresent(Node.class)) { overridenPrimaryJcrType = method.getDeclaringClass().getAnnotation(Node.class).jcrType(); } return overridenPrimaryJcrType; }
private static void addJcrPrimaryNodeTypeClassPair(Map<String, Class<? extends HippoBean>> jcrPrimaryNodeTypeClassPairs, Class clazz, boolean builtinType) throws HstComponentException { String jcrPrimaryNodeType = null; if (clazz.isAnnotationPresent(Node.class)) { Node anno = (Node) clazz.getAnnotation(Node.class); jcrPrimaryNodeType = anno.jcrType(); } if (jcrPrimaryNodeTypeClassPairs.get(jcrPrimaryNodeType) != null) { if (!builtinType) { throw new HstComponentFatalException("Annotated class for primarytype '"+jcrPrimaryNodeType+"' is duplicate. " + "You might have configured a bean in 'beans-annotated-classes.xml' that does not have a annotation for the jcrType and" + "inherits the jcrType from the bean it extends, resulting in 2 beans with the same jcrType. Correct your beans."); } return; } if (jcrPrimaryNodeType == null) { throw new IllegalArgumentException("There's no annotation for jcrType in the class: " + clazz); } jcrPrimaryNodeTypeClassPairs.put(jcrPrimaryNodeType,clazz); }
jcrPrimaryNodeType = anno.jcrType();
private static String findPrimaryJcrType(Class [] proxyInterfaces) { String primaryJcrType = null; for (Class proxyInterface : proxyInterfaces) { if (proxyInterface.isAnnotationPresent(Node.class)) { primaryJcrType = ((Node) proxyInterface.getAnnotation(Node.class)).jcrType(); break; } } if (primaryJcrType == null) { for (Class proxyInterface : proxyInterfaces) { Class [] extendingInterfaces = proxyInterface.getInterfaces(); if (extendingInterfaces.length > 0) { primaryJcrType = findPrimaryJcrType(extendingInterfaces); if (primaryJcrType != null) { break; } } } } return primaryJcrType; }
private static String findPrimaryJcrType(Class [] proxyInterfaces) { String primaryJcrType = null; for (Class proxyInterface : proxyInterfaces) { if (proxyInterface.isAnnotationPresent(Node.class)) { primaryJcrType = ((Node) proxyInterface.getAnnotation(Node.class)).jcrType(); break; } } if (primaryJcrType == null) { for (Class proxyInterface : proxyInterfaces) { Class [] extendingInterfaces = proxyInterface.getInterfaces(); if (extendingInterfaces.length > 0) { primaryJcrType = findPrimaryJcrType(extendingInterfaces); if (primaryJcrType != null) { break; } } } } return primaryJcrType; }
private static void addJcrPrimaryNodeTypeClassPair(Map<String, Class<? extends HippoBean>> jcrPrimaryNodeTypeClassPairs, Class clazz, boolean builtinType) throws HstComponentException { String jcrPrimaryNodeType = null; if (clazz.isAnnotationPresent(Node.class)) { Node anno = (Node) clazz.getAnnotation(Node.class); jcrPrimaryNodeType = anno.jcrType(); } if(jcrPrimaryNodeTypeClassPairs.get(jcrPrimaryNodeType) != null) { if(builtinType) { log.debug("Builtin annotated class for primary type '{}' is overridden. Builtin version is ignored", jcrPrimaryNodeType); } else { throw new HstComponentFatalException("Annotated class for primarytype '"+jcrPrimaryNodeType+"' is duplicate. " + "You might have configured a bean in 'beans-annotated-classes.xml' that does not have a annotation for the jcrType and" + "inherits the jcrType from the bean it extends, resulting in 2 beans with the same jcrType. Correct your beans."); } return; } if (jcrPrimaryNodeType == null) { throw new IllegalArgumentException("There's no annotation for jcrType in the class: " + clazz); } jcrPrimaryNodeTypeClassPairs.put(jcrPrimaryNodeType,clazz); }