Commit 06f0288059059e8be3509c909093fdb0340587aa
Exists in
master
Merge branch '2.4.0' of git@github.com:demoiselle/framework.git into 2.4.0
Showing
7 changed files
with
102 additions
and
74 deletions
Show diff stats
documentation/quickstart/pom.xml
| ... | ... | @@ -45,7 +45,7 @@ |
| 45 | 45 | <parent> |
| 46 | 46 | <groupId>br.gov.frameworkdemoiselle</groupId> |
| 47 | 47 | <artifactId>demoiselle-documentation-parent</artifactId> |
| 48 | - <version>8</version> | |
| 48 | + <version>9-SNAPSHOT</version> | |
| 49 | 49 | <relativePath>../../../internal/parent/documentation</relativePath> |
| 50 | 50 | </parent> |
| 51 | 51 | ... | ... |
documentation/reference/pom.xml
| ... | ... | @@ -45,7 +45,7 @@ |
| 45 | 45 | <parent> |
| 46 | 46 | <groupId>br.gov.frameworkdemoiselle</groupId> |
| 47 | 47 | <artifactId>demoiselle-documentation-parent</artifactId> |
| 48 | - <version>8</version> | |
| 48 | + <version>9-SNAPSHOT</version> | |
| 49 | 49 | <relativePath>../../../internal/parent/documentation</relativePath> |
| 50 | 50 | </parent> |
| 51 | 51 | ... | ... |
impl/extension/jmx/pom.xml
| ... | ... | @@ -45,7 +45,7 @@ |
| 45 | 45 | <parent> |
| 46 | 46 | <artifactId>demoiselle-extension-parent</artifactId> |
| 47 | 47 | <groupId>br.gov.frameworkdemoiselle</groupId> |
| 48 | - <version>2.4.0-BETA2-SNAPSHOT</version> | |
| 48 | + <version>2.4.0-BETA3-SNAPSHOT</version> | |
| 49 | 49 | <relativePath>../../../parent/extension</relativePath> |
| 50 | 50 | </parent> |
| 51 | 51 | ... | ... |
impl/extension/jmx/src/test/java/management/tests/internal/DynamicMBeanProxyTestCase.java
| ... | ... | @@ -52,12 +52,15 @@ import org.jboss.arquillian.container.test.api.Deployment; |
| 52 | 52 | import org.jboss.arquillian.junit.Arquillian; |
| 53 | 53 | import org.jboss.shrinkwrap.api.ShrinkWrap; |
| 54 | 54 | import org.jboss.shrinkwrap.api.asset.FileAsset; |
| 55 | -import org.jboss.shrinkwrap.api.exporter.ZipExporter; | |
| 56 | 55 | import org.jboss.shrinkwrap.api.spec.JavaArchive; |
| 56 | +import org.junit.AfterClass; | |
| 57 | +import org.junit.BeforeClass; | |
| 57 | 58 | import org.junit.Test; |
| 58 | 59 | import org.junit.runner.RunWith; |
| 59 | 60 | |
| 60 | 61 | import br.gov.frameworkdemoiselle.jmx.internal.MBeanManager; |
| 62 | +import br.gov.frameworkdemoiselle.lifecycle.AfterShutdownProccess; | |
| 63 | +import br.gov.frameworkdemoiselle.lifecycle.AfterStartupProccess; | |
| 61 | 64 | import br.gov.frameworkdemoiselle.util.Beans; |
| 62 | 65 | |
| 63 | 66 | @RunWith(Arquillian.class) |
| ... | ... | @@ -73,12 +76,21 @@ public class DynamicMBeanProxyTestCase { |
| 73 | 76 | .addPackages(false, DynamicMBeanProxyTestCase.class.getPackage()) |
| 74 | 77 | .addClasses(LocaleProducer.class, ManagedTestClass.class); |
| 75 | 78 | |
| 76 | - mainDeployment.as(ZipExporter.class).exportTo( | |
| 77 | - new File("/home/81986912515/myPackage.jar"), true); | |
| 78 | - | |
| 79 | 79 | return mainDeployment; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | + @BeforeClass | |
| 83 | + public static void fireEventStartupProccess() { | |
| 84 | + Beans.getBeanManager().fireEvent(new AfterStartupProccess() { | |
| 85 | + }); | |
| 86 | + } | |
| 87 | + | |
| 88 | + @AfterClass | |
| 89 | + public static void fireEventShutdownProccess() { | |
| 90 | + Beans.getBeanManager().fireEvent(new AfterShutdownProccess() { | |
| 91 | + }); | |
| 92 | + } | |
| 93 | + | |
| 82 | 94 | /** |
| 83 | 95 | * Testa se o bootstrap está corretamente carregando e registrando classes anotadas com {@link Managed} como MBeans. |
| 84 | 96 | */ | ... | ... |
impl/extension/jmx/src/test/java/management/tests/internal/NotificationBroadcasterTestCase.java
| ... | ... | @@ -55,11 +55,15 @@ import org.jboss.arquillian.junit.Arquillian; |
| 55 | 55 | import org.jboss.shrinkwrap.api.ShrinkWrap; |
| 56 | 56 | import org.jboss.shrinkwrap.api.asset.FileAsset; |
| 57 | 57 | import org.jboss.shrinkwrap.api.spec.JavaArchive; |
| 58 | +import org.junit.AfterClass; | |
| 59 | +import org.junit.BeforeClass; | |
| 58 | 60 | import org.junit.Test; |
| 59 | 61 | import org.junit.runner.RunWith; |
| 60 | 62 | |
| 61 | 63 | import br.gov.frameworkdemoiselle.jmx.configuration.JMXConfig; |
| 62 | 64 | import br.gov.frameworkdemoiselle.jmx.internal.MBeanManager; |
| 65 | +import br.gov.frameworkdemoiselle.lifecycle.AfterShutdownProccess; | |
| 66 | +import br.gov.frameworkdemoiselle.lifecycle.AfterStartupProccess; | |
| 63 | 67 | import br.gov.frameworkdemoiselle.management.AttributeChangeNotification; |
| 64 | 68 | import br.gov.frameworkdemoiselle.management.GenericNotification; |
| 65 | 69 | import br.gov.frameworkdemoiselle.management.NotificationManager; |
| ... | ... | @@ -67,7 +71,7 @@ import br.gov.frameworkdemoiselle.util.Beans; |
| 67 | 71 | |
| 68 | 72 | @RunWith(Arquillian.class) |
| 69 | 73 | public class NotificationBroadcasterTestCase { |
| 70 | - | |
| 74 | + | |
| 71 | 75 | @Deployment |
| 72 | 76 | public static JavaArchive createDeployment() { |
| 73 | 77 | JavaArchive mainDeployment = ShrinkWrap.create(JavaArchive.class); |
| ... | ... | @@ -80,129 +84,140 @@ public class NotificationBroadcasterTestCase { |
| 80 | 84 | |
| 81 | 85 | return mainDeployment; |
| 82 | 86 | } |
| 83 | - | |
| 87 | + | |
| 88 | + @BeforeClass | |
| 89 | + public static void fireEventStartupProccess() { | |
| 90 | + Beans.getBeanManager().fireEvent(new AfterStartupProccess() { | |
| 91 | + }); | |
| 92 | + } | |
| 93 | + | |
| 94 | + @AfterClass | |
| 95 | + public static void fireEventShutdownProccess() { | |
| 96 | + Beans.getBeanManager().fireEvent(new AfterShutdownProccess() { | |
| 97 | + }); | |
| 98 | + } | |
| 99 | + | |
| 84 | 100 | /** |
| 85 | 101 | * Testa o envio de uma mensagem para clientes conectados |
| 86 | 102 | */ |
| 87 | 103 | @Test |
| 88 | - public void sendMessageTest(){ | |
| 104 | + public void sendMessageTest() { | |
| 89 | 105 | JMXConfig config = Beans.getReference(JMXConfig.class); |
| 90 | - | |
| 91 | - //Este será o lado cliente. Este manager é usado para enviar notificações a partir do código da aplicação | |
| 106 | + | |
| 107 | + // Este será o lado cliente. Este manager é usado para enviar notificações a partir do código da aplicação | |
| 92 | 108 | NotificationManager notificationManager = Beans.getReference(NotificationManager.class); |
| 93 | - | |
| 94 | - //Obtém o servidor MBean onde anexaremos um listener para a notificação | |
| 109 | + | |
| 110 | + // Obtém o servidor MBean onde anexaremos um listener para a notificação | |
| 95 | 111 | MBeanServer server = ManagementFactory.getPlatformMBeanServer(); |
| 96 | - | |
| 97 | - //Aqui obtemos o MBean de notificações já registrado pelo bootstrap | |
| 112 | + | |
| 113 | + // Aqui obtemos o MBean de notificações já registrado pelo bootstrap | |
| 98 | 114 | StringBuffer notificationMBeanName = new StringBuffer() |
| 99 | - .append( config.getNotificationDomain()!=null ? config.getNotificationDomain() : "br.gov.frameworkdemoiselle.jmx" ) | |
| 100 | - .append(":name=") | |
| 101 | - .append( config.getNotificationMBeanName()); | |
| 102 | - | |
| 115 | + .append(config.getNotificationDomain() != null ? config.getNotificationDomain() | |
| 116 | + : "br.gov.frameworkdemoiselle.jmx").append(":name=").append(config.getNotificationMBeanName()); | |
| 117 | + | |
| 103 | 118 | ObjectName name = null; |
| 104 | 119 | try { |
| 105 | 120 | name = new ObjectName(notificationMBeanName.toString()); |
| 106 | 121 | } catch (MalformedObjectNameException e) { |
| 107 | 122 | Assert.fail(); |
| 108 | 123 | } |
| 109 | - | |
| 110 | - //StringBuffer vazio | |
| 124 | + | |
| 125 | + // StringBuffer vazio | |
| 111 | 126 | StringBuffer notificationBuffer = new StringBuffer(); |
| 112 | - | |
| 113 | - //Este notification listener será chamado quando o Demoiselle enviar a notificação e vai colocar | |
| 114 | - //a mensagem enviada em "notificationBuffer" | |
| 127 | + | |
| 128 | + // Este notification listener será chamado quando o Demoiselle enviar a notificação e vai colocar | |
| 129 | + // a mensagem enviada em "notificationBuffer" | |
| 115 | 130 | NotificationListener listener = new TestNotificationListener(notificationBuffer); |
| 116 | - | |
| 131 | + | |
| 117 | 132 | try { |
| 118 | - //Anexa o listener no servidor MBean | |
| 119 | - server.addNotificationListener(name,listener,null,null); | |
| 133 | + // Anexa o listener no servidor MBean | |
| 134 | + server.addNotificationListener(name, listener, null, null); | |
| 120 | 135 | } catch (InstanceNotFoundException e) { |
| 121 | 136 | Assert.fail(); |
| 122 | 137 | } |
| 123 | - | |
| 124 | - //Manda a notificação pelo Demoiselle | |
| 138 | + | |
| 139 | + // Manda a notificação pelo Demoiselle | |
| 125 | 140 | GenericNotification n = new GenericNotification("Notification test successful"); |
| 126 | 141 | notificationManager.sendNotification(n); |
| 127 | - | |
| 128 | - //Se o componente funcionou, o Demoiselle propagou a notificação para o servidor MBean e o listener preencheu | |
| 129 | - //o StringBuffer com nossa mensagem. | |
| 142 | + | |
| 143 | + // Se o componente funcionou, o Demoiselle propagou a notificação para o servidor MBean e o listener preencheu | |
| 144 | + // o StringBuffer com nossa mensagem. | |
| 130 | 145 | Assert.assertEquals("Notification test successful", notificationBuffer.toString()); |
| 131 | - | |
| 146 | + | |
| 132 | 147 | } |
| 133 | - | |
| 148 | + | |
| 134 | 149 | /** |
| 135 | 150 | * Testa o envio de uma mensagem de mudança de atributo para clientes conectados |
| 136 | 151 | */ |
| 137 | 152 | @Test |
| 138 | - public void sendAttributeChangedMessageTest(){ | |
| 153 | + public void sendAttributeChangedMessageTest() { | |
| 139 | 154 | JMXConfig config = Beans.getReference(JMXConfig.class); |
| 140 | - | |
| 141 | - //Obtém o servidor MBean onde anexaremos um listener para a notificação | |
| 155 | + | |
| 156 | + // Obtém o servidor MBean onde anexaremos um listener para a notificação | |
| 142 | 157 | MBeanServer server = ManagementFactory.getPlatformMBeanServer(); |
| 143 | - | |
| 158 | + | |
| 144 | 159 | NotificationManager notificationManager = Beans.getReference(NotificationManager.class); |
| 145 | 160 | MBeanManager mBeanManager = Beans.getReference(MBeanManager.class); |
| 146 | - | |
| 147 | - //Aqui obtemos o MBean de notificações já registrado pelo bootstrap | |
| 161 | + | |
| 162 | + // Aqui obtemos o MBean de notificações já registrado pelo bootstrap | |
| 148 | 163 | StringBuffer notificationMBeanName = new StringBuffer() |
| 149 | - .append( config.getNotificationDomain()!=null ? config.getNotificationDomain() : "br.gov.frameworkdemoiselle.jmx" ) | |
| 150 | - .append(":name=") | |
| 151 | - .append( config.getNotificationMBeanName()); | |
| 164 | + .append(config.getNotificationDomain() != null ? config.getNotificationDomain() | |
| 165 | + : "br.gov.frameworkdemoiselle.jmx").append(":name=").append(config.getNotificationMBeanName()); | |
| 152 | 166 | ObjectInstance instance = mBeanManager.findMBeanInstance(notificationMBeanName.toString()); |
| 153 | - | |
| 154 | - //StringBuffer vazio | |
| 167 | + | |
| 168 | + // StringBuffer vazio | |
| 155 | 169 | StringBuffer notificationBuffer = new StringBuffer(); |
| 156 | - | |
| 157 | - //Este notification listener será chamado quando o Demoiselle enviar a notificação e vai colocar | |
| 158 | - //a mensagem enviada em "notificationBuffer" | |
| 170 | + | |
| 171 | + // Este notification listener será chamado quando o Demoiselle enviar a notificação e vai colocar | |
| 172 | + // a mensagem enviada em "notificationBuffer" | |
| 159 | 173 | NotificationListener listener = new TestNotificationListener(notificationBuffer); |
| 160 | - | |
| 174 | + | |
| 161 | 175 | try { |
| 162 | - //Anexa o listener no servidor MBean | |
| 163 | - server.addNotificationListener(instance.getObjectName(),listener,null,null); | |
| 176 | + // Anexa o listener no servidor MBean | |
| 177 | + server.addNotificationListener(instance.getObjectName(), listener, null, null); | |
| 164 | 178 | } catch (InstanceNotFoundException e) { |
| 165 | 179 | Assert.fail(); |
| 166 | 180 | } |
| 167 | - | |
| 168 | - //Manda a notificação pelo Demoiselle | |
| 169 | - AttributeChangeNotification notification = new AttributeChangeNotification("Attribute Changed","name",String.class,"Demoiselle 1","Demoiselle 2"); | |
| 181 | + | |
| 182 | + // Manda a notificação pelo Demoiselle | |
| 183 | + AttributeChangeNotification notification = new AttributeChangeNotification("Attribute Changed", "name", | |
| 184 | + String.class, "Demoiselle 1", "Demoiselle 2"); | |
| 170 | 185 | notificationManager.sendNotification(notification); |
| 171 | - | |
| 172 | - //Se o componente funcionou, o Demoiselle propagou a notificação para o servidor MBean e o listener preencheu | |
| 173 | - //o StringBuffer com nossa mensagem. | |
| 186 | + | |
| 187 | + // Se o componente funcionou, o Demoiselle propagou a notificação para o servidor MBean e o listener preencheu | |
| 188 | + // o StringBuffer com nossa mensagem. | |
| 174 | 189 | Assert.assertEquals("Attribute Changed: name = Demoiselle 2", notificationBuffer.toString()); |
| 175 | - | |
| 190 | + | |
| 176 | 191 | } |
| 177 | - | |
| 192 | + | |
| 178 | 193 | /** |
| 179 | - * Implementação do {@link NotificationListener} do Java que vai por qualquer notificação recebida em um StringBuffer. | |
| 194 | + * Implementação do {@link NotificationListener} do Java que vai por qualquer notificação recebida em um | |
| 195 | + * StringBuffer. | |
| 180 | 196 | * |
| 181 | 197 | * @author serpro |
| 182 | - * | |
| 183 | 198 | */ |
| 184 | 199 | class TestNotificationListener implements NotificationListener { |
| 185 | - | |
| 200 | + | |
| 186 | 201 | StringBuffer message; |
| 187 | - | |
| 188 | - public TestNotificationListener(StringBuffer testMessage){ | |
| 202 | + | |
| 203 | + public TestNotificationListener(StringBuffer testMessage) { | |
| 189 | 204 | this.message = testMessage; |
| 190 | 205 | } |
| 191 | 206 | |
| 192 | 207 | @Override |
| 193 | 208 | public void handleNotification(javax.management.Notification notification, Object handback) { |
| 194 | - if (message!=null){ | |
| 209 | + if (message != null) { | |
| 195 | 210 | message.append(notification.getMessage()); |
| 196 | - | |
| 197 | - if (notification instanceof javax.management.AttributeChangeNotification){ | |
| 211 | + | |
| 212 | + if (notification instanceof javax.management.AttributeChangeNotification) { | |
| 198 | 213 | message.append(": ") |
| 199 | - .append( ((javax.management.AttributeChangeNotification)notification).getAttributeName() ) | |
| 200 | - .append(" = ") | |
| 201 | - .append(((javax.management.AttributeChangeNotification)notification).getNewValue()); | |
| 214 | + .append(((javax.management.AttributeChangeNotification) notification).getAttributeName()) | |
| 215 | + .append(" = ") | |
| 216 | + .append(((javax.management.AttributeChangeNotification) notification).getNewValue()); | |
| 202 | 217 | } |
| 203 | 218 | } |
| 204 | 219 | } |
| 205 | - | |
| 220 | + | |
| 206 | 221 | } |
| 207 | 222 | |
| 208 | 223 | } | ... | ... |
parent/framework/pom.xml
| ... | ... | @@ -45,7 +45,7 @@ |
| 45 | 45 | <parent> |
| 46 | 46 | <groupId>br.gov.frameworkdemoiselle</groupId> |
| 47 | 47 | <artifactId>demoiselle-parent</artifactId> |
| 48 | - <version>8</version> | |
| 48 | + <version>9-SNAPSHOT</version> | |
| 49 | 49 | <relativePath>../../../internal/parent/demoiselle</relativePath> |
| 50 | 50 | </parent> |
| 51 | 51 | ... | ... |
pom.xml
| ... | ... | @@ -45,7 +45,7 @@ |
| 45 | 45 | <parent> |
| 46 | 46 | <groupId>br.gov.frameworkdemoiselle</groupId> |
| 47 | 47 | <artifactId>demoiselle-build-parent</artifactId> |
| 48 | - <version>8</version> | |
| 48 | + <version>9-SNAPSHOT</version> | |
| 49 | 49 | <relativePath>../internal/parent/build/demoiselle</relativePath> |
| 50 | 50 | </parent> |
| 51 | 51 | |
| ... | ... | @@ -71,6 +71,7 @@ |
| 71 | 71 | <module>impl/extension/jta</module> |
| 72 | 72 | <module>impl/extension/se</module> |
| 73 | 73 | <module>impl/extension/servlet</module> |
| 74 | + <module>impl/extension/jmx</module> | |
| 74 | 75 | <!-- |
| 75 | 76 | <module>impl/extension/jaas</module> |
| 76 | 77 | --> | ... | ... |