[jbossws-commits] JBossWS SVN: r3682 - in branches/maeste_palin/integration/xfire: src/main/java/org/jboss/wsf/stack/xfire and 3 other directories.

jbossws-commits at lists.jboss.org jbossws-commits at lists.jboss.org
Thu Jun 21 12:24:14 EDT 2007


Author: maeste
Date: 2007-06-21 12:24:14 -0400 (Thu, 21 Jun 2007)
New Revision: 3682

Added:
   branches/maeste_palin/integration/xfire/src/main/java/org/jboss/wsf/stack/xfire/log/
   branches/maeste_palin/integration/xfire/src/main/java/org/jboss/wsf/stack/xfire/log/MessageDumpLogging.java
   branches/maeste_palin/integration/xfire/src/main/java/org/jboss/wsf/stack/xfire/log/MessageDumpLoggingMBean.java
Modified:
   branches/maeste_palin/integration/xfire/.classpath
   branches/maeste_palin/integration/xfire/src/main/resources/jbossws-xfire42.sar/jbossws.beans/META-INF/jboss-beans.xml
   branches/maeste_palin/integration/xfire/src/main/resources/jbossws-xfire50.sar/META-INF/jbossws-beans.xml
Log:
JBWS-1677 partial commit. Implemented MBean to enable disable log


Modified: branches/maeste_palin/integration/xfire/.classpath
===================================================================
--- branches/maeste_palin/integration/xfire/.classpath	2007-06-21 16:23:53 UTC (rev 3681)
+++ branches/maeste_palin/integration/xfire/.classpath	2007-06-21 16:24:14 UTC (rev 3682)
@@ -18,5 +18,7 @@
 	<classpathentry combineaccessrules="false" kind="src" path="/integration-jboss50"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/jboss-5.0.x"/>
 	<classpathentry kind="lib" path="thirdparty/commons-logging-1.1.jar"/>
+	<classpathentry kind="lib" path="/integration-spi/thirdparty/jboss-logging-log4j.jar"/>
+	<classpathentry kind="lib" path="/integration-spi/thirdparty/jboss-logging-spi.jar"/>
 	<classpathentry kind="output" path="output/eclipse"/>
 </classpath>

Added: branches/maeste_palin/integration/xfire/src/main/java/org/jboss/wsf/stack/xfire/log/MessageDumpLogging.java
===================================================================
--- branches/maeste_palin/integration/xfire/src/main/java/org/jboss/wsf/stack/xfire/log/MessageDumpLogging.java	                        (rev 0)
+++ branches/maeste_palin/integration/xfire/src/main/java/org/jboss/wsf/stack/xfire/log/MessageDumpLogging.java	2007-06-21 16:24:14 UTC (rev 3682)
@@ -0,0 +1,235 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.wsf.stack.xfire.log;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.List;
+
+
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+import javax.management.ObjectName;
+
+import org.codehaus.xfire.service.Service;
+import org.codehaus.xfire.transport.http.XFireServletController;
+import org.codehaus.xfire.util.LoggingHandler;
+import org.codehaus.xfire.util.dom.DOMInHandler;
+import org.codehaus.xfire.util.dom.DOMOutHandler;
+import org.jboss.logging.Logger;
+import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.management.EndpointRegistry;
+import org.jboss.wsf.spi.management.EndpointRegistryFactory;
+import org.jboss.wsf.spi.utils.ObjectNameFactory;
+import org.jboss.wsf.stack.xfire.ManagedEndpointRegistry;
+
+/**
+ * @author Stefano Maestri <mailto:stefano.maestri at javalinux.it>
+ *
+ * since 21/06/2007
+ */
+public class MessageDumpLogging implements MessageDumpLoggingMBean
+{
+   // provide logging
+   private static final Logger log = Logger.getLogger(ManagedEndpointRegistry.class);
+
+   
+   
+   private static final DOMInHandler domInHandler = new DOMInHandler();
+   
+   private static final DOMOutHandler domOutHandler = new DOMOutHandler();
+   
+   private static final LoggingHandler loggingHandelr = new LoggingHandler();
+
+   /* (non-Javadoc)
+    * @see org.jboss.wsf.stack.xfire.log.MessageDumpLoggingMBean#getImplementationTitle()
+    */
+   public String getImplementationTitle()
+   {
+      return getClass().getPackage().getImplementationTitle();
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.wsf.stack.xfire.log.MessageDumpLoggingMBean#getImplementationVersion()
+    */
+   public String getImplementationVersion()
+   {
+      return getClass().getPackage().getImplementationVersion();
+   }
+
+   public void create() throws Exception
+   {
+      log.info(getImplementationTitle());
+      log.info(getImplementationVersion());
+      MBeanServer server = getMBeanServer();
+      if (server != null)
+      {
+         server.registerMBean(this, ObjectNameFactory.create("jboss.ws:service=MessageDumpLogging"));
+      }
+   }
+
+   public void destroy() throws Exception
+   {
+      log.debug("Destroy service endpoint manager");
+      MBeanServer server = getMBeanServer();
+      if (server != null)
+      {
+         server.unregisterMBean(ObjectNameFactory.create("jboss.ws:service=MessageDumpLogging"));
+      }
+   }
+
+   private MBeanServer getMBeanServer()
+   {
+      MBeanServer server = null;
+      ArrayList servers = MBeanServerFactory.findMBeanServer(null);
+      if (servers.size() > 0)
+      {
+         server = (MBeanServer)servers.get(0);
+      }
+      return server;
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.wsf.stack.xfire.log.MessageDumpLoggingMBean#modifyDumpingAll(boolean)
+    */
+   public void modifyDumpingAll(boolean enable)
+   {
+      EndpointRegistry epRegistry = EndpointRegistryFactory.getEndpointRegistry();
+      for (ObjectName epName : epRegistry.getEndpoints())
+      {
+         this.modifyAllServices(epName, enable);
+      }
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.wsf.stack.xfire.log.MessageDumpLoggingMBean#modifyDumpingEndpoit(java.lang.String, boolean)
+    */
+   public void modifyDumpingEndpoit(String endPointName, boolean enable)
+   {
+      this.modifyAllServices(ObjectNameFactory.create(endPointName), true);
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.wsf.stack.xfire.log.MessageDumpLoggingMBean#modifyDumpingService(java.lang.String, java.lang.String, boolean)
+    */
+   public void modifyDumpingService(String endPointName, String serviceName, boolean enable)
+   {
+      EndpointRegistry epRegistry = EndpointRegistryFactory.getEndpointRegistry();
+      Endpoint ep = epRegistry.getEndpoint(ObjectNameFactory.create(endPointName));
+      XFireServletController controller = ep.getAttachment(XFireServletController.class);
+      Service service = controller.getXFire().getServiceRegistry().getService(serviceName);
+      if (enable)
+      {
+         this.enableService(service);
+      }
+      else
+      {
+         this.disableService(service);
+      }
+   }
+
+   private void modifyAllServices(ObjectName epName, boolean enable)
+   {
+      EndpointRegistry epRegistry = EndpointRegistryFactory.getEndpointRegistry();
+      Endpoint ep = epRegistry.getEndpoint(epName);
+      XFireServletController controller = ep.getAttachment(XFireServletController.class);
+      if (controller != null)
+      {
+         for (Service service : (Collection<Service>)controller.getXFire().getServiceRegistry().getServices())
+         {
+            if (enable)
+            {
+               this.enableService(service);
+            }
+            else
+            {
+               this.disableService(service);
+            }
+         }
+      }
+   }
+
+   private void enableService(Service service)
+   {
+//      service.addInHandler(new DOMInHandler());
+//      service.addOutHandler(new DOMOutHandler());
+//      service.addFaultHandler(new DOMOutHandler());
+//      
+//      service.addInHandler(new LoggingHandler());
+//      service.addOutHandler(new LoggingHandler());
+//      service.addFaultHandler(new LoggingHandler());
+      
+    service.addInHandler(domInHandler);
+    service.addOutHandler(domOutHandler);
+    service.addFaultHandler(domOutHandler);
+    
+    service.addInHandler(loggingHandelr);
+    service.addOutHandler(loggingHandelr);
+    service.addFaultHandler(loggingHandelr);
+
+      
+   }
+
+   private void disableService(Service service)
+   {
+      service.getInHandlers().remove(domInHandler);
+      service.getOutHandlers().remove(domOutHandler);
+      service.getFaultHandlers().remove(domOutHandler);
+      service.getInHandlers().remove(loggingHandelr);
+      service.getOutHandlers().remove(loggingHandelr);
+      service.getFaultHandlers().remove(loggingHandelr);
+   }
+//      List toBeRemoved = new LinkedList();
+//      for (Object obj : service.getInHandlers())
+//      {
+//         if (obj instanceof LoggingHandler || obj instanceof DOMInHandler )
+//         {
+//            toBeRemoved.add(obj);
+//         }
+//      }
+//      service.getInHandlers().removeAll(toBeRemoved);
+//      
+//      toBeRemoved.clear();
+//      for (Object obj : service.getOutHandlers() )
+//      {
+//         if (obj instanceof LoggingHandler || obj instanceof DOMOutHandler)
+//         {
+//            toBeRemoved.add(obj);
+//         }
+//      }
+//      service.getOutHandlers().removeAll(toBeRemoved);
+//      
+//      toBeRemoved.clear();
+//      for (Object obj : service.getFaultHandlers())
+//      {
+//         if (obj instanceof LoggingHandler || obj instanceof DOMOutHandler)
+//         {
+//            toBeRemoved.add(obj);
+//         }
+//      }
+//      service.getFaultHandlers().removeAll(toBeRemoved);
+//   }
+      
+
+}
+

Added: branches/maeste_palin/integration/xfire/src/main/java/org/jboss/wsf/stack/xfire/log/MessageDumpLoggingMBean.java
===================================================================
--- branches/maeste_palin/integration/xfire/src/main/java/org/jboss/wsf/stack/xfire/log/MessageDumpLoggingMBean.java	                        (rev 0)
+++ branches/maeste_palin/integration/xfire/src/main/java/org/jboss/wsf/stack/xfire/log/MessageDumpLoggingMBean.java	2007-06-21 16:24:14 UTC (rev 3682)
@@ -0,0 +1,16 @@
+package org.jboss.wsf.stack.xfire.log;
+
+public interface MessageDumpLoggingMBean
+{
+
+   public abstract String getImplementationTitle();
+
+   public abstract String getImplementationVersion();
+
+   public abstract void modifyDumpingAll(boolean enable);
+
+   public abstract void modifyDumpingEndpoit(String endPointName, boolean enable);
+
+   public abstract void modifyDumpingService(String endPointName, String serviceName, boolean enable);
+
+}
\ No newline at end of file

Modified: branches/maeste_palin/integration/xfire/src/main/resources/jbossws-xfire42.sar/jbossws.beans/META-INF/jboss-beans.xml
===================================================================
--- branches/maeste_palin/integration/xfire/src/main/resources/jbossws-xfire42.sar/jbossws.beans/META-INF/jboss-beans.xml	2007-06-21 16:23:53 UTC (rev 3681)
+++ branches/maeste_palin/integration/xfire/src/main/resources/jbossws-xfire42.sar/jbossws.beans/META-INF/jboss-beans.xml	2007-06-21 16:24:14 UTC (rev 3682)
@@ -217,5 +217,7 @@
       </list>
     </property>
   </bean>
+  <bean name="MessageDump" class="org.jboss.wsf.stack.xfire.log.MessageDumpLogging"/>
+  
     
 </deployment>
\ No newline at end of file

Modified: branches/maeste_palin/integration/xfire/src/main/resources/jbossws-xfire50.sar/META-INF/jbossws-beans.xml
===================================================================
--- branches/maeste_palin/integration/xfire/src/main/resources/jbossws-xfire50.sar/META-INF/jbossws-beans.xml	2007-06-21 16:23:53 UTC (rev 3681)
+++ branches/maeste_palin/integration/xfire/src/main/resources/jbossws-xfire50.sar/META-INF/jbossws-beans.xml	2007-06-21 16:24:14 UTC (rev 3682)
@@ -247,5 +247,6 @@
     </uninstall>
     <depends>WebServiceMainDeployer</depends>
   </bean>
-    
+  <bean name="MessageDump" class="org.jboss.wsf.stack.xfire.log.MessageDumpLogging"/>
+  
 </deployment>




More information about the jbossws-commits mailing list