cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Josh Hill <Josh.H...@finzsoft.com>
Subject Dynamic policies using spring properties
Date Mon, 20 May 2013 06:42:14 GMT
I annotate my web services with one class level policy and two per method to take advantage
of the placement attribute (see Fig 1). I would like to set the policy's uri as a spring property
(see Fig 2).

My first solution was to use an custom policy in/out interceptor to read the @Policy annotation's
uri and if surround with "${}" then build a dynamic policy using Neethi and set it to PolicyConstants.POLICY_OVERRIDE.
A problem I encountered with this approach is that I need to attach three different policies
using different placements. Merging them may be a last resort option.

A temporary hack would be to alter org.apache.cxf.resource.ExtendedURIResolver.resolve() to
resolve a uri surrounded with "${}" to a spring property. I'm hoping someone here can suggest
a better solution.

Any thoughts

Fig 1.
@WebService
@SOAPBinding(style = SOAPBinding.Style.DOCUMENT, use = SOAPBinding.Use.LITERAL)
@Policy(uri = "classpath:/policy/service.policy", placement = Policy.Placement.SERVICE)
public interface ProductWS {

    @WebMethod
    @WebResult(name = "product-wsresponse")
    @Policies({
            @Policy(uri = "classpath:/policy/service-input.policy", placement = Policy.Placement.BINDING_OPERATION_INPUT),
            @Policy(uri = "classpath:/policy/service-output.policy", placement = Policy.Placement.BINDING_OPERATION_OUTPUT)
    })
    ProductResponseMessage products(@WebParam(name = "product-wsrequest") ProductRequestMessage
productRequestMessage);
}

Fig 2.
@WebService
@SOAPBinding(style = SOAPBinding.Style.DOCUMENT, use = SOAPBinding.Use.LITERAL)
@Policy(uri = "${product.service.policy}", placement = Policy.Placement.SERVICE)
public interface ProductWS {

    @WebMethod
    @WebResult(name = "product-wsresponse")
    @Policies({
            @Policy(uri = "${product.service.input.policy}", placement = Policy.Placement.BINDING_OPERATION_INPUT),
            @Policy(uri = "${product.service.output.policy}", placement = Policy.Placement.BINDING_OPERATION_OUTPUT)
    })
    ProductResponseMessage products(@WebParam(name = "product-wsrequest") ProductRequestMessage
productRequestMessage);
}



Josh Hill
Senior Java Developer



[cid:imagea80aa5.png@f27a0f82.ae304923]



sovereign finance and banking software



A Level 1, Building C, Millennium Centre, 602 Great South Road, Greenlane, Auckland, New Zealand
D 64 9 571 6812       P 64 9 571 6800    F 64 9 571 6899
E Josh.Hill@finzsoft.com    W www.finzsoft.com<http://www.finzsoft.com>


Please note: This email contains information that is confidential and may be privileged. If
you are not the intended recipient, you must not peruse, use, disseminate, distribute or copy
this email or attachments. If you have received this in error, please notify Finzsoft Solutions
(New Zealand) Ltd immediately by return email and delete this email. Thank you.

______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
______________________________________________________________________
Mime
  • Unnamed multipart/related (inline, None, 0 bytes)
View raw message