<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="es">
		<id>https://dosideas.com/wiki/index.php?action=history&amp;feed=atom&amp;title=Axis2ServiceDeployer</id>
		<title>Axis2ServiceDeployer - Historial de revisiones</title>
		<link rel="self" type="application/atom+xml" href="https://dosideas.com/wiki/index.php?action=history&amp;feed=atom&amp;title=Axis2ServiceDeployer"/>
		<link rel="alternate" type="text/html" href="https://dosideas.com/wiki/index.php?title=Axis2ServiceDeployer&amp;action=history"/>
		<updated>2026-05-20T16:46:51Z</updated>
		<subtitle>Historial de revisiones para esta página en el wiki</subtitle>
		<generator>MediaWiki 1.28.2</generator>

	<entry>
		<id>https://dosideas.com/wiki/index.php?title=Axis2ServiceDeployer&amp;diff=4585&amp;oldid=prev</id>
		<title>Esteban: Axis2ServiceDeployer</title>
		<link rel="alternate" type="text/html" href="https://dosideas.com/wiki/index.php?title=Axis2ServiceDeployer&amp;diff=4585&amp;oldid=prev"/>
				<updated>2010-02-08T13:15:31Z</updated>
		
		<summary type="html">&lt;p&gt;Axis2ServiceDeployer&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Página nueva&lt;/b&gt;&lt;/p&gt;&lt;div&gt;    package com.dosideas.spring;&lt;br /&gt;
    &lt;br /&gt;
    import java.io.ByteArrayOutputStream;&lt;br /&gt;
    import java.io.File;&lt;br /&gt;
    import java.io.FileNotFoundException;&lt;br /&gt;
    import java.io.FileOutputStream;&lt;br /&gt;
    import java.io.IOException;&lt;br /&gt;
    import java.io.InputStream;&lt;br /&gt;
    import org.springframework.beans.BeansException;&lt;br /&gt;
    import org.springframework.beans.factory.InitializingBean;&lt;br /&gt;
    import org.springframework.context.ApplicationContext;&lt;br /&gt;
    import org.springframework.context.ApplicationContextAware;&lt;br /&gt;
    import org.springframework.web.context.WebApplicationContext;&lt;br /&gt;
    &lt;br /&gt;
    /**&lt;br /&gt;
     *&lt;br /&gt;
     * @author ejgarcia&lt;br /&gt;
     */&lt;br /&gt;
    public class Axis2ServiceDeployer implements InitializingBean, ApplicationContextAware {&lt;br /&gt;
        /** Carpeta donde se van a desplegar los servicios. &lt;br /&gt;
         * Debe coincidir la propiedad axis2.repository.path, declarada como&lt;br /&gt;
         * init-param en la definición del AxisServlet en el archivo web.xml&lt;br /&gt;
         */ &lt;br /&gt;
        protected String servicesDeploymentFolder = null;&lt;br /&gt;
        /** Nombre del servicio. El nombre debe coincidir con el wsdl */&lt;br /&gt;
        protected String serviceName = null;&lt;br /&gt;
        private WebApplicationContext ctx;&lt;br /&gt;
        &lt;br /&gt;
        public String getServiceName() {&lt;br /&gt;
            return serviceName;&lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
        public void setServiceName(String serviceName) {&lt;br /&gt;
            this.serviceName = serviceName;&lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
        public String getServicesDeploymentFolder() {&lt;br /&gt;
            return servicesDeploymentFolder;&lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
        public void setServicesDeploymentFolder(String servicesDeploymentFolder) {&lt;br /&gt;
            this.servicesDeploymentFolder = servicesDeploymentFolder;&lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
        public void afterPropertiesSet() {&lt;br /&gt;
            /** creo la estructura de directorios default */&lt;br /&gt;
            File servicesDeploymentFolderFile = new File(servicesDeploymentFolder);&lt;br /&gt;
            servicesDeploymentFolderFile.mkdirs();&lt;br /&gt;
            &lt;br /&gt;
            File serviceFolderFile = &lt;br /&gt;
                new File(servicesDeploymentFolderFile, &amp;quot;services&amp;quot; + &lt;br /&gt;
                    File.separator + serviceName + File.separator + &amp;quot;META-INF&amp;quot;);&lt;br /&gt;
            serviceFolderFile.mkdirs();&lt;br /&gt;
            &lt;br /&gt;
            /** Copio los recursos al directorio */&lt;br /&gt;
            String serviceFileResourcePath = &amp;quot;services/&amp;quot; + serviceName + &amp;quot;/META-INF/services.xml&amp;quot;;&lt;br /&gt;
            String serviceWsdlResourcePath = &amp;quot;services/&amp;quot; + serviceName + &amp;quot;/META-INF/&amp;quot; + serviceName + &amp;quot;.wsdl&amp;quot;;&lt;br /&gt;
            &lt;br /&gt;
            String serviceFileClassPath = &amp;quot;/WEB-INF/&amp;quot; + serviceFileResourcePath;&lt;br /&gt;
            String serviceWsdlClassPath = &amp;quot;/WEB-INF/&amp;quot; + serviceWsdlResourcePath;&lt;br /&gt;
            //ClassLoader cl = this.getClass().getClassLoader();&lt;br /&gt;
            InputStream serviceIn = ctx.getServletContext().getResourceAsStream(serviceFileClassPath);&lt;br /&gt;
            InputStream wsdlIn = ctx.getServletContext().getResourceAsStream(serviceWsdlClassPath);&lt;br /&gt;
            System.err.println(&amp;quot;Recurso 2: &amp;quot; + serviceFileClassPath + &amp;quot; : &amp;quot; + serviceIn);&lt;br /&gt;
            System.err.println(&amp;quot;Recurso 2: &amp;quot; + serviceWsdlClassPath + &amp;quot; : &amp;quot; + wsdlIn);&lt;br /&gt;
            copyInputStreamToFile(serviceIn, new File(servicesDeploymentFolderFile, serviceFileResourcePath));&lt;br /&gt;
            copyInputStreamToFile(wsdlIn, new File(servicesDeploymentFolderFile, serviceWsdlResourcePath));&lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
        private void copyInputStreamToFile(InputStream in, File file) {&lt;br /&gt;
            if (in == null){System.err.println(&amp;quot;No se pudo encontrar... &amp;quot;); return;}&lt;br /&gt;
            FileOutputStream outToFile = null;&lt;br /&gt;
            ByteArrayOutputStream out = null;&lt;br /&gt;
            try {&lt;br /&gt;
                byte[] buffer = new byte[10000];&lt;br /&gt;
                out = new ByteArrayOutputStream();&lt;br /&gt;
                outToFile = new FileOutputStream(file);&lt;br /&gt;
                //int counter = 0;&lt;br /&gt;
                int bytesRead = 0;&lt;br /&gt;
                while ((bytesRead = in.read(buffer, 0, buffer.length)) &amp;gt; 0) {&lt;br /&gt;
                    System.err.println(&amp;quot;bytes leidos: &amp;quot; + bytesRead);&lt;br /&gt;
                    out.write(buffer, 0, bytesRead);&lt;br /&gt;
                    //counter += bytesRead;&lt;br /&gt;
                    //if (bytesRead &amp;lt; buffer.length) break;&lt;br /&gt;
                }&lt;br /&gt;
                out.writeTo(outToFile);&lt;br /&gt;
                &lt;br /&gt;
                in.close();&lt;br /&gt;
                out.close();&lt;br /&gt;
                outToFile.close();&lt;br /&gt;
            } catch (FileNotFoundException ex) {&lt;br /&gt;
                ex.printStackTrace();&lt;br /&gt;
            } catch (IOException ex) {&lt;br /&gt;
                ex.printStackTrace();&lt;br /&gt;
            } finally {&lt;br /&gt;
                try {&lt;br /&gt;
                    if (in != null) in.close();&lt;br /&gt;
                    if (outToFile != null) outToFile.close();&lt;br /&gt;
                    if (out != null) out.close();&lt;br /&gt;
                } catch (IOException ex) {&lt;br /&gt;
                    ex.printStackTrace();&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        &lt;br /&gt;
        public void setApplicationContext(ApplicationContext arg0) throws BeansException {&lt;br /&gt;
            this.ctx = (WebApplicationContext)arg0;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;/div&gt;</summary>
		<author><name>Esteban</name></author>	</entry>

	</feed>