001: /*
002: * Copyright 2005 Joe Walker
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: package org.directwebremoting.extend;
017:
018: import java.util.Map;
019:
020: /**
021: * A base class for all AllowedClasses
022: * @author Joe Walker [joe at getahead dot ltd dot uk]
023: */
024: public interface Creator {
025: /**
026: * DefaultConfiguration is done via access to the DOM Element.
027: * This is not at all ideal, but it will do for the moment.
028: * @param params The map of parameters to configure the creator
029: * @throws IllegalArgumentException If the config data in the Element is invalid
030: */
031: void setProperties(Map<String, String> params)
032: throws IllegalArgumentException;
033:
034: /**
035: * Accessor for the <code>java.lang.Class</code> that this Creator
036: * allows access to.
037: * @return The type of this allowed class
038: */
039: Class<?> getType();
040:
041: /**
042: * Accessor for the/an instance of this Creator.
043: * @return the instance to use
044: * @throws InstantiationException If for some reason the object can not be created
045: */
046: Object getInstance() throws InstantiationException;
047:
048: /**
049: * Each Creator creates objects with a given scope.
050: * @return How long do we hold onto instances created by this Creator
051: */
052: String getScope();
053:
054: /**
055: * Is the class behind the Creator likely to change over time?
056: * TODO: We should probably remove this. I suspect that the reason we added
057: * this was to handle ScriptCreator's ability to change things half way
058: * through, and it feels dangerous given the number of caches around the
059: * place.
060: * @return Returns the reloadable variable
061: */
062: boolean isCacheable();
063:
064: /**
065: * How is this creator referred to in Javascript land?
066: * @return A Javascript identifier
067: */
068: String getJavascript();
069:
070: /**
071: * Application scope: named reference remains available in the
072: * ServletContext until it is reclaimed.
073: */
074: static final String APPLICATION = "application";
075:
076: /**
077: * Session scope (only valid if this page participates in a session): the
078: * named reference remains available from the HttpSession (if any)
079: * associated with the Servlet until the HttpSession is invalidated.
080: */
081: static final String SESSION = "session";
082:
083: /**
084: * Script scope (tied to a id recorded in Javascript): the named reference
085: * remains available while the script variable remains stored in the
086: * browser.
087: */
088: static final String SCRIPT = "script";
089:
090: /**
091: * Request scope: the named reference remains available from the
092: * ServletRequest associated with the Servlet until the current request is
093: * completed. This scope type is almost identical to {@link #PAGE} scope
094: * and it is recommended to use {@link #PAGE} scope in place of this scope.
095: * Use of {@value #REQUEST} may be deprecated in the future.
096: */
097: static final String REQUEST = "request";
098:
099: /**
100: * Page scope: (this is the default) the named reference remains available
101: * in this PageContext until the return from the current Servlet.service()
102: * invocation.
103: */
104: static final String PAGE = "page";
105: }
|