1   /*
2    * $Id: TestComponent.java 7963 2007-08-21 08:53:15Z dirk.olmes $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.providers.quartz;
12  
13  import org.mule.providers.NullPayload;
14  import org.mule.umo.UMOEventContext;
15  import org.mule.umo.lifecycle.Callable;
16  
17  import edu.emory.mathcs.backport.java.util.concurrent.CountDownLatch;
18  
19  public class TestComponent implements Callable
20  {
21      protected static final CountDownLatch QUARTZ_COUNTER = new CountDownLatch(4);
22  
23      public Object onCall(UMOEventContext eventContext) throws Exception
24      {
25          if (eventContext.getMessageAsString().equals("quartz test") ||
26              (eventContext.getMessage().getPayload() instanceof NullPayload )) 
27          {
28              if (QUARTZ_COUNTER != null)
29              {
30                  QUARTZ_COUNTER.countDown();
31              }
32              else
33              {
34                  throw new IllegalStateException("QuartzCounter is null!");
35              }
36          }
37          else
38          {
39              throw new IllegalArgumentException("Unrecognised event payload");
40          }
41          return null;
42      }
43  
44  }