Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: edu/iicm/xpg/transitions/ClassLoaderTransition.java


1   /***********************************************************************
2    * @(#)$RCSfile: ClassLoaderTransition.java,v $   $Revision: 1.6 $ $Date: 2002/05/21 16:59:30 $
3    *
4    * Copyright (c) 2001 IICM, Graz University of Technology
5    * Schiesstattgasse 4a, A-8010 Graz, Austria.
6    *
7    * This program is free software; you can redistribute it and/or modify
8    * it under the terms of the GNU Lesser General Public License (LGPL)
9    * as published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This program is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   * GNU Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this program; if not, write to the
19   * Free Software Foundation, Inc.,
20   * 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
21   ***********************************************************************/
22  
23  
24  package edu.iicm.xpg.transitions;
25  
26  import edu.iicm.xpg.statemachine.Transition;
27  import edu.iicm.xpg.statemachine.TransitionException;
28  import edu.iicm.xpg.statemachine.StateMachine;
29  import edu.iicm.xpg.statemachine.Input;
30  import edu.iicm.xpg.statemachine.State;
31  import edu.iicm.xpg.statemachine.DataObject;
32  
33  import edu.iicm.xpg.util.Factory;
34  import java.io.IOException;
35  
36  //----------------------------------------------------------------------
37  /**
38   * @author Günther Brand
39   * @version $Revision: 1.6 $
40   */
41  
42  public class ClassLoaderTransition implements Transition
43  {
44      protected Factory transition_factory_;
45      protected String classname_;
46  
47      // FIXXME ??
48    public ClassLoaderTransition( Factory transition_factory, String classname )
49        throws IllegalArgumentException
50    {
51        if (transition_factory == null || classname == null)
52        {
53      throw (new IllegalArgumentException
54          ("Factory or classname in ClassLoaderTransition is null!"));
55        }
56        classname_ = classname;
57        transition_factory_ = transition_factory;
58    }
59  
60  //----------------------------------------------------------------------
61  /**
62   * @param input the input that triggered this transition
63   * @param from_state the start state for this transition
64   * @param to_state the destination state for this transition
65   * @param machine the state machine that this transition belongs to
66   * @param data user defined data
67   * @return
68   * @exception TransitionException whatever an implementation can throw
69   */
70  
71    public String transitionTriggered(Input input,State from_state,State to_state,
72                                      StateMachine machine,DataObject data)
73      throws TransitionException
74    {
75      Transition transition = null;
76          try 
77          {
78           transition= (Transition)transition_factory_.getInstance(classname_);
79          }
80          catch (ClassNotFoundException exc)
81          {
82            throw new TransitionException(exc);
83          }
84          catch (IOException exc)
85          {
86            throw new TransitionException(exc);
87          }
88  
89      transition.transitionTriggered(input, from_state, to_state, machine, data);
90  
91      return(null);
92    }
93  }
94  
95