001: /**********************************************************************************
002: * $URL: https://source.sakaiproject.org/svn/velocity/tags/sakai_2-4-1/tool/src/java/org/sakaiproject/cheftool/ControllerState.java $
003: * $Id: ControllerState.java 7247 2006-03-29 21:09:51Z ggolden@umich.edu $
004: ***********************************************************************************
005: *
006: * Copyright (c) 2003, 2004, 2005, 2006 The Sakai Foundation.
007: *
008: * Licensed under the Educational Community License, Version 1.0 (the "License");
009: * you may not use this file except in compliance with the License.
010: * You may obtain a copy of the License at
011: *
012: * http://www.opensource.org/licenses/ecl1.php
013: *
014: * Unless required by applicable law or agreed to in writing, software
015: * distributed under the License is distributed on an "AS IS" BASIS,
016: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: * See the License for the specific language governing permissions and
018: * limitations under the License.
019: *
020: **********************************************************************************/package org.sakaiproject.cheftool;
021:
022: import java.util.Observable;
023: import java.util.Observer;
024:
025: /**
026: * <p>
027: * ControllerState is the core base class for the CHEF Tool's state objects.
028: * </p>
029: * <p>
030: * State objects are used to store controller state for a tool. Specific state object implement this interface.
031: * </p>
032: * <p>
033: * To support creation of controller state objects, make sure to supply a void constructor.
034: * </p>
035: * <p>
036: * To support pooling of objects, implement the recycle() method to release any resources and restore the object to initial conditions before reuse.
037: * </p>
038: */
039: public abstract class ControllerState implements Observer {
040: /**
041: * Init to startup values
042: */
043: protected void init() {
044: } // init
045:
046: /**
047: * Release any resources and restore the object to initial conditions to be reused.
048: */
049: public void recycle() {
050: m_id = "";
051: m_setId = "";
052:
053: init();
054:
055: } // recycle
056:
057: /** This state's unique id (unique within the set) */
058: private String m_id = "";
059:
060: public String getId() {
061: return m_id;
062: }
063:
064: public void setId(String id) {
065: m_id = id;
066: }
067:
068: /** This state's set unique id */
069: private String m_setId = "";
070:
071: public String getSetId() {
072: return m_setId;
073: }
074:
075: public void setSetId(String id) {
076: m_setId = id;
077: }
078:
079: /**
080: * Access a unique key for this state, combining the set id and the state id.
081: *
082: * @return A unique key for this state, combining the set id and the state id.
083: */
084: public String getKey() {
085: return m_setId + m_id;
086:
087: } // getKey
088:
089: /**********************************************************************************************************************************************************************************************************************************************************
090: * Observer implementation
091: *********************************************************************************************************************************************************************************************************************************************************/
092:
093: /**
094: * This method is called whenever the observed object is changed. An application calls an <tt>Observable</tt> object's <code>notifyObservers</code> method to have all the object's observers notified of the change. default implementation is to
095: * cause the courier service to deliver to the interface controlled by my controller. Extensions can override.
096: *
097: * @param o
098: * the observable object.
099: * @param arg
100: * an argument passed to the <code>notifyObservers</code> method.
101: */
102: public void update(Observable o, Object arg) {
103: // Log.debug("chef", this + ".update: " + arg.toString());
104: //
105: // CourierService.deliver(getSetId(), getId());
106:
107: } // update
108:
109: } // ControllerState
|