src/share/jaxws_classes/com/sun/xml/internal/ws/policy/PolicyMapMutator.java

Thu, 12 Oct 2017 19:44:07 +0800

author
aoqi
date
Thu, 12 Oct 2017 19:44:07 +0800
changeset 760
e530533619ec
parent 0
373ffda63c9a
permissions
-rw-r--r--

merge

     1 /*
     2  * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     8  * particular file as subject to the "Classpath" exception as provided
     9  * by Oracle in the LICENSE file that accompanied this code.
    10  *
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    14  * version 2 for more details (a copy is included in the LICENSE file that
    15  * accompanied this code).
    16  *
    17  * You should have received a copy of the GNU General Public License version
    18  * 2 along with this work; if not, write to the Free Software Foundation,
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    20  *
    21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    22  * or visit www.oracle.com if you need additional information or have any
    23  * questions.
    24  */
    26 package com.sun.xml.internal.ws.policy;
    28 import com.sun.xml.internal.ws.policy.privateutil.LocalizationMessages;
    29 import com.sun.xml.internal.ws.policy.privateutil.PolicyLogger;
    31 /**
    32  * The class serves as a base for specific policy map mutator implementations. It provides common methods that allow
    33  * concrete mutator implementations to connect and disconnect to/from a policy map instance.
    34  *
    35  * @author Marek Potociar (marek.potociar@sun.com)
    36  */
    37 public abstract class PolicyMapMutator {
    39     private static final PolicyLogger LOGGER = PolicyLogger.getLogger(PolicyMapMutator.class);
    41     private PolicyMap map = null;
    43     /**
    44      * Creates a new instance of PolicyMapMutator. This class cannot be extended from outside of this package.
    45      */
    46     PolicyMapMutator() {
    47         // nothing to instantiate
    48     }
    50     /**
    51      * The method is used to connect the policy map mutator instance to the map it should mutate.
    52      *
    53      * @param map the policy map instance that will be mutable by this mutator.
    54      * @throws IllegalStateException in case this mutator object is already connected to a policy map.
    55      */
    56     public void connect(final PolicyMap map) {
    57         if (isConnected()) {
    58             throw LOGGER.logSevereException(new IllegalStateException(LocalizationMessages.WSP_0044_POLICY_MAP_MUTATOR_ALREADY_CONNECTED()));
    59         }
    61         this.map = map;
    62     }
    64     /**
    65      * Can be used to retrieve the policy map currently connected to this mutator. Will return {@code null} if not connected.
    66      *
    67      * @return policy map currently connected to this mutator. May return {@code null} if the mutator is not connected.
    68      *
    69      * @see #isConnected()
    70      * @see #disconnect()
    71      */
    72     public PolicyMap getMap() {
    73         return this.map;
    74     }
    76     /**
    77      * Disconnects the mutator from the policy map object it is connected to. Method must be called prior to connecting this
    78      * mutator instance to another policy map.
    79      * <p/>
    80      * This operation is irreversible: you cannot connect the mutator to the same policy map instance once you disconnect from it.
    81      * Multiple consequent calls of this method will have no effect.
    82      */
    83     public void disconnect() {
    84         this.map = null;
    85     }
    87     /**
    88      * This method provides connection status information of the policy map mutator instance.
    89      *
    90      * @return {@code true} if the mutator instance is connected to a policy map, otherwise returns {@code false}.
    91      */
    92     public boolean isConnected() {
    93         return this.map != null;
    94     }
    95 }

mercurial