commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r897943 - in /commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/handlers: ./ DefaultLoaderHandler.java
Date Mon, 11 Jan 2010 17:00:07 GMT
Author: simonetripodi
Date: Mon Jan 11 17:00:07 2010
New Revision: 897943

URL: http://svn.apache.org/viewvc?rev=897943&view=rev
Log:
first checkin of DefaultLoaderHandler class

Added:
    commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/handlers/
    commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/handlers/DefaultLoaderHandler.java
  (with props)

Added: commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/handlers/DefaultLoaderHandler.java
URL: http://svn.apache.org/viewvc/commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/handlers/DefaultLoaderHandler.java?rev=897943&view=auto
==============================================================================
--- commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/handlers/DefaultLoaderHandler.java
(added)
+++ commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/handlers/DefaultLoaderHandler.java
Mon Jan 11 17:00:07 2010
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.digester.annotations.handlers;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
+
+import org.apache.commons.digester.Rule;
+import org.apache.commons.digester.annotations.AnnotationRuleProvider;
+import org.apache.commons.digester.annotations.DigesterLoaderHandler;
+import org.apache.commons.digester.annotations.DigesterRule;
+import org.apache.commons.digester.annotations.FromAnnotationsRuleSet;
+import org.apache.commons.digester.annotations.utils.AnnotationUtils;
+
+/**
+ * Default handler implementation that creates the related
+ * {@link AnnotationRuleProvider} and adds it on the {@link FromAnnotationsRuleSet}.
+ *
+ * @version $Id$
+ * @since 2.1
+ */
+public class DefaultLoaderHandler implements DigesterLoaderHandler<Annotation, AnnotatedElement>
{
+
+    /**
+     * {@inheritDoc}
+     */
+    @SuppressWarnings("unchecked")
+    public void handle(Annotation annotation, AnnotatedElement element, FromAnnotationsRuleSet
ruleSet) {
+        DigesterRule digesterRule = annotation.annotationType().getAnnotation(DigesterRule.class);
+        try {
+            AnnotationRuleProvider<Annotation, AnnotatedElement, Rule> ruleProvider
=
+                (AnnotationRuleProvider<Annotation, AnnotatedElement, Rule>) digesterRule.providedBy().newInstance();
+            ruleProvider.init(annotation, element);
+            ruleSet.addRuleProvider(AnnotationUtils.getAnnotationPattern(annotation), ruleProvider);
+        } catch (Throwable t) {
+            throw new RuntimeException("Impossible to instantiate provider of type '"
+                    + digesterRule.providedBy().getName()
+                    + "', see nested exceptions", t);
+        }
+    }
+
+}

Propchange: commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/handlers/DefaultLoaderHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/handlers/DefaultLoaderHandler.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/sandbox/at-digester/trunk/src/java/org/apache/commons/digester/annotations/handlers/DefaultLoaderHandler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message