简体   繁体   English

java ee7 @local和无接口视图

[英]java ee7 @local, and no-interface views

I have a question about EJB: Local, and No-Interface Views. 我有一个关于EJB的问题:本地视图和无接口视图。

According to the book "Beginning Java EE 7" 根据《 Java EE 7入门》一书

@Local: Denotes a local business interface. @Local:表示本地业务接口。 Method parameters are passed by reference from the client to the bean. 方法参数通过引用从客户端传递到Bean。

The no interface view is a variation of the local view that exposes all the public business methods of the bean class locally without the use of separate business interface. no接口视图是本地视图的一种变体,它在本地公开了bean类的所有公共业务方法,而无需使用单独的业务接口。

And my question is are there any significant differences between @Local annotation and no interface view, and if so how and when each of them should be used? 我的问题是@Local批注和没有接口视图之间是否有显着差异,如果是,应如何以及何时使用它们中的每一个?

It is called no interface view if you let you Bean implement only one Interface you do not need to annotate the Interface or Bean, because the Container will use this Interface as LocalInterface by default. 如果您让Bean仅实现一个接口而不需要对接口或Bean进行注释,则称为no interface view ,因为默认情况下容器将使用此接口作为LocalInterface。

The client who wants to use the EJBs Methods only see the public methods provided by the interface and all the other aspects of method implementation are hidden from the client. 想要使用EJB方法的客户端只能看到接口提供的公共方法,而方法实现的所有其他方面对客户端都是隐藏的。

So you can annotate bean or interface with @Local but you do not need it, if you only use one Interface. 因此,如果仅使用一个接口,则可以使用@Local注释bean或接口,但不需要它。

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

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