Package org.apache.cocoon

Examples of org.apache.cocoon.Cocoon


        try {
            URL configFile = (URL) this.appContext.get(Constants.CONTEXT_CONFIG_URL);
            if (getLogger().isInfoEnabled()) {
                getLogger().info("Reloading from: " + configFile.toExternalForm());
            }
            Cocoon c = (Cocoon) ClassUtils.newInstance("org.apache.cocoon.Cocoon");
            ContainerUtil.enableLogging(c, getCocoonLogger());
            c.setLoggerManager(getLoggerManager());
            ContainerUtil.contextualize(c, this.appContext);
            final ComponentManager parent = this.getParentComponentManager();
            if (parent != null) {
                ContainerUtil.compose(c, parent);
            }
            if (this.enableInstrumentation) {
                c.setInstrumentManager(getInstrumentManager());
            }
            ContainerUtil.initialize(c);
            this.creationTime = System.currentTimeMillis();

            disposeCocoon();
View Full Code Here


        try {
            URL configFile = (URL) this.appContext.get(Constants.CONTEXT_CONFIG_URL);
            if (log.isInfoEnabled()) {
                log.info("Reloading from: " + configFile.toExternalForm());
            }
            Cocoon c = (Cocoon) ClassUtils.newInstance("org.apache.cocoon.Cocoon");
            final String rootlogger = getInitParameter("cocoon-logger");
            if (rootlogger != null) {
                c.setLogger(this.logKitManager.getLogger(rootlogger));
            } else {
                c.setLogger(log);
            }
            c.contextualize(this.appContext);
            c.compose(getParentComponentManager ());
            c.setLogKitManager(this.logKitManager);
            c.initialize();
            this.creationTime = System.currentTimeMillis();

            this.disposeCocoon();

            this.cocoon = c;
View Full Code Here

        try {
            URL configFile = (URL) this.appContext.get(Constants.CONTEXT_CONFIG_URL);
            if (log.isInfoEnabled()) {
                log.info("Reloading from: " + configFile.toExternalForm());
            }
            Cocoon c = (Cocoon) ClassUtils.newInstance("org.apache.cocoon.Cocoon");
            final String rootlogger = getInitParameter("cocoon-logger");
            if (rootlogger != null) {
                c.setLogger(this.logKitManager.getLogger(rootlogger));
            } else {
                c.setLogger(log);
            }
            c.contextualize(this.appContext);
            c.compose(getParentComponentManager ());
            c.setLogKitManager(this.logKitManager);
            c.initialize();
            this.creationTime = System.currentTimeMillis();

            this.disposeCocoon();

            this.cocoon = c;
View Full Code Here

                            "Problem in creating the Request", null, null, e);
            return;
        }

        // Get the cocoon engine instance
        Cocoon cocoon = getCocoon();

        // Check if cocoon was initialized
        if (cocoon == null) {
            manageException(request, res, null, null,
                            "Initialization Problem",
                            null /* "Cocoon was not initialized" */,
                            null /* "Cocoon was not initialized, cannot process request" */,
                            this.exception);
            return;
        }

        // We got it... Process the request
        String uri = this.servletPath;
        if (uri == null) {
            uri = "portlets/" + getPortletConfig().getPortletName();
        }

        // override servlet-path by the request
        if (servletPathOverriding) {
            String reqServletPath = (String) request.getAttribute("servlet-path");

            if (reqServletPath != null) {
                uri = reqServletPath;
            } else {
                PortletPreferences prefs = request.getPreferences();
               
                if (prefs != null) {
                    uri = prefs.getValue("servlet-path", uri);
                }
            }
        }

        if (uri.startsWith("/")) {
            uri = uri.substring(1);
        }
        if (uri.endsWith("/")) {
            uri = uri.substring(0, uri.length() - 1);
        }

        String pathInfo = getPathInfo(request);

        if (pathInfo != null) {
            uri += pathInfo;
        }

        ContextMap ctxMap = null;

        Environment env;
        try {
            if (uri.charAt(0) == '/') {
                uri = uri.substring(1);
            }
            env = getEnvironment(servletPath, pathInfo, uri, request, res);
        } catch (Exception e) {
            if (getLogger().isErrorEnabled()) {
                getLogger().error("Problem with Cocoon portlet", e);
            }

            manageException(request, res, null, uri,
                            "Problem in creating the Environment", null, null, e);
            return;
        }

        try {
            try {
                // Initialize a fresh log context containing the object model: it
                // will be used by the CocoonLogFormatter
                ctxMap = ContextMap.getCurrentContext();
                // Add thread name (default content for empty context)
                String threadName = Thread.currentThread().getName();
                ctxMap.set("threadName", threadName);
                // Add the object model
                ctxMap.set("objectModel", env.getObjectModel());
                // Add a unique request id (threadName + currentTime
                ctxMap.set("request-id", threadName + System.currentTimeMillis());

                if (cocoon.process(env)) {
                } else {
                    // We reach this when there is nothing in the processing change that matches
                    // the request. For example, no matcher matches.
                    getLogger().fatalError("The Cocoon engine failed to process the request.");
                    manageException(request, res, env, uri,
View Full Code Here

        // get the request (wrapped if contains multipart-form data)
        RenderRequest request = req;

        // Get the cocoon engine instance
        Cocoon cocoon = getCocoon();

        // Check if cocoon was initialized
        if (cocoon == null) {
            manageException(request, res, null, null,
                            "Initialization Problem",
                            null /* "Cocoon was not initialized" */,
                            null /* "Cocoon was not initialized, cannot process request" */,
                            this.exception);
            return;
        }

        // We got it... Process the request
        String uri = this.servletPath;
        if (servletPath == null) {
            uri = "portlets/" + getPortletConfig().getPortletName();
        }

        // allow servlet-path override by request or preferences
        if (servletPathOverriding) {
            String reqServletPath = (String) request.getAttribute("servlet-path");

            if (reqServletPath != null) {
                uri = reqServletPath;
            } else {
                PortletPreferences prefs = request.getPreferences();
           
                if (prefs != null) {
                    uri = prefs.getValue("servlet-path", uri);
                }
            }
        }

        if (uri.startsWith("/")) {
            uri = uri.substring(1);
        }
        if (uri.endsWith("/")) {
            uri = uri.substring(0, uri.length() - 1);
        }

        String pathInfo = getPathInfo(request);

        if (pathInfo != null) {
            uri += pathInfo;
        }

        String contentType = null;
        ContextMap ctxMap = null;

        Environment env;
        try {
            if (uri.charAt(0) == '/') {
                uri = uri.substring(1);
            }
            env = getEnvironment(servletPath, pathInfo, uri, request, res);
        } catch (Exception e) {
            if (getLogger().isErrorEnabled()) {
                getLogger().error("Problem with Cocoon portlet", e);
            }

            manageException(request, res, null, uri,
                            "Problem in creating the Environment", null, null, e);
            return;
        }

        try {
            try {
                // Initialize a fresh log context containing the object model: it
                // will be used by the CocoonLogFormatter
                ctxMap = ContextMap.getCurrentContext();
                // Add thread name (default content for empty context)
                String threadName = Thread.currentThread().getName();
                ctxMap.set("threadName", threadName);
                // Add the object model
                ctxMap.set("objectModel", env.getObjectModel());
                // Add a unique request id (threadName + currentTime
                ctxMap.set("request-id", threadName + System.currentTimeMillis());

                if (cocoon.process(env)) {
                } else {
                    // We reach this when there is nothing in the processing change that matches
                    // the request. For example, no matcher matches.
                    getLogger().fatalError("The Cocoon engine failed to process the request.");
                    manageException(request, res, env, uri,
View Full Code Here

            this.exception = null;
            URL configFile = (URL) this.appContext.get(Constants.CONTEXT_CONFIG_URL);
            if (getLogger().isInfoEnabled()) {
                getLogger().info("Reloading from: " + configFile.toExternalForm());
            }
            Cocoon c = (Cocoon) ClassUtils.newInstance("org.apache.cocoon.Cocoon");
            ContainerUtil.enableLogging(c, getCocoonLogger());
            c.setLoggerManager(getLoggerManager());
            ContainerUtil.contextualize(c, this.appContext);
            final ComponentManager parent = this.getParentComponentManager();
            if (parent != null) {
                ContainerUtil.compose(c, parent);
            }
            if (this.enableInstrumentation) {
                c.setInstrumentManager(getInstrumentManager());
            }
            ContainerUtil.initialize(c);
            this.creationTime = System.currentTimeMillis();

            this.cocoon = c;
View Full Code Here

            appContext.put(Constants.CONTEXT_CONFIG_URL, this.conf.toURL());
            appContext.put(Constants.CONTEXT_DEFAULT_ENCODING, "ISO-8859-1");

            loadClasses(this.classList);

            this.cocoon = new Cocoon();
            ContainerUtil.enableLogging(this.cocoon, this.log);
            ContainerUtil.contextualize(this.cocoon, appContext);
            this.cocoon.setLoggerManager(this.logManager);
            ContainerUtil.initialize(this.cocoon);
View Full Code Here

        try {
            URL configFile = (URL) this.appContext.get(Constants.CONTEXT_CONFIG_URL);
            if (getLogger().isInfoEnabled()) {
                getLogger().info("Reloading from: " + configFile.toExternalForm());
            }
            Cocoon c = (Cocoon) ClassUtils.newInstance("org.apache.cocoon.Cocoon");
            ContainerUtil.enableLogging(c, getCocoonLogger() );
            c.setLoggerManager( getLoggerManager() );
            ContainerUtil.contextualize(c, this.appContext);
            final ComponentManager parent = this.getParentComponentManager();
            if ( parent != null ) {
                ContainerUtil.compose(c, parent);
            }
            if (this.enableInstrumentation) {
                c.setInstrumentManager(getInstrumentManager());
            }
            ContainerUtil.initialize(c);
            this.creationTime = System.currentTimeMillis();

            disposeCocoon();
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);
View Full Code Here

         * @exception  ContextException        thrown if configuring of Cocoon instance fails
         * @exception  ConfigurationException  thrown if contextualizing of Cocoon instance fails
         * @exception  Exception               thrown if initializing of Cocoon instance fails
         */
        public Cocoon createCocoon() throws Exception, ContextException, ConfigurationException {
            Cocoon cocoon = new Cocoon();
            cocoon.enableLogging(logger);
            cocoon.contextualize(this.ctx);
            cocoon.setLoggerManager(logKitLoggerManager);
            cocoon.initialize();
            return cocoon;
        }
View Full Code Here

TOP

Related Classes of org.apache.cocoon.Cocoon

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.