diff --git a/easyrules-jmx/pom.xml b/easyrules-jmx/pom.xml deleted file mode 100644 index 3d3bbb3..0000000 --- a/easyrules-jmx/pom.xml +++ /dev/null @@ -1,74 +0,0 @@ - - 4.0.0 - - - org.easyrules - easyrules - 2.4.0-SNAPSHOT - - - easyrules-jmx - jar - - Easy Rules JMX module - Module for rule monitoring and management through JMX - - - git@github.com:EasyRules/easyrules.git - scm:git:git@github.com:EasyRules/easyrules.git - scm:git:git@github.com:EasyRules/easyrules.git - HEAD - - - - GitHub - https://github.com/EasyRules/easyrules/issues - - - - Travis CI - https://travis-ci.org/EasyRules/easyrules - - - - - benas - Mahmoud Ben Hassine - http://benas.github.io - mahmoud.benhassine@icloud.com - - Lead developer - - - - - - - MIT License - http://opensource.org/licenses/mit-license.php - - - - - - org.easyrules - easyrules-core - - - junit - junit - test - - - org.assertj - assertj-core - test - - - org.mockito - mockito-core - test - - - - diff --git a/easyrules-jmx/src/main/java/org/easyrules/api/JmxRule.java b/easyrules-jmx/src/main/java/org/easyrules/api/JmxRule.java deleted file mode 100644 index 687e4b4..0000000 --- a/easyrules-jmx/src/main/java/org/easyrules/api/JmxRule.java +++ /dev/null @@ -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 { - -} diff --git a/easyrules-jmx/src/main/java/org/easyrules/api/JmxRulesEngine.java b/easyrules-jmx/src/main/java/org/easyrules/api/JmxRulesEngine.java deleted file mode 100644 index 77da2e2..0000000 --- a/easyrules-jmx/src/main/java/org/easyrules/api/JmxRulesEngine.java +++ /dev/null @@ -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 must 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); -} diff --git a/easyrules-jmx/src/main/java/org/easyrules/core/BasicJmxRule.java b/easyrules-jmx/src/main/java/org/easyrules/core/BasicJmxRule.java deleted file mode 100644 index e4e52f8..0000000 --- a/easyrules-jmx/src/main/java/org/easyrules/core/BasicJmxRule.java +++ /dev/null @@ -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 { - -} diff --git a/easyrules-jmx/src/main/java/org/easyrules/core/DefaultJmxRulesEngine.java b/easyrules-jmx/src/main/java/org/easyrules/core/DefaultJmxRulesEngine.java deleted file mode 100644 index daff049..0000000 --- a/easyrules-jmx/src/main/java/org/easyrules/core/DefaultJmxRulesEngine.java +++ /dev/null @@ -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 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); - } - -} diff --git a/easyrules-jmx/src/main/java/org/easyrules/core/JmxRulesEngineBuilder.java b/easyrules-jmx/src/main/java/org/easyrules/core/JmxRulesEngineBuilder.java deleted file mode 100644 index 05a86ce..0000000 --- a/easyrules-jmx/src/main/java/org/easyrules/core/JmxRulesEngineBuilder.java +++ /dev/null @@ -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 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); - } - -} diff --git a/easyrules-jmx/src/main/java/org/easyrules/core/MBeanManager.java b/easyrules-jmx/src/main/java/org/easyrules/core/MBeanManager.java deleted file mode 100644 index 9d5f522..0000000 --- a/easyrules-jmx/src/main/java/org/easyrules/core/MBeanManager.java +++ /dev/null @@ -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)); - } -} diff --git a/easyrules-jmx/src/test/java/org/easyrules/core/JmxRuleRegistrationTest.java b/easyrules-jmx/src/test/java/org/easyrules/core/JmxRuleRegistrationTest.java deleted file mode 100644 index 0cea0e1..0000000 --- a/easyrules-jmx/src/test/java/org/easyrules/core/JmxRuleRegistrationTest.java +++ /dev/null @@ -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(); - - } - -} diff --git a/pom.xml b/pom.xml index f09a074..bfe96f4 100644 --- a/pom.xml +++ b/pom.xml @@ -15,7 +15,6 @@ easyrules-archetype easyrules-core - easyrules-jmx easyrules-quartz easyrules-spring