EJB's - when to use Remote and/or local interfaces?

前端 未结 4 1402
温柔的废话
温柔的废话 2020-12-02 03:30

I\'m very new to Java EE and I\'m trying to understand the concept of Local interfaces and Remote interfaces. I\'ve been told that one of the big advantages of Java EE is th

4条回答
  •  悲哀的现实
    2020-12-02 04:16

    According to EJB Spec 3.2 an EJB can be either be local or remote. A business interface cannot be both local and remote at the same time.

    @Local annotated beans can only be accessed if they are in the same application.

    @Remote annotated beans can be accessed across different applications, residing in different jvms or across application servers.

    So the important things to keep in mind are:

    1. If a bean class contains the @Remote annotation, then all implemented interfaces are to be remote.
    2. If a bean class contains no annotation or if the @Local annotation is specified, then all implemented interface are assumed to be local.
    3. Any interfaces that is explicitly defined for a bean which contains no interface must be declared as @Local.
    4. The EJB 3.2 release tends to provide more granularity for situations where local and remote interfaces need to explicitly defined.

提交回复
热议问题