51 * </UL> 52 * In some cases, specialized MessageFactory objects may be obtained that produce messages 53 * prepopulated with additional entries in the {@code SOAPHeader} object and the 54 * {@code SOAPBody} object. 55 * The content of a new {@code SOAPMessage} object depends on which of the two 56 * {@code MessageFactory} methods is used to create it. 57 * <UL> 58 * <LI>{@code createMessage()} <BR> 59 * This is the method clients would normally use to create a request message. 60 * <LI>{@code createMessage(MimeHeaders, java.io.InputStream)} -- message has 61 * content from the {@code InputStream} object and headers from the 62 * {@code MimeHeaders} object <BR> 63 * This method can be used internally by a service implementation to 64 * create a message that is a response to a request. 65 * </UL> 66 * 67 * @since 1.6 68 */ 69 public abstract class MessageFactory { 70 71 static final String DEFAULT_MESSAGE_FACTORY 72 = "com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl"; 73 74 static private final String MESSAGE_FACTORY_PROPERTY 75 = "javax.xml.soap.MessageFactory"; 76 77 /** 78 * Creates a new {@code MessageFactory} object that is an instance 79 * of the default implementation (SOAP 1.1), 80 * 81 * This method uses the following ordered lookup procedure to determine the MessageFactory implementation class to load: 82 * <UL> 83 * <LI> Use the javax.xml.soap.MessageFactory system property. 84 * <LI> Use the properties file "lib/jaxm.properties" in the JRE directory. This configuration file is in standard 85 * java.util.Properties format and contains the fully qualified name of the implementation class with the key being the 86 * system property defined above. 87 * <LI> Use the Services API (as detailed in the JAR specification), if available, to determine the classname. The Services API 88 * will look for a classname in the file META-INF/services/javax.xml.soap.MessageFactory in jars available to the runtime. 89 * <LI> Use the SAAJMetaFactory instance to locate the MessageFactory implementation class. 90 * </UL> 91 92 * 93 * @return a new instance of a {@code MessageFactory} 94 * 95 * @exception SOAPException if there was an error in creating the 96 * default implementation of the 97 * {@code MessageFactory}. 98 * @see SAAJMetaFactory 99 */ 100 101 public static MessageFactory newInstance() throws SOAPException { 102 103 104 try { 105 MessageFactory factory = (MessageFactory) FactoryFinder.find( 106 MESSAGE_FACTORY_PROPERTY, 107 DEFAULT_MESSAGE_FACTORY, 108 false); 109 110 if (factory != null) { 111 return factory; 112 } 113 return newInstance(SOAPConstants.SOAP_1_1_PROTOCOL); 114 115 } catch (Exception ex) { 116 throw new SOAPException( 117 "Unable to create message factory for SOAP: " 118 +ex.getMessage()); 119 } 120 121 } 122 123 /** 124 * Creates a new {@code MessageFactory} object that is an instance 125 * of the specified implementation. May be a dynamic message factory, 126 * a SOAP 1.1 message factory, or a SOAP 1.2 message factory. A dynamic | 51 * </UL> 52 * In some cases, specialized MessageFactory objects may be obtained that produce messages 53 * prepopulated with additional entries in the {@code SOAPHeader} object and the 54 * {@code SOAPBody} object. 55 * The content of a new {@code SOAPMessage} object depends on which of the two 56 * {@code MessageFactory} methods is used to create it. 57 * <UL> 58 * <LI>{@code createMessage()} <BR> 59 * This is the method clients would normally use to create a request message. 60 * <LI>{@code createMessage(MimeHeaders, java.io.InputStream)} -- message has 61 * content from the {@code InputStream} object and headers from the 62 * {@code MimeHeaders} object <BR> 63 * This method can be used internally by a service implementation to 64 * create a message that is a response to a request. 65 * </UL> 66 * 67 * @since 1.6 68 */ 69 public abstract class MessageFactory { 70 71 private static final String DEFAULT_MESSAGE_FACTORY 72 = "com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl"; 73 74 /** 75 * Creates a new {@code MessageFactory} object that is an instance 76 * of the default implementation (SOAP 1.1). 77 * 78 * This method uses the lookup procedure specified in {@link javax.xml.soap} to locate and load the 79 * {@link javax.xml.soap.MessageFactory} class. 80 * 81 * @return a new instance of a {@code MessageFactory} 82 * 83 * @exception SOAPException if there was an error in creating the 84 * default implementation of the 85 * {@code MessageFactory}. 86 * @see SAAJMetaFactory 87 */ 88 89 public static MessageFactory newInstance() throws SOAPException { 90 91 92 try { 93 MessageFactory factory = (MessageFactory) FactoryFinder.find( 94 MessageFactory.class, 95 DEFAULT_MESSAGE_FACTORY, 96 false); 97 98 if (factory != null) { 99 return factory; 100 } 101 return newInstance(SOAPConstants.SOAP_1_1_PROTOCOL); 102 103 } catch (Exception ex) { 104 throw new SOAPException( 105 "Unable to create message factory for SOAP: " 106 +ex.getMessage()); 107 } 108 109 } 110 111 /** 112 * Creates a new {@code MessageFactory} object that is an instance 113 * of the specified implementation. May be a dynamic message factory, 114 * a SOAP 1.1 message factory, or a SOAP 1.2 message factory. A dynamic |