2009/05/20 - Apache Shale has been retired.

For more information, please explore the Attic.

View Javadoc

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  
18  package org.apache.shale.examples.test.dialog.basic;
19  
20  import java.io.Serializable;
21  import org.apache.shale.dialog.base.AbstractDialogContextListener;
22  
23  /***
24   * <p>Test implementation of DialogContextListener.</p>
25   */
26  public class ContextListener extends AbstractDialogContextListener
27   implements Serializable {
28  
29  
30      public void onStart() {
31  
32          // Log the fact that we are processing this event
33          System.out.println("ContextListener.onStart(name="
34            + getDialogContext().getName() + ", id="
35            + getDialogContext().getId() + ")");
36  
37      }
38  
39  
40      public void onStop() {
41  
42          // Log the fact that we are processing this event
43          System.out.println("ContextListener.onStop(name="
44            + getDialogContext().getName() + ", id="
45            + getDialogContext().getId() + ")");
46  
47      }
48  
49  
50      public void onActivate() {
51  
52          // Log the fact that we are processing this event
53          System.out.println("ContextListener.onActivate(name="
54            + getDialogContext().getName() + ", id="
55            + getDialogContext().getId() + ")");
56  
57      }
58  
59  
60      public void onPassivate() {
61  
62          // Log the fact that we are processing this event
63          System.out.println("ContextListener.onPassivate(name="
64            + getDialogContext().getName() + ", id="
65            + getDialogContext().getId() + ")");
66  
67      }
68  
69  
70      public void onException(Exception e) {
71  
72          // Log the fact that we are processing this event
73          System.out.println("ContextListener.onException(name="
74            + getDialogContext().getName() + ", id="
75            + getDialogContext().getId() + ")");
76          e.printStackTrace(System.out);
77  
78          // In a real application, you might also want to modify some
79          // state in your "data" property to reflect the fact that an
80          // exception occurred
81  
82      }
83  
84  
85      public void onEntry(String stateId) {
86  
87          // Log the fact that we are processing this event
88          System.out.println("ContextListener.onEntry(name="
89            + getDialogContext().getName() + ", id="
90            + getDialogContext().getId() + ", stateId="
91            + stateId + ")");
92  
93          // In a real application, you might also want to record the
94          // fact that this state was just entered
95  
96      }
97  
98  
99      public void onExit(String stateId) {
100 
101         // Log the fact that we are processing this event
102         System.out.println("ContextListener.onExit(name="
103           + getDialogContext().getName() + ", id="
104           + getDialogContext().getId() + ", stateId="
105           + stateId + ")");
106 
107     }
108 
109 
110     public void onTransition(String fromStateId, String toStateId) {
111 
112         // Log the fact that we are processing this event
113         System.out.println("ContextListener.onEntry(name="
114           + getDialogContext().getName() + ", id="
115           + getDialogContext().getId() + ", fromStateId="
116           + fromStateId + ", toStateId=" + toStateId + ")");
117 
118     }
119 
120 
121 }