O'Reilly logo

Hands-On High Performance with Spring 5 by Dinesh Radadiya, Prashant Goswami, Pritesh Shah, Subhash Shah, Chintan Mehta

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating an MBean

To create an MBean, we can use @Managed annotations to convert any class into an MBean. The class BankTransferService transfers an amount from one account to another. We will use this example for further understanding:

@Component@ManagedResource(objectName = "com.packt.springhighperformance.ch4.mbeans : name=BankMoneyTransferService", description = "Transfers money from one account to another")public class BankMoneyTransferService {  private Map<String, Integer> accountMap = new HashMap<String,   Integer>();   {    accountMap.put("12345", 20000);    accountMap.put("54321", 10000);   };  @ManagedOperation(description = "Amount transfer")  @ManagedOperationParameters({      @ManagedOperationParameter(name = "sourceAccount", description =  "Transfer ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required