axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Roshan Punnoose (JIRA)" <j...@apache.org>
Subject [jira] Created: (AXIS2-2240) InputStreamConfigurator
Date Thu, 22 Feb 2007 13:43:05 GMT
InputStreamConfigurator
-----------------------

                 Key: AXIS2-2240
                 URL: https://issues.apache.org/jira/browse/AXIS2-2240
             Project: Axis 2.0 (Axis2)
          Issue Type: Improvement
          Components: kernel
         Environment: Java 1.4.2
            Reporter: Roshan Punnoose
            Priority: Minor


> I've been also having problems with the FileBasedConfigurator that 
> looks for the axis2.xml file. Depending on where it is run, if it is 
> packed in a jar, I won't be able to use it. (Which isn't that great 
> for projects that depend on a project that actually does the Web 
> Service calls using AXIS) So I created an InputStreamConfigurator, 
> which is the exact same as the FileSystemConfigurator, except that it 
> uses the ClassLoader to load the axis2.xml. Is there already something 
> like this? And if not, is it something that would be helpful for you guys?


Below is the InputStreamConfigurator that I created, hope it helps:

package anything;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;

import org.apache.axis2.AxisFault;
import org.apache.axis2.Constants;
import org.apache.axis2.deployment.DeploymentConstants;
import org.apache.axis2.deployment.DeploymentEngine;
import org.apache.axis2.deployment.FileSystemConfigurator;
import org.apache.axis2.description.Parameter;
import org.apache.axis2.engine.AxisConfiguration;
import org.apache.axis2.engine.AxisConfigurator;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class InputStreamConfigurator extends DeploymentEngine implements
        AxisConfigurator {

    private static final Log log = LogFactory
            .getLog(InputStreamConfigurator.class);

    /**
     * To check whether need to create a service side or client side
     */
    private InputStream axis2xml = null;

    private String repoLocation = null;

    /**
     * Load an AxisConfiguration from the repository directory specified
     * 
     * @param repoLocation
     * @param axis2xml
     */
    public InputStreamConfigurator(String repoLocation, InputStream axis2xml) {
        if (repoLocation == null) {
            // checking wether user has set the system property
            repoLocation = System.getProperty(Constants.AXIS2_REPO);
        }

        // OK, we've got a repository location in mind. Let's make
        // sure it exists.
        try {
            if (repoLocation != null) {
                File repo = new File(repoLocation);
                if (repo.exists()) {
                    // ok, save it if so
                    this.repoLocation = repo.getAbsolutePath();
                }
            }
        } catch (Exception e) {
            log
                    .info("Couldn't find repository location '" + repoLocation
                            + "'");
            this.repoLocation = null;
        }

        // Deal with the config file. If a filename was specified as an
        // arg to this constructor, just respect it.
        if (axis2xml == null) {
            // If not, check for a system property setting
            // Get from the classloader if it exists
            axis2xml = Thread.currentThread().getContextClassLoader()
                    .getResourceAsStream(
                            System.getProperty(Constants.AXIS2_CONF));
        }

        this.axis2xml = axis2xml;
    }

    /**
     * First create a Deployment engine, use that to create an AxisConfiguration
     * 
     * @return Axis Configuration
     * @throws AxisFault
     */
    public synchronized AxisConfiguration getAxisConfiguration()
            throws AxisFault {
        InputStream axis2xmlSream;

        if (axis2xml != null && !"".equals(axis2xml)) {
            axis2xmlSream = axis2xml;
        } else {
            ClassLoader cl = Thread.currentThread().getContextClassLoader();
            axis2xmlSream = cl
                    .getResourceAsStream(DeploymentConstants.AXIS2_CONFIGURATION_RESOURCE);
        }

        if(axis2xmlSream == null) {throw new AxisFault("System can not find the given axis2.xml
" + axis2xml);}

        axisConfig = populateAxisConfiguration(axis2xmlSream);

        Parameter axis2repoPara = axisConfig
                .getParameter(DeploymentConstants.AXIS2_REPO);
        if (axis2repoPara != null)
            repoLocation = (String) axis2repoPara.getValue();
        if (!(repoLocation == null || "".equals(repoLocation))) {
            loadRepository(repoLocation);
        } else {
            loadFromClassPath();
        }
        return axisConfig;
    }

    public void engageGlobalModules() throws AxisFault {
        engageModules();
    }

    public void loadServices() {
        if (!(repoLocation == null || "".equals(repoLocation))) {
            super.loadServices();
        }
    }
}


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


Mime
View raw message