PolicyModelGeneratorpublic final class PolicyModelGenerator extends Object
Fields Summary |
---|
private static final com.sun.xml.ws.policy.privateutil.PolicyLogger | LOGGER | private static final PolicyModelGenerator | generator |
Constructors Summary |
---|
private PolicyModelGenerator()This private constructor avoids direct instantiation from outside of the class
// nothing to initialize
|
Methods Summary |
---|
public static com.sun.xml.ws.policy.sourcemodel.PolicyModelGenerator | getGenerator()Factory method that returns {@link PolicyModelGenerator} instance.
return generator;
| public PolicySourceModel | translate(com.sun.xml.ws.policy.Policy policy)This method translates a {@link Policy} into a
{@link com.sun.xml.ws.policy.sourcemodel policy infoset}. The resulting
PolicySourceModel is disconnected from the input policy, thus any
additional changes in the policy will have no effect on the PolicySourceModel.
LOGGER.entering(policy);
PolicySourceModel model = null;
if (policy == null) {
LOGGER.fine(LocalizationMessages.WSP_0047_POLICY_IS_NULL_RETURNING());
} else {
model = PolicySourceModel.createPolicySourceModel(policy.getId(), policy.getName());
final ModelNode rootNode = model.getRootNode();
final ModelNode exactlyOneNode = rootNode.createChildExactlyOneNode();
for (AssertionSet set : policy) {
final ModelNode alternativeNode = exactlyOneNode.createChildAllNode();
for (PolicyAssertion assertion : set) {
final AssertionData data = AssertionData.createAssertionData(assertion.getName(), assertion.getValue(), assertion.getAttributes());
final ModelNode assertionNode = alternativeNode.createChildAssertionNode(data);
if (assertion.hasNestedPolicy()) {
translate(assertionNode, assertion.getNestedPolicy());
}
if (assertion.hasNestedAssertions()) {
translate(assertion.getNestedAssertionsIterator(), assertionNode);
}
}
}
}
LOGGER.exiting(model);
return model;
| private ModelNode | translate(ModelNode parentAssertion, com.sun.xml.ws.policy.NestedPolicy policy)Iterates through a nested policy and return the corresponding policy info model.
final ModelNode nestedPolicyRoot = parentAssertion.createChildPolicyNode();
final ModelNode exactlyOneNode = nestedPolicyRoot.createChildExactlyOneNode();
final AssertionSet set = policy.getAssertionSet();
final ModelNode alternativeNode = exactlyOneNode.createChildAllNode();
for (PolicyAssertion assertion : set) {
final AssertionData data = AssertionData.createAssertionData(assertion.getName(), assertion.getValue(), assertion.getAttributes());
final ModelNode assertionNode = alternativeNode.createChildAssertionNode(data);
if (assertion.hasNestedPolicy()) {
translate(assertionNode, assertion.getNestedPolicy());
}
if (assertion.hasNestedAssertions()) {
translate(assertion.getNestedAssertionsIterator(), assertionNode);
}
}
return nestedPolicyRoot;
| private void | translate(java.util.Iterator assertionParametersIterator, ModelNode assertionNode)Iterates through all contained assertions and adds them to the info model.
while (assertionParametersIterator.hasNext()) {
final PolicyAssertion assertionParameter = assertionParametersIterator.next();
final AssertionData data = AssertionData.createAssertionParameterData(assertionParameter.getName(), assertionParameter.getValue(), assertionParameter.getAttributes());
final ModelNode assertionParameterNode = assertionNode.createChildAssertionParameterNode(data);
if (assertionParameter.hasNestedPolicy()) {
throw LOGGER.logSevereException(new IllegalStateException(LocalizationMessages.WSP_0005_UNEXPECTED_POLICY_ELEMENT_FOUND_IN_ASSERTION_PARAM(assertionParameter)));
}
if (assertionParameter.hasNestedAssertions()) {
translate(assertionParameter.getNestedAssertionsIterator(), assertionParameterNode);
}
}
|
|