Commit 49fa68d091176d5ee03ae790ac2510cead40eb6e

Authored by Julian Cesar dos Santos
1 parent 3de0d99c

Proposta de estruturação dos projetos do framework JEE.

Showing 196 changed files with 4922 additions and 6731 deletions   Show diff stats

Too many changes.

To preserve performance only 100 of 196 files displayed.

1 -Demoiselle 2 1 +Demoiselle 3
2 ============= 2 =============
3 3
4 O framework Demoiselle implementa o conceito de framework integrador. 4 O framework Demoiselle implementa o conceito de framework integrador.
basic/.gitignore
@@ -1,3 +0,0 @@ @@ -1,3 +0,0 @@
1 -/.settings/  
2 -/.classpath  
3 -/.project  
basic/pom.xml
@@ -1,34 +0,0 @@ @@ -1,34 +0,0 @@
1 -<?xml version="1.0" encoding="UTF-8"?>  
2 -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">  
3 - <modelVersion>4.0.0</modelVersion>  
4 - <groupId>org.demoiselle.jee</groupId>  
5 - <artifactId>demoiselle-security-basic</artifactId>  
6 - <version>3.0.0-SNAPSHOT</version>  
7 - <packaging>jar</packaging>  
8 - <properties>  
9 - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>  
10 - <maven.compiler.source>1.8</maven.compiler.source>  
11 - <maven.compiler.target>1.8</maven.compiler.target>  
12 - </properties>  
13 - <dependencies>  
14 -  
15 - <dependency>  
16 - <groupId>${project.groupId}</groupId>  
17 - <artifactId>demoiselle-core</artifactId>  
18 - <version>${project.version}</version>  
19 - </dependency>  
20 -  
21 - <dependency>  
22 - <groupId>${project.groupId}</groupId>  
23 - <artifactId>demoiselle-ws</artifactId>  
24 - <version>${project.version}</version>  
25 - </dependency>  
26 -  
27 - <dependency>  
28 - <groupId>${project.groupId}</groupId>  
29 - <artifactId>demoiselle-security</artifactId>  
30 - <version>${project.version}</version>  
31 - </dependency>  
32 -  
33 - </dependencies>  
34 -</project>  
basic/src/main/java/org/demoiselle/jee/security/basic/impl/TokensManagerImpl.java
@@ -1,51 +0,0 @@ @@ -1,51 +0,0 @@
1 -/*  
2 - * To change this license header, choose License Headers in Project Properties.  
3 - * To change this template file, choose Tools | Templates  
4 - * and open the template in the editor.  
5 - */  
6 -package org.demoiselle.jee.security.basic.impl;  
7 -  
8 -import java.security.Principal;  
9 -import java.util.Map;  
10 -import java.util.UUID;  
11 -import java.util.concurrent.ConcurrentHashMap;  
12 -import java.util.logging.Logger;  
13 -import javax.enterprise.context.Dependent;  
14 -import javax.inject.Inject;  
15 -import org.demoiselle.jee.security.Token;  
16 -import org.demoiselle.jee.security.interfaces.TokensManager;  
17 -  
18 -/**  
19 - *  
20 - * @author 70744416353  
21 - */  
22 -@Dependent  
23 -public class TokensManagerImpl implements TokensManager {  
24 -  
25 - private static ConcurrentHashMap<String, Principal> repo = new ConcurrentHashMap<>();  
26 -  
27 - @Inject  
28 - private Logger logger;  
29 -  
30 - @Override  
31 - public Principal getUser(Token token) {  
32 - return repo.get(token.getKey());  
33 - }  
34 -  
35 - @Override  
36 - public Token getToken(Principal user) {  
37 - String value = null;  
38 - if (!repo.containsValue(user)) {  
39 - value = UUID.randomUUID().toString();  
40 - repo.put(value, user);  
41 - } else {  
42 - for (Map.Entry<String, Principal> entry : repo.entrySet()) {  
43 - if (entry.getValue().equals(user)) {  
44 - return entry.getKey();  
45 - }  
46 - }  
47 - }  
48 - return value;  
49 - }  
50 -  
51 -}  
basic/src/main/resources/demoiselle.properties
@@ -1 +0,0 @@ @@ -1 +0,0 @@
1 -user-not-authenticated  
2 \ No newline at end of file 0 \ No newline at end of file
basic/src/main/resources/messages.properties
@@ -1 +0,0 @@ @@ -1 +0,0 @@
1 -tipo-seguranca=basic  
2 \ No newline at end of file 0 \ No newline at end of file
configuration/.gitignore
@@ -1,3 +0,0 @@ @@ -1,3 +0,0 @@
1 -.settings  
2 -.classpath  
3 -.project  
configuration/pom.xml
@@ -1,26 +0,0 @@ @@ -1,26 +0,0 @@
1 -<?xml version="1.0" encoding="UTF-8"?>  
2 -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
3 - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">  
4 - <modelVersion>4.0.0</modelVersion>  
5 - <groupId>org.demoiselle</groupId>  
6 - <artifactId>configuration</artifactId>  
7 - <version>3.0.0-SNAPSHOT</version>  
8 - <packaging>jar</packaging>  
9 - <properties>  
10 - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>  
11 - <maven.compiler.source>1.8</maven.compiler.source>  
12 - <maven.compiler.target>1.8</maven.compiler.target>  
13 - </properties>  
14 - <dependencies>  
15 - <dependency>  
16 - <groupId>${project.groupId}</groupId>  
17 - <artifactId>core</artifactId>  
18 - <version>${project.version}</version>  
19 - </dependency>  
20 - <dependency>  
21 - <groupId>org.apache.commons</groupId>  
22 - <artifactId>commons-configuration2</artifactId>  
23 - <version>2.1</version>  
24 - </dependency>  
25 - </dependencies>  
26 -</project>  
configuration/src/main/java/org/demoiselle/configuration/ConfigType.java
@@ -1,26 +0,0 @@ @@ -1,26 +0,0 @@
1 -package org.demoiselle.configuration;  
2 -  
3 -/**  
4 - * Defines configuration types to be loaded.  
5 - *  
6 - * @author SERPRO  
7 - */  
8 -@SuppressWarnings("WeakerAccess")  
9 -public enum ConfigType {  
10 -  
11 - /**  
12 - * Configuration loaded on {@link System#getProperties()} or {@link System#getenv()}.  
13 - */  
14 - @SuppressWarnings("unused") SYSTEM,  
15 -  
16 - /**  
17 - * Configuration loaded on XML resources.  
18 - */  
19 - @SuppressWarnings("unused") XML,  
20 -  
21 - /**  
22 - * Configuration loaded on properties resources.  
23 - */  
24 - @SuppressWarnings("unused") PROPERTIES  
25 -  
26 -}  
configuration/src/main/java/org/demoiselle/configuration/Configuration.java
@@ -1,115 +0,0 @@ @@ -1,115 +0,0 @@
1 -/*  
2 - * Demoiselle Framework  
3 - * Copyright (C) 2010 SERPRO  
4 - * ----------------------------------------------------------------------------  
5 - * This file is part of Demoiselle Framework.  
6 - *  
7 - * Demoiselle Framework is free software; you can redistribute it and/or  
8 - * modify it under the terms of the GNU Lesser General Public License version 3  
9 - * as published by the Free Software Foundation.  
10 - *  
11 - * This program is distributed in the hope that it will be useful,  
12 - * but WITHOUT ANY WARRANTY; without even the implied warranty of  
13 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  
14 - * GNU General Public License for more details.  
15 - *  
16 - * You should have received a copy of the GNU Lesser General Public License version 3  
17 - * along with this program; if not, see <http://www.gnu.org/licenses/>  
18 - * or write to the Free Software Foundation, Inc., 51 Franklin Street,  
19 - * Fifth Floor, Boston, MA 02110-1301, USA.  
20 - * ----------------------------------------------------------------------------  
21 - * Este arquivo é parte do Framework Demoiselle.  
22 - *  
23 - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou  
24 - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação  
25 - * do Software Livre (FSF).  
26 - *  
27 - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA  
28 - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou  
29 - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português  
30 - * para maiores detalhes.  
31 - *  
32 - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título  
33 - * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>  
34 - * ou escreva para a Fundação do Software Livre (FSF) Inc.,  
35 - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.  
36 - */  
37 -package org.demoiselle.configuration;  
38 -  
39 -import javax.enterprise.context.ApplicationScoped;  
40 -import javax.enterprise.inject.Stereotype;  
41 -import javax.enterprise.util.Nonbinding;  
42 -import javax.inject.Named;  
43 -import javax.interceptor.InterceptorBinding;  
44 -import java.lang.annotation.Retention;  
45 -import java.lang.annotation.Target;  
46 -  
47 -import static java.lang.annotation.ElementType.TYPE;  
48 -import static java.lang.annotation.RetentionPolicy.RUNTIME;  
49 -  
50 -/**  
51 - * <p>  
52 - * Identifies a <b>configuration class</b>, that is, a structure reserved to store configuration values retrieved from a  
53 - * given resource file or system variables.  
54 - * </p>  
55 - * <p>  
56 - * Configuration resources are application scoped, meaning only one instance can ever exist in  
57 - * a running application. For that reason usually configuration fields are immutable, to avoid  
58 - * changes made in one context affecting other contexts in a running application.  
59 - * </p>  
60 - * <p>A <i>Configuration</i> is:</p>  
61 - * <ul>  
62 - * <li>defined when annotated with {@code @Configuration}</li>  
63 - * <li>automatically injected whenever {@code @Inject} is used</li>  
64 - * </ul>  
65 - *  
66 - * @author SERPRO  
67 - */  
68 -@ApplicationScoped  
69 -@Named  
70 -@InterceptorBinding  
71 -@Stereotype  
72 -@Target(TYPE)  
73 -@Retention(RUNTIME)  
74 -public @interface Configuration {  
75 -  
76 - /**  
77 - * Define the default prefix.  
78 - */  
79 - String DEFAULT_PREFIX = "demoiselle";  
80 -  
81 - /**  
82 - * Define the default resource.  
83 - */  
84 - String DEFAULT_RESOURCE = "demoiselle";  
85 -  
86 - /**  
87 - * Defines the resource type to be used: a properties file, an XML file, or system variables.  
88 - * If not specified, a properties resource file is to be considered.  
89 - *  
90 - * @return ConfigType Type of configuration resource file to look for  
91 - */  
92 - @Nonbinding @SuppressWarnings("unused") ConfigType type() default ConfigType.PROPERTIES;  
93 -  
94 - /**  
95 - * Defines an optional prefix to be used on every parameter key.  
96 - * For instance, if prefix is set to <code>"demoiselle.pagination"</code> and an attribute named  
97 - * <code>defaultPageSize</code> is found in the class, the corresponding key  
98 - * <code>demoiselle.pagination.defaultPageSize</code> is expected to be read in the resource file.  
99 - *  
100 - * @return String prefix common to all attributes to be read by the configuration class  
101 - */  
102 - @Nonbinding @SuppressWarnings("unused") String prefix() default DEFAULT_PREFIX;  
103 -  
104 - /**  
105 - * Defines the resource file name to be read by this configuration class. There is no need to specify file extension  
106 - * in the case of properties or XML resources.  
107 - * For instance, when resource is set to <code>"bookmark"</code> and the type set to properties, a corresponding  
108 - * file named <code>bookmark.properties</code> is considered.  
109 - * If not specified, the default configuration file <code>demoiselle.properties</code> is used instead.  
110 - *  
111 - * @return String Name of the resource file to look for (minus file extension)  
112 - */  
113 - @Nonbinding @SuppressWarnings("unused") String resource() default DEFAULT_RESOURCE;  
114 -  
115 -}  
configuration/src/main/java/org/demoiselle/configuration/ConfigurationException.java
@@ -1,70 +0,0 @@ @@ -1,70 +0,0 @@
1 -/*  
2 - * Demoiselle Framework  
3 - * Copyright (C) 2010 SERPRO  
4 - * ----------------------------------------------------------------------------  
5 - * This file is part of Demoiselle Framework.  
6 - *  
7 - * Demoiselle Framework is free software; you can redistribute it and/or  
8 - * modify it under the terms of the GNU Lesser General Public License version 3  
9 - * as published by the Free Software Foundation.  
10 - *  
11 - * This program is distributed in the hope that it will be useful,  
12 - * but WITHOUT ANY WARRANTY; without even the implied warranty of  
13 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  
14 - * GNU General Public License for more details.  
15 - *  
16 - * You should have received a copy of the GNU Lesser General Public License version 3  
17 - * along with this program; if not, see <http://www.gnu.org/licenses/>  
18 - * or write to the Free Software Foundation, Inc., 51 Franklin Street,  
19 - * Fifth Floor, Boston, MA 02110-1301, USA.  
20 - * ----------------------------------------------------------------------------  
21 - * Este arquivo é parte do Framework Demoiselle.  
22 - *  
23 - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou  
24 - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação  
25 - * do Software Livre (FSF).  
26 - *  
27 - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA  
28 - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou  
29 - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português  
30 - * para maiores detalhes.  
31 - *  
32 - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título  
33 - * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>  
34 - * ou escreva para a Fundação do Software Livre (FSF) Inc.,  
35 - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.  
36 - */  
37 -package org.demoiselle.configuration;  
38 -  
39 -import org.demoiselle.exception.DemoiselleException;  
40 -  
41 -/**  
42 - * Exception class intended to be used by configuration components.  
43 - *  
44 - * @author SERPRO  
45 - */  
46 -@SuppressWarnings("unused")  
47 -public class ConfigurationException extends DemoiselleException {  
48 -  
49 - private static final long serialVersionUID = 1L;  
50 -  
51 - /**  
52 - * Constructor with message.  
53 - *  
54 - * @param message exception message  
55 - * @deprecated  
56 - */  
57 - public ConfigurationException(String message) {  
58 - super(message);  
59 - }  
60 -  
61 - /**  
62 - * Constructor with message and cause.  
63 - *  
64 - * @param message exception message  
65 - * @param cause exception cause  
66 - */  
67 - public ConfigurationException(String message, Throwable cause) {  
68 - super(message, cause);  
69 - }  
70 -}  
configuration/src/main/java/org/demoiselle/configuration/ConfigurationInterceptor.java
@@ -1,34 +0,0 @@ @@ -1,34 +0,0 @@
1 -package org.demoiselle.configuration;  
2 -  
3 -import org.demoiselle.annotation.literal.NamedQualifier;  
4 -import org.demoiselle.internal.implementation.ConfigurationLoader;  
5 -  
6 -import javax.annotation.Priority;  
7 -import javax.enterprise.context.Dependent;  
8 -import javax.enterprise.inject.spi.CDI;  
9 -import javax.inject.Inject;  
10 -import javax.inject.Named;  
11 -import javax.interceptor.AroundInvoke;  
12 -import javax.interceptor.Interceptor;  
13 -import javax.interceptor.InvocationContext;  
14 -  
15 -/**  
16 - * <p>  
17 - * Interceptor class that loads the values of configuration files  
18 - * into it's mapped class.  
19 - * </p>  
20 - */  
21 -@Dependent  
22 -@Configuration  
23 -@Interceptor  
24 -@Priority(Interceptor.Priority.APPLICATION)  
25 -public class ConfigurationInterceptor {  
26 - @AroundInvoke  
27 - public static Object constructConfiguration(final InvocationContext ic) throws Exception {  
28 - final ConfigurationLoader configurationLoader = CDI.current().select(ConfigurationLoader.class, new NamedQualifier("demoiselle-configuration-loader")).get();  
29 -  
30 - final Class<?> baseClass = ic.getMethod().getDeclaringClass();  
31 - configurationLoader.load(ic.getTarget(), baseClass);  
32 - return ic.proceed();  
33 - }  
34 -}  
configuration/src/main/java/org/demoiselle/configuration/ConfigurationValueExtractor.java
@@ -1,87 +0,0 @@ @@ -1,87 +0,0 @@
1 -/*  
2 - * Demoiselle Framework  
3 - * Copyright (C) 2010 SERPRO  
4 - * ----------------------------------------------------------------------------  
5 - * This file is part of Demoiselle Framework.  
6 - *  
7 - * Demoiselle Framework is free software; you can redistribute it and/or  
8 - * modify it under the terms of the GNU Lesser General Public License version 3  
9 - * as published by the Free Software Foundation.  
10 - *  
11 - * This program is distributed in the hope that it will be useful,  
12 - * but WITHOUT ANY WARRANTY; without even the implied warranty of  
13 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  
14 - * GNU General Public License for more details.  
15 - *  
16 - * You should have received a copy of the GNU Lesser General Public License version 3  
17 - * along with this program; if not, see <http://www.gnu.org/licenses/>  
18 - * or write to the Free Software Foundation, Inc., 51 Franklin Street,  
19 - * Fifth Floor, Boston, MA 02110-1301, USA.  
20 - * ----------------------------------------------------------------------------  
21 - * Este arquivo é parte do Framework Demoiselle.  
22 - *  
23 - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou  
24 - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação  
25 - * do Software Livre (FSF).  
26 - *  
27 - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA  
28 - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou  
29 - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português  
30 - * para maiores detalhes.  
31 - *  
32 - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título  
33 - * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>  
34 - * ou escreva para a Fundação do Software Livre (FSF) Inc.,  
35 - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.  
36 - */  
37 -package org.demoiselle.configuration;  
38 -  
39 -import java.lang.reflect.Field;  
40 -import org.apache.commons.configuration2.Configuration;  
41 -  
42 -/**  
43 - * <p>  
44 - * Interface that defines how to convert values extracted from configuration  
45 - * files to fields in a class annotated with {@link Configuration}.  
46 - * </p>  
47 - *  
48 - * <p>  
49 - * Primitive types like <code>int</code> and <code>float</code>, their wrapper  
50 - * counterparts like {@link Integer} and {@link Float} and the {@link String} class  
51 - * can already be converted by the framework, this interface is reserved for specialized  
52 - * classes.  
53 - * </p>  
54 - *  
55 - * @author SERPRO  
56 - */  
57 -@SuppressWarnings("unused")  
58 -public interface ConfigurationValueExtractor {  
59 -  
60 - /**  
61 - * Method that must appropriately extract the value from a property file and set this value to a  
62 - * field in a configuration class.  
63 - *  
64 - * @param prefix  
65 - * optional parte of property name that must be concatenated with <b>key</b> to form the whole  
66 - * property name.  
67 - * @param key  
68 - * key of the property.  
69 - * @param field  
70 - * configuration field to be setted.  
71 - * @param configuration  
72 - * a configuration object.  
73 - * @return current value of this property  
74 - * @throws Exception if the value can't be extracted from the property file  
75 - */  
76 - Object getValue(String prefix, String key, Field field, Configuration configuration) throws Exception;  
77 -  
78 - /**  
79 - * Checks if the extractor class is appropriate to extract values to the type of deffined by parameter  
80 - * <b>field</b>.  
81 - *  
82 - * @param field  
83 - * field to be checked.  
84 - * @return <code>true</code> if this extractor can convert this field into the extractor's final type  
85 - */  
86 - boolean isSupported(Field field);  
87 -}  
configuration/src/main/java/org/demoiselle/internal/implementation/ConfigurationArrayValueExtractor.java
@@ -1,63 +0,0 @@ @@ -1,63 +0,0 @@
1 -/*  
2 - * Demoiselle Framework  
3 - * Copyright (C) 2010 SERPRO  
4 - * ----------------------------------------------------------------------------  
5 - * This file is part of Demoiselle Framework.  
6 - *  
7 - * Demoiselle Framework is free software; you can redistribute it and/or  
8 - * modify it under the terms of the GNU Lesser General Public License version 3  
9 - * as published by the Free Software Foundation.  
10 - *  
11 - * This program is distributed in the hope that it will be useful,  
12 - * but WITHOUT ANY WARRANTY; without even the implied warranty of  
13 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  
14 - * GNU General Public License for more details.  
15 - *  
16 - * You should have received a copy of the GNU Lesser General Public License version 3  
17 - * along with this program; if not, see <http://www.gnu.org/licenses/>  
18 - * or write to the Free Software Foundation, Inc., 51 Franklin Street,  
19 - * Fifth Floor, Boston, MA 02110-1301, USA.  
20 - * ----------------------------------------------------------------------------  
21 - * Este arquivo é parte do Framework Demoiselle.  
22 - *  
23 - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou  
24 - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação  
25 - * do Software Livre (FSF).  
26 - *  
27 - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA  
28 - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou  
29 - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português  
30 - * para maiores detalhes.  
31 - *  
32 - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título  
33 - * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>  
34 - * ou escreva para a Fundação do Software Livre (FSF) Inc.,  
35 - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.  
36 - */  
37 -package org.demoiselle.internal.implementation;  
38 -  
39 -import org.apache.commons.configuration2.Configuration;  
40 -import org.apache.commons.configuration2.DataConfiguration;  
41 -import org.demoiselle.annotation.Priority;  
42 -import org.demoiselle.configuration.ConfigurationValueExtractor;  
43 -  
44 -import javax.enterprise.context.Dependent;  
45 -import java.lang.reflect.Field;  
46 -  
47 -import static org.demoiselle.annotation.Priority.L2_PRIORITY;  
48 -  
49 -@SuppressWarnings("unused")  
50 -@Dependent  
51 -@Priority(L2_PRIORITY)  
52 -public class ConfigurationArrayValueExtractor implements ConfigurationValueExtractor {  
53 -  
54 - @Override  
55 - public Object getValue(String prefix, String key, Field field, Configuration configuration) throws Exception {  
56 - return new DataConfiguration(configuration).getArray(field.getType().getComponentType(), prefix + key);  
57 - }  
58 -  
59 - @Override  
60 - public boolean isSupported(Field field) {  
61 - return field.getType().isArray();  
62 - }  
63 -}  
configuration/src/main/java/org/demoiselle/internal/implementation/ConfigurationClassValueExtractor.java
@@ -1,70 +0,0 @@ @@ -1,70 +0,0 @@
1 -/*  
2 - * Demoiselle Framework  
3 - * Copyright (C) 2010 SERPRO  
4 - * ----------------------------------------------------------------------------  
5 - * This file is part of Demoiselle Framework.  
6 - *  
7 - * Demoiselle Framework is free software; you can redistribute it and/or  
8 - * modify it under the terms of the GNU Lesser General Public License version 3  
9 - * as published by the Free Software Foundation.  
10 - *  
11 - * This program is distributed in the hope that it will be useful,  
12 - * but WITHOUT ANY WARRANTY; without even the implied warranty of  
13 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  
14 - * GNU General Public License for more details.  
15 - *  
16 - * You should have received a copy of the GNU Lesser General Public License version 3  
17 - * along with this program; if not, see <http://www.gnu.org/licenses/>  
18 - * or write to the Free Software Foundation, Inc., 51 Franklin Street,  
19 - * Fifth Floor, Boston, MA 02110-1301, USA.  
20 - * ----------------------------------------------------------------------------  
21 - * Este arquivo é parte do Framework Demoiselle.  
22 - *  
23 - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou  
24 - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação  
25 - * do Software Livre (FSF).  
26 - *  
27 - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA  
28 - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou  
29 - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português  
30 - * para maiores detalhes.  
31 - *  
32 - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título  
33 - * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>  
34 - * ou escreva para a Fundação do Software Livre (FSF) Inc.,  
35 - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.  
36 - */  
37 -package org.demoiselle.internal.implementation;  
38 -  
39 -import org.apache.commons.configuration2.Configuration;  
40 -import org.demoiselle.annotation.Priority;  
41 -import org.demoiselle.configuration.ConfigurationValueExtractor;  
42 -import org.demoiselle.util.Reflections;  
43 -  
44 -import javax.enterprise.context.Dependent;  
45 -import java.lang.reflect.Field;  
46 -  
47 -import static org.demoiselle.annotation.Priority.L2_PRIORITY;  
48 -  
49 -@SuppressWarnings("unused")  
50 -@Priority(L2_PRIORITY)  
51 -@Dependent  
52 -public class ConfigurationClassValueExtractor implements ConfigurationValueExtractor {  
53 -  
54 - @Override  
55 - public Object getValue(String prefix, String key, Field field, Configuration configuration) throws Exception {  
56 - Object value = null;  
57 - String canonicalName = configuration.getString(prefix + key);  
58 -  
59 - if (canonicalName != null) {  
60 - value = Reflections.forName(canonicalName);  
61 - }  
62 -  
63 - return value;  
64 - }  
65 -  
66 - @Override  
67 - public boolean isSupported(Field field) {  
68 - return field.getType() == Class.class;  
69 - }  
70 -}  
configuration/src/main/java/org/demoiselle/internal/implementation/ConfigurationEnumValueExtractor.java
@@ -1,92 +0,0 @@ @@ -1,92 +0,0 @@
1 -/*  
2 - * Demoiselle Framework  
3 - * Copyright (C) 2010 SERPRO  
4 - * ----------------------------------------------------------------------------  
5 - * This file is part of Demoiselle Framework.  
6 - *  
7 - * Demoiselle Framework is free software; you can redistribute it and/or  
8 - * modify it under the terms of the GNU Lesser General Public License version 3  
9 - * as published by the Free Software Foundation.  
10 - *  
11 - * This program is distributed in the hope that it will be useful,  
12 - * but WITHOUT ANY WARRANTY; without even the implied warranty of  
13 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  
14 - * GNU General Public License for more details.  
15 - *  
16 - * You should have received a copy of the GNU Lesser General Public License version 3  
17 - * along with this program; if not, see <http://www.gnu.org/licenses/>  
18 - * or write to the Free Software Foundation, Inc., 51 Franklin Street,  
19 - * Fifth Floor, Boston, MA 02110-1301, USA.  
20 - * ----------------------------------------------------------------------------  
21 - * Este arquivo é parte do Framework Demoiselle.  
22 - *  
23 - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou  
24 - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação  
25 - * do Software Livre (FSF).  
26 - *  
27 - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA  
28 - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou  
29 - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português  
30 - * para maiores detalhes.  
31 - *  
32 - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título  
33 - * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>  
34 - * ou escreva para a Fundação do Software Livre (FSF) Inc.,  
35 - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.  
36 - */  
37 -package org.demoiselle.internal.implementation;  
38 -  
39 -import org.apache.commons.configuration2.Configuration;  
40 -import org.apache.commons.configuration2.ex.ConversionException;  
41 -import org.demoiselle.annotation.Priority;  
42 -import org.demoiselle.annotation.literal.NamedQualifier;  
43 -import org.demoiselle.configuration.ConfigurationValueExtractor;  
44 -import org.demoiselle.util.ResourceBundle;  
45 -  
46 -import javax.enterprise.context.Dependent;  
47 -import javax.enterprise.inject.spi.CDI;  
48 -import java.lang.reflect.Field;  
49 -  
50 -import static org.demoiselle.annotation.Priority.L2_PRIORITY;  
51 -  
52 -@SuppressWarnings("unused")  
53 -@Priority(L2_PRIORITY)  
54 -@Dependent  
55 -public class ConfigurationEnumValueExtractor implements ConfigurationValueExtractor {  
56 -  
57 - private transient ResourceBundle bundle;  
58 -  
59 - @Override  
60 - public Object getValue(String prefix, String key, Field field, Configuration configuration) throws Exception {  
61 - String value = configuration.getString(prefix + key);  
62 -  
63 - if (value != null && !value.trim().equals("")) {  
64 - Object enums[] = field.getType().getEnumConstants();  
65 -  
66 - for (int i = 0; i < enums.length; i++) {  
67 - if (((Enum<?>) enums[i]).name().equals(value)) {  
68 - return enums[i];  
69 - }  
70 - }  
71 - } else {  
72 - return null;  
73 - }  
74 -  
75 - throw new ConversionException(getBundle()  
76 - .getString("configuration-not-conversion", value, field.getDeclaringClass().getCanonicalName()));  
77 - }  
78 -  
79 - @Override  
80 - public boolean isSupported(Field field) {  
81 - return field.getType().isEnum();  
82 - }  
83 -  
84 - private ResourceBundle getBundle() {  
85 - if (bundle == null) {  
86 - bundle = CDI.current().select(ResourceBundle.class, new NamedQualifier("demoiselle-core-bundle")).get();  
87 - }  
88 -  
89 - return bundle;  
90 - }  
91 -  
92 -}  
configuration/src/main/java/org/demoiselle/internal/implementation/ConfigurationLoader.java
@@ -1,356 +0,0 @@ @@ -1,356 +0,0 @@
1 -/*  
2 -/*  
3 - * Demoiselle Framework  
4 - * Copyright (C) 2010 SERPRO  
5 - * ----------------------------------------------------------------------------  
6 - * This file is part of Demoiselle Framework.  
7 - *  
8 - * Demoiselle Framework is free software; you can redistribute it and/or  
9 - * modify it under the terms of the GNU Lesser General Public License version 3  
10 - * as published by the Free Software Foundation.  
11 - *  
12 - * This program is distributed in the hope that it will be useful,  
13 - * but WITHOUT ANY WARRANTY; without even the implied warranty of  
14 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  
15 - * GNU General Public License for more details.  
16 - *  
17 - * You should have received a copy of the GNU Lesser General Public License version 3  
18 - * along with this program; if not, see <http://www.gnu.org/licenses/>  
19 - * or write to the Free Software Foundation, Inc., 51 Franklin Street,  
20 - * Fifth Floor, Boston, MA 02110-1301, USA.  
21 - * ----------------------------------------------------------------------------  
22 - * Este arquivo é parte do Framework Demoiselle.  
23 - *  
24 - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou  
25 - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação  
26 - * do Software Livre (FSF).  
27 - *  
28 - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA  
29 - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou  
30 - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português  
31 - * para maiores detalhes.  
32 - *  
33 - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título  
34 - * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>  
35 - * ou escreva para a Fundação do Software Livre (FSF) Inc.,  
36 - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.  
37 - */  
38 -package org.demoiselle.internal.implementation;  
39 -  
40 -import org.apache.commons.configuration2.Configuration;  
41 -import org.apache.commons.configuration2.*;  
42 -import org.apache.commons.configuration2.builder.BasicConfigurationBuilder;  
43 -import org.apache.commons.configuration2.builder.FileBasedConfigurationBuilder;  
44 -import org.apache.commons.configuration2.builder.fluent.Parameters;  
45 -import org.demoiselle.annotation.Ignore;  
46 -import org.demoiselle.annotation.Name;  
47 -import org.demoiselle.annotation.literal.NameQualifier;  
48 -import org.demoiselle.configuration.ConfigType;  
49 -import org.demoiselle.configuration.ConfigurationException;  
50 -import org.demoiselle.util.Reflections;  
51 -import org.demoiselle.util.ResourceBundle;  
52 -import org.demoiselle.util.Strings;  
53 -  
54 -import javax.enterprise.context.ApplicationScoped;  
55 -import javax.enterprise.inject.spi.CDI;  
56 -import javax.inject.Named;  
57 -import javax.validation.*;  
58 -import java.io.Serializable;  
59 -import java.lang.reflect.Field;  
60 -import java.util.*;  
61 -import java.util.concurrent.ConcurrentHashMap;  
62 -import java.util.logging.Logger;  
63 -import javax.inject.Inject;  
64 -import org.apache.commons.configuration2.ex.ConversionException;  
65 -  
66 -import static org.demoiselle.configuration.ConfigType.SYSTEM;  
67 -import org.demoiselle.configuration.ConfigurationValueExtractor;  
68 -  
69 -/**  
70 - * This component loads a config class annotated with  
71 - * {@link org.demoiselle.configuration.Configuration} by filling its attributes  
72 - * with {@link org.demoiselle.jsf.util.Parameter} according to a  
73 - * {@link org.demoiselle.configuration.ConfigType}.  
74 - *  
75 - * @author SERPRO  
76 - */  
77 -@ApplicationScoped  
78 -@Named("demoiselle-configuration-loader")  
79 -public class ConfigurationLoader implements Serializable {  
80 -  
81 - @Inject  
82 - private Logger LOG;  
83 -  
84 - private static final long serialVersionUID = 1L;  
85 -  
86 - private ResourceBundle bundle;  
87 -  
88 - private Object object;  
89 -  
90 - private Class<?> baseClass;  
91 -  
92 - private ConfigType type;  
93 -  
94 - private String resource;  
95 -  
96 - private String prefix;  
97 -  
98 - private Configuration configuration;  
99 -  
100 - private Collection<Field> fields;  
101 -  
102 - private final Map<Object, Boolean> loadedCache = new ConcurrentHashMap<>();  
103 -  
104 - private Collection<Class<?>> extractorCache;  
105 -  
106 - public void load(final Object object, Class<?> baseClass) throws ConfigurationException {  
107 - Boolean isLoaded = loadedCache.get(object);  
108 -  
109 - if (isLoaded == null || !isLoaded) {  
110 - try {  
111 - loadConfiguration(object, baseClass, true);  
112 - loadedCache.put(object, true);  
113 - } catch (ConfigurationException c) {  
114 - loadedCache.put(object, false);  
115 - throw c;  
116 - }  
117 - }  
118 - }  
119 -  
120 - public void load(final Object object, Class<?> baseClass, boolean logLoadingProcess) throws ConfigurationException {  
121 - Boolean isLoaded = loadedCache.get(object);  
122 -  
123 - if (isLoaded == null || !isLoaded) {  
124 - try {  
125 - loadConfiguration(object, baseClass, logLoadingProcess);  
126 - loadedCache.put(object, true);  
127 - } catch (ConfigurationException c) {  
128 - loadedCache.put(object, false);  
129 - throw c;  
130 - }  
131 - }  
132 - }  
133 -  
134 - private void loadConfiguration(final Object object, Class<?> baseClass, boolean logLoadingProcess)  
135 - throws ConfigurationException {  
136 - if (logLoadingProcess) {  
137 - LOG.fine(getBundle().getString("loading-configuration-class", baseClass.getName()));  
138 - }  
139 -  
140 - this.object = object;  
141 - this.baseClass = baseClass;  
142 -  
143 - loadFields();  
144 - validateFields();  
145 -  
146 - loadType();  
147 - loadResource();  
148 - loadConfiguration();  
149 -  
150 - if (this.configuration != null) {  
151 - loadPrefix();  
152 - loadValues();  
153 - }  
154 -  
155 - validateValues();  
156 - }  
157 -  
158 - private void loadFields() {  
159 - this.fields = Reflections.getNonStaticFields(baseClass);  
160 - }  
161 -  
162 - private void validateFields() {  
163 - this.fields.forEach(this::validateField);  
164 - }  
165 -  
166 - private void validateField(Field field) {  
167 - Name annotation = field.getAnnotation(Name.class);  
168 -  
169 - if (annotation != null && Strings.isEmpty(annotation.value())) {  
170 - throw new ConfigurationException(getBundle().getString("configuration-name-attribute-cant-be-empty"),  
171 - new IllegalArgumentException());  
172 - }  
173 - }  
174 -  
175 - private void loadType() {  
176 - this.type = baseClass.getAnnotation(org.demoiselle.configuration.Configuration.class).type();  
177 - }  
178 -  
179 - private void loadResource() {  
180 - if (this.type != SYSTEM) {  
181 - String name = baseClass.getAnnotation(org.demoiselle.configuration.Configuration.class)  
182 - .resource();  
183 - String extension = this.type.toString().toLowerCase();  
184 -  
185 - this.resource = name + "." + extension;  
186 - }  
187 - }  
188 -  
189 - private void loadConfiguration() {  
190 - Configuration config;  
191 - BasicConfigurationBuilder<? extends Configuration> builder = createConfiguration();  
192 -  
193 - if (builder instanceof FileBasedConfigurationBuilder) {  
194 - Parameters params = new Parameters();  
195 -  
196 - ((FileBasedConfigurationBuilder) builder)  
197 - .configure(params.fileBased().setURL(Reflections.getResourceAsURL(this.resource)));  
198 - }  
199 -  
200 - try {  
201 - config = builder.getConfiguration();  
202 - } catch (org.apache.commons.configuration2.ex.ConfigurationException e) {  
203 - LOG.warning(getBundle().getString("file-not-found", this.resource));  
204 - config = null;  
205 - }  
206 -  
207 - this.configuration = config;  
208 - }  
209 -  
210 - private BasicConfigurationBuilder<? extends Configuration> createConfiguration() {  
211 - BasicConfigurationBuilder<? extends Configuration> builder;  
212 -  
213 - switch (this.type) {  
214 - case XML:  
215 - builder = new FileBasedConfigurationBuilder<FileBasedConfiguration>(XMLConfiguration.class);  
216 - break;  
217 -  
218 - case SYSTEM:  
219 - builder = new BasicConfigurationBuilder<>(SystemConfiguration.class);  
220 - break;  
221 -  
222 - default:  
223 - builder = new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class);  
224 - }  
225 -  
226 - return builder;  
227 - }  
228 -  
229 - private void loadPrefix() {  
230 - String prefix = baseClass.getAnnotation(org.demoiselle.configuration.Configuration.class).prefix();  
231 -  
232 - if (prefix.endsWith(".")) {  
233 - LOG.warning(getBundle().getString("configuration-dot-after-prefix", this.resource));  
234 - } else if (!prefix.isEmpty()) {  
235 - prefix += ".";  
236 - }  
237 -  
238 - this.prefix = prefix;  
239 - }  
240 -  
241 - private void loadValues() {  
242 - this.fields.forEach(this::loadValue);  
243 - }  
244 -  
245 - private void loadValue(Field field) {  
246 - if (hasIgnore(field)) {  
247 - return;  
248 - }  
249 -  
250 - Object defaultValue = Reflections.getFieldValue(field, this.object);  
251 - Object loadedValue = getValue(field, field.getType(), getKey(field), defaultValue);  
252 - Object finalValue = (loadedValue == null ? defaultValue : loadedValue);  
253 -  
254 - if (loadedValue == null) {  
255 - LOG.fine(getBundle().getString("configuration-key-not-found", this.prefix + getKey(field)));  
256 - }  
257 -  
258 - Reflections.setFieldValue(field, this.object, finalValue);  
259 - LOG.finer(getBundle()  
260 - .getString("configuration-field-loaded", this.prefix + getKey(field), field.getName(),  
261 - finalValue == null ? "null" : finalValue));  
262 - }  
263 -  
264 - private Object getValue(Field field, Class<?> type, String key, Object defaultValue) {  
265 - Object value;  
266 -  
267 - try {  
268 - ConfigurationValueExtractor extractor = getValueExtractor(field);  
269 - value = extractor.getValue(this.prefix, key, field, this.configuration);  
270 -  
271 - } catch (ConfigurationException cause) {  
272 - throw cause;  
273 -  
274 - } catch (ConversionException cause) {  
275 - throw new ConfigurationException(getBundle()  
276 - .getString("configuration-not-conversion", this.prefix + getKey(field), field.getType().toString()),  
277 - cause);  
278 - } catch (Exception cause) {  
279 - throw new ConfigurationException(getBundle()  
280 - .getString("configuration-generic-extraction-error", field.getType().toString(),  
281 - getValueExtractor(field).getClass().getCanonicalName()), cause);  
282 - }  
283 - return value;  
284 - }  
285 -  
286 - private ConfigurationValueExtractor getValueExtractor(Field field) {  
287 - Collection<ConfigurationValueExtractor> candidates = new HashSet<ConfigurationValueExtractor>();  
288 -  
289 -  
290 - if (elected == null) {  
291 - throw new ConfigurationException(getBundle()  
292 - .getString("configuration-extractor-not-found", field.toGenericString(),  
293 - ConfigurationValueExtractor.class.getName()), new ClassNotFoundException());  
294 - }  
295 -  
296 - return elected;  
297 - }  
298 -  
299 - private String getKey(Field field) {  
300 - String key;  
301 -  
302 - if (field.isAnnotationPresent(Name.class)) {  
303 - key = field.getAnnotation(Name.class).value();  
304 - } else {  
305 - key = field.getName();  
306 - }  
307 -  
308 - return key;  
309 - }  
310 -  
311 - private boolean hasIgnore(Field field) {  
312 - return field.isAnnotationPresent(Ignore.class);  
313 - }  
314 -  
315 - private void validateValues() {  
316 - for (Field field : this.fields) {  
317 - validateValue(field, Reflections.getFieldValue(field, this.object));  
318 - }  
319 - }  
320 -  
321 - @SuppressWarnings({"rawtypes", "unchecked"})  
322 - private void validateValue(Field field, Object value) {  
323 - ValidatorFactory dfv = Validation.buildDefaultValidatorFactory();  
324 - Validator validator = dfv.getValidator();  
325 -  
326 - Set violations = validator.validateProperty(this.object, field.getName());  
327 -  
328 - StringBuilder message = new StringBuilder();  
329 -  
330 - if (!violations.isEmpty()) {  
331 - for (Iterator iter = violations.iterator(); iter.hasNext();) {  
332 - ConstraintViolation violation = (ConstraintViolation) iter.next();  
333 - message.append(field.toGenericString() + " " + violation.getMessage() + "\n");  
334 - }  
335 -  
336 - throw new ConfigurationException(message.toString(), new ConstraintViolationException(violations));  
337 - }  
338 - }  
339 -  
340 - private Collection<Class<?>> getCache() {  
341 - if (this.extractorCache == null) {  
342 - this.extractorCache = Collections.synchronizedSet(new HashSet<>());  
343 - }  
344 -  
345 - return this.extractorCache;  
346 - }  
347 -  
348 - private ResourceBundle getBundle() {  
349 - if (bundle == null) {  
350 - bundle = CDI.current().select(ResourceBundle.class, new NameQualifier("configuration-bundle")).get();  
351 - }  
352 -  
353 - return bundle;  
354 - }  
355 -  
356 -}  
configuration/src/main/java/org/demoiselle/internal/implementation/ConfigurationMapValueExtractor.java
@@ -1,93 +0,0 @@ @@ -1,93 +0,0 @@
1 -/*  
2 - * Demoiselle Framework  
3 - * Copyright (C) 2010 SERPRO  
4 - * ----------------------------------------------------------------------------  
5 - * This file is part of Demoiselle Framework.  
6 - *  
7 - * Demoiselle Framework is free software; you can redistribute it and/or  
8 - * modify it under the terms of the GNU Lesser General Public License version 3  
9 - * as published by the Free Software Foundation.  
10 - *  
11 - * This program is distributed in the hope that it will be useful,  
12 - * but WITHOUT ANY WARRANTY; without even the implied warranty of  
13 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  
14 - * GNU General Public License for more details.  
15 - *  
16 - * You should have received a copy of the GNU Lesser General Public License version 3  
17 - * along with this program; if not, see <http://www.gnu.org/licenses/>  
18 - * or write to the Free Software Foundation, Inc., 51 Franklin Street,  
19 - * Fifth Floor, Boston, MA 02110-1301, USA.  
20 - * ----------------------------------------------------------------------------  
21 - * Este arquivo é parte do Framework Demoiselle.  
22 - *  
23 - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou  
24 - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação  
25 - * do Software Livre (FSF).  
26 - *  
27 - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA  
28 - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou  
29 - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português  
30 - * para maiores detalhes.  
31 - *  
32 - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título  
33 - * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>  
34 - * ou escreva para a Fundação do Software Livre (FSF) Inc.,  
35 - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.  
36 - */  
37 -package org.demoiselle.internal.implementation;  
38 -  
39 -  
40 -  
41 -import org.apache.commons.configuration2.Configuration;  
42 -import org.demoiselle.annotation.Priority;  
43 -import org.demoiselle.configuration.ConfigurationValueExtractor;  
44 -  
45 -import javax.enterprise.context.Dependent;  
46 -import java.lang.reflect.Field;  
47 -import java.util.HashMap;  
48 -import java.util.Iterator;  
49 -import java.util.Map;  
50 -import java.util.regex.Matcher;  
51 -import java.util.regex.Pattern;  
52 -  
53 -import static org.demoiselle.annotation.Priority.L2_PRIORITY;  
54 -  
55 -@SuppressWarnings("unused")  
56 -@Priority(L2_PRIORITY)  
57 -@Dependent  
58 -public class ConfigurationMapValueExtractor implements ConfigurationValueExtractor {  
59 -  
60 - @Override  
61 - public Object getValue(String prefix, String key, Field field, Configuration configuration) throws Exception {  
62 - Map<String, Object> value = null;  
63 -  
64 - String regexp = "^(" + prefix + ")(" + key + ")(\\.(\\w+))?$";  
65 - Pattern pattern = Pattern.compile(regexp);  
66 -  
67 - for (Iterator<String> iter = configuration.getKeys(); iter.hasNext();) {  
68 - String iterKey = iter.next();  
69 - Matcher matcher = pattern.matcher(iterKey);  
70 -  
71 - if (matcher.matches()) {  
72 - String confKey = matcher.group(1) + matcher.group(2) + ( matcher.group(3)!=null ? matcher.group(3) : "" );  
73 -  
74 - /*matcher.group(1) + (matcher.group(2) == null ? "" : matcher.group(2))  
75 - + matcher.group(4);*/  
76 -  
77 - if (value == null) {  
78 - value = new HashMap<>();  
79 - }  
80 -  
81 - String mapKey = matcher.group(4) == null ? "default" : matcher.group(4);  
82 - value.put(mapKey, configuration.getString(confKey));  
83 - }  
84 - }  
85 -  
86 - return value;  
87 - }  
88 -  
89 - @Override  
90 - public boolean isSupported(Field field) {  
91 - return field.getType() == Map.class;  
92 - }  
93 -}  
configuration/src/main/java/org/demoiselle/internal/implementation/ConfigurationPrimitiveOrWrapperValueExtractor.java
@@ -1,92 +0,0 @@ @@ -1,92 +0,0 @@
1 -/*  
2 - * Demoiselle Framework  
3 - * Copyright (C) 2010 SERPRO  
4 - * ----------------------------------------------------------------------------  
5 - * This file is part of Demoiselle Framework.  
6 - *  
7 - * Demoiselle Framework is free software; you can redistribute it and/or  
8 - * modify it under the terms of the GNU Lesser General Public License version 3  
9 - * as published by the Free Software Foundation.  
10 - *  
11 - * This program is distributed in the hope that it will be useful,  
12 - * but WITHOUT ANY WARRANTY; without even the implied warranty of  
13 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  
14 - * GNU General Public License for more details.  
15 - *  
16 - * You should have received a copy of the GNU Lesser General Public License version 3  
17 - * along with this program; if not, see <http://www.gnu.org/licenses/>  
18 - * or write to the Free Software Foundation, Inc., 51 Franklin Street,  
19 - * Fifth Floor, Boston, MA 02110-1301, USA.  
20 - * ----------------------------------------------------------------------------  
21 - * Este arquivo é parte do Framework Demoiselle.  
22 - *  
23 - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou  
24 - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação  
25 - * do Software Livre (FSF).  
26 - *  
27 - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA  
28 - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou  
29 - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português  
30 - * para maiores detalhes.  
31 - *  
32 - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título  
33 - * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>  
34 - * ou escreva para a Fundação do Software Livre (FSF) Inc.,  
35 - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.  
36 - */  
37 -package org.demoiselle.internal.implementation;  
38 -  
39 -import org.apache.commons.configuration2.Configuration;  
40 -import org.apache.commons.configuration2.DataConfiguration;  
41 -import org.apache.commons.configuration2.ex.ConversionException;  
42 -import org.apache.commons.lang3.ClassUtils;  
43 -import org.demoiselle.annotation.Priority;  
44 -import org.demoiselle.configuration.ConfigurationValueExtractor;  
45 -  
46 -import javax.enterprise.context.Dependent;  
47 -import java.lang.reflect.Field;  
48 -import java.util.HashSet;  
49 -import java.util.Set;  
50 -  
51 -import static org.demoiselle.annotation.Priority.L2_PRIORITY;  
52 -  
53 -@SuppressWarnings("unused")  
54 -@Priority(L2_PRIORITY)  
55 -@Dependent  
56 -public class ConfigurationPrimitiveOrWrapperValueExtractor implements ConfigurationValueExtractor {  
57 -  
58 - private static final Set<Object> wrappers = new HashSet<Object>();  
59 -  
60 - static {  
61 - wrappers.add(Boolean.class);  
62 - wrappers.add(Byte.class);  
63 - wrappers.add(Character.class);  
64 - wrappers.add(Short.class);  
65 - wrappers.add(Integer.class);  
66 - wrappers.add(Long.class);  
67 - wrappers.add(Double.class);  
68 - wrappers.add(Float.class);  
69 - wrappers.add(Void.TYPE);  
70 - }  
71 -  
72 - @Override  
73 - @SuppressWarnings("unchecked")  
74 - public Object getValue(String prefix, String key, Field field, Configuration configuration) throws Exception {  
75 - Object value;  
76 -  
77 - try {  
78 - value = new DataConfiguration(configuration)  
79 - .get(ClassUtils.primitiveToWrapper(field.getType()), prefix + key);  
80 -  
81 - } catch (ConversionException cause) {  
82 - throw cause;  
83 - }  
84 -  
85 - return value;  
86 - }  
87 -  
88 - @Override  
89 - public boolean isSupported(Field field) {  
90 - return field.getType().isPrimitive() || wrappers.contains(field.getType());  
91 - }  
92 -}  
configuration/src/main/java/org/demoiselle/internal/implementation/ConfigurationProxyTemplateImpl.java
@@ -1,67 +0,0 @@ @@ -1,67 +0,0 @@
1 -/*  
2 - * Demoiselle Framework  
3 - * Copyright (C) 2010 SERPRO  
4 - * ----------------------------------------------------------------------------  
5 - * This file is part of Demoiselle Framework.  
6 - *  
7 - * Demoiselle Framework is free software; you can redistribute it and/or  
8 - * modify it under the terms of the GNU Lesser General Public License version 3  
9 - * as published by the Free Software Foundation.  
10 - *  
11 - * This program is distributed in the hope that it will be useful,  
12 - * but WITHOUT ANY WARRANTY; without even the implied warranty of  
13 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  
14 - * GNU General Public License for more details.  
15 - *  
16 - * You should have received a copy of the GNU Lesser General Public License version 3  
17 - * along with this program; if not, see <http://www.gnu.org/licenses/>  
18 - * or write to the Free Software Foundation, Inc., 51 Franklin Street,  
19 - * Fifth Floor, Boston, MA 02110-1301, USA.  
20 - * ----------------------------------------------------------------------------  
21 - * Este arquivo é parte do Framework Demoiselle.  
22 - *  
23 - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou  
24 - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação  
25 - * do Software Livre (FSF).  
26 - *  
27 - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA  
28 - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou  
29 - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português  
30 - * para maiores detalhes.  
31 - *  
32 - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título  
33 - * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>  
34 - * ou escreva para a Fundação do Software Livre (FSF) Inc.,  
35 - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.  
36 - */  
37 -package org.demoiselle.internal.implementation;  
38 -  
39 -import org.demoiselle.annotation.Ignore;  
40 -  
41 -import javax.enterprise.inject.spi.CDI;  
42 -import java.io.Serializable;  
43 -  
44 -public class ConfigurationProxyTemplateImpl implements Serializable {  
45 -  
46 - private static final long serialVersionUID = 1L;  
47 -  
48 - @Ignore  
49 - private Boolean loaded = false;  
50 -  
51 - private final Object lock = new Object();  
52 -  
53 - @SuppressWarnings("unused")  
54 - private void load(Object instance) throws Throwable {  
55 - /*synchronized (lock) {  
56 - if (!loaded) {  
57 - try {  
58 - CDI.current().select(ConfigurationLoader.class).get().load(instance);  
59 - loaded = true;  
60 - } catch (Throwable cause) {  
61 - loaded = false;  
62 - throw cause;  
63 - }  
64 - }  
65 - }*/  
66 - }  
67 -}  
configuration/src/main/java/org/demoiselle/internal/implementation/ConfigurationStringValueExtractor.java
@@ -1,62 +0,0 @@ @@ -1,62 +0,0 @@
1 -/*  
2 - * Demoiselle Framework  
3 - * Copyright (C) 2010 SERPRO  
4 - * ----------------------------------------------------------------------------  
5 - * This file is part of Demoiselle Framework.  
6 - *  
7 - * Demoiselle Framework is free software; you can redistribute it and/or  
8 - * modify it under the terms of the GNU Lesser General Public License version 3  
9 - * as published by the Free Software Foundation.  
10 - *  
11 - * This program is distributed in the hope that it will be useful,  
12 - * but WITHOUT ANY WARRANTY; without even the implied warranty of  
13 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  
14 - * GNU General Public License for more details.  
15 - *  
16 - * You should have received a copy of the GNU Lesser General Public License version 3  
17 - * along with this program; if not, see <http://www.gnu.org/licenses/>  
18 - * or write to the Free Software Foundation, Inc., 51 Franklin Street,  
19 - * Fifth Floor, Boston, MA 02110-1301, USA.  
20 - * ----------------------------------------------------------------------------  
21 - * Este arquivo é parte do Framework Demoiselle.  
22 - *  
23 - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou  
24 - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação  
25 - * do Software Livre (FSF).  
26 - *  
27 - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA  
28 - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou  
29 - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português  
30 - * para maiores detalhes.  
31 - *  
32 - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título  
33 - * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>  
34 - * ou escreva para a Fundação do Software Livre (FSF) Inc.,  
35 - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.  
36 - */  
37 -package org.demoiselle.internal.implementation;  
38 -  
39 -import org.apache.commons.configuration2.Configuration;  
40 -import org.demoiselle.annotation.Priority;  
41 -import org.demoiselle.configuration.ConfigurationValueExtractor;  
42 -  
43 -import javax.enterprise.context.Dependent;  
44 -import java.lang.reflect.Field;  
45 -  
46 -import static org.demoiselle.annotation.Priority.L2_PRIORITY;  
47 -  
48 -@SuppressWarnings("unused")  
49 -@Priority(L2_PRIORITY)  
50 -@Dependent  
51 -public class ConfigurationStringValueExtractor implements ConfigurationValueExtractor {  
52 -  
53 - @Override  
54 - public Object getValue(String prefix, String key, Field field, Configuration configuration) throws Exception {  
55 - return configuration.getString(prefix + key);  
56 - }  
57 -  
58 - @Override  
59 - public boolean isSupported(Field field) {  
60 - return field.getType() == String.class;  
61 - }  
62 -}  
configuration/src/main/java/org/demoiselle/util/Reflections.java
@@ -1,383 +0,0 @@ @@ -1,383 +0,0 @@
1 -/*  
2 - * Demoiselle Framework  
3 - * Copyright (C) 2010 SERPRO  
4 - * ----------------------------------------------------------------------------  
5 - * This file is part of Demoiselle Framework.  
6 - *  
7 - * Demoiselle Framework is free software; you can redistribute it and/or  
8 - * modify it under the terms of the GNU Lesser General Public License version 3  
9 - * as published by the Free Software Foundation.  
10 - *  
11 - * This program is distributed in the hope that it will be useful,  
12 - * but WITHOUT ANY WARRANTY; without even the implied warranty of  
13 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  
14 - * GNU General Public License for more details.  
15 - *  
16 - * You should have received a copy of the GNU Lesser General Public License version 3  
17 - * along with this program; if not, see <http://www.gnu.org/licenses/>  
18 - * or write to the Free Software Foundation, Inc., 51 Franklin Street,  
19 - * Fifth Floor, Boston, MA 02110-1301, USA.  
20 - * ----------------------------------------------------------------------------  
21 - * Este arquivo é parte do Framework Demoiselle.  
22 - *  
23 - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou  
24 - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação  
25 - * do Software Livre (FSF).  
26 - *  
27 - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA  
28 - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou  
29 - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português  
30 - * para maiores detalhes.  
31 - *  
32 - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título  
33 - * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>  
34 - * ou escreva para a Fundação do Software Livre (FSF) Inc.,  
35 - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.  
36 - */  
37 -package org.demoiselle.util;  
38 -  
39 -import java.io.InputStream;  
40 -import java.lang.reflect.*;  
41 -import java.net.URL;  
42 -import java.util.ArrayList;  
43 -import java.util.Arrays;  
44 -import java.util.List;  
45 -import java.util.logging.Logger;  
46 -  
47 -/**  
48 - * Provides some features to do some operations relating to java reflection.  
49 - *  
50 - * @author SERPRO  
51 - */  
52 -public class Reflections {  
53 -  
54 - private static final Logger LOG = Logger.getLogger(Reflections.class.getName());  
55 -  
56 - protected Reflections() {  
57 - // Impede instanciar subclasses desse tipo.  
58 - throw new UnsupportedOperationException();  
59 - }  
60 -  
61 - /**  
62 - * Return the parametized type used with a concrete implementation of a  
63 - * class that accepts generics. Ex: If you declare  
64 - * <pre>  
65 - * public class SpecializedCollection implements Collection&#60;SpecializedType&#62; {  
66 - * // ...  
67 - * }  
68 - * </pre> then the code  
69 - * <code>getGenericTypeArgument(SpecializedCollection.class , 0);</code>  
70 - * will return the type <code>SpecializedType</code>.  
71 - *  
72 - * @param type Base type to check for generic arguments  
73 - * @param idx zero based index of the generic argument to get  
74 - * @param <T> Type of the generic argument  
75 - * @return The class representing the type of the generic argument  
76 - */  
77 - @SuppressWarnings("unchecked")  
78 - public static <T> Class<T> getGenericTypeArgument(final Type type, final int idx) {  
79 - ParameterizedType paramType;  
80 - try {  
81 - paramType = (ParameterizedType) type;  
82 - } catch (ClassCastException cause) {  
83 - return getGenericTypeArgument((Class<T>) type, idx);  
84 - }  
85 -  
86 - return (Class<T>) paramType.getActualTypeArguments()[idx];  
87 - }  
88 -  
89 - /**  
90 - * Return the parametized type used with a concrete implementation of a  
91 - * class that accepts generics. Ex: If you declare  
92 - * <pre>  
93 - * <code>  
94 - * public class SpecializedCollection implements Collection&#60;SpecializedType&#62; {  
95 - * // ...  
96 - * }  
97 - * </code>  
98 - * </pre> then the code  
99 - * <code>getGenericTypeArgument(SpecializedCollection.class , 0);</code>  
100 - * will return the type <code>SpecializedType</code>.  
101 - *  
102 - * @param clazz Base type to check for generic arguments  
103 - * @param idx zero based index of the generic argument to get  
104 - * @param <T> Type of the generic argument  
105 - * @return The class representing the type of the generic argument  
106 - */  
107 - @SuppressWarnings("unchecked")  
108 - public static <T> Class<T> getGenericTypeArgument(final Class<?> clazz, final int idx) {  
109 - final Type type = clazz.getGenericSuperclass();  
110 -  
111 - ParameterizedType paramType;  
112 - try {  
113 - paramType = (ParameterizedType) type;  
114 - } catch (ClassCastException cause) {  
115 - return getGenericTypeArgument((Class<T>) type, idx);  
116 - }  
117 -  
118 - return (Class<T>) paramType.getActualTypeArguments()[idx];  
119 - }  
120 -  
121 - /**  
122 - * <p>  
123 - * Return the parametized type passed to field types that accepts Generics.  
124 - * </p>  
125 - * Ex: If you declare  
126 - * <pre>  
127 - * <code>  
128 - * public class MyClass{  
129 - * private Collection&lt;String&gt; myStringCollection;  
130 - * }  
131 - * </code>  
132 - * </pre> then the code  
133 - * <code>getGenericTypeArgument( MyClass.class.getDeclaredField("myStringCollection") , 0);</code>  
134 - * will return the type <code>String</code>.  
135 - *  
136 - * @param field Field which type is generified  
137 - * @param idx zero based index of the generic argument to get  
138 - * @param <T> Type of the generic argument  
139 - * @return The class representing the type of the generic argument  
140 - */  
141 - @SuppressWarnings("unchecked")  
142 - public static <T> Class<T> getGenericTypeArgument(final Field field, final int idx) {  
143 - final Type type = field.getGenericType();  
144 - final ParameterizedType paramType = (ParameterizedType) type;  
145 -  
146 - return (Class<T>) paramType.getActualTypeArguments()[idx];  
147 - }  
148 -  
149 - /**  
150 - * <p>  
151 - * Return the parametized type passed to members (fields or methods) that  
152 - * accepts Generics.  
153 - * </p>  
154 - *  
155 - * @param member Member which type is generified  
156 - * @param idx zero based index of the generic argument to get  
157 - * @param <T> Type of the generic argument  
158 - * @return The class representing the type of the generic argument  
159 - * @see #getGenericTypeArgument(Field field, int idx)  
160 - */  
161 - public static <T> Class<T> getGenericTypeArgument(final Member member, final int idx) {  
162 - Class<T> result = null;  
163 -  
164 - if (member instanceof Field) {  
165 - result = getGenericTypeArgument((Field) member, idx);  
166 - } else if (member instanceof Method) {  
167 - result = getGenericTypeArgument((Method) member, idx);  
168 - }  
169 -  
170 - return result;  
171 - }  
172 -  
173 - /**  
174 - * <p>  
175 - * Return the parametized type passed to methods that accepts Generics.  
176 - * </p>  
177 - *  
178 - * @param method Generified method reference  
179 - * @param idx zero based index of the generic argument to get  
180 - * @param <T> Type of the generic argument  
181 - * @return The class representing the type of the generic argument  
182 - * @see #getGenericTypeArgument(Field field, int idx)  
183 - */  
184 - @SuppressWarnings("unchecked")  
185 - public static <T> Class<T> getGenericTypeArgument(final Method method, final int idx) {  
186 - return (Class<T>) method.getGenericParameterTypes()[idx];  
187 - }  
188 -  
189 - /**  
190 - * Returns the value contained in the given field.  
191 - *  
192 - * @param field field to be extracted the value.  
193 - * @param object object that contains the field.  
194 - * @param <T> Type of the generic argument  
195 - * @return value of the field.  
196 - */  
197 - @SuppressWarnings("unchecked")  
198 - public static <T> T getFieldValue(Field field, Object object) {  
199 - T result = null;  
200 -  
201 - try {  
202 - boolean acessible = field.isAccessible();  
203 - field.setAccessible(true);  
204 - result = (T) field.get(object);  
205 - field.setAccessible(acessible);  
206 -  
207 - } catch (Exception e) {  
208 - LOG.fine(e.getMessage());  
209 - }  
210 -  
211 - return result;  
212 - }  
213 -  
214 - /**  
215 - * Sets a value in a field.  
216 - *  
217 - * @param field field to be setted.  
218 - * @param object object that contains the field.  
219 - * @param value value to be setted in the field.  
220 - */  
221 - public static void setFieldValue(Field field, Object object, Object value) {  
222 - try {  
223 - boolean acessible = field.isAccessible();  
224 - field.setAccessible(true);  
225 - field.set(object, value);  
226 - field.setAccessible(acessible);  
227 -  
228 - } catch (Exception e) {  
229 - LOG.fine(e.getMessage());  
230 - }  
231 - }  
232 -  
233 - /**  
234 - * @param type Base type to look for fields  
235 - * @return All non static fields from a certain type. Inherited fields are  
236 - * not returned, so if you need to get inherited fields you must iterate  
237 - * over this type's hierarchy.  
238 - */  
239 - public static Field[] getNonStaticDeclaredFields(Class<?> type) {  
240 - List<Field> fields = new ArrayList<Field>();  
241 -  
242 - if (type != null) {  
243 - for (Field field : type.getDeclaredFields()) {  
244 - if (!Modifier.isStatic(field.getModifiers()) && !field.getType().equals(type.getDeclaringClass())) {  
245 - fields.add(field);  
246 - }  
247 - }  
248 - }  
249 -  
250 - return fields.toArray(new Field[0]);  
251 - }  
252 -  
253 - /**  
254 - * @param type Base type to look for fields  
255 - * @return All non static fields from a certain type, including fields  
256 - * declared in superclasses of this type.  
257 - */  
258 - public static List<Field> getNonStaticFields(Class<?> type) {  
259 - List<Field> fields = new ArrayList<Field>();  
260 -  
261 - if (type != null) {  
262 - Class<?> currentType = type;  
263 - while (currentType != null && !"java.lang.Object".equals(currentType.getCanonicalName())) {  
264 - fields.addAll(Arrays.asList(getNonStaticDeclaredFields(currentType)));  
265 - currentType = currentType.getSuperclass();  
266 - }  
267 - }  
268 -  
269 - return fields;  
270 - }  
271 -  
272 - /**  
273 - * Instantiate an object of the given type. The default constructor with no  
274 - * parameters is used.  
275 - *  
276 - * @param clazz Base type of object to instantiate  
277 - * @param <T> Final type of instantiated object  
278 - * @return New instance of provided type  
279 - */  
280 - public static <T> T instantiate(Class<T> clazz) {  
281 - T object = null;  
282 - try {  
283 - object = clazz.newInstance();  
284 - } catch (InstantiationException | IllegalAccessException e) {  
285 - LOG.fine(e.getMessage());  
286 - }  
287 - return object;  
288 - }  
289 -  
290 - /**  
291 - * Verifies if a given class could be converted to a given type.  
292 - *  
293 - * @param clazz class to be checked.  
294 - * @param type type to be checked.  
295 - * @return {@link Boolean} true if the given class can be converted to a  
296 - * given type, and false otherwise.  
297 - */  
298 - public static boolean isOfType(Class<?> clazz, Class<?> type) {  
299 - return type.isAssignableFrom(clazz) && clazz != type;  
300 - }  
301 -  
302 - /**  
303 - * Obtains the {@link ClassLoader} for the given class, from his canonical  
304 - * name.  
305 - *  
306 - * @param canonicalName canonical name of the the given class.  
307 - * @return {@link ClassLoader} ClassLoader for the given class.  
308 - */  
309 - public static ClassLoader getClassLoaderForClass(final String canonicalName) {  
310 - return Reflections.getClassLoaderForResource(canonicalName.replaceAll("\\.", "/") + ".class");  
311 - }  
312 -  
313 - /**  
314 - * Obtains the {@link ClassLoader} for the given resource.  
315 - *  
316 - * @param resource String representation of the fully qualified path to the  
317 - * resource on the classpath  
318 - * @return {@link ClassLoader} ClassLoader for the given resource.  
319 - */  
320 - public static ClassLoader getClassLoaderForResource(final String resource) {  
321 - final String stripped = resource.charAt(0) == '/' ? resource.substring(1) : resource;  
322 -  
323 - URL url = null;  
324 - ClassLoader result = Thread.currentThread().getContextClassLoader();  
325 -  
326 - if (result != null) {  
327 - url = result.getResource(stripped);  
328 - }  
329 -  
330 - if (url == null) {  
331 - result = Reflections.class.getClassLoader();  
332 - url = Reflections.class.getClassLoader().getResource(stripped);  
333 - }  
334 -  
335 - if (url == null) {  
336 - result = null;  
337 - }  
338 -  
339 - return result;  
340 - }  
341 -  
342 - /**  
343 - * Return an URL to access a resource available to the active classloader  
344 - * for the calling thread.  
345 - *  
346 - * @param resource String representation of the location of the resource on  
347 - * the classpath  
348 - * @return The {@link URL} for the resource  
349 - */  
350 - public static URL getResourceAsURL(final String resource) {  
351 - ClassLoader classLoader = getClassLoaderForResource(resource);  
352 - return classLoader != null ? classLoader.getResource(resource) : null;  
353 - }  
354 -  
355 - /**  
356 - * Return an InputStream to access a resource available to the active  
357 - * classloader for the calling thread.  
358 - *  
359 - * @param resource String representation of the location of the resource on  
360 - * the classpath  
361 - * @return An {@link InputStream} that reads data from the resource  
362 - */  
363 - public static InputStream getResourceAsStream(final String resource) {  
364 - ClassLoader classLoader = getClassLoaderForResource(resource);  
365 - return classLoader != null ? classLoader.getResourceAsStream(resource) : null;  
366 - }  
367 -  
368 - /**  
369 - * Loads a class with the given name using the active classloader for the  
370 - * current thread.  
371 - *  
372 - * @param className String with fully qualified class name of the desired  
373 - * class  
374 - * @param <T> Final type of the loaded class  
375 - * @return Class representing the loaded type  
376 - * @throws ClassNotFoundException If no class with this name exists  
377 - */  
378 - @SuppressWarnings("unchecked")  
379 - public static <T> Class<T> forName(final String className) throws ClassNotFoundException {  
380 - ClassLoader classLoader = getClassLoaderForClass(className);  
381 - return (Class<T>) Class.forName(className, true, classLoader);  
382 - }  
383 -}  
configuration/src/main/java/org/demoiselle/util/ResourceBundle.java
@@ -1,140 +0,0 @@ @@ -1,140 +0,0 @@
1 -/*  
2 - * Demoiselle Framework  
3 - * Copyright (C) 2010 SERPRO  
4 - * ----------------------------------------------------------------------------  
5 - * This file is part of Demoiselle Framework.  
6 - *  
7 - * Demoiselle Framework is free software; you can redistribute it and/or  
8 - * modify it under the terms of the GNU Lesser General Public License version 3  
9 - * as published by the Free Software Foundation.  
10 - *  
11 - * This program is distributed in the hope that it will be useful,  
12 - * but WITHOUT ANY WARRANTY; without even the implied warranty of  
13 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  
14 - * GNU General Public License for more details.  
15 - *  
16 - * You should have received a copy of the GNU Lesser General Public License version 3  
17 - * along with this program; if not, see <http://www.gnu.org/licenses/>  
18 - * or write to the Free Software Foundation, Inc., 51 Franklin Street,  
19 - * Fifth Floor, Boston, MA 02110-1301, USA.  
20 - * ----------------------------------------------------------------------------  
21 - * Este arquivo é parte do Framework Demoiselle.  
22 - *  
23 - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou  
24 - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação  
25 - * do Software Livre (FSF).  
26 - *  
27 - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA  
28 - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou  
29 - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português  
30 - * para maiores detalhes.  
31 - *  
32 - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título  
33 - * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>  
34 - * ou escreva para a Fundação do Software Livre (FSF) Inc.,  
35 - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.  
36 - */  
37 -package org.demoiselle.util;  
38 -  
39 -import java.io.Serializable;  
40 -import java.lang.reflect.Method;  
41 -import java.util.Enumeration;  
42 -import java.util.Locale;  
43 -import java.util.MissingResourceException;  
44 -import java.util.Set;  
45 -import javax.inject.Named;  
46 -  
47 -/**  
48 - * <p>  
49 - * The Demoiselle's ResourceBundle extends the abstraction  
50 - * {@link java.util.ResourceBundle}, and provide the locale and the base name  
51 - * for the bundle.</p>  
52 - *  
53 - * <p>  
54 - * To select which resource properties file to load when injecting beans of this  
55 - * class, qualify the injection point with  
56 - * {@link org.demoiselle.annotation.Name}, using the resource name (without the  
57 - * '.properties' extension) as the value. If the injection point isn't qualified  
58 - * the default file <code>messages.properties</code> will be loaded from the  
59 - * root of the classpath.</p>  
60 - *  
61 - * @author SERPRO  
62 - */  
63 -public class ResourceBundle extends java.util.ResourceBundle implements Serializable {  
64 -  
65 - private static final long serialVersionUID = 1L;  
66 -  
67 - private String baseName;  
68 -  
69 - private transient java.util.ResourceBundle delegate;  
70 -  
71 - private final Locale locale;  
72 -  
73 - private java.util.ResourceBundle getDelegate() {  
74 - if (delegate == null) {  
75 - try {  
76 - ClassLoader classLoader = Thread.currentThread().getContextClassLoader();  
77 - delegate = ResourceBundle.getBundle(baseName, locale, classLoader);  
78 -  
79 - } catch (MissingResourceException mre) {  
80 - delegate = ResourceBundle.getBundle(baseName, locale);  
81 - }  
82 - }  
83 -  
84 - return delegate;  
85 - }  
86 -  
87 - /**  
88 - * Constructor that set values of baseName and locale.  
89 - *  
90 - * @param baseName the base name to construct the complete bundle name.  
91 - *  
92 - * @param locale locale to define the choosen bundle.  
93 - */  
94 - public ResourceBundle(String baseName, Locale locale) {  
95 - this.baseName = baseName;  
96 - this.locale = locale;  
97 - }  
98 -  
99 - @Override  
100 - public boolean containsKey(String key) {  
101 - return getDelegate().containsKey(key);  
102 - }  
103 -  
104 - @Override  
105 - public Enumeration<String> getKeys() {  
106 - return getDelegate().getKeys();  
107 - }  
108 -  
109 - @Override  
110 - public Locale getLocale() {  
111 - return getDelegate().getLocale();  
112 - }  
113 -  
114 - @Override  
115 - public Set<String> keySet() {  
116 - return getDelegate().keySet();  
117 - }  
118 -  
119 - public String getString(String key, Object... params) {  
120 - return Strings.getString(getString(key), params);  
121 - }  
122 -  
123 - @Override  
124 - protected Object handleGetObject(String key) {  
125 - Object result;  
126 -  
127 - try {  
128 - Method method = getDelegate().getClass().getMethod("handleGetObject", String.class);  
129 -  
130 - method.setAccessible(true);  
131 - result = method.invoke(delegate, key);  
132 - method.setAccessible(false);  
133 -  
134 - } catch (Exception cause) {  
135 - throw new RuntimeException(cause);  
136 - }  
137 -  
138 - return result;  
139 - }  
140 -}  
configuration/src/main/java/org/demoiselle/util/Strings.java
@@ -1,289 +0,0 @@ @@ -1,289 +0,0 @@
1 -/*  
2 - * Demoiselle Framework  
3 - * Copyright (C) 2010 SERPRO  
4 - * ----------------------------------------------------------------------------  
5 - * This file is part of Demoiselle Framework.  
6 - *  
7 - * Demoiselle Framework is free software; you can redistribute it and/or  
8 - * modify it under the terms of the GNU Lesser General Public License version 3  
9 - * as published by the Free Software Foundation.  
10 - *  
11 - * This program is distributed in the hope that it will be useful,  
12 - * but WITHOUT ANY WARRANTY; without even the implied warranty of  
13 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  
14 - * GNU General Public License for more details.  
15 - *  
16 - * You should have received a copy of the GNU Lesser General Public License version 3  
17 - * along with this program; if not, see <http://www.gnu.org/licenses/>  
18 - * or write to the Free Software Foundation, Inc., 51 Franklin Street,  
19 - * Fifth Floor, Boston, MA 02110-1301, USA.  
20 - * ----------------------------------------------------------------------------  
21 - * Este arquivo é parte do Framework Demoiselle.  
22 - *  
23 - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou  
24 - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação  
25 - * do Software Livre (FSF).  
26 - *  
27 - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA  
28 - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou  
29 - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português  
30 - * para maiores detalhes.  
31 - *  
32 - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título  
33 - * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>  
34 - * ou escreva para a Fundação do Software Livre (FSF) Inc.,  
35 - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.  
36 - */  
37 -package org.demoiselle.util;  
38 -  
39 -import org.demoiselle.annotation.Ignore;  
40 -  
41 -import java.io.BufferedReader;  
42 -import java.io.IOException;  
43 -import java.io.InputStream;  
44 -import java.io.InputStreamReader;  
45 -import java.lang.reflect.Field;  
46 -import java.util.Arrays;  
47 -import java.util.regex.Matcher;  
48 -import java.util.regex.Pattern;  
49 -  
50 -/**  
51 - * Contain a set of methods that implements a set of functionalities that envolves manipulation of strings.  
52 - *  
53 - * @author SERPRO  
54 - */  
55 -public final class Strings {  
56 -  
57 - private Strings() {  
58 - }  
59 -  
60 - /**  
61 - * Returns if some string matches with the format of a ResourceBundle key or not.  
62 - *  
63 - * @param key string to check if matches with key format of ResourceBundle.  
64 - * @return boolean true if matches and false otherwise.  
65 - */  
66 - public static boolean isResourceBundleKeyFormat(final String key) {  
67 - return Pattern.matches("^\\{(.+)\\}$", key == null ? "" : key);  
68 - }  
69 -  
70 - /**  
71 - * Removes specific characteres from a given string.  
72 - *  
73 - * @param string string to be changed, by the removing of some characters.  
74 - * @param chars characters to be removed from string.  
75 - * @return String returns the given string without the given characters.  
76 - */  
77 - public static String removeChars(String string, char... chars) {  
78 - String result = string;  
79 -  
80 - if (result != null) {  
81 - for (char ch : chars) {  
82 - result = result.replace(String.valueOf(ch), "");  
83 - }  
84 - }  
85 - return result;  
86 - }  
87 -  
88 - public static String join(String separator, String... strings) {  
89 - StringBuffer result = new StringBuffer();  
90 -  
91 - if (strings != null) {  
92 - for (int i = 0; i < strings.length; i++) {  
93 - if (i != 0 && separator != null) {  
94 - result.append(separator);  
95 - }  
96 -  
97 - if (strings[i] != null) {  
98 - result.append(strings[i]);  
99 - }  
100 - }  
101 - }  
102 -  
103 - return result.length() > 0 ? result.toString() : null;  
104 - }  
105 -  
106 - /**  
107 - * Inserts the character "0" in the begin of a given string. The quantity of zeros that will be placed depends on  
108 - * the difference between the length of the given string and the value of howMuchZeros.  
109 - *  
110 - * @param string string to insert zeros characthers.  
111 - * @param howMuchZeros its controls how much zeros will be insert.  
112 - * @return String Retuns the string, added with appropriate number of zeros. For exemplo, if string = "yes" and  
113 - * howMuchZeros = 5, the returned string will be "00yes".  
114 - */  
115 - public static String insertZeros(String string, int howMuchZeros) {  
116 - StringBuffer result = new StringBuffer((string == null ? "" : string).trim());  
117 - int difference = howMuchZeros - result.toString().length();  
118 -  
119 - for (int j = 0; j < difference; j++) {  
120 - result.insert(0, '0');  
121 - }  
122 -  
123 - return result.toString();  
124 - }  
125 -  
126 - /**  
127 - * * Replaces the numbers between braces in the given string with the given parameters. The process will replace a  
128 - * number between braces for the parameter for which its order in the set of parameters matches with the number of  
129 - * the given string.  
130 - * For exemple, if is received the following string "Treats an {0} exception" and the set of parameters  
131 - * {"DemoiselleException"}, the return will be the following string: "Treats an DemoiselleException exception".  
132 - *  
133 - * @param string with the numbers with braces to be replaced with the parameters.  
134 - * @param params parameters that will replace the number with braces in the given string.  
135 - * @return String string with numbers replaced with the matching parameter.  
136 - */  
137 - public static String getString(final String string, final Object... params) {  
138 - String result = null;  
139 -  
140 - if (string != null) {  
141 - result = new String(string);  
142 - }  
143 -  
144 - if (params != null && string != null) {  
145 - for (int i = 0; i < params.length; i++) {  
146 - if (params[i] != null) {  
147 - result = result.replaceAll("\\{" + i + "\\}", Matcher.quoteReplacement(params[i].toString()));  
148 - }  
149 - }  
150 - }  
151 -  
152 - return result;  
153 - }  
154 -  
155 - /**  
156 - * Verifies if a given string is empty or null.  
157 - *  
158 - * @param string string to be verified.  
159 - * @return boolean returns true if the given string is empty or null and returns false otherwise.  
160 - */  
161 - public static boolean isEmpty(String string) {  
162 - return string == null || string.trim().isEmpty();  
163 - }  
164 -  
165 - /**  
166 - * Converts any object to string.  
167 - *  
168 - * @param object object to be converted.  
169 - * @return String the given object converted to string.  
170 - */  
171 - public static String toString(Object object) {  
172 - StringBuffer result = new StringBuffer();  
173 - Object fieldValue;  
174 -  
175 - if (object != null) {  
176 - result.append(object.getClass().getSimpleName());  
177 - result.append(" [");  
178 -  
179 - boolean first = true;  
180 - for (Field field : Reflections.getNonStaticDeclaredFields(object.getClass())) {  
181 - if (!field.isAnnotationPresent(Ignore.class)) {  
182 - if (first) {  
183 - first = false;  
184 - } else {  
185 - result.append(", ");  
186 - }  
187 -  
188 - result.append(field.getName());  
189 - result.append('=');  
190 - fieldValue = Reflections.getFieldValue(field, object);  
191 - result.append(fieldValue != null && fieldValue.getClass().isArray() ?  
192 - Arrays.toString((Object[]) fieldValue) :  
193 - fieldValue);  
194 - }  
195 - }  
196 -  
197 - result.append(']');  
198 - }  
199 -  
200 - return result.toString();  
201 - }  
202 -  
203 - /**  
204 - * Replace the camel case string for a lowercase string separated for a given symbol.  
205 - *  
206 - * @param string string that separeted with camel case.  
207 - * @param symbol simbol to be the new separator for the given string.  
208 - * @return String the given string separated with the given symbol.  
209 - */  
210 - public static String camelCaseToSymbolSeparated(String string, String symbol) {  
211 - if (symbol == null) {  
212 - symbol = "";  
213 - }  
214 -  
215 - return string == null ? null : string.replaceAll("\\B([A-Z])", symbol + "$1").toLowerCase();  
216 - }  
217 -  
218 - /**  
219 - * Sets the first character of a given string to upper case.  
220 - *  
221 - * @param string Full string to convert  
222 - * @return String the given string with the first character setted to upper case.  
223 - */  
224 - public static String firstToUpper(String string) {  
225 - String result = string;  
226 -  
227 - if (!Strings.isEmpty(string)) {  
228 - result = string.toUpperCase().charAt(0) + (string.length() > 1 ? string.substring(1) : "");  
229 - }  
230 -  
231 - return result;  
232 - }  
233 -  
234 - /**  
235 - * Removes braces from a given string.  
236 - *  
237 - * @param string Message to remove braces from  
238 - * @return String the given string without braces.  
239 - */  
240 - public static String removeBraces(String string) {  
241 - String result = string;  
242 -  
243 - if (isResourceBundleKeyFormat(string)) {  
244 - result = string.substring(1, string.length() - 1);  
245 - }  
246 -  
247 - return result;  
248 - }  
249 -  
250 - /**  
251 - * Inserts braces in a given string.  
252 - *  
253 - * @param string Original string to insert braces on.  
254 - * @return String the given string with braces.  
255 - */  
256 - public static String insertBraces(String string) {  
257 - String result = string;  
258 -  
259 - if (!isEmpty(string)) {  
260 - result = "{" + string + "}";  
261 - }  
262 -  
263 - return result;  
264 - }  
265 -  
266 - public static String parse(InputStream inputStream) throws IOException {  
267 - StringBuilder result = new StringBuilder();  
268 -  
269 - if (inputStream != null) {  
270 - BufferedReader reader = null;  
271 -  
272 - try {  
273 - reader = new BufferedReader(new InputStreamReader(inputStream));  
274 - String line;  
275 -  
276 - while ((line = reader.readLine()) != null) {  
277 - result.append(line);  
278 - }  
279 -  
280 - } finally {  
281 - if (reader != null) {  
282 - reader.close();  
283 - }  
284 - }  
285 - }  
286 -  
287 - return result.length() > 0 ? result.toString() : null;  
288 - }  
289 -}  
configuration/src/main/resources/configuration-bundle.properties
@@ -1,44 +0,0 @@ @@ -1,44 +0,0 @@
1 -# Demoiselle Framework  
2 -# Copyright (C) 2010 SERPRO  
3 -# ----------------------------------------------------------------------------  
4 -# This file is part of Demoiselle Framework.  
5 -#  
6 -# Demoiselle Framework is free software; you can redistribute it and/or  
7 -# modify it under the terms of the GNU Lesser General Public License version 3  
8 -# as published by the Free Software Foundation.  
9 -#  
10 -# This program is distributed in the hope that it will be useful,  
11 -# but WITHOUT ANY WARRANTY; without even the implied warranty of  
12 -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  
13 -# GNU General Public License for more details.  
14 -#  
15 -# You should have received a copy of the GNU Lesser General Public License version 3  
16 -# along with this program; if not, see <http://www.gnu.org/licenses/>  
17 -# or write to the Free Software Foundation, Inc., 51 Franklin Street,  
18 -# Fifth Floor, Boston, MA 02110-1301, USA.  
19 -# ----------------------------------------------------------------------------  
20 -# Este arquivo \u00e9 parte do Framework Demoiselle.  
21 -#  
22 -# O Framework Demoiselle \u00e9 um software livre; voc\u00ea pode redistribu\u00ed-lo e/ou  
23 -# modific\u00e1-lo dentro dos termos da GNU LGPL vers\u00e3o 3 como publicada pela Funda\u00e7\u00e3o  
24 -# do Software Livre (FSF).  
25 -#  
26 -# Este programa \u00e9 distribu\u00eddo na esperan\u00e7a que possa ser \u00fatil, mas SEM NENHUMA  
27 -# GARANTIA; sem uma garantia impl\u00edcita de ADEQUA\u00c7\u00c3O a qualquer MERCADO ou  
28 -# APLICA\u00c7\u00c3O EM PARTICULAR. Veja a Licen\u00e7a P\u00fablica Geral GNU/LGPL em portugu\u00eas  
29 -# para maiores detalhes.  
30 -#  
31 -# Voc\u00ea deve ter recebido uma c\u00f3pia da GNU LGPL vers\u00e3o 3, sob o t\u00edtulo  
32 -# "LICENCA.txt", junto com esse programa. Se n\u00e3o, acesse <http://www.gnu.org/licenses/>  
33 -# ou escreva para a Funda\u00e7\u00e3o do Software Livre (FSF) Inc.,  
34 -# 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.  
35 -  
36 -loading-configuration-class=Carregando a classe de configura\u00e7\u00e3o {0}  
37 -configuration-field-loaded={0}: {2}  
38 -configuration-attribute-is-mandatory=A configura\u00e7\u00e3o {0} \u00e9 obrigat\u00f3ria, mas n\u00e3o foi encontrada em {1}  
39 -configuration-name-attribute-cant-be-empty=A nota\u00e7\u00e3o @Name n\u00e3o pode estar em branco  
40 -configuration-generic-extraction-error=Ocorreu um erro durante a extra\u00e7\u00e3o do tipo {0} com o extrator {1}  
41 -configuration-dot-after-prefix=N\u00e3o \u00e9 necess\u00e1rio adicionar o ponto ap\u00f3s o prefixo para uma classe de configura\u00e7\u00e3o. \u00c9 recomendado que sejam retirados, pois poder\u00e3o causar erros em vers\u00f5es futuras do Framework.  
42 -configuration-key-not-found={0}\: [n\u00e3o encontrada]  
43 -configuration-extractor-not-found=N\u00e3o foi poss\u00edvel encontrar a classe extratora para o atributo {0}. Implemente a interface {1} para criar sua classe extratora.  
44 -configuration-not-conversion=N\u00e3o \u00e9 poss\u00edvel converter o valor {0} para o tipo {1}  
core/.gitignore
@@ -1,4 +0,0 @@ @@ -1,4 +0,0 @@
1 -.settings  
2 -.classpath  
3 -.project  
4 -/bin/  
core/pom.xml
@@ -1,35 +0,0 @@ @@ -1,35 +0,0 @@
1 -<?xml version="1.0" encoding="UTF-8"?>  
2 -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
3 - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">  
4 - <modelVersion>4.0.0</modelVersion>  
5 - <groupId>org.demoiselle.jee</groupId>  
6 - <artifactId>demoiselle-core</artifactId>  
7 - <version>3.0.0-SNAPSHOT</version>  
8 - <packaging>jar</packaging>  
9 -  
10 - <name>Demoiselle Core</name>  
11 - <description>  
12 - Contém funcionalidades comuns a todos os módulos framework.  
13 - </description>  
14 -  
15 - <url>http://demoiselle.org</url>  
16 -  
17 -  
18 - <properties>  
19 - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>  
20 - <maven.compiler.source>1.8</maven.compiler.source>  
21 - <maven.compiler.target>1.8</maven.compiler.target>  
22 - </properties>  
23 - <dependencies>  
24 - <dependency>  
25 - <groupId>javax</groupId>  
26 - <artifactId>javaee-web-api</artifactId>  
27 - <version>7.0</version>  
28 - </dependency>  
29 - <dependency>  
30 - <groupId>javax.enterprise</groupId>  
31 - <artifactId>cdi-api</artifactId>  
32 - <version>1.2</version>  
33 - </dependency>  
34 - </dependencies>  
35 -</project>  
core/src/main/java/org/demoiselle/jee/core/annotation/Ignore.java
@@ -1,56 +0,0 @@ @@ -1,56 +0,0 @@
1 -/*  
2 - * Demoiselle Framework  
3 - * Copyright (C) 2010 SERPRO  
4 - * ----------------------------------------------------------------------------  
5 - * This file is part of Demoiselle Framework.  
6 - *  
7 - * Demoiselle Framework is free software; you can redistribute it and/or  
8 - * modify it under the terms of the GNU Lesser General Public License version 3  
9 - * as published by the Free Software Foundation.  
10 - *  
11 - * This program is distributed in the hope that it will be useful,  
12 - * but WITHOUT ANY WARRANTY; without even the implied warranty of  
13 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  
14 - * GNU General Public License for more details.  
15 - *  
16 - * You should have received a copy of the GNU Lesser General Public License version 3  
17 - * along with this program; if not, see <http://www.gnu.org/licenses/>  
18 - * or write to the Free Software Foundation, Inc., 51 Franklin Street,  
19 - * Fifth Floor, Boston, MA 02110-1301, USA.  
20 - * ----------------------------------------------------------------------------  
21 - * Este arquivo é parte do Framework Demoiselle.  
22 - *  
23 - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou  
24 - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação  
25 - * do Software Livre (FSF).  
26 - *  
27 - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA  
28 - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou  
29 - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português  
30 - * para maiores detalhes.  
31 - *  
32 - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título  
33 - * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>  
34 - * ou escreva para a Fundação do Software Livre (FSF) Inc.,  
35 - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.  
36 - */  
37 -package org.demoiselle.jee.core.annotation;  
38 -  
39 -import static java.lang.annotation.ElementType.FIELD;  
40 -import static java.lang.annotation.RetentionPolicy.RUNTIME;  
41 -  
42 -import java.lang.annotation.Retention;  
43 -import java.lang.annotation.Target;  
44 -  
45 -/**  
46 - * <p>Used in fields of classes annotated with {@link org.demoiselle.configuration.Configuration}  
47 - * to indicate that the system should ignore this field when population the new configuration  
48 - * instance with values extracted from the source file.</p>  
49 - *  
50 - * @see org.demoiselle.configuration.Configuration  
51 - * @author SERPRO  
52 - */  
53 -@Target(FIELD)  
54 -@Retention(RUNTIME)  
55 -public @interface Ignore {  
56 -}  
core/src/main/java/org/demoiselle/jee/core/annotation/Name.java
@@ -1,98 +0,0 @@ @@ -1,98 +0,0 @@
1 -/*  
2 - * Demoiselle Framework  
3 - * Copyright (C) 2010 SERPRO  
4 - * ----------------------------------------------------------------------------  
5 - * This file is part of Demoiselle Framework.  
6 - *  
7 - * Demoiselle Framework is free software; you can redistribute it and/or  
8 - * modify it under the terms of the GNU Lesser General Public License version 3  
9 - * as published by the Free Software Foundation.  
10 - *  
11 - * This program is distributed in the hope that it will be useful,  
12 - * but WITHOUT ANY WARRANTY; without even the implied warranty of  
13 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  
14 - * GNU General Public License for more details.  
15 - *  
16 - * You should have received a copy of the GNU Lesser General Public License version 3  
17 - * along with this program; if not, see <http://www.gnu.org/licenses/>  
18 - * or write to the Free Software Foundation, Inc., 51 Franklin Street,  
19 - * Fifth Floor, Boston, MA 02110-1301, USA.  
20 - * ----------------------------------------------------------------------------  
21 - * Este arquivo é parte do Framework Demoiselle.  
22 - *  
23 - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou  
24 - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação  
25 - * do Software Livre (FSF).  
26 - *  
27 - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA  
28 - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou  
29 - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português  
30 - * para maiores detalhes.  
31 - *  
32 - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título  
33 - * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>  
34 - * ou escreva para a Fundação do Software Livre (FSF) Inc.,  
35 - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.  
36 - */  
37 -package org.demoiselle.jee.core.annotation;  
38 -  
39 -import javax.enterprise.inject.spi.InjectionPoint;  
40 -import javax.enterprise.util.Nonbinding;  
41 -import javax.inject.Named;  
42 -import javax.inject.Qualifier;  
43 -import java.lang.annotation.Inherited;  
44 -import java.lang.annotation.Retention;  
45 -import java.lang.annotation.Target;  
46 -  
47 -import static java.lang.annotation.ElementType.*;  
48 -import static java.lang.annotation.RetentionPolicy.RUNTIME;  
49 -  
50 -/**  
51 - * <p>  
52 - * String based non-binding qualifier.  
53 - * </p>  
54 - *  
55 - * <p>  
56 - * This annotation is used to qualify beans using an user defined String. {@link javax.enterprise.inject.Produces}  
57 - * methods can then read this string and use it to customize the bean creation process.  
58 - * </p>  
59 - *  
60 - * <p>  
61 - * The {@link #value()} attribute is non-binding (contrary to {@link Named#value()}, meaning multiple classes  
62 - * qualified with this annotation, even with different values, will be considered the same candidate for  
63 - * injection points. To avoid ambiguous resolutions and select which candidate to choose usually you'll need a  
64 - * producer method to read the string and select the best fitted candidate.  
65 - * </p>  
66 - *  
67 - * <p>  
68 - * The framework classes qualified with this annotation already have such producers and the accepted values for  
69 - * this annotation will be detailed in their respective documentations.  
70 - * </p>  
71 - *  
72 - *  
73 - * @author SERPRO  
74 - *  
75 - * @see org.demoiselle.util.ResourceBundle  
76 - * @see org.demoiselle.internal.producer.ResourceBundleProducer#create(InjectionPoint)  
77 - * @see org.demoiselle.internal.producer.LoggerProducer#createNamed(InjectionPoint)  
78 - */  
79 -@Qualifier  
80 -@Inherited  
81 -@Retention(RUNTIME)  
82 -@Target({ TYPE, FIELD, METHOD, PARAMETER })  
83 -public @interface Name {  
84 -  
85 - /**  
86 - * <p>  
87 - * Specifies a name to access a custom configuration that will change how the annotated bean works.  
88 - * </p>  
89 - * <p>  
90 - * This attribute is nonbinding so you can use the {@link Name} annotation to create {@linkplain javax.enterprise.inject.Produces}  
91 - * methods or fields and have only one producer that works with all injection points no matter the value of this attribute.  
92 - * </p>  
93 - * @return Name of custom settings to personalize how the annotated bean works.  
94 - */  
95 - @Nonbinding  
96 - String value() default "";  
97 -  
98 -}  
core/src/main/java/org/demoiselle/jee/core/annotation/Priority.java
@@ -1,96 +0,0 @@ @@ -1,96 +0,0 @@
1 -/*  
2 - * Demoiselle Framework  
3 - * Copyright (C) 2010 SERPRO  
4 - * ----------------------------------------------------------------------------  
5 - * This file is part of Demoiselle Framework.  
6 - *  
7 - * Demoiselle Framework is free software; you can redistribute it and/or  
8 - * modify it under the terms of the GNU Lesser General Public License version 3  
9 - * as published by the Free Software Foundation.  
10 - *  
11 - * This program is distributed in the hope that it will be useful,  
12 - * but WITHOUT ANY WARRANTY; without even the implied warranty of  
13 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  
14 - * GNU General Public License for more details.  
15 - *  
16 - * You should have received a copy of the GNU Lesser General Public License version 3  
17 - * along with this program; if not, see <http://www.gnu.org/licenses/>  
18 - * or write to the Free Software Foundation, Inc., 51 Franklin Street,  
19 - * Fifth Floor, Boston, MA 02110-1301, USA.  
20 - * ----------------------------------------------------------------------------  
21 - * Este arquivo é parte do Framework Demoiselle.  
22 - *  
23 - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou  
24 - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação  
25 - * do Software Livre (FSF).  
26 - *  
27 - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA  
28 - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou  
29 - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português  
30 - * para maiores detalhes.  
31 - *  
32 - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título  
33 - * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>  
34 - * ou escreva para a Fundação do Software Livre (FSF) Inc.,  
35 - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.  
36 - */  
37 -package org.demoiselle.jee.core.annotation;  
38 -  
39 -import java.lang.annotation.Retention;  
40 -import java.lang.annotation.Target;  
41 -  
42 -import static java.lang.annotation.ElementType.METHOD;  
43 -import static java.lang.annotation.ElementType.TYPE;  
44 -import static java.lang.annotation.RetentionPolicy.RUNTIME;  
45 -  
46 -/**  
47 - * <p>  
48 - * Used to prioritize some execution flow, as methods annotated with @startup or @shutdown,  
49 - * or some interface implementation.  
50 - * </p>  
51 - *  
52 - * @author SERPRO  
53 - */  
54 -@Target({ TYPE, METHOD })  
55 -@Retention(RUNTIME)  
56 -public @interface Priority {  
57 -  
58 - /**  
59 - * Most important priority value.  
60 - */  
61 - static int MAX_PRIORITY = Integer.MIN_VALUE;  
62 -  
63 - /**  
64 - * Less important priority value.  
65 - */  
66 - static int MIN_PRIORITY = Integer.MAX_VALUE;  
67 -  
68 - /**  
69 - * Less important priority value.  
70 - */  
71 - static int L1_PRIORITY = MIN_PRIORITY;  
72 -  
73 - /**  
74 - * Higher priority than L1_PRIORITY  
75 - */  
76 - static int L2_PRIORITY = L1_PRIORITY - 100;  
77 -  
78 - /**  
79 - * Higher priority than L2_PRIORITY  
80 - */  
81 - static int L3_PRIORITY = L2_PRIORITY - 100;  
82 -  
83 - /**  
84 - * Higher priority than L3_PRIORITY  
85 - */  
86 - static int L4_PRIORITY = L3_PRIORITY - 100;  
87 -  
88 - /**  
89 - * <p>  
90 - * An integer value defines the priority order. The lower the value, the greater priority.  
91 - * <p>  
92 - *  
93 - * @return Priority value, lower values have higher priority.  
94 - */  
95 - int value();  
96 -}  
core/src/main/java/org/demoiselle/jee/core/annotation/Strategy.java
@@ -1,83 +0,0 @@ @@ -1,83 +0,0 @@
1 -/*  
2 - * Demoiselle Framework  
3 - * Copyright (C) 2010 SERPRO  
4 - * ----------------------------------------------------------------------------  
5 - * This file is part of Demoiselle Framework.  
6 - *  
7 - * Demoiselle Framework is free software; you can redistribute it and/or  
8 - * modify it under the terms of the GNU Lesser General Public License version 3  
9 - * as published by the Free Software Foundation.  
10 - *  
11 - * This program is distributed in the hope that it will be useful,  
12 - * but WITHOUT ANY WARRANTY; without even the implied warranty of  
13 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  
14 - * GNU General Public License for more details.  
15 - *  
16 - * You should have received a copy of the GNU Lesser General Public License version 3  
17 - * along with this program; if not, see <http://www.gnu.org/licenses/>  
18 - * or write to the Free Software Foundation, Inc., 51 Franklin Street,  
19 - * Fifth Floor, Boston, MA 02110-1301, USA.  
20 - * ----------------------------------------------------------------------------  
21 - * Este arquivo é parte do Framework Demoiselle.  
22 - *  
23 - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou  
24 - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação  
25 - * do Software Livre (FSF).  
26 - *  
27 - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA  
28 - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou  
29 - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português  
30 - * para maiores detalhes.  
31 - *  
32 - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título  
33 - * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>  
34 - * ou escreva para a Fundação do Software Livre (FSF) Inc.,  
35 - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.  
36 - */  
37 -package org.demoiselle.jee.core.annotation;  
38 -import static java.lang.annotation.ElementType.FIELD;  
39 -import static java.lang.annotation.ElementType.METHOD;  
40 -import static java.lang.annotation.ElementType.PARAMETER;  
41 -import static java.lang.annotation.ElementType.TYPE;  
42 -import static java.lang.annotation.RetentionPolicy.RUNTIME;  
43 -  
44 -import java.lang.annotation.Inherited;  
45 -import java.lang.annotation.Retention;  
46 -import java.lang.annotation.Target;  
47 -  
48 -import javax.inject.Qualifier;  
49 -  
50 -/**  
51 - *  
52 - * <p>  
53 - * This literal marks a bean to be selected at runtime based on a priority system.  
54 - * The user qualifies the injection point with this literal and then at runtime  
55 - * the CDI engine will circle through all candidate subtypes to be injected  
56 - * that are annotated with {@link Priority}. If there is only one subtype with the  
57 - * highest priority then this one will be selected to be injected.  
58 - * </p>  
59 - *  
60 - * <p>  
61 - * This allows users to plug in libraries with new candidates and have them be selected  
62 - * if their priority values are higher than the default values already present. One example  
63 - * is the {@link org.demoiselle.security.Authorizer} type, the framework has a {@link org.demoiselle.internal.implementation.DefaultAuthorizer}  
64 - * with {@link Priority#L1_PRIORITY the lowest priority} but the user can add libraries with new  
65 - * implementations of {@link org.demoiselle.security.Authorizer} annotated with higher priorities, the code will  
66 - * then automatically select these new implementations with no extra configuration.  
67 - * </p>  
68 - *  
69 - * <p>  
70 - * This annotation must be used with supported types. Usually this involves creating {@link javax.enterprise.inject.Produces} CDI  
71 - * producer methods that will select the correct strategy. To create your own producer  
72 - * methods that support strategy selection, use the utility {@linkplain org.demoiselle.internal.producer.StrategySelector}.  
73 - * </p>  
74 - *  
75 - * @author SERPRO  
76 - */  
77 -@Qualifier  
78 -@Inherited  
79 -@Retention(RUNTIME)  
80 -@Target({ TYPE, FIELD, METHOD, PARAMETER })  
81 -public @interface Strategy {  
82 -  
83 -}  
core/src/main/java/org/demoiselle/jee/core/annotation/Type.java
@@ -1,60 +0,0 @@ @@ -1,60 +0,0 @@
1 -/*  
2 - * Demoiselle Framework  
3 - *  
4 - * License: GNU Lesser General Public License (LGPL), version 3 or later.  
5 - * See the lgpl.txt file in the root directory or <https://www.gnu.org/licenses/lgpl.html>.  
6 - */  
7 -package org.demoiselle.jee.core.annotation;  
8 -  
9 -import static java.lang.annotation.ElementType.FIELD;  
10 -import static java.lang.annotation.ElementType.METHOD;  
11 -import static java.lang.annotation.ElementType.PARAMETER;  
12 -import static java.lang.annotation.ElementType.TYPE;  
13 -import static java.lang.annotation.RetentionPolicy.RUNTIME;  
14 -  
15 -import java.lang.annotation.Inherited;  
16 -import java.lang.annotation.Retention;  
17 -import java.lang.annotation.Target;  
18 -  
19 -import javax.enterprise.util.Nonbinding;  
20 -import javax.inject.Qualifier;  
21 -  
22 -/**  
23 - * <p>  
24 - * Type based non-binding qualifier.  
25 - * </p>  
26 - *  
27 - * <p>  
28 - * This annotation is used to qualify beans using a class type.  
29 - * {@link javax.enterprise.inject.Produces} methods can then read this type and  
30 - * use it to customize the bean creation process.  
31 - * </p>  
32 - *  
33 - * <p>  
34 - * The {@link #value()} attribute is non-binding, meaning multiple classes  
35 - * qualified with this annotation, even with different values, will be  
36 - * considered the same candidate for injection points. To avoid ambiguous  
37 - * resolutions and select which candidate to choose usually you'll need a  
38 - * producer method to read the type and select the best fitted candidate.  
39 - * </p>  
40 - *  
41 - * <p>  
42 - * The framework classes qualified with this annotation already have such  
43 - * producers and the accepted values for this annotation will be detailed in  
44 - * their respective documentations.  
45 - * </p>  
46 - *  
47 - *  
48 - * @author SERPRO  
49 - *  
50 - */  
51 -@Qualifier  
52 -@Inherited  
53 -@Retention(RUNTIME)  
54 -@Target({ TYPE, FIELD, METHOD, PARAMETER })  
55 -public @interface Type {  
56 -  
57 - @Nonbinding  
58 - Class<?> value() default Object.class;  
59 -  
60 -}  
core/src/main/java/org/demoiselle/jee/core/annotation/literal/NameQualifier.java
@@ -1,70 +0,0 @@ @@ -1,70 +0,0 @@
1 -/*  
2 - * Demoiselle Framework  
3 - * Copyright (C) 2010 SERPRO  
4 - * ----------------------------------------------------------------------------  
5 - * This file is part of Demoiselle Framework.  
6 - *  
7 - * Demoiselle Framework is free software; you can redistribute it and/or  
8 - * modify it under the terms of the GNU Lesser General Public License version 3  
9 - * as published by the Free Software Foundation.  
10 - *  
11 - * This program is distributed in the hope that it will be useful,  
12 - * but WITHOUT ANY WARRANTY; without even the implied warranty of  
13 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  
14 - * GNU General Public License for more details.  
15 - *  
16 - * You should have received a copy of the GNU Lesser General Public License version 3  
17 - * along with this program; if not, see <http://www.gnu.org/licenses/>  
18 - * or write to the Free Software Foundation, Inc., 51 Franklin Street,  
19 - * Fifth Floor, Boston, MA 02110-1301, USA.  
20 - * ----------------------------------------------------------------------------  
21 - * Este arquivo é parte do Framework Demoiselle.  
22 - *  
23 - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou  
24 - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação  
25 - * do Software Livre (FSF).  
26 - *  
27 - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA  
28 - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou  
29 - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português  
30 - * para maiores detalhes.  
31 - *  
32 - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título  
33 - * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>  
34 - * ou escreva para a Fundação do Software Livre (FSF) Inc.,  
35 - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.  
36 - */  
37 -package org.demoiselle.jee.core.annotation.literal;  
38 -  
39 -import org.demoiselle.jee.core.annotation.Name;  
40 -  
41 -import javax.enterprise.util.AnnotationLiteral;  
42 -  
43 -/**  
44 - * Annotation litteral that allows to create instances of the {@link Name} literal. The created instance can then be  
45 - * used to call {@link javax.enterprise.inject.spi.CDI#select(Class subtype, java.lang.annotation.Annotation... qualifiers)}  
46 - *  
47 - * @author SERPRO  
48 - * @see javax.enterprise.inject.spi.CDI  
49 - */  
50 -@SuppressWarnings("all")  
51 -public class NameQualifier extends AnnotationLiteral<Name> implements Name {  
52 -  
53 - private static final long serialVersionUID = 1L;  
54 -  
55 - private final String value;  
56 -  
57 - /**  
58 - * Constructor with string value of name literal.  
59 - *  
60 - * @param value value of name literal.  
61 - */  
62 - public NameQualifier(String value) {  
63 - this.value = value;  
64 - }  
65 -  
66 - @Override  
67 - public String value() {  
68 - return this.value;  
69 - }  
70 -}  
core/src/main/java/org/demoiselle/jee/core/annotation/literal/NamedQualifier.java
@@ -1,67 +0,0 @@ @@ -1,67 +0,0 @@
1 -/*  
2 - * Demoiselle Framework  
3 - * Copyright (C) 2010 SERPRO  
4 - * ----------------------------------------------------------------------------  
5 - * This file is part of Demoiselle Framework.  
6 - *  
7 - * Demoiselle Framework is free software; you can redistribute it and/or  
8 - * modify it under the terms of the GNU Lesser General Public License version 3  
9 - * as published by the Free Software Foundation.  
10 - *  
11 - * This program is distributed in the hope that it will be useful,  
12 - * but WITHOUT ANY WARRANTY; without even the implied warranty of  
13 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  
14 - * GNU General Public License for more details.  
15 - *  
16 - * You should have received a copy of the GNU Lesser General Public License version 3  
17 - * along with this program; if not, see <http://www.gnu.org/licenses/>  
18 - * or write to the Free Software Foundation, Inc., 51 Franklin Street,  
19 - * Fifth Floor, Boston, MA 02110-1301, USA.  
20 - * ----------------------------------------------------------------------------  
21 - * Este arquivo é parte do Framework Demoiselle.  
22 - *  
23 - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou  
24 - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação  
25 - * do Software Livre (FSF).  
26 - *  
27 - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA  
28 - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou  
29 - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português  
30 - * para maiores detalhes.  
31 - *  
32 - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título  
33 - * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>  
34 - * ou escreva para a Fundação do Software Livre (FSF) Inc.,  
35 - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.  
36 - */  
37 -package org.demoiselle.jee.core.annotation.literal;  
38 -  
39 -import javax.enterprise.util.AnnotationLiteral;  
40 -import javax.inject.Named;  
41 -import java.lang.annotation.Annotation;  
42 -  
43 -/**  
44 - * Annotation litteral that allows to create instances of the {@link Named} literal.  
45 - * Those instances can then be used to call  
46 - * {@link javax.enterprise.inject.spi.CDI#select(Class subtype, Annotation... qualifiers)}  
47 - *  
48 - * @see javax.enterprise.inject.spi.CDI  
49 - * @see Named  
50 - *  
51 - * @author SERPRO  
52 - */  
53 -@SuppressWarnings("all")  
54 -public class NamedQualifier extends AnnotationLiteral<Named> implements Named {  
55 -  
56 - private static final long serialVersionUID = 6790759427086052113L;  
57 -  
58 - private String namedValue;  
59 -  
60 - public NamedQualifier(String value) {  
61 - namedValue = value;  
62 - }  
63 -  
64 - public String value() {  
65 - return namedValue;  
66 - }  
67 -}  
core/src/main/java/org/demoiselle/jee/core/annotation/literal/StrategyQualifier.java
@@ -1,53 +0,0 @@ @@ -1,53 +0,0 @@
1 -/*  
2 - * Demoiselle Framework  
3 - * Copyright (C) 2010 SERPRO  
4 - * ----------------------------------------------------------------------------  
5 - * This file is part of Demoiselle Framework.  
6 - *  
7 - * Demoiselle Framework is free software; you can redistribute it and/or  
8 - * modify it under the terms of the GNU Lesser General Public License version 3  
9 - * as published by the Free Software Foundation.  
10 - *  
11 - * This program is distributed in the hope that it will be useful,  
12 - * but WITHOUT ANY WARRANTY; without even the implied warranty of  
13 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  
14 - * GNU General Public License for more details.  
15 - *  
16 - * You should have received a copy of the GNU Lesser General Public License version 3  
17 - * along with this program; if not, see <http://www.gnu.org/licenses/>  
18 - * or write to the Free Software Foundation, Inc., 51 Franklin Street,  
19 - * Fifth Floor, Boston, MA 02110-1301, USA.  
20 - * ----------------------------------------------------------------------------  
21 - * Este arquivo é parte do Framework Demoiselle.  
22 - *  
23 - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou  
24 - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação  
25 - * do Software Livre (FSF).  
26 - *  
27 - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA  
28 - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou  
29 - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português  
30 - * para maiores detalhes.  
31 - *  
32 - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título  
33 - * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>  
34 - * ou escreva para a Fundação do Software Livre (FSF) Inc.,  
35 - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.  
36 - */  
37 -package org.demoiselle.jee.core.annotation.literal;  
38 -  
39 -import org.demoiselle.jee.core.annotation.Strategy;  
40 -  
41 -import javax.enterprise.util.AnnotationLiteral;  
42 -  
43 -/**  
44 - * Annotation litteral that allows to create instances of the {@link Strategy} literal. The created instance can then be  
45 - * used to call {@link javax.enterprise.inject.spi.CDI#select(Class subtype, java.lang.annotation.Annotation... qualifiers)}.  
46 - *  
47 - * @see javax.enterprise.inject.spi.CDI  
48 - * @author SERPRO  
49 - */  
50 -@SuppressWarnings("all")  
51 -public class StrategyQualifier extends AnnotationLiteral<Strategy> implements Strategy {  
52 -  
53 -}  
core/src/main/java/org/demoiselle/jee/core/annotation/literal/TypeQualifier.java
@@ -1,71 +0,0 @@ @@ -1,71 +0,0 @@
1 -/*  
2 - * Demoiselle Framework  
3 - * Copyright (C) 2010 SERPRO  
4 - * ----------------------------------------------------------------------------  
5 - * This file is part of Demoiselle Framework.  
6 - *  
7 - * Demoiselle Framework is free software; you can redistribute it and/or  
8 - * modify it under the terms of the GNU Lesser General Public License version 3  
9 - * as published by the Free Software Foundation.  
10 - *  
11 - * This program is distributed in the hope that it will be useful,  
12 - * but WITHOUT ANY WARRANTY; without even the implied warranty of  
13 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  
14 - * GNU General Public License for more details.  
15 - *  
16 - * You should have received a copy of the GNU Lesser General Public License version 3  
17 - * along with this program; if not, see <http://www.gnu.org/licenses/>  
18 - * or write to the Free Software Foundation, Inc., 51 Franklin Street,  
19 - * Fifth Floor, Boston, MA 02110-1301, USA.  
20 - * ----------------------------------------------------------------------------  
21 - * Este arquivo é parte do Framework Demoiselle.  
22 - *  
23 - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou  
24 - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação  
25 - * do Software Livre (FSF).  
26 - *  
27 - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA  
28 - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou  
29 - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português  
30 - * para maiores detalhes.  
31 - *  
32 - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título  
33 - * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>  
34 - * ou escreva para a Fundação do Software Livre (FSF) Inc.,  
35 - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.  
36 - */  
37 -package org.demoiselle.jee.core.annotation.literal;  
38 -  
39 -import org.demoiselle.jee.core.annotation.Type;  
40 -  
41 -import javax.enterprise.util.AnnotationLiteral;  
42 -  
43 -/**  
44 - * Annotation litteral that allows to create instances of the {@link Type}  
45 - * literal. The created instance can then be used to call  
46 - * {@link javax.enterprise.inject.spi.CDI#select(Class subtype, java.lang.annotation.Annotation... qualifiers)}.  
47 - *  
48 - * @see javax.enterprise.inject.spi.CDI  
49 - * @author SERPRO  
50 - */  
51 -@SuppressWarnings("all")  
52 -public class TypeQualifier extends AnnotationLiteral<Type> implements Type {  
53 -  
54 - private static final long serialVersionUID = 1L;  
55 -  
56 - private final Class<?> value;  
57 -  
58 - /**  
59 - * Constructor with string value of name literal.  
60 - *  
61 - * @param value value of name literal.  
62 - */  
63 - public TypeQualifier(Class<?> value) {  
64 - this.value = value;  
65 - }  
66 -  
67 - @Override  
68 - public Class<?> value() {  
69 - return this.value;  
70 - }  
71 -}  
core/src/main/java/org/demoiselle/jee/core/crud/package-info.java
@@ -1,11 +0,0 @@ @@ -1,11 +0,0 @@
1 -/*  
2 - * Demoiselle Framework  
3 - *  
4 - * License: GNU Lesser General Public License (LGPL), version 3 or later.  
5 - * See the lgpl.txt file in the root directory or <https://www.gnu.org/licenses/lgpl.html>.  
6 - */  
7 -/**  
8 - * Esta pacote tem o objetivo de conter as classes relacionadas aos  
9 - * facilitadores de CRUD do framework Demoiselle.  
10 - */  
11 -package org.demoiselle.jee.core.crud;  
12 \ No newline at end of file 0 \ No newline at end of file
core/src/main/java/org/demoiselle/jee/core/exception/DemoiselleException.java
@@ -1,49 +0,0 @@ @@ -1,49 +0,0 @@
1 -/*  
2 - * Demoiselle Framework  
3 - *  
4 - * License: GNU Lesser General Public License (LGPL), version 3 or later.  
5 - * See the lgpl.txt file in the root directory or <https://www.gnu.org/licenses/lgpl.html>.  
6 - */  
7 -package org.demoiselle.jee.core.exception;  
8 -  
9 -/**  
10 - * Exception class intended to be used by framework configuration and to be derived by other framework exceptions.  
11 - *  
12 - * @author SERPRO  
13 - */  
14 -public class DemoiselleException extends RuntimeException {  
15 -  
16 - private static final long serialVersionUID = 1L;  
17 -  
18 - /**  
19 - * Constructor with message.  
20 - *  
21 - * @param message  
22 - * exception message  
23 - */  
24 - public DemoiselleException(String message) {  
25 - super(message);  
26 - }  
27 -  
28 - /**  
29 - * Constructor with cause.  
30 - *  
31 - * @param cause  
32 - * exception cause  
33 - */  
34 - public DemoiselleException(Throwable cause) {  
35 - super(cause);  
36 - }  
37 -  
38 - /**  
39 - * Constructor with message and cause.  
40 - *  
41 - * @param message  
42 - * exception message  
43 - * @param cause  
44 - * exception cause  
45 - */  
46 - public DemoiselleException(String message, Throwable cause) {  
47 - super(message, cause);  
48 - }  
49 -}  
core/src/main/java/org/demoiselle/jee/core/internal/producer/LoggerProducer.java
@@ -1,45 +0,0 @@ @@ -1,45 +0,0 @@
1 -/*  
2 - * To change this license header, choose License Headers in Project Properties.  
3 - * To change this template file, choose Tools | Templates  
4 - * and open the template in the editor.  
5 - */  
6 -package org.demoiselle.jee.core.internal.producer;  
7 -  
8 -import java.io.Serializable;  
9 -import java.util.logging.Logger;  
10 -import javax.enterprise.context.Dependent;  
11 -import javax.enterprise.inject.Default;  
12 -import javax.enterprise.inject.Produces;  
13 -import javax.enterprise.inject.spi.InjectionPoint;  
14 -  
15 -/**  
16 - *  
17 - * @author 70744416353  
18 - */  
19 -@Dependent  
20 -public class LoggerProducer implements Serializable {  
21 -  
22 - private static final long serialVersionUID = 1L;  
23 -  
24 - /*  
25 - * Produces a default {@link Logger} instance. If it's possible  
26 - * to infer the injection point's parent class then this class'es  
27 - * name will be used to categorize the logger, if not then  
28 - * the logger won't be categorized.  
29 - *  
30 - */  
31 - @Default  
32 - @Produces  
33 - public static final Logger create(final InjectionPoint ip) {  
34 - String name;  
35 -  
36 - if (ip != null && ip.getMember() != null) {  
37 - name = ip.getMember().getDeclaringClass().getName();  
38 - } else {  
39 - name = "not.categorized";  
40 - }  
41 -  
42 - return Logger.getLogger(name);  
43 - }  
44 -  
45 -}  
core/src/main/java/org/demoiselle/jee/core/internal/producer/ResourceBundleProducer.java
@@ -1,75 +0,0 @@ @@ -1,75 +0,0 @@
1 -/*  
2 - * To change this license header, choose License Headers in Project Properties.  
3 - * To change this template file, choose Tools | Templates  
4 - * and open the template in the editor.  
5 - */  
6 -package org.demoiselle.jee.core.internal.producer;  
7 -  
8 -import java.io.Serializable;  
9 -import java.util.Locale;  
10 -  
11 -import javax.enterprise.context.Dependent;  
12 -import javax.enterprise.inject.Default;  
13 -import javax.enterprise.inject.Produces;  
14 -import javax.enterprise.inject.spi.CDI;  
15 -import javax.enterprise.inject.spi.InjectionPoint;  
16 -  
17 -import org.demoiselle.jee.core.annotation.Name;  
18 -import org.demoiselle.jee.core.util.CDIUtils;  
19 -import org.demoiselle.jee.core.util.ResourceBundle;  
20 -  
21 -/**  
22 - *  
23 - * @author 70744416353  
24 - */  
25 -@Dependent  
26 -public class ResourceBundleProducer implements Serializable {  
27 -  
28 - private static final long serialVersionUID = 1L;  
29 -  
30 - @Default  
31 - @Produces  
32 - public ResourceBundle createDefault() {  
33 - return create((String) null);  
34 - }  
35 -  
36 - /*  
37 - * Produces a {@link java.util.ResourceBundle} instance loading the properties file whose name  
38 - * is defined by the {@link Name} literal. If no value is specified  
39 - * then the default "messages.properties" file is loaded.  
40 - */  
41 - @Name  
42 - @Produces  
43 - public ResourceBundle create(InjectionPoint ip) {  
44 - String baseName = null;  
45 - if (ip != null && ip.getQualifiers() != null) {  
46 - Name nameQualifier = CDIUtils.getQualifier(Name.class, ip);  
47 - if (nameQualifier != null) {  
48 - baseName = nameQualifier.value();  
49 - if ("".equals(baseName)) {  
50 - baseName = null;  
51 - }  
52 - }  
53 - }  
54 -  
55 - return create(baseName);  
56 - }  
57 -  
58 - @SuppressWarnings("serial")  
59 - public static ResourceBundle create(String baseName) {  
60 - ResourceBundle bundle;  
61 -  
62 - try {  
63 - bundle = baseName != null  
64 - ? new ResourceBundle(baseName, CDI.current().select(Locale.class).get()) {  
65 - }  
66 - : new ResourceBundle("messages", CDI.current().select(Locale.class).get());  
67 - } catch (RuntimeException e) {  
68 - bundle = baseName != null  
69 - ? new ResourceBundle(baseName, Locale.getDefault())  
70 - : new ResourceBundle("messages", Locale.getDefault());  
71 - }  
72 -  
73 - return bundle;  
74 - }  
75 -}  
core/src/main/java/org/demoiselle/jee/core/lifecycle/LifecycleAnnotation.java
@@ -1,30 +0,0 @@ @@ -1,30 +0,0 @@
1 -/*  
2 - * Demoiselle Framework  
3 - *  
4 - * License: GNU Lesser General Public License (LGPL), version 3 or later.  
5 - * See the lgpl.txt file in the root directory or <https://www.gnu.org/licenses/lgpl.html>.  
6 - */  
7 -package org.demoiselle.jee.core.lifecycle;  
8 -  
9 -import java.lang.annotation.ElementType;  
10 -import java.lang.annotation.Inherited;  
11 -import java.lang.annotation.Retention;  
12 -import java.lang.annotation.Target;  
13 -  
14 -import static java.lang.annotation.RetentionPolicy.RUNTIME;  
15 -  
16 -/**  
17 - * Annotate other annotations with this one to  
18 - * mark them as lifecycle annotations, meaning  
19 - * the lifecycle processor of the framework will  
20 - * read them and fire events based on their represented  
21 - * lifecycle stages.  
22 - *  
23 - * @author SERPRO  
24 - */  
25 -@Inherited  
26 -@Target(ElementType.ANNOTATION_TYPE)  
27 -@Retention(RUNTIME)  
28 -public @interface LifecycleAnnotation {  
29 -  
30 -}  
core/src/main/java/org/demoiselle/jee/core/util/CDIUtils.java
@@ -1,115 +0,0 @@ @@ -1,115 +0,0 @@
1 -package org.demoiselle.jee.core.util;  
2 -  
3 -import java.lang.annotation.Annotation;  
4 -import java.util.Collection;  
5 -  
6 -import javax.enterprise.inject.spi.InjectionPoint;  
7 -  
8 -/**  
9 - * Utility class to peform useful operations on CDI discovered beans.  
10 - *  
11 - * @author SERPRO  
12 - */  
13 -public final class CDIUtils {  
14 -  
15 - private static final Annotation[] annotationArrayType = new Annotation[0];  
16 -  
17 - /**  
18 - * Returns <code>true</code> if one annotation of the provided type is present  
19 - * on a list of annotations.  
20 - *  
21 - * @param annotationType Annotation type being looked for.  
22 - * @param allAnnotations List of all annotations where to look for.  
23 - * @return <code>true</code> if the annotation is present on the list  
24 - */  
25 - public static boolean hasAnnotation(Class<? extends Annotation> annotationType, Annotation... allAnnotations) {  
26 - for (Annotation currentAnnotation : allAnnotations) {  
27 - if (currentAnnotation.annotationType().isAssignableFrom(annotationType)) {  
28 - return true;  
29 - }  
30 - }  
31 -  
32 - return false;  
33 - }  
34 -  
35 - /**  
36 - * @param annotationType Type of the annotation being checked  
37 - * @param allAnnotations List of annotations to check for the specific one  
38 - * @see #hasAnnotation(Class, Annotation...)  
39 - * @return <code>true</code> if the annotation is present on the list  
40 - */  
41 - public static boolean hasAnnotation(Class<? extends Annotation> annotationType,  
42 - Collection<Annotation> allAnnotations) {  
43 - return hasAnnotation(annotationType, allAnnotations.toArray(annotationArrayType));  
44 - }  
45 -  
46 - /**  
47 - * Returns <code>true</code> if a base class is annotated with the provided annotation.  
48 - *  
49 - * @param annotationType Annotation type to look for  
50 - * @param baseType Class to check for the informed annotation  
51 - * @see #hasAnnotation(Class, Annotation...)  
52 - * @return <code>true</code> if the annotation is present on the list  
53 - */  
54 - public static boolean hasAnnotation(Class<? extends Annotation> annotationType, Class<?> baseType) {  
55 - return hasAnnotation(annotationType, baseType.getAnnotations());  
56 - }  
57 -  
58 - /**  
59 - * Returns the annotation instance that matches the annotation type provided,  
60 - * or <code>null</code> if no annotation of that type is present.  
61 - *  
62 - * @param annotationType Annotation type being looked for.  
63 - * @param allAnnotations List of all annotations where to look for.  
64 - * @param <T> Type of the specific annotation returned  
65 - * @return The annotation instance found, or <code>null</code> if there is no such annotation present.  
66 - */  
67 - @SuppressWarnings("unchecked")  
68 - public static <T extends Annotation> T getAnnotation(Class<T> annotationType, Annotation... allAnnotations) {  
69 - for (Annotation currentAnnotation : allAnnotations) {  
70 - if (currentAnnotation.annotationType().isAssignableFrom(annotationType)) {  
71 - return (T) currentAnnotation;  
72 - }  
73 - }  
74 -  
75 - return null;  
76 - }  
77 -  
78 - /**  
79 - * @param annotationType Annotation type being looked for.  
80 - * @param allAnnotations List of all annotations where to look for.  
81 - * @param <T> Type of the specific annotation returned  
82 - * @see #getAnnotation(Class, Annotation...)  
83 - * @return The annotation instance found, or <code>null</code> if there is no such annotation present.  
84 - */  
85 - public static <T extends Annotation> T getAnnotation(Class<T> annotationType,  
86 - Collection<Annotation> allAnnotations) {  
87 - return getAnnotation(annotationType, allAnnotations.toArray(annotationArrayType));  
88 - }  
89 -  
90 - /**  
91 - * Returns <code>true</code> if one qualifier of the provided type is present  
92 - * on an injection point.  
93 - *  
94 - * @param qualifierAnnotationType Annotation type being looked for.  
95 - * @param ip Injection point of a bean type.  
96 - * @return <code>true</code> if the annotation is present on the list  
97 - */  
98 - public static boolean hasQualifier(Class<? extends Annotation> qualifierAnnotationType, InjectionPoint ip) {  
99 - return hasAnnotation(qualifierAnnotationType, ip.getQualifiers());  
100 - }  
101 -  
102 - /**  
103 - * Returns the annotation instance that matches the annotation type provided,  
104 - * or <code>null</code> if no annotation of that type is present.  
105 - *  
106 - * @param qualifierAnnotationType Annotation type being looked for.  
107 - * @param ip Injection point of a bean type.  
108 - * @param <T> Type of the specific annotation returned  
109 - * @return The annotation instance found, or <code>null</code> if there is no such annotation present.  
110 - */  
111 - public static <T extends Annotation> T getQualifier(Class<T> qualifierAnnotationType, InjectionPoint ip) {  
112 - return getAnnotation(qualifierAnnotationType, ip.getQualifiers());  
113 - }  
114 -  
115 -}  
core/src/main/java/org/demoiselle/jee/core/util/Exceptions.java
@@ -1,67 +0,0 @@ @@ -1,67 +0,0 @@
1 -/*  
2 - * Demoiselle Framework  
3 - * Copyright (C) 2010 SERPRO  
4 - * ----------------------------------------------------------------------------  
5 - * This file is part of Demoiselle Framework.  
6 - *  
7 - * Demoiselle Framework is free software; you can redistribute it and/or  
8 - * modify it under the terms of the GNU Lesser General Public License version 3  
9 - * as published by the Free Software Foundation.  
10 - *  
11 - * This program is distributed in the hope that it will be useful,  
12 - * but WITHOUT ANY WARRANTY; without even the implied warranty of  
13 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  
14 - * GNU General Public License for more details.  
15 - *  
16 - * You should have received a copy of the GNU Lesser General Public License version 3  
17 - * along with this program; if not, see <http://www.gnu.org/licenses/>  
18 - * or write to the Free Software Foundation, Inc., 51 Franklin Street,  
19 - * Fifth Floor, Boston, MA 02110-1301, USA.  
20 - * ----------------------------------------------------------------------------  
21 - * Este arquivo é parte do Framework Demoiselle.  
22 - *  
23 - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou  
24 - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação  
25 - * do Software Livre (FSF).  
26 - *  
27 - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA  
28 - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou  
29 - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português  
30 - * para maiores detalhes.  
31 - *  
32 - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título  
33 - * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>  
34 - * ou escreva para a Fundação do Software Livre (FSF) Inc.,  
35 - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.  
36 - */  
37 -package org.demoiselle.jee.core.util;  
38 -  
39 -/**  
40 - *Class that offer tow methods that can help with manipulation of throwable exceptions.  
41 - *  
42 - * @author SERPRO  
43 - */  
44 -public final class Exceptions {  
45 -  
46 - /**  
47 - * Constructor without parameters.  
48 - */  
49 - private Exceptions() {  
50 - }  
51 -  
52 - /**  
53 - * Receives as parameter any kind of Throwable objects, and throws a RuntimeException instead.  
54 - *  
55 - * @param throwable  
56 - * a throwable object.  
57 - *  
58 - * @throws RuntimeException throws this kind of exception every time that is called.  
59 - */  
60 - public static void handleToRuntimeException(final Throwable throwable) throws RuntimeException {  
61 - if (throwable instanceof RuntimeException) {  
62 - throw (RuntimeException) throwable;  
63 - } else {  
64 - throw new RuntimeException(throwable);  
65 - }  
66 - }  
67 -}  
core/src/main/java/org/demoiselle/jee/core/util/Reflections.java
@@ -1,367 +0,0 @@ @@ -1,367 +0,0 @@
1 -/*  
2 - * Demoiselle Framework  
3 - * Copyright (C) 2010 SERPRO  
4 - * ----------------------------------------------------------------------------  
5 - * This file is part of Demoiselle Framework.  
6 - *  
7 - * Demoiselle Framework is free software; you can redistribute it and/or  
8 - * modify it under the terms of the GNU Lesser General Public License version 3  
9 - * as published by the Free Software Foundation.  
10 - *  
11 - * This program is distributed in the hope that it will be useful,  
12 - * but WITHOUT ANY WARRANTY; without even the implied warranty of  
13 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  
14 - * GNU General Public License for more details.  
15 - *  
16 - * You should have received a copy of the GNU Lesser General Public License version 3  
17 - * along with this program; if not, see <http://www.gnu.org/licenses/>  
18 - * or write to the Free Software Foundation, Inc., 51 Franklin Street,  
19 - * Fifth Floor, Boston, MA 02110-1301, USA.  
20 - * ----------------------------------------------------------------------------  
21 - * Este arquivo é parte do Framework Demoiselle.  
22 - *  
23 - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou  
24 - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação  
25 - * do Software Livre (FSF).  
26 - *  
27 - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA  
28 - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou  
29 - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português  
30 - * para maiores detalhes.  
31 - *  
32 - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título  
33 - * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>  
34 - * ou escreva para a Fundação do Software Livre (FSF) Inc.,  
35 - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.  
36 - */  
37 -package org.demoiselle.jee.core.util;  
38 -  
39 -import java.io.InputStream;  
40 -import java.lang.reflect.*;  
41 -import java.net.URL;  
42 -import java.util.ArrayList;  
43 -import java.util.Arrays;  
44 -import java.util.List;  
45 -  
46 -/**  
47 - * Provides some features to do some operations relating to java reflection.  
48 - *  
49 - * @author SERPRO  
50 - */  
51 -public class Reflections {  
52 -  
53 - protected Reflections() {  
54 - // Impede instanciar subclasses desse tipo.  
55 - throw new UnsupportedOperationException();  
56 - }  
57 -  
58 - /**  
59 - * Return the parametized type used with a concrete implementation of a class that accepts generics. Ex: If you  
60 - * declare  
61 - * <pre>  
62 - * public class SpecializedCollection implements Collection&#60;SpecializedType&#62; {  
63 - * // ...  
64 - * }  
65 - * </pre>  
66 - * then the code <code>getGenericTypeArgument(SpecializedCollection.class , 0);</code> will return the type  
67 - * <code>SpecializedType</code>.  
68 - *  
69 - * @param type Base type to check for generic arguments  
70 - * @param idx zero based index of the generic argument to get  
71 - * @param <T> Type of the generic argument  
72 - * @return The class representing the type of the generic argument  
73 - */  
74 - @SuppressWarnings("unchecked")  
75 - public static <T> Class<T> getGenericTypeArgument(final Type type, final int idx) {  
76 - ParameterizedType paramType;  
77 - try {  
78 - paramType = (ParameterizedType) type;  
79 - } catch (ClassCastException cause) {  
80 - return getGenericTypeArgument((Class<T>) type, idx);  
81 - }  
82 -  
83 - return (Class<T>) paramType.getActualTypeArguments()[idx];  
84 - }  
85 -  
86 - /**  
87 - * Return the parametized type used with a concrete implementation of a class that accepts generics. Ex: If you  
88 - * declare  
89 - * <pre>  
90 - * <code>  
91 - * public class SpecializedCollection implements Collection&#60;SpecializedType&#62; {  
92 - * // ...  
93 - * }  
94 - * </code>  
95 - * </pre>  
96 - * then the code <code>getGenericTypeArgument(SpecializedCollection.class , 0);</code> will return the type  
97 - * <code>SpecializedType</code>.  
98 - *  
99 - * @param clazz Base type to check for generic arguments  
100 - * @param idx zero based index of the generic argument to get  
101 - * @param <T> Type of the generic argument  
102 - * @return The class representing the type of the generic argument  
103 - */  
104 - @SuppressWarnings("unchecked")  
105 - public static <T> Class<T> getGenericTypeArgument(final Class<?> clazz, final int idx) {  
106 - final Type type = clazz.getGenericSuperclass();  
107 -  
108 - ParameterizedType paramType;  
109 - try {  
110 - paramType = (ParameterizedType) type;  
111 - } catch (ClassCastException cause) {  
112 - return getGenericTypeArgument((Class<T>) type, idx);  
113 - }  
114 -  
115 - return (Class<T>) paramType.getActualTypeArguments()[idx];  
116 - }  
117 -  
118 - /**  
119 - * <p>  
120 - * Return the parametized type passed to field types that accepts Generics.  
121 - * </p>  
122 - * Ex: If you declare  
123 - * <pre>  
124 - * <code>  
125 - * public class MyClass{  
126 - * private Collection&lt;String&gt; myStringCollection;  
127 - * }  
128 - * </code>  
129 - * </pre>  
130 - * then the code <code>getGenericTypeArgument( MyClass.class.getDeclaredField("myStringCollection") , 0);</code>  
131 - * will return the type <code>String</code>.  
132 - *  
133 - * @param field Field which type is generified  
134 - * @param idx zero based index of the generic argument to get  
135 - * @param <T> Type of the generic argument  
136 - * @return The class representing the type of the generic argument  
137 - */  
138 - @SuppressWarnings("unchecked")  
139 - public static <T> Class<T> getGenericTypeArgument(final Field field, final int idx) {  
140 - final Type type = field.getGenericType();  
141 - final ParameterizedType paramType = (ParameterizedType) type;  
142 -  
143 - return (Class<T>) paramType.getActualTypeArguments()[idx];  
144 - }  
145 -  
146 - /**  
147 - * <p>  
148 - * Return the parametized type passed to members (fields or methods) that accepts Generics.  
149 - * </p>  
150 - *  
151 - * @param member Member which type is generified  
152 - * @param idx zero based index of the generic argument to get  
153 - * @param <T> Type of the generic argument  
154 - * @return The class representing the type of the generic argument  
155 - * @see #getGenericTypeArgument(Field field, int idx)  
156 - */  
157 - public static <T> Class<T> getGenericTypeArgument(final Member member, final int idx) {  
158 - Class<T> result = null;  
159 -  
160 - if (member instanceof Field) {  
161 - result = getGenericTypeArgument((Field) member, idx);  
162 - } else if (member instanceof Method) {  
163 - result = getGenericTypeArgument((Method) member, idx);  
164 - }  
165 -  
166 - return result;  
167 - }  
168 -  
169 - /**  
170 - * <p>  
171 - * Return the parametized type passed to methods that accepts Generics.  
172 - * </p>  
173 - *  
174 - * @param method Generified method reference  
175 - * @param idx zero based index of the generic argument to get  
176 - * @param <T> Type of the generic argument  
177 - * @return The class representing the type of the generic argument  
178 - * @see #getGenericTypeArgument(Field field, int idx)  
179 - */  
180 - @SuppressWarnings("unchecked")  
181 - public static <T> Class<T> getGenericTypeArgument(final Method method, final int idx) {  
182 - return (Class<T>) method.getGenericParameterTypes()[idx];  
183 - }  
184 -  
185 - /**  
186 - * Returns the value contained in the given field.  
187 - *  
188 - * @param field field to be extracted the value.  
189 - * @param object object that contains the field.  
190 - * @param <T> Type of the generic argument  
191 - * @return value of the field.  
192 - */  
193 - @SuppressWarnings("unchecked")  
194 - public static <T> T getFieldValue(Field field, Object object) {  
195 - T result = null;  
196 -  
197 - try {  
198 - boolean acessible = field.isAccessible();  
199 - field.setAccessible(true);  
200 - result = (T) field.get(object);  
201 - field.setAccessible(acessible);  
202 -  
203 - } catch (Exception e) {  
204 - Exceptions.handleToRuntimeException(e);  
205 - }  
206 -  
207 - return result;  
208 - }  
209 -  
210 - /**  
211 - * Sets a value in a field.  
212 - *  
213 - * @param field field to be setted.  
214 - * @param object object that contains the field.  
215 - * @param value value to be setted in the field.  
216 - */  
217 - public static void setFieldValue(Field field, Object object, Object value) {  
218 - try {  
219 - boolean acessible = field.isAccessible();  
220 - field.setAccessible(true);  
221 - field.set(object, value);  
222 - field.setAccessible(acessible);  
223 -  
224 - } catch (Exception e) {  
225 - Exceptions.handleToRuntimeException(e);  
226 - }  
227 - }  
228 -  
229 - /**  
230 - * @param type Base type to look for fields  
231 - * @return All non static fields from a certain type. Inherited fields are not returned, so if you need to get  
232 - * inherited fields you must iterate over this type's hierarchy.  
233 - */  
234 - public static Field[] getNonStaticDeclaredFields(Class<?> type) {  
235 - List<Field> fields = new ArrayList<Field>();  
236 -  
237 - if (type != null) {  
238 - for (Field field : type.getDeclaredFields()) {  
239 - if (!Modifier.isStatic(field.getModifiers()) && !field.getType().equals(type.getDeclaringClass())) {  
240 - fields.add(field);  
241 - }  
242 - }  
243 - }  
244 -  
245 - return fields.toArray(new Field[0]);  
246 - }  
247 -  
248 - /**  
249 - * @param type Base type to look for fields  
250 - * @return All non static fields from a certain type, including fields declared in superclasses of this type.  
251 - */  
252 - public static List<Field> getNonStaticFields(Class<?> type) {  
253 - List<Field> fields = new ArrayList<Field>();  
254 -  
255 - if (type != null) {  
256 - Class<?> currentType = type;  
257 - while (currentType != null && !"java.lang.Object".equals(currentType.getCanonicalName())) {  
258 - fields.addAll(Arrays.asList(getNonStaticDeclaredFields(currentType)));  
259 - currentType = currentType.getSuperclass();  
260 - }  
261 - }  
262 -  
263 - return fields;  
264 - }  
265 -  
266 - /**  
267 - * Instantiate an object of the given type. The default constructor with no parameters is used.  
268 - *  
269 - * @param clazz Base type of object to instantiate  
270 - * @param <T> Final type of instantiated object  
271 - * @return New instance of provided type  
272 - */  
273 - public static <T> T instantiate(Class<T> clazz) {  
274 - T object = null;  
275 - try {  
276 - object = clazz.newInstance();  
277 - } catch (InstantiationException | IllegalAccessException e) {  
278 - Exceptions.handleToRuntimeException(e);  
279 - }  
280 - return object;  
281 - }  
282 -  
283 - /**  
284 - * Verifies if a given class could be converted to a given type.  
285 - *  
286 - * @param clazz class to be checked.  
287 - * @param type type to be checked.  
288 - * @return {@link Boolean} true if the given class can be converted to a given type, and false otherwise.  
289 - */  
290 - public static boolean isOfType(Class<?> clazz, Class<?> type) {  
291 - return type.isAssignableFrom(clazz) && clazz != type;  
292 - }  
293 -  
294 - /**  
295 - * Obtains the {@link ClassLoader} for the given class, from his canonical name.  
296 - *  
297 - * @param canonicalName canonical name of the the given class.  
298 - * @return {@link ClassLoader} ClassLoader for the given class.  
299 - */  
300 - public static ClassLoader getClassLoaderForClass(final String canonicalName) {  
301 - return Reflections.getClassLoaderForResource(canonicalName.replaceAll("\\.", "/") + ".class");  
302 - }  
303 -  
304 - /**  
305 - * Obtains the {@link ClassLoader} for the given resource.  
306 - *  
307 - * @param resource String representation of the fully qualified path to the resource on the classpath  
308 - * @return {@link ClassLoader} ClassLoader for the given resource.  
309 - */  
310 - public static ClassLoader getClassLoaderForResource(final String resource) {  
311 - final String stripped = resource.charAt(0) == '/' ? resource.substring(1) : resource;  
312 -  
313 - URL url = null;  
314 - ClassLoader result = Thread.currentThread().getContextClassLoader();  
315 -  
316 - if (result != null) {  
317 - url = result.getResource(stripped);  
318 - }  
319 -  
320 - if (url == null) {  
321 - result = Reflections.class.getClassLoader();  
322 - url = Reflections.class.getClassLoader().getResource(stripped);  
323 - }  
324 -  
325 - if (url == null) {  
326 - result = null;  
327 - }  
328 -  
329 - return result;  
330 - }  
331 -  
332 - /**  
333 - * Return an URL to access a resource available to the active classloader for the calling thread.  
334 - *  
335 - * @param resource String representation of the location of the resource on the classpath  
336 - * @return The {@link URL} for the resource  
337 - */  
338 - public static URL getResourceAsURL(final String resource) {  
339 - ClassLoader classLoader = getClassLoaderForResource(resource);  
340 - return classLoader != null ? classLoader.getResource(resource) : null;  
341 - }  
342 -  
343 - /**  
344 - * Return an InputStream to access a resource available to the active classloader for the calling thread.  
345 - *  
346 - * @param resource String representation of the location of the resource on the classpath  
347 - * @return An {@link InputStream} that reads data from the resource  
348 - */  
349 - public static InputStream getResourceAsStream(final String resource) {  
350 - ClassLoader classLoader = getClassLoaderForResource(resource);  
351 - return classLoader != null ? classLoader.getResourceAsStream(resource) : null;  
352 - }  
353 -  
354 - /**  
355 - * Loads a class with the given name using the active classloader for the current thread.  
356 - *  
357 - * @param className String with fully qualified class name of the desired class  
358 - * @param <T> Final type of the loaded class  
359 - * @return Class representing the loaded type  
360 - * @throws ClassNotFoundException If no class with this name exists  
361 - */  
362 - @SuppressWarnings("unchecked")  
363 - public static <T> Class<T> forName(final String className) throws ClassNotFoundException {  
364 - ClassLoader classLoader = getClassLoaderForClass(className);  
365 - return (Class<T>) Class.forName(className, true, classLoader);  
366 - }  
367 -}  
core/src/main/java/org/demoiselle/jee/core/util/ResourceBundle.java
@@ -1,136 +0,0 @@ @@ -1,136 +0,0 @@
1 -/*  
2 - * Demoiselle Framework  
3 - * Copyright (C) 2010 SERPRO  
4 - * ----------------------------------------------------------------------------  
5 - * This file is part of Demoiselle Framework.  
6 - *  
7 - * Demoiselle Framework is free software; you can redistribute it and/or  
8 - * modify it under the terms of the GNU Lesser General Public License version 3  
9 - * as published by the Free Software Foundation.  
10 - *  
11 - * This program is distributed in the hope that it will be useful,  
12 - * but WITHOUT ANY WARRANTY; without even the implied warranty of  
13 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  
14 - * GNU General Public License for more details.  
15 - *  
16 - * You should have received a copy of the GNU Lesser General Public License version 3  
17 - * along with this program; if not, see <http://www.gnu.org/licenses/>  
18 - * or write to the Free Software Foundation, Inc., 51 Franklin Street,  
19 - * Fifth Floor, Boston, MA 02110-1301, USA.  
20 - * ----------------------------------------------------------------------------  
21 - * Este arquivo é parte do Framework Demoiselle.  
22 - *  
23 - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou  
24 - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação  
25 - * do Software Livre (FSF).  
26 - *  
27 - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA  
28 - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou  
29 - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português  
30 - * para maiores detalhes.  
31 - *  
32 - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título  
33 - * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>  
34 - * ou escreva para a Fundação do Software Livre (FSF) Inc.,  
35 - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.  
36 - */  
37 -package org.demoiselle.jee.core.util;  
38 -  
39 -import java.io.Serializable;  
40 -import java.lang.reflect.Method;  
41 -import java.util.Enumeration;  
42 -import java.util.Locale;  
43 -import java.util.MissingResourceException;  
44 -import java.util.Set;  
45 -  
46 -/**  
47 - * <p>The Demoiselle's ResourceBundle extends the abstraction {@link java.util.ResourceBundle},  
48 - * and provide the locale and the base name for the bundle.</p>  
49 - *  
50 - * <p>To select which resource properties file to load when injecting beans of this class, qualify  
51 - * the injection point with {@link org.demoiselle.annotation.Name}, using the resource name (without  
52 - * the '.properties' extension) as the value. If the injection point isn't qualified the default  
53 - * file <code>messages.properties</code> will be loaded from the root of the classpath.</p>  
54 - *  
55 - * @author SERPRO  
56 - */  
57 -public class ResourceBundle extends java.util.ResourceBundle implements Serializable {  
58 -  
59 - private static final long serialVersionUID = 1L;  
60 -  
61 - private String baseName;  
62 -  
63 - private transient java.util.ResourceBundle delegate;  
64 -  
65 - private final Locale locale;  
66 -  
67 - private java.util.ResourceBundle getDelegate() {  
68 - if (delegate == null) {  
69 - try {  
70 - ClassLoader classLoader = Thread.currentThread().getContextClassLoader();  
71 - delegate = ResourceBundle.getBundle(baseName, locale, classLoader);  
72 -  
73 - } catch (MissingResourceException mre) {  
74 - delegate = ResourceBundle.getBundle(baseName, locale);  
75 - }  
76 - }  
77 -  
78 - return delegate;  
79 - }  
80 -  
81 - /**  
82 - * Constructor that set values of baseName and locale.  
83 - *  
84 - * @param baseName  
85 - * the base name to construct the complete bundle name.  
86 - *  
87 - * @param locale  
88 - * locale to define the choosen bundle.  
89 - */  
90 - public ResourceBundle(String baseName, Locale locale) {  
91 - this.baseName = baseName;  
92 - this.locale = locale;  
93 - }  
94 -  
95 - @Override  
96 - public boolean containsKey(String key) {  
97 - return getDelegate().containsKey(key);  
98 - }  
99 -  
100 - @Override  
101 - public Enumeration<String> getKeys() {  
102 - return getDelegate().getKeys();  
103 - }  
104 -  
105 - @Override  
106 - public Locale getLocale() {  
107 - return getDelegate().getLocale();  
108 - }  
109 -  
110 - @Override  
111 - public Set<String> keySet() {  
112 - return getDelegate().keySet();  
113 - }  
114 -  
115 - public String getString(String key, Object... params) {  
116 - return Strings.getString(getString(key), params);  
117 - }  
118 -  
119 - @Override  
120 - protected Object handleGetObject(String key) {  
121 - Object result;  
122 -  
123 - try {  
124 - Method method = getDelegate().getClass().getMethod("handleGetObject", String.class);  
125 -  
126 - method.setAccessible(true);  
127 - result = method.invoke(delegate, key);  
128 - method.setAccessible(false);  
129 -  
130 - } catch (Exception cause) {  
131 - throw new RuntimeException(cause);  
132 - }  
133 -  
134 - return result;  
135 - }  
136 -}  
core/src/main/java/org/demoiselle/jee/core/util/Strings.java
@@ -1,300 +0,0 @@ @@ -1,300 +0,0 @@
1 -/*  
2 - * Demoiselle Framework  
3 - * Copyright (C) 2010 SERPRO  
4 - * ----------------------------------------------------------------------------  
5 - * This file is part of Demoiselle Framework.  
6 - *  
7 - * Demoiselle Framework is free software; you can redistribute it and/or  
8 - * modify it under the terms of the GNU Lesser General Public License version 3  
9 - * as published by the Free Software Foundation.  
10 - *  
11 - * This program is distributed in the hope that it will be useful,  
12 - * but WITHOUT ANY WARRANTY; without even the implied warranty of  
13 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  
14 - * GNU General Public License for more details.  
15 - *  
16 - * You should have received a copy of the GNU Lesser General Public License version 3  
17 - * along with this program; if not, see <http://www.gnu.org/licenses/>  
18 - * or write to the Free Software Foundation, Inc., 51 Franklin Street,  
19 - * Fifth Floor, Boston, MA 02110-1301, USA.  
20 - * ----------------------------------------------------------------------------  
21 - * Este arquivo é parte do Framework Demoiselle.  
22 - *  
23 - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou  
24 - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação  
25 - * do Software Livre (FSF).  
26 - *  
27 - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA  
28 - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou  
29 - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português  
30 - * para maiores detalhes.  
31 - *  
32 - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título  
33 - * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>  
34 - * ou escreva para a Fundação do Software Livre (FSF) Inc.,  
35 - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.  
36 - */  
37 -package org.demoiselle.jee.core.util;  
38 -  
39 -import java.io.BufferedReader;  
40 -import java.io.IOException;  
41 -import java.io.InputStream;  
42 -import java.io.InputStreamReader;  
43 -import java.lang.reflect.Field;  
44 -import java.util.Arrays;  
45 -import java.util.regex.Matcher;  
46 -import java.util.regex.Pattern;  
47 -  
48 -import org.demoiselle.jee.core.annotation.Ignore;  
49 -  
50 -/**  
51 - * Contain a set of methods that implements a set of functionalities that  
52 - * envolves manipulation of strings.  
53 - *  
54 - * @author SERPRO  
55 - */  
56 -public final class Strings {  
57 -  
58 - private Strings() {  
59 - }  
60 -  
61 - /**  
62 - * Returns if some string matches with the format of a ResourceBundle key or  
63 - * not.  
64 - *  
65 - * @param key string to check if matches with key format of ResourceBundle.  
66 - * @return boolean true if matches and false otherwise.  
67 - */  
68 - public static boolean isResourceBundleKeyFormat(final String key) {  
69 - return Pattern.matches("^\\{(.+)\\}$", key == null ? "" : key);  
70 - }  
71 -  
72 - /**  
73 - * Removes specific characteres from a given string.  
74 - *  
75 - * @param string string to be changed, by the removing of some characters.  
76 - * @param chars characters to be removed from string.  
77 - * @return String returns the given string without the given characters.  
78 - */  
79 - public static String removeChars(String string, char... chars) {  
80 - String result = string;  
81 -  
82 - if (result != null) {  
83 - for (char ch : chars) {  
84 - result = result.replace(String.valueOf(ch), "");  
85 - }  
86 - }  
87 - return result;  
88 - }  
89 -  
90 - public static String join(String separator, String... strings) {  
91 - StringBuffer result = new StringBuffer();  
92 -  
93 - if (strings != null) {  
94 - for (int i = 0; i < strings.length; i++) {  
95 - if (i != 0 && separator != null) {  
96 - result.append(separator);  
97 - }  
98 -  
99 - if (strings[i] != null) {  
100 - result.append(strings[i]);  
101 - }  
102 - }  
103 - }  
104 -  
105 - return result.length() > 0 ? result.toString() : null;  
106 - }  
107 -  
108 - /**  
109 - * Inserts the character "0" in the begin of a given string. The quantity of  
110 - * zeros that will be placed depends on the difference between the length of  
111 - * the given string and the value of howMuchZeros.  
112 - *  
113 - * @param string string to insert zeros characthers.  
114 - * @param howMuchZeros its controls how much zeros will be insert.  
115 - * @return String Retuns the string, added with appropriate number of zeros.  
116 - * For exemplo, if string = "yes" and howMuchZeros = 5, the returned string  
117 - * will be "00yes".  
118 - */  
119 - public static String insertZeros(String string, int howMuchZeros) {  
120 - StringBuffer result = new StringBuffer((string == null ? "" : string).trim());  
121 - int difference = howMuchZeros - result.toString().length();  
122 -  
123 - for (int j = 0; j < difference; j++) {  
124 - result.insert(0, '0');  
125 - }  
126 -  
127 - return result.toString();  
128 - }  
129 -  
130 - /**  
131 - * * Replaces the numbers between braces in the given string with the given  
132 - * parameters. The process will replace a number between braces for the  
133 - * parameter for which its order in the set of parameters matches with the  
134 - * number of the given string. For exemple, if is received the following  
135 - * string "Treats an {0} exception" and the set of parameters  
136 - * {"DemoiselleException"}, the return will be the following string: "Treats  
137 - * an DemoiselleException exception".  
138 - *  
139 - * @param string with the numbers with braces to be replaced with the  
140 - * parameters.  
141 - * @param params parameters that will replace the number with braces in the  
142 - * given string.  
143 - * @return String string with numbers replaced with the matching parameter.  
144 - */  
145 - public static String getString(final String string, final Object... params) {  
146 - String result = null;  
147 -  
148 - if (string != null) {  
149 - result = new String(string);  
150 - }  
151 -  
152 - if (params != null && string != null) {  
153 - for (int i = 0; i < params.length; i++) {  
154 - if (params[i] != null) {  
155 - result = result.replaceAll("\\{" + i + "\\}", Matcher.quoteReplacement(params[i].toString()));  
156 - }  
157 - }  
158 - }  
159 -  
160 - return result;  
161 - }  
162 -  
163 - /**  
164 - * Verifies if a given string is empty or null.  
165 - *  
166 - * @param string string to be verified.  
167 - * @return boolean returns true if the given string is empty or null and  
168 - * returns false otherwise.  
169 - */  
170 - public static boolean isEmpty(String string) {  
171 - return string == null || string.trim().isEmpty();  
172 - }  
173 -  
174 - /**  
175 - * Converts any object to string.  
176 - *  
177 - * @param object object to be converted.  
178 - * @return String the given object converted to string.  
179 - */  
180 - public static String toString(Object object) {  
181 - StringBuffer result = new StringBuffer();  
182 - Object fieldValue;  
183 -  
184 - if (object != null) {  
185 - result.append(object.getClass().getSimpleName());  
186 - result.append(" [");  
187 -  
188 - boolean first = true;  
189 - for (Field field : Reflections.getNonStaticDeclaredFields(object.getClass())) {  
190 - if (!field.isAnnotationPresent(Ignore.class)) {  
191 - if (first) {  
192 - first = false;  
193 - } else {  
194 - result.append(", ");  
195 - }  
196 -  
197 - result.append(field.getName());  
198 - result.append('=');  
199 - fieldValue = Reflections.getFieldValue(field, object);  
200 - result.append(fieldValue != null && fieldValue.getClass().isArray()  
201 - ? Arrays.toString((Object[]) fieldValue)  
202 - : fieldValue);  
203 - }  
204 - }  
205 -  
206 - result.append(']');  
207 - }  
208 -  
209 - return result.toString();  
210 - }  
211 -  
212 - /**  
213 - * Replace the camel case string for a lowercase string separated for a  
214 - * given symbol.  
215 - *  
216 - * @param string string that separeted with camel case.  
217 - * @param symbol simbol to be the new separator for the given string.  
218 - * @return String the given string separated with the given symbol.  
219 - */  
220 - public static String camelCaseToSymbolSeparated(String string, String symbol) {  
221 - if (symbol == null) {  
222 - symbol = "";  
223 - }  
224 -  
225 - return string == null ? null : string.replaceAll("\\B([A-Z])", symbol + "$1").toLowerCase();  
226 - }  
227 -  
228 - /**  
229 - * Sets the first character of a given string to upper case.  
230 - *  
231 - * @param string Full string to convert  
232 - * @return String the given string with the first character setted to upper  
233 - * case.  
234 - */  
235 - public static String firstToUpper(String string) {  
236 - String result = string;  
237 -  
238 - if (!Strings.isEmpty(string)) {  
239 - result = string.toUpperCase().charAt(0) + (string.length() > 1 ? string.substring(1) : "");  
240 - }  
241 -  
242 - return result;  
243 - }  
244 -  
245 - /**  
246 - * Removes braces from a given string.  
247 - *  
248 - * @param string Message to remove braces from  
249 - * @return String the given string without braces.  
250 - */  
251 - public static String removeBraces(String string) {  
252 - String result = string;  
253 -  
254 - if (isResourceBundleKeyFormat(string)) {  
255 - result = string.substring(1, string.length() - 1);  
256 - }  
257 -  
258 - return result;  
259 - }  
260 -  
261 - /**  
262 - * Inserts braces in a given string.  
263 - *  
264 - * @param string Original string to insert braces on.  
265 - * @return String the given string with braces.  
266 - */  
267 - public static String insertBraces(String string) {  
268 - String result = string;  
269 -  
270 - if (!isEmpty(string)) {  
271 - result = "{" + string + "}";  
272 - }  
273 -  
274 - return result;  
275 - }  
276 -  
277 - public static String parse(InputStream inputStream) throws IOException {  
278 - StringBuilder result = new StringBuilder();  
279 -  
280 - if (inputStream != null) {  
281 - BufferedReader reader = null;  
282 -  
283 - try {  
284 - reader = new BufferedReader(new InputStreamReader(inputStream));  
285 - String line;  
286 -  
287 - while ((line = reader.readLine()) != null) {  
288 - result.append(line);  
289 - }  
290 -  
291 - } finally {  
292 - if (reader != null) {  
293 - reader.close();  
294 - }  
295 - }  
296 - }  
297 -  
298 - return result.length() > 0 ? result.toString() : null;  
299 - }  
300 -}  
core/src/main/java/org/demoiselle/jee/stereotype/BusinessController.java
@@ -1,36 +0,0 @@ @@ -1,36 +0,0 @@
1 -/*  
2 - * Demoiselle Framework  
3 - *  
4 - * License: GNU Lesser General Public License (LGPL), version 3 or later.  
5 - * See the lgpl.txt file in the root directory or <https://www.gnu.org/licenses/lgpl.html>.  
6 - */  
7 -package org.demoiselle.jee.stereotype;  
8 -  
9 -import javax.enterprise.inject.Stereotype;  
10 -import java.lang.annotation.Inherited;  
11 -import java.lang.annotation.Retention;  
12 -import java.lang.annotation.Target;  
13 -  
14 -import static java.lang.annotation.ElementType.TYPE;  
15 -import static java.lang.annotation.RetentionPolicy.RUNTIME;  
16 -  
17 -/**  
18 - * Identifies a <b>business controller</b> class. Business controller objects typically implement the controller design  
19 - * pattern, i.e., they contain no data elements but methods that orchestrate interaction among business entities.  
20 - * <p>  
21 - * A <i>Business Controller</i> is:  
22 - * <ul>  
23 - * <li>defined when annotated with {@code @BusinessController}</li>  
24 - * <li>automatically injected whenever {@code @Inject} is used</li>  
25 - * </ul>  
26 - *  
27 - * @author SERPRO  
28 - * @see Controller  
29 - */  
30 -@Controller  
31 -@Stereotype  
32 -@Inherited  
33 -@Target(TYPE)  
34 -@Retention(RUNTIME)  
35 -public @interface BusinessController {  
36 -}  
core/src/main/java/org/demoiselle/jee/stereotype/Controller.java
@@ -1,28 +0,0 @@ @@ -1,28 +0,0 @@
1 -/*  
2 - * Demoiselle Framework  
3 - *  
4 - * License: GNU Lesser General Public License (LGPL), version 3 or later.  
5 - * See the lgpl.txt file in the root directory or <https://www.gnu.org/licenses/lgpl.html>.  
6 - */  
7 -package org.demoiselle.jee.stereotype;  
8 -  
9 -import javax.interceptor.InterceptorBinding;  
10 -import java.lang.annotation.Inherited;  
11 -import java.lang.annotation.Retention;  
12 -import java.lang.annotation.Target;  
13 -  
14 -import static java.lang.annotation.ElementType.METHOD;  
15 -import static java.lang.annotation.ElementType.TYPE;  
16 -import static java.lang.annotation.RetentionPolicy.RUNTIME;  
17 -  
18 -/**  
19 - * Identifies a <b>controller</b> class or stereotype, the latter being most suitable for it.  
20 - *  
21 - * @author SERPRO  
22 - */  
23 -@InterceptorBinding  
24 -@Inherited  
25 -@Target({ TYPE, METHOD })  
26 -@Retention(RUNTIME)  
27 -public @interface Controller {  
28 -}  
core/src/main/java/org/demoiselle/jee/stereotype/PersistenceController.java
@@ -1,37 +0,0 @@ @@ -1,37 +0,0 @@
1 -/*  
2 - * Demoiselle Framework  
3 - *  
4 - * License: GNU Lesser General Public License (LGPL), version 3 or later.  
5 - * See the lgpl.txt file in the root directory or <https://www.gnu.org/licenses/lgpl.html>.  
6 - */  
7 -package org.demoiselle.jee.stereotype;  
8 -  
9 -import javax.enterprise.inject.Stereotype;  
10 -import java.lang.annotation.Inherited;  
11 -import java.lang.annotation.Retention;  
12 -import java.lang.annotation.Target;  
13 -  
14 -import static java.lang.annotation.ElementType.TYPE;  
15 -import static java.lang.annotation.RetentionPolicy.RUNTIME;  
16 -  
17 -/**  
18 - * Identifies a <b>persistence controller</b> class. A persistence controller is  
19 - * a layer which provides simplified access to data stored in persistent storage  
20 - * of some kind, such as an entity-relational database.  
21 - * <p>  
22 - * A <i>Persitence Controller</i> is:  
23 - * <ul>  
24 - * <li>defined when annotated with {@code @PersistenceController}</li>  
25 - * <li>automatically injected whenever {@code @Inject} is used</li>  
26 - * </ul>  
27 - *  
28 - * @author SERPRO  
29 - * @see Controller  
30 - */  
31 -@Controller  
32 -@Stereotype  
33 -@Inherited  
34 -@Target(TYPE)  
35 -@Retention(RUNTIME)  
36 -public @interface PersistenceController {  
37 -}  
core/src/main/java/org/demoiselle/jee/stereotype/RestController.java
@@ -1,36 +0,0 @@ @@ -1,36 +0,0 @@
1 -/*  
2 - * Demoiselle Framework  
3 - *  
4 - * License: GNU Lesser General Public License (LGPL), version 3 or later.  
5 - * See the lgpl.txt file in the root directory or <https://www.gnu.org/licenses/lgpl.html>.  
6 - */  
7 -package org.demoiselle.jee.stereotype;  
8 -  
9 -import javax.enterprise.inject.Stereotype;  
10 -import java.lang.annotation.Inherited;  
11 -import java.lang.annotation.Retention;  
12 -import java.lang.annotation.Target;  
13 -  
14 -import static java.lang.annotation.ElementType.TYPE;  
15 -import static java.lang.annotation.RetentionPolicy.RUNTIME;  
16 -  
17 -/**  
18 - * Identifies a <b>facade</b> class. A facade is an object that provides a  
19 - * simplified interface to a larger body of code, such as a class library.  
20 - * <p>  
21 - * A <i>Facade</i> is:  
22 - * <ul>  
23 - * <li>defined when annotated with {@code @FacadeController}</li>  
24 - * <li>automatically injected whenever {@code @Inject} is used</li>  
25 - * </ul>  
26 - *  
27 - * @author SERPRO  
28 - * @see Controller  
29 - */  
30 -@Controller  
31 -@Stereotype  
32 -@Inherited  
33 -@Target(TYPE)  
34 -@Retention(RUNTIME)  
35 -public @interface RestController {  
36 -}  
core/src/main/resources/demoiselle.properties
@@ -1,5 +0,0 @@ @@ -1,5 +0,0 @@
1 -# Enables JPA transaction strategy, automatically detected if demoiselle-jpa component is detected. Use only if you need to overwrite the default behaviour  
2 -#frameworkdemoiselle.transaction.class=br.gov.frameworkdemoiselle.transaction.JPATransaction  
3 -  
4 -# Enables JTA transaction strategy, automatically detected if demoiselle-jta component is detected. Use only if you need to overwrite the default behaviour  
5 -#frameworkdemoiselle.transaction.class=br.gov.frameworkdemoiselle.transaction.JTATransaction  
core/src/main/resources/messages.properties
@@ -1,81 +0,0 @@ @@ -1,81 +0,0 @@
1 -  
2 -version=${project.version}  
3 -engine-on=Iniciando o Demoiselle Framework ${project.version} (Neo)  
4 -resource-not-found=Arquivo {0} n\u00e3o foi encontrado  
5 -key-not-found=A chave {0} n\u00e3o foi encontrada  
6 -ambiguous-strategy-resolution=Foi detectada ambiguidade da interface {0} com as seguintes implementa\u00e7\u00f5es\: {1}. Para resolver o conflito, defina explicitamente a implementa\u00e7\u00e3o no demoiselle.properties.  
7 -ambiguous-bean-resolution=Falha ao obter {0} pois foi detectada ambiguidade nas seguintes implementa\u00e7\u00f5es\: {1}  
8 -bean-not-found=Voc\u00ea est\u00e1 tentando obter um objeto n\u00e3o reconhecido pelo CDI via Beans.getReference({0})  
9 -store-not-found=O objeto do tipo [{0}] n\u00e3o pode ser armazenado no escopo indicado\: {1}  
10 -more-than-one-exceptionhandler-defined-for-same-class=Foi definido mais de um m\u00e9todo na classe {0} para tratar a exce\u00e7\u00e3o {1}  
11 -handling-exception=Tratando a exce\u00e7\u00e3o {0}  
12 -taking-off=O Demoiselle ${project.version} decolou  
13 -engine-off=Desligando os motores do Demoiselle ${project.version}  
14 -setting-up-bean-manager=BeanManager dispon\u00edvel atrav\u00e9s do utilit\u00e1rio {0}  
15 -  
16 -user-transaction-lookup-fail=N\u00e3o foi encontrada nenhuma transa\u00e7\u00e3o com o nome {0} no contexto JNDI  
17 -transactional-execution=Execu\u00e7\u00e3o transacional de {0}  
18 -begin-transaction=Transa\u00e7\u00e3o iniciada  
19 -transaction-marked-rollback=Transa\u00e7\u00e3o marcada para rollback [{0}]  
20 -transaction-already-finalized=A transa\u00e7\u00e3o j\u00e1 havia sido finalizada  
21 -transaction-commited=Transa\u00e7\u00e3o finalizada com sucesso  
22 -transaction-rolledback=Transa\u00e7\u00e3o finalizada com rollback  
23 -  
24 -bootstrap.configuration.processing=Processando {0}  
25 -bootstrap-context-already-managed=O contexto {0} para o escopo {1} j\u00e1 foi adicionado  
26 -bootstrap-context-added=Adicionando o contexto {0} para o escopo {1}  
27 -  
28 -loading-configuration-class=Carregando a classe de configura\u00e7\u00e3o {0}  
29 -configuration-field-loaded={0}: {2}  
30 -configuration-attribute-is-mandatory=A configura\u00e7\u00e3o {0} \u00e9 obrigat\u00f3ria, mas n\u00e3o foi encontrada em {1}  
31 -configuration-name-attribute-cant-be-empty=A nota\u00e7\u00e3o @Name n\u00e3o pode estar em branco  
32 -configuration-generic-extraction-error=Ocorreu um erro durante a extra\u00e7\u00e3o do tipo {0} com o extrator {1}  
33 -configuration-dot-after-prefix=N\u00e3o \u00e9 necess\u00e1rio adicionar o ponto ap\u00f3s o prefixo para uma classe de configura\u00e7\u00e3o. \u00c9 recomendado que sejam retirados, pois poder\u00e3o causar erros em vers\u00f5es futuras do Framework.  
34 -configuration-key-not-found={0}\: [n\u00e3o encontrada]  
35 -configuration-extractor-not-found=N\u00e3o foi poss\u00edvel encontrar a classe extratora para o atributo {0}. Implemente a interface {1} para criar sua classe extratora.  
36 -configuration-not-conversion=N\u00e3o \u00e9 poss\u00edvel converter o valor {0} para o tipo {1}  
37 -  
38 -transaction-not-defined=Nenhuma transa\u00e7\u00e3o foi definida. Para utilizar @{0} \u00e9 preciso definir a propriedade frameworkdemoiselle.transaction.class com a estrat\u00e9gia de transa\u00e7\u00e3o desejada no arquivo demoiselle.properties  
39 -executing-all=Executando m\u00e9todos anotados com @{0}  
40 -custom-context-selected=Produzindo inst\u00e2ncia do contexto {0}  
41 -custom-context-was-activated=O contexto {0} foi ativado para o escopo {1}  
42 -custom-context-was-deactivated=O contexto {0} foi desativado para o escopo {1}  
43 -custom-context-already-activated=N\u00e3o foi poss\u00edvel ativar o contexto {0}, o escopo {1} j\u00e1 est\u00e1 ativo no contexto {2}  
44 -custom-context-not-found=N\u00e3o foi encontrado um contexto gerenciado do tipo [{0}] para o escopo [{1}]  
45 -custom-context-manager-not-initialized=ContextManager n\u00e3o foi inicializado. Chame [initialize] ao capturar o evento [AfterBeanDiscovery] em uma extens\u00e3o CDI  
46 -  
47 -error-creating-new-instance-for=Error creating a new instance for "{0}"  
48 -executed-successfully={0} execultado com sucesso  
49 -must-declare-one-single-parameter=Voc\u00ea deve declarar um par\u00e2metro \u00fanico em {0}  
50 -loading-default-transaction-manager=Carregando o gerenciador de transa\u00e7\u00e3o padr\u00e3o {0}  
51 -results-count-greater-page-size=Quantidade de resultados {0} \u00e9 maior que o tamanho da p\u00e1gina {1}  
52 -page-result=Resultado paginado [p\u00e1gina\={0}, total de resultados\={1}]  
53 -pagination-not-initialized=Pagina\u00e7\u00e3o n\u00e3o inicializada. Inicialize o sistema de pagina\u00e7\u00e3o definindo a p\u00e1gina atual ou o total de resultados ao menos uma vez na requisi\u00e7\u00e3o.  
54 -pagination-invalid-value=Valor inv\u00e1lido para paginador: [{0}].  
55 -page=P\u00e1gina [n\u00famero\={0}, tamanho\={1}]  
56 -processing=Processando\: {0}  
57 -processing-fail=Falha no processamento devido a uma exce\u00e7\u00e3o lan\u00e7ada pela aplica\u00e7\u00e3o  
58 -for= \ para\:  
59 -file-not-found=O arquivo {0} n\u00e3o foi encontrado  
60 -  
61 -management-notification-attribute-changed=O atributo [{0}] da classe gerenciada [{1}] foi alterado  
62 -management-null-class-defined=O controlador de gerenciamento informado n\u00e3o pode ser [null]  
63 -management-abstract-class-defined=O controlador de gerenciamento [{0}] precisa ser uma classe concreta  
64 -management-no-annotation-found=Classe {0} precisa ser anotada com @ManagementController  
65 -management-invalid-property-no-getter-setter=Falha ao inicializar classe gerenciada {0}, n\u00e3o foi encontrado um m\u00e9todo get ou m\u00e9todo set para a propriedade {1}  
66 -management-invalid-property-as-operation=Falha ao inicializar classe gerenciada {0}, n\u00e3o \u00e9 poss\u00edvel declarar uma propriedade cujo m\u00e9todo get ou set \u00e9 uma opera\u00e7\u00e3o  
67 -management-introspection-error=Erro ao ler atributos da classe gerenciada {0}  
68 -management-type-not-found=A classe gerenciada informada n\u00e3o existe\: {0}  
69 -management-invoke-error=Erro ao tentar invocar a opera\u00e7\u00e3o "{0}" da classe gerenciada, a opera\u00e7\u00e3o n\u00e3o foi encontrada  
70 -management-write-value-error=N\u00e3o foi poss\u00edvel definir um valor para a propriedade {0}  
71 -management-read-value-error=N\u00e3o foi poss\u00edvel ler o valor da propriedade {0}  
72 -management-debug-acessing-property=Acessando propriedade {0} da classe gerenciada {1}  
73 -management-debug-setting-property=Definindo novo valor para propriedade {0} da classe gerenciada {1}  
74 -management-debug-invoking-operation=Invocando opera\u00e7\u00e3o {0} da classe gerenciada {1}  
75 -management-debug-starting-custom-context=Levantando contexto {0} para executar comando na classe gerenciada {1}  
76 -management-debug-stoping-custom-context=Desligando contexto {0} para classe gerenciada {1}  
77 -management-debug-registering-managed-type=Registrando classe gerenciada [{0}]  
78 -management-debug-processing-management-extension=Processando extens\u00e3o de gerenciamento [{0}]  
79 -management-debug-removing-management-extension=Desativando extens\u00e3o de gerenciamento [{0}]  
80 -management-validation-constraint-violation=Ocorreu um erro de valida\u00e7\u00e3o na classe [{0}] ao definir um valor para a propriedade [{1}]\: [{2}]  
81 -management-validation-validator-not-found=Nenhum provedor de valida\u00e7\u00e3o de beans encontrado, as anota\u00e7\u00f5es de valida\u00e7\u00e3o n\u00e3o ser\u00e3o processadas  
demoiselle-core/.gitignore 0 → 100644
@@ -0,0 +1,5 @@ @@ -0,0 +1,5 @@
  1 +.settings
  2 +.classpath
  3 +.project
  4 +/bin/
  5 +/target/
demoiselle-core/pom.xml 0 → 100644
@@ -0,0 +1,49 @@ @@ -0,0 +1,49 @@
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  4 + <modelVersion>4.0.0</modelVersion>
  5 + <groupId>org.demoiselle.jee</groupId>
  6 + <artifactId>demoiselle-core</artifactId>
  7 + <version>3.0.0-SNAPSHOT</version>
  8 + <packaging>jar</packaging>
  9 +
  10 + <name>Demoiselle Core</name>
  11 + <description>
  12 + Contém funcionalidades comuns a todos os módulos framework.
  13 + </description>
  14 +
  15 + <url>http://demoiselle.org</url>
  16 +
  17 +
  18 + <properties>
  19 + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  20 + <maven.compiler.source>1.8</maven.compiler.source>
  21 + <maven.compiler.target>1.8</maven.compiler.target>
  22 + </properties>
  23 + <dependencies>
  24 + <dependency>
  25 + <groupId>javax</groupId>
  26 + <artifactId>javaee-web-api</artifactId>
  27 + <version>7.0</version>
  28 + </dependency>
  29 + <dependency>
  30 + <groupId>javax.enterprise</groupId>
  31 + <artifactId>cdi-api</artifactId>
  32 + <version>1.2</version>
  33 + </dependency>
  34 +
  35 + <!-- Configuration/Messages -->
  36 + <dependency>
  37 + <groupId>org.apache.deltaspike.core</groupId>
  38 + <artifactId>deltaspike-core-api</artifactId>
  39 + <scope>compile</scope>
  40 + <version>1.7.1</version>
  41 + </dependency>
  42 + <dependency>
  43 + <groupId>org.apache.deltaspike.core</groupId>
  44 + <artifactId>deltaspike-core-impl</artifactId>
  45 + <scope>runtime</scope>
  46 + <version>1.7.1</version>
  47 + </dependency>
  48 + </dependencies>
  49 +</project>
demoiselle-core/src/main/java/org/demoiselle/jee/core/annotation/Ignore.java 0 → 100644
@@ -0,0 +1,56 @@ @@ -0,0 +1,56 @@
  1 +/*
  2 + * Demoiselle Framework
  3 + * Copyright (C) 2010 SERPRO
  4 + * ----------------------------------------------------------------------------
  5 + * This file is part of Demoiselle Framework.
  6 + *
  7 + * Demoiselle Framework is free software; you can redistribute it and/or
  8 + * modify it under the terms of the GNU Lesser General Public License version 3
  9 + * as published by the Free Software Foundation.
  10 + *
  11 + * This program is distributed in the hope that it will be useful,
  12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14 + * GNU General Public License for more details.
  15 + *
  16 + * You should have received a copy of the GNU Lesser General Public License version 3
  17 + * along with this program; if not, see <http://www.gnu.org/licenses/>
  18 + * or write to the Free Software Foundation, Inc., 51 Franklin Street,
  19 + * Fifth Floor, Boston, MA 02110-1301, USA.
  20 + * ----------------------------------------------------------------------------
  21 + * Este arquivo é parte do Framework Demoiselle.
  22 + *
  23 + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou
  24 + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação
  25 + * do Software Livre (FSF).
  26 + *
  27 + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA
  28 + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou
  29 + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português
  30 + * para maiores detalhes.
  31 + *
  32 + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título
  33 + * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>
  34 + * ou escreva para a Fundação do Software Livre (FSF) Inc.,
  35 + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
  36 + */
  37 +package org.demoiselle.jee.core.annotation;
  38 +
  39 +import static java.lang.annotation.ElementType.FIELD;
  40 +import static java.lang.annotation.RetentionPolicy.RUNTIME;
  41 +
  42 +import java.lang.annotation.Retention;
  43 +import java.lang.annotation.Target;
  44 +
  45 +/**
  46 + * <p>Used in fields of classes annotated with {@link org.demoiselle.configuration.Configuration}
  47 + * to indicate that the system should ignore this field when population the new configuration
  48 + * instance with values extracted from the source file.</p>
  49 + *
  50 + * @see org.demoiselle.configuration.Configuration
  51 + * @author SERPRO
  52 + */
  53 +@Target(FIELD)
  54 +@Retention(RUNTIME)
  55 +public @interface Ignore {
  56 +}
demoiselle-core/src/main/java/org/demoiselle/jee/core/annotation/Name.java 0 → 100644
@@ -0,0 +1,98 @@ @@ -0,0 +1,98 @@
  1 +/*
  2 + * Demoiselle Framework
  3 + * Copyright (C) 2010 SERPRO
  4 + * ----------------------------------------------------------------------------
  5 + * This file is part of Demoiselle Framework.
  6 + *
  7 + * Demoiselle Framework is free software; you can redistribute it and/or
  8 + * modify it under the terms of the GNU Lesser General Public License version 3
  9 + * as published by the Free Software Foundation.
  10 + *
  11 + * This program is distributed in the hope that it will be useful,
  12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14 + * GNU General Public License for more details.
  15 + *
  16 + * You should have received a copy of the GNU Lesser General Public License version 3
  17 + * along with this program; if not, see <http://www.gnu.org/licenses/>
  18 + * or write to the Free Software Foundation, Inc., 51 Franklin Street,
  19 + * Fifth Floor, Boston, MA 02110-1301, USA.
  20 + * ----------------------------------------------------------------------------
  21 + * Este arquivo é parte do Framework Demoiselle.
  22 + *
  23 + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou
  24 + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação
  25 + * do Software Livre (FSF).
  26 + *
  27 + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA
  28 + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou
  29 + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português
  30 + * para maiores detalhes.
  31 + *
  32 + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título
  33 + * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>
  34 + * ou escreva para a Fundação do Software Livre (FSF) Inc.,
  35 + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
  36 + */
  37 +package org.demoiselle.jee.core.annotation;
  38 +
  39 +import javax.enterprise.inject.spi.InjectionPoint;
  40 +import javax.enterprise.util.Nonbinding;
  41 +import javax.inject.Named;
  42 +import javax.inject.Qualifier;
  43 +import java.lang.annotation.Inherited;
  44 +import java.lang.annotation.Retention;
  45 +import java.lang.annotation.Target;
  46 +
  47 +import static java.lang.annotation.ElementType.*;
  48 +import static java.lang.annotation.RetentionPolicy.RUNTIME;
  49 +
  50 +/**
  51 + * <p>
  52 + * String based non-binding qualifier.
  53 + * </p>
  54 + *
  55 + * <p>
  56 + * This annotation is used to qualify beans using an user defined String. {@link javax.enterprise.inject.Produces}
  57 + * methods can then read this string and use it to customize the bean creation process.
  58 + * </p>
  59 + *
  60 + * <p>
  61 + * The {@link #value()} attribute is non-binding (contrary to {@link Named#value()}, meaning multiple classes
  62 + * qualified with this annotation, even with different values, will be considered the same candidate for
  63 + * injection points. To avoid ambiguous resolutions and select which candidate to choose usually you'll need a
  64 + * producer method to read the string and select the best fitted candidate.
  65 + * </p>
  66 + *
  67 + * <p>
  68 + * The framework classes qualified with this annotation already have such producers and the accepted values for
  69 + * this annotation will be detailed in their respective documentations.
  70 + * </p>
  71 + *
  72 + *
  73 + * @author SERPRO
  74 + *
  75 + * @see org.demoiselle.util.ResourceBundle
  76 + * @see org.demoiselle.internal.producer.ResourceBundleProducer#create(InjectionPoint)
  77 + * @see org.demoiselle.internal.producer.LoggerProducer#createNamed(InjectionPoint)
  78 + */
  79 +@Qualifier
  80 +@Inherited
  81 +@Retention(RUNTIME)
  82 +@Target({ TYPE, FIELD, METHOD, PARAMETER })
  83 +public @interface Name {
  84 +
  85 + /**
  86 + * <p>
  87 + * Specifies a name to access a custom configuration that will change how the annotated bean works.
  88 + * </p>
  89 + * <p>
  90 + * This attribute is nonbinding so you can use the {@link Name} annotation to create {@linkplain javax.enterprise.inject.Produces}
  91 + * methods or fields and have only one producer that works with all injection points no matter the value of this attribute.
  92 + * </p>
  93 + * @return Name of custom settings to personalize how the annotated bean works.
  94 + */
  95 + @Nonbinding
  96 + String value() default "";
  97 +
  98 +}
demoiselle-core/src/main/java/org/demoiselle/jee/core/annotation/Priority.java 0 → 100644
@@ -0,0 +1,96 @@ @@ -0,0 +1,96 @@
  1 +/*
  2 + * Demoiselle Framework
  3 + * Copyright (C) 2010 SERPRO
  4 + * ----------------------------------------------------------------------------
  5 + * This file is part of Demoiselle Framework.
  6 + *
  7 + * Demoiselle Framework is free software; you can redistribute it and/or
  8 + * modify it under the terms of the GNU Lesser General Public License version 3
  9 + * as published by the Free Software Foundation.
  10 + *
  11 + * This program is distributed in the hope that it will be useful,
  12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14 + * GNU General Public License for more details.
  15 + *
  16 + * You should have received a copy of the GNU Lesser General Public License version 3
  17 + * along with this program; if not, see <http://www.gnu.org/licenses/>
  18 + * or write to the Free Software Foundation, Inc., 51 Franklin Street,
  19 + * Fifth Floor, Boston, MA 02110-1301, USA.
  20 + * ----------------------------------------------------------------------------
  21 + * Este arquivo é parte do Framework Demoiselle.
  22 + *
  23 + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou
  24 + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação
  25 + * do Software Livre (FSF).
  26 + *
  27 + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA
  28 + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou
  29 + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português
  30 + * para maiores detalhes.
  31 + *
  32 + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título
  33 + * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>
  34 + * ou escreva para a Fundação do Software Livre (FSF) Inc.,
  35 + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
  36 + */
  37 +package org.demoiselle.jee.core.annotation;
  38 +
  39 +import java.lang.annotation.Retention;
  40 +import java.lang.annotation.Target;
  41 +
  42 +import static java.lang.annotation.ElementType.METHOD;
  43 +import static java.lang.annotation.ElementType.TYPE;
  44 +import static java.lang.annotation.RetentionPolicy.RUNTIME;
  45 +
  46 +/**
  47 + * <p>
  48 + * Used to prioritize some execution flow, as methods annotated with @startup or @shutdown,
  49 + * or some interface implementation.
  50 + * </p>
  51 + *
  52 + * @author SERPRO
  53 + */
  54 +@Target({ TYPE, METHOD })
  55 +@Retention(RUNTIME)
  56 +public @interface Priority {
  57 +
  58 + /**
  59 + * Most important priority value.
  60 + */
  61 + static int MAX_PRIORITY = Integer.MIN_VALUE;
  62 +
  63 + /**
  64 + * Less important priority value.
  65 + */
  66 + static int MIN_PRIORITY = Integer.MAX_VALUE;
  67 +
  68 + /**
  69 + * Less important priority value.
  70 + */
  71 + static int L1_PRIORITY = MIN_PRIORITY;
  72 +
  73 + /**
  74 + * Higher priority than L1_PRIORITY
  75 + */
  76 + static int L2_PRIORITY = L1_PRIORITY - 100;
  77 +
  78 + /**
  79 + * Higher priority than L2_PRIORITY
  80 + */
  81 + static int L3_PRIORITY = L2_PRIORITY - 100;
  82 +
  83 + /**
  84 + * Higher priority than L3_PRIORITY
  85 + */
  86 + static int L4_PRIORITY = L3_PRIORITY - 100;
  87 +
  88 + /**
  89 + * <p>
  90 + * An integer value defines the priority order. The lower the value, the greater priority.
  91 + * <p>
  92 + *
  93 + * @return Priority value, lower values have higher priority.
  94 + */
  95 + int value();
  96 +}
demoiselle-core/src/main/java/org/demoiselle/jee/core/annotation/Strategy.java 0 → 100644
@@ -0,0 +1,83 @@ @@ -0,0 +1,83 @@
  1 +/*
  2 + * Demoiselle Framework
  3 + * Copyright (C) 2010 SERPRO
  4 + * ----------------------------------------------------------------------------
  5 + * This file is part of Demoiselle Framework.
  6 + *
  7 + * Demoiselle Framework is free software; you can redistribute it and/or
  8 + * modify it under the terms of the GNU Lesser General Public License version 3
  9 + * as published by the Free Software Foundation.
  10 + *
  11 + * This program is distributed in the hope that it will be useful,
  12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14 + * GNU General Public License for more details.
  15 + *
  16 + * You should have received a copy of the GNU Lesser General Public License version 3
  17 + * along with this program; if not, see <http://www.gnu.org/licenses/>
  18 + * or write to the Free Software Foundation, Inc., 51 Franklin Street,
  19 + * Fifth Floor, Boston, MA 02110-1301, USA.
  20 + * ----------------------------------------------------------------------------
  21 + * Este arquivo é parte do Framework Demoiselle.
  22 + *
  23 + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou
  24 + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação
  25 + * do Software Livre (FSF).
  26 + *
  27 + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA
  28 + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou
  29 + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português
  30 + * para maiores detalhes.
  31 + *
  32 + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título
  33 + * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>
  34 + * ou escreva para a Fundação do Software Livre (FSF) Inc.,
  35 + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
  36 + */
  37 +package org.demoiselle.jee.core.annotation;
  38 +import static java.lang.annotation.ElementType.FIELD;
  39 +import static java.lang.annotation.ElementType.METHOD;
  40 +import static java.lang.annotation.ElementType.PARAMETER;
  41 +import static java.lang.annotation.ElementType.TYPE;
  42 +import static java.lang.annotation.RetentionPolicy.RUNTIME;
  43 +
  44 +import java.lang.annotation.Inherited;
  45 +import java.lang.annotation.Retention;
  46 +import java.lang.annotation.Target;
  47 +
  48 +import javax.inject.Qualifier;
  49 +
  50 +/**
  51 + *
  52 + * <p>
  53 + * This literal marks a bean to be selected at runtime based on a priority system.
  54 + * The user qualifies the injection point with this literal and then at runtime
  55 + * the CDI engine will circle through all candidate subtypes to be injected
  56 + * that are annotated with {@link Priority}. If there is only one subtype with the
  57 + * highest priority then this one will be selected to be injected.
  58 + * </p>
  59 + *
  60 + * <p>
  61 + * This allows users to plug in libraries with new candidates and have them be selected
  62 + * if their priority values are higher than the default values already present. One example
  63 + * is the {@link org.demoiselle.security.Authorizer} type, the framework has a {@link org.demoiselle.internal.implementation.DefaultAuthorizer}
  64 + * with {@link Priority#L1_PRIORITY the lowest priority} but the user can add libraries with new
  65 + * implementations of {@link org.demoiselle.security.Authorizer} annotated with higher priorities, the code will
  66 + * then automatically select these new implementations with no extra configuration.
  67 + * </p>
  68 + *
  69 + * <p>
  70 + * This annotation must be used with supported types. Usually this involves creating {@link javax.enterprise.inject.Produces} CDI
  71 + * producer methods that will select the correct strategy. To create your own producer
  72 + * methods that support strategy selection, use the utility {@linkplain org.demoiselle.internal.producer.StrategySelector}.
  73 + * </p>
  74 + *
  75 + * @author SERPRO
  76 + */
  77 +@Qualifier
  78 +@Inherited
  79 +@Retention(RUNTIME)
  80 +@Target({ TYPE, FIELD, METHOD, PARAMETER })
  81 +public @interface Strategy {
  82 +
  83 +}
demoiselle-core/src/main/java/org/demoiselle/jee/core/annotation/Type.java 0 → 100644
@@ -0,0 +1,60 @@ @@ -0,0 +1,60 @@
  1 +/*
  2 + * Demoiselle Framework
  3 + *
  4 + * License: GNU Lesser General Public License (LGPL), version 3 or later.
  5 + * See the lgpl.txt file in the root directory or <https://www.gnu.org/licenses/lgpl.html>.
  6 + */
  7 +package org.demoiselle.jee.core.annotation;
  8 +
  9 +import static java.lang.annotation.ElementType.FIELD;
  10 +import static java.lang.annotation.ElementType.METHOD;
  11 +import static java.lang.annotation.ElementType.PARAMETER;
  12 +import static java.lang.annotation.ElementType.TYPE;
  13 +import static java.lang.annotation.RetentionPolicy.RUNTIME;
  14 +
  15 +import java.lang.annotation.Inherited;
  16 +import java.lang.annotation.Retention;
  17 +import java.lang.annotation.Target;
  18 +
  19 +import javax.enterprise.util.Nonbinding;
  20 +import javax.inject.Qualifier;
  21 +
  22 +/**
  23 + * <p>
  24 + * Type based non-binding qualifier.
  25 + * </p>
  26 + *
  27 + * <p>
  28 + * This annotation is used to qualify beans using a class type.
  29 + * {@link javax.enterprise.inject.Produces} methods can then read this type and
  30 + * use it to customize the bean creation process.
  31 + * </p>
  32 + *
  33 + * <p>
  34 + * The {@link #value()} attribute is non-binding, meaning multiple classes
  35 + * qualified with this annotation, even with different values, will be
  36 + * considered the same candidate for injection points. To avoid ambiguous
  37 + * resolutions and select which candidate to choose usually you'll need a
  38 + * producer method to read the type and select the best fitted candidate.
  39 + * </p>
  40 + *
  41 + * <p>
  42 + * The framework classes qualified with this annotation already have such
  43 + * producers and the accepted values for this annotation will be detailed in
  44 + * their respective documentations.
  45 + * </p>
  46 + *
  47 + *
  48 + * @author SERPRO
  49 + *
  50 + */
  51 +@Qualifier
  52 +@Inherited
  53 +@Retention(RUNTIME)
  54 +@Target({ TYPE, FIELD, METHOD, PARAMETER })
  55 +public @interface Type {
  56 +
  57 + @Nonbinding
  58 + Class<?> value() default Object.class;
  59 +
  60 +}
demoiselle-core/src/main/java/org/demoiselle/jee/core/annotation/literal/NameQualifier.java 0 → 100644
@@ -0,0 +1,70 @@ @@ -0,0 +1,70 @@
  1 +/*
  2 + * Demoiselle Framework
  3 + * Copyright (C) 2010 SERPRO
  4 + * ----------------------------------------------------------------------------
  5 + * This file is part of Demoiselle Framework.
  6 + *
  7 + * Demoiselle Framework is free software; you can redistribute it and/or
  8 + * modify it under the terms of the GNU Lesser General Public License version 3
  9 + * as published by the Free Software Foundation.
  10 + *
  11 + * This program is distributed in the hope that it will be useful,
  12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14 + * GNU General Public License for more details.
  15 + *
  16 + * You should have received a copy of the GNU Lesser General Public License version 3
  17 + * along with this program; if not, see <http://www.gnu.org/licenses/>
  18 + * or write to the Free Software Foundation, Inc., 51 Franklin Street,
  19 + * Fifth Floor, Boston, MA 02110-1301, USA.
  20 + * ----------------------------------------------------------------------------
  21 + * Este arquivo é parte do Framework Demoiselle.
  22 + *
  23 + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou
  24 + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação
  25 + * do Software Livre (FSF).
  26 + *
  27 + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA
  28 + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou
  29 + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português
  30 + * para maiores detalhes.
  31 + *
  32 + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título
  33 + * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>
  34 + * ou escreva para a Fundação do Software Livre (FSF) Inc.,
  35 + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
  36 + */
  37 +package org.demoiselle.jee.core.annotation.literal;
  38 +
  39 +import org.demoiselle.jee.core.annotation.Name;
  40 +
  41 +import javax.enterprise.util.AnnotationLiteral;
  42 +
  43 +/**
  44 + * Annotation litteral that allows to create instances of the {@link Name} literal. The created instance can then be
  45 + * used to call {@link javax.enterprise.inject.spi.CDI#select(Class subtype, java.lang.annotation.Annotation... qualifiers)}
  46 + *
  47 + * @author SERPRO
  48 + * @see javax.enterprise.inject.spi.CDI
  49 + */
  50 +@SuppressWarnings("all")
  51 +public class NameQualifier extends AnnotationLiteral<Name> implements Name {
  52 +
  53 + private static final long serialVersionUID = 1L;
  54 +
  55 + private final String value;
  56 +
  57 + /**
  58 + * Constructor with string value of name literal.
  59 + *
  60 + * @param value value of name literal.
  61 + */
  62 + public NameQualifier(String value) {
  63 + this.value = value;
  64 + }
  65 +
  66 + @Override
  67 + public String value() {
  68 + return this.value;
  69 + }
  70 +}
demoiselle-core/src/main/java/org/demoiselle/jee/core/annotation/literal/NamedQualifier.java 0 → 100644
@@ -0,0 +1,67 @@ @@ -0,0 +1,67 @@
  1 +/*
  2 + * Demoiselle Framework
  3 + * Copyright (C) 2010 SERPRO
  4 + * ----------------------------------------------------------------------------
  5 + * This file is part of Demoiselle Framework.
  6 + *
  7 + * Demoiselle Framework is free software; you can redistribute it and/or
  8 + * modify it under the terms of the GNU Lesser General Public License version 3
  9 + * as published by the Free Software Foundation.
  10 + *
  11 + * This program is distributed in the hope that it will be useful,
  12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14 + * GNU General Public License for more details.
  15 + *
  16 + * You should have received a copy of the GNU Lesser General Public License version 3
  17 + * along with this program; if not, see <http://www.gnu.org/licenses/>
  18 + * or write to the Free Software Foundation, Inc., 51 Franklin Street,
  19 + * Fifth Floor, Boston, MA 02110-1301, USA.
  20 + * ----------------------------------------------------------------------------
  21 + * Este arquivo é parte do Framework Demoiselle.
  22 + *
  23 + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou
  24 + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação
  25 + * do Software Livre (FSF).
  26 + *
  27 + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA
  28 + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou
  29 + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português
  30 + * para maiores detalhes.
  31 + *
  32 + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título
  33 + * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>
  34 + * ou escreva para a Fundação do Software Livre (FSF) Inc.,
  35 + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
  36 + */
  37 +package org.demoiselle.jee.core.annotation.literal;
  38 +
  39 +import javax.enterprise.util.AnnotationLiteral;
  40 +import javax.inject.Named;
  41 +import java.lang.annotation.Annotation;
  42 +
  43 +/**
  44 + * Annotation litteral that allows to create instances of the {@link Named} literal.
  45 + * Those instances can then be used to call
  46 + * {@link javax.enterprise.inject.spi.CDI#select(Class subtype, Annotation... qualifiers)}
  47 + *
  48 + * @see javax.enterprise.inject.spi.CDI
  49 + * @see Named
  50 + *
  51 + * @author SERPRO
  52 + */
  53 +@SuppressWarnings("all")
  54 +public class NamedQualifier extends AnnotationLiteral<Named> implements Named {
  55 +
  56 + private static final long serialVersionUID = 6790759427086052113L;
  57 +
  58 + private String namedValue;
  59 +
  60 + public NamedQualifier(String value) {
  61 + namedValue = value;
  62 + }
  63 +
  64 + public String value() {
  65 + return namedValue;
  66 + }
  67 +}
demoiselle-core/src/main/java/org/demoiselle/jee/core/annotation/literal/StrategyQualifier.java 0 → 100644
@@ -0,0 +1,53 @@ @@ -0,0 +1,53 @@
  1 +/*
  2 + * Demoiselle Framework
  3 + * Copyright (C) 2010 SERPRO
  4 + * ----------------------------------------------------------------------------
  5 + * This file is part of Demoiselle Framework.
  6 + *
  7 + * Demoiselle Framework is free software; you can redistribute it and/or
  8 + * modify it under the terms of the GNU Lesser General Public License version 3
  9 + * as published by the Free Software Foundation.
  10 + *
  11 + * This program is distributed in the hope that it will be useful,
  12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14 + * GNU General Public License for more details.
  15 + *
  16 + * You should have received a copy of the GNU Lesser General Public License version 3
  17 + * along with this program; if not, see <http://www.gnu.org/licenses/>
  18 + * or write to the Free Software Foundation, Inc., 51 Franklin Street,
  19 + * Fifth Floor, Boston, MA 02110-1301, USA.
  20 + * ----------------------------------------------------------------------------
  21 + * Este arquivo é parte do Framework Demoiselle.
  22 + *
  23 + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou
  24 + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação
  25 + * do Software Livre (FSF).
  26 + *
  27 + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA
  28 + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou
  29 + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português
  30 + * para maiores detalhes.
  31 + *
  32 + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título
  33 + * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>
  34 + * ou escreva para a Fundação do Software Livre (FSF) Inc.,
  35 + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
  36 + */
  37 +package org.demoiselle.jee.core.annotation.literal;
  38 +
  39 +import org.demoiselle.jee.core.annotation.Strategy;
  40 +
  41 +import javax.enterprise.util.AnnotationLiteral;
  42 +
  43 +/**
  44 + * Annotation litteral that allows to create instances of the {@link Strategy} literal. The created instance can then be
  45 + * used to call {@link javax.enterprise.inject.spi.CDI#select(Class subtype, java.lang.annotation.Annotation... qualifiers)}.
  46 + *
  47 + * @see javax.enterprise.inject.spi.CDI
  48 + * @author SERPRO
  49 + */
  50 +@SuppressWarnings("all")
  51 +public class StrategyQualifier extends AnnotationLiteral<Strategy> implements Strategy {
  52 +
  53 +}
demoiselle-core/src/main/java/org/demoiselle/jee/core/annotation/literal/TypeQualifier.java 0 → 100644
@@ -0,0 +1,71 @@ @@ -0,0 +1,71 @@
  1 +/*
  2 + * Demoiselle Framework
  3 + * Copyright (C) 2010 SERPRO
  4 + * ----------------------------------------------------------------------------
  5 + * This file is part of Demoiselle Framework.
  6 + *
  7 + * Demoiselle Framework is free software; you can redistribute it and/or
  8 + * modify it under the terms of the GNU Lesser General Public License version 3
  9 + * as published by the Free Software Foundation.
  10 + *
  11 + * This program is distributed in the hope that it will be useful,
  12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14 + * GNU General Public License for more details.
  15 + *
  16 + * You should have received a copy of the GNU Lesser General Public License version 3
  17 + * along with this program; if not, see <http://www.gnu.org/licenses/>
  18 + * or write to the Free Software Foundation, Inc., 51 Franklin Street,
  19 + * Fifth Floor, Boston, MA 02110-1301, USA.
  20 + * ----------------------------------------------------------------------------
  21 + * Este arquivo é parte do Framework Demoiselle.
  22 + *
  23 + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou
  24 + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação
  25 + * do Software Livre (FSF).
  26 + *
  27 + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA
  28 + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou
  29 + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português
  30 + * para maiores detalhes.
  31 + *
  32 + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título
  33 + * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>
  34 + * ou escreva para a Fundação do Software Livre (FSF) Inc.,
  35 + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
  36 + */
  37 +package org.demoiselle.jee.core.annotation.literal;
  38 +
  39 +import org.demoiselle.jee.core.annotation.Type;
  40 +
  41 +import javax.enterprise.util.AnnotationLiteral;
  42 +
  43 +/**
  44 + * Annotation litteral that allows to create instances of the {@link Type}
  45 + * literal. The created instance can then be used to call
  46 + * {@link javax.enterprise.inject.spi.CDI#select(Class subtype, java.lang.annotation.Annotation... qualifiers)}.
  47 + *
  48 + * @see javax.enterprise.inject.spi.CDI
  49 + * @author SERPRO
  50 + */
  51 +@SuppressWarnings("all")
  52 +public class TypeQualifier extends AnnotationLiteral<Type> implements Type {
  53 +
  54 + private static final long serialVersionUID = 1L;
  55 +
  56 + private final Class<?> value;
  57 +
  58 + /**
  59 + * Constructor with string value of name literal.
  60 + *
  61 + * @param value value of name literal.
  62 + */
  63 + public TypeQualifier(Class<?> value) {
  64 + this.value = value;
  65 + }
  66 +
  67 + @Override
  68 + public Class<?> value() {
  69 + return this.value;
  70 + }
  71 +}
demoiselle-core/src/main/java/org/demoiselle/jee/core/crud/package-info.java 0 → 100644
@@ -0,0 +1,11 @@ @@ -0,0 +1,11 @@
  1 +/*
  2 + * Demoiselle Framework
  3 + *
  4 + * License: GNU Lesser General Public License (LGPL), version 3 or later.
  5 + * See the lgpl.txt file in the root directory or <https://www.gnu.org/licenses/lgpl.html>.
  6 + */
  7 +/**
  8 + * Esta pacote tem o objetivo de conter as classes relacionadas aos
  9 + * facilitadores de CRUD do framework Demoiselle.
  10 + */
  11 +package org.demoiselle.jee.core.crud;
0 \ No newline at end of file 12 \ No newline at end of file
demoiselle-core/src/main/java/org/demoiselle/jee/core/exception/DemoiselleException.java 0 → 100644
@@ -0,0 +1,57 @@ @@ -0,0 +1,57 @@
  1 +/*
  2 + * Demoiselle Framework
  3 + *
  4 + * License: GNU Lesser General Public License (LGPL), version 3 or later.
  5 + * See the lgpl.txt file in the root directory or <https://www.gnu.org/licenses/lgpl.html>.
  6 + */
  7 +package org.demoiselle.jee.core.exception;
  8 +
  9 +/**
  10 + * Exception class intended to be used by framework configuration and to be derived by other framework exceptions.
  11 + *
  12 + * @author SERPRO
  13 + */
  14 +public class DemoiselleException extends RuntimeException {
  15 +
  16 + private static final long serialVersionUID = 1L;
  17 +
  18 + /**
  19 + * Constructor .
  20 + *
  21 + */
  22 + public DemoiselleException() {
  23 +
  24 + }
  25 +
  26 + /**
  27 + * Constructor with message.
  28 + *
  29 + * @param message
  30 + * exception message
  31 + */
  32 + public DemoiselleException(String message) {
  33 + super(message);
  34 + }
  35 +
  36 + /**
  37 + * Constructor with cause.
  38 + *
  39 + * @param cause
  40 + * exception cause
  41 + */
  42 + public DemoiselleException(Throwable cause) {
  43 + super(cause);
  44 + }
  45 +
  46 + /**
  47 + * Constructor with message and cause.
  48 + *
  49 + * @param message
  50 + * exception message
  51 + * @param cause
  52 + * exception cause
  53 + */
  54 + public DemoiselleException(String message, Throwable cause) {
  55 + super(message, cause);
  56 + }
  57 +}
demoiselle-core/src/main/java/org/demoiselle/jee/core/internal/producer/LoggerProducer.java 0 → 100644
@@ -0,0 +1,45 @@ @@ -0,0 +1,45 @@
  1 +/*
  2 + * To change this license header, choose License Headers in Project Properties.
  3 + * To change this template file, choose Tools | Templates
  4 + * and open the template in the editor.
  5 + */
  6 +package org.demoiselle.jee.core.internal.producer;
  7 +
  8 +import java.io.Serializable;
  9 +import java.util.logging.Logger;
  10 +import javax.enterprise.context.Dependent;
  11 +import javax.enterprise.inject.Default;
  12 +import javax.enterprise.inject.Produces;
  13 +import javax.enterprise.inject.spi.InjectionPoint;
  14 +
  15 +/**
  16 + *
  17 + * @author 70744416353
  18 + */
  19 +@Dependent
  20 +public class LoggerProducer implements Serializable {
  21 +
  22 + private static final long serialVersionUID = 1L;
  23 +
  24 + /*
  25 + * Produces a default {@link Logger} instance. If it's possible
  26 + * to infer the injection point's parent class then this class'es
  27 + * name will be used to categorize the logger, if not then
  28 + * the logger won't be categorized.
  29 + *
  30 + */
  31 + @Default
  32 + @Produces
  33 + public static final Logger create(final InjectionPoint ip) {
  34 + String name;
  35 +
  36 + if (ip != null && ip.getMember() != null) {
  37 + name = ip.getMember().getDeclaringClass().getName();
  38 + } else {
  39 + name = "not.categorized";
  40 + }
  41 +
  42 + return Logger.getLogger(name);
  43 + }
  44 +
  45 +}
demoiselle-core/src/main/java/org/demoiselle/jee/core/internal/producer/ResourceBundleProducer.java 0 → 100644
@@ -0,0 +1,75 @@ @@ -0,0 +1,75 @@
  1 +/*
  2 + * To change this license header, choose License Headers in Project Properties.
  3 + * To change this template file, choose Tools | Templates
  4 + * and open the template in the editor.
  5 + */
  6 +package org.demoiselle.jee.core.internal.producer;
  7 +
  8 +import java.io.Serializable;
  9 +import java.util.Locale;
  10 +
  11 +import javax.enterprise.context.Dependent;
  12 +import javax.enterprise.inject.Default;
  13 +import javax.enterprise.inject.Produces;
  14 +import javax.enterprise.inject.spi.CDI;
  15 +import javax.enterprise.inject.spi.InjectionPoint;
  16 +
  17 +import org.demoiselle.jee.core.annotation.Name;
  18 +import org.demoiselle.jee.core.util.CDIUtils;
  19 +import org.demoiselle.jee.core.util.ResourceBundle;
  20 +
  21 +/**
  22 + *
  23 + * @author 70744416353
  24 + */
  25 +@Dependent
  26 +public class ResourceBundleProducer implements Serializable {
  27 +
  28 + private static final long serialVersionUID = 1L;
  29 +
  30 + @Default
  31 + @Produces
  32 + public ResourceBundle createDefault() {
  33 + return create((String) null);
  34 + }
  35 +
  36 + /*
  37 + * Produces a {@link java.util.ResourceBundle} instance loading the properties file whose name
  38 + * is defined by the {@link Name} literal. If no value is specified
  39 + * then the default "messages.properties" file is loaded.
  40 + */
  41 + @Name
  42 + @Produces
  43 + public ResourceBundle create(InjectionPoint ip) {
  44 + String baseName = null;
  45 + if (ip != null && ip.getQualifiers() != null) {
  46 + Name nameQualifier = CDIUtils.getQualifier(Name.class, ip);
  47 + if (nameQualifier != null) {
  48 + baseName = nameQualifier.value();
  49 + if ("".equals(baseName)) {
  50 + baseName = null;
  51 + }
  52 + }
  53 + }
  54 +
  55 + return create(baseName);
  56 + }
  57 +
  58 + @SuppressWarnings("serial")
  59 + public static ResourceBundle create(String baseName) {
  60 + ResourceBundle bundle;
  61 +
  62 + try {
  63 + bundle = baseName != null
  64 + ? new ResourceBundle(baseName, CDI.current().select(Locale.class).get()) {
  65 + }
  66 + : new ResourceBundle("messages", CDI.current().select(Locale.class).get());
  67 + } catch (RuntimeException e) {
  68 + bundle = baseName != null
  69 + ? new ResourceBundle(baseName, Locale.getDefault())
  70 + : new ResourceBundle("messages", Locale.getDefault());
  71 + }
  72 +
  73 + return bundle;
  74 + }
  75 +}
demoiselle-core/src/main/java/org/demoiselle/jee/core/lifecycle/LifecycleAnnotation.java 0 → 100644
@@ -0,0 +1,30 @@ @@ -0,0 +1,30 @@
  1 +/*
  2 + * Demoiselle Framework
  3 + *
  4 + * License: GNU Lesser General Public License (LGPL), version 3 or later.
  5 + * See the lgpl.txt file in the root directory or <https://www.gnu.org/licenses/lgpl.html>.
  6 + */
  7 +package org.demoiselle.jee.core.lifecycle;
  8 +
  9 +import java.lang.annotation.ElementType;
  10 +import java.lang.annotation.Inherited;
  11 +import java.lang.annotation.Retention;
  12 +import java.lang.annotation.Target;
  13 +
  14 +import static java.lang.annotation.RetentionPolicy.RUNTIME;
  15 +
  16 +/**
  17 + * Annotate other annotations with this one to
  18 + * mark them as lifecycle annotations, meaning
  19 + * the lifecycle processor of the framework will
  20 + * read them and fire events based on their represented
  21 + * lifecycle stages.
  22 + *
  23 + * @author SERPRO
  24 + */
  25 +@Inherited
  26 +@Target(ElementType.ANNOTATION_TYPE)
  27 +@Retention(RUNTIME)
  28 +public @interface LifecycleAnnotation {
  29 +
  30 +}
demoiselle-core/src/main/java/org/demoiselle/jee/core/messages/DemoiselleMessages.java 0 → 100644
@@ -0,0 +1,51 @@ @@ -0,0 +1,51 @@
  1 +package org.demoiselle.jee.core.messages;
  2 +
  3 +import org.apache.deltaspike.core.api.message.MessageBundle;
  4 +import org.apache.deltaspike.core.api.message.MessageTemplate;
  5 +
  6 +@MessageBundle
  7 +public interface DemoiselleMessages {
  8 +
  9 + @MessageTemplate("{version}")
  10 + String version();
  11 +
  12 + @MessageTemplate("{engine-on}")
  13 + String engineOn();
  14 +
  15 + @MessageTemplate("{resource-not-found}")
  16 + String resourceNotFound();
  17 +
  18 + @MessageTemplate("{key-not-found}")
  19 + String keyNotFound(String key);
  20 +
  21 + @MessageTemplate("{ambiguous-strategy-resolution}")
  22 + String ambiguousStrategyResolution(String interfaceString, String implementations);
  23 +
  24 + @MessageTemplate("{ambiguous-bean-resolution}")
  25 + String ambiguousBeanResolution(String implementation);
  26 +
  27 + @MessageTemplate("{bean-not-found}")
  28 + String beanNotFound(String bean);
  29 +
  30 + @MessageTemplate("{store-not-found}")
  31 + String storeNotFound(String object, String scope);
  32 +
  33 + @MessageTemplate("{more-than-one-exceptionhandler-defined-for-same-class}")
  34 + String moreThanOneExceptionhandlerDefinedForSameClass(String clazz, String ex);
  35 +
  36 + @MessageTemplate("{handling-exception}")
  37 + String handlingException(String ex);
  38 +
  39 + @MessageTemplate("{taking-off}")
  40 + String takingOff();
  41 +
  42 + @MessageTemplate("{engine-off}")
  43 + String engineOff(String ex);
  44 +
  45 + @MessageTemplate("{setting-up-bean-manager}")
  46 + String settingUpBeanManagerException(String util);
  47 +
  48 + @MessageTemplate("{processing-fail}")
  49 + String processingFail();
  50 +
  51 +}
0 \ No newline at end of file 52 \ No newline at end of file
demoiselle-core/src/main/java/org/demoiselle/jee/core/util/CDIUtils.java 0 → 100644
@@ -0,0 +1,115 @@ @@ -0,0 +1,115 @@
  1 +package org.demoiselle.jee.core.util;
  2 +
  3 +import java.lang.annotation.Annotation;
  4 +import java.util.Collection;
  5 +
  6 +import javax.enterprise.inject.spi.InjectionPoint;
  7 +
  8 +/**
  9 + * Utility class to peform useful operations on CDI discovered beans.
  10 + *
  11 + * @author SERPRO
  12 + */
  13 +public final class CDIUtils {
  14 +
  15 + private static final Annotation[] annotationArrayType = new Annotation[0];
  16 +
  17 + /**
  18 + * Returns <code>true</code> if one annotation of the provided type is present
  19 + * on a list of annotations.
  20 + *
  21 + * @param annotationType Annotation type being looked for.
  22 + * @param allAnnotations List of all annotations where to look for.
  23 + * @return <code>true</code> if the annotation is present on the list
  24 + */
  25 + public static boolean hasAnnotation(Class<? extends Annotation> annotationType, Annotation... allAnnotations) {
  26 + for (Annotation currentAnnotation : allAnnotations) {
  27 + if (currentAnnotation.annotationType().isAssignableFrom(annotationType)) {
  28 + return true;
  29 + }
  30 + }
  31 +
  32 + return false;
  33 + }
  34 +
  35 + /**
  36 + * @param annotationType Type of the annotation being checked
  37 + * @param allAnnotations List of annotations to check for the specific one
  38 + * @see #hasAnnotation(Class, Annotation...)
  39 + * @return <code>true</code> if the annotation is present on the list
  40 + */
  41 + public static boolean hasAnnotation(Class<? extends Annotation> annotationType,
  42 + Collection<Annotation> allAnnotations) {
  43 + return hasAnnotation(annotationType, allAnnotations.toArray(annotationArrayType));
  44 + }
  45 +
  46 + /**
  47 + * Returns <code>true</code> if a base class is annotated with the provided annotation.
  48 + *
  49 + * @param annotationType Annotation type to look for
  50 + * @param baseType Class to check for the informed annotation
  51 + * @see #hasAnnotation(Class, Annotation...)
  52 + * @return <code>true</code> if the annotation is present on the list
  53 + */
  54 + public static boolean hasAnnotation(Class<? extends Annotation> annotationType, Class<?> baseType) {
  55 + return hasAnnotation(annotationType, baseType.getAnnotations());
  56 + }
  57 +
  58 + /**
  59 + * Returns the annotation instance that matches the annotation type provided,
  60 + * or <code>null</code> if no annotation of that type is present.
  61 + *
  62 + * @param annotationType Annotation type being looked for.
  63 + * @param allAnnotations List of all annotations where to look for.
  64 + * @param <T> Type of the specific annotation returned
  65 + * @return The annotation instance found, or <code>null</code> if there is no such annotation present.
  66 + */
  67 + @SuppressWarnings("unchecked")
  68 + public static <T extends Annotation> T getAnnotation(Class<T> annotationType, Annotation... allAnnotations) {
  69 + for (Annotation currentAnnotation : allAnnotations) {
  70 + if (currentAnnotation.annotationType().isAssignableFrom(annotationType)) {
  71 + return (T) currentAnnotation;
  72 + }
  73 + }
  74 +
  75 + return null;
  76 + }
  77 +
  78 + /**
  79 + * @param annotationType Annotation type being looked for.
  80 + * @param allAnnotations List of all annotations where to look for.
  81 + * @param <T> Type of the specific annotation returned
  82 + * @see #getAnnotation(Class, Annotation...)
  83 + * @return The annotation instance found, or <code>null</code> if there is no such annotation present.
  84 + */
  85 + public static <T extends Annotation> T getAnnotation(Class<T> annotationType,
  86 + Collection<Annotation> allAnnotations) {
  87 + return getAnnotation(annotationType, allAnnotations.toArray(annotationArrayType));
  88 + }
  89 +
  90 + /**
  91 + * Returns <code>true</code> if one qualifier of the provided type is present
  92 + * on an injection point.
  93 + *
  94 + * @param qualifierAnnotationType Annotation type being looked for.
  95 + * @param ip Injection point of a bean type.
  96 + * @return <code>true</code> if the annotation is present on the list
  97 + */
  98 + public static boolean hasQualifier(Class<? extends Annotation> qualifierAnnotationType, InjectionPoint ip) {
  99 + return hasAnnotation(qualifierAnnotationType, ip.getQualifiers());
  100 + }
  101 +
  102 + /**
  103 + * Returns the annotation instance that matches the annotation type provided,
  104 + * or <code>null</code> if no annotation of that type is present.
  105 + *
  106 + * @param qualifierAnnotationType Annotation type being looked for.
  107 + * @param ip Injection point of a bean type.
  108 + * @param <T> Type of the specific annotation returned
  109 + * @return The annotation instance found, or <code>null</code> if there is no such annotation present.
  110 + */
  111 + public static <T extends Annotation> T getQualifier(Class<T> qualifierAnnotationType, InjectionPoint ip) {
  112 + return getAnnotation(qualifierAnnotationType, ip.getQualifiers());
  113 + }
  114 +
  115 +}
demoiselle-core/src/main/java/org/demoiselle/jee/core/util/Exceptions.java 0 → 100644
@@ -0,0 +1,67 @@ @@ -0,0 +1,67 @@
  1 +/*
  2 + * Demoiselle Framework
  3 + * Copyright (C) 2010 SERPRO
  4 + * ----------------------------------------------------------------------------
  5 + * This file is part of Demoiselle Framework.
  6 + *
  7 + * Demoiselle Framework is free software; you can redistribute it and/or
  8 + * modify it under the terms of the GNU Lesser General Public License version 3
  9 + * as published by the Free Software Foundation.
  10 + *
  11 + * This program is distributed in the hope that it will be useful,
  12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14 + * GNU General Public License for more details.
  15 + *
  16 + * You should have received a copy of the GNU Lesser General Public License version 3
  17 + * along with this program; if not, see <http://www.gnu.org/licenses/>
  18 + * or write to the Free Software Foundation, Inc., 51 Franklin Street,
  19 + * Fifth Floor, Boston, MA 02110-1301, USA.
  20 + * ----------------------------------------------------------------------------
  21 + * Este arquivo é parte do Framework Demoiselle.
  22 + *
  23 + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou
  24 + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação
  25 + * do Software Livre (FSF).
  26 + *
  27 + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA
  28 + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou
  29 + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português
  30 + * para maiores detalhes.
  31 + *
  32 + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título
  33 + * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>
  34 + * ou escreva para a Fundação do Software Livre (FSF) Inc.,
  35 + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
  36 + */
  37 +package org.demoiselle.jee.core.util;
  38 +
  39 +/**
  40 + *Class that offer tow methods that can help with manipulation of throwable exceptions.
  41 + *
  42 + * @author SERPRO
  43 + */
  44 +public final class Exceptions {
  45 +
  46 + /**
  47 + * Constructor without parameters.
  48 + */
  49 + private Exceptions() {
  50 + }
  51 +
  52 + /**
  53 + * Receives as parameter any kind of Throwable objects, and throws a RuntimeException instead.
  54 + *
  55 + * @param throwable
  56 + * a throwable object.
  57 + *
  58 + * @throws RuntimeException throws this kind of exception every time that is called.
  59 + */
  60 + public static void handleToRuntimeException(final Throwable throwable) throws RuntimeException {
  61 + if (throwable instanceof RuntimeException) {
  62 + throw (RuntimeException) throwable;
  63 + } else {
  64 + throw new RuntimeException(throwable);
  65 + }
  66 + }
  67 +}
demoiselle-core/src/main/java/org/demoiselle/jee/core/util/Reflections.java 0 → 100644
@@ -0,0 +1,367 @@ @@ -0,0 +1,367 @@
  1 +/*
  2 + * Demoiselle Framework
  3 + * Copyright (C) 2010 SERPRO
  4 + * ----------------------------------------------------------------------------
  5 + * This file is part of Demoiselle Framework.
  6 + *
  7 + * Demoiselle Framework is free software; you can redistribute it and/or
  8 + * modify it under the terms of the GNU Lesser General Public License version 3
  9 + * as published by the Free Software Foundation.
  10 + *
  11 + * This program is distributed in the hope that it will be useful,
  12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14 + * GNU General Public License for more details.
  15 + *
  16 + * You should have received a copy of the GNU Lesser General Public License version 3
  17 + * along with this program; if not, see <http://www.gnu.org/licenses/>
  18 + * or write to the Free Software Foundation, Inc., 51 Franklin Street,
  19 + * Fifth Floor, Boston, MA 02110-1301, USA.
  20 + * ----------------------------------------------------------------------------
  21 + * Este arquivo é parte do Framework Demoiselle.
  22 + *
  23 + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou
  24 + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação
  25 + * do Software Livre (FSF).
  26 + *
  27 + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA
  28 + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou
  29 + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português
  30 + * para maiores detalhes.
  31 + *
  32 + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título
  33 + * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>
  34 + * ou escreva para a Fundação do Software Livre (FSF) Inc.,
  35 + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
  36 + */
  37 +package org.demoiselle.jee.core.util;
  38 +
  39 +import java.io.InputStream;
  40 +import java.lang.reflect.*;
  41 +import java.net.URL;
  42 +import java.util.ArrayList;
  43 +import java.util.Arrays;
  44 +import java.util.List;
  45 +
  46 +/**
  47 + * Provides some features to do some operations relating to java reflection.
  48 + *
  49 + * @author SERPRO
  50 + */
  51 +public class Reflections {
  52 +
  53 + protected Reflections() {
  54 + // Impede instanciar subclasses desse tipo.
  55 + throw new UnsupportedOperationException();
  56 + }
  57 +
  58 + /**
  59 + * Return the parametized type used with a concrete implementation of a class that accepts generics. Ex: If you
  60 + * declare
  61 + * <pre>
  62 + * public class SpecializedCollection implements Collection&#60;SpecializedType&#62; {
  63 + * // ...
  64 + * }
  65 + * </pre>
  66 + * then the code <code>getGenericTypeArgument(SpecializedCollection.class , 0);</code> will return the type
  67 + * <code>SpecializedType</code>.
  68 + *
  69 + * @param type Base type to check for generic arguments
  70 + * @param idx zero based index of the generic argument to get
  71 + * @param <T> Type of the generic argument
  72 + * @return The class representing the type of the generic argument
  73 + */
  74 + @SuppressWarnings("unchecked")
  75 + public static <T> Class<T> getGenericTypeArgument(final Type type, final int idx) {
  76 + ParameterizedType paramType;
  77 + try {
  78 + paramType = (ParameterizedType) type;
  79 + } catch (ClassCastException cause) {
  80 + return getGenericTypeArgument((Class<T>) type, idx);
  81 + }
  82 +
  83 + return (Class<T>) paramType.getActualTypeArguments()[idx];
  84 + }
  85 +
  86 + /**
  87 + * Return the parametized type used with a concrete implementation of a class that accepts generics. Ex: If you
  88 + * declare
  89 + * <pre>
  90 + * <code>
  91 + * public class SpecializedCollection implements Collection&#60;SpecializedType&#62; {
  92 + * // ...
  93 + * }
  94 + * </code>
  95 + * </pre>
  96 + * then the code <code>getGenericTypeArgument(SpecializedCollection.class , 0);</code> will return the type
  97 + * <code>SpecializedType</code>.
  98 + *
  99 + * @param clazz Base type to check for generic arguments
  100 + * @param idx zero based index of the generic argument to get
  101 + * @param <T> Type of the generic argument
  102 + * @return The class representing the type of the generic argument
  103 + */
  104 + @SuppressWarnings("unchecked")
  105 + public static <T> Class<T> getGenericTypeArgument(final Class<?> clazz, final int idx) {
  106 + final Type type = clazz.getGenericSuperclass();
  107 +
  108 + ParameterizedType paramType;
  109 + try {
  110 + paramType = (ParameterizedType) type;
  111 + } catch (ClassCastException cause) {
  112 + return getGenericTypeArgument((Class<T>) type, idx);
  113 + }
  114 +
  115 + return (Class<T>) paramType.getActualTypeArguments()[idx];
  116 + }
  117 +
  118 + /**
  119 + * <p>
  120 + * Return the parametized type passed to field types that accepts Generics.
  121 + * </p>
  122 + * Ex: If you declare
  123 + * <pre>
  124 + * <code>
  125 + * public class MyClass{
  126 + * private Collection&lt;String&gt; myStringCollection;
  127 + * }
  128 + * </code>
  129 + * </pre>
  130 + * then the code <code>getGenericTypeArgument( MyClass.class.getDeclaredField("myStringCollection") , 0);</code>
  131 + * will return the type <code>String</code>.
  132 + *
  133 + * @param field Field which type is generified
  134 + * @param idx zero based index of the generic argument to get
  135 + * @param <T> Type of the generic argument
  136 + * @return The class representing the type of the generic argument
  137 + */
  138 + @SuppressWarnings("unchecked")
  139 + public static <T> Class<T> getGenericTypeArgument(final Field field, final int idx) {
  140 + final Type type = field.getGenericType();
  141 + final ParameterizedType paramType = (ParameterizedType) type;
  142 +
  143 + return (Class<T>) paramType.getActualTypeArguments()[idx];
  144 + }
  145 +
  146 + /**
  147 + * <p>
  148 + * Return the parametized type passed to members (fields or methods) that accepts Generics.
  149 + * </p>
  150 + *
  151 + * @param member Member which type is generified
  152 + * @param idx zero based index of the generic argument to get
  153 + * @param <T> Type of the generic argument
  154 + * @return The class representing the type of the generic argument
  155 + * @see #getGenericTypeArgument(Field field, int idx)
  156 + */
  157 + public static <T> Class<T> getGenericTypeArgument(final Member member, final int idx) {
  158 + Class<T> result = null;
  159 +
  160 + if (member instanceof Field) {
  161 + result = getGenericTypeArgument((Field) member, idx);
  162 + } else if (member instanceof Method) {
  163 + result = getGenericTypeArgument((Method) member, idx);
  164 + }
  165 +
  166 + return result;
  167 + }
  168 +
  169 + /**
  170 + * <p>
  171 + * Return the parametized type passed to methods that accepts Generics.
  172 + * </p>
  173 + *
  174 + * @param method Generified method reference
  175 + * @param idx zero based index of the generic argument to get
  176 + * @param <T> Type of the generic argument
  177 + * @return The class representing the type of the generic argument
  178 + * @see #getGenericTypeArgument(Field field, int idx)
  179 + */
  180 + @SuppressWarnings("unchecked")
  181 + public static <T> Class<T> getGenericTypeArgument(final Method method, final int idx) {
  182 + return (Class<T>) method.getGenericParameterTypes()[idx];
  183 + }
  184 +
  185 + /**
  186 + * Returns the value contained in the given field.
  187 + *
  188 + * @param field field to be extracted the value.
  189 + * @param object object that contains the field.
  190 + * @param <T> Type of the generic argument
  191 + * @return value of the field.
  192 + */
  193 + @SuppressWarnings("unchecked")
  194 + public static <T> T getFieldValue(Field field, Object object) {
  195 + T result = null;
  196 +
  197 + try {
  198 + boolean acessible = field.isAccessible();
  199 + field.setAccessible(true);
  200 + result = (T) field.get(object);
  201 + field.setAccessible(acessible);
  202 +
  203 + } catch (Exception e) {
  204 + Exceptions.handleToRuntimeException(e);
  205 + }
  206 +
  207 + return result;
  208 + }
  209 +
  210 + /**
  211 + * Sets a value in a field.
  212 + *
  213 + * @param field field to be setted.
  214 + * @param object object that contains the field.
  215 + * @param value value to be setted in the field.
  216 + */
  217 + public static void setFieldValue(Field field, Object object, Object value) {
  218 + try {
  219 + boolean acessible = field.isAccessible();
  220 + field.setAccessible(true);
  221 + field.set(object, value);
  222 + field.setAccessible(acessible);
  223 +
  224 + } catch (Exception e) {
  225 + Exceptions.handleToRuntimeException(e);
  226 + }
  227 + }
  228 +
  229 + /**
  230 + * @param type Base type to look for fields
  231 + * @return All non static fields from a certain type. Inherited fields are not returned, so if you need to get
  232 + * inherited fields you must iterate over this type's hierarchy.
  233 + */
  234 + public static Field[] getNonStaticDeclaredFields(Class<?> type) {
  235 + List<Field> fields = new ArrayList<Field>();
  236 +
  237 + if (type != null) {
  238 + for (Field field : type.getDeclaredFields()) {
  239 + if (!Modifier.isStatic(field.getModifiers()) && !field.getType().equals(type.getDeclaringClass())) {
  240 + fields.add(field);
  241 + }
  242 + }
  243 + }
  244 +
  245 + return fields.toArray(new Field[0]);
  246 + }
  247 +
  248 + /**
  249 + * @param type Base type to look for fields
  250 + * @return All non static fields from a certain type, including fields declared in superclasses of this type.
  251 + */
  252 + public static List<Field> getNonStaticFields(Class<?> type) {
  253 + List<Field> fields = new ArrayList<Field>();
  254 +
  255 + if (type != null) {
  256 + Class<?> currentType = type;
  257 + while (currentType != null && !"java.lang.Object".equals(currentType.getCanonicalName())) {
  258 + fields.addAll(Arrays.asList(getNonStaticDeclaredFields(currentType)));
  259 + currentType = currentType.getSuperclass();
  260 + }
  261 + }
  262 +
  263 + return fields;
  264 + }
  265 +
  266 + /**
  267 + * Instantiate an object of the given type. The default constructor with no parameters is used.
  268 + *
  269 + * @param clazz Base type of object to instantiate
  270 + * @param <T> Final type of instantiated object
  271 + * @return New instance of provided type
  272 + */
  273 + public static <T> T instantiate(Class<T> clazz) {
  274 + T object = null;
  275 + try {
  276 + object = clazz.newInstance();
  277 + } catch (InstantiationException | IllegalAccessException e) {
  278 + Exceptions.handleToRuntimeException(e);
  279 + }
  280 + return object;
  281 + }
  282 +
  283 + /**
  284 + * Verifies if a given class could be converted to a given type.
  285 + *
  286 + * @param clazz class to be checked.
  287 + * @param type type to be checked.
  288 + * @return {@link Boolean} true if the given class can be converted to a given type, and false otherwise.
  289 + */
  290 + public static boolean isOfType(Class<?> clazz, Class<?> type) {
  291 + return type.isAssignableFrom(clazz) && clazz != type;
  292 + }
  293 +
  294 + /**
  295 + * Obtains the {@link ClassLoader} for the given class, from his canonical name.
  296 + *
  297 + * @param canonicalName canonical name of the the given class.
  298 + * @return {@link ClassLoader} ClassLoader for the given class.
  299 + */
  300 + public static ClassLoader getClassLoaderForClass(final String canonicalName) {
  301 + return Reflections.getClassLoaderForResource(canonicalName.replaceAll("\\.", "/") + ".class");
  302 + }
  303 +
  304 + /**
  305 + * Obtains the {@link ClassLoader} for the given resource.
  306 + *
  307 + * @param resource String representation of the fully qualified path to the resource on the classpath
  308 + * @return {@link ClassLoader} ClassLoader for the given resource.
  309 + */
  310 + public static ClassLoader getClassLoaderForResource(final String resource) {
  311 + final String stripped = resource.charAt(0) == '/' ? resource.substring(1) : resource;
  312 +
  313 + URL url = null;
  314 + ClassLoader result = Thread.currentThread().getContextClassLoader();
  315 +
  316 + if (result != null) {
  317 + url = result.getResource(stripped);
  318 + }
  319 +
  320 + if (url == null) {
  321 + result = Reflections.class.getClassLoader();
  322 + url = Reflections.class.getClassLoader().getResource(stripped);
  323 + }
  324 +
  325 + if (url == null) {
  326 + result = null;
  327 + }
  328 +
  329 + return result;
  330 + }
  331 +
  332 + /**
  333 + * Return an URL to access a resource available to the active classloader for the calling thread.
  334 + *
  335 + * @param resource String representation of the location of the resource on the classpath
  336 + * @return The {@link URL} for the resource
  337 + */
  338 + public static URL getResourceAsURL(final String resource) {
  339 + ClassLoader classLoader = getClassLoaderForResource(resource);
  340 + return classLoader != null ? classLoader.getResource(resource) : null;
  341 + }
  342 +
  343 + /**
  344 + * Return an InputStream to access a resource available to the active classloader for the calling thread.
  345 + *
  346 + * @param resource String representation of the location of the resource on the classpath
  347 + * @return An {@link InputStream} that reads data from the resource
  348 + */
  349 + public static InputStream getResourceAsStream(final String resource) {
  350 + ClassLoader classLoader = getClassLoaderForResource(resource);
  351 + return classLoader != null ? classLoader.getResourceAsStream(resource) : null;
  352 + }
  353 +
  354 + /**
  355 + * Loads a class with the given name using the active classloader for the current thread.
  356 + *
  357 + * @param className String with fully qualified class name of the desired class
  358 + * @param <T> Final type of the loaded class
  359 + * @return Class representing the loaded type
  360 + * @throws ClassNotFoundException If no class with this name exists
  361 + */
  362 + @SuppressWarnings("unchecked")
  363 + public static <T> Class<T> forName(final String className) throws ClassNotFoundException {
  364 + ClassLoader classLoader = getClassLoaderForClass(className);
  365 + return (Class<T>) Class.forName(className, true, classLoader);
  366 + }
  367 +}
demoiselle-core/src/main/java/org/demoiselle/jee/core/util/ResourceBundle.java 0 → 100644
@@ -0,0 +1,136 @@ @@ -0,0 +1,136 @@
  1 +/*
  2 + * Demoiselle Framework
  3 + * Copyright (C) 2010 SERPRO
  4 + * ----------------------------------------------------------------------------
  5 + * This file is part of Demoiselle Framework.
  6 + *
  7 + * Demoiselle Framework is free software; you can redistribute it and/or
  8 + * modify it under the terms of the GNU Lesser General Public License version 3
  9 + * as published by the Free Software Foundation.
  10 + *
  11 + * This program is distributed in the hope that it will be useful,
  12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14 + * GNU General Public License for more details.
  15 + *
  16 + * You should have received a copy of the GNU Lesser General Public License version 3
  17 + * along with this program; if not, see <http://www.gnu.org/licenses/>
  18 + * or write to the Free Software Foundation, Inc., 51 Franklin Street,
  19 + * Fifth Floor, Boston, MA 02110-1301, USA.
  20 + * ----------------------------------------------------------------------------
  21 + * Este arquivo é parte do Framework Demoiselle.
  22 + *
  23 + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou
  24 + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação
  25 + * do Software Livre (FSF).
  26 + *
  27 + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA
  28 + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou
  29 + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português
  30 + * para maiores detalhes.
  31 + *
  32 + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título
  33 + * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>
  34 + * ou escreva para a Fundação do Software Livre (FSF) Inc.,
  35 + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
  36 + */
  37 +package org.demoiselle.jee.core.util;
  38 +
  39 +import java.io.Serializable;
  40 +import java.lang.reflect.Method;
  41 +import java.util.Enumeration;
  42 +import java.util.Locale;
  43 +import java.util.MissingResourceException;
  44 +import java.util.Set;
  45 +
  46 +/**
  47 + * <p>The Demoiselle's ResourceBundle extends the abstraction {@link java.util.ResourceBundle},
  48 + * and provide the locale and the base name for the bundle.</p>
  49 + *
  50 + * <p>To select which resource properties file to load when injecting beans of this class, qualify
  51 + * the injection point with {@link org.demoiselle.annotation.Name}, using the resource name (without
  52 + * the '.properties' extension) as the value. If the injection point isn't qualified the default
  53 + * file <code>messages.properties</code> will be loaded from the root of the classpath.</p>
  54 + *
  55 + * @author SERPRO
  56 + */
  57 +public class ResourceBundle extends java.util.ResourceBundle implements Serializable {
  58 +
  59 + private static final long serialVersionUID = 1L;
  60 +
  61 + private String baseName;
  62 +
  63 + private transient java.util.ResourceBundle delegate;
  64 +
  65 + private final Locale locale;
  66 +
  67 + private java.util.ResourceBundle getDelegate() {
  68 + if (delegate == null) {
  69 + try {
  70 + ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
  71 + delegate = ResourceBundle.getBundle(baseName, locale, classLoader);
  72 +
  73 + } catch (MissingResourceException mre) {
  74 + delegate = ResourceBundle.getBundle(baseName, locale);
  75 + }
  76 + }
  77 +
  78 + return delegate;
  79 + }
  80 +
  81 + /**
  82 + * Constructor that set values of baseName and locale.
  83 + *
  84 + * @param baseName
  85 + * the base name to construct the complete bundle name.
  86 + *
  87 + * @param locale
  88 + * locale to define the choosen bundle.
  89 + */
  90 + public ResourceBundle(String baseName, Locale locale) {
  91 + this.baseName = baseName;
  92 + this.locale = locale;
  93 + }
  94 +
  95 + @Override
  96 + public boolean containsKey(String key) {
  97 + return getDelegate().containsKey(key);
  98 + }
  99 +
  100 + @Override
  101 + public Enumeration<String> getKeys() {
  102 + return getDelegate().getKeys();
  103 + }
  104 +
  105 + @Override
  106 + public Locale getLocale() {
  107 + return getDelegate().getLocale();
  108 + }
  109 +
  110 + @Override
  111 + public Set<String> keySet() {
  112 + return getDelegate().keySet();
  113 + }
  114 +
  115 + public String getString(String key, Object... params) {
  116 + return Strings.getString(getString(key), params);
  117 + }
  118 +
  119 + @Override
  120 + protected Object handleGetObject(String key) {
  121 + Object result;
  122 +
  123 + try {
  124 + Method method = getDelegate().getClass().getMethod("handleGetObject", String.class);
  125 +
  126 + method.setAccessible(true);
  127 + result = method.invoke(delegate, key);
  128 + method.setAccessible(false);
  129 +
  130 + } catch (Exception cause) {
  131 + throw new RuntimeException(cause);
  132 + }
  133 +
  134 + return result;
  135 + }
  136 +}
demoiselle-core/src/main/java/org/demoiselle/jee/core/util/Strings.java 0 → 100644
@@ -0,0 +1,300 @@ @@ -0,0 +1,300 @@
  1 +/*
  2 + * Demoiselle Framework
  3 + * Copyright (C) 2010 SERPRO
  4 + * ----------------------------------------------------------------------------
  5 + * This file is part of Demoiselle Framework.
  6 + *
  7 + * Demoiselle Framework is free software; you can redistribute it and/or
  8 + * modify it under the terms of the GNU Lesser General Public License version 3
  9 + * as published by the Free Software Foundation.
  10 + *
  11 + * This program is distributed in the hope that it will be useful,
  12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14 + * GNU General Public License for more details.
  15 + *
  16 + * You should have received a copy of the GNU Lesser General Public License version 3
  17 + * along with this program; if not, see <http://www.gnu.org/licenses/>
  18 + * or write to the Free Software Foundation, Inc., 51 Franklin Street,
  19 + * Fifth Floor, Boston, MA 02110-1301, USA.
  20 + * ----------------------------------------------------------------------------
  21 + * Este arquivo é parte do Framework Demoiselle.
  22 + *
  23 + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou
  24 + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação
  25 + * do Software Livre (FSF).
  26 + *
  27 + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA
  28 + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou
  29 + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português
  30 + * para maiores detalhes.
  31 + *
  32 + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título
  33 + * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>
  34 + * ou escreva para a Fundação do Software Livre (FSF) Inc.,
  35 + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
  36 + */
  37 +package org.demoiselle.jee.core.util;
  38 +
  39 +import java.io.BufferedReader;
  40 +import java.io.IOException;
  41 +import java.io.InputStream;
  42 +import java.io.InputStreamReader;
  43 +import java.lang.reflect.Field;
  44 +import java.util.Arrays;
  45 +import java.util.regex.Matcher;
  46 +import java.util.regex.Pattern;
  47 +
  48 +import org.demoiselle.jee.core.annotation.Ignore;
  49 +
  50 +/**
  51 + * Contain a set of methods that implements a set of functionalities that
  52 + * envolves manipulation of strings.
  53 + *
  54 + * @author SERPRO
  55 + */
  56 +public final class Strings {
  57 +
  58 + private Strings() {
  59 + }
  60 +
  61 + /**
  62 + * Returns if some string matches with the format of a ResourceBundle key or
  63 + * not.
  64 + *
  65 + * @param key string to check if matches with key format of ResourceBundle.
  66 + * @return boolean true if matches and false otherwise.
  67 + */
  68 + public static boolean isResourceBundleKeyFormat(final String key) {
  69 + return Pattern.matches("^\\{(.+)\\}$", key == null ? "" : key);
  70 + }
  71 +
  72 + /**
  73 + * Removes specific characteres from a given string.
  74 + *
  75 + * @param string string to be changed, by the removing of some characters.
  76 + * @param chars characters to be removed from string.
  77 + * @return String returns the given string without the given characters.
  78 + */
  79 + public static String removeChars(String string, char... chars) {
  80 + String result = string;
  81 +
  82 + if (result != null) {
  83 + for (char ch : chars) {
  84 + result = result.replace(String.valueOf(ch), "");
  85 + }
  86 + }
  87 + return result;
  88 + }
  89 +
  90 + public static String join(String separator, String... strings) {
  91 + StringBuffer result = new StringBuffer();
  92 +
  93 + if (strings != null) {
  94 + for (int i = 0; i < strings.length; i++) {
  95 + if (i != 0 && separator != null) {
  96 + result.append(separator);
  97 + }
  98 +
  99 + if (strings[i] != null) {
  100 + result.append(strings[i]);
  101 + }
  102 + }
  103 + }
  104 +
  105 + return result.length() > 0 ? result.toString() : null;
  106 + }
  107 +
  108 + /**
  109 + * Inserts the character "0" in the begin of a given string. The quantity of
  110 + * zeros that will be placed depends on the difference between the length of
  111 + * the given string and the value of howMuchZeros.
  112 + *
  113 + * @param string string to insert zeros characthers.
  114 + * @param howMuchZeros its controls how much zeros will be insert.
  115 + * @return String Retuns the string, added with appropriate number of zeros.
  116 + * For exemplo, if string = "yes" and howMuchZeros = 5, the returned string
  117 + * will be "00yes".
  118 + */
  119 + public static String insertZeros(String string, int howMuchZeros) {
  120 + StringBuffer result = new StringBuffer((string == null ? "" : string).trim());
  121 + int difference = howMuchZeros - result.toString().length();
  122 +
  123 + for (int j = 0; j < difference; j++) {
  124 + result.insert(0, '0');
  125 + }
  126 +
  127 + return result.toString();
  128 + }
  129 +
  130 + /**
  131 + * * Replaces the numbers between braces in the given string with the given
  132 + * parameters. The process will replace a number between braces for the
  133 + * parameter for which its order in the set of parameters matches with the
  134 + * number of the given string. For exemple, if is received the following
  135 + * string "Treats an {0} exception" and the set of parameters
  136 + * {"DemoiselleException"}, the return will be the following string: "Treats
  137 + * an DemoiselleException exception".
  138 + *
  139 + * @param string with the numbers with braces to be replaced with the
  140 + * parameters.
  141 + * @param params parameters that will replace the number with braces in the
  142 + * given string.
  143 + * @return String string with numbers replaced with the matching parameter.
  144 + */
  145 + public static String getString(final String string, final Object... params) {
  146 + String result = null;
  147 +
  148 + if (string != null) {
  149 + result = new String(string);
  150 + }
  151 +
  152 + if (params != null && string != null) {
  153 + for (int i = 0; i < params.length; i++) {
  154 + if (params[i] != null) {
  155 + result = result.replaceAll("\\{" + i + "\\}", Matcher.quoteReplacement(params[i].toString()));
  156 + }
  157 + }
  158 + }
  159 +
  160 + return result;
  161 + }
  162 +
  163 + /**
  164 + * Verifies if a given string is empty or null.
  165 + *
  166 + * @param string string to be verified.
  167 + * @return boolean returns true if the given string is empty or null and
  168 + * returns false otherwise.
  169 + */
  170 + public static boolean isEmpty(String string) {
  171 + return string == null || string.trim().isEmpty();
  172 + }
  173 +
  174 + /**
  175 + * Converts any object to string.
  176 + *
  177 + * @param object object to be converted.
  178 + * @return String the given object converted to string.
  179 + */
  180 + public static String toString(Object object) {
  181 + StringBuffer result = new StringBuffer();
  182 + Object fieldValue;
  183 +
  184 + if (object != null) {
  185 + result.append(object.getClass().getSimpleName());
  186 + result.append(" [");
  187 +
  188 + boolean first = true;
  189 + for (Field field : Reflections.getNonStaticDeclaredFields(object.getClass())) {
  190 + if (!field.isAnnotationPresent(Ignore.class)) {
  191 + if (first) {
  192 + first = false;
  193 + } else {
  194 + result.append(", ");
  195 + }
  196 +
  197 + result.append(field.getName());
  198 + result.append('=');
  199 + fieldValue = Reflections.getFieldValue(field, object);
  200 + result.append(fieldValue != null && fieldValue.getClass().isArray()
  201 + ? Arrays.toString((Object[]) fieldValue)
  202 + : fieldValue);
  203 + }
  204 + }
  205 +
  206 + result.append(']');
  207 + }
  208 +
  209 + return result.toString();
  210 + }
  211 +
  212 + /**
  213 + * Replace the camel case string for a lowercase string separated for a
  214 + * given symbol.
  215 + *
  216 + * @param string string that separeted with camel case.
  217 + * @param symbol simbol to be the new separator for the given string.
  218 + * @return String the given string separated with the given symbol.
  219 + */
  220 + public static String camelCaseToSymbolSeparated(String string, String symbol) {
  221 + if (symbol == null) {
  222 + symbol = "";
  223 + }
  224 +
  225 + return string == null ? null : string.replaceAll("\\B([A-Z])", symbol + "$1").toLowerCase();
  226 + }
  227 +
  228 + /**
  229 + * Sets the first character of a given string to upper case.
  230 + *
  231 + * @param string Full string to convert
  232 + * @return String the given string with the first character setted to upper
  233 + * case.
  234 + */
  235 + public static String firstToUpper(String string) {
  236 + String result = string;
  237 +
  238 + if (!Strings.isEmpty(string)) {
  239 + result = string.toUpperCase().charAt(0) + (string.length() > 1 ? string.substring(1) : "");
  240 + }
  241 +
  242 + return result;
  243 + }
  244 +
  245 + /**
  246 + * Removes braces from a given string.
  247 + *
  248 + * @param string Message to remove braces from
  249 + * @return String the given string without braces.
  250 + */
  251 + public static String removeBraces(String string) {
  252 + String result = string;
  253 +
  254 + if (isResourceBundleKeyFormat(string)) {
  255 + result = string.substring(1, string.length() - 1);
  256 + }
  257 +
  258 + return result;
  259 + }
  260 +
  261 + /**
  262 + * Inserts braces in a given string.
  263 + *
  264 + * @param string Original string to insert braces on.
  265 + * @return String the given string with braces.
  266 + */
  267 + public static String insertBraces(String string) {
  268 + String result = string;
  269 +
  270 + if (!isEmpty(string)) {
  271 + result = "{" + string + "}";
  272 + }
  273 +
  274 + return result;
  275 + }
  276 +
  277 + public static String parse(InputStream inputStream) throws IOException {
  278 + StringBuilder result = new StringBuilder();
  279 +
  280 + if (inputStream != null) {
  281 + BufferedReader reader = null;
  282 +
  283 + try {
  284 + reader = new BufferedReader(new InputStreamReader(inputStream));
  285 + String line;
  286 +
  287 + while ((line = reader.readLine()) != null) {
  288 + result.append(line);
  289 + }
  290 +
  291 + } finally {
  292 + if (reader != null) {
  293 + reader.close();
  294 + }
  295 + }
  296 + }
  297 +
  298 + return result.length() > 0 ? result.toString() : null;
  299 + }
  300 +}
demoiselle-core/src/main/java/org/demoiselle/jee/stereotype/BusinessController.java 0 → 100644
@@ -0,0 +1,36 @@ @@ -0,0 +1,36 @@
  1 +/*
  2 + * Demoiselle Framework
  3 + *
  4 + * License: GNU Lesser General Public License (LGPL), version 3 or later.
  5 + * See the lgpl.txt file in the root directory or <https://www.gnu.org/licenses/lgpl.html>.
  6 + */
  7 +package org.demoiselle.jee.stereotype;
  8 +
  9 +import javax.enterprise.inject.Stereotype;
  10 +import java.lang.annotation.Inherited;
  11 +import java.lang.annotation.Retention;
  12 +import java.lang.annotation.Target;
  13 +
  14 +import static java.lang.annotation.ElementType.TYPE;
  15 +import static java.lang.annotation.RetentionPolicy.RUNTIME;
  16 +
  17 +/**
  18 + * Identifies a <b>business controller</b> class. Business controller objects typically implement the controller design
  19 + * pattern, i.e., they contain no data elements but methods that orchestrate interaction among business entities.
  20 + * <p>
  21 + * A <i>Business Controller</i> is:
  22 + * <ul>
  23 + * <li>defined when annotated with {@code @BusinessController}</li>
  24 + * <li>automatically injected whenever {@code @Inject} is used</li>
  25 + * </ul>
  26 + *
  27 + * @author SERPRO
  28 + * @see Controller
  29 + */
  30 +@Controller
  31 +@Stereotype
  32 +@Inherited
  33 +@Target(TYPE)
  34 +@Retention(RUNTIME)
  35 +public @interface BusinessController {
  36 +}
demoiselle-core/src/main/java/org/demoiselle/jee/stereotype/Controller.java 0 → 100644
@@ -0,0 +1,28 @@ @@ -0,0 +1,28 @@
  1 +/*
  2 + * Demoiselle Framework
  3 + *
  4 + * License: GNU Lesser General Public License (LGPL), version 3 or later.
  5 + * See the lgpl.txt file in the root directory or <https://www.gnu.org/licenses/lgpl.html>.
  6 + */
  7 +package org.demoiselle.jee.stereotype;
  8 +
  9 +import javax.interceptor.InterceptorBinding;
  10 +import java.lang.annotation.Inherited;
  11 +import java.lang.annotation.Retention;
  12 +import java.lang.annotation.Target;
  13 +
  14 +import static java.lang.annotation.ElementType.METHOD;
  15 +import static java.lang.annotation.ElementType.TYPE;
  16 +import static java.lang.annotation.RetentionPolicy.RUNTIME;
  17 +
  18 +/**
  19 + * Identifies a <b>controller</b> class or stereotype, the latter being most suitable for it.
  20 + *
  21 + * @author SERPRO
  22 + */
  23 +@InterceptorBinding
  24 +@Inherited
  25 +@Target({ TYPE, METHOD })
  26 +@Retention(RUNTIME)
  27 +public @interface Controller {
  28 +}
demoiselle-core/src/main/java/org/demoiselle/jee/stereotype/PersistenceController.java 0 → 100644
@@ -0,0 +1,37 @@ @@ -0,0 +1,37 @@
  1 +/*
  2 + * Demoiselle Framework
  3 + *
  4 + * License: GNU Lesser General Public License (LGPL), version 3 or later.
  5 + * See the lgpl.txt file in the root directory or <https://www.gnu.org/licenses/lgpl.html>.
  6 + */
  7 +package org.demoiselle.jee.stereotype;
  8 +
  9 +import javax.enterprise.inject.Stereotype;
  10 +import java.lang.annotation.Inherited;
  11 +import java.lang.annotation.Retention;
  12 +import java.lang.annotation.Target;
  13 +
  14 +import static java.lang.annotation.ElementType.TYPE;
  15 +import static java.lang.annotation.RetentionPolicy.RUNTIME;
  16 +
  17 +/**
  18 + * Identifies a <b>persistence controller</b> class. A persistence controller is
  19 + * a layer which provides simplified access to data stored in persistent storage
  20 + * of some kind, such as an entity-relational database.
  21 + * <p>
  22 + * A <i>Persitence Controller</i> is:
  23 + * <ul>
  24 + * <li>defined when annotated with {@code @PersistenceController}</li>
  25 + * <li>automatically injected whenever {@code @Inject} is used</li>
  26 + * </ul>
  27 + *
  28 + * @author SERPRO
  29 + * @see Controller
  30 + */
  31 +@Controller
  32 +@Stereotype
  33 +@Inherited
  34 +@Target(TYPE)
  35 +@Retention(RUNTIME)
  36 +public @interface PersistenceController {
  37 +}
demoiselle-core/src/main/java/org/demoiselle/jee/stereotype/RestController.java 0 → 100644
@@ -0,0 +1,36 @@ @@ -0,0 +1,36 @@
  1 +/*
  2 + * Demoiselle Framework
  3 + *
  4 + * License: GNU Lesser General Public License (LGPL), version 3 or later.
  5 + * See the lgpl.txt file in the root directory or <https://www.gnu.org/licenses/lgpl.html>.
  6 + */
  7 +package org.demoiselle.jee.stereotype;
  8 +
  9 +import javax.enterprise.inject.Stereotype;
  10 +import java.lang.annotation.Inherited;
  11 +import java.lang.annotation.Retention;
  12 +import java.lang.annotation.Target;
  13 +
  14 +import static java.lang.annotation.ElementType.TYPE;
  15 +import static java.lang.annotation.RetentionPolicy.RUNTIME;
  16 +
  17 +/**
  18 + * Identifies a <b>facade</b> class. A facade is an object that provides a
  19 + * simplified interface to a larger body of code, such as a class library.
  20 + * <p>
  21 + * A <i>Facade</i> is:
  22 + * <ul>
  23 + * <li>defined when annotated with {@code @FacadeController}</li>
  24 + * <li>automatically injected whenever {@code @Inject} is used</li>
  25 + * </ul>
  26 + *
  27 + * @author SERPRO
  28 + * @see Controller
  29 + */
  30 +@Controller
  31 +@Stereotype
  32 +@Inherited
  33 +@Target(TYPE)
  34 +@Retention(RUNTIME)
  35 +public @interface RestController {
  36 +}
demoiselle-core/src/main/resources/demoiselle.properties 0 → 100644
@@ -0,0 +1,5 @@ @@ -0,0 +1,5 @@
  1 +# Enables JPA transaction strategy, automatically detected if demoiselle-jpa component is detected. Use only if you need to overwrite the default behaviour
  2 +#frameworkdemoiselle.transaction.class=br.gov.frameworkdemoiselle.transaction.JPATransaction
  3 +
  4 +# Enables JTA transaction strategy, automatically detected if demoiselle-jta component is detected. Use only if you need to overwrite the default behaviour
  5 +#frameworkdemoiselle.transaction.class=br.gov.frameworkdemoiselle.transaction.JTATransaction
demoiselle-core/src/main/resources/messages.properties 0 → 100644
@@ -0,0 +1,81 @@ @@ -0,0 +1,81 @@
  1 +
  2 +version=${project.version}
  3 +engine-on=Iniciando o Demoiselle Framework ${project.version} (Neo)
  4 +resource-not-found=Arquivo {0} n\u00e3o foi encontrado
  5 +key-not-found=A chave {0} n\u00e3o foi encontrada
  6 +ambiguous-strategy-resolution=Foi detectada ambiguidade da interface {0} com as seguintes implementa\u00e7\u00f5es\: {1}. Para resolver o conflito, defina explicitamente a implementa\u00e7\u00e3o no demoiselle.properties.
  7 +ambiguous-bean-resolution=Falha ao obter {0} pois foi detectada ambiguidade nas seguintes implementa\u00e7\u00f5es\: {1}
  8 +bean-not-found=Voc\u00ea est\u00e1 tentando obter um objeto n\u00e3o reconhecido pelo CDI via Beans.getReference({0})
  9 +store-not-found=O objeto do tipo [{0}] n\u00e3o pode ser armazenado no escopo indicado\: {1}
  10 +more-than-one-exceptionhandler-defined-for-same-class=Foi definido mais de um m\u00e9todo na classe {0} para tratar a exce\u00e7\u00e3o {1}
  11 +handling-exception=Tratando a exce\u00e7\u00e3o {0}
  12 +taking-off=O Demoiselle ${project.version} decolou
  13 +engine-off=Desligando os motores do Demoiselle ${project.version}
  14 +setting-up-bean-manager=BeanManager dispon\u00edvel atrav\u00e9s do utilit\u00e1rio {0}
  15 +
  16 +user-transaction-lookup-fail=N\u00e3o foi encontrada nenhuma transa\u00e7\u00e3o com o nome {0} no contexto JNDI
  17 +transactional-execution=Execu\u00e7\u00e3o transacional de {0}
  18 +begin-transaction=Transa\u00e7\u00e3o iniciada
  19 +transaction-marked-rollback=Transa\u00e7\u00e3o marcada para rollback [{0}]
  20 +transaction-already-finalized=A transa\u00e7\u00e3o j\u00e1 havia sido finalizada
  21 +transaction-commited=Transa\u00e7\u00e3o finalizada com sucesso
  22 +transaction-rolledback=Transa\u00e7\u00e3o finalizada com rollback
  23 +
  24 +bootstrap.configuration.processing=Processando {0}
  25 +bootstrap-context-already-managed=O contexto {0} para o escopo {1} j\u00e1 foi adicionado
  26 +bootstrap-context-added=Adicionando o contexto {0} para o escopo {1}
  27 +
  28 +loading-configuration-class=Carregando a classe de configura\u00e7\u00e3o {0}
  29 +configuration-field-loaded={0}: {2}
  30 +configuration-attribute-is-mandatory=A configura\u00e7\u00e3o {0} \u00e9 obrigat\u00f3ria, mas n\u00e3o foi encontrada em {1}
  31 +configuration-name-attribute-cant-be-empty=A nota\u00e7\u00e3o @Name n\u00e3o pode estar em branco
  32 +configuration-generic-extraction-error=Ocorreu um erro durante a extra\u00e7\u00e3o do tipo {0} com o extrator {1}
  33 +configuration-dot-after-prefix=N\u00e3o \u00e9 necess\u00e1rio adicionar o ponto ap\u00f3s o prefixo para uma classe de configura\u00e7\u00e3o. \u00c9 recomendado que sejam retirados, pois poder\u00e3o causar erros em vers\u00f5es futuras do Framework.
  34 +configuration-key-not-found={0}\: [n\u00e3o encontrada]
  35 +configuration-extractor-not-found=N\u00e3o foi poss\u00edvel encontrar a classe extratora para o atributo {0}. Implemente a interface {1} para criar sua classe extratora.
  36 +configuration-not-conversion=N\u00e3o \u00e9 poss\u00edvel converter o valor {0} para o tipo {1}
  37 +
  38 +transaction-not-defined=Nenhuma transa\u00e7\u00e3o foi definida. Para utilizar @{0} \u00e9 preciso definir a propriedade frameworkdemoiselle.transaction.class com a estrat\u00e9gia de transa\u00e7\u00e3o desejada no arquivo demoiselle.properties
  39 +executing-all=Executando m\u00e9todos anotados com @{0}
  40 +custom-context-selected=Produzindo inst\u00e2ncia do contexto {0}
  41 +custom-context-was-activated=O contexto {0} foi ativado para o escopo {1}
  42 +custom-context-was-deactivated=O contexto {0} foi desativado para o escopo {1}
  43 +custom-context-already-activated=N\u00e3o foi poss\u00edvel ativar o contexto {0}, o escopo {1} j\u00e1 est\u00e1 ativo no contexto {2}
  44 +custom-context-not-found=N\u00e3o foi encontrado um contexto gerenciado do tipo [{0}] para o escopo [{1}]
  45 +custom-context-manager-not-initialized=ContextManager n\u00e3o foi inicializado. Chame [initialize] ao capturar o evento [AfterBeanDiscovery] em uma extens\u00e3o CDI
  46 +
  47 +error-creating-new-instance-for=Error creating a new instance for "{0}"
  48 +executed-successfully={0} execultado com sucesso
  49 +must-declare-one-single-parameter=Voc\u00ea deve declarar um par\u00e2metro \u00fanico em {0}
  50 +loading-default-transaction-manager=Carregando o gerenciador de transa\u00e7\u00e3o padr\u00e3o {0}
  51 +results-count-greater-page-size=Quantidade de resultados {0} \u00e9 maior que o tamanho da p\u00e1gina {1}
  52 +page-result=Resultado paginado [p\u00e1gina\={0}, total de resultados\={1}]
  53 +pagination-not-initialized=Pagina\u00e7\u00e3o n\u00e3o inicializada. Inicialize o sistema de pagina\u00e7\u00e3o definindo a p\u00e1gina atual ou o total de resultados ao menos uma vez na requisi\u00e7\u00e3o.
  54 +pagination-invalid-value=Valor inv\u00e1lido para paginador: [{0}].
  55 +page=P\u00e1gina [n\u00famero\={0}, tamanho\={1}]
  56 +processing=Processando\: {0}
  57 +processing-fail=Falha no processamento devido a uma exce\u00e7\u00e3o lan\u00e7ada pela aplica\u00e7\u00e3o
  58 +for= \ para\:
  59 +file-not-found=O arquivo {0} n\u00e3o foi encontrado
  60 +
  61 +management-notification-attribute-changed=O atributo [{0}] da classe gerenciada [{1}] foi alterado
  62 +management-null-class-defined=O controlador de gerenciamento informado n\u00e3o pode ser [null]
  63 +management-abstract-class-defined=O controlador de gerenciamento [{0}] precisa ser uma classe concreta
  64 +management-no-annotation-found=Classe {0} precisa ser anotada com @ManagementController
  65 +management-invalid-property-no-getter-setter=Falha ao inicializar classe gerenciada {0}, n\u00e3o foi encontrado um m\u00e9todo get ou m\u00e9todo set para a propriedade {1}
  66 +management-invalid-property-as-operation=Falha ao inicializar classe gerenciada {0}, n\u00e3o \u00e9 poss\u00edvel declarar uma propriedade cujo m\u00e9todo get ou set \u00e9 uma opera\u00e7\u00e3o
  67 +management-introspection-error=Erro ao ler atributos da classe gerenciada {0}
  68 +management-type-not-found=A classe gerenciada informada n\u00e3o existe\: {0}
  69 +management-invoke-error=Erro ao tentar invocar a opera\u00e7\u00e3o "{0}" da classe gerenciada, a opera\u00e7\u00e3o n\u00e3o foi encontrada
  70 +management-write-value-error=N\u00e3o foi poss\u00edvel definir um valor para a propriedade {0}
  71 +management-read-value-error=N\u00e3o foi poss\u00edvel ler o valor da propriedade {0}
  72 +management-debug-acessing-property=Acessando propriedade {0} da classe gerenciada {1}
  73 +management-debug-setting-property=Definindo novo valor para propriedade {0} da classe gerenciada {1}
  74 +management-debug-invoking-operation=Invocando opera\u00e7\u00e3o {0} da classe gerenciada {1}
  75 +management-debug-starting-custom-context=Levantando contexto {0} para executar comando na classe gerenciada {1}
  76 +management-debug-stoping-custom-context=Desligando contexto {0} para classe gerenciada {1}
  77 +management-debug-registering-managed-type=Registrando classe gerenciada [{0}]
  78 +management-debug-processing-management-extension=Processando extens\u00e3o de gerenciamento [{0}]
  79 +management-debug-removing-management-extension=Desativando extens\u00e3o de gerenciamento [{0}]
  80 +management-validation-constraint-violation=Ocorreu um erro de valida\u00e7\u00e3o na classe [{0}] ao definir um valor para a propriedade [{1}]\: [{2}]
  81 +management-validation-validator-not-found=Nenhum provedor de valida\u00e7\u00e3o de beans encontrado, as anota\u00e7\u00f5es de valida\u00e7\u00e3o n\u00e3o ser\u00e3o processadas
demoiselle-persistence-jpa/.gitignore 0 → 100644
@@ -0,0 +1,5 @@ @@ -0,0 +1,5 @@
  1 +/.settings/
  2 +/.project
  3 +/.classpath
  4 +/bin/
  5 +/target/
demoiselle-persistence-jpa/pom.xml 0 → 100644
@@ -0,0 +1,56 @@ @@ -0,0 +1,56 @@
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  3 + <modelVersion>4.0.0</modelVersion>
  4 + <groupId>org.demoiselle.jee</groupId>
  5 + <artifactId>demoiselle-persistence-jpa</artifactId>
  6 + <version>3.0.0-SNAPSHOT</version>
  7 + <packaging>jar</packaging>
  8 +
  9 + <name>Demoiselle Persistence</name>
  10 + <description>
  11 + Demoiselle Persistence
  12 + </description>
  13 +
  14 + <properties>
  15 + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  16 + <maven.compiler.source>1.8</maven.compiler.source>
  17 + <maven.compiler.target>1.8</maven.compiler.target>
  18 + </properties>
  19 + <dependencies>
  20 + <dependency>
  21 + <groupId>${project.groupId}</groupId>
  22 + <artifactId>demoiselle-core</artifactId>
  23 + <version>${project.version}</version>
  24 + </dependency>
  25 + <dependency>
  26 + <groupId>javax.ejb</groupId>
  27 + <artifactId>javax.ejb-api</artifactId>
  28 + <version>3.2</version>
  29 + <scope>provided</scope>
  30 + </dependency>
  31 + <dependency>
  32 + <groupId>javax.cache</groupId>
  33 + <artifactId>cache-api</artifactId>
  34 + <version>1.0.0</version>
  35 + <type>jar</type>
  36 + </dependency>
  37 + <dependency>
  38 + <groupId>javax.cache</groupId>
  39 + <artifactId>cache-api</artifactId>
  40 + <version>1.0.0</version>
  41 + <type>jar</type>
  42 + </dependency>
  43 + <dependency>
  44 + <groupId>javax.persistence</groupId>
  45 + <artifactId>persistence-api</artifactId>
  46 + <version>1.0.2</version>
  47 + <type>jar</type>
  48 + </dependency>
  49 + <dependency>
  50 + <groupId>javax.transaction</groupId>
  51 + <artifactId>javax.transaction-api</artifactId>
  52 + <version>1.2</version>
  53 + <type>jar</type>
  54 + </dependency>
  55 + </dependencies>
  56 +</project>
demoiselle-persistence-jpa/pom.xml~ 0 → 100644
@@ -0,0 +1,56 @@ @@ -0,0 +1,56 @@
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  3 + <modelVersion>4.0.0</modelVersion>
  4 + <groupId>org.demoiselle.jee</groupId>
  5 + <artifactId>demoiselle-persistence</artifactId>
  6 + <version>3.0.0-SNAPSHOT</version>
  7 + <packaging>jar</packaging>
  8 +
  9 + <name>Demoiselle Persistence</name>
  10 + <description>
  11 + Demoiselle Persistence
  12 + </description>
  13 +
  14 + <properties>
  15 + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  16 + <maven.compiler.source>1.8</maven.compiler.source>
  17 + <maven.compiler.target>1.8</maven.compiler.target>
  18 + </properties>
  19 + <dependencies>
  20 + <dependency>
  21 + <groupId>${project.groupId}</groupId>
  22 + <artifactId>demoiselle-core</artifactId>
  23 + <version>${project.version}</version>
  24 + </dependency>
  25 + <dependency>
  26 + <groupId>javax.ejb</groupId>
  27 + <artifactId>javax.ejb-api</artifactId>
  28 + <version>3.2</version>
  29 + <scope>provided</scope>
  30 + </dependency>
  31 + <dependency>
  32 + <groupId>javax.cache</groupId>
  33 + <artifactId>cache-api</artifactId>
  34 + <version>1.0.0</version>
  35 + <type>jar</type>
  36 + </dependency>
  37 + <dependency>
  38 + <groupId>javax.cache</groupId>
  39 + <artifactId>cache-api</artifactId>
  40 + <version>1.0.0</version>
  41 + <type>jar</type>
  42 + </dependency>
  43 + <dependency>
  44 + <groupId>javax.persistence</groupId>
  45 + <artifactId>persistence-api</artifactId>
  46 + <version>1.0.2</version>
  47 + <type>jar</type>
  48 + </dependency>
  49 + <dependency>
  50 + <groupId>javax.transaction</groupId>
  51 + <artifactId>javax.transaction-api</artifactId>
  52 + <version>1.2</version>
  53 + <type>jar</type>
  54 + </dependency>
  55 + </dependencies>
  56 +</project>
demoiselle-persistence-jpa/src/main/java/org/demoiselle/jee/persistence/jpa/context/package-info.java 0 → 100644
@@ -0,0 +1,11 @@ @@ -0,0 +1,11 @@
  1 +/*
  2 + * Demoiselle Framework
  3 + *
  4 + * License: GNU Lesser General Public License (LGPL), version 3 or later.
  5 + * See the lgpl.txt file in the root directory or <https://www.gnu.org/licenses/lgpl.html>.
  6 + */
  7 +/**
  8 + * Esta pacote tem o objetivo de conter as classes relacionadas ao contexto da
  9 + * camada de persistência do framework Demoiselle.
  10 + */
  11 +package org.demoiselle.jee.persistence.jpa.context;
0 \ No newline at end of file 12 \ No newline at end of file
demoiselle-persistence-jpa/src/main/java/org/demoiselle/jee/persistence/jpa/crud/GenericCrudDAO.java 0 → 100644
@@ -0,0 +1,166 @@ @@ -0,0 +1,166 @@
  1 +/*
  2 + * Demoiselle Framework
  3 + *
  4 + * License: GNU Lesser General Public License (LGPL), version 3 or later.
  5 + * See the lgpl.txt file in the root directory or <https://www.gnu.org/licenses/lgpl.html>.
  6 + */
  7 +package org.demoiselle.jee.persistence.jpa.crud;
  8 +
  9 +import java.util.HashMap;
  10 +import java.util.Iterator;
  11 +import java.util.List;
  12 +
  13 +import javax.persistence.EntityManager;
  14 +import javax.persistence.Query;
  15 +
  16 +public abstract class GenericCrudDAO<T> {
  17 +
  18 + private Class<T> entityClass;
  19 +
  20 + public GenericCrudDAO(Class<T> entityClass) {
  21 + this.entityClass = entityClass;
  22 + }
  23 +
  24 + protected abstract EntityManager getEntityManager();
  25 +
  26 + public void create(T entity) {
  27 + getEntityManager().persist(entity);
  28 + }
  29 +
  30 + public void edit(T entity) {
  31 + getEntityManager().merge(entity);
  32 + }
  33 +
  34 + public void remove(T entity) {
  35 + getEntityManager().remove(getEntityManager().merge(entity));
  36 + }
  37 +
  38 + public T find(Object id) {
  39 + return getEntityManager().find(entityClass, id);
  40 + }
  41 +
  42 + @SuppressWarnings({ "rawtypes", "unchecked" })
  43 + public List<T> findAll() {
  44 + javax.persistence.criteria.CriteriaQuery cq = getEntityManager().getCriteriaBuilder().createQuery();
  45 + cq.select(cq.from(entityClass));
  46 + return getEntityManager().createQuery(cq).getResultList();
  47 + }
  48 +
  49 + @SuppressWarnings({ "rawtypes", "unchecked" })
  50 + public List<T> findRange(int[] range) {
  51 + javax.persistence.criteria.CriteriaQuery cq = getEntityManager().getCriteriaBuilder().createQuery();
  52 + cq.select(cq.from(entityClass));
  53 + javax.persistence.Query q = getEntityManager().createQuery(cq);
  54 + q.setMaxResults(range[1] - range[0] + 1);
  55 + q.setFirstResult(range[0]);
  56 + return q.getResultList();
  57 + }
  58 +
  59 + @SuppressWarnings("rawtypes")
  60 + public GenericDataPage pageResult(String sort, String order, Integer from, Integer size, String search,
  61 + String fields, HashMap<String, String> filter) {
  62 +
  63 + // TODO: Rever esta validação
  64 + // if (GPUtils.isEmpty(sort, order) || !((order.equalsIgnoreCase("asc")
  65 + // || order.equalsIgnoreCase("desc"))
  66 + // && (GPUtils.fieldInClass(sort, this.entityClass)))) {
  67 + // throw new GPException(GPMessage.LIST_PARAM_ERROR);
  68 + // }
  69 +
  70 + if (from == null) {
  71 + from = 0;
  72 + }
  73 + if (size == null) {
  74 + size = Integer.MAX_VALUE;
  75 + }
  76 + boolean hasSearch = search != null && !search.isEmpty();
  77 +
  78 + String query = new String("select u from " + this.entityClass.getSimpleName() + " u ");
  79 + if (hasSearch) {
  80 + query += " where lower(concat(";
  81 + String[] f = fields.split(",");
  82 + for (int i = 0; i < f.length; i++) {
  83 + query += "u." + f[i];
  84 + if (i < f.length - 1) {
  85 + query += ", ' ',";
  86 + }
  87 + }
  88 + query += ")) like concat('%', :part, '%')";
  89 + }
  90 +
  91 + if (filter != null && !filter.isEmpty()) {
  92 + Iterator<String> keys = filter.keySet().iterator();
  93 + if (hasSearch) {
  94 + while (keys.hasNext()) {
  95 + String key = keys.next();
  96 + query += " AND u." + key + "=" + filter.get(key);
  97 + }
  98 + } else {
  99 + query += " where ";
  100 + while (keys.hasNext()) {
  101 + String key = keys.next();
  102 + query += " u." + key + "=" + filter.get(key);
  103 + if (keys.hasNext()) {
  104 + query += " and ";
  105 + }
  106 + }
  107 + }
  108 + }
  109 + // Total de Registros
  110 + String query_total = query.replaceFirst("select u", "select COUNT(u)");
  111 + Query qr = getEntityManager().createQuery(query_total);
  112 + if (hasSearch) {
  113 + qr.setParameter("part", search.toLowerCase());
  114 + }
  115 + Long total = (Long) qr.getSingleResult();
  116 +
  117 + // Conteudo
  118 + qr = getEntityManager().createQuery(query.toString() + " ORDER BY " + sort + " " + order);
  119 + List content = null;
  120 + if (hasSearch) {
  121 + qr.setParameter("part", search.toLowerCase());
  122 + }
  123 + content = qr.setFirstResult(from).setMaxResults(size).getResultList();
  124 + return new GenericDataPage(content, from, size, total, fields, search);
  125 + }
  126 +
  127 + public GenericDataPage list(String field, String order) {
  128 + List<T> list = getEntityManager()
  129 + .createQuery("select u from " + this.entityClass.getSimpleName() + " u ORDER BY " + field + " " + order,
  130 + this.entityClass)
  131 + .getResultList();
  132 + return new GenericDataPage(list, 0, list.size(), list.size());
  133 + }
  134 +
  135 + public GenericDataPage list() {
  136 + List<T> list = getEntityManager()
  137 + .createQuery("select u from " + this.entityClass.getSimpleName() + " u ", this.entityClass)
  138 + .getResultList();
  139 + return new GenericDataPage(list, 0, list.size(), list.size());
  140 + }
  141 +
  142 + public List<T> list(String field, String order, int init, int qtde) {
  143 + return getEntityManager()
  144 + .createQuery("select u from " + this.entityClass.getSimpleName() + " u ORDER BY " + field + " " + order,
  145 + this.entityClass)
  146 + .setFirstResult(init).setMaxResults(qtde).getResultList();
  147 + }
  148 +
  149 + public List<T> find(String whereField, String whereValue, String fieldOrder, String order, int init, int qtde) {
  150 + return getEntityManager()
  151 + .createQuery("select u from " + this.entityClass.getSimpleName() + " u where u." + whereField + " = "
  152 + + whereValue + " ORDER BY " + fieldOrder + " " + order, this.entityClass)
  153 + .setFirstResult(init).setMaxResults(qtde).getResultList();
  154 + }
  155 +
  156 + public Long count() {
  157 + return (Long) getEntityManager().createQuery("select COUNT(u) from " + this.entityClass.getSimpleName() + " u")
  158 + .getSingleResult();
  159 + }
  160 +
  161 + public Long count(String whereField, String whereValue) {
  162 + return (Long) getEntityManager().createQuery("select COUNT(u) from " + this.entityClass.getSimpleName()
  163 + + " u where u." + whereField + " = " + whereValue).getSingleResult();
  164 + }
  165 +
  166 +}
demoiselle-persistence-jpa/src/main/java/org/demoiselle/jee/persistence/jpa/crud/GenericDataPage.java 0 → 100644
@@ -0,0 +1,95 @@ @@ -0,0 +1,95 @@
  1 +/*
  2 + * Demoiselle Framework
  3 + *
  4 + * License: GNU Lesser General Public License (LGPL), version 3 or later.
  5 + * See the lgpl.txt file in the root directory or <https://www.gnu.org/licenses/lgpl.html>.
  6 + */
  7 +package org.demoiselle.jee.persistence.jpa.crud;
  8 +
  9 +import java.io.Serializable;
  10 +import java.util.List;
  11 +
  12 +@SuppressWarnings("rawtypes")
  13 +public class GenericDataPage implements Serializable {
  14 +
  15 + private static final long serialVersionUID = 1L;
  16 +
  17 + private long total;
  18 +
  19 + private int from;
  20 +
  21 + private int size;
  22 +
  23 + private String fields;
  24 +
  25 + private String search;
  26 +
  27 + private List content;
  28 +
  29 + public GenericDataPage(List content, int from, int size, long total) {
  30 + super();
  31 + this.from = from;
  32 + this.size = size;
  33 + this.total = total;
  34 + this.content = content;
  35 + }
  36 +
  37 + public GenericDataPage(List content, int from, int size, long total, String fields, String search) {
  38 + super();
  39 + this.from = from;
  40 + this.size = size;
  41 + this.total = total;
  42 + this.fields = fields;
  43 + this.search = search;
  44 + this.content = content;
  45 + }
  46 +
  47 + public long getTotal() {
  48 + return total;
  49 + }
  50 +
  51 + public void setTotal(long total) {
  52 + this.total = total;
  53 + }
  54 +
  55 + public int getFrom() {
  56 + return from;
  57 + }
  58 +
  59 + public void setFrom(int from) {
  60 + this.from = from;
  61 + }
  62 +
  63 + public int getSize() {
  64 + return size;
  65 + }
  66 +
  67 + public void setSize(int size) {
  68 + this.size = size;
  69 + }
  70 +
  71 + public String getFields() {
  72 + return fields;
  73 + }
  74 +
  75 + public void setFields(String fields) {
  76 + this.fields = fields;
  77 + }
  78 +
  79 + public String getSearch() {
  80 + return search;
  81 + }
  82 +
  83 + public void setSearch(String search) {
  84 + this.search = search;
  85 + }
  86 +
  87 + public List getContent() {
  88 + return content;
  89 + }
  90 +
  91 + public void setContent(List content) {
  92 + this.content = content;
  93 + }
  94 +
  95 +}
demoiselle-persistence-jpa/src/main/java/org/demoiselle/jee/persistence/jpa/crud/package-info.java 0 → 100644
@@ -0,0 +1,11 @@ @@ -0,0 +1,11 @@
  1 +/*
  2 + * Demoiselle Framework
  3 + *
  4 + * License: GNU Lesser General Public License (LGPL), version 3 or later.
  5 + * See the lgpl.txt file in the root directory or <https://www.gnu.org/licenses/lgpl.html>.
  6 + */
  7 +/**
  8 + * Esta pacote tem o objetivo de conter as classes relacionadas aos
  9 + * facilitadores de CRUD do framework Demoiselle.
  10 + */
  11 +package org.demoiselle.jee.persistence.jpa.crud;
0 \ No newline at end of file 12 \ No newline at end of file
demoiselle-persistence-jpa/src/main/java/org/demoiselle/jee/persistence/jpa/exception/DemoisellePersistenceException.java 0 → 100644
@@ -0,0 +1,27 @@ @@ -0,0 +1,27 @@
  1 +/*
  2 + * Demoiselle Framework
  3 + *
  4 + * License: GNU Lesser General Public License (LGPL), version 3 or later.
  5 + * See the lgpl.txt file in the root directory or <https://www.gnu.org/licenses/lgpl.html>.
  6 + */
  7 +package org.demoiselle.jee.persistence.jpa.exception;
  8 +
  9 +import org.demoiselle.jee.core.exception.DemoiselleException;
  10 +
  11 +public class DemoisellePersistenceException extends DemoiselleException {
  12 +
  13 + private static final long serialVersionUID = 1L;
  14 +
  15 + public DemoisellePersistenceException(String message) {
  16 + super(message);
  17 + }
  18 +
  19 + public DemoisellePersistenceException(Throwable cause) {
  20 + super(cause);
  21 + }
  22 +
  23 + public DemoisellePersistenceException(String message, Throwable cause) {
  24 + super(message, cause);
  25 + }
  26 +
  27 +}
demoiselle-persistence-jpa/src/main/java/org/demoiselle/jee/persistence/jpa/exception/package-info.java 0 → 100644
@@ -0,0 +1,11 @@ @@ -0,0 +1,11 @@
  1 +/*
  2 + * Demoiselle Framework
  3 + *
  4 + * License: GNU Lesser General Public License (LGPL), version 3 or later.
  5 + * See the lgpl.txt file in the root directory or <https://www.gnu.org/licenses/lgpl.html>.
  6 + */
  7 +/**
  8 + * Esta pacote tem o objetivo de conter as classes relacionadas as Exceptions da
  9 + * persistencia do framework Demoiselle.
  10 + */
  11 +package org.demoiselle.jee.persistence.jpa.exception;
0 \ No newline at end of file 12 \ No newline at end of file
demoiselle-persistence-jpa/src/main/java/org/demoiselle/jee/persistence/jpa/interceptor/package-info.java 0 → 100644
@@ -0,0 +1,11 @@ @@ -0,0 +1,11 @@
  1 +/*
  2 + * Demoiselle Framework
  3 + *
  4 + * License: GNU Lesser General Public License (LGPL), version 3 or later.
  5 + * See the lgpl.txt file in the root directory or <https://www.gnu.org/licenses/lgpl.html>.
  6 + */
  7 +/**
  8 + * Esta pacote tem o objetivo de conter as classes relacionadas aos
  9 + * interceptadores da persistencia do framework Demoiselle.
  10 + */
  11 +package org.demoiselle.jee.persistence.jpa.interceptor;
0 \ No newline at end of file 12 \ No newline at end of file
demoiselle-security-basic/.gitignore 0 → 100644
@@ -0,0 +1,3 @@ @@ -0,0 +1,3 @@
  1 +/.settings/
  2 +/.classpath
  3 +/.project
demoiselle-security-basic/pom.xml 0 → 100644
@@ -0,0 +1,34 @@ @@ -0,0 +1,34 @@
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  3 + <modelVersion>4.0.0</modelVersion>
  4 + <groupId>org.demoiselle.jee</groupId>
  5 + <artifactId>demoiselle-security-basic</artifactId>
  6 + <version>3.0.0-SNAPSHOT</version>
  7 + <packaging>jar</packaging>
  8 + <properties>
  9 + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  10 + <maven.compiler.source>1.8</maven.compiler.source>
  11 + <maven.compiler.target>1.8</maven.compiler.target>
  12 + </properties>
  13 + <dependencies>
  14 +
  15 + <dependency>
  16 + <groupId>${project.groupId}</groupId>
  17 + <artifactId>demoiselle-core</artifactId>
  18 + <version>${project.version}</version>
  19 + </dependency>
  20 +
  21 + <dependency>
  22 + <groupId>${project.groupId}</groupId>
  23 + <artifactId>demoiselle-ws-jaxrs</artifactId>
  24 + <version>${project.version}</version>
  25 + </dependency>
  26 +
  27 + <dependency>
  28 + <groupId>${project.groupId}</groupId>
  29 + <artifactId>demoiselle-security</artifactId>
  30 + <version>${project.version}</version>
  31 + </dependency>
  32 +
  33 + </dependencies>
  34 +</project>
demoiselle-security-basic/pom.xml~ 0 → 100644
@@ -0,0 +1,34 @@ @@ -0,0 +1,34 @@
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  3 + <modelVersion>4.0.0</modelVersion>
  4 + <groupId>org.demoiselle.jee</groupId>
  5 + <artifactId>demoiselle-security-basic</artifactId>
  6 + <version>3.0.0-SNAPSHOT</version>
  7 + <packaging>jar</packaging>
  8 + <properties>
  9 + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  10 + <maven.compiler.source>1.8</maven.compiler.source>
  11 + <maven.compiler.target>1.8</maven.compiler.target>
  12 + </properties>
  13 + <dependencies>
  14 +
  15 + <dependency>
  16 + <groupId>${project.groupId}</groupId>
  17 + <artifactId>demoiselle-core</artifactId>
  18 + <version>${project.version}</version>
  19 + </dependency>
  20 +
  21 + <dependency>
  22 + <groupId>${project.groupId}</groupId>
  23 + <artifactId>demoiselle-ws</artifactId>
  24 + <version>${project.version}</version>
  25 + </dependency>
  26 +
  27 + <dependency>
  28 + <groupId>${project.groupId}</groupId>
  29 + <artifactId>demoiselle-security</artifactId>
  30 + <version>${project.version}</version>
  31 + </dependency>
  32 +
  33 + </dependencies>
  34 +</project>
demoiselle-security-basic/src/main/java/org/demoiselle/jee/security/basic/impl/TokensManagerImpl.java 0 → 100644
@@ -0,0 +1,51 @@ @@ -0,0 +1,51 @@
  1 +/*
  2 + * To change this license header, choose License Headers in Project Properties.
  3 + * To change this template file, choose Tools | Templates
  4 + * and open the template in the editor.
  5 + */
  6 +package org.demoiselle.jee.security.basic.impl;
  7 +
  8 +import java.security.Principal;
  9 +import java.util.Map;
  10 +import java.util.UUID;
  11 +import java.util.concurrent.ConcurrentHashMap;
  12 +import java.util.logging.Logger;
  13 +import javax.enterprise.context.Dependent;
  14 +import javax.inject.Inject;
  15 +import org.demoiselle.jee.security.Token;
  16 +import org.demoiselle.jee.security.interfaces.TokensManager;
  17 +
  18 +/**
  19 + *
  20 + * @author 70744416353
  21 + */
  22 +@Dependent
  23 +public class TokensManagerImpl implements TokensManager {
  24 +
  25 + private static ConcurrentHashMap<String, Principal> repo = new ConcurrentHashMap<>();
  26 +
  27 + @Inject
  28 + private Logger logger;
  29 +
  30 + @Override
  31 + public Principal getUser(Token token) {
  32 + return repo.get(token.getKey());
  33 + }
  34 +
  35 + @Override
  36 + public Token getToken(Principal user) {
  37 + String value = null;
  38 + if (!repo.containsValue(user)) {
  39 + value = UUID.randomUUID().toString();
  40 + repo.put(value, user);
  41 + } else {
  42 + for (Map.Entry<String, Principal> entry : repo.entrySet()) {
  43 + if (entry.getValue().equals(user)) {
  44 + return entry.getKey();
  45 + }
  46 + }
  47 + }
  48 + return value;
  49 + }
  50 +
  51 +}
demoiselle-security-basic/src/main/resources/demoiselle.properties 0 → 100644
@@ -0,0 +1 @@ @@ -0,0 +1 @@
  1 +user-not-authenticated
0 \ No newline at end of file 2 \ No newline at end of file
demoiselle-security-basic/src/main/resources/messages.properties 0 → 100644
@@ -0,0 +1 @@ @@ -0,0 +1 @@
  1 +tipo-seguranca=basic
0 \ No newline at end of file 2 \ No newline at end of file
demoiselle-security-basic/target/classes/demoiselle.properties 0 → 100644
@@ -0,0 +1 @@ @@ -0,0 +1 @@
  1 +user-not-authenticated
0 \ No newline at end of file 2 \ No newline at end of file
demoiselle-security-basic/target/classes/messages.properties 0 → 100644
@@ -0,0 +1 @@ @@ -0,0 +1 @@
  1 +tipo-seguranca=basic
0 \ No newline at end of file 2 \ No newline at end of file
demoiselle-security-jwt/.gitignore 0 → 100644
@@ -0,0 +1,3 @@ @@ -0,0 +1,3 @@
  1 +/.settings/
  2 +/.classpath
  3 +/.project
demoiselle-security-jwt/pom.xml 0 → 100644
@@ -0,0 +1,41 @@ @@ -0,0 +1,41 @@
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  3 + <modelVersion>4.0.0</modelVersion>
  4 + <groupId>org.demoiselle.jee</groupId>
  5 + <artifactId>demoiselle-security-jwt</artifactId>
  6 + <version>3.0.0-SNAPSHOT</version>
  7 + <packaging>jar</packaging>
  8 + <properties>
  9 + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  10 + <maven.compiler.source>1.8</maven.compiler.source>
  11 + <maven.compiler.target>1.8</maven.compiler.target>
  12 + </properties>
  13 + <dependencies>
  14 +
  15 + <dependency>
  16 + <groupId>${project.groupId}</groupId>
  17 + <artifactId>demoiselle-core</artifactId>
  18 + <version>${project.version}</version>
  19 + </dependency>
  20 +
  21 + <dependency>
  22 + <groupId>${project.groupId}</groupId>
  23 + <artifactId>demoiselle-security</artifactId>
  24 + <version>${project.version}</version>
  25 + </dependency>
  26 +
  27 + <dependency>
  28 + <groupId>org.bitbucket.b_c</groupId>
  29 + <artifactId>jose4j</artifactId>
  30 + <version>0.4.1</version>
  31 + </dependency>
  32 +
  33 + <dependency>
  34 + <groupId>com.google.code.gson</groupId>
  35 + <artifactId>gson</artifactId>
  36 + <version>2.2.2</version>
  37 + <scope>compile</scope>
  38 + </dependency>
  39 +
  40 + </dependencies>
  41 +</project>