简体   繁体   English

Java Web Service构造函数调用

[英]Java Web Service Constructor invocation

How do you invoke a Java Web service constructor. 您如何调用Java Web服务构造函数。 Ideally when does constructor invocation happen while you consume the service from a client 理想情况下,当您从客户端使用服务时何时进行构造函数调用

You do not explicitly invoke a constructor from the client. 您没有从客户端显式调用构造函数。 From a Web services perspective, you are invoking an operation. 从Web服务的角度来看,您正在调用操作。 You have no knowledge in the client of how that operation is implemented. 您不知道客户端如何执行该操作。

The life-cycle of your server-side object is in the hands of your specific implementation of JAX-WS. 服务器端对象的生命周期掌握在JAX-WS的特定实现中。 Possibly, at the time your server starts, it will instantiate one or more copies of your service object, and so that's when your constructor is called. 可能在服务器启动时,它将实例化服务对象的一个​​或多个副本,因此就是在调用构造函数时。

In Web services, each operation is usually a "stateless" action. 在Web服务中,每个操作通常是“无状态”操作。 If you have some standard processing you need to do, you would just include that processing in your implementation. 如果您需要执行一些标准处理,则只需将该处理包含在实现中即可。

operationAaa(final String exampleParam) {
    auditLog(exampleParam);

    doAaaWork(exampleParam);
}

operationBbb(final String exampleParam) {
    auditLog(exampleParam);

    doBbbWork(exampleParam);
}

Now, possibly, you may have the kind of processing that could be implemented in a Handler. 现在,也许您已经拥有可以在Handler中实现的那种处理。 See this article . 看到这篇文章

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

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