1 16 package org.apache.cocoon.components.treeprocessor.sitemap; 17 18 import org.apache.avalon.framework.activity.Disposable; 19 import org.apache.avalon.framework.component.Component; 20 import org.apache.avalon.framework.component.ComponentException; 21 import org.apache.avalon.framework.component.ComponentManager; 22 import org.apache.avalon.framework.component.ComponentSelector; 23 import org.apache.avalon.framework.component.Composable; 24 25 import org.apache.cocoon.components.flow.Interpreter; 26 import org.apache.cocoon.components.treeprocessor.AbstractProcessingNode; 27 import org.apache.cocoon.components.treeprocessor.InvokeContext; 28 import org.apache.cocoon.environment.Environment; 29 30 37 public class FlowNode extends AbstractProcessingNode 38 implements Composable, Disposable { 39 40 private ComponentManager manager; 41 private String language; 42 private Interpreter interpreter; 43 private ComponentSelector interpreterSelector; 44 45 public FlowNode(String language) { 46 this.language = language; 47 } 48 49 57 public void compose(ComponentManager manager) throws ComponentException { 58 this.manager = manager; 59 60 try { 61 this.interpreterSelector = (ComponentSelector) manager.lookup(Interpreter.ROLE); 62 this.interpreter = (Interpreter) this.interpreterSelector.select(language); 64 this.interpreter.setInterpreterID(this.location.getURI()); 66 } catch (ComponentException e) { 67 throw e; 68 } catch (Exception e) { 69 throw new ComponentException(language, 70 "FlowNode: Couldn't obtain a flow interpreter for '" + language + 71 "' at " + getLocation(), e); 72 } 73 } 74 75 85 public boolean invoke(Environment env, InvokeContext context) throws Exception { 86 return true; 87 } 88 89 public Interpreter getInterpreter() { 90 return interpreter; 91 } 92 93 96 public void dispose() { 97 if (this.manager != null) { 98 if (this.interpreterSelector != null) { 99 this.interpreterSelector.release((Component) this.interpreter); 100 this.interpreter = null; 101 102 this.manager.release(this.interpreterSelector); 103 this.interpreterSelector = null; 104 } 105 this.manager = null; 106 } 107 } 108 } 109 | Popular Tags |