1 16 package org.apache.cocoon.webapps.session.transformation; 17 18 import org.apache.avalon.framework.service.ServiceException; 19 import org.apache.cocoon.ProcessingException; 20 import org.apache.cocoon.environment.Session; 21 import org.apache.cocoon.transformation.AbstractSAXTransformer; 22 import org.apache.cocoon.webapps.session.ContextManager; 23 import org.apache.cocoon.webapps.session.FormManager; 24 import org.apache.cocoon.webapps.session.SessionManager; 25 26 32 public abstract class AbstractSessionTransformer extends AbstractSAXTransformer { 33 34 private SessionManager sessionManager; 35 private FormManager formManager; 36 private ContextManager contextManager; 37 38 41 protected SessionManager getSessionManager() 42 throws ProcessingException { 43 if (this.sessionManager == null) { 44 try { 45 this.sessionManager = (SessionManager)this.manager.lookup(SessionManager.ROLE); 46 } catch (ServiceException ce) { 47 throw new ProcessingException("Error during lookup of SessionManager component.", ce); 48 } 49 } 50 return this.sessionManager; 51 } 52 53 56 protected ContextManager getContextManager() 57 throws ProcessingException { 58 if (this.contextManager == null) { 59 try { 60 this.contextManager = (ContextManager)this.manager.lookup(ContextManager.ROLE); 61 } catch (ServiceException ce) { 62 throw new ProcessingException("Error during lookup of ContextManager component.", ce); 63 } 64 } 65 return this.contextManager; 66 } 67 68 71 protected FormManager getFormManager() 72 throws ProcessingException { 73 if (this.formManager == null) { 74 try { 75 this.formManager = (FormManager)this.manager.lookup(FormManager.ROLE); 76 } catch (ServiceException ce) { 77 throw new ProcessingException("Error during lookup of FormManager component.", ce); 78 } 79 } 80 return this.formManager; 81 } 82 83 86 public void recycle() { 87 this.manager.release( this.sessionManager); 88 this.manager.release( this.formManager); 89 this.manager.release( this.contextManager); 90 this.sessionManager = null; 91 this.formManager = null; 92 this.contextManager = null; 93 94 super.recycle(); 95 } 96 97 101 public Session getSession() 102 throws ProcessingException { 103 return this.getSessionManager().getSession(false); 104 } 105 } 106 | Popular Tags |