home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-cocoon-addon-1.4.9-installer.exe / Configurator.class (.txt) < prev    next >
Encoding:
Java Class File  |  2004-07-12  |  2.7 KB  |  35 lines

  1. package org.apache.cocoon.samples.parentcm;
  2.  
  3. import java.util.Hashtable;
  4. import javax.naming.Context;
  5. import javax.naming.InitialContext;
  6. import org.apache.avalon.excalibur.naming.memory.MemoryInitialContextFactory;
  7. import org.apache.avalon.framework.configuration.DefaultConfiguration;
  8.  
  9. public class Configurator {
  10.    public static Context initialContext = null;
  11.  
  12.    static {
  13.       try {
  14.          DefaultConfiguration config = new DefaultConfiguration("roles", "");
  15.          DefaultConfiguration timeComponent = new DefaultConfiguration("role", "roles");
  16.          timeComponent.addAttribute("name", Time.ROLE);
  17.          timeComponent.addAttribute("default-class", TimeComponent.class.getName());
  18.          timeComponent.addAttribute("shorthand", "samples-parentcm-time");
  19.          config.addChild(timeComponent);
  20.          Hashtable environment = new Hashtable();
  21.          environment.put("java.naming.factory.initial", MemoryInitialContextFactory.class.getName());
  22.          initialContext = new InitialContext(environment);
  23.          Context ctx = initialContext.createSubcontext("org");
  24.          ctx = ctx.createSubcontext("apache");
  25.          ctx = ctx.createSubcontext("cocoon");
  26.          ctx = ctx.createSubcontext("samples");
  27.          ctx = ctx.createSubcontext("parentcm");
  28.          ctx.rebind("ParentCMConfiguration", config);
  29.       } catch (Exception e) {
  30.          e.printStackTrace(System.err);
  31.       }
  32.  
  33.    }
  34. }
  35.