Author: alessio.soldano(a)jboss.com
Date: 2007-12-12 12:50:58 -0500 (Wed, 12 Dec 2007)
New Revision: 5281
Added:
framework/branches/asoldano/trunk/src/main/java/org/jboss/wsf/framework/management/recording/LogRecorder.java
framework/branches/asoldano/trunk/src/main/java/org/jboss/wsf/framework/management/recording/MemoryBufferRecorder.java
Removed:
framework/branches/asoldano/trunk/src/main/java/org/jboss/wsf/framework/management/recording/RecordBufferProcessor.java
framework/branches/asoldano/trunk/src/main/java/org/jboss/wsf/framework/management/recording/RecordDumpProcessor.java
Modified:
framework/branches/asoldano/trunk/src/main/java/org/jboss/wsf/framework/deployment/EndpointRecordProcessorDeploymentAspect.java
Log:
Name refactoring
Modified:
framework/branches/asoldano/trunk/src/main/java/org/jboss/wsf/framework/deployment/EndpointRecordProcessorDeploymentAspect.java
===================================================================
---
framework/branches/asoldano/trunk/src/main/java/org/jboss/wsf/framework/deployment/EndpointRecordProcessorDeploymentAspect.java 2007-12-12
17:28:19 UTC (rev 5280)
+++
framework/branches/asoldano/trunk/src/main/java/org/jboss/wsf/framework/deployment/EndpointRecordProcessorDeploymentAspect.java 2007-12-12
17:50:58 UTC (rev 5281)
@@ -32,8 +32,8 @@
import org.jboss.wsf.common.ObjectNameFactory;
import org.jboss.wsf.framework.management.recording.ManagedRecordExtractor;
import org.jboss.wsf.framework.management.recording.ManagedRecordProcessor;
-import org.jboss.wsf.framework.management.recording.RecordBufferProcessor;
-import org.jboss.wsf.framework.management.recording.RecordDumpProcessor;
+import org.jboss.wsf.framework.management.recording.MemoryBufferRecorder;
+import org.jboss.wsf.framework.management.recording.LogRecorder;
import org.jboss.wsf.framework.management.recording.RecordExtractor;
import org.jboss.wsf.spi.deployment.Deployment;
import org.jboss.wsf.spi.deployment.DeploymentAspect;
@@ -55,18 +55,18 @@
{
for (Endpoint ep : dep.getService().getEndpoints())
{
- /** Record buffer **/
- RecordBufferProcessor bufferProc = new RecordBufferProcessor();
- bufferProc.setName("RecordBuffer");
- this.registerRecordProcessor(bufferProc, ep);
- /** Record dump **/
- RecordDumpProcessor dumpProc = new RecordDumpProcessor();
- dumpProc.setName("RecordDump");
- this.registerRecordProcessor(dumpProc, ep);
+ /** Memory buffer recorder **/
+ MemoryBufferRecorder memoryRecorder = new MemoryBufferRecorder();
+ memoryRecorder.setName("MemoryBufferRecorder");
+ this.registerRecordProcessor(memoryRecorder, ep);
+ /** Log recorder **/
+ LogRecorder logRecorder = new LogRecorder();
+ logRecorder.setName("LogRecorder");
+ this.registerRecordProcessor(logRecorder, ep);
List<RecordProcessor> recordProcessorList = new
LinkedList<RecordProcessor>();
- recordProcessorList.add(bufferProc);
- recordProcessorList.add(dumpProc);
+ recordProcessorList.add(memoryRecorder);
+ recordProcessorList.add(logRecorder);
ep.setRecordProcessors(recordProcessorList);
}
}
Copied:
framework/branches/asoldano/trunk/src/main/java/org/jboss/wsf/framework/management/recording/LogRecorder.java
(from rev 5276,
framework/branches/asoldano/trunk/src/main/java/org/jboss/wsf/framework/management/recording/RecordDumpProcessor.java)
===================================================================
---
framework/branches/asoldano/trunk/src/main/java/org/jboss/wsf/framework/management/recording/LogRecorder.java
(rev 0)
+++
framework/branches/asoldano/trunk/src/main/java/org/jboss/wsf/framework/management/recording/LogRecorder.java 2007-12-12
17:50:58 UTC (rev 5281)
@@ -0,0 +1,139 @@
+/*
+ * 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.framework.management.recording;
+
+//$Id$
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.logging.Logger;
+import org.jboss.wsf.spi.management.recording.Record;
+import org.jboss.wsf.spi.management.recording.Record.MessageType;
+
+/**
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 8-Dec-2007
+ */
+public class LogRecorder extends AbstractRecordProcessor
+{
+ private Logger log = Logger.getLogger(this.getClass());
+
+ @Override
+ public void processRecord(Record record)
+ {
+ StringBuffer sb = new StringBuffer();
+ if (this.isProcessMessageType())
+ {
+ if (record.getMessageType() == MessageType.INBOUND)
+ {
+ sb.append("INBOUND MESSAGE ");
+ if (this.isProcessSourceHost())
+ {
+ sb.append("from ");
+ sb.append(record.getSourceHost());
+ }
+ }
+ else if (record.getMessageType() == MessageType.OUTBOUND)
+ {
+ sb.append("OUTBOUND MESSAGE ");
+ if (this.isProcessDestinationHost())
+ {
+ sb.append("to ");
+ sb.append(record.getDestinationHost());
+ }
+ }
+ else
+ {
+ log.warn("Unknown message type: " + record.getMessageType());
+ if (this.isProcessSourceHost())
+ {
+ sb.append("from ");
+ sb.append(record.getSourceHost());
+ }
+ if (this.isProcessDestinationHost())
+ {
+ sb.append("to ");
+ sb.append(record.getDestinationHost());
+ }
+ }
+ }
+ else
+ {
+ sb.append("MESSAGE");
+ }
+ sb.append(":");
+ if (this.isProcessDate())
+ {
+ sb.append("\nDate: ");
+ sb.append(record.getDate());
+ }
+ sb.append("\nGroupID: ");
+ sb.append(record.getGroupID());
+ if (this.isProcessOperation())
+ {
+ sb.append("\nOperation: ");
+ sb.append(record.getOperation());
+ }
+ sb.append("\n");
+ Map<String, List<String>> headers = record.getHeaders();
+ if (this.isProcessHeaders() && headers != null)
+ {
+ for (String key : headers.keySet())
+ {
+ sb.append(key);
+ sb.append(": ");
+ for (String h : headers.get(key))
+ {
+ sb.append(h);
+ sb.append("; ");
+ }
+ sb.append("\n");
+ }
+ sb.append("\n");
+ }
+ sb.append("\n");
+ if (this.isProcessMessage())
+ {
+ if (record.getPayload() != null)
+ {
+ try
+ {
+ ByteArrayOutputStream out = new ByteArrayOutputStream(1024);
+ out.write(record.getPayload());
+ out.close();
+ sb.append(out.toString()); //improve this...
+ sb.append("\n");
+ }
+ catch (IOException e)
+ {
+ log.warn("Error while writing the payload!");
+ }
+ }
+ sb.append(record.getEnvelope());
+ }
+ log.debug(sb.toString());
+ }
+}
Added:
framework/branches/asoldano/trunk/src/main/java/org/jboss/wsf/framework/management/recording/MemoryBufferRecorder.java
===================================================================
---
framework/branches/asoldano/trunk/src/main/java/org/jboss/wsf/framework/management/recording/MemoryBufferRecorder.java
(rev 0)
+++
framework/branches/asoldano/trunk/src/main/java/org/jboss/wsf/framework/management/recording/MemoryBufferRecorder.java 2007-12-12
17:50:58 UTC (rev 5281)
@@ -0,0 +1,144 @@
+/*
+ * 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.framework.management.recording;
+
+//$Id$
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentLinkedQueue;
+
+import javax.xml.namespace.QName;
+
+import org.jboss.wsf.spi.management.recording.Record;
+import org.jboss.wsf.spi.management.recording.RecordFilter;
+import org.jboss.wsf.spi.management.recording.Record.MessageType;
+
+/**
+ * Keeps the last received records in memory and allows user to
+ * search / get statistics on them.
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 12-Dec-2007
+ */
+public class MemoryBufferRecorder extends AbstractRecordProcessor implements
RecordExtractor
+{
+
+ private Map<String, List<Record>> recentRecords =
Collections.synchronizedMap(new HashMap<String, List<Record>>());
+ private ConcurrentLinkedQueue<Long> recentRecordGroups = new
ConcurrentLinkedQueue<Long>();
+ private int size = 0;
+
+ private int maxSize = 50;
+
+ @Override
+ public void processRecord(Record record)
+ {
+ synchronized (recentRecords)
+ {
+ if (size >= maxSize)
+ {
+ Long id = recentRecordGroups.poll();
+ if (id != null)
+ {
+ recentRecords.remove(id);
+ size--;
+ }
+ }
+ List<Record> list = recentRecords.get(record.getGroupID());
+ if (list == null)
+ {
+ list = new LinkedList<Record>();
+ recentRecords.put(record.getGroupID(), list);
+ }
+ list.add(record);
+ size++;
+ }
+ }
+
+ private Map<String, List<Record>> getRecentRecords()
+ {
+ synchronized (recentRecords)
+ {
+ return new HashMap<String, List<Record>>(recentRecords);
+ }
+ }
+
+ public Set<String> getClientHosts()
+ {
+ Map<String, List<Record>> map = this.getRecentRecords();
+ Set<String> hosts = new HashSet<String>();
+ for (List<Record> list : map.values())
+ {
+ for (Record record : list)
+ {
+ if (MessageType.INBOUND.equals(record.getMessageType()) &&
record.getSourceHost() != null)
+ {
+ hosts.add(record.getSourceHost());
+ }
+ }
+ }
+ return hosts;
+ }
+
+ public Map<String, List<Record>> getMatchingRecords(RecordFilter[]
filters)
+ {
+ Map<String, List<Record>> map = this.getRecentRecords();
+ Map<String, List<Record>> result = new HashMap<String,
List<Record>>();
+ for (List<Record> list : map.values())
+ {
+ for (Record record : list)
+ {
+ boolean match = true;
+ for (int i = 0; i < filters.length && match; i++)
+ {
+ match = match && filters[i].match(record);
+ }
+ if (match)
+ {
+ result.put(record.getGroupID(), list);
+ break;
+ }
+ }
+ }
+ return result;
+ }
+
+ public Map<String, List<Record>> getRecordsByClientHost(String
clientHost)
+ {
+ RecordFilter[] filters = new RecordFilter[1];
+ filters[0] = new HostFilter(clientHost, true);
+ return this.getMatchingRecords(filters);
+ }
+
+ public Map<String, List<Record>> getRecordsByOperation(String namespace,
String localPart)
+ {
+ RecordFilter[] filters = new RecordFilter[1];
+ filters[0] = new OperationFilter(new QName(namespace, localPart));
+ return this.getMatchingRecords(filters);
+ }
+
+}
Property changes on:
framework/branches/asoldano/trunk/src/main/java/org/jboss/wsf/framework/management/recording/MemoryBufferRecorder.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Deleted:
framework/branches/asoldano/trunk/src/main/java/org/jboss/wsf/framework/management/recording/RecordBufferProcessor.java
===================================================================
---
framework/branches/asoldano/trunk/src/main/java/org/jboss/wsf/framework/management/recording/RecordBufferProcessor.java 2007-12-12
17:28:19 UTC (rev 5280)
+++
framework/branches/asoldano/trunk/src/main/java/org/jboss/wsf/framework/management/recording/RecordBufferProcessor.java 2007-12-12
17:50:58 UTC (rev 5281)
@@ -1,144 +0,0 @@
-/*
- * 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.framework.management.recording;
-
-//$Id$
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentLinkedQueue;
-
-import javax.xml.namespace.QName;
-
-import org.jboss.wsf.spi.management.recording.Record;
-import org.jboss.wsf.spi.management.recording.RecordFilter;
-import org.jboss.wsf.spi.management.recording.Record.MessageType;
-
-/**
- * Keeps the last received records in memory and allows user to
- * search / get statistics on them.
- *
- * @author alessio.soldano(a)jboss.com
- * @since 12-Dec-2007
- */
-public class RecordBufferProcessor extends AbstractRecordProcessor implements
RecordExtractor
-{
-
- private Map<String, List<Record>> recentRecords =
Collections.synchronizedMap(new HashMap<String, List<Record>>());
- private ConcurrentLinkedQueue<Long> recentRecordGroups = new
ConcurrentLinkedQueue<Long>();
- private int size = 0;
-
- private int maxSize = 50;
-
- @Override
- public void processRecord(Record record)
- {
- synchronized (recentRecords)
- {
- if (size >= maxSize)
- {
- Long id = recentRecordGroups.poll();
- if (id != null)
- {
- recentRecords.remove(id);
- size--;
- }
- }
- List<Record> list = recentRecords.get(record.getGroupID());
- if (list == null)
- {
- list = new LinkedList<Record>();
- recentRecords.put(record.getGroupID(), list);
- }
- list.add(record);
- size++;
- }
- }
-
- private Map<String, List<Record>> getRecentRecords()
- {
- synchronized (recentRecords)
- {
- return new HashMap<String, List<Record>>(recentRecords);
- }
- }
-
- public Set<String> getClientHosts()
- {
- Map<String, List<Record>> map = this.getRecentRecords();
- Set<String> hosts = new HashSet<String>();
- for (List<Record> list : map.values())
- {
- for (Record record : list)
- {
- if (MessageType.INBOUND.equals(record.getMessageType()) &&
record.getSourceHost() != null)
- {
- hosts.add(record.getSourceHost());
- }
- }
- }
- return hosts;
- }
-
- public Map<String, List<Record>> getMatchingRecords(RecordFilter[]
filters)
- {
- Map<String, List<Record>> map = this.getRecentRecords();
- Map<String, List<Record>> result = new HashMap<String,
List<Record>>();
- for (List<Record> list : map.values())
- {
- for (Record record : list)
- {
- boolean match = true;
- for (int i = 0; i < filters.length && match; i++)
- {
- match = match && filters[i].match(record);
- }
- if (match)
- {
- result.put(record.getGroupID(), list);
- break;
- }
- }
- }
- return result;
- }
-
- public Map<String, List<Record>> getRecordsByClientHost(String
clientHost)
- {
- RecordFilter[] filters = new RecordFilter[1];
- filters[0] = new HostFilter(clientHost, true);
- return this.getMatchingRecords(filters);
- }
-
- public Map<String, List<Record>> getRecordsByOperation(String namespace,
String localPart)
- {
- RecordFilter[] filters = new RecordFilter[1];
- filters[0] = new OperationFilter(new QName(namespace, localPart));
- return this.getMatchingRecords(filters);
- }
-
-}
Deleted:
framework/branches/asoldano/trunk/src/main/java/org/jboss/wsf/framework/management/recording/RecordDumpProcessor.java
===================================================================
---
framework/branches/asoldano/trunk/src/main/java/org/jboss/wsf/framework/management/recording/RecordDumpProcessor.java 2007-12-12
17:28:19 UTC (rev 5280)
+++
framework/branches/asoldano/trunk/src/main/java/org/jboss/wsf/framework/management/recording/RecordDumpProcessor.java 2007-12-12
17:50:58 UTC (rev 5281)
@@ -1,139 +0,0 @@
-/*
- * 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.framework.management.recording;
-
-//$Id$
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.util.List;
-import java.util.Map;
-
-import org.jboss.logging.Logger;
-import org.jboss.wsf.spi.management.recording.Record;
-import org.jboss.wsf.spi.management.recording.Record.MessageType;
-
-/**
- *
- * @author alessio.soldano(a)jboss.com
- * @since 8-Dec-2007
- */
-public class RecordDumpProcessor extends AbstractRecordProcessor
-{
- private Logger log = Logger.getLogger(this.getClass());
-
- @Override
- public void processRecord(Record record)
- {
- StringBuffer sb = new StringBuffer();
- if (this.isProcessMessageType())
- {
- if (record.getMessageType() == MessageType.INBOUND)
- {
- sb.append("INBOUND MESSAGE ");
- if (this.isProcessSourceHost())
- {
- sb.append("from ");
- sb.append(record.getSourceHost());
- }
- }
- else if (record.getMessageType() == MessageType.OUTBOUND)
- {
- sb.append("OUTBOUND MESSAGE ");
- if (this.isProcessDestinationHost())
- {
- sb.append("to ");
- sb.append(record.getDestinationHost());
- }
- }
- else
- {
- log.warn("Unknown message type: " + record.getMessageType());
- if (this.isProcessSourceHost())
- {
- sb.append("from ");
- sb.append(record.getSourceHost());
- }
- if (this.isProcessDestinationHost())
- {
- sb.append("to ");
- sb.append(record.getDestinationHost());
- }
- }
- }
- else
- {
- sb.append("MESSAGE");
- }
- sb.append(":");
- if (this.isProcessDate())
- {
- sb.append("\nDate: ");
- sb.append(record.getDate());
- }
- sb.append("\nGroupID: ");
- sb.append(record.getGroupID());
- if (this.isProcessOperation())
- {
- sb.append("\nOperation: ");
- sb.append(record.getOperation());
- }
- sb.append("\n");
- Map<String, List<String>> headers = record.getHeaders();
- if (this.isProcessHeaders() && headers != null)
- {
- for (String key : headers.keySet())
- {
- sb.append(key);
- sb.append(": ");
- for (String h : headers.get(key))
- {
- sb.append(h);
- sb.append("; ");
- }
- sb.append("\n");
- }
- sb.append("\n");
- }
- sb.append("\n");
- if (this.isProcessMessage())
- {
- if (record.getPayload() != null)
- {
- try
- {
- ByteArrayOutputStream out = new ByteArrayOutputStream(1024);
- out.write(record.getPayload());
- out.close();
- sb.append(out.toString()); //improve this...
- sb.append("\n");
- }
- catch (IOException e)
- {
- log.warn("Error while writing the payload!");
- }
- }
- sb.append(record.getEnvelope());
- }
- log.debug(sb.toString());
- }
-}