All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.lsn.java.common.soap.factory.AbstractFactory Maven / Gradle / Ivy

package io.lsn.java.common.soap.factory;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;

/**
 * @author Patryk Szlagowski 
 */
public abstract class AbstractFactory {

    protected Environment env;
    protected T instance;

    @Autowired
    public void setEnv(Environment env) {
        this.env = env;
    }

    public URL getWsdlUrl(String wsdlLocation) throws MalformedURLException {
        URL wsdlUrl = new File(wsdlLocation).toURI().toURL();
        if (this.env.acceptsProfiles("dev")) {
            wsdlUrl = this.getClass().getResource(wsdlLocation);
        }
        if (wsdlUrl == null || wsdlUrl.getFile() == null) {
            throw new MalformedURLException("wsdl "+wsdlLocation+" is unreachable");
        }
        return wsdlUrl;
    }

    /**
     * @TODO override this method
     * @return
     */
    public T getInstance() throws Exception {
        return null;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy