Fork me on GitHub

n. Slang a rough lawless young Kuali developer.
[perhaps variant of Houlihan, Irish surname]
kualiganism n

Blog of an rSmart Java Developer. Full of code examples, solutions, best practices, et al.

Monday, February 13, 2012

Adding Java Melody to a Kuali Project

Overview


Steps for KFS

1 Setup Dependencies

  1. Download the latest javamelody.jar from http://code.google.com/p/javamelody/downloads/list
  2. Add the jar to build/kfs-lib/

2 Setup Filters and SessionListener

  1. If you have not already, create a file in build/properties called <your institution>-configuration.properties and a <your institution>-build.properties
  2. Add the following to the <your institution>-configuration.properties
    monitoring.listener=${monitoring.license}
    monitoring.filter=${monitoring.filter}
    monitoring.mapping=${monitoring.mapping}
  3. Add the following to the <your institution>-build.properties
    monitoring.filter=monitoring \
        net.bull.javamelody.MonitoringFilter \
         \
            log\
            true\
         \
         \
                 system-actions-enabled\
                 true\
         \
         \
                  url-exclude-pattern\
                  /static/.*|/kr/static/.*|/kr/images/.*|/images-portal/.*\
         \
     \
            
    monitoring.mapping= \
              <![CDATA[ \
     \
        monitoring \
        /* \
     \
              ]]> \
            
    monitoring.listener=         \
              <![CDATA[ \
     \
        net.bull.javamelody.SessionListener \
     \
              ]]> \
            
    
  4. You need to add the following to your web.xml:
    <!-- Change this if you want to use a different Spring file -->
      <context-param>
        <param-name>web.bootstrap.spring.file</param-name>
        <param-value>${bootstrap.spring.file}</param-value>
      </context-param>
    
      ${monitoring.filter}
    
  5. You need to add the following to your web.xml:
    <filter>
        <filter-name>UserPreferencesFilter</filter-name>
        <filter-class>org.kuali.rice.kew.web.UserPreferencesFilter</filter-class>
      </filter>
    
      ${monitoring.mapping}
  6. You need to add the following to your web.xml:
    ${monitoring.listener}
    
      <listener>
        <listener-class>org.kuali.rice.krad.web.session.NonSerializableSessionListener</listener-class>
      </listener>
  7. If you haven't already, set the following in your *kfs-build.properties*
    institution.build.properties.file=build/properties/<your institution>-build.properties
    institution.configuration.properties.file=build/properties/<your institution>-configuration.properties

3 Setup Spring Configuration

  1. Add the following to work/src/spring-kfs-rice-overrides.xml
    <import resource="classpath:net/bull/javamelody/monitoring-spring.xml" />
              <bean id="facadeMonitoringAdvisor" class="net.bull.javamelody.MonitoringSpringAdvisor">
                  <property name="pointcut">
                      <bean class="org.springframework.aop.support.JdkRegexpMethodPointcut">
                          <property name="pattern" value=".*(krad|krms|location|edl|kim|kcb|ken|kew|kns|ksb).*ServiceImp.*" />
                      </bean>
                  </property>
              </bean>
    

4 Prepare for Deployment

    Steps for Rice

    1 Setup Dependencies

    Add the following to the web/pom.xml
    <properties>
        <monitoring.filter />
        <monitoring.mapping />
        <monitoring.listener />
      </properties>
    ...
    ...
      <profiles>
        <profile>
          <id>monitoring</id>
          <properties>
            <monitoring.filter>
              <![CDATA[
    <filter>
        <filter-name>monitoring</filter-name>
        <filter-class>net.bull.javamelody.MonitoringFilter</filter-class>
        <init-param>
            <param-name>log</param-name><param-value>true</param-value></init-param>
        <init-param>
                 <param-name>system-actions-enabled</param-name><param-value>true</param-value></init-param>
        <init-param>
                  <param-name>url-exclude-pattern</param-name><param-value>/static/.*|/kr/static/.*|/kr/images/.*|/images-portal/.*</param-value></init-param>
    </filter>
              ]]>
            </monitoring.filter>
            <monitoring.mapping>
              <![CDATA[
    <filter-mapping>
        <filter-name>monitoring</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
              ]]>
            </monitoring.mapping>
            <monitoring.listener>
              <![CDATA[
    <listener>
        <listener-class>net.bull.javamelody.SessionListener</listener-class>
    </listener>
              ]]>
            </monitoring.listener>
          </properties>
          <build>
          </build>
          <dependencies>
            <!-- javamelody-core -->
            <dependency>
              <groupid>net.bull.javamelody</groupId>
              <artifactid>javamelody-core</artifactId>
              <version>1.31.0</version>
            </dependency>
    ...
    ...
          </dependencies>
        </profiles>
    

    2 Setup Filters and SessionListener

    1. You need to add the following to your web.xml:
      <!-- Change this if you want to use a different Spring file -->
        <context-param>
          <param-name>web.bootstrap.spring.file</param-name>
          <param-value>${bootstrap.spring.file}</param-value>
        </context-param>
      
        ${monitoring.filter}
      
    2. You need to add the following to your web.xml:
      <filter>
          <filter-name>UserPreferencesFilter</filter-name>
          <filter-class>org.kuali.rice.kew.web.UserPreferencesFilter</filter-class>
        </filter>
      
        ${monitoring.mapping}
    3. You need to add the following to your web.xml:
      ${monitoring.listener}
      
        <listener>
          <listener-class>org.kuali.rice.krad.web.session.NonSerializableSessionListener</listener-class>
        </listener>
    4. If you haven't already, set the following in your *kfs-build.properties*
      institution.build.properties.file=build/properties/<your institution>-build.properties
      institution.configuration.properties.file=build/properties/<your institution>-configuration.properties

    3 Setup Spring Configuration

    Add the following to core/impl/src/main/resources/org/kuali/rice/core/CommonSpringBeans.xml:
    
    
      ${monitoring.spring.service}

    4 Prepare for Deployment

    Now you just use:
    mvn -Pmonitoring clean install
    The above will build your distribution of rice with javamelody turned on.

    The Results

    You should see something like this

    No comments:

    Post a Comment