Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright (c) 2010-2011. Axon Framework
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 package org.axonframework.commandhandling;
 
 import java.util.List;

Statistics object to store information about the internals of the SimpleCommandBus.

You can request information about the registered handlers but also about the number of received commands.

Next to requesting information it is also possible to reset the counters

Finally, the statistics are only gathered when explicitly enabled. By default they are switched off.

Author(s):
Jettro Coenradie
Allard Buijze
Since:
0.6
 
 
     private AtomicLong handlerCounter = new AtomicLong(0);
     private AtomicLong receivedCommandCounter = new AtomicLong(0);
     private List<StringhandlerTypes = new CopyOnWriteArrayList<String>();

    
Creates an instance of this statistics MBean.
 
     public SimpleCommandBusStatistics() {
     }

    
Returns the amount of registered handlers.

Returns:
long representing the amount of registered handlers
 
     @Override
     public long getCommandHandlerCount() {
         return .get();
     }

    
Returns the amount of received commands from the beginning of starting up or after the last reset.

Returns:
long representing the amount of received commands
 
     @Override
     public long getReceivedCommandCount() {
         return .get();
     }

    
Returns a list with the names of the types of the registered handlers.

Returns:
List of strings with the names of the registered handlers
 
     @Override
     public List<StringgetHandlerTypes() {
         return Collections.unmodifiableList();
     }

    
Resets the received command counter.
 
     @Override
     public void resetReceivedCommandsCounter() {
         .set(0);
     }

    
Indicate a new handler with the provided name is registered. Multiple handlers with the same name are supported.

Parameters:
name String representing the name of the handler to register
 
     void reportHandlerRegistered(String name) {
         this..add(name);
         this..incrementAndGet();
     }

    
Indicate a handler with the provided name is unregistered. In case multiple handlers with the same name are registered, only one is unregistered. If no handler exists with the provided name no action is taken.

Parameters:
name String representing the name of the handler to un-register
 
    void recordUnregisteredHandler(String name) {
        this..remove(name);
        this..decrementAndGet();
    }

    
Indicate a new command is received. The statistics are only gathered if they are enabled.
    void recordReceivedCommand() {
    }
New to GrepCode? Check out our FAQ X