lipog-commit Mailing List for Little Portal Gizmo (Page 13)
Status: Beta
Brought to you by:
jbu
You can subscribe to this list here.
2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(94) |
Jun
(14) |
Jul
(168) |
Aug
(39) |
Sep
|
Oct
|
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(6) |
Dec
|
From: Joerg B. <jb...@us...> - 2009-05-10 20:19:25
|
Update of /cvsroot/lipog/net.heilancoo.portal In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv30817 Modified Files: plugin.xml Log Message: created responders package Index: plugin.xml =================================================================== RCS file: /cvsroot/lipog/net.heilancoo.portal/plugin.xml,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** plugin.xml 22 Apr 2009 21:37:00 -0000 1.5 --- plugin.xml 10 May 2009 20:19:14 -0000 1.6 *************** *** 18,22 **** point="net.heilancoo.portal.responsegenerator"> <responsegenerator ! generator-factory="net.heilancoo.portal.responses.PlainResponderFactory"> </responsegenerator> </extension> --- 18,22 ---- point="net.heilancoo.portal.responsegenerator"> <responsegenerator ! generator-factory="net.heilancoo.portal.responders.PlainResponderFactory"> </responsegenerator> </extension> |
From: Joerg B. <jb...@us...> - 2009-05-10 20:19:25
|
Update of /cvsroot/lipog/net.heilancoo.portal/src/net/heilancoo/portal/responders In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv30817/src/net/heilancoo/portal/responders Added Files: ResponderCreationException.java ResponderFactory.java PlainResponder.java FileResponder.java Responder.java PlainResponderFactory.java Log Message: created responders package --- NEW FILE: PlainResponderFactory.java --- /* * Copyright (c) 2009 Heilan' Coo -- Joerg Bullmann * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which is available at http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Joerg Bullmann <jb...@he...> */ package net.heilancoo.portal.responders; import java.lang.reflect.Method; import net.heilancoo.portal.htmlforms.FormFieldContainer; import net.heilancoo.portal.requests.MimeTypeMapper; import org.apache.http.HttpRequest; import org.apache.http.HttpResponse; import org.apache.http.protocol.HttpContext; import org.apache.log4j.Logger; import org.osgi.framework.Bundle; /** * @author joerg * */ public class PlainResponderFactory extends ResponderFactory { private static final Logger logger = Logger.getLogger(PlainResponderFactory.class); public PlainResponderFactory() { super(new Class<?> [] { HttpRequest.class, FormFieldContainer.class, HttpResponse.class, HttpContext.class }); } /* * (non-Javadoc) * @see net.heilancoo.portal.responses.ResponderFactory#makeGeneratorFor(java.lang.reflect.Method, org.osgi.framework.Bundle, net.heilancoo.portal.requests.MimeTypeMapper) */ @Override public Responder makeGeneratorFor(Method method, Bundle bundle, MimeTypeMapper mimeMapper) { logger.info("Making plain responder for method " + method.getName() + "."); return new PlainResponder(method); } } --- NEW FILE: ResponderCreationException.java --- /* * Copyright (c) 2009 Heilan' Coo -- Joerg Bullmann * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which is available at http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Joerg Bullmann <jb...@he...> */ package net.heilancoo.portal.responders; /** * @author joerg * */ public class ResponderCreationException extends Exception { private static final long serialVersionUID = -5327154193057367054L; public ResponderCreationException() { } public ResponderCreationException(String why) { super(why); } } --- NEW FILE: FileResponder.java --- /* * Copyright (c) 2009 Heilan' Coo -- Joerg Bullmann * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which is available at http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Joerg Bullmann <jb...@he...> */ package net.heilancoo.portal.responders; import java.io.File; import java.lang.reflect.InvocationTargetException; import net.heilancoo.portal.htmlforms.FormFieldContainer; import net.heilancoo.portal.requests.FileRequestHandler; import net.heilancoo.portal.requests.MimeTypeMapper; import net.heilancoo.portal.responses.RequestTarget; import org.apache.http.HttpRequest; import org.apache.http.HttpResponse; import org.apache.http.protocol.HttpContext; /** * @author joerg * */ public class FileResponder extends Responder { private File file; private MimeTypeMapper mimeMapper; public FileResponder(File file, MimeTypeMapper mimeMapper) { this.file = file; this.mimeMapper = mimeMapper; } /* (non-Javadoc) * @see net.heilancoo.portal.responses.Responder#execute(net.heilancoo.portal.session.Session, org.apache.http.HttpRequest, net.heilancoo.portal.htmlforms.FormFieldContainer, org.apache.http.HttpResponse, org.apache.http.protocol.HttpContext) */ @Override public boolean execute(RequestTarget target, String format, HttpRequest request, FormFieldContainer fields, HttpResponse response, HttpContext context) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { FileRequestHandler.serveFile(file, request, response, context, mimeMapper, false); return true; } } --- NEW FILE: ResponderFactory.java --- /* * Copyright (c) 2009 Heilan' Coo -- Joerg Bullmann * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which is available at http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Joerg Bullmann <jb...@he...> */ package net.heilancoo.portal.responders; import java.lang.reflect.Method; import net.heilancoo.portal.requests.MimeTypeMapper; import org.osgi.framework.Bundle; /** * @author joerg * */ public abstract class ResponderFactory { private final Class<?> [] parameterTypes; protected ResponderFactory(Class<?> [] parameterTypes) { this.parameterTypes = parameterTypes; } protected boolean matches(Method method) { if(method.getParameterTypes().length != parameterTypes.length) return false; for(int i = 0; i < parameterTypes.length; i++) { Class<?> meth = method.getParameterTypes()[i]; Class<?> gen = parameterTypes[i]; if(!meth.equals(gen)) return false; } return true; } public Responder tryMakingResponderFor(Method method, Bundle bundle, MimeTypeMapper mimeMapper) { if(!matches(method)) return null; try { return makeGeneratorFor(method, bundle, mimeMapper); } catch(ResponderCreationException e) { return null; } } protected abstract Responder makeGeneratorFor(Method method, Bundle bundle, MimeTypeMapper mimeMapper) throws ResponderCreationException; } --- NEW FILE: Responder.java --- /* * Copyright (c) 2009 Heilan' Coo -- Joerg Bullmann * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which is available at http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Joerg Bullmann <jb...@he...> */ package net.heilancoo.portal.responders; import java.lang.reflect.Method; import net.heilancoo.portal.htmlforms.FormFieldContainer; import net.heilancoo.portal.responses.RequestTarget; import org.apache.http.HttpRequest; import org.apache.http.HttpResponse; import org.apache.http.protocol.HttpContext; /** * @author joerg * */ public abstract class Responder { protected Method method; public abstract boolean execute(RequestTarget target, String format, HttpRequest request, FormFieldContainer fields, HttpResponse response, HttpContext context) throws Exception; } --- NEW FILE: PlainResponder.java --- /* * Copyright (c) 2009 Heilan' Coo -- Joerg Bullmann * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which is available at http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Joerg Bullmann <jb...@he...> */ package net.heilancoo.portal.responders; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import net.heilancoo.portal.htmlforms.FormFieldContainer; import net.heilancoo.portal.responses.RequestTarget; import org.apache.http.HttpRequest; import org.apache.http.HttpResponse; import org.apache.http.protocol.HttpContext; /** * @author joerg * */ public class PlainResponder extends Responder { public PlainResponder(Method method) { this.method = method; } /* (non-Javadoc) * @see net.heilancoo.portal.responses.Responder#execute(net.heilancoo.portal.session.Session, org.apache.http.HttpRequest, net.heilancoo.portal.htmlforms.FormFieldContainer, org.apache.http.HttpResponse, org.apache.http.protocol.HttpContext) */ @Override public boolean execute(RequestTarget target, String format, HttpRequest request, FormFieldContainer fields, HttpResponse response, HttpContext context) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { method.invoke(target, request, fields, response, context); return true; } } |
From: Joerg B. <jb...@us...> - 2009-05-10 20:19:25
|
Update of /cvsroot/lipog/net.heilancoo.portal/src/net/heilancoo/portal In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv30817/src/net/heilancoo/portal Modified Files: PortalPlugin.java Log Message: created responders package Index: PortalPlugin.java =================================================================== RCS file: /cvsroot/lipog/net.heilancoo.portal/src/net/heilancoo/portal/PortalPlugin.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** PortalPlugin.java 4 May 2009 21:57:02 -0000 1.15 --- PortalPlugin.java 10 May 2009 20:19:14 -0000 1.16 *************** *** 27,32 **** import net.heilancoo.portal.requests.MimeTypeMapper; import net.heilancoo.portal.requests.RequestHandler; ! import net.heilancoo.portal.responses.Responder; ! import net.heilancoo.portal.responses.ResponderFactory; import net.heilancoo.portal.service.HttpService; import net.heilancoo.utils.Utils; --- 27,32 ---- import net.heilancoo.portal.requests.MimeTypeMapper; import net.heilancoo.portal.requests.RequestHandler; ! import net.heilancoo.portal.responders.Responder; ! import net.heilancoo.portal.responders.ResponderFactory; import net.heilancoo.portal.service.HttpService; import net.heilancoo.utils.Utils; |
From: Joerg B. <jb...@us...> - 2009-05-10 20:19:25
|
Update of /cvsroot/lipog/net.heilancoo.portal/META-INF In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv30817/META-INF Modified Files: MANIFEST.MF Log Message: created responders package Index: MANIFEST.MF =================================================================== RCS file: /cvsroot/lipog/net.heilancoo.portal/META-INF/MANIFEST.MF,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MANIFEST.MF 20 Apr 2009 18:56:18 -0000 1.2 --- MANIFEST.MF 10 May 2009 20:19:14 -0000 1.3 *************** *** 15,18 **** --- 15,19 ---- net.heilancoo.portal.htmlforms, net.heilancoo.portal.requests, + net.heilancoo.portal.responders, net.heilancoo.portal.responses, net.heilancoo.portal.service, |
From: Joerg B. <jb...@us...> - 2009-05-10 20:19:25
|
Update of /cvsroot/lipog/net.heilancoo.portal/src/net/heilancoo/portal/responses In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv30817/src/net/heilancoo/portal/responses Modified Files: RequestTargetManager.java Removed Files: ResponderCreationException.java ResponderFactory.java FileResponder.java Responder.java PlainResponderFactory.java PlainResponder.java Log Message: created responders package --- PlainResponderFactory.java DELETED --- --- ResponderCreationException.java DELETED --- Index: RequestTargetManager.java =================================================================== RCS file: /cvsroot/lipog/net.heilancoo.portal/src/net/heilancoo/portal/responses/RequestTargetManager.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** RequestTargetManager.java 10 May 2009 19:51:37 -0000 1.3 --- RequestTargetManager.java 10 May 2009 20:19:14 -0000 1.4 *************** *** 18,21 **** --- 18,22 ---- import net.heilancoo.portal.PortalPlugin; import net.heilancoo.portal.requests.MimeTypeMapper; + import net.heilancoo.portal.responders.Responder; import net.heilancoo.portal.session.ChangeController; import net.heilancoo.portal.session.ChangeControllers; --- FileResponder.java DELETED --- --- ResponderFactory.java DELETED --- --- Responder.java DELETED --- --- PlainResponder.java DELETED --- |
From: Joerg B. <jb...@us...> - 2009-05-10 20:19:20
|
Update of /cvsroot/lipog/net.heilancoo.portal/src/net/heilancoo/portal/responders In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv30805/src/net/heilancoo/portal/responders Log Message: Directory /cvsroot/lipog/net.heilancoo.portal/src/net/heilancoo/portal/responders added to the repository |
From: Joerg B. <jb...@us...> - 2009-05-10 20:17:21
|
Update of /cvsroot/lipog/net.heilancoo.portal.documentation/doc In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv30622/doc Modified Files: change-log.html Log Message: easier controller changing: @ChangeControllers annotation Index: change-log.html =================================================================== RCS file: /cvsroot/lipog/net.heilancoo.portal.documentation/doc/change-log.html,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** change-log.html 4 May 2009 22:18:15 -0000 1.17 --- change-log.html 10 May 2009 20:17:09 -0000 1.18 *************** *** 11,14 **** --- 11,15 ---- <h2>Release 4 (upcoming)</h2> <ul> + <li>Request target (controller) changing improved and simplified (@ChangeControllers annotation).</li> <li>Form field decoding is now done much later, just before the form fields are actually needed; as a consequence in cases of malformed URIs or bad session keys form fields will not be decoded at all which saves |
From: Joerg B. <jb...@us...> - 2009-05-10 19:51:48
|
Update of /cvsroot/lipog/net.heilancoo.portal.examples/src/net/heilancoo/portal/examples/controllerchange In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv25741/src/net/heilancoo/portal/examples/controllerchange Modified Files: ThePreferences.java TheMain.java TheSession.java Added Files: TheExport.java Log Message: easier controller changing: @ChangeControllers annotation Index: TheMain.java =================================================================== RCS file: /cvsroot/lipog/net.heilancoo.portal.examples/src/net/heilancoo/portal/examples/controllerchange/TheMain.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TheMain.java 1 May 2009 13:42:47 -0000 1.1 --- TheMain.java 10 May 2009 19:51:40 -0000 1.2 *************** *** 12,19 **** package net.heilancoo.portal.examples.controllerchange; - import org.apache.http.HttpRequest; - import org.apache.http.HttpResponse; - import org.apache.http.protocol.HttpContext; - import net.heilancoo.portal.freemarker.FreeMarkerModel; import net.heilancoo.portal.htmlforms.FormFieldContainer; --- 12,15 ---- *************** *** 21,25 **** import net.heilancoo.portal.responses.RequestTarget; import net.heilancoo.portal.responses.ValidResponseFormats; ! import net.heilancoo.portal.session.ChangeController; /** --- 17,25 ---- import net.heilancoo.portal.responses.RequestTarget; import net.heilancoo.portal.responses.ValidResponseFormats; ! import net.heilancoo.portal.session.ChangeControllers; ! ! import org.apache.http.HttpRequest; ! import org.apache.http.HttpResponse; ! import org.apache.http.protocol.HttpContext; /** *************** *** 27,30 **** --- 27,31 ---- * */ + @ChangeControllers({ TheExport.class, ThePreferences.class }) public class TheMain implements RequestTarget { *************** *** 51,58 **** model.put("s", s); } - - @ChangeController - public ThePreferences prefs(TheSession s, FormFieldContainer fields) { - return new ThePreferences(s); - } } --- 52,54 ---- --- NEW FILE: TheExport.java --- /* * Copyright (c) 2009 Heilan' Coo -- Joerg Bullmann * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which is available at http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Joerg Bullmann <jb...@he...> */ package net.heilancoo.portal.examples.controllerchange; import org.apache.http.HttpRequest; import org.apache.http.HttpResponse; import org.apache.http.protocol.HttpContext; import net.heilancoo.portal.freemarker.FreeMarkerModel; import net.heilancoo.portal.htmlforms.FormFieldContainer; import net.heilancoo.portal.responses.EntryPoint; import net.heilancoo.portal.responses.Request; import net.heilancoo.portal.responses.RequestTarget; import net.heilancoo.portal.session.ChangeController; import net.heilancoo.portal.session.ChangeControllers; /** * @author joerg * */ @EntryPoint("export") @ChangeControllers({ TheMain.class, ThePreferences.class }) public class TheExport implements RequestTarget { private TheSession s; public TheExport(TheSession s) { this.s = s; } @Request public void export(HttpRequest request, FormFieldContainer fields, HttpResponse response, HttpContext context, FreeMarkerModel model) { s.access(); model.put("s", s); } @ChangeController public TheMain main(TheSession s, FormFieldContainer fields) { return new TheMain(s); } } Index: ThePreferences.java =================================================================== RCS file: /cvsroot/lipog/net.heilancoo.portal.examples/src/net/heilancoo/portal/examples/controllerchange/ThePreferences.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ThePreferences.java 1 May 2009 13:42:47 -0000 1.1 --- ThePreferences.java 10 May 2009 19:51:40 -0000 1.2 *************** *** 46,50 **** @ChangeController public TheMain main(TheSession s, FormFieldContainer fields) { ! return new TheMain(s); } } --- 46,55 ---- @ChangeController public TheMain main(TheSession s, FormFieldContainer fields) { ! return null; ! } ! ! @ChangeController ! public TheExport export(TheSession s, FormFieldContainer fields) { ! return null; } } Index: TheSession.java =================================================================== RCS file: /cvsroot/lipog/net.heilancoo.portal.examples/src/net/heilancoo/portal/examples/controllerchange/TheSession.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TheSession.java 1 May 2009 13:42:47 -0000 1.1 --- TheSession.java 10 May 2009 19:51:40 -0000 1.2 *************** *** 22,26 **** * */ ! @ValidControllers({ TheMain.class, ThePreferences.class }) public class TheSession implements Session { --- 22,26 ---- * */ ! @ValidControllers({ TheMain.class, ThePreferences.class, TheExport.class }) public class TheSession implements Session { |
From: Joerg B. <jb...@us...> - 2009-05-10 19:51:47
|
Update of /cvsroot/lipog/net.heilancoo.portal.examples/templates In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv25741/templates Modified Files: main.html Added Files: export.html Log Message: easier controller changing: @ChangeControllers annotation --- NEW FILE: export.html --- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>This is ${s.user}'s Exports</title> </head> <body> <h1>My exports</h1> <p>user = ${s.user}</p> <p>serial = ${s.getSerial()}</p> <p>access count = ${s.getAccess()}</p> <p>Go back to <a href="main">main</a>.</p> <p>Or: change your <a href="prefs">preferences</a>.</p> <p>Or: <a href="logout">Log out</a>.</p> </body> </html> Index: main.html =================================================================== RCS file: /cvsroot/lipog/net.heilancoo.portal.examples/templates/main.html,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** main.html 1 May 2009 13:42:47 -0000 1.1 --- main.html 10 May 2009 19:51:40 -0000 1.2 *************** *** 3,16 **** <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> ! <title>This is ${s.getUser()}</title> </head> <body> <h1>My Session</h1> ! <p>user = ${s.getUser()}</p> ! <p>serial = ${s.getSerial()}</p> ! <p>access count = ${s.getAccess()}</p> <p>Try this page again in <a href="main">HTML</a>.</p> <p>Try the other page in <a href="other.html">HTML</a>.</p> <p>Try the other page as <a href="other">plain text</a>.</p> <p>Or: change your <a href="prefs">preferences</a>.</p> <p>Or: <a href="logout">Log out</a>.</p> --- 3,17 ---- <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> ! <title>This is ${s.user}</title> </head> <body> <h1>My Session</h1> ! <p>user = ${s.user}</p> ! <p>serial = ${s.serial}</p> ! <p>access count = ${s.access}</p> <p>Try this page again in <a href="main">HTML</a>.</p> <p>Try the other page in <a href="other.html">HTML</a>.</p> <p>Try the other page as <a href="other">plain text</a>.</p> + <p>Or: visit your <a href="export">export</a>.</p> <p>Or: change your <a href="prefs">preferences</a>.</p> <p>Or: <a href="logout">Log out</a>.</p> |
From: Joerg B. <jb...@us...> - 2009-05-10 19:51:45
|
Update of /cvsroot/lipog/net.heilancoo.portal/src/net/heilancoo/portal/session In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv25718/src/net/heilancoo/portal/session Modified Files: ControllerChanger.java ChangeController.java Added Files: ChangeControllers.java Log Message: easier controller changing: @ChangeControllers annotation --- NEW FILE: ChangeControllers.java --- /* * Copyright (c) 2009 Heilan' Coo -- Joerg Bullmann * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which is available at http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Joerg Bullmann <jb...@he...> */ package net.heilancoo.portal.session; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** * @author joerg * */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) public @interface ChangeControllers { Class<?> [] value(); } Index: ChangeController.java =================================================================== RCS file: /cvsroot/lipog/net.heilancoo.portal/src/net/heilancoo/portal/session/ChangeController.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ChangeController.java 1 May 2009 13:30:55 -0000 1.1 --- ChangeController.java 10 May 2009 19:51:36 -0000 1.2 *************** *** 24,26 **** --- 24,27 ---- @Target(ElementType.METHOD) public @interface ChangeController { + Class<?> value() default Object.class; } Index: ControllerChanger.java =================================================================== RCS file: /cvsroot/lipog/net.heilancoo.portal/src/net/heilancoo/portal/session/ControllerChanger.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ControllerChanger.java 1 May 2009 13:30:55 -0000 1.1 --- ControllerChanger.java 10 May 2009 19:51:36 -0000 1.2 *************** *** 12,15 **** --- 12,16 ---- package net.heilancoo.portal.session; + import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; *************** *** 18,21 **** --- 19,23 ---- import net.heilancoo.portal.requests.ResponseHelper; import net.heilancoo.portal.responses.RequestTarget; + import net.heilancoo.portal.responses.RequestTargetManager; import org.apache.http.HttpResponse; *************** *** 28,47 **** public class ControllerChanger { private final Method method; private final Class<?> sessionClass; public ControllerChanger(Method method) { ! this.method = method; ! this.sessionClass = method.getParameterTypes()[0]; } public boolean change(SessionCompound sessionCompound, FormFieldContainer fields, HttpResponse response) throws IllegalArgumentException, ! IllegalAccessException, InvocationTargetException, ClassCastException { RequestTarget c = sessionCompound.getController(); Session s = sessionCompound.getSession(); ! Object o = method.invoke(c, sessionClass.cast(s), fields); if(o == null) { ResponseHelper.error(HttpStatus.SC_INTERNAL_SERVER_ERROR, response, --- 30,202 ---- public class ControllerChanger { + /* + * Below enum defines the the priority for constructor/ + * initialiser selection. Highest priority at the top. + */ + public enum InitMode { + CtorSessionControllerFields(0, true), + InitSessionControllerFields(0, false), + CtorSessionFields(1, true), + InitSessionFields(1, false), + CtorSessionController(2, true), + InitSessionController(2, false), + CtorSession(3, true), + InitSession(3, false), + None(4, false); + + public int id; + public boolean ctor; + + InitMode(int id, boolean ctor) { + this.id = id; + this.ctor = ctor; + } + + boolean lessThan(InitMode m) { + return id < m.id; + } + }; + private final Method method; + private final String name; private final Class<?> sessionClass; + private Class<?> newControllerClass; + private final Class<?> currentControllerClass; + private InitMode initMode; + private Method initialiser; + private Constructor<?> constructor; + public ControllerChanger(Class<?> sessionClass, Class<?> currentControllerClass, RequestTargetManager targetManager) { + this.method = null; + this.name = targetManager.getEntryPoint(); + this.newControllerClass = targetManager.getTargetClass(); + this.currentControllerClass = currentControllerClass; + this.sessionClass = sessionClass; + + determineInitMode(); + } + public ControllerChanger(Method method) { ! this.method = method; ! this.name = method.getName(); ! this.sessionClass = method.getParameterTypes()[0]; ! this.currentControllerClass = method.getDeclaringClass(); ! ! determineNewControllerClass(); ! determineInitMode(); ! } ! ! /** ! * Find out which class the controller is of that this controller changer ! * method changes to. ! */ ! private void determineNewControllerClass() { ! ChangeController c = method.getAnnotation(ChangeController.class); ! ! newControllerClass = method.getReturnType(); ! ! if(newControllerClass.getName().equals("void") && c != null && !c.value().equals(Object.class)) ! newControllerClass = c.value(); ! } ! ! /** ! * Find out how instances of the new controller are initialised, if ! * created implicitly. ! */ ! private void determineInitMode() { ! InitMode cMode = InitMode.None; ! InitMode iMode = InitMode.None; ! ! for(Constructor<?> c : newControllerClass.getConstructors()) { ! Class<?> p[] = c.getParameterTypes(); ! ! if(p.length == 3 ! && p[0].equals(sessionClass) ! && p[1].equals(currentControllerClass) ! && p[2].equals(FormFieldContainer.class) ! && InitMode.CtorSessionControllerFields.lessThan(cMode)) { ! constructor = c; ! cMode = InitMode.CtorSessionControllerFields; ! } ! else if(p.length == 2 ! && p[0].equals(sessionClass) ! && p[1].equals(FormFieldContainer.class) ! && InitMode.CtorSessionFields.lessThan(cMode)) { ! constructor = c; ! cMode = InitMode.CtorSessionFields; ! } ! else if(p.length == 2 ! && p[0].equals(sessionClass) ! && p[1].equals(currentControllerClass) ! && InitMode.CtorSessionController.lessThan(cMode)) { ! constructor = c; ! cMode = InitMode.CtorSessionController; ! } ! else if(p.length == 1 ! && p[0].equals(sessionClass) ! && InitMode.CtorSession.lessThan(cMode)) { ! constructor = c; ! cMode = InitMode.CtorSession; ! } ! } ! ! for(Method m : newControllerClass.getMethods()) ! if(m.getName().equals("initialise")) { ! Class<?> p[] = m.getParameterTypes(); ! ! if(p.length == 3 ! && p[0].equals(sessionClass) ! && p[1].equals(currentControllerClass) ! && p[2].equals(FormFieldContainer.class) ! && InitMode.InitSessionControllerFields.lessThan(iMode)) { ! initialiser = m; ! iMode = InitMode.InitSessionControllerFields; ! } ! else if(p.length == 2 ! && p[0].equals(sessionClass) ! && p[1].equals(FormFieldContainer.class) ! && InitMode.InitSessionFields.lessThan(iMode)) { ! initialiser = m; ! iMode = InitMode.InitSessionFields; ! } ! else if(p.length == 2 ! && p[0].equals(sessionClass) ! && p[1].equals(currentControllerClass) ! && InitMode.InitSessionController.lessThan(iMode)) { ! initialiser = m; ! iMode = InitMode.InitSessionController; ! } ! else if(p.length == 1 ! && p[0].equals(sessionClass) ! && InitMode.InitSession.lessThan(iMode)) { ! initialiser = m; ! iMode = InitMode.InitSession; ! } ! } ! ! if(iMode.equals(InitMode.None)) ! initMode = cMode; ! else if(cMode.equals(InitMode.None)) ! initMode = iMode; ! else if(cMode.lessThan(iMode)) ! initMode = iMode; ! else ! initMode = cMode; } public boolean change(SessionCompound sessionCompound, FormFieldContainer fields, HttpResponse response) throws IllegalArgumentException, ! IllegalAccessException, InvocationTargetException, ClassCastException, InstantiationException { RequestTarget c = sessionCompound.getController(); Session s = sessionCompound.getSession(); ! Object o = null; ! ! if(method != null) ! o = method.invoke(c, sessionClass.cast(s), fields); + if(o == null) + o = createNew(sessionCompound, fields); + if(o == null) { ResponseHelper.error(HttpStatus.SC_INTERNAL_SERVER_ERROR, response, *************** *** 62,71 **** } public String getName() { ! return method.getName(); } public String getControllerClassName() { ! return method.getReturnType().getCanonicalName(); } } --- 217,273 ---- } + private Object createNew(SessionCompound sc, FormFieldContainer fields) throws IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException { + Object o; + + switch(initMode) { + case CtorSessionControllerFields: + o = constructor.newInstance(sc.getSession(), sc.getController(), fields); + break; + + case CtorSessionFields: + o = constructor.newInstance(sc.getSession(), fields); + break; + + case CtorSessionController: + o = constructor.newInstance(sc.getSession(), sc.getController()); + break; + + case CtorSession: + o = constructor.newInstance(sc.getSession()); + break; + + case InitSessionControllerFields: + o = newControllerClass.newInstance(); + initialiser.invoke(o, sc.getSession(), sc.getController(), fields); + break; + + case InitSessionFields: + o = newControllerClass.newInstance(); + initialiser.invoke(o, sc.getSession(), fields); + break; + + case InitSessionController: + o = newControllerClass.newInstance(); + initialiser.invoke(o, sc.getSession(), sc.getController()); + break; + + case InitSession: + o = newControllerClass.newInstance(); + initialiser.invoke(o, sc.getSession()); + break; + + default: + o = null; + } + + return o; + } + public String getName() { ! return name; } public String getControllerClassName() { ! return newControllerClass.getCanonicalName(); } } |
From: Joerg B. <jb...@us...> - 2009-05-10 19:51:45
|
Update of /cvsroot/lipog/net.heilancoo.portal/src/net/heilancoo/portal/responses In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv25718/src/net/heilancoo/portal/responses Modified Files: RequestTargetManager.java Log Message: easier controller changing: @ChangeControllers annotation Index: RequestTargetManager.java =================================================================== RCS file: /cvsroot/lipog/net.heilancoo.portal/src/net/heilancoo/portal/responses/RequestTargetManager.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** RequestTargetManager.java 1 May 2009 13:30:55 -0000 1.2 --- RequestTargetManager.java 10 May 2009 19:51:37 -0000 1.3 *************** *** 19,22 **** --- 19,23 ---- import net.heilancoo.portal.requests.MimeTypeMapper; import net.heilancoo.portal.session.ChangeController; + import net.heilancoo.portal.session.ChangeControllers; import net.heilancoo.portal.session.ControllerChanger; *************** *** 38,41 **** --- 39,43 ---- private final Map<String, ControllerChanger> changers; + private boolean stateOk; private boolean initialised; *************** *** 50,64 **** this.exitPoint = defaultEntryPoint == null ? null : (exp != null ? exp.value() : defaultExitPoint); this.initialised = false; } ! public boolean initialise(Bundle bundle, String logTag, MimeTypeMapper mimeMapper) { ! boolean stateOk = true; ! if(initialised) { logger.error("Attempt at multiple initialisation of " + logTag + " class " + targetClass.getCanonicalName() + "."); ! return false; } ! logger.info("Initialising " + logTag + " class " + targetClass.getCanonicalName() + "."); for(Method m : targetClass.getMethods()) { --- 52,65 ---- this.exitPoint = defaultEntryPoint == null ? null : (exp != null ? exp.value() : defaultExitPoint); this.initialised = false; + this.stateOk = true; } ! public void initialiseMethods(Bundle bundle, String logTag, MimeTypeMapper mimeMapper) { if(initialised) { logger.error("Attempt at multiple initialisation of " + logTag + " class " + targetClass.getCanonicalName() + "."); ! return; } ! logger.info("Initialising methods for " + logTag + " class " + targetClass.getCanonicalName() + "."); for(Method m : targetClass.getMethods()) { *************** *** 82,85 **** --- 83,127 ---- } + logger.info("Done initialising methods for " + logTag + " class " + targetClass.getCanonicalName() + "."); + } + + public void initialiseChangers(String logTag, Class<?> sessionClass, Map<Class<?>, RequestTargetManager> targetManagerMap) { + ChangeControllers vc = targetClass.getAnnotation(ChangeControllers.class); + + if(vc == null) + return; + + logger.info("Initialising target changers for " + logTag + " class " + targetClass.getCanonicalName() + "."); + + Class<?> [] changeTargets = vc.value(); + + for(Class<?> newTarget : changeTargets) { + RequestTargetManager newManager = targetManagerMap.get(newTarget); + + if(newManager == null) { + logger.error("Unknown target manager class " + newTarget.getCanonicalName() + "."); + stateOk = false; + continue; + } + + String entry = newManager.getEntryPoint(); + + if(responders.containsKey(entry)) { + logger.error("Responder method " + entry + " hides target changer in " + targetClass.getCanonicalName() + "."); + stateOk = false; + } + else if(!changers.containsKey(entry)) { + ControllerChanger c = new ControllerChanger(sessionClass, targetClass, newManager); + changers.put(newManager.getEntryPoint(), c); + logger.info("Controller change method " + c.getName() + " creates " + c.getControllerClassName() + "."); + } + } + + logger.info("Done initialising target changers for " + logTag + " class " + targetClass.getCanonicalName() + "."); + } + + public boolean wrapUpInitialisations(String logTag) { + logger.info("Summarize initialisation for " + logTag + " class " + targetClass.getCanonicalName() + "."); + logger.info("Found " + responders.size() + " response method(s)."); *************** *** 111,115 **** initialised = true; ! return stateOk; } --- 153,157 ---- initialised = true; ! return stateOk; } *************** *** 127,130 **** --- 169,176 ---- } + public Class<?> getTargetClass() { + return targetClass; + } + public ControllerChanger getChanger(String request) { return changers.get(request); |
From: Joerg B. <jb...@us...> - 2009-05-10 19:51:45
|
Update of /cvsroot/lipog/net.heilancoo.portal/src/net/heilancoo/portal/application In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv25718/src/net/heilancoo/portal/application Modified Files: ApplicationRequestHandler.java Log Message: easier controller changing: @ChangeControllers annotation Index: ApplicationRequestHandler.java =================================================================== RCS file: /cvsroot/lipog/net.heilancoo.portal/src/net/heilancoo/portal/application/ApplicationRequestHandler.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ApplicationRequestHandler.java 4 May 2009 22:06:00 -0000 1.8 --- ApplicationRequestHandler.java 10 May 2009 19:51:37 -0000 1.9 *************** *** 179,189 **** ValidControllers vc = sessionClass.getAnnotation(ValidControllers.class); ! if(vc != null) { ! for(Class<?> controllerClass : vc.value()) ! if(!initialiseSession(controllerClass, bundle)) ! stateOk = false; ! } else ! if(!initialiseSession(sessionClass, bundle)) stateOk = false; } --- 179,193 ---- ValidControllers vc = sessionClass.getAnnotation(ValidControllers.class); ! if(vc == null) ! initialiseController(sessionClass, "session", bundle); else ! for(Class<?> controllerClass : vc.value()) ! initialiseController(controllerClass, "controller", bundle); ! ! for(RequestTargetManager tm : targetManagerMap.values()) ! tm.initialiseChangers("controller", sessionClass, targetManagerMap); ! ! for(RequestTargetManager tm : targetManagerMap.values()) ! if(!tm.wrapUpInitialisations("controller")) stateOk = false; } *************** *** 208,215 **** }); ! return tm.initialise(bundle, "application", mimeMapper); } ! private boolean initialiseSession(Class<?> sessionClass, Bundle bundle) { RequestTargetManager tm = new RequestTargetManager(sessionClass, "main", "logout"); --- 212,220 ---- }); ! tm.initialiseMethods(bundle, "application", mimeMapper); ! return tm.wrapUpInitialisations("application"); } ! private void initialiseController(Class<?> sessionClass, String logTag, Bundle bundle) { RequestTargetManager tm = new RequestTargetManager(sessionClass, "main", "logout"); *************** *** 226,230 **** }); ! return tm.initialise(bundle, "session", mimeMapper); } --- 231,235 ---- }); ! tm.initialiseMethods(bundle, logTag, mimeMapper); } *************** *** 316,320 **** logger.info("Controller change " + method + ", application " + getUriPrefix() + ", session " + targetKey + ", " + c.getControllerClassName()); - dispatchSessionMethod(method, presentation, targetKey, request, fields, response, context); } --- 321,324 ---- |
From: Joerg B. <jb...@us...> - 2009-05-04 22:18:29
|
Update of /cvsroot/lipog/net.heilancoo.portal.documentation/doc In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv22010/doc Modified Files: change-log.html Log Message: updated to cover latest form field decoding related changes Index: change-log.html =================================================================== RCS file: /cvsroot/lipog/net.heilancoo.portal.documentation/doc/change-log.html,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** change-log.html 4 May 2009 18:28:19 -0000 1.16 --- change-log.html 4 May 2009 22:18:15 -0000 1.17 *************** *** 11,14 **** --- 11,17 ---- <h2>Release 4 (upcoming)</h2> <ul> + <li>Form field decoding is now done much later, just before the form fields are actually needed; as a + consequence in cases of malformed URIs or bad session keys form fields will not be decoded at all which saves + resources.</li> <li>The Gizmo now identifies itself as 'Little-Portal-Gizmo/1.1'</li> <li>Delegate request processing to controllers. Be able to switch controllers |
From: Joerg B. <jb...@us...> - 2009-05-04 22:18:00
|
Update of /cvsroot/lipog/net.heilancoo.portal.documentation/doc In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv21923/doc Modified Files: index.html Log Message: updated to include reference to commit mailing list Index: index.html =================================================================== RCS file: /cvsroot/lipog/net.heilancoo.portal.documentation/doc/index.html,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** index.html 4 May 2009 18:28:08 -0000 1.14 --- index.html 4 May 2009 22:17:46 -0000 1.15 *************** *** 60,64 **** releases very often.</li> <li>Consider checking the <a href="change-log.html">Change Log</a>. It tells you what's going on.</li> ! <li>Consider joining the <a href="http://sourceforge.net/mail/?group_id=257822">Mailing List</a>.</li> </ul> --- 60,64 ---- releases very often.</li> <li>Consider checking the <a href="change-log.html">Change Log</a>. It tells you what's going on.</li> ! <li>Consider joining the <a href="http://sourceforge.net/mail/?group_id=257822">Mailing Lists</a>.</li> </ul> *************** *** 83,87 **** <ul> <li><a href="http://sourceforge.net/forum/?group_id=257822">Forum</a></li> ! <li><a href="http://sourceforge.net/mail/?group_id=257822">Mailing List</a></li> <li><script type="text/javascript"> //<![CDATA[ --- 83,87 ---- <ul> <li><a href="http://sourceforge.net/forum/?group_id=257822">Forum</a></li> ! <li><a href="http://sourceforge.net/mail/?group_id=257822">Mailing Lists</a></li> <li><script type="text/javascript"> //<![CDATA[ |
From: Joerg B. <jb...@us...> - 2009-05-04 22:06:11
|
Update of /cvsroot/lipog/net.heilancoo.portal/src/net/heilancoo/portal/application In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv20004/src/net/heilancoo/portal/application Modified Files: ApplicationRequestHandler.java Log Message: decodeFrom(..) -> decodeFields(..) Index: ApplicationRequestHandler.java =================================================================== RCS file: /cvsroot/lipog/net.heilancoo.portal/src/net/heilancoo/portal/application/ApplicationRequestHandler.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ApplicationRequestHandler.java 4 May 2009 21:57:02 -0000 1.7 --- ApplicationRequestHandler.java 4 May 2009 22:06:00 -0000 1.8 *************** *** 265,269 **** try { ! FormFieldContainer fields = FormFieldDecoder.decodeFrom(request); RequestTargetManager tm = getTargetManager(application, response); --- 265,269 ---- try { ! FormFieldContainer fields = FormFieldDecoder.decodeFields(request); RequestTargetManager tm = getTargetManager(application, response); *************** *** 305,309 **** if(fields == null) ! fields = FormFieldDecoder.decodeFrom(request); Responder g = tm.getResponder(method); --- 305,309 ---- if(fields == null) ! fields = FormFieldDecoder.decodeFields(request); Responder g = tm.getResponder(method); |
From: Joerg B. <jb...@us...> - 2009-05-04 22:06:09
|
Update of /cvsroot/lipog/net.heilancoo.portal/src/net/heilancoo/portal/htmlforms In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv20004/src/net/heilancoo/portal/htmlforms Modified Files: FormReadingRequest.java FormFieldDecoder.java Log Message: decodeFrom(..) -> decodeFields(..) Index: FormFieldDecoder.java =================================================================== RCS file: /cvsroot/lipog/net.heilancoo.portal/src/net/heilancoo/portal/htmlforms/FormFieldDecoder.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** FormFieldDecoder.java 4 May 2009 21:57:02 -0000 1.1 --- FormFieldDecoder.java 4 May 2009 22:06:00 -0000 1.2 *************** *** 26,30 **** public class FormFieldDecoder { ! public static FormFieldContainer decodeFrom(HttpRequest request) throws ParseException, IOException { FormFieldContainer fields = new FormFieldContainer(); --- 26,30 ---- public class FormFieldDecoder { ! public static FormFieldContainer decodeFields(HttpRequest request) throws ParseException, IOException { FormFieldContainer fields = new FormFieldContainer(); Index: FormReadingRequest.java =================================================================== RCS file: /cvsroot/lipog/net.heilancoo.portal/src/net/heilancoo/portal/htmlforms/FormReadingRequest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** FormReadingRequest.java 4 May 2009 21:57:02 -0000 1.3 --- FormReadingRequest.java 4 May 2009 22:06:00 -0000 1.4 *************** *** 35,39 **** public void handle(HttpRequest request, HttpResponse response, HttpContext context) throws HttpException, IOException { ! FormFieldContainer fields = FormFieldDecoder.decodeFrom(request); handler.handleRequest(request, fields, response, context); } --- 35,39 ---- public void handle(HttpRequest request, HttpResponse response, HttpContext context) throws HttpException, IOException { ! FormFieldContainer fields = FormFieldDecoder.decodeFields(request); handler.handleRequest(request, fields, response, context); } |
From: Jörg B. <jb...@us...> - 2009-05-04 21:57:14
|
Update of /cvsroot/lipog/net.heilancoo.portal/src/net/heilancoo/portal/application In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv18544/src/net/heilancoo/portal/application Modified Files: ApplicationRequestHandler.java Log Message: application request handler now decodes form fields as late as possible so it can be avoided in case of e.g. malformed requests or missing sessions or so Index: ApplicationRequestHandler.java =================================================================== RCS file: /cvsroot/lipog/net.heilancoo.portal/src/net/heilancoo/portal/application/ApplicationRequestHandler.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ApplicationRequestHandler.java 1 May 2009 13:30:55 -0000 1.6 --- ApplicationRequestHandler.java 4 May 2009 21:57:02 -0000 1.7 *************** *** 24,30 **** import net.heilancoo.portal.PortalPlugin; import net.heilancoo.portal.htmlforms.FormFieldContainer; import net.heilancoo.portal.requests.FileRequestHandler; import net.heilancoo.portal.requests.MimeTypeMapper; - import net.heilancoo.portal.requests.RequestHandler; import net.heilancoo.portal.requests.ResponseHelper; import net.heilancoo.portal.responses.FileResponder; --- 24,30 ---- import net.heilancoo.portal.PortalPlugin; import net.heilancoo.portal.htmlforms.FormFieldContainer; + import net.heilancoo.portal.htmlforms.FormFieldDecoder; import net.heilancoo.portal.requests.FileRequestHandler; import net.heilancoo.portal.requests.MimeTypeMapper; import net.heilancoo.portal.requests.ResponseHelper; import net.heilancoo.portal.responses.FileResponder; *************** *** 43,46 **** --- 43,47 ---- import org.apache.http.HttpStatus; import org.apache.http.protocol.HttpContext; + import org.apache.http.protocol.HttpRequestHandler; import org.apache.log4j.Logger; import org.osgi.framework.Bundle; *************** *** 50,54 **** * */ ! public class ApplicationRequestHandler implements RequestHandler { private static final Logger logger = Logger.getLogger(ApplicationRequestHandler.class); --- 51,55 ---- * */ ! public class ApplicationRequestHandler implements HttpRequestHandler { private static final Logger logger = Logger.getLogger(ApplicationRequestHandler.class); *************** *** 228,233 **** } ! public void handleRequest(HttpRequest request, FormFieldContainer fields, ! HttpResponse response, HttpContext context) { String uri = request.getRequestLine().getUri(); int paramStart = uri.indexOf('?'); --- 229,234 ---- } ! @Override ! public void handle(HttpRequest request, HttpResponse response, HttpContext context) { String uri = request.getRequestLine().getUri(); int paramStart = uri.indexOf('?'); *************** *** 244,248 **** if(components.length == 2) ! dispatchApplicationMethod(method, presentation, request, fields, response, context); else if(components.length == 3) { String key = components[1]; --- 245,249 ---- if(components.length == 2) ! dispatchApplicationMethod(method, presentation, request, response, context); else if(components.length == 3) { String key = components[1]; *************** *** 252,256 **** ResponseHelper.error(HttpStatus.SC_NOT_FOUND, response, "No Session", "No session " + key + "."); else ! dispatchSessionMethod(method, presentation, key, request, fields, response, context); } else --- 253,257 ---- ResponseHelper.error(HttpStatus.SC_NOT_FOUND, response, "No Session", "No session " + key + "."); else ! dispatchSessionMethod(method, presentation, key, request, null, response, context); } else *************** *** 260,269 **** private void dispatchApplicationMethod(String method, String presentation, HttpRequest request, ! FormFieldContainer fields, HttpResponse response, ! HttpContext context) { response.addHeader("Cache-Control", "no-cache"); try { ! RequestTargetManager tm = getTargetManager(application, response); if(tm == null) --- 261,270 ---- private void dispatchApplicationMethod(String method, String presentation, HttpRequest request, ! HttpResponse response, HttpContext context) { response.addHeader("Cache-Control", "no-cache"); try { ! FormFieldContainer fields = FormFieldDecoder.decodeFrom(request); ! RequestTargetManager tm = getTargetManager(application, response); if(tm == null) *************** *** 292,297 **** private void dispatchSessionMethod(String method, String presentation, String targetKey, HttpRequest request, ! FormFieldContainer fields, HttpResponse response, ! HttpContext context) { response.addHeader("Cache-Control", "no-cache"); --- 293,297 ---- private void dispatchSessionMethod(String method, String presentation, String targetKey, HttpRequest request, ! FormFieldContainer fields, HttpResponse response, HttpContext context) { response.addHeader("Cache-Control", "no-cache"); *************** *** 304,307 **** --- 304,310 ---- return; + if(fields == null) + fields = FormFieldDecoder.decodeFrom(request); + Responder g = tm.getResponder(method); |
From: Jörg B. <jb...@us...> - 2009-05-04 21:57:12
|
Update of /cvsroot/lipog/net.heilancoo.portal/src/net/heilancoo/portal/htmlforms In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv18544/src/net/heilancoo/portal/htmlforms Modified Files: FormReadingRequest.java Added Files: FormFieldDecoder.java Log Message: application request handler now decodes form fields as late as possible so it can be avoided in case of e.g. malformed requests or missing sessions or so --- NEW FILE: FormFieldDecoder.java --- /* * Copyright (c) 2009 Heilan' Coo -- Joerg Bullmann * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which is available at http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Joerg Bullmann <jb...@he...> */ package net.heilancoo.portal.htmlforms; import java.io.IOException; import org.apache.http.HttpEntity; import org.apache.http.HttpEntityEnclosingRequest; import org.apache.http.HttpRequest; import org.apache.http.ParseException; import org.apache.http.util.EntityUtils; /** * @author joerg * */ public class FormFieldDecoder { public static FormFieldContainer decodeFrom(HttpRequest request) throws ParseException, IOException { FormFieldContainer fields = new FormFieldContainer(); if(request instanceof HttpEntityEnclosingRequest) { //if(request.)... beware file uploads... HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity(); String entityContent = EntityUtils.toString(entity); fields.addFromString(entityContent); } fields.addFromUri(request.getRequestLine().getUri()); return fields; } } Index: FormReadingRequest.java =================================================================== RCS file: /cvsroot/lipog/net.heilancoo.portal/src/net/heilancoo/portal/htmlforms/FormReadingRequest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** FormReadingRequest.java 10 Apr 2009 15:08:33 -0000 1.2 --- FormReadingRequest.java 4 May 2009 21:57:02 -0000 1.3 *************** *** 16,21 **** import net.heilancoo.portal.requests.RequestHandler; - import org.apache.http.HttpEntity; - import org.apache.http.HttpEntityEnclosingRequest; import org.apache.http.HttpException; import org.apache.http.HttpRequest; --- 16,19 ---- *************** *** 23,27 **** import org.apache.http.protocol.HttpContext; import org.apache.http.protocol.HttpRequestHandler; - import org.apache.http.util.EntityUtils; /** --- 21,24 ---- *************** *** 38,52 **** public void handle(HttpRequest request, HttpResponse response, HttpContext context) throws HttpException, IOException { ! FormFieldContainer fields = new FormFieldContainer(); ! ! if(request instanceof HttpEntityEnclosingRequest) { ! //if(request.)... beware file uploads... ! HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity(); ! String entityContent = EntityUtils.toString(entity); ! fields.addFromString(entityContent); ! } ! ! fields.addFromUri(request.getRequestLine().getUri()); ! handler.handleRequest(request, fields, response, context); } --- 35,39 ---- public void handle(HttpRequest request, HttpResponse response, HttpContext context) throws HttpException, IOException { ! FormFieldContainer fields = FormFieldDecoder.decodeFrom(request); handler.handleRequest(request, fields, response, context); } |
From: Jörg B. <jb...@us...> - 2009-05-04 21:57:09
|
Update of /cvsroot/lipog/net.heilancoo.portal/src/net/heilancoo/portal In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv18544/src/net/heilancoo/portal Modified Files: PortalPlugin.java Log Message: application request handler now decodes form fields as late as possible so it can be avoided in case of e.g. malformed requests or missing sessions or so Index: PortalPlugin.java =================================================================== RCS file: /cvsroot/lipog/net.heilancoo.portal/src/net/heilancoo/portal/PortalPlugin.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** PortalPlugin.java 23 Apr 2009 19:12:05 -0000 1.14 --- PortalPlugin.java 4 May 2009 21:57:02 -0000 1.15 *************** *** 243,249 **** application.initialise(handler); webAppMap.put(uriPrefix, handler); ! FormReadingRequest formHandler = new FormReadingRequest(handler); ! requestHandlerMap.put("/" + uriPrefix, formHandler); ! requestHandlerMap.put("/" + uriPrefix + "/*", formHandler); } } --- 243,248 ---- application.initialise(handler); webAppMap.put(uriPrefix, handler); ! requestHandlerMap.put("/" + uriPrefix, handler); ! requestHandlerMap.put("/" + uriPrefix + "/*", handler); } } |
From: Jörg B. <jb...@us...> - 2009-05-04 21:55:29
|
Update of /cvsroot/lipog/net.heilancoo.portal/src/net/heilancoo/portal/session In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv18321/src/net/heilancoo/portal/session Modified Files: SessionCompound.java Log Message: add some comment Index: SessionCompound.java =================================================================== RCS file: /cvsroot/lipog/net.heilancoo.portal/src/net/heilancoo/portal/session/SessionCompound.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SessionCompound.java 1 May 2009 13:30:55 -0000 1.1 --- SessionCompound.java 4 May 2009 21:55:22 -0000 1.2 *************** *** 15,20 **** /** * @author joerg - * */ public class SessionCompound { --- 15,28 ---- /** + * A SessionCompound is a bit more than a Session. It is a Session plus + * the currently active Controller of that Session. The active + * controller of a session is the active RequestTarget, the object + * HTTP requests will be run against. + * <p> + * The SessionCompound is not normally visible to Gizmo web + * applications but acts behind the scenes instead. + * <p> + * Someone come up with a nicer name than "SessionCompound." * @author joerg */ public class SessionCompound { |
From: Jörg B. <jb...@us...> - 2009-05-04 19:51:49
|
Update of /cvsroot/lipog/net.heilancoo.portal.documentation/doc In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv1249/doc Modified Files: getting-ready.html Log Message: added examples plug-in Index: getting-ready.html =================================================================== RCS file: /cvsroot/lipog/net.heilancoo.portal.documentation/doc/getting-ready.html,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** getting-ready.html 7 Apr 2009 16:27:09 -0000 1.6 --- getting-ready.html 4 May 2009 19:51:32 -0000 1.7 *************** *** 9,97 **** <p><a href="index.html">Home of Little Portal Gizmo</a></p> <h1>Getting Ready for Development with the Gizmo</h1> ! <p>Developing web apps with the Gizmo means developing one or more Eclipse plug-ins, ! based on the Gizmo base plug-ins. You need to set up an Eclipse workspace containing the Gizmo base ! plug-ins to start with. Here are the plug-ins making up the project with a bit of a (very brief) description of what they do.</p> <table> ! <tr> ! <th>Plug-in</th><th>Description</th> ! </tr> ! <tr> ! <td>net.heilancoo.portal</td><td>The core portal code. The web server/web application container.</td> ! </tr> ! <tr> ! <td>net.heilancoo.portal.test</td><td>JUnit tests for net.heilancoo.portal.</td> ! </tr> ! <tr> ! <td>net.heilancoo.portal.admin</td><td>A mini web app (actually a "request handler") that shows a directory ! of all web apps installed. You get this, when requesting the root URI ("/").</td> ! </tr> ! <tr> ! <td>net.heilancoo.portal.freemarker</td><td>A response generator using the Freemarker template engine.</td> ! </tr> ! <tr> ! <td>net.heilancoo.portal.json</td><td>A response generator for generating JSON responses.</td> ! </tr> ! <tr> ! <td>net.heilancoo.utils</td><td>Utility classes not strictly related to the portal related functionality.</td> ! </tr> ! <tr> ! <td>org.apache.httpcore</td><td>The Apache HttpComponents jar files, just packaged up as an Eclipse plug-in.</td> ! </tr> ! <tr> ! <td>org.dojotoolkit</td><td>The Dojo JavaScript library files packaged in an Eclipse plug-in. ! This is not necessary on a technical level for the Gizmo to work. I have used it in a web app I have written ! in the Gizmo. So I just include it here. It also gives an example of how non-Java (static) content can ! be packaged in an Eclipse plug-in to be used with (or served from) the Gizmo.</td> ! </tr> ! <tr> ! <td>org.freemarker</td><td>The Freemarker template engine jar file, just packaged up as an Eclipse plug-in.</td> ! </tr> ! <tr> ! <td>org.json</td><td>The JSON Java sources (as taken from the JSON web site), just packaged up as an Eclipse plug-in.</td> ! </tr> ! <tr> ! <td>net.heilancoo.portal.documentation</td><td>The project documentation, including this file here. When installed ! along with the rest of the portal, it should be reachable via the URI "/portaldocs". Strictly speaking, not ! technically needed for development.</td> ! </tr> ! <tr> ! <td>net.heilancoo.portal.bingo</td><td>The bingo web app used as example in the tutorials. Not needed for development.</td> ! </tr> </table> <h2>Checking Out Gizmo Plug-ins From CVS</h2> ! <p>There is standard SF <a href="http://sourceforge.net/scm/?type=cvs&group_id=257822">info on CVS access</a> ! telling you how to connect to the Gizmo CVS repository. Create a new empty workspace and check out the plug-ins ! above.</p> <p>An empty workspace:</p> ! <img src="snaps/cvs-checkout-1.png"> <p>Use the import "Projects from CVS" option:</p> ! <img src="snaps/cvs-checkout-2.png"> <p>Connect as anonymous user to the Gizmo repository:</p> ! <img src="snaps/cvs-checkout-3.png"> ! <p>Click the "configure connection preferences..." link to enable connection compression. Don't forget ! to click OK.</p> ! <img src="snaps/cvs-checkout-4.png"> ! <p>In the "Select Module" dialog, click the "User existing module" radio button. This will bring up ! the list of existing modules. Select all but the "CVSROOT" one. Then click "Finish" to kick off the ! checkout.</p> ! <img src="snaps/cvs-checkout-5.png"> ! <p>Your workspace will be populated with the Gizmo plug-ins. It should then look a bit like this here:</p> ! <img src="snaps/cvs-checkout-6.png"> <p>That's it, you're ready to go.</p> <h2>Downloading a Packaged Gizmo Release</h2> ! <p>Go to the Gizmo downloads page and get the packages of the release you want to use.</p> <p>Unpack the packages to a temporary location.</p> ! <p>In Eclipse, create a new empty workspace and import the plug-ins using the Eclipse import ! "Existing Projects into Workspace" function.</p> ! <p class="revinfo"> <div id="rev">$Revision$</div> <div id="date">$Date$</div> <div id="auth">$Author$</div> ! </p> ! <a href="http://sourceforge.net/projects/lipog"> ! <img src="http://sflogo.sourceforge.net/sflogo.php?group_id=257822&type=16" ! border="0" width="150" height="40" ! alt="Get Little Portal Gizmo at SourceForge.net. Fast, secure and Free Open Source software downloads" /></a> </body> </html> \ No newline at end of file --- 9,129 ---- <p><a href="index.html">Home of Little Portal Gizmo</a></p> <h1>Getting Ready for Development with the Gizmo</h1> ! <p>Developing web apps with the Gizmo means developing one or more ! Eclipse plug-ins, based on the Gizmo base plug-ins. You need to set up ! an Eclipse workspace containing the Gizmo base plug-ins to start with. ! Here are the plug-ins making up the project with a bit of a (very brief) description of what they do.</p> <table> ! <tr> ! <th>Plug-in</th> ! <th>Description</th> ! </tr> ! <tr> ! <td>net.heilancoo.portal</td> ! <td>The core portal code. The web server/web application ! container.</td> ! </tr> ! <tr> ! <td>net.heilancoo.portal.test</td> ! <td>JUnit tests for net.heilancoo.portal.</td> ! </tr> ! <tr> ! <td>net.heilancoo.portal.admin</td> ! <td>A mini web app (actually a "request handler") that shows a ! directory of all web apps installed. You get this, when requesting the ! root URI ("/").</td> ! </tr> ! <tr> ! <td>net.heilancoo.portal.freemarker</td> ! <td>A response generator using the Freemarker template engine.</td> ! </tr> ! <tr> ! <td>net.heilancoo.portal.json</td> ! <td>A response generator for generating JSON responses.</td> ! </tr> ! <tr> ! <td>net.heilancoo.utils</td> ! <td>Utility classes not strictly related to the portal related ! functionality.</td> ! </tr> ! <tr> ! <td>org.apache.httpcore</td> ! <td>The Apache HttpComponents jar files, just packaged up as an ! Eclipse plug-in.</td> ! </tr> ! <tr> ! <td>org.dojotoolkit</td> ! <td>The Dojo JavaScript library files packaged in an Eclipse ! plug-in. This is not necessary on a technical level for the Gizmo to ! work. I have used it in a web app I have written in the Gizmo. So I ! just include it here. It also gives an example of how non-Java ! (static) content can be packaged in an Eclipse plug-in to be used with ! (or served from) the Gizmo.</td> ! </tr> ! <tr> ! <td>org.freemarker</td> ! <td>The Freemarker template engine jar file, just packaged up as ! an Eclipse plug-in.</td> ! </tr> ! <tr> ! <td>org.json</td> ! <td>The JSON Java sources (as taken from the JSON web site), just ! packaged up as an Eclipse plug-in.</td> ! </tr> ! <tr> ! <td>net.heilancoo.portal.documentation</td> ! <td>The project documentation, including this file here. When ! installed along with the rest of the portal, it should be reachable ! via the URI "/portaldocs". Strictly speaking, not technically needed ! for development.</td> ! </tr> ! <tr> ! <td>net.heilancoo.portal.examples</td> ! <td>A number of examples. Useful to see how things are intended ! to be used. Not needed for development.</td> ! </tr> ! <tr> ! <td>net.heilancoo.portal.bingo</td> ! <td>The bingo web app used as example in the tutorials. Not ! needed for development.</td> ! </tr> </table> <h2>Checking Out Gizmo Plug-ins From CVS</h2> ! <p>There is standard SF <a ! href="http://sourceforge.net/scm/?type=cvs&group_id=257822">info ! on CVS access</a> telling you how to connect to the Gizmo CVS repository. ! Create a new empty workspace and check out the plug-ins above.</p> <p>An empty workspace:</p> ! <img src="snaps/cvs-checkout-1.png" alt=""> <p>Use the import "Projects from CVS" option:</p> ! <img src="snaps/cvs-checkout-2.png" alt=""> <p>Connect as anonymous user to the Gizmo repository:</p> ! <img src="snaps/cvs-checkout-3.png" alt=""> ! <p>Click the "configure connection preferences..." link to enable ! connection compression. Don't forget to click OK.</p> ! <img src="snaps/cvs-checkout-4.png" alt=""> ! <p>In the "Select Module" dialog, click the "User existing module" ! radio button. This will bring up the list of existing modules. Select ! all but the "CVSROOT" one. Then click "Finish" to kick off the checkout.</p> ! <img src="snaps/cvs-checkout-5.png" alt=""> ! <p>Your workspace will be populated with the Gizmo plug-ins. It ! should then look a bit like this here:</p> ! <img src="snaps/cvs-checkout-6.png" alt=""> <p>That's it, you're ready to go.</p> <h2>Downloading a Packaged Gizmo Release</h2> ! <p>Go to the Gizmo downloads page and get the packages of the ! release you want to use.</p> <p>Unpack the packages to a temporary location.</p> ! <p>In Eclipse, create a new empty workspace and import the plug-ins ! using the Eclipse import "Existing Projects into Workspace" function.</p> ! <p class="revinfo"></p> <div id="rev">$Revision$</div> <div id="date">$Date$</div> <div id="auth">$Author$</div> ! <p></p> ! <a href="http://sourceforge.net/projects/lipog"> <img ! src="http://sflogo.sourceforge.net/sflogo.php?group_id=257822&type=16" ! border="0" width="150" height="40" ! alt="Get Little Portal Gizmo at SourceForge.net. Fast, secure and Free Open Source software downloads" /></a> </body> </html> \ No newline at end of file |