Commit 239a83aed7a5a5fb0754efc11db469b01b1f0774

Authored by Ednara Oliveira
2 parents 82767e57 6b429231
Exists in master

Merge branch '2.4.0' of git@github.com:demoiselle/framework.git into 2.4.0

Showing 30 changed files with 486 additions and 272 deletions   Show diff stats
documentation/reference/pom.xml
... ... @@ -45,7 +45,7 @@
45 45 <parent>
46 46 <groupId>br.gov.frameworkdemoiselle</groupId>
47 47 <artifactId>demoiselle-documentation-parent</artifactId>
48   - <version>8</version>
  48 + <version>9-SNAPSHOT</version>
49 49 <relativePath>../../../internal/parent/documentation</relativePath>
50 50 </parent>
51 51  
... ...
documentation/reference/pt-BR/gerenciamento.xml
1 1 <?xml version='1.0' encoding="utf-8"?>
2 2 <!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" []>
4   -<chapter id="mensagem">
  4 +<chapter id="gerenciamento">
5 5  
6 6 <title>Monitoração e Gerenciamento de Recursos</title>
7 7  
... ... @@ -32,31 +32,179 @@
32 32 anotada com o estereótipo <code>@ManagementController</code>.</para>
33 33  
34 34 <programlisting role="JAVA"><![CDATA[
35   - @ManagementController
36   - public class GerenciadorUsuarios]]></programlisting>
  35 +@ManagementController
  36 +public class GerenciadorUsuarios]]></programlisting>
37 37  
38 38 <para>Essa anotação é suficiente para o mecanismo de gerenciamento descobrir sua classe e disponibiliza-la para ser monitorada e gerenciada.</para>
39 39  
40 40 <para>Contudo, a simples anotação acima não informa ao mecanismo quais aspectos da classe serão expostos. Por padrão, um <emphasis>Management Controller</emphasis>
41   - não expõe nenhum aspecto seu. Para selecionais quais aspectos serão expostos usamos as anotações <code>@ManagedProperty</code> e <code>@ManagedOperation</code>.</para>
42   -
43   - <table>
44   - <tbody>
45   - <row>
46   - <entry>
47   - <emphasis role="BOLD">@ManagedProperty</emphasis>
48   - </entry>
49   - </row>
50   -
51   - <row>
52   - <entry>
53   - <para>Marca um atributo na classe como uma propriedade gerenciada, significando que clientes externos podem ler e/ou escrever valores nesses atributos.</para>
54   - <para>Um</para>
55   - </entry>
56   - </row>
57   - </tbody>
58   - </table>
  41 + não expõe nenhum aspecto seu. Para selecionar quais aspectos serão expostos usamos as anotações
  42 + <emphasis>@ManagedProperty</emphasis> e <emphasis>@ManagedOperation</emphasis>. Além disso outras anotações podem ser usadas para personalizar o funcionamento
  43 + de classes anotadas com <code>@ManagementController</code>.</para>
59 44  
  45 + <informaltable>
  46 + <tgroup cols="3">
  47 + <thead>
  48 + <row>
  49 + <entry>Anotação</entry>
  50 + <entry>Descrição</entry>
  51 + <entry>Atributos</entry>
  52 + </row>
  53 + </thead>
  54 +
  55 + <tbody>
  56 + <row>
  57 + <entry>
  58 + <emphasis role="BOLD">@ManagedProperty</emphasis>
  59 + </entry>
  60 +
  61 + <entry>
  62 + <para>Marca um atributo na classe como uma propriedade gerenciada, significando que clientes externos podem ler e/ou escrever valores nesses atributos.</para>
  63 + <para>Um atributo marcado pode estar disponível para leitura e/ou escrita. Por padrão, o que determina a visibilidade de um atributo
  64 + marcado é a presença dos métodos <emphasis>getAtributo</emphasis> e <emphasis>setAtributo</emphasis>, respectivamente disponibilizando o atributo
  65 + para leitura e escrita.</para>
  66 + <para>Para sobrescrever esse comportamento existe na anotação <emphasis role="BOLD">@ManagedProperty</emphasis> o atributo <emphasis>accessLevel</emphasis>.
  67 + Com ele é possível criar um atributo apenas para leitura, mas que contenha um método <emphasis>set</emphasis>. O contrário também é possível.</para>
  68 + </entry>
  69 +
  70 + <entry>
  71 + <itemizedlist>
  72 + <listitem><emphasis role="BOLD">description</emphasis>: Um texto descritivo documentando o propósito da propriedade.</listitem>
  73 + <listitem><emphasis role="BOLD">accessLevel</emphasis>: Sobrescreve o nível padrão de acesso de uma propriedade. Os valores possíveis são
  74 + READ_ONLY, WRITE_ONLY e DEFAULT, que significa que a presença de métodos <emphasis>get</emphasis> e <emphasis>set</emphasis> vai determinar o nível de acesso.</listitem>
  75 + </itemizedlist>
  76 + </entry>
  77 + </row>
  78 +
  79 + <row>
  80 + <entry>
  81 + <emphasis role="BOLD">@ManagedOperation</emphasis>
  82 + </entry>
  83 +
  84 + <entry>
  85 + <para>Marca um método da classe gerenciada como uma operação, o que significa que clientes externos podem invocar esse método remotamente.</para>
  86 + <para>Operações gerenciadas normalmente são criadas para executar intervenções em um sistema já em execução. Por exemplo, é possível criar uma
  87 + operação que, ao ser invocada, destrua todas as seções abertas no servidor e não utilizadas nos últimos 30 minutos.</para>
  88 + </entry>
  89 +
  90 + <entry>
  91 + <itemizedlist>
  92 + <listitem><emphasis role="BOLD">description</emphasis>: Um texto descritivo documentando o propósito da operação.</listitem>
  93 + <listitem><emphasis role="BOLD">type</emphasis>: Documenta o propósito da operação. <emphasis>ACTION</emphasis> informa que a operação modificará
  94 + o sistema de alguma forma. <emphasis>INFO</emphasis> diz que a operação coletará e retornará informações sobre o sistema. <emphasis>ACTION_INFO</emphasis>
  95 + informa que a operação modificará o sistema de alguma forma e retornará informações sobre o resultado. <emphasis>UNKNOWN</emphasis> é o padrão
  96 + e significa que o resultado da execução da operação é desconhecido.</listitem>
  97 + </itemizedlist>
  98 + </entry>
  99 + </row>
  100 +
  101 + <row>
  102 + <entry>
  103 + <emphasis role="BOLD">@OperationParameter</emphasis>
  104 + </entry>
  105 +
  106 + <entry>
  107 + <para>Esta anotação opcional pode ser usada para cada parâmetro de um método anotado com <emphasis role="BOLD">@ManagedOperation</emphasis>.</para>
  108 +
  109 + <para>Ele permite detalhar melhor parâmetros em uma operação gerenciada. O efeito desta anotação é dependente da
  110 + tecnologia utilizada para comunicação entre cliente e servidor. Na maioria das tecnologias, essa anotação meramente permite ao cliente
  111 + exibir informações sobre cada parâmetro: nome, tipo e descrição.</para>
  112 + </entry>
  113 +
  114 + <entry>
  115 + <itemizedlist>
  116 + <listitem><emphasis role="BOLD">name</emphasis>: O nome do parâmetro quando exibido para clientes.</listitem>
  117 + <listitem><emphasis role="BOLD">description</emphasis>: Um texto descritivo documentando o propósito do parâmetro.</listitem>
  118 + </itemizedlist>
  119 + </entry>
  120 + </row>
  121 + </tbody>
  122 + </tgroup>
  123 + </informaltable>
  124 +
  125 + </section>
  126 +
  127 +
  128 +
  129 + <section>
  130 + <title>Expondo aspectos de sua aplicação para monitoração</title>
  131 +
  132 + <para>Uma vez que uma classe esteja anotada com <emphasis>@ManagementController</emphasis> e seus atributos e operações estejam expostos, a classe está pronta para
  133 + ser monitorada.</para>
  134 +
  135 + <para>Suponha que a aplicação deseje expor o número de usuários que efetuaram login. A operação de <emphasis>login</emphasis> será processada em
  136 + uma classe de negócio <emphasis>ControleAcesso</emphasis>. Vamos supor também que existe uma classe chamada <emphasis>MonitorLogin</emphasis> responsável
  137 + por expor o número de usuários que efetuaram login no sistema.</para>
  138 +
  139 + <programlisting role="JAVA"><![CDATA[
  140 +@BusinessController
  141 +public class ControleAcesso{
  142 +
  143 + @Inject
  144 + private MonitorLogin monitorLogin;
  145 +
  146 + public boolean efetuarLogin(String usuario , String senha){
  147 + // código de login
  148 + monitorLogin.setContadorLogin( monitorLogin.getContadorLogin() + 1 );
  149 + }
  150 +}]]></programlisting>
  151 +
  152 + <para>Como é possível ver, classes anotadas com <emphasis>@ManagementController</emphasis> podem ser injetadas em qualquer ponto do código. Valores definidos
  153 + para seus atributos retêm seu estado, então um cliente que acesse remotamente o sistema e monitore o valor do atributo <emphasis>contadorLogin</emphasis> verá
  154 + a quantidade de logins efetuados no momento da consulta.</para>
60 155 </section>
  156 +
  157 + <section>
  158 + <title>Conectando um cliente de monitoração</title>
  159 +
  160 + <para>O <emphasis>demoiselle-core</emphasis> contém as funcionalidades necessárias para marcar aspectos monitoráveis de sua aplicação,
  161 + mas não conta com nenhum mecanismo para estabelecer uma conexão com um cliente de monitoração. Para isso utiliza-se extensões do framework.</para>
  162 +
  163 + <para>A extensão padrão do framework <emphasis>Demoiselle</emphasis> responsável pela tecnologia de monitoração é a <emphasis>demoiselle-jmx</emphasis>.
  164 + Essa extensão utiliza a especificação JMX (JSR 3) e permite registrar as classes marcadas para monitoração como <emphasis>MBeans</emphasis>.
  165 + Uma vez que as classes sejam registradas como <emphasis>MBeans</emphasis>, seus atributos e operações expostos para monitoração podem ser
  166 + acessados via JMX por um cliente adequado, como o <emphasis>JConsole</emphasis> que acompanha por padrão o JDK da Oracle.</para>
  167 +
  168 + <tip>
  169 + <para>Para acrescentar a extensão <emphasis>demoiselle-jmx</emphasis> em um projeto Maven, adicione a dependência abaixo no arquivo <emphasis>pom.xml</emphasis>.</para>
  170 +
  171 + <programlisting role="XML"><![CDATA[
  172 +<dependency>
  173 + <groupId>br.gov.frameworkdemoiselle</groupId>
  174 + <artifactId>demoiselle-jmx</artifactId>
  175 + <scope>compile</scope>
  176 +</dependency>]]></programlisting>
  177 + </tip>
  178 +
  179 + <tip>
  180 + <para>A API de monitoração é compatível com o uso de múltiplas extensões simultãneas. Adicione em seu projeto a dependência às extensões desejadas e configure-as
  181 + individualmente, as classes monitoradas serão então expostas para todas as extensões escolhidas.</para>
  182 + </tip>
  183 +
  184 + <para>A figura <xref linkend="exemplo_jconsole"/> mostra como uma classe monitorada na aplicação <emphasis>Bookmark</emphasis> é exibida no <emphasis>JConsole</emphasis>.</para>
  185 +
  186 + <programlisting role="JAVA"><![CDATA[
  187 +@ManagementController
  188 +public class BookmarkMonitor {
  189 +
  190 + @Inject
  191 + private BookmarkDAO bookmarkDAO;
  192 +
  193 + @ManagedOperation(type=OperationType.INFO , description="Informa quantos bookmarks estão salvos no sistema")
  194 + public int countSavedBookmarks(){
  195 + return bookmarkDAO.findAll().size();
  196 + }
  197 +}]]></programlisting>
  198 +
  199 + <figure id="exemplo_jconsole"><title>JConsole acessando a aplicação <emphasis>Bookmark</emphasis></title>
  200 + <mediaobject>
  201 + <imageobject>
  202 + <imagedata fileref="images/jmx-jconsole-example.png" width="90%" />
  203 + </imageobject>
  204 + <textobject><phrase>JConsole acessando a aplicação <emphasis>Bookmark</emphasis></phrase></textobject>
  205 + </mediaobject>
  206 + </figure>
  207 + </section>
  208 +
61 209  
62 210 </chapter>
63 211 \ No newline at end of file
... ...
documentation/reference/pt-BR/images/jmx-jconsole-example.png 0 → 100644

290 KB

documentation/reference/pt-BR/master.xml
... ... @@ -39,6 +39,7 @@
39 39 <xi:include href="templates.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
40 40 <xi:include href="security.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
41 41 <xi:include href="paginacao.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
  42 + <xi:include href="gerenciamento.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
42 43 <xi:include href="properties.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
43 44  
44 45 <!-- parte 1 -->
... ...
documentation/reference/pt-BR/security.xml
... ... @@ -214,8 +214,13 @@ public class Credential {
214 214 frameworkdemoiselle.security.authorizer.class=projeto.MeuAuthorizer
215 215 </programlisting> -->
216 216 <para>
217   - Pronto! Sua aplicação já possui uma implementação de segurança definida. Caso sua ela não implemente essas interfaces, no momento em que
218   - forem chamadas, o framework lançará uma exceção informando que a aplicação precisa implementá-las.
  217 + Pronto! Sua aplicação já possui uma implementação de segurança definida.
  218 + </para>
  219 +
  220 + <para>
  221 + Caso sua aplicação detecte o uso das anotações @RequiredRole e @RequiredPermission mas nenhuma classe
  222 + implemente essas interfaces, no momento em que os recursos anotados forem acessados, o framework lançará uma exceção informando que a
  223 + aplicação precisa implementá-las.
219 224 </para>
220 225 <para>
221 226 Se você tem mais de uma implementação de <literal>Authenticator</literal> e/ou <literal>Authorizer</literal> (o que pode acontecer, por exemplo, quando
... ...
impl/core/src/main/java/br/gov/frameworkdemoiselle/annotation/OperationType.java
... ... @@ -36,7 +36,6 @@
36 36 */
37 37 package br.gov.frameworkdemoiselle.annotation;
38 38  
39   -import javax.management.MBeanOperationInfo;
40 39  
41 40 /**
42 41 * <p>
... ... @@ -56,32 +55,24 @@ public enum OperationType {
56 55 * ManagedOperation is write-only, it causes the application to change some of it's behaviour but doesn't return any
57 56 * kind of information
58 57 */
59   - ACTION(MBeanOperationInfo.ACTION),
  58 + ACTION,
  59 +
60 60 /**
61 61 * ManagedOperation is read-only, it will operate over data provided by the application and return some information,
62 62 * but will not change the application in any way.
63 63 */
64   - INFO(MBeanOperationInfo.INFO),
  64 + INFO,
  65 +
65 66 /**
66 67 * ManagedOperation is read-write, it will both change the way the application work and return some information
67 68 * regarding the result of the operation.
68 69 */
69   - ACTION_INFO(MBeanOperationInfo.ACTION_INFO),
  70 + ACTION_INFO,
  71 +
70 72 /**
71 73 * The effect of calling this operation is unknown. This is the default type and if this type is assigned to an
72 74 * operation, the user must rely on the {@link ManagedOperation#description()} attribute to learn about how the
73 75 * operation works.
74 76 */
75   - UNKNOWN(MBeanOperationInfo.UNKNOWN);
76   -
77   - private int operationTypeValue;
78   -
79   - private OperationType(int type) {
80   - this.operationTypeValue = type;
81   - }
82   -
83   - public int getValue() {
84   - return operationTypeValue;
85   - }
86   -
  77 + UNKNOWN
87 78 }
... ...
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/ManagementBootstrap.java
... ... @@ -13,7 +13,6 @@ import javax.enterprise.inject.spi.AfterDeploymentValidation;
13 13 import javax.enterprise.inject.spi.AnnotatedType;
14 14 import javax.enterprise.inject.spi.Bean;
15 15 import javax.enterprise.inject.spi.BeanManager;
16   -import javax.enterprise.inject.spi.BeforeShutdown;
17 16 import javax.enterprise.inject.spi.Extension;
18 17 import javax.enterprise.inject.spi.ProcessAnnotatedType;
19 18  
... ... @@ -23,6 +22,7 @@ import br.gov.frameworkdemoiselle.internal.context.ManagedContext;
23 22 import br.gov.frameworkdemoiselle.internal.management.ManagedType;
24 23 import br.gov.frameworkdemoiselle.internal.management.Management;
25 24 import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer;
  25 +import br.gov.frameworkdemoiselle.lifecycle.AfterShutdownProccess;
26 26 import br.gov.frameworkdemoiselle.lifecycle.ManagementExtension;
27 27 import br.gov.frameworkdemoiselle.stereotype.ManagementController;
28 28 import br.gov.frameworkdemoiselle.util.Beans;
... ... @@ -72,7 +72,7 @@ public class ManagementBootstrap implements Extension {
72 72 monitoringManager.initialize(managementExtensionCache);
73 73 }
74 74  
75   - public void unregisterAvailableManagedTypes(@Observes final BeforeShutdown event) {
  75 + public void unregisterAvailableManagedTypes(@Observes final AfterShutdownProccess event) {
76 76  
77 77 Management manager = Beans.getReference(Management.class);
78 78 manager.shutdown(managementExtensionCache);
... ...
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/context/AbstractCustomContext.java
... ... @@ -65,7 +65,6 @@ public abstract class AbstractCustomContext implements CustomContext {
65 65 }
66 66  
67 67 @Override
68   - @SuppressWarnings("unchecked")
69 68 public <T> T get(final Contextual<T> contextual, final CreationalContext<T> creationalContext) {
70 69 T instance = null;
71 70  
... ...
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/NotificationManagerImpl.java 0 → 100644
... ... @@ -0,0 +1,64 @@
  1 +package br.gov.frameworkdemoiselle.internal.implementation;
  2 +
  3 +import java.io.Serializable;
  4 +
  5 +import javax.enterprise.event.Event;
  6 +import javax.enterprise.util.AnnotationLiteral;
  7 +import javax.inject.Inject;
  8 +
  9 +import br.gov.frameworkdemoiselle.internal.management.ManagementNotificationEventImpl;
  10 +import br.gov.frameworkdemoiselle.internal.management.qualifier.AttributeChange;
  11 +import br.gov.frameworkdemoiselle.internal.management.qualifier.Generic;
  12 +import br.gov.frameworkdemoiselle.management.AttributeChangeNotification;
  13 +import br.gov.frameworkdemoiselle.management.ManagementNotificationEvent;
  14 +import br.gov.frameworkdemoiselle.management.GenericNotification;
  15 +import br.gov.frameworkdemoiselle.management.NotificationManager;
  16 +import br.gov.frameworkdemoiselle.util.Beans;
  17 +
  18 +
  19 +@SuppressWarnings("serial")
  20 +public class NotificationManagerImpl implements NotificationManager,Serializable {
  21 +
  22 + @Inject
  23 + @Generic
  24 + private Event<ManagementNotificationEvent> genericNotificationEvent;
  25 +
  26 + @Inject
  27 + @AttributeChange
  28 + private Event<ManagementNotificationEvent> attributeChangeNotificationEvent;
  29 +
  30 + /**
  31 + * Sends a generic notification to all management clients.
  32 + *
  33 + * @param notification The notification to send
  34 + */
  35 + public void sendNotification(GenericNotification notification) {
  36 + if (! AttributeChangeNotification.class.isInstance(notification) ){
  37 + getGenericNotificationEvent().fire(new ManagementNotificationEventImpl(notification));
  38 + }
  39 + else{
  40 + getAttributeChangeNotificationEvent().fire(new ManagementNotificationEventImpl(notification));
  41 + }
  42 + }
  43 +
  44 + @SuppressWarnings("unchecked")
  45 + private Event<ManagementNotificationEvent> getGenericNotificationEvent() {
  46 + if (genericNotificationEvent==null){
  47 + genericNotificationEvent = Beans.getReference(Event.class , new AnnotationLiteral<Generic>() {});
  48 + }
  49 +
  50 + return genericNotificationEvent;
  51 + }
  52 +
  53 + @SuppressWarnings("unchecked")
  54 + private Event<ManagementNotificationEvent> getAttributeChangeNotificationEvent() {
  55 + if (attributeChangeNotificationEvent==null){
  56 + attributeChangeNotificationEvent = Beans.getReference(Event.class , new AnnotationLiteral<AttributeChange>() {});
  57 + }
  58 +
  59 + return attributeChangeNotificationEvent;
  60 + }
  61 +
  62 +
  63 +
  64 +}
... ...
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/management/ManagedType.java
... ... @@ -47,6 +47,7 @@ import javax.inject.Qualifier;
47 47 import br.gov.frameworkdemoiselle.DemoiselleException;
48 48 import br.gov.frameworkdemoiselle.annotation.ManagedOperation;
49 49 import br.gov.frameworkdemoiselle.annotation.ManagedProperty;
  50 +import br.gov.frameworkdemoiselle.annotation.OperationType;
50 51 import br.gov.frameworkdemoiselle.annotation.ManagedProperty.ManagedPropertyAccess;
51 52 import br.gov.frameworkdemoiselle.annotation.OperationParameter;
52 53 import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer;
... ... @@ -163,6 +164,7 @@ public class ManagedType {
163 164 Class<?>[] parameterTypes = method.getParameterTypes();
164 165 Annotation[][] parameterAnnotations = method.getParameterAnnotations();
165 166 ParameterDetail[] parameterDetails = new ParameterDetail[parameterTypes.length];
  167 + OperationType operationType = opAnnotation.type();
166 168  
167 169 for (int i = 0; i < parameterTypes.length; i++) {
168 170 OperationParameter paramAnnotation = null;
... ... @@ -181,7 +183,7 @@ public class ManagedType {
181 183  
182 184 // Com todas as informações, criamos nossa instância de MethodDetail e
183 185 // acrescentamos na lista de todas as operações.
184   - MethodDetail detail = new MethodDetail(method, opAnnotation.description(), parameterDetails);
  186 + MethodDetail detail = new MethodDetail(method, opAnnotation.description(), operationType, parameterDetails);
185 187 operationMethods.put(method.getName(), detail);
186 188 }
187 189 }
... ... @@ -326,12 +328,15 @@ public class ManagedType {
326 328  
327 329 private final ParameterDetail[] parameterTypers;
328 330  
329   - private String description;
  331 + private final String description;
  332 +
  333 + private final OperationType type;
330 334  
331   - public MethodDetail(Method method, String description, ParameterDetail[] parameterTypers) {
  335 + public MethodDetail(Method method, String description, OperationType type,ParameterDetail[] parameterTypers) {
332 336 super();
333 337 this.method = method;
334 338 this.description = description;
  339 + this.type = type;
335 340 this.parameterTypers = parameterTypers;
336 341 }
337 342  
... ... @@ -347,6 +352,10 @@ public class ManagedType {
347 352 return description;
348 353 }
349 354  
  355 + public OperationType getType() {
  356 + return type;
  357 + }
  358 +
350 359 }
351 360  
352 361 public final class ParameterDetail {
... ...
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/management/ManagementNotificationEvent.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.internal.management;
38   -
39   -import br.gov.frameworkdemoiselle.management.Notification;
40   -import br.gov.frameworkdemoiselle.management.NotificationManager;
41   -
42   -/**
43   - * Event fired when a notification is sent by {@link NotificationManager}.
44   - * Implementators can capture this event and be notified when the {@link NotificationManager}
45   - * sends notifications, so they can pass the notification to the underlying technology.
46   - *
47   - * @author serpro
48   - *
49   - */
50   -public class ManagementNotificationEvent {
51   -
52   - private Notification notification;
53   -
54   - public ManagementNotificationEvent(Notification notification){
55   - this.notification = notification;
56   - }
57   -
58   - public Notification getNotification() {
59   - return notification;
60   - }
61   -
62   - public void setNotification(Notification notification) {
63   - this.notification = notification;
64   - }
65   -}
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/management/ManagementNotificationEventImpl.java 0 → 100644
... ... @@ -0,0 +1,65 @@
  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.management;
  38 +
  39 +import br.gov.frameworkdemoiselle.management.GenericNotification;
  40 +import br.gov.frameworkdemoiselle.management.NotificationManager;
  41 +
  42 +/**
  43 + * Event fired when a notification is sent by {@link NotificationManager}.
  44 + * Implementators can capture this event and be notified when the {@link NotificationManager}
  45 + * sends notifications, so they can pass the notification to the underlying technology.
  46 + *
  47 + * @author serpro
  48 + *
  49 + */
  50 +public class ManagementNotificationEventImpl implements br.gov.frameworkdemoiselle.management.ManagementNotificationEvent {
  51 +
  52 + private GenericNotification notification;
  53 +
  54 + public ManagementNotificationEventImpl(GenericNotification notification){
  55 + this.notification = notification;
  56 + }
  57 +
  58 + public GenericNotification getNotification() {
  59 + return notification;
  60 + }
  61 +
  62 + public void setNotification(GenericNotification notification) {
  63 + this.notification = notification;
  64 + }
  65 +}
... ...
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/management/qualifier/AttributeChange.java
... ... @@ -43,8 +43,8 @@ import java.lang.annotation.Target;
43 43  
44 44 import javax.inject.Qualifier;
45 45  
46   -import br.gov.frameworkdemoiselle.internal.management.ManagementNotificationEvent;
47 46 import br.gov.frameworkdemoiselle.management.AttributeChangeNotification;
  47 +import br.gov.frameworkdemoiselle.management.ManagementNotificationEvent;
48 48  
49 49 /**
50 50 *
... ...
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/management/qualifier/Generic.java
... ... @@ -43,13 +43,13 @@ import java.lang.annotation.Target;
43 43  
44 44 import javax.inject.Qualifier;
45 45  
46   -import br.gov.frameworkdemoiselle.internal.management.ManagementNotificationEvent;
47   -import br.gov.frameworkdemoiselle.management.Notification;
  46 +import br.gov.frameworkdemoiselle.management.ManagementNotificationEvent;
  47 +import br.gov.frameworkdemoiselle.management.GenericNotification;
48 48  
49 49 /**
50 50 *
51 51 * Enables {@link ManagementNotificationEvent} observers to trigger only with notifications
52   - * of the base type {@link Notification}.
  52 + * of the base type {@link GenericNotification}.
53 53 *
54 54 * @author serpro
55 55 *
... ...
impl/core/src/main/java/br/gov/frameworkdemoiselle/management/AttributeChangeNotification.java
... ... @@ -39,12 +39,12 @@ package br.gov.frameworkdemoiselle.management;
39 39 /**
40 40 * Special notification to denote an attribute has changed values.
41 41 *
42   - * @see Notification
  42 + * @see GenericNotification
43 43 *
44 44 * @author serpro
45 45 *
46 46 */
47   -public class AttributeChangeNotification extends Notification {
  47 +public class AttributeChangeNotification extends GenericNotification {
48 48  
49 49 private String attributeName;
50 50  
... ...
impl/core/src/main/java/br/gov/frameworkdemoiselle/management/GenericNotification.java 0 → 100644
... ... @@ -0,0 +1,77 @@
  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.management;
  38 +
  39 +/**
  40 + *
  41 + * Notification that can be sent by the {@link NotificationManager}.
  42 + *
  43 + * @author serpro
  44 + *
  45 + */
  46 +public class GenericNotification {
  47 +
  48 + private Object message;
  49 +
  50 + public GenericNotification(){
  51 + }
  52 +
  53 + public GenericNotification(Object message) {
  54 + super();
  55 + this.message = message;
  56 + }
  57 +
  58 +
  59 + public Object getMessage() {
  60 + return message;
  61 + }
  62 +
  63 +
  64 + public void setMessage(Object message) {
  65 + this.message = message;
  66 + }
  67 +
  68 +
  69 + public Class<? extends Object> getType() {
  70 + if (message!=null){
  71 + return message.getClass();
  72 + }
  73 +
  74 + return null;
  75 + }
  76 +
  77 +}
... ...
impl/core/src/main/java/br/gov/frameworkdemoiselle/management/ManagementNotificationEvent.java 0 → 100644
... ... @@ -0,0 +1,15 @@
  1 +package br.gov.frameworkdemoiselle.management;
  2 +
  3 +/**
  4 + * Event fired when a notification is sent by {@link NotificationManager}.
  5 + * Implementators can capture this event and be notified when the {@link NotificationManager}
  6 + * sends notifications, so they can pass the notification to the underlying technology.
  7 + *
  8 + * @author serpro
  9 + *
  10 + */
  11 +public interface ManagementNotificationEvent {
  12 +
  13 + public GenericNotification getNotification();
  14 +
  15 +}
... ...
impl/core/src/main/java/br/gov/frameworkdemoiselle/management/Notification.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.management;
38   -
39   -/**
40   - *
41   - * Notification that can be sent by the {@link NotificationManager}.
42   - *
43   - * @author serpro
44   - *
45   - */
46   -public class Notification {
47   -
48   - private Object message;
49   -
50   - public Notification(){
51   - }
52   -
53   - public Notification(Object message) {
54   - super();
55   - this.message = message;
56   - }
57   -
58   -
59   - public Object getMessage() {
60   - return message;
61   - }
62   -
63   -
64   - public void setMessage(Object message) {
65   - this.message = message;
66   - }
67   -
68   -
69   - public Class<? extends Object> getType() {
70   - if (message!=null){
71   - return message.getClass();
72   - }
73   -
74   - return null;
75   - }
76   -
77   -}
impl/core/src/main/java/br/gov/frameworkdemoiselle/management/NotificationManager.java
... ... @@ -36,23 +36,18 @@
36 36 */
37 37 package br.gov.frameworkdemoiselle.management;
38 38  
39   -import java.io.Serializable;
40   -
41 39 import javax.enterprise.context.ApplicationScoped;
42   -import javax.enterprise.event.Event;
43 40 import javax.enterprise.event.Observes;
44   -import javax.enterprise.util.AnnotationLiteral;
45 41 import javax.inject.Inject;
46 42  
47   -import br.gov.frameworkdemoiselle.internal.management.ManagementNotificationEvent;
48 43 import br.gov.frameworkdemoiselle.internal.management.qualifier.AttributeChange;
49 44 import br.gov.frameworkdemoiselle.internal.management.qualifier.Generic;
50 45 import br.gov.frameworkdemoiselle.util.Beans;
51 46  
52 47 /**
53 48 *
54   - * <p>Central class to manage sending notifications to management clients.
55   - * This class allows applications to send management notifications without
  49 + * <p>Central type to manage sending notifications to management clients.
  50 + * This interface allows applications to send management notifications without
56 51 * knowledge of the technology used to send those notifications.</p>
57 52 *
58 53 * <p>To obtain an instance of the {@link NotificationManager} simply inject it in
... ... @@ -68,49 +63,13 @@ import br.gov.frameworkdemoiselle.util.Beans;
68 63 *
69 64 */
70 65 @ApplicationScoped
71   -@SuppressWarnings("serial")
72   -public class NotificationManager implements Serializable{
73   -
74   - @Inject
75   - @Generic
76   - private Event<ManagementNotificationEvent> genericNotificationEvent;
77   -
78   - @Inject
79   - @AttributeChange
80   - private Event<ManagementNotificationEvent> attributeChangeNotificationEvent;
  66 +public interface NotificationManager {
81 67  
82 68 /**
83   - * Sends a generic notification to all management clients.
  69 + * Sends a notification to all management clients.
84 70 *
85 71 * @param notification The notification to send
86 72 */
87   - public void sendNotification(Notification notification) {
88   - if (! AttributeChangeNotification.class.isInstance(notification) ){
89   - getGenericNotificationEvent().fire(new ManagementNotificationEvent(notification));
90   - }
91   - else{
92   - getAttributeChangeNotificationEvent().fire(new ManagementNotificationEvent(notification));
93   - }
94   - }
  73 + public void sendNotification(GenericNotification notification);
95 74  
96   - @SuppressWarnings("unchecked")
97   - private Event<ManagementNotificationEvent> getGenericNotificationEvent() {
98   - if (genericNotificationEvent==null){
99   - genericNotificationEvent = Beans.getReference(Event.class , new AnnotationLiteral<Generic>() {});
100   - }
101   -
102   - return genericNotificationEvent;
103   - }
104   -
105   - @SuppressWarnings("unchecked")
106   - private Event<ManagementNotificationEvent> getAttributeChangeNotificationEvent() {
107   - if (attributeChangeNotificationEvent==null){
108   - attributeChangeNotificationEvent = Beans.getReference(Event.class , new AnnotationLiteral<AttributeChange>() {});
109   - }
110   -
111   - return attributeChangeNotificationEvent;
112   - }
113   -
114   -
115   -
116 75 }
... ...
impl/core/src/test/java/management/NotificationTestCase.java
... ... @@ -57,7 +57,7 @@ import br.gov.frameworkdemoiselle.annotation.Name;
57 57 import br.gov.frameworkdemoiselle.internal.management.ManagedType;
58 58 import br.gov.frameworkdemoiselle.internal.management.Management;
59 59 import br.gov.frameworkdemoiselle.management.AttributeChangeNotification;
60   -import br.gov.frameworkdemoiselle.management.Notification;
  60 +import br.gov.frameworkdemoiselle.management.GenericNotification;
61 61 import br.gov.frameworkdemoiselle.management.NotificationManager;
62 62 import br.gov.frameworkdemoiselle.util.Beans;
63 63 import br.gov.frameworkdemoiselle.util.ResourceBundle;
... ... @@ -98,7 +98,7 @@ public class NotificationTestCase {
98 98 */
99 99 @Test
100 100 public void testSendGenericNotification(){
101   - manager.sendNotification(new Notification("Test Message"));
  101 + manager.sendNotification(new GenericNotification("Test Message"));
102 102 DummyNotificationListener listener = Beans.getReference(DummyNotificationListener.class);
103 103 Assert.assertEquals("Test Message", listener.getMessage());
104 104 }
... ...
impl/core/src/test/java/management/testclasses/DummyNotificationListener.java
... ... @@ -39,10 +39,10 @@ package management.testclasses;
39 39 import javax.enterprise.context.ApplicationScoped;
40 40 import javax.enterprise.event.Observes;
41 41  
42   -import br.gov.frameworkdemoiselle.internal.management.ManagementNotificationEvent;
43 42 import br.gov.frameworkdemoiselle.internal.management.qualifier.AttributeChange;
44 43 import br.gov.frameworkdemoiselle.internal.management.qualifier.Generic;
45 44 import br.gov.frameworkdemoiselle.management.AttributeChangeNotification;
  45 +import br.gov.frameworkdemoiselle.management.ManagementNotificationEvent;
46 46 import br.gov.frameworkdemoiselle.management.NotificationManager;
47 47  
48 48 /**
... ...
impl/extension/jmx/src/main/java/br/gov/frameworkdemoiselle/jmx/internal/DynamicMBeanProxy.java
... ... @@ -212,9 +212,27 @@ public class DynamicMBeanProxy implements DynamicMBean {
212 212  
213 213 // Com todas as informações, criamos nossa instância de MBeanOperationInfo e
214 214 // acrescentamos na lista de todas as operações.
  215 + int operationType = 0;
  216 + switch(methodDetail.getType()){
  217 + case ACTION:
  218 + operationType = MBeanOperationInfo.ACTION;
  219 + break;
  220 +
  221 + case INFO:
  222 + operationType = MBeanOperationInfo.INFO;
  223 + break;
  224 +
  225 + case ACTION_INFO:
  226 + operationType = MBeanOperationInfo.ACTION_INFO;
  227 + break;
  228 +
  229 + default:
  230 + operationType = MBeanOperationInfo.UNKNOWN;
  231 + }
  232 +
215 233 MBeanOperationInfo operation = new MBeanOperationInfo(methodDetail.getMethod().getName(),
216 234 methodDetail.getDescription(), parameters, methodDetail.getMethod().getReturnType().getName(),
217   - MBeanOperationInfo.ACTION_INFO);
  235 + operationType);
218 236  
219 237 operations.add(operation);
220 238  
... ...
impl/extension/jmx/src/main/java/br/gov/frameworkdemoiselle/jmx/internal/MBeanManager.java
... ... @@ -39,10 +39,10 @@ package br.gov.frameworkdemoiselle.jmx.internal;
39 39 import java.util.Collection;
40 40 import java.util.HashMap;
41 41  
42   -import javax.inject.Singleton;
  42 +import javax.enterprise.context.ApplicationScoped;
43 43 import javax.management.ObjectInstance;
44 44  
45   -@Singleton
  45 +@ApplicationScoped
46 46 public class MBeanManager {
47 47  
48 48 private HashMap<String,ObjectInstance> registeredMBeans = new HashMap<String,ObjectInstance>();
... ...
impl/extension/jmx/src/main/java/br/gov/frameworkdemoiselle/jmx/internal/NotificationBroadcaster.java
... ... @@ -42,8 +42,8 @@ import javax.management.AttributeChangeNotification;
42 42 import javax.management.Notification;
43 43 import javax.management.NotificationBroadcasterSupport;
44 44  
45   -import br.gov.frameworkdemoiselle.internal.management.ManagementNotificationEvent;
46 45 import br.gov.frameworkdemoiselle.jmx.configuration.JMXConfig;
  46 +import br.gov.frameworkdemoiselle.management.ManagementNotificationEvent;
47 47 import br.gov.frameworkdemoiselle.management.NotificationManager;
48 48  
49 49 /**
... ... @@ -67,7 +67,7 @@ final class NotificationBroadcaster extends NotificationBroadcasterSupport imple
67 67 private static final String NOTIFICATION_TYPE_GENERIC = "jmx.message";
68 68  
69 69 protected void sendNotification( ManagementNotificationEvent event , JMXConfig config ) {
70   - br.gov.frameworkdemoiselle.management.Notification demoiselleNotification = event.getNotification();
  70 + br.gov.frameworkdemoiselle.management.GenericNotification demoiselleNotification = event.getNotification();
71 71 Notification n = new Notification(NOTIFICATION_TYPE_GENERIC, config.getNotificationMBeanName(), sequenceNumber++, System.currentTimeMillis(), demoiselleNotification.getMessage().toString());
72 72 sendNotification(n);
73 73 }
... ...
impl/extension/jmx/src/main/java/br/gov/frameworkdemoiselle/jmx/internal/NotificationEventListener.java
... ... @@ -41,10 +41,10 @@ import java.io.Serializable;
41 41 import javax.enterprise.context.ApplicationScoped;
42 42 import javax.enterprise.event.Observes;
43 43  
44   -import br.gov.frameworkdemoiselle.internal.management.ManagementNotificationEvent;
45 44 import br.gov.frameworkdemoiselle.internal.management.qualifier.AttributeChange;
46 45 import br.gov.frameworkdemoiselle.internal.management.qualifier.Generic;
47 46 import br.gov.frameworkdemoiselle.jmx.configuration.JMXConfig;
  47 +import br.gov.frameworkdemoiselle.management.ManagementNotificationEvent;
48 48 import br.gov.frameworkdemoiselle.management.NotificationManager;
49 49  
50 50 /**
... ...
impl/extension/jmx/src/test/java/management/tests/internal/NotificationBroadcasterTestCase.java
... ... @@ -61,7 +61,7 @@ import org.junit.runner.RunWith;
61 61 import br.gov.frameworkdemoiselle.jmx.configuration.JMXConfig;
62 62 import br.gov.frameworkdemoiselle.jmx.internal.MBeanManager;
63 63 import br.gov.frameworkdemoiselle.management.AttributeChangeNotification;
64   -import br.gov.frameworkdemoiselle.management.Notification;
  64 +import br.gov.frameworkdemoiselle.management.GenericNotification;
65 65 import br.gov.frameworkdemoiselle.management.NotificationManager;
66 66 import br.gov.frameworkdemoiselle.util.Beans;
67 67  
... ... @@ -122,7 +122,7 @@ public class NotificationBroadcasterTestCase {
122 122 }
123 123  
124 124 //Manda a notificação pelo Demoiselle
125   - Notification n = new Notification("Notification test successful");
  125 + GenericNotification n = new GenericNotification("Notification test successful");
126 126 notificationManager.sendNotification(n);
127 127  
128 128 //Se o componente funcionou, o Demoiselle propagou a notificação para o servidor MBean e o listener preencheu
... ...
impl/extension/jsf/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/SecurityObserver.java
... ... @@ -48,6 +48,7 @@ import javax.servlet.http.HttpSession;
48 48  
49 49 import org.slf4j.Logger;
50 50  
  51 +import br.gov.frameworkdemoiselle.annotation.Name;
51 52 import br.gov.frameworkdemoiselle.configuration.ConfigurationException;
52 53 import br.gov.frameworkdemoiselle.internal.configuration.JsfSecurityConfig;
53 54 import br.gov.frameworkdemoiselle.security.AfterLoginSuccessful;
... ... @@ -55,6 +56,7 @@ import br.gov.frameworkdemoiselle.security.AfterLogoutSuccessful;
55 56 import br.gov.frameworkdemoiselle.util.Beans;
56 57 import br.gov.frameworkdemoiselle.util.PageNotFoundException;
57 58 import br.gov.frameworkdemoiselle.util.Redirector;
  59 +import br.gov.frameworkdemoiselle.util.ResourceBundle;
58 60  
59 61 @SessionScoped
60 62 public class SecurityObserver implements Serializable {
... ... @@ -69,6 +71,10 @@ public class SecurityObserver implements Serializable {
69 71  
70 72 @Inject
71 73 private Logger logger;
  74 +
  75 + @Inject
  76 + @Name("demoiselle-jsf-bundle")
  77 + private ResourceBundle bundle;
72 78  
73 79 public SecurityObserver() {
74 80 clear();
... ... @@ -107,12 +113,7 @@ public class SecurityObserver implements Serializable {
107 113 Redirector.redirect(getConfig().getLoginPage());
108 114  
109 115 } catch (PageNotFoundException cause) {
110   - // TODO Colocar a mensagem no bundle
111   - throw new ConfigurationException(
112   - "A tela de login \""
113   - + cause.getViewId()
114   - + "\" não foi encontrada. Caso o seu projeto possua outra, defina no arquivo de configuração a chave \""
115   - + "frameworkdemoiselle.security.login.page" + "\"", cause);
  116 + throw new ConfigurationException( bundle.getString("login-page-not-found",cause.getViewId()) , cause);
116 117 }
117 118 }
118 119  
... ... @@ -130,12 +131,7 @@ public class SecurityObserver implements Serializable {
130 131  
131 132 } catch (PageNotFoundException cause) {
132 133 if (redirectedFromConfig) {
133   - // TODO Colocar a mensagem no bundle
134   - throw new ConfigurationException(
135   - "A tela \""
136   - + cause.getViewId()
137   - + "\" que é invocada após o logon não foi encontrada. Caso o seu projeto possua outra, defina no arquivo de configuração a chave \""
138   - + "frameworkdemoiselle.security.redirect.after.login" + "\"", cause);
  134 + throw new ConfigurationException( bundle.getString("after-login-page-not-found",cause.getViewId()) , cause);
139 135 } else {
140 136 throw cause;
141 137 }
... ... @@ -152,12 +148,7 @@ public class SecurityObserver implements Serializable {
152 148 }
153 149  
154 150 } catch (PageNotFoundException cause) {
155   - // TODO Colocar a mensagem no bundle
156   - throw new ConfigurationException(
157   - "A tela \""
158   - + cause.getViewId()
159   - + "\" que é invocada após o logout não foi encontrada. Caso o seu projeto possua outra, defina no arquivo de configuração a chave \""
160   - + "frameworkdemoiselle.security.redirect.after.logout" + "\"", cause);
  151 + throw new ConfigurationException( bundle.getString("after-logout-page-not-found",cause.getViewId()) , cause);
161 152  
162 153 } finally {
163 154 try {
... ...
impl/extension/jsf/src/main/resources/demoiselle-jsf-bundle.properties
... ... @@ -33,4 +33,7 @@
33 33 # ou escreva para a Fundação do Software Livre (FSF) Inc.,
34 34 # 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.
35 35  
36   -id-converter-not-found=Voc\u00EA precisa criar um FacesConverter para a classe "{0}".
37 36 \ No newline at end of file
  37 +id-converter-not-found=Voc\u00EA precisa criar um FacesConverter para a classe "{0}".
  38 +login-page-not-found=A tela de login "{0}" n\u00E3o foi encontrada. Caso essa n\u00E3o seja a p\u00E1gina correta, defina a p\u00E1gina no arquivo de configura\u00E7\u00E3o usando a chave "frameworkdemoiselle.security.login.page"
  39 +after-login-page-not-found=A tela "{0}" acessada ap\u00F3s o login n\u00E3o foi encontrada. Caso essa n\u00E3o seja a p\u00E1gina correta, defina a p\u00E1gina no arquivo de configura\u00E7\u00E3o usando a chave "frameworkdemoiselle.security.redirect.after.login"
  40 +after-logout-page-not-found=A tela "{0}" acessada ap\u00F3s o logout n\u00E3o foi encontrada. Caso essa n\u00E3o seja a p\u00E1gina correta, defina a p\u00E1gina no arquivo de configura\u00E7\u00E3o usando a chave "frameworkdemoiselle.security.redirect.after.logout"
38 41 \ No newline at end of file
... ...
impl/extension/servlet/src/main/java/br/gov/frameworkdemoiselle/security/ServletAuthenticator.java
... ... @@ -58,8 +58,9 @@ public class ServletAuthenticator implements Authenticator {
58 58 @Override
59 59 public void authenticate() throws AuthenticationException {
60 60 try {
61   - getRequest().login(getCredentials().getUsername(), getCredentials().getPassword());
62   -
  61 + if (this.getUser()==null){
  62 + getRequest().login(getCredentials().getUsername(), getCredentials().getPassword());
  63 + }
63 64 } catch (ServletException cause) {
64 65 throw new AuthenticationException(getBundle().getString("authentication-failed"), cause);
65 66 }
... ... @@ -68,6 +69,11 @@ public class ServletAuthenticator implements Authenticator {
68 69 @Override
69 70 public void unAuthenticate() {
70 71 getCredentials().clear();
  72 + try {
  73 + getRequest().logout();
  74 + } catch (ServletException e) {
  75 + //Logout já havia sido efetuado
  76 + }
71 77 getRequest().getSession().invalidate();
72 78 }
73 79  
... ...
parent/bom/pom.xml
... ... @@ -105,6 +105,11 @@
105 105 <artifactId>demoiselle-se</artifactId>
106 106 <version>2.4.0-BETA2-SNAPSHOT</version>
107 107 </dependency>
  108 + <dependency>
  109 + <groupId>br.gov.frameworkdemoiselle</groupId>
  110 + <artifactId>demoiselle-jmx</artifactId>
  111 + <version>2.4.0-BETA2-SNAPSHOT</version>
  112 + </dependency>
108 113 <!--
109 114 <dependency>
110 115 <groupId>br.gov.frameworkdemoiselle</groupId>
... ...