FileDocCategorySizeDatePackage
PolicySubject.javaAPI DocExample7466Tue May 29 16:56:34 BST 2007com.sun.xml.ws.policy

PolicySubject

public final class PolicySubject extends Object
A PolicySubject is an entity (e.g., a port, operation, binding, service) with which a policy can be associated.

Fields Summary
private static final com.sun.xml.ws.policy.privateutil.PolicyLogger
LOGGER
private final List
policies
private final Object
subject
Constructors Summary
public PolicySubject(Object subject, Policy policy)
Constructs a policy subject instance.

param
subject object to which the policies are attached. Must not be {@code null}.
param
policy first policy attached to the subject. Must not be {@code null}.
throws
IllegalArgumentException in case any of the arguments is {@code null}.

    
                                                    
           
        if (subject == null || policy == null) {
            throw LOGGER.logSevereException(new IllegalArgumentException(LocalizationMessages.WSP_0021_SUBJECT_AND_POLICY_PARAM_MUST_NOT_BE_NULL(subject, policy)));
        }
        
        this.subject = subject;
        this.attach(policy);
    
public PolicySubject(Object subject, Collection policies)
Constructs a policy subject instance.

param
subject object to which the policies are attached. Must not be {@code null}.
param
policies first policy attached to the subject. Must not be {@code null}.
throws
IllegalArgumentException in case any of the arguments is {@code null} or in case {@code policies} argument represents empty collection.

        if (subject == null || policies == null) {
            throw LOGGER.logSevereException(new IllegalArgumentException(LocalizationMessages.WSP_0062_INPUT_PARAMS_MUST_NOT_BE_NULL()));
        }
        
        if (policies.isEmpty()) {
            throw LOGGER.logSevereException(new IllegalArgumentException(LocalizationMessages.WSP_0064_INITIAL_POLICY_COLLECTION_MUST_NOT_BE_EMPTY()));
        }
        
        this.subject = subject;
        this.policies.addAll(policies);
    
Methods Summary
public voidattach(Policy policy)
Attaches another Policy instance to the policy subject.

param
policy new policy instance to be attached to this subject
throws
IllegalArgumentException in case {@code policy} argument is {@code null}.

        if (policy == null) {
            throw LOGGER.logSevereException(new IllegalArgumentException(LocalizationMessages.WSP_0038_POLICY_TO_ATTACH_MUST_NOT_BE_NULL()));
        }
        this.policies.add(policy);
    
public PolicygetEffectivePolicy(PolicyMerger merger)
Returns the effective policy of the subject, i.e. all policies of the subject merged together.

return
effective policy of the subject

        return merger.merge(policies);
    
public PolicygetEffectivePolicy(java.util.Collection namespaces, PolicyMerger merger)
Retrieve only the assertions of the effective policy that match the given set of namespaces

        final LinkedList<Policy> reducedPolicies = new LinkedList<Policy>();
        for (Policy policy : policies) {
            // Policy reducedPolicy = policy.reduce(namespaces);
            // reducedPolicies.add(reducedPolicy);
        }
        return merger.merge(reducedPolicies);
    
public java.lang.ObjectgetSubject()
A unique identifier of the subject Subjects may not always be uniquely identifiable. Also, once the subject is assigned to a scope, its identity may not matter anymore. Therefore this may be null.

        return this.subject;
    
public java.lang.StringtoString()
An {@code Object.toString()} method override.

        return toString(0, new StringBuffer()).toString();
    
java.lang.StringBuffertoString(int indentLevel, java.lang.StringBuffer buffer)
A helper method that appends indented string representation of this instance to the input string buffer.

param
indentLevel indentation level to be used.
param
buffer buffer to be used for appending string representation of this instance
return
modified buffer containing new string representation of the instance

        final String indent = PolicyUtils.Text.createIndent(indentLevel);
        final String innerIndent = PolicyUtils.Text.createIndent(indentLevel + 1);
        
        buffer.append(indent).append("policy subject {").append(PolicyUtils.Text.NEW_LINE);
        buffer.append(innerIndent).append("subject = '").append(subject).append('\'").append(PolicyUtils.Text.NEW_LINE);
        for (Policy policy : policies) {
            policy.toString(indentLevel + 1, buffer).append(PolicyUtils.Text.NEW_LINE);
        }
        buffer.append(indent).append('}");
        
        return buffer;