001/* $Id: FactoryCreate.java 992750 2010-09-05 09:54:37Z simonetripodi $
002 *
003 * Licensed to the Apache Software Foundation (ASF) under one or more
004 * contributor license agreements.  See the NOTICE file distributed with
005 * this work for additional information regarding copyright ownership.
006 * The ASF licenses this file to You under the Apache License, Version 2.0
007 * (the "License"); you may not use this file except in compliance with
008 * the License.  You may obtain a copy of the License at
009 *
010 *      http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018package org.apache.commons.digester.annotations.rules;
019
020import java.lang.annotation.Documented;
021import java.lang.annotation.ElementType;
022import java.lang.annotation.Retention;
023import java.lang.annotation.RetentionPolicy;
024import java.lang.annotation.Target;
025
026import org.apache.commons.digester.AbstractObjectCreationFactory;
027import org.apache.commons.digester.FactoryCreateRule;
028import org.apache.commons.digester.annotations.CreationRule;
029import org.apache.commons.digester.annotations.DigesterRule;
030import org.apache.commons.digester.annotations.DigesterRuleList;
031import org.apache.commons.digester.annotations.providers.FactoryCreateRuleProvider;
032
033/**
034 * Classes annotated with {@code FactoryCreate} will be bound with
035 * {@code FactoryCreateRule} digester rule.
036 *
037 * @see org.apache.commons.digester.Digester#addFactoryCreate(String,org.apache.commons.digester.ObjectCreationFactory,boolean)
038 * @since 2.1
039 */
040@Documented
041@Retention(RetentionPolicy.RUNTIME)
042@Target(ElementType.TYPE)
043@CreationRule
044@DigesterRule(
045        reflectsRule = FactoryCreateRule.class,
046        providedBy = FactoryCreateRuleProvider.class
047)
048public @interface FactoryCreate {
049
050    /**
051     * The Java class of the object creation factory class
052     *
053     * @return the Java class of the object creation factory class.
054     */
055    Class<? extends AbstractObjectCreationFactory> factoryClass();
056
057    /**
058     * The element matching pattern.
059     *
060     * @return the element matching pattern.
061     */
062    String pattern();
063
064    /**
065     * When true any exceptions thrown during object creation will be ignored.
066     *
067     * @return when true any exceptions thrown during object creation will be
068     *         ignored.
069     */
070    boolean ignoreCreateExceptions() default false;
071
072    /**
073     * Defines several {@code @FactoryCreate} annotations on the same element.
074     *
075     * @see FactoryCreate
076     */
077    @Documented
078    @Retention(RetentionPolicy.RUNTIME)
079    @Target(ElementType.TYPE)
080    @DigesterRuleList
081    @interface List {
082        FactoryCreate[] value();
083    }
084
085}