Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0

...

Legacy case: don't wire it

Code Block
xmlxml
titleGet the legacy behavior by not wiring
xml
<!-- 
 | no change to applicationContext.xml or to portal.properties 
 | or to any other configuration file is required to get the behavior of uPortal 2.5.0 
 +-->

...

In uPortal 2.6.0, as implemented in the current uPortal 2 HEAD, the legacy behavior goes away and failing to declare an IStatsRecorder instance via Spring configuration will result in no stats recording.

Doing nothing

xml
Code Block
xml
titleDeclaring a do-nothing stats recorder
xml
<bean name="statsRecorder"
      class="org.jasig.portal.services.stats.DoNothingStatsRecorder"/>

...

A logging example

xml
Code Block
xml
titleLogging some IStatsRecorder events
xml

<!--
 | The parent bean is the Conditional wrapper because first we want to filter down to
 | the events we're actually going to log.
 +-->
<bean name="statsRecorder"
    class="org.jasig.portal.services.stats.ConditionalStatsRecorder">
    <property name="flags">
        <!--
         | This JavaBean lets us configure which events we'd like the Conditional 
         | wrapper to propogate.  The flags default to false so we need only declared those
         | methods we would like to propogate.
         +-->
        <bean class="org.jasig.portal.services.stats.StatsRecorderFlagsImpl">
            <property name="recordChannelRendered" value="true"/>
        </bean>
    </property>

    <!-- 
     | The Conditional stats recorder will call this target when its condition is fulfilled, that is
     | when the method call is recordChannelRendered().  IStatsRecorder calls other than 
     | recordChannelRendered will have no effect, that is, are filtered away 
     | by the Conditional stats recorder. 
     +-->
    <property name="targetStatsRecorder">
        <!-- 
         | The target of the Conditional is the thread firing wrapper so that we'll use separate
         | threads to perform the actual logging. 
         +-->
        <bean class="org.jasig.portal.services.stats.ThreadFiringStatsRecorder">
            <!-- initial thread pool size -->
            <constructor-arg value="5"/>
            <!-- maximum thread pool size -->
            <constructor-arg value="15"/>
            <!-- thread priority -->
            <constructor-arg value="5"/>

            <!--
             | The target of the threads we fire is this LoggingStatsRecorder instance.
             +-->
            <property name="targetStatsRecorder">
                <bean class="org.jasig.portal.services.stats.LoggingStatsRecorder"/>
            </property>

        </bean>
    </property>
</bean>

...

Wiring in your custom stats recorder

Code Block
xmlxml
titleDeclaring your own stats recorder
xml
<bean name="statsRecorder"
      class="edu.yale.its.portal.services.stats.YaleStatsRecorder"/>

Multiple stats recorders

Code Block
xmlxml
titleAn ambitious example involving multiple stats recorders
xml

<!--
 | The parent bean is the Conditional wrapper because first we want to filter down to
 | the events we're actually going to use.
 +-->
<bean name="statsRecorder"
    class="org.jasig.portal.services.stats.ConditionalStatsRecorder">
    <property name="flags">
        <!--
         | This JavaBean lets us configure which events we'd like the Conditional 
         | wrapper to propogate.  The flags default to false so we need only declared those
         | methods we would like to propogate.
         +-->
        <bean class="org.jasig.portal.services.stats.StatsRecorderFlagsImpl">
            <property name="recordChannelRendered" value="true"/>
            <property name="recordFolderAddedToLayout" value="true"/>
        </bean>
    </property>

    <!-- 
     | The Conditional stats recorder will call this target when its condition is fulfilled, that is
     | when the method call is recordChannelRendered().  IStatsRecorder calls other than 
     | recordChannelRendered will have no effect, that is, are filtered away 
     | by the Conditional stats recorder. 
     +-->
    <property name="targetStatsRecorder">
        <!-- 
         | Here we're firing new threads.  If we're going to use a large list of stats recorders,
         | recording stats could take awhile so we want this to be undertaken in threads from the
         | pool for this purpose rather than engaging core channel rendering, session management, or
         | Servlet Container threads in this project.  We need to let go of the current thread to let it
         | get back to the work of rendering the response to the user.
         +-->
        <bean class="org.jasig.portal.services.stats.ThreadFiringStatsRecorder">
            <!-- initial thread pool size -->
            <constructor-arg value="5"/>
            <!-- maximum thread pool size -->
            <constructor-arg value="15"/>
            <!-- thread priority -->
            <constructor-arg value="5"/>

            <!--
             | The target of the threads we fire is the List recorder implementation, which
             | will delegate to our configured list of stats recorders.
             +-->
            <property name="targetStatsRecorder">
                <bean class="org.jasig.portal.services.stats.ListStatsRecorder">
                   <property name="children">
                       <list>
                           <!-- here we declare the IStatsRecorders we'd like to run. -->
                           <bean class="org.jasig.portal.services.stats.LoggingStatsRecorder"/>
                           <bean class="org.jasig.portal.services.stats.PrintingStatsRecorder"/>
                           <!-- 
                            | for example, you might use some of the included recorders 
                            | as well as a custom recorder implementation
                            +-->
                           <bean class="edu.someschool.DatabaseStatsRecorder">
                               <!--
                                | If your stats recorder needs a DataSource, you can inject it.
                                +--> 
                               <property name="dataSource">
                                   <bean 
                                       class="org.springframework.jndi.JndiObjectFactoryBean">
		                       <property 
                                           name="jndiName" 
                                           value="java:comp/env/jdbc/myDatasource" />
	                           </bean>
                              </property>
                           </bean>
                       </list>
                   </property>
                </bean>
            </property>

        </bean>
    </property>
</bean>

...