paulsp      02/04/13 01:24:44

  Modified:    build    build.xml
               src/java/org/apache/jetspeed/test TestBasicSanity.java
               src/java/org/apache/jetspeed/util/template
                        BaseJetspeedLink.java JetspeedLink.java
                        JetspeedTemplateLink.java TestJetspeedLink.java
               webapp/WEB-INF/conf TurbineResources.properties
  Added:       src/java/org/apache/jetspeed/util/template
                        TestUnitJetspeedLink.java JetspeedLinkFactory.java
  Log:
  Part of PEID implementation
  o JetspeedLinkFactory can pool object, using Turbine's pool service
  o JetspeedLinkFactory returns same class as used by the tool jlink
  o Update server test
  o Added unit test
  
  Revision  Changes    Path
  1.139     +1 -0      jakarta-jetspeed/build/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/build/build.xml,v
  retrieving revision 1.138
  retrieving revision 1.139
  diff -u -r1.138 -r1.139
  --- build.xml 9 Apr 2002 04:36:35 -0000       1.138
  +++ build.xml 13 Apr 2002 08:24:44 -0000      1.139
  @@ -809,6 +809,7 @@
               <test 
name="org.apache.jetspeed.services.registry.TestMarshallRegistry"/>
               <test 
name="org.apache.jetspeed.services.registry.TestRegistryCategories"/>
             <!--  <test 
name="org.apache.jetspeed.services.registry.TestRegistryPersistence"/> -->
  +            <test name="org.apache.jetspeed.util.template.TestUnitJetspeedLink"/>
           </junit>
       </target>
   
  
  
  
  1.2       +2 -2      
jakarta-jetspeed/src/java/org/apache/jetspeed/test/TestBasicSanity.java
  
  Index: TestBasicSanity.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/test/TestBasicSanity.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestBasicSanity.java      30 Mar 2002 12:37:37 -0000      1.1
  +++ TestBasicSanity.java      13 Apr 2002 08:24:44 -0000      1.2
  @@ -92,7 +92,7 @@
   /**
    *
    * @author <a href="[EMAIL PROTECTED]">Paul Spencer</a>
  - * @version $Id: TestBasicSanity.java,v 1.1 2002/03/30 12:37:37 paulsp Exp $
  + * @version $Id: TestBasicSanity.java,v 1.2 2002/04/13 08:24:44 paulsp Exp $
    */
   
   public class TestBasicSanity extends ServletTestCase
  @@ -208,7 +208,7 @@
           TurbinePull.populateContext( context, rundata);
   
           // Verify tool are in the context
  -        assertNotNull( "Got jtool from context", context.get("jlink"));
  +        assertNotNull( "Got jlink from context", context.get("jlink"));
   
           // Generatate and output thre page
           TurbineTestUtilities.generatePage(rundata);
  
  
  
  1.2       +16 -3     
jakarta-jetspeed/src/java/org/apache/jetspeed/util/template/BaseJetspeedLink.java
  
  Index: BaseJetspeedLink.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/util/template/BaseJetspeedLink.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BaseJetspeedLink.java     9 Apr 2002 04:36:35 -0000       1.1
  +++ BaseJetspeedLink.java     13 Apr 2002 08:24:44 -0000      1.2
  @@ -87,7 +87,7 @@
    * rendering code. This is done currently in VelocityPortlet.</p>
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Paul Spencer</a>
  - * @version $Id: BaseJetspeedLink.java,v 1.1 2002/04/09 04:36:35 paulsp Exp $
  + * @version $Id: BaseJetspeedLink.java,v 1.2 2002/04/13 08:24:44 paulsp Exp $
    */
   public class BaseJetspeedLink implements ApplicationTool, JetspeedLink
   {
  @@ -140,9 +140,19 @@
        */
       public BaseJetspeedLink(RunData data)
       {
  -        init(data);
  +        init((Object) data);
       }
       
  +    /**
  +     * This will initialise a JetspeedLink object that was
  +     * constructed with the default constructor 
  +     *
  +     * @param rundata to be a RunData object
  +     */
  +    public void init(RunData rundata)
  +    {
  +        init( (Object) rundata);
  +    }
       
       /**
        * Return an link to a specific portal element
  @@ -479,7 +489,10 @@
       public void init(Object data)
       {
           // Keeping init small and fast
  -        this.rundata = (JetspeedRunData)data;
  +        if (data instanceof JetspeedRunData)
  +            this.rundata = (JetspeedRunData)data;
  +        else
  +            this.rundata = null;
           profile = null;
           locator = null;
           return;
  
  
  
  1.3       +11 -2     
jakarta-jetspeed/src/java/org/apache/jetspeed/util/template/JetspeedLink.java
  
  Index: JetspeedLink.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/util/template/JetspeedLink.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JetspeedLink.java 9 Apr 2002 04:36:35 -0000       1.2
  +++ JetspeedLink.java 13 Apr 2002 08:24:44 -0000      1.3
  @@ -59,6 +59,7 @@
   
   // Turbine
   import org.apache.turbine.util.DynamicURI;
  +import org.apache.turbine.util.RunData;
   
   /**
    * <p>A customized version of the TemplateLink which can handle portlet
  @@ -70,10 +71,18 @@
    * rendering code. This is done currently in VelocityPortlet.</p>
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Paul Spencer</a>
  - * @version $Id: JetspeedLink.java,v 1.2 2002/04/09 04:36:35 paulsp Exp $
  + * @version $Id: JetspeedLink.java,v 1.3 2002/04/13 08:24:44 paulsp Exp $
    */
  -public interface  JetspeedLink 
  +public interface JetspeedLink 
   {
  +    /**
  +     * This will initialise a JetspeedLink object that was
  +     * constructed with the default constructor 
  +     *
  +     * @param rundata to be a RunData object
  +     */
  +    public void init(RunData rundata);
  +
       /**
        * Return an link to a specific portal element
        *
  
  
  
  1.8       +41 -3     
jakarta-jetspeed/src/java/org/apache/jetspeed/util/template/JetspeedTemplateLink.java
  
  Index: JetspeedTemplateLink.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/util/template/JetspeedTemplateLink.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- JetspeedTemplateLink.java 11 Mar 2002 07:22:12 -0000      1.7
  +++ JetspeedTemplateLink.java 13 Apr 2002 08:24:44 -0000      1.8
  @@ -66,7 +66,7 @@
   import org.apache.jetspeed.portal.PanedPortletController;
   
   import org.apache.jetspeed.services.rundata.JetspeedRunData;
  -
  +import org.apache.jetspeed.util.template.JetspeedLink;
   
   /**
    * <p>A customized version of the TemplateLink which can handle portlet
  @@ -79,10 +79,12 @@
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Raphaël Luta</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Santiago Gala</a>
  - * @version $Id: JetspeedTemplateLink.java,v 1.7 2002/03/11 07:22:12 taylor Exp $
  + * @version $Id: JetspeedTemplateLink.java,v 1.8 2002/04/13 08:24:44 paulsp Exp $
  + * 
  + * @deprecated Use JetspeedBaseLink
    */
   public class JetspeedTemplateLink
  -    extends TemplateLink implements ApplicationTool
  +    extends TemplateLink implements ApplicationTool, JetspeedLink
   {
           
       // parameter names for the Jetspeed framework elements    
  @@ -320,4 +322,40 @@
       }
   
   
  +    /*
  +     *  Part of JetspeedLink interface
  +     */
  +    /**
  +     * Return an link to a specific portal element
  +     *
  +     * @param peid of the portal element
  +     * @return DynamicURI to specific portal element
  +     */
  +    public DynamicURI setPortalElement(String peid)
  +    {
  +        return addPathInfo("js_peid", peid);
  +    }    
  +
  +    /**
  +     * Return a link to a specific pane using the pane's id
  +     *
  +     * @param paneId of the Pane
  +     * @return  URI to specific portlet
  +     */
  +    public DynamicURI setPaneById(String paneId)
  +    {
  +        return addPathInfo("js_pane", paneId);
  +    }
  +    
  +    /**
  +     * Return an link to a specific portlet using the portet's id
  +     *
  +     * @param peid of the portlet
  +     * @return DynamicURI to specific portlet
  +     */
  +    public DynamicURI setPortletById(String peid)
  +    {
  +        return addPathInfo("js_peid", peid);
  +    }
  +    
   }
  
  
  
  1.2       +59 -11    
jakarta-jetspeed/src/java/org/apache/jetspeed/util/template/TestJetspeedLink.java
  
  Index: TestJetspeedLink.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/util/template/TestJetspeedLink.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestJetspeedLink.java     4 Apr 2002 11:00:26 -0000       1.1
  +++ TestJetspeedLink.java     13 Apr 2002 08:24:44 -0000      1.2
  @@ -78,6 +78,7 @@
   import org.apache.jetspeed.services.JetspeedSecurity;
   import org.apache.jetspeed.services.rundata.JetspeedRunData;
   import org.apache.jetspeed.util.template.JetspeedLink;
  +import org.apache.jetspeed.util.template.JetspeedLinkFactory;
   import org.apache.jetspeed.test.TurbineTestUtilities;
   
   // Turbine imports
  @@ -92,7 +93,7 @@
    * TestJespeedLink
    *
    * @author <a href="[EMAIL PROTECTED]">Paul Spencer</a>
  - * @version $Id: TestJetspeedLink.java,v 1.1 2002/04/04 11:00:26 paulsp Exp $
  + * @version $Id: TestJetspeedLink.java,v 1.2 2002/04/13 08:24:44 paulsp Exp $
    */
   public class TestJetspeedLink extends ServletTestCase
   {
  @@ -117,8 +118,7 @@
        */
       public static void main(String args[])
       {
  -        TestRunner.main( new String[]
  -        { TestJetspeedLink.class.getName() } );
  +        TestRunner.main( new String[] { TestJetspeedLink.class.getName() } );
       }
       
       /**
  @@ -207,7 +207,7 @@
           
           // Verify tool are in the context
           JetspeedLink jlink = (JetspeedLink) context.get("jlink");
  -        assertNotNull( "Got jtool from context", jlink);
  +        assertNotNull( "Got jlink from context", jlink);
           
           // Generate the link
           String link = jlink.toString();
  @@ -254,7 +254,7 @@
           
           // Verify tool are in the context
           JetspeedLink jlink = (JetspeedLink) context.get("jlink");
  -        assertNotNull( "Got jtool from context", jlink);
  +        assertNotNull( "Got jlink from context", jlink);
           
           // Generate the link
           String link = jlink.toString();
  @@ -274,7 +274,7 @@
           System.out.println("text = " + theResponse.getText().length());
       }
       
  -    public void beginGroupPageLink(WebRequest theRequest)
  +    public void beginGroupPage(WebRequest theRequest)
       {
           theRequest.setURL(TEST_HOST, TEST_CONTEXT, TEST_SERVLET
           , "/group/apache/page/news" , null);
  @@ -285,7 +285,7 @@
        * Test the User link
        * @throws Exception
        */
  -    public void testGroupPageLink() throws Exception
  +    public void testGroupPage() throws Exception
       {
           // Create the RunData object to be used during testing.
           RunData rundata = RunDataFactory.getRunData( request, response, config );
  @@ -299,12 +299,12 @@
           
           // Verify tool are in the context
           JetspeedLink jlink = (JetspeedLink) context.get("jlink");
  -        assertNotNull( "Got jtool from context", jlink);
  +        assertNotNull( "Got jlink from context", jlink);
           
           // Generate the link
           String link = jlink.toString();
  -        System.out.println("Page Link = " + link);
  -        assertTrue( "Verifing page Link", 
  +        System.out.println("Group/Page Link = " + link);
  +        assertTrue( "Verifing group/page Link", 
             link.startsWith("http://"; + TEST_HOST + TEST_CONTEXT + TEST_SERVLET 
+"/group/apache/page/news"));
           
           // Generatate and output thre page
  @@ -314,7 +314,55 @@
           // Return the used RunData to the factory for recycling.
           RunDataFactory.putRunData(rundata);
       }
  -    public void endGroupPageLink(org.apache.cactus.WebResponse theResponse)
  +    public void endGroupPage(org.apache.cactus.WebResponse theResponse)
  +    {
  +        System.out.println("text = " + theResponse.getText().length());
  +    }
  +
  +    public void beginGroupPage2(WebRequest theRequest)
  +    {
  +        theRequest.setURL(TEST_HOST, TEST_CONTEXT, TEST_SERVLET
  +        , "/group/apache/page/news" , null);
  +        System.out.println("post set URL = " + theRequest.getURL());
  +    }
  +    
  +    /**
  +     * Test the User link
  +     * @throws Exception
  +     */
  +    public void testGroupPage2() throws Exception
  +    {
  +        // Create the RunData object to be used during testing.
  +        RunData rundata = RunDataFactory.getRunData( request, response, config );
  +        assertNotNull( "Got rundata", rundata);
  +        TurbineTestUtilities.setupRunData(rundata);
  +        
  +        // Get and populate the context
  +        Context context = TurbineVelocity.getContext(rundata);
  +        assertNotNull( "Got context", context);
  +        TurbinePull.populateContext( context, rundata);
  +        
  +        // Verify tool are in the context
  +        JetspeedLink jlink = (JetspeedLink) context.get("jlink");
  +        assertNotNull( "Got jlink from context", jlink);
  +        
  +        // Generate the link
  +        String link = jlink.toString();
  +        System.out.println("Group/Page Link = " + link);
  +        
  +        // Generate the link from JetspeedLink
  +        JetspeedLink jetspeedLink = JetspeedLinkFactory.getInstance(rundata);
  +        System.out.println("Group/Page jetspeedLink = " + jetspeedLink.toString());
  +        assertTrue( "jlink = jetspeedLink", link.equals( jetspeedLink.toString()));
  +        
  +        // Generatate and output thre page
  +        TurbineTestUtilities.generatePage(rundata);
  +        TurbineTestUtilities.outputPage(rundata);
  +        
  +        // Return the used RunData to the factory for recycling.
  +        RunDataFactory.putRunData(rundata);
  +    }
  +    public void endGroupPage2(org.apache.cactus.WebResponse theResponse)
       {
           System.out.println("text = " + theResponse.getText().length());
       }
  
  
  
  1.1                  
jakarta-jetspeed/src/java/org/apache/jetspeed/util/template/TestUnitJetspeedLink.java
  
  Index: TestUnitJetspeedLink.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *     "Apache Jetspeed" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache" or
   *    "Apache Jetspeed", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  
  package org.apache.jetspeed.util.template;
  
  // Cactus and Junit imports
  import junit.framework.Test;
  import junit.framework.TestCase;
  import junit.framework.TestSuite;
  import junit.awtui.TestRunner;
  
  // Jetspeed imports
  import org.apache.jetspeed.util.template.JetspeedLink;
  
  // Turbine imports
  import org.apache.turbine.services.pool.TurbinePool;
  import org.apache.turbine.util.TurbineConfig;
  import org.apache.turbine.util.StringUtils;
  
  /**
   * TestTurbineCache
   *
   * @author <a href="[EMAIL PROTECTED]">Paul Spencer</a>
   * @version $Id: TestUnitJetspeedLink.java,v 1.1 2002/04/13 08:24:44 paulsp Exp $
   */
  public class TestUnitJetspeedLink extends TestCase {
      
      /**
       * Configuration object to run Turbine outside a servlet container
       * ( uses turbine.properties )
       */
      private static TurbineConfig config = null;
      
      /**
       * Sets up TurbineConfig using the system property:
       * <pre>turbine.properties</pre>
       */
      static
      {
          try
          {
              config = new TurbineConfig( "../webapp",
              "/WEB-INF/conf/TurbineResources.properties");
              config.init();
          }
          catch (Exception e)
          {
              fail(StringUtils.stackTrace(e));
          }
      }
  
      /**
       * Defines the testcase name for JUnit.
       *
       * @param name the testcase's name.
       */
      public TestUnitJetspeedLink(String name) {
          super( name );
      }
      
      /**
       * Start the tests.
       *
       * @param args the arguments. Not used
       */
      public static void main(String args[]) {
          TestRunner.main( new String[] { TestUnitJetspeedLink.class.getName() } );
      }
   
      /**
       * Creates the test suite.
       *
       * @return a test suite (<code>TestSuite</code>) that includes all methods
       *         starting with "test"
       */
      public static Test suite() {
          // All methods starting with "test" will be executed in the test suite.
          return new TestSuite( TestUnitJetspeedLink.class );
      }
      
      /**
       * Simple test that get a JetspeedLink object
       *
       * @throws Exception
       */
      public void testSimpleGet() throws Exception
      {
          JetspeedLink jlink = JetspeedLinkFactory.getInstance();
          System.out.println("Class return by JetspeedLinkFactory: " + 
jlink.getClass().getName());
          assertNotNull( "Got JetspeedLink", jlink);
          assertTrue( "jlink instance of JetspeedLink", (jlink instanceof 
JetspeedLink));
      }
  
      /**
       * Simple test that gets and put a JetspeedLink object
       *
       * @throws Exception
       */
      public void testGetandPut() throws Exception
      {
          JetspeedLink jlink = null;
          for (int counter = 0; counter < 10; counter++)
          {
            jlink = JetspeedLinkFactory.getInstance();
            assertNotNull( "Get loop - Got JetspeedLink", jlink);
            assertTrue( "Get loop - jlink instance of JetspeedLink", (jlink instanceof 
JetspeedLink));
          }
          jlink = null;
  
          for (int counter = 0; counter < 10; counter++)
          {
            jlink = JetspeedLinkFactory.getInstance();
            assertNotNull( "Get/put loop - Got JetspeedLink", jlink);
            assertTrue( "Get/put loop - jlink instance of JetspeedLink", (jlink 
instanceof JetspeedLink));
            JetspeedLinkFactory.putInstance(jlink);
            jlink = null;
          }
      }
  }
  
  
  
  1.1                  
jakarta-jetspeed/src/java/org/apache/jetspeed/util/template/JetspeedLinkFactory.java
  
  Index: JetspeedLinkFactory.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *     "Apache Jetspeed" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache" or
   *    "Apache Jetspeed", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.jetspeed.util.template;
  
  // Jetspeed
  import org.apache.jetspeed.util.template.BaseJetspeedLink;
  import org.apache.jetspeed.services.resources.JetspeedResources;
  
  // Turbine
  import org.apache.turbine.util.TurbineException;
  import org.apache.turbine.services.pool.TurbinePool;
  import org.apache.turbine.util.RunData;
  
  /**
   * Return a JetspeedLink object.  The object may be
   * returned from a pool or instanciated.  The pool
   * is maintained by Turbine's pool service.
   *
   */
  public class JetspeedLinkFactory
  {
      /**
       * Name of class for JetspeedLink.  The class is the same one used
       * by the tool <code>jlink</code>, so the class name is retrieved from 
       * the tool's configuration.
       */
       private static String JETSPEEDLINK_CLASSNAME = 
JetspeedResources.getString("tool.request.jlink","org.apache.jetspeed.util.template.BaseJetspeedLink");
  
      /**
       * Get an JetspeedLink object.  The object may be retreived
       * from a pool.  If no object is available in the pool, then one will
       * be instanciated.
       *
       * The JetspeedLink's init() should be called to return a valid link.
       *
       * @throws TurbineException by Turbine's pool service
       * @return JetspeedLink 
       */    
      public static JetspeedLink getInstance()
      throws TurbineException
      {
          JetspeedLink jlink = (JetspeedLink) TurbinePool.getInstance( 
JETSPEEDLINK_CLASSNAME);
          if (jlink == null)
              jlink = new BaseJetspeedLink();
          return jlink;
      }
      
      /**
       * Get an initialized JetspeedLink object.  The object may be retreived
       * from a pool.  If no object is available in the pool, then one will
       * be instanciated.  The object will be initialized with Rundata.
       *
       * @param rundata The request data.
       * @throws TurbineException by Turbine's pool service
       * @return JetspeedLink
       */    
      public static JetspeedLink getInstance( RunData rundata)
      throws TurbineException
      {
          JetspeedLink jlink = getInstance();
          if (jlink != null)
              jlink.init(rundata);
          return jlink;
      }
      
      /**
       * Return an object to the pool
       *
       * @param jetspeedLink object to return to pool
       */    
      public static void putInstance(JetspeedLink jetspeedLink)
      {
          if (jetspeedLink != null)
              TurbinePool.putInstance( jetspeedLink);
          return;
      }
  }
  
  
  
  1.48      +3 -2      jakarta-jetspeed/webapp/WEB-INF/conf/TurbineResources.properties
  
  Index: TurbineResources.properties
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed/webapp/WEB-INF/conf/TurbineResources.properties,v
  retrieving revision 1.47
  retrieving revision 1.48
  diff -u -r1.47 -r1.48
  --- TurbineResources.properties       8 Apr 2002 16:54:44 -0000       1.47
  +++ TurbineResources.properties       13 Apr 2002 08:24:44 -0000      1.48
  @@ -1,5 +1,5 @@
   # -------------------------------------------------------------------
  -# $Id: TurbineResources.properties,v 1.47 2002/04/08 16:54:44 kimptoc Exp $
  +# $Id: TurbineResources.properties,v 1.48 2002/04/13 08:24:44 paulsp Exp $
   #
   # This is the configuration file for Turbine.
   #
  @@ -590,7 +590,8 @@
   tool.request.page=org.apache.turbine.util.template.TemplatePageAttributes
   tool.request.content=org.apache.turbine.util.ContentURI
   tool.request.clink=org.apache.jetspeed.util.template.ContentTemplateLink
  -tool.request.jlink=org.apache.jetspeed.util.template.JetspeedTemplateLink
  +tool.request.jlink=org.apache.jetspeed.util.template.BaseJetspeedLink
  +#tool.request.jlink=org.apache.jetspeed.util.template.JetspeedTemplateLink
   tool.request.jetspeed=org.apache.jetspeed.util.template.JetspeedTool
   tool.request.l10n=org.apache.turbine.services.localization.LocalizationTool
   
#tool.request.jnavigation=org.apache.jetspeed.util.template.JetspeedTemplateNavigation
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to