<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--

    Copyright (C) 2010 eXo Platform SAS.

    This is free software; you can redistribute it and/or modify it
    under the terms of the GNU Lesser General Public License as
    published by the Free Software Foundation; either version 2.1 of
    the License, or (at your option) any later version.

    This software is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this software; if not, write to the Free
    Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
    02110-1301 USA, or see the FSF site: http://www.fsf.org.

-->
<agent-configuration>
   <pointcuts>
      <!-- Collection information about JCR API calls -->
      <pointcut pointcut-class-name="org.exoplatform.instrument.transformer.MethodExecutionPoincut">
         <recipients>
            <!-- Session -->
            <recipient method-name="getRepository" class-name="org.exoplatform.services.jcr.impl.core.SessionImpl" />
            <recipient method-name="getAttribute" class-name="org.exoplatform.services.jcr.impl.core.SessionImpl" />
            <recipient method-name="getWorkspace" class-name="org.exoplatform.services.jcr.impl.core.SessionImpl" />
            <recipient method-name="getRootNode" class-name="org.exoplatform.services.jcr.impl.core.SessionImpl" />
            <recipient method-name="getItem" class-name="org.exoplatform.services.jcr.impl.core.SessionImpl" />
            <recipient method-name="getNodeByUUID" class-name="org.exoplatform.services.jcr.impl.core.SessionImpl" />
            <recipient method-name="logout" class-name="org.exoplatform.services.jcr.impl.core.SessionImpl" />
            <recipient method-name="save" class-name="org.exoplatform.services.jcr.impl.core.SessionImpl" />
            <recipient method-name="move" class-nCpuStatisticCollectorAdviceame="org.exoplatform.services.jcr.impl.core.SessionImpl" />
            <recipient method-name="importXML" class-name="org.exoplatform.services.jcr.impl.core.SessionImpl" />
            <recipient method-name="addLockToken" class-name="org.exoplatform.services.jcr.impl.core.SessionImpl" />
            <recipient method-name="getLockToken" class-name="org.exoplatform.services.jcr.impl.core.SessionImpl" />
            <recipient method-name="removeLockToken" class-name="org.exoplatform.services.jcr.impl.core.SessionImpl" />
            <recipient method-name="exportSystemView" class-name="org.exoplatform.services.jcr.impl.core.SessionImpl" />
            <recipient method-name="exportDocumentView" class-name="org.exoplatform.services.jcr.impl.core.SessionImpl" />

            <!-- Workspace -->
            <recipient method-name="getSession" class-name="org.exoplatform.services.jcr.impl.core.WorkspaceImpl" />
            <recipient method-name="getQueryManager" class-name="org.exoplatform.services.jcr.impl.core.WorkspaceImpl" />
            <recipient method-name="getNamespaceRegistry" class-name="org.exoplatform.services.jcr.impl.core.WorkspaceImpl" />
            <recipient method-name="copy" class-name="org.exoplatform.services.jcr.impl.core.WorkspaceImpl" />
            <recipient method-name="move" class-name="org.exoplatform.services.jcr.impl.core.WorkspaceImpl" />
            <recipient method-name="clone" class-CpuStatisticCollectorAdvicename="org.exoplatform.services.jcr.impl.core.WorkspaceImpl" />
            <recipient method-name="importXML" class-name="org.exoplatform.services.jcr.impl.core.WorkspaceImpl" />
            <recipient method-name="restore" class-name="org.exoplatform.services.jcr.impl.core.WorkspaceImpl" />

            <!-- Node -->
            <recipient method-name="getNode" class-name="org.exoplatform.services.jcr.impl.core.NodeImpl" />
            <recipient method-name="getNodes" class-name="org.exoplatform.services.jcr.impl.core.NodeImpl" />
            <recipient method-name="getProperty" class-name="org.exoplatform.services.jcr.impl.core.NodeImpl" />
            <recipient method-name="getProperties" class-name="org.exoplatform.services.jcr.impl.core.NodeImpl" />
            <recipient method-name="getPrimaryItem" class-name="org.exoplatform.services.jcr.impl.core.NodeImpl" />
            <recipient method-name="getUUID" class-name="org.exoplatform.services.jcr.impl.core.NodeImpl" />
            <recipient method-name="addNode" class-name="org.exoplatform.services.jcr.impl.core.NodeImpl" />
            <recipient method-name="getProperty" class-name="org.exoplatform.services.jcr.impl.core.NodeImpl" />
            <recipient method-name="merge" class-name="org.exoplatform.services.jcr.impl.core.NodeImpl" />
            <recipient method-name="restore" class-name="org.exoplatform.services.jcr.impl.core.NodeImpl" />
            <recipient method-name="restoreByLabel" class-name="org.exoplatform.services.jcr.impl.core.NodeImpl" />
            <recipient method-name="getVersionHistory" class-name="org.exoplatform.services.jcr.impl.core.NodeImpl" />
            <recipient method-name="getBaseVersion" class-name="org.exoplatform.services.jcr.impl.core.NodeImpl" />
            <recipient method-name="lock" class-name="org.exoplatform.services.jcr.impl.core.NodeImpl" />
            <recipient method-name="getLock" class-name="org.exoplatform.services.jcr.impl.core.NodeImpl" />
            <recipient method-name="unlock" class-name="org.exoplatform.services.jcr.impl.core.NodeImpl" />

            <!-- Property -->
            <recipient method-name="getValue" class-name="org.exoplatform.services.jcr.impl.core.PropertyImpl" />
            <recipient method-name="getValues" class-name="org.exoplatform.services.jcr.impl.core.PropertyImpl" />
            <recipient method-name="getType" class-name="org.exoplatform.services.jcr.impl.core.PropertyImpl" />
            <recipient method-name="getString" class-name="org.exoplatform.services.jcr.impl.core.PropertyImpl" />
            <recipient method-name="getStream" class-name="org.exoplatform.services.jcr.impl.core.PropertyImpl" />
            <recipient method-name="getDouble" class-name="org.exoplatform.services.jcr.impl.core.PropertyImpl" />
            <recipient method-name="getLong" class-name="org.exoplatform.services.jcr.impl.core.PropertyImpl" />
            <recipient method-name="getDate" class-name="org.exoplatform.services.jcr.impl.core.PropertyImpl" />
            <recipient method-name="getBoolean" class-name="org.exoplatform.services.jcr.impl.core.PropertyImpl" />
            <recipient method-name="getNode" class-name="org.exoplatform.services.jcr.impl.core.PropertyImpl" />
            <recipient method-name="setValue" class-name="org.exoplatform.services.jcr.impl.core.PropertyImpl" />

            <!-- Value -->
            <recipient method-name="getType" class-name="org.exoplatform.services.jcr.impl.core.value.BaseValue" />
            <recipient method-name="getDate" class-name="org.exoplatform.services.jcr.impl.core.value.BaseValue" />
            <recipient method-name="getLong" class-name="org.exoplatform.services.jcr.impl.core.value.BaseValue" />
            <recipient method-name="getBoolean" class-name="org.exoplatform.services.jcr.impl.core.value.BaseValue" />
            <recipient method-name="getDouble" class-name="org.exoplatform.services.jcr.impl.core.value.BaseValue" />
            <recipient method-name="getStream" class-name="org.exoplatform.services.jcr.impl.core.value.BaseValue" />
            <recipient method-name="getString" class-name="org.exoplatform.services.jcr.impl.core.value.BaseValue" />
            <recipient method-name="read" class-name="org.exoplatform.services.jcr.impl.core.value.BaseValue" />

            <!-- Item -->
            <recipient method-name="getName" class-name="org.exoplatform.services.jcr.impl.core.ItemImpl" />
            <recipient method-name="getAncestor" class-name="org.exoplatform.services.jcr.impl.core.ItemImpl" />
            <recipient method-name="getParent" class-name="org.exoplatform.services.jcr.impl.core.ItemImpl" />
            <recipient method-name="getSession" class-name="org.exoplatform.services.jcr.impl.core.ItemImpl" />
            <recipient method-name="save" class-name="org.exoplatform.services.jcr.impl.core.ItemImpl" />
            <recipient method-name="remove" class-name="org.exoplatform.services.jcr.impl.core.ItemImpl" />

            <!-- QueryManager -->
            <recipient method-name="createQuery" class-name="org.exoplatform.services.jcr.impl.core.query.QueryManagerImpl" />
            <recipient method-name="getQuery" class-name="org.exoplatform.services.jcr.impl.core.query.QueryManagerImpl" />

            <!-- Query -->
            <recipient method-name="execute" class-name="org.exoplatform.services.jcr.impl.core.query.QueryImpl" />
            <recipient method-name="storeAsNode" class-name="org.exoplatform.services.jcr.impl.core.query.QueryImpl" />

            <!-- Row -->
            <recipient method-name="getValues" class-name="org.exoplatform.services.jcr.impl.core.query.lucene.RowIteratorImpl.RowImpl" />
            <recipient method-name="getValue" class-name="org.exoplatform.services.jcr.impl.core.query.lucene.RowIteratorImpl.RowImpl" />

            <!-- ValueFactory -->
            <recipient method-name="createValue" class-name="org.exoplatform.services.jcr.impl.core.value.ValueFactoryImpl" />

            <!-- VersionHistory -->
            <recipient method-name="getRootVersion" class-name="org.exoplatform.services.jcr.impl.core.version.VersionHistoryImpl" />
            <recipient method-name="getAllVersions" class-name="org.exoplatform.services.jcr.impl.core.version.VersionHistoryImpl" />
            <recipient method-name="getVersion" class-name="org.exoplatform.services.jcr.impl.core.version.VersionHistoryImpl" />
            <recipient method-name="getVersionByLabel" class-name="org.exoplatform.services.jcr.impl.core.version.VersionHistoryImpl" />
            <recipient method-name="addVersionLabel" class-name="org.exoplatform.services.jcr.impl.core.version.VersionHistoryImpl" />
            <recipient method-name="getVersionLabels" class-name="org.exoplatform.services.jcr.impl.core.version.VersionHistoryImpl" />
            <recipient method-name="removeVersionLabel" class-name="org.exoplatform.services.jcr.impl.core.version.VersionHistoryImpl" />
            <recipient method-name="removeVersion" class-name="org.exoplatform.services.jcr.impl.core.version.VersionHistoryImpl" />

            <!-- Version -->
            <recipient method-name="getContainingHistory" class-name="org.exoplatform.services.jcr.impl.core.version.VersionImpl" />
            <recipient method-name="getSuccessors" class-name="org.exoplatform.services.jcr.impl.core.version.VersionImpl" />
            <recipient method-name="getPredecessors" class-name="org.exoplatform.services.jcr.impl.core.version.VersionImpl" />
         </recipients>
         <advices>
            <advice class-name="org.exoplatform.instrument.transformer.MethodCallCollectorAdvice" />
         </advices>
      </pointcut>

      <!-- Collecting information about JCR storage size -->
      <pointcut pointcut-class-name="org.exoplatform.instrument.transformer.MethodExecutionPoincut">
         <recipients>
            <recipient method-name="save" class-name="org.exoplatform.services.jcr.impl.dataflow.persistent.WorkspacePersistentDataManager" />
         </recipients>
         <advices>
            <advice class-name="org.exoplatform.instrument.transformer.JcrDataSizeCollectorAdvice" />
         </advices>
      </pointcut>

      <!-- Limit size of JCR Value (in bytes) -->
      <pointcut pointcut-class-name="org.exoplatform.instrument.transformer.MethodExecutionPoincut">
         <recipients>
            <recipient method-name="createValue" class-name="org.exoplatform.services.jcr.impl.core.value.ValueFactoryImpl" />
         </recipients>
         <advices>
            <advice class-name="org.exoplatform.instrument.transformer.LimitJcrValueSize" />
         </advices>
         <parameters>
            <parameter value="20971520" name="maximum-value-size" />
         </parameters>
      </pointcut>

      <!-- Collecting information about incoming/outcoming traffic and limit size of Response and Request body sizes -->
      <pointcut pointcut-class-name="org.exoplatform.instrument.transformer.ParameterWrapperPointcut">
         <recipients>
            <recipient method-name="doFilterInternal" class-name="org.exoplatform.cloudmanagement.multitenancy.SetTenantRepositoryFilter" />
         </recipients>
         <advices>
            <advice class-name="org.exoplatform.instrument.transformer.CountingInputStreamServletRequestAdvice" />
            <advice class-name="org.exoplatform.instrument.transformer.LimitiedInputStreamServletRequestAdvice">
               <parameters>
                  <parameter value="20971520" name="maximum-request-size" />
               </parameters>
            </advice>
            <advice class-name="org.exoplatform.instrument.transformer.LimitiedOutputStreamServletResponseAdvice">
               <parameters>
                  <parameter value="20971520" name="maximum-response-size" />
               </parameters>
            </advice>
            <advice class-name="org.exoplatform.instrument.transformer.CountingOutputStreamServletResponseAdvice" />
         </advices>
      </pointcut>

      <!-- Collecting information about CPU usage -->
      <pointcut pointcut-class-name="org.exoplatform.instrument.transformer.MethodExecutionPoincut">
         <recipients>
            <recipient method-name="doFilterInternal" class-name="org.exoplatform.cloudmanagement.multitenancy.SetTenantRepositoryFilter" />
         </recipients>
         <advices>
            <advice class-name="org.exoplatform.instrument.transformer.CpuStatisticCollectorAdvice" />
         </advices>
      </pointcut>

      <!-- Limitation of amount of Registered users -->
      <pointcut pointcut-class-name="org.exoplatform.instrument.transformer.MethodExecutionPoincut">
         <recipients>
            <recipient method-name="createUser" class-name="org.exoplatform.services.jcr.ext.organization.UserHandlerImpl" />
         </recipients>
         <advices>
            <advice class-name="org.exoplatform.instrument.transformer.LimitRegisteredUsersAdvice">
               <parameters>
                  <parameter value="20" name="user-limit" />
               </parameters>
            </advice>
         </advices>
      </pointcut>

      <!-- Limiter the number of concurrent HTTP requests -->
      <pointcut pointcut-class-name="org.exoplatform.instrument.transformer.MethodExecutionWithClassVariablePoincut">
         <recipients>
            <recipient method-name="onService" class-name="org.exoplatform.services.rest.servlet.RestServlet" />
         </recipients>
         <advices>
            <advice class-name="org.exoplatform.instrument.transformer.TenancyRequestLimiterAdvice" />
            <parameters>
               <parameter value="200" name="request-limit" />
            </parameters>
         </advices>
      </pointcut>

      <!-- Collecting information about registered groovy services -->
      <pointcut pointcut-class-name="org.exoplatform.instrument.transformer.MethodExecutionPoincut">
         <recipients>
            <recipient method-name="notifyResources" class-name="org.exoplatform.cloudmanagement.rest.TenancyResourceBinder" />
         </recipients>
         <advices>
            <advice class-name="org.exoplatform.instrument.transformer.TenancyResourceCollectorAdvice" />
         </advices>
      </pointcut>

      <!-- Collecting information about Request count -->
      <pointcut pointcut-class-name="org.exoplatform.instrument.transformer.MethodExecutionPoincut">
         <recipients>
            <recipient method-name="doFilterInternal" class-name="org.exoplatform.cloudmanagement.multitenancy.SetTenantRepositoryFilter" />
         </recipients>
         <advices>
            <advice class-name="org.exoplatform.instrument.transformer.HttpRequestStatisticCollectorAdvice" />
         </advices>
      </pointcut>

      <!-- Limits the number of deployed groovy services -->
      <pointcut pointcut-class-name="org.exoplatform.instrument.transformer.MethodExecutionPoincut">
         <recipients>
            <recipient method-name="addResource" class-name="org.exoplatform.cloudmanagement.rest.TenancyResourceBinder" />
         </recipients>
         <advices>
            <advice class-name="org.exoplatform.instrument.transformer.LimitedRestResourceAdvice">
               <parameters>
                  <parameter value="250" name="rest-resource-limit" />
               </parameters>
            </advice>
         </advices>
      </pointcut>

   </pointcuts>
</agent-configuration>