Package org.apache.avalon.framework.context

Examples of org.apache.avalon.framework.context.DefaultContext


     *
     * @param configuration the class configurations.
     * @see org.apache.avalon.framework.configuration.Configurable#configure(Configuration)
     */
    public void configure(Configuration configuration) throws ConfigurationException {
        this.resolverContext = new DefaultContext();
        this.tmplEngine = new VelocityEngine();

        // Set up a JavaScript introspector for the Cocoon flow layer
        this.tmplEngine.setProperty(org.apache.velocity.runtime.RuntimeConstants.UBERSPECT_CLASSNAME,
                                    JSIntrospector.class.getName());
View Full Code Here


        Configuration config = (Configuration) initialContext.lookup(this.jndiName);

        // We ignore the setRoleManager call, as ExcaliburComponentManager handles that
        // in configure().
        this.delegate.enableLogging(logger);
        this.delegate.contextualize(new DefaultContext());
        this.delegate.configure(config);
        this.delegate.initialize();

        this.logger.debug("Component manager successfully initialized.");
    }
View Full Code Here

        }

        // Check validity of members
        checkValidity();

        DefaultContext rootCtx = new DefaultContext();
        DefaultConfiguration configuration = new DefaultConfiguration("root", "");
        Cocoon cocoon = null;
        CocoonFactory cocoonFactory = null;

        try {
            // fill rootCtx
            rootCtx.put("dest-dir", destDir);
            rootCtx.put("context-root", this.contextDir);
            rootCtx.put(Constants.CONTEXT_WORK_DIR, this.workDir);
            rootCtx.put(Constants.CONTEXT_CONFIG_URL, configFile.toURL());

            ClassLoader classLoader = null;
            if (this.cocoonClasspath != null) {
                //
                // I think there is no real need for creating an additional
                // AntClassLoader
                // CocoonTask was already loaded via an AntClassLoader by Ant
                //
                AntClassLoader antClassLoader = new AntClassLoader(this.project, this.cocoonClasspath, false);

                log("Using Class Loader having classpath " + String.valueOf(this.cocoonClasspath), Project.MSG_INFO);
                classLoader = antClassLoader;
            } else {
                classLoader = this.getClass().getClassLoader();
            }
            rootCtx.put(Constants.CONTEXT_CLASS_LOADER, classLoader);

            // set classloader explicitly
            // this is very important otherwise ClassUtils.loadClass(), et al.
            // will use the system classloader for loading classes, and resources
            // but only this class (the CocoonTask) was loaded via an
View Full Code Here

         * @param  context               parent context
         * @exception  ContextException  thrown if parent context fails to provide
         *   mandadory context entries
         */
        public void contextualize(Context context) throws ContextException {
            this.ctx = new DefaultContext(context);

            File contextDir = (File) this.ctx.get("context-root");
            File workDir = (File) this.ctx.get(Constants.CONTEXT_WORK_DIR);

            CommandLineContext clContext = new CommandLineContext(contextDir.toString());
View Full Code Here

                    try {
                        final DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
                        final Configuration logKitConf = builder.buildFromFile(logKit);
                        this.logKitLoggerManager = new LogKitLoggerManager(Hierarchy.getDefaultHierarchy());

                        final DefaultContext subcontext = new DefaultContext(this.ctx);
                        File contextDir = (File) this.ctx.get("context-root");
                        subcontext.put("context-root", contextDir);
                        this.logKitLoggerManager.contextualize(subcontext);
                        this.logKitLoggerManager.configure(logKitConf);
                        logger = this.logKitLoggerManager.getLoggerForCategory(logKitLogCategory);
                    } catch (Exception e) {
                        getLogger().error("Cannot initialize log-kit-manager from logkit-xconf " + String.valueOf(logKit));
View Full Code Here

        Map objectModel = new HashMap();
        FlowHelper.setContextObject(objectModel, flowContextObject);
        objectModel.put(ObjectModelHelper.REQUEST_OBJECT, request);
        Map contextObjectModel = new HashMap();
        contextObjectModel.put(ContextHelper.CONTEXT_OBJECT_MODEL, objectModel);
        Context context = new DefaultContext(contextObjectModel);
        Source sampleSource = new ResourceSource("resource://org/apache/cocoon/woody/datatype/FlowJXPathSelectionListTestCase.source.xml");
        Document sample = parser.parse(sampleSource.getInputStream());
        Element datatypeElement = (Element) sample.getElementsByTagNameNS(Constants.WD_NS, "datatype").item(0);
        Datatype datatype = datatypeManager.createDatatype(datatypeElement, false);
        FlowJXPathSelectionList list = new FlowJXPathSelectionList
View Full Code Here

        Map objectModel = new HashMap();
        FlowHelper.setContextObject(objectModel, flowContextObject);
        objectModel.put(ObjectModelHelper.REQUEST_OBJECT, request);
        Map contextObjectModel = new HashMap();
        contextObjectModel.put(ContextHelper.CONTEXT_OBJECT_MODEL, objectModel);
        Context context = new DefaultContext(contextObjectModel);
        Source sampleSource = new ResourceSource("resource://org/apache/cocoon/woody/datatype/FlowJXPathSelectionListTestCase.source.xml");
        Document sample = parser.parse(sampleSource.getInputStream());
        Element datatypeElement = (Element) sample.getElementsByTagNameNS(Constants.WD_NS, "datatype").item(0);
        Datatype datatype = datatypeManager.createDatatype(datatypeElement, false);
        FlowJXPathSelectionList list = new FlowJXPathSelectionList
View Full Code Here

        this.work = getDir(workDir, "working");

        this.conf = getConfigurationFile(this.context, this.configFile);

        try {
            DefaultContext appContext = new DefaultContext();
            appContext.put(
                Constants.CONTEXT_CLASS_LOADER,
                CocoonWrapper.class.getClassLoader());
            cliContext = new CommandLineContext(contextDir);
            cliContext.enableLogging(log);
            appContext.put(Constants.CONTEXT_ENVIRONMENT_CONTEXT, cliContext);
            LogKitLoggerManager logKitLoggerManager =
                    new LogKitLoggerManager(Hierarchy.getDefaultHierarchy());
            logKitLoggerManager.enableLogging(log);

            if (this.logKit != null) {
                final FileInputStream fis = new FileInputStream(logKit);
                final DefaultConfigurationBuilder builder =
                    new DefaultConfigurationBuilder();
                final Configuration logKitConf = builder.build(fis);
                final DefaultContext subcontext = new DefaultContext(appContext);
                subcontext.put("context-root", contextDir);
                logKitLoggerManager.contextualize(subcontext);
                logKitLoggerManager.configure(logKitConf);
                if (logger != null) {
                    log = logKitLoggerManager.getLoggerForCategory(logger);
                } else {
View Full Code Here

        final LoggerManager loggerManager =
                newLoggerManager(loggerManagerClass, defaultHierarchy);
        ContainerUtil.enableLogging(loggerManager, logger);

        final DefaultContext subcontext = new DefaultContext(this.appContext);
        subcontext.put("servlet-context", this.servletContext);
        if (this.servletContextPath == null) {
            File logSCDir = new File(this.workDir, "log");
            logSCDir.mkdirs();
            if (logger.isWarnEnabled()) {
                logger.warn("Setting servlet-context for LogKit to " + logSCDir);
            }
            subcontext.put("context-root", logSCDir.toString());
        } else {
            subcontext.put("context-root", this.servletContextPath);
        }

        try {
            ContainerUtil.contextualize(loggerManager, subcontext);
            this.loggerManager = loggerManager;
View Full Code Here

    public void contextualize(Context context) throws ContextException {
        if (this.context == null) {
            this.context = new ComponentContext(context);
           
            try {
                DefaultContext setup = (DefaultContext)this.context;
                this.threads = new TPCThreadManager();
               
                Parameters params = new Parameters();
                params.setParameter("threads-per-processor", "1");
                params.setParameter("sleep-time", "100");
                params.setParameter("block-timeout", "1000");
                params.setParameter("force-shutdown", "true");
                params.makeReadOnly();
               
                ContainerUtil.enableLogging(this.threads, getLogger().getChildLogger("thread.manager"));
                ContainerUtil.parameterize(this.threads, params);
                ContainerUtil.initialize(this.threads);
               
                this.commands = new CommandManager();
                ContainerUtil.enableLogging(this.commands, getLogger().getChildLogger("thread.manager"));
                this.threads.register(this.commands);
               
                setup.put(Queue.ROLE, this.commands.getCommandSink());
               
                setup.makeReadOnly();
            } catch (Exception e) {
                getLogger().error("Could not set up the Command Manager", e);
            }
           
            this.classpath = (String)context.get(Constants.CONTEXT_CLASSPATH);
View Full Code Here

TOP

Related Classes of org.apache.avalon.framework.context.DefaultContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.