You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by cw...@apache.org on 2009/09/02 17:26:23 UTC

svn commit: r810564 - in /incubator/uima/uima-as/trunk/uimaj-as-jms/src/main/java/org/apache/uima/jms/error/handler: InvalidJMSMessageHandler.java JMSExceptionHandler.java

Author: cwiklik
Date: Wed Sep  2 15:26:23 2009
New Revision: 810564

URL: http://svn.apache.org/viewvc?rev=810564&view=rev
Log:
UIMA-1541 Reformatted to conform to UIMA formatting guidelines. No other changes included.

Modified:
    incubator/uima/uima-as/trunk/uimaj-as-jms/src/main/java/org/apache/uima/jms/error/handler/InvalidJMSMessageHandler.java
    incubator/uima/uima-as/trunk/uimaj-as-jms/src/main/java/org/apache/uima/jms/error/handler/JMSExceptionHandler.java

Modified: incubator/uima/uima-as/trunk/uimaj-as-jms/src/main/java/org/apache/uima/jms/error/handler/InvalidJMSMessageHandler.java
URL: http://svn.apache.org/viewvc/incubator/uima/uima-as/trunk/uimaj-as-jms/src/main/java/org/apache/uima/jms/error/handler/InvalidJMSMessageHandler.java?rev=810564&r1=810563&r2=810564&view=diff
==============================================================================
--- incubator/uima/uima-as/trunk/uimaj-as-jms/src/main/java/org/apache/uima/jms/error/handler/InvalidJMSMessageHandler.java (original)
+++ incubator/uima/uima-as/trunk/uimaj-as-jms/src/main/java/org/apache/uima/jms/error/handler/InvalidJMSMessageHandler.java Wed Sep  2 15:26:23 2009
@@ -33,35 +33,31 @@
 import org.apache.uima.adapter.jms.JmsConstants;
 import org.apache.uima.util.Level;
 
-public class InvalidJMSMessageHandler extends ErrorHandlerBase implements ErrorHandler
-{
-	private static final Class CLASS_NAME = InvalidJMSMessageHandler.class;
+public class InvalidJMSMessageHandler extends ErrorHandlerBase implements ErrorHandler {
+  private static final Class CLASS_NAME = InvalidJMSMessageHandler.class;
 
-	public InvalidJMSMessageHandler( Map anEndpointThreasholdMap )
-	{
-		super(anEndpointThreasholdMap);
-	}
-	public InvalidJMSMessageHandler( )
-	{
-	}
-	public boolean handleError(Throwable t, ErrorContext anErrorContext, AnalysisEngineController aController)
-	{
-		if (t instanceof InvalidMessageException )
-		{
+  public InvalidJMSMessageHandler(Map anEndpointThreasholdMap) {
+    super(anEndpointThreasholdMap);
+  }
+
+  public InvalidJMSMessageHandler() {
+  }
+
+  public boolean handleError(Throwable t, ErrorContext anErrorContext,
+          AnalysisEngineController aController) {
+    if (t instanceof InvalidMessageException) {
       if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.INFO)) {
-        UIMAFramework.getLogger(CLASS_NAME).logrb(Level.INFO, CLASS_NAME.getName(),
-	                "handleError", JmsConstants.JMS_LOG_RESOURCE_BUNDLE, "UIMAJMS_handling_invalid_jms_message__INFO",
-	                new Object[] {});
+        UIMAFramework.getLogger(CLASS_NAME).logrb(Level.INFO, CLASS_NAME.getName(), "handleError",
+                JmsConstants.JMS_LOG_RESOURCE_BUNDLE, "UIMAJMS_handling_invalid_jms_message__INFO",
+                new Object[] {});
+      }
+      if (anErrorContext.containsKey(UIMAMessage.RawMsg)) {
+
+        Message invalidMessage = (Message) anErrorContext.get(UIMAMessage.RawMsg);
+        // Handle the message here.
       }
-			if ( anErrorContext.containsKey(UIMAMessage.RawMsg ))
-			{
-				
-				
-				Message invalidMessage = (Message)anErrorContext.get(UIMAMessage.RawMsg);
-				//	Handle the message here.
-			}
-			return true;
-		}
-		return false;
-	}
+      return true;
+    }
+    return false;
+  }
 }

Modified: incubator/uima/uima-as/trunk/uimaj-as-jms/src/main/java/org/apache/uima/jms/error/handler/JMSExceptionHandler.java
URL: http://svn.apache.org/viewvc/incubator/uima/uima-as/trunk/uimaj-as-jms/src/main/java/org/apache/uima/jms/error/handler/JMSExceptionHandler.java?rev=810564&r1=810563&r2=810564&view=diff
==============================================================================
--- incubator/uima/uima-as/trunk/uimaj-as-jms/src/main/java/org/apache/uima/jms/error/handler/JMSExceptionHandler.java (original)
+++ incubator/uima/uima-as/trunk/uimaj-as-jms/src/main/java/org/apache/uima/jms/error/handler/JMSExceptionHandler.java Wed Sep  2 15:26:23 2009
@@ -34,76 +34,61 @@
 import org.apache.uima.aae.error.ErrorHandlerBase;
 import org.apache.uima.aae.message.AsynchAEMessage;
 
-public class JMSExceptionHandler extends ErrorHandlerBase implements ErrorHandler
-{
-	public boolean handleError(Throwable t, ErrorContext anErrorContext, AnalysisEngineController aController)
-	{
-		if ( t instanceof JMSException )
-		{
-			
-			Throwable cause = t.getCause();
-			boolean handled = false;
-			if ( cause != null )
-			{
-				if ( cause instanceof ConnectException )
-				{
-					handleConnectError((ConnectException)cause, anErrorContext, aController);
-					handled = true;
-				}
-			}
-			if ( !handled )
-			{
-				if ( cause == null )
-				{
-					System.out.println("No Handler for JMS Exception Cause ::"+t.getLocalizedMessage());
-				}
-				else
-				{
-					System.out.println("No Handler for JMS Exception Cause ::"+cause.getLocalizedMessage());
-				}
-				t.printStackTrace();
-				
-			}
-			return true;
-		}
-		else if (t instanceof  java.lang.IllegalArgumentException &&
-			t.getCause() != null && t.getCause() instanceof java.net.URISyntaxException)
-		{
-			//	 Handled invalid syntax in the URI
-			System.out.println("Invalid JMS Destination::"+t.getMessage());
-			return true;
-		}
-		return false;
-	}
-
-	private void handleConnectError( ConnectException exception, ErrorContext anErrorContext, AnalysisEngineController aController)
-	{
-		System.out.println("Handling JMS Connect Exception Due To::"+exception.getLocalizedMessage());
-		System.out.println("Exception Cause::"+exception.getClass().getName()+":::Message::"+exception.getLocalizedMessage());
-		
-		String casReferenceId = (String)anErrorContext.get(AsynchAEMessage.CasReference);
-		Endpoint endpoint = (Endpoint)anErrorContext.get(AsynchAEMessage.Endpoint);
-		
-		//	If this is a PrimitiveController and not collocated with its aggregate
-		//	drop the CAS
-		if ( !( aController instanceof AggregateAnalysisEngineController ) )
-		{
-			CacheEntry entry = null;
-			
-			try
-			{
-				entry = aController.getInProcessCache().getCacheEntryForCAS(casReferenceId);
-				if ( endpoint.isRemote() && entry != null )
-				{
-					aController.dropCAS(casReferenceId, true );
-				}
-			}
-			catch( AsynchAEException e) 
-			{
-				System.out.println("Cas:"+casReferenceId+" Not Found In the Cache.");
-			}
-		}
-	}
-	
+public class JMSExceptionHandler extends ErrorHandlerBase implements ErrorHandler {
+  public boolean handleError(Throwable t, ErrorContext anErrorContext,
+          AnalysisEngineController aController) {
+    if (t instanceof JMSException) {
+
+      Throwable cause = t.getCause();
+      boolean handled = false;
+      if (cause != null) {
+        if (cause instanceof ConnectException) {
+          handleConnectError((ConnectException) cause, anErrorContext, aController);
+          handled = true;
+        }
+      }
+      if (!handled) {
+        if (cause == null) {
+          System.out.println("No Handler for JMS Exception Cause ::" + t.getLocalizedMessage());
+        } else {
+          System.out.println("No Handler for JMS Exception Cause ::" + cause.getLocalizedMessage());
+        }
+        t.printStackTrace();
+
+      }
+      return true;
+    } else if (t instanceof java.lang.IllegalArgumentException && t.getCause() != null
+            && t.getCause() instanceof java.net.URISyntaxException) {
+      // Handled invalid syntax in the URI
+      System.out.println("Invalid JMS Destination::" + t.getMessage());
+      return true;
+    }
+    return false;
+  }
+
+  private void handleConnectError(ConnectException exception, ErrorContext anErrorContext,
+          AnalysisEngineController aController) {
+    System.out.println("Handling JMS Connect Exception Due To::" + exception.getLocalizedMessage());
+    System.out.println("Exception Cause::" + exception.getClass().getName() + ":::Message::"
+            + exception.getLocalizedMessage());
+
+    String casReferenceId = (String) anErrorContext.get(AsynchAEMessage.CasReference);
+    Endpoint endpoint = (Endpoint) anErrorContext.get(AsynchAEMessage.Endpoint);
+
+    // If this is a PrimitiveController and not collocated with its aggregate
+    // drop the CAS
+    if (!(aController instanceof AggregateAnalysisEngineController)) {
+      CacheEntry entry = null;
+
+      try {
+        entry = aController.getInProcessCache().getCacheEntryForCAS(casReferenceId);
+        if (endpoint.isRemote() && entry != null) {
+          aController.dropCAS(casReferenceId, true);
+        }
+      } catch (AsynchAEException e) {
+        System.out.println("Cas:" + casReferenceId + " Not Found In the Cache.");
+      }
+    }
+  }
 
 }