Commit fd1fee0978d5576f071fa3019f5a2f81b676297e

Authored by Cleverson Sacramento
1 parent ba243602
Exists in master

Criação da pasta impl contendo o core + extensions e ajustes no assembly

Showing 547 changed files with 28932 additions and 28843 deletions   Show diff stats

Too many changes.

To preserve performance only 100 of 547 files displayed.

assembly/bin.xml 0 → 100644
... ... @@ -0,0 +1,75 @@
  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 +<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  38 + xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
  39 + <id>bin</id>
  40 + <formats>
  41 + <format>zip</format>
  42 + </formats>
  43 + <moduleSets>
  44 + <moduleSet>
  45 + <excludes>
  46 + <exclude>*parent*</exclude>
  47 + <exclude>*aggregator*</exclude>
  48 + <exclude>*archetype*</exclude>
  49 + </excludes>
  50 + <binaries>
  51 + <outputDirectory>${module.artifactId}</outputDirectory>
  52 + <unpack>false</unpack>
  53 + <dependencySets>
  54 + <dependencySet>
  55 + <outputDirectory>/${module.artifactId}/lib</outputDirectory>
  56 + <useTransitiveDependencies>true</useTransitiveDependencies>
  57 + </dependencySet>
  58 + </dependencySets>
  59 + </binaries>
  60 + </moduleSet>
  61 + <moduleSet>
  62 + <excludes>
  63 + <exclude>*parent*</exclude>
  64 + <exclude>*aggregator*</exclude>
  65 + <exclude>*archetype*</exclude>
  66 + </excludes>
  67 + <binaries>
  68 + <attachmentClassifier>javadoc</attachmentClassifier>
  69 + <outputDirectory>${module.artifactId}</outputDirectory>
  70 + <unpack>false</unpack>
  71 + <includeDependencies>false</includeDependencies>
  72 + </binaries>
  73 + </moduleSet>
  74 + </moduleSets>
  75 +</assembly>
... ...
assembly/src.xml 0 → 100644
... ... @@ -0,0 +1,63 @@
  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 +<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  38 + xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
  39 + <id>src</id>
  40 + <formats>
  41 + <format>zip</format>
  42 + </formats>
  43 + <moduleSets>
  44 + <moduleSet>
  45 + <excludes>
  46 + <exclude>*parent*</exclude>
  47 + <exclude>*aggregator*</exclude>
  48 + <exclude>*archetype*</exclude>
  49 + </excludes>
  50 + <sources>
  51 + <fileSets>
  52 + <fileSet>
  53 + <includes>
  54 + <include>pom.xml</include>
  55 + <include>src/**/*</include>
  56 + </includes>
  57 + <useDefaultExcludes>true</useDefaultExcludes>
  58 + </fileSet>
  59 + </fileSets>
  60 + </sources>
  61 + </moduleSet>
  62 + </moduleSets>
  63 +</assembly>
... ...
core/.gitignore
... ... @@ -1,5 +0,0 @@
1   -/target
2   -/.project
3   -/.classpath
4   -/.settings
5   -/.externalToolBuilders
core/pom.xml
... ... @@ -1,167 +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   -<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/maven-v4_0_0.xsd">
38   -
39   - <modelVersion>4.0.0</modelVersion>
40   -
41   - <artifactId>demoiselle-core</artifactId>
42   - <packaging>jar</packaging>
43   -
44   - <parent>
45   - <groupId>br.gov.frameworkdemoiselle</groupId>
46   - <artifactId>demoiselle-parent</artifactId>
47   - <version>2.2.1-SNAPSHOT</version>
48   - <relativePath>../parent/root/pom.xml</relativePath>
49   - </parent>
50   -
51   - <organization>
52   - <name>Serpro</name>
53   - <url>http://www.serpro.gov.br</url>
54   - </organization>
55   -
56   - <name>Core</name>
57   - <description>
58   - Contém funcionalidades comuns a todos os projetos e extensões do framework de forma independente de
59   - camadas de apresentação e persistência.
60   - </description>
61   -
62   - <build>
63   - <plugins>
64   - <plugin>
65   - <groupId>org.apache.maven.plugins</groupId>
66   - <artifactId>maven-compiler-plugin</artifactId>
67   - </plugin>
68   - <plugin>
69   - <groupId>org.apache.maven.plugins</groupId>
70   - <artifactId>maven-javadoc-plugin</artifactId>
71   - </plugin>
72   - <plugin>
73   - <groupId>org.apache.maven.plugins</groupId>
74   - <artifactId>maven-source-plugin</artifactId>
75   - </plugin>
76   - <plugin>
77   - <groupId>org.apache.maven.plugins</groupId>
78   - <artifactId>maven-site-plugin</artifactId>
79   - </plugin>
80   - <plugin>
81   - <groupId>org.codehaus.mojo</groupId>
82   - <artifactId>cobertura-maven-plugin</artifactId>
83   - </plugin>
84   - </plugins>
85   - </build>
86   -
87   - <dependencies>
88   - <dependency>
89   - <groupId>javax.enterprise</groupId>
90   - <artifactId>cdi-api</artifactId>
91   - </dependency>
92   - <dependency>
93   - <artifactId>validation-api</artifactId>
94   - <groupId>javax.validation</groupId>
95   - </dependency>
96   - <dependency>
97   - <groupId>org.slf4j</groupId>
98   - <artifactId>slf4j-api</artifactId>
99   - </dependency>
100   - <dependency>
101   - <groupId>commons-configuration</groupId>
102   - <artifactId>commons-configuration</artifactId>
103   - <exclusions>
104   - <exclusion>
105   - <artifactId>commons-digester</artifactId>
106   - <groupId>commons-digester</groupId>
107   - </exclusion>
108   - <exclusion>
109   - <artifactId>log4j</artifactId>
110   - <groupId>log4j</groupId>
111   - </exclusion>
112   - <exclusion>
113   - <artifactId>servlet-api</artifactId>
114   - <groupId>javax.servlet</groupId>
115   - </exclusion>
116   - <exclusion>
117   - <artifactId>logkit</artifactId>
118   - <groupId>logkit</groupId>
119   - </exclusion>
120   - <exclusion>
121   - <artifactId>avalon-framework</artifactId>
122   - <groupId>avalon-framework</groupId>
123   - </exclusion>
124   - </exclusions>
125   - </dependency>
126   -
127   - <!-- for tests -->
128   - <dependency>
129   - <groupId>junit</groupId>
130   - <artifactId>junit</artifactId>
131   - <scope>test</scope>
132   - </dependency>
133   - <dependency>
134   - <groupId>org.easymock</groupId>
135   - <artifactId>easymock</artifactId>
136   - <scope>test</scope>
137   - </dependency>
138   - <dependency>
139   - <groupId>org.powermock</groupId>
140   - <artifactId>powermock-module-junit4</artifactId>
141   - <scope>test</scope>
142   - </dependency>
143   - <dependency>
144   - <groupId>org.powermock</groupId>
145   - <artifactId>powermock-api-easymock</artifactId>
146   - <scope>test</scope>
147   - </dependency>
148   - <dependency>
149   - <groupId>javax.el</groupId>
150   - <artifactId>el-api</artifactId>
151   - <scope>test</scope>
152   - </dependency>
153   - <dependency>
154   - <groupId>org.slf4j</groupId>
155   - <artifactId>slf4j-log4j12</artifactId>
156   - <scope>test</scope>
157   - </dependency>
158   - </dependencies>
159   -
160   - <repositories>
161   - <repository>
162   - <id>demoiselle.sourceforge.net</id>
163   - <name>Demoiselle Maven Repository</name>
164   - <url>http://demoiselle.sourceforge.net/repository/release</url>
165   - </repository>
166   - </repositories>
167   -</project>
core/src/main/java/br/gov/frameworkdemoiselle/DemoiselleException.java
... ... @@ -1,79 +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 br.gov.frameworkdemoiselle;
38   -
39   -/**
40   - * Exception class intended to be used by framework configuration and to be derived by other framework exceptions.
41   - *
42   - * @author SERPRO
43   - */
44   -public class DemoiselleException extends RuntimeException {
45   -
46   - private static final long serialVersionUID = 1L;
47   -
48   - /**
49   - * Constructor with message.
50   - *
51   - * @param message
52   - * exception message
53   - */
54   - public DemoiselleException(String message) {
55   - super(message);
56   - }
57   -
58   - /**
59   - * Constructor with cause.
60   - *
61   - * @param cause
62   - * exception cause
63   - */
64   - public DemoiselleException(Throwable cause) {
65   - super(cause);
66   - }
67   -
68   - /**
69   - * Constructor with message and cause.
70   - *
71   - * @param message
72   - * exception message
73   - * @param cause
74   - * exception cause
75   - */
76   - public DemoiselleException(String message, Throwable cause) {
77   - super(message, cause);
78   - }
79   -}
core/src/main/java/br/gov/frameworkdemoiselle/annotation/Ignore.java
... ... @@ -1,48 +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 br.gov.frameworkdemoiselle.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   -@Target(FIELD)
46   -@Retention(RUNTIME)
47   -public @interface Ignore {
48   -}
core/src/main/java/br/gov/frameworkdemoiselle/annotation/Name.java
... ... @@ -1,59 +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 br.gov.frameworkdemoiselle.annotation;
38   -
39   -import static java.lang.annotation.ElementType.FIELD;
40   -import static java.lang.annotation.ElementType.METHOD;
41   -import static java.lang.annotation.ElementType.PARAMETER;
42   -import static java.lang.annotation.ElementType.TYPE;
43   -import static java.lang.annotation.RetentionPolicy.RUNTIME;
44   -
45   -import java.lang.annotation.Inherited;
46   -import java.lang.annotation.Retention;
47   -import java.lang.annotation.Target;
48   -
49   -import javax.enterprise.util.Nonbinding;
50   -
51   -@Inherited
52   -@Retention(RUNTIME)
53   -@Target({ TYPE, FIELD, METHOD, PARAMETER })
54   -public @interface Name {
55   -
56   - @Nonbinding
57   - String value();
58   -
59   -}
core/src/main/java/br/gov/frameworkdemoiselle/annotation/Shutdown.java
... ... @@ -1,91 +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 br.gov.frameworkdemoiselle.annotation;
38   -
39   -import static java.lang.annotation.ElementType.METHOD;
40   -import static java.lang.annotation.RetentionPolicy.RUNTIME;
41   -
42   -import java.lang.annotation.Retention;
43   -import java.lang.annotation.Target;
44   -
45   -/**
46   - * Identifies a method eligible to be executed automatically during <b>application finalization</b>.
47   - * <p>
48   - * Take a look at the following usage sample:
49   - * <p>
50   - * <blockquote>
51   - *
52   - * <pre>
53   - * public class Finalizer {
54   - *
55   - * &#064;Shutdown(priority = 5)
56   - * public void finalize() {
57   - * ...
58   - * }
59   - * }
60   - *
61   - *
62   - *
63   - * </pre>
64   - *
65   - * </blockquote>
66   - * <p>
67   - * The <code>@Shutdown</code> annotation allows an integer value to be defined, which stands for the method execution
68   - * priority when several finalizer classes are available in the application.
69   - *
70   - * @author SERPRO
71   - */
72   -@Target(METHOD)
73   -@Retention(RUNTIME)
74   -public @interface Shutdown {
75   -
76   - /**
77   - * Most important priority value.
78   - */
79   - public static int MAX_PRIORITY = Integer.MIN_VALUE;
80   -
81   - /**
82   - * Less important priority value.
83   - */
84   - public static int MIN_PRIORITY = Integer.MAX_VALUE;
85   -
86   - /**
87   - * An integer value defines method execution order (i.e., priority).
88   - */
89   - int priority() default MIN_PRIORITY;
90   -
91   -}
core/src/main/java/br/gov/frameworkdemoiselle/annotation/Startup.java
... ... @@ -1,90 +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 br.gov.frameworkdemoiselle.annotation;
38   -
39   -import static java.lang.annotation.ElementType.METHOD;
40   -import static java.lang.annotation.RetentionPolicy.RUNTIME;
41   -
42   -import java.lang.annotation.Retention;
43   -import java.lang.annotation.Target;
44   -
45   -/**
46   - * Identifies a method eligible to be executed automatically during <b>application initialization</b>.
47   - * <p>
48   - * Take a look at the following usage sample:
49   - * <p>
50   - * <blockquote>
51   - *
52   - * <pre>
53   - * public class Initializer {
54   - *
55   - * &#064;Startup(priority = 1)
56   - * public void initialize() {
57   - * ...
58   - * }
59   - * }
60   - *
61   - *
62   - * </pre>
63   - *
64   - * </blockquote>
65   - * <p>
66   - * The <code>@Startup</code> annotation allows an integer value to be defined, which stands for the method execution
67   - * priority when several initializer classes are available in the application.
68   - *
69   - * @author SERPRO
70   - */
71   -@Target(METHOD)
72   -@Retention(RUNTIME)
73   -public @interface Startup {
74   -
75   - /**
76   - * Most important priority value.
77   - */
78   - public static int MAX_PRIORITY = Integer.MIN_VALUE;
79   -
80   - /**
81   - * Less important priority value.
82   - */
83   - public static int MIN_PRIORITY = Integer.MAX_VALUE;
84   -
85   - /**
86   - * An integer value defines method execution order (i.e., priority).
87   - */
88   - int priority() default MIN_PRIORITY;
89   -
90   -}
core/src/main/java/br/gov/frameworkdemoiselle/annotation/ViewScoped.java
... ... @@ -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 br.gov.frameworkdemoiselle.annotation;
38   -
39   -import static java.lang.annotation.ElementType.FIELD;
40   -import static java.lang.annotation.ElementType.METHOD;
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.enterprise.context.NormalScope;
49   -
50   -@Inherited
51   -@Target({ METHOD, TYPE, FIELD })
52   -@Retention(RUNTIME)
53   -@NormalScope
54   -public @interface ViewScoped {
55   -
56   -}
core/src/main/java/br/gov/frameworkdemoiselle/configuration/ConfigType.java
... ... @@ -1,61 +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 br.gov.frameworkdemoiselle.configuration;
38   -
39   -/**
40   - * Defines configuration types to be loaded.
41   - *
42   - * @author SERPRO
43   - */
44   -public enum ConfigType {
45   -
46   - /**
47   - * Configuration loaded on {@link System#getProperties()} or {@link System#getenv()}.
48   - */
49   - SYSTEM,
50   -
51   - /**
52   - * Configuration loaded on XML resources.
53   - */
54   - XML,
55   -
56   - /**
57   - * Configuration loaded on properties resources.
58   - */
59   - PROPERTIES;
60   -
61   -}
core/src/main/java/br/gov/frameworkdemoiselle/configuration/Configuration.java
... ... @@ -1,106 +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 br.gov.frameworkdemoiselle.configuration;
38   -
39   -import static java.lang.annotation.ElementType.TYPE;
40   -import static java.lang.annotation.RetentionPolicy.RUNTIME;
41   -
42   -import java.lang.annotation.Inherited;
43   -import java.lang.annotation.Retention;
44   -import java.lang.annotation.Target;
45   -
46   -import javax.enterprise.inject.Stereotype;
47   -import javax.inject.Singleton;
48   -
49   -/**
50   - * Identifies a <b>configuration class</b>, that is, a structure reserved to store configuration values retrieved from a
51   - * given resource file or system variables.
52   - * <p>
53   - * This class is gonna have a single instance throughout the application, as stated by the <b>singleton</b> design
54   - * pattern approach.
55   - * <p>
56   - * A <i>Configuration</i> is:
57   - * <ul>
58   - * <li>defined when annotated with {@code @Configuration}</li>
59   - * <li>automatically injected whenever {@code @Inject} is used</li>
60   - * </ul>
61   - *
62   - * @author SERPRO
63   - */
64   -@Singleton
65   -@Stereotype
66   -@Inherited
67   -@Target(TYPE)
68   -@Retention(RUNTIME)
69   -public @interface Configuration {
70   -
71   - public static final String DEFAULT_RESOURCE = "demoiselle";
72   -
73   - /**
74   - * Defines the resource type to be used: a properties file, an XML file, or system variables.
75   - * <p>
76   - * If not specified, a properties resource file is to be considered.
77   - *
78   - * @return ConfigType
79   - */
80   - ConfigType type() default ConfigType.PROPERTIES;
81   -
82   - /**
83   - * Defines an optional prefix to be used on every parameter key.
84   - * <p>
85   - * For instance, if prefix is set to <code>"frameworkdemoiselle.pagination"</code> and an attribute named
86   - * <code>defaultPageSize</code> is found in the class, the corresponding key
87   - * <code>frameworkdemoiselle.pagination.defaultPageSize</code> is expected to be read in the resource file.
88   - *
89   - * @return String
90   - */
91   - String prefix() default "";
92   -
93   - /**
94   - * Defines the resource file name to be read by this configuration class. There is no need to specify file extension
95   - * in the case of properties or XML resources.
96   - * <p>
97   - * For instance, when resource is set to <code>"bookmark"</code> and the type set to properties, a corresponding
98   - * file named <code>bookmark.properties</code> is considered.
99   - * <p>
100   - * If not specified, the default configuration file <code>demoiselle.properties</code> is rather considered.
101   - *
102   - * @return String
103   - */
104   - String resource() default DEFAULT_RESOURCE;
105   -
106   -}
core/src/main/java/br/gov/frameworkdemoiselle/configuration/ConfigurationException.java
... ... @@ -1,72 +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 br.gov.frameworkdemoiselle.configuration;
38   -
39   -import br.gov.frameworkdemoiselle.DemoiselleException;
40   -
41   -/**
42   - * Exception class intended to be used by configuration components.
43   - *
44   - * @author SERPRO
45   - */
46   -public class ConfigurationException extends DemoiselleException {
47   -
48   - private static final long serialVersionUID = 1L;
49   -
50   - /**
51   - * Constructor with message.
52   - *
53   - * @param message
54   - * exception message
55   - */
56   - public ConfigurationException(String message) {
57   - super(message);
58   - }
59   -
60   - /**
61   - * Constructor with message and cause.
62   - *
63   - * @param message
64   - * exception message
65   - * @param cause
66   - * exception cause
67   - */
68   - public ConfigurationException(String message, Throwable cause) {
69   - super(message, cause);
70   - }
71   -
72   -}
core/src/main/java/br/gov/frameworkdemoiselle/exception/ApplicationException.java
... ... @@ -1,75 +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 br.gov.frameworkdemoiselle.exception;
38   -
39   -import static java.lang.annotation.ElementType.TYPE;
40   -import static java.lang.annotation.RetentionPolicy.RUNTIME;
41   -
42   -import java.lang.annotation.Inherited;
43   -import java.lang.annotation.Retention;
44   -import java.lang.annotation.Target;
45   -
46   -import javax.enterprise.inject.Stereotype;
47   -
48   -import br.gov.frameworkdemoiselle.message.SeverityType;
49   -
50   -/**
51   - * Annotation to be used in application exceptions. Exceptions marked with this annotation can receive special treatment
52   - * like transaction management and special messages based on severity type attribute.
53   - *
54   - * @author CETEC
55   - */
56   -@Stereotype
57   -@Inherited
58   -@Target(TYPE)
59   -@Retention(RUNTIME)
60   -public @interface ApplicationException {
61   -
62   - /**
63   - * When raised, the exception that uses this annotation must cause a rollback in the current transaction?
64   - *
65   - * @return True if current transaction must be rolledback
66   - */
67   - boolean rollback() default true;
68   -
69   - /**
70   - * Exception Severity.
71   - *
72   - * @return
73   - */
74   - SeverityType severity() default SeverityType.INFO;
75   -}
core/src/main/java/br/gov/frameworkdemoiselle/exception/ExceptionHandler.java
... ... @@ -1,66 +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 br.gov.frameworkdemoiselle.exception;
38   -
39   -import static java.lang.annotation.ElementType.METHOD;
40   -import static java.lang.annotation.RetentionPolicy.RUNTIME;
41   -
42   -import java.lang.annotation.Inherited;
43   -import java.lang.annotation.Retention;
44   -import java.lang.annotation.Target;
45   -
46   -import br.gov.frameworkdemoiselle.stereotype.BusinessController;
47   -import br.gov.frameworkdemoiselle.stereotype.PersistenceController;
48   -import br.gov.frameworkdemoiselle.stereotype.ViewController;
49   -
50   -/**
51   - * <p>
52   - * Should be used exclusively with controller objects, i.e., classes annotated with {@link ViewController},
53   - * {@link BusinessController}, or {@link PersistenceController}.
54   - * </p>
55   - * <p>
56   - * Methods that use this annotation will automatically handle all exceptions of a specific type thrown by the method
57   - * owner class.
58   - * </p>
59   - *
60   - * @author SERPRO
61   - */
62   -@Inherited
63   -@Target(METHOD)
64   -@Retention(RUNTIME)
65   -public @interface ExceptionHandler {
66   -}
core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/AbstractBootstrap.java
... ... @@ -1,77 +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 br.gov.frameworkdemoiselle.internal.bootstrap;
38   -
39   -import javax.enterprise.inject.spi.AfterBeanDiscovery;
40   -import javax.enterprise.inject.spi.Extension;
41   -
42   -import org.slf4j.Logger;
43   -
44   -import br.gov.frameworkdemoiselle.internal.context.Contexts;
45   -import br.gov.frameworkdemoiselle.internal.context.CustomContext;
46   -import br.gov.frameworkdemoiselle.internal.producer.LoggerProducer;
47   -import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer;
48   -import br.gov.frameworkdemoiselle.util.ResourceBundle;
49   -
50   -public class AbstractBootstrap implements Extension {
51   -
52   - private static ResourceBundleProducer bundleFactory = new ResourceBundleProducer();
53   -
54   - protected static ResourceBundle getBundle() {
55   - return getBundle("demoiselle-core-bundle");
56   - }
57   -
58   - protected static ResourceBundle getBundle(String baseName) {
59   - return bundleFactory.create(baseName);
60   - }
61   -
62   - protected static Logger getLogger() {
63   - return LoggerProducer.create(AbstractBootstrap.class);
64   - }
65   -
66   - protected static void addContext(final CustomContext context, final AfterBeanDiscovery event) {
67   - Contexts.add(context, event);
68   - getLogger()
69   - .trace(getBundle().getString("custom-context-was-registered", context.getScope().getCanonicalName()));
70   - }
71   -
72   - protected static void disableContext(final CustomContext context) {
73   - Contexts.remove(context);
74   - getLogger()
75   - .trace(getBundle().getString("custom-context-was-registered", context.getScope().getCanonicalName()));
76   - }
77   -}
core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/ConfigurationBootstrap.java
... ... @@ -1,95 +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 br.gov.frameworkdemoiselle.internal.bootstrap;
38   -
39   -import java.util.ArrayList;
40   -import java.util.Collections;
41   -import java.util.List;
42   -
43   -import javax.enterprise.context.RequestScoped;
44   -import javax.enterprise.context.SessionScoped;
45   -import javax.enterprise.event.Observes;
46   -import javax.enterprise.inject.spi.AfterBeanDiscovery;
47   -import javax.enterprise.inject.spi.AfterDeploymentValidation;
48   -import javax.enterprise.inject.spi.AnnotatedType;
49   -import javax.enterprise.inject.spi.BeanManager;
50   -import javax.enterprise.inject.spi.ProcessAnnotatedType;
51   -
52   -import br.gov.frameworkdemoiselle.configuration.Configuration;
53   -import br.gov.frameworkdemoiselle.configuration.ConfigurationException;
54   -import br.gov.frameworkdemoiselle.internal.configuration.ConfigurationLoader;
55   -import br.gov.frameworkdemoiselle.internal.context.ThreadLocalContext;
56   -import br.gov.frameworkdemoiselle.util.Beans;
57   -
58   -/**
59   - * @author SERPRO
60   - */
61   -public class ConfigurationBootstrap extends AbstractBootstrap {
62   -
63   - private static List<AnnotatedType<?>> types = Collections.synchronizedList(new ArrayList<AnnotatedType<?>>());
64   -
65   - private static final String MSG_PROCESSING = "bootstrap.configuration.processing";
66   -
67   - private ThreadLocalContext c1;
68   -
69   - private ThreadLocalContext c2;
70   -
71   - public <T> void detectAnnotation(@Observes final ProcessAnnotatedType<T> event, final BeanManager beanManager) {
72   - if (event.getAnnotatedType().isAnnotationPresent(Configuration.class)) {
73   - types.add(event.getAnnotatedType());
74   - }
75   - }
76   -
77   - public void loadTempContexts(@Observes final AfterBeanDiscovery event) {
78   - c1 = new ThreadLocalContext(RequestScoped.class);
79   - addContext(c1, event);
80   - c2 = new ThreadLocalContext(SessionScoped.class);
81   - addContext(c2, event);
82   - }
83   -
84   - public void processLoader(@Observes final AfterDeploymentValidation event)
85   - throws ConfigurationException {
86   - ConfigurationLoader configurationLoader = Beans.getReference(ConfigurationLoader.class);
87   - for (AnnotatedType<?> type : types) {
88   - getLogger().debug(getBundle().getString(MSG_PROCESSING, type.toString()));
89   - configurationLoader.load(Beans.getReference(type.getJavaClass()));
90   - }
91   - disableContext(c1);
92   - disableContext(c2);
93   - }
94   -
95   -}
core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/CoreBootstrap.java
... ... @@ -1,94 +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 br.gov.frameworkdemoiselle.internal.bootstrap;
38   -
39   -import java.util.HashMap;
40   -import java.util.Map;
41   -
42   -import javax.enterprise.event.Observes;
43   -import javax.enterprise.inject.spi.AfterDeploymentValidation;
44   -import javax.enterprise.inject.spi.AnnotatedType;
45   -import javax.enterprise.inject.spi.BeanManager;
46   -import javax.enterprise.inject.spi.BeforeBeanDiscovery;
47   -import javax.enterprise.inject.spi.BeforeShutdown;
48   -import javax.enterprise.inject.spi.ProcessAnnotatedType;
49   -
50   -import org.slf4j.Logger;
51   -
52   -import br.gov.frameworkdemoiselle.util.Beans;
53   -
54   -//TODO Inter [NQ]: verificar o melhor nome para todas as classes desta natureza.
55   -public class CoreBootstrap extends AbstractBootstrap {
56   -
57   - private static final Map<Class<?>, AnnotatedType<?>> beans = new HashMap<Class<?>, AnnotatedType<?>>();
58   -
59   - public static boolean isAnnotatedType(Class<?> type) {
60   - return beans.containsKey(type);
61   - }
62   -
63   - public void engineOn(@Observes final BeforeBeanDiscovery event, BeanManager beanManager) {
64   - String description;
65   - Logger log = getLogger();
66   -
67   - description = getBundle("demoiselle-core-bundle").getString("engine-on");
68   - log.info(description);
69   -
70   - Beans.setBeanManager(beanManager);
71   -
72   - description = getBundle("demoiselle-core-bundle").getString("setting-up-bean-manager",
73   - Beans.class.getCanonicalName());
74   - log.info(description);
75   - }
76   -
77   - protected <T> void detectAnnotation(@Observes final ProcessAnnotatedType<T> event) {
78   - beans.put(event.getAnnotatedType().getJavaClass(), event.getAnnotatedType());
79   - }
80   -
81   - public static void takeOff(@Observes final AfterDeploymentValidation event) {
82   - String description = getBundle("demoiselle-core-bundle").getString("taking-off");
83   -
84   - Logger log = getLogger();
85   - log.info(description);
86   - }
87   -
88   - public static void engineOff(@Observes final BeforeShutdown event) {
89   - String description = getBundle("demoiselle-core-bundle").getString("engine-off");
90   -
91   - Logger log = getLogger();
92   - log.info(description);
93   - }
94   -}
core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/ShutdownBootstrap.java
... ... @@ -1,138 +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 br.gov.frameworkdemoiselle.internal.bootstrap;
38   -
39   -import java.lang.annotation.Annotation;
40   -import java.util.ArrayList;
41   -import java.util.Collections;
42   -import java.util.List;
43   -
44   -import javax.enterprise.context.ConversationScoped;
45   -import javax.enterprise.context.RequestScoped;
46   -import javax.enterprise.context.SessionScoped;
47   -import javax.enterprise.event.Observes;
48   -import javax.enterprise.inject.spi.AfterBeanDiscovery;
49   -import javax.enterprise.inject.spi.AnnotatedMethod;
50   -import javax.enterprise.inject.spi.AnnotatedType;
51   -import javax.enterprise.inject.spi.BeanManager;
52   -import javax.enterprise.inject.spi.BeforeShutdown;
53   -import javax.enterprise.inject.spi.ProcessAnnotatedType;
54   -
55   -import br.gov.frameworkdemoiselle.annotation.Shutdown;
56   -import br.gov.frameworkdemoiselle.annotation.ViewScoped;
57   -import br.gov.frameworkdemoiselle.internal.context.ThreadLocalContext;
58   -import br.gov.frameworkdemoiselle.internal.context.CustomContext;
59   -import br.gov.frameworkdemoiselle.internal.processor.ShutdownProcessor;
60   -
61   -/**
62   - * This class run at application shutdown
63   - */
64   -public class ShutdownBootstrap extends AbstractBootstrap {
65   -
66   - private static final Class<? extends Annotation> annotationClass = Shutdown.class;
67   -
68   - private static final List<CustomContext> tempContexts = new ArrayList<CustomContext>();
69   -
70   - @SuppressWarnings("rawtypes")
71   - private static final List<ShutdownProcessor> processors = Collections
72   - .synchronizedList(new ArrayList<ShutdownProcessor>());
73   -
74   - private static AfterBeanDiscovery event;
75   -
76   - /**
77   - * Observes all methods annotated with @Shutdown and create an instance of ShutdownProcessor for them
78   - *
79   - * @param <T>
80   - * @param event
81   - * @param beanManager
82   - */
83   - public <T> void processAnnotatedType(@Observes final ProcessAnnotatedType<T> event, final BeanManager beanManager) {
84   - final AnnotatedType<T> annotatedType = event.getAnnotatedType();
85   - for (AnnotatedMethod<?> am : annotatedType.getMethods()) {
86   - if (am.isAnnotationPresent(annotationClass)) {
87   - @SuppressWarnings("unchecked")
88   - AnnotatedMethod<T> annotatedMethod = (AnnotatedMethod<T>) am;
89   - processors.add(new ShutdownProcessor<T>(annotatedMethod, beanManager));
90   - }
91   - }
92   - }
93   -
94   - public void saveEvent(@Observes final AfterBeanDiscovery event) {
95   - ShutdownBootstrap.event = event;
96   - }
97   -
98   - public static void loadTempContexts(final AfterBeanDiscovery event) {
99   - // Não registrar o contexto de aplicação pq ele já é registrado pela
100   - // implementação do CDI
101   - tempContexts.add(new ThreadLocalContext(ViewScoped.class));
102   - tempContexts.add(new ThreadLocalContext(SessionScoped.class, false));
103   - tempContexts.add(new ThreadLocalContext(ConversationScoped.class));
104   - tempContexts.add(new ThreadLocalContext(RequestScoped.class));
105   -
106   - for (CustomContext tempContext : tempContexts) {
107   - addContext(tempContext, event);
108   - }
109   - }
110   -
111   - /**
112   - * Before Shutdown it execute the methods annotateds with @Shutdown considering the priority order;
113   - *
114   - * @param event
115   - * @throws Exception
116   - */
117   - @SuppressWarnings("unchecked")
118   - public static void shuttingDown(@Observes final BeforeShutdown event) throws Throwable {
119   - loadTempContexts(ShutdownBootstrap.event);
120   -
121   - getLogger().debug(
122   - getBundle("demoiselle-core-bundle").getString("executing-all", annotationClass.getSimpleName()));
123   - Collections.sort(processors);
124   -
125   - for (ShutdownProcessor<?> processor : processors) {
126   - processor.process();
127   - }
128   -
129   - processors.clear();
130   - unloadTempContexts();
131   - }
132   -
133   - private static void unloadTempContexts() {
134   - for (CustomContext tempContext : tempContexts) {
135   - disableContext(tempContext);
136   - }
137   - }
138   -}
core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/StartupBootstrap.java
... ... @@ -1,128 +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 br.gov.frameworkdemoiselle.internal.bootstrap;
38   -
39   -import java.lang.annotation.Annotation;
40   -import java.util.ArrayList;
41   -import java.util.Collections;
42   -import java.util.List;
43   -
44   -import javax.enterprise.context.ConversationScoped;
45   -import javax.enterprise.context.RequestScoped;
46   -import javax.enterprise.context.SessionScoped;
47   -import javax.enterprise.event.Observes;
48   -import javax.enterprise.inject.spi.AfterBeanDiscovery;
49   -import javax.enterprise.inject.spi.AfterDeploymentValidation;
50   -import javax.enterprise.inject.spi.AnnotatedMethod;
51   -import javax.enterprise.inject.spi.AnnotatedType;
52   -import javax.enterprise.inject.spi.BeanManager;
53   -import javax.enterprise.inject.spi.ProcessAnnotatedType;
54   -
55   -import br.gov.frameworkdemoiselle.annotation.Startup;
56   -import br.gov.frameworkdemoiselle.annotation.ViewScoped;
57   -import br.gov.frameworkdemoiselle.internal.context.ThreadLocalContext;
58   -import br.gov.frameworkdemoiselle.internal.processor.StartupProcessor;
59   -
60   -/**
61   - * This class is the bootstrap to execute the processes at load time.
62   - */
63   -public class StartupBootstrap extends AbstractBootstrap {
64   -
65   - private static final Class<? extends Annotation> annotationClass = Startup.class;
66   -
67   - private final List<ThreadLocalContext> tempContexts = new ArrayList<ThreadLocalContext>();
68   -
69   - @SuppressWarnings("rawtypes")
70   - private static final List<StartupProcessor> processors = Collections
71   - .synchronizedList(new ArrayList<StartupProcessor>());
72   -
73   - /**
74   - * Observes all methods annotated with @Startup and create an instance of StartupAction for them
75   - *
76   - * @param <T>
77   - * @param event
78   - * @param beanManager
79   - */
80   - public <T> void processAnnotatedType(@Observes final ProcessAnnotatedType<T> event, final BeanManager beanManager) {
81   - final AnnotatedType<T> annotatedType = event.getAnnotatedType();
82   - for (AnnotatedMethod<?> am : annotatedType.getMethods()) {
83   - if (am.isAnnotationPresent(annotationClass)) {
84   - @SuppressWarnings("unchecked")
85   - AnnotatedMethod<T> annotatedMethod = (AnnotatedMethod<T>) am;
86   - processors.add(new StartupProcessor<T>(annotatedMethod, beanManager));
87   - }
88   - }
89   - }
90   -
91   - public void loadTempContexts(@Observes final AfterBeanDiscovery event) {
92   - //Não registrar o contexto de aplicação pq ele já é registrado pela implementação do CDI
93   - this.tempContexts.add(new ThreadLocalContext(ViewScoped.class));
94   - this.tempContexts.add(new ThreadLocalContext(SessionScoped.class));
95   - this.tempContexts.add(new ThreadLocalContext(ConversationScoped.class));
96   - this.tempContexts.add(new ThreadLocalContext(RequestScoped.class));
97   -
98   - for (ThreadLocalContext tempContext : this.tempContexts) {
99   - addContext(tempContext, event);
100   - }
101   - }
102   -
103   - /**
104   - * After the deployment validation it execute the methods annotateds with @Startup considering the priority order;
105   - *
106   - * @param event
107   - * @throws Exception
108   - * @throws StartupException
109   - */
110   - @SuppressWarnings("unchecked")
111   - public void startup(@Observes final AfterDeploymentValidation event) throws Throwable {
112   - getLogger().debug(
113   - getBundle("demoiselle-core-bundle").getString("executing-all", annotationClass.getSimpleName()));
114   - Collections.sort(processors);
115   -
116   - for (StartupProcessor<?> action : processors) {
117   - action.process();
118   - }
119   - processors.clear();
120   - unloadTempContexts();
121   - }
122   -
123   - private void unloadTempContexts() {
124   - for (ThreadLocalContext tempContext : this.tempContexts) {
125   - disableContext(tempContext);
126   - }
127   - }
128   -}
core/src/main/java/br/gov/frameworkdemoiselle/internal/configuration/ConfigurationLoader.java
... ... @@ -1,301 +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 br.gov.frameworkdemoiselle.internal.configuration;
38   -
39   -import java.lang.reflect.Field;
40   -import java.lang.reflect.Method;
41   -import java.util.HashSet;
42   -import java.util.Iterator;
43   -import java.util.Properties;
44   -import java.util.Set;
45   -
46   -import javax.inject.Inject;
47   -import javax.validation.constraints.NotNull;
48   -
49   -import org.apache.commons.configuration.PropertiesConfiguration;
50   -import org.apache.commons.configuration.SystemConfiguration;
51   -import org.apache.commons.configuration.XMLConfiguration;
52   -import org.slf4j.Logger;
53   -
54   -import br.gov.frameworkdemoiselle.annotation.Ignore;
55   -import br.gov.frameworkdemoiselle.annotation.Name;
56   -import br.gov.frameworkdemoiselle.configuration.ConfigType;
57   -import br.gov.frameworkdemoiselle.configuration.Configuration;
58   -import br.gov.frameworkdemoiselle.configuration.ConfigurationException;
59   -import br.gov.frameworkdemoiselle.internal.bootstrap.CoreBootstrap;
60   -import br.gov.frameworkdemoiselle.util.Reflections;
61   -import br.gov.frameworkdemoiselle.util.ResourceBundle;
62   -import br.gov.frameworkdemoiselle.util.Strings;
63   -
64   -/**
65   - * This component loads a config class annotated with {@link Configuration} by filling its attributes with {@link Param}
66   - * according to a {@link ConfigType}.
67   - *
68   - * @author SERPRO
69   - */
70   -public class ConfigurationLoader {
71   -
72   - @Inject
73   - @Name("demoiselle-core-bundle")
74   - private ResourceBundle bundle;
75   -
76   - @Inject
77   - private Logger logger;
78   -
79   - /**
80   - * Loads a config class filling it with the corresponding values.
81   - *
82   - * @param object
83   - * config object
84   - * @throws ConfigurationException
85   - */
86   - public void load(Object object) throws ConfigurationException {
87   - Class<?> config = object.getClass();
88   -
89   - if (!CoreBootstrap.isAnnotatedType(config)) {
90   - config = config.getSuperclass();
91   - logger.debug(bundle.getString("proxy-detected", config, config.getClass().getSuperclass()));
92   - }
93   -
94   - logger.debug(bundle.getString("loading-configuration-class", config.getName()));
95   -
96   - for (Field field : Reflections.getNonStaticDeclaredFields(config)) {
97   - loadField(field, object, config);
98   - }
99   - }
100   -
101   - private void loadField(Field field, Object object, Class<?> clazz) {
102   - if (!field.isAnnotationPresent(Ignore.class) && clazz.isAnnotationPresent(Configuration.class)) {
103   - String resource = clazz.getAnnotation(Configuration.class).resource();
104   - ConfigType type = clazz.getAnnotation(Configuration.class).type();
105   - org.apache.commons.configuration.Configuration config = getConfiguration(resource, type);
106   -
107   - String key = getKey(field, clazz, config);
108   - Object value = getValue(key, field.getType(), config);
109   -
110   - validate(field, key, value, resource);
111   - setValue(field, key, object, value);
112   - }
113   - }
114   -
115   - private void setValue(Field field, String key, Object object, Object value) {
116   - if (value != null) {
117   - Reflections.setFieldValue(field, object, value);
118   - logger.debug(bundle.getString("configuration-field-loaded", key, field.getName(), value));
119   - }
120   - }
121   -
122   - private void validate(Field field, String key, Object value, String resource) {
123   - if (field.isAnnotationPresent(NotNull.class) && value == null) {
124   - throw new ConfigurationException(bundle.getString("configuration-attribute-is-mandatory", key, resource));
125   - }
126   - }
127   -
128   - private String getKey(final Field field, final Class<?> clazz,
129   - final org.apache.commons.configuration.Configuration config) {
130   -
131   - final String prefix = getPrefix(field, clazz);
132   - final StringBuffer key = new StringBuffer();
133   -
134   - key.append(prefix);
135   -
136   - if (field.isAnnotationPresent(Name.class)) {
137   - key.append(getKeyByAnnotation(field));
138   - } else {
139   - key.append(getKeyByConvention(field, prefix, config));
140   - }
141   -
142   - return key.toString();
143   - }
144   -
145   - private String getPrefix(Field field, Class<?> type) {
146   - String prefix = "";
147   -
148   - Configuration classAnnotation = type.getAnnotation(Configuration.class);
149   - if (!Strings.isEmpty(classAnnotation.prefix())) {
150   - prefix = classAnnotation.prefix() + ".";
151   - }
152   -
153   - return prefix;
154   - }
155   -
156   - private String getKeyByAnnotation(Field field) {
157   - String key = null;
158   -
159   - Name nameAnnotation = field.getAnnotation(Name.class);
160   - if (Strings.isEmpty(nameAnnotation.value())) {
161   - throw new ConfigurationException(bundle.getString("configuration-name-attribute-cant-be-empty"));
162   - } else {
163   - key = nameAnnotation.value();
164   - }
165   -
166   - return key;
167   - }
168   -
169   - private String getKeyByConvention(Field field, String prefix, org.apache.commons.configuration.Configuration config) {
170   -
171   - Set<String> conventions = new HashSet<String>();
172   - conventions.add(field.getName());
173   - conventions.add(Strings.camelCaseToSymbolSeparated(field.getName(), "."));
174   - conventions.add(Strings.camelCaseToSymbolSeparated(field.getName(), "_"));
175   - conventions.add(field.getName().toLowerCase());
176   - conventions.add(field.getName().toUpperCase());
177   -
178   - int matches = 0;
179   - String key = field.getName();
180   - for (String convention : conventions) {
181   - if (config.containsKey(prefix + convention)) {
182   - key = convention;
183   - matches++;
184   - }
185   - }
186   -
187   - if (matches == 0) {
188   - logger.debug(bundle.getString("configuration-key-not-found", key, conventions));
189   - } else if (matches > 1) {
190   - throw new ConfigurationException(bundle.getString("ambiguous-key", field.getName(),
191   - field.getDeclaringClass()));
192   - }
193   -
194   - return key;
195   - }
196   -
197   - /**
198   - * Returns the configuration class according to specified resource name and configuration type.
199   - *
200   - * @param resource
201   - * @param type
202   - * @return a configuration
203   - */
204   - private org.apache.commons.configuration.Configuration getConfiguration(String resource, ConfigType type) {
205   - org.apache.commons.configuration.Configuration config = null;
206   -
207   - try {
208   - switch (type) {
209   - case SYSTEM:
210   - config = new SystemConfiguration();
211   - break;
212   -
213   - case PROPERTIES:
214   - config = new PropertiesConfiguration(resource + ".properties");
215   - break;
216   -
217   - case XML:
218   - config = new XMLConfiguration(resource + ".xml");
219   - break;
220   -
221   - default:
222   - throw new ConfigurationException(bundle.getString("configuration-type-not-implemented-yet",
223   - type.name()));
224   - }
225   -
226   - } catch (Exception cause) {
227   - throw new ConfigurationException(bundle.getString("error-creating-configuration-from-resource", resource),
228   - cause);
229   - }
230   -
231   - return config;
232   - }
233   -
234   - /**
235   - * Returns the value associated with the given configuration class and field type.
236   - *
237   - * @param name
238   - * @param config
239   - * @param fieldClass
240   - * @return the value
241   - */
242   - @SuppressWarnings("unchecked")
243   - private <T> T getValue(String key, Class<T> fieldClass, org.apache.commons.configuration.Configuration config) {
244   - Object value;
245   -
246   - if (fieldClass.isArray() && fieldClass.getComponentType().equals(String.class)) {
247   - value = config.getStringArray(key);
248   -
249   - } else if (fieldClass.equals(Properties.class)) {
250   - value = getProperty(key, config);
251   -
252   - } else {
253   - value = getBasic(key, fieldClass, config);
254   - }
255   -
256   - return (T) value;
257   - }
258   -
259   - private <T> Object getBasic(String key, Class<T> fieldClass, org.apache.commons.configuration.Configuration config) {
260   - Object value = null;
261   -
262   - try {
263   - Method method;
264   - String methodName = "get" + Strings.firstToUpper(fieldClass.getSimpleName());
265   -
266   - if (!fieldClass.isPrimitive()) {
267   - method = config.getClass().getMethod(methodName, String.class, fieldClass);
268   - value = method.invoke(config, key, null);
269   - } else if (config.containsKey(key)) {
270   - method = config.getClass().getMethod(methodName, String.class);
271   - value = method.invoke(config, key);
272   - }
273   -
274   - } catch (Throwable cause) {
275   - throw new ConfigurationException(bundle.getString("error-converting-to-type", fieldClass.getName()), cause);
276   - }
277   -
278   - return value;
279   - }
280   -
281   - private Object getProperty(String key, org.apache.commons.configuration.Configuration config) {
282   - Object value = null;
283   -
284   - @SuppressWarnings("unchecked")
285   - Iterator<String> iterator = config.getKeys(key);
286   - if (iterator.hasNext()) {
287   - Properties props = new Properties();
288   -
289   - while (iterator.hasNext()) {
290   - String fullKey = iterator.next();
291   - String prefix = key + ".";
292   - String unprefixedKey = fullKey.substring(prefix.length());
293   - props.put(unprefixedKey, config.getString(fullKey));
294   - }
295   -
296   - value = props;
297   - }
298   -
299   - return value;
300   - }
301   -}
core/src/main/java/br/gov/frameworkdemoiselle/internal/configuration/PaginationConfig.java
... ... @@ -1,81 +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 br.gov.frameworkdemoiselle.internal.configuration;
38   -
39   -import java.io.Serializable;
40   -
41   -import br.gov.frameworkdemoiselle.annotation.Name;
42   -import br.gov.frameworkdemoiselle.configuration.Configuration;
43   -
44   -/**
45   - * The <code>PaginationConfig</code> class provides a pagination context to be used where this type of control is
46   - * needed. For example: in a UI as a data grid or on a search to the database.
47   - *
48   - * @author SERPRO
49   - */
50   -@Configuration(prefix = "frameworkdemoiselle.pagination")
51   -public class PaginationConfig implements Serializable {
52   -
53   - private static final long serialVersionUID = 1L;
54   -
55   - @Name("page.size")
56   - private int pageSize = 10;
57   -
58   - @Name("max.page.links")
59   - private int maxPageLinks = 5;
60   -
61   - /**
62   - * Returns the number of rows that will be shown in a data grid.
63   - *
64   - * @return the value defined for the key <i>frameworkdemoiselle.pagination.page.size</i> in the
65   - * <b>demoiselle.properties</b> file. If there is no value defined, returns the default value 10
66   - */
67   - public int getPageSize() {
68   - return pageSize;
69   - }
70   -
71   - /**
72   - * Returns the maximum number of pages that will be shown in a data grid footer
73   - *
74   - * @return the value defined for the key <i>frameworkdemoiselle.pagination.max.page.links</i> in the
75   - * <b>demoiselle.properties</b> file. If there is no value defined, returns the default value 5
76   - */
77   - public int getMaxPageLinks() {
78   - return maxPageLinks;
79   - }
80   -
81   -}
core/src/main/java/br/gov/frameworkdemoiselle/internal/configuration/SecurityConfig.java
... ... @@ -1,68 +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 br.gov.frameworkdemoiselle.internal.configuration;
38   -
39   -import java.io.Serializable;
40   -
41   -import br.gov.frameworkdemoiselle.annotation.Name;
42   -import br.gov.frameworkdemoiselle.configuration.Configuration;
43   -
44   -/**
45   - * A <code>SecurityConfig</code> object is responsible for specifying which security configurations should be used for a
46   - * particular application.
47   - *
48   - * @author SERPRO
49   - */
50   -@Configuration(prefix = "frameworkdemoiselle.security")
51   -public class SecurityConfig implements Serializable {
52   -
53   - private static final long serialVersionUID = 1L;
54   -
55   - @Name("enabled")
56   - private boolean enabled = true;
57   -
58   - /**
59   - * Tells whether or not the security is enabled for the current application. This value could be defined in the
60   - * <b>demoiselle.properties</b> file, using the key <i>frameworkdemoiselle.security.enabled</i>.
61   - *
62   - * @return the value defined for the key <i>frameworkdemoiselle.security.enabled</i> in the
63   - * <b>demoiselle.properties</b> file. If there is no value defined, returns the default value <tt>true</tt>
64   - */
65   - public boolean isEnabled() {
66   - return enabled;
67   - }
68   -}
core/src/main/java/br/gov/frameworkdemoiselle/internal/context/ContextStore.java
... ... @@ -1,58 +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 br.gov.frameworkdemoiselle.internal.context;
38   -
39   -import java.util.Map;
40   -import java.util.TreeMap;
41   -
42   -public class ContextStore {
43   -
44   - private Map<String, Object> map = new TreeMap<String, Object>();
45   -
46   - public boolean contains(final String name) {
47   - return this.map.containsKey(name);
48   - }
49   -
50   - public Object get(final String name) {
51   - return this.map.get(name);
52   - }
53   -
54   - public void put(final String name, final Object instance) {
55   - this.map.put(name, instance);
56   - }
57   -
58   -}
core/src/main/java/br/gov/frameworkdemoiselle/internal/context/Contexts.java
... ... @@ -1,123 +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 br.gov.frameworkdemoiselle.internal.context;
38   -
39   -import java.lang.annotation.Annotation;
40   -import java.util.ArrayList;
41   -import java.util.Collections;
42   -import java.util.List;
43   -
44   -import javax.enterprise.inject.spi.AfterBeanDiscovery;
45   -
46   -public class Contexts {
47   -
48   - private static List<CustomContext> activeContexts;
49   -
50   - private static List<CustomContext> inactiveContexts;
51   -
52   - public static void add(CustomContext context, AfterBeanDiscovery event) {
53   - Class<? extends Annotation> scope = context.getScope();
54   -
55   - if (get(scope, getActiveContexts()) != null) {
56   - getInactiveContexts().add(context);
57   - context.setActive(false);
58   -
59   - } else {
60   - getActiveContexts().add(context);
61   - context.setActive(true);
62   - }
63   -
64   - if (event != null) {
65   - event.addContext(context);
66   - }
67   - }
68   -
69   - private static CustomContext get(Class<? extends Annotation> scope, List<CustomContext> contexts) {
70   - CustomContext result = null;
71   -
72   - for (CustomContext context : contexts) {
73   - if (scope.equals(context.getScope())) {
74   - result = context;
75   - break;
76   - }
77   - }
78   -
79   - return result;
80   - }
81   -
82   - public static void remove(CustomContext context) {
83   - if (getActiveContexts().contains(context)) {
84   - getActiveContexts().remove(context);
85   - context.setActive(false);
86   -
87   - CustomContext inactive = get(context.getScope(), getInactiveContexts());
88   - if (inactive != null) {
89   - getActiveContexts().add(inactive);
90   - inactive.setActive(true);
91   - getInactiveContexts().remove(inactive);
92   - }
93   -
94   - } else if (getInactiveContexts().contains(context)) {
95   - getInactiveContexts().remove(context);
96   - }
97   - }
98   -
99   - public static void clear() {
100   - for (CustomContext context : getActiveContexts()) {
101   - context.setActive(false);
102   - }
103   -
104   - activeContexts = null;
105   - inactiveContexts = null;
106   - }
107   -
108   - public static List<CustomContext> getActiveContexts() {
109   - if (activeContexts == null) {
110   - activeContexts = Collections.synchronizedList(new ArrayList<CustomContext>());
111   - }
112   -
113   - return activeContexts;
114   - }
115   -
116   - public static List<CustomContext> getInactiveContexts() {
117   - if (inactiveContexts == null) {
118   - inactiveContexts = Collections.synchronizedList(new ArrayList<CustomContext>());
119   - }
120   -
121   - return inactiveContexts;
122   - }
123   -}
core/src/main/java/br/gov/frameworkdemoiselle/internal/context/CustomContext.java
... ... @@ -1,45 +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 br.gov.frameworkdemoiselle.internal.context;
38   -
39   -import javax.enterprise.context.spi.Context;
40   -
41   -public interface CustomContext extends Context {
42   -
43   - void setActive(boolean b);
44   -
45   -}
core/src/main/java/br/gov/frameworkdemoiselle/internal/context/ThreadLocalContext.java
... ... @@ -1,130 +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   -/*
38   - * Demoiselle Framework Copyright (c) 2010 Serpro and other contributors as indicated by the @author tag. See the
39   - * copyright.txt in the distribution for a full listing of contributors. Demoiselle Framework is an open source Java EE
40   - * library designed to accelerate the development of transactional database Web applications. Demoiselle Framework is
41   - * released under the terms of the LGPL license 3 http://www.gnu.org/licenses/lgpl.html LGPL License 3 This file is part
42   - * of Demoiselle Framework. Demoiselle Framework is free software: you can redistribute it and/or modify it under the
43   - * terms of the GNU Lesser General Public License 3 as published by the Free Software Foundation. Demoiselle Framework
44   - * is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
45   - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You
46   - * should have received a copy of the GNU Lesser General Public License along with Demoiselle Framework. If not, see
47   - * <http://www.gnu.org/licenses/>.
48   - */
49   -package br.gov.frameworkdemoiselle.internal.context;
50   -
51   -import java.lang.annotation.Annotation;
52   -
53   -import javax.enterprise.context.ContextNotActiveException;
54   -import javax.enterprise.context.spi.Contextual;
55   -import javax.enterprise.context.spi.CreationalContext;
56   -import javax.enterprise.inject.spi.Bean;
57   -
58   -public class ThreadLocalContext implements CustomContext {
59   -
60   - private final ThreadLocal<ContextStore> threadLocal = new ThreadLocal<ContextStore>();
61   -
62   - private boolean active;
63   -
64   - private final Class<? extends Annotation> scope;
65   -
66   - public ThreadLocalContext(final Class<? extends Annotation> scope) {
67   - this(scope, true);
68   - }
69   -
70   - public ThreadLocalContext(final Class<? extends Annotation> scope,
71   - boolean active) {
72   - this.scope = scope;
73   - this.active = active;
74   - }
75   -
76   - @Override
77   - public <T> T get(final Contextual<T> contextual) {
78   - return get(contextual, null);
79   - }
80   -
81   - @Override
82   - @SuppressWarnings("unchecked")
83   - public <T> T get(final Contextual<T> contextual,
84   - final CreationalContext<T> creationalContext) {
85   - T instance = null;
86   -
87   - if (!isActive()) {
88   - throw new ContextNotActiveException();
89   - }
90   -
91   - String id = getId(contextual);
92   - if (getStore().contains(id)) {
93   - instance = (T) getStore().get(id);
94   -
95   - } else if (creationalContext != null) {
96   - instance = contextual.create(creationalContext);
97   - getStore().put(id, instance);
98   - }
99   -
100   - return instance;
101   - }
102   -
103   - private <T> String getId(final Contextual<T> contextual) {
104   - Bean<T> bean = (Bean<T>) contextual;
105   - return bean.getBeanClass().getCanonicalName();
106   - }
107   -
108   - @Override
109   - public Class<? extends Annotation> getScope() {
110   - return this.scope;
111   - }
112   -
113   - private ContextStore getStore() {
114   - if (this.threadLocal.get() == null) {
115   - this.threadLocal.set(new ContextStore());
116   - }
117   -
118   - return this.threadLocal.get();
119   - }
120   -
121   - @Override
122   - public boolean isActive() {
123   - return this.active;
124   - }
125   -
126   - public void setActive(final boolean active) {
127   - this.active = active;
128   - }
129   -
130   -}
core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/CoreBundle.java
... ... @@ -1,28 +0,0 @@
1   -package br.gov.frameworkdemoiselle.internal.implementation;
2   -
3   -import javax.inject.Inject;
4   -
5   -import br.gov.frameworkdemoiselle.annotation.Name;
6   -import br.gov.frameworkdemoiselle.util.Beans;
7   -import br.gov.frameworkdemoiselle.util.ResourceBundle;
8   -
9   -public class CoreBundle {
10   -
11   - @Inject
12   - @Name("demoiselle-core-bundle")
13   - private ResourceBundle bundle;
14   -
15   - private static CoreBundle instance;
16   -
17   - private static synchronized CoreBundle getInstance() {
18   - if (instance == null) {
19   - instance = Beans.getReference(CoreBundle.class);
20   - }
21   -
22   - return instance;
23   - }
24   -
25   - public static ResourceBundle get() {
26   - return getInstance().bundle;
27   - }
28   -}
core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/DefaultAuthenticator.java
... ... @@ -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 br.gov.frameworkdemoiselle.internal.implementation;
38   -
39   -import br.gov.frameworkdemoiselle.DemoiselleException;
40   -import br.gov.frameworkdemoiselle.security.Authenticator;
41   -import br.gov.frameworkdemoiselle.security.SecurityContext;
42   -import br.gov.frameworkdemoiselle.security.User;
43   -
44   -/**
45   - * Authenticator that actually does nothing but raise exceptions.
46   - *
47   - * @author SERPRO
48   - * @see Authenticator
49   - */
50   -public class DefaultAuthenticator implements Authenticator {
51   -
52   - private static final long serialVersionUID = 1L;
53   -
54   - /**
55   - * @see br.gov.frameworkdemoiselle.security.Authenticator#authenticate()
56   - */
57   - @Override
58   - public boolean authenticate() {
59   - throw getException();
60   - }
61   -
62   - /**
63   - * @see br.gov.frameworkdemoiselle.security.Authenticator#unAuthenticate()
64   - */
65   - @Override
66   - public void unAuthenticate() {
67   - throw getException();
68   - }
69   -
70   - /**
71   - * @see br.gov.frameworkdemoiselle.security.Authenticator#getUser()
72   - */
73   - @Override
74   - public User getUser() {
75   - throw getException();
76   - }
77   -
78   - private DemoiselleException getException() {
79   - return new DemoiselleException(CoreBundle.get().getString("authenticator-not-defined",
80   - SecurityContext.class.getSimpleName()));
81   - }
82   -
83   -}
core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/DefaultAuthorizer.java
... ... @@ -1,66 +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 br.gov.frameworkdemoiselle.internal.implementation;
38   -
39   -import br.gov.frameworkdemoiselle.DemoiselleException;
40   -import br.gov.frameworkdemoiselle.security.Authorizer;
41   -import br.gov.frameworkdemoiselle.security.RequiredPermission;
42   -import br.gov.frameworkdemoiselle.security.RequiredRole;
43   -
44   -/**
45   - * Authorizator that actually does nothing but raise exceptions.
46   - *
47   - * @author SERPRO
48   - * @see Authorizer
49   - */
50   -public class DefaultAuthorizer implements Authorizer {
51   -
52   - private static final long serialVersionUID = 1L;
53   -
54   - @Override
55   - public boolean hasRole(String role) {
56   - throw new DemoiselleException(CoreBundle.get().getString("authorizer-not-defined",
57   - RequiredRole.class.getSimpleName()));
58   - }
59   -
60   - @Override
61   - public boolean hasPermission(String resource, String operation) {
62   - throw new DemoiselleException(CoreBundle.get().getString("authorizer-not-defined",
63   - RequiredPermission.class.getSimpleName()));
64   - }
65   -
66   -}
core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/DefaultTransaction.java
... ... @@ -1,90 +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 br.gov.frameworkdemoiselle.internal.implementation;
38   -
39   -import javax.enterprise.context.SessionScoped;
40   -
41   -import br.gov.frameworkdemoiselle.DemoiselleException;
42   -import br.gov.frameworkdemoiselle.transaction.Transaction;
43   -import br.gov.frameworkdemoiselle.transaction.Transactional;
44   -
45   -/**
46   - * Transaction strategy that actually does nothing but raise exceptions.
47   - *
48   - * @author SERPRO
49   - * @see Transaction
50   - */
51   -@SessionScoped
52   -public class DefaultTransaction implements Transaction {
53   -
54   - private static final long serialVersionUID = 1L;
55   -
56   - @Override
57   - public void begin() {
58   - throw getException();
59   - }
60   -
61   - @Override
62   - public void commit() {
63   - throw getException();
64   - }
65   -
66   - @Override
67   - public boolean isActive() {
68   - throw getException();
69   - }
70   -
71   - @Override
72   - public boolean isMarkedRollback() {
73   - throw getException();
74   - }
75   -
76   - @Override
77   - public void rollback() {
78   - throw getException();
79   - }
80   -
81   - @Override
82   - public void setRollbackOnly() {
83   - throw getException();
84   - }
85   -
86   - private DemoiselleException getException() {
87   - return new DemoiselleException(CoreBundle.get().getString("transaction-not-defined",
88   - Transactional.class.getSimpleName()));
89   - }
90   -}
core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/MessageContextImpl.java
... ... @@ -1,105 +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 br.gov.frameworkdemoiselle.internal.implementation;
38   -
39   -import java.io.Serializable;
40   -import java.util.ArrayList;
41   -import java.util.List;
42   -
43   -import javax.enterprise.context.SessionScoped;
44   -import javax.inject.Inject;
45   -
46   -import org.slf4j.Logger;
47   -
48   -import br.gov.frameworkdemoiselle.message.DefaultMessage;
49   -import br.gov.frameworkdemoiselle.message.Message;
50   -import br.gov.frameworkdemoiselle.message.MessageContext;
51   -import br.gov.frameworkdemoiselle.message.SeverityType;
52   -
53   -/**
54   - * The message store is designed to provide access to messages. It is shared by every application layer.
55   - *
56   - * @see MessageContext
57   - */
58   -@SessionScoped
59   -//@ConversationScoped
60   -// FIXME colocar o escopo de conversação, para não ter que limpar o contexto manualmente. Ou seria melhor colocar no
61   -// escopo de request para não precisar se preocupar com isso?
62   -public class MessageContextImpl implements Serializable, MessageContext {
63   -
64   - private static final long serialVersionUID = 1L;
65   -
66   - @Inject
67   - private Logger logger;
68   -
69   - private final List<Message> messages = new ArrayList<Message>();
70   -
71   - @Override
72   - public void add(final Message message, Object... params) {
73   - Message aux;
74   -
75   - if (params != null) {
76   - aux = new DefaultMessage(message.getText(), message.getSeverity(), params);
77   - } else {
78   - aux = message;
79   - }
80   -
81   - logger.debug(CoreBundle.get().getString("adding-message-to-context", message.toString()));
82   - messages.add(aux);
83   - }
84   -
85   - @Override
86   - public void add(String text, Object... params) {
87   - add(text, null, params);
88   - }
89   -
90   - @Override
91   - public void add(String text, SeverityType severity, Object... params) {
92   - add(new DefaultMessage(text, severity, params));
93   - }
94   -
95   - @Override
96   - public List<Message> getMessages() {
97   - return messages;
98   - }
99   -
100   - @Override
101   - public void clear() {
102   - logger.debug(CoreBundle.get().getString("cleaning-message-context"));
103   - messages.clear();
104   - }
105   -}
core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/PaginationContextImpl.java
... ... @@ -1,84 +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 br.gov.frameworkdemoiselle.internal.implementation;
38   -
39   -import java.io.Serializable;
40   -import java.util.HashMap;
41   -import java.util.Map;
42   -
43   -import javax.enterprise.context.SessionScoped;
44   -import javax.inject.Inject;
45   -
46   -import br.gov.frameworkdemoiselle.internal.configuration.PaginationConfig;
47   -import br.gov.frameworkdemoiselle.pagination.Pagination;
48   -import br.gov.frameworkdemoiselle.pagination.PaginationContext;
49   -
50   -/**
51   - * Context implementation reserved for pagination purposes. Internally a hash map is used to store pagination data for
52   - * each class type.
53   - *
54   - * @author SERPRO
55   - * @see PaginationContext
56   - */
57   -@SessionScoped
58   -public class PaginationContextImpl implements Serializable, PaginationContext {
59   -
60   - private static final long serialVersionUID = 1L;
61   -
62   - @Inject
63   - private PaginationConfig config;
64   -
65   - private final Map<Class<?>, Pagination> cache = new HashMap<Class<?>, Pagination>();
66   -
67   - public Pagination getPagination(final Class<?> clazz) {
68   - return this.getPagination(clazz, false);
69   - }
70   -
71   - public Pagination getPagination(final Class<?> clazz, final boolean create) {
72   - Pagination pagination = cache.get(clazz);
73   -
74   - if (pagination == null && create) {
75   - pagination = new PaginationImpl();
76   - pagination.setPageSize(config.getPageSize());
77   -
78   - cache.put(clazz, pagination);
79   - }
80   -
81   - return pagination;
82   - }
83   -
84   -}
core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/PaginationImpl.java
... ... @@ -1,184 +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 br.gov.frameworkdemoiselle.internal.implementation;
38   -
39   -import java.io.Serializable;
40   -
41   -import javax.enterprise.inject.Alternative;
42   -
43   -import br.gov.frameworkdemoiselle.pagination.Pagination;
44   -import br.gov.frameworkdemoiselle.util.Strings;
45   -
46   -/**
47   - * Structure used to handle pagination of data results on both <i>backend</i> (i.e., persistence) and <i>frontend</i>
48   - * (i.e., presentation) layers in the application.
49   - * <p>
50   - * Internally, it stores the current page index on {@code currentPage} variable, the amount of records in a single page
51   - * on {@code pageSize}, and the total number of pages in {@code totalPages}.
52   - *
53   - * @author SERPRO
54   - * @see Pagination
55   - */
56   -@Alternative
57   -public class PaginationImpl implements Serializable, Pagination {
58   -
59   - private static final long serialVersionUID = 1L;
60   -
61   - private int currentPage;
62   -
63   - private int pageSize;
64   -
65   - private int totalResults;
66   -
67   - private int totalPages;
68   -
69   - public PaginationImpl() {
70   - pageSize = 0;
71   - totalResults = 0;
72   - reset();
73   - }
74   -
75   - private void reset() {
76   - currentPage = 0;
77   - totalPages = 0;
78   - }
79   -
80   - public int getCurrentPage() {
81   - return currentPage;
82   - }
83   -
84   - private void setTotalPages(int totalPages) {
85   - validateNegativeValue(totalPages);
86   - this.totalPages = totalPages;
87   -
88   - if (totalPages == 0) {
89   - reset();
90   - } else if (getCurrentPage() >= totalPages) {
91   - setCurrentPage(totalPages - 1);
92   - }
93   - }
94   -
95   - private void validateNegativeValue(int input) throws IndexOutOfBoundsException {
96   - if (input < 0) {
97   - throw new IndexOutOfBoundsException("colocar mensagem");
98   - }
99   - }
100   -
101   - private void validateCurrentPage(int currentPage) throws IndexOutOfBoundsException {
102   - if (currentPage >= this.totalPages) {
103   - if (this.totalPages > 0) {
104   - throw new IndexOutOfBoundsException("colocar mensagem");
105   - }
106   - }
107   - }
108   -
109   - public void setCurrentPage(int currentPage) {
110   - validateNegativeValue(currentPage);
111   - validateCurrentPage(currentPage);
112   - this.currentPage = currentPage;
113   - }
114   -
115   - public int getPageSize() {
116   - return pageSize;
117   - }
118   -
119   - public int getTotalResults() {
120   - return totalResults;
121   - }
122   -
123   - public void setTotalResults(int totalResults) {
124   - validateNegativeValue(totalResults);
125   - this.totalResults = totalResults;
126   -
127   - if (totalResults > 0) {
128   - setTotalPages();
129   - } else {
130   - reset();
131   - }
132   - }
133   -
134   - private void setTotalPages() {
135   - if (totalResults > 0) {
136   - setTotalPages((int) Math.ceil(totalResults * 1d / getPageSize()));
137   - } else {
138   - setTotalPages(0);
139   - }
140   - }
141   -
142   - public int getTotalPages() {
143   - return totalPages;
144   - }
145   -
146   - public int getFirstResult() {
147   - return getCurrentPage() * getPageSize();
148   - }
149   -
150   - public void setPageSize(int pageSize) {
151   - validateNegativeValue(pageSize);
152   - this.pageSize = pageSize;
153   -
154   - if (pageSize > 0) {
155   - setTotalPages();
156   - } else {
157   - reset();
158   - }
159   - }
160   -
161   - private void validateFirstResult(int firstResult) throws IndexOutOfBoundsException {
162   - if (firstResult >= this.totalResults) {
163   - if (this.totalResults > 0) {
164   - throw new IndexOutOfBoundsException("colocar mensagem");
165   - }
166   - }
167   - }
168   -
169   - public void setFirstResult(int firstResult) {
170   - validateNegativeValue(firstResult);
171   - validateFirstResult(firstResult);
172   -
173   - if (firstResult > 0) {
174   - setCurrentPage(firstResult / pageSize);
175   - } else {
176   - setCurrentPage(0);
177   - }
178   - }
179   -
180   - @Override
181   - public String toString() {
182   - return Strings.toString(this);
183   - }
184   -}
core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/SecurityContextImpl.java
... ... @@ -1,185 +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 br.gov.frameworkdemoiselle.internal.implementation;
38   -
39   -import javax.enterprise.context.SessionScoped;
40   -import javax.inject.Inject;
41   -import javax.inject.Named;
42   -
43   -import br.gov.frameworkdemoiselle.annotation.Name;
44   -import br.gov.frameworkdemoiselle.internal.configuration.SecurityConfig;
45   -import br.gov.frameworkdemoiselle.security.AfterLoginSuccessful;
46   -import br.gov.frameworkdemoiselle.security.AfterLogoutSuccessful;
47   -import br.gov.frameworkdemoiselle.security.Authenticator;
48   -import br.gov.frameworkdemoiselle.security.Authorizer;
49   -import br.gov.frameworkdemoiselle.security.NotLoggedInException;
50   -import br.gov.frameworkdemoiselle.security.SecurityContext;
51   -import br.gov.frameworkdemoiselle.security.User;
52   -import br.gov.frameworkdemoiselle.util.Beans;
53   -import br.gov.frameworkdemoiselle.util.ResourceBundle;
54   -
55   -/**
56   - * This is the default implementation of {@link SecurityContext} interface.
57   - *
58   - * @author SERPRO
59   - */
60   -@SessionScoped
61   -@Named("securityContext")
62   -public class SecurityContextImpl implements SecurityContext {
63   -
64   - private static final long serialVersionUID = 1L;
65   -
66   - @Inject
67   - @Name("demoiselle-core-bundle")
68   - private ResourceBundle bundle;
69   -
70   - @Inject
71   - private Authenticator authenticator;
72   -
73   - @Inject
74   - private Authorizer authorizer;
75   -
76   - @Inject
77   - private SecurityConfig config;
78   -
79   - /**
80   - * @see br.gov.frameworkdemoiselle.security.SecurityContext#hasPermission(java.lang.String, java.lang.String)
81   - */
82   - @Override
83   - public boolean hasPermission(String resource, String operation) throws NotLoggedInException {
84   - if (config.isEnabled()) {
85   - checkLoggedIn();
86   - return authorizer.hasPermission(resource, operation);
87   -
88   - } else {
89   - return true;
90   - }
91   - }
92   -
93   - /**
94   - * @see br.gov.frameworkdemoiselle.security.SecurityContext#hasRole(java.lang.String)
95   - */
96   - @Override
97   - public boolean hasRole(String role) throws NotLoggedInException {
98   - if (config.isEnabled()) {
99   - checkLoggedIn();
100   - return authorizer.hasRole(role);
101   -
102   - } else {
103   - return true;
104   - }
105   - }
106   -
107   - /**
108   - * @see br.gov.frameworkdemoiselle.security.SecurityContext#isLoggedIn()
109   - */
110   - @Override
111   - public boolean isLoggedIn() {
112   - if (config.isEnabled()) {
113   - return getUser() != null;
114   - } else {
115   - return true;
116   - }
117   - }
118   -
119   - /**
120   - * @see br.gov.frameworkdemoiselle.security.SecurityContext#login()
121   - */
122   - @Override
123   - public void login() {
124   - if (config.isEnabled() && authenticator.authenticate()) {
125   - Beans.getBeanManager().fireEvent(new AfterLoginSuccessful() {
126   -
127   - private static final long serialVersionUID = 1L;
128   -
129   - });
130   - }
131   - }
132   -
133   - /**
134   - * @see br.gov.frameworkdemoiselle.security.SecurityContext#logout()
135   - */
136   - @Override
137   - public void logout() throws NotLoggedInException {
138   - if (config.isEnabled()) {
139   - checkLoggedIn();
140   - authenticator.unAuthenticate();
141   -
142   - Beans.getBeanManager().fireEvent(new AfterLogoutSuccessful() {
143   -
144   - private static final long serialVersionUID = 1L;
145   - });
146   - }
147   - }
148   -
149   - /**
150   - * @see br.gov.frameworkdemoiselle.security.SecurityContext#getUser()
151   - */
152   - @Override
153   - public User getUser() {
154   - User user = authenticator.getUser();
155   -
156   - if (!config.isEnabled() && user == null) {
157   - user = new User() {
158   -
159   - private static final long serialVersionUID = 1L;
160   -
161   - @Override
162   - public void setAttribute(Object key, Object value) {
163   - }
164   -
165   - @Override
166   - public String getId() {
167   - return "demoiselle";
168   - }
169   -
170   - @Override
171   - public Object getAttribute(Object key) {
172   - return null;
173   - }
174   - };
175   - }
176   -
177   - return user;
178   - }
179   -
180   - private void checkLoggedIn() throws NotLoggedInException {
181   - if (!isLoggedIn()) {
182   - throw new NotLoggedInException(bundle.getString("user-not-authenticated"));
183   - }
184   - }
185   -}
core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/TransactionInfo.java
... ... @@ -1,37 +0,0 @@
1   -package br.gov.frameworkdemoiselle.internal.implementation;
2   -
3   -import java.io.Serializable;
4   -
5   -import javax.enterprise.context.RequestScoped;
6   -
7   -//TODO Inter [NQ]: considerar a necessidade da criação de um contexto de transação para manter a coerência com as demais funcionalidades que possuem um contexto.
8   -//Resposta: não foi feito porque só foi identificado uma funcionalidade (getCurrentTransaction). Aguardar novas ideias.
9   -@RequestScoped
10   -public class TransactionInfo implements Serializable {
11   -
12   - private static final long serialVersionUID = 1L;
13   -
14   - private int counter = 0;
15   -
16   - private boolean owner = false;
17   -
18   - public int getCounter() {
19   - return counter;
20   - }
21   -
22   - public void incrementCounter() {
23   - this.counter++;
24   - }
25   -
26   - public void decrementCounter() {
27   - this.counter--;
28   - }
29   -
30   - public void markAsOwner() {
31   - this.owner = true;
32   - }
33   -
34   - public boolean isOwner() {
35   - return owner;
36   - }
37   -}
core/src/main/java/br/gov/frameworkdemoiselle/internal/interceptor/ExceptionHandlerInterceptor.java
... ... @@ -1,177 +0,0 @@
1   -/*
2   - * Demoiselle Framework Copyright (C) 2010 SERPRO
3   - * ---------------------------------------------------------------------------- This file is part of Demoiselle
4   - * Framework. Demoiselle Framework is free software; you can redistribute it and/or modify it under the terms of the GNU
5   - * Lesser General Public License version 3 as published by the Free Software Foundation. This program is distributed in
6   - * the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7   - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a
8   - * copy of the GNU Lesser General Public License version 3 along with this program; if not, see
9   - * <http://www.gnu.org/licenses/> or write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
10   - * Boston, MA 02110-1301, USA. ---------------------------------------------------------------------------- Este arquivo
11   - * é parte do Framework Demoiselle. O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou
12   - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação do Software Livre (FSF). Este
13   - * programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de
14   - * ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português para
15   - * maiores detalhes. Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título "LICENCA.txt", junto com esse
16   - * programa. Se não, acesse <http://www.gnu.org/licenses/> ou escreva para a Fundação do Software Livre (FSF) Inc., 51
17   - * Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
18   - */
19   -package br.gov.frameworkdemoiselle.internal.interceptor;
20   -
21   -import java.io.Serializable;
22   -import java.lang.reflect.InvocationTargetException;
23   -import java.lang.reflect.Method;
24   -import java.util.HashMap;
25   -import java.util.Map;
26   -
27   -import javax.inject.Inject;
28   -import javax.interceptor.AroundInvoke;
29   -import javax.interceptor.Interceptor;
30   -import javax.interceptor.InvocationContext;
31   -
32   -import org.slf4j.Logger;
33   -
34   -import br.gov.frameworkdemoiselle.DemoiselleException;
35   -import br.gov.frameworkdemoiselle.annotation.Name;
36   -import br.gov.frameworkdemoiselle.exception.ExceptionHandler;
37   -import br.gov.frameworkdemoiselle.internal.bootstrap.CoreBootstrap;
38   -import br.gov.frameworkdemoiselle.stereotype.Controller;
39   -import br.gov.frameworkdemoiselle.util.ResourceBundle;
40   -
41   -@Interceptor
42   -@Controller
43   -public class ExceptionHandlerInterceptor implements Serializable {
44   -
45   - private static final long serialVersionUID = 1L;
46   -
47   - private final ResourceBundle bundle;
48   -
49   - private final Logger logger;
50   -
51   - @Inject
52   - public ExceptionHandlerInterceptor(Logger logger, @Name("demoiselle-core-bundle") ResourceBundle bundle) {
53   - this.logger = logger;
54   - this.bundle = bundle;
55   - }
56   -
57   - private final Map<Class<?>, Map<Class<?>, Method>> cache = new HashMap<Class<?>, Map<Class<?>, Method>>();
58   -
59   - private final boolean handleException(final Exception cause, final InvocationContext ic) throws Throwable {
60   - logger.info(bundle.getString("handling-exception", cause.getClass().getCanonicalName()));
61   -
62   - boolean handled = false;
63   - Class<?> type = getType(ic);
64   -
65   - if (!isLoaded(type)) {
66   - loadHandlers(type);
67   - }
68   -
69   - Method handler = getMethod(type, cause);
70   - if (handler != null) {
71   - invoke(handler, ic.getTarget(), cause);
72   - handled = true;
73   - }
74   -
75   - return handled;
76   - }
77   -
78   - private final Class<?> getType(final InvocationContext ic) {
79   - Class<?> type = ic.getTarget().getClass();
80   -
81   - if (!CoreBootstrap.isAnnotatedType(type)) {
82   - type = type.getSuperclass();
83   - logger.debug(bundle.getString("proxy-detected", ic.getTarget().getClass(), ic.getTarget().getClass()
84   - .getSuperclass()));
85   - }
86   -
87   - return type;
88   - }
89   -
90   - /**
91   - * If there is an handler in the current class for the expected exception, then this method will be returned; Else
92   - * returns null;
93   - *
94   - * @param type
95   - * @param cause
96   - * @return
97   - */
98   - private final Method getMethod(final Class<?> type, final Exception cause) {
99   - Method handler = null;
100   -
101   - if (cache.containsKey(type) && cache.get(type).containsKey(cause.getClass())) {
102   - handler = cache.get(type).get(cause.getClass());
103   - }
104   -
105   - return handler;
106   - }
107   -
108   - /**
109   - * Create an map of Exception Handler for this class and put it on the cache.
110   - *
111   - * @param type
112   - */
113   - private final void loadHandlers(final Class<?> type) {
114   - Map<Class<?>, Method> mapHandlers = new HashMap<Class<?>, Method>();
115   - Method[] methods = type.getMethods();
116   -
117   - for (Method method : methods) {
118   - if (method.isAnnotationPresent(ExceptionHandler.class)) {
119   - validateHandler(method);
120   - mapHandlers.put(method.getParameterTypes()[0], method);
121   - }
122   - }
123   - cache.put(type, mapHandlers);
124   - }
125   -
126   - /**
127   - * Verify the method for compliance with an handler. It must be: public, single parameter, parameter type must be
128   - * assigned from Exception
129   - *
130   - * @param method
131   - */
132   - private final void validateHandler(final Method method) {
133   - if (method.getParameterTypes().length != 1) {
134   - throw new DemoiselleException(bundle.getString("must-declare-one-single-parameter",
135   - method.toGenericString()));
136   - }
137   - }
138   -
139   - /**
140   - * Indicates if this class is already loaded in cache control.
141   - *
142   - * @param type
143   - * @return
144   - */
145   - private final boolean isLoaded(final Class<?> type) {
146   - return cache.containsKey(type);
147   - }
148   -
149   - private final void invoke(final Method method, final Object object, final Exception param) throws Throwable {
150   - boolean accessible = method.isAccessible();
151   - method.setAccessible(true);
152   -
153   - try {
154   - method.invoke(object, param);
155   - } catch (InvocationTargetException cause) {
156   - throw cause.getTargetException();
157   - }
158   -
159   - method.setAccessible(accessible);
160   - }
161   -
162   - @AroundInvoke
163   - public Object manage(final InvocationContext ic) throws Throwable {
164   - Object result = null;
165   -
166   - try {
167   - result = ic.proceed();
168   - } catch (Exception cause) {
169   - if (!handleException(cause, ic)) {
170   - throw cause;
171   - }
172   - }
173   -
174   - return result;
175   - }
176   -
177   -}
core/src/main/java/br/gov/frameworkdemoiselle/internal/interceptor/RequiredPermissionInterceptor.java
... ... @@ -1,176 +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 br.gov.frameworkdemoiselle.internal.interceptor;
38   -
39   -import java.io.Serializable;
40   -
41   -import javax.enterprise.inject.Instance;
42   -import javax.inject.Inject;
43   -import javax.interceptor.AroundInvoke;
44   -import javax.interceptor.Interceptor;
45   -import javax.interceptor.InvocationContext;
46   -
47   -import org.slf4j.Logger;
48   -
49   -import br.gov.frameworkdemoiselle.annotation.Name;
50   -import br.gov.frameworkdemoiselle.security.AuthorizationException;
51   -import br.gov.frameworkdemoiselle.security.RequiredPermission;
52   -import br.gov.frameworkdemoiselle.security.SecurityContext;
53   -import br.gov.frameworkdemoiselle.security.User;
54   -import br.gov.frameworkdemoiselle.util.ResourceBundle;
55   -import br.gov.frameworkdemoiselle.util.Strings;
56   -
57   -/**
58   - * Intercepts calls with {@code @RequiredPermission} annotations.
59   - *
60   - * @author SERPRO
61   - */
62   -@Interceptor
63   -@RequiredPermission
64   -public class RequiredPermissionInterceptor implements Serializable {
65   -
66   - private static final long serialVersionUID = 1L;
67   -
68   - private final Instance<SecurityContext> securityContext;
69   -
70   - private final ResourceBundle bundle;
71   -
72   - private final Logger logger;
73   -
74   - @Inject
75   - public RequiredPermissionInterceptor(Instance<SecurityContext> securityContext,
76   - @Name("demoiselle-core-bundle") ResourceBundle bundle, Logger logger) {
77   - this.securityContext = securityContext;
78   - this.bundle = bundle;
79   - this.logger = logger;
80   - }
81   -
82   - /**
83   - * Gets the values for both resource and operation properties of {@code @RequiredPermission}. Delegates to
84   - * {@code SecurityContext} check permissions. If the user has the required permission it executes the mehtod,
85   - * otherwise throws an exception. Returns what is returned from the intercepted method. If the method's return type
86   - * is {@code void} returns {@code null}.
87   - *
88   - * @param ic
89   - * the {@code InvocationContext} in which the method is being called
90   - * @return what is returned from the intercepted method. If the method's return type is {@code void} returns
91   - * {@code null}
92   - * @throws Exception
93   - * if there is an error during the permission check or during the method's processing
94   - */
95   - @AroundInvoke
96   - public Object manage(final InvocationContext ic) throws Exception {
97   - String resource = getResource(ic);
98   - String operation = getOperation(ic);
99   - String username = null;
100   -
101   - if (securityContext.get().isLoggedIn()) {
102   - username = getUsername();
103   - logger.trace(bundle.getString("access-checking", username, operation, resource));
104   - }
105   -
106   - if (!securityContext.get().hasPermission(resource, operation)) {
107   - logger.error(bundle.getString("access-denied", username, operation, resource));
108   - throw new AuthorizationException(bundle.getString("access-denied-ui", resource, operation));
109   - }
110   -
111   - logger.debug(bundle.getString("access-allowed", username, operation, resource));
112   - return ic.proceed();
113   - }
114   -
115   - /**
116   - * Returns the id of the currently logged in user.
117   - *
118   - * @return the id of the currently logged in user
119   - */
120   - private String getUsername() {
121   - String username = "";
122   - User user = securityContext.get().getUser();
123   -
124   - if (user != null && user.getId() != null) {
125   - username = user.getId();
126   - }
127   -
128   - return username;
129   - }
130   -
131   - /**
132   - * Returns the resource defined in {@code @RequiredPermission} annotation, the name defined in {@code @Name}
133   - * annotation or the class name itself
134   - *
135   - * @param ic
136   - * the {@code InvocationContext} in which the method is being called
137   - * @return the resource defined in {@code @RequiredPermission} annotation, the name defined in {@code @Name}
138   - * annotation or the class name itself
139   - */
140   - private String getResource(InvocationContext ic) {
141   - RequiredPermission requiredPermission = ic.getMethod().getAnnotation(RequiredPermission.class);
142   -
143   - if (requiredPermission == null || Strings.isEmpty(requiredPermission.resource())) {
144   - if (ic.getTarget().getClass().getAnnotation(Name.class) == null) {
145   - return ic.getTarget().getClass().getSimpleName();
146   - } else {
147   - return ic.getTarget().getClass().getAnnotation(Name.class).value();
148   - }
149   - } else {
150   - return requiredPermission.resource();
151   - }
152   - }
153   -
154   - /**
155   - * Returns the operation defined in {@code @RequiredPermission} annotation, the name defined in {@code @Name}
156   - * annotation or the method's name itself
157   - *
158   - * @param ic
159   - * the {@code InvocationContext} in which the method is being called
160   - * @return the operation defined in {@code @RequiredPermission} annotation, the name defined in {@code @Name}
161   - * annotation or the method's name itself
162   - */
163   - private String getOperation(InvocationContext ic) {
164   - RequiredPermission requiredPermission = ic.getMethod().getAnnotation(RequiredPermission.class);
165   -
166   - if (requiredPermission == null || Strings.isEmpty(requiredPermission.operation())) {
167   - if (ic.getMethod().getAnnotation(Name.class) == null) {
168   - return ic.getMethod().getName();
169   - } else {
170   - return ic.getMethod().getAnnotation(Name.class).value();
171   - }
172   - } else {
173   - return requiredPermission.operation();
174   - }
175   - }
176   -}
core/src/main/java/br/gov/frameworkdemoiselle/internal/interceptor/RequiredRoleInterceptor.java
... ... @@ -1,152 +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 br.gov.frameworkdemoiselle.internal.interceptor;
38   -
39   -import java.io.Serializable;
40   -import java.util.ArrayList;
41   -import java.util.Arrays;
42   -import java.util.List;
43   -
44   -import javax.enterprise.inject.Instance;
45   -import javax.inject.Inject;
46   -import javax.interceptor.AroundInvoke;
47   -import javax.interceptor.Interceptor;
48   -import javax.interceptor.InvocationContext;
49   -
50   -import org.slf4j.Logger;
51   -
52   -import br.gov.frameworkdemoiselle.annotation.Name;
53   -import br.gov.frameworkdemoiselle.security.AuthorizationException;
54   -import br.gov.frameworkdemoiselle.security.RequiredRole;
55   -import br.gov.frameworkdemoiselle.security.SecurityContext;
56   -import br.gov.frameworkdemoiselle.util.ResourceBundle;
57   -
58   -/**
59   - * Intercepts calls with {@code @RequiredRole} annotations.
60   - *
61   - * @author SERPRO
62   - */
63   -@Interceptor
64   -@RequiredRole(value = "")
65   -public class RequiredRoleInterceptor implements Serializable {
66   -
67   - private static final long serialVersionUID = 1L;
68   -
69   - private final Instance<SecurityContext> securityContext;
70   -
71   - private final ResourceBundle bundle;
72   -
73   - private final Logger logger;
74   -
75   - @Inject
76   - public RequiredRoleInterceptor(Instance<SecurityContext> securityContext,
77   - @Name("demoiselle-core-bundle") ResourceBundle bundle, Logger logger) {
78   - this.securityContext = securityContext;
79   - this.bundle = bundle;
80   - this.logger = logger;
81   - }
82   -
83   - /**
84   - * Gets the value property of {@code @RequiredRole}. Delegates to {@code SecurityContext} check role. If the user
85   - * has the required role it executes the mehtod, otherwise throws an exception. Returns what is returned from the
86   - * intercepted method. If the method's return type is {@code void} returns {@code null}.
87   - *
88   - * @param ic
89   - * the {@code InvocationContext} in which the method is being called
90   - * @return what is returned from the intercepted method. If the method's return type is {@code void} returns
91   - * {@code null}
92   - * @throws Exception
93   - * if there is an error during the role check or during the method's processing
94   - */
95   - @AroundInvoke
96   - public Object manage(final InvocationContext ic) throws Exception {
97   -
98   - List<String> roles = getRoles(ic);
99   -
100   - if (securityContext.get().isLoggedIn()) {
101   - logger.info(bundle.getString("has-role-verification", securityContext.get().getUser().getId(), roles));
102   - }
103   -
104   - List<String> userRoles = new ArrayList<String>();
105   -
106   - for (String role : roles) {
107   - if (securityContext.get().hasRole(role)) {
108   - userRoles.add(role);
109   - }
110   - }
111   -
112   - if (userRoles.isEmpty()) {
113   - logger.error(bundle.getString("does-not-have-role", securityContext.get().getUser().getId(), roles));
114   -
115   - @SuppressWarnings("unused")
116   - AuthorizationException a = new AuthorizationException(null);
117   - throw new AuthorizationException(bundle.getString("does-not-have-role-ui", roles));
118   - }
119   -
120   - logger.debug(bundle.getString("user-has-role", securityContext.get().getUser().getId(), userRoles));
121   -
122   - return ic.proceed();
123   -
124   - }
125   -
126   - /**
127   - * Returns the value defined in {@code @RequiredRole} annotation.
128   - *
129   - * @param ic
130   - * the {@code InvocationContext} in which the method is being called
131   - * @return the value defined in {@code @RequiredRole} annotation
132   - */
133   - private List<String> getRoles(InvocationContext ic) {
134   -
135   - String[] roles = {};
136   -
137   - if (ic.getMethod().getAnnotation(RequiredRole.class) == null) {
138   -
139   - if (ic.getTarget().getClass().getAnnotation(RequiredRole.class) != null) {
140   - roles = ic.getTarget().getClass().getAnnotation(RequiredRole.class).value();
141   - }
142   -
143   - } else {
144   -
145   - roles = ic.getMethod().getAnnotation(RequiredRole.class).value();
146   -
147   - }
148   -
149   - return Arrays.asList(roles);
150   -
151   - }
152   -}
core/src/main/java/br/gov/frameworkdemoiselle/internal/interceptor/TransactionalInterceptor.java
... ... @@ -1,152 +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 br.gov.frameworkdemoiselle.internal.interceptor;
38   -
39   -import java.io.Serializable;
40   -
41   -import javax.enterprise.inject.Instance;
42   -import javax.inject.Inject;
43   -import javax.interceptor.AroundInvoke;
44   -import javax.interceptor.Interceptor;
45   -import javax.interceptor.InvocationContext;
46   -
47   -import org.slf4j.Logger;
48   -
49   -import br.gov.frameworkdemoiselle.annotation.Name;
50   -import br.gov.frameworkdemoiselle.exception.ApplicationException;
51   -import br.gov.frameworkdemoiselle.internal.implementation.TransactionInfo;
52   -import br.gov.frameworkdemoiselle.transaction.Transaction;
53   -import br.gov.frameworkdemoiselle.transaction.Transactional;
54   -import br.gov.frameworkdemoiselle.util.ResourceBundle;
55   -
56   -@Interceptor
57   -@Transactional
58   -public class TransactionalInterceptor implements Serializable {
59   -
60   - private static final long serialVersionUID = 1L;
61   -
62   - private final Instance<Transaction> transaction;
63   -
64   - private final Logger logger;
65   -
66   - private final ResourceBundle bundle;
67   -
68   - private final Instance<TransactionInfo> transactionInfo;
69   -
70   - @Inject
71   - public TransactionalInterceptor(Instance<Transaction> transaction, Instance<TransactionInfo> transactionInfo,
72   - Logger logger, @Name("demoiselle-core-bundle") ResourceBundle bundle) {
73   - this.transaction = transaction;
74   - this.transactionInfo = transactionInfo;
75   - this.logger = logger;
76   - this.bundle = bundle;
77   -
78   - }
79   -
80   - @AroundInvoke
81   - public Object manage(final InvocationContext ic) throws Exception {
82   - initiate(ic);
83   -
84   - Object result = null;
85   - try {
86   - this.logger.debug(bundle.getString("transactional-execution", ic.getMethod().toGenericString()));
87   - transactionInfo.get().incrementCounter();
88   -
89   - result = ic.proceed();
90   -
91   - } catch (Exception cause) {
92   - handleException(cause);
93   - throw cause;
94   -
95   - } finally {
96   - transactionInfo.get().decrementCounter();
97   - complete(ic);
98   - }
99   -
100   - return result;
101   - }
102   -
103   - private void initiate(final InvocationContext ic) {
104   - Transaction tx = this.transaction.get();
105   - TransactionInfo ctx = this.transactionInfo.get();
106   -
107   - if (!tx.isActive()) {
108   - tx.begin();
109   - ctx.markAsOwner();
110   - this.logger.info(bundle.getString("begin-transaction"));
111   - }
112   - }
113   -
114   - private void handleException(final Exception cause) {
115   - Transaction tx = this.transaction.get();
116   -
117   - if (!tx.isMarkedRollback()) {
118   - boolean rollback = false;
119   - ApplicationException annotation = cause.getClass().getAnnotation(ApplicationException.class);
120   -
121   - if (annotation == null || annotation.rollback()) {
122   - rollback = true;
123   - }
124   -
125   - if (rollback) {
126   - tx.setRollbackOnly();
127   - this.logger.info(bundle.getString("transaction-marked-rollback", cause.getMessage()));
128   - }
129   - }
130   - }
131   -
132   - private void complete(final InvocationContext ic) {
133   - Transaction tx = this.transaction.get();
134   - TransactionInfo ctx = this.transactionInfo.get();
135   -
136   - if (ctx.getCounter() == 0 && tx.isActive()) {
137   -
138   - if (ctx.isOwner()) {
139   - if (tx.isMarkedRollback()) {
140   - tx.rollback();
141   - this.logger.info(bundle.getString("transaction-rolledback"));
142   - } else {
143   - tx.commit();
144   - this.logger.info(bundle.getString("transaction-commited"));
145   - }
146   - }
147   -
148   - } else if (ctx.getCounter() == 0 && !tx.isActive()) {
149   - this.logger.info(bundle.getString("transaction-already-finalized"));
150   - }
151   - }
152   -}
core/src/main/java/br/gov/frameworkdemoiselle/internal/processor/AbstractProcessor.java
... ... @@ -1,117 +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 br.gov.frameworkdemoiselle.internal.processor;
38   -
39   -import javax.enterprise.inject.spi.AnnotatedCallable;
40   -import javax.enterprise.inject.spi.Bean;
41   -import javax.enterprise.inject.spi.BeanManager;
42   -
43   -import org.slf4j.Logger;
44   -
45   -import br.gov.frameworkdemoiselle.internal.producer.LoggerProducer;
46   -import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer;
47   -import br.gov.frameworkdemoiselle.util.ResourceBundle;
48   -
49   -/**
50   - * It abstract the integration between Processor and the context;
51   - *
52   - * @param <DC>
53   - * the declaring class
54   - */
55   -public abstract class AbstractProcessor<DC> implements Processor {
56   -
57   - private BeanManager beanManager;
58   -
59   - private AnnotatedCallable<DC> annotatedCallable;
60   -
61   - private ResourceBundleProducer bundleFactory = new ResourceBundleProducer();
62   -
63   - private ResourceBundle bundle;
64   -
65   - protected static final String BUNDLE_BASE_NAME = "demoiselle-core-bundle";
66   -
67   - public AbstractProcessor(final BeanManager beanManager) {
68   - this.beanManager = beanManager;
69   - }
70   -
71   - public AbstractProcessor(final AnnotatedCallable<DC> annotatedCallable, final BeanManager beanManager) {
72   - this.annotatedCallable = annotatedCallable;
73   - this.beanManager = beanManager;
74   - }
75   -
76   - protected AnnotatedCallable<DC> getAnnotatedCallable() {
77   - return this.annotatedCallable;
78   - }
79   -
80   - protected BeanManager getBeanManager() {
81   - return this.beanManager;
82   - }
83   -
84   - /**
85   - * Ask the bean manager for the firt instance of the declaring classe for this java member, then returns the current
86   - * reference;
87   - *
88   - * @param <T>
89   - * DeclaringClass
90   - * @return
91   - */
92   - @SuppressWarnings("unchecked")
93   - protected DC getReferencedBean() {
94   - Class<DC> classType = (Class<DC>) getAnnotatedCallable().getJavaMember().getDeclaringClass();
95   - return getReferencedBean(classType);
96   - }
97   -
98   - @SuppressWarnings("unchecked")
99   - protected DC getReferencedBean(final Class<DC> type) {
100   - Bean<DC> bean = (Bean<DC>) beanManager.getBeans(type).iterator().next();
101   - return (DC) beanManager.getReference(bean, type, beanManager.createCreationalContext(bean));
102   - }
103   -
104   - protected ResourceBundle getBundle() {
105   - return getBundle(BUNDLE_BASE_NAME);
106   - }
107   -
108   - protected ResourceBundle getBundle(String baseName) {
109   - if (bundle == null)
110   - bundle = bundleFactory.create(baseName);
111   - return bundle;
112   - }
113   -
114   - protected Logger getLogger() {
115   - return LoggerProducer.create(this.getClass());
116   - }
117   -}
core/src/main/java/br/gov/frameworkdemoiselle/internal/processor/AnnotatedMethodProcessor.java
... ... @@ -1,105 +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 br.gov.frameworkdemoiselle.internal.processor;
38   -
39   -import java.lang.reflect.InvocationTargetException;
40   -
41   -import javax.enterprise.inject.spi.AnnotatedMethod;
42   -import javax.enterprise.inject.spi.BeanManager;
43   -
44   -import br.gov.frameworkdemoiselle.exception.ApplicationException;
45   -import br.gov.frameworkdemoiselle.message.SeverityType;
46   -
47   -/**
48   - * Represents an annotated method to be processed;
49   - *
50   - * @param <DC>
51   - * declaring class owner of the method
52   - */
53   -public class AnnotatedMethodProcessor<DC> extends AbstractProcessor<DC> {
54   -
55   - public AnnotatedMethodProcessor(final AnnotatedMethod<DC> annotatedMethod, final BeanManager beanManager) {
56   - super(annotatedMethod, beanManager);
57   - }
58   -
59   - protected AnnotatedMethod<DC> getAnnotatedMethod() {
60   - return (AnnotatedMethod<DC>) getAnnotatedCallable();
61   - }
62   -
63   - public boolean process(Object... args) throws Throwable {
64   - getLogger().info(getBundle().getString("processing", getAnnotatedMethod().getJavaMember().toGenericString()));
65   -
66   - try {
67   - getAnnotatedMethod().getJavaMember().invoke(getReferencedBean(), args);
68   -
69   - } catch (InvocationTargetException cause) {
70   - handleException(cause.getCause());
71   - }
72   -
73   - return true;
74   - }
75   -
76   - private void handleException(Throwable cause) throws Throwable {
77   - ApplicationException ann = cause.getClass().getAnnotation(ApplicationException.class);
78   -
79   - if (ann == null || SeverityType.FATAL == ann.severity()) {
80   - throw cause;
81   -
82   - } else {
83   - switch (ann.severity()) {
84   - case INFO:
85   - getLogger().info(cause.getMessage());
86   - break;
87   -
88   - case WARN:
89   - getLogger().warn(cause.getMessage());
90   - break;
91   -
92   - default:
93   - getLogger().error(getBundle().getString("processing-fail"), cause);
94   - break;
95   - }
96   - }
97   - }
98   -
99   - @Override
100   - public String toString() {
101   - return getBundle().getString("for", getClass().getSimpleName(),
102   - getAnnotatedMethod().getJavaMember().toGenericString());
103   - }
104   -
105   -}
core/src/main/java/br/gov/frameworkdemoiselle/internal/processor/Processor.java
... ... @@ -1,45 +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 br.gov.frameworkdemoiselle.internal.processor;
38   -
39   -/**
40   - * Represents an classe that can be processed.
41   - */
42   -public interface Processor {
43   -
44   - public boolean process(Object... args) throws Throwable;
45   -}
core/src/main/java/br/gov/frameworkdemoiselle/internal/processor/ShutdownProcessor.java
... ... @@ -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 br.gov.frameworkdemoiselle.internal.processor;
38   -
39   -import javax.enterprise.inject.spi.AnnotatedMethod;
40   -import javax.enterprise.inject.spi.BeanManager;
41   -
42   -import br.gov.frameworkdemoiselle.annotation.Shutdown;
43   -
44   -public class ShutdownProcessor<T> extends AnnotatedMethodProcessor<T> implements Comparable<ShutdownProcessor<T>> {
45   -
46   - public ShutdownProcessor(AnnotatedMethod<T> annotatedMethod, BeanManager beanManager) {
47   - super(annotatedMethod, beanManager);
48   - }
49   -
50   - @Override
51   - public int compareTo(final ShutdownProcessor<T> other) {
52   - int result = 0;
53   - Shutdown annotationThis = getAnnotatedMethod().getAnnotation(Shutdown.class);
54   - Shutdown annotationOther = other.getAnnotatedMethod().getAnnotation(Shutdown.class);
55   - if (annotationThis != null && annotationThis != null) {
56   - Integer orderThis = annotationThis.priority();
57   - Integer orderOther = annotationOther.priority();
58   - result = orderThis.compareTo(orderOther);
59   - }
60   - return result;
61   - }
62   -
63   -}
core/src/main/java/br/gov/frameworkdemoiselle/internal/processor/StartupProcessor.java
... ... @@ -1,68 +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 br.gov.frameworkdemoiselle.internal.processor;
38   -
39   -import javax.enterprise.inject.spi.AnnotatedMethod;
40   -import javax.enterprise.inject.spi.BeanManager;
41   -
42   -import br.gov.frameworkdemoiselle.annotation.Startup;
43   -
44   -/**
45   - * Processor for a {@code @Startup} annotated method, making it comparable.
46   - *
47   - * @param <T>
48   - */
49   -public class StartupProcessor<T> extends AnnotatedMethodProcessor<T> implements Comparable<StartupProcessor<T>> {
50   -
51   - public StartupProcessor(final AnnotatedMethod<T> annotatedMethod, final BeanManager beanManager) {
52   - super(annotatedMethod, beanManager);
53   - }
54   -
55   - @Override
56   - public int compareTo(final StartupProcessor<T> other) {
57   - int result = 0;
58   - Startup annotationThis = getAnnotatedMethod().getAnnotation(Startup.class);
59   - Startup annotationOther = other.getAnnotatedMethod().getAnnotation(Startup.class);
60   - if (annotationThis != null && annotationOther != null) {
61   - Integer orderThis = annotationThis.priority();
62   - Integer orderOther = annotationOther.priority();
63   - result = orderThis.compareTo(orderOther);
64   - }
65   - return result;
66   - }
67   -
68   -}
core/src/main/java/br/gov/frameworkdemoiselle/internal/producer/ContextProducer.java
... ... @@ -1,84 +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   -/*
38   - * Demoiselle Framework Copyright (c) 2010 Serpro and other contributors as indicated by the @author tag. See the
39   - * copyright.txt in the distribution for a full listing of contributors. Demoiselle Framework is an open source Java EE
40   - * library designed to accelerate the development of transactional database Web applications. Demoiselle Framework is
41   - * released under the terms of the LGPL license 3 http://www.gnu.org/licenses/lgpl.html LGPL License 3 This file is part
42   - * of Demoiselle Framework. Demoiselle Framework is free software: you can redistribute it and/or modify it under the
43   - * terms of the GNU Lesser General Public License 3 as published by the Free Software Foundation. Demoiselle Framework
44   - * is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
45   - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You
46   - * should have received a copy of the GNU Lesser General Public License along with Demoiselle Framework. If not, see
47   - * <http://www.gnu.org/licenses/>.
48   - */
49   -package br.gov.frameworkdemoiselle.internal.producer;
50   -
51   -import java.io.Serializable;
52   -
53   -import javax.enterprise.inject.Default;
54   -import javax.enterprise.inject.Produces;
55   -import javax.naming.Context;
56   -import javax.naming.InitialContext;
57   -import javax.naming.NamingException;
58   -
59   -import br.gov.frameworkdemoiselle.DemoiselleException;
60   -import br.gov.frameworkdemoiselle.internal.proxy.ContextProxy;
61   -
62   -public class ContextProducer implements Serializable {
63   -
64   - private static final long serialVersionUID = 1L;
65   -
66   - // @Inject
67   - // @Name("demoiselle-core-bundle")
68   - // private ResourceBundle bundle;
69   -
70   - @Produces
71   - @Default
72   - public static Context create() {
73   - Context context = null;
74   -
75   - try {
76   - context = new ContextProxy(new InitialContext());
77   -
78   - } catch (NamingException cause) {
79   - throw new DemoiselleException("Erro ao criar InitialContext", cause);
80   - }
81   -
82   - return context;
83   - }
84   -}
core/src/main/java/br/gov/frameworkdemoiselle/internal/producer/LocaleProducer.java
... ... @@ -1,16 +0,0 @@
1   -package br.gov.frameworkdemoiselle.internal.producer;
2   -
3   -import java.util.Locale;
4   -
5   -import javax.enterprise.inject.Default;
6   -import javax.enterprise.inject.Produces;
7   -
8   -public class LocaleProducer {
9   -
10   - @Produces
11   - @Default
12   - public Locale create() {
13   - return Locale.getDefault();
14   - }
15   -
16   -}
core/src/main/java/br/gov/frameworkdemoiselle/internal/producer/LoggerProducer.java
... ... @@ -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   -/*
38   - * Demoiselle Framework Copyright (c) 2010 Serpro and other contributors as indicated by the @author tag. See the
39   - * copyright.txt in the distribution for a full listing of contributors. Demoiselle Framework is an open source Java EE
40   - * library designed to accelerate the development of transactional database Web applications. Demoiselle Framework is
41   - * released under the terms of the LGPL license 3 http://www.gnu.org/licenses/lgpl.html LGPL License 3 This file is part
42   - * of Demoiselle Framework. Demoiselle Framework is free software: you can redistribute it and/or modify it under the
43   - * terms of the GNU Lesser General Public License 3 as published by the Free Software Foundation. Demoiselle Framework
44   - * is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
45   - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You
46   - * should have received a copy of the GNU Lesser General Public License along with Demoiselle Framework. If not, see
47   - * <http://www.gnu.org/licenses/>.
48   - */
49   -package br.gov.frameworkdemoiselle.internal.producer;
50   -
51   -import java.io.Serializable;
52   -
53   -import javax.enterprise.inject.Default;
54   -import javax.enterprise.inject.Produces;
55   -import javax.enterprise.inject.spi.InjectionPoint;
56   -
57   -import org.slf4j.Logger;
58   -import org.slf4j.LoggerFactory;
59   -
60   -import br.gov.frameworkdemoiselle.internal.proxy.Slf4jLoggerProxy;
61   -
62   -public class LoggerProducer implements Serializable {
63   -
64   - private static final long serialVersionUID = 1L;
65   -
66   - @Produces
67   - @Default
68   - public static Logger create(final InjectionPoint ip) {
69   - Class<?> type;
70   -
71   - if (ip != null) {
72   - type = ip.getMember().getDeclaringClass();
73   - } else {
74   - type = LoggerProducer.class;
75   - }
76   -
77   - return create(type);
78   - }
79   -
80   - public static <T> Logger create(Class<T> type) {
81   - return new Slf4jLoggerProxy(LoggerFactory.getLogger(type));
82   - }
83   -}
core/src/main/java/br/gov/frameworkdemoiselle/internal/producer/ResourceBundleProducer.java
... ... @@ -1,135 +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 br.gov.frameworkdemoiselle.internal.producer;
38   -
39   -import java.io.Serializable;
40   -import java.util.HashMap;
41   -import java.util.Locale;
42   -import java.util.Map;
43   -import java.util.MissingResourceException;
44   -
45   -import javax.enterprise.context.ApplicationScoped;
46   -import javax.enterprise.inject.Default;
47   -import javax.enterprise.inject.Produces;
48   -import javax.enterprise.inject.spi.InjectionPoint;
49   -import javax.inject.Inject;
50   -
51   -import br.gov.frameworkdemoiselle.DemoiselleException;
52   -import br.gov.frameworkdemoiselle.annotation.Name;
53   -import br.gov.frameworkdemoiselle.util.ResourceBundle;
54   -
55   -/**
56   - * This factory creates ResourceBundles with the application scopes.
57   - *
58   - * @author SERPRO
59   - */
60   -@ApplicationScoped
61   -public class ResourceBundleProducer implements Serializable {
62   -
63   - private static final long serialVersionUID = 1L;
64   -
65   - @Inject
66   - protected Locale locale;
67   -
68   - private final Map<String, ResourceBundle> map = new HashMap<String, ResourceBundle>();
69   -
70   - public ResourceBundleProducer() {
71   - this.locale = Locale.getDefault();
72   - }
73   -
74   - /**
75   - * This constructor should be used by classes that can not inject ResourceBundle.
76   - *
77   - * @param Locale
78   - * locale
79   - */
80   - public ResourceBundleProducer(Locale locale) {
81   - this.locale = locale;
82   - }
83   -
84   - /**
85   - * This method should be used by classes that can not inject ResourceBundle, to create the ResourceBundle.
86   - *
87   - * @param String
88   - * baseName
89   - */
90   - public ResourceBundle create(String baseName) {
91   - return getResourceBundle(baseName);
92   - }
93   -
94   - /**
95   - * This method is the factory default for ResourceBundle. It creates the ResourceBundle based on a file called
96   - * messages.properties.
97   - */
98   - @Produces
99   - @Default
100   - public ResourceBundle create(InjectionPoint ip, Locale locale) {
101   - this.locale = locale;
102   - String baseName;
103   -
104   - if (ip != null && ip.getAnnotated().isAnnotationPresent(Name.class)) {
105   - baseName = ip.getAnnotated().getAnnotation(Name.class).value();
106   - } else {
107   - baseName = "messages";
108   - }
109   -
110   - return create(baseName);
111   - }
112   -
113   - /**
114   - * This method checks if the bundle was created already. If the bundle has not been created, it creates and saves
115   - * the bundle on a Map.
116   - */
117   - private ResourceBundle getResourceBundle(String baseName) {
118   - ResourceBundle bundle = null;
119   -
120   - if (map.containsKey(baseName + "-" + this.locale)) {
121   - bundle = map.get(baseName + "-" + this.locale);
122   -
123   - } else {
124   - try {
125   - bundle = new ResourceBundle(ResourceBundle.getBundle(baseName, this.locale));
126   - } catch (MissingResourceException e) {
127   - throw new DemoiselleException("File " + baseName + " not found!");
128   - }
129   - map.put(baseName + "-" + this.locale, bundle);
130   - }
131   -
132   - return bundle;
133   - }
134   -
135   -}
core/src/main/java/br/gov/frameworkdemoiselle/internal/proxy/ContextProxy.java
... ... @@ -1,168 +0,0 @@
1   -package br.gov.frameworkdemoiselle.internal.proxy;
2   -
3   -import java.io.Serializable;
4   -import java.util.Hashtable;
5   -
6   -import javax.naming.Binding;
7   -import javax.naming.Context;
8   -import javax.naming.Name;
9   -import javax.naming.NameClassPair;
10   -import javax.naming.NameParser;
11   -import javax.naming.NamingEnumeration;
12   -import javax.naming.NamingException;
13   -
14   -public class ContextProxy implements Context, Serializable {
15   -
16   - private static final long serialVersionUID = 1L;
17   -
18   - private final Context delegate;
19   -
20   - public ContextProxy(Context delegate) {
21   - this.delegate = delegate;
22   - }
23   -
24   - @Override
25   - public Object addToEnvironment(String propName, Object propVal) throws NamingException {
26   - return delegate.addToEnvironment(propName, propVal);
27   - }
28   -
29   - @Override
30   - public void bind(Name name, Object obj) throws NamingException {
31   - delegate.bind(name, obj);
32   - }
33   -
34   - @Override
35   - public void bind(String name, Object obj) throws NamingException {
36   - delegate.bind(name, obj);
37   - }
38   -
39   - @Override
40   - public void close() throws NamingException {
41   - delegate.close();
42   - }
43   -
44   - @Override
45   - public Name composeName(Name name, Name prefix) throws NamingException {
46   - return delegate.composeName(name, prefix);
47   - }
48   -
49   - @Override
50   - public String composeName(String name, String prefix) throws NamingException {
51   - return delegate.composeName(name, prefix);
52   - }
53   -
54   - @Override
55   - public Context createSubcontext(Name name) throws NamingException {
56   - return delegate.createSubcontext(name);
57   - }
58   -
59   - @Override
60   - public Context createSubcontext(String name) throws NamingException {
61   - return delegate.createSubcontext(name);
62   - }
63   -
64   - @Override
65   - public void destroySubcontext(Name name) throws NamingException {
66   - delegate.destroySubcontext(name);
67   - }
68   -
69   - @Override
70   - public void destroySubcontext(String name) throws NamingException {
71   - delegate.destroySubcontext(name);
72   - }
73   -
74   - @Override
75   - public Hashtable<?, ?> getEnvironment() throws NamingException {
76   - return delegate.getEnvironment();
77   - }
78   -
79   - @Override
80   - public String getNameInNamespace() throws NamingException {
81   - return delegate.getNameInNamespace();
82   - }
83   -
84   - @Override
85   - public NameParser getNameParser(Name name) throws NamingException {
86   - return delegate.getNameParser(name);
87   - }
88   -
89   - @Override
90   - public NameParser getNameParser(String name) throws NamingException {
91   - return delegate.getNameParser(name);
92   - }
93   -
94   - @Override
95   - public NamingEnumeration<NameClassPair> list(Name name) throws NamingException {
96   - return delegate.list(name);
97   - }
98   -
99   - @Override
100   - public NamingEnumeration<NameClassPair> list(String name) throws NamingException {
101   - return delegate.list(name);
102   - }
103   -
104   - @Override
105   - public NamingEnumeration<Binding> listBindings(Name name) throws NamingException {
106   - return delegate.listBindings(name);
107   - }
108   -
109   - @Override
110   - public NamingEnumeration<Binding> listBindings(String name) throws NamingException {
111   - return delegate.listBindings(name);
112   - }
113   -
114   - @Override
115   - public Object lookup(Name name) throws NamingException {
116   - return delegate.lookup(name);
117   - }
118   -
119   - @Override
120   - public Object lookup(String name) throws NamingException {
121   - return delegate.lookup(name);
122   - }
123   -
124   - @Override
125   - public Object lookupLink(Name name) throws NamingException {
126   - return delegate.lookupLink(name);
127   - }
128   -
129   - @Override
130   - public Object lookupLink(String name) throws NamingException {
131   - return delegate.lookupLink(name);
132   - }
133   -
134   - @Override
135   - public void rebind(Name name, Object obj) throws NamingException {
136   - delegate.rebind(name, obj);
137   - }
138   -
139   - @Override
140   - public void rebind(String name, Object obj) throws NamingException {
141   - delegate.rebind(name, obj);
142   - }
143   -
144   - @Override
145   - public Object removeFromEnvironment(String propName) throws NamingException {
146   - return delegate.removeFromEnvironment(propName);
147   - }
148   -
149   - @Override
150   - public void rename(Name oldName, Name newName) throws NamingException {
151   - delegate.rename(oldName, newName);
152   - }
153   -
154   - @Override
155   - public void rename(String oldName, String newName) throws NamingException {
156   - delegate.rename(oldName, newName);
157   - }
158   -
159   - @Override
160   - public void unbind(Name name) throws NamingException {
161   - delegate.unbind(name);
162   - }
163   -
164   - @Override
165   - public void unbind(String name) throws NamingException {
166   - delegate.unbind(name);
167   - }
168   -}
core/src/main/java/br/gov/frameworkdemoiselle/internal/proxy/Slf4jLoggerProxy.java
... ... @@ -1,371 +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   -/*
38   - * Demoiselle Framework Copyright (c) 2010 Serpro and other contributors as indicated by the @author tag. See the
39   - * copyright.txt in the distribution for a full listing of contributors. Demoiselle Framework is an open source Java EE
40   - * library designed to accelerate the development of transactional database Web applications. Demoiselle Framework is
41   - * released under the terms of the LGPL license 3 http://www.gnu.org/licenses/lgpl.html LGPL License 3 This file is part
42   - * of Demoiselle Framework. Demoiselle Framework is free software: you can redistribute it and/or modify it under the
43   - * terms of the GNU Lesser General Public License 3 as published by the Free Software Foundation. Demoiselle Framework
44   - * is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
45   - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You
46   - * should have received a copy of the GNU Lesser General Public License along with Demoiselle Framework. If not, see
47   - * <http://www.gnu.org/licenses/>.
48   - */
49   -package br.gov.frameworkdemoiselle.internal.proxy;
50   -
51   -import java.io.Serializable;
52   -
53   -import org.slf4j.Logger;
54   -import org.slf4j.Marker;
55   -
56   -public class Slf4jLoggerProxy implements Logger, Serializable {
57   -
58   - private static final long serialVersionUID = 1L;
59   -
60   - private transient final Logger delegate;
61   -
62   - public Slf4jLoggerProxy(final Logger logger) {
63   - this.delegate = logger;
64   - }
65   -
66   - @Override
67   - public void debug(final Marker marker, final String msg) {
68   - this.delegate.debug(marker, msg);
69   - }
70   -
71   - @Override
72   - public void debug(final Marker marker, final String format, final Object arg) {
73   - this.delegate.debug(marker, format, arg);
74   - }
75   -
76   - @Override
77   - public void debug(final Marker marker, final String format, final Object arg1, final Object arg2) {
78   - this.delegate.debug(marker, format, arg1, arg2);
79   - }
80   -
81   - @Override
82   - public void debug(final Marker marker, final String format, final Object[] argArray) {
83   - this.delegate.debug(marker, format, argArray);
84   - }
85   -
86   - @Override
87   - public void debug(final Marker marker, final String msg, final Throwable t) {
88   - this.delegate.debug(marker, msg, t);
89   - }
90   -
91   - @Override
92   - public void debug(final String msg) {
93   - this.delegate.debug(msg);
94   - }
95   -
96   - @Override
97   - public void debug(final String format, final Object arg) {
98   - this.delegate.debug(format, arg);
99   - }
100   -
101   - @Override
102   - public void debug(final String format, final Object arg1, final Object arg2) {
103   - this.delegate.debug(format, arg1, arg2);
104   - }
105   -
106   - @Override
107   - public void debug(final String format, final Object[] argArray) {
108   - this.delegate.debug(format, argArray);
109   - }
110   -
111   - @Override
112   - public void debug(final String msg, final Throwable t) {
113   - this.delegate.debug(msg, t);
114   - }
115   -
116   - @Override
117   - public void error(final Marker marker, final String msg) {
118   - this.delegate.error(marker, msg);
119   - }
120   -
121   - @Override
122   - public void error(final Marker marker, final String format, final Object arg) {
123   - this.delegate.error(marker, format, arg);
124   - }
125   -
126   - @Override
127   - public void error(final Marker marker, final String format, final Object arg1, final Object arg2) {
128   - this.delegate.error(marker, format, arg1, arg2);
129   - }
130   -
131   - @Override
132   - public void error(final Marker marker, final String format, final Object[] argArray) {
133   - this.delegate.error(marker, format, argArray);
134   - }
135   -
136   - @Override
137   - public void error(final Marker marker, final String msg, final Throwable t) {
138   - this.delegate.error(marker, msg, t);
139   - }
140   -
141   - @Override
142   - public void error(final String msg) {
143   - this.delegate.error(msg);
144   - }
145   -
146   - @Override
147   - public void error(final String format, final Object arg) {
148   - this.delegate.error(format, arg);
149   - }
150   -
151   - @Override
152   - public void error(final String format, final Object arg1, final Object arg2) {
153   - this.delegate.error(format, arg1, arg2);
154   - }
155   -
156   - @Override
157   - public void error(final String format, final Object[] argArray) {
158   - this.delegate.error(format, argArray);
159   - }
160   -
161   - @Override
162   - public void error(final String msg, final Throwable t) {
163   - this.delegate.error(msg, t);
164   - }
165   -
166   - @Override
167   - public String getName() {
168   - return this.delegate.getName();
169   - }
170   -
171   - @Override
172   - public void info(final Marker marker, final String msg) {
173   - this.delegate.info(marker, msg);
174   - }
175   -
176   - @Override
177   - public void info(final Marker marker, final String format, final Object arg) {
178   - this.delegate.info(marker, format, arg);
179   - }
180   -
181   - @Override
182   - public void info(final Marker marker, final String format, final Object arg1, final Object arg2) {
183   - this.delegate.info(marker, format, arg1, arg2);
184   - }
185   -
186   - @Override
187   - public void info(final Marker marker, final String format, final Object[] argArray) {
188   - this.delegate.info(marker, format, argArray);
189   - }
190   -
191   - @Override
192   - public void info(final Marker marker, final String msg, final Throwable t) {
193   - this.delegate.info(marker, msg, t);
194   - }
195   -
196   - @Override
197   - public void info(final String msg) {
198   - this.delegate.info(msg);
199   - }
200   -
201   - @Override
202   - public void info(final String format, final Object arg) {
203   - this.delegate.info(format, arg);
204   - }
205   -
206   - @Override
207   - public void info(final String format, final Object arg1, final Object arg2) {
208   - this.delegate.info(format, arg1, arg2);
209   - }
210   -
211   - @Override
212   - public void info(final String format, final Object[] argArray) {
213   - this.delegate.info(format, argArray);
214   - }
215   -
216   - @Override
217   - public void info(final String msg, final Throwable t) {
218   - this.delegate.info(msg, t);
219   - }
220   -
221   - @Override
222   - public boolean isDebugEnabled() {
223   - return this.delegate.isDebugEnabled();
224   - }
225   -
226   - @Override
227   - public boolean isDebugEnabled(final Marker marker) {
228   - return this.delegate.isDebugEnabled(marker);
229   - }
230   -
231   - @Override
232   - public boolean isErrorEnabled() {
233   - return this.delegate.isErrorEnabled();
234   - }
235   -
236   - @Override
237   - public boolean isErrorEnabled(final Marker marker) {
238   - return this.delegate.isErrorEnabled(marker);
239   - }
240   -
241   - @Override
242   - public boolean isInfoEnabled() {
243   - return this.delegate.isInfoEnabled();
244   - }
245   -
246   - @Override
247   - public boolean isInfoEnabled(final Marker marker) {
248   - return this.delegate.isInfoEnabled(marker);
249   - }
250   -
251   - @Override
252   - public boolean isTraceEnabled() {
253   - return this.delegate.isTraceEnabled();
254   - }
255   -
256   - @Override
257   - public boolean isTraceEnabled(final Marker marker) {
258   - return this.delegate.isTraceEnabled(marker);
259   - }
260   -
261   - @Override
262   - public boolean isWarnEnabled() {
263   - return this.delegate.isWarnEnabled();
264   - }
265   -
266   - @Override
267   - public boolean isWarnEnabled(final Marker marker) {
268   - return this.delegate.isWarnEnabled(marker);
269   - }
270   -
271   - @Override
272   - public void trace(final Marker marker, final String msg) {
273   - this.delegate.trace(marker, msg);
274   - }
275   -
276   - @Override
277   - public void trace(final Marker marker, final String format, final Object arg) {
278   - this.delegate.trace(marker, format, arg);
279   - }
280   -
281   - @Override
282   - public void trace(final Marker marker, final String format, final Object arg1, final Object arg2) {
283   - this.delegate.trace(marker, format, arg1, arg2);
284   - }
285   -
286   - @Override
287   - public void trace(final Marker marker, final String format, final Object[] argArray) {
288   - this.delegate.trace(marker, format, argArray);
289   - }
290   -
291   - @Override
292   - public void trace(final Marker marker, final String msg, final Throwable t) {
293   - this.delegate.trace(marker, msg, t);
294   - }
295   -
296   - @Override
297   - public void trace(final String msg) {
298   - this.delegate.trace(msg);
299   - }
300   -
301   - @Override
302   - public void trace(final String format, final Object arg) {
303   - this.delegate.trace(format, arg);
304   - }
305   -
306   - @Override
307   - public void trace(final String format, final Object arg1, final Object arg2) {
308   - this.delegate.trace(format, arg1, arg2);
309   - }
310   -
311   - @Override
312   - public void trace(final String format, final Object[] argArray) {
313   - this.delegate.trace(format, argArray);
314   - }
315   -
316   - @Override
317   - public void trace(final String msg, final Throwable t) {
318   - this.delegate.trace(msg, t);
319   - }
320   -
321   - @Override
322   - public void warn(final Marker marker, final String msg) {
323   - this.delegate.warn(marker, msg);
324   - }
325   -
326   - @Override
327   - public void warn(final Marker marker, final String format, final Object arg) {
328   - this.delegate.warn(marker, format, arg);
329   - }
330   -
331   - @Override
332   - public void warn(final Marker marker, final String format, final Object arg1, final Object arg2) {
333   - this.delegate.warn(marker, format, arg1, arg2);
334   - }
335   -
336   - @Override
337   - public void warn(final Marker marker, final String format, final Object[] argArray) {
338   - this.delegate.warn(marker, format, argArray);
339   - }
340   -
341   - @Override
342   - public void warn(final Marker marker, final String msg, final Throwable t) {
343   - this.delegate.warn(marker, msg, t);
344   - }
345   -
346   - @Override
347   - public void warn(final String msg) {
348   - this.delegate.warn(msg);
349   - }
350   -
351   - @Override
352   - public void warn(final String format, final Object arg) {
353   - this.delegate.warn(format, arg);
354   - }
355   -
356   - @Override
357   - public void warn(final String format, final Object arg1, final Object arg2) {
358   - this.delegate.warn(format, arg1, arg2);
359   - }
360   -
361   - @Override
362   - public void warn(final String format, final Object[] argArray) {
363   - this.delegate.warn(format, argArray);
364   - }
365   -
366   - @Override
367   - public void warn(final String msg, final Throwable t) {
368   - this.delegate.warn(msg, t);
369   - }
370   -
371   -}
core/src/main/java/br/gov/frameworkdemoiselle/message/DefaultMessage.java
... ... @@ -1,101 +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 br.gov.frameworkdemoiselle.message;
38   -
39   -import javax.enterprise.inject.Alternative;
40   -
41   -import br.gov.frameworkdemoiselle.util.Beans;
42   -import br.gov.frameworkdemoiselle.util.ResourceBundle;
43   -import br.gov.frameworkdemoiselle.util.Strings;
44   -
45   -/**
46   - * @author SERPRO
47   - */
48   -@Alternative
49   -public class DefaultMessage implements Message {
50   -
51   - private final String originalText;
52   -
53   - private String parsedText;
54   -
55   - private final SeverityType severity;
56   -
57   - private final Object[] params;
58   -
59   - private final ResourceBundle bundle;
60   -
61   - public static final SeverityType DEFAULT_SEVERITY = SeverityType.INFO;
62   -
63   - public DefaultMessage(String text, SeverityType severity, Object... params) {
64   - this.originalText = text;
65   - this.severity = (severity == null ? DEFAULT_SEVERITY : severity);
66   - this.params = params;
67   - this.bundle = Beans.getReference(ResourceBundle.class);
68   - }
69   -
70   - public DefaultMessage(String text, Object... params) {
71   - this(text, null, (Object[]) params);
72   - }
73   -
74   - public String getText() {
75   - initParsedText();
76   - return parsedText;
77   - }
78   -
79   - private void initParsedText() {
80   - if (parsedText == null) {
81   - if (Strings.isResourceBundleKeyFormat(originalText)) {
82   - parsedText = bundle.getString(Strings.removeBraces(originalText));
83   -
84   - } else if (originalText != null) {
85   - parsedText = new String(originalText);
86   - }
87   -
88   - parsedText = Strings.getString(parsedText, params);
89   - }
90   - }
91   -
92   - public SeverityType getSeverity() {
93   - return severity;
94   - }
95   -
96   - @Override
97   - public String toString() {
98   - initParsedText();
99   - return Strings.toString(this);
100   - }
101   -}
core/src/main/java/br/gov/frameworkdemoiselle/message/Message.java
... ... @@ -1,60 +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 br.gov.frameworkdemoiselle.message;
38   -
39   -/**
40   - * Represents the configuration of a single message.
41   - *
42   - * @author SERPRO
43   - */
44   -public interface Message {
45   -
46   - /**
47   - * Represents the text of the message.
48   - */
49   - String getText();
50   -
51   -// void setText(String text);
52   -
53   - /**
54   - * Represents the kind of message. It could be useful for presentation layer.
55   - */
56   - SeverityType getSeverity();
57   -
58   -// void setSeverity(SeverityType severity);
59   -
60   -}
core/src/main/java/br/gov/frameworkdemoiselle/message/MessageContext.java
... ... @@ -1,75 +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 br.gov.frameworkdemoiselle.message;
38   -
39   -import java.util.List;
40   -
41   -/**
42   - * Context interface reserved for messaging purposes.
43   - * <p>
44   - * In order to use this, just add the line below in the code:
45   - * <p>
46   - * <code>@Inject MessageContext messageContext;</code>
47   - *
48   - * @author SERPRO
49   - * @see Message
50   - */
51   -public interface MessageContext {
52   -
53   - /**
54   - * Saves a message into the context.
55   - *
56   - * @param message
57   - */
58   -
59   - void add(Message message, Object... params);
60   -
61   - void add(String text, Object... params);
62   -
63   - void add(String text, SeverityType severity, Object... params);
64   -
65   - /**
66   - * Returns all messages in the context.
67   - */
68   - List<Message> getMessages();
69   -
70   - /**
71   - * Clears the list of messages in the context.
72   - */
73   - void clear();
74   -
75   -}
core/src/main/java/br/gov/frameworkdemoiselle/message/SeverityType.java
... ... @@ -1,66 +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 br.gov.frameworkdemoiselle.message;
38   -
39   -/**
40   - * Defines severity types to be used.
41   - *
42   - * @author SERPRO
43   - */
44   -public enum SeverityType {
45   -
46   - /**
47   - * Information (less critical)
48   - */
49   - INFO,
50   -
51   - /**
52   - * Warning
53   - */
54   - WARN,
55   -
56   - /**
57   - * Error
58   - */
59   - ERROR,
60   -
61   - /**
62   - * Fatal (most critical)
63   - */
64   - FATAL
65   -
66   -}
core/src/main/java/br/gov/frameworkdemoiselle/pagination/Pagination.java
... ... @@ -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 br.gov.frameworkdemoiselle.pagination;
38   -
39   -/**
40   - * Structure used to handle pagination of data results on both <i>backend</i> (i.e., persistence) and <i>frontend</i>
41   - * (i.e., presentation) layers in the application.
42   - *
43   - * @author SERPRO
44   - */
45   -public interface Pagination {
46   -
47   - /**
48   - * Returns the current page.
49   - */
50   - int getCurrentPage();
51   -
52   - /**
53   - * Sets the current page.
54   - */
55   - void setCurrentPage(int currentPage);
56   -
57   - /**
58   - * Returns the page size.
59   - */
60   - int getPageSize();
61   -
62   - /**
63   - * Sets the page size.
64   - */
65   - void setPageSize(int pageSize);
66   -
67   - /**
68   - * Returns the total number of results.
69   - */
70   - int getTotalResults();
71   -
72   - /**
73   - * Sets the total number of results and calculates the number of pages.
74   - */
75   - void setTotalResults(int totalResults);
76   -
77   - /**
78   - * Returns the total number of pages.
79   - */
80   - int getTotalPages();
81   -
82   - /**
83   - * Returns the position for the first record according to current page and page size.
84   - */
85   - int getFirstResult();
86   -
87   - /**
88   - * Sets the position for the first record and hence calculates current page according to page size.
89   - */
90   - void setFirstResult(int firstResult);
91   -
92   -}
core/src/main/java/br/gov/frameworkdemoiselle/pagination/PaginationContext.java
... ... @@ -1,69 +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 br.gov.frameworkdemoiselle.pagination;
38   -
39   -/**
40   - * Context interface reserved for pagination purposes.
41   - * <p>
42   - * In order to use this, just add the line below in the code:
43   - * <p>
44   - * <code>@Inject PaginationContext paginationContext;</code>
45   - *
46   - * @author SERPRO
47   - * @see Pagination
48   - */
49   -public interface PaginationContext {
50   -
51   - /**
52   - * Retrieves the pagination according to the class type specified.
53   - *
54   - * @param clazz a {@code Class} type
55   - * @return Pagination
56   - */
57   - Pagination getPagination(Class<?> clazz);
58   -
59   - /**
60   - * Retrieves the pagination according to the class type specified. If not existing, creates the pagination whenever
61   - * {@code create} parameter is true.
62   - *
63   - * @param clazz a {@code Class} type
64   - * @param create determines whether pagination must always be returned
65   - * @return Pagination
66   - */
67   - Pagination getPagination(Class<?> clazz, boolean create);
68   -
69   -}
core/src/main/java/br/gov/frameworkdemoiselle/security/AfterLoginSuccessful.java
... ... @@ -1,48 +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 br.gov.frameworkdemoiselle.security;
38   -
39   -import java.io.Serializable;
40   -
41   -/**
42   - * This interface represents an event that is fired when user successfully logs in.
43   - *
44   - * @author SERPRO
45   - */
46   -public interface AfterLoginSuccessful extends Serializable {
47   -
48   -}
core/src/main/java/br/gov/frameworkdemoiselle/security/AfterLogoutSuccessful.java
... ... @@ -1,48 +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 br.gov.frameworkdemoiselle.security;
38   -
39   -import java.io.Serializable;
40   -
41   -/**
42   - * This interface represents an event fired just after the user unauthenticates.
43   - *
44   - * @author SERPRO
45   - */
46   -public interface AfterLogoutSuccessful extends Serializable {
47   -
48   -}
core/src/main/java/br/gov/frameworkdemoiselle/security/Authenticator.java
... ... @@ -1,66 +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 br.gov.frameworkdemoiselle.security;
38   -
39   -import java.io.Serializable;
40   -
41   -/**
42   - * Defines the methods that should be implemented by anyone who wants an authentication mechanism.
43   - *
44   - * @author SERPRO
45   - */
46   -public interface Authenticator extends Serializable {
47   -
48   - /**
49   - * Executes the necessary steps to authenticate an user.
50   - *
51   - * @return {@code true} if the user was authenticated properly
52   - */
53   - boolean authenticate();
54   -
55   - /**
56   - * Executes the necessary steps to unauthenticate an user.
57   - */
58   - void unAuthenticate();
59   -
60   - /**
61   - * Returns the currently authenticated user.
62   - *
63   - * @return the user currently authenticated
64   - */
65   - User getUser();
66   -}
core/src/main/java/br/gov/frameworkdemoiselle/security/AuthorizationException.java
... ... @@ -1,65 +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 br.gov.frameworkdemoiselle.security;
38   -
39   -import br.gov.frameworkdemoiselle.internal.implementation.CoreBundle;
40   -
41   -/**
42   - * Thrown when trying to access some resource and/or execute an operation without the proper authorization.
43   - *
44   - * @author SERPRO
45   - */
46   -public class AuthorizationException extends SecurityException {
47   -
48   - private static final long serialVersionUID = 1L;
49   -
50   - /**
51   - * Constructor with message.
52   - *
53   - * @param message
54   - * exception message
55   - */
56   - public AuthorizationException(String message) {
57   - super(message);
58   - }
59   -
60   - public AuthorizationException(String resource, String operation) {
61   - // TODO: remove the CoreBundle call
62   - super(CoreBundle.get().getString("access-denied-ui", resource, operation));
63   - }
64   -
65   -}
core/src/main/java/br/gov/frameworkdemoiselle/security/Authorizer.java
... ... @@ -1,68 +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 br.gov.frameworkdemoiselle.security;
38   -
39   -import java.io.Serializable;
40   -
41   -/**
42   - * Defines the methods that should be implemented by anyone who wants an authorization mechanism.
43   - *
44   - * @author SERPRO
45   - */
46   -public interface Authorizer extends Serializable {
47   -
48   - /**
49   - * Checks if the logged user has an specific role
50   - *
51   - * @param role
52   - * role to be checked
53   - * @return {@code true} if the user has the role
54   - */
55   - boolean hasRole(String role);
56   -
57   - /**
58   - * Checks if the logged user has permission to execute an specific operation on a specific resource.
59   - *
60   - * @param resource
61   - * resource to be checked
62   - * @param operation
63   - * operation to be checked
64   - * @return {@code true} if the user has the permission
65   - */
66   - boolean hasPermission(String resource, String operation);
67   -
68   -}
core/src/main/java/br/gov/frameworkdemoiselle/security/NotLoggedInException.java
... ... @@ -1,54 +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 br.gov.frameworkdemoiselle.security;
38   -
39   -/**
40   - * Thrown when trying to access some resource or execute an operation that requires authentication.
41   - *
42   - * @author SERPRO
43   - */
44   -public class NotLoggedInException extends SecurityException {
45   -
46   - private static final long serialVersionUID = 1L;
47   -
48   - /**
49   - * Constructs an <code>NotLoggedInException</code> with no detail message.
50   - */
51   - public NotLoggedInException(String message) {
52   - super(message);
53   - }
54   -}
core/src/main/java/br/gov/frameworkdemoiselle/security/RequiredPermission.java
... ... @@ -1,66 +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 br.gov.frameworkdemoiselle.security;
38   -
39   -import static java.lang.annotation.ElementType.METHOD;
40   -import static java.lang.annotation.ElementType.TYPE;
41   -import static java.lang.annotation.RetentionPolicy.RUNTIME;
42   -
43   -import java.lang.annotation.Inherited;
44   -import java.lang.annotation.Retention;
45   -import java.lang.annotation.Target;
46   -
47   -import javax.enterprise.util.Nonbinding;
48   -import javax.interceptor.InterceptorBinding;
49   -
50   -/**
51   - * Indicates that a specific permission is required in order to invocate the annotated method or class.
52   - *
53   - * @author SERPRO
54   - */
55   -@Inherited
56   -@InterceptorBinding
57   -@Target({ METHOD, TYPE })
58   -@Retention(RUNTIME)
59   -public @interface RequiredPermission {
60   -
61   - @Nonbinding
62   - String resource() default "";
63   -
64   - @Nonbinding
65   - String operation() default "";
66   -}
core/src/main/java/br/gov/frameworkdemoiselle/security/RequiredRole.java
... ... @@ -1,64 +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 br.gov.frameworkdemoiselle.security;
38   -
39   -import static java.lang.annotation.ElementType.METHOD;
40   -import static java.lang.annotation.ElementType.TYPE;
41   -import static java.lang.annotation.RetentionPolicy.RUNTIME;
42   -
43   -import java.lang.annotation.Inherited;
44   -import java.lang.annotation.Retention;
45   -import java.lang.annotation.Target;
46   -
47   -import javax.enterprise.util.Nonbinding;
48   -import javax.interceptor.InterceptorBinding;
49   -
50   -/**
51   - * Indicates that the annotated method or class requires the user to have one or more roles associated in order to be
52   - * invocated.
53   - *
54   - * @author SERPRO
55   - */
56   -@Inherited
57   -@InterceptorBinding
58   -@Target({ METHOD, TYPE })
59   -@Retention(RUNTIME)
60   -public @interface RequiredRole {
61   -
62   - @Nonbinding
63   - String[] value();
64   -}
core/src/main/java/br/gov/frameworkdemoiselle/security/SecurityContext.java
... ... @@ -1,99 +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 br.gov.frameworkdemoiselle.security;
38   -
39   -import java.io.Serializable;
40   -
41   -
42   -/**
43   - * Structure used to handle both authentication and authorizations mechanisms.
44   - *
45   - * @author SERPRO
46   - */
47   -public interface SecurityContext extends Serializable {
48   -
49   - /**
50   - * Executes the login of a user to the application.
51   - */
52   - void login();
53   -
54   - /**
55   - * Executes the logout of a user.
56   - *
57   - * @throws NotLoggedInException
58   - * if there is no user logged in a specific session
59   - */
60   - void logout() throws NotLoggedInException;
61   -
62   - /**
63   - * Checks if a specific user is logged in.
64   - *
65   - * @return {@code true} if the user is logged in
66   - */
67   - boolean isLoggedIn();
68   -
69   - /**
70   - * Checks if the logged user has permission to execute an specific operation on a specific resource.
71   - *
72   - * @param resource
73   - * resource to be checked
74   - * @param operation
75   - * operation to be checked
76   - * @return {@code true} if the user has the permission
77   - * @throws NotLoggedInException
78   - * if there is no user logged in a specific session.
79   - */
80   - boolean hasPermission(String resource, String operation) throws NotLoggedInException;
81   -
82   - /**
83   - * Checks if the logged user has an specific role
84   - *
85   - * @param role
86   - * role to be checked
87   - * @return {@code true} if the user has the role
88   - * @throws NotLoggedInException
89   - * if there is no user logged in a specific session.
90   - */
91   - boolean hasRole(String role) throws NotLoggedInException;
92   -
93   - /**
94   - * Return the user logged in the session.
95   - *
96   - * @return the user logged in a specific session. If there is no active session returns {@code null}
97   - */
98   - User getUser();
99   -}
core/src/main/java/br/gov/frameworkdemoiselle/security/SecurityException.java
... ... @@ -1,60 +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 br.gov.frameworkdemoiselle.security;
38   -
39   -import br.gov.frameworkdemoiselle.DemoiselleException;
40   -
41   -/**
42   - * <code>SecurityException</code> is the superclass of those exceptions that can be thrown due to any security related
43   - * issue.
44   - *
45   - * @author SERPRO
46   - */
47   -public class SecurityException extends DemoiselleException {
48   -
49   - private static final long serialVersionUID = 1L;
50   -
51   - /**
52   - * Constructs an <code>SecurityException</code> with the specified detail message.
53   - *
54   - * @param message
55   - * the detail message.
56   - */
57   - public SecurityException(String message) {
58   - super(message);
59   - }
60   -}
core/src/main/java/br/gov/frameworkdemoiselle/security/User.java
... ... @@ -1,73 +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 br.gov.frameworkdemoiselle.security;
38   -
39   -import java.io.Serializable;
40   -
41   -/**
42   - * @author SERPRO
43   - *
44   - */
45   -public interface User extends Serializable {
46   -
47   - /**
48   - * Returns the id of the logged user.
49   - *
50   - * @return the id of the logged user
51   - */
52   - String getId();
53   -
54   - /**
55   - * Return the value associated with the key being passed.
56   - *
57   - * @param key
58   - * the key whose value should be searched
59   - * @return the value associated with the key being passed
60   - */
61   - Object getAttribute(Object key);
62   -
63   - /**
64   - * Sets an attribute.
65   - *
66   - * @param key
67   - * the key that identifies the value
68   - * @param value
69   - * the value to be stored
70   - */
71   - void setAttribute(Object key, Object value);
72   -
73   -}
core/src/main/java/br/gov/frameworkdemoiselle/stereotype/BusinessController.java
... ... @@ -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 br.gov.frameworkdemoiselle.stereotype;
38   -
39   -import static java.lang.annotation.ElementType.TYPE;
40   -import static java.lang.annotation.RetentionPolicy.RUNTIME;
41   -
42   -import java.lang.annotation.Inherited;
43   -import java.lang.annotation.Retention;
44   -import java.lang.annotation.Target;
45   -
46   -import javax.enterprise.inject.Stereotype;
47   -
48   -/**
49   - * Identifies a <b>business controller</b> class. Business controller objects typically implement the controller design
50   - * pattern, i.e., they contain no data elements but methods that orchestrate interaction among business entities.
51   - * <p>
52   - * A <i>Business Controller</i> is:
53   - * <ul>
54   - * <li>defined when annotated with {@code @BusinessController}</li>
55   - * <li>automatically injected whenever {@code @Inject} is used</li>
56   - * </ul>
57   - *
58   - * @author SERPRO
59   - * @see @Controller
60   - */
61   -@Controller
62   -@Stereotype
63   -@Inherited
64   -@Target(TYPE)
65   -@Retention(RUNTIME)
66   -public @interface BusinessController {
67   -}
core/src/main/java/br/gov/frameworkdemoiselle/stereotype/Controller.java
... ... @@ -1,59 +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 br.gov.frameworkdemoiselle.stereotype;
38   -
39   -import static java.lang.annotation.ElementType.METHOD;
40   -import static java.lang.annotation.ElementType.TYPE;
41   -import static java.lang.annotation.RetentionPolicy.RUNTIME;
42   -
43   -import java.lang.annotation.Inherited;
44   -import java.lang.annotation.Retention;
45   -import java.lang.annotation.Target;
46   -
47   -import javax.interceptor.InterceptorBinding;
48   -
49   -/**
50   - * Identifies a <b>controller</b> class or stereotype, the latter being most suitable for it.
51   - *
52   - * @author SERPRO
53   - */
54   -@InterceptorBinding
55   -@Inherited
56   -@Target({ TYPE, METHOD })
57   -@Retention(RUNTIME)
58   -public @interface Controller {
59   -}
core/src/main/java/br/gov/frameworkdemoiselle/stereotype/FacadeController.java
... ... @@ -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 br.gov.frameworkdemoiselle.stereotype;
38   -
39   -import static java.lang.annotation.ElementType.TYPE;
40   -import static java.lang.annotation.RetentionPolicy.RUNTIME;
41   -
42   -import java.lang.annotation.Inherited;
43   -import java.lang.annotation.Retention;
44   -import java.lang.annotation.Target;
45   -
46   -import javax.enterprise.inject.Stereotype;
47   -
48   -/**
49   - * Identifies a <b>facade</b> class. A facade is an object that provides a simplified interface to a larger body of
50   - * code, such as a class library.
51   - * <p>
52   - * A <i>Facade</i> is:
53   - * <ul>
54   - * <li>defined when annotated with {@code @Facade}</li>
55   - * <li>automatically injected whenever {@code @Inject} is used</li>
56   - * </ul>
57   - *
58   - * @author SERPRO
59   - * @see @Controller
60   - */
61   -@Controller
62   -@Stereotype
63   -@Inherited
64   -@Target(TYPE)
65   -@Retention(RUNTIME)
66   -public @interface FacadeController {
67   -}
core/src/main/java/br/gov/frameworkdemoiselle/stereotype/PersistenceController.java
... ... @@ -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 br.gov.frameworkdemoiselle.stereotype;
38   -
39   -import static java.lang.annotation.ElementType.TYPE;
40   -import static java.lang.annotation.RetentionPolicy.RUNTIME;
41   -
42   -import java.lang.annotation.Inherited;
43   -import java.lang.annotation.Retention;
44   -import java.lang.annotation.Target;
45   -
46   -import javax.enterprise.inject.Stereotype;
47   -
48   -/**
49   - * Identifies a <b>persistence controller</b> class. A persistence controller is a layer which provides simplified
50   - * access to data stored in persistent storage of some kind, such as an entity-relational database.
51   - * <p>
52   - * A <i>Persitence Controller</i> is:
53   - * <ul>
54   - * <li>defined when annotated with {@code @PersistenceController}</li>
55   - * <li>automatically injected whenever {@code @Inject} is used</li>
56   - * </ul>
57   - *
58   - * @author SERPRO
59   - * @see @Controller
60   - */
61   -@Controller
62   -@Stereotype
63   -@Inherited
64   -@Target(TYPE)
65   -@Retention(RUNTIME)
66   -public @interface PersistenceController {
67   -}
core/src/main/java/br/gov/frameworkdemoiselle/stereotype/ViewController.java
... ... @@ -1,72 +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 br.gov.frameworkdemoiselle.stereotype;
38   -
39   -import static java.lang.annotation.ElementType.TYPE;
40   -import static java.lang.annotation.RetentionPolicy.RUNTIME;
41   -
42   -import java.lang.annotation.Inherited;
43   -import java.lang.annotation.Retention;
44   -import java.lang.annotation.Target;
45   -
46   -import javax.enterprise.inject.Stereotype;
47   -import javax.inject.Named;
48   -
49   -import br.gov.frameworkdemoiselle.annotation.ViewScoped;
50   -
51   -/**
52   - * Identifies a <b>view controller</b> class. A view controller class is intend to respond to events initiated in the
53   - * application front-view. It should have attributes and methods intented to populate the view.
54   - * <p>
55   - * A <i>View Controller</i> is:
56   - * <ul>
57   - * <li>defined when annotated with {@code @ViewController}</li>
58   - * <li>automatically injected whenever {@code @Inject} is used</li>
59   - * </ul>
60   - *
61   - * @author SERPRO
62   - * @see @Controller
63   - */
64   -@Named
65   -@Controller
66   -@Stereotype
67   -@ViewScoped
68   -@Inherited
69   -@Target(TYPE)
70   -@Retention(RUNTIME)
71   -public @interface ViewController {
72   -}
core/src/main/java/br/gov/frameworkdemoiselle/template/Crud.java
... ... @@ -1,54 +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 br.gov.frameworkdemoiselle.template;
38   -
39   -import java.io.Serializable;
40   -import java.util.List;
41   -
42   -public interface Crud<T, I> extends Serializable {
43   -
44   - void delete(I id);
45   -
46   - List<T> findAll();
47   -
48   - void insert(T bean);
49   -
50   - T load(I id);
51   -
52   - void update(T bean);
53   -
54   -}
core/src/main/java/br/gov/frameworkdemoiselle/template/DelegateCrud.java
... ... @@ -1,95 +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 br.gov.frameworkdemoiselle.template;
38   -
39   -import java.util.List;
40   -
41   -import br.gov.frameworkdemoiselle.transaction.Transactional;
42   -import br.gov.frameworkdemoiselle.util.Beans;
43   -import br.gov.frameworkdemoiselle.util.Reflections;
44   -
45   -public class DelegateCrud<T, I, C extends Crud<T, I>> implements Crud<T, I> {
46   -
47   - private static final long serialVersionUID = 1L;
48   -
49   - private Class<C> delegateClass;
50   -
51   - private C delegate;
52   -
53   - @Override
54   - @Transactional
55   - public void delete(final I id) {
56   - this.getDelegate().delete(id);
57   - }
58   -
59   - @Override
60   - public List<T> findAll() {
61   - return getDelegate().findAll();
62   - }
63   -
64   - protected C getDelegate() {
65   - if (this.delegate == null) {
66   - this.delegate = Beans.getReference(getDelegateClass());
67   - }
68   - return this.delegate;
69   - }
70   -
71   - protected Class<C> getDelegateClass() {
72   - if (this.delegateClass == null) {
73   - this.delegateClass = Reflections.getGenericTypeArgument(this.getClass(), 2);
74   - }
75   - return this.delegateClass;
76   - }
77   -
78   - @Override
79   - @Transactional
80   - public void insert(final T bean) {
81   - getDelegate().insert(bean);
82   - }
83   -
84   - @Override
85   - public T load(final I id) {
86   - return getDelegate().load(id);
87   - }
88   -
89   - @Override
90   - @Transactional
91   - public void update(final T bean) {
92   - getDelegate().update(bean);
93   - }
94   -
95   -}
core/src/main/java/br/gov/frameworkdemoiselle/transaction/Transaction.java
... ... @@ -1,86 +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 br.gov.frameworkdemoiselle.transaction;
38   -
39   -import java.io.Serializable;
40   -
41   -/**
42   - * This interface improves UserTransaction by defining additional methods to it, allowing an application to explicitly
43   - * manage transaction boundaries.
44   - *
45   - * @author SERPRO
46   - * @see UserTransaction
47   - */
48   -public interface Transaction extends Serializable {
49   -
50   - /**
51   - * Indicates whether the given transaction is still active.
52   - *
53   - * @return a boolean
54   - */
55   - boolean isActive();
56   -
57   - /**
58   - * Indicates whether the given transaction is already marked to be rolled back.
59   - *
60   - * @return a boolean
61   - */
62   - boolean isMarkedRollback();
63   -
64   - /**
65   - * Create a new transaction and associate it with the current thread.
66   - */
67   - void begin();
68   -
69   - /**
70   - * Complete the transaction associated with the current thread. When this method completes, the thread is no longer
71   - * associated with a transaction.
72   - */
73   - void commit();
74   -
75   - /**
76   - * Roll back the transaction associated with the current thread. When this method completes, the thread is no longer
77   - * associated with a transaction.
78   - */
79   - void rollback();
80   -
81   - /**
82   - * Modify the transaction associated with the current thread such that the only possible outcome of the transaction
83   - * is to roll back the transaction.
84   - */
85   - void setRollbackOnly();
86   -}
core/src/main/java/br/gov/frameworkdemoiselle/transaction/TransactionException.java
... ... @@ -1,12 +0,0 @@
1   -package br.gov.frameworkdemoiselle.transaction;
2   -
3   -import br.gov.frameworkdemoiselle.DemoiselleException;
4   -
5   -public class TransactionException extends DemoiselleException {
6   -
7   - private static final long serialVersionUID = 1L;
8   -
9   - public TransactionException(Throwable cause) {
10   - super(cause);
11   - }
12   -}
core/src/main/java/br/gov/frameworkdemoiselle/transaction/Transactional.java
... ... @@ -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 br.gov.frameworkdemoiselle.transaction;
38   -
39   -import static java.lang.annotation.ElementType.METHOD;
40   -import static java.lang.annotation.ElementType.TYPE;
41   -import static java.lang.annotation.RetentionPolicy.RUNTIME;
42   -
43   -import java.lang.annotation.Inherited;
44   -import java.lang.annotation.Retention;
45   -import java.lang.annotation.Target;
46   -
47   -import javax.interceptor.InterceptorBinding;
48   -
49   -/**
50   - * <p>
51   - * Identifies a method to be <b>transactional</b>, i.e., it will be inspected and a transaction automatically managed
52   - * when it is fired.
53   - * </p>
54   - *
55   - * @author SERPRO
56   - */
57   -@Inherited
58   -@InterceptorBinding
59   -@Target({ METHOD, TYPE })
60   -@Retention(RUNTIME)
61   -public @interface Transactional {
62   -}
core/src/main/java/br/gov/frameworkdemoiselle/util/Beans.java
... ... @@ -1,90 +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   -/*
38   - * Demoiselle Framework Copyright (c) 2010 Serpro and other contributors as indicated by the @author tag. See the
39   - * copyright.txt in the distribution for a full listing of contributors. Demoiselle Framework is an open source Java EE
40   - * library designed to accelerate the development of transactional database Web applications. Demoiselle Framework is
41   - * released under the terms of the LGPL license 3 http://www.gnu.org/licenses/lgpl.html LGPL License 3 This file is part
42   - * of Demoiselle Framework. Demoiselle Framework is free software: you can redistribute it and/or modify it under the
43   - * terms of the GNU Lesser General Public License 3 as published by the Free Software Foundation. Demoiselle Framework
44   - * is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
45   - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You
46   - * should have received a copy of the GNU Lesser General Public License along with Demoiselle Framework. If not, see
47   - * <http://www.gnu.org/licenses/>.
48   - */
49   -package br.gov.frameworkdemoiselle.util;
50   -
51   -import java.lang.annotation.Annotation;
52   -
53   -import javax.enterprise.inject.spi.Bean;
54   -import javax.enterprise.inject.spi.BeanManager;
55   -
56   -public class Beans {
57   -
58   - private static BeanManager manager;
59   -
60   - public static void setBeanManager(BeanManager beanManager) {
61   - manager = beanManager;
62   - }
63   -
64   - public static BeanManager getBeanManager() {
65   - return manager;
66   - }
67   -
68   - @SuppressWarnings("unchecked")
69   - public static <T> T getReference(final Class<T> beanClass, Annotation... qualifiers) {
70   - Bean<?> bean = manager.getBeans(beanClass, qualifiers).iterator().next();
71   - return (T) getReference(bean);
72   - }
73   -
74   - @SuppressWarnings("unchecked")
75   - public static <T> T getReference(final Class<T> beanClass) {
76   - Bean<?> bean = manager.getBeans(beanClass).iterator().next();
77   - return (T) getReference(bean);
78   - }
79   -
80   - @SuppressWarnings("unchecked")
81   - public static <T> T getReference(String beanName) {
82   - Bean<?> bean = manager.getBeans(beanName).iterator().next();
83   - return (T) getReference(bean);
84   - }
85   -
86   - @SuppressWarnings("unchecked")
87   - private static <T> T getReference(Bean<?> bean) {
88   - return (T) manager.getReference(bean, bean.getBeanClass(), manager.createCreationalContext(bean));
89   - }
90   -}
core/src/main/java/br/gov/frameworkdemoiselle/util/Exceptions.java
... ... @@ -1,36 +0,0 @@
1   -/*
2   - * Demoiselle Framework Copyright (C) 2010 SERPRO
3   - * ---------------------------------------------------------------------------- This file is part of Demoiselle
4   - * Framework. Demoiselle Framework is free software; you can redistribute it and/or modify it under the terms of the GNU
5   - * Lesser General Public License version 3 as published by the Free Software Foundation. This program is distributed in
6   - * the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7   - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a
8   - * copy of the GNU Lesser General Public License version 3 along with this program; if not, see
9   - * <http://www.gnu.org/licenses/> or write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
10   - * Boston, MA 02110-1301, USA. ---------------------------------------------------------------------------- Este arquivo
11   - * é parte do Framework Demoiselle. O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou
12   - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação do Software Livre (FSF). Este
13   - * programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de
14   - * ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português para
15   - * maiores detalhes. Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título "LICENCA.txt", junto com esse
16   - * programa. Se não, acesse <http://www.gnu.org/licenses/> ou escreva para a Fundação do Software Livre (FSF) Inc., 51
17   - * Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
18   - */
19   -package br.gov.frameworkdemoiselle.util;
20   -
21   -import br.gov.frameworkdemoiselle.exception.ApplicationException;
22   -
23   -public class Exceptions {
24   -
25   - public static boolean isApplicationException(final Throwable throwable) {
26   - return throwable.getClass().isAnnotationPresent(ApplicationException.class);
27   - }
28   -
29   - public static void handleToRuntimeException(final Throwable throwable) throws RuntimeException {
30   - if (throwable instanceof RuntimeException) {
31   - throw (RuntimeException) throwable;
32   - } else {
33   - throw new RuntimeException(throwable);
34   - }
35   - }
36   -}
core/src/main/java/br/gov/frameworkdemoiselle/util/Reflections.java
... ... @@ -1,143 +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 br.gov.frameworkdemoiselle.util;
38   -
39   -import java.lang.reflect.Field;
40   -import java.lang.reflect.Member;
41   -import java.lang.reflect.Method;
42   -import java.lang.reflect.Modifier;
43   -import java.lang.reflect.ParameterizedType;
44   -import java.lang.reflect.Type;
45   -import java.util.ArrayList;
46   -import java.util.List;
47   -
48   -public class Reflections {
49   -
50   - @SuppressWarnings("unchecked")
51   - public static <T> Class<T> getGenericTypeArgument(final Class<?> clazz, final int idx) {
52   - final Type type = clazz.getGenericSuperclass();
53   -
54   - ParameterizedType paramType;
55   - try {
56   - paramType = (ParameterizedType) type;
57   - } catch (ClassCastException cause) {
58   - paramType = (ParameterizedType) ((Class<T>) type).getGenericSuperclass();
59   - }
60   -
61   - return (Class<T>) paramType.getActualTypeArguments()[idx];
62   - }
63   -
64   - @SuppressWarnings("unchecked")
65   - public static <T> Class<T> getGenericTypeArgument(final Field field, final int idx) {
66   - final Type type = field.getGenericType();
67   - final ParameterizedType paramType = (ParameterizedType) type;
68   -
69   - return (Class<T>) paramType.getActualTypeArguments()[idx];
70   - }
71   -
72   - public static <T> Class<T> getGenericTypeArgument(final Member member, final int idx) {
73   - Class<T> result = null;
74   -
75   - if (member instanceof Field) {
76   - result = getGenericTypeArgument((Field) member, idx);
77   - } else if (member instanceof Method) {
78   - result = getGenericTypeArgument((Method) member, idx);
79   - }
80   -
81   - return result;
82   - }
83   -
84   - @SuppressWarnings("unchecked")
85   - public static <T> Class<T> getGenericTypeArgument(final Method method, final int pos) {
86   - return (Class<T>) method.getGenericParameterTypes()[pos];
87   - }
88   -
89   - public static Object getFieldValue(Field field, Object object) {
90   - Object result = null;
91   -
92   - try {
93   - boolean acessible = field.isAccessible();
94   - field.setAccessible(true);
95   - result = field.get(object);
96   - field.setAccessible(acessible);
97   -
98   - } catch (Exception e) {
99   - Exceptions.handleToRuntimeException(e);
100   - }
101   -
102   - return result;
103   - }
104   -
105   - public static void setFieldValue(Field field, Object object, Object value) {
106   - try {
107   - boolean acessible = field.isAccessible();
108   - field.setAccessible(true);
109   - field.set(object, value);
110   - field.setAccessible(acessible);
111   -
112   - } catch (Exception e) {
113   - Exceptions.handleToRuntimeException(e);
114   - }
115   - }
116   -
117   - public static Field[] getNonStaticDeclaredFields(Class<?> type) {
118   - List<Field> fields = new ArrayList<Field>();
119   -
120   - if (type != null) {
121   - for (Field field : type.getDeclaredFields()) {
122   - if (!Modifier.isStatic(field.getModifiers()) && !field.getType().equals(type.getDeclaringClass())) {
123   - fields.add(field);
124   - }
125   - }
126   - }
127   -
128   - return fields.toArray(new Field[0]);
129   - }
130   -
131   - public static <T> T instantiate(Class<T> clasz) {
132   - T object = null;
133   - try {
134   - object = clasz.newInstance();
135   - } catch (InstantiationException e) {
136   - Exceptions.handleToRuntimeException(e);
137   - } catch (IllegalAccessException e) {
138   - Exceptions.handleToRuntimeException(e);
139   - }
140   - return object;
141   - }
142   -
143   -}
core/src/main/java/br/gov/frameworkdemoiselle/util/ResourceBundle.java
... ... @@ -1,95 +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 br.gov.frameworkdemoiselle.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.Set;
44   -
45   -public class ResourceBundle extends java.util.ResourceBundle implements Serializable {
46   -
47   - private static final long serialVersionUID = 1L;
48   -
49   - private transient java.util.ResourceBundle delegate;
50   -
51   - public ResourceBundle(java.util.ResourceBundle resourceBundle) {
52   - this.delegate = resourceBundle;
53   - }
54   -
55   - @Override
56   - public boolean containsKey(String key) {
57   - return delegate.containsKey(key);
58   - }
59   -
60   - @Override
61   - public Enumeration<String> getKeys() {
62   - return delegate.getKeys();
63   - }
64   -
65   - @Override
66   - public Locale getLocale() {
67   - return delegate.getLocale();
68   - }
69   -
70   - @Override
71   - public Set<String> keySet() {
72   - return delegate.keySet();
73   - }
74   -
75   - public String getString(String key, Object... params) {
76   - return Strings.getString(getString(key), params);
77   - }
78   -
79   - @Override
80   - protected Object handleGetObject(String key) {
81   - Object result;
82   -
83   - try {
84   - Method method = delegate.getClass().getMethod("handleGetObject", String.class);
85   -
86   - method.setAccessible(true);
87   - result = method.invoke(delegate, key);
88   - method.setAccessible(false);
89   -
90   - } catch (Exception cause) {
91   - throw new RuntimeException(cause);
92   - }
93   - return result;
94   - }
95   -}
core/src/main/java/br/gov/frameworkdemoiselle/util/Strings.java
... ... @@ -1,162 +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 br.gov.frameworkdemoiselle.util;
38   -
39   -import java.lang.reflect.Field;
40   -import java.util.Arrays;
41   -import java.util.regex.Matcher;
42   -import java.util.regex.Pattern;
43   -
44   -import br.gov.frameworkdemoiselle.annotation.Ignore;
45   -
46   -public class Strings {
47   -
48   - public static boolean isResourceBundleKeyFormat(final String key) {
49   - return Pattern.matches("^\\{(.+)\\}$", key == null ? "" : key);
50   - }
51   -
52   - public static String removeChars(String string, char... chars) {
53   - if (string != null) {
54   - for (char ch : chars) {
55   - string = string.replace(String.valueOf(ch), "");
56   - }
57   - }
58   - return string;
59   - }
60   -
61   - public static String insertZeros(String string, int howMuchZeros) {
62   - StringBuffer result = new StringBuffer((string == null ? "" : string).trim());
63   - int difference = howMuchZeros - string.length();
64   -
65   - for (int j = 0; j < difference; j++) {
66   - result.insert(0, '0');
67   - }
68   -
69   - return result.toString();
70   - }
71   -
72   - public static String getString(final String string, final Object... params) {
73   - String result = null;
74   -
75   - if (string != null) {
76   - result = new String(string);
77   - }
78   -
79   - if (params != null && string != null) {
80   - for (int i = 0; i < params.length; i++) {
81   - if (params[i] != null) {
82   - result = result.replaceAll("\\{" + i + "\\}", Matcher.quoteReplacement(params[i].toString()));
83   - }
84   - }
85   - }
86   -
87   - return result;
88   - }
89   -
90   - public static boolean isEmpty(String string) {
91   - return string == null || string.trim().isEmpty();
92   - }
93   -
94   - public static String toString(Object object) {
95   - StringBuffer result = new StringBuffer();
96   - Object fieldValue;
97   -
98   - if (object != null) {
99   - result.append(object.getClass().getSimpleName());
100   - result.append(" [");
101   -
102   - boolean first = true;
103   - for (Field field : Reflections.getNonStaticDeclaredFields(object.getClass())) {
104   - if (!field.isAnnotationPresent(Ignore.class)) {
105   - if (first) {
106   - first = false;
107   - } else {
108   - result.append(", ");
109   - }
110   -
111   - result.append(field.getName());
112   - result.append("=");
113   - fieldValue = Reflections.getFieldValue(field, object);
114   - result.append(fieldValue != null && fieldValue.getClass().isArray() ? Arrays
115   - .toString((Object[]) fieldValue) : fieldValue);
116   - }
117   - }
118   -
119   - result.append("]");
120   - }
121   -
122   - return result.toString();
123   - }
124   -
125   - public static String camelCaseToSymbolSeparated(String string, String symbol) {
126   - if (symbol == null) {
127   - symbol = "";
128   - }
129   -
130   - return string == null ? null : string.replaceAll("\\B([A-Z])", symbol + "$1").toLowerCase();
131   - }
132   -
133   - public static String firstToUpper(String string) {
134   - String result = string;
135   -
136   - if (!Strings.isEmpty(string)) {
137   - result = string.toUpperCase().charAt(0) + (string.length() > 1 ? string.substring(1) : "");
138   - }
139   -
140   - return result;
141   - }
142   -
143   - public static String removeBraces(String string) {
144   - String result = string;
145   -
146   - if (isResourceBundleKeyFormat(string)) {
147   - result = string.substring(1, string.length() - 1);
148   - }
149   -
150   - return result;
151   - }
152   -
153   - public static String insertBraces(String string) {
154   - String result = string;
155   -
156   - if (!isEmpty(string)) {
157   - result = "{" + string + "}";
158   - }
159   -
160   - return result;
161   - }
162   -}
core/src/main/resources/META-INF/beans.xml
... ... @@ -1,47 +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   -<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
38   - xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
39   -
40   - <interceptors>
41   - <class>br.gov.frameworkdemoiselle.internal.interceptor.ExceptionHandlerInterceptor</class>
42   - <class>br.gov.frameworkdemoiselle.internal.interceptor.RequiredPermissionInterceptor</class>
43   - <class>br.gov.frameworkdemoiselle.internal.interceptor.RequiredRoleInterceptor</class>
44   - <class>br.gov.frameworkdemoiselle.internal.interceptor.TransactionalInterceptor</class>
45   - </interceptors>
46   -
47   -</beans>
48 0 \ No newline at end of file
core/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
... ... @@ -1,5 +0,0 @@
1   -br.gov.frameworkdemoiselle.internal.bootstrap.CoreBootstrap
2   -br.gov.frameworkdemoiselle.internal.bootstrap.ConfigurationBootstrap
3   -
4   -br.gov.frameworkdemoiselle.internal.bootstrap.StartupBootstrap
5   -br.gov.frameworkdemoiselle.internal.bootstrap.ShutdownBootstrap
core/src/main/resources/demoiselle-core-bundle.properties
... ... @@ -1,95 +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 é parte do Framework Demoiselle.
21   -#
22   -# O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou
23   -# modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação
24   -# do Software Livre (FSF).
25   -#
26   -# Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA
27   -# GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou
28   -# APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português
29   -# para maiores detalhes.
30   -#
31   -# Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título
32   -# "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>
33   -# ou escreva para a Fundação do Software Livre (FSF) Inc.,
34   -# 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
35   -
36   -engine-on=Ligando os motores do Demoiselle ${project.version}
37   -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}
38   -handling-exception=Tratando a exce\u00E7\u00E3o {0}
39   -proxy-detected=Detectado o proxy {0} da classe {1}
40   -ambiguous-key=Existe mais de uma chave declarada no arquivo de configura\u00E7\u00E3o para o campo {0} da classe {1}. Indique qual a chave correta utilizando a anota\u00E7\u00E3o Name
41   -taking-off=O Demoiselle ${project.version} decolou
42   -engine-off=Desligando os motores do Demoiselle ${project.version}
43   -setting-up-bean-manager=BeanManager dispon\u00EDvel atrav\u00E9s do utilit\u00E1rio {0}
44   -
45   -user-transaction-lookup-fail=N\u00E3o foi encontrada nenhuma transa\u00E7\u00E3o com o nome {0} no contexto JNDI
46   -transactional-execution=Execu\u00E7\u00E3o transacional de {0}
47   -begin-transaction=Transa\u00E7\u00E3o iniciada
48   -transaction-marked-rollback=Transa\u00E7\u00E3o marcada para rollback [{0}]
49   -transaction-already-finalized=A transa\u00E7\u00E3o j\u00E1 havia sido finalizada
50   -transaction-commited=Transa\u00E7\u00E3o finalizada com sucesso
51   -transaction-rolledback=Transa\u00E7\u00E3o finalizada com rollback
52   -
53   -bootstrap.configuration.processing=Processando {0}
54   -
55   -loading-configuration-class=Carregando a classe de configura\u00E7\u00E3o {0}
56   -configuration-field-loaded=Configura\u00E7\u00E3o {0} atribu\u00EDda \u00E0 {1} com o valor {2}
57   -configuration-attribute-is-mandatory=A configura\u00E7\u00E3o {0} \u00E9 obrigat\u00F3ria, mas n\u00E3o foi encontrada em {1}
58   -configuration-name-attribute-cant-be-empty=A nota\u00E7\u00E3o Name n\u00E3o pode estar em branco
59   -configuration-key-not-found=Chave de configura\u00E7\u00E3o "{0}" n\u00E3o encontrada. Conven\u00E7\u00F5es verificadas\: "{1}"
60   -
61   -transaction-not-defined=Nenhuma transa\u00E7\u00E3o foi definida. Para utilizar @{0} \u00E9 preciso definir a estrat\u00E9gia de transa\u00E7\u00E3o desejada no arquivo beans.xml
62   -executing-all=Executando todos os \: {0}
63   -custom-context-was-registered=O contexto {0} foi registrado
64   -custom-context-was-unregistered=O contexto {0} foi removido
65   -
66   -error-creating-configuration-from-resource=Error creating configuration from resource named "{0}"
67   -configuration-type-not-implemented-yet=Configuration type "{0}" is not implemented yet
68   -error-converting-to-type=Error converting to type "{0}"
69   -error-creating-new-instance-for=Error creating a new instance for "{0}"
70   -executed-successfully=\ {0} execultado com sucesso
71   -must-declare-one-single-parameter=Voc\u00EA deve declarar um par\u00E2metro \u00FAnico em {0}
72   -loading-default-transaction-manager=Carregando o gerenciador de transa\u00E7\u00E3o padr\u00E3o {0}
73   -transaction-class-not-found=A classe de transa\u00E7\u00E3o "{0}" informada n\u00E3o foi encontrada.
74   -transaction-class-must-be-of-type=A classe de transa\u00E7\u00E3o "{0}" informada deve ser do tipo {1}
75   -results-count-greater-page-size=Quantidade de resultados {0} \u00E9 maior que o tamanho da p\u00E1gina {1}
76   -page-result=Resultado paginado [p\u00E1gina\={0}, total de resultados\={1}]
77   -page=P\u00E1gina [n\u00FAmero\={0}, tamanho\={1}]
78   -processing=Processando\: {0}
79   -processing-fail=Falha no processamento devido a uma exce\u00E7\u00E3o lan\u00E7ada pela aplica\u00E7\u00E3o
80   -for= \ para\:
81   -file-not-found=O arquivo {0} n\u00E3o foi encontrado
82   -
83   -adding-message-to-context=Adicionando uma mensagem no contexto: [{0}]
84   -cleaning-message-context=Limpando o contexto de mensagens
85   -access-checking=Verificando permiss\u00E3o do usu\u00E1rio "{0}" para executar a a\u00E7\u00E3o "{1}" no recurso "{2}"
86   -access-allowed=O usu\u00E1rio "{0}" acessou o recurso "{2}" com a a\u00E7\u00E3o "{1}"
87   -access-denied=O usu\u00E1rio "{0}" n\u00E3o possui permiss\u00E3o para executar a a\u00E7\u00E3o "{1}" no recurso "{2}"
88   -access-denied-ui=Voc\u00EA n\u00E3o est\u00E1 autorizado a executar a a\u00E7\u00E3o {1} no recurso {0}
89   -authorizer-not-defined=Nenhuma regra de resolu\u00E7\u00E3o de permiss\u00F5es foi definida. Para utilizar @{0} \u00E9 preciso definir a estrat\u00E9gia de resolu\u00E7\u00E3o de permiss\u00F5es desejada no arquivo beans.xml
90   -user-not-authenticated=Usu\u00E1rio n\u00E3o autenticado
91   -has-role-verification=Verificando se o usu\u00E1rio {0} possui a(s) role(s)\: {1}
92   -does-not-have-role=Usu\u00E1rio {0} n\u00E3o possui a(s) role(s)\: {1}
93   -does-not-have-role-ui=Para acessar este recurso \u00E9 necess\u00E1rio ser {0}
94   -user-has-role=Usu\u00E1rio {0} possui a(s) role(s)\: {1}
95   -authenticator-not-defined=Nenhum mecanismo de autentica\u00E7\u00E3o foi definido. Para utilizar {0} \u00E9 preciso definir o mecanismo de autentica\u00E7\u00E3o desejado no arquivo beans.xml
96 0 \ No newline at end of file
core/src/test/java/br/gov/frameworkdemoiselle/internal/bootstrap/AbstractBootstrapTest.java
... ... @@ -1,132 +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 br.gov.frameworkdemoiselle.internal.bootstrap;
38   -
39   -import static org.easymock.EasyMock.expect;
40   -import static org.powermock.api.easymock.PowerMock.mockStatic;
41   -import static org.powermock.api.easymock.PowerMock.replayAll;
42   -import static org.powermock.api.easymock.PowerMock.verifyAll;
43   -
44   -import javax.enterprise.inject.spi.AfterBeanDiscovery;
45   -import javax.inject.Scope;
46   -
47   -import org.easymock.EasyMock;
48   -import org.junit.Before;
49   -import org.junit.Test;
50   -import org.junit.runner.RunWith;
51   -import org.powermock.api.easymock.PowerMock;
52   -import org.powermock.core.classloader.annotations.PrepareForTest;
53   -import org.powermock.modules.junit4.PowerMockRunner;
54   -import org.powermock.reflect.Whitebox;
55   -import org.slf4j.Logger;
56   -
57   -import br.gov.frameworkdemoiselle.internal.context.Contexts;
58   -import br.gov.frameworkdemoiselle.internal.context.ThreadLocalContext;
59   -import br.gov.frameworkdemoiselle.internal.producer.LoggerProducer;
60   -import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer;
61   -import br.gov.frameworkdemoiselle.util.ResourceBundle;
62   -
63   -@RunWith(PowerMockRunner.class)
64   -@PrepareForTest({ LoggerProducer.class, Contexts.class })
65   -public class AbstractBootstrapTest {
66   -
67   - private AbstractBootstrap bootstrap;
68   -
69   - @Before
70   - public void setUp() {
71   - bootstrap = new AbstractBootstrap();
72   - }
73   -
74   - @SuppressWarnings("unchecked")
75   - @Test
76   - public void testAddContext() {
77   - mockStatic(LoggerProducer.class);
78   - mockStatic(Contexts.class);
79   -
80   - Logger logger = PowerMock.createMock(Logger.class);
81   - logger.trace(EasyMock.anyObject(String.class));
82   -
83   - expect(LoggerProducer.create(EasyMock.anyObject(Class.class))).andReturn(logger);
84   -
85   - ResourceBundle bundle = PowerMock.createMock(ResourceBundle.class);
86   - expect(bundle.getString(EasyMock.anyObject(String.class), EasyMock.anyObject(String.class))).andReturn(null);
87   -
88   - ResourceBundleProducer bundleFactory = PowerMock.createMock(ResourceBundleProducer.class);
89   - expect(bundleFactory.create(EasyMock.anyObject(String.class))).andReturn(bundle);
90   -
91   - Whitebox.setInternalState(AbstractBootstrap.class, "bundleFactory", bundleFactory);
92   -
93   - ThreadLocalContext context = new ThreadLocalContext(Scope.class);
94   - Contexts.add(EasyMock.anyObject(ThreadLocalContext.class), EasyMock.anyObject(AfterBeanDiscovery.class));
95   - replayAll(bundle, bundleFactory, logger, LoggerProducer.class, Contexts.class);
96   -
97   - bootstrap.addContext(context,null);
98   -
99   - verifyAll();
100   - }
101   -
102   - @SuppressWarnings("unchecked")
103   - @Test
104   - public void testDisableContext() {
105   - AbstractBootstrap bootstrap = new AbstractBootstrap();
106   -
107   - mockStatic(LoggerProducer.class);
108   - mockStatic(Contexts.class);
109   -
110   - Logger logger = PowerMock.createMock(Logger.class);
111   - logger.trace(EasyMock.anyObject(String.class));
112   - expect(LoggerProducer.create(EasyMock.anyObject(Class.class))).andReturn(logger);
113   -
114   - ResourceBundle bundle = PowerMock.createMock(ResourceBundle.class);
115   - expect(bundle.getString(EasyMock.anyObject(String.class), EasyMock.anyObject(String.class))).andReturn(null);
116   -
117   - ResourceBundleProducer bundleFactory = PowerMock.createMock(ResourceBundleProducer.class);
118   - expect(bundleFactory.create(EasyMock.anyObject(String.class))).andReturn(bundle);
119   -
120   - Whitebox.setInternalState(AbstractBootstrap.class, "bundleFactory", bundleFactory);
121   -
122   - ThreadLocalContext context = new ThreadLocalContext(Scope.class);
123   -
124   - Contexts.remove(context);
125   - replayAll(bundle, bundleFactory, logger, LoggerProducer.class, Contexts.class);
126   -
127   - bootstrap.disableContext(context);
128   -
129   - verifyAll();
130   - }
131   -
132   -}
core/src/test/java/br/gov/frameworkdemoiselle/internal/bootstrap/CoreBootstrapTest.java
... ... @@ -1,8 +0,0 @@
1   -package br.gov.frameworkdemoiselle.internal.bootstrap;
2   -
3   -import org.junit.Ignore;
4   -
5   -@Ignore
6   -public class CoreBootstrapTest {
7   -
8   -}
core/src/test/java/br/gov/frameworkdemoiselle/internal/bootstrap/MyStartupAnnotatedClass.java
... ... @@ -1,66 +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 br.gov.frameworkdemoiselle.internal.bootstrap;
38   -
39   -import java.util.Stack;
40   -
41   -import br.gov.frameworkdemoiselle.annotation.Startup;
42   -
43   -public class MyStartupAnnotatedClass {
44   -
45   - public static Stack<String> stackOfMethods = new Stack<String>();
46   -
47   - @Startup(priority=-1)
48   - public void startMethod1(){
49   - addMethodExecuted("startMethod1");
50   - }
51   -
52   - @Startup(priority=1)
53   - public void startMethod2(){
54   - addMethodExecuted("startMethod2");
55   - }
56   -
57   - @Startup(priority=0)
58   - public void startMethod3(){
59   - addMethodExecuted("startMethod3");
60   - }
61   -
62   - private void addMethodExecuted(String name) {
63   - stackOfMethods.push(name);
64   - }
65   -
66   -}
core/src/test/java/br/gov/frameworkdemoiselle/internal/bootstrap/ShutdownBootstrapTest.java
... ... @@ -1,217 +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 br.gov.frameworkdemoiselle.internal.bootstrap;
38   -
39   -import static junit.framework.Assert.assertNull;
40   -import static org.easymock.EasyMock.expect;
41   -import static org.easymock.EasyMock.replay;
42   -import static org.easymock.EasyMock.verify;
43   -import static org.junit.Assert.assertFalse;
44   -import static org.junit.Assert.assertNotNull;
45   -import static org.junit.Assert.assertTrue;
46   -
47   -import java.lang.reflect.Field;
48   -import java.util.ArrayList;
49   -import java.util.HashSet;
50   -import java.util.List;
51   -import java.util.Set;
52   -
53   -import javax.enterprise.inject.spi.AfterBeanDiscovery;
54   -import javax.enterprise.inject.spi.AnnotatedMethod;
55   -import javax.enterprise.inject.spi.AnnotatedType;
56   -import javax.enterprise.inject.spi.BeanManager;
57   -import javax.enterprise.inject.spi.ProcessAnnotatedType;
58   -
59   -import org.easymock.EasyMock;
60   -import org.junit.Before;
61   -import org.junit.Test;
62   -import org.junit.runner.RunWith;
63   -import org.powermock.api.easymock.PowerMock;
64   -import org.powermock.core.classloader.annotations.PrepareForTest;
65   -import org.powermock.modules.junit4.PowerMockRunner;
66   -import org.powermock.reflect.Whitebox;
67   -import org.slf4j.Logger;
68   -
69   -import br.gov.frameworkdemoiselle.annotation.Shutdown;
70   -import br.gov.frameworkdemoiselle.internal.context.Contexts;
71   -import br.gov.frameworkdemoiselle.internal.context.ThreadLocalContext;
72   -import br.gov.frameworkdemoiselle.internal.processor.ShutdownProcessor;
73   -import br.gov.frameworkdemoiselle.internal.producer.LoggerProducer;
74   -import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer;
75   -import br.gov.frameworkdemoiselle.util.ResourceBundle;
76   -
77   -@RunWith(PowerMockRunner.class)
78   -@PrepareForTest({ Contexts.class, LoggerProducer.class, ResourceBundle.class, ResourceBundleProducer.class })
79   -@SuppressWarnings("rawtypes")
80   -public class ShutdownBootstrapTest {
81   -
82   - private ProcessAnnotatedType event;
83   -
84   - private BeanManager beanManager;
85   -
86   - private AnnotatedType annotatedType;
87   -
88   - @Before
89   - public void before() {
90   - event = EasyMock.createMock(ProcessAnnotatedType.class);
91   - annotatedType = EasyMock.createMock(AnnotatedType.class);
92   - beanManager = null;
93   - }
94   -
95   - @SuppressWarnings("unchecked")
96   - private List<ShutdownProcessor> getProcessors(ShutdownBootstrap bootstrap) throws IllegalArgumentException,
97   - IllegalAccessException {
98   - Set<Field> fields = Whitebox.getAllStaticFields(ShutdownBootstrap.class);
99   - List<ShutdownProcessor> list = new ArrayList<ShutdownProcessor>();
100   - for (Field field : fields) {
101   - if (field.getName().equals("processors")) {
102   - list = (List<ShutdownProcessor>) field.get(bootstrap);
103   - }
104   - }
105   - return list;
106   - }
107   -
108   - @SuppressWarnings({ "unchecked" })
109   - @Test
110   - public void processAnnotatedType() throws IllegalArgumentException, IllegalAccessException {
111   - ShutdownBootstrap bootstrap = new ShutdownBootstrap();
112   - List<ShutdownProcessor> list = getProcessors(bootstrap);
113   -
114   - assertTrue(list.isEmpty());
115   -
116   - AnnotatedMethod am1 = PowerMock.createMock(AnnotatedMethod.class);
117   - AnnotatedMethod am2 = PowerMock.createMock(AnnotatedMethod.class);
118   - AnnotatedMethod am3 = PowerMock.createMock(AnnotatedMethod.class);
119   -
120   - Set<AnnotatedMethod> set = new HashSet<AnnotatedMethod>();
121   - set.add(am1);
122   - set.add(am2);
123   - set.add(am3);
124   -
125   - expect(am1.isAnnotationPresent(Shutdown.class)).andReturn(true);
126   - expect(am2.isAnnotationPresent(Shutdown.class)).andReturn(true);
127   - expect(am3.isAnnotationPresent(Shutdown.class)).andReturn(false);
128   - expect(event.getAnnotatedType()).andReturn(annotatedType);
129   - expect(annotatedType.getMethods()).andReturn(set);
130   -
131   - replay(event, annotatedType, am1, am2, am3);
132   - bootstrap.processAnnotatedType(event, beanManager);
133   - verify(event, annotatedType);
134   -
135   - list = getProcessors(bootstrap);
136   - assertNotNull(list);
137   - assertFalse(list.isEmpty());
138   - assertTrue(list.size() == 2);
139   - }
140   -
141   - @SuppressWarnings({ "unchecked" })
142   - @Test
143   - public void testShuttingDown() throws Throwable {
144   - ShutdownBootstrap bootstrap = new ShutdownBootstrap();
145   -
146   - PowerMock.mockStatic(Contexts.class);
147   - PowerMock.mockStatic(LoggerProducer.class);
148   -
149   - Logger logger = PowerMock.createMock(Logger.class);
150   - ResourceBundleProducer bundleFactory = PowerMock.createMock(ResourceBundleProducer.class);
151   - ResourceBundle bundle = PowerMock.createMock(ResourceBundle.class);
152   -
153   - expect(LoggerProducer.create(EasyMock.anyObject(Class.class))).andReturn(logger).anyTimes();
154   - expect(bundleFactory.create(EasyMock.anyObject(String.class))).andReturn(bundle).anyTimes();
155   - expect(bundle.getString(EasyMock.anyObject(String.class), EasyMock.anyObject(String.class))).andReturn("")
156   - .anyTimes();
157   -
158   - logger.debug(EasyMock.anyObject(String.class));
159   - logger.trace(EasyMock.anyObject(String.class));
160   - EasyMock.expectLastCall().anyTimes();
161   -
162   - Whitebox.setInternalState(AbstractBootstrap.class, ResourceBundleProducer.class, bundleFactory);
163   -
164   - List<ShutdownProcessor> list = getProcessors(bootstrap);
165   - list.clear();
166   -
167   - MyShuttingDownProcessor<?> processor = PowerMock.createMock(MyShuttingDownProcessor.class);
168   - list.add(processor);
169   - expect(processor.process()).andReturn(true).times(1);
170   -
171   - Contexts.add(EasyMock.anyObject(ThreadLocalContext.class), EasyMock.anyObject(AfterBeanDiscovery.class));
172   - EasyMock.expectLastCall().anyTimes();
173   -
174   - Contexts.remove(EasyMock.anyObject(ThreadLocalContext.class));
175   - EasyMock.expectLastCall().anyTimes();
176   -
177   - PowerMock.replayAll();
178   - bootstrap.shuttingDown(null);
179   -
180   - assertTrue(list.isEmpty());
181   - PowerMock.verifyAll();
182   - }
183   -
184   - @Test
185   - public void testSaveEvent() throws Throwable {
186   -
187   - ShutdownBootstrap bootstrap = new ShutdownBootstrap();
188   -
189   - AfterBeanDiscovery event = Whitebox.getInternalState(ShutdownBootstrap.class, AfterBeanDiscovery.class);
190   -
191   - assertNull(event);
192   -
193   - AfterBeanDiscovery newEvent = EasyMock.createMock(AfterBeanDiscovery.class);
194   -
195   - EasyMock.replay(newEvent);
196   -
197   - bootstrap.saveEvent(newEvent);
198   -
199   - event = Whitebox.getInternalState(ShutdownBootstrap.class, AfterBeanDiscovery.class);
200   -
201   - assertNotNull(event);
202   - }
203   -}
204   -
205   -@SuppressWarnings("rawtypes")
206   -class MyShuttingDownProcessor<T> extends ShutdownProcessor<T> {
207   -
208   - @SuppressWarnings("unchecked")
209   - public MyShuttingDownProcessor(AnnotatedMethod annotatedMethod, BeanManager beanManager) {
210   - super(annotatedMethod, beanManager);
211   - }
212   -
213   - @Override
214   - public int compareTo(final ShutdownProcessor<T> other) {
215   - return 1;
216   - }
217   -}
core/src/test/java/br/gov/frameworkdemoiselle/internal/bootstrap/StartupBootstrapTest.java
... ... @@ -1,256 +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 br.gov.frameworkdemoiselle.internal.bootstrap;
38   -
39   -import static junit.framework.Assert.assertEquals;
40   -import static org.easymock.EasyMock.expect;
41   -import static org.easymock.EasyMock.replay;
42   -import static org.easymock.EasyMock.verify;
43   -import static org.junit.Assert.assertFalse;
44   -import static org.junit.Assert.assertNotNull;
45   -import static org.junit.Assert.assertTrue;
46   -import static org.junit.Assert.fail;
47   -
48   -import java.lang.reflect.Field;
49   -import java.util.HashSet;
50   -import java.util.List;
51   -import java.util.Set;
52   -
53   -import javax.enterprise.context.ConversationScoped;
54   -import javax.enterprise.context.RequestScoped;
55   -import javax.enterprise.context.SessionScoped;
56   -import javax.enterprise.inject.spi.AfterBeanDiscovery;
57   -import javax.enterprise.inject.spi.AnnotatedMethod;
58   -import javax.enterprise.inject.spi.AnnotatedType;
59   -import javax.enterprise.inject.spi.BeanManager;
60   -import javax.enterprise.inject.spi.ProcessAnnotatedType;
61   -
62   -import junit.framework.Assert;
63   -
64   -import org.easymock.EasyMock;
65   -import org.junit.Before;
66   -import org.junit.Test;
67   -import org.junit.runner.RunWith;
68   -import org.powermock.api.easymock.PowerMock;
69   -import org.powermock.core.classloader.annotations.PrepareForTest;
70   -import org.powermock.modules.junit4.PowerMockRunner;
71   -import org.powermock.reflect.Whitebox;
72   -import org.slf4j.Logger;
73   -
74   -import br.gov.frameworkdemoiselle.annotation.Startup;
75   -import br.gov.frameworkdemoiselle.annotation.ViewScoped;
76   -import br.gov.frameworkdemoiselle.internal.context.Contexts;
77   -import br.gov.frameworkdemoiselle.internal.context.ThreadLocalContext;
78   -import br.gov.frameworkdemoiselle.internal.processor.StartupProcessor;
79   -import br.gov.frameworkdemoiselle.internal.producer.LoggerProducer;
80   -import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer;
81   -import br.gov.frameworkdemoiselle.util.ResourceBundle;
82   -
83   -@RunWith(PowerMockRunner.class)
84   -@PrepareForTest({ Contexts.class, LoggerProducer.class, ResourceBundle.class, ResourceBundleProducer.class })
85   -@SuppressWarnings({ "rawtypes", "unchecked" })
86   -public class StartupBootstrapTest {
87   -
88   - private ProcessAnnotatedType event;
89   -
90   - private BeanManager beanManager;
91   -
92   - private AnnotatedType annotatedType;
93   -
94   - @Before
95   - public void before() {
96   - event = EasyMock.createMock(ProcessAnnotatedType.class);
97   - annotatedType = EasyMock.createMock(AnnotatedType.class);
98   - beanManager = null;
99   - }
100   -
101   - private List<StartupProcessor> getActions(StartupBootstrap bootstrap) throws IllegalArgumentException,
102   - IllegalAccessException {
103   - Set<Field> fields = Whitebox.getAllStaticFields(StartupBootstrap.class);
104   - List<StartupProcessor> list = null;
105   - for (Field field : fields) {
106   - if (field.getName().equals("processors")) {
107   - list = (List<StartupProcessor>) field.get(bootstrap);
108   - }
109   - }
110   - return list;
111   - }
112   -
113   - @Test
114   - public void processAnnotatedType() throws IllegalArgumentException, IllegalAccessException {
115   - StartupBootstrap bootstrap = new StartupBootstrap();
116   - List<StartupProcessor> list = getActions(bootstrap);
117   -
118   - assertNotNull(list);
119   - assertTrue(list.isEmpty());
120   -
121   - AnnotatedMethod am1 = PowerMock.createMock(AnnotatedMethod.class);
122   - AnnotatedMethod am2 = PowerMock.createMock(AnnotatedMethod.class);
123   - AnnotatedMethod am3 = PowerMock.createMock(AnnotatedMethod.class);
124   -
125   - Set<AnnotatedMethod> set = new HashSet<AnnotatedMethod>();
126   - set.add(am1);
127   - set.add(am2);
128   - set.add(am3);
129   -
130   - expect(am1.isAnnotationPresent(Startup.class)).andReturn(true);
131   - expect(am2.isAnnotationPresent(Startup.class)).andReturn(true);
132   - expect(am3.isAnnotationPresent(Startup.class)).andReturn(false);
133   - expect(event.getAnnotatedType()).andReturn(annotatedType);
134   - expect(annotatedType.getMethods()).andReturn(set);
135   -
136   - replay(event, annotatedType, am1, am2, am3);
137   - bootstrap.processAnnotatedType(event, beanManager);
138   - verify(event, annotatedType);
139   -
140   - list = getActions(bootstrap);
141   - assertNotNull(list);
142   - assertFalse(list.isEmpty());
143   - assertTrue(list.size() == 2);
144   - }
145   -
146   - @Test
147   - public void testLoadTempContexts() {
148   - StartupBootstrap bootstrap = new StartupBootstrap();
149   -
150   - Logger logger = PowerMock.createMock(Logger.class);
151   - ResourceBundleProducer bundleFactory = PowerMock.createMock(ResourceBundleProducer.class);
152   - ResourceBundle bundle = PowerMock.createMock(ResourceBundle.class);
153   -
154   - PowerMock.mockStatic(Contexts.class);
155   - PowerMock.mockStatic(LoggerProducer.class);
156   -
157   - List<ThreadLocalContext> tempContexts = Whitebox.getInternalState(bootstrap, "tempContexts");
158   -
159   - assertNotNull(tempContexts);
160   - assertTrue(tempContexts.isEmpty());
161   -
162   - expect(LoggerProducer.create(EasyMock.anyObject(Class.class))).andReturn(logger).anyTimes();
163   - expect(bundleFactory.create(EasyMock.anyObject(String.class))).andReturn(bundle).anyTimes();
164   - expect(bundle.getString(EasyMock.anyObject(String.class), EasyMock.anyObject(String.class))).andReturn("")
165   - .anyTimes();
166   -
167   - logger.trace(EasyMock.anyObject(String.class));
168   - EasyMock.expectLastCall().anyTimes();
169   -
170   - Contexts.add(EasyMock.anyObject(ThreadLocalContext.class), EasyMock.anyObject(AfterBeanDiscovery.class));
171   - EasyMock.expectLastCall().anyTimes();
172   -
173   - Whitebox.setInternalState(AbstractBootstrap.class, ResourceBundleProducer.class, bundleFactory);
174   -
175   - PowerMock.replayAll();
176   - bootstrap.loadTempContexts(null);
177   - PowerMock.verifyAll();
178   -
179   - assertNotNull(tempContexts);
180   - assertEquals(4, tempContexts.size());
181   -
182   - for (ThreadLocalContext tlc : tempContexts) {
183   - if (!tlc.getScope().equals(SessionScoped.class) && !tlc.getScope().equals(ConversationScoped.class)
184   - && !tlc.getScope().equals(RequestScoped.class) && !tlc.getScope().equals(ViewScoped.class)) {
185   - fail();
186   - }
187   - }
188   - }
189   -
190   - @Test
191   - public void testStartup() throws Throwable {
192   - StartupBootstrap bootstrap = new StartupBootstrap();
193   -
194   - PowerMock.mockStatic(Contexts.class);
195   - PowerMock.mockStatic(LoggerProducer.class);
196   -
197   - Logger logger = PowerMock.createMock(Logger.class);
198   - ResourceBundleProducer bundleFactory = PowerMock.createMock(ResourceBundleProducer.class);
199   - ResourceBundle bundle = PowerMock.createMock(ResourceBundle.class);
200   -
201   - expect(LoggerProducer.create(EasyMock.anyObject(Class.class))).andReturn(logger).anyTimes();
202   - expect(bundleFactory.create(EasyMock.anyObject(String.class))).andReturn(bundle).anyTimes();
203   - expect(bundle.getString(EasyMock.anyObject(String.class), EasyMock.anyObject(String.class))).andReturn("")
204   - .anyTimes();
205   -
206   - logger.debug(EasyMock.anyObject(String.class));
207   - EasyMock.expectLastCall().anyTimes();
208   -
209   - Whitebox.setInternalState(AbstractBootstrap.class, ResourceBundleProducer.class, bundleFactory);
210   -
211   - List<StartupProcessor> list = getActions(bootstrap);
212   - list.clear();
213   -
214   - MyProcessor<?> processor = PowerMock.createMock(MyProcessor.class);
215   - list.add(processor);
216   - expect(processor.process()).andReturn(true).times(1);
217   -
218   - PowerMock.replayAll();
219   - bootstrap.startup(null);
220   -
221   - assertTrue(list.isEmpty());
222   - PowerMock.verifyAll();
223   - }
224   -
225   - @Test
226   - public void testLoadTempContextsAndStartup() {
227   -
228   - StartupBootstrap bootstrap = new StartupBootstrap();
229   -
230   - bootstrap.loadTempContexts(null);
231   - Assert.assertFalse(Contexts.getActiveContexts().isEmpty());
232   -
233   - try {
234   - bootstrap.startup(null);
235   - Assert.assertTrue(Contexts.getActiveContexts().isEmpty());
236   - } catch (Throwable e) {
237   - fail();
238   - }
239   -
240   - }
241   -
242   -}
243   -
244   -@SuppressWarnings("rawtypes")
245   -class MyProcessor<T> extends StartupProcessor<T> {
246   -
247   - @SuppressWarnings("unchecked")
248   - public MyProcessor(AnnotatedMethod annotatedMethod, BeanManager beanManager) {
249   - super(annotatedMethod, beanManager);
250   - }
251   -
252   - @Override
253   - public int compareTo(final StartupProcessor<T> other) {
254   - return 1;
255   - }
256   -}
core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/ClassExtendsFromClassThanImplementsTransactionInterface.java
... ... @@ -1,44 +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 br.gov.frameworkdemoiselle.internal.configuration;
38   -
39   -
40   -public class ClassExtendsFromClassThanImplementsTransactionInterface extends ClassImplementsTransactionInterface{
41   -
42   - private static final long serialVersionUID = 1L;
43   -
44   -}
core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/ClassImplementsTransactionInterface.java
... ... @@ -1,80 +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 br.gov.frameworkdemoiselle.internal.configuration;
38   -
39   -import br.gov.frameworkdemoiselle.transaction.Transaction;
40   -
41   -public class ClassImplementsTransactionInterface implements Transaction {
42   -
43   - private static final long serialVersionUID = 1L;
44   -
45   - @Override
46   - public void begin() {
47   - // TODO Auto-generated method stub
48   -
49   - }
50   -
51   - @Override
52   - public void commit() {
53   - // TODO Auto-generated method stub
54   -
55   - }
56   -
57   - @Override
58   - public void rollback() {
59   - // TODO Auto-generated method stub
60   -
61   - }
62   -
63   - @Override
64   - public void setRollbackOnly() {
65   - // TODO Auto-generated method stub
66   -
67   - }
68   -
69   - @Override
70   - public boolean isActive() {
71   - // TODO Auto-generated method stub
72   - return false;
73   - }
74   -
75   - @Override
76   - public boolean isMarkedRollback() {
77   - // TODO Auto-generated method stub
78   - return false;
79   - }
80   -}
core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/ClassThanImplementsInterfaceThanExtendsFromTransactionInterface.java
... ... @@ -1,79 +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 br.gov.frameworkdemoiselle.internal.configuration;
38   -
39   -public class ClassThanImplementsInterfaceThanExtendsFromTransactionInterface implements
40   - InterfaceExtendsFromTransactionInterface {
41   -
42   - private static final long serialVersionUID = 1L;
43   -
44   - @Override
45   - public boolean isActive() {
46   - // TODO Auto-generated method stub
47   - return false;
48   - }
49   -
50   - @Override
51   - public boolean isMarkedRollback() {
52   - // TODO Auto-generated method stub
53   - return false;
54   - }
55   -
56   - @Override
57   - public void begin() {
58   - // TODO Auto-generated method stub
59   -
60   - }
61   -
62   - @Override
63   - public void commit() {
64   - // TODO Auto-generated method stub
65   -
66   - }
67   -
68   - @Override
69   - public void rollback() {
70   - // TODO Auto-generated method stub
71   -
72   - }
73   -
74   - @Override
75   - public void setRollbackOnly() {
76   - // TODO Auto-generated method stub
77   -
78   - }
79   -}
core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/ConfigurationLoaderTest.java
... ... @@ -1,644 +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 br.gov.frameworkdemoiselle.internal.configuration;
38   -
39   -import static org.easymock.EasyMock.expect;
40   -import static org.easymock.EasyMock.replay;
41   -import static org.junit.Assert.assertEquals;
42   -import static org.junit.Assert.assertNull;
43   -import static org.junit.Assert.assertTrue;
44   -import static org.junit.Assert.fail;
45   -import static org.powermock.api.easymock.PowerMock.mockStatic;
46   -import static org.powermock.api.easymock.PowerMock.replayAll;
47   -
48   -import javax.validation.constraints.NotNull;
49   -
50   -import org.easymock.EasyMock;
51   -import org.junit.After;
52   -import org.junit.Before;
53   -import org.junit.Test;
54   -import org.junit.runner.RunWith;
55   -import org.powermock.api.easymock.PowerMock;
56   -import org.powermock.core.classloader.annotations.PrepareForTest;
57   -import org.powermock.modules.junit4.PowerMockRunner;
58   -import org.powermock.reflect.Whitebox;
59   -import org.slf4j.Logger;
60   -
61   -import br.gov.frameworkdemoiselle.annotation.Ignore;
62   -import br.gov.frameworkdemoiselle.annotation.Name;
63   -import br.gov.frameworkdemoiselle.configuration.ConfigType;
64   -import br.gov.frameworkdemoiselle.configuration.Configuration;
65   -import br.gov.frameworkdemoiselle.configuration.ConfigurationException;
66   -import br.gov.frameworkdemoiselle.internal.bootstrap.CoreBootstrap;
67   -import br.gov.frameworkdemoiselle.util.ResourceBundle;
68   -
69   -@RunWith(PowerMockRunner.class)
70   -@PrepareForTest(CoreBootstrap.class)
71   -public class ConfigurationLoaderTest {
72   -
73   - private ConfigurationLoader configurationLoader;
74   -
75   - @Configuration
76   - public class ConfigurationSuccessfulProperties {
77   -
78   - @Name("frameworkdemoiselle.configurationtest.nameConfiguration")
79   - protected String nameConfiguration;
80   -
81   - }
82   -
83   - @Configuration
84   - public class ConfigurationSuccessfulProperties2 {
85   -
86   - @Name("frameworkdemoiselle.configurationtest.name")
87   - protected String name;
88   -
89   - }
90   -
91   - @Configuration(resource = "absentFile")
92   - public class ConfigurationPropertiesWithAbsentFile {
93   -
94   - @Name("frameworkdemoiselle.configurationtest.nameConfiguration")
95   - protected String nameConfiguration;
96   -
97   - }
98   -
99   - @Configuration
100   - public class ConfigurationWithEmptyName {
101   -
102   - @Name("")
103   - protected String nameConfiguration;
104   -
105   - }
106   -
107   - @Configuration
108   - public class ConfigurationWithoutNameAnnotation {
109   -
110   - protected String nameConfiguration;
111   -
112   - }
113   -
114   - @Configuration
115   - public class ConfigurationWithIgnoreAnnotation {
116   -
117   - @Ignore
118   - protected String nameConfiguration;
119   -
120   - }
121   -
122   - @Configuration(prefix = "frameworkdemoiselle.configurationtest")
123   - public class ConfigurationWithPrefix {
124   -
125   - @Name("nameConfiguration")
126   - protected String nameConfiguration;
127   -
128   - }
129   -
130   - @Configuration
131   - public class ConfigurationWithKeyNotFoundInProperties {
132   -
133   - protected Integer notExistKey;
134   - }
135   -
136   - @Configuration
137   - public class ConfigurationWithNotNullFieldButValueIsNull {
138   -
139   - @Name("notexistKey")
140   - @NotNull
141   - protected int nameConfiguration;
142   -
143   - }
144   -
145   - @Configuration
146   - public class ConfigurationWithNotNullFieldAndValueIsNotNull {
147   -
148   - @Name("nameConfiguration")
149   - @NotNull
150   - protected String nameConfiguration;
151   -
152   - }
153   -
154   - @Configuration
155   - public class ConfigurationWithNonPrimitiveFieldValueNull {
156   -
157   - @Name("notexistKey")
158   - protected String nameConfiguration;
159   -
160   - }
161   -
162   - @Configuration
163   - public class ConfigurationWithPrimitiveFieldValueNull {
164   -
165   - @Name("notexistKey")
166   - protected int nameConfiguration = 1;
167   -
168   - }
169   -
170   - @Configuration(type = ConfigType.SYSTEM)
171   - public class ConfigurationWithKeyFromSystem {
172   -
173   - @Name("os.name")
174   - protected String nameConfiguration;
175   -
176   - }
177   -
178   - @Configuration(type = ConfigType.XML)
179   - public class ConfigurationWithKeyFromXML {
180   -
181   - @Name("nameConfiguration")
182   - protected String nameConfiguration;
183   -
184   - }
185   -
186   - @Configuration(type = ConfigType.XML, prefix = "br.gov.frameworkdemoiselle")
187   - public class ConfigurationFromXMLWithPrefix {
188   -
189   - @Name("nameConfiguration")
190   - protected String nameConfiguration;
191   -
192   - }
193   -
194   - @Configuration
195   - public class ConfigurationPropertiesWithTwoAmbiguousKey {
196   -
197   - protected String twoConfiguration;
198   -
199   - }
200   -
201   - @Configuration
202   - public class ConfigurationPropertiesWithThreeAmbiguousKey {
203   -
204   - protected String threeConfiguration;
205   -
206   - }
207   -
208   - @Configuration
209   - public class ConfigurationPropertiesWithFourAmbiguousKey {
210   -
211   - protected String fourConfiguration;
212   -
213   - }
214   -
215   - @Configuration
216   - public class ConfigurationWithConventionUnderline {
217   -
218   - protected String conventionUnderline;
219   -
220   - }
221   -
222   - @Configuration(type = ConfigType.XML)
223   - public class ConfigurationXMLWithConventionUnderline {
224   -
225   - protected String conventionUnderline;
226   -
227   - }
228   -
229   - @Configuration
230   - public class ConfigurationWithConventionDot {
231   -
232   - protected String conventionDot;
233   -
234   - }
235   -
236   - @Configuration(type = ConfigType.XML)
237   - public class ConfigurationXMLWithConventionDot {
238   -
239   - protected String conventionDot;
240   -
241   - }
242   -
243   - @Configuration
244   - public class ConfigurationWithConventionAllUpperCase {
245   -
246   - protected String conventionAllUpperCase;
247   -
248   - }
249   -
250   - @Configuration(type = ConfigType.XML)
251   - public class ConfigurationXMLWithConventionAllUpperCase {
252   -
253   - protected String conventionAllUpperCase;
254   -
255   - }
256   -
257   - @Configuration
258   - public class ConfigurationWithConventionAllLowerCase {
259   -
260   - protected String conventionAllLowerCase;
261   -
262   - }
263   -
264   - @Configuration(type = ConfigType.XML)
265   - public class ConfigurationXMLWithConventionAllLowerCase {
266   -
267   - protected String conventionAllLowerCase;
268   -
269   - }
270   -
271   - @Configuration(prefix = "br.gov.frameworkdemoiselle")
272   - public class ConfigurationPropertiesSuccessWithPrefixNonAmbiguous {
273   -
274   - protected String success;
275   -
276   - }
277   -
278   - @Configuration
279   - public class ConfigurationPropertiesErrorWithComplexObject {
280   -
281   - protected ConfigurationWithConventionAllLowerCase complexObject;
282   - }
283   -
284   - @Before
285   - public void setUp() throws Exception {
286   - Logger logger;
287   - ResourceBundle bundle;
288   - logger = PowerMock.createMock(Logger.class);
289   - bundle = new ResourceBundle(ResourceBundle.getBundle("demoiselle-core-bundle"));
290   - configurationLoader = new ConfigurationLoader();
291   - Whitebox.setInternalState(this.configurationLoader, "bundle", bundle);
292   - Whitebox.setInternalState(this.configurationLoader, "logger", logger);
293   - }
294   -
295   - @After
296   - public void tearDown() throws Exception {
297   - }
298   -
299   - @Test
300   - public void testConfigurationSuccessfulPropertiesPossibleConventions() {
301   - ConfigurationSuccessfulProperties config = new ConfigurationSuccessfulProperties();
302   -
303   - mockStatic(CoreBootstrap.class);
304   - expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true);
305   - PowerMock.replay(CoreBootstrap.class);
306   -
307   - configurationLoader.load(config);
308   - assertEquals("ConfigurationTest", config.nameConfiguration);
309   -
310   - }
311   -
312   - @Test
313   - public void testConfigurationSuccessfulPropertiesNoConventions() {
314   - ConfigurationSuccessfulProperties2 config = new ConfigurationSuccessfulProperties2();
315   -
316   - mockStatic(CoreBootstrap.class);
317   - expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true);
318   - PowerMock.replay(CoreBootstrap.class);
319   -
320   - configurationLoader.load(config);
321   - assertEquals("ConfigurationTest2", config.name);
322   - }
323   -
324   - @Test
325   - public void ConfigurationPropertiesWithAbsentFile() {
326   - ConfigurationPropertiesWithAbsentFile config = new ConfigurationPropertiesWithAbsentFile();
327   -
328   - mockStatic(CoreBootstrap.class);
329   - expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true);
330   - PowerMock.replay(CoreBootstrap.class);
331   -
332   - try {
333   - configurationLoader.load(config);
334   - fail();
335   - } catch (Exception e) {
336   - }
337   - }
338   -
339   - @Test
340   - public void testConfigurationProcessorWithNameEmpty() {
341   - ConfigurationWithEmptyName config = new ConfigurationWithEmptyName();
342   -
343   - mockStatic(CoreBootstrap.class);
344   - expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true);
345   - PowerMock.replay(CoreBootstrap.class);
346   -
347   - try {
348   - configurationLoader.load(config);
349   - fail();
350   - } catch (Exception e) {
351   - }
352   - }
353   -
354   - @Test
355   - public void testConfigurationWithoutNameAnnotation() {
356   - ConfigurationWithoutNameAnnotation config = new ConfigurationWithoutNameAnnotation();
357   -
358   - mockStatic(CoreBootstrap.class);
359   - expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true);
360   - PowerMock.replay(CoreBootstrap.class);
361   -
362   - configurationLoader.load(config);
363   - assertEquals("ConfigurationTest", config.nameConfiguration);
364   - }
365   -
366   - @Test
367   - public void testConfigurationWithIgnoreAnnotation() {
368   - ConfigurationWithIgnoreAnnotation config = new ConfigurationWithIgnoreAnnotation();
369   -
370   - configurationLoader.load(config);
371   - assertNull(config.nameConfiguration);
372   - }
373   -
374   - @Test
375   - public void testConfigurationWithPrefix() {
376   - ConfigurationWithPrefix config = new ConfigurationWithPrefix();
377   -
378   - mockStatic(CoreBootstrap.class);
379   - expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true);
380   - PowerMock.replay(CoreBootstrap.class);
381   -
382   - configurationLoader.load(config);
383   - assertEquals("ConfigurationTest", config.nameConfiguration);
384   - }
385   -
386   - @Test
387   - public void testConfigurationWithKeyNotFoundInProperties() {
388   - ConfigurationWithKeyNotFoundInProperties config = new ConfigurationWithKeyNotFoundInProperties();
389   -
390   - configurationLoader.load(config);
391   - assertNull(config.notExistKey);
392   - }
393   -
394   - @Test
395   - public void testConfigurationWithNotNullFieldButValueIsNull() {
396   - ConfigurationWithNotNullFieldButValueIsNull config = new ConfigurationWithNotNullFieldButValueIsNull();
397   -
398   - mockStatic(CoreBootstrap.class);
399   - expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true);
400   - PowerMock.replay(CoreBootstrap.class);
401   -
402   - try {
403   - configurationLoader.load(config);
404   - fail();
405   - } catch (Exception e) {
406   - assertTrue(true);
407   - }
408   - }
409   -
410   - @Test
411   - public void testConfigurationWithNotNullFieldAndValueIsNotNull() {
412   - ConfigurationWithNotNullFieldAndValueIsNotNull config = new ConfigurationWithNotNullFieldAndValueIsNotNull();
413   -
414   - mockStatic(CoreBootstrap.class);
415   - expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true);
416   - PowerMock.replay(CoreBootstrap.class);
417   -
418   - configurationLoader.load(config);
419   - assertEquals("ConfigurationTest", config.nameConfiguration);
420   - }
421   -
422   - @Test
423   - public void testConfigurationWithNonPrimitiveFieldValueNull() {
424   - ConfigurationWithNonPrimitiveFieldValueNull config = new ConfigurationWithNonPrimitiveFieldValueNull();
425   -
426   - configurationLoader.load(config);
427   - assertNull(config.nameConfiguration);
428   - }
429   -
430   - @Test
431   - public void testConfigurationWithPrimitiveFieldValueNull() {
432   - ConfigurationWithPrimitiveFieldValueNull config = new ConfigurationWithPrimitiveFieldValueNull();
433   -
434   - configurationLoader.load(config);
435   - assertEquals(1, config.nameConfiguration);
436   - }
437   -
438   - @Test
439   - public void testConfigurationWithKeyFromSystem() {
440   - ConfigurationWithKeyFromSystem config = new ConfigurationWithKeyFromSystem();
441   -
442   - mockStatic(CoreBootstrap.class);
443   - expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true);
444   - PowerMock.replay(CoreBootstrap.class);
445   -
446   - configurationLoader.load(config);
447   - assertEquals(System.getProperty("os.name"), config.nameConfiguration);
448   - }
449   -
450   - @Test
451   - public void testConfigurationWithKeyFromXML() {
452   - ConfigurationWithKeyFromXML config = new ConfigurationWithKeyFromXML();
453   -
454   - mockStatic(CoreBootstrap.class);
455   - expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true);
456   - PowerMock.replay(CoreBootstrap.class);
457   -
458   - configurationLoader.load(config);
459   - assertEquals("ConfigurationTest", config.nameConfiguration);
460   - }
461   -
462   - @Test
463   - public void testConfigurationWithTwoAmbiguousKey() {
464   - ConfigurationPropertiesWithTwoAmbiguousKey config = new ConfigurationPropertiesWithTwoAmbiguousKey();
465   -
466   - mockStatic(CoreBootstrap.class);
467   - expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true);
468   - PowerMock.replay(CoreBootstrap.class);
469   -
470   - try {
471   - configurationLoader.load(config);
472   - fail();
473   - } catch (Exception e) {
474   - assertTrue(e instanceof ConfigurationException);
475   - }
476   -
477   - }
478   -
479   - @Test
480   - public void testConfigurationWithThreeAmbiguousKey() {
481   - ConfigurationPropertiesWithThreeAmbiguousKey config = new ConfigurationPropertiesWithThreeAmbiguousKey();
482   -
483   - mockStatic(CoreBootstrap.class);
484   - expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true);
485   - PowerMock.replay(CoreBootstrap.class);
486   -
487   - try {
488   - configurationLoader.load(config);
489   - fail();
490   - } catch (Exception e) {
491   - assertTrue(e instanceof ConfigurationException);
492   - }
493   -
494   - }
495   -
496   - @Test
497   - public void testConfigurationWithFourAmbiguousKey() {
498   - ConfigurationPropertiesWithFourAmbiguousKey config = new ConfigurationPropertiesWithFourAmbiguousKey();
499   -
500   - mockStatic(CoreBootstrap.class);
501   - expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true);
502   - PowerMock.replay(CoreBootstrap.class);
503   -
504   - try {
505   - configurationLoader.load(config);
506   - fail();
507   - } catch (Exception e) {
508   - assertTrue(e instanceof ConfigurationException);
509   - }
510   -
511   - }
512   -
513   - @Test
514   - public void testConfigurationWithPrefixNotAmbiguous() {
515   - ConfigurationPropertiesSuccessWithPrefixNonAmbiguous config = new ConfigurationPropertiesSuccessWithPrefixNonAmbiguous();
516   -
517   - mockStatic(CoreBootstrap.class);
518   - expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true);
519   - PowerMock.replay(CoreBootstrap.class);
520   -
521   - configurationLoader.load(config);
522   - assertEquals("Success", config.success);
523   - }
524   -
525   - @Test
526   - public void testConfigurationWithConventionUnderline() {
527   - ConfigurationWithConventionUnderline config = new ConfigurationWithConventionUnderline();
528   -
529   - mockStatic(CoreBootstrap.class);
530   - expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true);
531   - PowerMock.replay(CoreBootstrap.class);
532   -
533   - configurationLoader.load(config);
534   - assertEquals("Convention Underline", config.conventionUnderline);
535   - }
536   -
537   - @Test
538   - public void testConfigurationWithConventionDot() {
539   - ConfigurationWithConventionDot config = new ConfigurationWithConventionDot();
540   -
541   - mockStatic(CoreBootstrap.class);
542   - expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true);
543   - PowerMock.replay(CoreBootstrap.class);
544   -
545   - configurationLoader.load(config);
546   - assertEquals("Convention Dot", config.conventionDot);
547   - }
548   -
549   - @Test
550   - public void testConfigurationWithConventionAllLowerCase() {
551   - ConfigurationWithConventionAllLowerCase config = new ConfigurationWithConventionAllLowerCase();
552   -
553   - mockStatic(CoreBootstrap.class);
554   - expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true);
555   - PowerMock.replay(CoreBootstrap.class);
556   -
557   - configurationLoader.load(config);
558   - assertEquals("All LowerCase", config.conventionAllLowerCase);
559   - }
560   -
561   - @Test
562   - public void testConfigurationWithConventionAllUpperCase() {
563   - ConfigurationWithConventionAllUpperCase config = new ConfigurationWithConventionAllUpperCase();
564   -
565   - mockStatic(CoreBootstrap.class);
566   - expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true);
567   - PowerMock.replay(CoreBootstrap.class);
568   -
569   - configurationLoader.load(config);
570   - assertEquals("ALL UPPERCASE", config.conventionAllUpperCase);
571   - }
572   -
573   - @Test
574   - public void testConfigurationPropertiesErrorWithComplexObject() {
575   - ConfigurationPropertiesErrorWithComplexObject config = new ConfigurationPropertiesErrorWithComplexObject();
576   -
577   - try {
578   - configurationLoader.load(config);
579   - fail();
580   - } catch (Throwable throwable) {
581   - }
582   - }
583   -
584   - @Test
585   - public void testConfigurationFromXMLWithPrefix() {
586   - ConfigurationFromXMLWithPrefix config = new ConfigurationFromXMLWithPrefix();
587   -
588   - mockStatic(CoreBootstrap.class);
589   - expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true);
590   - PowerMock.replay(CoreBootstrap.class);
591   -
592   - configurationLoader.load(config);
593   - assertEquals("ConfigurationTest", config.nameConfiguration);
594   - }
595   -
596   - @Test
597   - public void testConfigurationXMLWithConventionDot() {
598   - ConfigurationXMLWithConventionDot config = new ConfigurationXMLWithConventionDot();
599   -
600   - mockStatic(CoreBootstrap.class);
601   - expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true);
602   - PowerMock.replay(CoreBootstrap.class);
603   -
604   - configurationLoader.load(config);
605   - assertEquals("convention.dot", config.conventionDot);
606   - }
607   -
608   - @Test
609   - public void testConfigurationXMLWithConventionUnderline() {
610   - ConfigurationXMLWithConventionUnderline config = new ConfigurationXMLWithConventionUnderline();
611   -
612   - mockStatic(CoreBootstrap.class);
613   - expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true);
614   - PowerMock.replay(CoreBootstrap.class);
615   -
616   - configurationLoader.load(config);
617   - assertEquals("Convention_Underline", config.conventionUnderline);
618   - }
619   -
620   - @Test
621   - public void testConfigurationXMLWithConventionAllUpperCase() {
622   - ConfigurationXMLWithConventionAllUpperCase config = new ConfigurationXMLWithConventionAllUpperCase();
623   -
624   - mockStatic(CoreBootstrap.class);
625   - expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true);
626   - PowerMock.replay(CoreBootstrap.class);
627   -
628   - configurationLoader.load(config);
629   - assertEquals("ALL UPPERCASE", config.conventionAllUpperCase);
630   - }
631   -
632   - @Test
633   - public void testConfigurationXMLWithConventionAllLowerCase() {
634   - ConfigurationXMLWithConventionAllLowerCase config = new ConfigurationXMLWithConventionAllLowerCase();
635   -
636   - mockStatic(CoreBootstrap.class);
637   - expect(CoreBootstrap.isAnnotatedType(config.getClass())).andReturn(true);
638   - PowerMock.replay(CoreBootstrap.class);
639   -
640   - configurationLoader.load(config);
641   - assertEquals("All LowerCase", config.conventionAllLowerCase);
642   - }
643   -
644   -}
core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/InterfaceExtendsFromTransactionInterface.java
... ... @@ -1,44 +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 br.gov.frameworkdemoiselle.internal.configuration;
38   -
39   -import br.gov.frameworkdemoiselle.transaction.Transaction;
40   -
41   -
42   -public interface InterfaceExtendsFromTransactionInterface extends Transaction{
43   -
44   -}
core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/PaginationConfigTest.java
... ... @@ -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 br.gov.frameworkdemoiselle.internal.configuration;
38   -
39   -import static org.junit.Assert.assertEquals;
40   -
41   -import org.junit.Before;
42   -import org.junit.Test;
43   -
44   -public class PaginationConfigTest {
45   -
46   - private PaginationConfig config;
47   -
48   - @Before
49   - public void setUp() throws Exception {
50   - this.config = new PaginationConfig();
51   - }
52   -
53   - @Test
54   - public void testGetMaxPageLinks() {
55   - assertEquals(5, config.getMaxPageLinks());
56   - }
57   -
58   - @Test
59   - public void testGetPageSize() {
60   - assertEquals(10, config.getPageSize());
61   - }
62   -
63   -}
core/src/test/java/br/gov/frameworkdemoiselle/internal/configuration/SecurityConfigTest.java
... ... @@ -1,22 +0,0 @@
1   -package br.gov.frameworkdemoiselle.internal.configuration;
2   -
3   -import static org.junit.Assert.assertEquals;
4   -
5   -import org.junit.Before;
6   -import org.junit.Test;
7   -
8   -public class SecurityConfigTest {
9   -
10   - private SecurityConfig config;
11   -
12   - @Before
13   - public void setUp() throws Exception {
14   - this.config = new SecurityConfig();
15   - }
16   -
17   - @Test
18   - public void testIsEnabled() {
19   - assertEquals(true, config.isEnabled());
20   - }
21   -
22   -}
core/src/test/java/br/gov/frameworkdemoiselle/internal/context/ContextStoreTest.java
... ... @@ -1,89 +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 br.gov.frameworkdemoiselle.internal.context;
38   -
39   -import java.util.Map;
40   -import java.util.TreeMap;
41   -
42   -import org.easymock.EasyMock;
43   -import org.junit.Assert;
44   -import org.junit.Before;
45   -import org.junit.Test;
46   -import org.powermock.api.easymock.PowerMock;
47   -import org.powermock.reflect.Whitebox;
48   -
49   -public class ContextStoreTest {
50   -
51   - private ContextStore store;
52   -
53   - private Map<String, Object> map;
54   -
55   - @SuppressWarnings("unchecked")
56   - @Before
57   - public void setUp() {
58   - store = new ContextStore();
59   - map = PowerMock.createMock(Map.class);
60   - Whitebox.setInternalState(store, "map", map);
61   - }
62   -
63   - @Test
64   - public void testContains() {
65   - EasyMock.expect(map.containsKey(EasyMock.anyObject(String.class))).andReturn(true);
66   - EasyMock.replay(map);
67   -
68   - Assert.assertTrue(store.contains(""));
69   - EasyMock.verify(map);
70   - }
71   -
72   - @Test
73   - public void testGet() {
74   - EasyMock.expect(map.get(EasyMock.anyObject(String.class))).andReturn("testing");
75   - EasyMock.replay(map);
76   -
77   - Assert.assertEquals("testing", store.get(""));
78   - EasyMock.verify(map);
79   - }
80   -
81   - @Test
82   - public void testPut() {
83   - Map<String, Object> map = new TreeMap<String, Object>();
84   - Whitebox.setInternalState(store, "map", map);
85   - store.put("testing", map);
86   - Assert.assertTrue(map.containsKey("testing"));
87   - }
88   -
89   -}
core/src/test/java/br/gov/frameworkdemoiselle/internal/context/ContextsTest.java
... ... @@ -1,204 +0,0 @@
1   -/*
2   - * Demoiselle Framework Copyright (C) 2010 SERPRO
3   - * ---------------------------------------------------------------------------- This file is part of Demoiselle
4   - * Framework. Demoiselle Framework is free software; you can redistribute it and/or modify it under the terms of the GNU
5   - * Lesser General Public License version 3 as published by the Free Software Foundation. This program is distributed in
6   - * the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7   - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a
8   - * copy of the GNU Lesser General Public License version 3 along with this program; if not, see
9   - * <http://www.gnu.org/licenses/> or write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
10   - * Boston, MA 02110-1301, USA. ---------------------------------------------------------------------------- Este arquivo
11   - * é parte do Framework Demoiselle. O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou
12   - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação do Software Livre (FSF). Este
13   - * programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA GARANTIA; sem uma garantia implícita de
14   - * ADEQUAÇÃO a qualquer MERCADO ou APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português para
15   - * maiores detalhes. Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título "LICENCA.txt", junto com esse
16   - * programa. Se não, acesse <http://www.gnu.org/licenses/> ou escreva para a Fundação do Software Livre (FSF) Inc., 51
17   - * Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
18   - */
19   -package br.gov.frameworkdemoiselle.internal.context;
20   -
21   -import static org.easymock.EasyMock.createMock;
22   -import static org.easymock.EasyMock.expectLastCall;
23   -import static org.easymock.EasyMock.replay;
24   -import static org.junit.Assert.assertEquals;
25   -import static org.junit.Assert.assertFalse;
26   -import static org.junit.Assert.assertTrue;
27   -
28   -import java.util.ArrayList;
29   -import java.util.List;
30   -
31   -import javax.enterprise.context.ApplicationScoped;
32   -import javax.enterprise.context.RequestScoped;
33   -import javax.enterprise.context.SessionScoped;
34   -import javax.enterprise.inject.spi.AfterBeanDiscovery;
35   -
36   -import org.junit.Assert;
37   -import org.junit.Before;
38   -import org.junit.BeforeClass;
39   -import org.junit.Test;
40   -
41   -import br.gov.frameworkdemoiselle.annotation.ViewScoped;
42   -
43   -public class ContextsTest {
44   -
45   - private AfterBeanDiscovery event;
46   -
47   - @BeforeClass
48   - public static void setUpClass() throws Exception {
49   - // TODO AfterBeanDiscovery event = ??? mock ???
50   - }
51   -
52   - @Before
53   - public void setUp() throws Exception {
54   - Contexts.clear();
55   - }
56   -
57   - @Test
58   - public void testRemovingInexistentContext() {
59   - Contexts.remove(new ThreadLocalContext(SessionScoped.class));
60   - }
61   -
62   - @Test
63   - public void testRemovingLastInactiveContext() {
64   - ThreadLocalContext context1 = new ThreadLocalContext(RequestScoped.class);
65   - ThreadLocalContext context2 = new ThreadLocalContext(RequestScoped.class);
66   - ThreadLocalContext context3 = new ThreadLocalContext(RequestScoped.class);
67   -
68   - Contexts.add(context1, event);
69   - Contexts.add(context2, event);
70   - Contexts.add(context3, event);
71   - Contexts.remove(context3);
72   - assertFalse(Contexts.getInactiveContexts().contains(context3));
73   - }
74   -
75   - @Test
76   - public void testRemovingActiveContextAndActivatingInactiveContext() {
77   - ThreadLocalContext context1 = new ThreadLocalContext(SessionScoped.class);
78   - ThreadLocalContext context2 = new ThreadLocalContext(SessionScoped.class);
79   - ThreadLocalContext context3 = new ThreadLocalContext(SessionScoped.class);
80   -
81   - Contexts.add(context1, event);
82   - Contexts.add(context2, event);
83   - Contexts.add(context3, event);
84   - assertTrue(context1.isActive());
85   - assertFalse(context2.isActive());
86   - assertFalse(context3.isActive());
87   -
88   - Contexts.remove(context1);
89   - assertTrue(context2.isActive());
90   - assertFalse(context3.isActive());
91   -
92   - Contexts.remove(context2);
93   - assertTrue(context3.isActive());
94   - }
95   -
96   - @Test
97   - public void testRemovingActiveContext() {
98   - ThreadLocalContext context = new ThreadLocalContext(SessionScoped.class);
99   -
100   - Contexts.add(context, event);
101   - Contexts.remove(context);
102   - assertEquals(0, Contexts.getActiveContexts().size());
103   - }
104   -
105   - @Test
106   - public void testRemovingInactiveContext() {
107   - ThreadLocalContext context = new ThreadLocalContext(SessionScoped.class);
108   -
109   - Contexts.add(new ThreadLocalContext(SessionScoped.class), event);
110   - Contexts.add(context, event);
111   - Contexts.remove(context);
112   - assertEquals(0, Contexts.getInactiveContexts().size());
113   - }
114   -
115   - @Test
116   - public void testClear() {
117   - List<ThreadLocalContext> list = new ArrayList<ThreadLocalContext>();
118   -
119   - list.add(new ThreadLocalContext(SessionScoped.class));
120   - list.add(new ThreadLocalContext(SessionScoped.class));
121   - list.add(new ThreadLocalContext(ApplicationScoped.class));
122   -
123   - for (ThreadLocalContext context : list) {
124   - Contexts.add(context, event);
125   - }
126   -
127   - Contexts.clear();
128   - assertEquals(0, Contexts.getActiveContexts().size());
129   - assertEquals(0, Contexts.getInactiveContexts().size());
130   -
131   - for (ThreadLocalContext context : list) {
132   - assertFalse(context.isActive());
133   - }
134   - }
135   -
136   - @Test
137   - public void testAdd() {
138   - Contexts.add(new ThreadLocalContext(SessionScoped.class), event);
139   - assertEquals(1, Contexts.getActiveContexts().size());
140   - }
141   -
142   - @Test
143   - public void testAddingRepeatedScopeType() {
144   - Contexts.add(new ThreadLocalContext(SessionScoped.class), event);
145   - assertEquals(1, Contexts.getActiveContexts().size());
146   - assertEquals(0, Contexts.getInactiveContexts().size());
147   -
148   - Contexts.add(new ThreadLocalContext(SessionScoped.class), event);
149   - assertEquals(1, Contexts.getActiveContexts().size());
150   - assertEquals(1, Contexts.getInactiveContexts().size());
151   - }
152   -
153   - @Test
154   - public void testAddingRepeatedScopeInstance() {
155   - ThreadLocalContext context1 = new ThreadLocalContext(SessionScoped.class);
156   - ThreadLocalContext context2 = new ThreadLocalContext(SessionScoped.class);
157   -
158   - Contexts.add(context1, event);
159   - Contexts.add(context2, event);
160   -
161   - assertTrue(context1.isActive());
162   - assertFalse(context2.isActive());
163   -
164   - assertEquals(1, Contexts.getActiveContexts().size());
165   - assertEquals(1, Contexts.getInactiveContexts().size());
166   - }
167   -
168   - @Test
169   - public void testIsActive() {
170   - ThreadLocalContext context = new ThreadLocalContext(SessionScoped.class);
171   -
172   - Contexts.add(context, event);
173   - assertTrue(context.isActive());
174   - }
175   -
176   - @Test
177   - public void testIsInactive() {
178   - ThreadLocalContext context = new ThreadLocalContext(ViewScoped.class);
179   -
180   - Contexts.add(new ThreadLocalContext(ViewScoped.class), event);
181   - Contexts.add(context, event);
182   - assertFalse(context.isActive());
183   - }
184   -
185   - @Test
186   - public void testAddWithEventNotNull() {
187   - event = createMock(AfterBeanDiscovery.class);
188   - ThreadLocalContext context = new ThreadLocalContext(SessionScoped.class);
189   - event.addContext(context);
190   - expectLastCall();
191   - replay(event);
192   -
193   - Contexts.add(context, event);
194   - assertEquals(1, Contexts.getActiveContexts().size());
195   - }
196   -
197   - // Only to get 100% on coverage report
198   - @Test
199   - public void testCreateNew() {
200   - Contexts context = new Contexts();
201   - Assert.assertNotNull(context);
202   - }
203   -
204   -}