Hi,

Axis supports also plugable Providers. New Providers could be used with a
service without changing the Axis source code.

<service name="MyService" provider="java:ECHO">
   <parameter name="param1" value="hossa"/>
</service>

Below is a step by step example. In the Provider the service's parameters
can be read:

msgContext.getService().getOption("param1");

Security Information can be passed via ThreadLocal or the MessageContext to
the service Implementation. We have subclassed EJBProvider for Example and
pass the HTTPAuthentication to the EJB Container.

Thomas



Example Plugable Provider
=========================

You can create your own provider with the following steps:

1.) Write the provider class. The example is a simple EchoProvider that
extends BasicProvider.

public class EchoProvider extends BasicProvider {

  public void initServiceDesc(
    SOAPService service,
    MessageContext msgContext)
    throws AxisFault {
  }

  public void invoke(MessageContext msgContext)
    throws AxisFault {
    Message requestMessage = msgContext.getRequestMessage();
    SOAPEnvelope requestEnvelope =
      requestMessage.getSOAPEnvelope();

    Message responseMessage = new Message(requestEnvelope);
    msgContext.setResponseMessage(responseMessage);
  }
}

2.) Write a Factory for the provider.

public class WSDDEchoProvider extends WSDDProvider {

  public Handler newProviderInstance(
    WSDDService arg0,
    EngineConfiguration arg1)
    throws Exception {
    return new EchoProvider();
  }

  public String getName() {
    return "ECHO";
  }
}

3.) Tell Axis about the new Provider. Axis is looking for a file in the
directory structure META-INF/service in the classpath with the file name
org.apache.axis.deployment.wsdd.Provider

META-INF/services/org.apache.axis.deployment.wsdd.Provider

In the file you can specify factories for plugable providers:

de.oio.providers.WSDDEchoProvider






> -----Urspr�ngliche Nachricht-----
> Von: Uwe Kubosch [mailto:[EMAIL PROTECTED]
> Gesendet: Mittwoch, 12. November 2003 15:13
> An: [EMAIL PROTECTED]
> Betreff: SV: Deploying Providers ?
>
>
> Hi Stefan!
>
> > I wrote my own provider but I cant test it, because
> > I didnt find anything about deploying providers.
> >
> > How can I tell Axis to use my Provider for some service ?
> > Is there a possibility to tell axis that java:MyRPC is
> > of class package.MyRPCProvider in the server-config.wsdd ?
>
> I just did this, and I must say the documentation was not a great
> help.  I'll try to summerize what I did.  If anybody has tips on
> a better way to do it, please add your advice.
>
> My service is a standard Java class, but all methods have an
> extra argument at the end.  This argument is a SecurityContext,
> and is not provided by the user of the service. It is provided by
> a custom provider.
>
> The custom provider is a class implementing the Handler interface.
>
> In my case I subclass the RPCProvider class, and override the
> invokeMethod() method, and add my extra argument before calling
> super.invokeMethod().
>
> To deploy the service with a custom provider set your provider
> attribute in the service tag to "Handler", and add a parameter
> tag with the name of the custom provider class.  The first
> parameter tag below indicates which provider to use.  The second
> indicates the backend service class to use, as with the standard
> RPCProvider.
>
> Example:
>
> <service name="MyService" provider="Handler">
>       <parameter name="handlerClass"
>               value="mypackage.MyProvider" />
>
>       <parameter name="className"
>               value="mypackage.MyServiceImpl" />
>       <parameter name="allowedMethods" value="*" />
> </service>
>
> I would have expected to be able to put the class name directly
> in the provider attribute of the service tag, and also be able to
> refer to a previously defined handler like this:
>
> <handler name="MyHandler"
>       type="mypackage.MyProvider" />
>
> <service name="MyService" provider="java:mypackage.MyProvider">
>       <parameter name="className"
>               value="mypackage.MyServiceImpl" />
>       <parameter name="allowedMethods" value="*" />
> </service>
>
> <service name="MyService" provider="MyHandler">
>       <parameter name="className"
>               value="mypackage.MyServiceImpl" />
>       <parameter name="allowedMethods" value="*" />
> </service>
>
> If someone can tell me how this can be done, I'd be very happy :)
>
>
> donV
>

Reply via email to