001    /*
002     * Copyright 2001,2004 The Apache Software Foundation.
003     * 
004     * Licensed under the Apache License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     * 
008     *      http://www.apache.org/licenses/LICENSE-2.0
009     * 
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    
017    package org.apache.commons.scaffold.util;
018    
019    
020    import java.util.Locale;
021    
022    
023    /**
024     * Simple helper bean that can be used to encapsulate a method
025     * representing a business process.
026     * <p>
027     * The business logic should be implemented in one of the supplied
028     * execute methods, or by another method called by one of these.
029     * A concrete subclass may return a default scope and attribute
030     * name to use when storing the bean (if applicable).
031     * <p>
032     * The preferred approach is to implement the <code>Object
033     * execute(Object)</code> signature, and use execute() to pass
034     * null, some other default value. If a default value is not
035     * possible, it is recommended that <code>execute() throw an
036     * or throw a UnsupportedOperationException.
037     * <p>
038     * Known implementations: BusinessBeanBase.
039     * @author Ted Husted
040     * @version $Revision: 155464 $ $Date: 2005-02-26 13:26:54 +0000 (Sat, 26 Feb 2005) $
041     */
042    public interface ProcessBean {
043    
044    // --------------------------------------------------------- Properties
045    
046        /**
047         * The session attribute key for our user profile bean ["userProfile"].
048         */
049        public static String USER_PROFILE_KEY = "userProfile";
050    
051    
052        /**
053         * Return the locale for this bean instance.
054         *
055         * @return the locale
056         */
057        public Locale getLocale();
058    
059    
060        /**
061         * Set the locale for this bean instance.
062         *
063         * @param locale The new locale
064         */
065        public void setLocale(Locale locale);
066    
067    
068        /**
069         * Return the network address of the client for this bean instance.
070         * <p>
071         * @return the network address.
072         */
073        public Integer getRemoteNode();
074    
075    
076        /**
077         * Set the network address of the client for this bean instance.
078         * @param remoteNode The new remoteNode.
079         */
080        public void setRemoteNode(Integer remoteNode);
081    
082    
083        /**
084         * The remote server object for this bean instance, if any.
085         * <p>
086         * This is often an application-scope object that can be used
087         * to process a JDBC query or equivalent.
088         * By default, the <code>ProcessAction</code> will set this to any
089         * application scope object found under the key
090         * <code>BaseAction.REMOTE_SERVER</code> or to null.
091         *
092         * @return the remote server
093         */
094        public Object getRemoteServer();
095    
096    
097        /**
098         * Set the remote server
099         *
100         * @param server The new server
101         */
102        public void setRemoteServer(Object server);
103    
104    
105        /**
106         * Return the parameter.
107         */
108        public String getParameter();
109    
110    
111        /**
112         * Set the parameter.
113         * @param parameter The new parameter
114         */
115        public void setParameter(String parameter);
116        
117    
118    // ------------------------------------------------------- Public Methods
119    
120    
121        /**
122         * Perform business logic for this bean, often by passing default
123         * values to the <code>Object execute(Object)</code> signature.
124         * If there is no default, it is recommended that a subclass throw
125         * an UnsupportedOperationException instead.
126         *
127         * @exception Throws Exception on any error. A subclass of
128         * ChainedException is recommended.
129         */
130        public Object execute() throws Exception;
131    
132    
133        /**
134         * Perform business logic for this, by retrieving any settings from
135         * the parameters object and returning a result object.
136         *
137         * @exception Throws Exception on any error. A subclass of
138         * <code>ChainedException</code> is recommended.
139         * @param parameters The map or other object to use with this operation
140         */
141        public Object execute(Object parameters) throws Exception;
142    
143    } // end ProcessBean