Class AbstractProfilingAspect

  • All Implemented Interfaces:
    Profiler
    Direct Known Subclasses:
    ProfilingAspect

    public abstract class AbstractProfilingAspect
    extends java.lang.Object
    implements Profiler
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.Enum accuracy  
      protected java.lang.String aspectNodeName  
      protected java.lang.String domain  
      protected long limit  
      protected java.lang.Class<?> template  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected long calculateExecutionTime​(long startTime)  
      protected org.springframework.jmx.export.assembler.MBeanInfoAssembler getAssembler()  
      protected javax.management.ObjectInstance getOrCreateMBean​(java.lang.Object resource, java.lang.String method)
      Creates or returns a MBean instance for the specified method
      protected javax.management.ObjectInstance getOrCreateResource​(java.lang.Class template, java.lang.String profiledMethod)
      Wrapper method for getOrCreateMBean method.
      protected abstract Tenant getOwnTenant()  
      protected long getTime()
      Returns the current time in the specified time unit setAccuracy(String)
      void logException​(javax.management.ObjectInstance bean)
      This method will be used for incrementing an internal "failed execution counter"
      void logExecutionTime​(javax.management.ObjectInstance bean, long executionTime, long calledAt)
      Logs the execution time of the currently profiled method
      void setAccuracy​(java.lang.String accuracy)
      Setter of the time measure accuracy (use 'ns' for nano seconds , 'ms' for milliseconds [default])
      void setAspectNodeName​(java.lang.String aspectNodeName)
      Setter of the JMX node name (this node will appear below 'hybris/{Tenant ID}')
      void setAssembler​(org.springframework.jmx.export.assembler.MBeanInfoAssembler assembler)
      assembler for gathering required MBeanInfo object for a bean
      void setDomain​(java.lang.String domain)
      Setter of the JMX domain.
      void setLimit​(long limit)
      Sets the minimum method execution time.
      void setTemplate​(java.lang.Class<? extends ProfilingReportBean> template)
      Setter for the ProfilingReportBean instance.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • template

        protected java.lang.Class<?> template
      • domain

        protected java.lang.String domain
      • aspectNodeName

        protected java.lang.String aspectNodeName
      • accuracy

        protected java.lang.Enum accuracy
      • limit

        protected long limit
    • Constructor Detail

      • AbstractProfilingAspect

        public AbstractProfilingAspect()
    • Method Detail

      • getAssembler

        protected org.springframework.jmx.export.assembler.MBeanInfoAssembler getAssembler()
      • setAssembler

        public void setAssembler​(org.springframework.jmx.export.assembler.MBeanInfoAssembler assembler)
        assembler for gathering required MBeanInfo object for a bean
      • setAspectNodeName

        public void setAspectNodeName​(java.lang.String aspectNodeName)
        Setter of the JMX node name (this node will appear below 'hybris/{Tenant ID}')
        Parameters:
        aspectNodeName - the JMX node name (default is the class name of the aspect)
      • setAccuracy

        public void setAccuracy​(java.lang.String accuracy)
        Setter of the time measure accuracy (use 'ns' for nano seconds , 'ms' for milliseconds [default])
        Parameters:
        accuracy - the time unit
      • setLimit

        public void setLimit​(long limit)
        Sets the minimum method execution time. If the execution time of the currently analyzed method is lesser than that value, the method will be ignored.
        Specified by:
        setLimit in interface Profiler
        Parameters:
        limit -
      • getTime

        protected long getTime()
        Returns the current time in the specified time unit setAccuracy(String)
        Returns:
        current time
      • calculateExecutionTime

        protected long calculateExecutionTime​(long startTime)
      • getOrCreateMBean

        protected javax.management.ObjectInstance getOrCreateMBean​(java.lang.Object resource,
                                                                   java.lang.String method)
                                                            throws javax.management.JMException,
                                                                   javax.management.modelmbean.InvalidTargetObjectTypeException,
                                                                   java.lang.IllegalArgumentException,
                                                                   java.lang.InstantiationException,
                                                                   java.lang.IllegalAccessException,
                                                                   java.lang.reflect.InvocationTargetException
        Creates or returns a MBean instance for the specified method
        Parameters:
        resource - an implementation of ProfilingReportBean
        method - the profiled method
        Returns:
        mbean instance
        Throws:
        javax.management.JMException
        javax.management.modelmbean.InvalidTargetObjectTypeException
        java.lang.reflect.InvocationTargetException
        java.lang.IllegalAccessException
        java.lang.InstantiationException
        java.lang.IllegalArgumentException
      • getOwnTenant

        protected abstract Tenant getOwnTenant()
      • getOrCreateResource

        protected javax.management.ObjectInstance getOrCreateResource​(java.lang.Class template,
                                                                      java.lang.String profiledMethod)
                                                               throws java.lang.InstantiationException,
                                                                      java.lang.IllegalAccessException,
                                                                      java.lang.IllegalArgumentException,
                                                                      javax.management.JMException,
                                                                      javax.management.modelmbean.InvalidTargetObjectTypeException,
                                                                      java.lang.reflect.InvocationTargetException
        Wrapper method for getOrCreateMBean method. Checks if given template instance exists in cache and calls getOrCreateMBean with template instance as a parameter.
        Parameters:
        template - an implementation of ProfilingReportBean
        profiledMethod - the profiled method
        Returns:
        mbean instance
        Throws:
        javax.management.JMException
        javax.management.modelmbean.InvalidTargetObjectTypeException
        java.lang.reflect.InvocationTargetException
        java.lang.IllegalAccessException
        java.lang.InstantiationException
        java.lang.IllegalArgumentException
      • logExecutionTime

        public void logExecutionTime​(javax.management.ObjectInstance bean,
                                     long executionTime,
                                     long calledAt)
                              throws javax.management.JMException,
                                     javax.management.modelmbean.InvalidTargetObjectTypeException
        Logs the execution time of the currently profiled method
        Parameters:
        bean - the used bean for "displaying" the profiled data via JMX
        executionTime - the execution time
        calledAt - the start time
        Throws:
        javax.management.JMException
        javax.management.modelmbean.InvalidTargetObjectTypeException
      • logException

        public void logException​(javax.management.ObjectInstance bean)
                          throws javax.management.JMException,
                                 javax.management.modelmbean.InvalidTargetObjectTypeException
        This method will be used for incrementing an internal "failed execution counter"
        Parameters:
        bean - the JMX bean which will be notified about the notified execution of its corresponding method
        Throws:
        javax.management.JMException
        javax.management.modelmbean.InvalidTargetObjectTypeException