Commit 33801f670b87ea06a6f0b37ab13fc3736130b4ee
1 parent
4f73e196
Exists in
master
Limpando a casa...
Showing
5 changed files
with
0 additions
and
417 deletions
Show diff stats
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/processor/AbstractProcessor.java
@@ -1,113 +0,0 @@ | @@ -1,113 +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.util.Locale; | ||
40 | - | ||
41 | -import javax.enterprise.inject.spi.AnnotatedCallable; | ||
42 | -import javax.enterprise.inject.spi.BeanManager; | ||
43 | - | ||
44 | -import org.slf4j.Logger; | ||
45 | - | ||
46 | -import br.gov.frameworkdemoiselle.internal.producer.LoggerProducer; | ||
47 | -import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer; | ||
48 | -import br.gov.frameworkdemoiselle.util.Beans; | ||
49 | -import br.gov.frameworkdemoiselle.util.ResourceBundle; | ||
50 | - | ||
51 | -/** | ||
52 | - * It abstract the integration between Processor and the context; | ||
53 | - * | ||
54 | - * @param <T> | ||
55 | - * the declaring class | ||
56 | - */ | ||
57 | -public abstract class AbstractProcessor<T> implements Processor { | ||
58 | - | ||
59 | - private BeanManager beanManager; | ||
60 | - | ||
61 | - private AnnotatedCallable<T> annotatedCallable; | ||
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<T> annotatedCallable, final BeanManager beanManager) { | ||
72 | - this.annotatedCallable = annotatedCallable; | ||
73 | - this.beanManager = beanManager; | ||
74 | - } | ||
75 | - | ||
76 | - protected AnnotatedCallable<T> 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 T getReferencedBean() { | ||
94 | - Class<T> classType = (Class<T>) getAnnotatedCallable().getJavaMember().getDeclaringClass(); | ||
95 | - return Beans.getReference(classType); | ||
96 | - } | ||
97 | - | ||
98 | - protected ResourceBundle getBundle() { | ||
99 | - return getBundle(BUNDLE_BASE_NAME); | ||
100 | - } | ||
101 | - | ||
102 | - protected ResourceBundle getBundle(String baseName) { | ||
103 | - if (bundle == null) { | ||
104 | - bundle = ResourceBundleProducer.create(baseName, Locale.getDefault()); | ||
105 | - } | ||
106 | - | ||
107 | - return bundle; | ||
108 | - } | ||
109 | - | ||
110 | - protected Logger getLogger() { | ||
111 | - return LoggerProducer.create(this.getClass()); | ||
112 | - } | ||
113 | -} |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/processor/AnnotatedMethodProcessor.java
@@ -1,125 +0,0 @@ | @@ -1,125 +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.annotation.Priority; | ||
45 | -import br.gov.frameworkdemoiselle.exception.ApplicationException; | ||
46 | -import br.gov.frameworkdemoiselle.message.SeverityType; | ||
47 | - | ||
48 | -/** | ||
49 | - * Represents an annotated method to be processed; | ||
50 | - * | ||
51 | - * @param <T> | ||
52 | - * declaring class owner of the method | ||
53 | - */ | ||
54 | -public abstract class AnnotatedMethodProcessor<T> extends AbstractProcessor<T> implements | ||
55 | - Comparable<AnnotatedMethodProcessor<T>> { | ||
56 | - | ||
57 | - public AnnotatedMethodProcessor(final AnnotatedMethod<T> annotatedMethod, final BeanManager beanManager) { | ||
58 | - super(annotatedMethod, beanManager); | ||
59 | - } | ||
60 | - | ||
61 | - public AnnotatedMethod<T> getAnnotatedMethod() { | ||
62 | - return (AnnotatedMethod<T>) getAnnotatedCallable(); | ||
63 | - } | ||
64 | - | ||
65 | - protected Integer getPriority(AnnotatedMethod<T> annotatedMethod) { | ||
66 | - Integer priority = Priority.MIN_PRIORITY; | ||
67 | - | ||
68 | - Priority annotation = annotatedMethod.getAnnotation(Priority.class); | ||
69 | - if (annotation != null) { | ||
70 | - priority = annotation.value(); | ||
71 | - } | ||
72 | - | ||
73 | - return priority; | ||
74 | - } | ||
75 | - | ||
76 | - public int compareTo(final AnnotatedMethodProcessor<T> other) { | ||
77 | - Integer orderThis = getPriority(getAnnotatedMethod()); | ||
78 | - Integer orderOther = getPriority(other.getAnnotatedMethod()); | ||
79 | - | ||
80 | - return orderThis.compareTo(orderOther); | ||
81 | - } | ||
82 | - | ||
83 | - public boolean process(Object... args) throws Throwable { | ||
84 | - getLogger().info(getBundle().getString("processing", getAnnotatedMethod().getJavaMember().toGenericString())); | ||
85 | - | ||
86 | - try { | ||
87 | - getAnnotatedMethod().getJavaMember().invoke(getReferencedBean(), args); | ||
88 | - | ||
89 | - } catch (InvocationTargetException cause) { | ||
90 | - handleException(cause.getCause()); | ||
91 | - } | ||
92 | - | ||
93 | - return true; | ||
94 | - } | ||
95 | - | ||
96 | - private void handleException(Throwable cause) throws Throwable { | ||
97 | - ApplicationException ann = cause.getClass().getAnnotation(ApplicationException.class); | ||
98 | - | ||
99 | - if (ann == null || SeverityType.FATAL == ann.severity()) { | ||
100 | - throw cause; | ||
101 | - | ||
102 | - } else { | ||
103 | - switch (ann.severity()) { | ||
104 | - case INFO: | ||
105 | - getLogger().info(cause.getMessage()); | ||
106 | - break; | ||
107 | - | ||
108 | - case WARN: | ||
109 | - getLogger().warn(cause.getMessage()); | ||
110 | - break; | ||
111 | - | ||
112 | - default: | ||
113 | - getLogger().error(getBundle().getString("processing-fail"), cause); | ||
114 | - break; | ||
115 | - } | ||
116 | - } | ||
117 | - } | ||
118 | - | ||
119 | - @Override | ||
120 | - public String toString() { | ||
121 | - return getBundle().getString("for", getClass().getSimpleName(), | ||
122 | - getAnnotatedMethod().getJavaMember().toGenericString()); | ||
123 | - } | ||
124 | - | ||
125 | -} |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/processor/Processor.java
@@ -1,45 +0,0 @@ | @@ -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 | -} |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/processor/ShutdownProcessor.java
@@ -1,67 +0,0 @@ | @@ -1,67 +0,0 @@ | ||
1 | -/* | ||
2 | - * Demoiselle Framework | ||
3 | - * Copyright (C) 2010 SERPRO | ||
4 | - * ---------------------------------------------------------------------------- | ||
5 | - * This file is part of Demoiselle Framework. | ||
6 | - * | ||
7 | - * Demoiselle Framework is free software; you can redistribute it and/or | ||
8 | - * modify it under the terms of the GNU Lesser General Public License version 3 | ||
9 | - * as published by the Free Software Foundation. | ||
10 | - * | ||
11 | - * This program is distributed in the hope that it will be useful, | ||
12 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | - * GNU General Public License for more details. | ||
15 | - * | ||
16 | - * You should have received a copy of the GNU Lesser General Public License version 3 | ||
17 | - * along with this program; if not, see <http://www.gnu.org/licenses/> | ||
18 | - * or write to the Free Software Foundation, Inc., 51 Franklin Street, | ||
19 | - * Fifth Floor, Boston, MA 02110-1301, USA. | ||
20 | - * ---------------------------------------------------------------------------- | ||
21 | - * Este arquivo é parte do Framework Demoiselle. | ||
22 | - * | ||
23 | - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | ||
24 | - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | ||
25 | - * do Software Livre (FSF). | ||
26 | - * | ||
27 | - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | ||
28 | - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | ||
29 | - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | ||
30 | - * para maiores detalhes. | ||
31 | - * | ||
32 | - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | ||
33 | - * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/> | ||
34 | - * ou escreva para a Fundação do Software Livre (FSF) Inc., | ||
35 | - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | ||
36 | - */ | ||
37 | -package 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.Priority; | ||
43 | -import br.gov.frameworkdemoiselle.annotation.Shutdown; | ||
44 | - | ||
45 | -/** | ||
46 | - * Processor for a {@code Shutdown} annotated method, making it comparable. | ||
47 | - * | ||
48 | - * @param <T> | ||
49 | - */ | ||
50 | -public class ShutdownProcessor<T> extends AnnotatedMethodProcessor<T> { | ||
51 | - | ||
52 | - public ShutdownProcessor(AnnotatedMethod<T> annotatedMethod, BeanManager beanManager) { | ||
53 | - super(annotatedMethod, beanManager); | ||
54 | - } | ||
55 | - | ||
56 | - @SuppressWarnings("deprecation") | ||
57 | - protected Integer getPriority(AnnotatedMethod<T> annotatedMethod) { | ||
58 | - Integer priority = super.getPriority(annotatedMethod); | ||
59 | - | ||
60 | - if (!annotatedMethod.isAnnotationPresent(Priority.class)) { | ||
61 | - Shutdown annotation = annotatedMethod.getAnnotation(Shutdown.class); | ||
62 | - priority = annotation.priority(); | ||
63 | - } | ||
64 | - | ||
65 | - return priority; | ||
66 | - } | ||
67 | -} |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/processor/StartupProcessor.java
@@ -1,67 +0,0 @@ | @@ -1,67 +0,0 @@ | ||
1 | -/* | ||
2 | - * Demoiselle Framework | ||
3 | - * Copyright (C) 2010 SERPRO | ||
4 | - * ---------------------------------------------------------------------------- | ||
5 | - * This file is part of Demoiselle Framework. | ||
6 | - * | ||
7 | - * Demoiselle Framework is free software; you can redistribute it and/or | ||
8 | - * modify it under the terms of the GNU Lesser General Public License version 3 | ||
9 | - * as published by the Free Software Foundation. | ||
10 | - * | ||
11 | - * This program is distributed in the hope that it will be useful, | ||
12 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | - * GNU General Public License for more details. | ||
15 | - * | ||
16 | - * You should have received a copy of the GNU Lesser General Public License version 3 | ||
17 | - * along with this program; if not, see <http://www.gnu.org/licenses/> | ||
18 | - * or write to the Free Software Foundation, Inc., 51 Franklin Street, | ||
19 | - * Fifth Floor, Boston, MA 02110-1301, USA. | ||
20 | - * ---------------------------------------------------------------------------- | ||
21 | - * Este arquivo é parte do Framework Demoiselle. | ||
22 | - * | ||
23 | - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | ||
24 | - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | ||
25 | - * do Software Livre (FSF). | ||
26 | - * | ||
27 | - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | ||
28 | - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | ||
29 | - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | ||
30 | - * para maiores detalhes. | ||
31 | - * | ||
32 | - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | ||
33 | - * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/> | ||
34 | - * ou escreva para a Fundação do Software Livre (FSF) Inc., | ||
35 | - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | ||
36 | - */ | ||
37 | -package 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.Priority; | ||
43 | -import br.gov.frameworkdemoiselle.annotation.Startup; | ||
44 | - | ||
45 | -/** | ||
46 | - * Processor for a {@code @Startup} annotated method, making it comparable. | ||
47 | - * | ||
48 | - * @param <T> | ||
49 | - */ | ||
50 | -public class StartupProcessor<T> extends AnnotatedMethodProcessor<T> { | ||
51 | - | ||
52 | - public StartupProcessor(final AnnotatedMethod<T> annotatedMethod, final BeanManager beanManager) { | ||
53 | - super(annotatedMethod, beanManager); | ||
54 | - } | ||
55 | - | ||
56 | - @SuppressWarnings("deprecation") | ||
57 | - protected Integer getPriority(AnnotatedMethod<T> annotatedMethod) { | ||
58 | - Integer priority = super.getPriority(annotatedMethod); | ||
59 | - | ||
60 | - if (!annotatedMethod.isAnnotationPresent(Priority.class)) { | ||
61 | - Startup annotation = annotatedMethod.getAnnotation(Startup.class); | ||
62 | - priority = annotation.priority(); | ||
63 | - } | ||
64 | - | ||
65 | - return priority; | ||
66 | - } | ||
67 | -} |