Return-Path: X-Original-To: apmail-sling-commits-archive@www.apache.org Delivered-To: apmail-sling-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id DCB0F10153 for ; Tue, 18 Mar 2014 15:08:10 +0000 (UTC) Received: (qmail 17307 invoked by uid 500); 18 Mar 2014 15:08:10 -0000 Delivered-To: apmail-sling-commits-archive@sling.apache.org Received: (qmail 17227 invoked by uid 500); 18 Mar 2014 15:08:07 -0000 Mailing-List: contact commits-help@sling.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@sling.apache.org Delivered-To: mailing list commits@sling.apache.org Received: (qmail 17101 invoked by uid 99); 18 Mar 2014 15:08:05 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 18 Mar 2014 15:08:05 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 18 Mar 2014 15:08:04 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 85F9E23888FE; Tue, 18 Mar 2014 15:07:44 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1578946 - /sling/trunk/bundles/extensions/models/impl/src/main/java/org/apache/sling/models/impl/ModelAdapterFactory.java Date: Tue, 18 Mar 2014 15:07:44 -0000 To: commits@sling.apache.org From: justin@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140318150744.85F9E23888FE@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: justin Date: Tue Mar 18 15:07:43 2014 New Revision: 1578946 URL: http://svn.apache.org/r1578946 Log: SLING-3460 - internal refactoring to ease meta-annotation support Modified: sling/trunk/bundles/extensions/models/impl/src/main/java/org/apache/sling/models/impl/ModelAdapterFactory.java Modified: sling/trunk/bundles/extensions/models/impl/src/main/java/org/apache/sling/models/impl/ModelAdapterFactory.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/impl/src/main/java/org/apache/sling/models/impl/ModelAdapterFactory.java?rev=1578946&r1=1578945&r2=1578946&view=diff ============================================================================== --- sling/trunk/bundles/extensions/models/impl/src/main/java/org/apache/sling/models/impl/ModelAdapterFactory.java (original) +++ sling/trunk/bundles/extensions/models/impl/src/main/java/org/apache/sling/models/impl/ModelAdapterFactory.java Tue Mar 18 15:07:43 2014 @@ -289,14 +289,31 @@ public class ModelAdapterFactory impleme } private String getSource(AnnotatedElement element) { - Source source = element.getAnnotation(Source.class); + Source source = getAnnotation(element, Source.class); if (source != null) { return source.value(); } else { + return null; + } + } + + /** + * Get an annotation from either the element itself or on any of the + * element's annotations (meta-annotations). + * + * @param element the element + * @param annotationClass the annotation class + * @return the found annotation or null + */ + private T getAnnotation(AnnotatedElement element, Class annotationClass) { + T annotation = element.getAnnotation(annotationClass); + if (annotation != null) { + return annotation; + } else { for (Annotation ann : element.getAnnotations()) { - source = ann.annotationType().getAnnotation(Source.class); - if (source != null) { - return source.value(); + annotation = ann.annotationType().getAnnotation(annotationClass); + if (annotation != null) { + return annotation; } } }