##### Coverage Report - org.apache.commons.scxml.invoke.AsyncTrigger

Classes in this File | Line Coverage | Branch Coverage | Complexity
AsyncTrigger |
0% |
0% |
| 1.5;1.5

1 |  |
     /*
2 |  |
      * Licensed to the Apache Software Foundation (ASF) under one or more
3 |  |
      * contributor license agreements.  See the NOTICE file distributed with
4 |  |
      * this work for additional information regarding copyright ownership.
5 |  |
      * The ASF licenses this file to You under the Apache License, Version 2.0
6 |  |
      * (the "License"); you may not use this file except in compliance with
7 |  |
      * the License.  You may obtain a copy of the License at
8 |  |
      *
9 |  |
      *     http://www.apache.org/licenses/LICENSE-2.0
10 |  |
      *
11 |  |
      * Unless required by applicable law or agreed to in writing, software
12 |  |
      * distributed under the License is distributed on an "AS IS" BASIS,
13 |  |
      * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 |  |
      * See the License for the specific language governing permissions and
15 |  |
      * limitations under the License.
16 |  |
      */
17 |  |
     package org.apache.commons.scxml.invoke;
18 |  |
19 |  |
     import org.apache.commons.logging.Log;
20 |  |
     import org.apache.commons.logging.LogFactory;
21 |  |
     import org.apache.commons.scxml.SCXMLExecutor;
22 |  |
     import org.apache.commons.scxml.TriggerEvent;
23 |  |
     import org.apache.commons.scxml.model.ModelException;
24 |  |
25 |  |
     /**
26 |  |
      * Trigger the given {@link TriggerEvent} (or array of) on the given
27 |  |
      * state machine executor asynchronously, once.
28 |  |
      */
29 |  |
     class AsyncTrigger implements Runnable {
30 |  |
31 |  |
         /** The state machine executor. */
32 |  |
         private SCXMLExecutor executor;
33 |  |
         /** The event(s) to be triggered. */
34 |  |
         private TriggerEvent[] events;
35 |  |
         /** The log. */
36 | 0 |
         private Log log = LogFactory.getLog(AsyncTrigger.class);
37 |  |
38 |  |
         /**
39 |  |
          * Constructor.
40 |  |
          *
41 |  |
          * @param executor The {@link SCXMLExecutor} to trigger the event on.
42 |  |
          * @param event The {@link TriggerEvent}.
43 |  |
          */
44 | 0 |
         AsyncTrigger(final SCXMLExecutor executor, final TriggerEvent event) {
45 | 0 |
             this.executor = executor;
46 | 0 |
             this.events = new TriggerEvent[1];
47 | 0 |
             this.events[0] = event;
48 | 0 |
             new Thread(this).start();
49 | 0 |
         }
50 |  |
51 |  |
         /**
52 |  |
          * Fire the event(s).
53 |  |
          */
54 |  |
         public void run() {
55 |  |
             try {
56 | 0 |
                 synchronized (executor) {
57 | 0 |
                     executor.triggerEvents(events);
58 | 0 |
                 }
59 | 0 |
             } catch (ModelException me) {
60 | 0 |
                 log.error(me.getMessage(), me);
61 | 0 |
             }
62 | 0 |
         }
63 |  |
64 |  |
     }
65 |  |