1 /* |
1 /* |
2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
81 private static final QName POLICY_ATTACHMENT = new QName("http://www.w3.org/ns/ws-policy", "PolicyAttachment"); |
81 private static final QName POLICY_ATTACHMENT = new QName("http://www.w3.org/ns/ws-policy", "PolicyAttachment"); |
82 private static final QName APPLIES_TO = new QName("http://www.w3.org/ns/ws-policy", "AppliesTo"); |
82 private static final QName APPLIES_TO = new QName("http://www.w3.org/ns/ws-policy", "AppliesTo"); |
83 private static final QName POLICY = new QName("http://www.w3.org/ns/ws-policy", "Policy"); |
83 private static final QName POLICY = new QName("http://www.w3.org/ns/ws-policy", "Policy"); |
84 private static final QName URI = new QName("http://www.w3.org/ns/ws-policy", "URI"); |
84 private static final QName URI = new QName("http://www.w3.org/ns/ws-policy", "URI"); |
85 private static final QName POLICIES = new QName(PolicyConstants.SUN_MANAGEMENT_NAMESPACE, "Policies"); |
85 private static final QName POLICIES = new QName(PolicyConstants.SUN_MANAGEMENT_NAMESPACE, "Policies"); |
86 private static final XMLInputFactory XML_INPUT_FACTORY = XMLInputFactory.newInstance(); |
86 private static final ContextClassloaderLocal<XMLInputFactory> XML_INPUT_FACTORY = new ContextClassloaderLocal<XMLInputFactory>() { |
|
87 @Override |
|
88 protected XMLInputFactory initialValue() throws Exception { |
|
89 return XMLInputFactory.newInstance(); |
|
90 } |
|
91 }; |
|
92 |
87 private static final PolicyModelUnmarshaller POLICY_UNMARSHALLER = PolicyModelUnmarshaller.getXmlUnmarshaller(); |
93 private static final PolicyModelUnmarshaller POLICY_UNMARSHALLER = PolicyModelUnmarshaller.getXmlUnmarshaller(); |
88 |
94 |
89 private final Map<URI, Policy> map = new HashMap<URI, Policy>(); |
95 private final Map<URI, Policy> map = new HashMap<URI, Policy>(); |
90 private URI currentUri = null; |
96 private URI currentUri = null; |
91 private Policy currentPolicy = null; |
97 private Policy currentPolicy = null; |
92 |
98 |
93 public static Map<URI, Policy> unmarshal(final Reader source) throws PolicyException { |
99 public static Map<URI, Policy> unmarshal(final Reader source) throws PolicyException { |
94 LOGGER.entering(source); |
100 LOGGER.entering(source); |
95 try { |
101 try { |
96 XMLEventReader reader = XML_INPUT_FACTORY.createXMLEventReader(source); |
102 XMLEventReader reader = XML_INPUT_FACTORY.get().createXMLEventReader(source); |
97 ExternalAttachmentsUnmarshaller instance = new ExternalAttachmentsUnmarshaller(); |
103 ExternalAttachmentsUnmarshaller instance = new ExternalAttachmentsUnmarshaller(); |
98 final Map<URI, Policy> map = instance.unmarshal(reader, null); |
104 final Map<URI, Policy> map = instance.unmarshal(reader, null); |
99 LOGGER.exiting(map); |
105 LOGGER.exiting(map); |
100 return Collections.unmodifiableMap(map); |
106 return Collections.unmodifiableMap(map); |
101 } catch (XMLStreamException ex) { |
107 } catch (XMLStreamException ex) { |