org.demoiselle.jee.configuration.annotation.Configuration Maven / Gradle / Ivy
Show all versions of demoiselle-configuration Show documentation
/*
* Demoiselle Framework
*
* License: GNU Lesser General Public License (LGPL), version 3 or later.
* See the lgpl.txt file in the root directory or .
*/
package org.demoiselle.jee.configuration.annotation;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Stereotype;
import javax.enterprise.util.Nonbinding;
import javax.interceptor.InterceptorBinding;
import org.demoiselle.jee.configuration.ConfigurationType;
/**
*
* Identifies a configuration class, that is, a structure reserved to
* store configuration values retrieved from a
* given resource file or system variables.
*
*
* This class is gonna have a single instance throughout the application, as
* stated by the singleton design
* pattern approach.
*
*
* A Configuration is:
*
* - defined when annotated with {@code @Configuration}
* - automatically injected whenever {@code @Inject} is used
*
*
* @author SERPRO
*/
@ApplicationScoped
@InterceptorBinding
@Stereotype
@Target(TYPE)
@Retention(RUNTIME)
public @interface Configuration {
String DEFAULT_PREFIX = "demoiselle";
/**
* Define the default resource.
*/
String DEFAULT_RESOURCE = "demoiselle";
/**
* Defines the resource type to be used: a properties file, an XML file or
* system variables.
*
* If not specified, a properties resource file is to be considered.
*
*
* @return {@link ConfigurationType}
*/
@Nonbinding
ConfigurationType type() default ConfigurationType.PROPERTIES;
/**
* Defines an optional prefix to be used on every parameter key.
*
* For instance, if prefix is set to "demoiselle.pagination" and an
* attribute named
* defaultPageSize is found in the class, the corresponding key
* demoiselle.pagination.defaultPageSize is expected to be read in
* the resource file.
*
*
* @return String
*/
@Nonbinding
String prefix() default DEFAULT_PREFIX;
/**
* Defines the resource file name to be read by this configuration class.
* There is no need to specify file extension
* in the case of properties or XML resources.
*
*
* For instance, when resource is set to "bookmark" and the type set
* to properties, a corresponding
* file named bookmark.properties is considered.
*
*
*
* If not specified, the default configuration file
* demoiselle.properties is rather considered.
*
*
* @return String
*/
@Nonbinding
String resource() default DEFAULT_RESOURCE;
}