View Javadoc

1   package org.apache.maven.werkz;
2   
3   /* ====================================================================
4    *   Licensed to the Apache Software Foundation (ASF) under one or more
5    *   contributor license agreements.  See the NOTICE file distributed with
6    *   this work for additional information regarding copyright ownership.
7    *   The ASF licenses this file to You under the Apache License, Version 2.0
8    *   (the "License"); you may not use this file except in compliance with
9    *   the License.  You may obtain a copy of the License at
10   *
11   *       http://www.apache.org/licenses/LICENSE-2.0
12   *
13   *   Unless required by applicable law or agreed to in writing, software
14   *   distributed under the License is distributed on an "AS IS" BASIS,
15   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   *   See the License for the specific language governing permissions and
17   *   limitations under the License.
18   * ====================================================================
19   */
20  
21  /*
22   $Id: Action.java 517014 2007-03-11 21:15:50Z ltheussl $
23  
24   Copyright 2002 (C) The Werken Company. All Rights Reserved.
25   
26   Redistribution and use of this software and associated documentation
27   ("Software"), with or without modification, are permitted provided
28   that the following conditions are met:
29  
30   1. Redistributions of source code must retain copyright
31   statements and notices.  Redistributions must also contain a
32   copy of this document.
33   
34   2. Redistributions in binary form must reproduce the
35   above copyright notice, this list of conditions and the
36   following disclaimer in the documentation and/or other
37   materials provided with the distribution.
38   
39   3. The name "werkz" must not be used to endorse or promote
40   products derived from this Software without prior written
41   permission of The Werken Company.  For written permission,
42   please contact bob@werken.com.
43   
44   4. Products derived from this Software may not be called "werkz"
45   nor may "werkz" appear in their names without prior written
46   permission of The Werken Company. "werkz" is a registered
47   trademark of The Werken Company.
48   
49   5. Due credit should be given to "the werkz project"
50   ( http://werkz.werken.com/ ).
51   
52   THIS SOFTWARE IS PROVIDED BY THE WERKEN COMPANY AND CONTRIBUTORS
53   ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
54   NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
55   FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
56   THE WERKEN COMPANY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
57   INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
58   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
59   SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
60   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
61   STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
62   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
63   OF THE POSSIBILITY OF SUCH DAMAGE.
64   
65   */
66  
67  /** Interface for goal-satisfying actions.
68   *
69   *  @see Goal
70   *  @see Goal#setAction
71   *  @see DefaultAction
72   *
73   *  @author <a href="mailto:bob@eng.werken.com">bob mcwhirter</a>
74   */
75  public interface Action
76  {
77      /** Determine if this <code>Action</code>'s {@link #performAction} method
78       *  should be invoked.
79       *  
80       *  <p>
81       *  This method is called after this <code>Goal</code>'s prerequisites
82       *  have been completely satisfied, and immediately before the possibility
83       *  of invoking <code>performAction()</code>.
84       *  </p>
85       *
86       *  <p>
87       *  If this method returns <code>true</code>, then this <code>Goal</code>'s
88       *  <code>performAction()</code> will be called in order to satisfy this
89       *  <code>Goal</code>.  If this method returns <code>false</code>, then
90       *  this <code>Goal</code> is considered satisfied without invoking the
91       *  <code>performAction()</code> method.
92       *  </p>
93       *
94       *  <p>
95       *  This method is the location to implement intra-goal dependency-checking.
96       *  </p>
97       *
98       *  @see #performAction
99       *
100      *  @return <code>true</code> if this <code>Goal</code>'s <code>performAction()</code>
101      *          method should be immediately invoked, otherwise <code>false</code>.
102      */
103     boolean requiresAction();
104 
105     /** Perform the action required to satisfy the <code>Goal</code>.
106      *
107      *  <p>
108      *  Once all prerequisites have been satisfied, the <code>Goal</code>'s
109      *  <code>performAction()</code> method may be invoked, depending on
110      *  the return value of {@link #requiresAction}, in order to satisfy
111      *  this <code>Goal</code>.
112      *
113      *  @throws Exception if an errors occurs during execution.
114      */
115     void performAction( Session session )
116         throws Exception;
117 }