简体   繁体   English

普通接口和MBean接口的区别

[英]Difference between normal Interface and MBean Interface

I have doubt about the difference between normal Interface and MBean interface.我怀疑普通接口和MBean接口之间的区别。

public interface TryMBean
{
    // method declaration
}

public class Try implements TryMBeans
{
    // method definition
}

this looks like a normal interface, but for this we are able to use jConsole to monitor.这看起来像一个普通的界面,但为此我们可以使用 jConsole 进行监控。 My doubt is, what is the difference so that we can monitor it, and how to get idea when to use normal interface and when to go for MBean.我的疑问是,有什么区别以便我们可以监视它,以及如何了解何时使用普通接口以及何时使用 MBean 的 go。 I am new to JMX.我是 JMX 的新手。

An MBean interface is a regular interface. MBean接口常规接口。 But it's definition follows some conventions, like it's name. 但它的定义遵循一些惯例,如它的名称。 The name of an MBean interface is supposed to end with MBean . MBean接口的名称应该以MBean结尾。 Also, it defines its operations and attributes following some rules that are describe in the Standard MBeans documentation 此外,它还遵循标准MBeans文档中描述的一些规则来定义其操作和属性

Basically, if you want to create an MBean that can be used with a JMX console, you have to adhere to these rules. 基本上,如果要创建可与JMX控制台一起使用的MBean,则必须遵守这些规则。 There are also other ways to create MBeans more dynamically that follows some other rules, eg if you're using Spring JMX, where MBeans can be dynamically generated based on a "regular" interface. 还有其他方法可以更加动态地创建MBean,遵循其他规则,例如,如果您使用的是Spring JMX,其中MBean可以基于“常规”接口动态生成。

Consider using abstract classes if any of these statements apply to your situation:如果这些陈述中的任何一个适用于您的情况,请考虑使用抽象类:

In the java application, there are some related classes that need to share some lines of code then you can put these lines of code within the abstract class and this abstract class should be extended by all these related classes.在 java 应用程序中,有一些相关的类需要共享一些代码行,然后您可以将这些代码行放在抽象 class 中,这个抽象 class 应该由所有这些相关类扩展。 You can define the non-static or non-final field(s) in the abstract class so that via a method you can access and modify the state of the object to which they belong.您可以在抽象 class 中定义非静态或非最终字段,以便通过方法访问和修改它们所属的 object 的 state。 You can expect that the classes that extend an abstract class have many common methods or fields, or require access modifiers other than public (such as protected and private).您可以期望扩展抽象 class 的类具有许多公共方法或字段,或者需要公共以外的访问修饰符(例如受保护和私有)。 Consider using interfaces if any of these statements apply to your situation:如果这些陈述中的任何一个适用于您的情况,请考虑使用接口:

It is a total abstraction, All methods declared within an interface must be implemented by the class(es) that implements this interface.它是一个完全抽象,接口中声明的所有方法都必须由实现该接口的类来实现。 A class can implement more than one interface.一个 class 可以实现多个接口。 It is called multiple inheritances.它被称为多重继承。 You want to specify the behavior of a particular data type but are not concerned about who implements its behavior.您想指定特定数据类型的行为,但不关心谁实现了它的行为。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM