Search in sources :

Example 1 with ReferenceResolver

use of org.apache.cxf.ws.policy.attachment.reference.ReferenceResolver in project cxf by apache.

the class WSPolicyFeature method resolveLocal.

Policy resolveLocal(PolicyReference ref, final Bus bus, DescriptionInfo i) {
    String uri = ref.getURI().substring(1);
    String absoluteURI = i == null ? uri : i.getBaseURI() + uri;
    PolicyRegistry registry = bus.getExtension(PolicyEngine.class).getRegistry();
    Policy resolved = registry.lookup(absoluteURI);
    if (null != resolved) {
        return resolved;
    }
    ReferenceResolver resolver = new ReferenceResolver() {

        public Policy resolveReference(String uri) {
            PolicyBean pb = bus.getExtension(ConfiguredBeanLocator.class).getBeanOfType(uri, PolicyBean.class);
            if (null != pb) {
                PolicyBuilder builder = bus.getExtension(PolicyBuilder.class);
                return builder.getPolicy(pb.getElement());
            }
            return null;
        }
    };
    resolved = resolver.resolveReference(uri);
    if (null != resolved) {
        ref.setURI(absoluteURI);
        registry.register(absoluteURI, resolved);
    }
    return resolved;
}
Also used : Policy(org.apache.neethi.Policy) ConfiguredBeanLocator(org.apache.cxf.configuration.ConfiguredBeanLocator) PolicyRegistry(org.apache.neethi.PolicyRegistry) ReferenceResolver(org.apache.cxf.ws.policy.attachment.reference.ReferenceResolver) RemoteReferenceResolver(org.apache.cxf.ws.policy.attachment.reference.RemoteReferenceResolver)

Example 2 with ReferenceResolver

use of org.apache.cxf.ws.policy.attachment.reference.ReferenceResolver in project cxf by apache.

the class AbstractPolicyProvider method resolveExternal.

protected Policy resolveExternal(PolicyReference ref, String baseURI) {
    Policy resolved = registry.lookup(ref.getURI());
    if (null != resolved) {
        return resolved;
    }
    ReferenceResolver resolver = new RemoteReferenceResolver(baseURI, builder);
    return resolver.resolveReference(ref.getURI());
}
Also used : Policy(org.apache.neethi.Policy) RemoteReferenceResolver(org.apache.cxf.ws.policy.attachment.reference.RemoteReferenceResolver) ReferenceResolver(org.apache.cxf.ws.policy.attachment.reference.ReferenceResolver) RemoteReferenceResolver(org.apache.cxf.ws.policy.attachment.reference.RemoteReferenceResolver)

Example 3 with ReferenceResolver

use of org.apache.cxf.ws.policy.attachment.reference.ReferenceResolver in project cxf by apache.

the class ExternalAttachmentProvider method resolveLocal.

Policy resolveLocal(PolicyReference ref, Document doc) {
    String relativeURI = ref.getURI().substring(1);
    String absoluteURI = doc.getBaseURI() + ref.getURI();
    Policy resolved = registry.lookup(absoluteURI);
    if (null != resolved) {
        return resolved;
    }
    ReferenceResolver resolver = new LocalDocumentReferenceResolver(doc, builder);
    resolved = resolver.resolveReference(relativeURI);
    if (null != resolved) {
        ref.setURI(absoluteURI);
        registry.register(absoluteURI, resolved);
    }
    return resolved;
}
Also used : Policy(org.apache.neethi.Policy) LocalDocumentReferenceResolver(org.apache.cxf.ws.policy.attachment.reference.LocalDocumentReferenceResolver) ReferenceResolver(org.apache.cxf.ws.policy.attachment.reference.ReferenceResolver) LocalDocumentReferenceResolver(org.apache.cxf.ws.policy.attachment.reference.LocalDocumentReferenceResolver)

Example 4 with ReferenceResolver

use of org.apache.cxf.ws.policy.attachment.reference.ReferenceResolver in project cxf by apache.

the class AbstractSTSClient method setPolicyInternal.

protected void setPolicyInternal(String policyReference) {
    PolicyBuilder builder = bus.getExtension(PolicyBuilder.class);
    ReferenceResolver resolver = new RemoteReferenceResolver(null, builder);
    PolicyRegistry registry = bus.getExtension(PolicyEngine.class).getRegistry();
    Policy resolved = registry.lookup(policyReference);
    if (null != resolved) {
        this.setPolicyInternal(resolved);
    } else {
        this.setPolicyInternal(resolver.resolveReference(policyReference));
    }
}
Also used : Policy(org.apache.neethi.Policy) EffectivePolicy(org.apache.cxf.ws.policy.EffectivePolicy) RemoteReferenceResolver(org.apache.cxf.ws.policy.attachment.reference.RemoteReferenceResolver) PolicyEngine(org.apache.cxf.ws.policy.PolicyEngine) PolicyBuilder(org.apache.cxf.ws.policy.PolicyBuilder) PolicyRegistry(org.apache.neethi.PolicyRegistry) RemoteReferenceResolver(org.apache.cxf.ws.policy.attachment.reference.RemoteReferenceResolver) ReferenceResolver(org.apache.cxf.ws.policy.attachment.reference.ReferenceResolver)

Example 5 with ReferenceResolver

use of org.apache.cxf.ws.policy.attachment.reference.ReferenceResolver in project cxf by apache.

the class WSPolicyFeature method resolveExternal.

protected Policy resolveExternal(PolicyReference ref, String baseURI, Bus bus) {
    PolicyBuilder builder = bus.getExtension(PolicyBuilder.class);
    ReferenceResolver resolver = new RemoteReferenceResolver(baseURI, builder);
    PolicyRegistry registry = bus.getExtension(PolicyEngine.class).getRegistry();
    Policy resolved = registry.lookup(ref.getURI());
    if (null != resolved) {
        return resolved;
    }
    return resolver.resolveReference(ref.getURI());
}
Also used : Policy(org.apache.neethi.Policy) RemoteReferenceResolver(org.apache.cxf.ws.policy.attachment.reference.RemoteReferenceResolver) PolicyRegistry(org.apache.neethi.PolicyRegistry) ReferenceResolver(org.apache.cxf.ws.policy.attachment.reference.ReferenceResolver) RemoteReferenceResolver(org.apache.cxf.ws.policy.attachment.reference.RemoteReferenceResolver)

Aggregations

ReferenceResolver (org.apache.cxf.ws.policy.attachment.reference.ReferenceResolver)6 Policy (org.apache.neethi.Policy)6 RemoteReferenceResolver (org.apache.cxf.ws.policy.attachment.reference.RemoteReferenceResolver)4 PolicyRegistry (org.apache.neethi.PolicyRegistry)3 ConfiguredBeanLocator (org.apache.cxf.configuration.ConfiguredBeanLocator)1 EffectivePolicy (org.apache.cxf.ws.policy.EffectivePolicy)1 PolicyBuilder (org.apache.cxf.ws.policy.PolicyBuilder)1 PolicyEngine (org.apache.cxf.ws.policy.PolicyEngine)1 LocalDocumentReferenceResolver (org.apache.cxf.ws.policy.attachment.reference.LocalDocumentReferenceResolver)1 LocalServiceModelReferenceResolver (org.apache.cxf.ws.policy.attachment.reference.LocalServiceModelReferenceResolver)1