Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements.  See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License.  You may obtain a copy of the License at
 
     http://www.apache.org/licenses/LICENSE-2.0
 
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.


===============
Header Resource
===============

  Overviews:
  ----------

   Header Resource component allows user to set tags, such as <link> and
   <script> tag into <head> tag. Currently, Jetspeed2 puts only decorators
   stylesheet tag into <head> tag. But, using Header Resource Component,
   user can put user-defined stylesheet and javascript file from portal or
   portlet.


  Design:
  -------

   i) Process to add tags to HeaderResource component

                      --------------------------- 
                      |JetspeedPortletServices..|
                      --------------------------- 
                                 |
                                 V
               -------------------------------------------- 
               |o.a.j.headerresource.HeaderResourceFactory|
               -------------------------------------------- 
                                 | getHeaderResouce(RequestContext requestContext)
                                 V
                  ------------------------------------- 
                  |o.a.j.headerresource.HeaderResource|
                  ------------------------------------- 
                                 A Add tag into Set for HeaderResource
                                 | addHeaderInfo(), addJavaScript(), addStyleSheet()
                       Tag (<link> and <script>)
              


   ii) Process to get tags from HeaderResource component

                      --------------------------- 
                      |JetspeedPortletServices..|
                      --------------------------- 
                                 |
                                 V
               -------------------------------------------- 
               |o.a.j.headerresource.HeaderResourceFactory|
               -------------------------------------------- 
                                 | getHeaderResouce(RequestContext requestContext)
                                 V
                  ------------------------------------- 
                  |o.a.j.headerresource.HeaderResource|
                  ------------------------------------- 
                                 | toString()
                                 V
                       Template file(ex. decorator-tom.vm)


  Class Description
  -----------------

   Added Interfaces
   ----------------

   o org.apache.jetspeed.headerresource.HeaderResource

     public abstract HeaderResource getHeaderResouce(RequestContext requestContext);
     public abstract HeaderResource getHeaderResouce(PortletRequest request);

   o org.apache.jetspeed.headerresource.HeaderResourceFactory

     public abstract String toString();
     public abstract void addHeaderInfo(String elementName, Map attributes, String text);
     public abstract void addJavaScript(String path, boolean defer);
     public abstract void addJavaScript(String path);
     public abstract void addStyleSheet(String path);


   Added Classes
   -------------

    components/src/java/org/apache/jetspeed/headerresource/impl/HeaderResourceFactoryImpl.java
    components/src/java/org/apache/jetspeed/headerresource/impl/HeaderResourceImpl.java

    - HeaderResourceImpl class creates LinkedHashSet and put it into
      RequestContext#setAttribute(). LinkedHashSet has tags info to put
      them in <head>.


  Usage
  -----

   In Portal
   ---------
    Example:

      HeaderResourceFactory headerResourceFactory
           = (HeaderResourceFactory)Jetspeed.getComponentManager().getComponent(HeaderResourceFactory.class);
      HeaderResource headerResource = headerResourceFactory.getHeaderResouce(requestContext);

      headerResource.addStyleSheet("content/css/styles.css");

   In Portlet
   ----------
    Example:

      HeaderResourceFactory headerResourceFactory
        = getPortletContext().getAttribute(CommonPortletServices.CPS_HEADER_RESOURCE_FACTORY);
      HeaderResource headerResource = headerResourceFactory.getHeaderResouce(request);

      headerResource.addJavascript("script.js");


