Package org.apache.cocoon.environment

Examples of org.apache.cocoon.environment.Context


  public TestBeanAction() {
  }

  public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String src, Parameters param) throws java.lang.Exception {
      Request request = ObjectModelHelper.getRequest(objectModel);
      Context context = ObjectModelHelper.getContext(objectModel);
      if(context != null)
        request.setAttribute("Wale",new  TestBean("Wale in the big sea","context"));

      Session session =request.getSession(true);
      session.setAttribute("Mouse",new  TestBean("Liveing in the session","session"));
View Full Code Here


                    if (session != null) {
                        bean = session.getAttribute(name);
                    }
                }
                if (bean == null) {
                    Context context = ObjectModelHelper.getContext(objectModel);
                    if (context != null) {
                        bean = context.getAttribute(name);
                    }
                }
                if (bean == null) {
                    bean = objectModel.get(name);
                }
            } else if (SCOPE_SITEMAP.equals(scope)) {
                bean = objectModel.get(name);
            } else if (SCOPE_REQUEST.equals(scope)) {
                bean = request.getAttribute(name);
            } if (SCOPE_SESSION.equals(scope)) {
                Session session = request.getSession(false);
                if (session != null) {
                    bean = session.getAttribute(name);
                }
            } if (SCOPE_CONTEXT.equals(scope)) {
                Context context = ObjectModelHelper.getContext(objectModel);
                if(context != null){
                    bean=context.getAttribute(name);
                }
            }

            if (bean != null) {
                insertBean(name, bean, mapping);
View Full Code Here

     */
    public final JXPathContext getRequestContext() {
        Request request = ObjectModelHelper.getRequest(objectModel);
        JXPathContext context = (JXPathContext) request.getAttribute(Constants.JXPATH_CONTEXT);
        if (context == null) {
            Context cocoonContext = ObjectModelHelper.getContext(objectModel);
            JXPathContext parentContext = null;
            Session session = request.getSession(false);
            if (session != null) {
                parentContext = getSessionContext(session, cocoonContext);
            } else {
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

            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

     * @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().error(location + " could not be found. (possible context problem)");
            throw new RuntimeException(location + " could not be found. (possible context problem)");
View Full Code Here

    /**
     * Returns the mime-type of the resource in process.
     */
    public String getMimeType () {
        Context ctx = (Context) objectModel.get(Constants.CONTEXT_OBJECT);

        if (ctx != null) {
           return ctx.getMimeType(this.source);
        } else {
           return null;
        }
    }
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

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.