Unity Logo

Invokers

Invokers allow you to customise how a particular method is executed. This is particular useful if your underlying service objects are not plain javabeans and instead need to be created or looked up via a custom factory.

XFire does provide a number of bundled invokers to handle simple cases. One of these simple cases is when it is desirable to have a singleton for the service object. In this case, you would like to provide a single object instance that should be used for all service invocations. The provided BeanInvoker covers this functionality, and would be used as follows:

The following example illustrates how an invoker can be used to allow xfire to expose remote stateless session beans as a webservice. Given the method to invoke, this invoker will create a stateless session bean instance to invoke the method on. The same technique can be used to enable service calls to any object that requires custom creation/lookup.

The invoker implementation is as follows:

Invokers, once defined, need to be registered with the service binding. Once a handle onto a Service object has been obtained, the example invoker above can be registered on the binding like this:

If you are using an EJB3 container you can use the following invoker, which is just a simplified version of the above:

Executors

In addition to providing your own Invokers, you can also supply Executors for your service. Executors are a way to control scheduling for your service. XFire expects an executor to conform to this class definition, but there is no defined interface to implement:

To supply your own executor for a service just do:

© 2003-2008 Codehaus