本文介绍了Javabean和EJB之间的差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



JavaBean和EJB之间有什么区别?

解决方案

Java bean只是一组约定。 EJB是J2EE业务组件的标准。



具体来说,一个Java bean:




  • 具有公共默认构造函数;

  • 可读属性方法先于get;

  • 可写属性方法先于set;

  • 是可序列化的。



例如,具有margin属性的Java bean 最少会像这样:

  public class MyBean implements Serializable {
private int margin;

public MyBean(){}
public int getMargin(){return margin; }
public void setMargin(int margin){this.margin = margin; }
}

EJB尽管名称几乎完全不相关。


Just a simple question from a relative Java newbie:

what is the difference between a JavaBean and an EJB?

解决方案

Java bean is just a set of conventions. EJB is a standard for J2EE business components.

Specifically a Java bean:

  • has a public default constructor;
  • readable property methods precedes with "get";
  • writable property methods precedes with "set"; and
  • is Serializable.

For example, a Java bean with a property of "margin" would minimally look like this:

public class MyBean implements Serializable {
  private int margin;

  public MyBean() { }
  public int getMargin() { return margin; }
  public void setMargin(int margin) { this.margin = margin; }
}

EJB, despite the name, is almost completely unrelated.

这篇关于Javabean和EJB之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 13:13