use of org.apache.neethi.PolicyRegistry 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;
}
use of org.apache.neethi.PolicyRegistry in project cxf by apache.
the class PolicyEngineTest method testAccessors.
@Test
public void testAccessors() throws Exception {
engine = new PolicyEngineImpl(false);
assertNotNull(engine.getRegistry());
assertNull(engine.getBus());
assertNotNull(engine.getPolicyProviders());
assertNull(engine.getAlternativeSelector());
assertTrue(!engine.isEnabled());
Bus bus = new ExtensionManagerBus();
engine.setBus(bus);
List<PolicyProvider> providers = CastUtils.cast(Collections.EMPTY_LIST, PolicyProvider.class);
engine.setPolicyProviders(providers);
PolicyRegistry reg = control.createMock(PolicyRegistry.class);
engine.setRegistry(reg);
engine.setEnabled(true);
AlternativeSelector selector = control.createMock(AlternativeSelector.class);
engine.setAlternativeSelector(selector);
assertSame(bus, engine.getBus());
assertSame(reg, engine.getRegistry());
assertTrue(engine.isEnabled());
assertSame(selector, engine.getAlternativeSelector());
assertNotNull(engine.createOutPolicyInfo());
bus.shutdown(true);
}
use of org.apache.neethi.PolicyRegistry 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));
}
}
use of org.apache.neethi.PolicyRegistry 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());
}
Aggregations