diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/ManagementBootstrap.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/ManagementBootstrap.java index dfb6082..ec9cacc 100644 --- a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/ManagementBootstrap.java +++ b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/ManagementBootstrap.java @@ -55,10 +55,10 @@ import javax.enterprise.inject.spi.ProcessAnnotatedType; import br.gov.frameworkdemoiselle.DemoiselleException; import br.gov.frameworkdemoiselle.internal.context.ContextManager; import br.gov.frameworkdemoiselle.internal.context.ManagedContext; -import br.gov.frameworkdemoiselle.internal.management.ManagedType; -import br.gov.frameworkdemoiselle.internal.management.Management; +import br.gov.frameworkdemoiselle.internal.implementation.ManagedType; +import br.gov.frameworkdemoiselle.internal.implementation.Management; import br.gov.frameworkdemoiselle.lifecycle.AfterShutdownProccess; -import br.gov.frameworkdemoiselle.lifecycle.ManagementExtension; +import br.gov.frameworkdemoiselle.management.ManagementExtension; import br.gov.frameworkdemoiselle.stereotype.ManagementController; import br.gov.frameworkdemoiselle.util.Beans; import br.gov.frameworkdemoiselle.util.ResourceBundle; diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/AttributeChange.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/AttributeChange.java new file mode 100644 index 0000000..48d9b2a --- /dev/null +++ b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/AttributeChange.java @@ -0,0 +1,62 @@ +/* + * Demoiselle Framework + * Copyright (C) 2010 SERPRO + * ---------------------------------------------------------------------------- + * This file is part of Demoiselle Framework. + * + * Demoiselle Framework is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License version 3 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License version 3 + * along with this program; if not, see + * or write to the Free Software Foundation, Inc., 51 Franklin Street, + * Fifth Floor, Boston, MA 02110-1301, USA. + * ---------------------------------------------------------------------------- + * Este arquivo é parte do Framework Demoiselle. + * + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação + * do Software Livre (FSF). + * + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português + * para maiores detalhes. + * + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título + * "LICENCA.txt", junto com esse programa. Se não, acesse + * ou escreva para a Fundação do Software Livre (FSF) Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. + */ +package br.gov.frameworkdemoiselle.internal.implementation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import javax.inject.Qualifier; + +import br.gov.frameworkdemoiselle.management.AttributeChangeNotification; +import br.gov.frameworkdemoiselle.management.ManagementNotificationEvent; + +/** + * + * Enables {@link ManagementNotificationEvent} observers to trigger only with notifications + * of the specialized type {@link AttributeChangeNotification}. + * + * @author SERPRO + * + */ +@Qualifier +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER, ElementType.TYPE}) +public @interface AttributeChange { + +} diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/Generic.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/Generic.java new file mode 100644 index 0000000..89e62ae --- /dev/null +++ b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/Generic.java @@ -0,0 +1,62 @@ +/* + * Demoiselle Framework + * Copyright (C) 2010 SERPRO + * ---------------------------------------------------------------------------- + * This file is part of Demoiselle Framework. + * + * Demoiselle Framework is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License version 3 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License version 3 + * along with this program; if not, see + * or write to the Free Software Foundation, Inc., 51 Franklin Street, + * Fifth Floor, Boston, MA 02110-1301, USA. + * ---------------------------------------------------------------------------- + * Este arquivo é parte do Framework Demoiselle. + * + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação + * do Software Livre (FSF). + * + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português + * para maiores detalhes. + * + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título + * "LICENCA.txt", junto com esse programa. Se não, acesse + * ou escreva para a Fundação do Software Livre (FSF) Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. + */ +package br.gov.frameworkdemoiselle.internal.implementation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import javax.inject.Qualifier; + +import br.gov.frameworkdemoiselle.management.ManagementNotificationEvent; +import br.gov.frameworkdemoiselle.management.GenericNotification; + +/** + * + * Enables {@link ManagementNotificationEvent} observers to trigger only with notifications + * of the base type {@link GenericNotification}. + * + * @author SERPRO + * + */ +@Qualifier +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER, ElementType.TYPE}) +public @interface Generic { + +} diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/ManagedType.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/ManagedType.java new file mode 100644 index 0000000..a9bd4a2 --- /dev/null +++ b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/ManagedType.java @@ -0,0 +1,388 @@ +/* + * Demoiselle Framework + * Copyright (C) 2010 SERPRO + * ---------------------------------------------------------------------------- + * This file is part of Demoiselle Framework. + * + * Demoiselle Framework is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License version 3 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License version 3 + * along with this program; if not, see + * or write to the Free Software Foundation, Inc., 51 Franklin Street, + * Fifth Floor, Boston, MA 02110-1301, USA. + * ---------------------------------------------------------------------------- + * Este arquivo é parte do Framework Demoiselle. + * + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação + * do Software Livre (FSF). + * + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português + * para maiores detalhes. + * + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título + * "LICENCA.txt", junto com esse programa. Se não, acesse + * ou escreva para a Fundação do Software Livre (FSF) Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. + */ +package br.gov.frameworkdemoiselle.internal.implementation; + +import java.lang.annotation.Annotation; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Locale; +import java.util.TreeMap; + +import javax.inject.Qualifier; + +import br.gov.frameworkdemoiselle.DemoiselleException; +import br.gov.frameworkdemoiselle.annotation.ManagedOperation; +import br.gov.frameworkdemoiselle.annotation.ManagedProperty; +import br.gov.frameworkdemoiselle.annotation.ManagedProperty.ManagedPropertyAccess; +import br.gov.frameworkdemoiselle.annotation.OperationParameter; +import br.gov.frameworkdemoiselle.annotation.OperationType; +import br.gov.frameworkdemoiselle.stereotype.ManagementController; +import br.gov.frameworkdemoiselle.util.ResourceBundle; + +/** + *

Package class containing information about a discovered {@link ManagementController}.

+ * + *

Instances if this class are passed to each discovered management extension during bootstrap so they can have + * enough information to expose all discovered {@link ManagementController}'s to management clients.

+ * + * @author SERPRO + */ +public class ManagedType { + + private Class type; + + private Annotation[] qualifiers; + + private TreeMap fields; + + private TreeMap operationMethods; + + private ResourceBundle bundle; + + private String description; + + public ManagedType(Class type) { + bundle = new ResourceBundle("demoiselle-core-bundle",Locale.getDefault()); + + if (type == null) { + throw new DemoiselleException(bundle.getString("management-null-class-defined")); + } + if (!type.isAnnotationPresent(ManagementController.class)) { + throw new DemoiselleException(bundle.getString("management-no-annotation-found", type.getCanonicalName())); + } + + this.type = type; + fields = new TreeMap(); + operationMethods = new TreeMap(); + this.description = type.getAnnotation(ManagementController.class).description(); + this.qualifiers = getQualifierAnnotations(type); + + initialize(); + } + + public Class getType() { + return type; + } + + public String getDescription() { + return description; + } + + public TreeMap getFields() { + return fields; + } + + public TreeMap getOperationMethods() { + return operationMethods; + } + + /** + *

Return a (possibly empty) list of all qualifiers this type have. Qualifiers + * are any annotations marked as {@link Qualifier}.

+ * + *

This method returns the true list of qualifiers. If implementators change this list, it will + * affect future calls of this method. This is so that resources can be spared by not creating many instances of this list.

+ * + */ + public Annotation[] getQualifiers(){ + return this.qualifiers; + } + + private void initialize() { + // Para cada atributo verifica se ele está anotado com ManagedProperty e extrai as informações dele (método get, set e + // descrição do atributo). + Field[] fields = type.getDeclaredFields(); + if (fields != null) { + for (Field field : fields) { + if (field.isAnnotationPresent(ManagedProperty.class)) { + // Obtém os métodos GET e SET para esta propriedade + Method getterMethod = getGetterMethod(field); + Method setterMethod = getSetterMethod(field); + if (getterMethod == null && setterMethod == null) { + throw new DemoiselleException(bundle.getString("management-invalid-property-no-getter-setter", + type.getSimpleName(), field.getName())); + } else if ((getterMethod != null && getterMethod.isAnnotationPresent(ManagedOperation.class)) + || (setterMethod != null && setterMethod.isAnnotationPresent(ManagedOperation.class))) { + throw new DemoiselleException(bundle.getString("management-invalid-property-as-operation", + type.getSimpleName())); + } + + String propertyDescription = field.getAnnotation(ManagedProperty.class).description(); + + this.fields.put(field.getName(), new FieldDetail(field, propertyDescription, getterMethod, + setterMethod)); + } + } + } + + // Para cada metodo verifica se ele está anotado com ManagedOperation e cria um MBeanOperationInfo para ele. + Method[] methodList = type.getMethods(); + if (methodList != null) { + for (Method method : methodList) { + ManagedOperation opAnnotation = method.getAnnotation(ManagedOperation.class); + + if (opAnnotation != null) { + // Lemos as informações sobre o método e criamos uma instância + // de MethodDetail para representar este método como uma + // operação. + + Class[] parameterTypes = method.getParameterTypes(); + Annotation[][] parameterAnnotations = method.getParameterAnnotations(); + ParameterDetail[] parameterDetails = new ParameterDetail[parameterTypes.length]; + OperationType operationType = opAnnotation.type(); + + for (int i = 0; i < parameterTypes.length; i++) { + OperationParameter paramAnnotation = null; + for (Annotation annotation : parameterAnnotations[i]) { + if (annotation.annotationType() == OperationParameter.class) { + paramAnnotation = (OperationParameter) annotation; + break; + } + } + + String name = paramAnnotation != null ? paramAnnotation.name() : ("arg" + i); + String description = paramAnnotation != null ? paramAnnotation.description() : null; + + parameterDetails[i] = new ParameterDetail(parameterTypes[i], name, description); + } + + // Com todas as informações, criamos nossa instância de MethodDetail e + // acrescentamos na lista de todas as operações. + MethodDetail detail = new MethodDetail(method, opAnnotation.description(), operationType, parameterDetails); + operationMethods.put(method.getName(), detail); + } + } + } + } + + /** + * Returns the public getter method for a given field, or null if no getter method can be found. + */ + private Method getGetterMethod(Field field) { + StringBuffer getterMethodName = new StringBuffer() + .append("get") + .append(field.getName().substring(0, 1).toUpperCase()) + .append(field.getName().substring(1)); + + //Se propriedade está anotada como WRITE-ONLY, ignora essa etapa. + ManagedProperty annotation = field.getAnnotation(ManagedProperty.class); + if (annotation.accessLevel() == ManagedPropertyAccess.WRITE_ONLY){ + return null; + } + + Method getterMethod; + + try { + getterMethod = type.getMethod(getterMethodName.toString()); + } catch (Exception e) { + getterMethod = null; + } + + // Se atributo for boolean, procura método getter no formato "isAttribute". + if (getterMethod == null + && (Boolean.TYPE.isAssignableFrom(field.getType()) || Boolean.class.isAssignableFrom(field.getType()))) { + // Boolean.TYPE representa o tipo primitivo "boolean", Boolean.class é a classe wrapper. + getterMethodName = new StringBuffer() + .append("is") + .append(field.getName().substring(0, 1).toUpperCase()) + .append(field.getName().substring(1).toUpperCase()); + + try { + getterMethod = type.getMethod(getterMethodName.toString()); + } catch (Exception e) { + getterMethod = null; + } + } + + return getterMethod; + } + + /** + * Returns the public setter method for a given field, or null if no setter method can be found. + */ + private Method getSetterMethod(Field field) { + + //Se propriedade está anotada como READ-ONLY, ignora essa etapa. + ManagedProperty annotation = field.getAnnotation(ManagedProperty.class); + if (annotation.accessLevel() == ManagedPropertyAccess.READ_ONLY){ + return null; + } + + StringBuffer setterMethodName = new StringBuffer() + .append("set") + .append(field.getName().substring(0, 1).toUpperCase()) + .append(field.getName().substring(1)); + + Method setterMethod; + + try { + setterMethod = type.getMethod(setterMethodName.toString() , field.getType()); + } catch (Exception e) { + setterMethod = null; + } + + return setterMethod; + } + + /** + * Indicates another {@link ManagedType} represents the same {@link Class} as this one. This method also supports a + * {@link Class} as a parameter, in this case it will return true if the passed class is exactly the + * same Java class represented by this {@link ManagedType}. + */ + @Override + public boolean equals(Object other) { + if (other == null) { + return false; + } + + return ((ManagedType) other).getType().getCanonicalName().equals(this.getType().getCanonicalName()); + } + + private synchronized Annotation[] getQualifierAnnotations(Class beanClass){ + Annotation[] annotations = beanClass.getAnnotations(); + ArrayList qualifiers = new ArrayList(annotations.length); + + for (int i=0; i parameterType; + + private final String parameterName; + + private final String parameterDescription; + + public ParameterDetail(Class parameterType, String parameterName, String parameterDescription) { + super(); + this.parameterType = parameterType; + this.parameterName = parameterName; + this.parameterDescription = parameterDescription; + } + + public Class getParameterType() { + return parameterType; + } + + public String getParameterName() { + return parameterName; + } + + public String getParameterDescription() { + return parameterDescription; + } + } +} diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/Management.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/Management.java new file mode 100644 index 0000000..a781500 --- /dev/null +++ b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/Management.java @@ -0,0 +1,358 @@ +/* + * Demoiselle Framework + * Copyright (C) 2010 SERPRO + * ---------------------------------------------------------------------------- + * This file is part of Demoiselle Framework. + * + * Demoiselle Framework is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License version 3 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License version 3 + * along with this program; if not, see + * or write to the Free Software Foundation, Inc., 51 Franklin Street, + * Fifth Floor, Boston, MA 02110-1301, USA. + * ---------------------------------------------------------------------------- + * Este arquivo é parte do Framework Demoiselle. + * + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação + * do Software Livre (FSF). + * + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português + * para maiores detalhes. + * + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título + * "LICENCA.txt", junto com esse programa. Se não, acesse + * ou escreva para a Fundação do Software Livre (FSF) Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. + */ +package br.gov.frameworkdemoiselle.internal.implementation; + +import java.io.Serializable; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Set; + +import javax.enterprise.context.ApplicationScoped; +import javax.enterprise.context.RequestScoped; +import javax.inject.Inject; +import javax.validation.ConstraintViolation; +import javax.validation.ConstraintViolationException; +import javax.validation.Validation; +import javax.validation.ValidationException; +import javax.validation.Validator; + +import org.slf4j.Logger; + +import br.gov.frameworkdemoiselle.annotation.ManagedProperty; +import br.gov.frameworkdemoiselle.annotation.Name; +import br.gov.frameworkdemoiselle.internal.context.ContextManager; +import br.gov.frameworkdemoiselle.internal.context.ManagedContext; +import br.gov.frameworkdemoiselle.internal.implementation.ManagedType.MethodDetail; +import br.gov.frameworkdemoiselle.management.AttributeChangeNotification; +import br.gov.frameworkdemoiselle.management.ManagedAttributeNotFoundException; +import br.gov.frameworkdemoiselle.management.ManagedInvokationException; +import br.gov.frameworkdemoiselle.management.ManagementExtension; +import br.gov.frameworkdemoiselle.management.NotificationManager; +import br.gov.frameworkdemoiselle.stereotype.ManagementController; +import br.gov.frameworkdemoiselle.util.Beans; +import br.gov.frameworkdemoiselle.util.ResourceBundle; + +/** + * Central class used by management extensions to obtain information, access properties and call operations over + * discovered {@link ManagementController} classes. + * + * @author SERPRO + */ +@ApplicationScoped +public class Management implements Serializable { + + private static final long serialVersionUID = 1L; + + @Inject + private Logger logger; + + @Inject + @Name("demoiselle-core-bundle") + private ResourceBundle bundle; + + private final List managedTypes = new ArrayList(); + + private Validator validator; + + public void addManagedType(ManagedType managedType) { + managedTypes.add(managedType); + logger.debug(bundle.getString("management-debug-registering-managed-type", managedType.getType() + .getCanonicalName())); + } + + /** + * @return List all discovered {@link ManagementController} classes. The returned list is a shallow copy of the + * internal list, so you are free to modify it. TODO precisamos desse clone na lista? + */ + public List getManagedTypes() { + ArrayList cloneList = new ArrayList(); + cloneList.addAll(managedTypes); + return cloneList; + } + + /** + *

+ * Invoke an operation over a {@link ManagementController}. + *

+ *

+ * This method is not thread-safe, it's the user's responsibility to make the operations of the managed type + * synchronized if necessary. + *

+ * + * @param managedType + * A type annotated with {@link ManagementController}. This method will create an (or obtain an already + * created) instance of this type and invoke the operation over it. + * @param actionName + * Name of method to be invoked, the type must have this operation on it's list + * @param params + * List of values for the operation parameters. Can be null if the operation require no + * parameters. + * @return The return value of the original invoked operation. Methods of return type void will return + * the {@link Void} type. + * @throws ManagedInvokationException + * In case the operation doesn't exist or have a different signature + */ + public Object invoke(ManagedType managedType, String actionName, Object[] params) { + if (managedTypes.contains(managedType)) { + activateContexts(managedType.getType()); + + try { + Object delegate = Beans.getReference(managedType.getType() , managedType.getQualifiers()); + MethodDetail method = managedType.getOperationMethods().get(actionName); + + if (method != null) { + try { + logger.debug(bundle.getString("management-debug-invoking-operation", actionName, managedType + .getType().getCanonicalName())); + return method.getMethod().invoke(delegate, params); + } catch (Exception e) { + throw new ManagedInvokationException(bundle.getString("management-invoke-error", actionName), e); + } + } else { + throw new ManagedInvokationException(bundle.getString("management-invoke-error", actionName)); + } + } finally { + deactivateContexts(managedType.getType()); + } + } else { + throw new ManagedInvokationException(bundle.getString("management-type-not-found")); + } + } + + /** + *

+ * Retrieve the current value of a property from a managed type. Properties are attributes annotated with + * {@link ManagedProperty}. + *

+ *

+ * This method is not thread-safe, it's the user's responsibility to create the property's access methods from the + * managed type synchronized if necessary. + *

+ * + * @param managedType + * The type that has the property the client wants to know the value of. + * @param propertyName + * The name of the property + * @return The current value of the property + * @throws ManagedAttributeNotFoundException If the given property doesn't exist or there was a problem trying to read the property value. + * @throws ManagedInvokationException If there was an error trying to invoke the getter method to read the propery value. + */ + public Object getProperty(ManagedType managedType, String propertyName) { + + if (managedTypes.contains(managedType)) { + Method getterMethod = managedType.getFields().get(propertyName).getGetterMethod(); + + if (getterMethod != null) { + logger.debug(bundle.getString("management-debug-acessing-property", getterMethod.getName(), managedType + .getType().getCanonicalName())); + + activateContexts(managedType.getType()); + + try { + Object delegate = Beans.getReference(managedType.getType() , managedType.getQualifiers()); + + return getterMethod.invoke(delegate, (Object[]) null); + } catch (Exception e) { + throw new ManagedInvokationException(bundle.getString("management-invoke-error", getterMethod.getName()), + e); + } finally { + deactivateContexts(managedType.getType()); + } + } else { + throw new ManagedAttributeNotFoundException(bundle.getString("management-read-value-error", propertyName)); + } + } else { + throw new ManagedInvokationException(bundle.getString("management-type-not-found")); + } + } + + /** + *

+ * Sets a new value for a property contained inside a managed type. A property is an attribute annotated with + * {@link ManagedProperty}. + *

+ *

+ * This method is not thread-safe, it's the user's responsibility to create the property's access methods from the + * managed type synchronized if necessary. + *

+ * + * @param managedType + * The type that has access to the property + * @param propertyName + * The name of the property + * @param newValue + * The new value of the property + * @throws ManagedInvokationException If there was an error trying to call the setter method for this property. + * @throws ManagedAttributeNotFoundException If the giver property doesn't exist or could'n be written to. + * @throws ConstraintViolationException If the property defined one or more validation constraints and setting this value violates some of those constraints. + */ + @SuppressWarnings("unchecked") + public void setProperty(ManagedType managedType, String propertyName, Object newValue) { + + if (managedTypes.contains(managedType)) { + // Procura o método set do atributo em questão + Method method = managedType.getFields().get(propertyName).getSetterMethod(); + if (method != null) { + logger.debug(bundle.getString("management-debug-setting-property", method.getName(), managedType + .getType().getCanonicalName())); + + activateContexts(managedType.getType()); + try { + // Obtém uma instância da classe gerenciada, lembrando que + // classes + // anotadas com @ManagementController são sempre singletons. + Object delegate = Beans.getReference(managedType.getType() , managedType.getQualifiers() ); + + // Se houver um validador anexado à propriedade alterada, executa o validador sobre + // o novo valor. + Validator validator = getDefaultValidator(); + if (validator != null) { + Set violations = validator.validateValue(managedType.getType(), propertyName, newValue); + if (violations.size() > 0) { + StringBuffer errorBuffer = new StringBuffer(); + for (Object objectViolation : violations) { + ConstraintViolation violation = (ConstraintViolation) objectViolation; + errorBuffer.append(violation.getMessage()).append('\r').append('\n'); + } + + if (errorBuffer.length() > 0) { + errorBuffer.insert(0, "\r\n"); + errorBuffer.insert(errorBuffer.length(), "\r\n"); + } + + throw new ConstraintViolationException(bundle.getString("management-validation-constraint-violation" + , managedType.getType().getCanonicalName(), propertyName, errorBuffer.toString()) + , (Set>) violations); + } + } else { + logger.warn(bundle.getString("management-validation-validator-not-found")); + } + + Method getterMethod = managedType.getFields().get(propertyName).getGetterMethod(); + Object oldValue; + try { + oldValue = getterMethod.invoke(delegate, (Object[]) null); + } catch (Exception e) { + oldValue = null; + } + + method.invoke(delegate, new Object[] { newValue }); + + // Manda uma notificação de mudança de atributo + NotificationManager notificationManager = Beans.getReference(NotificationManager.class); + Class attributeType = newValue != null ? newValue.getClass() : null; + + AttributeChangeNotification notification = new AttributeChangeNotification(bundle.getString( + "management-notification-attribute-changed", propertyName, managedType.getType() + .getCanonicalName()), propertyName, attributeType, oldValue, newValue); + notificationManager.sendNotification(notification); + + } catch (ConstraintViolationException ce) { + throw ce; + } catch (Exception e) { + throw new ManagedInvokationException(bundle.getString("management-invoke-error", method.getName()), e); + } finally { + deactivateContexts(managedType.getType()); + } + + } else { + throw new ManagedAttributeNotFoundException(bundle.getString("management-write-value-error", propertyName)); + } + } else { + throw new ManagedInvokationException(bundle.getString("management-type-not-found")); + } + + } + + private void activateContexts(Class managedType) { + logger.debug(bundle.getString("management-debug-starting-custom-context", + ManagedContext.class.getCanonicalName(), managedType.getCanonicalName())); + + ContextManager.activate(ManagedContext.class, RequestScoped.class); + } + + private void deactivateContexts(Class managedType) { + logger.debug(bundle.getString("management-debug-stoping-custom-context", + ManagedContext.class.getCanonicalName(), managedType.getCanonicalName())); + + ContextManager.deactivate(ManagedContext.class, RequestScoped.class); + } + + public void shutdown(Collection> monitoringExtensions) { + + for (Class monitoringExtensionClass : monitoringExtensions) { + + ManagementExtension monitoringExtension = Beans.getReference(monitoringExtensionClass); + + monitoringExtension.shutdown(this.getManagedTypes()); + + logger.debug(bundle.getString("management-debug-removing-management-extension", monitoringExtension + .getClass().getCanonicalName())); + + } + + } + + public void initialize(Collection> monitoringExtensions) { + + for (Class monitoringExtensionClass : monitoringExtensions) { + ManagementExtension monitoringExtension = Beans.getReference(monitoringExtensionClass); + + logger.debug(bundle.getString("management-debug-processing-management-extension", monitoringExtension + .getClass().getCanonicalName())); + + monitoringExtension.initialize(this.getManagedTypes()); + } + + } + + private Validator getDefaultValidator() { + if (validator == null) { + try { + this.validator = Validation.buildDefaultValidatorFactory().getValidator(); + } catch (ValidationException e) { + this.validator = null; + } + } + + return this.validator; + } + + +} diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/ManagementNotificationEventImpl.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/ManagementNotificationEventImpl.java new file mode 100644 index 0000000..1739b4d --- /dev/null +++ b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/ManagementNotificationEventImpl.java @@ -0,0 +1,65 @@ +/* + * Demoiselle Framework + * Copyright (C) 2010 SERPRO + * ---------------------------------------------------------------------------- + * This file is part of Demoiselle Framework. + * + * Demoiselle Framework is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License version 3 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License version 3 + * along with this program; if not, see + * or write to the Free Software Foundation, Inc., 51 Franklin Street, + * Fifth Floor, Boston, MA 02110-1301, USA. + * ---------------------------------------------------------------------------- + * Este arquivo é parte do Framework Demoiselle. + * + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação + * do Software Livre (FSF). + * + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português + * para maiores detalhes. + * + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título + * "LICENCA.txt", junto com esse programa. Se não, acesse + * ou escreva para a Fundação do Software Livre (FSF) Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. + */ +package br.gov.frameworkdemoiselle.internal.implementation; + +import br.gov.frameworkdemoiselle.management.GenericNotification; +import br.gov.frameworkdemoiselle.management.NotificationManager; + +/** + * Event fired when a notification is sent by {@link NotificationManager}. + * Implementators can capture this event and be notified when the {@link NotificationManager} + * sends notifications, so they can pass the notification to the underlying technology. + * + * @author SERPRO + * + */ +public class ManagementNotificationEventImpl implements br.gov.frameworkdemoiselle.management.ManagementNotificationEvent { + + private GenericNotification notification; + + public ManagementNotificationEventImpl(GenericNotification notification){ + this.notification = notification; + } + + public GenericNotification getNotification() { + return notification; + } + + public void setNotification(GenericNotification notification) { + this.notification = notification; + } +} diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/NotificationManagerImpl.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/NotificationManagerImpl.java index e358e1b..a438fcb 100644 --- a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/NotificationManagerImpl.java +++ b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/NotificationManagerImpl.java @@ -42,9 +42,6 @@ import javax.enterprise.event.Event; import javax.enterprise.util.AnnotationLiteral; import javax.inject.Inject; -import br.gov.frameworkdemoiselle.internal.management.ManagementNotificationEventImpl; -import br.gov.frameworkdemoiselle.internal.management.qualifier.AttributeChange; -import br.gov.frameworkdemoiselle.internal.management.qualifier.Generic; import br.gov.frameworkdemoiselle.management.AttributeChangeNotification; import br.gov.frameworkdemoiselle.management.GenericNotification; import br.gov.frameworkdemoiselle.management.ManagementNotificationEvent; diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/management/ManagedType.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/management/ManagedType.java deleted file mode 100644 index a02526e..0000000 --- a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/management/ManagedType.java +++ /dev/null @@ -1,388 +0,0 @@ -/* - * Demoiselle Framework - * Copyright (C) 2010 SERPRO - * ---------------------------------------------------------------------------- - * This file is part of Demoiselle Framework. - * - * Demoiselle Framework is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License version 3 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License version 3 - * along with this program; if not, see - * or write to the Free Software Foundation, Inc., 51 Franklin Street, - * Fifth Floor, Boston, MA 02110-1301, USA. - * ---------------------------------------------------------------------------- - * Este arquivo é parte do Framework Demoiselle. - * - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação - * do Software Livre (FSF). - * - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português - * para maiores detalhes. - * - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título - * "LICENCA.txt", junto com esse programa. Se não, acesse - * ou escreva para a Fundação do Software Livre (FSF) Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - */ -package br.gov.frameworkdemoiselle.internal.management; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Locale; -import java.util.TreeMap; - -import javax.inject.Qualifier; - -import br.gov.frameworkdemoiselle.DemoiselleException; -import br.gov.frameworkdemoiselle.annotation.ManagedOperation; -import br.gov.frameworkdemoiselle.annotation.ManagedProperty; -import br.gov.frameworkdemoiselle.annotation.ManagedProperty.ManagedPropertyAccess; -import br.gov.frameworkdemoiselle.annotation.OperationParameter; -import br.gov.frameworkdemoiselle.annotation.OperationType; -import br.gov.frameworkdemoiselle.stereotype.ManagementController; -import br.gov.frameworkdemoiselle.util.ResourceBundle; - -/** - *

Package class containing information about a discovered {@link ManagementController}.

- * - *

Instances if this class are passed to each discovered management extension during bootstrap so they can have - * enough information to expose all discovered {@link ManagementController}'s to management clients.

- * - * @author SERPRO - */ -public class ManagedType { - - private Class type; - - private Annotation[] qualifiers; - - private TreeMap fields; - - private TreeMap operationMethods; - - private ResourceBundle bundle; - - private String description; - - public ManagedType(Class type) { - bundle = new ResourceBundle("demoiselle-core-bundle",Locale.getDefault()); - - if (type == null) { - throw new DemoiselleException(bundle.getString("management-null-class-defined")); - } - if (!type.isAnnotationPresent(ManagementController.class)) { - throw new DemoiselleException(bundle.getString("management-no-annotation-found", type.getCanonicalName())); - } - - this.type = type; - fields = new TreeMap(); - operationMethods = new TreeMap(); - this.description = type.getAnnotation(ManagementController.class).description(); - this.qualifiers = getQualifierAnnotations(type); - - initialize(); - } - - public Class getType() { - return type; - } - - public String getDescription() { - return description; - } - - public TreeMap getFields() { - return fields; - } - - public TreeMap getOperationMethods() { - return operationMethods; - } - - /** - *

Return a (possibly empty) list of all qualifiers this type have. Qualifiers - * are any annotations marked as {@link Qualifier}.

- * - *

This method returns the true list of qualifiers. If implementators change this list, it will - * affect future calls of this method. This is so that resources can be spared by not creating many instances of this list.

- * - */ - public Annotation[] getQualifiers(){ - return this.qualifiers; - } - - private void initialize() { - // Para cada atributo verifica se ele está anotado com ManagedProperty e extrai as informações dele (método get, set e - // descrição do atributo). - Field[] fields = type.getDeclaredFields(); - if (fields != null) { - for (Field field : fields) { - if (field.isAnnotationPresent(ManagedProperty.class)) { - // Obtém os métodos GET e SET para esta propriedade - Method getterMethod = getGetterMethod(field); - Method setterMethod = getSetterMethod(field); - if (getterMethod == null && setterMethod == null) { - throw new DemoiselleException(bundle.getString("management-invalid-property-no-getter-setter", - type.getSimpleName(), field.getName())); - } else if ((getterMethod != null && getterMethod.isAnnotationPresent(ManagedOperation.class)) - || (setterMethod != null && setterMethod.isAnnotationPresent(ManagedOperation.class))) { - throw new DemoiselleException(bundle.getString("management-invalid-property-as-operation", - type.getSimpleName())); - } - - String propertyDescription = field.getAnnotation(ManagedProperty.class).description(); - - this.fields.put(field.getName(), new FieldDetail(field, propertyDescription, getterMethod, - setterMethod)); - } - } - } - - // Para cada metodo verifica se ele está anotado com ManagedOperation e cria um MBeanOperationInfo para ele. - Method[] methodList = type.getMethods(); - if (methodList != null) { - for (Method method : methodList) { - ManagedOperation opAnnotation = method.getAnnotation(ManagedOperation.class); - - if (opAnnotation != null) { - // Lemos as informações sobre o método e criamos uma instância - // de MethodDetail para representar este método como uma - // operação. - - Class[] parameterTypes = method.getParameterTypes(); - Annotation[][] parameterAnnotations = method.getParameterAnnotations(); - ParameterDetail[] parameterDetails = new ParameterDetail[parameterTypes.length]; - OperationType operationType = opAnnotation.type(); - - for (int i = 0; i < parameterTypes.length; i++) { - OperationParameter paramAnnotation = null; - for (Annotation annotation : parameterAnnotations[i]) { - if (annotation.annotationType() == OperationParameter.class) { - paramAnnotation = (OperationParameter) annotation; - break; - } - } - - String name = paramAnnotation != null ? paramAnnotation.name() : ("arg" + i); - String description = paramAnnotation != null ? paramAnnotation.description() : null; - - parameterDetails[i] = new ParameterDetail(parameterTypes[i], name, description); - } - - // Com todas as informações, criamos nossa instância de MethodDetail e - // acrescentamos na lista de todas as operações. - MethodDetail detail = new MethodDetail(method, opAnnotation.description(), operationType, parameterDetails); - operationMethods.put(method.getName(), detail); - } - } - } - } - - /** - * Returns the public getter method for a given field, or null if no getter method can be found. - */ - private Method getGetterMethod(Field field) { - StringBuffer getterMethodName = new StringBuffer() - .append("get") - .append(field.getName().substring(0, 1).toUpperCase()) - .append(field.getName().substring(1)); - - //Se propriedade está anotada como WRITE-ONLY, ignora essa etapa. - ManagedProperty annotation = field.getAnnotation(ManagedProperty.class); - if (annotation.accessLevel() == ManagedPropertyAccess.WRITE_ONLY){ - return null; - } - - Method getterMethod; - - try { - getterMethod = type.getMethod(getterMethodName.toString()); - } catch (Exception e) { - getterMethod = null; - } - - // Se atributo for boolean, procura método getter no formato "isAttribute". - if (getterMethod == null - && (Boolean.TYPE.isAssignableFrom(field.getType()) || Boolean.class.isAssignableFrom(field.getType()))) { - // Boolean.TYPE representa o tipo primitivo "boolean", Boolean.class é a classe wrapper. - getterMethodName = new StringBuffer() - .append("is") - .append(field.getName().substring(0, 1).toUpperCase()) - .append(field.getName().substring(1).toUpperCase()); - - try { - getterMethod = type.getMethod(getterMethodName.toString()); - } catch (Exception e) { - getterMethod = null; - } - } - - return getterMethod; - } - - /** - * Returns the public setter method for a given field, or null if no setter method can be found. - */ - private Method getSetterMethod(Field field) { - - //Se propriedade está anotada como READ-ONLY, ignora essa etapa. - ManagedProperty annotation = field.getAnnotation(ManagedProperty.class); - if (annotation.accessLevel() == ManagedPropertyAccess.READ_ONLY){ - return null; - } - - StringBuffer setterMethodName = new StringBuffer() - .append("set") - .append(field.getName().substring(0, 1).toUpperCase()) - .append(field.getName().substring(1)); - - Method setterMethod; - - try { - setterMethod = type.getMethod(setterMethodName.toString() , field.getType()); - } catch (Exception e) { - setterMethod = null; - } - - return setterMethod; - } - - /** - * Indicates another {@link ManagedType} represents the same {@link Class} as this one. This method also supports a - * {@link Class} as a parameter, in this case it will return true if the passed class is exactly the - * same Java class represented by this {@link ManagedType}. - */ - @Override - public boolean equals(Object other) { - if (other == null) { - return false; - } - - return ((ManagedType) other).getType().getCanonicalName().equals(this.getType().getCanonicalName()); - } - - private synchronized Annotation[] getQualifierAnnotations(Class beanClass){ - Annotation[] annotations = beanClass.getAnnotations(); - ArrayList qualifiers = new ArrayList(annotations.length); - - for (int i=0; i parameterType; - - private final String parameterName; - - private final String parameterDescription; - - public ParameterDetail(Class parameterType, String parameterName, String parameterDescription) { - super(); - this.parameterType = parameterType; - this.parameterName = parameterName; - this.parameterDescription = parameterDescription; - } - - public Class getParameterType() { - return parameterType; - } - - public String getParameterName() { - return parameterName; - } - - public String getParameterDescription() { - return parameterDescription; - } - } -} diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/management/Management.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/management/Management.java deleted file mode 100644 index 479bc73..0000000 --- a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/management/Management.java +++ /dev/null @@ -1,358 +0,0 @@ -/* - * Demoiselle Framework - * Copyright (C) 2010 SERPRO - * ---------------------------------------------------------------------------- - * This file is part of Demoiselle Framework. - * - * Demoiselle Framework is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License version 3 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License version 3 - * along with this program; if not, see - * or write to the Free Software Foundation, Inc., 51 Franklin Street, - * Fifth Floor, Boston, MA 02110-1301, USA. - * ---------------------------------------------------------------------------- - * Este arquivo é parte do Framework Demoiselle. - * - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação - * do Software Livre (FSF). - * - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português - * para maiores detalhes. - * - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título - * "LICENCA.txt", junto com esse programa. Se não, acesse - * ou escreva para a Fundação do Software Livre (FSF) Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - */ -package br.gov.frameworkdemoiselle.internal.management; - -import java.io.Serializable; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Set; - -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.context.RequestScoped; -import javax.inject.Inject; -import javax.validation.ConstraintViolation; -import javax.validation.ConstraintViolationException; -import javax.validation.Validation; -import javax.validation.ValidationException; -import javax.validation.Validator; - -import org.slf4j.Logger; - -import br.gov.frameworkdemoiselle.annotation.ManagedProperty; -import br.gov.frameworkdemoiselle.annotation.Name; -import br.gov.frameworkdemoiselle.internal.context.ContextManager; -import br.gov.frameworkdemoiselle.internal.context.ManagedContext; -import br.gov.frameworkdemoiselle.internal.management.ManagedType.MethodDetail; -import br.gov.frameworkdemoiselle.lifecycle.ManagementExtension; -import br.gov.frameworkdemoiselle.management.AttributeChangeNotification; -import br.gov.frameworkdemoiselle.management.ManagedAttributeNotFoundException; -import br.gov.frameworkdemoiselle.management.ManagedInvokationException; -import br.gov.frameworkdemoiselle.management.NotificationManager; -import br.gov.frameworkdemoiselle.stereotype.ManagementController; -import br.gov.frameworkdemoiselle.util.Beans; -import br.gov.frameworkdemoiselle.util.ResourceBundle; - -/** - * Central class used by management extensions to obtain information, access properties and call operations over - * discovered {@link ManagementController} classes. - * - * @author SERPRO - */ -@ApplicationScoped -public class Management implements Serializable { - - private static final long serialVersionUID = 1L; - - @Inject - private Logger logger; - - @Inject - @Name("demoiselle-core-bundle") - private ResourceBundle bundle; - - private final List managedTypes = new ArrayList(); - - private Validator validator; - - public void addManagedType(ManagedType managedType) { - managedTypes.add(managedType); - logger.debug(bundle.getString("management-debug-registering-managed-type", managedType.getType() - .getCanonicalName())); - } - - /** - * @return List all discovered {@link ManagementController} classes. The returned list is a shallow copy of the - * internal list, so you are free to modify it. TODO precisamos desse clone na lista? - */ - public List getManagedTypes() { - ArrayList cloneList = new ArrayList(); - cloneList.addAll(managedTypes); - return cloneList; - } - - /** - *

- * Invoke an operation over a {@link ManagementController}. - *

- *

- * This method is not thread-safe, it's the user's responsibility to make the operations of the managed type - * synchronized if necessary. - *

- * - * @param managedType - * A type annotated with {@link ManagementController}. This method will create an (or obtain an already - * created) instance of this type and invoke the operation over it. - * @param actionName - * Name of method to be invoked, the type must have this operation on it's list - * @param params - * List of values for the operation parameters. Can be null if the operation require no - * parameters. - * @return The return value of the original invoked operation. Methods of return type void will return - * the {@link Void} type. - * @throws ManagedInvokationException - * In case the operation doesn't exist or have a different signature - */ - public Object invoke(ManagedType managedType, String actionName, Object[] params) { - if (managedTypes.contains(managedType)) { - activateContexts(managedType.getType()); - - try { - Object delegate = Beans.getReference(managedType.getType() , managedType.getQualifiers()); - MethodDetail method = managedType.getOperationMethods().get(actionName); - - if (method != null) { - try { - logger.debug(bundle.getString("management-debug-invoking-operation", actionName, managedType - .getType().getCanonicalName())); - return method.getMethod().invoke(delegate, params); - } catch (Exception e) { - throw new ManagedInvokationException(bundle.getString("management-invoke-error", actionName), e); - } - } else { - throw new ManagedInvokationException(bundle.getString("management-invoke-error", actionName)); - } - } finally { - deactivateContexts(managedType.getType()); - } - } else { - throw new ManagedInvokationException(bundle.getString("management-type-not-found")); - } - } - - /** - *

- * Retrieve the current value of a property from a managed type. Properties are attributes annotated with - * {@link ManagedProperty}. - *

- *

- * This method is not thread-safe, it's the user's responsibility to create the property's access methods from the - * managed type synchronized if necessary. - *

- * - * @param managedType - * The type that has the property the client wants to know the value of. - * @param propertyName - * The name of the property - * @return The current value of the property - * @throws ManagedAttributeNotFoundException If the given property doesn't exist or there was a problem trying to read the property value. - * @throws ManagedInvokationException If there was an error trying to invoke the getter method to read the propery value. - */ - public Object getProperty(ManagedType managedType, String propertyName) { - - if (managedTypes.contains(managedType)) { - Method getterMethod = managedType.getFields().get(propertyName).getGetterMethod(); - - if (getterMethod != null) { - logger.debug(bundle.getString("management-debug-acessing-property", getterMethod.getName(), managedType - .getType().getCanonicalName())); - - activateContexts(managedType.getType()); - - try { - Object delegate = Beans.getReference(managedType.getType() , managedType.getQualifiers()); - - return getterMethod.invoke(delegate, (Object[]) null); - } catch (Exception e) { - throw new ManagedInvokationException(bundle.getString("management-invoke-error", getterMethod.getName()), - e); - } finally { - deactivateContexts(managedType.getType()); - } - } else { - throw new ManagedAttributeNotFoundException(bundle.getString("management-read-value-error", propertyName)); - } - } else { - throw new ManagedInvokationException(bundle.getString("management-type-not-found")); - } - } - - /** - *

- * Sets a new value for a property contained inside a managed type. A property is an attribute annotated with - * {@link ManagedProperty}. - *

- *

- * This method is not thread-safe, it's the user's responsibility to create the property's access methods from the - * managed type synchronized if necessary. - *

- * - * @param managedType - * The type that has access to the property - * @param propertyName - * The name of the property - * @param newValue - * The new value of the property - * @throws ManagedInvokationException If there was an error trying to call the setter method for this property. - * @throws ManagedAttributeNotFoundException If the giver property doesn't exist or could'n be written to. - * @throws ConstraintViolationException If the property defined one or more validation constraints and setting this value violates some of those constraints. - */ - @SuppressWarnings("unchecked") - public void setProperty(ManagedType managedType, String propertyName, Object newValue) { - - if (managedTypes.contains(managedType)) { - // Procura o método set do atributo em questão - Method method = managedType.getFields().get(propertyName).getSetterMethod(); - if (method != null) { - logger.debug(bundle.getString("management-debug-setting-property", method.getName(), managedType - .getType().getCanonicalName())); - - activateContexts(managedType.getType()); - try { - // Obtém uma instância da classe gerenciada, lembrando que - // classes - // anotadas com @ManagementController são sempre singletons. - Object delegate = Beans.getReference(managedType.getType() , managedType.getQualifiers() ); - - // Se houver um validador anexado à propriedade alterada, executa o validador sobre - // o novo valor. - Validator validator = getDefaultValidator(); - if (validator != null) { - Set violations = validator.validateValue(managedType.getType(), propertyName, newValue); - if (violations.size() > 0) { - StringBuffer errorBuffer = new StringBuffer(); - for (Object objectViolation : violations) { - ConstraintViolation violation = (ConstraintViolation) objectViolation; - errorBuffer.append(violation.getMessage()).append('\r').append('\n'); - } - - if (errorBuffer.length() > 0) { - errorBuffer.insert(0, "\r\n"); - errorBuffer.insert(errorBuffer.length(), "\r\n"); - } - - throw new ConstraintViolationException(bundle.getString("management-validation-constraint-violation" - , managedType.getType().getCanonicalName(), propertyName, errorBuffer.toString()) - , (Set>) violations); - } - } else { - logger.warn(bundle.getString("management-validation-validator-not-found")); - } - - Method getterMethod = managedType.getFields().get(propertyName).getGetterMethod(); - Object oldValue; - try { - oldValue = getterMethod.invoke(delegate, (Object[]) null); - } catch (Exception e) { - oldValue = null; - } - - method.invoke(delegate, new Object[] { newValue }); - - // Manda uma notificação de mudança de atributo - NotificationManager notificationManager = Beans.getReference(NotificationManager.class); - Class attributeType = newValue != null ? newValue.getClass() : null; - - AttributeChangeNotification notification = new AttributeChangeNotification(bundle.getString( - "management-notification-attribute-changed", propertyName, managedType.getType() - .getCanonicalName()), propertyName, attributeType, oldValue, newValue); - notificationManager.sendNotification(notification); - - } catch (ConstraintViolationException ce) { - throw ce; - } catch (Exception e) { - throw new ManagedInvokationException(bundle.getString("management-invoke-error", method.getName()), e); - } finally { - deactivateContexts(managedType.getType()); - } - - } else { - throw new ManagedAttributeNotFoundException(bundle.getString("management-write-value-error", propertyName)); - } - } else { - throw new ManagedInvokationException(bundle.getString("management-type-not-found")); - } - - } - - private void activateContexts(Class managedType) { - logger.debug(bundle.getString("management-debug-starting-custom-context", - ManagedContext.class.getCanonicalName(), managedType.getCanonicalName())); - - ContextManager.activate(ManagedContext.class, RequestScoped.class); - } - - private void deactivateContexts(Class managedType) { - logger.debug(bundle.getString("management-debug-stoping-custom-context", - ManagedContext.class.getCanonicalName(), managedType.getCanonicalName())); - - ContextManager.deactivate(ManagedContext.class, RequestScoped.class); - } - - public void shutdown(Collection> monitoringExtensions) { - - for (Class monitoringExtensionClass : monitoringExtensions) { - - ManagementExtension monitoringExtension = Beans.getReference(monitoringExtensionClass); - - monitoringExtension.shutdown(this.getManagedTypes()); - - logger.debug(bundle.getString("management-debug-removing-management-extension", monitoringExtension - .getClass().getCanonicalName())); - - } - - } - - public void initialize(Collection> monitoringExtensions) { - - for (Class monitoringExtensionClass : monitoringExtensions) { - ManagementExtension monitoringExtension = Beans.getReference(monitoringExtensionClass); - - logger.debug(bundle.getString("management-debug-processing-management-extension", monitoringExtension - .getClass().getCanonicalName())); - - monitoringExtension.initialize(this.getManagedTypes()); - } - - } - - private Validator getDefaultValidator() { - if (validator == null) { - try { - this.validator = Validation.buildDefaultValidatorFactory().getValidator(); - } catch (ValidationException e) { - this.validator = null; - } - } - - return this.validator; - } - - -} diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/management/ManagementNotificationEventImpl.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/management/ManagementNotificationEventImpl.java deleted file mode 100644 index caf5e09..0000000 --- a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/management/ManagementNotificationEventImpl.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Demoiselle Framework - * Copyright (C) 2010 SERPRO - * ---------------------------------------------------------------------------- - * This file is part of Demoiselle Framework. - * - * Demoiselle Framework is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License version 3 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License version 3 - * along with this program; if not, see - * or write to the Free Software Foundation, Inc., 51 Franklin Street, - * Fifth Floor, Boston, MA 02110-1301, USA. - * ---------------------------------------------------------------------------- - * Este arquivo é parte do Framework Demoiselle. - * - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação - * do Software Livre (FSF). - * - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português - * para maiores detalhes. - * - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título - * "LICENCA.txt", junto com esse programa. Se não, acesse - * ou escreva para a Fundação do Software Livre (FSF) Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - */ -package br.gov.frameworkdemoiselle.internal.management; - -import br.gov.frameworkdemoiselle.management.GenericNotification; -import br.gov.frameworkdemoiselle.management.NotificationManager; - -/** - * Event fired when a notification is sent by {@link NotificationManager}. - * Implementators can capture this event and be notified when the {@link NotificationManager} - * sends notifications, so they can pass the notification to the underlying technology. - * - * @author SERPRO - * - */ -public class ManagementNotificationEventImpl implements br.gov.frameworkdemoiselle.management.ManagementNotificationEvent { - - private GenericNotification notification; - - public ManagementNotificationEventImpl(GenericNotification notification){ - this.notification = notification; - } - - public GenericNotification getNotification() { - return notification; - } - - public void setNotification(GenericNotification notification) { - this.notification = notification; - } -} diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/management/qualifier/AttributeChange.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/management/qualifier/AttributeChange.java deleted file mode 100644 index c8d23ff..0000000 --- a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/management/qualifier/AttributeChange.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Demoiselle Framework - * Copyright (C) 2010 SERPRO - * ---------------------------------------------------------------------------- - * This file is part of Demoiselle Framework. - * - * Demoiselle Framework is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License version 3 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License version 3 - * along with this program; if not, see - * or write to the Free Software Foundation, Inc., 51 Franklin Street, - * Fifth Floor, Boston, MA 02110-1301, USA. - * ---------------------------------------------------------------------------- - * Este arquivo é parte do Framework Demoiselle. - * - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação - * do Software Livre (FSF). - * - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português - * para maiores detalhes. - * - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título - * "LICENCA.txt", junto com esse programa. Se não, acesse - * ou escreva para a Fundação do Software Livre (FSF) Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - */ -package br.gov.frameworkdemoiselle.internal.management.qualifier; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import javax.inject.Qualifier; - -import br.gov.frameworkdemoiselle.management.AttributeChangeNotification; -import br.gov.frameworkdemoiselle.management.ManagementNotificationEvent; - -/** - * - * Enables {@link ManagementNotificationEvent} observers to trigger only with notifications - * of the specialized type {@link AttributeChangeNotification}. - * - * @author SERPRO - * - */ -@Qualifier -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER, ElementType.TYPE}) -public @interface AttributeChange { - -} diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/management/qualifier/Generic.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/management/qualifier/Generic.java deleted file mode 100644 index e38e021..0000000 --- a/impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/management/qualifier/Generic.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Demoiselle Framework - * Copyright (C) 2010 SERPRO - * ---------------------------------------------------------------------------- - * This file is part of Demoiselle Framework. - * - * Demoiselle Framework is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License version 3 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License version 3 - * along with this program; if not, see - * or write to the Free Software Foundation, Inc., 51 Franklin Street, - * Fifth Floor, Boston, MA 02110-1301, USA. - * ---------------------------------------------------------------------------- - * Este arquivo é parte do Framework Demoiselle. - * - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação - * do Software Livre (FSF). - * - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português - * para maiores detalhes. - * - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título - * "LICENCA.txt", junto com esse programa. Se não, acesse - * ou escreva para a Fundação do Software Livre (FSF) Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - */ -package br.gov.frameworkdemoiselle.internal.management.qualifier; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import javax.inject.Qualifier; - -import br.gov.frameworkdemoiselle.management.ManagementNotificationEvent; -import br.gov.frameworkdemoiselle.management.GenericNotification; - -/** - * - * Enables {@link ManagementNotificationEvent} observers to trigger only with notifications - * of the base type {@link GenericNotification}. - * - * @author SERPRO - * - */ -@Qualifier -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER, ElementType.TYPE}) -public @interface Generic { - -} diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/lifecycle/ManagementExtension.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/lifecycle/ManagementExtension.java deleted file mode 100644 index a923824..0000000 --- a/impl/core/src/main/java/br/gov/frameworkdemoiselle/lifecycle/ManagementExtension.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Demoiselle Framework - * Copyright (C) 2010 SERPRO - * ---------------------------------------------------------------------------- - * This file is part of Demoiselle Framework. - * - * Demoiselle Framework is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License version 3 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License version 3 - * along with this program; if not, see - * or write to the Free Software Foundation, Inc., 51 Franklin Street, - * Fifth Floor, Boston, MA 02110-1301, USA. - * ---------------------------------------------------------------------------- - * Este arquivo é parte do Framework Demoiselle. - * - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação - * do Software Livre (FSF). - * - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português - * para maiores detalhes. - * - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título - * "LICENCA.txt", junto com esse programa. Se não, acesse - * ou escreva para a Fundação do Software Livre (FSF) Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - */ -package br.gov.frameworkdemoiselle.lifecycle; - -import java.util.List; - -import br.gov.frameworkdemoiselle.internal.management.ManagedType; -import br.gov.frameworkdemoiselle.stereotype.ManagementController; - -/** - *

- * Interface defining the lifecycle of a management extension, an extension capable of exposing - * {@link ManagementController}'s to external clients in one of the available management technologies, such as JMX or - * SNMP. - *

- *

- * To include a management extension into the management lifecycle, it just needs to implement this interface and be a - * CDI bean (have a beans.xml file inside the META-INF folder of it's java package). The Demoiselle Core - * lifecycle controller will call the {@link #initialize(List managedTypes)} and {@link #shutdown(List managedTypes)} - * methods at the apropriate times. - *

- * - * @author SERPRO - */ -public interface ManagementExtension { - - /** - * This method is called during the application initialization process for each concrete implementation of this - * interface. - * - * @param managedTypes - * The list of discovered {@link ManagementController} classes. - */ - void initialize(List managedTypes); - - /** - * This method is called during the application shutdown process for each concrete implementation of this interface. - * - * @param managedTypes - * The list of discovered {@link ManagementController} classes. - */ - void shutdown(List managedTypes); - -} diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/management/ManagementExtension.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/management/ManagementExtension.java new file mode 100644 index 0000000..9e2ab73 --- /dev/null +++ b/impl/core/src/main/java/br/gov/frameworkdemoiselle/management/ManagementExtension.java @@ -0,0 +1,78 @@ +/* + * Demoiselle Framework + * Copyright (C) 2010 SERPRO + * ---------------------------------------------------------------------------- + * This file is part of Demoiselle Framework. + * + * Demoiselle Framework is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License version 3 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License version 3 + * along with this program; if not, see + * or write to the Free Software Foundation, Inc., 51 Franklin Street, + * Fifth Floor, Boston, MA 02110-1301, USA. + * ---------------------------------------------------------------------------- + * Este arquivo é parte do Framework Demoiselle. + * + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação + * do Software Livre (FSF). + * + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português + * para maiores detalhes. + * + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título + * "LICENCA.txt", junto com esse programa. Se não, acesse + * ou escreva para a Fundação do Software Livre (FSF) Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. + */ +package br.gov.frameworkdemoiselle.management; + +import java.util.List; + +import br.gov.frameworkdemoiselle.internal.implementation.ManagedType; +import br.gov.frameworkdemoiselle.stereotype.ManagementController; + +/** + *

+ * Interface defining the lifecycle of a management extension, an extension capable of exposing + * {@link ManagementController}'s to external clients in one of the available management technologies, such as JMX or + * SNMP. + *

+ *

+ * To include a management extension into the management lifecycle, it just needs to implement this interface and be a + * CDI bean (have a beans.xml file inside the META-INF folder of it's java package). The Demoiselle Core + * lifecycle controller will call the {@link #initialize(List managedTypes)} and {@link #shutdown(List managedTypes)} + * methods at the apropriate times. + *

+ * + * @author SERPRO + */ +public interface ManagementExtension { + + /** + * This method is called during the application initialization process for each concrete implementation of this + * interface. + * + * @param managedTypes + * The list of discovered {@link ManagementController} classes. + */ + void initialize(List managedTypes); + + /** + * This method is called during the application shutdown process for each concrete implementation of this interface. + * + * @param managedTypes + * The list of discovered {@link ManagementController} classes. + */ + void shutdown(List managedTypes); + +} diff --git a/impl/core/src/main/java/br/gov/frameworkdemoiselle/management/NotificationManager.java b/impl/core/src/main/java/br/gov/frameworkdemoiselle/management/NotificationManager.java index 95242f3..fae0912 100644 --- a/impl/core/src/main/java/br/gov/frameworkdemoiselle/management/NotificationManager.java +++ b/impl/core/src/main/java/br/gov/frameworkdemoiselle/management/NotificationManager.java @@ -40,8 +40,8 @@ import javax.enterprise.context.ApplicationScoped; import javax.enterprise.event.Observes; import javax.inject.Inject; -import br.gov.frameworkdemoiselle.internal.management.qualifier.AttributeChange; -import br.gov.frameworkdemoiselle.internal.management.qualifier.Generic; +import br.gov.frameworkdemoiselle.internal.implementation.AttributeChange; +import br.gov.frameworkdemoiselle.internal.implementation.Generic; import br.gov.frameworkdemoiselle.util.Beans; /** diff --git a/impl/core/src/test/java/management/bootstrap/ManagementBootstrapTest.java b/impl/core/src/test/java/management/bootstrap/ManagementBootstrapTest.java index f4e1065..1e00d29 100644 --- a/impl/core/src/test/java/management/bootstrap/ManagementBootstrapTest.java +++ b/impl/core/src/test/java/management/bootstrap/ManagementBootstrapTest.java @@ -50,9 +50,9 @@ import org.junit.Test; import org.junit.runner.RunWith; import test.Tests; -import br.gov.frameworkdemoiselle.internal.management.ManagedType; +import br.gov.frameworkdemoiselle.internal.implementation.ManagedType; import br.gov.frameworkdemoiselle.lifecycle.AfterShutdownProccess; -import br.gov.frameworkdemoiselle.lifecycle.ManagementExtension; +import br.gov.frameworkdemoiselle.management.ManagementExtension; import br.gov.frameworkdemoiselle.util.Beans; @RunWith(Arquillian.class) diff --git a/impl/core/src/test/java/management/notification/NotificationTest.java b/impl/core/src/test/java/management/notification/NotificationTest.java index 618f8a2..326a576 100644 --- a/impl/core/src/test/java/management/notification/NotificationTest.java +++ b/impl/core/src/test/java/management/notification/NotificationTest.java @@ -50,8 +50,8 @@ import org.junit.runner.RunWith; import test.Tests; import br.gov.frameworkdemoiselle.annotation.Name; -import br.gov.frameworkdemoiselle.internal.management.ManagedType; -import br.gov.frameworkdemoiselle.internal.management.Management; +import br.gov.frameworkdemoiselle.internal.implementation.ManagedType; +import br.gov.frameworkdemoiselle.internal.implementation.Management; import br.gov.frameworkdemoiselle.management.AttributeChangeNotification; import br.gov.frameworkdemoiselle.management.GenericNotification; import br.gov.frameworkdemoiselle.management.NotificationManager; diff --git a/impl/core/src/test/java/management/testclasses/DummyManagementExtension.java b/impl/core/src/test/java/management/testclasses/DummyManagementExtension.java index 8ac61e1..41d5cf4 100644 --- a/impl/core/src/test/java/management/testclasses/DummyManagementExtension.java +++ b/impl/core/src/test/java/management/testclasses/DummyManagementExtension.java @@ -41,8 +41,8 @@ import java.util.List; import javax.inject.Inject; -import br.gov.frameworkdemoiselle.internal.management.ManagedType; -import br.gov.frameworkdemoiselle.lifecycle.ManagementExtension; +import br.gov.frameworkdemoiselle.internal.implementation.ManagedType; +import br.gov.frameworkdemoiselle.management.ManagementExtension; public class DummyManagementExtension implements ManagementExtension { diff --git a/impl/core/src/test/java/management/testclasses/DummyNotificationListener.java b/impl/core/src/test/java/management/testclasses/DummyNotificationListener.java index 4a63791..7ba3493 100644 --- a/impl/core/src/test/java/management/testclasses/DummyNotificationListener.java +++ b/impl/core/src/test/java/management/testclasses/DummyNotificationListener.java @@ -39,8 +39,8 @@ package management.testclasses; import javax.enterprise.context.ApplicationScoped; import javax.enterprise.event.Observes; -import br.gov.frameworkdemoiselle.internal.management.qualifier.AttributeChange; -import br.gov.frameworkdemoiselle.internal.management.qualifier.Generic; +import br.gov.frameworkdemoiselle.internal.implementation.AttributeChange; +import br.gov.frameworkdemoiselle.internal.implementation.Generic; import br.gov.frameworkdemoiselle.management.AttributeChangeNotification; import br.gov.frameworkdemoiselle.management.ManagementNotificationEvent; import br.gov.frameworkdemoiselle.management.NotificationManager; diff --git a/impl/core/src/test/java/management/testclasses/ManagedClassStore.java b/impl/core/src/test/java/management/testclasses/ManagedClassStore.java index 776e625..1359014 100644 --- a/impl/core/src/test/java/management/testclasses/ManagedClassStore.java +++ b/impl/core/src/test/java/management/testclasses/ManagedClassStore.java @@ -42,8 +42,8 @@ import java.util.List; import javax.enterprise.context.ApplicationScoped; -import br.gov.frameworkdemoiselle.internal.management.ManagedType; -import br.gov.frameworkdemoiselle.internal.management.Management; +import br.gov.frameworkdemoiselle.internal.implementation.ManagedType; +import br.gov.frameworkdemoiselle.internal.implementation.Management; import br.gov.frameworkdemoiselle.util.Beans; /** -- libgit2 0.21.2