1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 package org.objectledge.web.mvc.finders;
29
30 import org.objectledge.pipeline.Valve;
31 import org.objectledge.web.mvc.builders.Builder;
32 import org.objectledge.web.mvc.components.Component;
33
34 /***
35 * A class finder for finding MVC model classes.
36 *
37 * @author <a href="mailto:dgajda@caltha.pl">Damian Gajda</a>
38 * @version $Id: MVCClassFinder.java,v 1.17 2005/07/22 17:25:53 pablo Exp $
39 */
40 public interface MVCClassFinder
41 {
42
43
44 /***
45 * Returns a runnable action instance based on a given name. If no runnable exists, a
46 * <code>null</code> is returned.
47 *
48 * @param actionName name of an action class
49 * @return found runnable action instance
50 */
51 public Valve getAction(String actionName);
52
53
54
55 /***
56 * Returns a result object containing reference to the found builder for a given view
57 * name. If no builder is found, a <code>null</code> builder is returned in the result object.
58 *
59 * @param builderName part of a name of a builder class to be instantiated
60 * @return found builder instance with accompanying info.
61 */
62 public Result findBuilder(String builderName);
63
64 /***
65 * Returns an enclosing view name for a given view name. If no name is found, a
66 * <code>null</code> is returned.
67 *
68 * @param viewName name of a view for which an enclosing view must be found
69 * @return found view name
70 */
71 public String findEnclosingViewName(String viewName);
72
73
74
75 /***
76 * Returns a component instance based on a given name. If no component exists, a
77 * <code>null</code> is returned.
78 *
79 * @param componentName part of a name of a component class to be found/instantiated
80 * @return found component instance
81 */
82 public Component getComponent(String componentName);
83
84 /***
85 * The search result for builder find method.
86 *
87 * @author <a href="mailto:dgajda@caltha.pl">Damian Gajda</a>
88 */
89 public static class Result
90 {
91 private final String originalView;
92 private final Builder builder;
93 private final String actualView;
94
95 /***
96 * Creates a new Result instance.
97 *
98 * @param originalView originally requested builder.
99 * @param builder resolved builder.
100 * @param actualView the actual view associated with the resolved builder.
101 */
102 public Result(String originalView, Builder builder, String actualView)
103 {
104 this.originalView = originalView;
105 this.builder = builder;
106 this.actualView = actualView;
107 }
108
109 /***
110 * @return Returns the original view used to search for the builder.
111 */
112 public String getOriginalView()
113 {
114 return originalView;
115 }
116
117 /***
118 * @return Returns the actual view name computed during search.
119 */
120 public String getActualView()
121 {
122 return actualView;
123 }
124
125 /***
126 * @return Returns the found builder.
127 */
128 public Builder getBuilder()
129 {
130 return builder;
131 }
132
133 /***
134 * @return Tells whether fallback on view name was preformed during builder search.
135 */
136 public boolean fallbackPerformed()
137 {
138 return !originalView.equals(actualView);
139 }
140 }
141 }