简体   繁体   English

EJB 2.X中存根和骨架的概念

[英]Concept of stub and Skeleton in EJB 2.X

As per my knowledge, in the EJB 2.x, the client uses the home interface to ask for a reference to the component interface and calls Enterprise java bean's business method using that reference. 据我所知,在EJB 2.x中,客户端使用home接口请求对组件接口的引用,并使用该引用调用Enterprise java bean的业务方法。 But the concept of stub and skeleton are not clear to me. 但是存根和骨架的概念对我来说并不清楚。

Is the reference to the component interface acts as a stub? 对组件接口的引用是否充当存根? Then which one act as a skeleton? 然后哪一个充当骨架?

Please clarify. 请澄清。

Stub and skeleton are actually RMI concepts, EJB is just reusing them. Stub和skeleton实际上是RMI概念,EJB只是重用它们。 As such, they are only needed when you are using remote interfaces. 因此,只有在使用远程接口时才需要它们。

  • Stub is used by the client to invoke methods on the remote EJB -- it is basically a proxy object that implements the remote interface. 客户端使用Stub来调用远程EJB上的方法 - 它基本上是一个实现远程接口的代理对象。 It is responsible for serializing the invocation into a byte stream and sending it to the server hosting the EJB. 它负责将调用序列化为字节流并将其发送到托管EJB的服务器。
  • Skeleton is running on the server side -- it receives the remote calls from the stub over the network, deserializes the invocation and and delegates it to the EJB. Skeleton在服务器端运行 - 它通过网络从存根接收远程调用,反序列化调用并将其委托给EJB。

See also: Java RMI : What is the role of the stub-skeleton that are generated by the rmic compiler 另请参阅: Java RMI:rmic编译器生成的stub-skeleton的作用是什么

Nowadays, stubs and skeletons are typically generated at runtime (or the same function is just handled via reflection), so you do not need to worry about them (see also Do I need RMI stubs to access EJBs from my java client? - this is specific to Glassfish, but the general principles usually apply also to other containers). 现在, 存根和骨架通常在运行时生成 (或者相同的函数只是通过反射处理),因此您不必担心它们(另请参阅我是否需要RMI存根来从我的Java客户端访问EJB? - 这是Glassfish特有的,但一般原则通常也适用于其他容器)。

自1998年以来,骷髅已经过时了。不要担心它们。

Well stub and skeleton are just there when you are using Remote interfaces. 当您使用远程接口时,存根和骨架就在那里。 Stub is an object implementing Remote interface (implemented usually by code generation) and skeleton is implemented inside the container and invokes method on the EJB (inside the container). Stub是一个实现Remote接口的对象(通常通过代码生成实现),框架在容器内部实现,并在EJB(容器内)上调用方法。

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

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