diff --git a/impl/extension/jmx/src/main/java/br/gov/frameworkdemoiselle/configuration/JMXConfig.java b/impl/extension/jmx/src/main/java/br/gov/frameworkdemoiselle/configuration/JMXConfig.java new file mode 100644 index 0000000..60e2ccb --- /dev/null +++ b/impl/extension/jmx/src/main/java/br/gov/frameworkdemoiselle/configuration/JMXConfig.java @@ -0,0 +1,142 @@ +/* + * Demoiselle Framework + * Copyright (C) 2010 SERPRO + * ---------------------------------------------------------------------------- + * This file is part of Demoiselle Framework. + * + * Demoiselle Framework is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License version 3 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License version 3 + * along with this program; if not, see + * or write to the Free Software Foundation, Inc., 51 Franklin Street, + * Fifth Floor, Boston, MA 02110-1301, USA. + * ---------------------------------------------------------------------------- + * Este arquivo é parte do Framework Demoiselle. + * + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação + * do Software Livre (FSF). + * + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português + * para maiores detalhes. + * + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título + * "LICENCA.txt", junto com esse programa. Se não, acesse + * ou escreva para a Fundação do Software Livre (FSF) Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. + */ +package br.gov.frameworkdemoiselle.configuration; + +import javax.management.NotificationBroadcaster; + +import br.gov.frameworkdemoiselle.annotation.Name; +import br.gov.frameworkdemoiselle.configuration.Configuration; +import br.gov.frameworkdemoiselle.stereotype.ManagementController; + +/** + * + * Contains configuration parameters to control how {@link Managed} classes are exposed to the MBean server. + * + * To use this class, inject it into your code using the {@link Inject} annotation. + * + * ex:

+ * 
+ * public class BusinessClass(){
+ * 
+ *    //...
+ *    
+ *    &at;Inject
+ *    private JMXConfig jmxConfiguration;
+ *    
+ *    //...
+ *    
+ * }
+ * 
+ * + * @author serpro + * + */ +@Configuration(prefix = "frameworkdemoiselle.management.jmx.") +public class JMXConfig { + + @Name("mbean.domain") + private String mbeanDomain; + + @Name("notification.domain") + private String notificationDomain = "br.gov.frameworkdemoiselle.jmx"; + + @Name("notification.name") + private String notificationMBeanName = "NotificationBroadcaster"; + + /** + *

The domain to register all {@link ManagementController} classes found during boot.

+ * + *

The full name of a MBean has the format of domain:name=MBeanName (ex: br.gov.frameworkdemoiselle.jmx:name=NotificationBroadcaster), this + * parameter is the "domain" portion of the full name.

+ * + *

The default is null and when is set to null, all {@link Managed} classes will use it's own package as the domain.

+ * + */ + public String getMbeanDomain() { + return mbeanDomain; + } + + /** + * @see #getMbeanDomain() + */ + public void setMbeanDomain(String mbeanDomain) { + this.mbeanDomain = mbeanDomain; + } + + /** + *

The name the {@link NotificationBroadcaster} MBean will be registered to. The full name + * of a MBean has the format of domain:name=MBeanName (ex: br.gov.frameworkdemoiselle.jmx:name=NotificationBroadcaster), this + * parameter is the ":name=MBeanName" portion without the ":name=".

+ * + *

The default is the value returned by {@link Class#getSimpleName()} when called from the {@link NotificationBroadcaster} class.

+ * + * @see #getMbeanDomain() + */ + public String getNotificationMBeanName() { + return notificationMBeanName; + } + + /** + * @see #getNotificationMBeanName() + */ + public void setNotificationMBeanName(String notificationMBeanName) { + this.notificationMBeanName = notificationMBeanName; + } + + /** + *

The domain to register the {@link NotificationBroadcaster} MBean.

+ * + *

The full name of a MBean has the format of domain:name=MBeanName (ex: br.gov.frameworkdemoiselle.jmx:name=NotificationBroadcaster), this + * parameter is the "domain" portion of the full name.

+ * + *

The default is br.gov.frameworkdemoiselle.jmx.

+ * + */ + public String getNotificationDomain() { + return notificationDomain; + } + + /** + * @see #getNotificationDomain() + */ + public void setNotificationDomain(String notificationDomain) { + this.notificationDomain = notificationDomain; + } + + + +} diff --git a/impl/extension/jmx/src/main/java/br/gov/frameworkdemoiselle/internal/DynamicMBeanProxy.java b/impl/extension/jmx/src/main/java/br/gov/frameworkdemoiselle/internal/DynamicMBeanProxy.java new file mode 100644 index 0000000..af023c7 --- /dev/null +++ b/impl/extension/jmx/src/main/java/br/gov/frameworkdemoiselle/internal/DynamicMBeanProxy.java @@ -0,0 +1,264 @@ +/* + * Demoiselle Framework + * Copyright (C) 2010 SERPRO + * ---------------------------------------------------------------------------- + * This file is part of Demoiselle Framework. + * + * Demoiselle Framework is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License version 3 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License version 3 + * along with this program; if not, see + * or write to the Free Software Foundation, Inc., 51 Franklin Street, + * Fifth Floor, Boston, MA 02110-1301, USA. + * ---------------------------------------------------------------------------- + * Este arquivo é parte do Framework Demoiselle. + * + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação + * do Software Livre (FSF). + * + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português + * para maiores detalhes. + * + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título + * "LICENCA.txt", junto com esse programa. Se não, acesse + * ou escreva para a Fundação do Software Livre (FSF) Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. + */ +package br.gov.frameworkdemoiselle.internal; + +import java.util.ArrayList; +import java.util.Locale; +import java.util.Map.Entry; + +import javax.management.Attribute; +import javax.management.AttributeList; +import javax.management.AttributeNotFoundException; +import javax.management.DynamicMBean; +import javax.management.InvalidAttributeValueException; +import javax.management.MBeanAttributeInfo; +import javax.management.MBeanException; +import javax.management.MBeanInfo; +import javax.management.MBeanOperationInfo; +import javax.management.MBeanParameterInfo; +import javax.management.ReflectionException; + +import br.gov.frameworkdemoiselle.DemoiselleException; +import br.gov.frameworkdemoiselle.internal.management.ManagedType; +import br.gov.frameworkdemoiselle.internal.management.ManagedType.FieldDetail; +import br.gov.frameworkdemoiselle.internal.management.ManagedType.MethodDetail; +import br.gov.frameworkdemoiselle.internal.management.ManagedType.ParameterDetail; +import br.gov.frameworkdemoiselle.internal.management.Management; +import br.gov.frameworkdemoiselle.stereotype.ManagementController; +import br.gov.frameworkdemoiselle.util.Beans; +import br.gov.frameworkdemoiselle.util.ResourceBundle; + +/** + *

+ * This class is a MBean that gets registered everytime you mark a class with {@link ManagementController}. It dynamicaly reads the + * fields and operations contained in a {@link ManagementController} class and exposes them to the MBean server. Everytime a client + * tries to call an operation or read/write a property inside a ManagementController class, this class will call the appropriate + * method and pass the result to the MBean client. + *

+ * + * @author SERPRO + */ +public class DynamicMBeanProxy implements DynamicMBean { + + private MBeanInfo delegateInfo; + + private ManagedType managedType; + + private ResourceBundle bundle; + + public DynamicMBeanProxy(ManagedType type) { + if (type == null) { + throw new NullPointerException(getBundle().getString("mbean-null-type-defined")); + } + managedType = type; + } + + @Override + public Object getAttribute(String attribute) throws AttributeNotFoundException, MBeanException, ReflectionException { + // Se o bean ainda não foi lido para determinar seus atributos, o faz agora. + if (delegateInfo == null) { + initializeMBeanInfo(); + } + + Management manager = Beans.getReference(Management.class); + return manager.getProperty(managedType, attribute); + } + + @Override + public void setAttribute(Attribute attribute) throws AttributeNotFoundException, InvalidAttributeValueException, + MBeanException, ReflectionException { + + // Se o bean ainda não foi lido para determinar seus atributos, o faz agora. + if (delegateInfo == null) { + initializeMBeanInfo(); + } + + Management manager = Beans.getReference(Management.class); + manager.setProperty(managedType, attribute.getName(), attribute.getValue()); + } + + @Override + public AttributeList getAttributes(String[] attributes) { + if (attributes != null) { + AttributeList list = new AttributeList(); + for (String attribute : attributes) { + try { + Object value = getAttribute(attribute); + list.add(new Attribute(attribute, value)); + } catch (Throwable t) { + } + } + + return list; + } + + return null; + } + + @Override + public AttributeList setAttributes(AttributeList attributes) { + AttributeList settedAttributes = new AttributeList(); + if (attributes != null) { + for (Attribute attribute : attributes.asList()) { + try { + setAttribute(attribute); + + // A razão para separarmos a criação do atributo de sua adição na lista é que + // caso a obtenção do novo valor do atributo dispare uma exceção então o atributo não será + // adicionado na lista de atributos que foram afetados. + Attribute attributeWithNewValue = new Attribute(attribute.getName(), + getAttribute(attribute.getName())); + settedAttributes.add(attributeWithNewValue); + } catch (Throwable t) { + } + } + } + + return settedAttributes; + } + + @Override + public Object invoke(String actionName, Object[] params, String[] signature) throws MBeanException, + ReflectionException { + + // Se o bean ainda não foi lido para determinar seus atributos, o faz agora. + if (this.delegateInfo == null) { + initializeMBeanInfo(); + } + + Management manager = Beans.getReference(Management.class); + return manager.invoke(managedType, actionName, params); + } + + /** + * Initialize the Managed information for this instance of Managed + */ + private void initializeMBeanInfo() { + // Aqui vamos armazenar nossos atributos + ArrayList attributes = new ArrayList(); + + // Aqui vamos armazenar nossas operações + ArrayList operations = new ArrayList(); + + // Para cada propriedade descoberta no ManagementController, cria um attributeInfo correspondente + for (Entry fieldEntry : managedType.getFields().entrySet()) { + + try { + + MBeanAttributeInfo attributeInfo = new MBeanAttributeInfo(fieldEntry.getKey(), fieldEntry.getValue() + .getDescription(), fieldEntry.getValue().getGetterMethod(), fieldEntry.getValue() + .getSetterMethod()); + attributes.add(attributeInfo); + + } catch (javax.management.IntrospectionException e) { + throw new DemoiselleException(getBundle().getString("mbean-introspection-error", managedType.getType() + .getSimpleName())); + } + } + + // Para cada operação descoberta no ManagementController, cria um operationInfo correspondente + for (Entry methodEntry : managedType.getOperationMethods().entrySet()) { + + MethodDetail methodDetail = methodEntry.getValue(); + + ParameterDetail[] parameterTypes = methodDetail.getParameterTypers(); + + MBeanParameterInfo[] parameters = parameterTypes.length > 0 ? new MBeanParameterInfo[parameterTypes.length] + : null; + + if (parameters != null) { + + for (int i = 0; i < parameterTypes.length; i++) { + + parameters[i] = new MBeanParameterInfo(parameterTypes[i].getParameterName(), parameterTypes[i] + .getParameterType().getCanonicalName(), parameterTypes[i].getParameterDescription()); + } + } + + // Com todas as informações, criamos nossa instância de MBeanOperationInfo e + // acrescentamos na lista de todas as operações. + int operationType = 0; + switch(methodDetail.getType()){ + case ACTION: + operationType = MBeanOperationInfo.ACTION; + break; + + case INFO: + operationType = MBeanOperationInfo.INFO; + break; + + case ACTION_INFO: + operationType = MBeanOperationInfo.ACTION_INFO; + break; + + default: + operationType = MBeanOperationInfo.UNKNOWN; + } + + MBeanOperationInfo operation = new MBeanOperationInfo(methodDetail.getMethod().getName(), + methodDetail.getDescription(), parameters, methodDetail.getMethod().getReturnType().getName(), + operationType); + + operations.add(operation); + + } + + // Por fim criamos nosso bean info. + delegateInfo = new MBeanInfo(managedType.getType().getCanonicalName(), managedType.getDescription(), + attributes.toArray(new MBeanAttributeInfo[0]), null, operations.toArray(new MBeanOperationInfo[0]), + null); + + } + + @Override + public MBeanInfo getMBeanInfo() { + if (delegateInfo == null) { + initializeMBeanInfo(); + } + + return delegateInfo; + } + + public ResourceBundle getBundle(){ + if (bundle==null){ + bundle = new ResourceBundle("demoiselle-jmx-bundle", Locale.getDefault()); + } + + return bundle; + } + +} diff --git a/impl/extension/jmx/src/main/java/br/gov/frameworkdemoiselle/internal/JMXManagementExtension.java b/impl/extension/jmx/src/main/java/br/gov/frameworkdemoiselle/internal/JMXManagementExtension.java new file mode 100644 index 0000000..9ddfdf1 --- /dev/null +++ b/impl/extension/jmx/src/main/java/br/gov/frameworkdemoiselle/internal/JMXManagementExtension.java @@ -0,0 +1,104 @@ +/* + * Demoiselle Framework + * Copyright (C) 2010 SERPRO + * ---------------------------------------------------------------------------- + * This file is part of Demoiselle Framework. + * + * Demoiselle Framework is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License version 3 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License version 3 + * along with this program; if not, see + * or write to the Free Software Foundation, Inc., 51 Franklin Street, + * Fifth Floor, Boston, MA 02110-1301, USA. + * ---------------------------------------------------------------------------- + * Este arquivo é parte do Framework Demoiselle. + * + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação + * do Software Livre (FSF). + * + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português + * para maiores detalhes. + * + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título + * "LICENCA.txt", junto com esse programa. Se não, acesse + * ou escreva para a Fundação do Software Livre (FSF) Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. + */ +package br.gov.frameworkdemoiselle.internal; + +import java.util.List; + +import javax.management.ObjectInstance; + +import br.gov.frameworkdemoiselle.annotation.Name; +import br.gov.frameworkdemoiselle.configuration.JMXConfig; +import br.gov.frameworkdemoiselle.internal.management.ManagedType; +import br.gov.frameworkdemoiselle.lifecycle.ManagementExtension; +import br.gov.frameworkdemoiselle.util.Beans; + +public class JMXManagementExtension implements ManagementExtension { + + public void registerNotificationMBean(){ + MBeanManager mbeanManager = Beans.getReference(MBeanManager.class); + JMXConfig configuration = Beans.getReference(JMXConfig.class); + + StringBuffer notificationMBeanName = new StringBuffer() + .append( configuration.getNotificationDomain()!=null ? configuration.getNotificationDomain() : "br.gov.frameworkdemoiselle.jmx" ) + .append(":name=") + .append(configuration.getNotificationMBeanName()); + + if (mbeanManager.findMBeanInstance(notificationMBeanName.toString()) == null){ + NotificationEventListener listener = Beans.getReference(NotificationEventListener.class); + + ObjectInstance instance = MBeanHelper.register(listener.createNotificationBroadcaster(), notificationMBeanName.toString()); + mbeanManager.storeRegisteredMBean(instance); + } + } + + @Override + public void initialize(List managedTypes) { + MBeanManager manager = Beans.getReference(MBeanManager.class); + JMXConfig configuration = Beans.getReference(JMXConfig.class); + + for (ManagedType type : managedTypes) { + DynamicMBeanProxy beanProxy = new DynamicMBeanProxy(type); + + Name nameAnnotation = type.getType().getAnnotation(Name.class); + String mbeanName = nameAnnotation != null ? nameAnnotation.value() : type.getType().getSimpleName(); + + StringBuffer name = new StringBuffer() + .append( configuration.getMbeanDomain()!=null ? configuration.getMbeanDomain() : type.getType().getPackage().getName() ) + .append(":name=") + .append( mbeanName ); + + + if (manager.findMBeanInstance(name.toString()) == null){ + ObjectInstance instance = MBeanHelper.register(beanProxy, name.toString()); + manager.storeRegisteredMBean(instance); + } + } + + registerNotificationMBean(); + } + + @Override + public void shutdown(List managedTypes) { + MBeanManager manager = Beans.getReference(MBeanManager.class); + for (ObjectInstance instance : manager.listRegisteredMBeans()){ + MBeanHelper.unregister(instance.getObjectName()); + } + + manager.cleanRegisteredMBeans(); + } + +} diff --git a/impl/extension/jmx/src/main/java/br/gov/frameworkdemoiselle/internal/MBeanHelper.java b/impl/extension/jmx/src/main/java/br/gov/frameworkdemoiselle/internal/MBeanHelper.java new file mode 100644 index 0000000..be1dce9 --- /dev/null +++ b/impl/extension/jmx/src/main/java/br/gov/frameworkdemoiselle/internal/MBeanHelper.java @@ -0,0 +1,120 @@ +/* + * Demoiselle Framework + * Copyright (C) 2010 SERPRO + * ---------------------------------------------------------------------------- + * This file is part of Demoiselle Framework. + * + * Demoiselle Framework is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License version 3 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License version 3 + * along with this program; if not, see + * or write to the Free Software Foundation, Inc., 51 Franklin Street, + * Fifth Floor, Boston, MA 02110-1301, USA. + * ---------------------------------------------------------------------------- + * Este arquivo é parte do Framework Demoiselle. + * + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação + * do Software Livre (FSF). + * + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português + * para maiores detalhes. + * + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título + * "LICENCA.txt", junto com esse programa. Se não, acesse + * ou escreva para a Fundação do Software Livre (FSF) Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. + */ +package br.gov.frameworkdemoiselle.internal; + +import java.lang.management.ManagementFactory; +import java.util.Locale; + +import javax.management.MBeanServer; +import javax.management.ObjectInstance; +import javax.management.ObjectName; + +import org.slf4j.Logger; + +import br.gov.frameworkdemoiselle.DemoiselleException; +import br.gov.frameworkdemoiselle.internal.producer.LoggerProducer; +import br.gov.frameworkdemoiselle.util.ResourceBundle; + +/** + * Class with common tools for registering MBeans into an Managed server + * + * @author SERPRO + */ +public class MBeanHelper { + + private static final Logger logger = LoggerProducer.create(MBeanHelper.class); + + private static ResourceBundle bundle = new ResourceBundle("demoiselle-jmx-bundle", Locale.getDefault()); + + private static final MBeanServer server = ManagementFactory.getPlatformMBeanServer(); + + // @Inject + // @Name("demoiselle-monitoring-bundle") + // private ResourceBundle bundle; + + /** + * Return the MBean Server instance. + * + * @return MBeanServer + */ + public static final MBeanServer getMBeanServer() { + return server; + } + + /** + * Register a given managed bean (MBean) with the specified name. + * + * @param mbean + * the managed bean to register + * @param name + * the name under which to register the bean + * @return the object name of the mbean, for later deregistration + */ + public static ObjectInstance register(final Object mbean, final String name) { + + logger.info(bundle.getString("mbean-registration",name)); + + ObjectInstance instance = null; + try { + ObjectName objectName = new ObjectName(name); + instance = server.registerMBean(mbean, objectName); + } catch (Exception e) { + logger.error(bundle.getString("mbean-registration-error",name),e); + throw new DemoiselleException(bundle.getString("mbean-registration-error",name), e); + } + + return instance; + } + + /** + * Remove the registration of a mbean. + * + * @param objectName + * the name of the bean to unregister + */ + public static void unregister(final ObjectName objectName) { + + logger.info(bundle.getString("mbean-deregistration",objectName.getCanonicalName())); + + try { + server.unregisterMBean(objectName); + } catch (Exception e) { + logger.error(bundle.getString("mbean-deregistration",objectName.getCanonicalName()),e); + throw new DemoiselleException(bundle.getString("mbean-deregistration",objectName.getCanonicalName()), e); + } + } +} diff --git a/impl/extension/jmx/src/main/java/br/gov/frameworkdemoiselle/internal/MBeanManager.java b/impl/extension/jmx/src/main/java/br/gov/frameworkdemoiselle/internal/MBeanManager.java new file mode 100644 index 0000000..6e681f0 --- /dev/null +++ b/impl/extension/jmx/src/main/java/br/gov/frameworkdemoiselle/internal/MBeanManager.java @@ -0,0 +1,67 @@ +/* + * Demoiselle Framework + * Copyright (C) 2010 SERPRO + * ---------------------------------------------------------------------------- + * This file is part of Demoiselle Framework. + * + * Demoiselle Framework is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License version 3 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License version 3 + * along with this program; if not, see + * or write to the Free Software Foundation, Inc., 51 Franklin Street, + * Fifth Floor, Boston, MA 02110-1301, USA. + * ---------------------------------------------------------------------------- + * Este arquivo é parte do Framework Demoiselle. + * + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação + * do Software Livre (FSF). + * + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português + * para maiores detalhes. + * + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título + * "LICENCA.txt", junto com esse programa. Se não, acesse + * ou escreva para a Fundação do Software Livre (FSF) Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. + */ +package br.gov.frameworkdemoiselle.internal; + +import java.util.Collection; +import java.util.HashMap; + +import javax.enterprise.context.ApplicationScoped; +import javax.management.ObjectInstance; + +@ApplicationScoped +public class MBeanManager { + + private HashMap registeredMBeans = new HashMap(); + + public void storeRegisteredMBean(ObjectInstance instance){ + registeredMBeans.put(instance.getObjectName().getCanonicalName(),instance); + } + + public Collection listRegisteredMBeans(){ + return registeredMBeans.values(); + } + + public ObjectInstance findMBeanInstance(String name){ + ObjectInstance instance = registeredMBeans.get(name); + return instance; + } + + public void cleanRegisteredMBeans(){ + registeredMBeans.clear(); + } + +} diff --git a/impl/extension/jmx/src/main/java/br/gov/frameworkdemoiselle/internal/NotificationBroadcaster.java b/impl/extension/jmx/src/main/java/br/gov/frameworkdemoiselle/internal/NotificationBroadcaster.java new file mode 100644 index 0000000..5790ae1 --- /dev/null +++ b/impl/extension/jmx/src/main/java/br/gov/frameworkdemoiselle/internal/NotificationBroadcaster.java @@ -0,0 +1,86 @@ +/* + * Demoiselle Framework + * Copyright (C) 2010 SERPRO + * ---------------------------------------------------------------------------- + * This file is part of Demoiselle Framework. + * + * Demoiselle Framework is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License version 3 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License version 3 + * along with this program; if not, see + * or write to the Free Software Foundation, Inc., 51 Franklin Street, + * Fifth Floor, Boston, MA 02110-1301, USA. + * ---------------------------------------------------------------------------- + * Este arquivo é parte do Framework Demoiselle. + * + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação + * do Software Livre (FSF). + * + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português + * para maiores detalhes. + * + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título + * "LICENCA.txt", junto com esse programa. Se não, acesse + * ou escreva para a Fundação do Software Livre (FSF) Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. + */ +package br.gov.frameworkdemoiselle.internal; + +import java.io.Serializable; + +import javax.management.AttributeChangeNotification; +import javax.management.Notification; +import javax.management.NotificationBroadcasterSupport; + +import br.gov.frameworkdemoiselle.configuration.JMXConfig; +import br.gov.frameworkdemoiselle.management.ManagementNotificationEvent; +import br.gov.frameworkdemoiselle.management.NotificationManager; + +/** + * Implementation of the {@link NotificationBroadcaster} MBean. + * When the {@link NotificationManager} sends an event, a {@link NotificationEventListener} captures the notification and uses + * this MBean to send it as a JMX notification. + * + * @author serpro + * + */ +public final class NotificationBroadcaster extends NotificationBroadcasterSupport implements NotificationBroadcasterMBean,Serializable { + + private static final long serialVersionUID = 1L; + + private int sequenceNumber = 1; + + /*public static final String NOTIFICATION_DEFAULT_MBEAN_NAME = NotificationBroadcaster.class.getPackage().getName() + +":name=" + +NotificationBroadcaster.class.getSimpleName();*/ + + private static final String NOTIFICATION_TYPE_GENERIC = "jmx.message"; + + protected void sendNotification( ManagementNotificationEvent event , JMXConfig config ) { + br.gov.frameworkdemoiselle.management.GenericNotification demoiselleNotification = event.getNotification(); + Notification n = new Notification(NOTIFICATION_TYPE_GENERIC, config.getNotificationMBeanName(), sequenceNumber++, System.currentTimeMillis(), demoiselleNotification.getMessage().toString()); + sendNotification(n); + } + + protected void sendAttributeChangedMessage( ManagementNotificationEvent event , JMXConfig config ) { + br.gov.frameworkdemoiselle.management.AttributeChangeNotification demoiselleNotification = (br.gov.frameworkdemoiselle.management.AttributeChangeNotification)event.getNotification(); + + AttributeChangeNotification n = new AttributeChangeNotification(config.getNotificationMBeanName(), sequenceNumber++ + , System.currentTimeMillis(), demoiselleNotification.getMessage().toString() + , demoiselleNotification.getAttributeName(), demoiselleNotification.getAttributeType().getSimpleName() + , demoiselleNotification.getOldValue(), demoiselleNotification.getNewValue()); + + sendNotification(n); + } + +} diff --git a/impl/extension/jmx/src/main/java/br/gov/frameworkdemoiselle/internal/NotificationBroadcasterMBean.java b/impl/extension/jmx/src/main/java/br/gov/frameworkdemoiselle/internal/NotificationBroadcasterMBean.java new file mode 100644 index 0000000..56aa5cb --- /dev/null +++ b/impl/extension/jmx/src/main/java/br/gov/frameworkdemoiselle/internal/NotificationBroadcasterMBean.java @@ -0,0 +1,48 @@ +/* + * Demoiselle Framework + * Copyright (C) 2010 SERPRO + * ---------------------------------------------------------------------------- + * This file is part of Demoiselle Framework. + * + * Demoiselle Framework is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License version 3 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License version 3 + * along with this program; if not, see + * or write to the Free Software Foundation, Inc., 51 Franklin Street, + * Fifth Floor, Boston, MA 02110-1301, USA. + * ---------------------------------------------------------------------------- + * Este arquivo é parte do Framework Demoiselle. + * + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação + * do Software Livre (FSF). + * + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português + * para maiores detalhes. + * + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título + * "LICENCA.txt", junto com esse programa. Se não, acesse + * ou escreva para a Fundação do Software Livre (FSF) Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. + */ +package br.gov.frameworkdemoiselle.internal; + + + +/** + * MBean interface responsible for sending MBean notifications to remote clients. + * + * @author serpro + * + */ +public interface NotificationBroadcasterMBean { +} diff --git a/impl/extension/jmx/src/main/java/br/gov/frameworkdemoiselle/internal/NotificationEventListener.java b/impl/extension/jmx/src/main/java/br/gov/frameworkdemoiselle/internal/NotificationEventListener.java new file mode 100644 index 0000000..7936266 --- /dev/null +++ b/impl/extension/jmx/src/main/java/br/gov/frameworkdemoiselle/internal/NotificationEventListener.java @@ -0,0 +1,80 @@ +/* + * Demoiselle Framework + * Copyright (C) 2010 SERPRO + * ---------------------------------------------------------------------------- + * This file is part of Demoiselle Framework. + * + * Demoiselle Framework is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License version 3 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License version 3 + * along with this program; if not, see + * or write to the Free Software Foundation, Inc., 51 Franklin Street, + * Fifth Floor, Boston, MA 02110-1301, USA. + * ---------------------------------------------------------------------------- + * Este arquivo é parte do Framework Demoiselle. + * + * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou + * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação + * do Software Livre (FSF). + * + * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA + * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou + * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português + * para maiores detalhes. + * + * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título + * "LICENCA.txt", junto com esse programa. Se não, acesse + * ou escreva para a Fundação do Software Livre (FSF) Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. + */ +package br.gov.frameworkdemoiselle.internal; + +import java.io.Serializable; + +import javax.enterprise.context.ApplicationScoped; +import javax.enterprise.event.Observes; + +import br.gov.frameworkdemoiselle.configuration.JMXConfig; +import br.gov.frameworkdemoiselle.internal.management.qualifier.AttributeChange; +import br.gov.frameworkdemoiselle.internal.management.qualifier.Generic; +import br.gov.frameworkdemoiselle.management.ManagementNotificationEvent; +import br.gov.frameworkdemoiselle.management.NotificationManager; + +/** + * Listens to {@link NotificationManager} notification events and proxies them + * to a {@link NotificationBroadcaster} MBean. This MBean will send the notification to + * any JMX clients connected and listening. + * + * @author serpro + * + */ +@ApplicationScoped +@SuppressWarnings("serial") +public class NotificationEventListener implements Serializable { + + private NotificationBroadcaster notificationBroadcaster; + + public void sendNotification( @Observes @Generic ManagementNotificationEvent event , JMXConfig config ) { + createNotificationBroadcaster().sendNotification(event,config); + } + + public void sendAttributeChangedMessage( @Observes @AttributeChange ManagementNotificationEvent event , JMXConfig config ) { + createNotificationBroadcaster().sendAttributeChangedMessage(event, config); + } + + public NotificationBroadcaster createNotificationBroadcaster(){ + if (notificationBroadcaster==null){ + notificationBroadcaster = new NotificationBroadcaster(); + } + + return notificationBroadcaster; + } + +} diff --git a/impl/extension/jmx/src/main/java/br/gov/frameworkdemoiselle/jmx/bootstrap/JMXManagementExtension.java b/impl/extension/jmx/src/main/java/br/gov/frameworkdemoiselle/jmx/bootstrap/JMXManagementExtension.java deleted file mode 100644 index 47a19b7..0000000 --- a/impl/extension/jmx/src/main/java/br/gov/frameworkdemoiselle/jmx/bootstrap/JMXManagementExtension.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Demoiselle Framework - * Copyright (C) 2010 SERPRO - * ---------------------------------------------------------------------------- - * This file is part of Demoiselle Framework. - * - * Demoiselle Framework is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License version 3 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License version 3 - * along with this program; if not, see - * or write to the Free Software Foundation, Inc., 51 Franklin Street, - * Fifth Floor, Boston, MA 02110-1301, USA. - * ---------------------------------------------------------------------------- - * Este arquivo é parte do Framework Demoiselle. - * - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação - * do Software Livre (FSF). - * - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português - * para maiores detalhes. - * - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título - * "LICENCA.txt", junto com esse programa. Se não, acesse - * ou escreva para a Fundação do Software Livre (FSF) Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - */ -package br.gov.frameworkdemoiselle.jmx.bootstrap; - -import java.util.List; - -import javax.management.ObjectInstance; - -import br.gov.frameworkdemoiselle.annotation.Name; -import br.gov.frameworkdemoiselle.internal.management.ManagedType; -import br.gov.frameworkdemoiselle.jmx.configuration.JMXConfig; -import br.gov.frameworkdemoiselle.jmx.internal.DynamicMBeanProxy; -import br.gov.frameworkdemoiselle.jmx.internal.MBeanHelper; -import br.gov.frameworkdemoiselle.jmx.internal.MBeanManager; -import br.gov.frameworkdemoiselle.jmx.internal.NotificationEventListener; -import br.gov.frameworkdemoiselle.lifecycle.ManagementExtension; -import br.gov.frameworkdemoiselle.util.Beans; - -public class JMXManagementExtension implements ManagementExtension { - - public void registerNotificationMBean(){ - MBeanManager mbeanManager = Beans.getReference(MBeanManager.class); - JMXConfig configuration = Beans.getReference(JMXConfig.class); - - StringBuffer notificationMBeanName = new StringBuffer() - .append( configuration.getNotificationDomain()!=null ? configuration.getNotificationDomain() : "br.gov.frameworkdemoiselle.jmx" ) - .append(":name=") - .append(configuration.getNotificationMBeanName()); - - if (mbeanManager.findMBeanInstance(notificationMBeanName.toString()) == null){ - NotificationEventListener listener = Beans.getReference(NotificationEventListener.class); - - ObjectInstance instance = MBeanHelper.register(listener.createNotificationBroadcaster(), notificationMBeanName.toString()); - mbeanManager.storeRegisteredMBean(instance); - } - } - - @Override - public void initialize(List managedTypes) { - MBeanManager manager = Beans.getReference(MBeanManager.class); - JMXConfig configuration = Beans.getReference(JMXConfig.class); - - for (ManagedType type : managedTypes) { - DynamicMBeanProxy beanProxy = new DynamicMBeanProxy(type); - - Name nameAnnotation = type.getType().getAnnotation(Name.class); - String mbeanName = nameAnnotation != null ? nameAnnotation.value() : type.getType().getSimpleName(); - - StringBuffer name = new StringBuffer() - .append( configuration.getMbeanDomain()!=null ? configuration.getMbeanDomain() : type.getType().getPackage().getName() ) - .append(":name=") - .append( mbeanName ); - - - if (manager.findMBeanInstance(name.toString()) == null){ - ObjectInstance instance = MBeanHelper.register(beanProxy, name.toString()); - manager.storeRegisteredMBean(instance); - } - } - - registerNotificationMBean(); - } - - @Override - public void shutdown(List managedTypes) { - MBeanManager manager = Beans.getReference(MBeanManager.class); - for (ObjectInstance instance : manager.listRegisteredMBeans()){ - MBeanHelper.unregister(instance.getObjectName()); - } - - manager.cleanRegisteredMBeans(); - } - -} diff --git a/impl/extension/jmx/src/main/java/br/gov/frameworkdemoiselle/jmx/configuration/JMXConfig.java b/impl/extension/jmx/src/main/java/br/gov/frameworkdemoiselle/jmx/configuration/JMXConfig.java deleted file mode 100644 index 6d5fc97..0000000 --- a/impl/extension/jmx/src/main/java/br/gov/frameworkdemoiselle/jmx/configuration/JMXConfig.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Demoiselle Framework - * Copyright (C) 2010 SERPRO - * ---------------------------------------------------------------------------- - * This file is part of Demoiselle Framework. - * - * Demoiselle Framework is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License version 3 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License version 3 - * along with this program; if not, see - * or write to the Free Software Foundation, Inc., 51 Franklin Street, - * Fifth Floor, Boston, MA 02110-1301, USA. - * ---------------------------------------------------------------------------- - * Este arquivo é parte do Framework Demoiselle. - * - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação - * do Software Livre (FSF). - * - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português - * para maiores detalhes. - * - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título - * "LICENCA.txt", junto com esse programa. Se não, acesse - * ou escreva para a Fundação do Software Livre (FSF) Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - */ -package br.gov.frameworkdemoiselle.jmx.configuration; - -import javax.management.NotificationBroadcaster; - -import br.gov.frameworkdemoiselle.annotation.Name; -import br.gov.frameworkdemoiselle.configuration.Configuration; -import br.gov.frameworkdemoiselle.stereotype.ManagementController; - -@Configuration(prefix = "frameworkdemoiselle.management.jmx.") -public class JMXConfig { - - @Name("mbean.domain") - private String mbeanDomain; - - @Name("notification.domain") - private String notificationDomain = "br.gov.frameworkdemoiselle.jmx"; - - @Name("notification.name") - private String notificationMBeanName = "NotificationBroadcaster"; - - /** - *

The domain to register all {@link ManagementController} classes found during boot.

- * - *

The full name of a MBean has the format of domain:name=MBeanName (ex: br.gov.frameworkdemoiselle.jmx:name=NotificationBroadcaster), this - * parameter is the "domain" portion of the full name.

- * - *

The default is null and when is set to null, all {@link Managed} classes will use it's own package as the domain.

- * - */ - public String getMbeanDomain() { - return mbeanDomain; - } - - /** - * @see #getMbeanDomain() - */ - public void setMbeanDomain(String mbeanDomain) { - this.mbeanDomain = mbeanDomain; - } - - /** - *

The name the {@link NotificationBroadcaster} MBean will be registered to. The full name - * of a MBean has the format of domain:name=MBeanName (ex: br.gov.frameworkdemoiselle.jmx:name=NotificationBroadcaster), this - * parameter is the ":name=MBeanName" portion without the ":name=".

- * - *

The default is the value returned by {@link Class#getSimpleName()} when called from the {@link NotificationBroadcaster} class.

- * - * @see #getMbeanDomain() - */ - public String getNotificationMBeanName() { - return notificationMBeanName; - } - - /** - * @see #getNotificationMBeanName() - */ - public void setNotificationMBeanName(String notificationMBeanName) { - this.notificationMBeanName = notificationMBeanName; - } - - /** - *

The domain to register the {@link NotificationBroadcaster} MBean.

- * - *

The full name of a MBean has the format of domain:name=MBeanName (ex: br.gov.frameworkdemoiselle.jmx:name=NotificationBroadcaster), this - * parameter is the "domain" portion of the full name.

- * - *

The default is br.gov.frameworkdemoiselle.jmx.

- * - */ - public String getNotificationDomain() { - return notificationDomain; - } - - /** - * @see #getNotificationDomain() - */ - public void setNotificationDomain(String notificationDomain) { - this.notificationDomain = notificationDomain; - } - - - -} diff --git a/impl/extension/jmx/src/main/java/br/gov/frameworkdemoiselle/jmx/internal/DynamicMBeanProxy.java b/impl/extension/jmx/src/main/java/br/gov/frameworkdemoiselle/jmx/internal/DynamicMBeanProxy.java deleted file mode 100644 index 22b5474..0000000 --- a/impl/extension/jmx/src/main/java/br/gov/frameworkdemoiselle/jmx/internal/DynamicMBeanProxy.java +++ /dev/null @@ -1,264 +0,0 @@ -/* - * Demoiselle Framework - * Copyright (C) 2010 SERPRO - * ---------------------------------------------------------------------------- - * This file is part of Demoiselle Framework. - * - * Demoiselle Framework is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License version 3 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License version 3 - * along with this program; if not, see - * or write to the Free Software Foundation, Inc., 51 Franklin Street, - * Fifth Floor, Boston, MA 02110-1301, USA. - * ---------------------------------------------------------------------------- - * Este arquivo é parte do Framework Demoiselle. - * - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação - * do Software Livre (FSF). - * - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português - * para maiores detalhes. - * - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título - * "LICENCA.txt", junto com esse programa. Se não, acesse - * ou escreva para a Fundação do Software Livre (FSF) Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - */ -package br.gov.frameworkdemoiselle.jmx.internal; - -import java.util.ArrayList; -import java.util.Locale; -import java.util.Map.Entry; - -import javax.management.Attribute; -import javax.management.AttributeList; -import javax.management.AttributeNotFoundException; -import javax.management.DynamicMBean; -import javax.management.InvalidAttributeValueException; -import javax.management.MBeanAttributeInfo; -import javax.management.MBeanException; -import javax.management.MBeanInfo; -import javax.management.MBeanOperationInfo; -import javax.management.MBeanParameterInfo; -import javax.management.ReflectionException; - -import br.gov.frameworkdemoiselle.DemoiselleException; -import br.gov.frameworkdemoiselle.internal.management.ManagedType; -import br.gov.frameworkdemoiselle.internal.management.ManagedType.FieldDetail; -import br.gov.frameworkdemoiselle.internal.management.ManagedType.MethodDetail; -import br.gov.frameworkdemoiselle.internal.management.ManagedType.ParameterDetail; -import br.gov.frameworkdemoiselle.internal.management.Management; -import br.gov.frameworkdemoiselle.stereotype.ManagementController; -import br.gov.frameworkdemoiselle.util.Beans; -import br.gov.frameworkdemoiselle.util.ResourceBundle; - -/** - *

- * This class is a MBean that gets registered everytime you mark a class with {@link ManagementController}. It dynamicaly reads the - * fields and operations contained in a {@link ManagementController} class and exposes them to the MBean server. Everytime a client - * tries to call an operation or read/write a property inside a ManagementController class, this class will call the appropriate - * method and pass the result to the MBean client. - *

- * - * @author SERPRO - */ -public class DynamicMBeanProxy implements DynamicMBean { - - private MBeanInfo delegateInfo; - - private ManagedType managedType; - - private ResourceBundle bundle; - - public DynamicMBeanProxy(ManagedType type) { - if (type == null) { - throw new NullPointerException(getBundle().getString("mbean-null-type-defined")); - } - managedType = type; - } - - @Override - public Object getAttribute(String attribute) throws AttributeNotFoundException, MBeanException, ReflectionException { - // Se o bean ainda não foi lido para determinar seus atributos, o faz agora. - if (delegateInfo == null) { - initializeMBeanInfo(); - } - - Management manager = Beans.getReference(Management.class); - return manager.getProperty(managedType, attribute); - } - - @Override - public void setAttribute(Attribute attribute) throws AttributeNotFoundException, InvalidAttributeValueException, - MBeanException, ReflectionException { - - // Se o bean ainda não foi lido para determinar seus atributos, o faz agora. - if (delegateInfo == null) { - initializeMBeanInfo(); - } - - Management manager = Beans.getReference(Management.class); - manager.setProperty(managedType, attribute.getName(), attribute.getValue()); - } - - @Override - public AttributeList getAttributes(String[] attributes) { - if (attributes != null) { - AttributeList list = new AttributeList(); - for (String attribute : attributes) { - try { - Object value = getAttribute(attribute); - list.add(new Attribute(attribute, value)); - } catch (Throwable t) { - } - } - - return list; - } - - return null; - } - - @Override - public AttributeList setAttributes(AttributeList attributes) { - AttributeList settedAttributes = new AttributeList(); - if (attributes != null) { - for (Attribute attribute : attributes.asList()) { - try { - setAttribute(attribute); - - // A razão para separarmos a criação do atributo de sua adição na lista é que - // caso a obtenção do novo valor do atributo dispare uma exceção então o atributo não será - // adicionado na lista de atributos que foram afetados. - Attribute attributeWithNewValue = new Attribute(attribute.getName(), - getAttribute(attribute.getName())); - settedAttributes.add(attributeWithNewValue); - } catch (Throwable t) { - } - } - } - - return settedAttributes; - } - - @Override - public Object invoke(String actionName, Object[] params, String[] signature) throws MBeanException, - ReflectionException { - - // Se o bean ainda não foi lido para determinar seus atributos, o faz agora. - if (this.delegateInfo == null) { - initializeMBeanInfo(); - } - - Management manager = Beans.getReference(Management.class); - return manager.invoke(managedType, actionName, params); - } - - /** - * Initialize the Managed information for this instance of Managed - */ - private void initializeMBeanInfo() { - // Aqui vamos armazenar nossos atributos - ArrayList attributes = new ArrayList(); - - // Aqui vamos armazenar nossas operações - ArrayList operations = new ArrayList(); - - // Para cada propriedade descoberta no ManagementController, cria um attributeInfo correspondente - for (Entry fieldEntry : managedType.getFields().entrySet()) { - - try { - - MBeanAttributeInfo attributeInfo = new MBeanAttributeInfo(fieldEntry.getKey(), fieldEntry.getValue() - .getDescription(), fieldEntry.getValue().getGetterMethod(), fieldEntry.getValue() - .getSetterMethod()); - attributes.add(attributeInfo); - - } catch (javax.management.IntrospectionException e) { - throw new DemoiselleException(getBundle().getString("mbean-introspection-error", managedType.getType() - .getSimpleName())); - } - } - - // Para cada operação descoberta no ManagementController, cria um operationInfo correspondente - for (Entry methodEntry : managedType.getOperationMethods().entrySet()) { - - MethodDetail methodDetail = methodEntry.getValue(); - - ParameterDetail[] parameterTypes = methodDetail.getParameterTypers(); - - MBeanParameterInfo[] parameters = parameterTypes.length > 0 ? new MBeanParameterInfo[parameterTypes.length] - : null; - - if (parameters != null) { - - for (int i = 0; i < parameterTypes.length; i++) { - - parameters[i] = new MBeanParameterInfo(parameterTypes[i].getParameterName(), parameterTypes[i] - .getParameterType().getCanonicalName(), parameterTypes[i].getParameterDescription()); - } - } - - // Com todas as informações, criamos nossa instância de MBeanOperationInfo e - // acrescentamos na lista de todas as operações. - int operationType = 0; - switch(methodDetail.getType()){ - case ACTION: - operationType = MBeanOperationInfo.ACTION; - break; - - case INFO: - operationType = MBeanOperationInfo.INFO; - break; - - case ACTION_INFO: - operationType = MBeanOperationInfo.ACTION_INFO; - break; - - default: - operationType = MBeanOperationInfo.UNKNOWN; - } - - MBeanOperationInfo operation = new MBeanOperationInfo(methodDetail.getMethod().getName(), - methodDetail.getDescription(), parameters, methodDetail.getMethod().getReturnType().getName(), - operationType); - - operations.add(operation); - - } - - // Por fim criamos nosso bean info. - delegateInfo = new MBeanInfo(managedType.getType().getCanonicalName(), managedType.getDescription(), - attributes.toArray(new MBeanAttributeInfo[0]), null, operations.toArray(new MBeanOperationInfo[0]), - null); - - } - - @Override - public MBeanInfo getMBeanInfo() { - if (delegateInfo == null) { - initializeMBeanInfo(); - } - - return delegateInfo; - } - - public ResourceBundle getBundle(){ - if (bundle==null){ - bundle = new ResourceBundle("demoiselle-jmx-bundle", Locale.getDefault()); - } - - return bundle; - } - -} diff --git a/impl/extension/jmx/src/main/java/br/gov/frameworkdemoiselle/jmx/internal/MBeanHelper.java b/impl/extension/jmx/src/main/java/br/gov/frameworkdemoiselle/jmx/internal/MBeanHelper.java deleted file mode 100644 index ff16bfe..0000000 --- a/impl/extension/jmx/src/main/java/br/gov/frameworkdemoiselle/jmx/internal/MBeanHelper.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Demoiselle Framework - * Copyright (C) 2010 SERPRO - * ---------------------------------------------------------------------------- - * This file is part of Demoiselle Framework. - * - * Demoiselle Framework is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License version 3 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License version 3 - * along with this program; if not, see - * or write to the Free Software Foundation, Inc., 51 Franklin Street, - * Fifth Floor, Boston, MA 02110-1301, USA. - * ---------------------------------------------------------------------------- - * Este arquivo é parte do Framework Demoiselle. - * - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação - * do Software Livre (FSF). - * - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português - * para maiores detalhes. - * - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título - * "LICENCA.txt", junto com esse programa. Se não, acesse - * ou escreva para a Fundação do Software Livre (FSF) Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - */ -package br.gov.frameworkdemoiselle.jmx.internal; - -import java.lang.management.ManagementFactory; -import java.util.Locale; - -import javax.management.MBeanServer; -import javax.management.ObjectInstance; -import javax.management.ObjectName; - -import org.slf4j.Logger; - -import br.gov.frameworkdemoiselle.DemoiselleException; -import br.gov.frameworkdemoiselle.internal.producer.LoggerProducer; -import br.gov.frameworkdemoiselle.util.ResourceBundle; - -/** - * Class with common tools for registering MBeans into an Managed server - * - * @author SERPRO - */ -public class MBeanHelper { - - private static final Logger logger = LoggerProducer.create(MBeanHelper.class); - - private static ResourceBundle bundle = new ResourceBundle("demoiselle-jmx-bundle", Locale.getDefault()); - - private static final MBeanServer server = ManagementFactory.getPlatformMBeanServer(); - - // @Inject - // @Name("demoiselle-monitoring-bundle") - // private ResourceBundle bundle; - - /** - * Return the MBean Server instance. - * - * @return MBeanServer - */ - public static final MBeanServer getMBeanServer() { - return server; - } - - /** - * Register a given managed bean (MBean) with the specified name. - * - * @param mbean - * the managed bean to register - * @param name - * the name under which to register the bean - * @return the object name of the mbean, for later deregistration - */ - public static ObjectInstance register(final Object mbean, final String name) { - - logger.info(bundle.getString("mbean-registration",name)); - - ObjectInstance instance = null; - try { - ObjectName objectName = new ObjectName(name); - instance = server.registerMBean(mbean, objectName); - } catch (Exception e) { - logger.error(bundle.getString("mbean-registration-error",name),e); - throw new DemoiselleException(bundle.getString("mbean-registration-error",name), e); - } - - return instance; - } - - /** - * Remove the registration of a mbean. - * - * @param objectName - * the name of the bean to unregister - */ - public static void unregister(final ObjectName objectName) { - - logger.info(bundle.getString("mbean-deregistration",objectName.getCanonicalName())); - - try { - server.unregisterMBean(objectName); - } catch (Exception e) { - logger.error(bundle.getString("mbean-deregistration",objectName.getCanonicalName()),e); - throw new DemoiselleException(bundle.getString("mbean-deregistration",objectName.getCanonicalName()), e); - } - } -} diff --git a/impl/extension/jmx/src/main/java/br/gov/frameworkdemoiselle/jmx/internal/MBeanManager.java b/impl/extension/jmx/src/main/java/br/gov/frameworkdemoiselle/jmx/internal/MBeanManager.java deleted file mode 100644 index 7c7b052..0000000 --- a/impl/extension/jmx/src/main/java/br/gov/frameworkdemoiselle/jmx/internal/MBeanManager.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Demoiselle Framework - * Copyright (C) 2010 SERPRO - * ---------------------------------------------------------------------------- - * This file is part of Demoiselle Framework. - * - * Demoiselle Framework is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License version 3 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License version 3 - * along with this program; if not, see - * or write to the Free Software Foundation, Inc., 51 Franklin Street, - * Fifth Floor, Boston, MA 02110-1301, USA. - * ---------------------------------------------------------------------------- - * Este arquivo é parte do Framework Demoiselle. - * - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação - * do Software Livre (FSF). - * - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português - * para maiores detalhes. - * - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título - * "LICENCA.txt", junto com esse programa. Se não, acesse - * ou escreva para a Fundação do Software Livre (FSF) Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - */ -package br.gov.frameworkdemoiselle.jmx.internal; - -import java.util.Collection; -import java.util.HashMap; - -import javax.enterprise.context.ApplicationScoped; -import javax.management.ObjectInstance; - -@ApplicationScoped -public class MBeanManager { - - private HashMap registeredMBeans = new HashMap(); - - public void storeRegisteredMBean(ObjectInstance instance){ - registeredMBeans.put(instance.getObjectName().getCanonicalName(),instance); - } - - public Collection listRegisteredMBeans(){ - return registeredMBeans.values(); - } - - public ObjectInstance findMBeanInstance(String name){ - ObjectInstance instance = registeredMBeans.get(name); - return instance; - } - - public void cleanRegisteredMBeans(){ - registeredMBeans.clear(); - } - -} diff --git a/impl/extension/jmx/src/main/java/br/gov/frameworkdemoiselle/jmx/internal/NotificationBroadcaster.java b/impl/extension/jmx/src/main/java/br/gov/frameworkdemoiselle/jmx/internal/NotificationBroadcaster.java deleted file mode 100644 index 6eaf606..0000000 --- a/impl/extension/jmx/src/main/java/br/gov/frameworkdemoiselle/jmx/internal/NotificationBroadcaster.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Demoiselle Framework - * Copyright (C) 2010 SERPRO - * ---------------------------------------------------------------------------- - * This file is part of Demoiselle Framework. - * - * Demoiselle Framework is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License version 3 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License version 3 - * along with this program; if not, see - * or write to the Free Software Foundation, Inc., 51 Franklin Street, - * Fifth Floor, Boston, MA 02110-1301, USA. - * ---------------------------------------------------------------------------- - * Este arquivo é parte do Framework Demoiselle. - * - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação - * do Software Livre (FSF). - * - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português - * para maiores detalhes. - * - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título - * "LICENCA.txt", junto com esse programa. Se não, acesse - * ou escreva para a Fundação do Software Livre (FSF) Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - */ -package br.gov.frameworkdemoiselle.jmx.internal; - -import java.io.Serializable; - -import javax.management.AttributeChangeNotification; -import javax.management.Notification; -import javax.management.NotificationBroadcasterSupport; - -import br.gov.frameworkdemoiselle.jmx.configuration.JMXConfig; -import br.gov.frameworkdemoiselle.management.ManagementNotificationEvent; -import br.gov.frameworkdemoiselle.management.NotificationManager; - -/** - * Implementation of the {@link NotificationBroadcaster} MBean. - * When the {@link NotificationManager} sends an event, a {@link NotificationEventListener} captures the notification and uses - * this MBean to send it as a JMX notification. - * - * @author serpro - * - */ -final class NotificationBroadcaster extends NotificationBroadcasterSupport implements NotificationBroadcasterMBean,Serializable { - - private static final long serialVersionUID = 1L; - - private int sequenceNumber = 1; - - /*public static final String NOTIFICATION_DEFAULT_MBEAN_NAME = NotificationBroadcaster.class.getPackage().getName() - +":name=" - +NotificationBroadcaster.class.getSimpleName();*/ - - private static final String NOTIFICATION_TYPE_GENERIC = "jmx.message"; - - protected void sendNotification( ManagementNotificationEvent event , JMXConfig config ) { - br.gov.frameworkdemoiselle.management.GenericNotification demoiselleNotification = event.getNotification(); - Notification n = new Notification(NOTIFICATION_TYPE_GENERIC, config.getNotificationMBeanName(), sequenceNumber++, System.currentTimeMillis(), demoiselleNotification.getMessage().toString()); - sendNotification(n); - } - - protected void sendAttributeChangedMessage( ManagementNotificationEvent event , JMXConfig config ) { - br.gov.frameworkdemoiselle.management.AttributeChangeNotification demoiselleNotification = (br.gov.frameworkdemoiselle.management.AttributeChangeNotification)event.getNotification(); - - AttributeChangeNotification n = new AttributeChangeNotification(config.getNotificationMBeanName(), sequenceNumber++ - , System.currentTimeMillis(), demoiselleNotification.getMessage().toString() - , demoiselleNotification.getAttributeName(), demoiselleNotification.getAttributeType().getSimpleName() - , demoiselleNotification.getOldValue(), demoiselleNotification.getNewValue()); - - sendNotification(n); - } - -} diff --git a/impl/extension/jmx/src/main/java/br/gov/frameworkdemoiselle/jmx/internal/NotificationBroadcasterMBean.java b/impl/extension/jmx/src/main/java/br/gov/frameworkdemoiselle/jmx/internal/NotificationBroadcasterMBean.java deleted file mode 100644 index 600646c..0000000 --- a/impl/extension/jmx/src/main/java/br/gov/frameworkdemoiselle/jmx/internal/NotificationBroadcasterMBean.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Demoiselle Framework - * Copyright (C) 2010 SERPRO - * ---------------------------------------------------------------------------- - * This file is part of Demoiselle Framework. - * - * Demoiselle Framework is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License version 3 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License version 3 - * along with this program; if not, see - * or write to the Free Software Foundation, Inc., 51 Franklin Street, - * Fifth Floor, Boston, MA 02110-1301, USA. - * ---------------------------------------------------------------------------- - * Este arquivo é parte do Framework Demoiselle. - * - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação - * do Software Livre (FSF). - * - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português - * para maiores detalhes. - * - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título - * "LICENCA.txt", junto com esse programa. Se não, acesse - * ou escreva para a Fundação do Software Livre (FSF) Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - */ -package br.gov.frameworkdemoiselle.jmx.internal; - - - -/** - * MBean interface responsible for sending MBean notifications to remote clients. - * - * @author serpro - * - */ -interface NotificationBroadcasterMBean { -} diff --git a/impl/extension/jmx/src/main/java/br/gov/frameworkdemoiselle/jmx/internal/NotificationEventListener.java b/impl/extension/jmx/src/main/java/br/gov/frameworkdemoiselle/jmx/internal/NotificationEventListener.java deleted file mode 100644 index 6f0eac0..0000000 --- a/impl/extension/jmx/src/main/java/br/gov/frameworkdemoiselle/jmx/internal/NotificationEventListener.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Demoiselle Framework - * Copyright (C) 2010 SERPRO - * ---------------------------------------------------------------------------- - * This file is part of Demoiselle Framework. - * - * Demoiselle Framework is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License version 3 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License version 3 - * along with this program; if not, see - * or write to the Free Software Foundation, Inc., 51 Franklin Street, - * Fifth Floor, Boston, MA 02110-1301, USA. - * ---------------------------------------------------------------------------- - * Este arquivo é parte do Framework Demoiselle. - * - * O Framework Demoiselle é um software livre; você pode redistribuí-lo e/ou - * modificá-lo dentro dos termos da GNU LGPL versão 3 como publicada pela Fundação - * do Software Livre (FSF). - * - * Este programa é distribuído na esperança que possa ser útil, mas SEM NENHUMA - * GARANTIA; sem uma garantia implícita de ADEQUAÇÃO a qualquer MERCADO ou - * APLICAÇÃO EM PARTICULAR. Veja a Licença Pública Geral GNU/LGPL em português - * para maiores detalhes. - * - * Você deve ter recebido uma cópia da GNU LGPL versão 3, sob o título - * "LICENCA.txt", junto com esse programa. Se não, acesse - * ou escreva para a Fundação do Software Livre (FSF) Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02111-1301, USA. - */ -package br.gov.frameworkdemoiselle.jmx.internal; - -import java.io.Serializable; - -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.event.Observes; - -import br.gov.frameworkdemoiselle.internal.management.qualifier.AttributeChange; -import br.gov.frameworkdemoiselle.internal.management.qualifier.Generic; -import br.gov.frameworkdemoiselle.jmx.configuration.JMXConfig; -import br.gov.frameworkdemoiselle.management.ManagementNotificationEvent; -import br.gov.frameworkdemoiselle.management.NotificationManager; - -/** - * Listens to {@link NotificationManager} notification events and proxies them - * to a {@link NotificationBroadcaster} MBean. This MBean will send the notification to - * any JMX clients connected and listening. - * - * @author serpro - * - */ -@ApplicationScoped -@SuppressWarnings("serial") -public class NotificationEventListener implements Serializable { - - private NotificationBroadcaster notificationBroadcaster; - - public void sendNotification( @Observes @Generic ManagementNotificationEvent event , JMXConfig config ) { - createNotificationBroadcaster().sendNotification(event,config); - } - - public void sendAttributeChangedMessage( @Observes @AttributeChange ManagementNotificationEvent event , JMXConfig config ) { - createNotificationBroadcaster().sendAttributeChangedMessage(event, config); - } - - public NotificationBroadcaster createNotificationBroadcaster(){ - if (notificationBroadcaster==null){ - notificationBroadcaster = new NotificationBroadcaster(); - } - - return notificationBroadcaster; - } - -} diff --git a/impl/extension/jmx/src/test/java/management/tests/basic/DynamicMBeanProxyTest.java b/impl/extension/jmx/src/test/java/management/tests/basic/DynamicMBeanProxyTest.java index 2184413..fb692f2 100644 --- a/impl/extension/jmx/src/test/java/management/tests/basic/DynamicMBeanProxyTest.java +++ b/impl/extension/jmx/src/test/java/management/tests/basic/DynamicMBeanProxyTest.java @@ -55,7 +55,7 @@ import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; -import br.gov.frameworkdemoiselle.jmx.internal.MBeanManager; +import br.gov.frameworkdemoiselle.internal.MBeanManager; import br.gov.frameworkdemoiselle.lifecycle.AfterShutdownProccess; import br.gov.frameworkdemoiselle.lifecycle.AfterStartupProccess; import br.gov.frameworkdemoiselle.util.Beans; diff --git a/impl/extension/jmx/src/test/java/management/tests/notification/NotificationBroadcasterTest.java b/impl/extension/jmx/src/test/java/management/tests/notification/NotificationBroadcasterTest.java index 4a46aa3..a8ec782 100644 --- a/impl/extension/jmx/src/test/java/management/tests/notification/NotificationBroadcasterTest.java +++ b/impl/extension/jmx/src/test/java/management/tests/notification/NotificationBroadcasterTest.java @@ -57,8 +57,8 @@ import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; -import br.gov.frameworkdemoiselle.jmx.configuration.JMXConfig; -import br.gov.frameworkdemoiselle.jmx.internal.MBeanManager; +import br.gov.frameworkdemoiselle.configuration.JMXConfig; +import br.gov.frameworkdemoiselle.internal.MBeanManager; import br.gov.frameworkdemoiselle.lifecycle.AfterShutdownProccess; import br.gov.frameworkdemoiselle.lifecycle.AfterStartupProccess; import br.gov.frameworkdemoiselle.management.AttributeChangeNotification; -- libgit2 0.21.2