View Javadoc
1   /**
2    * Copyright 2005-2013 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.ksb.messaging.remotedservices;
17  
18  import java.io.Serializable;
19  
20  import org.kuali.rice.core.api.config.CoreConfigHelper;
21  import org.kuali.rice.ksb.messaging.service.KSBJavaService;
22  
23  
24  public class TestHarnessSharedTopic implements KSBJavaService {
25  
26      public static int CALL_COUNT = 0;
27      public static int CALL_COUNT_NOTIFICATION_THRESHOLD = 0;
28      public static Object LOCK = new Object();
29  
30      public synchronized void invoke(Serializable payLoad) {
31              CALL_COUNT++;
32          System.out.println("!!!TestHarnessSharedTopic called with M.E " + CoreConfigHelper.getApplicationId() + " !!! ");
33          ServiceCallInformationHolder.stuff.put("TestHarnessCalled", Boolean.TRUE);
34          if (CALL_COUNT_NOTIFICATION_THRESHOLD > 0) {
35              if (CALL_COUNT == CALL_COUNT_NOTIFICATION_THRESHOLD) {
36              notifyOnLock();
37              }
38          } else {
39              notifyOnLock();
40          }
41  
42  
43      }
44      
45      public void notifyOnLock() {
46          synchronized (LOCK) {
47              LOCK.notifyAll();
48          }
49      }
50  
51  }