Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlyn Normington2010-04-20 14:38:13 +0000
committerGlyn Normington2010-04-20 14:38:13 +0000
commit1fe315346425dcdea73feebd431aba7ae2a75f61 (patch)
tree617c48f3ec41fb2cde58e215bc42bc2b3a5d8678 /org.eclipse.virgo.medic.testfragment
downloadorg.eclipse.virgo.medic-1fe315346425dcdea73feebd431aba7ae2a75f61.tar.gz
org.eclipse.virgo.medic-1fe315346425dcdea73feebd431aba7ae2a75f61.tar.xz
org.eclipse.virgo.medic-1fe315346425dcdea73feebd431aba7ae2a75f61.zip
[bug 307650] initial check-in from dm Server Virgo medic 0a647883a0176f60d8572f51c7eff591b7e408b6
Diffstat (limited to 'org.eclipse.virgo.medic.testfragment')
-rw-r--r--org.eclipse.virgo.medic.testfragment/.classpath28
-rw-r--r--org.eclipse.virgo.medic.testfragment/.project36
-rw-r--r--org.eclipse.virgo.medic.testfragment/.settings/com.springsource.server.ide.bundlor.core.prefs5
-rw-r--r--org.eclipse.virgo.medic.testfragment/.settings/org.eclipse.wst.common.project.facet.core.xml4
-rw-r--r--org.eclipse.virgo.medic.testfragment/.springBeans13
-rw-r--r--org.eclipse.virgo.medic.testfragment/build.xml10
-rw-r--r--org.eclipse.virgo.medic.testfragment/ivy.xml25
-rw-r--r--org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/dump/Dump.java83
-rw-r--r--org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/dump/DumpContributionFailedException.java46
-rw-r--r--org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/dump/DumpContributor.java39
-rw-r--r--org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/dump/DumpGenerationFailedException.java46
-rw-r--r--org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/dump/DumpGenerator.java51
-rw-r--r--org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/dump/JmxDumpContributionParticipant.java34
-rw-r--r--org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/eventlog/EventLogger.java86
-rw-r--r--org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/eventlog/EventLoggerFactory.java36
-rw-r--r--org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/eventlog/Level.java16
-rw-r--r--org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/eventlog/LogEvent.java38
-rw-r--r--org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/log/ConfigurationPublicationFailedException.java30
-rw-r--r--org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/log/DelegatingPrintStream.java34
-rw-r--r--org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/log/EntryExitTrace.aj95
-rw-r--r--org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/log/LoggingConfiguration.java19
-rw-r--r--org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/log/LoggingConfigurationPublisher.java34
-rw-r--r--org.eclipse.virgo.medic.testfragment/src/main/resources/.gitignore0
-rw-r--r--org.eclipse.virgo.medic.testfragment/src/test/java/.gitignore0
-rw-r--r--org.eclipse.virgo.medic.testfragment/src/test/resources/.gitignore0
-rw-r--r--org.eclipse.virgo.medic.testfragment/template.mf13
26 files changed, 821 insertions, 0 deletions
diff --git a/org.eclipse.virgo.medic.testfragment/.classpath b/org.eclipse.virgo.medic.testfragment/.classpath
new file mode 100644
index 0000000..6635d80
--- /dev/null
+++ b/org.eclipse.virgo.medic.testfragment/.classpath
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/main/java">
+ <attributes>
+ <attribute name="com.springsource.server.ide.jdt.core.test.classpathentry" value="false"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="src" path="src/main/resources">
+ <attributes>
+ <attribute name="com.springsource.server.ide.jdt.core.test.classpathentry" value="false"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="src" output="target/test-classes" path="src/test/java">
+ <attributes>
+ <attribute name="com.springsource.server.ide.jdt.core.test.classpathentry" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="src" output="target/test-classes" path="src/test/resources">
+ <attributes>
+ <attribute name="com.springsource.server.ide.jdt.core.test.classpathentry" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="var" path="MEDIC_IVY_CACHE/org.eclipse.osgi/org.eclipse.osgi/3.5.1.R35x_v20091005/org.eclipse.osgi-3.5.1.R35x_v20091005.jar" sourcepath="/MEDIC_IVY_CACHE/org.eclipse.osgi/org.eclipse.osgi/3.5.1.R35x_v20091005/org.eclipse.osgi-sources-3.5.1.R35x_v20091005.jar"/>
+ <classpathentry kind="con" path="org.eclipse.ajdt.core.ASPECTJRT_CONTAINER"/>
+ <classpathentry kind="var" path="MEDIC_IVY_CACHE/org.slf4j/com.springsource.slf4j.api/1.5.10/com.springsource.slf4j.api-1.5.10.jar" sourcepath="/MEDIC_IVY_CACHE/org.slf4j/com.springsource.slf4j.api/1.5.10/com.springsource.slf4j.api-sources-1.5.10.jar"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
diff --git a/org.eclipse.virgo.medic.testfragment/.project b/org.eclipse.virgo.medic.testfragment/.project
new file mode 100644
index 0000000..80226e7
--- /dev/null
+++ b/org.eclipse.virgo.medic.testfragment/.project
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.virgo.medic.testfragment</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.wst.common.project.facet.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.ajdt.core.ajbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>com.springsource.server.ide.bundlor.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.springframework.ide.eclipse.core.springbuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.ajdt.ui.ajnature</nature>
+ <nature>com.springsource.server.ide.facet.core.bundlenature</nature>
+ <nature>org.springframework.ide.eclipse.core.springnature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
+ </natures>
+</projectDescription>
diff --git a/org.eclipse.virgo.medic.testfragment/.settings/com.springsource.server.ide.bundlor.core.prefs b/org.eclipse.virgo.medic.testfragment/.settings/com.springsource.server.ide.bundlor.core.prefs
new file mode 100644
index 0000000..16863b5
--- /dev/null
+++ b/org.eclipse.virgo.medic.testfragment/.settings/com.springsource.server.ide.bundlor.core.prefs
@@ -0,0 +1,5 @@
+#Thu Nov 12 08:44:57 GMT 2009
+com.springsource.server.ide.bundlor.core.bundlor.generated.manifest.autoformatting=true
+com.springsource.server.ide.bundlor.core.byte.code.scanning=true
+com.springsource.server.ide.bundlor.core.template.properties.files=../build.versions
+eclipse.preferences.version=1
diff --git a/org.eclipse.virgo.medic.testfragment/.settings/org.eclipse.wst.common.project.facet.core.xml b/org.eclipse.virgo.medic.testfragment/.settings/org.eclipse.wst.common.project.facet.core.xml
new file mode 100644
index 0000000..801f856
--- /dev/null
+++ b/org.eclipse.virgo.medic.testfragment/.settings/org.eclipse.wst.common.project.facet.core.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faceted-project>
+ <installed facet="com.springsource.server.bundle" version="1.0"/>
+</faceted-project>
diff --git a/org.eclipse.virgo.medic.testfragment/.springBeans b/org.eclipse.virgo.medic.testfragment/.springBeans
new file mode 100644
index 0000000..5152991
--- /dev/null
+++ b/org.eclipse.virgo.medic.testfragment/.springBeans
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beansProjectDescription>
+ <version>1</version>
+ <pluginVersion><![CDATA[2.2.5.M1]]></pluginVersion>
+ <configSuffixes>
+ <configSuffix><![CDATA[xml]]></configSuffix>
+ </configSuffixes>
+ <enableImports><![CDATA[false]]></enableImports>
+ <configs>
+ </configs>
+ <configSets>
+ </configSets>
+</beansProjectDescription>
diff --git a/org.eclipse.virgo.medic.testfragment/build.xml b/org.eclipse.virgo.medic.testfragment/build.xml
new file mode 100644
index 0000000..daa4411
--- /dev/null
+++ b/org.eclipse.virgo.medic.testfragment/build.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="org.eclipse.virgo.medic.testfragment">
+
+ <property name="clover.coverage" value="0%"/>
+
+ <property file="${basedir}/../build.properties"/>
+ <property file="${basedir}/../build.versions"/>
+ <import file="${basedir}/../virgo-build/aspect/default.xml"/>
+
+</project>
diff --git a/org.eclipse.virgo.medic.testfragment/ivy.xml b/org.eclipse.virgo.medic.testfragment/ivy.xml
new file mode 100644
index 0000000..482ad18
--- /dev/null
+++ b/org.eclipse.virgo.medic.testfragment/ivy.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?xml-stylesheet type="text/xsl" href="http://ivyrep.jayasoft.org/ivy-doc.xsl"?>
+<ivy-module
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="http://incubator.apache.org/ivy/schemas/ivy.xsd"
+ version="1.3">
+
+ <info organisation="org.eclipse.virgo.medic" module="${ant.project.name}"/>
+
+ <configurations>
+ <include file="${virgo.build.dir}/common/default-ivy-configurations.xml"/>
+ </configurations>
+
+ <publications>
+ <artifact name="${ant.project.name}"/>
+ <artifact name="${ant.project.name}-sources" type="src" ext="jar"/>
+ </publications>
+
+ <dependencies>
+ <dependency org="org.eclipse.osgi" name="org.eclipse.osgi" rev="${org.eclipse.osgi}" conf="provided->runtime"/>
+ <dependency org="org.slf4j" name="com.springsource.slf4j.api" rev="${org.slf4j}" conf="aspects->runtime"/>
+ <dependency org="org.aspectj" name="com.springsource.org.aspectj.runtime" rev="${org.aspectj}" conf="aspects->runtime"/>
+ </dependencies>
+
+</ivy-module>
diff --git a/org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/dump/Dump.java b/org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/dump/Dump.java
new file mode 100644
index 0000000..2dd3a81
--- /dev/null
+++ b/org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/dump/Dump.java
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.medic.dump;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.Writer;
+import java.util.Map;
+
+/**
+ * A <code>Dump</code> represents a dump being generated by a {@link DumpGenerator}. During dump generation
+ * {@link DumpContributor DumpContributors} are called to contribute to the dump. Contributors can request a
+ * {@link Writer}, {@link File}, etc. which they may use to write out their contribution to the dump.
+ */
+public interface Dump {
+
+ /**
+ * Returns a timestamp that identifies that time at which this dump was generated.
+ *
+ * @return The timestamp of the dump's generation
+ */
+ long getTimestamp();
+
+ /**
+ * Returns the context that is associated with this dump. If there is no associated context an empty
+ * <code>Map</code> is returned.
+ *
+ * @return The dump's context
+ */
+ Map<String, Object> getContext();
+
+ /**
+ * Returns the {@link Throwable Throwables} associated with this dump.
+ *
+ * @return The dump's <code>Throwable</code>s
+ */
+ Throwable[] getThrowables();
+
+ /**
+ * Returns the cause of this dump.
+ *
+ * @return The dump's cause.
+ */
+ String getCause();
+
+ /**
+ * Creates a {@link FileWriter} that writes to a file with the supplied name, within this dump's output location.
+ * @param name
+ *
+ * @return a <code>FileWriter</code> to which a contribution to the dump can be written
+ * @throws DumpContributionFailedException
+ */
+ FileWriter createFileWriter(String name) throws DumpContributionFailedException;
+
+ /**
+ * Creates a {@link FileOutputStream} that writes to a file with the supplied name, within this dump's output
+ * location.
+ * @param name
+ *
+ * @return a <code>FileOutputStream</code> to which a contribution to the dump can be written
+ * @throws DumpContributionFailedException
+ */
+ FileOutputStream createFileOutputStream(String name) throws DumpContributionFailedException;
+
+ /**
+ * Creates a {@link File} with the supplied name, within this dump's output location.
+ * @param name
+ *
+ * @return a <code>File</code> to which a contribution to the dump can be written
+ */
+ File createFile(String name);
+
+}
diff --git a/org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/dump/DumpContributionFailedException.java b/org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/dump/DumpContributionFailedException.java
new file mode 100644
index 0000000..edaf464
--- /dev/null
+++ b/org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/dump/DumpContributionFailedException.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.medic.dump;
+
+/**
+ * A <code>DumpContributionFailedException</code> is thrown by a {@link DumpContributor} to indicate that a failure has
+ * occurred when it was attempting to make a contribution to a dump.
+ * <p />
+ *
+ * <strong>Concurrent Semantics</strong><br />
+ * Thread-safe.
+ *
+ */
+public class DumpContributionFailedException extends DumpGenerationFailedException {
+
+ private static final long serialVersionUID = -3196511149954617337L;
+
+ /**
+ * Create a new DumpContributionFailedException with the supplied message that describes the failure
+ *
+ * @param message The message describing the failure
+ */
+ public DumpContributionFailedException(String message) {
+ super(message);
+ }
+
+ /**
+ * Create a new DumpContributionFailedException with the supplied failure cause and message that describes the
+ * failure
+ *
+ * @param message The message describing the failure
+ * @param cause The cause of the contribution failure
+ */
+ public DumpContributionFailedException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/dump/DumpContributor.java b/org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/dump/DumpContributor.java
new file mode 100644
index 0000000..ddffe7c
--- /dev/null
+++ b/org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/dump/DumpContributor.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.medic.dump;
+
+/**
+ * A <code>DumpContributor</code> is implemented to contribute information to a dump. Contributors are 'registered' with
+ * a {@link DumpGenerator} by publishing them in the service registry.
+ * <p />
+ *
+ * <strong>Concurrent Semantics</strong><br />
+ * <code>DumpContributor</code>s must be thread-safe.
+ */
+public interface DumpContributor {
+
+ /**
+ * Contribute to the supplied {@link Dump}.
+ *
+ * @param dump The dump to which a contribution may be made.
+ * @throws DumpContributionFailedException if the dump contribution cannot be created
+ */
+ void contribute(Dump dump) throws DumpContributionFailedException;
+
+ /**
+ * Returns the name of this <code>DumpContributor</code>. The name is used by a {@link DumpGenerator} when
+ * determining which contributors should be excluded from contributing to a dump.
+ *
+ * @return The contributor's name
+ */
+ String getName();
+}
diff --git a/org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/dump/DumpGenerationFailedException.java b/org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/dump/DumpGenerationFailedException.java
new file mode 100644
index 0000000..5dded04
--- /dev/null
+++ b/org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/dump/DumpGenerationFailedException.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.medic.dump;
+
+/**
+ * A <code>DumpGenerationFailedException</code> is thrown by a {@link DumpGenerator} to indicate that a failure has
+ * occurred during dump generation.
+ *
+ * <p />
+ *
+ * <strong>Concurrent Semantics</strong><br />
+ * Thread-safe.
+ *
+ */
+public class DumpGenerationFailedException extends Exception {
+
+ private static final long serialVersionUID = -3196511149954617337L;
+
+ /**
+ * Create a new DumpGenerationFailedException with the supplied message that describes the failure
+ *
+ * @param message The message describing the failure
+ */
+ public DumpGenerationFailedException(String message) {
+ super(message);
+ }
+
+ /**
+ * Create a new DumpGenerationFailedException with the supplied failure cause and message that describes the failure
+ *
+ * @param message The message describing the failure
+ * @param cause The cause of the generation failure
+ */
+ public DumpGenerationFailedException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/dump/DumpGenerator.java b/org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/dump/DumpGenerator.java
new file mode 100644
index 0000000..2a2d530
--- /dev/null
+++ b/org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/dump/DumpGenerator.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.medic.dump;
+
+import java.util.Map;
+
+/**
+ * A <code>DumpGenerator</code> can be used to programatically request the generation of a dump. A
+ * <code>DumpGenerator</code> instance can be obtained from the service registry.
+ * <p />
+ *
+ * When a dump is requested, the <code>DumpGenerator</code> will, by default, provide all {@link DumpContributor
+ * DumpContributors} that are known to it with an opportunity to contribute to the dump. <code>DumpContributor</code>
+ * instances are made known to a <code>DumpGeneraator</code> by publishing them in the service registry.
+ * <p />
+ *
+ * A <code>DumpGenerator</code> can be configured to exclude <code>DumpContributor</code>s from contributing to dumps
+ * with a particular cause. TODO Expand the documentation on contributor exclusion
+ * <p />
+ *
+ * <strong>Concurrent Semantics</strong><br />
+ * <code>DumpGenerator</code>s must be thread-safe.
+ */
+public interface DumpGenerator {
+
+ /**
+ * Generates a dump
+ *
+ * @param cause the cause of the dump
+ * @param throwables {@link Throwable} instances to be associated with the dump
+ */
+ void generateDump(String cause, Throwable... throwables);
+
+ /**
+ * Generates a dump, with additional context.
+ *
+ * @param cause the cause of the dump
+ * @param context additional context that can be used by the <code>DumpProvider</code>s
+ * @param throwables {@link Throwable} instances to be associated with the dump
+ */
+ void generateDump(String cause, Map<String, Object> context, Throwable... throwables);
+}
diff --git a/org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/dump/JmxDumpContributionParticipant.java b/org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/dump/JmxDumpContributionParticipant.java
new file mode 100644
index 0000000..28a897d
--- /dev/null
+++ b/org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/dump/JmxDumpContributionParticipant.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.medic.dump;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.management.DescriptorKey;
+
+/**
+ * Indicates that this MBean should be treated as a JmxDumpContributionParticipant
+ * <p />
+ *
+ */
+@Documented
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface JmxDumpContributionParticipant {
+
+ @DescriptorKey("jmxDumpContributionParticipant")
+ boolean value() default true;
+}
diff --git a/org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/eventlog/EventLogger.java b/org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/eventlog/EventLogger.java
new file mode 100644
index 0000000..8e09071
--- /dev/null
+++ b/org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/eventlog/EventLogger.java
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.medic.eventlog;
+
+import java.util.ResourceBundle;
+
+/**
+ * An <code>EventLogger</code> provides support for logging events as human-readable, potentially internationalized,
+ * messages identified by a unique code.
+ * <p />
+ * An <code>EventLogger</code> instance can be obtained directly from the service registry. Such instances will search
+ * the <code>Bundle</code> that obtained the instance, and the <code>EventLogger</code> implementations <code>Bundle</code>
+ * for a properties file that contains entry for the an event's code. The implementation bundle is searched to support
+ * providing properties files in fragment bundles which are attached to the implementation.
+ * <p />
+ * Alternatively, an <code>EventLogger</code> can be obtained from an {@link EventLoggerFactory} allowing a specific
+ * <code>Bundle</code> to be supplied that will be used to search for properties files.
+ * <p />
+ * The algorithm used to find properties files matches that described in
+ * {@link ResourceBundle#getBundle(String, java.util.Locale, ClassLoader) ResourceBundle}, with the exception that no
+ * searching for class files is performed.
+ * <p />
+ * <strong>Concurrent Semantics</strong><br />
+ * Implementations <strong>must</strong> be thread-safe.
+ */
+public interface EventLogger {
+
+ /**
+ * Logs an event in the form of a message identified by the supplied code. The message is resolved by searching the
+ * available {@link ResourceBundle ResourceBundles} for an entry with the key that matches the code.
+ *
+ * The event is logged at the supplied level, with the supplied inserts being applied to the message.
+ *
+ * @param code The code of the message to be logged
+ * @param level The level at which the event should be logged
+ * @param inserts The inserts for the message
+ */
+ void log(String code, Level level, Object... inserts);
+
+ /**
+ * Logs an event in the form of a message identified by the supplied code. The message is resolved by searching the
+ * available {@link ResourceBundle ResourceBundles} for an entry with the key that matches the code.
+ *
+ * The event is logged at the supplied level, with the supplied inserts being applied to the message.
+ *
+ * @param logEvent The log event to be logged
+ * @param inserts The inserts for the message
+ */
+ void log(LogEvent logEvent, Object... inserts);
+
+ /**
+ * Logs an event in the form of a message identified by the supplied code. The message is resolved by searching the
+ * available {@link ResourceBundle ResourceBundles} for an entry with the key that matches the code.
+ *
+ * The event is logged at the supplied level, with the supplied inserts being applied to the message. The supplied
+ * <code>Throwable</code> is logged with the message.
+ *
+ * @param code The code of the message to be logged
+ * @param level The level at which the event should be logged
+ * @param throwable The <code>Throwable</code> to be logged
+ * @param inserts The inserts for the message
+ */
+ void log(String code, Level level, Throwable throwable, Object... inserts);
+
+ /**
+ * Logs an event in the form of a message identified by the supplied code. The message is resolved by searching the
+ * available {@link ResourceBundle ResourceBundles} for an entry with the key that matches the code.
+ *
+ * The event is logged at the supplied level, with the supplied inserts being applied to the message. The supplied
+ * <code>Throwable</code> is logged with the message.
+ *
+ * @param logEvent The log event to be logged
+ * @param throwable The <code>Throwable</code> to be logged
+ * @param inserts The inserts for the message
+ */
+ void log(LogEvent logEvent, Throwable throwable, Object... inserts);
+}
diff --git a/org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/eventlog/EventLoggerFactory.java b/org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/eventlog/EventLoggerFactory.java
new file mode 100644
index 0000000..da99120
--- /dev/null
+++ b/org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/eventlog/EventLoggerFactory.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.medic.eventlog;
+
+import java.util.ResourceBundle;
+
+import org.osgi.framework.Bundle;
+
+/**
+ * An <code>EventLoggerFactory</code> is used to create an <code>EventLogger</code> instance that will search a specific
+ * bundle, in addition to the EventLogger implementation's bundle, for {@link ResourceBundle ResourceBundles}.
+ * <p />
+ * <strong>Concurrent Semantics</strong><br />
+ * Implementations <strong>must</strong> be thread-safe.
+ */
+public interface EventLoggerFactory {
+
+ /**
+ * Creates a new <code>EventLogger</code> that will search the supplied bundle, in addition to the
+ * <code>EventLogger</code> implementation's bundle, for {@link ResourceBundle ResourceBundles}.
+ *
+ * @param bundle The <code>Bundle</code> to search for <code>ResourceBundle</code>s.
+ *
+ * @return The <code>EventLogger</code>
+ */
+ public EventLogger createEventLogger(Bundle bundle);
+}
diff --git a/org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/eventlog/Level.java b/org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/eventlog/Level.java
new file mode 100644
index 0000000..b8d9eae
--- /dev/null
+++ b/org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/eventlog/Level.java
@@ -0,0 +1,16 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.medic.eventlog;
+
+public enum Level {
+ ERROR, WARNING, INFO
+}
diff --git a/org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/eventlog/LogEvent.java b/org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/eventlog/LogEvent.java
new file mode 100644
index 0000000..3387160
--- /dev/null
+++ b/org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/eventlog/LogEvent.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.medic.eventlog;
+
+/**
+ * A <code>LogEvent</code> encapsulates the details of an event that is to be logged.
+ * <p/>
+ *
+ * <strong>Concurrent Semantics</strong><br />
+ * Implementations <strong>must</strong> be thread-safe.
+ *
+ */
+public interface LogEvent {
+
+ /**
+ * Returns the code that uniquely identifies this <code>LogEvent</code>. Typically, this code is used to locate the
+ * message for the event in a resource bundle.
+ *
+ * @return The event's code
+ */
+ public String getEventCode();
+
+ /**
+ * Returns the {@link Level} at which this <code>LogEvent</code> should be published.
+ *
+ * @return The level of the event.
+ */
+ public Level getLevel();
+}
diff --git a/org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/log/ConfigurationPublicationFailedException.java b/org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/log/ConfigurationPublicationFailedException.java
new file mode 100644
index 0000000..e2bbf0e
--- /dev/null
+++ b/org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/log/ConfigurationPublicationFailedException.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.medic.log;
+
+/**
+ * Thrown by {@link LoggingConfigurationPublisher} when a request to publish logging configuration fails.
+ */
+public class ConfigurationPublicationFailedException extends Exception {
+
+ private static final long serialVersionUID = 4317804271280636565L;
+
+ /**
+ * Creates a new exception with the supplied message and cause.
+ *
+ * @param message The exception's message
+ * @param cause The exception's cause
+ */
+ public ConfigurationPublicationFailedException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/log/DelegatingPrintStream.java b/org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/log/DelegatingPrintStream.java
new file mode 100644
index 0000000..131f597
--- /dev/null
+++ b/org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/log/DelegatingPrintStream.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.medic.log;
+
+import java.io.PrintStream;
+
+/**
+ * A <code>DelegatingPrintStream</code> is a {@link PrintStream} implementation that delegates to another
+ * {@link PrintStream} instance and allows the delegate to be changed at runtime.
+ * <p />
+ *
+ * <strong>Concurrent Semantics</strong><br />
+ * Thread-safe.
+ *
+ */
+public interface DelegatingPrintStream {
+
+ /**
+ * Sets the {@link PrintStream} to be used as a delegate. The given <code>printStream</code> may be
+ * <code>null</code> to disable delegation.
+ *
+ * @param printStream The delegate, or <code>null</code> to disable delegation.
+ */
+ void setDelegate(PrintStream printStream);
+}
diff --git a/org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/log/EntryExitTrace.aj b/org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/log/EntryExitTrace.aj
new file mode 100644
index 0000000..ed2b3aa
--- /dev/null
+++ b/org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/log/EntryExitTrace.aj
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.medic.log;
+
+import org.aspectj.lang.JoinPoint;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * An aspect that will advise any method with entry and exit trace logging.
+ *
+ * <strong>Concurrent Semantics</strong><br />
+ *
+ * Threadsafe
+ *
+ */
+public aspect EntryExitTrace pertypewithin(*) {
+
+ private volatile Logger logger;
+
+ pointcut medic() : within(org.eclipse.virgo.medic..*);
+
+ pointcut logback() : within(ch.qos.logback..*) || within(org.slf4j.impl..*);
+
+ pointcut infoCandidate() : execution(public * *(..)) && !medic() && !logback();
+
+ pointcut debugCandidate() : execution(!public !private * *(..)) && !medic() && !logback();
+
+ pointcut traceCandidate() : execution(private * *(..)) && !medic() && !logback();
+
+ before() : infoCandidate() {
+ getLogger(thisJoinPointStaticPart).info("{} {}", ">", getSignature(thisJoinPointStaticPart));
+ }
+
+ after() returning : infoCandidate() {
+ getLogger(thisJoinPointStaticPart).info("{} {}", "<", getSignature(thisJoinPointStaticPart));
+ }
+
+ after() throwing(Throwable t) : infoCandidate() {
+ Logger logger = getLogger(thisJoinPointStaticPart);
+ if (logger.isInfoEnabled()) {
+ logger.info(String.format("< %s", getSignature(thisJoinPointStaticPart)), t);
+ }
+ }
+
+ before() : debugCandidate() {
+ getLogger(thisJoinPointStaticPart).debug("{} {}", ">", getSignature(thisJoinPointStaticPart));
+ }
+
+ after() returning : debugCandidate() {
+ getLogger(thisJoinPointStaticPart).debug("{} {}", "<", getSignature(thisJoinPointStaticPart));
+ }
+
+ after() throwing(Throwable t) : debugCandidate() {
+ Logger logger = getLogger(thisJoinPointStaticPart);
+ if (logger.isDebugEnabled()) {
+ logger.debug(String.format("< %s", getSignature(thisJoinPointStaticPart)), t);
+ }
+ }
+
+ before() : traceCandidate() {
+ getLogger(thisJoinPointStaticPart).trace("{} {}", ">", getSignature(thisJoinPointStaticPart));
+ }
+
+ after() returning : traceCandidate() {
+ getLogger(thisJoinPointStaticPart).trace("{} {}", "<", getSignature(thisJoinPointStaticPart));
+ }
+
+ after() throwing(Throwable t) : traceCandidate() {
+ Logger logger = getLogger(thisJoinPointStaticPart);
+ if (logger.isTraceEnabled()) {
+ logger.trace(String.format("< %s", getSignature(thisJoinPointStaticPart)), t);
+ }
+ }
+
+ private Logger getLogger(JoinPoint.StaticPart sp) {
+ if (this.logger == null) {
+ this.logger = LoggerFactory.getLogger(sp.getSignature().getDeclaringType());
+ }
+ return this.logger;
+ }
+
+ private String getSignature(JoinPoint.StaticPart sp) {
+ return sp.getSignature().toLongString();
+ }
+}
diff --git a/org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/log/LoggingConfiguration.java b/org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/log/LoggingConfiguration.java
new file mode 100644
index 0000000..4156c90
--- /dev/null
+++ b/org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/log/LoggingConfiguration.java
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.medic.log;
+
+public interface LoggingConfiguration {
+
+ String getConfiguration();
+
+ String getName();
+}
diff --git a/org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/log/LoggingConfigurationPublisher.java b/org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/log/LoggingConfigurationPublisher.java
new file mode 100644
index 0000000..e0d3c90
--- /dev/null
+++ b/org.eclipse.virgo.medic.testfragment/src/main/java/org/eclipse/virgo/medic/log/LoggingConfigurationPublisher.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2010 VMware Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VMware Inc. - initial contribution
+ *******************************************************************************/
+
+package org.eclipse.virgo.medic.log;
+
+import java.io.File;
+
+/**
+ * A <code>LoggingConfigurationPublisher</code> is used to publish {@link LoggingConfiguration} into the service
+ * registry. <code>LoggingConfiguration</code> instances in the service registry are referenced by bundles using the
+ * <code>Medic-LoggingConfiguration</code> manifest header.
+ */
+public interface LoggingConfigurationPublisher {
+
+ /**
+ * Publishes the configuration in the supplied <code>File</code> as a <code>LoggingConfiguration</code> instance,
+ * identified with the supplied id. The published configuration can then be referenced by a bundle using the
+ * <code>Medic-LoggingConfiguration</code> manifest header with a value equal to the supplied id.
+ *
+ * @param configuration The configuration to be published
+ * @param id The identifier to be applied to the configuration when its published
+ *
+ * @throws ConfigurationPublicationFailedException if the publication of the configuration fails
+ */
+ void publishConfiguration(File configuration, String id) throws ConfigurationPublicationFailedException;
+}
diff --git a/org.eclipse.virgo.medic.testfragment/src/main/resources/.gitignore b/org.eclipse.virgo.medic.testfragment/src/main/resources/.gitignore
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/org.eclipse.virgo.medic.testfragment/src/main/resources/.gitignore
diff --git a/org.eclipse.virgo.medic.testfragment/src/test/java/.gitignore b/org.eclipse.virgo.medic.testfragment/src/test/java/.gitignore
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/org.eclipse.virgo.medic.testfragment/src/test/java/.gitignore
diff --git a/org.eclipse.virgo.medic.testfragment/src/test/resources/.gitignore b/org.eclipse.virgo.medic.testfragment/src/test/resources/.gitignore
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/org.eclipse.virgo.medic.testfragment/src/test/resources/.gitignore
diff --git a/org.eclipse.virgo.medic.testfragment/template.mf b/org.eclipse.virgo.medic.testfragment/template.mf
new file mode 100644
index 0000000..36875d2
--- /dev/null
+++ b/org.eclipse.virgo.medic.testfragment/template.mf
@@ -0,0 +1,13 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: org.eclipse.virgo.medic.testfragment
+Bundle-Vendor: SpringSource Inc.
+Import-Template:
+ org.aspectj.lang.*;version="${org.aspectj:[=.=.= , +1.0.0)}",
+ javax.management.*;version="0",
+ org.osgi.framework;version="0",
+ org.slf4j.*;version="${org.slf4j:[=.=.=, =.+1.0)}"
+Bundle-Version: 1.0.0
+Bundle-Name: Medic API
+Excluded-Imports:
+ ch.qos.logback.classic.*

Back to the top