Version 2

    BarrierControllerExample

     

    <?xml version="1.0" encoding="UTF-8"?>
    <!-- $Id:$ -->
    
    <server>
      <!--
        In this example we have the BarrierController controlling a Barrier
        that is started when we receive the "jboss.tomcat.connectors.started"
        notification from the Tomcat mbean, and stopped when we receive the
        "org.jboss.system.server.stopped" notification from the server mbean.
        
        The dependent services need only define a dependency on the Barrier mbean!
      -->
      <mbean code="org.jboss.system.BarrierController"
             name="jboss:service=BarrierController">
        
        <!-- Whether to have the Barrier initially started or not -->
        <attribute name="BarrierEnabledOnStartup">false</attribute>
        
        <!-- Whether to subscribe for notifications after startup -->
        <attribute name="DynamicSubscriptions">true</attribute>
        
        <!-- Dependent services will depend on this mbean -->
        <attribute name="BarrierObjectName">jboss:name=TomcatConnector,type=Barrier</attribute>
        
        <!-- The notification subscription handback that starts the barrier -->
        <attribute name="StartBarrierHandback">start</attribute>
        
        <!-- The notification subscription handback that stops the barrier -->
        <attribute name="StopBarrierHandback">stop</attribute>
        
        <!-- The notifications to subscribe for, along with their handbacks -->
        <attribute name="SubscriptionList">
          <subscription-list>
            <mbean name="jboss.web:service=WebServer" handback="start">
              <filter factory="NotificationFilterSupportFactory">
                <enable type="jboss.tomcat.connectors.started"></enable>
              </filter>
            </mbean>
            <mbean name="jboss.system:type=Server" handback="stop">
              <filter factory="NotificationFilterSupportFactory">
                <enable type="org.jboss.system.server.stopped"></enable>
              </filter>
            </mbean>        
          </subscription-list>
        </attribute>
      </mbean>
    
      <!--
        An example service that depends on the Barrier we declared above.
        This services creates a background thread and monitors the memory
        usage. When it exceeds the defined thresholds it emits notifications
      -->
      <mbean code="org.jboss.monitor.services.MemoryMonitor"
             name="jboss.monitor:service=MemoryMonitor">
    
        <attribute name="FreeMemoryWarningThreshold">20m</attribute>
        <attribute name="FreeMemoryCriticalThreshold">15m</attribute>
        
        <!-- The BarrierObjectName configured in the BarrierController -->
        <depends>jboss:name=TomcatConnector,type=Barrier</depends>
      </mbean>
      
    </server>
    

     

    Referenced by: