actionframework-users Mailing List for ActionFramework (Page 7)
Status: Inactive
Brought to you by:
ptoman
You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(12) |
Jul
(11) |
Aug
(26) |
Sep
(38) |
Oct
(33) |
Nov
(18) |
Dec
(3) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
(26) |
Feb
(7) |
Mar
(3) |
Apr
(14) |
May
(12) |
Jun
(1) |
Jul
(7) |
Aug
|
Sep
(2) |
Oct
|
Nov
(5) |
Dec
|
2004 |
Jan
(4) |
Feb
(5) |
Mar
(2) |
Apr
|
May
(2) |
Jun
(2) |
Jul
(1) |
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
2005 |
Jan
|
Feb
|
Mar
|
Apr
(2) |
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2013 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Petr T. <cz5...@ti...> - 2002-10-03 04:14:06
|
>> destroySession(); >> runtime.destroy(); >> prepareSession(request); >> >> and tell me if it works, please :) > >Sorry no. Of course not! :) prepareSession() manipulates runtime, which is assigned later. I apologize. Please try: destroySession(); try { runtime.destroy(); } catch (Exception e) { runtime.log.error("[" + context.hashCode() + "] " + "Error ocurred while destroying runtime", e); } runtime =3D newRuntime; prepareSession(request); I hope it's ok now. Petr [ http://dione.zcu.cz/~toman40 - Pet...@pi... - ICQ=3D22957959 ] _________________________________________________________________ Chcete v=ECd=ECt jak=E9 to je m=EDt =B9est jazyk=F9? Zkuste to na http://= slovnik.tiscali.cz |
From: Mark D. A. <md...@di...> - 2002-10-02 03:13:31
|
> I'm thinking of another solution... > > Try to replace line 345 in ActionServlet: > > runtime.destroy(); > > with > > destroySession(); > runtime.destroy(); > prepareSession(request); > > and tell me if it works, please :) Sorry no. I still get: java.lang.IllegalStateException: Cannot get component with "request" persistence from non-servlet thread with this change. -mda |
From: Mark D. A. <md...@di...> - 2002-09-30 23:58:50
|
> It seems that Geir is going to fix the problem for Velocity 1.4, so > if you can live with that your .war-s include velocity-*.jar in > WEB-INF\lib folder, I would let this up to Velocity. How is Geir going to fix a problem due to a static variable in actionservlet source code? I don't see what can be done on the velocity side about the fact that org/actionframework/engines/velocity/VelocityInOutVariable.java has a static variable that instead should reflect per webapp (and per velocity configuration) state. What has to happen IMHO is for VelocityInOutVariable stop using any static variables, but use one of its constructor arguments for gaining access to velocity functionality. -mda |
From: Mark D. A. <md...@di...> - 2002-09-30 23:43:55
|
> Let's discuss where could an error ocurr and how to handle it: > - error in action method -> handled by <on-exception> or onException() > - in template -> exception is propagated from handle() No it isn't, if my reading of the code is correct. handle() only returns a template, it is not above the stack when the template is actually executed. If you look at doRequest() in org/apache/velocity/servlet/VelocityServlet.java, you'll see that handleRequest() is what calls into the actionservlet stuff. After that returns, *then* it calls mergeTemplate, and any exceptions there are missed by actionservlet. If actionservlet had an override for error() in org/apache/velocity/servlet/VelocityServlet.java, things would be better, but right now a lot is missed. Furthermore (again, according to my reading of the code), currently actionservlet makes it impossible to have exception handling (or cleanup handling) with the same scope that is possible when using velocity directly. -mda |
From: Petr T. <Pet...@pi...> - 2002-09-30 16:02:03
|
Hello, I would like to release AS 0.93.2c and start working on AS 0.94. If you have something to bugfix please report ASAP!ASAP Here are the proposed changes: - DefaultInstantiator recoginezed component construtor with 3 args (Context) - RMIInstatiator accepts component name with specified host - AS also tries to load ActionConfig relatively to the servlet "real path" - VelocityServlet overrides error() so default error template is used also for velocity-related errors - bugfix: invocation of "static" component's method caused NullPointerException - bugfix: if ActionConfig reloading was enabled, invoking action method of "session"/"request" components could cause IllegalStateException Petr -- [ http://dione.zcu.cz/~toman40 - Pet...@pi... - ICQ=22957959 ] |
From: Petr T. <Pet...@pi...> - 2002-09-30 16:02:02
|
>> When i said "multiple servlets" i should have said "multiple web >> applications". The actionframework examples war puts all the >> servlets into a single web application. That means there is just a >> single url mapping, and so the bug i mentioned doesn't happen. >> >> However, if you have multiple web apps, things go wrong. > > Aha. I will look at this issue by the end of this week. If you find a > solution by yourself in the meantime, please post it here or through > SourceForge. Thank you. It seems that Geir is going to fix the problem for Velocity 1.4, so if you can live with that your .war-s include velocity-*.jar in WEB-INF\lib folder, I would let this up to Velocity. Petr -- [ http://dione.zcu.cz/~toman40 - Pet...@pi... - ICQ=22957959 ] |
From: Petr T. <Pet...@pi...> - 2002-09-30 16:02:01
|
> org.apache.velocity.servlet.VelocityServlet has an overridable method > error() which is currently not being overridden by > org/actionframework/engines/velocity/VelocityServlet (a subclass, > confusingly the same file name). I think it should, so that velocity > errors get handled by error.vm instead of velocity's compiled-in > error html. Yeah, it should render error.vm as for non-velocity errors. Petr -- [ http://dione.zcu.cz/~toman40 - Pet...@pi... - ICQ=22957959 ] |
From: Petr T. <Pet...@pi...> - 2002-09-30 16:02:00
|
> AS's VelocityServlet should also override Velocity's > VelocityServlet.requestCleanup > > As with error(), because AS's VelocityServlet is not hooking those, I > am left with no access to those. There is a big difference between > velocity's requestCleanup and ActionServlet's cleanupRequest, because > cleanupRequest is in a finally, whereas velocity's requestCleanup is > only called if no exception was thrown. > > In combination, the fact that neither are available to users of > ActionServlet is that I have no easy way to determine whether request > processing was even successful. Let's discuss where could an error ocurr and how to handle it: - error in action method -> handled by <on-exception> or onException() - in template -> exception is propagated from handle() - in onException() & co. -> exception is propagated from handle() So, I think that you may just catch Throwable in overridden handle() method - and VelocityServlet.requestCleanup() is not needed. Petr -- [ http://dione.zcu.cz/~toman40 - Pet...@pi... - ICQ=22957959 ] |
From: Petr T. <Pet...@pi...> - 2002-09-29 18:15:02
|
> So now I'm thinking that AFWException.java should not be touched. And > my error.vm will use a tool like "$Tools.getErrorMessage($error)" > > I would suggest however that the AS core code be changed to help bind > exception objects. That way the policy of what to display is not > restricted by the core. > > One approach would be to bind the "error" context variable to an > exception object instead of a string. This will generally work since > "$error" would call its toString method (which however should be > escaped). > > Another approach would be to separately bind an "exception" context > variable before invoking error.vm (in addition to any "error"). AS is designed so that onException() should be called for all exceptions (unhandled by <on-exception> elements) -> you can override onException() and put anything you like to context. I think that binding "exception" is better than changing "error" type to Exception, since there could be errors not caused by exception. I usually override onException() and for unexpected exceptions do: ByteArrayOutputStream out = new ByteArrayOutputStream(); StringBuffer sb = new StringBuffer(e.toString() + "<P><PRE>"); e.printStackTrace(new PrintStream(out)); sb.append(out.toString() + "</PRE>"); return error(context, sb.toString()); > Other related suggested changes: - change onException() to accept any > Throwable, not just ActionException - change Template error(Context > context, String message) to Template error(Context context, String > message, Throwable e) onException() is passed ActionException which (usually) holds exception origin - "detail" field, so you can always do wrapping, but I don't see any objection for widening ActionException to Throwable :) error() method serves only as provider of a default error page and you can put anything to context - why do you want the Throwable parameter? To keep backward compatibility, error(*whatever*) had to be added, not changed. > But just looking at the code, it is clear how things can get through: > 1. handle() does significant work outside of a try clause, and only > catches IOException 2. processRequest() only catches Exception, not > Throwable. Since the fallback handling is terrible, I always have > servlet handlers catch Throwable. Particularly if you are going to > Method.invoke, which can spew all sorts of non-Exception objects. Ok, I will review the code and put Throwable where possible :) Petr PS: I will reply to the rest of your questions tomorrow. -- [ http://dione.zcu.cz/~toman40 - Pet...@pi... - ICQ=22957959 ] |
From: Mark D. A. <md...@di...> - 2002-09-26 05:39:02
|
AS's VelocityServlet should also override Velocity's VelocityServlet.requestCleanup As with error(), because AS's VelocityServlet is not hooking those, I am left with no access to those. There is a big difference between velocity's requestCleanup and ActionServlet's cleanupRequest, because cleanupRequest is in a finally, whereas velocity's requestCleanup is only called if no exception was thrown. In combination, the fact that neither are available to users of ActionServlet is that I have no easy way to determine whether request processing was even successful. -mda |
From: Mark D. A. <md...@di...> - 2002-09-26 05:33:23
|
org.apache.velocity.servlet.VelocityServlet has an overridable method error() which is currently not being overridden by org/actionframework/engines/velocity/VelocityServlet (a subclass, confusingly the same file name). I think it should, so that velocity errors get handled by error.vm instead of velocity's compiled-in error html. -mda |
From: Mark D. A. <md...@di...> - 2002-09-24 18:12:25
|
> I wouldn't name the method getStackTrace() because there is such a > method in JDK 1.4. The question is whether to introduce, say > getStackTraceString(), or let people migrate to 1.4. Yes, getStackTrace() was a bad choice as a name. Another problem with using my idea of $error.StackTrace is that it would only work with exceptions that have that method, and rather I'd like all exceptions to work. Also, it doesn't deal with html parameter escaping. So now I'm thinking that AFWException.java should not be touched. And my error.vm will use a tool like "$Tools.getErrorMessage($error)" I would suggest however that the AS core code be changed to help bind exception objects. That way the policy of what to display is not restricted by the core. One approach would be to bind the "error" context variable to an exception object instead of a string. This will generally work since "$error" would call its toString method (which however should be escaped). Another approach would be to separately bind an "exception" context variable before invoking error.vm (in addition to any "error"). Other related suggested changes: - change onException() to accept any Throwable, not just ActionException - change Template error(Context context, String message) to Template error(Context context, String message, Throwable e) where e might be null. You might pass in a boolean too, such as "boolean already_escaped" to indicate whether the string might already have had html entity escaping done. [i'd also suggest renaming the error() method to onErrorMessage() or getErrorTemplate or something] > > There still seem to be a whole bunch of different exceptions that are > > not caught by onException, which is a different problem.... > > ConversionExceptions are not, others should be. Do you have an example? I'm sorry I didn't keep good records. When I first started using AS, it seemed almost nothing was caught by AS, because my errors were so fundamental. Now it is catching more. But just looking at the code, it is clear how things can get through: 1. handle() does significant work outside of a try clause, and only catches IOException 2. processRequest() only catches Exception, not Throwable. Since the fallback handling is terrible, I always have servlet handlers catch Throwable. Particularly if you are going to Method.invoke, which can spew all sorts of non-Exception objects. -mda |
From: Mark D. A. <md...@di...> - 2002-09-24 18:02:15
|
> I wouldn't name the method getStackTrace() because there is such a > method in JDK 1.4. The question is whether to introduce, say > getStackTraceString(), or let people migrate to 1.4. Yes, getStackTrace() was a bad choice as a name. Another problem with using my idea of $error.StackTrace is that it would only work with exceptions that have that method, and rather I'd like all exceptions to work. Also, it doesn't deal with html parameter escaping. So now I'm thinking that AFWException.java should not be touched. And my error.vm will use a tool like "$Tools.getErrorMessage($error)" I would suggest however that the AS core code be changed to help bind exception objects. That way the policy of what to display is not restricted by the core. One approach would be to bind the "error" context variable to an exception object instead of a string. This will generally work since "$error" would call its toString method (which however should be escaped). Another approach would be to separately bind an "exception" context variable before invoking error.vm (in addition to any "error"). Other related suggested changes: - change onException() to accept any Throwable, not just ActionException - change Template error(Context context, String message) to Template error(Context context, String message, Throwable e) > > There still seem to be a whole bunch of different exceptions that are > > not caught by onException, which is a different problem.... > > ConversionExceptions are not, others should be. Do you have an example? I'm sorry I didn't keep good records. When I first started using AS, it seemed almost nothing was caught by AS, because my errors were so fundamental. Now it is catching more. But just looking at the code, it is clear how things can get through: 1. handle() does significant work outside of a try clause, and only catches IOException 2. processRequest() only catches Exception, not Throwable. Since the fallback handling is terrible, I always have servlet handlers catch Throwable. Particularly if you are going to Method.invoke, which can spew all sorts of non-Exception objects. -mda |
From: Petr T. <Pet...@pi...> - 2002-09-24 16:01:45
|
> If I turn on reloadActionConfig and if I have "request" level > components, then I get this when I change the action config file and > reload a page: > > java.lang.IllegalStateException: Cannot get component with "request" > persistence from non-servlet thread > > A fix would be to either copy over more state (such as > threadSessions) between the two, or to modify the existing runtime > instance instead of replacing it. I'm thinking of another solution... Try to replace line 345 in ActionServlet: runtime.destroy(); with destroySession(); runtime.destroy(); prepareSession(request); and tell me if it works, please :) Petr -- [ http://dione.zcu.cz/~toman40 - Pet...@pi... - ICQ=22957959 ] |
From: Petr T. <Pet...@pi...> - 2002-09-24 16:01:45
|
> public String getStackTrace() { > java.io.StringWriter w = new java.io.StringWriter(); > this.printStackTrace(new java.io.PrintWriter(w, true)); > return w.toString(); > } I wouldn't name the method getStackTrace() because there is such a method in JDK 1.4. The question is whether to introduce, say getStackTraceString(), or let people migrate to 1.4. I agre that stacktrace as string is handy for error reporting, but you can always put the code above into onException() method. > There still seem to be a whole bunch of different exceptions that are > not caught by onException, which is a different problem.... ConversionExceptions are not, others should be. Do you have an example? Petr -- [ http://dione.zcu.cz/~toman40 - Pet...@pi... - ICQ=22957959 ] |
From: Petr T. <Pet...@pi...> - 2002-09-24 16:01:42
|
> org/actionframework/engines/velocity/VelocityServlet.java to > relativize the value of FILE_RESOURCE_LOADER_PATH is incorrect if > there is a comma-separated value, which is supported by velocity. > Velocity does this by using > org.apache.commons.collections.ExtendedProperties AS could do that > too, but i didn't want to make a deep change. Rather, i just added > this function. Thank you for the patch! It seems we will get AS pretty clean soon :) Petr -- [ http://dione.zcu.cz/~toman40 - Pet...@pi... - ICQ=22957959 ] |
From: Mark D. A. <md...@di...> - 2002-09-24 07:19:41
|
The logic in org/actionframework/engines/velocity/VelocityServlet.java to relativize the value of FILE_RESOURCE_LOADER_PATH is incorrect if there is a comma-separated value, which is supported by velocity. Velocity does this by using org.apache.commons.collections.ExtendedProperties AS could do that too, but i didn't want to make a deep change. Rather, i just added this function. -mda ------------------------------------ // deal with the fact that this might comma separated, not just a single token protected String relativize_loader_path(Properties p, String v) { StringBuffer sb = new StringBuffer(""); java.util.StringTokenizer st = new java.util.StringTokenizer(v, ", "); while (st.hasMoreTokens()) { String f = st.nextToken(); String real_path = getServletContext().getRealPath(f); if (real_path == null) { _getLog("Velocity").error("[init] " + "Cannot get real path of template path '" + f + "'"); } else { _getLog("Velocity").info("Template path = '" + real_path + "'"); f = real_path; } if (sb.length() > 0) sb.append(","); sb.append(f); } String new_val = sb.toString(); p.put(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, new_val); _getLog("Velocity").info("new value of " + RuntimeConstants.FILE_RESOURCE_LOADER_PATH + " = '" + new_val + "'"); return new_val; } .... // "file.resource.loader.path" property String templatePath = p.getProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH); if (templatePath != null) { relativize_loader_path(p, templatePath); } else _getLog("Velocity").warning("Template path '"+ RuntimeConstants.FILE_RESOURCE_LOADER_PATH +"' not specified"); ... |
From: Mark D. A. <md...@di...> - 2002-09-23 06:11:01
|
A useful addition to AFWException.java is: /** * Like printStackTrace(), but return into a string instead of writing to a stream. */ public String getStackTrace() { java.io.StringWriter w = new java.io.StringWriter(); this.printStackTrace(new java.io.PrintWriter(w, true)); return w.toString(); } This is useful because then error.vm can be: <html> <head> </head> <body bgcolor="white"> <h1><font color="red">Ack!</font></h1> #if ($error.StackTrace) <pre> $error.StackTrace </pre> #else <TT>$error</TT> #end </body> </html> this way, stack traces can be seen if the error variable is an exception object that has a getStackTrace method. Of course, that means overriding onException (unless Petr changes ActionServlet) so that "error" is an exception object in the context, and not a string: protected Template onException(Context context, String form, String action, org.actionframework.ActionException e) { // return error(context, org.actionframework.util.Util.filterSpecialHTMLChars(e.toString())); context.put("error", e); return getTemplate("error.vm"); } There still seem to be a whole bunch of different exceptions that are not caught by onException, which is a different problem.... -mda |
From: Mark D. A. <md...@di...> - 2002-09-23 06:06:21
|
If I turn on reloadActionConfig and if I have "request" level components, then I get this when I change the action config file and reload a page: java.lang.IllegalStateException: Cannot get component with "request" persistence from non-servlet thread at org.actionframework.ActionRuntime.getComponent(ActionRuntime.java:1448) at org.actionframework.ActionServlet.getComponent(ActionServlet.java:737) at org.actionframework.ActionServlet.processRequest(ActionServlet.java:532) at org.actionframework.ActionServlet.handle(ActionServlet.java:359) This is presumably because ActionServlet stores session ids in runtime.threadSessions, and the actionConfigFile change handling is implemented by replacing runtime by newRuntime. A fix would be to either copy over more state (such as threadSessions) between the two, or to modify the existing runtime instance instead of replacing it. -mda |
From: Petr T. <cz5...@ti...> - 2002-09-20 07:19:58
|
The code in Action.java [624] should be: if (retValue =3D=3D null) { if (i > 0 || componentData.persistence !=3D ComponentData.PERSISTENCE= _STATIC) throw new ActionException("Method '" + methodStack[i-1] + "' of action '" + debugName + "' returns null"); } else { // ensure proper class loading (required by RMI & co.) if (retValue.getClass() !=3D methodStack[i].getDeclaringClass()) methodStack[i] =3D retValue.getClass().getMethod(methodStack[i].g= etName(), methodStack[i].getParameterTypes()); } Petr [ http://dione.zcu.cz/~toman40 - Pet...@pi... - ICQ=3D22957959 ] _________________________________________________________________ Chcete v=ECd=ECt jak=E9 to je m=EDt =B9est jazyk=F9? Zkuste to na http://= slovnik.tiscali.cz |
From: Petr T. <cz5...@ti...> - 2002-09-20 06:14:56
|
Hello everyone, I think now it is the right time to discuss the future. I (re)collected my ideas and plans (some had been already posted in "Proposals for 0.94" thread) and here is the result is below (will be added to www). Todo for 0.93.1c/0.93.2c (bugfix release: end of September) ------------------------ [ ] this could be the last bugfix release before I start working on 0.94 Todo for 0.94 ("orthogonality" release: 1st half of October) ------------- [ ] add ActionServlet.destroyComponent(String componentName) method [ ] add ActionServlet.getTypeHandler(Class srcType, Class targetType) met= hod [ ] add BaseCompositeHandler + javadoc org.actionframework.th package [ ] allow <type-handler> element nested in <input-variable> of <action> (to allow explicit selection of type handler) <action name=3D"/actionA" method=3D"methodA(java.util.List listA)"> <input-variable name=3D"listA" value=3D"roleUids[]"> <type-handler class=3D"my.specific.Handler"/> </input-variable> <on-return value=3D"void" show-template=3D"someTemplate.wm"/> </action> [ ] enable <on-exception>s common to all components [ ] allow arbitrary order of <output-variabele>s and <invoke>s inside <template>, <on-return> and <exception> [ ] put $REQUEST, $RESPONSE into Context by default (note: do not add getRequest() and getResponse() methods to Context because on client side there will be no HTTP request/response)= [ ] add new <on-new-session> element - allowing 'show-url' redirect (ensure $SERVLET, $URL and $CONTEXT are set before processing it!) [ ] allow evaluation of 'show-url' directly, not only through <output-var= iable> [ ] evaluate values of show-template=3D"$currentPage" attribute [ ] enable <property> values like: <property name=3D"SomeProperty" value=3D"$xyz"> <input-variable name=3D"xyz" component=3D"Comp" value=3D"getValue(= )"/> </property> - requires also to change return type of ActionServlet.getProperty() [ ] introduce <validate> element - for parameter validation: <action name=3D"/myAction1" method=3D"method1(String str, int value)"= > <validate class=3D"my.Validator1" variables=3D"str"/> </action> <action name=3D"/myAction2" method=3D"method2(String str, int value)"= > <validate class=3D"my.Validator2" variables=3D"str, value"/> </action> [ ] allow <template> names containing regexps, so that <output-variable>s= can be set for several templates in one place [ ] allow new <template-ref name=3D"template.wm"> element nested in <temp= late> (will enable nesting of templates) [ ] allow invocation of static methods of components in <in/out-variable>= s [ ] owerwiting of tmp uploaded files -> update multipartrequest.jar to 1.= 30 [ ] add optional type=3D"GET/POST" attribute for <action> to allow select= ion of action based on the type of request -> also change AS methods that ha= ve 'form' parameter (beforeInvoke(), invokeMethod() etc.) - example: beforeInvoke(Context context, String form, String action, Object[] pa= rams) // would change to: beforeInvoke(Context context, String type, String action, Object[] pa= rams) Values of 'form' and 'action' will be concatenated by '.': form=3D"form1", action=3D"submit" -> action value would be "form1.sub= mit" [ ] ConversionException should be also processable by <on-exception> elem= ent Todo for 0.95 ("programmatic ActionConfig" release: October) ------------- [ ] API for ActionConfig (support for multiple/programmatic configuration= ) [ ] replace ActionServlet.getActionMethod() by config.getAction().getMeth= od()? [ ] add getVersion(), getAction() methods to Context [ ] some ActionConfig error messages don't indicate line number - ex: "Er= ror while parsing action method definition; nested exception is: java.text.ParseException: Unknown parameter type '$userName' in actio= n definition: 'getReservations($userName)'" [ ] implement <pre-condition>s (nested in <action>) - example: <pre-condition if=3D"$var" show-template=3D"loggedIn.wm"> <input-variable name=3D"var" component=3D"auth" value=3D"isLoggedI= n()"/> </pre-condition> <pre-condition if=3D"!$REQUEST.isSecure()" show-url=3D"https:/$SERLVE= T"/> <pre-condition if=3D"!$REQUEST.isSecure()"> <invoke component=3D"counter" method=3D"incNumberOfInsecureCalls()= "/> <invoke component=3D"counter" method=3D"incNumberOfErrors()"/> </pre-condition> <pre-condition if=3D"!$REQUEST.isSecure()"> <invoke component=3D"Authenticator" method=3D"isLoggedIn()"/> <on-return value=3D"true" show-template=3D"HttpsRequiredError.w= m"> </invoke> </pre-condition> <pre-condition>s may be defined for: - all components (inside <components>) - all actions of one component (inside <component>) - single action (inside <action>) Todo for 0.96 ("pluggable template engine" release: November) ------------- [ ] reimplement In/OutputVars - will remove dependency on Velocity/WebMac= ro [ ] add <in/output-variable> attribute 'type' - to set var type manually [ ] make pluggable parser API public [ ] JSP and FreeMarker engine support Todo for 0.97 ("ActionController" release: December) ------------- [ ] introduce ActionController interface - will make Actionframework usage possible for client side development Todo (not yet scheduled) ------------------------ [ ] enable passing of all incomming HTTP/URL parameters between requests (=3D put all HTTP/URL parameters into Context) [ ] include error.wm/.vm in ActionServlet.jar - will be used if not found= in template path [ ] examples configuration + out-of-box ant task for Jetty (problem: Jetty does not work on path with spaces) [ ] reload components if ActionConfig changes [ ] allow accessing ActionServlet.getComponent() via JNDI context [ ] write better Tutorial describing all features step by step [ ] enable forwarding actions? (may be now solved by URL redirecting) [ ] standardize "connector architecture" -> publish ParameterRetrievers API (AS will be able to handle requests from different sources - RMI/miniRMI/Corba/POP3/SOAP,...) [ ] template postprocessing (XSL/VSL) --- Release dates are just rough estimates. I'm awaiting your comments and su= ggestions! :) Petr [ http://dione.zcu.cz/~toman40 - Pet...@pi... - ICQ=3D22957959 ] _________________________________________________________________ Chcete v=ECd=ECt jak=E9 to je m=EDt =B9est jazyk=F9? Zkuste to na http://= slovnik.tiscali.cz |
From: Petr T. <cz5...@ti...> - 2002-09-20 05:20:01
|
>below is a new version of DefaultInstantiator.java >I cleaned up the code, and added the ability to find and use a 3-arg con= structor, >which takes arguments (ActionServlet, String, Context). >I included updated javadoc at the top of the file, but updating document= ation >and specification elsewhere is left to the maintainer :). > >This change is useful for "request" level components, which often (to me= ) >seem to need access to context. Cool! You really aspire to be honoured in AS' credits.txt! :) Petr [ http://dione.zcu.cz/~toman40 - Pet...@pi... - ICQ=3D22957959 ] _________________________________________________________________ Chcete v=ECd=ECt jak=E9 to je m=EDt =B9est jazyk=F9? Zkuste to na http://= slovnik.tiscali.cz |
From: Mark D. A. <md...@di...> - 2002-09-19 21:54:37
|
below is a new version of DefaultInstantiator.java I cleaned up the code, and added the ability to find and use a 3-arg constructor, which takes arguments (ActionServlet, String, Context). I included updated javadoc at the top of the file, but updating documentation and specification elsewhere is left to the maintainer :). This change is useful for "request" level components, which often (to me) seem to need access to context. -mda ----------- DefaultInstantiator.java ------------ package org.actionframework.instantiators; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.util.Hashtable; import org.actionframework.ActionServlet; import org.actionframework.Context; /** * Instantiates "normal" ActionServlet components. Used if '<TT>instantiator</TT>' attribute * is not specified for the component in ActionConfig. * * Each component class must have a public constructor with the parameter types that are assignable (that is class or subclass) from one of these: * <ul> * <li>({@link org.actionframework.ActionServlet}, <TT>java.lang.String</TT>, {@link org.actionframework.Context}) * <li>({@link org.actionframework.ActionServlet}, <TT>java.lang.String</TT>) * <li>({@link org.actionframework.ActionServlet}) * <li>() * </ul> * That is, it attempts to find the longest match. * * @since version 0.92 */ public class DefaultInstantiator implements Instantiator { private class ComponentEntry { Constructor constructor; int n; ComponentEntry(Constructor constructor) { this.constructor = constructor; this.n = constructor.getParameterTypes().length; } } /** * Key: component class name, value = ComponentEntry */ private final Hashtable componentClasses = new Hashtable(); protected ActionServlet servlet; /** * Creates instantiator. */ public DefaultInstantiator(ActionServlet servlet) { this.servlet = servlet; } /** * generic utility for finding a constructor which matches subclasses, * not just formal parameters (unlike Class.getConstructor()). * <p> * If n_avail >= 0, it pretends that is the length of avail_param_types. * If n_avail == -1, it uses n_avail = avail_param_types.length. * <p> * Returns null if none is found. */ public static Constructor getAssignableConstructor(Class obj_class, Class[] avail_param_types, int n_avail) { Constructor[] constructors = obj_class.getConstructors(); if (n_avail == -1) n_avail = avail_param_types.length; for (int i = 0; i < constructors.length; i++) { Class[] paramTypes = constructors[i].getParameterTypes(); if (paramTypes.length != n_avail) continue; int j; for (j = 0; j < n_avail; ++j) { if (!avail_param_types[j].isAssignableFrom(paramTypes[j])) break; } if (j == n_avail) return constructors[i]; } return null; } /** * Finds the constructor matching the longest number of args. * Iterates using getAssignableConstructor decreasing n. */ public static Constructor getLongestAssignableConstructor(Class obj_class, Class[] avail_param_types) { for(int n=avail_param_types.length; n>=0; --n) { Constructor found = getAssignableConstructor(obj_class, avail_param_types, n); if (found != null) return found; } return null; } protected static Class[] CON_CLASSES = new Class[] {ActionServlet.class, String.class, Context.class}; /** * Returns a new instance of ActionServlet component. */ public Object createComponent(Context context, Class componentClass, String componentName) throws InstantiatorException { String componentClassName = componentClass.getName(); // check cache ComponentEntry componentEntry = (ComponentEntry) componentClasses.get(componentClassName); if (componentEntry == null) { Constructor constructor = getLongestAssignableConstructor(componentClass, CON_CLASSES); if (constructor == null) throw new InstantiatorException("Component class '" + componentClassName + "' does not have a public constructor with parameters: () or (ActionServlet) or (ActionServlet, String) or (ActionServlet, String, Context)"); // put in cache componentEntry = new ComponentEntry(constructor); componentClasses.put(componentClassName, componentEntry); } try { switch (componentEntry.n) { case 0: return componentEntry.constructor.newInstance(new Object[] {}); case 1: return componentEntry.constructor.newInstance(new Object[] {servlet}); case 2: return componentEntry.constructor.newInstance(new Object[] {servlet, componentName}); case 3: return componentEntry.constructor.newInstance(new Object[] {servlet, componentName, context}); default: return null; // cannot happen } } catch(InvocationTargetException e) { throw new InstantiatorException("Error while invoking constructor of component '" + componentName + "'", e.getTargetException()); } catch(java.lang.InstantiationException e) { throw new InstantiatorException("Cannot instantiate component '" + componentName + "'", e); } catch(IllegalAccessException e) { throw new InstantiatorException("Cannot access component '" + componentName + "'", e); } } } |
From: Petr T. <cz5...@ti...> - 2002-09-19 05:31:46
|
>Note that just making the i-1 be i doesn't seem correct either. >The problem only seems to happen with static components; i made the comp= onent >be "application" and it stopped throwing. That [i-1] is ok for non-static components, because [0] is the component itself. I'm going to fix it now (as well as that Velocity ri problem). Thanks for= bug report! Petr [ http://dione.zcu.cz/~toman40 - Pet...@pi... - ICQ=3D22957959 ] _________________________________________________________________ Chcete v=ECd=ECt jak=E9 to je m=EDt =B9est jazyk=F9? Zkuste to na http://= slovnik.tiscali.cz |
From: Mark D. A. <md...@di...> - 2002-09-18 15:31:02
|
Note that just making the i-1 be i doesn't seem correct either. The problem only seems to happen with static components; i made the component be "application" and it stopped throwing. -mda ----- Original Message ----- From: "Mark D. Anderson" <md...@di...> To: <act...@li...> Sent: Wednesday, September 18, 2002 12:54 AM Subject: [Actionframework-users] bug in Action.java > Action.java has this code: > for (int i = 0; i < convertedParams.length; i++) > try { > if (retValue == null) > throw new ActionException("Method '" + methodStack[i-1] + "' of action '" + debugName + "' returns > null"); > > That -1 is kind of a problem when i=0..... |