geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r392555 - /geronimo/xbean/trunk/xbean-server/src/main/java/org/apache/xbean/server/spring/jmx/MBeanServerFactoryBean.java
Date Sat, 08 Apr 2006 16:42:04 GMT
Author: chirino
Date: Sat Apr  8 09:42:02 2006
New Revision: 392555

URL: http://svn.apache.org/viewcvs?rev=392555&view=rev
Log:
Forgot to add.

Added:
    geronimo/xbean/trunk/xbean-server/src/main/java/org/apache/xbean/server/spring/jmx/MBeanServerFactoryBean.java
  (with props)

Added: geronimo/xbean/trunk/xbean-server/src/main/java/org/apache/xbean/server/spring/jmx/MBeanServerFactoryBean.java
URL: http://svn.apache.org/viewcvs/geronimo/xbean/trunk/xbean-server/src/main/java/org/apache/xbean/server/spring/jmx/MBeanServerFactoryBean.java?rev=392555&view=auto
==============================================================================
--- geronimo/xbean/trunk/xbean-server/src/main/java/org/apache/xbean/server/spring/jmx/MBeanServerFactoryBean.java
(added)
+++ geronimo/xbean/trunk/xbean-server/src/main/java/org/apache/xbean/server/spring/jmx/MBeanServerFactoryBean.java
Sat Apr  8 09:42:02 2006
@@ -0,0 +1,59 @@
+/**
+ *
+ * Copyright 2005-2006 The Apache Software Foundation
+ *
+ * Licensed 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.xbean.server.spring.jmx;
+
+import javax.management.MBeanServer;
+
+import org.springframework.beans.factory.FactoryBean;
+import org.springframework.beans.factory.InitializingBean;
+
+/**
+ * A FactoryBean that uses the xbean.tiger MBeanServerFactoryBean if it can be loaded or,
uses 
+ * the spring MBeanServerFactoryBean otherwise.
+ * 
+ * @version $Revision$
+ */
+public class MBeanServerFactoryBean implements FactoryBean {
+
+    public Object getObject() throws Exception {
+        
+        ClassLoader classLoader = MBeanServerFactoryBean.class.getClassLoader();
+        try {
+            
+            // Try to use the xbean tiger version first...
+            FactoryBean fb = (FactoryBean) classLoader.loadClass("org.apache.xbean.tiger.MBeanServerFactoryBean").newInstance();
+            return fb.getObject();
+            
+        } catch (Throwable e) {
+            
+            // Fallback to using the spring factory bean then 
+            FactoryBean fb = (FactoryBean) classLoader.loadClass("org.springframework.jmx.support.MBeanServerFactoryBean").newInstance();
+            ((InitializingBean)fb).afterPropertiesSet();
+            return fb.getObject();
+            
+        }
+    }
+
+    public Class getObjectType() {
+        return MBeanServer.class;
+    }
+
+    public boolean isSingleton() {
+        return true;
+    }
+
+}

Propchange: geronimo/xbean/trunk/xbean-server/src/main/java/org/apache/xbean/server/spring/jmx/MBeanServerFactoryBean.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message