[Lipog-commit] net.heilancoo.portal/src/net/heilancoo/portal/responses RequestTargetManager.java,
Status: Beta
Brought to you by:
jbu
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); |