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 */ 25 26 package com.sun.xml.internal.ws.api.policy; 27 28 import com.sun.xml.internal.ws.addressing.policy.AddressingPrefixMapper; 29 import com.sun.xml.internal.ws.config.management.policy.ManagementPrefixMapper; 30 import com.sun.xml.internal.ws.encoding.policy.EncodingPrefixMapper; 31 import com.sun.xml.internal.ws.policy.sourcemodel.PolicySourceModel; 32 import com.sun.xml.internal.ws.policy.sourcemodel.wspolicy.NamespaceVersion; 33 import com.sun.xml.internal.ws.policy.spi.PrefixMapper; 34 35 import java.util.Arrays; 36 37 /** 38 * This class is a root of unmarshalled policy source structure. Each instance of 39 * the class contains factory method to create new com.sun.xml.internal.ws.policy.sourcemodel.ModelNode 40 * instances associated with the actual model instance. 41 * 42 * @author Fabian Ritzmann 43 */ 44 public class SourceModel extends PolicySourceModel { 45 46 private static final PrefixMapper[] JAXWS_PREFIX_MAPPERS = { 47 new AddressingPrefixMapper(), 48 new EncodingPrefixMapper(), 49 new ManagementPrefixMapper() 50 }; 51 52 53 /** 54 * Private constructor that creates a new policy source model instance without any 55 * id or name identifier. The namespace-to-prefix map is initialized with mapping 56 * of policy namespace to the default value set by 57 * {@link PolicyConstants#POLICY_NAMESPACE_PREFIX POLICY_NAMESPACE_PREFIX constant}. 58 * 59 * @param nsVersion The WS-Policy version. 60 */ 61 private SourceModel(NamespaceVersion nsVersion) { 62 this(nsVersion, null, null); 63 } 64 65 /** 66 * Private constructor that creates a new policy source model instance with given 67 * id or name identifier and a set of PrefixMappers. 68 * 69 * @param nsVersion The WS-Policy version. 70 * @param policyId Relative policy reference within an XML document. May be {@code null}. 71 * @param policyName Absolute IRI of policy expression. May be {@code null}. 72 */ 73 private SourceModel(NamespaceVersion nsVersion, String policyId, String policyName) { 74 super(nsVersion, policyId, policyName, Arrays.asList(JAXWS_PREFIX_MAPPERS)); 75 } 76 77 /** 78 * Factory method that creates new policy source model instance. 79 * 80 * @param nsVersion The policy version 81 * @return Newly created policy source model instance. 82 */ 83 public static PolicySourceModel createSourceModel(final NamespaceVersion nsVersion) { 84 return new SourceModel(nsVersion); 85 } 86 87 /** 88 * Factory method that creates new policy source model instance and initializes it according to parameters provided. 89 * 90 * @param nsVersion The policy version 91 * @param policyId local policy identifier - relative URI. May be {@code null}. 92 * @param policyName global policy identifier - absolute policy expression URI. May be {@code null}. 93 * @return Newly created policy source model instance with its name and id properly set. 94 */ 95 public static PolicySourceModel createSourceModel(final NamespaceVersion nsVersion, 96 final String policyId, final String policyName) { 97 return new SourceModel(nsVersion, policyId, policyName); 98 } 99 100 }