< prev index next >

src/java.xml.ws/share/classes/com/sun/xml/internal/ws/assembler/MetroConfigLoader.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 39,48 **** --- 39,49 ---- import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBElement; import javax.xml.bind.Unmarshaller; import javax.xml.stream.XMLInputFactory; import javax.xml.ws.WebServiceException; + import java.io.InputStream; import java.lang.reflect.Method; import java.net.MalformedURLException; import java.net.URI; import java.net.URISyntaxException; import java.net.URL;
*** 120,132 **** if (defaultFileName == null) { defaultFileName = defaultTubesConfigNames.getDefaultFileName(); } this.defaultConfigUrl = locateResource(defaultFileName, loaders); ! if (defaultConfigUrl == null) { ! throw LOGGER.logSevereException(new IllegalStateException(TubelineassemblyMessages.MASM_0001_DEFAULT_CFG_FILE_NOT_FOUND(defaultFileName))); ! } LOGGER.config(TubelineassemblyMessages.MASM_0002_DEFAULT_CFG_FILE_LOCATED(defaultFileName, defaultConfigUrl)); this.defaultConfig = MetroConfigLoader.loadMetroConfig(defaultConfigUrl); if (defaultConfig == null) { throw LOGGER.logSevereException(new IllegalStateException(TubelineassemblyMessages.MASM_0003_DEFAULT_CFG_FILE_NOT_LOADED(defaultFileName))); --- 121,135 ---- if (defaultFileName == null) { defaultFileName = defaultTubesConfigNames.getDefaultFileName(); } this.defaultConfigUrl = locateResource(defaultFileName, loaders); ! ! // TODO-Miran: revisit ! // if (defaultConfigUrl == null) { ! // throw LOGGER.logSevereException(new IllegalStateException(TubelineassemblyMessages.MASM_0001_DEFAULT_CFG_FILE_NOT_FOUND(defaultFileName))); ! // } LOGGER.config(TubelineassemblyMessages.MASM_0002_DEFAULT_CFG_FILE_LOCATED(defaultFileName, defaultConfigUrl)); this.defaultConfig = MetroConfigLoader.loadMetroConfig(defaultConfigUrl); if (defaultConfig == null) { throw LOGGER.logSevereException(new IllegalStateException(TubelineassemblyMessages.MASM_0003_DEFAULT_CFG_FILE_NOT_LOADED(defaultFileName)));
*** 233,253 **** } return null; } private static MetroConfig loadMetroConfig(@NotNull URL resourceUrl) { - MetroConfig result = null; try { JAXBContext jaxbContext = createJAXBContext(); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); XMLInputFactory factory = XmlUtil.newXMLInputFactory(true); ! final JAXBElement<MetroConfig> configElement = unmarshaller.unmarshal(factory.createXMLStreamReader(resourceUrl.openStream()), MetroConfig.class); ! result = configElement.getValue(); } catch (Exception e) { ! LOGGER.warning(TubelineassemblyMessages.MASM_0010_ERROR_READING_CFG_FILE_FROM_LOCATION(resourceUrl.toString()), e); } - return result; } private static JAXBContext createJAXBContext() throws Exception { if (isJDKInternal()) { // since jdk classes are repackaged, extra privilege is necessary to create JAXBContext --- 236,266 ---- } return null; } private static MetroConfig loadMetroConfig(@NotNull URL resourceUrl) { try { JAXBContext jaxbContext = createJAXBContext(); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); XMLInputFactory factory = XmlUtil.newXMLInputFactory(true); ! ! InputStream is; ! if (resourceUrl != null) { ! is = resourceUrl.openStream(); ! } else { ! is = MetroConfig.class.getResourceAsStream("jaxws-tubes-default.xml"); ! } ! JAXBElement<MetroConfig> configElement = unmarshaller.unmarshal(factory.createXMLStreamReader(is), MetroConfig.class); ! ! return configElement.getValue(); } catch (Exception e) { ! InternalError error = new InternalError( ! TubelineassemblyMessages.MASM_0010_ERROR_READING_CFG_FILE_FROM_LOCATION(resourceUrl != null ? resourceUrl.toString() : null) ! ); ! LOGGER.logException(error, e, Level.SEVERE); ! throw error; } } private static JAXBContext createJAXBContext() throws Exception { if (isJDKInternal()) { // since jdk classes are repackaged, extra privilege is necessary to create JAXBContext
< prev index next >