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


     * @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

  public TestBeanAction() {
  }
  public Map act(Redirector redirector, SourceResolver resolver, Map objectmodel, String src, Parameters param) throws java.lang.Exception {
      Request request =(Request)objectmodel.get(Constants.REQUEST_OBJECT);
      Context context = (Context)objectmodel.get(Constants.CONTEXT_OBJECT);
      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

                return;
              }
            }
          }
          if(sourcemap == null || VALUE_CONTEXT.equals(sourcemap)){
            Context context = (Context)objectModel.get(Constants.CONTEXT_OBJECT );
            if(context != null){
              toInsert=context.getAttribute(name);
              if(toInsert != null){
                insertBean(toInsert,mapping);
                return;
              }
            }
View Full Code Here

    /**
     * Returns the mime-type of the resource in process.
     */
    public String getMimeType() {
        Context ctx = (Context) objectModel.get(Constants.CONTEXT_OBJECT);
        return (ctx != null) ? ctx.getMimeType(this.source) : null;
    }
View Full Code Here

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

        }
    }

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

        String testPath = System.getProperty("testPath", "build/test");
        File testRootDir = new File(testPath);
        context.put("test-path", testRootDir);

        Context envContext = new CommandLineContext(contextRoot);
        ContainerUtil.enableLogging(envContext, getLogger());
        context.put(Constants.CONTEXT_ENVIRONMENT_CONTEXT, envContext);

        File tempDir = new File(tempPath);
View Full Code Here

                getRequestParameters());
        context.put("object-model.request", this.request);

        Map objectModel = new HashMap();
        objectModel.put(ObjectModelHelper.REQUEST_OBJECT, request);
        Context envContext = (Context) context.get(Constants.CONTEXT_ENVIRONMENT_CONTEXT);
        objectModel.put(ObjectModelHelper.CONTEXT_OBJECT, envContext);
        context.put(ContextHelper.CONTEXT_OBJECT_MODEL, objectModel);
       
        EntityResolver entityResolver = (EntityResolver) getManager().lookup(EntityResolver.ROLE);
        DocumentHelper.setEntityResolver(entityResolver);
View Full Code Here

        final Map objectModel = ContextHelper.getObjectModel(this.context);

        Request request = ObjectModelHelper.getRequest(objectModel);
        JXPathContext context = (JXPathContext) request.getAttribute(Constants.JXPATH_CONTEXT);
        if (context == null) {
            Context envContext = ObjectModelHelper.getContext(objectModel);
            JXPathContext parentContext = null;

            Session session = request.getSession(false);
            if (session != null) {
                parentContext = getSessionContext(session, envContext);
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.