Coverage report

  %line %branch
org.apache.jetspeed.profiler.rules.impl.AbstractProfilingRule
0% 
0% 

 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 3  
  * contributor license agreements.  See the NOTICE file distributed with
 4  
  * this work for additional information regarding copyright ownership.
 5  
  * The ASF licenses this file to You under the Apache License, Version 2.0
 6  
  * (the "License"); you may not use this file except in compliance with
 7  
  * the License.  You may obtain a copy of the License at
 8  
  * 
 9  
  *      http://www.apache.org/licenses/LICENSE-2.0
 10  
  * 
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 package org.apache.jetspeed.profiler.rules.impl;
 18  
 
 19  
 import java.util.Collection;
 20  
 import java.util.Collections;
 21  
 import java.util.HashMap;
 22  
 import java.util.Map;
 23  
 import org.apache.jetspeed.profiler.ProfileLocator;
 24  
 import org.apache.jetspeed.profiler.Profiler;
 25  
 import org.apache.jetspeed.profiler.rules.ProfileResolvers;
 26  
 import org.apache.jetspeed.profiler.rules.ProfilingRule;
 27  
 import org.apache.jetspeed.profiler.rules.RuleCriterionResolver;
 28  
 import org.apache.jetspeed.request.RequestContext;
 29  
 import org.apache.ojb.broker.util.collections.RemovalAwareCollection;
 30  
 
 31  
 /**
 32  
  * ProfilingRuleImpl
 33  
  *
 34  
  * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
 35  
  * @version $Id: AbstractProfilingRule.java 605772 2007-12-20 01:14:31Z taylor $
 36  
  */
 37  
 public abstract class AbstractProfilingRule implements ProfilingRule
 38  
 {
 39  
     private static final long serialVersionUID = 1;    
 40  0
     protected Collection criteria = new RemovalAwareCollection();
 41  
     protected String id;
 42  
     protected String title;
 43  
     protected String ojbConcreteClass;
 44  
     
 45  
     /** Map of profile locators kept around for reuse TODO: evict entries after max size reached */    
 46  0
     protected Map locators = Collections.synchronizedMap(new HashMap());
 47  
     
 48  
     /** Map of resolver rules for criteria. The map goes from criterion name to resolver class */
 49  
     protected ProfileResolvers resolvers;
 50  
 
 51  
     public AbstractProfilingRule()
 52  0
     {        
 53  0
     }
 54  
     
 55  
     public AbstractProfilingRule(ProfileResolvers resolvers) 
 56  0
     {
 57  0
         this.resolvers = resolvers;
 58  0
     }
 59  
     
 60  
      
 61  
     protected ProfileLocator getLocatorFromCache(String key)
 62  
     {
 63  0
         return (ProfileLocator)locators.get(key);
 64  
     }
 65  
     
 66  
     
 67  
     protected void addLocatorToCache(String key, ProfileLocator locator)
 68  
     {
 69  0
         locators.put(key, locator);
 70  0
     }
 71  
     
 72  
     /* (non-Javadoc)
 73  
      * @see org.apache.jetspeed.profiler.rules.ProfilingRule#getResolver(java.lang.String)
 74  
      */
 75  
     public RuleCriterionResolver getResolver(String name)
 76  
     {
 77  0
         return resolvers.get(name);
 78  
     }
 79  
 
 80  
     public RuleCriterionResolver getDefaultResolver()
 81  
     {
 82  0
         return resolvers.get(RuleCriterionResolver.REQUEST);
 83  
     }
 84  
     
 85  
     /* (non-Javadoc)
 86  
      * @see org.apache.jetspeed.profiler.rules.ProfilingRule#apply(org.apache.jetspeed.request.RequestContext, org.apache.jetspeed.profiler.Profiler)
 87  
      */
 88  
     public abstract ProfileLocator apply(RequestContext context, Profiler service);
 89  
     
 90  
     /* (non-Javadoc)
 91  
      * @see org.apache.jetspeed.profiler.rules.ProfilingRule#getRuleCriterion()
 92  
      */
 93  
     public Collection getRuleCriteria()
 94  
     {
 95  0
         return criteria;
 96  
     }
 97  
     
 98  
     /* (non-Javadoc)
 99  
      * @see org.apache.jetspeed.profiler.rules.ProfilingRule#getId()
 100  
      */
 101  
     public String getId()
 102  
     {
 103  0
         return this.id;    
 104  
     }
 105  
     
 106  
     /* (non-Javadoc)
 107  
      * @see org.apache.jetspeed.profiler.rules.ProfilingRule#setId(java.lang.String)
 108  
      */
 109  
     public void setId(String id)
 110  
     {
 111  0
         this.id = id;
 112  0
     }
 113  
         
 114  
     /* (non-Javadoc)
 115  
      * @see org.apache.jetspeed.profiler.rules.ProfilingRule#getTitle()
 116  
      */
 117  
     public String getTitle()
 118  
     {
 119  0
         return this.title;
 120  
     }
 121  
     
 122  
     /* (non-Javadoc)
 123  
      * @see org.apache.jetspeed.profiler.rules.ProfilingRule#setTitle(java.lang.String)
 124  
      */
 125  
     public void setTitle(String title)
 126  
     {
 127  0
         this.title = title;                        
 128  0
     }
 129  
 
 130  
     /* (non-Javadoc)
 131  
      * @see org.apache.jetspeed.profiler.rules.ProfilingRule#getClassname()
 132  
      */
 133  
     public String getClassname()
 134  
     {
 135  0
         return this.ojbConcreteClass;
 136  
     }
 137  
     
 138  
     /* (non-Javadoc)
 139  
      * @see org.apache.jetspeed.profiler.rules.ProfilingRule#setClassname(java.lang.String)
 140  
      */
 141  
     public void setClassname(String classname)
 142  
     {
 143  0
         this.ojbConcreteClass = classname;
 144  0
     }
 145  
     
 146  
     public String toString()
 147  
     {
 148  0
         if (id != null)
 149  
         {
 150  0
             return id;
 151  
         }
 152  0
         else if (title != null)
 153  
         {
 154  0
             return title;
 155  
         }
 156  0
         return this.getClass().toString();
 157  
     }
 158  
     
 159  
     /**
 160  
      * @return Returns the resolvers.
 161  
      */
 162  
     public ProfileResolvers getResolvers()
 163  
     {
 164  0
         return resolvers;
 165  
     }
 166  
     /**
 167  
      * @param resolvers The resolvers to set.
 168  
      */
 169  
     public void setResolvers(ProfileResolvers resolvers)
 170  
     {
 171  0
         this.resolvers = resolvers;
 172  0
     }
 173  
     
 174  
     
 175  
     
 176  
     
 177  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.