/** * Converts given input stream expecting XML inside to {@link GridUriDeploymentSpringDocument}. * * <p>This is a workaround for the {@link InputStreamResource} which does not work properly. * * @param in Input stream with XML. * @param log Logger * @return Grid wrapper for the input stream. * @throws GridSpiException Thrown if incoming input stream could not be read or parsed by {@code * Spring} {@link XmlBeanFactory}. * @see XmlBeanFactory */ static GridUriDeploymentSpringDocument parseTasksDocument(InputStream in, GridLogger log) throws GridSpiException { assert in != null; // Note: use ByteArrayResource instead of InputStreamResource because InputStreamResource // doesn't work. ByteArrayOutputStream out = new ByteArrayOutputStream(); try { U.copy(in, out); XmlBeanFactory factory = new XmlBeanFactory(new ByteArrayResource(out.toByteArray())); return new GridUriDeploymentSpringDocument(factory); } catch (BeansException e) { throw new GridSpiException("Failed to parse spring XML file.", e); } catch (IOException e) { throw new GridSpiException("Failed to parse spring XML file.", e); } finally { U.close(out, log); } }