01: /*
02: * Copyright 2005 Joe Walker
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.directwebremoting.extend;
17:
18: import java.util.Collection;
19: import java.util.Map;
20:
21: /**
22: * A class to manage the types of creators and the instantiated creators.
23: * @author Joe Walker [joe at getahead dot ltd dot uk]
24: */
25: public interface CreatorManager {
26: /**
27: * Debug mode allows access to the list of creator names
28: * @return Are we in debug mode
29: * @see CreatorManager#getCreatorNames()
30: */
31: boolean isDebug();
32:
33: /**
34: * In init mode, add a new type of creator
35: * @param typeName The name of the new creator type
36: * @param className The class that we create
37: */
38: void addCreatorType(String typeName, String className);
39:
40: /**
41: * Add a new creator
42: * @param scriptName The name of the creator to Javascript
43: * @param typeName The class to use as a creator
44: * @param params The extra parameters to allow the creator to configure itself
45: * @throws InstantiationException If reflection based creation fails
46: * @throws IllegalAccessException If reflection based creation fails
47: * @throws IllegalArgumentException If we have a duplicate name
48: */
49: void addCreator(String scriptName, String typeName,
50: Map<String, String> params) throws InstantiationException,
51: IllegalAccessException, IllegalArgumentException;
52:
53: /**
54: * Add a new creator.
55: * TODO: If we refactor this, we should remove the scriptName parameter and
56: * read the value from the creator
57: * @param scriptName The name of the creator to Javascript
58: * @param creator The creator to add
59: * @throws IllegalArgumentException If we have a duplicate name
60: */
61: void addCreator(String scriptName, Creator creator)
62: throws IllegalArgumentException;
63:
64: /**
65: * Get a list of the javascript names of the allowed creators.
66: * This method could be seen as a security risk because it could allow an
67: * attacker to find out extra information about your system so it is only
68: * available if debug is turned on.
69: * @return Loop over all the known allowed classes
70: * @throws SecurityException If we are not in debug mode
71: */
72: Collection<String> getCreatorNames() throws SecurityException;
73:
74: /**
75: * Find an <code>Creator</code> by name
76: * @param scriptName The name of the creator to Javascript
77: * @return The found Creator instance, or null if none was found.
78: * @throws SecurityException If the Creator is not known
79: */
80: Creator getCreator(String scriptName) throws SecurityException;
81:
82: /**
83: * Sets the creators for this creator manager.
84: * @param creators the map of managed beans and their creator instances
85: */
86: void setCreators(Map<String, Creator> creators);
87: }
|