xfire is a web service framework that can expose pojo objects as web service.
Yan provides an integration package allowing configuring xfire services with yan.
A sample xfire configuration file is:
The <service> tag is supported by the jfun.yan.xfire.ServiceNut class. This tag supports every attribute currently supported by the native xfire configuration.
The "scope" attribute can be set to "application", "service", "session" and "request".
- "application" and "service" are equivalent. They both enforce one EchoImpl instance per service. Therefore "service" is picked as scope name.
- "session" scope enforces one EchoImpl instance per session.
- "request" scope uses one EchoImpl instance per service method invocation.
- if "scope" is not specified, the default scope is "service'.
- If you simply want a globally singleton EchoImpl, just set the nested EchoImpl component to singleton as: The scope is changed to "request" to avoid any caching done at the service level.
- "singleton" attribute (and many other common attributes) can still be set on the <service> tag to control the instantiation of the Service object. A Service is a regular component.
In order to set up xfire environment, either "jfun/yan/xfire/xfireXmlBeans.xml" or "jfun/yan/xfire/xfire.xml" needs to be loaded.
A typical Java code that bootstrap xfire may look like:
The container created can then be used to lookup regular beans as well as xfire Service:
When deployed as a servlet, jfun.yan.xfire.XFireYanServlet can be used to read service information from a yan configuration file.
For example, the xfire book example can be configured using Yan configuration file.
The web.xml file will look like:
The "yanConfigFile" parameter is used to specify the location of the configuration file.
And the yan.xml file looks like:
In this example, component "bookshelf" is configured in exactly the same way as any other regular component. We then use the "service" tag to expose it as a web service.
Though not required, reading the xfire.xml helps in knowing what ids the xfire infrastructure beans are registered under. Now let's take a look: