notify-dpml AT lists.ibiblio.org
Subject: DPML Notify
List archive
svn commit: r2026 - in development/main/planet/facilities/jmx: . api/src/main/net/dpml/jmx handler/src/main/net/dpml/jmx/handler java5 java5/src java5/src/main java5/src/main/net java5/src/main/net/dpml java5/src/main/net/dpml/jmx java5/src/main/net/dpml/jmx/java5 mx4j/src/main/net/dpml/jmx/mx4j spi/src/main/net/dpml/jmx/spi util/src/main/net/dpml/jmx/util
- From: herzog AT raffael.ch
- To: notify-dpml AT lists.ibiblio.org
- Subject: svn commit: r2026 - in development/main/planet/facilities/jmx: . api/src/main/net/dpml/jmx handler/src/main/net/dpml/jmx/handler java5 java5/src java5/src/main java5/src/main/net java5/src/main/net/dpml java5/src/main/net/dpml/jmx java5/src/main/net/dpml/jmx/java5 mx4j/src/main/net/dpml/jmx/mx4j spi/src/main/net/dpml/jmx/spi util/src/main/net/dpml/jmx/util
- Date: Thu, 10 Mar 2005 23:40:39 -0500
Author: herzog AT raffael.ch
Date: Thu Mar 10 23:40:37 2005
New Revision: 2026
Added:
development/main/planet/facilities/jmx/index.xml
development/main/planet/facilities/jmx/java5/
development/main/planet/facilities/jmx/java5/build.xml
development/main/planet/facilities/jmx/java5/src/
development/main/planet/facilities/jmx/java5/src/main/
development/main/planet/facilities/jmx/java5/src/main/net/
development/main/planet/facilities/jmx/java5/src/main/net/dpml/
development/main/planet/facilities/jmx/java5/src/main/net/dpml/jmx/
development/main/planet/facilities/jmx/java5/src/main/net/dpml/jmx/java5/
development/main/planet/facilities/jmx/java5/src/main/net/dpml/jmx/java5/Java5ComponentRegistrationManager.java
development/main/planet/facilities/jmx/module.xml
Modified:
development/main/planet/facilities/jmx/api/src/main/net/dpml/jmx/ComponentRegistrationException.java
development/main/planet/facilities/jmx/api/src/main/net/dpml/jmx/ComponentRegistrationManager.java
development/main/planet/facilities/jmx/handler/src/main/net/dpml/jmx/handler/JmxManagementHandler.java
development/main/planet/facilities/jmx/mx4j/src/main/net/dpml/jmx/mx4j/MX4JComponentRegistrationManager.java
development/main/planet/facilities/jmx/mx4j/src/main/net/dpml/jmx/mx4j/MX4JLoggerAdapter.java
development/main/planet/facilities/jmx/spi/src/main/net/dpml/jmx/spi/AbstractComponentRegistrationManager.java
development/main/planet/facilities/jmx/spi/src/main/net/dpml/jmx/spi/AbstractJMXComponentRegistrationManager.java
development/main/planet/facilities/jmx/spi/src/main/net/dpml/jmx/spi/ManagedEntry.java
development/main/planet/facilities/jmx/util/src/main/net/dpml/jmx/util/ConfigurationBuilder.java
development/main/planet/facilities/jmx/util/src/main/net/dpml/jmx/util/DTDInfo.java
development/main/planet/facilities/jmx/util/src/main/net/dpml/jmx/util/DTDResolver.java
development/main/planet/facilities/jmx/util/src/main/net/dpml/jmx/util/MBeanInfoBuilder.java
development/main/planet/facilities/jmx/util/src/main/net/dpml/jmx/util/Target.java
Log:
Starting to reactivate the JMX facility, adding support for Java5.
Modified:
development/main/planet/facilities/jmx/api/src/main/net/dpml/jmx/ComponentRegistrationException.java
==============================================================================
---
development/main/planet/facilities/jmx/api/src/main/net/dpml/jmx/ComponentRegistrationException.java
(original)
+++
development/main/planet/facilities/jmx/api/src/main/net/dpml/jmx/ComponentRegistrationException.java
Thu Mar 10 23:40:37 2005
@@ -1,5 +1,6 @@
/*
- * Copyright 2004 Apache Software Foundation
+ * Copyright 2004 Digital Product Meta Library
+ *
* 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
Modified:
development/main/planet/facilities/jmx/api/src/main/net/dpml/jmx/ComponentRegistrationManager.java
==============================================================================
---
development/main/planet/facilities/jmx/api/src/main/net/dpml/jmx/ComponentRegistrationManager.java
(original)
+++
development/main/planet/facilities/jmx/api/src/main/net/dpml/jmx/ComponentRegistrationManager.java
Thu Mar 10 23:40:37 2005
@@ -1,5 +1,6 @@
/*
- * Copyright 2004 Apache Software Foundation
+ * Copyright 2004 Digital Product Meta Library
+ *
* 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
Modified:
development/main/planet/facilities/jmx/handler/src/main/net/dpml/jmx/handler/JmxManagementHandler.java
==============================================================================
---
development/main/planet/facilities/jmx/handler/src/main/net/dpml/jmx/handler/JmxManagementHandler.java
(original)
+++
development/main/planet/facilities/jmx/handler/src/main/net/dpml/jmx/handler/JmxManagementHandler.java
Thu Mar 10 23:40:37 2005
@@ -1,5 +1,6 @@
/*
- * Copyright 2004 Apache Software Foundation
+ * Copyright 2004 Digital Product Meta Library
+ *
* 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
@@ -16,40 +17,35 @@
*/
package net.dpml.jmx.handler;
+import net.dpml.activity.Disposable;
import net.dpml.composition.event.CompositionEvent;
import net.dpml.composition.event.CompositionListener;
import net.dpml.composition.model.ComponentModel;
import net.dpml.composition.model.ContainmentModel;
import net.dpml.composition.model.DeploymentModel;
-
-import net.dpml.i18n.ResourceManager;
-import net.dpml.i18n.Resources;
-
-import net.dpml.activity.Disposable;
import net.dpml.context.Context;
import net.dpml.context.ContextException;
-import net.dpml.context.Contextualizable;
+import net.dpml.i18n.ResourceManager;
+import net.dpml.i18n.Resources;
+import net.dpml.jmx.ComponentRegistrationException;
+import net.dpml.jmx.ComponentRegistrationManager;
import net.dpml.logging.Logger;
import net.dpml.service.ServiceException;
import net.dpml.service.ServiceManager;
-import net.dpml.service.Serviceable;
-
-import net.dpml.jmx.ComponentRegistrationManager;
-import net.dpml.jmx.ComponentRegistrationException;
/**
- *
+ *
* @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
* @version $Revision: 1.2 $
*
* @metro.component name="jmx-handler" lifestyle="singleton"
*/
-public class JmxManagementHandler
+public class JmxManagementHandler
implements CompositionListener, Disposable
{
private static final Resources REZ = ResourceManager.getPackageResources(
JmxManagementHandler.class );
-
+
private ContainmentModel m_model;
private ComponentRegistrationManager m_manager;
private Logger m_logger;
@@ -59,23 +55,23 @@
*
* @param logger the logging channel
* @param context the Context for this component
- * @metro.entry key="urn:composition:containment.model"
+ * @metro.entry key="urn:composition:containment.model"
* type="net.dpml.composition.model.ContainmentModel"
* @param manager the ServiceManager from which to retrieve service
dependencies
- * @metro.dependency key="registry"
- * type="net.dpml.jmx.ComponentRegistrationManager"
+ * @metro.dependency key="registry"
+ * type="net.dpml.jmx.ComponentRegistrationManager"
* @throws ContextException if a required context entry is not available
* @throws ServiceException if a required service is not available
*/
- public JmxManagementHandler(
- Logger logger, Context context, ServiceManager manager )
+ public JmxManagementHandler(
+ Logger logger, Context context, ServiceManager manager )
throws ContextException, ServiceException
{
m_logger = logger;
- m_model =
- (ContainmentModel) context.get(
+ m_model =
+ (ContainmentModel) context.get(
"urn:composition:containment.model" );
- m_manager =
+ m_manager =
(ComponentRegistrationManager) manager.lookup( "registry" );
synchronized ( m_model )
{
@@ -117,7 +113,7 @@
{
if ( model instanceof ContainmentModel )
{
- ContainmentModel containment =
+ ContainmentModel containment =
(ContainmentModel) model;
if ( flag )
{
@@ -135,7 +131,7 @@
}
else if ( model instanceof ComponentModel )
{
- final ComponentModel componentModel =
+ final ComponentModel componentModel =
(ComponentModel)model;
if ( flag )
@@ -146,8 +142,8 @@
}
catch ( ComponentRegistrationException cme )
{
- final String message =
- REZ.getString(
+ final String message =
+ REZ.getString(
"compositionlistener.error.register",
componentModel.getQualifiedName() );
getLogger().debug( message, cme );
@@ -162,8 +158,8 @@
}
catch ( ComponentRegistrationException cme )
{
- final String message =
- REZ.getString(
+ final String message =
+ REZ.getString(
"compositionlistener.error.unregister",
componentModel.getQualifiedName() );
getLogger().debug( message, cme );
Added: development/main/planet/facilities/jmx/index.xml
==============================================================================
--- (empty file)
+++ development/main/planet/facilities/jmx/index.xml Thu Mar 10 23:40:37
2005
@@ -0,0 +1,223 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ * Copyright 2004 Stephen J. McConnell.
+ * Copyright 2004 Niclas Hedman.
+ *
+ * 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.dpml.net/central/about/legal/
+ *
+ * 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.
+-->
+
+<index key="dpml-jmx">
+
+ <import uri="artifact:module:dpml/util/dpml-util#SNAPSHOT"/>
+ <import uri="artifact:module:dpml/transit/dpml-transit#SNAPSHOT"/>
+ <import uri="artifact:module:dpml/metro/dpml-metro#SNAPSHOT"/>
+
+ <project file="module.xml">
+ <info>
+ <group>dpml/jmx</group>
+ <name>dpml-jmx</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ <type>module</type>
+ </info>
+ <dependencies>
+ <include key="dpml-transit"/>
+ <include key="dpml-metro"/>
+ </dependencies>
+ </project>
+
+ <project basedir="api">
+ <info>
+ <group>dpml/jmx</group>
+ <name>dpml-jmx-api</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ </info>
+ <dependencies>
+ <include key="dpml-composition-api"/>
+ </dependencies>
+ </project>
+
+ <project basedir="handler">
+ <info>
+ <group>dpml/jmx</group>
+ <name>dpml-jmx-handler</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ </info>
+ <dependencies>
+ <include key="dpml-jmx-api"/>
+ <include key="dpml-util-i18n"/>
+ <include key="dpml-activity-api"/>
+ </dependencies>
+ <plugins>
+ <include key="dpml-meta-tools"/>
+ </plugins>
+ </project>
+
+ <project basedir="spi">
+ <info>
+ <group>dpml/jmx</group>
+ <name>dpml-jmx-spi</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ </info>
+ <dependencies>
+ <include key="dpml-jmx-api"/>
+ <include key="dpml-util-i18n"/>
+ <include key="dpml-jmx-util"/>
+ <include key="dpml-activity-api"/>
+ <include key="mx4j-jmx"/>
+ </dependencies>
+ </project>
+
+ <project basedir="mx4j">
+ <info>
+ <group>dpml/jmx</group>
+ <name>dpml-jmx-mx4j</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ </info>
+ <dependencies>
+ <include key="dpml-jmx-api"/>
+ <include key="dpml-jmx-spi"/>
+ <include key="dpml-logging-api"/>
+ <include key="dpml-parameters-api"/>
+ <include key="dpml-context-api"/>
+ <include key="mx4j-rjmx"/>
+ <include key="mx4j-impl"/>
+ <include key="mx4j-tools"/>
+ </dependencies>
+ <plugins>
+ <include key="dpml-meta-tools"/>
+ </plugins>
+ </project>
+
+ <project basedir="java5">
+ <info>
+ <group>dpml/jmx</group>
+ <name>dpml-jmx-java5</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ </info>
+ <dependencies>
+ <include key="dpml-jmx-spi"/>
+ <include key="dpml-logging-api"/>
+ <include key="mx4j-jmx"/>
+ <include key="org.mortbay.jetty"/>
+ <!-- include key="xmojoadaptors"/ -->
+ <include key="dpml-metro-unit" build="true" test="true"
runtime="false"/>
+ </dependencies>
+ <plugins>
+ <include key="dpml-meta-tools"/>
+ </plugins>
+ </project>
+
+ <project basedir="util">
+ <info>
+ <group>dpml/jmx</group>
+ <name>dpml-jmx-util</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ </info>
+ <dependencies>
+ <include key="dpml-logging-api"/>
+ <include key="dpml-configuration-impl"/>
+ <include key="mx4j-jmx"/>
+ <include key="dpml-util-i18n"/>
+ </dependencies>
+ </project>
+
+ <resource>
+ <info>
+ <group>mx4j</group>
+ <name>mx4j-jmx</name>
+ <version>3.0.1</version>
+ <type>jar</type>
+ </info>
+ </resource>
+
+ <resource>
+ <info>
+ <group>mx4j</group>
+ <name>mx4j-rjmx</name>
+ <version>3.0.1</version>
+ <type>jar</type>
+ </info>
+ </resource>
+
+ <resource>
+ <info>
+ <group>mx4j</group>
+ <name>mx4j-impl</name>
+ <version>3.0.1</version>
+ <type>jar</type>
+ </info>
+ <dependencies>
+ <include key="mx4j-jmx"/>
+ </dependencies>
+ </resource>
+
+ <resource>
+ <info>
+ <group>mx4j</group>
+ <name>mx4j-tools</name>
+ <version>3.0.1</version>
+ <type>jar</type>
+ </info>
+ </resource>
+
+ <!--
+ <resource>
+ <info>
+ <group>xmojo</group>
+ <name>xmojoadaptors</name>
+ <version>5.0.0</version>
+ <type>jar</type>
+ </info>
+ <dependencies>
+ <include key="xmojoutils"/>
+ <include key="servletapi"/>
+ <include key="org.mortbay.jetty"/>
+ </dependencies>
+ </resource>
+
+ <resource>
+ <info>
+ <group>xmojo</group>
+ <name>xmojoutils</name>
+ <version>5.0.0</version>
+ <type>jar</type>
+ </info>
+ </resource>
+
+ <resource>
+ <info>
+ <group>servletapi</group>
+ <name>servletapi</name>
+ <version>2.3</version>
+ <type>jar</type>
+ </info>
+ </resource>
+ -->
+
+ <resource>
+ <info>
+ <group>jetty</group>
+ <name>org.mortbay.jetty</name>
+ <version>5.0.0</version>
+ <type>jar</type>
+ </info>
+ </resource>
+
+</index>
Added: development/main/planet/facilities/jmx/java5/build.xml
==============================================================================
--- (empty file)
+++ development/main/planet/facilities/jmx/java5/build.xml Thu Mar 10
23:40:37 2005
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<project name="dpml-jmx-java5" default="install" basedir="."
+ xmlns:transit="antlib:net.dpml.transit"
xmlns:x="plugin:dpml/magic/dpml-magic-core" >
+
+ <transit:import uri="artifact:template:dpml/magic/standard"/>
+
+</project>
+
Added:
development/main/planet/facilities/jmx/java5/src/main/net/dpml/jmx/java5/Java5ComponentRegistrationManager.java
==============================================================================
--- (empty file)
+++
development/main/planet/facilities/jmx/java5/src/main/net/dpml/jmx/java5/Java5ComponentRegistrationManager.java
Thu Mar 10 23:40:37 2005
@@ -0,0 +1,103 @@
+/*
+ * Copyright 2004 Digital Product Meta Library
+ *
+ * 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 net.dpml.jmx.java5;
+
+import javax.management.MBeanServer;
+
+import java.lang.reflect.Method;
+
+import net.dpml.configuration.Configuration;
+import net.dpml.jmx.spi.AbstractJMXComponentRegistrationManager;
+import net.dpml.logging.Logger;
+import org.mortbay.jetty.Server;
+
+/**
+ * An implementation of ComponentRegistrationManager that uses the platform
JMX server
+ * of the built-in JMX implementation in JDK 5.0.
+ *
+ * @metro.component name="jmx-java5-manager" version="1.0.0"
lifestyle="singleton"
+ * @metro.service type="net.dpml.jmx.ComponentRegistrationManager"
+ * @metro.attribute key="urn:composition:deployment.timeout" value="30000"
+ *
+ * @author <a href="mailto:herzog AT raffael.ch>Raffael Herzog</a>
+ */
+public class Java5ComponentRegistrationManager extends
AbstractJMXComponentRegistrationManager {
+
+ private final boolean startHttpServer;
+ private final String[] listen;
+
+ private Server httpServer = null;
+
+ /**
+ */
+ public Java5ComponentRegistrationManager(Logger logger, Configuration
config) throws Exception {
+ super(logger);
+ this.startHttpServer =
config.getChild("startHttpServer").getValueAsBoolean(true);
+ Configuration[] listenConf = config.getChildren("listen");
+ if ( listenConf.length == 0 ) {
+ this.listen = new String[] { ":8080" };
+ }
+ else {
+ this.listen = new String[listenConf.length];
+ for ( int i = 0; i < listenConf.length; i++ ) {
+ Configuration l = listenConf[i];
+ this.listen[i] = l.getValue();
+ }
+ }
+ }
+
+ /**
+ * Get the platform JMX server. This method actually uses reflection to
get the server,
+ * so it compiles with JDK <5.0. It will need a 5.0 runtime environment
to run, though.
+ *
+ * @return
+ * @throws Exception
+ */
+ protected MBeanServer createMBeanServer() throws Exception {
+ Class clazz =
Class.forName("java.lang.management.ManagementFactory");
+ Method getPlatformMBeanServer =
clazz.getMethod("getPlatformMBeanServer", null);
+ MBeanServer mBeanServer =
(MBeanServer)getPlatformMBeanServer.invoke(null, null);
+ if ( startHttpServer ) {
+ getLogger().info("Starting HTTP server");
+ long time = System.currentTimeMillis();
+ httpServer = new Server();
+ for ( int i = 0; i < listen.length; i++ ) {
+ httpServer.addListener(listen[i]);
+ }
+ httpServer.addWebApplication("/",
"artifact:war:jmx-html/jmx-html#1.3!/");
+ httpServer.start();
+ getLogger().info("HTTP server started in " +
(System.currentTimeMillis() - time) + "ms");
+ }
+ return mBeanServer;
+ }
+
+ public void dispose() {
+ super.dispose();
+ if ( httpServer != null ) {
+ try {
+ getLogger().info("Stopping HTTP server");
+ httpServer.stop();
+ }
+ catch ( InterruptedException e ) {
+ getLogger().warn("Interrupted waiting for HTTP server
shutdown", e);
+ }
+ httpServer = null;
+ }
+ }
+
+}
Added: development/main/planet/facilities/jmx/module.xml
==============================================================================
--- (empty file)
+++ development/main/planet/facilities/jmx/module.xml Thu Mar 10 23:40:37
2005
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<project name="dpml-jmx" default="install" basedir="."
+ xmlns:transit="antlib:net.dpml.transit"
+ xmlns:x="plugin:dpml/magic/dpml-magic-core">
+
+ <transit:import uri="artifact:template:dpml/magic/standard"/>
+
+ <target name="build" depends="standard.build">
+ <x:module index="index.xml">
+ <header>
+ </header>
+ </x:module>
+ </target>
+
+</project>
Modified:
development/main/planet/facilities/jmx/mx4j/src/main/net/dpml/jmx/mx4j/MX4JComponentRegistrationManager.java
==============================================================================
---
development/main/planet/facilities/jmx/mx4j/src/main/net/dpml/jmx/mx4j/MX4JComponentRegistrationManager.java
(original)
+++
development/main/planet/facilities/jmx/mx4j/src/main/net/dpml/jmx/mx4j/MX4JComponentRegistrationManager.java
Thu Mar 10 23:40:37 2005
@@ -1,5 +1,6 @@
/*
- * Copyright 2004 Apache Software Foundation
+ * Copyright 2004 Digital Product Meta Library
+ *
* 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
@@ -16,10 +17,6 @@
*/
package net.dpml.jmx.mx4j;
-import java.io.File;
-import java.util.HashMap;
-import java.util.Map;
-
import javax.management.Attribute;
import javax.management.AttributeNotFoundException;
import javax.management.InstanceNotFoundException;
@@ -33,17 +30,16 @@
import javax.management.remote.JMXConnectorServerFactory;
import javax.management.remote.JMXServiceURL;
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+
+import net.dpml.context.Context;
import net.dpml.i18n.ResourceManager;
import net.dpml.i18n.Resources;
-
-import mx4j.log.Log;
-
+import net.dpml.jmx.spi.AbstractJMXComponentRegistrationManager;
import net.dpml.logging.Logger;
import net.dpml.parameters.Parameters;
-import net.dpml.context.Context;
-
-import net.dpml.jmx.ComponentRegistrationManager;
-import net.dpml.jmx.spi.AbstractJMXComponentRegistrationManager;
/**
@@ -56,14 +52,14 @@
* @metro.service type="net.dpml.jmx.ComponentRegistrationManager"
* @metro.attribute key="urn:composition:deployment.timeout" value="6000"
*/
-public class MX4JComponentRegistrationManager extends
AbstractJMXComponentRegistrationManager
+public class MX4JComponentRegistrationManager extends
AbstractJMXComponentRegistrationManager
{
- private static final Resources REZ =
+ private static final Resources REZ =
ResourceManager.getPackageResources(
MX4JComponentRegistrationManager.class );
private static final String DEFAULT_NAMING_FACTORY =
"com.sun.jndi.rmi.registry.RegistryContextFactory";
private static final String DEFAULT_HTTPADAPTER_HOST = "localhost";
- private static final int DEFAULT_HTTPADAPTER_PORT =
+ private static final int DEFAULT_HTTPADAPTER_PORT =
Integer.getInteger( "metro.adapter.http", 8082 ).intValue();
private String m_host;
@@ -102,7 +98,7 @@
m_password = parameters.getParameter( "password", null );
final MBeanServer mBeanServer = getMBeanServer();
- startHttpAdaptor( mBeanServer );
+ //startHttpAdaptor( mBeanServer );
if( m_rmi )
{
startRMIAdaptor( mBeanServer );
@@ -126,20 +122,21 @@
private void startHttpAdaptor( final MBeanServer mBeanServer ) throws
Exception
{
- final ObjectName adaptorName = new ObjectName(
"Http:name=HttpAdaptor" );
- mBeanServer.createMBean( "mx4j.tools.adaptor.http.HttpAdaptor",
adaptorName, null );
- mBeanServer.setAttribute( adaptorName, new Attribute( "Host", m_host
) );
- mBeanServer.setAttribute( adaptorName, new Attribute( "Port", new
Integer( m_port ) ) );
+ final ObjectName adaptorName = new
ObjectName("Http:name=HttpAdaptor");
+ //final HttpAdaptor adaptor = new HttpAdaptor();
+ //mBeanServer.registerMBean(adaptor, adaptorName);
+ mBeanServer.createMBean("mx4j.tools.adaptor.http.HttpAdaptor",
adaptorName, null);
+ mBeanServer.setAttribute(adaptorName, new Attribute("Host", m_host));
+ mBeanServer.setAttribute(adaptorName, new Attribute("Port", new
Integer(m_port)));
- if ( null != m_username )
- {
- configureAuthentication( mBeanServer, adaptorName );
+ if ( null != m_username ) {
+ configureAuthentication(mBeanServer, adaptorName);
}
- configureProcessor( mBeanServer, adaptorName );
+ configureProcessor(mBeanServer, adaptorName);
// starts the server
- mBeanServer.invoke( adaptorName, "start", null, null );
+ mBeanServer.invoke(adaptorName, "start", null, null);
}
private void configureProcessor( final MBeanServer mBeanServer, final
ObjectName adaptorName ) throws
@@ -217,8 +214,8 @@
protected MBeanServer createMBeanServer() throws Exception
{
- MX4JLoggerAdapter.setLogger( getLogger() );
- Log.redirectTo( new MX4JLoggerAdapter() );
+ //MX4JLoggerAdapter.setLogger( getLogger() );
+ //Log.redirectTo( new MX4JLoggerAdapter() );
return MBeanServerFactory.createMBeanServer( "Metro" );
}
Modified:
development/main/planet/facilities/jmx/mx4j/src/main/net/dpml/jmx/mx4j/MX4JLoggerAdapter.java
==============================================================================
---
development/main/planet/facilities/jmx/mx4j/src/main/net/dpml/jmx/mx4j/MX4JLoggerAdapter.java
(original)
+++
development/main/planet/facilities/jmx/mx4j/src/main/net/dpml/jmx/mx4j/MX4JLoggerAdapter.java
Thu Mar 10 23:40:37 2005
@@ -1,5 +1,6 @@
/*
- * Copyright 2004 Apache Software Foundation
+ * Copyright 2004 Digital Product Meta Library
+ *
* 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
Modified:
development/main/planet/facilities/jmx/spi/src/main/net/dpml/jmx/spi/AbstractComponentRegistrationManager.java
==============================================================================
---
development/main/planet/facilities/jmx/spi/src/main/net/dpml/jmx/spi/AbstractComponentRegistrationManager.java
(original)
+++
development/main/planet/facilities/jmx/spi/src/main/net/dpml/jmx/spi/AbstractComponentRegistrationManager.java
Thu Mar 10 23:40:37 2005
@@ -1,5 +1,6 @@
/*
- * Copyright 2004 Apache Software Foundation
+ * Copyright 2004 Digital Product Meta Library
+ *
* 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
@@ -31,13 +32,13 @@
import net.dpml.i18n.Resources;
/**
- * This is an abstract implementation of a component to provide a lifecycle
+ * This is an abstract implementation of a component to provide a lifecycle
* extension to export management interfaces for other components.
*
* @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
* @version $Revision: 1.3 $
*/
-public abstract class AbstractComponentRegistrationManager
+public abstract class AbstractComponentRegistrationManager
implements ComponentRegistrationManager
{
@@ -54,7 +55,7 @@
m_logger = logger;
}
- public void register( ComponentModel componentModel )
+ public void register( ComponentModel componentModel )
throws ComponentRegistrationException
{
final Class[] interfaces = getManagementInterfaces( componentModel );
@@ -78,7 +79,7 @@
}
}
- public void unregister( ComponentModel componentModel )
+ public void unregister( ComponentModel componentModel )
throws ComponentRegistrationException
{
final String name = getName( componentModel );
Modified:
development/main/planet/facilities/jmx/spi/src/main/net/dpml/jmx/spi/AbstractJMXComponentRegistrationManager.java
==============================================================================
---
development/main/planet/facilities/jmx/spi/src/main/net/dpml/jmx/spi/AbstractJMXComponentRegistrationManager.java
(original)
+++
development/main/planet/facilities/jmx/spi/src/main/net/dpml/jmx/spi/AbstractJMXComponentRegistrationManager.java
Thu Mar 10 23:40:37 2005
@@ -1,5 +1,6 @@
/*
- * Copyright 2004 Apache Software Foundation
+ * Copyright 2004 Digital Product Meta Library
+ *
* 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
@@ -16,25 +17,24 @@
*/
package net.dpml.jmx.spi;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
import javax.management.DynamicMBean;
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
-import net.dpml.composition.model.ComponentModel;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+import net.dpml.activity.Disposable;
+import net.dpml.activity.Initializable;
+import net.dpml.composition.model.ComponentModel;
import net.dpml.i18n.ResourceManager;
import net.dpml.i18n.Resources;
-
-import net.dpml.activity.Disposable;
-import net.dpml.logging.Logger;
import net.dpml.jmx.ComponentRegistrationException;
import net.dpml.jmx.util.MBeanInfoBuilder;
import net.dpml.jmx.util.Target;
+import net.dpml.logging.Logger;
/**
* An abstract implementation of a JMX based Component Manager.
@@ -42,13 +42,13 @@
* @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
* @version $Revision: 1.1 $
*/
-public abstract class AbstractJMXComponentRegistrationManager
- extends AbstractComponentRegistrationManager
- implements Disposable
+public abstract class AbstractJMXComponentRegistrationManager
+ extends AbstractComponentRegistrationManager
+ implements Initializable, Disposable
{
private static final Resources REZ = ResourceManager.getPackageResources(
AbstractJMXComponentRegistrationManager.class );
-
+
private MBeanInfoBuilder topicBuilder;
private MBeanServer m_mBeanServer;
private String m_domain = "Metro";
@@ -58,10 +58,12 @@
{
super( logger );
+ topicBuilder = new MBeanInfoBuilder( logger );
+ }
+
+ public void initialize() throws Exception {
final MBeanServer mBeanServer = createMBeanServer();
setMBeanServer( mBeanServer );
-
- topicBuilder = new MBeanInfoBuilder( logger );
}
public void dispose()
@@ -80,7 +82,7 @@
* @return the exported object
* @throws ComponentRegistrationException if an error occurs
*/
- protected Object export( final String name, final Object object, final
Class[] interfaces )
+ protected Object export( final String name, final Object object, final
Class[] interfaces )
throws ComponentRegistrationException
{
try
@@ -104,7 +106,7 @@
* @param exportedObject the object return by export
* @throws ComponentRegistrationException if an error occurs
*/
- protected void unexport( final String name, final Object exportedObject
)
+ protected void unexport( final String name, final Object exportedObject )
throws ComponentRegistrationException
{
try
@@ -115,14 +117,14 @@
while ( i.hasNext() )
{
- final ObjectName objectName =
+ final ObjectName objectName =
createObjectName( name, ( String ) i.next() );
getMBeanServer().unregisterMBean( objectName );
}
}
catch ( final Exception e )
{
- final String message =
+ final String message =
REZ.getString( "jmxmanager.error.unexport.fail", name );
getLogger().error( message, e );
throw new ComponentRegistrationException( message, e );
@@ -135,7 +137,7 @@
* @param clazz the interface class
* @throws ComponentRegistrationException if verification fails
*/
- protected void verifyInterface( final Class clazz )
+ protected void verifyInterface( final Class clazz )
throws ComponentRegistrationException
{
//TODO: check it extends all right things and that it
@@ -174,8 +176,8 @@
{
if ( getLogger().isDebugEnabled() )
{
- final String message =
- REZ.getString(
+ final String message =
+ REZ.getString(
"jmxmanager.debug.interface",
allInterfaces[i].getName() );
getLogger().debug( message );
@@ -188,7 +190,7 @@
return ( Class[] ) mbeanInterfaces.toArray( new
Class[mbeanInterfaces.size()] );
}
- protected String getName( ComponentModel componentModel )
+ protected String getName( ComponentModel componentModel )
throws ComponentRegistrationException
{
String[] nameComponents = componentModel.getQualifiedName().split(
"/" );
@@ -248,7 +250,7 @@
* @param target the management target
* @throws Exception if the Target cannot be exported
*/
- protected void exportTarget( final Target target )
+ protected void exportTarget( final Target target )
throws Exception
{
// loop through each topic and export it
Modified:
development/main/planet/facilities/jmx/spi/src/main/net/dpml/jmx/spi/ManagedEntry.java
==============================================================================
---
development/main/planet/facilities/jmx/spi/src/main/net/dpml/jmx/spi/ManagedEntry.java
(original)
+++
development/main/planet/facilities/jmx/spi/src/main/net/dpml/jmx/spi/ManagedEntry.java
Thu Mar 10 23:40:37 2005
@@ -1,5 +1,6 @@
/*
- * Copyright 2004 Apache Software Foundation
+ * Copyright 2004 Digital Product Meta Library
+ *
* 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
Modified:
development/main/planet/facilities/jmx/util/src/main/net/dpml/jmx/util/ConfigurationBuilder.java
==============================================================================
---
development/main/planet/facilities/jmx/util/src/main/net/dpml/jmx/util/ConfigurationBuilder.java
(original)
+++
development/main/planet/facilities/jmx/util/src/main/net/dpml/jmx/util/ConfigurationBuilder.java
Thu Mar 10 23:40:37 2005
@@ -1,5 +1,6 @@
/*
- * Copyright 2004 Apache Software Foundation
+ * Copyright 2004 Digital Product Meta Library
+ *
* 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
@@ -16,15 +17,14 @@
*/
package net.dpml.jmx.util;
-import java.io.IOException;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
-import net.dpml.configuration.Configuration;
+import java.io.IOException;
+import net.dpml.configuration.Configuration;
import net.dpml.configuration.impl.SAXConfigurationHandler;
-
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
@@ -44,17 +44,17 @@
(
"-//PHOENIX/Mx Info DTD Version 1.0//EN",
"http://avalon.apache.org/dtds/meta/mxinfo_1_0.dtd",
- "org/apache/avalon/jmx/util/mxinfo.dtd"
+ "org/apache/avalon/jmx/util/mxinfo.dtd"
),
new DTDInfo
- (
+ (
"-//PHOENIX/Mx Info DTD Version 1.0//EN",
"http://jakarta.apache.org/avalon/dtds/phoenix/mxinfo_1_0.dtd",
- "org/apache/avalon/jmx/util/mxinfo.dtd"
+ "org/apache/avalon/jmx/util/mxinfo.dtd"
)
};
- private static final DTDResolver RESOLVER = new DTDResolver(
+ private static final DTDResolver RESOLVER = new DTDResolver(
DTD_INFO, ConfigurationBuilder.class.getClassLoader() );
/**
Modified:
development/main/planet/facilities/jmx/util/src/main/net/dpml/jmx/util/DTDInfo.java
==============================================================================
---
development/main/planet/facilities/jmx/util/src/main/net/dpml/jmx/util/DTDInfo.java
(original)
+++
development/main/planet/facilities/jmx/util/src/main/net/dpml/jmx/util/DTDInfo.java
Thu Mar 10 23:40:37 2005
@@ -1,5 +1,6 @@
/*
- * Copyright 2004 Apache Software Foundation
+ * Copyright 2004 Digital Product Meta Library
+ *
* 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
Modified:
development/main/planet/facilities/jmx/util/src/main/net/dpml/jmx/util/DTDResolver.java
==============================================================================
---
development/main/planet/facilities/jmx/util/src/main/net/dpml/jmx/util/DTDResolver.java
(original)
+++
development/main/planet/facilities/jmx/util/src/main/net/dpml/jmx/util/DTDResolver.java
Thu Mar 10 23:40:37 2005
@@ -1,5 +1,6 @@
/*
- * Copyright 2004 Apache Software Foundation
+ * Copyright 2004 Digital Product Meta Library
+ *
* 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
Modified:
development/main/planet/facilities/jmx/util/src/main/net/dpml/jmx/util/MBeanInfoBuilder.java
==============================================================================
---
development/main/planet/facilities/jmx/util/src/main/net/dpml/jmx/util/MBeanInfoBuilder.java
(original)
+++
development/main/planet/facilities/jmx/util/src/main/net/dpml/jmx/util/MBeanInfoBuilder.java
Thu Mar 10 23:40:37 2005
@@ -1,5 +1,6 @@
/*
- * Copyright 2004 Apache Software Foundation
+ * Copyright 2004 Digital Product Meta Library
+ *
* 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
@@ -16,14 +17,6 @@
*/
package net.dpml.jmx.util;
-import java.beans.BeanInfo;
-import java.beans.Introspector;
-import java.beans.MethodDescriptor;
-import java.beans.ParameterDescriptor;
-import java.beans.PropertyDescriptor;
-import java.io.InputStream;
-import java.lang.reflect.Method;
-
import javax.management.Descriptor;
import javax.management.DynamicMBean;
import javax.management.MBeanParameterInfo;
@@ -37,13 +30,19 @@
import javax.management.modelmbean.ModelMBeanOperationInfo;
import javax.management.modelmbean.RequiredModelMBean;
-import net.dpml.i18n.ResourceManager;
-import net.dpml.i18n.Resources;
+import java.beans.BeanInfo;
+import java.beans.Introspector;
+import java.beans.MethodDescriptor;
+import java.beans.ParameterDescriptor;
+import java.beans.PropertyDescriptor;
+import java.io.InputStream;
+import java.lang.reflect.Method;
import net.dpml.configuration.Configuration;
import net.dpml.configuration.ConfigurationException;
+import net.dpml.i18n.ResourceManager;
+import net.dpml.i18n.Resources;
import net.dpml.logging.Logger;
-
import org.xml.sax.InputSource;
/**
@@ -64,12 +63,12 @@
private static final String REQ_MODEL_MBEAN =
RequiredModelMBean.class.getName();
private Logger m_logger;
-
+
public MBeanInfoBuilder( Logger logger )
{
m_logger = logger;
}
-
+
protected Logger getLogger()
{
return m_logger;
@@ -83,7 +82,7 @@
* @param interfaces the interface Classes to expose through the MBean
* @throws ConfigurationException if the MBeans cannot be generated
*/
- public void build( final Target target, final Class managedClass, final
Class[] interfaces )
+ public void build( final Target target, final Class managedClass, final
Class[] interfaces )
throws ConfigurationException
{
final String notice = REZ.getString( "mxinfo.debug.building",
managedClass.getName() );
@@ -134,7 +133,7 @@
* @throws ConfigurationException if there is an error creating MBeans
*/
private void buildFromMxInfo( final Target target, final Class
managedClass,
- final Configuration config )
+ final Configuration config )
throws ConfigurationException
{
BeanInfo beanInfo;
@@ -184,13 +183,13 @@
}
- private DynamicMBean createMBean( final ModelMBeanInfo topic, final
Object target )
+ private DynamicMBean createMBean( final ModelMBeanInfo topic, final
Object target )
throws Exception
{
final String className = topic.getClassName();
// Load the ModelMBean implementation class
final ClassLoader cl =
Thread.currentThread().getContextClassLoader();
-
+
final Class clazz;
try
{
@@ -205,12 +204,12 @@
}
catch ( Exception e )
{
- final String message =
+ final String message =
REZ.getString( "jmxmanager.error.mbean.load.class", className
);
getLogger().error( message, e );
throw new Exception( message, e );
}
-
+
// Create a new ModelMBean instance
ModelMBean mbean = null;
try
@@ -220,12 +219,12 @@
}
catch ( final Exception e )
{
- final String message =
+ final String message =
REZ.getString( "jmxmanager.error.mbean.instantiate", className
);
getLogger().error( message, e );
throw new Exception( message, e );
}
-
+
// Set the managed resource (if any)
try
{
@@ -236,12 +235,12 @@
}
catch ( Exception e )
{
- final String message =
+ final String message =
REZ.getString( "jmxmanager.error.mbean.set.resource",
className );
getLogger().error( message, e );
throw new Exception( message, e );
}
-
+
return mbean;
}
@@ -252,7 +251,7 @@
* @param interfaceClass the Class to introspect for management methods
* @throws ConfigurationException if there is an error introspecting the
class or generating MBeans
*/
- private void buildFromIntrospection( final Target target, final Class
interfaceClass )
+ private void buildFromIntrospection( final Target target, final Class
interfaceClass )
throws ConfigurationException
{
try
@@ -278,7 +277,7 @@
* @return the created ModelMBeanInfoSupport
* @throws ConfigurationException if an error occurs
*/
- private ModelMBeanInfo buildTopic( final Configuration config, final
BeanInfo beanInfo )
+ private ModelMBeanInfo buildTopic( final Configuration config, final
BeanInfo beanInfo )
throws ConfigurationException
{
final ModelMBeanAttributeInfo[] attributes = buildAttributeInfos(
config, beanInfo );
@@ -305,7 +304,7 @@
* @throws ConfigurationException if there is a problem generating the
Proxy
*/
private ModelMBeanInfo buildProxyTopic( final Configuration
proxyTagConfig,
- final Class managedClass )
+ final Class managedClass )
throws ConfigurationException
{
try
@@ -347,7 +346,7 @@
* @throws ConfigurationException
*/
private ModelMBeanAttributeInfo[] buildAttributeInfos( final
Configuration config,
- final BeanInfo
info )
+ final BeanInfo
info )
throws ConfigurationException
{
final Configuration[] attributesConfig = config.getChildren(
"attribute" );
@@ -387,7 +386,7 @@
{
return null;
}
-
+
final String type = property.getPropertyType().getName();
String description = property.getDisplayName();
@@ -431,7 +430,7 @@
* Returns the PropertyDescriptor with the specified name from the array
*/
private PropertyDescriptor getPropertyDescriptor( final String name,
- final
PropertyDescriptor[] propertys )
+ final
PropertyDescriptor[] propertys )
throws ConfigurationException
{
for ( int i = 0; i < propertys.length; i++ )
@@ -454,7 +453,7 @@
* @throws ConfigurationException
*/
private ModelMBeanOperationInfo[] buildOperationInfos( final
Configuration config,
- final BeanInfo
info )
+ final BeanInfo
info )
throws ConfigurationException
{
final Configuration[] operationsConfig = config.getChildren(
"operation" );
@@ -484,7 +483,7 @@
* @return the operation descriptor based on the configuration
*/
private ModelMBeanOperationInfo buildOperationInfo( final
MethodDescriptor method,
- final Configuration
config )
+ final Configuration
config )
throws ConfigurationException
{
ModelMBeanOperationInfo info;
@@ -514,7 +513,7 @@
info = new ModelMBeanOperationInfo( name, description,
params, type, impact );
}
-
+
}
else
@@ -549,7 +548,7 @@
* Returns the MethodDescriptor with the specified name from the array
*/
private MethodDescriptor getMethodDescriptor( final String name,
- final MethodDescriptor[]
methods )
+ final MethodDescriptor[]
methods )
throws ConfigurationException
{
@@ -570,7 +569,7 @@
* @throws ConfigurationException if configuration not structured
corretly
* @return the descriptor
*/
- private MBeanParameterInfo buildParameterInfo( Configuration paramConfig
)
+ private MBeanParameterInfo buildParameterInfo( Configuration paramConfig
)
throws ConfigurationException
{
final String name = paramConfig.getAttribute( "name" );
@@ -603,7 +602,7 @@
* @throws ConfigurationException
* @return the configuration file, or null if none exists
*/
- private Configuration loadMxInfo( final Class clazz )
+ private Configuration loadMxInfo( final Class clazz )
throws ConfigurationException
{
final String mxinfoName = "/" + clazz.getName().replace( '.', '/' )
+ ".mxinfo";
Modified:
development/main/planet/facilities/jmx/util/src/main/net/dpml/jmx/util/Target.java
==============================================================================
---
development/main/planet/facilities/jmx/util/src/main/net/dpml/jmx/util/Target.java
(original)
+++
development/main/planet/facilities/jmx/util/src/main/net/dpml/jmx/util/Target.java
Thu Mar 10 23:40:37 2005
@@ -1,5 +1,6 @@
/*
- * Copyright 2004 Apache Software Foundation
+ * Copyright 2004 Digital Product Meta Library
+ *
* 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
@@ -16,11 +17,11 @@
*/
package net.dpml.jmx.util;
+import javax.management.DynamicMBean;
+
import java.util.HashMap;
import java.util.Set;
-import javax.management.DynamicMBean;
-
/**
* It reprensents a managed object in the managegement space. It is a
container for
* zero or more management topics and zero or more management lists.
- svn commit: r2026 - in development/main/planet/facilities/jmx: . api/src/main/net/dpml/jmx handler/src/main/net/dpml/jmx/handler java5 java5/src java5/src/main java5/src/main/net java5/src/main/net/dpml java5/src/main/net/dpml/jmx java5/src/main/net/dpml/jmx/java5 mx4j/src/main/net/dpml/jmx/mx4j spi/src/main/net/dpml/jmx/spi util/src/main/net/dpml/jmx/util, herzog, 03/10/2005
Archive powered by MHonArc 2.6.24.