Package org.apache.cocoon.environment

Examples of org.apache.cocoon.environment.Context


    /**
     * Returns the mime-type of the resource in process.
     */
    public String getMimeType () {
        Context ctx = ObjectModelHelper.getContext(this.objectModel);

        if (ctx != null) {
           return ctx.getMimeType(this.source);
        } else {
           return null;
        }
    }
View Full Code Here


                    int scope)
    {
        XScriptVariableScope s;

        if (scope == XScriptManager.GLOBAL_SCOPE) {
            Context context = ObjectModelHelper.getContext(objectModel);
            synchronized (context) {
                s = (XScriptVariableScope) context.getAttribute(CONTEXT);
                if (s == null) {
                    context.setAttribute(CONTEXT, s = new XScriptVariableScope());
                }
            }
        } else if (scope == XScriptManager.SESSION_SCOPE) {
            Session session = ObjectModelHelper.getRequest(objectModel).getSession();
            synchronized (session) {
View Full Code Here

     * @param location The location
     * @return The URL pointed to by the location
     * @exception MalformedURLException If the location is malformed
     */
    public URL getURL(String location) throws MalformedURLException {
        Context envContext = null;
        try {
            envContext = (Context)this.context.get(Constants.CONTEXT_ENVIRONMENT_CONTEXT);
        } catch (ContextException e){
            getLogger().error("ContextException in getURL",e);
        }
        if (envContext == null) {
            getLogger().warn("no environment-context in application context (making an absolute URL)");
            return new URL(location);
        }
        URL u = envContext.getResource("/" + location);
        if (u != null)
            return u;
        else {
            getLogger().info(location + " could not be found. (possible context problem)");
            throw new RuntimeException(location + " could not be found. (possible context problem)");
View Full Code Here

        throws IOException {
            File file = new File(filename);
            if (file.isAbsolute() && file.exists()) {
                return filename;
            }
            Context context = ObjectModelHelper.getContext(objectModel);
            return NetUtils.getPath(context.getResource(filename).toExternalForm());
    }
View Full Code Here

        }
    }

    public static Object getContextAttribute(Map objectModel, String name)
    {
        Context context = ObjectModelHelper.getContext(objectModel);
        return context.getAttribute(name);
    }
View Full Code Here

        this.manager = manager;
    }

    public void contextualize(org.apache.avalon.framework.context.Context context)
      throws ContextException {
        Context ctx = ((Context) context.get(Constants.CONTEXT_ENVIRONMENT_CONTEXT));
        this.contextpath = ctx.getRealPath("/");
        this.workdir = context.get(Constants.CONTEXT_WORK_DIR).toString();
    }
View Full Code Here

    public static String relativeFilename(String filename, Map objectModel) throws IOException {
        File file = new File(filename);
        if (file.isAbsolute() && file.exists()) {
            return filename;
        }
        Context context = ObjectModelHelper.getContext(objectModel);
        URL resource = context.getResource(filename);
        if (resource == null) {
            throw new FileNotFoundException("The file " + filename + " does not exist!");
        }
        return NetUtils.getPath(resource.toExternalForm());
    }
View Full Code Here

            return cnt;
        }
    }

    public static Object getContextAttribute(Map objectModel, String name) {
        Context context = ObjectModelHelper.getContext(objectModel);
        return context.getAttribute(name);
    }
View Full Code Here

     */
    public static Publication getPublication(Map objectModel) throws PublicationException {

        assert objectModel != null;
        Request request = ObjectModelHelper.getRequest(objectModel);
        Context context = ObjectModelHelper.getContext(objectModel);
        return getPublication(request, context);
    }
View Full Code Here

                    int scope)
    {
        XScriptVariableScope s;

        if (scope == XScriptManager.GLOBAL_SCOPE) {
            Context context = ObjectModelHelper.getContext(objectModel);
            synchronized (context) {
                s = (XScriptVariableScope) context.getAttribute(CONTEXT);
                if (s == null) {
                    context.setAttribute(CONTEXT, s = new XScriptVariableScope());
                }
            }
        } else if (scope == XScriptManager.SESSION_SCOPE) {
            Session session = ObjectModelHelper.getRequest(objectModel).getSession();
            synchronized (session) {
View Full Code Here

TOP

Related Classes of org.apache.cocoon.environment.Context

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.