Skip to content

Commit

Permalink
Set an ignore comment on the failing testcase. Ran PMD on the code to…
Browse files Browse the repository at this point in the history
… clean up some unused modifiers.
  • Loading branch information
lennartj committed Mar 23, 2013
1 parent 295dfd3 commit cb949a2
Show file tree
Hide file tree
Showing 39 changed files with 460 additions and 320 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# idea project settings #
*.iml
*.ipr
*.iws
.idea/*
.idea

# Package Files #
*.war
Expand Down
37 changes: 36 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
weak-references,
message filtering,
ordering of message handlers etc.

</description>

<url>https://github.com/bennidi/mbassador</url>
Expand All @@ -50,6 +49,10 @@
</developers>

<properties>
<nazgul-codestyle.version>2.0.1</nazgul-codestyle.version>
<jdk.version>1.6</jdk.version>
<pmd.plugin.version>3.0.1</pmd.plugin.version>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.java.version>1.6</project.build.java.version>
<github.url>file://${project.basedir}/mvn-local-repo</github.url>
Expand Down Expand Up @@ -77,6 +80,38 @@

<build>
<plugins>
<!-- plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>${pmd.plugin.version}</version>
<configuration>
<excludeRoots>
<excludeRoot>src/main/generated</excludeRoot>
<excludeRoot>src/test</excludeRoot>
</excludeRoots>
<rulesets>
<ruleset>/codestyle/pmd-rules.xml</ruleset>
</rulesets>
<targetJdk>${jdk.version}</targetJdk>
<sourceEncoding>${project.build.sourceEncoding}</sourceEncoding>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal>
<goal>cpd-check</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>se.jguru.nazgul.tools.codestyle</groupId>
<artifactId>nazgul-codestyle</artifactId>
<version>${nazgul-codestyle.version}</version>
</dependency>
</dependencies>
</plugin -->

<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
Expand Down
38 changes: 25 additions & 13 deletions src/main/java/net/engio/mbassy/IPublicationErrorHandler.java
Original file line number Diff line number Diff line change
@@ -1,32 +1,44 @@
package net.engio.mbassy;

/**
* Publication error handlers are provided with a publication error every time an error occurs during message publication.
* A handler might fail with an exception, not be accessible because of the presence of a security manager
* or other reasons might lead to failures during the message publication process.
*
* Publication error handlers are provided with a publication error every time an
* error occurs during message publication.
* A handler might fail with an exception, not be accessible because of the presence
* of a security manager or other reasons might lead to failures during the message publication process.
* <p/>
*
* @author bennidi
* Date: 2/22/12
* Date: 2/22/12
*/
@SuppressWarnings("PMD.UnusedModifier")
public interface IPublicationErrorHandler {

/**
* Handle the given publication error.
*
* @param error
* @param error The PublicationError to handle.
*/
public void handleError(PublicationError error);
void handleError(PublicationError error);

// This is the default error handler it will simply log to standard out and
// print stack trace if available
/**
* The default error handler will simply log to standard out and
* print the stack trace if available.
*/
static final class ConsoleLogger implements IPublicationErrorHandler {

/**
* {@inheritDoc}
*/
@Override
public void handleError(PublicationError error) {
public void handleError(final PublicationError error) {

// Printout the error itself
System.out.println(error);
if (error.getCause() != null) error.getCause().printStackTrace();

// Printout the stacktrace from the cause.
if (error.getCause() != null) {
error.getCause().printStackTrace();
}
}
}

;
}
147 changes: 87 additions & 60 deletions src/main/java/net/engio/mbassy/PublicationError.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,83 +3,110 @@
import java.lang.reflect.Method;

/**
* Publication errors are created when object publication fails for some reason and contain details
* as to the cause and location where they occured.
* Publication errors are created when object publication fails
* for some reason and contain details as to the cause and location
* where they occurred.
* <p/>
*
* @author bennidi
* Date: 2/22/12
* Time: 4:59 PM
* Date: 2/22/12
* Time: 4:59 PM
*/
public class PublicationError {

private Throwable cause;

private String message;

private Method listener;

private Object listeningObject;

private Object publishedObject;


public PublicationError(Throwable cause, String message, Method listener, Object listeningObject, Object publishedObject) {
this.cause = cause;
this.message = message;
this.listener = listener;
this.listeningObject = listeningObject;
this.publishedObject = publishedObject;
}
// Internal state
private Throwable cause;
private String message;
private Method listener;
private Object listeningObject;
private Object publishedObject;

/**
* Compound constructor, creating a PublicationError from the supplied objects.
*
* @param cause The Throwable giving rise to this PublicationError.
* @param message The message to send.
* @param listener The method where the error was created.
* @param listeningObject The object in which the PublicationError was generated.
* @param publishedObject The published object which gave rise to the error.
*/
public PublicationError(final Throwable cause,
final String message,
final Method listener,
final Object listeningObject,
final Object publishedObject) {

this.cause = cause;
this.message = message;
this.listener = listener;
this.listeningObject = listeningObject;
this.publishedObject = publishedObject;
}

public PublicationError(){
super();
}
/**
* Default constructor.
*/
public PublicationError() {
super();
}

public Throwable getCause() {
return cause;
}
/**
* @return The Throwable giving rise to this PublicationError.
*/
public Throwable getCause() {
return cause;
}

public PublicationError setCause(Throwable cause) {
this.cause = cause;
return this;
}
/**
* Assigns the cause of this PublicationError.
*
* @param cause A Throwable which gave rise to this PublicationError.
* @return This PublicationError.
*/
public PublicationError setCause(Throwable cause) {
this.cause = cause;
return this;
}

public String getMessage() {
return message;
}
public String getMessage() {
return message;
}

public PublicationError setMessage(String message) {
this.message = message;
return this;
}
public PublicationError setMessage(String message) {
this.message = message;
return this;
}

public Method getListener() {
return listener;
}
public Method getListener() {
return listener;
}

public PublicationError setListener(Method listener) {
this.listener = listener;
return this;
}
public PublicationError setListener(Method listener) {
this.listener = listener;
return this;
}

public Object getListeningObject() {
return listeningObject;
}
public Object getListeningObject() {
return listeningObject;
}

public PublicationError setListeningObject(Object listeningObject) {
this.listeningObject = listeningObject;
return this;
}
public PublicationError setListeningObject(Object listeningObject) {
this.listeningObject = listeningObject;
return this;
}

public Object getPublishedObject() {
return publishedObject;
}
public Object getPublishedObject() {
return publishedObject;
}

public PublicationError setPublishedObject(Object publishedObject) {
this.publishedObject = publishedObject;
return this;
}
public PublicationError setPublishedObject(Object publishedObject) {
this.publishedObject = publishedObject;
return this;
}

/**
* {@inheritDoc}
*/
@Override
public String toString() {
return "PublicationError{" +
Expand Down
Loading

0 comments on commit cb949a2

Please sign in to comment.