taylor      2004/10/29 17:15:37

  Modified:    components/profiler/src/java/org/apache/jetspeed/profiler/impl
                        JetspeedProfiler.java
               components/profiler project.xml
               components/profiler/src/test/org/apache/jetspeed/profiler
                        TestProfiler.java
  Added:       components/profiler/src/java/org/apache/jetspeed/profiler/impl
                        JetspeedProfilerImpl.java
               components/profiler/src/java/META-INF test-spring.xml
                        profiler-ojb.xml
  Removed:     components/profiler/src/java/META-INF ojb_repository.xml
  Log:
  conversion of Profiler to interception-based declarative tx via Spring DAO
  
  Revision  Changes    Path
  1.15      +2 -1      
jakarta-jetspeed-2/components/profiler/src/java/org/apache/jetspeed/profiler/impl/JetspeedProfiler.java
  
  Index: JetspeedProfiler.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed-2/components/profiler/src/java/org/apache/jetspeed/profiler/impl/JetspeedProfiler.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- JetspeedProfiler.java     26 Oct 2004 19:02:30 -0000      1.14
  +++ JetspeedProfiler.java     30 Oct 2004 00:15:36 -0000      1.15
  @@ -45,6 +45,7 @@
   /**
    * JetspeedProfiler
    * 
  + * @deprecated: instead @see JetspeedProfilerImpl
    * @author <a href="mailto:[EMAIL PROTECTED]">David Sean Taylor </a>
    * @version $Id$
    */
  
  
  
  1.1                  
jakarta-jetspeed-2/components/profiler/src/java/org/apache/jetspeed/profiler/impl/JetspeedProfilerImpl.java
  
  Index: JetspeedProfilerImpl.java
  ===================================================================
  /*
   * Copyright 2000-2004 The Apache Software Foundation.
   * 
   * Licensed 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.
   */
  package org.apache.jetspeed.profiler.impl;
  
  import java.security.Principal;
  import java.util.Collection;
  import java.util.HashMap;
  import java.util.Iterator;
  import java.util.Map;
  import java.util.Properties;
  
  import javax.security.auth.Subject;
  
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  import org.apache.jetspeed.components.dao.InitablePersistenceBrokerDaoSupport;
  import org.apache.jetspeed.profiler.ProfileLocator;
  import org.apache.jetspeed.profiler.ProfiledPageContext;
  import org.apache.jetspeed.profiler.Profiler;
  import org.apache.jetspeed.profiler.ProfilerException;
  import org.apache.jetspeed.profiler.rules.PrincipalRule;
  import org.apache.jetspeed.profiler.rules.ProfilingRule;
  import org.apache.jetspeed.profiler.rules.impl.AbstractProfilingRule;
  import org.apache.jetspeed.profiler.rules.impl.PrincipalRuleImpl;
  import org.apache.jetspeed.request.RequestContext;
  import org.apache.jetspeed.security.SecurityHelper;
  import org.apache.jetspeed.security.UserPrincipal;
  import org.apache.ojb.broker.query.Criteria;
  import org.apache.ojb.broker.query.QueryFactory;
  
  
  /**
   * JetspeedTransactionalProfiler
   * 
   * @author <a href="mailto:[EMAIL PROTECTED]">David Sean Taylor</a>
   * @version $Id: JetspeedProfilerImpl.java,v 1.1 2004/10/30 00:15:36 taylor Exp $
   */
  public class JetspeedProfilerImpl extends
          InitablePersistenceBrokerDaoSupport implements Profiler
  {
      /** Commons logging */
      protected final static Log log = LogFactory.getLog(JetspeedProfilerImpl.class);
  
      /** The default locator class implementation */
      private Class locatorClass = JetspeedProfileLocator.class;
      /** The default profiled page context class implementation */
      private Class profiledPageContextClass = JetspeedProfiledPageContext.class;
      /** The default principalRule association class implementation */
      private Class principalRuleClass = PrincipalRuleImpl.class;
      /** The base (abstract) profilingRule class implementation */
      private Class profilingRuleClass = AbstractProfilingRule.class;
  
      /** The configured default rule for this portal */
      private String defaultRule = "j1";
  
      private String anonymousUser = "guest";
  
      private Map principalRules = new HashMap();
      
      public JetspeedProfilerImpl(String repositoryPath)
      {
          super(repositoryPath);
      }
  
      /**
       * Create a JetspeedProfiler with properties. Expected properties are:
       * 
       * defaultRule = the default profiling rule anonymousUser = the name of the
       * anonymous user storeName = The name of the persistence store component to
       * connect to services.profiler.locator.impl = the pluggable Profile Locator
       * impl services.profiler.principalRule.impl = the pluggable Principal Rule
       * impl services.profiler.profilingRule.impl = the pluggable Profiling Rule
       * impl
       * 
       * @param properties
       *            Properties for this component described above
       * @throws ClassNotFoundException
       *             if any the implementation classes defined within the
       *             <code>properties</code> argument could not be found.
       */    
      public JetspeedProfilerImpl(String repositoryPath, Properties properties)
      throws ClassNotFoundException    
      {
          this(repositoryPath);
          this.defaultRule = properties.getProperty("defaultRule", "j1");
          this.anonymousUser = properties.getProperty("anonymousUser", "guest");
          initModelClasses(properties); // TODO: move this to start()        
      }
      
      private void initModelClasses( Properties properties ) throws 
ClassNotFoundException
      {
          String modelName = "";
  
          if ((modelName = properties.getProperty("locator.impl")) != null)
          {
              locatorClass = Class.forName(modelName);
          }
          if ((modelName = properties.getProperty("profiledPageContext.impl")) != null)
          {
              profiledPageContextClass = Class.forName(modelName);
          }
          if ((modelName = properties.getProperty("principalRule.impl")) != null)
          {
              principalRuleClass = Class.forName(modelName);
          }
          if ((modelName = properties.getProperty("profilingRule.impl")) != null)
          {
              profilingRuleClass = Class.forName(modelName);
          }
      }
      
      public ProfileLocator getProfile(RequestContext context, String locatorName) 
      throws ProfilerException
      {
          // get the principal representing the currently logged on user
          Subject subject = context.getSubject();
          if (subject == null)
          {
              String msg = "Invalid (null) Subject in request pipeline";
              log.error(msg);
              throw new ProfilerException(msg);
          }
          // get the UserPrincipal, finding the first UserPrincipal, or
          // find the first principal if no UserPrincipal isn't available
          Principal principal = SecurityHelper.getBestPrincipal(subject, 
UserPrincipal.class);
          if (principal == null)
          {
              String msg = "Could not find a principle for subject in request 
pipeline";
              log.error(msg);
              throw new ProfilerException(msg);
          }
  
          // find a profiling rule for this principal
          ProfilingRule rule = getRuleForPrincipal(principal, locatorName);
          if (null == rule)
          {
              log.warn("Could not find profiling rule for principal: " + principal);
              rule = this.getDefaultRule();
          }
  
          if (null == rule)
          {
              String msg = "Couldn't find any profiling rules including default rule 
for principal " + principal;
              log.error(msg);
              throw new ProfilerException(msg);
          }
          // create a profile locator for given rule
          return rule.apply(context, this);
      }
  
      /* (non-Javadoc)
       * @see 
org.apache.jetspeed.profiler.Profiler#getProfile(org.apache.jetspeed.request.RequestContext,
 org.apache.jetspeed.profiler.rules.ProfilingRule)
       */
      public ProfileLocator getProfile(RequestContext context, ProfilingRule rule)
              throws ProfilerException
      {
          // create a profile locator for given rule
          return rule.apply(context, this);
      }
  
      /* (non-Javadoc)
       * @see 
org.apache.jetspeed.profiler.Profiler#createLocator(org.apache.jetspeed.request.RequestContext)
       */
      public ProfileLocator createLocator(RequestContext context)
      {
          try
          {
              ProfileLocator locator = (ProfileLocator) locatorClass.newInstance();
              locator.init(this, context.getPath());
              return locator;
          }
          catch (Exception e)
          {
              log.error("Failed to create locator for " + locatorClass);
          }
          return null;
      }
  
      /* (non-Javadoc)
       * @see 
org.apache.jetspeed.profiler.Profiler#createProfiledPageContext(java.util.Map)
       */
      public ProfiledPageContext createProfiledPageContext(Map locators)
      {
          try
          {
              ProfiledPageContext pageContext = (ProfiledPageContext) 
profiledPageContextClass.newInstance();
              pageContext.init(this, locators);
              return pageContext;
          }
          catch (Exception e)
          {
              log.error("Failed to create profiled page context for " + 
profiledPageContextClass);
          }
          return null;
      }
  
      /* (non-Javadoc)
       * @see 
org.apache.jetspeed.profiler.Profiler#getRuleForPrincipal(java.security.Principal, 
java.lang.String)
       */
      public ProfilingRule getRuleForPrincipal(Principal principal,
              String locatorName)
      {
          // lookup the rule for the given principal in our user/rule table
          PrincipalRule pr = lookupPrincipalRule(principal.getName(), locatorName);
  
          // if not found, fallback to the system wide rule
          if (pr == null)
          {
              return getDefaultRule();
          }
  
          // Now get the associated rule
          return pr.getProfilingRule();
      }
  
      /* (non-Javadoc)
       * @see 
org.apache.jetspeed.profiler.Profiler#setRuleForPrincipal(java.security.Principal, 
org.apache.jetspeed.profiler.rules.ProfilingRule, java.lang.String)
       */
      public void setRuleForPrincipal(Principal principal, 
                                      ProfilingRule rule,
                                      String locatorName)
      {
          Criteria c = new Criteria();
          c.addEqualTo("principalName", principal);
          c.addEqualTo("locatorName", locatorName);
  
          PrincipalRule pr = (PrincipalRule)  
                  getPersistenceBrokerTemplate().getObjectByQuery(
                  QueryFactory.newQuery(principalRuleClass, c));
                  
          if (pr == null)
          {
              pr = new PrincipalRuleImpl(); // TODO: factory
              pr.setPrincipalName(principal.getName());
              pr.setLocatorName(locatorName);
              pr.setProfilingRule(rule);
          }
          pr.setProfilingRule(rule);
          getPersistenceBrokerTemplate().store(pr);
          principalRules.put(makePrincipalRuleKey(principal.getName(), locatorName), 
pr);
      }
      
      private String makePrincipalRuleKey(String principal, String locator)
      {
          return principal + ":" + locator;
      }
      
      /**
       * Helper function to lookup principal rule associations by principal
       * 
       * @param principal
       *            The string representation of the principal name.
       * @return The found PrincipalRule associated with the principal key or null
       *         if not found.
       */
      private PrincipalRule lookupPrincipalRule(String principal, String locatorName)
      {
          PrincipalRule pr = (PrincipalRule) 
principalRules.get(makePrincipalRuleKey(principal, locatorName));
          if (pr != null)
          {
              return pr;
          }
          Criteria c = new Criteria();
          c.addEqualTo("principalName", principal);
          c.addEqualTo("locatorName", locatorName);
  
          pr = (PrincipalRule)  
                  getPersistenceBrokerTemplate().getObjectByQuery(
                  QueryFactory.newQuery(principalRuleClass, c));
          
          principalRules.put(makePrincipalRuleKey(principal, locatorName), pr);
          return pr;
      }
      
      /* (non-Javadoc)
       * @see org.apache.jetspeed.profiler.Profiler#getDefaultRule()
       */
      public ProfilingRule getDefaultRule()
      {
          return getRule(this.defaultRule);
      }
  
      /* (non-Javadoc)
       * @see org.apache.jetspeed.profiler.Profiler#getRules()
       */
      public Collection getRules()
      {
          return getPersistenceBrokerTemplate().getCollectionByQuery(
                  QueryFactory.newQuery(profilingRuleClass, new Criteria()));
      }
  
      /* (non-Javadoc)
       * @see org.apache.jetspeed.profiler.Profiler#getRule(java.lang.String)
       */
      public ProfilingRule getRule(String id)
      {
          // TODO: implement caching
          Criteria c = new Criteria();
          c.addEqualTo("id", id);
  
          return (ProfilingRule)  
                  getPersistenceBrokerTemplate().getObjectByQuery(
                  QueryFactory.newQuery(profilingRuleClass, c));
      }
  
      /* (non-Javadoc)
       * @see org.apache.jetspeed.profiler.Profiler#getAnonymousUser()
       */
      public String getAnonymousUser()
      {
          return this.anonymousUser;
      }
  
      /* (non-Javadoc)
       * @see 
org.apache.jetspeed.profiler.Profiler#getLocatorNamesForPrincipal(java.security.Principal)
       */
      public String[] getLocatorNamesForPrincipal(Principal principal)
      {
          Criteria c = new Criteria();
          c.addEqualTo("principalName", principal.getName());
          
          Collection result = getPersistenceBrokerTemplate().getCollectionByQuery(
                  QueryFactory.newQuery(principalRuleClass, c));        
          if (result.size() == 0)
          {
              return new String[]{};
          }
          String [] names = new String[result.size()];
          Iterator it = result.iterator();
          int ix = 0;
          while (it.hasNext())
          {
              PrincipalRule pr = (PrincipalRule)it.next();
              names[ix] = pr.getLocatorName();
              ix++;
          }
          return names;
      }
  
      /* (non-Javadoc)
       * @see 
org.apache.jetspeed.profiler.Profiler#getRulesForPrincipal(java.security.Principal)
       */
      public Collection getRulesForPrincipal(Principal principal)
      {
          Criteria c = new Criteria();
          c.addEqualTo("principalName", principal.getName());
          return getPersistenceBrokerTemplate().getCollectionByQuery(
                  QueryFactory.newQuery(principalRuleClass, c));        
      }
  
      /* (non-Javadoc)
       * @see 
org.apache.jetspeed.profiler.Profiler#getProfileLocators(org.apache.jetspeed.request.RequestContext,
 java.security.Principal)
       */
      public Map getProfileLocators(RequestContext context, Principal principal)
              throws ProfilerException
      {
          Map locators = new HashMap();
          Iterator it = getRulesForPrincipal(principal).iterator();
          while (it.hasNext())
          {
              PrincipalRule pr = (PrincipalRule)it.next();
              locators.put(pr.getLocatorName(), getProfile(context, 
pr.getLocatorName()));   
          }
          return locators;
      }
  
      /* (non-Javadoc)
       * @see 
org.apache.jetspeed.profiler.Profiler#storeProfilingRule(org.apache.jetspeed.profiler.rules.ProfilingRule)
       */
      public void storeProfilingRule(ProfilingRule rule) throws ProfilerException
      {
          getPersistenceBrokerTemplate().store(rule);
      }
  
      /* (non-Javadoc)
       * @see 
org.apache.jetspeed.profiler.Profiler#deleteProfilingRule(org.apache.jetspeed.profiler.rules.ProfilingRule)
       */
      public void deleteProfilingRule(ProfilingRule rule)
              throws ProfilerException
      {
          getPersistenceBrokerTemplate().delete(rule);
      }
  
      /* (non-Javadoc)
       * @see 
org.apache.jetspeed.profiler.Profiler#storePrincipalRule(org.apache.jetspeed.profiler.rules.PrincipalRule)
       */
      public void storePrincipalRule(PrincipalRule rule) throws ProfilerException
      {
          getPersistenceBrokerTemplate().store(rule);
      }
  
      /* (non-Javadoc)
       * @see 
org.apache.jetspeed.profiler.Profiler#deletePrincipalRule(org.apache.jetspeed.profiler.rules.PrincipalRule)
       */
      public void deletePrincipalRule(PrincipalRule rule)
              throws ProfilerException
      {
          getPersistenceBrokerTemplate().delete(rule);
      }
  
  }
  
  
  
  1.5       +8 -0      jakarta-jetspeed-2/components/profiler/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/components/profiler/project.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- project.xml       13 Oct 2004 20:01:46 -0000      1.4
  +++ project.xml       30 Oct 2004 00:15:36 -0000      1.5
  @@ -41,6 +41,14 @@
        
        &db-ojb-deps;
        
  +     <dependency>
  +      <id>jetspeed-cm</id>
  +      <groupId>jetspeed2</groupId>
  +      <version>2.0-a1-dev</version>
  +      <properties>
  +        <war.bundle>true</war.bundle>
  +      </properties>
  +    </dependency>    
        <dependency>
         <id>jetspeed2:jetspeed-commons</id>
         <version>2.0-a1-dev</version>
  
  
  
  1.1                  
jakarta-jetspeed-2/components/profiler/src/java/META-INF/test-spring.xml
  
  Index: test-spring.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" 
"http://www.springframework.org/dtd/spring-beans.dtd";>
  
  <!--
    - Application context definition for PortletRegistry using Apache OJB.
        -->
  <beans>
    
        <!-- Transaction manager for a single OJB PersistenceBroker (alternative to 
JTA) -->
        <bean id="transactionManager" 
class="org.springframework.orm.ojb.PersistenceBrokerTransactionManager"/>
  
        <!-- Transaction manager that delegates to JTA (for a transactional JNDI 
DataSource) -->
        <!--
        <bean id="transactionManager" 
class="org.springframework.transaction.jta.JtaTransactionManager"/>
        -->
  
  
  
        <!--
                - A parent bean definition which is a base definition for transaction 
proxies.
                - It is markes as abstract, since it is never supposed to be 
instantiated itself.
                - We set shared transaction attributes here, following our naming 
patterns.
                - The attributes can still be overridden in child bean definitions.
                -->
        <bean id="baseTransactionProxy" 
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"
                        abstract="true">
                <property name="transactionManager"><ref 
bean="transactionManager"/></property>
                <property name="transactionAttributes">
                        <props>
                                <prop key="*">PROPAGATION_REQUIRED</prop>
                        </props>
                </property>
        </bean>
        
    <!-- Profiler DAO-->
    <bean id="profilerImpl" 
class="org.apache.jetspeed.profiler.impl.JetspeedProfilerImpl" init-method="init">
        <constructor-arg>
                <value>META-INF/profiler-ojb.xml</value>
        </constructor-arg>
      </bean>
    
    <!-- Profiler -->  
    <bean id="org.apache.jetspeed.profiler.Profiler" 
          name="profiler"
          parent="baseTransactionProxy"        
    >      
                <property name="proxyInterfaces">
                        <value>org.apache.jetspeed.profiler.Profiler</value>
                </property>
                <property name="target">
                        <ref bean="profilerImpl"/>
                </property>
                <property name="transactionAttributes">
                        <props>                         
                                <prop 
key="setRuleForPrincipal">PROPAGATION_REQUIRED,-org.apache.jetspeed.components.profiler.ProfilerException</prop>
                                <prop 
key="store*">PROPAGATION_REQUIRED,-org.apache.jetspeed.components.profiler.ProfilerException</prop>
                                <prop 
key="delete*">PROPAGATION_REQUIRED,-org.apache.jetspeed.components.profiler.ProfilerException</prop>
                                <prop key="*">PROPAGATION_SUPPORTS</prop>
                        </props>
                </property>                        
    </bean>
        
  </beans>
  
  
  1.1                  
jakarta-jetspeed-2/components/profiler/src/java/META-INF/profiler-ojb.xml
  
  Index: profiler-ojb.xml
  ===================================================================
  <!--
  Copyright 2004 The Apache Software Foundation
  
  Licensed 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.
  -->
  <!--
     - P R O F I L I N G  R U L E
  -->   
   <descriptor-repository version="1.0">
     <class-descriptor 
class="org.apache.jetspeed.profiler.rules.impl.AbstractProfilingRule">
        <extent-class 
class-ref="org.apache.jetspeed.profiler.rules.impl.StandardProfilingRule" />
        <extent-class 
class-ref="org.apache.jetspeed.profiler.rules.impl.RoleFallbackProfilingRule" />
     </class-descriptor>
            
  <class-descriptor
      class="org.apache.jetspeed.profiler.rules.impl.StandardProfilingRule"
      table="PROFILING_RULE"
  >     
      <field-descriptor
       name="id"
       column="RULE_ID"
       jdbc-type="VARCHAR"
       primarykey="true"
       autoincrement="false"         
      />
      <field-descriptor
       name="ojbConcreteClass"
       column="CLASS_NAME"
       jdbc-type="VARCHAR"
      />
      <field-descriptor
       name="title"
       column="TITLE"
       jdbc-type="VARCHAR"
      />    
        <collection-descriptor
           name="criteria"
           
element-class-ref="org.apache.jetspeed.profiler.rules.impl.RuleCriterionImpl" 
           auto-delete="object"
           auto-update = "object"
           auto-retrieve = "true"
         >
         <inverse-foreignkey field-ref="ruleId"/>
        </collection-descriptor>
  
  
  </class-descriptor>
  
  <class-descriptor
      class="org.apache.jetspeed.profiler.rules.impl.RoleFallbackProfilingRule"
      table="PROFILING_RULE"
  >     
      <field-descriptor
       name="id"
       column="RULE_ID"
       jdbc-type="VARCHAR"
       primarykey="true"
       autoincrement="false"         
      />
      <field-descriptor
       name="ojbConcreteClass"
       column="CLASS_NAME"
       jdbc-type="VARCHAR"
      />
      <field-descriptor
       name="title"
       column="TITLE"
       jdbc-type="VARCHAR"
      />    
      <collection-descriptor
           name="criteria"
           
element-class-ref="org.apache.jetspeed.profiler.rules.impl.RuleCriterionImpl" 
           auto-retrieve="true"
      >
      <inverse-foreignkey field-ref="ruleId"/>
      </collection-descriptor>
  </class-descriptor>
  
  <!--
     - R U L E  C R I T E R I O N
  -->   
  
  <class-descriptor
      class="org.apache.jetspeed.profiler.rules.impl.RuleCriterionImpl"
      table="RULE_CRITERION"
  >     
      <field-descriptor
       name="id"
       column="CRITERION_ID"
       jdbc-type="VARCHAR"
       primarykey="true"
       autoincrement="true"         
      />
      <field-descriptor
       name="ruleId"
       column="RULE_ID"
       jdbc-type="VARCHAR"
      />
      <field-descriptor
       name="fallbackOrder"
       column="FALLBACK_ORDER"
       jdbc-type="INTEGER"
      />    
      <field-descriptor
       name="type"
       column="REQUEST_TYPE"
       jdbc-type="VARCHAR"
      />    
      <field-descriptor
       name="name"
       column="NAME"
       jdbc-type="VARCHAR"
      />    
      <field-descriptor
       name="value"
       column="VALUE"
       jdbc-type="VARCHAR"
      />    
      <field-descriptor 
          name="fallbackType" 
          jdbc-type="INTEGER"
          column="FALLBACK_TYPE" 
      />
  
  </class-descriptor>
  
  <!--
     - P R I N C I P A L  R U L E
  -->   
  
  <class-descriptor
      class="org.apache.jetspeed.profiler.rules.impl.PrincipalRuleImpl"
      table="PRINCIPAL_RULE_ASSOC"
  >     
      <field-descriptor
       name="principalName"
       column="PRINCIPAL_NAME"
       jdbc-type="VARCHAR"
       primarykey="true"
       autoincrement="false"           
      />
      <field-descriptor
       name="locatorName"
       column="LOCATOR_NAME"
       jdbc-type="VARCHAR"
       primarykey="true"
       autoincrement="false"           
      />    
      <field-descriptor
       name="ruleId"
       column="RULE_ID"
       jdbc-type="VARCHAR"
      />
      <reference-descriptor 
        name="profilingRule" 
        class-ref="org.apache.jetspeed.profiler.rules.impl.AbstractProfilingRule" 
        auto-delete="false"  
        auto-retrieve="true"  
        >
       <foreignkey field-ref="ruleId"/>
      </reference-descriptor>
  
  </class-descriptor>
  
  </descriptor-repository>
  
     
        
        
    
  
  
  1.8       +13 -15    
jakarta-jetspeed-2/components/profiler/src/test/org/apache/jetspeed/profiler/TestProfiler.java
  
  Index: TestProfiler.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed-2/components/profiler/src/test/org/apache/jetspeed/profiler/TestProfiler.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- TestProfiler.java 20 Oct 2004 16:43:38 -0000      1.7
  +++ TestProfiler.java 30 Oct 2004 00:15:37 -0000      1.8
  @@ -25,8 +25,10 @@
   import junit.framework.TestSuite;
   
   import 
org.apache.jetspeed.components.persistence.store.util.PersistenceSupportedTestCase;
  +import org.apache.jetspeed.components.portletentity.PortletEntityAccessComponent;
  +import org.apache.jetspeed.components.util.DatasourceEnabledSpringTestCase;
   import org.apache.jetspeed.mockobjects.request.MockRequestContext;
  -import org.apache.jetspeed.profiler.impl.JetspeedProfiler;
  +import org.apache.jetspeed.profiler.impl.JetspeedProfilerImpl;
   import org.apache.jetspeed.profiler.rules.ProfilingRule;
   import org.apache.jetspeed.profiler.rules.RuleCriterion;
   import org.apache.jetspeed.profiler.rules.impl.RoleFallbackProfilingRule;
  @@ -41,9 +43,9 @@
    * @author <a href="mailto:[EMAIL PROTECTED]">David Sean Taylor</a>
    * @version $Id$
    */
  -public class TestProfiler extends PersistenceSupportedTestCase
  +public class TestProfiler extends DatasourceEnabledSpringTestCase
   {
  -    private JetspeedProfiler profiler = null;
  +    private Profiler profiler = null;
       protected static final Properties TEST_PROPS = new Properties();
       
       static
  @@ -62,15 +64,6 @@
       {
         super.tearDown();
       }
  -    /**
  -     * Defines the testcase name for JUnit.
  -     *
  -     * @param name the testcase's name.
  -     */
  -    public TestProfiler(String name)
  -    {
  -        super(name);
  -    }
   
       /**
        * Start the tests.
  @@ -85,8 +78,7 @@
       protected void setUp() throws Exception
       {
           super.setUp();
  -        
  -        profiler = new JetspeedProfiler(persistenceStore, TEST_PROPS);
  +        this.profiler = (Profiler) ctx.getBean("profiler");
       }
   
       public static Test suite()
  @@ -399,4 +391,10 @@
           
           System.out.println("Maintenance tests completed.");
       }
  +
  +    protected String[] getConfigurations()
  +    {
  +        return new String[] {"/META-INF/test-spring.xml"};
  +    }
  +    
   }
  
  
  

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

Reply via email to