remove easyrules-jmx module. JMX managed rules have been deprecated in version 2.3 (issue #47)

pull/55/head
Mahmoud Ben Hassine 9 years ago
parent e084f1e88e
commit 29f2a24087

@ -1,74 +0,0 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.easyrules</groupId>
<artifactId>easyrules</artifactId>
<version>2.4.0-SNAPSHOT</version>
</parent>
<artifactId>easyrules-jmx</artifactId>
<packaging>jar</packaging>
<name>Easy Rules JMX module</name>
<description>Module for rule monitoring and management through JMX</description>
<scm>
<url>git@github.com:EasyRules/easyrules.git</url>
<connection>scm:git:git@github.com:EasyRules/easyrules.git</connection>
<developerConnection>scm:git:git@github.com:EasyRules/easyrules.git</developerConnection>
<tag>HEAD</tag>
</scm>
<issueManagement>
<system>GitHub</system>
<url>https://github.com/EasyRules/easyrules/issues</url>
</issueManagement>
<ciManagement>
<system>Travis CI</system>
<url>https://travis-ci.org/EasyRules/easyrules</url>
</ciManagement>
<developers>
<developer>
<id>benas</id>
<name>Mahmoud Ben Hassine</name>
<url>http://benas.github.io</url>
<email>mahmoud.benhassine@icloud.com</email>
<roles>
<role>Lead developer</role>
</roles>
</developer>
</developers>
<licenses>
<license>
<name>MIT License</name>
<url>http://opensource.org/licenses/mit-license.php</url>
</license>
</licenses>
<dependencies>
<dependency>
<groupId>org.easyrules</groupId>
<artifactId>easyrules-core</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>

@ -1,38 +0,0 @@
/*
* The MIT License
*
* Copyright (c) 2016, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.easyrules.api;
import javax.management.MXBean;
/**
* This is simply a Marker interface that decorates {@link org.easyrules.api.Rule} as being an MXBean interface.
*
* @author Drem Darios (drem.darios@gmail.com)
*/
@Deprecated
@MXBean
public interface JmxRule extends Rule {
}

@ -1,51 +0,0 @@
/*
* The MIT License
*
* Copyright (c) 2016, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.easyrules.api;
/**
* Decorates {@link org.easyrules.api.RulesEngine} to add handling of JMX rules.
*
* @author Drem Darios (drem.darios@gmail.com)
*/
@Deprecated
public interface JmxRulesEngine extends RulesEngine {
/**
* Register a rule in the rules engine registry.
* This method also registers the rule as a JMX bean.
* The rule object <strong>must</strong> be JMX compliant.
*
* @param rule the rule to register
*/
void registerJmxRule(Object rule);
/**
* Unegister a rule from the rules engine registry.
* This method also unregisters the rule from MBean server.
*
* @param rule the rule to register
*/
void unregisterJmxRule(Object rule);
}

@ -1,40 +0,0 @@
/*
* The MIT License
*
* Copyright (c) 2016, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.easyrules.core;
import org.easyrules.api.JmxRule;
import javax.management.MXBean;
/**
* An extension of {@link org.easyrules.core.BasicRule} that is supported by JMX.
*
* @author Drem Darios (drem.darios@gmail.com)
*/
@Deprecated
@MXBean
public class BasicJmxRule extends BasicRule implements JmxRule {
}

@ -1,59 +0,0 @@
/*
* The MIT License
*
* Copyright (c) 2016, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.easyrules.core;
import org.easyrules.api.JmxRulesEngine;
import org.easyrules.api.RuleListener;
import java.util.List;
/**
* Default {@link JmxRulesEngine} implementation.
*
* This implementation handles a set of JMX rules with unique names.
*
* @author Drem Darios (drem.darios@gmail.com)
*/
class DefaultJmxRulesEngine extends DefaultRulesEngine implements JmxRulesEngine {
private MBeanManager beanManager = new MBeanManager();
DefaultJmxRulesEngine(RulesEngineParameters parameters, List<RuleListener> ruleListeners) {
super(parameters, ruleListeners);
}
@Override
public void registerJmxRule(Object rule) {
super.registerRule(rule);
beanManager.registerJmxMBean(rule);
}
@Override
public void unregisterJmxRule(Object rule) {
super.unregisterRule(rule);
beanManager.unregisterJmxMBean(rule);
}
}

@ -1,90 +0,0 @@
/*
* The MIT License
*
* Copyright (c) 2016, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.easyrules.core;
import org.easyrules.api.JmxRulesEngine;
import org.easyrules.api.RuleListener;
import org.easyrules.util.Utils;
import java.util.ArrayList;
import java.util.List;
/**
* Builder for Jmx rules engine instances.
*
* @author Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com)
*/
@Deprecated
public class JmxRulesEngineBuilder {
private RulesEngineParameters parameters;
private List<RuleListener> ruleListeners;
@Deprecated
public static JmxRulesEngineBuilder aNewJmxRulesEngine() {
return new JmxRulesEngineBuilder();
}
private JmxRulesEngineBuilder() {
parameters = new RulesEngineParameters(Utils.DEFAULT_ENGINE_NAME, false, false, Utils.DEFAULT_RULE_PRIORITY_THRESHOLD, false);
ruleListeners = new ArrayList<>();
}
public JmxRulesEngineBuilder named(String name) {
parameters.setName(name);
return this;
}
public JmxRulesEngineBuilder withSkipOnFirstAppliedRule(boolean skipOnFirstAppliedRule) {
parameters.setSkipOnFirstAppliedRule(skipOnFirstAppliedRule);
return this;
}
public JmxRulesEngineBuilder withSkipOnFirstFailedRule(boolean skipOnFirstFailedRule) {
parameters.setSkipOnFirstFailedRule(skipOnFirstFailedRule);
return this;
}
public JmxRulesEngineBuilder withRulePriorityThreshold(int priorityThreshold) {
parameters.setPriorityThreshold(priorityThreshold);
return this;
}
public JmxRulesEngineBuilder withRuleListener(RuleListener ruleListener) {
this.ruleListeners.add(ruleListener);
return this;
}
public JmxRulesEngineBuilder withSilentMode(boolean silentMode) {
parameters.setSilentMode(silentMode);
return this;
}
public JmxRulesEngine build() {
return new DefaultJmxRulesEngine(parameters, ruleListeners);
}
}

@ -1,93 +0,0 @@
/*
* The MIT License
*
* Copyright (c) 2016, Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.easyrules.core;
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
import java.lang.management.ManagementFactory;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* Handles keeping track of MBeans and helps reduce Boilerplate code.
*
* @author Drem Darios (drem.darios@gmail.com)
*/
class MBeanManager {
private static final Logger LOGGER = Logger.getLogger(MBeanManager.class.getName());
/**
* The JMX server instance in which rule's MBeans will be registered.
*/
private MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
/*
* Unregister the JMX MBean of a rule.
*/
public void unregisterJmxMBean(final Object rule) {
ObjectName name;
try {
name = getObjectName(rule);
if (mBeanServer.isRegistered(name)) {
mBeanServer.unregisterMBean(name);
LOGGER.log(Level.INFO, "JMX MBean unregistered successfully for rule: ''{0}''", rule);
}
} catch (Exception e) {
LOGGER.log(Level.SEVERE, String.format("Unable to unregister JMX MBean for rule: '%s'", rule), e);
}
}
/*
* Register a JMX MBean for a rule.
*/
public void registerJmxMBean(final Object rule) {
ObjectName name;
try {
name = getObjectName(rule);
if (!mBeanServer.isRegistered(name)) {
mBeanServer.registerMBean(rule, name);
LOGGER.log(
Level.INFO,
"JMX MBean registered successfully as: ''{0}'' for rule: ''{1}''",
new Object[]{name.getCanonicalName(), rule});
}
} catch (Exception e) {
LOGGER.log(Level.SEVERE, String.format("Unable to register JMX MBean for rule: '%s'", rule), e);
}
}
/*
* Utility method to get rule's JMX Object name
*/
private ObjectName getObjectName(Object rule)
throws MalformedObjectNameException {
return new ObjectName(String.format("org.easyrules.core.jmx:type=%s,name=%s", rule.getClass().getSimpleName(), rule));
}
}

@ -1,59 +0,0 @@
package org.easyrules.core;
import org.easyrules.api.JmxRule;
import org.easyrules.api.JmxRulesEngine;
import org.easyrules.api.Rule;
import org.junit.Before;
import org.junit.Test;
import javax.management.*;
import java.lang.management.ManagementFactory;
import static org.assertj.core.api.Assertions.assertThat;
import static org.easyrules.core.JmxRulesEngineBuilder.aNewJmxRulesEngine;
/**
* Test class for JMX managed rule registration.
*
* @author Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com)
*/
public class JmxRuleRegistrationTest {
private JmxRule rule;
private JmxRulesEngine rulesEngine;
@Before
public void setup() {
rule = new BasicJmxRule();
rulesEngine = aNewJmxRulesEngine().build();
}
@Test
public void testJmxRuleRegistration() throws MalformedObjectNameException, IntrospectionException, InstanceNotFoundException, ReflectionException {
rulesEngine.registerJmxRule(rule);
//assert that the rule has been successfully registered within the JMX registry
MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
ObjectName name = new ObjectName("org.easyrules.core.jmx:type=" + rule.getClass().getSimpleName() + ",name=" + rule.getName());
MBeanInfo mBeanInfo = mBeanServer.getMBeanInfo(name);
assertThat(mBeanInfo).isNotNull();
assertThat(mBeanServer.isRegistered(name)).isTrue();
}
@Test
public void testJmxRuleUnregistration() throws MalformedObjectNameException, IntrospectionException, InstanceNotFoundException, ReflectionException {
rulesEngine.unregisterJmxRule(rule);
//assert that the rule has been successfully unregistered form the JMX registry
MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
ObjectName name = new ObjectName("org.easyrules.core.jmx:type=" + rule.getClass().getSimpleName() + ",name=" + rule.getName());
assertThat(mBeanServer.isRegistered(name)).isFalse();
}
}

@ -15,7 +15,6 @@
<modules>
<module>easyrules-archetype</module>
<module>easyrules-core</module>
<module>easyrules-jmx</module>
<module>easyrules-quartz</module>
<module>easyrules-spring</module>
</modules>

Loading…
Cancel
Save