portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject cvs commit: jakarta-jetspeed-2/cps/src/test/org/apache/jetspeed/cps TestPico.java
Date Fri, 13 Feb 2004 03:48:27 GMT
taylor      2004/02/12 19:48:27

  Modified:    cps      project.xml
               cps/src/java/org/apache/jetspeed/cps
                        CommonPortletServices.java
               cps/src/java/org/apache/jetspeed/cps/template
                        TemplateLocatorComponentImpl.java
               cps/src/test/org/apache/jetspeed/cps TestPico.java
  Log:
  pico is now loading the template service
  next step is getting the configuration completely hooked in, and then hooking it into a
container
  
  Revision  Changes    Path
  1.8       +1 -1      jakarta-jetspeed-2/cps/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/cps/project.xml,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- project.xml	11 Feb 2004 04:35:11 -0000	1.7
  +++ project.xml	13 Feb 2004 03:48:27 -0000	1.8
  @@ -93,7 +93,7 @@
       </dependency>
       <dependency>
         <id>picocontainer</id>
  -      <version>1.0-beta-4</version>
  +      <version>1.0-beta-5-SNAPSHOT</version>
         <properties>
           <war.bundle.jar>true</war.bundle.jar>
         </properties>
  
  
  
  1.5       +21 -1     jakarta-jetspeed-2/cps/src/java/org/apache/jetspeed/cps/CommonPortletServices.java
  
  Index: CommonPortletServices.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/cps/src/java/org/apache/jetspeed/cps/CommonPortletServices.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- CommonPortletServices.java	3 Feb 2004 22:21:00 -0000	1.4
  +++ CommonPortletServices.java	13 Feb 2004 03:48:27 -0000	1.5
  @@ -53,9 +53,12 @@
    */
   package org.apache.jetspeed.cps;
   
  +import java.util.Enumeration;
   import java.util.Hashtable;
   import java.util.Properties;
   import java.io.FileInputStream;
  +import java.io.IOException;
  +import java.net.URL;
   
   import javax.naming.Context;
   import javax.naming.InitialContext;
  @@ -230,5 +233,22 @@
       public boolean isInitialized()
       {
           return initialized;
  +    }
  +    
  +    /**
  +     * Load all CPS component descriptors from the class path
  +     * 
  +     * @throws IOException
  +     */
  +    public static void loadServiceDescriptors()
  +    throws IOException
  +    {
  +        ClassLoader cl = Thread.currentThread().getContextClassLoader() ;    
  +        Enumeration e = cl.getResources("META-INF/component.properties") ;
  +        while(e.hasMoreElements()) 
  +        {
  +            URL url = (URL)e.nextElement();                    
  +            System.out.println("url = " + url);
  +        }        
       }
   }
  
  
  
  1.2       +28 -10    jakarta-jetspeed-2/cps/src/java/org/apache/jetspeed/cps/template/TemplateLocatorComponentImpl.java
  
  Index: TemplateLocatorComponentImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/cps/src/java/org/apache/jetspeed/cps/template/TemplateLocatorComponentImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TemplateLocatorComponentImpl.java	11 Feb 2004 04:35:11 -0000	1.1
  +++ TemplateLocatorComponentImpl.java	13 Feb 2004 03:48:27 -0000	1.2
  @@ -61,8 +61,12 @@
   import java.util.StringTokenizer;
   
   import org.apache.commons.configuration.Configuration;
  +import org.apache.commons.configuration.PropertiesConfiguration;
  +
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
  +import org.apache.jetspeed.cps.CPSInitializationException;
  +import org.apache.jetspeed.cps.CommonPortletServices;
   
   /**
    * TemplateLocatorComponentImpl
  @@ -310,7 +314,7 @@
           {
               try
               {                
  -                // TODO: locatorClassName = getConfiguration().getString(TEMPLATE_LOCATOR_CLASS);
  +                locatorClassName = getConfiguration().getString(TEMPLATE_LOCATOR_CLASS);
                   locatorClass = Class.forName(locatorClassName);
               }
               catch(Exception e)
  @@ -331,20 +335,34 @@
           }
           return locator;    
       }
  -        
  +
  +/*        
       public TemplateLocatorComponentImpl()
       {  
           System.out.println("--- DEFAULT constructing template locator impl");      
       }
  -
  +*/
       public TemplateLocatorComponentImpl(Configuration configuration)
       {  
           System.out.println("--- CONFIGURATION constructing template locator impl");
  -        this.configuration = configuration;      
  +        this.configuration = configuration;
  +/*        
  +        try
  +        {
  +            init();
  +            System.out.println("-- TLC implemented ok");
  +        }
  +        catch (Throwable t)
  +        {      
  +            t.printStackTrace();
  +            log.error(t);
  +        }
  +*/        
       }
       
       
  -    Configuration configuration = null;
  +    private Configuration configuration = null;
  +    private boolean isInit = false;
       
       public Configuration getConfiguration()
       {
  @@ -353,10 +371,10 @@
       
       /* (non-Javadoc)
        * @see org.apache.fulcrum.Service#init()
  -     *
  +     */
       public void init() throws CPSInitializationException
       {
  -        if (isInitialized())
  +        if (isInit)
           {
               return;
           }
  @@ -396,9 +414,9 @@
               }
           }
           
  -        setInit(true);
  +        isInit = true;
       }
  -  */
  +
     
       /* (non-Javadoc)
        * @see org.apache.jetspeed.cps.template.TemplateLocatorService#query(org.apache.jetspeed.cps.template.TemplateLocator)
  
  
  
  1.2       +15 -4     jakarta-jetspeed-2/cps/src/test/org/apache/jetspeed/cps/TestPico.java
  
  Index: TestPico.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/cps/src/test/org/apache/jetspeed/cps/TestPico.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestPico.java	11 Feb 2004 04:35:11 -0000	1.1
  +++ TestPico.java	13 Feb 2004 03:48:27 -0000	1.2
  @@ -64,12 +64,15 @@
   import org.apache.jetspeed.cps.template.TemplateLocatorComponentImpl;
   import org.picocontainer.ComponentAdapter;
   import org.picocontainer.MutablePicoContainer;
  +import org.picocontainer.defaults.ConstantParameter;
   import org.picocontainer.defaults.DefaultPicoContainer;
   
   import junit.framework.Test;
   import junit.framework.TestCase;
   import junit.framework.TestSuite;
   
  +import org.picocontainer.Parameter;
  +
   /**
    * TestPico
    *
  @@ -115,10 +118,18 @@
           Configuration configuration = getConfiguration();
           
           MutablePicoContainer pico = new DefaultPicoContainer();
  -        // ConstructorComponentAdaptorFactory cca = new ConstructorComponentAdaptorFactory();
               
  -        pico.registerComponentImplementation(TemplateLocatorComponent.class, TemplateLocatorComponentImpl.class);
   
  -        // pico.addParameterToComponent(TemplateLocatorComponent.class, Configuration.class,
configuration);    
  +        // pico.registerComponentImplementation(TemplateLocatorComponent.class, TemplateLocatorComponentImpl.class);
  +            
  +        Parameter [] parameters =  {new ConstantParameter(configuration)};
  +                
  +        System.out.println("parameters: " + parameters.length);
  +        
  +        pico.registerComponentImplementation(
  +            TemplateLocatorComponent.class,
  +            TemplateLocatorComponentImpl.class,
  +            parameters);
  +            
           pico.start();
           
           TemplateLocatorComponent locator1 = (TemplateLocatorComponent)pico.getComponentInstance(TemplateLocatorComponent.class);
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org


Mime
View raw message