Thu, 12 Oct 2017 19:44:07 +0800
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.sourcemodel;
28 import java.util.Collection;
29 import com.sun.xml.internal.ws.policy.PolicyException;
31 /**
32 * Abstract class defines interface for policy model marshaller implementations that are specific to underlying
33 * persistence layer.
34 *
35 * @author Marek Potociar
36 */
37 public abstract class PolicyModelMarshaller {
38 private static final PolicyModelMarshaller defaultXmlMarshaller = new XmlPolicyModelMarshaller(false);
39 private static final PolicyModelMarshaller invisibleAssertionXmlMarshaller = new XmlPolicyModelMarshaller(true);
41 /**
42 * Default constructor to ensure we have a common model marshaller base, but only our API classes implemented in this
43 * package will be able to extend this abstract class. This is to restrict attempts of extending the class from
44 * a client code.
45 */
46 PolicyModelMarshaller() {
47 // nothing to instantiate
48 }
50 /**
51 * Marshalls the policy source model using provided storage reference
52 *
53 * @param model policy source model to be marshalled
54 * @param storage reference to underlying storage that should be used for model marshalling
55 * @throws PolicyException If marshalling failed
56 */
57 public abstract void marshal(PolicySourceModel model, Object storage) throws PolicyException;
59 /**
60 * Marshalls the collection of policy source models using provided storage reference
61 *
62 * @param models collection of policy source models to be marshalled
63 * @param storage reference to underlying storage that should be used for model marshalling
64 * @throws PolicyException If marshalling failed
65 */
66 public abstract void marshal(Collection<PolicySourceModel> models, Object storage) throws PolicyException;
68 /**
69 * Factory methods that returns a marshaller instance based on input parameter.
70 *
71 * @param marshallInvisible boolean parameter indicating whether the marshaller
72 * returned by this method does marshall private assertions or not.
73 *
74 * @return policy model marshaller that either marshalls private assertions or not
75 * based on the input argument.
76 */
77 public static PolicyModelMarshaller getXmlMarshaller(final boolean marshallInvisible) {
78 return (marshallInvisible) ? invisibleAssertionXmlMarshaller : defaultXmlMarshaller;
79 }
80 }