cziegeler    02/01/30 09:13:24

  Modified:    src/documentation/xdocs/developing deli.xml deliquick.xml
               src/java/org/apache/cocoon cocoon.roles
               src/java/org/apache/cocoon/components/deli DeliImpl.java
  Log:
  Making deli optional
  
  Revision  Changes    Path
  1.5       +3 -4      xml-cocoon2/src/documentation/xdocs/developing/deli.xml
  
  Index: deli.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/documentation/xdocs/developing/deli.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- deli.xml  30 Jan 2002 16:45:40 -0000      1.4
  +++ deli.xml  30 Jan 2002 17:13:24 -0000      1.5
  @@ -197,14 +197,13 @@
   configuration file or <code>legacyDevices.xml</code>, the
   DELI legacy device support file.</p>
                        <s2 title="Cocoon.xconf">
  -                             <p>In order to use DELI you need to specify
  -the configuration file and set the <code>use-deli</code> parameter to true. You can 
either
  +                             <p>In order to use DELI you need to configure Deli and 
specify
  +the configuration file. You can either
   do this in <code>deli.xconf</code> in which case you will need to rebuild
   Cocoon or change the deployed <code>cocoon.xconf</code> in the web-server 
directory:</p>
                                <source><![CDATA[
  -  <deli>
  +  <deli class="org.apache.cocoon.components.deli.DeliImpl">
       <parameter name="deli-config-file" 
value="resources/deli/config/deliConfig.xml"/>
  -    <parameter name="use-deli" value="true"/>
     </deli>
   ]]></source>
                        </s2>
  
  
  
  1.3       +2 -2      xml-cocoon2/src/documentation/xdocs/developing/deliquick.xml
  
  Index: deliquick.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/documentation/xdocs/developing/deliquick.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- deliquick.xml     22 Jan 2002 01:32:22 -0000      1.2
  +++ deliquick.xml     30 Jan 2002 17:13:24 -0000      1.3
  @@ -12,9 +12,9 @@
                <s1 title="DELI Quick Start Guide">
   <p>If you are seeing the 'DELI is switched off' message when you try the test pages 
then you need to enable DELI. If you do not
   want to rebuild Cocoon, just
  -set the <code>use-deli</code> parameter to true in the deployed 
<code>cocoon.xconf</code>:</p>
  +add the following lines to the deployed <code>cocoon.xconf</code>:</p>
                                <source><![CDATA[
  -<deli>
  +<deli class="org.apache.cocoon.components.deli.DeliImpl">
      <parameter name="deli-config-file" value="deliCocoonConfig.xml"/>
      <parameter name="use-deli" value="true"/>
   </deli>
  
  
  
  1.4       +1 -2      xml-cocoon2/src/java/org/apache/cocoon/cocoon.roles
  
  Index: cocoon.roles
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/cocoon.roles,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- cocoon.roles      27 Jan 2002 13:15:01 -0000      1.3
  +++ cocoon.roles      30 Jan 2002 17:13:24 -0000      1.4
  @@ -34,8 +34,7 @@
          shorthand="processor"/>
   -->
    <role name="org.apache.cocoon.components.deli.Deli"
  -       shorthand="deli"
  -       default-class="org.apache.cocoon.components.deli.DeliImpl"/>
  +       shorthand="deli"/>
   
    <role name="org.apache.cocoon.Processor"
          shorthand="sitemap"
  
  
  
  1.8       +142 -153  
xml-cocoon2/src/java/org/apache/cocoon/components/deli/DeliImpl.java
  
  Index: DeliImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/deli/DeliImpl.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- DeliImpl.java     30 Jan 2002 16:42:49 -0000      1.7
  +++ DeliImpl.java     30 Jan 2002 17:13:24 -0000      1.8
  @@ -8,19 +8,19 @@
   
   package org.apache.cocoon.components.deli;
   
  +import org.apache.avalon.framework.activity.Initializable;
  +import org.apache.avalon.framework.activity.Disposable;
   import org.apache.avalon.framework.component.Component;
   import org.apache.avalon.framework.component.Composable;
  -import org.apache.avalon.framework.activity.Disposable;
   import org.apache.avalon.framework.component.ComponentException;
   import org.apache.avalon.framework.component.ComponentManager;
  -import org.apache.avalon.framework.thread.ThreadSafe;
  -import org.apache.avalon.framework.parameters.Parameters;
  -import org.apache.avalon.framework.parameters.Parameterizable;
   import org.apache.avalon.framework.context.Context;
   import org.apache.avalon.framework.context.ContextException;
   import org.apache.avalon.framework.context.Contextualizable;
   import org.apache.avalon.framework.logger.AbstractLoggable;
  -
  +import org.apache.avalon.framework.parameters.Parameters;
  +import org.apache.avalon.framework.parameters.Parameterizable;
  +import org.apache.avalon.framework.thread.ThreadSafe;
   import org.apache.cocoon.environment.http.HttpContext;
   import org.apache.cocoon.environment.Request;
   import org.apache.cocoon.Constants;
  @@ -67,178 +67,168 @@
    * A Delivery Context Library for CC/PP and UAProf</a>.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Mark H. Butler</a>
  - * @version CVS $ $ $Date: 2002/01/30 16:42:49 $
  + * @version CVS $ $ $Date: 2002/01/30 17:13:24 $
    */
   
  -public class DeliImpl
  +public final class DeliImpl
   extends AbstractLoggable
  -implements Parameterizable, Component, Deli,
  -Composable, Disposable, ThreadSafe, Contextualizable
  -{
  -  /** The path to the Cocoon configuration files */
  -  private String defaultPath = null;
  -
  -  /** The name of the main DELI configuration file */
  -  private String deliConfig = "resources/deli/config/deliConfig.xml";
  -
  -  /** The DELI workspace */
  -  private Workspace workspace;
  -
  -  /** The component manager */
  -  protected ComponentManager manager = null;
  -
  -  /** Parser used to construct the DOM tree to import the profile to a stylesheet */
  -  Parser parser;
  -
  -  /** A context, used to retrieve the path to the configuration file */
  -  protected CocoonServletContext servletContext;
  -
  -  /** Contextualize this class */
  -  public void contextualize(Context context) throws ContextException
  -  {
  -     try
  -     {
  -    org.apache.cocoon.environment.Context ctx = 
(org.apache.cocoon.environment.Context) 
context.get(Constants.CONTEXT_ENVIRONMENT_CONTEXT);
  -        servletContext = new CocoonServletContext(ctx);
  -     }
  -     catch (Exception e)
  -     {
  -    System.out.println(e);
  +implements Parameterizable,
  +           Deli,
  +           Composable,
  +           Disposable,
  +           Initializable,
  +           ThreadSafe,
  +           Contextualizable {
  +
  +    /** The path to the Cocoon configuration files */
  +    private String defaultPath = null;
  +
  +    /** The name of the main DELI configuration file */
  +    private String deliConfig = "resources/deli/config/deliConfig.xml";
  +
  +    /** The DELI workspace */
  +    private Workspace workspace;
  +
  +    /** The component manager */
  +    protected ComponentManager manager = null;
  +
  +    /** Parser used to construct the DOM tree to import the profile to a stylesheet 
*/
  +    Parser parser;
  +
  +    /** A context, used to retrieve the path to the configuration file */
  +    protected CocoonServletContext servletContext;
  +
  +    /** Contextualize this class */
  +    public void contextualize(Context context)
  +    throws ContextException {
  +        org.apache.cocoon.environment.Context ctx = 
(org.apache.cocoon.environment.Context) 
context.get(Constants.CONTEXT_ENVIRONMENT_CONTEXT);
  +        this.servletContext = new CocoonServletContext(ctx);
  +    }
  +
  +    /** Compose this class */
  +    public void compose(ComponentManager manager)
  +    throws ComponentException {
  +        this.manager = manager;
  +        this.parser = (Parser)this.manager.lookup(Parser.ROLE);
  +    }
  +
  +     /** Configure this class */
  +     public void parameterize(Parameters params) {
  +         this.deliConfig = params.getParameter("deli-config-file", this.deliConfig);
        }
  -  }
   
  -  /** Compose this class */
  -  public void compose(ComponentManager manager) throws ComponentException
  -  {
  -    this.manager = manager;
  -    parser = (Parser)this.manager.lookup(Parser.ROLE);
  -  }
  -
  -  /** Configure this class */
  -  public final void parameterize(Parameters params)
  -  {
  -    this.deliConfig = params.getParameter("deli-config-file", this.deliConfig);
  -    try
  -    {
  -        workspace = new Workspace(servletContext, this.deliConfig);
  -    }
  -    catch (Exception e)
  -    {
  -    System.out.println(e);
  -    }
  -  }
  -
  -  /** Dispose of this class */
  -  public void dispose()
  -  {
  -    if(parser != null) this.manager.release((Component)parser);
  -  }
  -
  -  /** Process a HttpServletRequest and either extract
  -   *  CC/PP or UAProf information from it and use this information
  -   *  to resolve a profile or examine the user agent string, match
  -   *  this using the DELI legacy device database, and use this
  -   *  information to retrieve the appropriate CC/PP profile.
  -   *
  -   *@param   theRequest      The Request.
  -   *@return  The profile as a vector of profile attributes.
  -   *@exception       IOException.
  -   *@exception       ServletException.
  -   *@exception       Exception.
  -   */
  -  public Profile getProfile(Request theRequest) throws IOException, 
ServletException, Exception
  -  {
  -    CocoonServletRequest servletRequest = new CocoonServletRequest(theRequest);
  -    Profile theProfile = new Profile(workspace, (HttpServletRequest) 
servletRequest);
  -    return theProfile;
  -  }
  -
  -  /** Convert a profile stored as a vector of profile attributes
  -   *  to a DOM tree.
  -   *
  -   *@param   theProfile      The profile as a vector of profile attributes.
  -   *@return  The DOM tree.
  -   */
  -  public Document getUACapabilities(Profile theProfile)
  -  {
  -    Document document;
  -    Element rootElement;
  -    Element attributeNode;
  -    Element complexAttributeNode;
  -    Text text;
  -
  -    document = ((DOMFactory)parser).newDocument();
  -    rootElement = document.createElementNS(null, "browser");
  -    document.appendChild(rootElement);
  -
  -    Iterator profileIter = theProfile.iterator();
  -    while (profileIter.hasNext())
  -    {
  -      ProfileAttribute p = (ProfileAttribute) profileIter.next();
  -      attributeNode = document.createElementNS(null, p.getAttribute());
  -      rootElement.appendChild(attributeNode);
  -      Vector attributeValue = p.get();
  -      Iterator complexValueIter = attributeValue.iterator();
  -      if (p.getCollectionType().equals("Simple"))
  -      {
  -         // Simple attribute
  -         String value = (String) complexValueIter.next();
  -         text = document.createTextNode(value);
  -         attributeNode.appendChild(text);
  -      }
  -      else
  -      {
  -         // Complex attribute e.g. Seq or Bag
  -         while (complexValueIter.hasNext())
  -        {
  -      String value = (String) complexValueIter.next();
  -          complexAttributeNode = document.createElementNS(null, "li");
  -          attributeNode.appendChild(complexAttributeNode);
  -          text = document.createTextNode(value);
  -          complexAttributeNode.appendChild(text);
  +    /**
  +     * Initialize
  +     */
  +    public void initialize()
  +    throws Exception {
  +        this.workspace = new Workspace(this.servletContext, this.deliConfig);
  +    }
  +
  +    /** Dispose of this class */
  +    public void dispose() {
  +        if (parser != null) this.manager.release((Component)parser);
  +        this.parser = null;
  +    }
  +
  +    /** Process a HttpServletRequest and either extract
  +     *  CC/PP or UAProf information from it and use this information
  +     *  to resolve a profile or examine the user agent string, match
  +     *  this using the DELI legacy device database, and use this
  +     *  information to retrieve the appropriate CC/PP profile.
  +     *
  +     *@param theRequest      The Request.
  +     *@return        The profile as a vector of profile attributes.
  +     *@exception     IOException.
  +     *@exception     ServletException.
  +     *@exception     Exception.
  +     */
  +    public Profile getProfile(Request theRequest)
  +    throws IOException, ServletException, Exception {
  +        CocoonServletRequest servletRequest = new CocoonServletRequest(theRequest);
  +        Profile theProfile = new Profile(this.workspace, (HttpServletRequest) 
servletRequest);
  +        return theProfile;
       }
  -      }
  +
  +    /** Convert a profile stored as a vector of profile attributes
  +     *  to a DOM tree.
  +     *
  +     *@param theProfile      The profile as a vector of profile attributes.
  +     *@return        The DOM tree.
  +     */
  +    public Document getUACapabilities(Profile theProfile) {
  +        Document document;
  +        Element rootElement;
  +        Element attributeNode;
  +        Element complexAttributeNode;
  +        Text text;
  +
  +        document = ((DOMFactory)parser).newDocument();
  +        rootElement = document.createElementNS(null, "browser");
  +        document.appendChild(rootElement);
  +
  +        Iterator profileIter = theProfile.iterator();
  +        while (profileIter.hasNext()) {
  +            ProfileAttribute p = (ProfileAttribute) profileIter.next();
  +            attributeNode = document.createElementNS(null, p.getAttribute());
  +            rootElement.appendChild(attributeNode);
  +            Vector attributeValue = p.get();
  +            Iterator complexValueIter = attributeValue.iterator();
  +            if (p.getCollectionType().equals("Simple")) {
  +                // Simple attribute
  +                String value = (String) complexValueIter.next();
  +                text = document.createTextNode(value);
  +                attributeNode.appendChild(text);
  +            } else {
  +                // Complex attribute e.g. Seq or Bag
  +                while (complexValueIter.hasNext()) {
  +                    String value = (String) complexValueIter.next();
  +                    complexAttributeNode = document.createElementNS(null, "li");
  +                    attributeNode.appendChild(complexAttributeNode);
  +                    text = document.createTextNode(value);
  +                    complexAttributeNode.appendChild(text);
  +                }
  +            }
  +        }
  +        return document;
       }
  -    return document;
  -  }
   
       public Document getUACapabilities(Request theRequest)
       throws IOException, Exception {
           return this.getUACapabilities(this.getProfile(theRequest));
       }
   
  -   /**
  +    /**
        * Stub implementation of Servlet Context
        */
  +    public class CocoonServletContext implements ServletContext {
  +
  +        org.apache.cocoon.environment.Context envContext;
  +
  +        public CocoonServletContext(org.apache.cocoon.environment.Context context) {
  +            this.envContext = context;
  +        }
   
  -   public class CocoonServletContext implements ServletContext
  -   {
  -    org.apache.cocoon.environment.Context envContext;
  -
  -    public CocoonServletContext(org.apache.cocoon.environment.Context context)
  -        {
  -        envContext = context;
  -    }
           public Object getAttribute(String name) { return 
envContext.getAttribute(name); }
           public void setAttribute(String name, Object value) { 
envContext.setAttribute(name, value); }
  -    public Enumeration getAttributeNames() { return envContext.getAttributeNames(); 
}
  -    public java.net.URL getResource(String path) throws MalformedURLException { 
return envContext.getResource(path);}
  +        public Enumeration getAttributeNames() { return 
envContext.getAttributeNames(); }
  +        public java.net.URL getResource(String path) throws MalformedURLException { 
return envContext.getResource(path);}
           public String getRealPath(String path) { return 
envContext.getRealPath(path); }
  -    public String getMimeType(String file) { return envContext.getMimeType(file); }
  -    public String getInitParameter(String name) { return 
envContext.getInitParameter(name); }
  -    public java.io.InputStream getResourceAsStream(String path){ return 
envContext.getResourceAsStream(path);}
  +        public String getMimeType(String file) { return 
envContext.getMimeType(file); }
  +        public String getInitParameter(String name) { return 
envContext.getInitParameter(name); }
  +        public java.io.InputStream getResourceAsStream(String path){ return 
envContext.getResourceAsStream(path);}
   
           public ServletContext getContext(String uripath) { return (null); }
           public Enumeration getInitParameterNames() {return (null); }
           public int getMajorVersion() { return (2); }
  -    public int getMinorVersion() { return (3); }
  +        public int getMinorVersion() { return (3); }
           public RequestDispatcher getNamedDispatcher(String name) { return (null); }
           public RequestDispatcher getRequestDispatcher(String path) { return (null); 
}
           public Set getResourcePaths(String path) { return null; }
           public String getServerInfo() { return (null); }
           public Servlet getServlet(String name) throws ServletException { return 
(null); }
           public String getServletContextName() { return (null); }
  -    public Enumeration getServletNames() { return (null); }
  +        public Enumeration getServletNames() { return (null); }
           public Enumeration getServlets() {  return (null); }
           public void log(String message) {}
           public void log(Exception exception, String message) {}
  @@ -246,17 +236,16 @@
           public void removeAttribute(String name) {}
      }
   
  -   /**
  +    /**
        * Stub implementation of HttpServletRequest
        */
  -    public class CocoonServletRequest implements HttpServletRequest
  -    {
  +    public class CocoonServletRequest implements HttpServletRequest {
           Request request;
   
  -        public CocoonServletRequest(Request request)
  -        {
  +        public CocoonServletRequest(Request request) {
               this.request = request;
           }
  +
           public String getAuthType(){ return request.getAuthType(); }
           public long getDateHeader(String s){ return request.getDateHeader(s); }
           public String getHeader(String s){ return request.getHeader(s); }
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to