1 16 package org.apache.cocoon.samples.parentcm; 17 18 import org.apache.avalon.excalibur.naming.memory.MemoryInitialContextFactory; 19 import org.apache.avalon.framework.configuration.DefaultConfiguration; 20 21 import javax.naming.Context ; 22 import javax.naming.InitialContext ; 23 import java.util.Hashtable ; 24 25 35 public class Configurator { 36 37 42 public static Context initialContext = null; 43 44 static { 45 try { 46 DefaultConfiguration config = new DefaultConfiguration("roles", ""); 50 DefaultConfiguration timeComponent = new DefaultConfiguration("role", "roles"); 51 timeComponent.addAttribute("name", Time.ROLE); 52 timeComponent.addAttribute("default-class", TimeComponent.class.getName()); 53 timeComponent.addAttribute("shorthand", "samples-parentcm-time"); 54 config.addChild(timeComponent); 55 56 Hashtable environment = new Hashtable (); 60 environment.put(Context.INITIAL_CONTEXT_FACTORY, MemoryInitialContextFactory.class.getName()); 61 initialContext = new InitialContext (environment); 62 63 Context ctx = initialContext.createSubcontext("org"); 67 ctx = ctx.createSubcontext("apache"); 68 ctx = ctx.createSubcontext("cocoon"); 69 ctx = ctx.createSubcontext("samples"); 70 ctx = ctx.createSubcontext("parentcm"); 71 ctx.rebind("ParentCMConfiguration", config); 72 } catch (Exception e) { 73 e.printStackTrace(System.err); 74 } 75 } 76 } 77 78 | Popular Tags |