1 16 package org.apache.cocoon.components.language.markup.xsp; 17 18 import org.apache.avalon.framework.component.Component; 19 import org.apache.avalon.framework.component.ComponentManager; 20 import org.apache.avalon.framework.component.ComponentException; 21 22 import org.apache.cocoon.ProcessingException; 23 24 import org.apache.cocoon.webapps.session.SessionManager; 25 26 import org.w3c.dom.DocumentFragment ; 27 28 35 public class XSPSessionFwHelper { 36 37 44 public static DocumentFragment getXML(ComponentManager cm, String context, String path) throws ProcessingException { 45 46 SessionManager sessionManager = null; 47 try { 48 sessionManager = (SessionManager)cm.lookup(SessionManager.ROLE); 50 DocumentFragment df = sessionManager.getContextFragment(context, path); 52 return df; 53 } catch (ComponentException ce) { 54 throw new ProcessingException("Error during lookup of SessionManager component.", ce); 55 } finally { 56 cm.release((Component)sessionManager); 58 } 59 } 60 61 68 public static String getXMLAsString(ComponentManager cm, String context, String path) throws ProcessingException { 69 DocumentFragment df = getXML(cm, context, path); 70 return df != null ? df.getFirstChild().getNodeValue() : ""; 71 } 72 } 73 74 | Popular Tags |