Commit 4b6c112d89337330f2b868b5fbc6d486db221eef
1 parent
1cb0ddf6
Exists in
master
Realizando merge
Showing
31 changed files
with
1325 additions
and
1048 deletions
Show diff stats
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/bootstrap/ManagementBootstrap.java
| ... | ... | @@ -55,10 +55,10 @@ import javax.enterprise.inject.spi.ProcessAnnotatedType; |
| 55 | 55 | import br.gov.frameworkdemoiselle.DemoiselleException; |
| 56 | 56 | import br.gov.frameworkdemoiselle.internal.context.ContextManager; |
| 57 | 57 | import br.gov.frameworkdemoiselle.internal.context.ManagedContext; |
| 58 | -import br.gov.frameworkdemoiselle.internal.management.ManagedType; | |
| 59 | -import br.gov.frameworkdemoiselle.internal.management.Management; | |
| 58 | +import br.gov.frameworkdemoiselle.internal.implementation.ManagedType; | |
| 59 | +import br.gov.frameworkdemoiselle.internal.implementation.Management; | |
| 60 | 60 | import br.gov.frameworkdemoiselle.lifecycle.AfterShutdownProccess; |
| 61 | -import br.gov.frameworkdemoiselle.lifecycle.ManagementExtension; | |
| 61 | +import br.gov.frameworkdemoiselle.management.ManagementExtension; | |
| 62 | 62 | import br.gov.frameworkdemoiselle.stereotype.ManagementController; |
| 63 | 63 | import br.gov.frameworkdemoiselle.util.Beans; |
| 64 | 64 | import br.gov.frameworkdemoiselle.util.ResourceBundle; | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/AttributeChange.java
0 → 100644
| ... | ... | @@ -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.implementation; | |
| 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.AttributeChangeNotification; | |
| 47 | +import br.gov.frameworkdemoiselle.management.ManagementNotificationEvent; | |
| 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/implementation/Generic.java
0 → 100644
| ... | ... | @@ -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.implementation; | |
| 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.ManagementNotificationEvent; | |
| 47 | +import br.gov.frameworkdemoiselle.management.GenericNotification; | |
| 48 | + | |
| 49 | +/** | |
| 50 | + * | |
| 51 | + * Enables {@link ManagementNotificationEvent} observers to trigger only with notifications | |
| 52 | + * of the base type {@link GenericNotification}. | |
| 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/implementation/ManagedType.java
0 → 100644
| ... | ... | @@ -0,0 +1,388 @@ |
| 1 | +/* | |
| 2 | + * Demoiselle Framework | |
| 3 | + * Copyright (C) 2010 SERPRO | |
| 4 | + * ---------------------------------------------------------------------------- | |
| 5 | + * This file is part of Demoiselle Framework. | |
| 6 | + * | |
| 7 | + * Demoiselle Framework is free software; you can redistribute it and/or | |
| 8 | + * modify it under the terms of the GNU Lesser General Public License version 3 | |
| 9 | + * as published by the Free Software Foundation. | |
| 10 | + * | |
| 11 | + * This program is distributed in the hope that it will be useful, | |
| 12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 | + * GNU General Public License for more details. | |
| 15 | + * | |
| 16 | + * You should have received a copy of the GNU Lesser General Public License version 3 | |
| 17 | + * along with this program; if not, see <http://www.gnu.org/licenses/> | |
| 18 | + * or write to the Free Software Foundation, Inc., 51 Franklin Street, | |
| 19 | + * Fifth Floor, Boston, MA 02110-1301, USA. | |
| 20 | + * ---------------------------------------------------------------------------- | |
| 21 | + * Este arquivo é parte do Framework Demoiselle. | |
| 22 | + * | |
| 23 | + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | |
| 24 | + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | |
| 25 | + * do Software Livre (FSF). | |
| 26 | + * | |
| 27 | + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | |
| 28 | + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | |
| 29 | + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | |
| 30 | + * para maiores detalhes. | |
| 31 | + * | |
| 32 | + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | |
| 33 | + * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/> | |
| 34 | + * ou escreva para a Fundação do Software Livre (FSF) Inc., | |
| 35 | + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | |
| 36 | + */ | |
| 37 | +package br.gov.frameworkdemoiselle.internal.implementation; | |
| 38 | + | |
| 39 | +import java.lang.annotation.Annotation; | |
| 40 | +import java.lang.reflect.Field; | |
| 41 | +import java.lang.reflect.Method; | |
| 42 | +import java.util.ArrayList; | |
| 43 | +import java.util.Locale; | |
| 44 | +import java.util.TreeMap; | |
| 45 | + | |
| 46 | +import javax.inject.Qualifier; | |
| 47 | + | |
| 48 | +import br.gov.frameworkdemoiselle.DemoiselleException; | |
| 49 | +import br.gov.frameworkdemoiselle.annotation.ManagedOperation; | |
| 50 | +import br.gov.frameworkdemoiselle.annotation.ManagedProperty; | |
| 51 | +import br.gov.frameworkdemoiselle.annotation.ManagedProperty.ManagedPropertyAccess; | |
| 52 | +import br.gov.frameworkdemoiselle.annotation.OperationParameter; | |
| 53 | +import br.gov.frameworkdemoiselle.annotation.OperationType; | |
| 54 | +import br.gov.frameworkdemoiselle.stereotype.ManagementController; | |
| 55 | +import br.gov.frameworkdemoiselle.util.ResourceBundle; | |
| 56 | + | |
| 57 | +/** | |
| 58 | + * <p>Package class containing information about a discovered {@link ManagementController}.</p> | |
| 59 | + * | |
| 60 | + * <p>Instances if this class are passed to each discovered management extension during bootstrap so they can have | |
| 61 | + * enough information to expose all discovered {@link ManagementController}'s to management clients.</p> | |
| 62 | + * | |
| 63 | + * @author SERPRO | |
| 64 | + */ | |
| 65 | +public class ManagedType { | |
| 66 | + | |
| 67 | + private Class<?> type; | |
| 68 | + | |
| 69 | + private Annotation[] qualifiers; | |
| 70 | + | |
| 71 | + private TreeMap<String, FieldDetail> fields; | |
| 72 | + | |
| 73 | + private TreeMap<String, MethodDetail> operationMethods; | |
| 74 | + | |
| 75 | + private ResourceBundle bundle; | |
| 76 | + | |
| 77 | + private String description; | |
| 78 | + | |
| 79 | + public ManagedType(Class<?> type) { | |
| 80 | + bundle = new ResourceBundle("demoiselle-core-bundle",Locale.getDefault()); | |
| 81 | + | |
| 82 | + if (type == null) { | |
| 83 | + throw new DemoiselleException(bundle.getString("management-null-class-defined")); | |
| 84 | + } | |
| 85 | + if (!type.isAnnotationPresent(ManagementController.class)) { | |
| 86 | + throw new DemoiselleException(bundle.getString("management-no-annotation-found", type.getCanonicalName())); | |
| 87 | + } | |
| 88 | + | |
| 89 | + this.type = type; | |
| 90 | + fields = new TreeMap<String, FieldDetail>(); | |
| 91 | + operationMethods = new TreeMap<String, MethodDetail>(); | |
| 92 | + this.description = type.getAnnotation(ManagementController.class).description(); | |
| 93 | + this.qualifiers = getQualifierAnnotations(type); | |
| 94 | + | |
| 95 | + initialize(); | |
| 96 | + } | |
| 97 | + | |
| 98 | + public Class<?> getType() { | |
| 99 | + return type; | |
| 100 | + } | |
| 101 | + | |
| 102 | + public String getDescription() { | |
| 103 | + return description; | |
| 104 | + } | |
| 105 | + | |
| 106 | + public TreeMap<String, FieldDetail> getFields() { | |
| 107 | + return fields; | |
| 108 | + } | |
| 109 | + | |
| 110 | + public TreeMap<String, MethodDetail> getOperationMethods() { | |
| 111 | + return operationMethods; | |
| 112 | + } | |
| 113 | + | |
| 114 | + /** | |
| 115 | + * <p>Return a (possibly empty) list of all qualifiers this type have. Qualifiers | |
| 116 | + * are any annotations marked as {@link Qualifier}.</p> | |
| 117 | + * | |
| 118 | + * <p>This method returns the true list of qualifiers. If implementators change this list, it will | |
| 119 | + * affect future calls of this method. This is so that resources can be spared by not creating many instances of this list.</p> | |
| 120 | + * | |
| 121 | + */ | |
| 122 | + public Annotation[] getQualifiers(){ | |
| 123 | + return this.qualifiers; | |
| 124 | + } | |
| 125 | + | |
| 126 | + private void initialize() { | |
| 127 | + // Para cada atributo verifica se ele está anotado com ManagedProperty e extrai as informações dele (método get, set e | |
| 128 | + // descrição do atributo). | |
| 129 | + Field[] fields = type.getDeclaredFields(); | |
| 130 | + if (fields != null) { | |
| 131 | + for (Field field : fields) { | |
| 132 | + if (field.isAnnotationPresent(ManagedProperty.class)) { | |
| 133 | + // Obtém os métodos GET e SET para esta propriedade | |
| 134 | + Method getterMethod = getGetterMethod(field); | |
| 135 | + Method setterMethod = getSetterMethod(field); | |
| 136 | + if (getterMethod == null && setterMethod == null) { | |
| 137 | + throw new DemoiselleException(bundle.getString("management-invalid-property-no-getter-setter", | |
| 138 | + type.getSimpleName(), field.getName())); | |
| 139 | + } else if ((getterMethod != null && getterMethod.isAnnotationPresent(ManagedOperation.class)) | |
| 140 | + || (setterMethod != null && setterMethod.isAnnotationPresent(ManagedOperation.class))) { | |
| 141 | + throw new DemoiselleException(bundle.getString("management-invalid-property-as-operation", | |
| 142 | + type.getSimpleName())); | |
| 143 | + } | |
| 144 | + | |
| 145 | + String propertyDescription = field.getAnnotation(ManagedProperty.class).description(); | |
| 146 | + | |
| 147 | + this.fields.put(field.getName(), new FieldDetail(field, propertyDescription, getterMethod, | |
| 148 | + setterMethod)); | |
| 149 | + } | |
| 150 | + } | |
| 151 | + } | |
| 152 | + | |
| 153 | + // Para cada metodo verifica se ele está anotado com ManagedOperation e cria um MBeanOperationInfo para ele. | |
| 154 | + Method[] methodList = type.getMethods(); | |
| 155 | + if (methodList != null) { | |
| 156 | + for (Method method : methodList) { | |
| 157 | + ManagedOperation opAnnotation = method.getAnnotation(ManagedOperation.class); | |
| 158 | + | |
| 159 | + if (opAnnotation != null) { | |
| 160 | + // Lemos as informações sobre o método e criamos uma instância | |
| 161 | + // de MethodDetail para representar este método como uma | |
| 162 | + // operação. | |
| 163 | + | |
| 164 | + Class<?>[] parameterTypes = method.getParameterTypes(); | |
| 165 | + Annotation[][] parameterAnnotations = method.getParameterAnnotations(); | |
| 166 | + ParameterDetail[] parameterDetails = new ParameterDetail[parameterTypes.length]; | |
| 167 | + OperationType operationType = opAnnotation.type(); | |
| 168 | + | |
| 169 | + for (int i = 0; i < parameterTypes.length; i++) { | |
| 170 | + OperationParameter paramAnnotation = null; | |
| 171 | + for (Annotation annotation : parameterAnnotations[i]) { | |
| 172 | + if (annotation.annotationType() == OperationParameter.class) { | |
| 173 | + paramAnnotation = (OperationParameter) annotation; | |
| 174 | + break; | |
| 175 | + } | |
| 176 | + } | |
| 177 | + | |
| 178 | + String name = paramAnnotation != null ? paramAnnotation.name() : ("arg" + i); | |
| 179 | + String description = paramAnnotation != null ? paramAnnotation.description() : null; | |
| 180 | + | |
| 181 | + parameterDetails[i] = new ParameterDetail(parameterTypes[i], name, description); | |
| 182 | + } | |
| 183 | + | |
| 184 | + // Com todas as informações, criamos nossa instância de MethodDetail e | |
| 185 | + // acrescentamos na lista de todas as operações. | |
| 186 | + MethodDetail detail = new MethodDetail(method, opAnnotation.description(), operationType, parameterDetails); | |
| 187 | + operationMethods.put(method.getName(), detail); | |
| 188 | + } | |
| 189 | + } | |
| 190 | + } | |
| 191 | + } | |
| 192 | + | |
| 193 | + /** | |
| 194 | + * Returns the public getter method for a given field, or <code>null</code> if no getter method can be found. | |
| 195 | + */ | |
| 196 | + private Method getGetterMethod(Field field) { | |
| 197 | + StringBuffer getterMethodName = new StringBuffer() | |
| 198 | + .append("get") | |
| 199 | + .append(field.getName().substring(0, 1).toUpperCase()) | |
| 200 | + .append(field.getName().substring(1)); | |
| 201 | + | |
| 202 | + //Se propriedade está anotada como WRITE-ONLY, ignora essa etapa. | |
| 203 | + ManagedProperty annotation = field.getAnnotation(ManagedProperty.class); | |
| 204 | + if (annotation.accessLevel() == ManagedPropertyAccess.WRITE_ONLY){ | |
| 205 | + return null; | |
| 206 | + } | |
| 207 | + | |
| 208 | + Method getterMethod; | |
| 209 | + | |
| 210 | + try { | |
| 211 | + getterMethod = type.getMethod(getterMethodName.toString()); | |
| 212 | + } catch (Exception e) { | |
| 213 | + getterMethod = null; | |
| 214 | + } | |
| 215 | + | |
| 216 | + // Se atributo for boolean, procura método getter no formato "isAttribute". | |
| 217 | + if (getterMethod == null | |
| 218 | + && (Boolean.TYPE.isAssignableFrom(field.getType()) || Boolean.class.isAssignableFrom(field.getType()))) { | |
| 219 | + // Boolean.TYPE representa o tipo primitivo "boolean", Boolean.class é a classe wrapper. | |
| 220 | + getterMethodName = new StringBuffer() | |
| 221 | + .append("is") | |
| 222 | + .append(field.getName().substring(0, 1).toUpperCase()) | |
| 223 | + .append(field.getName().substring(1).toUpperCase()); | |
| 224 | + | |
| 225 | + try { | |
| 226 | + getterMethod = type.getMethod(getterMethodName.toString()); | |
| 227 | + } catch (Exception e) { | |
| 228 | + getterMethod = null; | |
| 229 | + } | |
| 230 | + } | |
| 231 | + | |
| 232 | + return getterMethod; | |
| 233 | + } | |
| 234 | + | |
| 235 | + /** | |
| 236 | + * Returns the public setter method for a given field, or <code>null</code> if no setter method can be found. | |
| 237 | + */ | |
| 238 | + private Method getSetterMethod(Field field) { | |
| 239 | + | |
| 240 | + //Se propriedade está anotada como READ-ONLY, ignora essa etapa. | |
| 241 | + ManagedProperty annotation = field.getAnnotation(ManagedProperty.class); | |
| 242 | + if (annotation.accessLevel() == ManagedPropertyAccess.READ_ONLY){ | |
| 243 | + return null; | |
| 244 | + } | |
| 245 | + | |
| 246 | + StringBuffer setterMethodName = new StringBuffer() | |
| 247 | + .append("set") | |
| 248 | + .append(field.getName().substring(0, 1).toUpperCase()) | |
| 249 | + .append(field.getName().substring(1)); | |
| 250 | + | |
| 251 | + Method setterMethod; | |
| 252 | + | |
| 253 | + try { | |
| 254 | + setterMethod = type.getMethod(setterMethodName.toString() , field.getType()); | |
| 255 | + } catch (Exception e) { | |
| 256 | + setterMethod = null; | |
| 257 | + } | |
| 258 | + | |
| 259 | + return setterMethod; | |
| 260 | + } | |
| 261 | + | |
| 262 | + /** | |
| 263 | + * Indicates another {@link ManagedType} represents the same {@link Class} as this one. This method also supports a | |
| 264 | + * {@link Class} as a parameter, in this case it will return <code>true</code> if the passed class is exactly the | |
| 265 | + * same Java class represented by this {@link ManagedType}. | |
| 266 | + */ | |
| 267 | + @Override | |
| 268 | + public boolean equals(Object other) { | |
| 269 | + if (other == null) { | |
| 270 | + return false; | |
| 271 | + } | |
| 272 | + | |
| 273 | + return ((ManagedType) other).getType().getCanonicalName().equals(this.getType().getCanonicalName()); | |
| 274 | + } | |
| 275 | + | |
| 276 | + private synchronized Annotation[] getQualifierAnnotations(Class<?> beanClass){ | |
| 277 | + Annotation[] annotations = beanClass.getAnnotations(); | |
| 278 | + ArrayList<Annotation> qualifiers = new ArrayList<Annotation>(annotations.length); | |
| 279 | + | |
| 280 | + for (int i=0; i<annotations.length; i++){ | |
| 281 | + if (annotations[i].annotationType().getAnnotation(Qualifier.class) != null){ | |
| 282 | + qualifiers.add(annotations[i]); | |
| 283 | + } | |
| 284 | + } | |
| 285 | + | |
| 286 | + return qualifiers.toArray(new Annotation[0]); | |
| 287 | + } | |
| 288 | + | |
| 289 | + public final class FieldDetail { | |
| 290 | + | |
| 291 | + private final Field field; | |
| 292 | + | |
| 293 | + private final String description; | |
| 294 | + | |
| 295 | + private Method getterMethod; | |
| 296 | + | |
| 297 | + private Method setterMethod; | |
| 298 | + | |
| 299 | + public FieldDetail(Field field, String description, Method getterMethod, Method setterMethod) { | |
| 300 | + super(); | |
| 301 | + this.field = field; | |
| 302 | + this.description = description; | |
| 303 | + this.getterMethod = getterMethod; | |
| 304 | + this.setterMethod = setterMethod; | |
| 305 | + } | |
| 306 | + | |
| 307 | + public Field getField() { | |
| 308 | + return field; | |
| 309 | + } | |
| 310 | + | |
| 311 | + public String getDescription() { | |
| 312 | + return description; | |
| 313 | + } | |
| 314 | + | |
| 315 | + public Method getGetterMethod() { | |
| 316 | + return getterMethod; | |
| 317 | + } | |
| 318 | + | |
| 319 | + public Method getSetterMethod() { | |
| 320 | + return setterMethod; | |
| 321 | + } | |
| 322 | + | |
| 323 | + } | |
| 324 | + | |
| 325 | + public final class MethodDetail { | |
| 326 | + | |
| 327 | + private final Method method; | |
| 328 | + | |
| 329 | + private final ParameterDetail[] parameterTypers; | |
| 330 | + | |
| 331 | + private final String description; | |
| 332 | + | |
| 333 | + private final OperationType type; | |
| 334 | + | |
| 335 | + public MethodDetail(Method method, String description, OperationType type,ParameterDetail[] parameterTypers) { | |
| 336 | + super(); | |
| 337 | + this.method = method; | |
| 338 | + this.description = description; | |
| 339 | + this.type = type; | |
| 340 | + this.parameterTypers = parameterTypers; | |
| 341 | + } | |
| 342 | + | |
| 343 | + public Method getMethod() { | |
| 344 | + return method; | |
| 345 | + } | |
| 346 | + | |
| 347 | + public ParameterDetail[] getParameterTypers() { | |
| 348 | + return parameterTypers; | |
| 349 | + } | |
| 350 | + | |
| 351 | + public String getDescription() { | |
| 352 | + return description; | |
| 353 | + } | |
| 354 | + | |
| 355 | + public OperationType getType() { | |
| 356 | + return type; | |
| 357 | + } | |
| 358 | + | |
| 359 | + } | |
| 360 | + | |
| 361 | + public final class ParameterDetail { | |
| 362 | + | |
| 363 | + private final Class<?> parameterType; | |
| 364 | + | |
| 365 | + private final String parameterName; | |
| 366 | + | |
| 367 | + private final String parameterDescription; | |
| 368 | + | |
| 369 | + public ParameterDetail(Class<?> parameterType, String parameterName, String parameterDescription) { | |
| 370 | + super(); | |
| 371 | + this.parameterType = parameterType; | |
| 372 | + this.parameterName = parameterName; | |
| 373 | + this.parameterDescription = parameterDescription; | |
| 374 | + } | |
| 375 | + | |
| 376 | + public Class<?> getParameterType() { | |
| 377 | + return parameterType; | |
| 378 | + } | |
| 379 | + | |
| 380 | + public String getParameterName() { | |
| 381 | + return parameterName; | |
| 382 | + } | |
| 383 | + | |
| 384 | + public String getParameterDescription() { | |
| 385 | + return parameterDescription; | |
| 386 | + } | |
| 387 | + } | |
| 388 | +} | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/Management.java
0 → 100644
| ... | ... | @@ -0,0 +1,358 @@ |
| 1 | +/* | |
| 2 | + * Demoiselle Framework | |
| 3 | + * Copyright (C) 2010 SERPRO | |
| 4 | + * ---------------------------------------------------------------------------- | |
| 5 | + * This file is part of Demoiselle Framework. | |
| 6 | + * | |
| 7 | + * Demoiselle Framework is free software; you can redistribute it and/or | |
| 8 | + * modify it under the terms of the GNU Lesser General Public License version 3 | |
| 9 | + * as published by the Free Software Foundation. | |
| 10 | + * | |
| 11 | + * This program is distributed in the hope that it will be useful, | |
| 12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 | + * GNU General Public License for more details. | |
| 15 | + * | |
| 16 | + * You should have received a copy of the GNU Lesser General Public License version 3 | |
| 17 | + * along with this program; if not, see <http://www.gnu.org/licenses/> | |
| 18 | + * or write to the Free Software Foundation, Inc., 51 Franklin Street, | |
| 19 | + * Fifth Floor, Boston, MA 02110-1301, USA. | |
| 20 | + * ---------------------------------------------------------------------------- | |
| 21 | + * Este arquivo é parte do Framework Demoiselle. | |
| 22 | + * | |
| 23 | + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | |
| 24 | + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | |
| 25 | + * do Software Livre (FSF). | |
| 26 | + * | |
| 27 | + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | |
| 28 | + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | |
| 29 | + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | |
| 30 | + * para maiores detalhes. | |
| 31 | + * | |
| 32 | + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | |
| 33 | + * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/> | |
| 34 | + * ou escreva para a Fundação do Software Livre (FSF) Inc., | |
| 35 | + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | |
| 36 | + */ | |
| 37 | +package br.gov.frameworkdemoiselle.internal.implementation; | |
| 38 | + | |
| 39 | +import java.io.Serializable; | |
| 40 | +import java.lang.reflect.Method; | |
| 41 | +import java.util.ArrayList; | |
| 42 | +import java.util.Collection; | |
| 43 | +import java.util.List; | |
| 44 | +import java.util.Set; | |
| 45 | + | |
| 46 | +import javax.enterprise.context.ApplicationScoped; | |
| 47 | +import javax.enterprise.context.RequestScoped; | |
| 48 | +import javax.inject.Inject; | |
| 49 | +import javax.validation.ConstraintViolation; | |
| 50 | +import javax.validation.ConstraintViolationException; | |
| 51 | +import javax.validation.Validation; | |
| 52 | +import javax.validation.ValidationException; | |
| 53 | +import javax.validation.Validator; | |
| 54 | + | |
| 55 | +import org.slf4j.Logger; | |
| 56 | + | |
| 57 | +import br.gov.frameworkdemoiselle.annotation.ManagedProperty; | |
| 58 | +import br.gov.frameworkdemoiselle.annotation.Name; | |
| 59 | +import br.gov.frameworkdemoiselle.internal.context.ContextManager; | |
| 60 | +import br.gov.frameworkdemoiselle.internal.context.ManagedContext; | |
| 61 | +import br.gov.frameworkdemoiselle.internal.implementation.ManagedType.MethodDetail; | |
| 62 | +import br.gov.frameworkdemoiselle.management.AttributeChangeNotification; | |
| 63 | +import br.gov.frameworkdemoiselle.management.ManagedAttributeNotFoundException; | |
| 64 | +import br.gov.frameworkdemoiselle.management.ManagedInvokationException; | |
| 65 | +import br.gov.frameworkdemoiselle.management.ManagementExtension; | |
| 66 | +import br.gov.frameworkdemoiselle.management.NotificationManager; | |
| 67 | +import br.gov.frameworkdemoiselle.stereotype.ManagementController; | |
| 68 | +import br.gov.frameworkdemoiselle.util.Beans; | |
| 69 | +import br.gov.frameworkdemoiselle.util.ResourceBundle; | |
| 70 | + | |
| 71 | +/** | |
| 72 | + * Central class used by management extensions to obtain information, access properties and call operations over | |
| 73 | + * discovered {@link ManagementController} classes. | |
| 74 | + * | |
| 75 | + * @author SERPRO | |
| 76 | + */ | |
| 77 | +@ApplicationScoped | |
| 78 | +public class Management implements Serializable { | |
| 79 | + | |
| 80 | + private static final long serialVersionUID = 1L; | |
| 81 | + | |
| 82 | + @Inject | |
| 83 | + private Logger logger; | |
| 84 | + | |
| 85 | + @Inject | |
| 86 | + @Name("demoiselle-core-bundle") | |
| 87 | + private ResourceBundle bundle; | |
| 88 | + | |
| 89 | + private final List<ManagedType> managedTypes = new ArrayList<ManagedType>(); | |
| 90 | + | |
| 91 | + private Validator validator; | |
| 92 | + | |
| 93 | + public void addManagedType(ManagedType managedType) { | |
| 94 | + managedTypes.add(managedType); | |
| 95 | + logger.debug(bundle.getString("management-debug-registering-managed-type", managedType.getType() | |
| 96 | + .getCanonicalName())); | |
| 97 | + } | |
| 98 | + | |
| 99 | + /** | |
| 100 | + * @return List all discovered {@link ManagementController} classes. The returned list is a shallow copy of the | |
| 101 | + * internal list, so you are free to modify it. TODO precisamos desse clone na lista? | |
| 102 | + */ | |
| 103 | + public List<ManagedType> getManagedTypes() { | |
| 104 | + ArrayList<ManagedType> cloneList = new ArrayList<ManagedType>(); | |
| 105 | + cloneList.addAll(managedTypes); | |
| 106 | + return cloneList; | |
| 107 | + } | |
| 108 | + | |
| 109 | + /** | |
| 110 | + * <p> | |
| 111 | + * Invoke an operation over a {@link ManagementController}. | |
| 112 | + * </p> | |
| 113 | + * <p> | |
| 114 | + * This method is not thread-safe, it's the user's responsibility to make the operations of the managed type | |
| 115 | + * synchronized if necessary. | |
| 116 | + * </p> | |
| 117 | + * | |
| 118 | + * @param managedType | |
| 119 | + * A type annotated with {@link ManagementController}. This method will create an (or obtain an already | |
| 120 | + * created) instance of this type and invoke the operation over it. | |
| 121 | + * @param actionName | |
| 122 | + * Name of method to be invoked, the type must have this operation on it's list | |
| 123 | + * @param params | |
| 124 | + * List of values for the operation parameters. Can be <code>null</code> if the operation require no | |
| 125 | + * parameters. | |
| 126 | + * @return The return value of the original invoked operation. Methods of return type <code>void</code> will return | |
| 127 | + * the {@link Void} type. | |
| 128 | + * @throws ManagedInvokationException | |
| 129 | + * In case the operation doesn't exist or have a different signature | |
| 130 | + */ | |
| 131 | + public Object invoke(ManagedType managedType, String actionName, Object[] params) { | |
| 132 | + if (managedTypes.contains(managedType)) { | |
| 133 | + activateContexts(managedType.getType()); | |
| 134 | + | |
| 135 | + try { | |
| 136 | + Object delegate = Beans.getReference(managedType.getType() , managedType.getQualifiers()); | |
| 137 | + MethodDetail method = managedType.getOperationMethods().get(actionName); | |
| 138 | + | |
| 139 | + if (method != null) { | |
| 140 | + try { | |
| 141 | + logger.debug(bundle.getString("management-debug-invoking-operation", actionName, managedType | |
| 142 | + .getType().getCanonicalName())); | |
| 143 | + return method.getMethod().invoke(delegate, params); | |
| 144 | + } catch (Exception e) { | |
| 145 | + throw new ManagedInvokationException(bundle.getString("management-invoke-error", actionName), e); | |
| 146 | + } | |
| 147 | + } else { | |
| 148 | + throw new ManagedInvokationException(bundle.getString("management-invoke-error", actionName)); | |
| 149 | + } | |
| 150 | + } finally { | |
| 151 | + deactivateContexts(managedType.getType()); | |
| 152 | + } | |
| 153 | + } else { | |
| 154 | + throw new ManagedInvokationException(bundle.getString("management-type-not-found")); | |
| 155 | + } | |
| 156 | + } | |
| 157 | + | |
| 158 | + /** | |
| 159 | + * <p> | |
| 160 | + * Retrieve the current value of a property from a managed type. Properties are attributes annotated with | |
| 161 | + * {@link ManagedProperty}. | |
| 162 | + * </p> | |
| 163 | + * <p> | |
| 164 | + * This method is not thread-safe, it's the user's responsibility to create the property's access methods from the | |
| 165 | + * managed type synchronized if necessary. | |
| 166 | + * </p> | |
| 167 | + * | |
| 168 | + * @param managedType | |
| 169 | + * The type that has the property the client wants to know the value of. | |
| 170 | + * @param propertyName | |
| 171 | + * The name of the property | |
| 172 | + * @return The current value of the property | |
| 173 | + * @throws ManagedAttributeNotFoundException If the given property doesn't exist or there was a problem trying to read the property value. | |
| 174 | + * @throws ManagedInvokationException If there was an error trying to invoke the getter method to read the propery value. | |
| 175 | + */ | |
| 176 | + public Object getProperty(ManagedType managedType, String propertyName) { | |
| 177 | + | |
| 178 | + if (managedTypes.contains(managedType)) { | |
| 179 | + Method getterMethod = managedType.getFields().get(propertyName).getGetterMethod(); | |
| 180 | + | |
| 181 | + if (getterMethod != null) { | |
| 182 | + logger.debug(bundle.getString("management-debug-acessing-property", getterMethod.getName(), managedType | |
| 183 | + .getType().getCanonicalName())); | |
| 184 | + | |
| 185 | + activateContexts(managedType.getType()); | |
| 186 | + | |
| 187 | + try { | |
| 188 | + Object delegate = Beans.getReference(managedType.getType() , managedType.getQualifiers()); | |
| 189 | + | |
| 190 | + return getterMethod.invoke(delegate, (Object[]) null); | |
| 191 | + } catch (Exception e) { | |
| 192 | + throw new ManagedInvokationException(bundle.getString("management-invoke-error", getterMethod.getName()), | |
| 193 | + e); | |
| 194 | + } finally { | |
| 195 | + deactivateContexts(managedType.getType()); | |
| 196 | + } | |
| 197 | + } else { | |
| 198 | + throw new ManagedAttributeNotFoundException(bundle.getString("management-read-value-error", propertyName)); | |
| 199 | + } | |
| 200 | + } else { | |
| 201 | + throw new ManagedInvokationException(bundle.getString("management-type-not-found")); | |
| 202 | + } | |
| 203 | + } | |
| 204 | + | |
| 205 | + /** | |
| 206 | + * <p> | |
| 207 | + * Sets a new value for a property contained inside a managed type. A property is an attribute annotated with | |
| 208 | + * {@link ManagedProperty}. | |
| 209 | + * </p> | |
| 210 | + * <p> | |
| 211 | + * This method is not thread-safe, it's the user's responsibility to create the property's access methods from the | |
| 212 | + * managed type synchronized if necessary. | |
| 213 | + * </p> | |
| 214 | + * | |
| 215 | + * @param managedType | |
| 216 | + * The type that has access to the property | |
| 217 | + * @param propertyName | |
| 218 | + * The name of the property | |
| 219 | + * @param newValue | |
| 220 | + * The new value of the property | |
| 221 | + * @throws ManagedInvokationException If there was an error trying to call the setter method for this property. | |
| 222 | + * @throws ManagedAttributeNotFoundException If the giver property doesn't exist or could'n be written to. | |
| 223 | + * @throws ConstraintViolationException If the property defined one or more validation constraints and setting this value violates some of those constraints. | |
| 224 | + */ | |
| 225 | + @SuppressWarnings("unchecked") | |
| 226 | + public void setProperty(ManagedType managedType, String propertyName, Object newValue) { | |
| 227 | + | |
| 228 | + if (managedTypes.contains(managedType)) { | |
| 229 | + // Procura o método set do atributo em questão | |
| 230 | + Method method = managedType.getFields().get(propertyName).getSetterMethod(); | |
| 231 | + if (method != null) { | |
| 232 | + logger.debug(bundle.getString("management-debug-setting-property", method.getName(), managedType | |
| 233 | + .getType().getCanonicalName())); | |
| 234 | + | |
| 235 | + activateContexts(managedType.getType()); | |
| 236 | + try { | |
| 237 | + // Obtém uma instância da classe gerenciada, lembrando que | |
| 238 | + // classes | |
| 239 | + // anotadas com @ManagementController são sempre singletons. | |
| 240 | + Object delegate = Beans.getReference(managedType.getType() , managedType.getQualifiers() ); | |
| 241 | + | |
| 242 | + // Se houver um validador anexado à propriedade alterada, executa o validador sobre | |
| 243 | + // o novo valor. | |
| 244 | + Validator validator = getDefaultValidator(); | |
| 245 | + if (validator != null) { | |
| 246 | + Set<?> violations = validator.validateValue(managedType.getType(), propertyName, newValue); | |
| 247 | + if (violations.size() > 0) { | |
| 248 | + StringBuffer errorBuffer = new StringBuffer(); | |
| 249 | + for (Object objectViolation : violations) { | |
| 250 | + ConstraintViolation<?> violation = (ConstraintViolation<?>) objectViolation; | |
| 251 | + errorBuffer.append(violation.getMessage()).append('\r').append('\n'); | |
| 252 | + } | |
| 253 | + | |
| 254 | + if (errorBuffer.length() > 0) { | |
| 255 | + errorBuffer.insert(0, "\r\n"); | |
| 256 | + errorBuffer.insert(errorBuffer.length(), "\r\n"); | |
| 257 | + } | |
| 258 | + | |
| 259 | + throw new ConstraintViolationException(bundle.getString("management-validation-constraint-violation" | |
| 260 | + , managedType.getType().getCanonicalName(), propertyName, errorBuffer.toString()) | |
| 261 | + , (Set<ConstraintViolation<?>>) violations); | |
| 262 | + } | |
| 263 | + } else { | |
| 264 | + logger.warn(bundle.getString("management-validation-validator-not-found")); | |
| 265 | + } | |
| 266 | + | |
| 267 | + Method getterMethod = managedType.getFields().get(propertyName).getGetterMethod(); | |
| 268 | + Object oldValue; | |
| 269 | + try { | |
| 270 | + oldValue = getterMethod.invoke(delegate, (Object[]) null); | |
| 271 | + } catch (Exception e) { | |
| 272 | + oldValue = null; | |
| 273 | + } | |
| 274 | + | |
| 275 | + method.invoke(delegate, new Object[] { newValue }); | |
| 276 | + | |
| 277 | + // Manda uma notificação de mudança de atributo | |
| 278 | + NotificationManager notificationManager = Beans.getReference(NotificationManager.class); | |
| 279 | + Class<? extends Object> attributeType = newValue != null ? newValue.getClass() : null; | |
| 280 | + | |
| 281 | + AttributeChangeNotification notification = new AttributeChangeNotification(bundle.getString( | |
| 282 | + "management-notification-attribute-changed", propertyName, managedType.getType() | |
| 283 | + .getCanonicalName()), propertyName, attributeType, oldValue, newValue); | |
| 284 | + notificationManager.sendNotification(notification); | |
| 285 | + | |
| 286 | + } catch (ConstraintViolationException ce) { | |
| 287 | + throw ce; | |
| 288 | + } catch (Exception e) { | |
| 289 | + throw new ManagedInvokationException(bundle.getString("management-invoke-error", method.getName()), e); | |
| 290 | + } finally { | |
| 291 | + deactivateContexts(managedType.getType()); | |
| 292 | + } | |
| 293 | + | |
| 294 | + } else { | |
| 295 | + throw new ManagedAttributeNotFoundException(bundle.getString("management-write-value-error", propertyName)); | |
| 296 | + } | |
| 297 | + } else { | |
| 298 | + throw new ManagedInvokationException(bundle.getString("management-type-not-found")); | |
| 299 | + } | |
| 300 | + | |
| 301 | + } | |
| 302 | + | |
| 303 | + private void activateContexts(Class<?> managedType) { | |
| 304 | + logger.debug(bundle.getString("management-debug-starting-custom-context", | |
| 305 | + ManagedContext.class.getCanonicalName(), managedType.getCanonicalName())); | |
| 306 | + | |
| 307 | + ContextManager.activate(ManagedContext.class, RequestScoped.class); | |
| 308 | + } | |
| 309 | + | |
| 310 | + private void deactivateContexts(Class<?> managedType) { | |
| 311 | + logger.debug(bundle.getString("management-debug-stoping-custom-context", | |
| 312 | + ManagedContext.class.getCanonicalName(), managedType.getCanonicalName())); | |
| 313 | + | |
| 314 | + ContextManager.deactivate(ManagedContext.class, RequestScoped.class); | |
| 315 | + } | |
| 316 | + | |
| 317 | + public void shutdown(Collection<Class<? extends ManagementExtension>> monitoringExtensions) { | |
| 318 | + | |
| 319 | + for (Class<? extends ManagementExtension> monitoringExtensionClass : monitoringExtensions) { | |
| 320 | + | |
| 321 | + ManagementExtension monitoringExtension = Beans.getReference(monitoringExtensionClass); | |
| 322 | + | |
| 323 | + monitoringExtension.shutdown(this.getManagedTypes()); | |
| 324 | + | |
| 325 | + logger.debug(bundle.getString("management-debug-removing-management-extension", monitoringExtension | |
| 326 | + .getClass().getCanonicalName())); | |
| 327 | + | |
| 328 | + } | |
| 329 | + | |
| 330 | + } | |
| 331 | + | |
| 332 | + public void initialize(Collection<Class<? extends ManagementExtension>> monitoringExtensions) { | |
| 333 | + | |
| 334 | + for (Class<? extends ManagementExtension> monitoringExtensionClass : monitoringExtensions) { | |
| 335 | + ManagementExtension monitoringExtension = Beans.getReference(monitoringExtensionClass); | |
| 336 | + | |
| 337 | + logger.debug(bundle.getString("management-debug-processing-management-extension", monitoringExtension | |
| 338 | + .getClass().getCanonicalName())); | |
| 339 | + | |
| 340 | + monitoringExtension.initialize(this.getManagedTypes()); | |
| 341 | + } | |
| 342 | + | |
| 343 | + } | |
| 344 | + | |
| 345 | + private Validator getDefaultValidator() { | |
| 346 | + if (validator == null) { | |
| 347 | + try { | |
| 348 | + this.validator = Validation.buildDefaultValidatorFactory().getValidator(); | |
| 349 | + } catch (ValidationException e) { | |
| 350 | + this.validator = null; | |
| 351 | + } | |
| 352 | + } | |
| 353 | + | |
| 354 | + return this.validator; | |
| 355 | + } | |
| 356 | + | |
| 357 | + | |
| 358 | +} | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/ManagementNotificationEventImpl.java
0 → 100644
| ... | ... | @@ -0,0 +1,65 @@ |
| 1 | +/* | |
| 2 | + * Demoiselle Framework | |
| 3 | + * Copyright (C) 2010 SERPRO | |
| 4 | + * ---------------------------------------------------------------------------- | |
| 5 | + * This file is part of Demoiselle Framework. | |
| 6 | + * | |
| 7 | + * Demoiselle Framework is free software; you can redistribute it and/or | |
| 8 | + * modify it under the terms of the GNU Lesser General Public License version 3 | |
| 9 | + * as published by the Free Software Foundation. | |
| 10 | + * | |
| 11 | + * This program is distributed in the hope that it will be useful, | |
| 12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 | + * GNU General Public License for more details. | |
| 15 | + * | |
| 16 | + * You should have received a copy of the GNU Lesser General Public License version 3 | |
| 17 | + * along with this program; if not, see <http://www.gnu.org/licenses/> | |
| 18 | + * or write to the Free Software Foundation, Inc., 51 Franklin Street, | |
| 19 | + * Fifth Floor, Boston, MA 02110-1301, USA. | |
| 20 | + * ---------------------------------------------------------------------------- | |
| 21 | + * Este arquivo é parte do Framework Demoiselle. | |
| 22 | + * | |
| 23 | + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | |
| 24 | + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | |
| 25 | + * do Software Livre (FSF). | |
| 26 | + * | |
| 27 | + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | |
| 28 | + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | |
| 29 | + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | |
| 30 | + * para maiores detalhes. | |
| 31 | + * | |
| 32 | + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | |
| 33 | + * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/> | |
| 34 | + * ou escreva para a Fundação do Software Livre (FSF) Inc., | |
| 35 | + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | |
| 36 | + */ | |
| 37 | +package br.gov.frameworkdemoiselle.internal.implementation; | |
| 38 | + | |
| 39 | +import br.gov.frameworkdemoiselle.management.GenericNotification; | |
| 40 | +import br.gov.frameworkdemoiselle.management.NotificationManager; | |
| 41 | + | |
| 42 | +/** | |
| 43 | + * Event fired when a notification is sent by {@link NotificationManager}. | |
| 44 | + * Implementators can capture this event and be notified when the {@link NotificationManager} | |
| 45 | + * sends notifications, so they can pass the notification to the underlying technology. | |
| 46 | + * | |
| 47 | + * @author SERPRO | |
| 48 | + * | |
| 49 | + */ | |
| 50 | +public class ManagementNotificationEventImpl implements br.gov.frameworkdemoiselle.management.ManagementNotificationEvent { | |
| 51 | + | |
| 52 | + private GenericNotification notification; | |
| 53 | + | |
| 54 | + public ManagementNotificationEventImpl(GenericNotification notification){ | |
| 55 | + this.notification = notification; | |
| 56 | + } | |
| 57 | + | |
| 58 | + public GenericNotification getNotification() { | |
| 59 | + return notification; | |
| 60 | + } | |
| 61 | + | |
| 62 | + public void setNotification(GenericNotification notification) { | |
| 63 | + this.notification = notification; | |
| 64 | + } | |
| 65 | +} | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/implementation/NotificationManagerImpl.java
| ... | ... | @@ -42,9 +42,6 @@ import javax.enterprise.event.Event; |
| 42 | 42 | import javax.enterprise.util.AnnotationLiteral; |
| 43 | 43 | import javax.inject.Inject; |
| 44 | 44 | |
| 45 | -import br.gov.frameworkdemoiselle.internal.management.ManagementNotificationEventImpl; | |
| 46 | -import br.gov.frameworkdemoiselle.internal.management.qualifier.AttributeChange; | |
| 47 | -import br.gov.frameworkdemoiselle.internal.management.qualifier.Generic; | |
| 48 | 45 | import br.gov.frameworkdemoiselle.management.AttributeChangeNotification; |
| 49 | 46 | import br.gov.frameworkdemoiselle.management.GenericNotification; |
| 50 | 47 | import br.gov.frameworkdemoiselle.management.ManagementNotificationEvent; | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/management/ManagedType.java
| ... | ... | @@ -1,388 +0,0 @@ |
| 1 | -/* | |
| 2 | - * Demoiselle Framework | |
| 3 | - * Copyright (C) 2010 SERPRO | |
| 4 | - * ---------------------------------------------------------------------------- | |
| 5 | - * This file is part of Demoiselle Framework. | |
| 6 | - * | |
| 7 | - * Demoiselle Framework is free software; you can redistribute it and/or | |
| 8 | - * modify it under the terms of the GNU Lesser General Public License version 3 | |
| 9 | - * as published by the Free Software Foundation. | |
| 10 | - * | |
| 11 | - * This program is distributed in the hope that it will be useful, | |
| 12 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 | - * GNU General Public License for more details. | |
| 15 | - * | |
| 16 | - * You should have received a copy of the GNU Lesser General Public License version 3 | |
| 17 | - * along with this program; if not, see <http://www.gnu.org/licenses/> | |
| 18 | - * or write to the Free Software Foundation, Inc., 51 Franklin Street, | |
| 19 | - * Fifth Floor, Boston, MA 02110-1301, USA. | |
| 20 | - * ---------------------------------------------------------------------------- | |
| 21 | - * Este arquivo é parte do Framework Demoiselle. | |
| 22 | - * | |
| 23 | - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | |
| 24 | - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | |
| 25 | - * do Software Livre (FSF). | |
| 26 | - * | |
| 27 | - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | |
| 28 | - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | |
| 29 | - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | |
| 30 | - * para maiores detalhes. | |
| 31 | - * | |
| 32 | - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | |
| 33 | - * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/> | |
| 34 | - * ou escreva para a Fundação do Software Livre (FSF) Inc., | |
| 35 | - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | |
| 36 | - */ | |
| 37 | -package br.gov.frameworkdemoiselle.internal.management; | |
| 38 | - | |
| 39 | -import java.lang.annotation.Annotation; | |
| 40 | -import java.lang.reflect.Field; | |
| 41 | -import java.lang.reflect.Method; | |
| 42 | -import java.util.ArrayList; | |
| 43 | -import java.util.Locale; | |
| 44 | -import java.util.TreeMap; | |
| 45 | - | |
| 46 | -import javax.inject.Qualifier; | |
| 47 | - | |
| 48 | -import br.gov.frameworkdemoiselle.DemoiselleException; | |
| 49 | -import br.gov.frameworkdemoiselle.annotation.ManagedOperation; | |
| 50 | -import br.gov.frameworkdemoiselle.annotation.ManagedProperty; | |
| 51 | -import br.gov.frameworkdemoiselle.annotation.ManagedProperty.ManagedPropertyAccess; | |
| 52 | -import br.gov.frameworkdemoiselle.annotation.OperationParameter; | |
| 53 | -import br.gov.frameworkdemoiselle.annotation.OperationType; | |
| 54 | -import br.gov.frameworkdemoiselle.stereotype.ManagementController; | |
| 55 | -import br.gov.frameworkdemoiselle.util.ResourceBundle; | |
| 56 | - | |
| 57 | -/** | |
| 58 | - * <p>Package class containing information about a discovered {@link ManagementController}.</p> | |
| 59 | - * | |
| 60 | - * <p>Instances if this class are passed to each discovered management extension during bootstrap so they can have | |
| 61 | - * enough information to expose all discovered {@link ManagementController}'s to management clients.</p> | |
| 62 | - * | |
| 63 | - * @author SERPRO | |
| 64 | - */ | |
| 65 | -public class ManagedType { | |
| 66 | - | |
| 67 | - private Class<?> type; | |
| 68 | - | |
| 69 | - private Annotation[] qualifiers; | |
| 70 | - | |
| 71 | - private TreeMap<String, FieldDetail> fields; | |
| 72 | - | |
| 73 | - private TreeMap<String, MethodDetail> operationMethods; | |
| 74 | - | |
| 75 | - private ResourceBundle bundle; | |
| 76 | - | |
| 77 | - private String description; | |
| 78 | - | |
| 79 | - public ManagedType(Class<?> type) { | |
| 80 | - bundle = new ResourceBundle("demoiselle-core-bundle",Locale.getDefault()); | |
| 81 | - | |
| 82 | - if (type == null) { | |
| 83 | - throw new DemoiselleException(bundle.getString("management-null-class-defined")); | |
| 84 | - } | |
| 85 | - if (!type.isAnnotationPresent(ManagementController.class)) { | |
| 86 | - throw new DemoiselleException(bundle.getString("management-no-annotation-found", type.getCanonicalName())); | |
| 87 | - } | |
| 88 | - | |
| 89 | - this.type = type; | |
| 90 | - fields = new TreeMap<String, FieldDetail>(); | |
| 91 | - operationMethods = new TreeMap<String, MethodDetail>(); | |
| 92 | - this.description = type.getAnnotation(ManagementController.class).description(); | |
| 93 | - this.qualifiers = getQualifierAnnotations(type); | |
| 94 | - | |
| 95 | - initialize(); | |
| 96 | - } | |
| 97 | - | |
| 98 | - public Class<?> getType() { | |
| 99 | - return type; | |
| 100 | - } | |
| 101 | - | |
| 102 | - public String getDescription() { | |
| 103 | - return description; | |
| 104 | - } | |
| 105 | - | |
| 106 | - public TreeMap<String, FieldDetail> getFields() { | |
| 107 | - return fields; | |
| 108 | - } | |
| 109 | - | |
| 110 | - public TreeMap<String, MethodDetail> getOperationMethods() { | |
| 111 | - return operationMethods; | |
| 112 | - } | |
| 113 | - | |
| 114 | - /** | |
| 115 | - * <p>Return a (possibly empty) list of all qualifiers this type have. Qualifiers | |
| 116 | - * are any annotations marked as {@link Qualifier}.</p> | |
| 117 | - * | |
| 118 | - * <p>This method returns the true list of qualifiers. If implementators change this list, it will | |
| 119 | - * affect future calls of this method. This is so that resources can be spared by not creating many instances of this list.</p> | |
| 120 | - * | |
| 121 | - */ | |
| 122 | - public Annotation[] getQualifiers(){ | |
| 123 | - return this.qualifiers; | |
| 124 | - } | |
| 125 | - | |
| 126 | - private void initialize() { | |
| 127 | - // Para cada atributo verifica se ele está anotado com ManagedProperty e extrai as informações dele (método get, set e | |
| 128 | - // descrição do atributo). | |
| 129 | - Field[] fields = type.getDeclaredFields(); | |
| 130 | - if (fields != null) { | |
| 131 | - for (Field field : fields) { | |
| 132 | - if (field.isAnnotationPresent(ManagedProperty.class)) { | |
| 133 | - // Obtém os métodos GET e SET para esta propriedade | |
| 134 | - Method getterMethod = getGetterMethod(field); | |
| 135 | - Method setterMethod = getSetterMethod(field); | |
| 136 | - if (getterMethod == null && setterMethod == null) { | |
| 137 | - throw new DemoiselleException(bundle.getString("management-invalid-property-no-getter-setter", | |
| 138 | - type.getSimpleName(), field.getName())); | |
| 139 | - } else if ((getterMethod != null && getterMethod.isAnnotationPresent(ManagedOperation.class)) | |
| 140 | - || (setterMethod != null && setterMethod.isAnnotationPresent(ManagedOperation.class))) { | |
| 141 | - throw new DemoiselleException(bundle.getString("management-invalid-property-as-operation", | |
| 142 | - type.getSimpleName())); | |
| 143 | - } | |
| 144 | - | |
| 145 | - String propertyDescription = field.getAnnotation(ManagedProperty.class).description(); | |
| 146 | - | |
| 147 | - this.fields.put(field.getName(), new FieldDetail(field, propertyDescription, getterMethod, | |
| 148 | - setterMethod)); | |
| 149 | - } | |
| 150 | - } | |
| 151 | - } | |
| 152 | - | |
| 153 | - // Para cada metodo verifica se ele está anotado com ManagedOperation e cria um MBeanOperationInfo para ele. | |
| 154 | - Method[] methodList = type.getMethods(); | |
| 155 | - if (methodList != null) { | |
| 156 | - for (Method method : methodList) { | |
| 157 | - ManagedOperation opAnnotation = method.getAnnotation(ManagedOperation.class); | |
| 158 | - | |
| 159 | - if (opAnnotation != null) { | |
| 160 | - // Lemos as informações sobre o método e criamos uma instância | |
| 161 | - // de MethodDetail para representar este método como uma | |
| 162 | - // operação. | |
| 163 | - | |
| 164 | - Class<?>[] parameterTypes = method.getParameterTypes(); | |
| 165 | - Annotation[][] parameterAnnotations = method.getParameterAnnotations(); | |
| 166 | - ParameterDetail[] parameterDetails = new ParameterDetail[parameterTypes.length]; | |
| 167 | - OperationType operationType = opAnnotation.type(); | |
| 168 | - | |
| 169 | - for (int i = 0; i < parameterTypes.length; i++) { | |
| 170 | - OperationParameter paramAnnotation = null; | |
| 171 | - for (Annotation annotation : parameterAnnotations[i]) { | |
| 172 | - if (annotation.annotationType() == OperationParameter.class) { | |
| 173 | - paramAnnotation = (OperationParameter) annotation; | |
| 174 | - break; | |
| 175 | - } | |
| 176 | - } | |
| 177 | - | |
| 178 | - String name = paramAnnotation != null ? paramAnnotation.name() : ("arg" + i); | |
| 179 | - String description = paramAnnotation != null ? paramAnnotation.description() : null; | |
| 180 | - | |
| 181 | - parameterDetails[i] = new ParameterDetail(parameterTypes[i], name, description); | |
| 182 | - } | |
| 183 | - | |
| 184 | - // Com todas as informações, criamos nossa instância de MethodDetail e | |
| 185 | - // acrescentamos na lista de todas as operações. | |
| 186 | - MethodDetail detail = new MethodDetail(method, opAnnotation.description(), operationType, parameterDetails); | |
| 187 | - operationMethods.put(method.getName(), detail); | |
| 188 | - } | |
| 189 | - } | |
| 190 | - } | |
| 191 | - } | |
| 192 | - | |
| 193 | - /** | |
| 194 | - * Returns the public getter method for a given field, or <code>null</code> if no getter method can be found. | |
| 195 | - */ | |
| 196 | - private Method getGetterMethod(Field field) { | |
| 197 | - StringBuffer getterMethodName = new StringBuffer() | |
| 198 | - .append("get") | |
| 199 | - .append(field.getName().substring(0, 1).toUpperCase()) | |
| 200 | - .append(field.getName().substring(1)); | |
| 201 | - | |
| 202 | - //Se propriedade está anotada como WRITE-ONLY, ignora essa etapa. | |
| 203 | - ManagedProperty annotation = field.getAnnotation(ManagedProperty.class); | |
| 204 | - if (annotation.accessLevel() == ManagedPropertyAccess.WRITE_ONLY){ | |
| 205 | - return null; | |
| 206 | - } | |
| 207 | - | |
| 208 | - Method getterMethod; | |
| 209 | - | |
| 210 | - try { | |
| 211 | - getterMethod = type.getMethod(getterMethodName.toString()); | |
| 212 | - } catch (Exception e) { | |
| 213 | - getterMethod = null; | |
| 214 | - } | |
| 215 | - | |
| 216 | - // Se atributo for boolean, procura método getter no formato "isAttribute". | |
| 217 | - if (getterMethod == null | |
| 218 | - && (Boolean.TYPE.isAssignableFrom(field.getType()) || Boolean.class.isAssignableFrom(field.getType()))) { | |
| 219 | - // Boolean.TYPE representa o tipo primitivo "boolean", Boolean.class é a classe wrapper. | |
| 220 | - getterMethodName = new StringBuffer() | |
| 221 | - .append("is") | |
| 222 | - .append(field.getName().substring(0, 1).toUpperCase()) | |
| 223 | - .append(field.getName().substring(1).toUpperCase()); | |
| 224 | - | |
| 225 | - try { | |
| 226 | - getterMethod = type.getMethod(getterMethodName.toString()); | |
| 227 | - } catch (Exception e) { | |
| 228 | - getterMethod = null; | |
| 229 | - } | |
| 230 | - } | |
| 231 | - | |
| 232 | - return getterMethod; | |
| 233 | - } | |
| 234 | - | |
| 235 | - /** | |
| 236 | - * Returns the public setter method for a given field, or <code>null</code> if no setter method can be found. | |
| 237 | - */ | |
| 238 | - private Method getSetterMethod(Field field) { | |
| 239 | - | |
| 240 | - //Se propriedade está anotada como READ-ONLY, ignora essa etapa. | |
| 241 | - ManagedProperty annotation = field.getAnnotation(ManagedProperty.class); | |
| 242 | - if (annotation.accessLevel() == ManagedPropertyAccess.READ_ONLY){ | |
| 243 | - return null; | |
| 244 | - } | |
| 245 | - | |
| 246 | - StringBuffer setterMethodName = new StringBuffer() | |
| 247 | - .append("set") | |
| 248 | - .append(field.getName().substring(0, 1).toUpperCase()) | |
| 249 | - .append(field.getName().substring(1)); | |
| 250 | - | |
| 251 | - Method setterMethod; | |
| 252 | - | |
| 253 | - try { | |
| 254 | - setterMethod = type.getMethod(setterMethodName.toString() , field.getType()); | |
| 255 | - } catch (Exception e) { | |
| 256 | - setterMethod = null; | |
| 257 | - } | |
| 258 | - | |
| 259 | - return setterMethod; | |
| 260 | - } | |
| 261 | - | |
| 262 | - /** | |
| 263 | - * Indicates another {@link ManagedType} represents the same {@link Class} as this one. This method also supports a | |
| 264 | - * {@link Class} as a parameter, in this case it will return <code>true</code> if the passed class is exactly the | |
| 265 | - * same Java class represented by this {@link ManagedType}. | |
| 266 | - */ | |
| 267 | - @Override | |
| 268 | - public boolean equals(Object other) { | |
| 269 | - if (other == null) { | |
| 270 | - return false; | |
| 271 | - } | |
| 272 | - | |
| 273 | - return ((ManagedType) other).getType().getCanonicalName().equals(this.getType().getCanonicalName()); | |
| 274 | - } | |
| 275 | - | |
| 276 | - private synchronized Annotation[] getQualifierAnnotations(Class<?> beanClass){ | |
| 277 | - Annotation[] annotations = beanClass.getAnnotations(); | |
| 278 | - ArrayList<Annotation> qualifiers = new ArrayList<Annotation>(annotations.length); | |
| 279 | - | |
| 280 | - for (int i=0; i<annotations.length; i++){ | |
| 281 | - if (annotations[i].annotationType().getAnnotation(Qualifier.class) != null){ | |
| 282 | - qualifiers.add(annotations[i]); | |
| 283 | - } | |
| 284 | - } | |
| 285 | - | |
| 286 | - return qualifiers.toArray(new Annotation[0]); | |
| 287 | - } | |
| 288 | - | |
| 289 | - public final class FieldDetail { | |
| 290 | - | |
| 291 | - private final Field field; | |
| 292 | - | |
| 293 | - private final String description; | |
| 294 | - | |
| 295 | - private Method getterMethod; | |
| 296 | - | |
| 297 | - private Method setterMethod; | |
| 298 | - | |
| 299 | - public FieldDetail(Field field, String description, Method getterMethod, Method setterMethod) { | |
| 300 | - super(); | |
| 301 | - this.field = field; | |
| 302 | - this.description = description; | |
| 303 | - this.getterMethod = getterMethod; | |
| 304 | - this.setterMethod = setterMethod; | |
| 305 | - } | |
| 306 | - | |
| 307 | - public Field getField() { | |
| 308 | - return field; | |
| 309 | - } | |
| 310 | - | |
| 311 | - public String getDescription() { | |
| 312 | - return description; | |
| 313 | - } | |
| 314 | - | |
| 315 | - public Method getGetterMethod() { | |
| 316 | - return getterMethod; | |
| 317 | - } | |
| 318 | - | |
| 319 | - public Method getSetterMethod() { | |
| 320 | - return setterMethod; | |
| 321 | - } | |
| 322 | - | |
| 323 | - } | |
| 324 | - | |
| 325 | - public final class MethodDetail { | |
| 326 | - | |
| 327 | - private final Method method; | |
| 328 | - | |
| 329 | - private final ParameterDetail[] parameterTypers; | |
| 330 | - | |
| 331 | - private final String description; | |
| 332 | - | |
| 333 | - private final OperationType type; | |
| 334 | - | |
| 335 | - public MethodDetail(Method method, String description, OperationType type,ParameterDetail[] parameterTypers) { | |
| 336 | - super(); | |
| 337 | - this.method = method; | |
| 338 | - this.description = description; | |
| 339 | - this.type = type; | |
| 340 | - this.parameterTypers = parameterTypers; | |
| 341 | - } | |
| 342 | - | |
| 343 | - public Method getMethod() { | |
| 344 | - return method; | |
| 345 | - } | |
| 346 | - | |
| 347 | - public ParameterDetail[] getParameterTypers() { | |
| 348 | - return parameterTypers; | |
| 349 | - } | |
| 350 | - | |
| 351 | - public String getDescription() { | |
| 352 | - return description; | |
| 353 | - } | |
| 354 | - | |
| 355 | - public OperationType getType() { | |
| 356 | - return type; | |
| 357 | - } | |
| 358 | - | |
| 359 | - } | |
| 360 | - | |
| 361 | - public final class ParameterDetail { | |
| 362 | - | |
| 363 | - private final Class<?> parameterType; | |
| 364 | - | |
| 365 | - private final String parameterName; | |
| 366 | - | |
| 367 | - private final String parameterDescription; | |
| 368 | - | |
| 369 | - public ParameterDetail(Class<?> parameterType, String parameterName, String parameterDescription) { | |
| 370 | - super(); | |
| 371 | - this.parameterType = parameterType; | |
| 372 | - this.parameterName = parameterName; | |
| 373 | - this.parameterDescription = parameterDescription; | |
| 374 | - } | |
| 375 | - | |
| 376 | - public Class<?> getParameterType() { | |
| 377 | - return parameterType; | |
| 378 | - } | |
| 379 | - | |
| 380 | - public String getParameterName() { | |
| 381 | - return parameterName; | |
| 382 | - } | |
| 383 | - | |
| 384 | - public String getParameterDescription() { | |
| 385 | - return parameterDescription; | |
| 386 | - } | |
| 387 | - } | |
| 388 | -} |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/management/Management.java
| ... | ... | @@ -1,358 +0,0 @@ |
| 1 | -/* | |
| 2 | - * Demoiselle Framework | |
| 3 | - * Copyright (C) 2010 SERPRO | |
| 4 | - * ---------------------------------------------------------------------------- | |
| 5 | - * This file is part of Demoiselle Framework. | |
| 6 | - * | |
| 7 | - * Demoiselle Framework is free software; you can redistribute it and/or | |
| 8 | - * modify it under the terms of the GNU Lesser General Public License version 3 | |
| 9 | - * as published by the Free Software Foundation. | |
| 10 | - * | |
| 11 | - * This program is distributed in the hope that it will be useful, | |
| 12 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 | - * GNU General Public License for more details. | |
| 15 | - * | |
| 16 | - * You should have received a copy of the GNU Lesser General Public License version 3 | |
| 17 | - * along with this program; if not, see <http://www.gnu.org/licenses/> | |
| 18 | - * or write to the Free Software Foundation, Inc., 51 Franklin Street, | |
| 19 | - * Fifth Floor, Boston, MA 02110-1301, USA. | |
| 20 | - * ---------------------------------------------------------------------------- | |
| 21 | - * Este arquivo é parte do Framework Demoiselle. | |
| 22 | - * | |
| 23 | - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | |
| 24 | - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | |
| 25 | - * do Software Livre (FSF). | |
| 26 | - * | |
| 27 | - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | |
| 28 | - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | |
| 29 | - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | |
| 30 | - * para maiores detalhes. | |
| 31 | - * | |
| 32 | - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | |
| 33 | - * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/> | |
| 34 | - * ou escreva para a Fundação do Software Livre (FSF) Inc., | |
| 35 | - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | |
| 36 | - */ | |
| 37 | -package br.gov.frameworkdemoiselle.internal.management; | |
| 38 | - | |
| 39 | -import java.io.Serializable; | |
| 40 | -import java.lang.reflect.Method; | |
| 41 | -import java.util.ArrayList; | |
| 42 | -import java.util.Collection; | |
| 43 | -import java.util.List; | |
| 44 | -import java.util.Set; | |
| 45 | - | |
| 46 | -import javax.enterprise.context.ApplicationScoped; | |
| 47 | -import javax.enterprise.context.RequestScoped; | |
| 48 | -import javax.inject.Inject; | |
| 49 | -import javax.validation.ConstraintViolation; | |
| 50 | -import javax.validation.ConstraintViolationException; | |
| 51 | -import javax.validation.Validation; | |
| 52 | -import javax.validation.ValidationException; | |
| 53 | -import javax.validation.Validator; | |
| 54 | - | |
| 55 | -import org.slf4j.Logger; | |
| 56 | - | |
| 57 | -import br.gov.frameworkdemoiselle.annotation.ManagedProperty; | |
| 58 | -import br.gov.frameworkdemoiselle.annotation.Name; | |
| 59 | -import br.gov.frameworkdemoiselle.internal.context.ContextManager; | |
| 60 | -import br.gov.frameworkdemoiselle.internal.context.ManagedContext; | |
| 61 | -import br.gov.frameworkdemoiselle.internal.management.ManagedType.MethodDetail; | |
| 62 | -import br.gov.frameworkdemoiselle.lifecycle.ManagementExtension; | |
| 63 | -import br.gov.frameworkdemoiselle.management.AttributeChangeNotification; | |
| 64 | -import br.gov.frameworkdemoiselle.management.ManagedAttributeNotFoundException; | |
| 65 | -import br.gov.frameworkdemoiselle.management.ManagedInvokationException; | |
| 66 | -import br.gov.frameworkdemoiselle.management.NotificationManager; | |
| 67 | -import br.gov.frameworkdemoiselle.stereotype.ManagementController; | |
| 68 | -import br.gov.frameworkdemoiselle.util.Beans; | |
| 69 | -import br.gov.frameworkdemoiselle.util.ResourceBundle; | |
| 70 | - | |
| 71 | -/** | |
| 72 | - * Central class used by management extensions to obtain information, access properties and call operations over | |
| 73 | - * discovered {@link ManagementController} classes. | |
| 74 | - * | |
| 75 | - * @author SERPRO | |
| 76 | - */ | |
| 77 | -@ApplicationScoped | |
| 78 | -public class Management implements Serializable { | |
| 79 | - | |
| 80 | - private static final long serialVersionUID = 1L; | |
| 81 | - | |
| 82 | - @Inject | |
| 83 | - private Logger logger; | |
| 84 | - | |
| 85 | - @Inject | |
| 86 | - @Name("demoiselle-core-bundle") | |
| 87 | - private ResourceBundle bundle; | |
| 88 | - | |
| 89 | - private final List<ManagedType> managedTypes = new ArrayList<ManagedType>(); | |
| 90 | - | |
| 91 | - private Validator validator; | |
| 92 | - | |
| 93 | - public void addManagedType(ManagedType managedType) { | |
| 94 | - managedTypes.add(managedType); | |
| 95 | - logger.debug(bundle.getString("management-debug-registering-managed-type", managedType.getType() | |
| 96 | - .getCanonicalName())); | |
| 97 | - } | |
| 98 | - | |
| 99 | - /** | |
| 100 | - * @return List all discovered {@link ManagementController} classes. The returned list is a shallow copy of the | |
| 101 | - * internal list, so you are free to modify it. TODO precisamos desse clone na lista? | |
| 102 | - */ | |
| 103 | - public List<ManagedType> getManagedTypes() { | |
| 104 | - ArrayList<ManagedType> cloneList = new ArrayList<ManagedType>(); | |
| 105 | - cloneList.addAll(managedTypes); | |
| 106 | - return cloneList; | |
| 107 | - } | |
| 108 | - | |
| 109 | - /** | |
| 110 | - * <p> | |
| 111 | - * Invoke an operation over a {@link ManagementController}. | |
| 112 | - * </p> | |
| 113 | - * <p> | |
| 114 | - * This method is not thread-safe, it's the user's responsibility to make the operations of the managed type | |
| 115 | - * synchronized if necessary. | |
| 116 | - * </p> | |
| 117 | - * | |
| 118 | - * @param managedType | |
| 119 | - * A type annotated with {@link ManagementController}. This method will create an (or obtain an already | |
| 120 | - * created) instance of this type and invoke the operation over it. | |
| 121 | - * @param actionName | |
| 122 | - * Name of method to be invoked, the type must have this operation on it's list | |
| 123 | - * @param params | |
| 124 | - * List of values for the operation parameters. Can be <code>null</code> if the operation require no | |
| 125 | - * parameters. | |
| 126 | - * @return The return value of the original invoked operation. Methods of return type <code>void</code> will return | |
| 127 | - * the {@link Void} type. | |
| 128 | - * @throws ManagedInvokationException | |
| 129 | - * In case the operation doesn't exist or have a different signature | |
| 130 | - */ | |
| 131 | - public Object invoke(ManagedType managedType, String actionName, Object[] params) { | |
| 132 | - if (managedTypes.contains(managedType)) { | |
| 133 | - activateContexts(managedType.getType()); | |
| 134 | - | |
| 135 | - try { | |
| 136 | - Object delegate = Beans.getReference(managedType.getType() , managedType.getQualifiers()); | |
| 137 | - MethodDetail method = managedType.getOperationMethods().get(actionName); | |
| 138 | - | |
| 139 | - if (method != null) { | |
| 140 | - try { | |
| 141 | - logger.debug(bundle.getString("management-debug-invoking-operation", actionName, managedType | |
| 142 | - .getType().getCanonicalName())); | |
| 143 | - return method.getMethod().invoke(delegate, params); | |
| 144 | - } catch (Exception e) { | |
| 145 | - throw new ManagedInvokationException(bundle.getString("management-invoke-error", actionName), e); | |
| 146 | - } | |
| 147 | - } else { | |
| 148 | - throw new ManagedInvokationException(bundle.getString("management-invoke-error", actionName)); | |
| 149 | - } | |
| 150 | - } finally { | |
| 151 | - deactivateContexts(managedType.getType()); | |
| 152 | - } | |
| 153 | - } else { | |
| 154 | - throw new ManagedInvokationException(bundle.getString("management-type-not-found")); | |
| 155 | - } | |
| 156 | - } | |
| 157 | - | |
| 158 | - /** | |
| 159 | - * <p> | |
| 160 | - * Retrieve the current value of a property from a managed type. Properties are attributes annotated with | |
| 161 | - * {@link ManagedProperty}. | |
| 162 | - * </p> | |
| 163 | - * <p> | |
| 164 | - * This method is not thread-safe, it's the user's responsibility to create the property's access methods from the | |
| 165 | - * managed type synchronized if necessary. | |
| 166 | - * </p> | |
| 167 | - * | |
| 168 | - * @param managedType | |
| 169 | - * The type that has the property the client wants to know the value of. | |
| 170 | - * @param propertyName | |
| 171 | - * The name of the property | |
| 172 | - * @return The current value of the property | |
| 173 | - * @throws ManagedAttributeNotFoundException If the given property doesn't exist or there was a problem trying to read the property value. | |
| 174 | - * @throws ManagedInvokationException If there was an error trying to invoke the getter method to read the propery value. | |
| 175 | - */ | |
| 176 | - public Object getProperty(ManagedType managedType, String propertyName) { | |
| 177 | - | |
| 178 | - if (managedTypes.contains(managedType)) { | |
| 179 | - Method getterMethod = managedType.getFields().get(propertyName).getGetterMethod(); | |
| 180 | - | |
| 181 | - if (getterMethod != null) { | |
| 182 | - logger.debug(bundle.getString("management-debug-acessing-property", getterMethod.getName(), managedType | |
| 183 | - .getType().getCanonicalName())); | |
| 184 | - | |
| 185 | - activateContexts(managedType.getType()); | |
| 186 | - | |
| 187 | - try { | |
| 188 | - Object delegate = Beans.getReference(managedType.getType() , managedType.getQualifiers()); | |
| 189 | - | |
| 190 | - return getterMethod.invoke(delegate, (Object[]) null); | |
| 191 | - } catch (Exception e) { | |
| 192 | - throw new ManagedInvokationException(bundle.getString("management-invoke-error", getterMethod.getName()), | |
| 193 | - e); | |
| 194 | - } finally { | |
| 195 | - deactivateContexts(managedType.getType()); | |
| 196 | - } | |
| 197 | - } else { | |
| 198 | - throw new ManagedAttributeNotFoundException(bundle.getString("management-read-value-error", propertyName)); | |
| 199 | - } | |
| 200 | - } else { | |
| 201 | - throw new ManagedInvokationException(bundle.getString("management-type-not-found")); | |
| 202 | - } | |
| 203 | - } | |
| 204 | - | |
| 205 | - /** | |
| 206 | - * <p> | |
| 207 | - * Sets a new value for a property contained inside a managed type. A property is an attribute annotated with | |
| 208 | - * {@link ManagedProperty}. | |
| 209 | - * </p> | |
| 210 | - * <p> | |
| 211 | - * This method is not thread-safe, it's the user's responsibility to create the property's access methods from the | |
| 212 | - * managed type synchronized if necessary. | |
| 213 | - * </p> | |
| 214 | - * | |
| 215 | - * @param managedType | |
| 216 | - * The type that has access to the property | |
| 217 | - * @param propertyName | |
| 218 | - * The name of the property | |
| 219 | - * @param newValue | |
| 220 | - * The new value of the property | |
| 221 | - * @throws ManagedInvokationException If there was an error trying to call the setter method for this property. | |
| 222 | - * @throws ManagedAttributeNotFoundException If the giver property doesn't exist or could'n be written to. | |
| 223 | - * @throws ConstraintViolationException If the property defined one or more validation constraints and setting this value violates some of those constraints. | |
| 224 | - */ | |
| 225 | - @SuppressWarnings("unchecked") | |
| 226 | - public void setProperty(ManagedType managedType, String propertyName, Object newValue) { | |
| 227 | - | |
| 228 | - if (managedTypes.contains(managedType)) { | |
| 229 | - // Procura o método set do atributo em questão | |
| 230 | - Method method = managedType.getFields().get(propertyName).getSetterMethod(); | |
| 231 | - if (method != null) { | |
| 232 | - logger.debug(bundle.getString("management-debug-setting-property", method.getName(), managedType | |
| 233 | - .getType().getCanonicalName())); | |
| 234 | - | |
| 235 | - activateContexts(managedType.getType()); | |
| 236 | - try { | |
| 237 | - // Obtém uma instância da classe gerenciada, lembrando que | |
| 238 | - // classes | |
| 239 | - // anotadas com @ManagementController são sempre singletons. | |
| 240 | - Object delegate = Beans.getReference(managedType.getType() , managedType.getQualifiers() ); | |
| 241 | - | |
| 242 | - // Se houver um validador anexado à propriedade alterada, executa o validador sobre | |
| 243 | - // o novo valor. | |
| 244 | - Validator validator = getDefaultValidator(); | |
| 245 | - if (validator != null) { | |
| 246 | - Set<?> violations = validator.validateValue(managedType.getType(), propertyName, newValue); | |
| 247 | - if (violations.size() > 0) { | |
| 248 | - StringBuffer errorBuffer = new StringBuffer(); | |
| 249 | - for (Object objectViolation : violations) { | |
| 250 | - ConstraintViolation<?> violation = (ConstraintViolation<?>) objectViolation; | |
| 251 | - errorBuffer.append(violation.getMessage()).append('\r').append('\n'); | |
| 252 | - } | |
| 253 | - | |
| 254 | - if (errorBuffer.length() > 0) { | |
| 255 | - errorBuffer.insert(0, "\r\n"); | |
| 256 | - errorBuffer.insert(errorBuffer.length(), "\r\n"); | |
| 257 | - } | |
| 258 | - | |
| 259 | - throw new ConstraintViolationException(bundle.getString("management-validation-constraint-violation" | |
| 260 | - , managedType.getType().getCanonicalName(), propertyName, errorBuffer.toString()) | |
| 261 | - , (Set<ConstraintViolation<?>>) violations); | |
| 262 | - } | |
| 263 | - } else { | |
| 264 | - logger.warn(bundle.getString("management-validation-validator-not-found")); | |
| 265 | - } | |
| 266 | - | |
| 267 | - Method getterMethod = managedType.getFields().get(propertyName).getGetterMethod(); | |
| 268 | - Object oldValue; | |
| 269 | - try { | |
| 270 | - oldValue = getterMethod.invoke(delegate, (Object[]) null); | |
| 271 | - } catch (Exception e) { | |
| 272 | - oldValue = null; | |
| 273 | - } | |
| 274 | - | |
| 275 | - method.invoke(delegate, new Object[] { newValue }); | |
| 276 | - | |
| 277 | - // Manda uma notificação de mudança de atributo | |
| 278 | - NotificationManager notificationManager = Beans.getReference(NotificationManager.class); | |
| 279 | - Class<? extends Object> attributeType = newValue != null ? newValue.getClass() : null; | |
| 280 | - | |
| 281 | - AttributeChangeNotification notification = new AttributeChangeNotification(bundle.getString( | |
| 282 | - "management-notification-attribute-changed", propertyName, managedType.getType() | |
| 283 | - .getCanonicalName()), propertyName, attributeType, oldValue, newValue); | |
| 284 | - notificationManager.sendNotification(notification); | |
| 285 | - | |
| 286 | - } catch (ConstraintViolationException ce) { | |
| 287 | - throw ce; | |
| 288 | - } catch (Exception e) { | |
| 289 | - throw new ManagedInvokationException(bundle.getString("management-invoke-error", method.getName()), e); | |
| 290 | - } finally { | |
| 291 | - deactivateContexts(managedType.getType()); | |
| 292 | - } | |
| 293 | - | |
| 294 | - } else { | |
| 295 | - throw new ManagedAttributeNotFoundException(bundle.getString("management-write-value-error", propertyName)); | |
| 296 | - } | |
| 297 | - } else { | |
| 298 | - throw new ManagedInvokationException(bundle.getString("management-type-not-found")); | |
| 299 | - } | |
| 300 | - | |
| 301 | - } | |
| 302 | - | |
| 303 | - private void activateContexts(Class<?> managedType) { | |
| 304 | - logger.debug(bundle.getString("management-debug-starting-custom-context", | |
| 305 | - ManagedContext.class.getCanonicalName(), managedType.getCanonicalName())); | |
| 306 | - | |
| 307 | - ContextManager.activate(ManagedContext.class, RequestScoped.class); | |
| 308 | - } | |
| 309 | - | |
| 310 | - private void deactivateContexts(Class<?> managedType) { | |
| 311 | - logger.debug(bundle.getString("management-debug-stoping-custom-context", | |
| 312 | - ManagedContext.class.getCanonicalName(), managedType.getCanonicalName())); | |
| 313 | - | |
| 314 | - ContextManager.deactivate(ManagedContext.class, RequestScoped.class); | |
| 315 | - } | |
| 316 | - | |
| 317 | - public void shutdown(Collection<Class<? extends ManagementExtension>> monitoringExtensions) { | |
| 318 | - | |
| 319 | - for (Class<? extends ManagementExtension> monitoringExtensionClass : monitoringExtensions) { | |
| 320 | - | |
| 321 | - ManagementExtension monitoringExtension = Beans.getReference(monitoringExtensionClass); | |
| 322 | - | |
| 323 | - monitoringExtension.shutdown(this.getManagedTypes()); | |
| 324 | - | |
| 325 | - logger.debug(bundle.getString("management-debug-removing-management-extension", monitoringExtension | |
| 326 | - .getClass().getCanonicalName())); | |
| 327 | - | |
| 328 | - } | |
| 329 | - | |
| 330 | - } | |
| 331 | - | |
| 332 | - public void initialize(Collection<Class<? extends ManagementExtension>> monitoringExtensions) { | |
| 333 | - | |
| 334 | - for (Class<? extends ManagementExtension> monitoringExtensionClass : monitoringExtensions) { | |
| 335 | - ManagementExtension monitoringExtension = Beans.getReference(monitoringExtensionClass); | |
| 336 | - | |
| 337 | - logger.debug(bundle.getString("management-debug-processing-management-extension", monitoringExtension | |
| 338 | - .getClass().getCanonicalName())); | |
| 339 | - | |
| 340 | - monitoringExtension.initialize(this.getManagedTypes()); | |
| 341 | - } | |
| 342 | - | |
| 343 | - } | |
| 344 | - | |
| 345 | - private Validator getDefaultValidator() { | |
| 346 | - if (validator == null) { | |
| 347 | - try { | |
| 348 | - this.validator = Validation.buildDefaultValidatorFactory().getValidator(); | |
| 349 | - } catch (ValidationException e) { | |
| 350 | - this.validator = null; | |
| 351 | - } | |
| 352 | - } | |
| 353 | - | |
| 354 | - return this.validator; | |
| 355 | - } | |
| 356 | - | |
| 357 | - | |
| 358 | -} |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/management/ManagementNotificationEventImpl.java
| ... | ... | @@ -1,65 +0,0 @@ |
| 1 | -/* | |
| 2 | - * Demoiselle Framework | |
| 3 | - * Copyright (C) 2010 SERPRO | |
| 4 | - * ---------------------------------------------------------------------------- | |
| 5 | - * This file is part of Demoiselle Framework. | |
| 6 | - * | |
| 7 | - * Demoiselle Framework is free software; you can redistribute it and/or | |
| 8 | - * modify it under the terms of the GNU Lesser General Public License version 3 | |
| 9 | - * as published by the Free Software Foundation. | |
| 10 | - * | |
| 11 | - * This program is distributed in the hope that it will be useful, | |
| 12 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 | - * GNU General Public License for more details. | |
| 15 | - * | |
| 16 | - * You should have received a copy of the GNU Lesser General Public License version 3 | |
| 17 | - * along with this program; if not, see <http://www.gnu.org/licenses/> | |
| 18 | - * or write to the Free Software Foundation, Inc., 51 Franklin Street, | |
| 19 | - * Fifth Floor, Boston, MA 02110-1301, USA. | |
| 20 | - * ---------------------------------------------------------------------------- | |
| 21 | - * Este arquivo é parte do Framework Demoiselle. | |
| 22 | - * | |
| 23 | - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | |
| 24 | - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | |
| 25 | - * do Software Livre (FSF). | |
| 26 | - * | |
| 27 | - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | |
| 28 | - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | |
| 29 | - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | |
| 30 | - * para maiores detalhes. | |
| 31 | - * | |
| 32 | - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | |
| 33 | - * "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/> | |
| 34 | - * ou escreva para a Fundação do Software Livre (FSF) Inc., | |
| 35 | - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | |
| 36 | - */ | |
| 37 | -package br.gov.frameworkdemoiselle.internal.management; | |
| 38 | - | |
| 39 | -import br.gov.frameworkdemoiselle.management.GenericNotification; | |
| 40 | -import br.gov.frameworkdemoiselle.management.NotificationManager; | |
| 41 | - | |
| 42 | -/** | |
| 43 | - * Event fired when a notification is sent by {@link NotificationManager}. | |
| 44 | - * Implementators can capture this event and be notified when the {@link NotificationManager} | |
| 45 | - * sends notifications, so they can pass the notification to the underlying technology. | |
| 46 | - * | |
| 47 | - * @author SERPRO | |
| 48 | - * | |
| 49 | - */ | |
| 50 | -public class ManagementNotificationEventImpl implements br.gov.frameworkdemoiselle.management.ManagementNotificationEvent { | |
| 51 | - | |
| 52 | - private GenericNotification notification; | |
| 53 | - | |
| 54 | - public ManagementNotificationEventImpl(GenericNotification notification){ | |
| 55 | - this.notification = notification; | |
| 56 | - } | |
| 57 | - | |
| 58 | - public GenericNotification getNotification() { | |
| 59 | - return notification; | |
| 60 | - } | |
| 61 | - | |
| 62 | - public void setNotification(GenericNotification notification) { | |
| 63 | - this.notification = notification; | |
| 64 | - } | |
| 65 | -} |
impl/core/src/main/java/br/gov/frameworkdemoiselle/internal/management/qualifier/AttributeChange.java
| ... | ... | @@ -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.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.management.AttributeChangeNotification; | |
| 47 | -import br.gov.frameworkdemoiselle.management.ManagementNotificationEvent; | |
| 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
| ... | ... | @@ -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.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.management.ManagementNotificationEvent; | |
| 47 | -import br.gov.frameworkdemoiselle.management.GenericNotification; | |
| 48 | - | |
| 49 | -/** | |
| 50 | - * | |
| 51 | - * Enables {@link ManagementNotificationEvent} observers to trigger only with notifications | |
| 52 | - * of the base type {@link GenericNotification}. | |
| 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/lifecycle/ManagementExtension.java
| ... | ... | @@ -1,78 +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.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 | - * <p> | |
| 46 | - * Interface defining the lifecycle of a <b>management extension</b>, an extension capable of exposing | |
| 47 | - * {@link ManagementController}'s to external clients in one of the available management technologies, such as JMX or | |
| 48 | - * SNMP. | |
| 49 | - * </p> | |
| 50 | - * <p> | |
| 51 | - * To include a management extension into the management lifecycle, it just needs to implement this interface and be a | |
| 52 | - * CDI bean (have a <b>beans.xml</b> file inside the META-INF folder of it's java package). The Demoiselle Core | |
| 53 | - * lifecycle controller will call the {@link #initialize(List managedTypes)} and {@link #shutdown(List managedTypes)} | |
| 54 | - * methods at the apropriate times. | |
| 55 | - * </p> | |
| 56 | - * | |
| 57 | - * @author SERPRO | |
| 58 | - */ | |
| 59 | -public interface ManagementExtension { | |
| 60 | - | |
| 61 | - /** | |
| 62 | - * This method is called during the application initialization process for each concrete implementation of this | |
| 63 | - * interface. | |
| 64 | - * | |
| 65 | - * @param managedTypes | |
| 66 | - * The list of discovered {@link ManagementController} classes. | |
| 67 | - */ | |
| 68 | - void initialize(List<ManagedType> managedTypes); | |
| 69 | - | |
| 70 | - /** | |
| 71 | - * This method is called during the application shutdown process for each concrete implementation of this interface. | |
| 72 | - * | |
| 73 | - * @param managedTypes | |
| 74 | - * The list of discovered {@link ManagementController} classes. | |
| 75 | - */ | |
| 76 | - void shutdown(List<ManagedType> managedTypes); | |
| 77 | - | |
| 78 | -} |
impl/core/src/main/java/br/gov/frameworkdemoiselle/management/ManagementExtension.java
0 → 100644
| ... | ... | @@ -0,0 +1,78 @@ |
| 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.util.List; | |
| 40 | + | |
| 41 | +import br.gov.frameworkdemoiselle.internal.implementation.ManagedType; | |
| 42 | +import br.gov.frameworkdemoiselle.stereotype.ManagementController; | |
| 43 | + | |
| 44 | +/** | |
| 45 | + * <p> | |
| 46 | + * Interface defining the lifecycle of a <b>management extension</b>, an extension capable of exposing | |
| 47 | + * {@link ManagementController}'s to external clients in one of the available management technologies, such as JMX or | |
| 48 | + * SNMP. | |
| 49 | + * </p> | |
| 50 | + * <p> | |
| 51 | + * To include a management extension into the management lifecycle, it just needs to implement this interface and be a | |
| 52 | + * CDI bean (have a <b>beans.xml</b> file inside the META-INF folder of it's java package). The Demoiselle Core | |
| 53 | + * lifecycle controller will call the {@link #initialize(List managedTypes)} and {@link #shutdown(List managedTypes)} | |
| 54 | + * methods at the apropriate times. | |
| 55 | + * </p> | |
| 56 | + * | |
| 57 | + * @author SERPRO | |
| 58 | + */ | |
| 59 | +public interface ManagementExtension { | |
| 60 | + | |
| 61 | + /** | |
| 62 | + * This method is called during the application initialization process for each concrete implementation of this | |
| 63 | + * interface. | |
| 64 | + * | |
| 65 | + * @param managedTypes | |
| 66 | + * The list of discovered {@link ManagementController} classes. | |
| 67 | + */ | |
| 68 | + void initialize(List<ManagedType> managedTypes); | |
| 69 | + | |
| 70 | + /** | |
| 71 | + * This method is called during the application shutdown process for each concrete implementation of this interface. | |
| 72 | + * | |
| 73 | + * @param managedTypes | |
| 74 | + * The list of discovered {@link ManagementController} classes. | |
| 75 | + */ | |
| 76 | + void shutdown(List<ManagedType> managedTypes); | |
| 77 | + | |
| 78 | +} | ... | ... |
impl/core/src/main/java/br/gov/frameworkdemoiselle/management/NotificationManager.java
| ... | ... | @@ -40,8 +40,8 @@ import javax.enterprise.context.ApplicationScoped; |
| 40 | 40 | import javax.enterprise.event.Observes; |
| 41 | 41 | import javax.inject.Inject; |
| 42 | 42 | |
| 43 | -import br.gov.frameworkdemoiselle.internal.management.qualifier.AttributeChange; | |
| 44 | -import br.gov.frameworkdemoiselle.internal.management.qualifier.Generic; | |
| 43 | +import br.gov.frameworkdemoiselle.internal.implementation.AttributeChange; | |
| 44 | +import br.gov.frameworkdemoiselle.internal.implementation.Generic; | |
| 45 | 45 | import br.gov.frameworkdemoiselle.util.Beans; |
| 46 | 46 | |
| 47 | 47 | /** | ... | ... |
impl/core/src/main/resources/META-INF/beans.xml
| ... | ... | @@ -0,0 +1,40 @@ |
| 1 | +<!-- | |
| 2 | + Demoiselle Framework | |
| 3 | + Copyright (C) 2010 SERPRO | |
| 4 | + ============================================================================ | |
| 5 | + This file is part of Demoiselle Framework. | |
| 6 | + | |
| 7 | + Demoiselle Framework is free software; you can redistribute it and/or | |
| 8 | + modify it under the terms of the GNU Lesser General Public License version 3 | |
| 9 | + as published by the Free Software Foundation. | |
| 10 | + | |
| 11 | + This program is distributed in the hope that it will be useful, | |
| 12 | + but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 | + GNU General Public License for more details. | |
| 15 | + | |
| 16 | + You should have received a copy of the GNU Lesser General Public License version 3 | |
| 17 | + along with this program; if not, see <http://www.gnu.org/licenses/> | |
| 18 | + or write to the Free Software Foundation, Inc., 51 Franklin Street, | |
| 19 | + Fifth Floor, Boston, MA 02110-1301, USA. | |
| 20 | + ============================================================================ | |
| 21 | + Este arquivo é parte do Framework Demoiselle. | |
| 22 | + | |
| 23 | + O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | |
| 24 | + modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | |
| 25 | + do Software Livre (FSF). | |
| 26 | + | |
| 27 | + Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | |
| 28 | + GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | |
| 29 | + APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | |
| 30 | + para maiores detalhes. | |
| 31 | + | |
| 32 | + Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | |
| 33 | + "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/> | |
| 34 | + ou escreva para a Fundação do Software Livre (FSF) Inc., | |
| 35 | + 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | |
| 36 | +--> | |
| 37 | +<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
| 38 | + xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd"> | |
| 39 | + | |
| 40 | +</beans> | ... | ... |
impl/core/src/test/java/management/bootstrap/ManagementBootstrapTest.java
| ... | ... | @@ -50,9 +50,9 @@ import org.junit.Test; |
| 50 | 50 | import org.junit.runner.RunWith; |
| 51 | 51 | |
| 52 | 52 | import test.Tests; |
| 53 | -import br.gov.frameworkdemoiselle.internal.management.ManagedType; | |
| 53 | +import br.gov.frameworkdemoiselle.internal.implementation.ManagedType; | |
| 54 | 54 | import br.gov.frameworkdemoiselle.lifecycle.AfterShutdownProccess; |
| 55 | -import br.gov.frameworkdemoiselle.lifecycle.ManagementExtension; | |
| 55 | +import br.gov.frameworkdemoiselle.management.ManagementExtension; | |
| 56 | 56 | import br.gov.frameworkdemoiselle.util.Beans; |
| 57 | 57 | |
| 58 | 58 | @RunWith(Arquillian.class) | ... | ... |
impl/core/src/test/java/management/notification/NotificationTest.java
| ... | ... | @@ -50,8 +50,8 @@ import org.junit.runner.RunWith; |
| 50 | 50 | |
| 51 | 51 | import test.Tests; |
| 52 | 52 | import br.gov.frameworkdemoiselle.annotation.Name; |
| 53 | -import br.gov.frameworkdemoiselle.internal.management.ManagedType; | |
| 54 | -import br.gov.frameworkdemoiselle.internal.management.Management; | |
| 53 | +import br.gov.frameworkdemoiselle.internal.implementation.ManagedType; | |
| 54 | +import br.gov.frameworkdemoiselle.internal.implementation.Management; | |
| 55 | 55 | import br.gov.frameworkdemoiselle.management.AttributeChangeNotification; |
| 56 | 56 | import br.gov.frameworkdemoiselle.management.GenericNotification; |
| 57 | 57 | import br.gov.frameworkdemoiselle.management.NotificationManager; | ... | ... |
impl/core/src/test/java/management/testclasses/DummyManagementExtension.java
| ... | ... | @@ -41,8 +41,8 @@ import java.util.List; |
| 41 | 41 | import javax.inject.Inject; |
| 42 | 42 | |
| 43 | 43 | |
| 44 | -import br.gov.frameworkdemoiselle.internal.management.ManagedType; | |
| 45 | -import br.gov.frameworkdemoiselle.lifecycle.ManagementExtension; | |
| 44 | +import br.gov.frameworkdemoiselle.internal.implementation.ManagedType; | |
| 45 | +import br.gov.frameworkdemoiselle.management.ManagementExtension; | |
| 46 | 46 | |
| 47 | 47 | public class DummyManagementExtension implements ManagementExtension { |
| 48 | 48 | ... | ... |
impl/core/src/test/java/management/testclasses/DummyNotificationListener.java
| ... | ... | @@ -39,8 +39,8 @@ package management.testclasses; |
| 39 | 39 | import javax.enterprise.context.ApplicationScoped; |
| 40 | 40 | import javax.enterprise.event.Observes; |
| 41 | 41 | |
| 42 | -import br.gov.frameworkdemoiselle.internal.management.qualifier.AttributeChange; | |
| 43 | -import br.gov.frameworkdemoiselle.internal.management.qualifier.Generic; | |
| 42 | +import br.gov.frameworkdemoiselle.internal.implementation.AttributeChange; | |
| 43 | +import br.gov.frameworkdemoiselle.internal.implementation.Generic; | |
| 44 | 44 | import br.gov.frameworkdemoiselle.management.AttributeChangeNotification; |
| 45 | 45 | import br.gov.frameworkdemoiselle.management.ManagementNotificationEvent; |
| 46 | 46 | import br.gov.frameworkdemoiselle.management.NotificationManager; | ... | ... |
impl/core/src/test/java/management/testclasses/ManagedClassStore.java
| ... | ... | @@ -42,8 +42,8 @@ import java.util.List; |
| 42 | 42 | |
| 43 | 43 | import javax.enterprise.context.ApplicationScoped; |
| 44 | 44 | |
| 45 | -import br.gov.frameworkdemoiselle.internal.management.ManagedType; | |
| 46 | -import br.gov.frameworkdemoiselle.internal.management.Management; | |
| 45 | +import br.gov.frameworkdemoiselle.internal.implementation.ManagedType; | |
| 46 | +import br.gov.frameworkdemoiselle.internal.implementation.Management; | |
| 47 | 47 | import br.gov.frameworkdemoiselle.util.Beans; |
| 48 | 48 | |
| 49 | 49 | /** | ... | ... |
impl/extension/jdbc/src/main/java/br/gov/frameworkdemoiselle/internal/producer/ConnectionProducer.java
| 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 | + */ | |
| 1 | 37 | package br.gov.frameworkdemoiselle.internal.producer; |
| 2 | 38 | |
| 3 | 39 | import java.io.Serializable; | ... | ... |
impl/extension/jdbc/src/main/java/br/gov/frameworkdemoiselle/internal/producer/DataSourceProducer.java
| 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 | + */ | |
| 1 | 37 | package br.gov.frameworkdemoiselle.internal.producer; |
| 2 | 38 | |
| 3 | 39 | import java.io.Serializable; | ... | ... |
impl/extension/jdbc/src/main/java/br/gov/frameworkdemoiselle/internal/proxy/BasicDataSourceProxy.java
| 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 | + */ | |
| 1 | 37 | package br.gov.frameworkdemoiselle.internal.proxy; |
| 2 | 38 | |
| 3 | 39 | import java.io.PrintWriter; | ... | ... |
impl/extension/jdbc/src/main/java/br/gov/frameworkdemoiselle/internal/proxy/ConnectionProxy.java
| 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 | + */ | |
| 1 | 37 | package br.gov.frameworkdemoiselle.internal.proxy; |
| 2 | 38 | |
| 3 | 39 | import java.io.Serializable; | ... | ... |
impl/extension/jdbc/src/main/resources/META-INF/beans.xml
| ... | ... | @@ -0,0 +1,40 @@ |
| 1 | +<!-- | |
| 2 | + Demoiselle Framework | |
| 3 | + Copyright (C) 2010 SERPRO | |
| 4 | + ============================================================================ | |
| 5 | + This file is part of Demoiselle Framework. | |
| 6 | + | |
| 7 | + Demoiselle Framework is free software; you can redistribute it and/or | |
| 8 | + modify it under the terms of the GNU Lesser General Public License version 3 | |
| 9 | + as published by the Free Software Foundation. | |
| 10 | + | |
| 11 | + This program is distributed in the hope that it will be useful, | |
| 12 | + but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 | + GNU General Public License for more details. | |
| 15 | + | |
| 16 | + You should have received a copy of the GNU Lesser General Public License version 3 | |
| 17 | + along with this program; if not, see <http://www.gnu.org/licenses/> | |
| 18 | + or write to the Free Software Foundation, Inc., 51 Franklin Street, | |
| 19 | + Fifth Floor, Boston, MA 02110-1301, USA. | |
| 20 | + ============================================================================ | |
| 21 | + Este arquivo é parte do Framework Demoiselle. | |
| 22 | + | |
| 23 | + O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou | |
| 24 | + modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação | |
| 25 | + do Software Livre (FSF). | |
| 26 | + | |
| 27 | + Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA | |
| 28 | + GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou | |
| 29 | + APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português | |
| 30 | + para maiores detalhes. | |
| 31 | + | |
| 32 | + Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título | |
| 33 | + "LICENCA.txt", junto com esse programa. Se não, acesse <http://www.gnu.org/licenses/> | |
| 34 | + ou escreva para a Fundação do Software Livre (FSF) Inc., | |
| 35 | + 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. | |
| 36 | +--> | |
| 37 | +<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
| 38 | + xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd"> | |
| 39 | + | |
| 40 | +</beans> | ... | ... |
impl/extension/jpa/src/main/resources/META-INF/beans.xml
| ... | ... | @@ -37,4 +37,4 @@ |
| 37 | 37 | <beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| 38 | 38 | xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd"> |
| 39 | 39 | |
| 40 | -</beans> | |
| 41 | 40 | \ No newline at end of file |
| 41 | +</beans> | ... | ... |
impl/extension/jsf/src/main/resources/META-INF/beans.xml
| ... | ... | @@ -37,4 +37,4 @@ |
| 37 | 37 | <beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| 38 | 38 | xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd"> |
| 39 | 39 | |
| 40 | -</beans> | |
| 41 | 40 | \ No newline at end of file |
| 41 | +</beans> | ... | ... |
impl/extension/jsf/src/test/java/test/Tests.java
| ... | ... | @@ -44,6 +44,41 @@ import org.jboss.shrinkwrap.api.spec.WebArchive; |
| 44 | 44 | import org.jboss.shrinkwrap.resolver.api.maven.Maven; |
| 45 | 45 | import org.junit.Ignore; |
| 46 | 46 | |
| 47 | +import br.gov.frameworkdemoiselle.annotation.NextView; | |
| 48 | +import br.gov.frameworkdemoiselle.annotation.PreviousView; | |
| 49 | +import br.gov.frameworkdemoiselle.annotation.Redirect; | |
| 50 | +import br.gov.frameworkdemoiselle.internal.bootstrap.JsfBootstrap; | |
| 51 | +import br.gov.frameworkdemoiselle.internal.configuration.ExceptionHandlerConfig; | |
| 52 | +import br.gov.frameworkdemoiselle.internal.configuration.JsfSecurityConfig; | |
| 53 | +import br.gov.frameworkdemoiselle.internal.context.ViewContext; | |
| 54 | +import br.gov.frameworkdemoiselle.internal.implementation.AbstractExceptionHandler; | |
| 55 | +import br.gov.frameworkdemoiselle.internal.implementation.ApplicationExceptionHandler; | |
| 56 | +import br.gov.frameworkdemoiselle.internal.implementation.ApplicationExceptionHandlerFactory; | |
| 57 | +import br.gov.frameworkdemoiselle.internal.implementation.AuthenticationExceptionHandler; | |
| 58 | +import br.gov.frameworkdemoiselle.internal.implementation.AuthenticationExceptionHandlerFactory; | |
| 59 | +import br.gov.frameworkdemoiselle.internal.implementation.AuthorizationExceptionHandler; | |
| 60 | +import br.gov.frameworkdemoiselle.internal.implementation.AuthorizationExceptionHandlerFactory; | |
| 61 | +import br.gov.frameworkdemoiselle.internal.implementation.FacesMessageAppender; | |
| 62 | +import br.gov.frameworkdemoiselle.internal.implementation.FileRendererImpl; | |
| 63 | +import br.gov.frameworkdemoiselle.internal.implementation.ParameterImpl; | |
| 64 | +import br.gov.frameworkdemoiselle.internal.implementation.RedirectExceptionHandler; | |
| 65 | +import br.gov.frameworkdemoiselle.internal.implementation.RedirectExceptionHandlerFactory; | |
| 66 | +import br.gov.frameworkdemoiselle.internal.implementation.SecurityObserver; | |
| 67 | +import br.gov.frameworkdemoiselle.internal.procuder.ParameterProducer; | |
| 68 | +import br.gov.frameworkdemoiselle.internal.proxy.FacesContextProxy; | |
| 69 | +import br.gov.frameworkdemoiselle.template.AbstractEditPageBean; | |
| 70 | +import br.gov.frameworkdemoiselle.template.AbstractListPageBean; | |
| 71 | +import br.gov.frameworkdemoiselle.template.AbstractPageBean; | |
| 72 | +import br.gov.frameworkdemoiselle.template.EditPageBean; | |
| 73 | +import br.gov.frameworkdemoiselle.template.ListPageBean; | |
| 74 | +import br.gov.frameworkdemoiselle.template.PageBean; | |
| 75 | +import br.gov.frameworkdemoiselle.util.Faces; | |
| 76 | +import br.gov.frameworkdemoiselle.util.FileRenderer; | |
| 77 | +import br.gov.frameworkdemoiselle.util.Locales; | |
| 78 | +import br.gov.frameworkdemoiselle.util.PageNotFoundException; | |
| 79 | +import br.gov.frameworkdemoiselle.util.Parameter; | |
| 80 | +import br.gov.frameworkdemoiselle.util.Redirector; | |
| 81 | + | |
| 47 | 82 | @Ignore |
| 48 | 83 | public final class Tests { |
| 49 | 84 | |
| ... | ... | @@ -60,18 +95,40 @@ public final class Tests { |
| 60 | 95 | |
| 61 | 96 | return ShrinkWrap |
| 62 | 97 | .create(WebArchive.class) |
| 63 | - // .addClass(ServletAuthenticator.class) | |
| 64 | - // .addClass(ServletAuthorizer.class) | |
| 65 | - // .addClass(ServletFilter.class) | |
| 66 | - // .addClass(ServletListener.class) | |
| 67 | - // .addClass(HttpServletRequestProducer.class) | |
| 68 | - // .addClass(HttpServletResponseProducer.class) | |
| 69 | - // .addClass(HttpSessionProducer.class) | |
| 70 | - // .addClass(ServletLocaleProducer.class) | |
| 71 | - // .addClass(BasicAuthenticationFilter.class) | |
| 72 | - // .addClass(HttpServletRequestProducerFilter.class) | |
| 73 | - // .addClass(HttpServletResponseProducerFilter.class) | |
| 74 | - // .addClass(InternalProcessorFilterImpl.class) | |
| 98 | + .addClass(PageNotFoundException.class) | |
| 99 | + .addClass(Locales.class) | |
| 100 | + .addClass(Parameter.class) | |
| 101 | + .addClass(Faces.class) | |
| 102 | + .addClass(Redirector.class) | |
| 103 | + .addClass(FileRenderer.class) | |
| 104 | + .addClass(JsfSecurityConfig.class) | |
| 105 | + .addClass(ExceptionHandlerConfig.class) | |
| 106 | + .addClass(ViewContext.class) | |
| 107 | + .addClass(AuthorizationExceptionHandlerFactory.class) | |
| 108 | + .addClass(ApplicationExceptionHandler.class) | |
| 109 | + .addClass(FileRendererImpl.class) | |
| 110 | + .addClass(SecurityObserver.class) | |
| 111 | + .addClass(FacesMessageAppender.class) | |
| 112 | + .addClass(RedirectExceptionHandler.class) | |
| 113 | + .addClass(AuthenticationExceptionHandlerFactory.class) | |
| 114 | + .addClass(AuthenticationExceptionHandler.class) | |
| 115 | + .addClass(ApplicationExceptionHandlerFactory.class) | |
| 116 | + .addClass(ParameterImpl.class) | |
| 117 | + .addClass(AuthorizationExceptionHandler.class) | |
| 118 | + .addClass(RedirectExceptionHandlerFactory.class) | |
| 119 | + .addClass(AbstractExceptionHandler.class) | |
| 120 | + .addClass(FacesContextProxy.class) | |
| 121 | + .addClass(JsfBootstrap.class) | |
| 122 | + .addClass(ParameterProducer.class) | |
| 123 | + .addClass(AbstractPageBean.class) | |
| 124 | + .addClass(ListPageBean.class) | |
| 125 | + .addClass(AbstractListPageBean.class) | |
| 126 | + .addClass(AbstractEditPageBean.class) | |
| 127 | + .addClass(PageBean.class) | |
| 128 | + .addClass(EditPageBean.class) | |
| 129 | + .addClass(PreviousView.class) | |
| 130 | + .addClass(Redirect.class) | |
| 131 | + .addClass(NextView.class) | |
| 75 | 132 | .addAsResource(createFileAsset("src/main/resources/demoiselle-jsf-bundle.properties"), |
| 76 | 133 | "demoiselle-jsf-bundle.properties") |
| 77 | 134 | .addAsWebInfResource(createFileAsset("src/test/resources/test/beans.xml"), "beans.xml") | ... | ... |
impl/extension/se/src/main/resources/META-INF/beans.xml
| 1 | -<?xml version="1.0"?> | |
| 2 | 1 | <!-- |
| 3 | 2 | Demoiselle Framework |
| 4 | 3 | Copyright (C) 2010 SERPRO |
| ... | ... | @@ -38,4 +37,4 @@ |
| 38 | 37 | <beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| 39 | 38 | xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd"> |
| 40 | 39 | |
| 41 | -</beans> | |
| 42 | 40 | \ No newline at end of file |
| 41 | +</beans> | ... | ... |
impl/extension/servlet/src/main/resources/META-INF/beans.xml
| ... | ... | @@ -37,4 +37,4 @@ |
| 37 | 37 | <beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| 38 | 38 | xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd"> |
| 39 | 39 | |
| 40 | -</beans> | |
| 41 | 40 | \ No newline at end of file |
| 41 | +</beans> | ... | ... |