stefano     2003/02/22 05:50:54

  Modified:    src/java/org/apache/cocoon/transformation
                        TraxTransformer.java
  Log:
  removed dependencies on deli (the new DeliTransformer will extend this one and 
provide Deli functionality) this is done to allow block decoupling
  
  Revision  Changes    Path
  1.43      +2 -125    
xml-cocoon2/src/java/org/apache/cocoon/transformation/TraxTransformer.java
  
  Index: TraxTransformer.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/transformation/TraxTransformer.java,v
  retrieving revision 1.42
  retrieving revision 1.43
  diff -u -r1.42 -r1.43
  --- TraxTransformer.java      31 Jan 2003 22:51:57 -0000      1.42
  +++ TraxTransformer.java      22 Feb 2003 13:50:54 -0000      1.43
  @@ -46,8 +46,8 @@
    on  behalf of the Apache Software  Foundation and was  originally created by
    Stefano Mazzocchi  <[EMAIL PROTECTED]>. For more  information on the Apache
    Software Foundation, please see <http://www.apache.org/>.
  -
   */
  +
   package org.apache.cocoon.transformation;
   
   import org.apache.excalibur.xml.xslt.XSLTProcessor;
  @@ -63,8 +63,6 @@
   import org.apache.avalon.framework.parameters.Parameters;
   import org.apache.cocoon.ProcessingException;
   import org.apache.cocoon.caching.CacheableProcessingComponent;
  -import org.apache.cocoon.components.browser.Browser;
  -import org.apache.cocoon.components.deli.Deli;
   import org.apache.cocoon.components.source.SourceUtil;
   import org.apache.cocoon.environment.Cookie;
   import org.apache.cocoon.environment.ObjectModelHelper;
  @@ -107,12 +105,6 @@
    * concerning cachability of the generated output of this transformer.<br>
    * This property is false by default.
    * <p>
  - * The &lt;use-browser-capabilities-db&gt; configuration forces the transformer to 
make all
  - * properties from the browser capability database available in the XSLT 
stylesheetas.
  - * Note that this might have issues concerning cachability of the generated output 
of this
  - * transformer.<br>
  - * This property is false by default.
  - * <p>
    * The &lt;use-cookies&gt; configuration forces the transformer to make all
    * cookies from the request available in the XSLT stylesheetas.
    * Note that this might have issues concerning cachability of the generated output 
of this
  @@ -125,14 +117,6 @@
    * session-id-from-cookie, session-id-from-url, session-valid, session-id.<br>
    * This property is false by default.
    *
  - * <p> The &lt;use-deli&gt; makes the DELI information available.
  - * If DELI component is configured in the cocoon.xconf, transformer will
  - * make all the properties from the CC/PP profile resolved from
  - * the request available in the XSLT stylesheets.  CC/PP support is
  - * provided via the DELI library. If the request does not provide
  - * CC/PP information, then CC/PP information can added via the DELI
  - * legacy device database.
  - * 
    * <p>Note that these properties might introduces issues concerning
    * cacheability of the generated output of this transformer.<br>
    *
  @@ -167,24 +151,10 @@
   public class TraxTransformer extends AbstractTransformer
   implements Transformer, Composable, Configurable, CacheableProcessingComponent, 
Disposable {
   
  -    /** The Browser service instance */
  -    private Browser browser = null;
  -
  -    /** The DELI service instance */
  -    private Deli deli = null;
  -
  -    /** Should we make the DELI CC/PP profile available to the stylesheet (default 
is off) */
  -    private boolean useDeli = false;
  -    private boolean _useDeli = false;
  -    
       /** Should we make the request parameters available in the stylesheet? (default 
is off) */
       private boolean useParameters = false;
       private boolean _useParameters = false;
   
  -    /** Should we make the browser capability properties available in the 
stylesheet? (default is off) */
  -    private boolean useBrowserCap = false;
  -    private boolean _useBrowserCap = false;
  -
       /** Should we make the cookies availalbe in the stylesheet? (default is off) */
       private boolean useCookies = false;
       private boolean _useCookies = false;
  @@ -237,18 +207,10 @@
           this.useCookies = child.getValueAsBoolean(false);
           this._useCookies = this.useCookies;
   
  -        child = conf.getChild("use-browser-capabilities-db");
  -        this.useBrowserCap = child.getValueAsBoolean(false);
  -        this._useBrowserCap = this.useBrowserCap;
  -
           child = conf.getChild("use-session-info");
           this.useSessionInfo = child.getValueAsBoolean(false);
           this._useSessionInfo = this.useSessionInfo;
   
  -        child = conf.getChild("use-deli");
  -        this.useDeli = child.getValueAsBoolean(false);
  -        this._useDeli = this.useDeli;
  -
           child = conf.getChild("transformer-factory");
   
           // traxFactory is null, if transformer-factory config is unspecified
  @@ -257,9 +219,7 @@
           if (this.getLogger().isDebugEnabled()) {
               this.getLogger().debug("Use parameters is " + this.useParameters + " 
for " + this);
               this.getLogger().debug("Use cookies is " + this.useCookies + " for " + 
this);
  -            this.getLogger().debug("Use browser capabilities is " + 
this.useBrowserCap + " for " + this);
               this.getLogger().debug("Use session info is " + this.useSessionInfo + " 
for " + this);
  -            this.getLogger().debug("Use DELI is " + this.useDeli + " for " + this);
   
               if (this.traxFactory != null) {
                   this.getLogger().debug("Use TrAX Transformer Factory " + 
this.traxFactory);
  @@ -286,22 +246,6 @@
        */
       public void compose(ComponentManager manager) throws ComponentException {
           this.manager = manager;
  -
  -        if (this.getLogger().isDebugEnabled()) {
  -            getLogger().debug("Looking up " + Browser.ROLE);
  -        }
  -        this.browser = (Browser) manager.lookup(Browser.ROLE);
  -
  -        if (this.manager.hasComponent(Deli.ROLE)) {
  -            if (this.getLogger().isDebugEnabled()) {
  -                getLogger().debug("Looking up " + Deli.ROLE);
  -            }
  -            this.deli = (Deli) this.manager.lookup(Deli.ROLE);
  -        } else {
  -            if (this.getLogger().isDebugEnabled()) {
  -                getLogger().debug("Deli is not available");
  -            }
  -        }
       }
   
       /**
  @@ -325,10 +269,8 @@
               throw SourceUtil.handle("Unable to resolve " + src, se);
           }
           _useParameters = par.getParameterAsBoolean("use-request-parameters", 
this.useParameters);
  -        _useBrowserCap = par.getParameterAsBoolean("use-browser-capabilities-db", 
this.useBrowserCap);
           _useCookies = par.getParameterAsBoolean("use-cookies", this.useCookies);
           _useSessionInfo = par.getParameterAsBoolean("use-session-info", 
this.useSessionInfo);
  -        _useDeli = par.getParameterAsBoolean("use-deli", this.useDeli);
   
           if (this.getLogger().isDebugEnabled()) {
               this.getLogger().debug("Using stylesheet: '" + 
this.inputSource.getURI() + "' in " + this);
  @@ -436,7 +378,6 @@
           }
   
           if (this._useParameters) {
  -            /** The Request object */
               Request request = ObjectModelHelper.getRequest(objectModel);
   
               Enumeration parameters = request.getParameterNames();
  @@ -455,7 +396,6 @@
           }
   
           if (this._useSessionInfo) {
  -            /** The Request object */
               Request request = ObjectModelHelper.getRequest(objectModel);
               if (map == null) map = new HashMap(5);
   
  @@ -489,69 +429,10 @@
               }
           }
   
  -        if (this._useBrowserCap) try {
  -            Request request = ObjectModelHelper.getRequest(objectModel);
  -            if (map == null) {
  -                map = new HashMap();
  -            }
  -
  -            /* Get the accept header; it's needed to get the browser type. */
  -            String accept = request.getParameter("accept");
  -            if (accept == null)
  -                accept = request.getHeader("accept");
  -
  -            /* Get the user agent; it's needed to get the browser type. */
  -            String agent = request.getParameter("user-agent");
  -            if (agent == null)
  -                agent = request.getHeader("user-agent");
  -
  -            /* add the accept param */
  -            map.put("accept", accept);
  -
  -            /* add the user agent param */
  -            map.put("user-agent", java.net.URLEncoder.encode(agent));
  -
  -            /* add the map param */
  -            HashMap agmap = browser.getBrowser(agent, accept);
  -            map.put("browser", agmap);
  -
  -            /* add the media param */
  -            String browserMedia = browser.getMedia(agmap);
  -            map.put("browser-media", browserMedia);
  -
  -            /* add the uaCapabilities param */
  -            org.w3c.dom.Document uaCapabilities = browser.getUACapabilities(agmap);
  -            map.put("ua-capabilities", uaCapabilities);
  -        } catch (Exception e) {
  -            getLogger().error("Error setting Browser info", e);
  -        }
  -
  -        if (this.deli != null && this._useDeli) {
  -            try {
  -                Request request = ObjectModelHelper.getRequest(objectModel);
  -                if (map == null) {
  -                    map = new HashMap();
  -                }
  -
  -                org.w3c.dom.Document deliCapabilities = 
this.deli.getUACapabilities(request);
  -                map.put("deli-capabilities", deliCapabilities);
  -
  -                String accept = request.getParameter("accept");
  -                if (accept == null)
  -                   accept = request.getHeader("accept");
  -
  -                /* add the accept param */
  -                map.put("accept", accept);
  -            } catch (Exception e) {
  -                getLogger().error("Error setting DELI info", e);
  -            }
  -        }
           this.logicSheetParameters = map;
           return map;
       }
   
  -    // FIXME (SM): this method may be a hotspot for requests with many
  -    //             parameters we should try to optimize it further
       static boolean isValidXSLTParameterName(String name) {
           if (name.length() == 0) {
               return false;
  @@ -579,12 +460,8 @@
        * Disposable
        */
       public void dispose() {
  -        this.manager.release(this.browser);
           this.manager.release(this.xsltProcessor);
  -        this.manager.release(this.deli);
  -        this.browser = null;
           this.xsltProcessor = null;
  -        this.deli = null;
           this.manager = null;
       }
   
  
  
  

Reply via email to