Added convenience constructor to DefaultStrategiesHelper
This commit is contained in:
@@ -27,12 +27,9 @@ import javax.xml.transform.TransformerConfigurationException;
|
||||
import javax.xml.transform.TransformerException;
|
||||
|
||||
import org.springframework.beans.factory.BeanInitializationException;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.oxm.Marshaller;
|
||||
import org.springframework.oxm.Unmarshaller;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.ws.FaultAwareWebServiceMessage;
|
||||
import org.springframework.ws.WebServiceMessage;
|
||||
@@ -297,9 +294,7 @@ public class WebServiceTemplate extends WebServiceAccessor implements WebService
|
||||
* @see #setMessageSender(WebServiceMessageSender)
|
||||
*/
|
||||
protected void initDefaultStrategies() {
|
||||
Resource resource = new ClassPathResource(ClassUtils.getShortName(WebServiceTemplate.class) + ".properties",
|
||||
WebServiceTemplate.class);
|
||||
DefaultStrategiesHelper strategiesHelper = new DefaultStrategiesHelper(resource);
|
||||
DefaultStrategiesHelper strategiesHelper = new DefaultStrategiesHelper(WebServiceTemplate.class);
|
||||
if (getMessageFactory() == null) {
|
||||
initMessageFactory(strategiesHelper);
|
||||
}
|
||||
|
||||
@@ -29,9 +29,6 @@ import org.springframework.beans.factory.BeanNameAware;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.core.OrderComparator;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.web.servlet.DispatcherServlet;
|
||||
import org.springframework.ws.FaultAwareWebServiceMessage;
|
||||
@@ -117,8 +114,7 @@ public class MessageDispatcher implements WebServiceMessageReceiver, BeanNameAwa
|
||||
|
||||
/** Initializes a new instance of the <code>MessageDispatcher</code>. */
|
||||
public MessageDispatcher() {
|
||||
Resource resource = new ClassPathResource(ClassUtils.getShortName(getClass()) + ".properties", getClass());
|
||||
defaultStrategiesHelper = new DefaultStrategiesHelper(resource);
|
||||
defaultStrategiesHelper = new DefaultStrategiesHelper(getClass());
|
||||
}
|
||||
|
||||
/** Returns the <code>EndpointAdapter</code>s to use by this <code>MessageDispatcher</code>. */
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.springframework.context.ApplicationEventPublisherAware;
|
||||
import org.springframework.context.MessageSourceAware;
|
||||
import org.springframework.context.ResourceLoaderAware;
|
||||
import org.springframework.core.OrderComparator;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.support.PropertiesLoaderUtils;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -78,6 +79,15 @@ public class DefaultStrategiesHelper {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes a new instance of the <code>DefaultStrategiesHelper</code> based on the given type.
|
||||
* <p/>
|
||||
* This constructor will attempt to load a 'typeName'.properties file in the same package as the given type.
|
||||
*/
|
||||
public DefaultStrategiesHelper(Class<?> type) {
|
||||
this(new ClassPathResource(ClassUtils.getShortName(type) + ".properties", type));
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a list of strategy objects for the given strategy interface. Strategies are retrieved from the
|
||||
* <code>Properties</code> object given at construction-time.
|
||||
|
||||
@@ -27,7 +27,6 @@ import org.springframework.beans.factory.BeanInitializationException;
|
||||
import org.springframework.beans.factory.BeanNameAware;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.web.servlet.DispatcherServlet;
|
||||
import org.springframework.web.servlet.FrameworkServlet;
|
||||
import org.springframework.web.util.WebUtils;
|
||||
@@ -84,12 +83,6 @@ public class MessageDispatcherServlet extends FrameworkServlet {
|
||||
/** Well-known name for the {@link XsdSchemaHandlerAdapter} object in the bean factory for this namespace. */
|
||||
public static final String DEFAULT_XSD_SCHEMA_HANDLER_ADAPTER_BEAN_NAME = "xsdSchemaHandlerAdapter";
|
||||
|
||||
/**
|
||||
* Name of the class path resource (relative to the {@link MessageDispatcherServlet} class) that defines
|
||||
* <code>MessageDispatcherServlet's</code> default strategy names.
|
||||
*/
|
||||
private static final String DEFAULT_STRATEGIES_PATH = "MessageDispatcherServlet.properties";
|
||||
|
||||
/** Suffix of a WSDL request uri. */
|
||||
private static final String WSDL_SUFFIX_NAME = ".wsdl";
|
||||
|
||||
@@ -129,8 +122,7 @@ public class MessageDispatcherServlet extends FrameworkServlet {
|
||||
|
||||
/** Public constructor, necessary for some Web application servers. */
|
||||
public MessageDispatcherServlet() {
|
||||
defaultStrategiesHelper = new DefaultStrategiesHelper(
|
||||
new ClassPathResource(DEFAULT_STRATEGIES_PATH, MessageDispatcherServlet.class));
|
||||
defaultStrategiesHelper = new DefaultStrategiesHelper(MessageDispatcherServlet.class);
|
||||
}
|
||||
|
||||
/** Returns the bean name used to lookup a {@link WebServiceMessageFactory}. */
|
||||
|
||||
Reference in New Issue
Block a user