deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject [3/5] deltaspike git commit: DELTASPIKE-1245 improve MBean handling
Date Wed, 03 May 2017 09:48:06 GMT
DELTASPIKE-1245 improve MBean handling


Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/d64cab49
Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/d64cab49
Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/d64cab49

Branch: refs/heads/master
Commit: d64cab49570a26094a8caaa7698d9a1c7fdce624
Parents: c566653
Author: Mark Struberg <struberg@apache.org>
Authored: Tue Apr 25 21:28:16 2017 +0200
Committer: Mark Struberg <struberg@apache.org>
Committed: Tue Apr 25 21:28:16 2017 +0200

----------------------------------------------------------------------
 .../impl/config/ConfigurationExtension.java     |  7 ++-
 .../core/impl/config/DeltaSpikeConfigInfo.java  | 64 ++++++++++++++++++++
 .../impl/config/DeltaSpikeConfigInfoMBean.java  | 26 ++++++++
 .../core/impl/config/DeltaSpikeConfigMBean.java | 63 -------------------
 .../META-INF/apache-deltaspike.properties       |  3 +
 ...ache.deltaspike.core.spi.config.ConfigSource | 20 ++++++
 6 files changed, 119 insertions(+), 64 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d64cab49/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/config/ConfigurationExtension.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/config/ConfigurationExtension.java
b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/config/ConfigurationExtension.java
index ea0dd38..1a14c18 100644
--- a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/config/ConfigurationExtension.java
+++ b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/config/ConfigurationExtension.java
@@ -33,6 +33,7 @@ import javax.enterprise.inject.spi.Extension;
 import javax.enterprise.inject.spi.InjectionPoint;
 import javax.enterprise.inject.spi.ProcessAnnotatedType;
 import javax.enterprise.inject.spi.ProcessBean;
+import javax.management.InstanceNotFoundException;
 import javax.management.MBeanServer;
 import javax.management.ObjectName;
 
@@ -121,7 +122,7 @@ public class ConfigurationExtension implements Extension, Deactivatable
                 MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
 
                 ClassLoader tccl = ClassUtils.getClassLoader(ConfigurationExtension.class);
-                DeltaSpikeConfigMBean cfgMBean = new DeltaSpikeConfigMBean(tccl);
+                DeltaSpikeConfigInfo cfgMBean = new DeltaSpikeConfigInfo(tccl);
 
                 ObjectName name = new ObjectName("deltaspike.config." + appName + ":type=DeltaSpikeConfig");
                 mBeanServer.registerMBean(cfgMBean, name);
@@ -145,6 +146,10 @@ public class ConfigurationExtension implements Extension, Deactivatable
 
                 mBeanServer.unregisterMBean(name);
             }
+            catch (InstanceNotFoundException infe)
+            {
+                // all ok, nothing to de-register it seems
+            }
             catch (Exception e)
             {
                 throw new RuntimeException(e);

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d64cab49/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/config/DeltaSpikeConfigInfo.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/config/DeltaSpikeConfigInfo.java
b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/config/DeltaSpikeConfigInfo.java
new file mode 100644
index 0000000..87f4b52
--- /dev/null
+++ b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/config/DeltaSpikeConfigInfo.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.deltaspike.core.impl.config;
+
+import org.apache.deltaspike.core.api.config.ConfigResolver;
+import org.apache.deltaspike.core.spi.config.ConfigSource;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * JMX MBean for DeltaSpike
+ */
+public class DeltaSpikeConfigInfo implements DeltaSpikeConfigInfoMBean
+{
+    private final ClassLoader appConfigClassLoader;
+
+    public DeltaSpikeConfigInfo(ClassLoader appConfigClassLoader)
+    {
+        this.appConfigClassLoader = appConfigClassLoader;
+    }
+
+    @Override
+    public List<String> getConfigSources()
+    {
+        ClassLoader originalCl = Thread.currentThread().getContextClassLoader();
+        try
+        {
+            Thread.currentThread().setContextClassLoader(appConfigClassLoader);
+            List<String> configSourceInfo = new ArrayList<String>();
+            ConfigSource[] configSources = ConfigResolver.getConfigSources();
+            for (ConfigSource configSource : configSources)
+            {
+                configSourceInfo.add(Integer.toString(configSource.getOrdinal()) +
+                        " - " + configSource.getConfigName());
+            }
+
+            return configSourceInfo;
+        }
+        finally
+        {
+            // set back the original TCCL
+            Thread.currentThread().setContextClassLoader(originalCl);
+        }
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d64cab49/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/config/DeltaSpikeConfigInfoMBean.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/config/DeltaSpikeConfigInfoMBean.java
b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/config/DeltaSpikeConfigInfoMBean.java
new file mode 100644
index 0000000..01335b8
--- /dev/null
+++ b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/config/DeltaSpikeConfigInfoMBean.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.deltaspike.core.impl.config;
+
+import java.util.List;
+
+public interface DeltaSpikeConfigInfoMBean
+{
+    List<String> getConfigSources();
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d64cab49/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/config/DeltaSpikeConfigMBean.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/config/DeltaSpikeConfigMBean.java
b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/config/DeltaSpikeConfigMBean.java
deleted file mode 100644
index a91d0e8..0000000
--- a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/config/DeltaSpikeConfigMBean.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.deltaspike.core.impl.config;
-
-import org.apache.deltaspike.core.api.config.ConfigResolver;
-import org.apache.deltaspike.core.spi.config.ConfigSource;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * JMX MBean for DeltaSpike
- */
-public class DeltaSpikeConfigMBean
-{
-    private final ClassLoader appConfigClassLoader;
-
-    public DeltaSpikeConfigMBean(ClassLoader appConfigClassLoader)
-    {
-        this.appConfigClassLoader = appConfigClassLoader;
-    }
-
-    public List<String> getConfigSources()
-    {
-        ClassLoader originalCl = Thread.currentThread().getContextClassLoader();
-        try
-        {
-            Thread.currentThread().setContextClassLoader(appConfigClassLoader);
-            List<String> configSourceInfo = new ArrayList<String>();
-            ConfigSource[] configSources = ConfigResolver.getConfigSources();
-            for (ConfigSource configSource : configSources)
-            {
-                configSourceInfo.add(Integer.toString(configSource.getOrdinal()) +
-                        " - " + configSource.getConfigName());
-            }
-
-            return configSourceInfo;
-        }
-        finally
-        {
-            // set back the original TCCL
-            Thread.currentThread().setContextClassLoader(originalCl);
-        }
-    }
-
-
-}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d64cab49/deltaspike/core/impl/src/test/resources/META-INF/apache-deltaspike.properties
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/test/resources/META-INF/apache-deltaspike.properties
b/deltaspike/core/impl/src/test/resources/META-INF/apache-deltaspike.properties
index c4a11c1..2bb3fc0 100644
--- a/deltaspike/core/impl/src/test/resources/META-INF/apache-deltaspike.properties
+++ b/deltaspike/core/impl/src/test/resources/META-INF/apache-deltaspike.properties
@@ -17,6 +17,9 @@
 # under the License.
 #
 
+# by providing an application name we trigger the JMX registration!
+deltaspike.application.name=ds-config-core-impl-tests
+
 testProperty03=test_value_03
 org.apache.deltaspike.core.spi.activation.ClassDeactivator=org.apache.deltaspike.test.core.impl.activation.TestClassDeactivator
 testProperty02=test_value_02

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d64cab49/deltaspike/modules/servlet/impl/src/main/resources/META-INF/services/org.apache.deltaspike.core.spi.config.ConfigSource
----------------------------------------------------------------------
diff --git a/deltaspike/modules/servlet/impl/src/main/resources/META-INF/services/org.apache.deltaspike.core.spi.config.ConfigSource
b/deltaspike/modules/servlet/impl/src/main/resources/META-INF/services/org.apache.deltaspike.core.spi.config.ConfigSource
new file mode 100644
index 0000000..e629d15
--- /dev/null
+++ b/deltaspike/modules/servlet/impl/src/main/resources/META-INF/services/org.apache.deltaspike.core.spi.config.ConfigSource
@@ -0,0 +1,20 @@
+#####################################################################################
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#####################################################################################
+
+org.apache.deltaspike.servlet.impl.config.ServletConfigSource
\ No newline at end of file


Mime
View raw message