All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.demoiselle.jee.configuration.annotation.Configuration Maven / Gradle / Ivy

Go to download

Demoiselle Configuration habilita os projetos a usarem configurações em arquivos .properties, .xml ou variáveis de ambiente.

There is a newer version: 3.0.4
Show newest version
package org.demoiselle.jee.configuration.annotation;

import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Stereotype;
import javax.enterprise.util.Nonbinding;
import javax.inject.Named;
import javax.interceptor.InterceptorBinding;

import org.demoiselle.jee.configuration.ConfigType;

import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
 * 
 * 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
  • *
* */ @ApplicationScoped @Named @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 ConfigType} */ @Nonbinding ConfigType type() default ConfigType.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; }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy