Commit eb82cbf7b381f0caa8e5f433539c427283100051

Authored by Dancovich
1 parent ec4dd5d2
Exists in master

Refatoração de classes que compõem a funcionalidade de monitoração e

gerenciamento, para se adaptarem à estrutura de pacotes do framework.
Showing 42 changed files with 1832 additions and 1802 deletions   Show diff stats
impl/core/src/main/java/br/gov/frameworkdemoiselle/annotation/ManagedOperation.java 0 → 100644
@@ -0,0 +1,74 @@ @@ -0,0 +1,74 @@
  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 java.lang.annotation.Documented;
  40 +import java.lang.annotation.ElementType;
  41 +import java.lang.annotation.Retention;
  42 +import java.lang.annotation.RetentionPolicy;
  43 +import java.lang.annotation.Target;
  44 +
  45 +import javax.enterprise.util.Nonbinding;
  46 +
  47 +import br.gov.frameworkdemoiselle.DemoiselleException;
  48 +
  49 +/**
  50 + * <p>Indicates that a method is a <b>managed operation</b>, meaning you can manage some aspect of the application by calling it from a external management client.</p>
  51 + * <p>This annotation can't be used together with {@link ManagedProperty}, doing so will throw a {@link DemoiselleException}.</p>
  52 + *
  53 + * @author SERPRO
  54 + *
  55 + */
  56 +@Documented
  57 +@Target({ElementType.METHOD})
  58 +@Retention(RetentionPolicy.RUNTIME)
  59 +public @interface ManagedOperation {
  60 +
  61 + /**
  62 + * Description that will be used to publish the operation to clients.
  63 + * Defaults to an empty description.
  64 + */
  65 + @Nonbinding
  66 + String description() default "";
  67 +
  68 + /**
  69 + * Type of operation. Defaults to {@link OperationType#UNKNOWN}.
  70 + */
  71 + @Nonbinding
  72 + OperationType type() default OperationType.UNKNOWN;
  73 +
  74 +}
impl/core/src/main/java/br/gov/frameworkdemoiselle/annotation/ManagedProperty.java 0 → 100644
@@ -0,0 +1,69 @@ @@ -0,0 +1,69 @@
  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 java.lang.annotation.Documented;
  40 +import java.lang.annotation.ElementType;
  41 +import java.lang.annotation.Retention;
  42 +import java.lang.annotation.RetentionPolicy;
  43 +import java.lang.annotation.Target;
  44 +
  45 +import javax.enterprise.util.Nonbinding;
  46 +
  47 +/**
  48 + * <p>Indicates that a field must be exposed as a property to management clients.</p>
  49 + * <p>The property will be writable if there's a public setter method
  50 + * declared for the field and readable if there's a getter method.</p>
  51 + * <p>It's a runtime error to annotate a field with no getter and no setter method.</p>
  52 + * <p>It's also a runtime error to declare a field as a property and one or both of it's getter and setter
  53 + * methods as an operation using the {@link ManagedOperation} annotation.</p>
  54 + *
  55 + * @author SERPRO
  56 + *
  57 + */
  58 +@Documented
  59 +@Target({ElementType.FIELD})
  60 +@Retention(RetentionPolicy.RUNTIME)
  61 +public @interface ManagedProperty {
  62 +
  63 + /**
  64 + * @return The description of this property exposed to management clients.
  65 + */
  66 + @Nonbinding
  67 + String description() default "";
  68 +
  69 +}
impl/core/src/main/java/br/gov/frameworkdemoiselle/annotation/OperationParameter.java 0 → 100644
@@ -0,0 +1,73 @@ @@ -0,0 +1,73 @@
  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 java.lang.annotation.Documented;
  40 +import java.lang.annotation.ElementType;
  41 +import java.lang.annotation.Retention;
  42 +import java.lang.annotation.RetentionPolicy;
  43 +import java.lang.annotation.Target;
  44 +
  45 +import javax.enterprise.util.Nonbinding;
  46 +
  47 +/**
  48 + * <p>Optional annotation to write additional detail about an operation's parameter.</p>
  49 + * <p>This annotation is ignored for non-operation methods.</p>
  50 + *
  51 + * @author SERPRO
  52 + *
  53 + */
  54 +@Documented
  55 +@Target({ElementType.PARAMETER})
  56 +@Retention(RetentionPolicy.RUNTIME)
  57 +public @interface OperationParameter {
  58 +
  59 + /**
  60 + * Name that will be used to publish this operation's parameter to clients.
  61 + */
  62 + @Nonbinding
  63 + String name();
  64 +
  65 + /**
  66 + * Optional description that will be used to publish this operation's parameter to clients.
  67 + * Defaults to an empty description.
  68 + */
  69 + @Nonbinding
  70 + String description() default "";
  71 +
  72 +
  73 +}
impl/core/src/main/java/br/gov/frameworkdemoiselle/annotation/OperationType.java 0 → 100644
@@ -0,0 +1,89 @@ @@ -0,0 +1,89 @@
  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 javax.management.MBeanOperationInfo;
  40 +
  41 +
  42 +/**
  43 + * <p>Define the operation type for an operation inside a ManagementController class.</p>
  44 + *
  45 + * <p>This is an optional annotation and it's significanse will change based on the management extension
  46 + * used. Most extensions will just publish this information to the client so it can better show to the user the inner
  47 + * workings of the annotated operation.</p>
  48 + *
  49 + *
  50 + * @author SERPRO
  51 + *
  52 + */
  53 +public enum OperationType {
  54 +
  55 + /**
  56 + * ManagedOperation is write-only, it causes the application
  57 + * to change some of it's behaviour but doesn't return any kind of information
  58 + */
  59 + ACTION(MBeanOperationInfo.ACTION)
  60 + ,
  61 + /**
  62 + * ManagedOperation is read-only, it will operate over data provided by the application and return some information,
  63 + * but will not change the application in any way.
  64 + */
  65 + INFO(MBeanOperationInfo.INFO)
  66 + ,
  67 + /**
  68 + * ManagedOperation is read-write, it will both change the way the application work and return some information regarding
  69 + * the result of the operation.
  70 + */
  71 + ACTION_INFO(MBeanOperationInfo.ACTION_INFO)
  72 + ,
  73 + /**
  74 + * The effect of calling this operation is unknown. This is the default type and if this type is assigned to an operation,
  75 + * the user must rely on the {@link ManagedOperation#description()} attribute to learn about how the operation works.
  76 + */
  77 + UNKNOWN(MBeanOperationInfo.UNKNOWN);
  78 +
  79 + private int operationTypeValue;
  80 +
  81 + private OperationType(int type){
  82 + this.operationTypeValue = type;
  83 + }
  84 +
  85 + public int getValue(){
  86 + return operationTypeValue;
  87 + }
  88 +
  89 +}
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/ManagementBootstrap.java
@@ -17,10 +17,10 @@ import javax.enterprise.inject.spi.ProcessAnnotatedType; @@ -17,10 +17,10 @@ import javax.enterprise.inject.spi.ProcessAnnotatedType;
17 17
18 import br.gov.frameworkdemoiselle.internal.context.ContextManager; 18 import br.gov.frameworkdemoiselle.internal.context.ContextManager;
19 import br.gov.frameworkdemoiselle.internal.context.ManagedContext; 19 import br.gov.frameworkdemoiselle.internal.context.ManagedContext;
20 -import br.gov.frameworkdemoiselle.management.annotation.Managed;  
21 -import br.gov.frameworkdemoiselle.management.extension.ManagementExtension;  
22 -import br.gov.frameworkdemoiselle.management.internal.ManagedType;  
23 -import br.gov.frameworkdemoiselle.management.internal.MonitoringManager; 20 +import br.gov.frameworkdemoiselle.internal.management.ManagedType;
  21 +import br.gov.frameworkdemoiselle.internal.management.Management;
  22 +import br.gov.frameworkdemoiselle.lifecycle.ManagementExtension;
  23 +import br.gov.frameworkdemoiselle.stereotype.ManagementController;
24 import br.gov.frameworkdemoiselle.util.Beans; 24 import br.gov.frameworkdemoiselle.util.Beans;
25 25
26 public class ManagementBootstrap implements Extension { 26 public class ManagementBootstrap implements Extension {
@@ -31,7 +31,7 @@ public class ManagementBootstrap implements Extension { @@ -31,7 +31,7 @@ public class ManagementBootstrap implements Extension {
31 31
32 32
33 public <T> void detectAnnotation(@Observes final ProcessAnnotatedType<T> event, final BeanManager beanManager) { 33 public <T> void detectAnnotation(@Observes final ProcessAnnotatedType<T> event, final BeanManager beanManager) {
34 - if (event.getAnnotatedType().isAnnotationPresent(Managed.class)) { 34 + if (event.getAnnotatedType().isAnnotationPresent(ManagementController.class)) {
35 types.add(event.getAnnotatedType()); 35 types.add(event.getAnnotatedType());
36 } 36 }
37 } 37 }
@@ -43,7 +43,7 @@ public class ManagementBootstrap implements Extension { @@ -43,7 +43,7 @@ public class ManagementBootstrap implements Extension {
43 43
44 @SuppressWarnings("unchecked") 44 @SuppressWarnings("unchecked")
45 public void registerAvailableManagedTypes(@Observes final AfterDeploymentValidation event,BeanManager beanManager) { 45 public void registerAvailableManagedTypes(@Observes final AfterDeploymentValidation event,BeanManager beanManager) {
46 - MonitoringManager monitoringManager = Beans.getReference(MonitoringManager.class); 46 + Management monitoringManager = Beans.getReference(Management.class);
47 for (AnnotatedType<?> type : types) { 47 for (AnnotatedType<?> type : types) {
48 ManagedType managedType = new ManagedType(type.getJavaClass()); 48 ManagedType managedType = new ManagedType(type.getJavaClass());
49 monitoringManager.addManagedType(managedType); 49 monitoringManager.addManagedType(managedType);
@@ -62,7 +62,7 @@ public class ManagementBootstrap implements Extension { @@ -62,7 +62,7 @@ public class ManagementBootstrap implements Extension {
62 62
63 public void unregisterAvailableManagedTypes(@Observes final BeforeShutdown event) { 63 public void unregisterAvailableManagedTypes(@Observes final BeforeShutdown event) {
64 64
65 - MonitoringManager manager = Beans.getReference(MonitoringManager.class); 65 + Management manager = Beans.getReference(Management.class);
66 manager.shutdown(managementExtensionCache); 66 manager.shutdown(managementExtensionCache);
67 67
68 managementExtensionCache.clear(); 68 managementExtensionCache.clear();
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/context/ManagedContext.java
@@ -2,10 +2,10 @@ package br.gov.frameworkdemoiselle.internal.context; @@ -2,10 +2,10 @@ package br.gov.frameworkdemoiselle.internal.context;
2 2
3 import javax.enterprise.context.RequestScoped; 3 import javax.enterprise.context.RequestScoped;
4 4
5 -import br.gov.frameworkdemoiselle.management.annotation.Managed; 5 +import br.gov.frameworkdemoiselle.stereotype.ManagementController;
6 6
7 /** 7 /**
8 - * Context that stores {@link RequestScoped} beans during client calls to {@link Managed} classes. 8 + * Context that stores {@link RequestScoped} beans during client calls to {@link ManagementController} classes.
9 * This context is only activated when no other context is active for {@link RequestScoped}. 9 * This context is only activated when no other context is active for {@link RequestScoped}.
10 * 10 *
11 * @author serpro 11 * @author serpro
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/management/ManagedType.java 0 → 100644
@@ -0,0 +1,334 @@ @@ -0,0 +1,334 @@
  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 java.lang.annotation.Annotation;
  40 +import java.lang.reflect.Field;
  41 +import java.lang.reflect.Method;
  42 +import java.util.TreeMap;
  43 +
  44 +import br.gov.frameworkdemoiselle.DemoiselleException;
  45 +import br.gov.frameworkdemoiselle.annotation.ManagedOperation;
  46 +import br.gov.frameworkdemoiselle.annotation.ManagedProperty;
  47 +import br.gov.frameworkdemoiselle.annotation.OperationParameter;
  48 +import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer;
  49 +import br.gov.frameworkdemoiselle.stereotype.ManagementController;
  50 +import br.gov.frameworkdemoiselle.util.ResourceBundle;
  51 +
  52 +/**
  53 + * <p>Package class containing information about a discovered {@link ManagementController}.</p>
  54 + *
  55 + * <p>Instances if this class are passed to each discovered management extension during bootstrap so they can have
  56 + * enough information to expose all discovered {@link ManagementController}'s to management clients.</p>
  57 + *
  58 + * @author serpro
  59 + */
  60 +public class ManagedType {
  61 +
  62 + private Class<?> type;
  63 +
  64 + private TreeMap<String, FieldDetail> fields;
  65 +
  66 + private TreeMap<String, MethodDetail> operationMethods;
  67 +
  68 + private ResourceBundle bundle;
  69 +
  70 + private String description;
  71 +
  72 + public ManagedType(Class<?> type) {
  73 + bundle = ResourceBundleProducer.create("demoiselle-core-bundle");
  74 +
  75 + if (type == null) {
  76 + throw new DemoiselleException(bundle.getString("management-null-class-defined"));
  77 + }
  78 + if (!type.isAnnotationPresent(ManagementController.class)) {
  79 + throw new DemoiselleException(bundle.getString("management-no-annotation-found", type.getCanonicalName()));
  80 + }
  81 +
  82 + this.type = type;
  83 + fields = new TreeMap<String, FieldDetail>();
  84 + operationMethods = new TreeMap<String, MethodDetail>();
  85 + this.description = type.getAnnotation(ManagementController.class).description();
  86 +
  87 + initialize();
  88 + }
  89 +
  90 + public Class<?> getType() {
  91 + return type;
  92 + }
  93 +
  94 + public String getDescription() {
  95 + return description;
  96 + }
  97 +
  98 + public TreeMap<String, FieldDetail> getFields() {
  99 + return fields;
  100 + }
  101 +
  102 + public TreeMap<String, MethodDetail> getOperationMethods() {
  103 + return operationMethods;
  104 + }
  105 +
  106 + private void initialize() {
  107 + // Para cada atributo verifica se ele está anotado com ManagedProperty e extrai as informações dele (método get, set e
  108 + // descrição do atributo).
  109 + Field[] fields = type.getDeclaredFields();
  110 + if (fields != null) {
  111 + for (Field field : fields) {
  112 + if (field.isAnnotationPresent(ManagedProperty.class)) {
  113 + // Obtém os métodos GET e SET para esta propriedade
  114 + Method getterMethod = getGetterMethod(field);
  115 + Method setterMethod = getSetterMethod(field);
  116 + if (getterMethod == null && setterMethod == null) {
  117 + throw new DemoiselleException(bundle.getString("management-invalid-property-no-getter-setter",
  118 + type.getSimpleName(), field.getName()));
  119 + } else if ((getterMethod != null && getterMethod.isAnnotationPresent(ManagedOperation.class))
  120 + || (setterMethod != null && setterMethod.isAnnotationPresent(ManagedOperation.class))) {
  121 + throw new DemoiselleException(bundle.getString("management-invalid-property-as-operation",
  122 + type.getSimpleName()));
  123 + }
  124 +
  125 + String propertyDescription = field.getAnnotation(ManagedProperty.class).description();
  126 +
  127 + this.fields.put(field.getName(), new FieldDetail(field, propertyDescription, getterMethod,
  128 + setterMethod));
  129 + }
  130 + }
  131 + }
  132 +
  133 + // Para cada metodo verifica se ele está anotado com ManagedOperation e cria um MBeanOperationInfo para ele.
  134 + Method[] methodList = type.getMethods();
  135 + if (methodList != null) {
  136 + for (Method method : methodList) {
  137 + ManagedOperation opAnnotation = method.getAnnotation(ManagedOperation.class);
  138 +
  139 + if (opAnnotation != null) {
  140 + // Lemos as informações sobre o método e criamos uma instância
  141 + // de MethodDetail para representar este método como uma
  142 + // operação.
  143 +
  144 + Class<?>[] parameterTypes = method.getParameterTypes();
  145 + Annotation[][] parameterAnnotations = method.getParameterAnnotations();
  146 + ParameterDetail[] parameterDetails = new ParameterDetail[parameterTypes.length];
  147 +
  148 + for (int i = 0; i < parameterTypes.length; i++) {
  149 + OperationParameter paramAnnotation = null;
  150 + for (Annotation annotation : parameterAnnotations[i]) {
  151 + if (annotation.annotationType() == OperationParameter.class) {
  152 + paramAnnotation = (OperationParameter) annotation;
  153 + break;
  154 + }
  155 + }
  156 +
  157 + String name = paramAnnotation != null ? paramAnnotation.name() : ("arg" + i);
  158 + String description = paramAnnotation != null ? paramAnnotation.description() : null;
  159 +
  160 + parameterDetails[i] = new ParameterDetail(parameterTypes[i], name, description);
  161 + }
  162 +
  163 + // Com todas as informações, criamos nossa instância de MethodDetail e
  164 + // acrescentamos na lista de todas as operações.
  165 + MethodDetail detail = new MethodDetail(method, opAnnotation.description(), parameterDetails);
  166 + operationMethods.put(method.getName(), detail);
  167 + }
  168 + }
  169 + }
  170 + }
  171 +
  172 + /**
  173 + * Returns the public getter method for a given field, or <code>null</code> if no getter method can be found.
  174 + */
  175 + private Method getGetterMethod(Field field) {
  176 + StringBuffer getterMethodName = new StringBuffer()
  177 + .append("get")
  178 + .append(field.getName().substring(0, 1).toUpperCase())
  179 + .append(field.getName().substring(1));
  180 +
  181 + Method getterMethod;
  182 +
  183 + try {
  184 + getterMethod = type.getMethod(getterMethodName.toString());
  185 + } catch (Exception e) {
  186 + getterMethod = null;
  187 + }
  188 +
  189 + // Se atributo for boolean, procura método getter no formato "isAttribute".
  190 + if (getterMethod == null
  191 + && (Boolean.TYPE.isAssignableFrom(field.getType()) || Boolean.class.isAssignableFrom(field.getType()))) {
  192 + // Boolean.TYPE representa o tipo primitivo "boolean", Boolean.class é a classe wrapper.
  193 + getterMethodName = new StringBuffer()
  194 + .append("is")
  195 + .append(field.getName().substring(0, 1).toUpperCase())
  196 + .append(field.getName().substring(1).toUpperCase());
  197 +
  198 + try {
  199 + getterMethod = type.getMethod(getterMethodName.toString());
  200 + } catch (Exception e) {
  201 + getterMethod = null;
  202 + }
  203 + }
  204 +
  205 + return getterMethod;
  206 + }
  207 +
  208 + /**
  209 + * Returns the public setter method for a given field, or <code>null</code> if no setter method can be found.
  210 + */
  211 + private Method getSetterMethod(Field field) {
  212 + StringBuffer setterMethodName = new StringBuffer()
  213 + .append("set")
  214 + .append(field.getName().substring(0, 1).toUpperCase())
  215 + .append(field.getName().substring(1));
  216 +
  217 + Method setterMethod;
  218 +
  219 + try {
  220 + setterMethod = type.getMethod(setterMethodName.toString() , field.getType());
  221 + } catch (Exception e) {
  222 + setterMethod = null;
  223 + }
  224 +
  225 + return setterMethod;
  226 + }
  227 +
  228 + public final class FieldDetail {
  229 +
  230 + private final Field field;
  231 +
  232 + private final String description;
  233 +
  234 + private Method getterMethod;
  235 +
  236 + private Method setterMethod;
  237 +
  238 + public FieldDetail(Field field, String description, Method getterMethod, Method setterMethod) {
  239 + super();
  240 + this.field = field;
  241 + this.description = description;
  242 + this.getterMethod = getterMethod;
  243 + this.setterMethod = setterMethod;
  244 + }
  245 +
  246 + public Field getField() {
  247 + return field;
  248 + }
  249 +
  250 + public String getDescription() {
  251 + return description;
  252 + }
  253 +
  254 + public Method getGetterMethod() {
  255 + return getterMethod;
  256 + }
  257 +
  258 + public Method getSetterMethod() {
  259 + return setterMethod;
  260 + }
  261 +
  262 + }
  263 +
  264 + public final class MethodDetail {
  265 +
  266 + private final Method method;
  267 +
  268 + private final ParameterDetail[] parameterTypers;
  269 +
  270 + private String description;
  271 +
  272 + public MethodDetail(Method method, String description, ParameterDetail[] parameterTypers) {
  273 + super();
  274 + this.method = method;
  275 + this.description = description;
  276 + this.parameterTypers = parameterTypers;
  277 + }
  278 +
  279 + public Method getMethod() {
  280 + return method;
  281 + }
  282 +
  283 + public ParameterDetail[] getParameterTypers() {
  284 + return parameterTypers;
  285 + }
  286 +
  287 + public String getDescription() {
  288 + return description;
  289 + }
  290 +
  291 + }
  292 +
  293 + public final class ParameterDetail {
  294 +
  295 + private final Class<?> parameterType;
  296 +
  297 + private final String parameterName;
  298 +
  299 + private final String parameterDescription;
  300 +
  301 + public ParameterDetail(Class<?> parameterType, String parameterName, String parameterDescription) {
  302 + super();
  303 + this.parameterType = parameterType;
  304 + this.parameterName = parameterName;
  305 + this.parameterDescription = parameterDescription;
  306 + }
  307 +
  308 + public Class<?> getParameterType() {
  309 + return parameterType;
  310 + }
  311 +
  312 + public String getParameterName() {
  313 + return parameterName;
  314 + }
  315 +
  316 + public String getParameterDescription() {
  317 + return parameterDescription;
  318 + }
  319 + }
  320 +
  321 + /**
  322 + * Indicates another {@link ManagedType} represents the same {@link Class} as this one. This method also supports a
  323 + * {@link Class} as a parameter, in this case it will return <code>true</code> if the passed class is exactly the
  324 + * same Java class represented by this {@link ManagedType}.
  325 + */
  326 + @Override
  327 + public boolean equals(Object other) {
  328 + if (other == null) {
  329 + return false;
  330 + }
  331 +
  332 + return ((ManagedType) other).getType().getCanonicalName().equals(this.getType().getCanonicalName());
  333 + }
  334 +}
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/management/Management.java 0 → 100644
@@ -0,0 +1,310 @@ @@ -0,0 +1,310 @@
  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 java.lang.reflect.Method;
  40 +import java.util.ArrayList;
  41 +import java.util.Collection;
  42 +import java.util.List;
  43 +
  44 +import javax.enterprise.context.ApplicationScoped;
  45 +import javax.enterprise.context.RequestScoped;
  46 +import javax.inject.Inject;
  47 +import javax.management.ReflectionException;
  48 +
  49 +import org.slf4j.Logger;
  50 +
  51 +import br.gov.frameworkdemoiselle.DemoiselleException;
  52 +import br.gov.frameworkdemoiselle.annotation.ManagedProperty;
  53 +import br.gov.frameworkdemoiselle.annotation.Name;
  54 +import br.gov.frameworkdemoiselle.internal.context.ContextManager;
  55 +import br.gov.frameworkdemoiselle.internal.context.ManagedContext;
  56 +import br.gov.frameworkdemoiselle.internal.management.ManagedType.MethodDetail;
  57 +import br.gov.frameworkdemoiselle.lifecycle.ManagementExtension;
  58 +import br.gov.frameworkdemoiselle.management.AttributeChangeNotification;
  59 +import br.gov.frameworkdemoiselle.management.NotificationManager;
  60 +import br.gov.frameworkdemoiselle.stereotype.ManagementController;
  61 +import br.gov.frameworkdemoiselle.util.Beans;
  62 +import br.gov.frameworkdemoiselle.util.ResourceBundle;
  63 +
  64 +/**
  65 + * Central class used by management extensions to obtain information, access properties and call operations
  66 + * over discovered {@link ManagementController} classes.
  67 + *
  68 + * @author serpro
  69 + */
  70 +@ApplicationScoped
  71 +public class Management {
  72 +
  73 + @Inject
  74 + private Logger logger;
  75 +
  76 + @Inject
  77 + @Name("demoiselle-core-bundle")
  78 + private ResourceBundle bundle;
  79 +
  80 + private final List<ManagedType> managedTypes = new ArrayList<ManagedType>();
  81 +
  82 + public void addManagedType(ManagedType managedType) {
  83 + managedTypes.add(managedType);
  84 + logger.debug(bundle.getString("management-debug-registering-managed-type",managedType.getType().getCanonicalName()));
  85 + }
  86 +
  87 + /**
  88 + * @return List all discovered {@link ManagementController} classes.
  89 + * The returned list is a shallow copy of the internal list, so you
  90 + * are free to modify it.
  91 + *
  92 + * TODO precisamos desse clone na lista?
  93 + */
  94 + public List<ManagedType> getManagedTypes() {
  95 + ArrayList<ManagedType> cloneList = new ArrayList<ManagedType>();
  96 + cloneList.addAll(managedTypes);
  97 + return cloneList;
  98 + }
  99 +
  100 + /**
  101 + * <p>Invoke an operation over a {@link ManagementController}.</p>
  102 + *
  103 + * <p>This method is not thread-safe, it's the user's responsibility to
  104 + * make the operations of the managed type synchronized if necessary.</p>
  105 + *
  106 + * @param managedType
  107 + * A type annotated with {@link ManagementController}. This method will create
  108 + * an (or obtain an already created) instance of this type and
  109 + * invoke the operation over it.
  110 + * @param actionName
  111 + * Name of method to be invoked, the type must have this
  112 + * operation on it's list
  113 + * @param params
  114 + * List of values for the operation parameters. Can be
  115 + * <code>null</code> if the operation require no parameters.
  116 + * @return The return value of the original invoked operation. Methods of
  117 + * return type <code>void</code> will return the {@link Void} type.
  118 + * @throws ReflectionException
  119 + * In case the operation doesn't exist or have a different
  120 + * signature
  121 + */
  122 + public Object invoke(ManagedType managedType, String actionName,
  123 + Object[] params) {
  124 + if ( managedTypes.contains(managedType) ) {
  125 + activateContexts(managedType.getType());
  126 +
  127 + Object delegate = Beans.getReference(managedType.getType());
  128 +
  129 + MethodDetail method = managedType.getOperationMethods().get(actionName);
  130 +
  131 + if (method != null) {
  132 + try {
  133 + logger.debug(bundle
  134 + .getString("management-debug-invoking-operation",actionName,managedType.getType().getCanonicalName()));
  135 + return method.getMethod().invoke(delegate, params);
  136 + } catch (Exception e) {
  137 + throw new DemoiselleException(bundle.getString(
  138 + "management-invoke-error", actionName), e);
  139 + } finally {
  140 + deactivateContexts(managedType.getType());
  141 + }
  142 + } else {
  143 + throw new DemoiselleException(bundle.getString(
  144 + "management-invoke-error", actionName));
  145 + }
  146 + } else {
  147 + throw new DemoiselleException(
  148 + bundle.getString("management-type-not-found"));
  149 + }
  150 + }
  151 +
  152 + /**
  153 + * <p>Retrieve the current value of a property from a managed type. Properties
  154 + * are attributes annotated with {@link ManagedProperty}.</p>
  155 + *
  156 + * <p>This method is not thread-safe, it's the user's responsibility to
  157 + * create the property's access methods from the managed type synchronized if necessary.</p>
  158 + *
  159 + * @param managedType The type that has the property the client wants to know the value of.
  160 + * @param propertyName The name of the property
  161 + * @return The current value of the property
  162 + */
  163 + public Object getProperty(ManagedType managedType, String propertyName) {
  164 +
  165 + if ( managedTypes.contains(managedType) ) {
  166 + Method getterMethod = managedType.getFields().get(propertyName).getGetterMethod();
  167 +
  168 + if (getterMethod != null) {
  169 + logger.debug(bundle.getString(
  170 + "management-debug-acessing-property", getterMethod
  171 + .getName(), managedType.getType().getCanonicalName()));
  172 +
  173 + activateContexts(managedType.getType());
  174 +
  175 + try {
  176 + Object delegate = Beans.getReference(managedType.getType());
  177 +
  178 + return getterMethod.invoke(delegate, (Object[]) null);
  179 + } catch (Exception e) {
  180 + throw new DemoiselleException(bundle.getString(
  181 + "management-invoke-error", getterMethod.getName()),
  182 + e);
  183 + } finally {
  184 + deactivateContexts(managedType.getType());
  185 + }
  186 + } else {
  187 + throw new DemoiselleException(bundle.getString(
  188 + "management-invoke-error", propertyName));
  189 + }
  190 + } else {
  191 + throw new DemoiselleException(
  192 + bundle.getString("management-type-not-found"));
  193 + }
  194 + }
  195 +
  196 + /**
  197 + * <p>Sets a new value for a property contained inside a managed type. A property
  198 + * is an attribute annotated with {@link ManagedProperty}.</p>
  199 + *
  200 + * <p>This method is not thread-safe, it's the user's responsibility to
  201 + * create the property's access methods from the managed type synchronized if necessary.</p>
  202 + *
  203 + * @param managedType The type that has access to the property
  204 + * @param propertyName The name of the property
  205 + * @param newValue The new value of the property
  206 + */
  207 + public void setProperty(ManagedType managedType, String propertyName,
  208 + Object newValue) {
  209 +
  210 + if ( managedTypes.contains(managedType) ) {
  211 + // Procura o método set do atributo em questão
  212 + Method method = managedType.getFields().get(propertyName).getSetterMethod();
  213 + if (method != null) {
  214 + logger.debug(bundle.getString(
  215 + "management-debug-setting-property", method.getName(),
  216 + managedType.getType().getCanonicalName()));
  217 +
  218 + // Obtém uma instância da classe gerenciada, lembrando que
  219 + // classes
  220 + // anotadas com @ManagementController são sempre singletons.
  221 + activateContexts(managedType.getType());
  222 + try {
  223 + Object delegate = Beans.getReference(managedType.getType());
  224 +
  225 + Method getterMethod = managedType.getFields().get(propertyName).getGetterMethod();
  226 + Object oldValue;
  227 + try{
  228 + oldValue = getterMethod.invoke(delegate, (Object[])null);
  229 + }
  230 + catch(Exception e){
  231 + oldValue = null;
  232 + }
  233 +
  234 + method.invoke(delegate, new Object[] { newValue });
  235 +
  236 + //Manda uma notificação de mudança de atributo
  237 + NotificationManager notificationManager = Beans.getReference(NotificationManager.class);
  238 + Class<? extends Object> attributeType = newValue!=null ? newValue.getClass() : null;
  239 +
  240 + AttributeChangeNotification notification = new AttributeChangeNotification(bundle.getString("management-notification-attribute-changed",propertyName,managedType.getType().getCanonicalName())
  241 + , propertyName
  242 + , attributeType
  243 + , oldValue
  244 + , newValue);
  245 + notificationManager.sendNotification(notification);
  246 +
  247 + } catch (Exception e) {
  248 + throw new DemoiselleException(bundle.getString(
  249 + "management-invoke-error", method.getName()), e);
  250 + } finally {
  251 + deactivateContexts(managedType.getType());
  252 + }
  253 +
  254 + } else {
  255 + throw new DemoiselleException(bundle.getString(
  256 + "management-invoke-error", propertyName));
  257 + }
  258 + } else {
  259 + throw new DemoiselleException(
  260 + bundle.getString("management-type-not-found"));
  261 + }
  262 +
  263 + }
  264 +
  265 + private void activateContexts(Class<?> managedType) {
  266 + logger.debug(bundle.getString("management-debug-starting-custom-context",
  267 + ManagedContext.class.getCanonicalName(),
  268 + managedType.getCanonicalName()));
  269 +
  270 + ContextManager.activate(ManagedContext.class,RequestScoped.class);
  271 + }
  272 +
  273 + private void deactivateContexts(Class<?> managedType) {
  274 + logger.debug(bundle.getString("management-debug-stoping-custom-context",
  275 + ManagedContext.class.getCanonicalName(),
  276 + managedType.getCanonicalName()));
  277 +
  278 + ContextManager.deactivate(ManagedContext.class,RequestScoped.class);
  279 + }
  280 +
  281 + public void shutdown(Collection<Class<? extends ManagementExtension>> monitoringExtensions) {
  282 +
  283 + for (Class<? extends ManagementExtension> monitoringExtensionClass : monitoringExtensions) {
  284 +
  285 + ManagementExtension monitoringExtension = Beans.getReference(monitoringExtensionClass);
  286 +
  287 + monitoringExtension.shutdown(this.getManagedTypes());
  288 +
  289 + logger.debug( bundle.getString("management-debug-removing-management-extension",monitoringExtension.getClass().getCanonicalName()) );
  290 +
  291 + }
  292 +
  293 + }
  294 +
  295 + public void initialize(Collection<Class<? extends ManagementExtension>> monitoringExtensions) {
  296 +
  297 + for (Class<? extends ManagementExtension> monitoringExtensionClass : monitoringExtensions) {
  298 +
  299 + ManagementExtension monitoringExtension = Beans
  300 + .getReference(monitoringExtensionClass);
  301 +
  302 + monitoringExtension.initialize(this.getManagedTypes());
  303 +
  304 + logger.debug( bundle.getString("management-debug-processing-management-extension",monitoringExtension.getClass().getCanonicalName()) );
  305 +
  306 + }
  307 +
  308 + }
  309 +
  310 +}
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/management/ManagementNotificationEvent.java 0 → 100644
@@ -0,0 +1,65 @@ @@ -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.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/qualifier/AttributeChange.java 0 → 100644
@@ -0,0 +1,62 @@ @@ -0,0 +1,62 @@
  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.qualifier;
  38 +
  39 +import java.lang.annotation.ElementType;
  40 +import java.lang.annotation.Retention;
  41 +import java.lang.annotation.RetentionPolicy;
  42 +import java.lang.annotation.Target;
  43 +
  44 +import javax.inject.Qualifier;
  45 +
  46 +import br.gov.frameworkdemoiselle.internal.management.ManagementNotificationEvent;
  47 +import br.gov.frameworkdemoiselle.management.AttributeChangeNotification;
  48 +
  49 +/**
  50 + *
  51 + * Enables {@link ManagementNotificationEvent} observers to trigger only with notifications
  52 + * of the specialized type {@link AttributeChangeNotification}.
  53 + *
  54 + * @author serpro
  55 + *
  56 + */
  57 +@Qualifier
  58 +@Retention(RetentionPolicy.RUNTIME)
  59 +@Target({ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER, ElementType.TYPE})
  60 +public @interface AttributeChange {
  61 +
  62 +}
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/management/qualifier/Generic.java 0 → 100644
@@ -0,0 +1,62 @@ @@ -0,0 +1,62 @@
  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.qualifier;
  38 +
  39 +import java.lang.annotation.ElementType;
  40 +import java.lang.annotation.Retention;
  41 +import java.lang.annotation.RetentionPolicy;
  42 +import java.lang.annotation.Target;
  43 +
  44 +import javax.inject.Qualifier;
  45 +
  46 +import br.gov.frameworkdemoiselle.internal.management.ManagementNotificationEvent;
  47 +import br.gov.frameworkdemoiselle.management.Notification;
  48 +
  49 +/**
  50 + *
  51 + * Enables {@link ManagementNotificationEvent} observers to trigger only with notifications
  52 + * of the base type {@link Notification}.
  53 + *
  54 + * @author serpro
  55 + *
  56 + */
  57 +@Qualifier
  58 +@Retention(RetentionPolicy.RUNTIME)
  59 +@Target({ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER, ElementType.TYPE})
  60 +public @interface Generic {
  61 +
  62 +}
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/validation/AllowedValuesValidator.java 0 → 100644
@@ -0,0 +1,104 @@ @@ -0,0 +1,104 @@
  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.validation;
  38 +
  39 +import java.math.BigDecimal;
  40 +
  41 +import javax.validation.ConstraintValidator;
  42 +import javax.validation.ConstraintValidatorContext;
  43 +
  44 +import br.gov.frameworkdemoiselle.validation.AllowedValues;
  45 +
  46 +
  47 +public class AllowedValuesValidator implements ConstraintValidator<AllowedValues, Object> {
  48 +
  49 + private br.gov.frameworkdemoiselle.validation.AllowedValues.ValueType valueType;
  50 + private String[] allowedValues;
  51 +
  52 + @Override
  53 + public void initialize(AllowedValues constraintAnnotation) {
  54 + valueType = constraintAnnotation.valueType();
  55 + allowedValues = constraintAnnotation.allows();
  56 + }
  57 +
  58 + @Override
  59 + public boolean isValid(Object value, ConstraintValidatorContext context) {
  60 +
  61 + if (value==null){
  62 + return false;
  63 + }
  64 +
  65 + switch(valueType){
  66 + case STRING:
  67 + for (String str : allowedValues){
  68 + if (str.equals(value)) return true;
  69 + }
  70 + return false;
  71 +
  72 + case INTEGER:
  73 + try{
  74 + Integer number = Integer.valueOf(value.toString());
  75 + String strNumber = number.toString();
  76 + for (String str : allowedValues){
  77 + if (str.equals(strNumber)) return true;
  78 + }
  79 +
  80 + return false;
  81 + }
  82 + catch(NumberFormatException ne){
  83 + return false;
  84 + }
  85 +
  86 + case DECIMAL:
  87 + try{
  88 + BigDecimal number = new BigDecimal(value.toString());
  89 + String strNumber = number.toString();
  90 + for (String str : allowedValues){
  91 + if (str.equals(strNumber)) return true;
  92 + }
  93 + }
  94 + catch(NumberFormatException ne){
  95 + return false;
  96 + }
  97 +
  98 + return false;
  99 + }
  100 +
  101 + return false;
  102 + }
  103 +
  104 +}
impl/core/src/main/java/br/gov/frameworkdemoiselle/lifecycle/ManagementExtension.java 0 → 100644
@@ -0,0 +1,76 @@ @@ -0,0 +1,76 @@
  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.lifecycle;
  38 +
  39 +import java.util.List;
  40 +
  41 +import br.gov.frameworkdemoiselle.internal.management.ManagedType;
  42 +import br.gov.frameworkdemoiselle.stereotype.ManagementController;
  43 +
  44 +/**
  45 + *
  46 + * <p>Interface defining the lifecycle of a <b>management extension</b>, an extension
  47 + * capable of exposing {@link ManagementController}'s to external clients in one
  48 + * of the available management technologies, such as JMX or SNMP.</p>
  49 + *
  50 + * <p>To include a management extension into the management lifecycle, it just needs
  51 + * to implement this interface and be a CDI bean (have a <b>beans.xml</b> file inside
  52 + * the META-INF folder of it's java package). The Demoiselle Core lifecycle controller
  53 + * will call the {@link #initialize(List managedTypes)} and {@link #shutdown(List managedTypes)} methods at the apropriate times.</p>
  54 + *
  55 + * @author serpro
  56 + *
  57 + */
  58 +public interface ManagementExtension {
  59 +
  60 + /**
  61 + * This method is called during the application initialization process for each concrete
  62 + * implementation of this interface.
  63 + *
  64 + * @param managedTypes The list of discovered {@link ManagementController} classes.
  65 + */
  66 + void initialize(List<ManagedType> managedTypes);
  67 +
  68 + /**
  69 + * This method is called during the application shutdown process for each concrete
  70 + * implementation of this interface.
  71 + *
  72 + * @param managedTypes The list of discovered {@link ManagementController} classes.
  73 + */
  74 + void shutdown(List<ManagedType> managedTypes);
  75 +
  76 +}
impl/core/src/main/java/br/gov/frameworkdemoiselle/management/AttributeChangeNotification.java 0 → 100644
@@ -0,0 +1,110 @@ @@ -0,0 +1,110 @@
  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 + * Special notification to denote an attribute has changed values.
  41 + *
  42 + * @see Notification
  43 + *
  44 + * @author serpro
  45 + *
  46 + */
  47 +public class AttributeChangeNotification extends Notification {
  48 +
  49 + private String attributeName;
  50 +
  51 + private Class<? extends Object> attributeType;
  52 +
  53 + private Object oldValue;
  54 +
  55 + private Object newValue;
  56 +
  57 + public AttributeChangeNotification(){}
  58 +
  59 + public AttributeChangeNotification(Object message, String attributeName, Class<? extends Object> attributeType, Object oldValue,
  60 + Object newValue) {
  61 + super(message);
  62 + this.attributeName = attributeName;
  63 + this.attributeType = attributeType;
  64 + this.oldValue = oldValue;
  65 + this.newValue = newValue;
  66 + }
  67 +
  68 +
  69 + public String getAttributeName() {
  70 + return attributeName;
  71 + }
  72 +
  73 +
  74 + public void setAttributeName(String attributeName) {
  75 + this.attributeName = attributeName;
  76 + }
  77 +
  78 +
  79 + public Class<? extends Object> getAttributeType() {
  80 + return attributeType;
  81 + }
  82 +
  83 +
  84 + public void setAttributeType(Class<? extends Object> attributeType) {
  85 + this.attributeType = attributeType;
  86 + }
  87 +
  88 +
  89 + public Object getOldValue() {
  90 + return oldValue;
  91 + }
  92 +
  93 +
  94 + public void setOldValue(Object oldValue) {
  95 + this.oldValue = oldValue;
  96 + }
  97 +
  98 +
  99 + public Object getNewValue() {
  100 + return newValue;
  101 + }
  102 +
  103 +
  104 + public void setNewValue(Object newValue) {
  105 + this.newValue = newValue;
  106 + }
  107 +
  108 +
  109 +
  110 +}
impl/core/src/main/java/br/gov/frameworkdemoiselle/management/Notification.java 0 → 100644
@@ -0,0 +1,77 @@ @@ -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 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 0 → 100644
@@ -0,0 +1,116 @@ @@ -0,0 +1,116 @@
  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 +import java.io.Serializable;
  40 +
  41 +import javax.enterprise.context.ApplicationScoped;
  42 +import javax.enterprise.event.Event;
  43 +import javax.enterprise.event.Observes;
  44 +import javax.enterprise.util.AnnotationLiteral;
  45 +import javax.inject.Inject;
  46 +
  47 +import br.gov.frameworkdemoiselle.internal.management.ManagementNotificationEvent;
  48 +import br.gov.frameworkdemoiselle.internal.management.qualifier.AttributeChange;
  49 +import br.gov.frameworkdemoiselle.internal.management.qualifier.Generic;
  50 +import br.gov.frameworkdemoiselle.util.Beans;
  51 +
  52 +/**
  53 + *
  54 + * <p>Central class to manage sending notifications to management clients.
  55 + * This class allows applications to send management notifications without
  56 + * knowledge of the technology used to send those notifications.</p>
  57 + *
  58 + * <p>To obtain an instance of the {@link NotificationManager} simply inject it in
  59 + * your code using {@link Inject} or the {@link Beans#getReference(Class beanType)} method. The {@link NotificationManager}
  60 + * is {@link ApplicationScoped}, so you can inject it as many times as needed and still have only one instance per application.</p>
  61 + *
  62 + * <p>Implementators of management protocols must observe the {@link ManagementNotificationEvent} event (using the {@link Observes} annotation), this way
  63 + * they will receive an event containing the original notification and can translate this notification to a specific protocol. Optionaly,
  64 + * the implementator can use qualifiers like the {@link Generic} and {@link AttributeChange} qualifiers
  65 + * to filter what king of notifications they will handle. One example of an implementator is the <b>demoiselle-jmx</b> extension.</p>
  66 + *
  67 + * @author serpro
  68 + *
  69 + */
  70 +@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;
  81 +
  82 + /**
  83 + * Sends a generic notification to all management clients.
  84 + *
  85 + * @param notification The notification to send
  86 + */
  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 + }
  95 +
  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 +}
impl/core/src/main/java/br/gov/frameworkdemoiselle/management/annotation/Managed.java
@@ -1,80 +0,0 @@ @@ -1,80 +0,0 @@
1 -/*  
2 - * Demoiselle Framework  
3 - * Copyright (C) 2011 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.annotation;  
38 -  
39 -import static java.lang.annotation.ElementType.TYPE;  
40 -import static java.lang.annotation.RetentionPolicy.RUNTIME;  
41 -  
42 -import java.lang.annotation.Documented;  
43 -import java.lang.annotation.Inherited;  
44 -import java.lang.annotation.Retention;  
45 -import java.lang.annotation.Target;  
46 -  
47 -import javax.enterprise.context.ApplicationScoped;  
48 -import javax.enterprise.inject.Stereotype;  
49 -import javax.enterprise.util.Nonbinding;  
50 -import javax.interceptor.InterceptorBinding;  
51 -  
52 -/**  
53 - * Stereotype to indicate a given class is managed. What it means is that an external client can manage the application  
54 - * this class is in by reading or writing it's attributes and calling it's operations.  
55 - * <p>  
56 - * Only fields annotated with {@link br.gov.frameworkdemoiselle.management.annotation.Property} or  
57 - * methods annotated with {@link br.gov.frameworkdemoiselle.management.annotation.Operation} will be exposed  
58 - * to clients.</p>  
59 - * <p>This stereotype only defines a class as managed, you need to choose an extension that will expose this managed class  
60 - * to external clients using any technology available. One example is the Demoiselle JMX extension, that will expose  
61 - * managed classes as MBeans.</p>  
62 - *  
63 - * @author SERPRO  
64 - */  
65 -@Documented  
66 -@Stereotype  
67 -@InterceptorBinding  
68 -@Inherited  
69 -@Retention(RUNTIME)  
70 -@Target({ TYPE })  
71 -@ApplicationScoped  
72 -public @interface Managed {  
73 -  
74 - /**  
75 - * @return Human readable description of this managed class.  
76 - */  
77 - @Nonbinding  
78 - String description() default "";  
79 -  
80 -}  
impl/core/src/main/java/br/gov/frameworkdemoiselle/management/annotation/Operation.java
@@ -1,73 +0,0 @@ @@ -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.management.annotation;  
38 -  
39 -import java.lang.annotation.Documented;  
40 -import java.lang.annotation.ElementType;  
41 -import java.lang.annotation.Retention;  
42 -import java.lang.annotation.RetentionPolicy;  
43 -import java.lang.annotation.Target;  
44 -  
45 -import javax.enterprise.util.Nonbinding;  
46 -import javax.management.MBeanException;  
47 -  
48 -/**  
49 - * <p>Indicates that a method is an operation, meaning you can manage some aspect of the application by calling it.</p>  
50 - * <p>This annotation can't be used together with {@link Property}, doing so will throw a {@link MBeanException}.</p>  
51 - *  
52 - * @author SERPRO  
53 - *  
54 - */  
55 -@Documented  
56 -@Target({ElementType.METHOD})  
57 -@Retention(RetentionPolicy.RUNTIME)  
58 -public @interface Operation {  
59 -  
60 - /**  
61 - * Description that will be used to publish the operation to clients.  
62 - * Defaults to an empty description.  
63 - */  
64 - @Nonbinding  
65 - String description() default "";  
66 -  
67 - /**  
68 - * Type of operation. Defaults to {@link OperationType#UNKNOWN}.  
69 - */  
70 - @Nonbinding  
71 - OperationType type() default OperationType.UNKNOWN;  
72 -  
73 -}  
impl/core/src/main/java/br/gov/frameworkdemoiselle/management/annotation/OperationParameter.java
@@ -1,73 +0,0 @@ @@ -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.management.annotation;  
38 -  
39 -import java.lang.annotation.Documented;  
40 -import java.lang.annotation.ElementType;  
41 -import java.lang.annotation.Retention;  
42 -import java.lang.annotation.RetentionPolicy;  
43 -import java.lang.annotation.Target;  
44 -  
45 -import javax.enterprise.util.Nonbinding;  
46 -  
47 -/**  
48 - * <p>Optional annotation to write additional detail about an operation's parameter.</p>  
49 - * <p>This annotation is ignored for non-operation methods.</p>  
50 - *  
51 - * @author SERPRO  
52 - *  
53 - */  
54 -@Documented  
55 -@Target({ElementType.PARAMETER})  
56 -@Retention(RetentionPolicy.RUNTIME)  
57 -public @interface OperationParameter {  
58 -  
59 - /**  
60 - * Name that will be used to publish this operation's parameter to clients.  
61 - */  
62 - @Nonbinding  
63 - String name();  
64 -  
65 - /**  
66 - * Optional description that will be used to publish this operation's parameter to clients.  
67 - * Defaults to an empty description.  
68 - */  
69 - @Nonbinding  
70 - String description() default "";  
71 -  
72 -  
73 -}  
impl/core/src/main/java/br/gov/frameworkdemoiselle/management/annotation/OperationType.java
@@ -1,81 +0,0 @@ @@ -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.management.annotation;  
38 -  
39 -import javax.management.MBeanOperationInfo;  
40 -  
41 -  
42 -/**  
43 - * Define the operation type for an operation inside a Managed class.  
44 - *  
45 - *  
46 - * @author SERPRO  
47 - *  
48 - */  
49 -public enum OperationType {  
50 -  
51 - /**  
52 - * Operation is write-only  
53 - */  
54 - ACTION(MBeanOperationInfo.ACTION)  
55 - ,  
56 - /**  
57 - * Operation is read-only  
58 - */  
59 - INFO(MBeanOperationInfo.INFO)  
60 - ,  
61 - /**  
62 - * Operation is read-write  
63 - */  
64 - ACTION_INFO(MBeanOperationInfo.ACTION_INFO)  
65 - ,  
66 - /**  
67 - * Operation is unkown  
68 - */  
69 - UNKNOWN(MBeanOperationInfo.UNKNOWN);  
70 -  
71 - private int operationTypeValue;  
72 -  
73 - private OperationType(int type){  
74 - this.operationTypeValue = type;  
75 - }  
76 -  
77 - public int getValue(){  
78 - return operationTypeValue;  
79 - }  
80 -  
81 -}  
impl/core/src/main/java/br/gov/frameworkdemoiselle/management/annotation/Property.java
@@ -1,69 +0,0 @@ @@ -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.management.annotation;  
38 -  
39 -import java.lang.annotation.Documented;  
40 -import java.lang.annotation.ElementType;  
41 -import java.lang.annotation.Retention;  
42 -import java.lang.annotation.RetentionPolicy;  
43 -import java.lang.annotation.Target;  
44 -  
45 -import javax.enterprise.util.Nonbinding;  
46 -  
47 -/**  
48 - * <p>Indicates that a field must be exposed as a property to management clients.</p>  
49 - * <p>The property will be writable if there's a public setter method  
50 - * declared for the field and readable if there's a getter method.</p>  
51 - * <p>It's a runtime error to annotate a field with no getter and no setter method.</p>  
52 - * <p>It's also a runtime error to declare a field as a property and one or both of it's getter and setter  
53 - * methods as an operation using the {@link Operation} annotation.</p>  
54 - *  
55 - * @author SERPRO  
56 - *  
57 - */  
58 -@Documented  
59 -@Target({ElementType.FIELD})  
60 -@Retention(RetentionPolicy.RUNTIME)  
61 -public @interface Property {  
62 -  
63 - /**  
64 - * @return The description of this property exposed to management clients.  
65 - */  
66 - @Nonbinding  
67 - String description() default "";  
68 -  
69 -}  
impl/core/src/main/java/br/gov/frameworkdemoiselle/management/annotation/validation/AllowedValues.java
@@ -1,76 +0,0 @@ @@ -1,76 +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.annotation.validation;  
38 -  
39 -import static java.lang.annotation.ElementType.FIELD;  
40 -import static java.lang.annotation.RetentionPolicy.RUNTIME;  
41 -  
42 -import java.lang.annotation.Documented;  
43 -import java.lang.annotation.Retention;  
44 -import java.lang.annotation.Target;  
45 -  
46 -import javax.validation.Constraint;  
47 -  
48 -import br.gov.frameworkdemoiselle.management.internal.validators.AllowedValuesValidator;  
49 -  
50 -@Documented  
51 -@Target({ FIELD})  
52 -@Retention(RUNTIME)  
53 -@Constraint(validatedBy = AllowedValuesValidator.class)  
54 -/**  
55 - * Validate a value against a list of allowed values.  
56 - *  
57 - * @author serpro  
58 - *  
59 - */  
60 -public @interface AllowedValues {  
61 -  
62 - /**  
63 - * List of accepted values  
64 - */  
65 - String[] allows();  
66 -  
67 - /**  
68 - * Type of allowed values. Defaults to {@link ValueType#STRING}.  
69 - */  
70 - ValueType valueType() default ValueType.STRING;  
71 -  
72 - enum ValueType {  
73 - STRING,INTEGER,DECIMAL;  
74 - }  
75 -  
76 -}  
impl/core/src/main/java/br/gov/frameworkdemoiselle/management/extension/ManagementExtension.java
@@ -1,56 +0,0 @@ @@ -1,56 +0,0 @@
1 -/*  
2 - * Demoiselle Framework  
3 - * Copyright (C) 2010 SERPRO  
4 - * ----------------------------------------------------------------------------  
5 - * This file is part of Demoiselle Framework.  
6 - *  
7 - * Demoiselle Framework is free software; you can redistribute it and/or  
8 - * modify it under the terms of the GNU Lesser General Public License version 3  
9 - * as published by the Free Software Foundation.  
10 - *  
11 - * This program is distributed in the hope that it will be useful,  
12 - * but WITHOUT ANY WARRANTY; without even the implied warranty of  
13 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  
14 - * GNU General Public License for more details.  
15 - *  
16 - * You should have received a copy of the GNU Lesser General Public License version 3  
17 - * along with this program; if not, see <http://www.gnu.org/licenses/>  
18 - * or write to the Free Software Foundation, Inc., 51 Franklin Street,  
19 - * Fifth Floor, Boston, MA 02110-1301, USA.  
20 - * ----------------------------------------------------------------------------  
21 - * Este arquivo é parte do Framework Demoiselle.  
22 - *  
23 - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou  
24 - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação  
25 - * do Software Livre (FSF).  
26 - *  
27 - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA  
28 - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou  
29 - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português  
30 - * para maiores detalhes.  
31 - *  
32 - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título  
33 - * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>  
34 - * ou escreva para a Fundação do Software Livre (FSF) Inc.,  
35 - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.  
36 - */  
37 -package br.gov.frameworkdemoiselle.management.extension;  
38 -  
39 -import java.util.List;  
40 -  
41 -import br.gov.frameworkdemoiselle.management.internal.ManagedType;  
42 -  
43 -/**  
44 - *  
45 - * Define an entry point for monitoring extension.  
46 - *  
47 - * @author serpro  
48 - *  
49 - */  
50 -public interface ManagementExtension {  
51 -  
52 - void initialize(List<ManagedType> managedTypes);  
53 -  
54 - void shutdown(List<ManagedType> managedTypes);  
55 -  
56 -}  
impl/core/src/main/java/br/gov/frameworkdemoiselle/management/internal/ManagedType.java
@@ -1,331 +0,0 @@ @@ -1,331 +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.internal;  
38 -  
39 -import java.lang.annotation.Annotation;  
40 -import java.lang.reflect.Field;  
41 -import java.lang.reflect.Method;  
42 -import java.util.TreeMap;  
43 -  
44 -import br.gov.frameworkdemoiselle.DemoiselleException;  
45 -import br.gov.frameworkdemoiselle.internal.producer.ResourceBundleProducer;  
46 -import br.gov.frameworkdemoiselle.management.annotation.Managed;  
47 -import br.gov.frameworkdemoiselle.management.annotation.Operation;  
48 -import br.gov.frameworkdemoiselle.management.annotation.OperationParameter;  
49 -import br.gov.frameworkdemoiselle.management.annotation.Property;  
50 -import br.gov.frameworkdemoiselle.util.ResourceBundle;  
51 -  
52 -/**  
53 - * Represents a detected managed type, a Java class annotated with {@link Managed}.  
54 - *  
55 - * @author serpro  
56 - */  
57 -public class ManagedType {  
58 -  
59 - private Class<?> type;  
60 -  
61 - private TreeMap<String, FieldDetail> fields;  
62 -  
63 - private TreeMap<String, MethodDetail> operationMethods;  
64 -  
65 - private ResourceBundle bundle;  
66 -  
67 - private String description;  
68 -  
69 - public ManagedType(Class<?> type) {  
70 - bundle = ResourceBundleProducer.create("demoiselle-core-bundle");  
71 -  
72 - if (type == null) {  
73 - throw new DemoiselleException(bundle.getString("management-null-class-defined"));  
74 - }  
75 - if (!type.isAnnotationPresent(Managed.class)) {  
76 - throw new DemoiselleException(bundle.getString("management-no-annotation-found", type.getCanonicalName()));  
77 - }  
78 -  
79 - this.type = type;  
80 - fields = new TreeMap<String, FieldDetail>();  
81 - operationMethods = new TreeMap<String, MethodDetail>();  
82 - this.description = type.getAnnotation(Managed.class).description();  
83 -  
84 - initialize();  
85 - }  
86 -  
87 - public Class<?> getType() {  
88 - return type;  
89 - }  
90 -  
91 - public String getDescription() {  
92 - return description;  
93 - }  
94 -  
95 - public TreeMap<String, FieldDetail> getFields() {  
96 - return fields;  
97 - }  
98 -  
99 - public TreeMap<String, MethodDetail> getOperationMethods() {  
100 - return operationMethods;  
101 - }  
102 -  
103 - private void initialize() {  
104 - // Para cada atributo verifica se ele está anotado com Property e extrai as informações dele (método get, set e  
105 - // descrição do atributo).  
106 - Field[] fields = type.getDeclaredFields();  
107 - if (fields != null) {  
108 - for (Field field : fields) {  
109 - if (field.isAnnotationPresent(Property.class)) {  
110 - // Obtém os métodos GET e SET para esta propriedade  
111 - Method getterMethod = getGetterMethod(field);  
112 - Method setterMethod = getSetterMethod(field);  
113 - if (getterMethod == null && setterMethod == null) {  
114 - throw new DemoiselleException(bundle.getString("management-invalid-property-no-getter-setter",  
115 - type.getSimpleName(), field.getName()));  
116 - } else if ((getterMethod != null && getterMethod.isAnnotationPresent(Operation.class))  
117 - || (setterMethod != null && setterMethod.isAnnotationPresent(Operation.class))) {  
118 - throw new DemoiselleException(bundle.getString("management-invalid-property-as-operation",  
119 - type.getSimpleName()));  
120 - }  
121 -  
122 - String propertyDescription = field.getAnnotation(Property.class).description();  
123 -  
124 - this.fields.put(field.getName(), new FieldDetail(field, propertyDescription, getterMethod,  
125 - setterMethod));  
126 - }  
127 - }  
128 - }  
129 -  
130 - // Para cada metodo verifica se ele está anotado com Operation e cria um MBeanOperationInfo para ele.  
131 - Method[] methodList = type.getMethods();  
132 - if (methodList != null) {  
133 - for (Method method : methodList) {  
134 - Operation opAnnotation = method.getAnnotation(Operation.class);  
135 -  
136 - if (opAnnotation != null) {  
137 - // Lemos as informações sobre o método e criamos uma instância  
138 - // de MethodDetail para representar este método como uma  
139 - // operação.  
140 -  
141 - Class<?>[] parameterTypes = method.getParameterTypes();  
142 - Annotation[][] parameterAnnotations = method.getParameterAnnotations();  
143 - ParameterDetail[] parameterDetails = new ParameterDetail[parameterTypes.length];  
144 -  
145 - for (int i = 0; i < parameterTypes.length; i++) {  
146 - OperationParameter paramAnnotation = null;  
147 - for (Annotation annotation : parameterAnnotations[i]) {  
148 - if (annotation.annotationType() == OperationParameter.class) {  
149 - paramAnnotation = (OperationParameter) annotation;  
150 - break;  
151 - }  
152 - }  
153 -  
154 - String name = paramAnnotation != null ? paramAnnotation.name() : ("arg" + i);  
155 - String description = paramAnnotation != null ? paramAnnotation.description() : null;  
156 -  
157 - parameterDetails[i] = new ParameterDetail(parameterTypes[i], name, description);  
158 - }  
159 -  
160 - // Com todas as informações, criamos nossa instância de MethodDetail e  
161 - // acrescentamos na lista de todas as operações.  
162 - MethodDetail detail = new MethodDetail(method, opAnnotation.description(), parameterDetails);  
163 - operationMethods.put(method.getName(), detail);  
164 - }  
165 - }  
166 - }  
167 - }  
168 -  
169 - /**  
170 - * Returns the public getter method for a given field, or <code>null</code> if no getter method can be found.  
171 - */  
172 - private Method getGetterMethod(Field field) {  
173 - StringBuffer getterMethodName = new StringBuffer()  
174 - .append("get")  
175 - .append(field.getName().substring(0, 1).toUpperCase())  
176 - .append(field.getName().substring(1));  
177 -  
178 - Method getterMethod;  
179 -  
180 - try {  
181 - getterMethod = type.getMethod(getterMethodName.toString());  
182 - } catch (Exception e) {  
183 - getterMethod = null;  
184 - }  
185 -  
186 - // Se atributo for boolean, procura método getter no formato "isAttribute".  
187 - if (getterMethod == null  
188 - && (Boolean.TYPE.isAssignableFrom(field.getType()) || Boolean.class.isAssignableFrom(field.getType()))) {  
189 - // Boolean.TYPE representa o tipo primitivo "boolean", Boolean.class é a classe wrapper.  
190 - getterMethodName = new StringBuffer()  
191 - .append("is")  
192 - .append(field.getName().substring(0, 1).toUpperCase())  
193 - .append(field.getName().substring(1).toUpperCase());  
194 -  
195 - try {  
196 - getterMethod = type.getMethod(getterMethodName.toString());  
197 - } catch (Exception e) {  
198 - getterMethod = null;  
199 - }  
200 - }  
201 -  
202 - return getterMethod;  
203 - }  
204 -  
205 - /**  
206 - * Returns the public setter method for a given field, or <code>null</code> if no setter method can be found.  
207 - */  
208 - private Method getSetterMethod(Field field) {  
209 - StringBuffer setterMethodName = new StringBuffer()  
210 - .append("set")  
211 - .append(field.getName().substring(0, 1).toUpperCase())  
212 - .append(field.getName().substring(1));  
213 -  
214 - Method setterMethod;  
215 -  
216 - try {  
217 - setterMethod = type.getMethod(setterMethodName.toString() , field.getType());  
218 - } catch (Exception e) {  
219 - setterMethod = null;  
220 - }  
221 -  
222 - return setterMethod;  
223 - }  
224 -  
225 - public final class FieldDetail {  
226 -  
227 - private final Field field;  
228 -  
229 - private final String description;  
230 -  
231 - private Method getterMethod;  
232 -  
233 - private Method setterMethod;  
234 -  
235 - public FieldDetail(Field field, String description, Method getterMethod, Method setterMethod) {  
236 - super();  
237 - this.field = field;  
238 - this.description = description;  
239 - this.getterMethod = getterMethod;  
240 - this.setterMethod = setterMethod;  
241 - }  
242 -  
243 - public Field getField() {  
244 - return field;  
245 - }  
246 -  
247 - public String getDescription() {  
248 - return description;  
249 - }  
250 -  
251 - public Method getGetterMethod() {  
252 - return getterMethod;  
253 - }  
254 -  
255 - public Method getSetterMethod() {  
256 - return setterMethod;  
257 - }  
258 -  
259 - }  
260 -  
261 - public final class MethodDetail {  
262 -  
263 - private final Method method;  
264 -  
265 - private final ParameterDetail[] parameterTypers;  
266 -  
267 - private String description;  
268 -  
269 - public MethodDetail(Method method, String description, ParameterDetail[] parameterTypers) {  
270 - super();  
271 - this.method = method;  
272 - this.description = description;  
273 - this.parameterTypers = parameterTypers;  
274 - }  
275 -  
276 - public Method getMethod() {  
277 - return method;  
278 - }  
279 -  
280 - public ParameterDetail[] getParameterTypers() {  
281 - return parameterTypers;  
282 - }  
283 -  
284 - public String getDescription() {  
285 - return description;  
286 - }  
287 -  
288 - }  
289 -  
290 - public final class ParameterDetail {  
291 -  
292 - private final Class<?> parameterType;  
293 -  
294 - private final String parameterName;  
295 -  
296 - private final String parameterDescription;  
297 -  
298 - public ParameterDetail(Class<?> parameterType, String parameterName, String parameterDescription) {  
299 - super();  
300 - this.parameterType = parameterType;  
301 - this.parameterName = parameterName;  
302 - this.parameterDescription = parameterDescription;  
303 - }  
304 -  
305 - public Class<?> getParameterType() {  
306 - return parameterType;  
307 - }  
308 -  
309 - public String getParameterName() {  
310 - return parameterName;  
311 - }  
312 -  
313 - public String getParameterDescription() {  
314 - return parameterDescription;  
315 - }  
316 - }  
317 -  
318 - /**  
319 - * Indicates another {@link ManagedType} represents the same {@link Class} as this one. This method also supports a  
320 - * {@link Class} as a parameter, in this case it will return <code>true</code> if the passed class is exactly the  
321 - * same Java class represented by this {@link ManagedType}.  
322 - */  
323 - @Override  
324 - public boolean equals(Object other) {  
325 - if (other == null) {  
326 - return false;  
327 - }  
328 -  
329 - return ((ManagedType) other).getType().getCanonicalName().equals(this.getType().getCanonicalName());  
330 - }  
331 -}  
impl/core/src/main/java/br/gov/frameworkdemoiselle/management/internal/MonitoringManager.java
@@ -1,311 +0,0 @@ @@ -1,311 +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.internal;  
38 -  
39 -import java.lang.reflect.Method;  
40 -import java.util.ArrayList;  
41 -import java.util.Collection;  
42 -import java.util.List;  
43 -  
44 -import javax.enterprise.context.ApplicationScoped;  
45 -import javax.enterprise.context.RequestScoped;  
46 -import javax.inject.Inject;  
47 -import javax.management.ReflectionException;  
48 -  
49 -import org.slf4j.Logger;  
50 -  
51 -import br.gov.frameworkdemoiselle.DemoiselleException;  
52 -import br.gov.frameworkdemoiselle.annotation.Name;  
53 -import br.gov.frameworkdemoiselle.internal.context.ContextManager;  
54 -import br.gov.frameworkdemoiselle.internal.context.ManagedContext;  
55 -import br.gov.frameworkdemoiselle.management.annotation.Managed;  
56 -import br.gov.frameworkdemoiselle.management.annotation.Property;  
57 -import br.gov.frameworkdemoiselle.management.extension.ManagementExtension;  
58 -import br.gov.frameworkdemoiselle.management.internal.ManagedType.MethodDetail;  
59 -import br.gov.frameworkdemoiselle.management.notification.AttributeChangeNotification;  
60 -import br.gov.frameworkdemoiselle.management.notification.NotificationManager;  
61 -import br.gov.frameworkdemoiselle.util.Beans;  
62 -import br.gov.frameworkdemoiselle.util.ResourceBundle;  
63 -  
64 -/**  
65 - * A manager that helps implementators of the management framework to obtain a  
66 - * list of managed classes, set or obtain values from them or invoke operations  
67 - * over them.  
68 - *  
69 - * @author serpro  
70 - */  
71 -@ApplicationScoped  
72 -public class MonitoringManager {  
73 -  
74 - @Inject  
75 - private Logger logger;  
76 -  
77 - @Inject  
78 - @Name("demoiselle-core-bundle")  
79 - private ResourceBundle bundle;  
80 -  
81 - private final List<ManagedType> managedTypes = new ArrayList<ManagedType>();  
82 -  
83 - public void addManagedType(ManagedType managedType) {  
84 - managedTypes.add(managedType);  
85 - logger.debug(bundle.getString("management-debug-registering-managed-type",managedType.getType().getCanonicalName()));  
86 - }  
87 -  
88 - /**  
89 - * @return A list all managed types, classes annotated with {@link Managed}.  
90 - * The returned list is a shallow copy of the internal list, so you  
91 - * are free to modify it.  
92 - *  
93 - * TODO precisamos desse clone na lista?  
94 - */  
95 - public List<ManagedType> getManagedTypes() {  
96 - ArrayList<ManagedType> cloneList = new ArrayList<ManagedType>();  
97 - cloneList.addAll(managedTypes);  
98 - return cloneList;  
99 - }  
100 -  
101 - /**  
102 - * <p>Invoke an operation over a managed type.</p>  
103 - *  
104 - * <p>This method is not thread-safe, it's the user's responsibility to  
105 - * make the operations of the managed type synchronized if necessary.</p>  
106 - *  
107 - * @param managedType  
108 - * A type annotated with {@link Managed}. This method will create  
109 - * an (or obtain an already created) instance of this type and  
110 - * invoke the operation over it.  
111 - * @param actionName  
112 - * Name of method to be invoked, the type must have this  
113 - * operation on it's list  
114 - * @param params  
115 - * List of values for the operation parameters. Can be  
116 - * <code>null</code> if the operation require no parameters.  
117 - * @return The return value of the original invoked operation. Methods of  
118 - * return type <code>void</code> will return the {@link Void} type.  
119 - * @throws ReflectionException  
120 - * In case the operation doesn't exist or have a different  
121 - * signature  
122 - */  
123 - public Object invoke(ManagedType managedType, String actionName,  
124 - Object[] params) {  
125 - if ( managedTypes.contains(managedType) ) {  
126 - activateContexts(managedType.getType());  
127 -  
128 - Object delegate = Beans.getReference(managedType.getType());  
129 -  
130 - MethodDetail method = managedType.getOperationMethods().get(actionName);  
131 -  
132 - if (method != null) {  
133 - try {  
134 - logger.debug(bundle  
135 - .getString("management-debug-invoking-operation",actionName,managedType.getType().getCanonicalName()));  
136 - return method.getMethod().invoke(delegate, params);  
137 - } catch (Exception e) {  
138 - throw new DemoiselleException(bundle.getString(  
139 - "management-invoke-error", actionName), e);  
140 - } finally {  
141 - deactivateContexts(managedType.getType());  
142 - }  
143 - } else {  
144 - throw new DemoiselleException(bundle.getString(  
145 - "management-invoke-error", actionName));  
146 - }  
147 - } else {  
148 - throw new DemoiselleException(  
149 - bundle.getString("management-type-not-found"));  
150 - }  
151 - }  
152 -  
153 - /**  
154 - * <p>Retrieve the current value of a property from a managed type. Properties  
155 - * are attributes annotated with {@link Property}.</p>  
156 - *  
157 - * <p>This method is not thread-safe, it's the user's responsibility to  
158 - * create the property's access methods from the managed type synchronized if necessary.</p>  
159 - *  
160 - * @param managedType The type that has the property the client wants to know the value of.  
161 - * @param propertyName The name of the property  
162 - * @return The current value of the property  
163 - */  
164 - public Object getProperty(ManagedType managedType, String propertyName) {  
165 -  
166 - if ( managedTypes.contains(managedType) ) {  
167 - Method getterMethod = managedType.getFields().get(propertyName).getGetterMethod();  
168 -  
169 - if (getterMethod != null) {  
170 - logger.debug(bundle.getString(  
171 - "management-debug-acessing-property", getterMethod  
172 - .getName(), managedType.getType().getCanonicalName()));  
173 -  
174 - activateContexts(managedType.getType());  
175 -  
176 - try {  
177 - Object delegate = Beans.getReference(managedType.getType());  
178 -  
179 - return getterMethod.invoke(delegate, (Object[]) null);  
180 - } catch (Exception e) {  
181 - throw new DemoiselleException(bundle.getString(  
182 - "management-invoke-error", getterMethod.getName()),  
183 - e);  
184 - } finally {  
185 - deactivateContexts(managedType.getType());  
186 - }  
187 - } else {  
188 - throw new DemoiselleException(bundle.getString(  
189 - "management-invoke-error", propertyName));  
190 - }  
191 - } else {  
192 - throw new DemoiselleException(  
193 - bundle.getString("management-type-not-found"));  
194 - }  
195 - }  
196 -  
197 - /**  
198 - * <p>Sets a new value for a property contained inside a managed type. A property  
199 - * is an attribute annotated with {@link Property}.</p>  
200 - *  
201 - * <p>This method is not thread-safe, it's the user's responsibility to  
202 - * create the property's access methods from the managed type synchronized if necessary.</p>  
203 - *  
204 - * @param managedType The type that has access to the property  
205 - * @param propertyName The name of the property  
206 - * @param newValue The new value of the property  
207 - */  
208 - public void setProperty(ManagedType managedType, String propertyName,  
209 - Object newValue) {  
210 -  
211 - if ( managedTypes.contains(managedType) ) {  
212 - // Procura o método set do atributo em questão  
213 - Method method = managedType.getFields().get(propertyName).getSetterMethod();  
214 - if (method != null) {  
215 - logger.debug(bundle.getString(  
216 - "management-debug-setting-property", method.getName(),  
217 - managedType.getType().getCanonicalName()));  
218 -  
219 - // Obtém uma instância da classe gerenciada, lembrando que  
220 - // classes  
221 - // anotadas com @Managed são sempre singletons.  
222 - activateContexts(managedType.getType());  
223 - try {  
224 - Object delegate = Beans.getReference(managedType.getType());  
225 -  
226 - Method getterMethod = managedType.getFields().get(propertyName).getGetterMethod();  
227 - Object oldValue;  
228 - try{  
229 - oldValue = getterMethod.invoke(delegate, (Object[])null);  
230 - }  
231 - catch(Exception e){  
232 - oldValue = null;  
233 - }  
234 -  
235 - method.invoke(delegate, new Object[] { newValue });  
236 -  
237 - //Manda uma notificação de mudança de atributo  
238 - NotificationManager notificationManager = Beans.getReference(NotificationManager.class);  
239 - Class<? extends Object> attributeType = newValue!=null ? newValue.getClass() : null;  
240 -  
241 - AttributeChangeNotification notification = new AttributeChangeNotification(bundle.getString("management-notification-attribute-changed",propertyName,managedType.getType().getCanonicalName())  
242 - , propertyName  
243 - , attributeType  
244 - , oldValue  
245 - , newValue);  
246 - notificationManager.sendNotification(notification);  
247 -  
248 - } catch (Exception e) {  
249 - throw new DemoiselleException(bundle.getString(  
250 - "management-invoke-error", method.getName()), e);  
251 - } finally {  
252 - deactivateContexts(managedType.getType());  
253 - }  
254 -  
255 - } else {  
256 - throw new DemoiselleException(bundle.getString(  
257 - "management-invoke-error", propertyName));  
258 - }  
259 - } else {  
260 - throw new DemoiselleException(  
261 - bundle.getString("management-type-not-found"));  
262 - }  
263 -  
264 - }  
265 -  
266 - private void activateContexts(Class<?> managedType) {  
267 - logger.debug(bundle.getString("management-debug-starting-custom-context",  
268 - ManagedContext.class.getCanonicalName(),  
269 - managedType.getCanonicalName()));  
270 -  
271 - ContextManager.activate(ManagedContext.class,RequestScoped.class);  
272 - }  
273 -  
274 - private void deactivateContexts(Class<?> managedType) {  
275 - logger.debug(bundle.getString("management-debug-stoping-custom-context",  
276 - ManagedContext.class.getCanonicalName(),  
277 - managedType.getCanonicalName()));  
278 -  
279 - ContextManager.deactivate(ManagedContext.class,RequestScoped.class);  
280 - }  
281 -  
282 - public void shutdown(Collection<Class<? extends ManagementExtension>> monitoringExtensions) {  
283 -  
284 - for (Class<? extends ManagementExtension> monitoringExtensionClass : monitoringExtensions) {  
285 -  
286 - ManagementExtension monitoringExtension = Beans.getReference(monitoringExtensionClass);  
287 -  
288 - monitoringExtension.shutdown(this.getManagedTypes());  
289 -  
290 - logger.debug( bundle.getString("management-debug-removing-management-extension",monitoringExtension.getClass().getCanonicalName()) );  
291 -  
292 - }  
293 -  
294 - }  
295 -  
296 - public void initialize(Collection<Class<? extends ManagementExtension>> monitoringExtensions) {  
297 -  
298 - for (Class<? extends ManagementExtension> monitoringExtensionClass : monitoringExtensions) {  
299 -  
300 - ManagementExtension monitoringExtension = Beans  
301 - .getReference(monitoringExtensionClass);  
302 -  
303 - monitoringExtension.initialize(this.getManagedTypes());  
304 -  
305 - logger.debug( bundle.getString("management-debug-processing-management-extension",monitoringExtension.getClass().getCanonicalName()) );  
306 -  
307 - }  
308 -  
309 - }  
310 -  
311 -}  
impl/core/src/main/java/br/gov/frameworkdemoiselle/management/internal/notification/event/NotificationEvent.java
@@ -1,65 +0,0 @@ @@ -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.management.internal.notification.event;  
38 -  
39 -import br.gov.frameworkdemoiselle.management.notification.Notification;  
40 -import br.gov.frameworkdemoiselle.management.notification.NotificationManager;  
41 -  
42 -/**  
43 - * Event fired when a notification is sent by {@link NotificationManager}.  
44 - * Implementators can capture this event and by notified when the {@link NotificationManager}  
45 - * sends notifications, so they can pass the notification to a underlying protocol such as JMX.  
46 - *  
47 - * @author serpro  
48 - *  
49 - */  
50 -public class NotificationEvent {  
51 -  
52 - private Notification notification;  
53 -  
54 - public NotificationEvent(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/management/internal/notification/qualifier/AttributeChange.java
@@ -1,62 +0,0 @@ @@ -1,62 +0,0 @@
1 -/*  
2 - * Demoiselle Framework  
3 - * Copyright (C) 2010 SERPRO  
4 - * ----------------------------------------------------------------------------  
5 - * This file is part of Demoiselle Framework.  
6 - *  
7 - * Demoiselle Framework is free software; you can redistribute it and/or  
8 - * modify it under the terms of the GNU Lesser General Public License version 3  
9 - * as published by the Free Software Foundation.  
10 - *  
11 - * This program is distributed in the hope that it will be useful,  
12 - * but WITHOUT ANY WARRANTY; without even the implied warranty of  
13 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  
14 - * GNU General Public License for more details.  
15 - *  
16 - * You should have received a copy of the GNU Lesser General Public License version 3  
17 - * along with this program; if not, see <http://www.gnu.org/licenses/>  
18 - * or write to the Free Software Foundation, Inc., 51 Franklin Street,  
19 - * Fifth Floor, Boston, MA 02110-1301, USA.  
20 - * ----------------------------------------------------------------------------  
21 - * Este arquivo é parte do Framework Demoiselle.  
22 - *  
23 - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou  
24 - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação  
25 - * do Software Livre (FSF).  
26 - *  
27 - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA  
28 - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou  
29 - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português  
30 - * para maiores detalhes.  
31 - *  
32 - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título  
33 - * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>  
34 - * ou escreva para a Fundação do Software Livre (FSF) Inc.,  
35 - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.  
36 - */  
37 -package br.gov.frameworkdemoiselle.management.internal.notification.qualifier;  
38 -  
39 -import java.lang.annotation.ElementType;  
40 -import java.lang.annotation.Retention;  
41 -import java.lang.annotation.RetentionPolicy;  
42 -import java.lang.annotation.Target;  
43 -  
44 -import javax.inject.Qualifier;  
45 -  
46 -import br.gov.frameworkdemoiselle.management.internal.notification.event.NotificationEvent;  
47 -import br.gov.frameworkdemoiselle.management.notification.AttributeChangeNotification;  
48 -  
49 -/**  
50 - *  
51 - * Enables {@link NotificationEvent} observers to trigger only with notifications  
52 - * of the specialized type {@link AttributeChangeNotification}.  
53 - *  
54 - * @author serpro  
55 - *  
56 - */  
57 -@Qualifier  
58 -@Retention(RetentionPolicy.RUNTIME)  
59 -@Target({ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER, ElementType.TYPE})  
60 -public @interface AttributeChange {  
61 -  
62 -}  
impl/core/src/main/java/br/gov/frameworkdemoiselle/management/internal/notification/qualifier/Generic.java
@@ -1,62 +0,0 @@ @@ -1,62 +0,0 @@
1 -/*  
2 - * Demoiselle Framework  
3 - * Copyright (C) 2010 SERPRO  
4 - * ----------------------------------------------------------------------------  
5 - * This file is part of Demoiselle Framework.  
6 - *  
7 - * Demoiselle Framework is free software; you can redistribute it and/or  
8 - * modify it under the terms of the GNU Lesser General Public License version 3  
9 - * as published by the Free Software Foundation.  
10 - *  
11 - * This program is distributed in the hope that it will be useful,  
12 - * but WITHOUT ANY WARRANTY; without even the implied warranty of  
13 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  
14 - * GNU General Public License for more details.  
15 - *  
16 - * You should have received a copy of the GNU Lesser General Public License version 3  
17 - * along with this program; if not, see <http://www.gnu.org/licenses/>  
18 - * or write to the Free Software Foundation, Inc., 51 Franklin Street,  
19 - * Fifth Floor, Boston, MA 02110-1301, USA.  
20 - * ----------------------------------------------------------------------------  
21 - * Este arquivo é parte do Framework Demoiselle.  
22 - *  
23 - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou  
24 - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação  
25 - * do Software Livre (FSF).  
26 - *  
27 - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA  
28 - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou  
29 - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português  
30 - * para maiores detalhes.  
31 - *  
32 - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título  
33 - * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/>  
34 - * ou escreva para a Fundação do Software Livre (FSF) Inc.,  
35 - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA.  
36 - */  
37 -package br.gov.frameworkdemoiselle.management.internal.notification.qualifier;  
38 -  
39 -import java.lang.annotation.ElementType;  
40 -import java.lang.annotation.Retention;  
41 -import java.lang.annotation.RetentionPolicy;  
42 -import java.lang.annotation.Target;  
43 -  
44 -import javax.inject.Qualifier;  
45 -  
46 -import br.gov.frameworkdemoiselle.management.internal.notification.event.NotificationEvent;  
47 -import br.gov.frameworkdemoiselle.management.notification.Notification;  
48 -  
49 -/**  
50 - *  
51 - * Enables {@link NotificationEvent} observers to trigger only with notifications  
52 - * of the base type {@link Notification}.  
53 - *  
54 - * @author serpro  
55 - *  
56 - */  
57 -@Qualifier  
58 -@Retention(RetentionPolicy.RUNTIME)  
59 -@Target({ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER, ElementType.TYPE})  
60 -public @interface Generic {  
61 -  
62 -}  
impl/core/src/main/java/br/gov/frameworkdemoiselle/management/internal/validators/AllowedValuesValidator.java
@@ -1,104 +0,0 @@ @@ -1,104 +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.internal.validators;  
38 -  
39 -import java.math.BigDecimal;  
40 -  
41 -import javax.validation.ConstraintValidator;  
42 -import javax.validation.ConstraintValidatorContext;  
43 -  
44 -import br.gov.frameworkdemoiselle.management.annotation.validation.AllowedValues;  
45 -  
46 -  
47 -public class AllowedValuesValidator implements ConstraintValidator<AllowedValues, Object> {  
48 -  
49 - private br.gov.frameworkdemoiselle.management.annotation.validation.AllowedValues.ValueType valueType;  
50 - private String[] allowedValues;  
51 -  
52 - @Override  
53 - public void initialize(AllowedValues constraintAnnotation) {  
54 - valueType = constraintAnnotation.valueType();  
55 - allowedValues = constraintAnnotation.allows();  
56 - }  
57 -  
58 - @Override  
59 - public boolean isValid(Object value, ConstraintValidatorContext context) {  
60 -  
61 - if (value==null){  
62 - return false;  
63 - }  
64 -  
65 - switch(valueType){  
66 - case STRING:  
67 - for (String str : allowedValues){  
68 - if (str.equals(value)) return true;  
69 - }  
70 - return false;  
71 -  
72 - case INTEGER:  
73 - try{  
74 - Integer number = Integer.valueOf(value.toString());  
75 - String strNumber = number.toString();  
76 - for (String str : allowedValues){  
77 - if (str.equals(strNumber)) return true;  
78 - }  
79 -  
80 - return false;  
81 - }  
82 - catch(NumberFormatException ne){  
83 - return false;  
84 - }  
85 -  
86 - case DECIMAL:  
87 - try{  
88 - BigDecimal number = new BigDecimal(value.toString());  
89 - String strNumber = number.toString();  
90 - for (String str : allowedValues){  
91 - if (str.equals(strNumber)) return true;  
92 - }  
93 - }  
94 - catch(NumberFormatException ne){  
95 - return false;  
96 - }  
97 -  
98 - return false;  
99 - }  
100 -  
101 - return false;  
102 - }  
103 -  
104 -}  
impl/core/src/main/java/br/gov/frameworkdemoiselle/management/notification/AttributeChangeNotification.java
@@ -1,110 +0,0 @@ @@ -1,110 +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.notification;  
38 -  
39 -/**  
40 - * Special notification to denote an attribute has changed values.  
41 - *  
42 - * @see Notification  
43 - *  
44 - * @author serpro  
45 - *  
46 - */  
47 -public class AttributeChangeNotification extends Notification {  
48 -  
49 - private String attributeName;  
50 -  
51 - private Class<? extends Object> attributeType;  
52 -  
53 - private Object oldValue;  
54 -  
55 - private Object newValue;  
56 -  
57 - public AttributeChangeNotification(){}  
58 -  
59 - public AttributeChangeNotification(Object message, String attributeName, Class<? extends Object> attributeType, Object oldValue,  
60 - Object newValue) {  
61 - super(message);  
62 - this.attributeName = attributeName;  
63 - this.attributeType = attributeType;  
64 - this.oldValue = oldValue;  
65 - this.newValue = newValue;  
66 - }  
67 -  
68 -  
69 - public String getAttributeName() {  
70 - return attributeName;  
71 - }  
72 -  
73 -  
74 - public void setAttributeName(String attributeName) {  
75 - this.attributeName = attributeName;  
76 - }  
77 -  
78 -  
79 - public Class<? extends Object> getAttributeType() {  
80 - return attributeType;  
81 - }  
82 -  
83 -  
84 - public void setAttributeType(Class<? extends Object> attributeType) {  
85 - this.attributeType = attributeType;  
86 - }  
87 -  
88 -  
89 - public Object getOldValue() {  
90 - return oldValue;  
91 - }  
92 -  
93 -  
94 - public void setOldValue(Object oldValue) {  
95 - this.oldValue = oldValue;  
96 - }  
97 -  
98 -  
99 - public Object getNewValue() {  
100 - return newValue;  
101 - }  
102 -  
103 -  
104 - public void setNewValue(Object newValue) {  
105 - this.newValue = newValue;  
106 - }  
107 -  
108 -  
109 -  
110 -}  
impl/core/src/main/java/br/gov/frameworkdemoiselle/management/notification/Notification.java
@@ -1,77 +0,0 @@ @@ -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.notification;  
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/notification/NotificationManager.java
@@ -1,116 +0,0 @@ @@ -1,116 +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.notification;  
38 -  
39 -import java.io.Serializable;  
40 -  
41 -import javax.enterprise.context.ApplicationScoped;  
42 -import javax.enterprise.event.Event;  
43 -import javax.enterprise.event.Observes;  
44 -import javax.enterprise.util.AnnotationLiteral;  
45 -import javax.inject.Inject;  
46 -  
47 -import br.gov.frameworkdemoiselle.management.internal.notification.event.NotificationEvent;  
48 -import br.gov.frameworkdemoiselle.management.internal.notification.qualifier.AttributeChange;  
49 -import br.gov.frameworkdemoiselle.management.internal.notification.qualifier.Generic;  
50 -import br.gov.frameworkdemoiselle.util.Beans;  
51 -  
52 -/**  
53 - *  
54 - * <p>Central class to manage sending notifications to management clients.  
55 - * This class allows applications to send management notifications without  
56 - * knowledge of the technology used to send those notifications.</p>  
57 - *  
58 - * <p>To obtain an instance of the {@link NotificationManager} simply inject it in  
59 - * your code using {@link Inject} or the {@link Beans#getReference(Class beanType)} method. The {@link NotificationManager}  
60 - * is {@link ApplicationScoped}, so you can inject it as many times as needed and still have only one instance per application.</p>  
61 - *  
62 - * <p>Implementators of management protocols must observe the {@link NotificationEvent} event (using the {@link Observes} annotation), this way  
63 - * they will receive an event containing the original notification and can translate this notification to a specific protocol. Optionaly,  
64 - * the implementator can use qualifiers like the {@link Generic} and {@link AttributeChange} qualifiers  
65 - * to filter what king of notifications they will handle. One example of an implementator is the <b>demoiselle-jmx</b> extension.</p>  
66 - *  
67 - * @author serpro  
68 - *  
69 - */  
70 -@ApplicationScoped  
71 -@SuppressWarnings("serial")  
72 -public class NotificationManager implements Serializable{  
73 -  
74 - @Inject  
75 - @Generic  
76 - private Event<NotificationEvent> genericNotificationEvent;  
77 -  
78 - @Inject  
79 - @AttributeChange  
80 - private Event<NotificationEvent> attributeChangeNotificationEvent;  
81 -  
82 - /**  
83 - * Sends a generic notification to all management clients.  
84 - *  
85 - * @param notification The notification to send  
86 - */  
87 - public void sendNotification(Notification notification) {  
88 - if (! AttributeChangeNotification.class.isInstance(notification) ){  
89 - getGenericNotificationEvent().fire(new NotificationEvent(notification));  
90 - }  
91 - else{  
92 - getAttributeChangeNotificationEvent().fire(new NotificationEvent(notification));  
93 - }  
94 - }  
95 -  
96 - @SuppressWarnings("unchecked")  
97 - private Event<NotificationEvent> 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<NotificationEvent> getAttributeChangeNotificationEvent() {  
107 - if (attributeChangeNotificationEvent==null){  
108 - attributeChangeNotificationEvent = Beans.getReference(Event.class , new AnnotationLiteral<AttributeChange>() {});  
109 - }  
110 -  
111 - return attributeChangeNotificationEvent;  
112 - }  
113 -  
114 -  
115 -  
116 -}  
impl/core/src/main/java/br/gov/frameworkdemoiselle/stereotype/ManagementController.java 0 → 100644
@@ -0,0 +1,79 @@ @@ -0,0 +1,79 @@
  1 +/*
  2 + * Demoiselle Framework
  3 + * Copyright (C) 2011 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.Documented;
  43 +import java.lang.annotation.Inherited;
  44 +import java.lang.annotation.Retention;
  45 +import java.lang.annotation.Target;
  46 +
  47 +import javax.enterprise.context.ApplicationScoped;
  48 +import javax.enterprise.inject.Stereotype;
  49 +import javax.enterprise.util.Nonbinding;
  50 +
  51 +/**
  52 + * <p>Identifies a <b>management controller</b> class. What it means is that an external client can manage the application
  53 + * this class is in by reading or writing it's attributes and calling it's operations.</p>
  54 + * <p>
  55 + * Only fields annotated with {@link br.gov.frameworkdemoiselle.annotation.ManagedProperty} or
  56 + * methods annotated with {@link br.gov.frameworkdemoiselle.annotation.ManagedOperation} will be exposed
  57 + * to clients.</p>
  58 + * <p>This stereotype only defines a class as managed, you need to choose an extension that will expose this managed class
  59 + * to external clients using any technology available. One example is the Demoiselle JMX extension, that will expose
  60 + * managed classes as MBeans.</p>
  61 + *
  62 + * @author SERPRO
  63 + */
  64 +@ApplicationScoped
  65 +@Stereotype
  66 +@Documented
  67 +@Controller
  68 +@Inherited
  69 +@Retention(RUNTIME)
  70 +@Target({ TYPE })
  71 +public @interface ManagementController {
  72 +
  73 + /**
  74 + * @return Human readable description of this managed class.
  75 + */
  76 + @Nonbinding
  77 + String description() default "";
  78 +
  79 +}
impl/core/src/main/java/br/gov/frameworkdemoiselle/validation/AllowedValues.java 0 → 100644
@@ -0,0 +1,76 @@ @@ -0,0 +1,76 @@
  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.validation;
  38 +
  39 +import static java.lang.annotation.ElementType.FIELD;
  40 +import static java.lang.annotation.RetentionPolicy.RUNTIME;
  41 +
  42 +import java.lang.annotation.Documented;
  43 +import java.lang.annotation.Retention;
  44 +import java.lang.annotation.Target;
  45 +
  46 +import javax.validation.Constraint;
  47 +
  48 +import br.gov.frameworkdemoiselle.internal.validation.AllowedValuesValidator;
  49 +
  50 +@Documented
  51 +@Target({ FIELD})
  52 +@Retention(RUNTIME)
  53 +@Constraint(validatedBy = AllowedValuesValidator.class)
  54 +/**
  55 + * Validate a value against a list of allowed values.
  56 + *
  57 + * @author serpro
  58 + *
  59 + */
  60 +public @interface AllowedValues {
  61 +
  62 + /**
  63 + * List of accepted values
  64 + */
  65 + String[] allows();
  66 +
  67 + /**
  68 + * Type of allowed values. Defaults to {@link ValueType#STRING}.
  69 + */
  70 + ValueType valueType() default ValueType.STRING;
  71 +
  72 + enum ValueType {
  73 + STRING,INTEGER,DECIMAL;
  74 + }
  75 +
  76 +}
impl/core/src/test/java/management/ManagementBootstrapTestCase.java
@@ -56,8 +56,8 @@ import org.junit.Test; @@ -56,8 +56,8 @@ import org.junit.Test;
56 import org.junit.runner.RunWith; 56 import org.junit.runner.RunWith;
57 57
58 import test.LocaleProducer; 58 import test.LocaleProducer;
59 -import br.gov.frameworkdemoiselle.management.extension.ManagementExtension;  
60 -import br.gov.frameworkdemoiselle.management.internal.ManagedType; 59 +import br.gov.frameworkdemoiselle.internal.management.ManagedType;
  60 +import br.gov.frameworkdemoiselle.lifecycle.ManagementExtension;
61 import br.gov.frameworkdemoiselle.util.Beans; 61 import br.gov.frameworkdemoiselle.util.Beans;
62 62
63 @RunWith(Arquillian.class) 63 @RunWith(Arquillian.class)
@@ -111,7 +111,7 @@ public class ManagementBootstrapTestCase { @@ -111,7 +111,7 @@ public class ManagementBootstrapTestCase {
111 deployer.deploy("default"); 111 deployer.deploy("default");
112 112
113 // "store" é application scoped e é usado pelo DummyManagementExtension para 113 // "store" é application scoped e é usado pelo DummyManagementExtension para
114 - // armazenar todos os beans anotados com @Managed. Se o bootstrap rodou corretamente, 114 + // armazenar todos os beans anotados com @ManagementController. Se o bootstrap rodou corretamente,
115 // ele chamou DummyManagementExtension.initialize e este store conterá o bean de teste que anotamos. 115 // ele chamou DummyManagementExtension.initialize e este store conterá o bean de teste que anotamos.
116 ManagedClassStore store = Beans.getReference(ManagedClassStore.class); 116 ManagedClassStore store = Beans.getReference(ManagedClassStore.class);
117 117
@@ -129,7 +129,7 @@ public class ManagementBootstrapTestCase { @@ -129,7 +129,7 @@ public class ManagementBootstrapTestCase {
129 deployer.deploy("default"); 129 deployer.deploy("default");
130 130
131 // "store" é application scoped e é usado pelo DummyManagementExtension para 131 // "store" é application scoped e é usado pelo DummyManagementExtension para
132 - // armazenar todos os beans anotados com @Managed. Se o bootstrap rodou corretamente, 132 + // armazenar todos os beans anotados com @ManagementController. Se o bootstrap rodou corretamente,
133 // ele chamou DummyManagementExtension.initialize e este store conterá o bean de teste que anotamos. 133 // ele chamou DummyManagementExtension.initialize e este store conterá o bean de teste que anotamos.
134 // Nós então disparamos o evento de shutdown onde ele deverá limpar o store. 134 // Nós então disparamos o evento de shutdown onde ele deverá limpar o store.
135 ManagedClassStore store = Beans.getReference(ManagedClassStore.class); 135 ManagedClassStore store = Beans.getReference(ManagedClassStore.class);
impl/core/src/test/java/management/ManagementTestCase.java
@@ -152,7 +152,7 @@ public class ManagementTestCase { @@ -152,7 +152,7 @@ public class ManagementTestCase {
152 152
153 try { 153 try {
154 // O método "nonOperationAnnotatedMethod" existe na classe DummyManagedClass, mas não está anotado como 154 // O método "nonOperationAnnotatedMethod" existe na classe DummyManagedClass, mas não está anotado como
155 - // "@Operation", então 155 + // "@ManagedOperation", então
156 // ela não pode ser exposta para extensões. 156 // ela não pode ser exposta para extensões.
157 store.invoke(DummyManagedClass.class, "nonOperationAnnotatedMethod"); 157 store.invoke(DummyManagedClass.class, "nonOperationAnnotatedMethod");
158 Assert.fail(); 158 Assert.fail();
impl/core/src/test/java/management/NotificationTestCase.java
@@ -54,11 +54,11 @@ import org.junit.runner.RunWith; @@ -54,11 +54,11 @@ import org.junit.runner.RunWith;
54 54
55 import test.LocaleProducer; 55 import test.LocaleProducer;
56 import br.gov.frameworkdemoiselle.annotation.Name; 56 import br.gov.frameworkdemoiselle.annotation.Name;
57 -import br.gov.frameworkdemoiselle.management.internal.ManagedType;  
58 -import br.gov.frameworkdemoiselle.management.internal.MonitoringManager;  
59 -import br.gov.frameworkdemoiselle.management.notification.AttributeChangeNotification;  
60 -import br.gov.frameworkdemoiselle.management.notification.Notification;  
61 -import br.gov.frameworkdemoiselle.management.notification.NotificationManager; 57 +import br.gov.frameworkdemoiselle.internal.management.ManagedType;
  58 +import br.gov.frameworkdemoiselle.internal.management.Management;
  59 +import br.gov.frameworkdemoiselle.management.AttributeChangeNotification;
  60 +import br.gov.frameworkdemoiselle.management.Notification;
  61 +import br.gov.frameworkdemoiselle.management.NotificationManager;
62 import br.gov.frameworkdemoiselle.util.Beans; 62 import br.gov.frameworkdemoiselle.util.Beans;
63 import br.gov.frameworkdemoiselle.util.ResourceBundle; 63 import br.gov.frameworkdemoiselle.util.ResourceBundle;
64 64
@@ -119,7 +119,7 @@ public class NotificationTestCase { @@ -119,7 +119,7 @@ public class NotificationTestCase {
119 */ 119 */
120 @Test 120 @Test
121 public void testNotifyChangeManagedClass(){ 121 public void testNotifyChangeManagedClass(){
122 - MonitoringManager manager = Beans.getReference(MonitoringManager.class); 122 + Management manager = Beans.getReference(Management.class);
123 123
124 for (ManagedType type : manager.getManagedTypes()){ 124 for (ManagedType type : manager.getManagedTypes()){
125 if (type.getType().equals(DummyManagedClass.class)){ 125 if (type.getType().equals(DummyManagedClass.class)){
impl/core/src/test/java/management/testclasses/DummyManagedClass.java
@@ -38,44 +38,44 @@ package management.testclasses; @@ -38,44 +38,44 @@ package management.testclasses;
38 38
39 import java.util.UUID; 39 import java.util.UUID;
40 40
41 -import br.gov.frameworkdemoiselle.management.annotation.Managed;  
42 -import br.gov.frameworkdemoiselle.management.annotation.Operation;  
43 -import br.gov.frameworkdemoiselle.management.annotation.Property;  
44 -import br.gov.frameworkdemoiselle.management.annotation.validation.AllowedValues;  
45 -import br.gov.frameworkdemoiselle.management.annotation.validation.AllowedValues.ValueType; 41 +import br.gov.frameworkdemoiselle.annotation.ManagedOperation;
  42 +import br.gov.frameworkdemoiselle.annotation.ManagedProperty;
  43 +import br.gov.frameworkdemoiselle.stereotype.ManagementController;
  44 +import br.gov.frameworkdemoiselle.validation.AllowedValues;
  45 +import br.gov.frameworkdemoiselle.validation.AllowedValues.ValueType;
46 46
47 -@Managed 47 +@ManagementController
48 public class DummyManagedClass { 48 public class DummyManagedClass {
49 49
50 - @Property 50 + @ManagedProperty
51 private String name; 51 private String name;
52 52
53 - @Property 53 + @ManagedProperty
54 @AllowedValues(allows={"f","m","F","M"},valueType=ValueType.INTEGER) 54 @AllowedValues(allows={"f","m","F","M"},valueType=ValueType.INTEGER)
55 private Integer id; 55 private Integer id;
56 56
57 - @Property 57 + @ManagedProperty
58 private Integer firstFactor , secondFactor; 58 private Integer firstFactor , secondFactor;
59 59
60 - @Property 60 + @ManagedProperty
61 private String uuid; 61 private String uuid;
62 62
63 - @Property 63 + @ManagedProperty
64 private String writeOnlyProperty; 64 private String writeOnlyProperty;
65 65
66 - @Property 66 + @ManagedProperty
67 private String readOnlyProperty = "Default Value"; 67 private String readOnlyProperty = "Default Value";
68 68
69 /** 69 /**
70 * Propriedade para testar detecção de métodos GET e SET quando propriedade tem apenas uma letra. 70 * Propriedade para testar detecção de métodos GET e SET quando propriedade tem apenas uma letra.
71 */ 71 */
72 - @Property 72 + @ManagedProperty
73 private Integer a; 73 private Integer a;
74 74
75 /** 75 /**
76 * Propriedade para testar detecção de métodos GET e SET quando propriedade tem apenas letras maiúsculas. 76 * Propriedade para testar detecção de métodos GET e SET quando propriedade tem apenas letras maiúsculas.
77 */ 77 */
78 - @Property 78 + @ManagedProperty
79 private Integer MAIUSCULO; 79 private Integer MAIUSCULO;
80 80
81 public Integer getId() { 81 public Integer getId() {
@@ -111,7 +111,7 @@ public class DummyManagedClass { @@ -111,7 +111,7 @@ public class DummyManagedClass {
111 MAIUSCULO = mAIUSCULO; 111 MAIUSCULO = mAIUSCULO;
112 } 112 }
113 113
114 - @Operation(description="Generates a random UUID") 114 + @ManagedOperation(description="Generates a random UUID")
115 public String generateUUID(){ 115 public String generateUUID(){
116 this.uuid = UUID.randomUUID().toString(); 116 this.uuid = UUID.randomUUID().toString();
117 return this.uuid; 117 return this.uuid;
@@ -152,7 +152,7 @@ public class DummyManagedClass { @@ -152,7 +152,7 @@ public class DummyManagedClass {
152 this.secondFactor = secondFactor; 152 this.secondFactor = secondFactor;
153 } 153 }
154 154
155 - @Operation 155 + @ManagedOperation
156 public Integer calculateFactorsNonSynchronized(Integer firstFactor , Integer secondFactor){ 156 public Integer calculateFactorsNonSynchronized(Integer firstFactor , Integer secondFactor){
157 setFirstFactor(firstFactor); 157 setFirstFactor(firstFactor);
158 setSecondFactor(secondFactor); 158 setSecondFactor(secondFactor);
@@ -173,7 +173,7 @@ public class DummyManagedClass { @@ -173,7 +173,7 @@ public class DummyManagedClass {
173 } 173 }
174 } 174 }
175 175
176 - @Operation 176 + @ManagedOperation
177 public synchronized Integer calculateFactorsSynchronized(Integer firstFactor , Integer secondFactor){ 177 public synchronized Integer calculateFactorsSynchronized(Integer firstFactor , Integer secondFactor){
178 setFirstFactor(firstFactor); 178 setFirstFactor(firstFactor);
179 setSecondFactor(secondFactor); 179 setSecondFactor(secondFactor);
impl/core/src/test/java/management/testclasses/DummyManagedClassPropertyError.java
@@ -36,8 +36,8 @@ @@ -36,8 +36,8 @@
36 */ 36 */
37 package management.testclasses; 37 package management.testclasses;
38 38
39 -import br.gov.frameworkdemoiselle.management.annotation.Managed;  
40 -import br.gov.frameworkdemoiselle.management.annotation.Property; 39 +import br.gov.frameworkdemoiselle.annotation.ManagedProperty;
  40 +import br.gov.frameworkdemoiselle.stereotype.ManagementController;
41 41
42 42
43 /** 43 /**
@@ -47,13 +47,13 @@ import br.gov.frameworkdemoiselle.management.annotation.Property; @@ -47,13 +47,13 @@ import br.gov.frameworkdemoiselle.management.annotation.Property;
47 * @author serpro 47 * @author serpro
48 * 48 *
49 */ 49 */
50 -@Managed 50 +@ManagementController
51 public class DummyManagedClassPropertyError { 51 public class DummyManagedClassPropertyError {
52 52
53 /** 53 /**
54 - * Property with no setter or getter 54 + * ManagedProperty with no setter or getter
55 */ 55 */
56 - @Property 56 + @ManagedProperty
57 private Long property; 57 private Long property;
58 58
59 } 59 }
impl/core/src/test/java/management/testclasses/DummyManagementExtension.java
@@ -41,8 +41,8 @@ import java.util.List; @@ -41,8 +41,8 @@ import java.util.List;
41 import javax.inject.Inject; 41 import javax.inject.Inject;
42 42
43 43
44 -import br.gov.frameworkdemoiselle.management.extension.ManagementExtension;  
45 -import br.gov.frameworkdemoiselle.management.internal.ManagedType; 44 +import br.gov.frameworkdemoiselle.internal.management.ManagedType;
  45 +import br.gov.frameworkdemoiselle.lifecycle.ManagementExtension;
46 46
47 public class DummyManagementExtension implements ManagementExtension { 47 public class DummyManagementExtension implements ManagementExtension {
48 48
impl/core/src/test/java/management/testclasses/DummyNotificationListener.java
@@ -39,11 +39,11 @@ package management.testclasses; @@ -39,11 +39,11 @@ package management.testclasses;
39 import javax.enterprise.context.ApplicationScoped; 39 import javax.enterprise.context.ApplicationScoped;
40 import javax.enterprise.event.Observes; 40 import javax.enterprise.event.Observes;
41 41
42 -import br.gov.frameworkdemoiselle.management.internal.notification.event.NotificationEvent;  
43 -import br.gov.frameworkdemoiselle.management.internal.notification.qualifier.AttributeChange;  
44 -import br.gov.frameworkdemoiselle.management.internal.notification.qualifier.Generic;  
45 -import br.gov.frameworkdemoiselle.management.notification.AttributeChangeNotification;  
46 -import br.gov.frameworkdemoiselle.management.notification.NotificationManager; 42 +import br.gov.frameworkdemoiselle.internal.management.ManagementNotificationEvent;
  43 +import br.gov.frameworkdemoiselle.internal.management.qualifier.AttributeChange;
  44 +import br.gov.frameworkdemoiselle.internal.management.qualifier.Generic;
  45 +import br.gov.frameworkdemoiselle.management.AttributeChangeNotification;
  46 +import br.gov.frameworkdemoiselle.management.NotificationManager;
47 47
48 /** 48 /**
49 * Dummy class to test receiving of notifications sent by the {@link NotificationManager} 49 * Dummy class to test receiving of notifications sent by the {@link NotificationManager}
@@ -56,11 +56,11 @@ public class DummyNotificationListener { @@ -56,11 +56,11 @@ public class DummyNotificationListener {
56 56
57 private String message = null; 57 private String message = null;
58 58
59 - public void listenNotification(@Observes @Generic NotificationEvent event){ 59 + public void listenNotification(@Observes @Generic ManagementNotificationEvent event){
60 message = event.getNotification().getMessage().toString(); 60 message = event.getNotification().getMessage().toString();
61 } 61 }
62 62
63 - public void listenAttributeChangeNotification(@Observes @AttributeChange NotificationEvent event){ 63 + public void listenAttributeChangeNotification(@Observes @AttributeChange ManagementNotificationEvent event){
64 AttributeChangeNotification notification = (AttributeChangeNotification)event.getNotification(); 64 AttributeChangeNotification notification = (AttributeChangeNotification)event.getNotification();
65 message = notification.getMessage().toString() + " - " + notification.getAttributeName(); 65 message = notification.getMessage().toString() + " - " + notification.getAttributeName();
66 } 66 }
impl/core/src/test/java/management/testclasses/ManagedClassStore.java
@@ -42,8 +42,8 @@ import java.util.List; @@ -42,8 +42,8 @@ import java.util.List;
42 42
43 import javax.enterprise.context.ApplicationScoped; 43 import javax.enterprise.context.ApplicationScoped;
44 44
45 -import br.gov.frameworkdemoiselle.management.internal.ManagedType;  
46 -import br.gov.frameworkdemoiselle.management.internal.MonitoringManager; 45 +import br.gov.frameworkdemoiselle.internal.management.ManagedType;
  46 +import br.gov.frameworkdemoiselle.internal.management.Management;
47 import br.gov.frameworkdemoiselle.util.Beans; 47 import br.gov.frameworkdemoiselle.util.Beans;
48 48
49 /** 49 /**
@@ -69,7 +69,7 @@ public class ManagedClassStore { @@ -69,7 +69,7 @@ public class ManagedClassStore {
69 } 69 }
70 70
71 public void setProperty(Class<?> managedClass , String attributeName , Object newValue){ 71 public void setProperty(Class<?> managedClass , String attributeName , Object newValue){
72 - MonitoringManager manager = Beans.getReference(MonitoringManager.class); 72 + Management manager = Beans.getReference(Management.class);
73 for (ManagedType type : manager.getManagedTypes()){ 73 for (ManagedType type : manager.getManagedTypes()){
74 if (type.getType().equals(managedClass)){ 74 if (type.getType().equals(managedClass)){
75 manager.setProperty(type, attributeName, newValue); 75 manager.setProperty(type, attributeName, newValue);
@@ -79,7 +79,7 @@ public class ManagedClassStore { @@ -79,7 +79,7 @@ public class ManagedClassStore {
79 } 79 }
80 80
81 public Object getProperty(Class<?> managedClass , String attributeName ){ 81 public Object getProperty(Class<?> managedClass , String attributeName ){
82 - MonitoringManager manager = Beans.getReference(MonitoringManager.class); 82 + Management manager = Beans.getReference(Management.class);
83 for (ManagedType type : manager.getManagedTypes()){ 83 for (ManagedType type : manager.getManagedTypes()){
84 if (type.getType().equals(managedClass)){ 84 if (type.getType().equals(managedClass)){
85 return manager.getProperty(type, attributeName); 85 return manager.getProperty(type, attributeName);
@@ -90,7 +90,7 @@ public class ManagedClassStore { @@ -90,7 +90,7 @@ public class ManagedClassStore {
90 } 90 }
91 91
92 public Object invoke(Class<?> managedClass , String operation , Object... params){ 92 public Object invoke(Class<?> managedClass , String operation , Object... params){
93 - MonitoringManager manager = Beans.getReference(MonitoringManager.class); 93 + Management manager = Beans.getReference(Management.class);
94 for (ManagedType type : manager.getManagedTypes()){ 94 for (ManagedType type : manager.getManagedTypes()){
95 if (type.getType().equals(managedClass)){ 95 if (type.getType().equals(managedClass)){
96 return manager.invoke(type, operation, params); 96 return manager.invoke(type, operation, params);