PROXY  WHOIS  RQUOTE  TEXTS  SOFT  FOREX  BBOARD
 Music  Philosophy  Code  Literature  Russian

= ROOT|Technical|Code_Examples|Java|javax|xml|soap|MessageFactory.java =

page 1 of 2



/*
 * $Id: MessageFactory.java,v 1.9 2004/04/02 01:24:17 ofung Exp $
 * $Revision: 1.9 $
 * $Date: 2004/04/02 01:24:17 $
 */

/*
 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
 * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
package javax.xml.soap;


import java.io.IOException;
import java.io.InputStream;

/**
 * A factory for creating <code>SOAPMessage</code> objects.
 * <P>
 * A SAAJ client can create a <code>MessageFactory</code> object
 * using the method <code>newInstance</code>, as shown in the following
 * lines of code.
 * <PRE>
 *       MessageFactory mf = MessageFactory.newInstance();
 *       MessageFactory mf12 = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
 * </PRE>
 * <P>
 * All <code>MessageFactory</code> objects, regardless of how they are
 * created, will produce <code>SOAPMessage</code> objects that
 * have the following elements by default:
 * <UL>
 *  <LI>A <code>SOAPPart</code> object
 *  <LI>A <code>SOAPEnvelope</code> object
 *  <LI>A <code>SOAPBody</code> object
 *  <LI>A <code>SOAPHeader</code> object
 * </UL>
 * In some cases, specialized MessageFactory objects may be obtained that produce messages 
 * prepopulated with additional entries in the <code>SOAPHeader</code> object and the  
 * <code>SOAPBody</code> object. 
 * The content of a new <code>SOAPMessage</code> object depends on which of the two
 * <code>MessageFactory</code> methods is used to create it.
 * <UL>
 *  <LI><code>createMessage()</code> <BR>
 *      This is the method clients would normally use to create a request message.
 *  <LI><code>createMessage(MimeHeaders, java.io.InputStream)</code> -- message has
 *       content from the <code>InputStream</code> object and headers from the
 *       <code>MimeHeaders</code> object <BR>
 *        This method can be used internally by a service implementation to
 *        create a message that is a response to a request.
 * </UL>
 */
public abstract class MessageFactory {

    static private final String DEFAULT_MESSAGE_FACTORY
        = "com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl";

    static private final String MESSAGE_FACTORY_PROPERTY
        = "javax.xml.soap.MessageFactory";

    /**
     * Creates a new <code>MessageFactory</code> object that is an instance
     * of the default implementation (SOAP 1.1),
     *
     * This method uses the following ordered lookup procedure to determine the MessageFactory implementation class to load:

     * <UL>
     *  <LI> Use the javax.xml.soap.MessageFactory system property.
     *  <LI> Use the properties file "lib/jaxm.properties" in the JRE directory. This configuration file is in standard

     * java.util.Properties format and contains the fully qualified name of the implementation class with the key being the

     * system property defined above.
     *  <LI> Use the Services API (as detailed in the JAR specification), if available, to determine the classname. The 
Services API
     * will look for a classname in the file META-INF/services/javax.xml.soap.MessageFactory in jars available to the 
runtime.
     *  <LI> Use the SAAJMetaFactory instance to locate the MessageFactory implementation class.
     * </UL>

     *
     * @return a new instance of a <code>MessageFactory</code>
     *
     * @exception SOAPException if there was an error in creating the
     *            default implementation of the
     *            <code>MessageFactory</code>.
     * @see SAAJMetaFactory
     */
     
    public static MessageFactory newInstance()
        throws SOAPException {
        try {
            MessageFactory factory = (MessageFactory)
                FactoryFinder.find(MESSAGE_FACTORY_PROPERTY);

            if (factory != null)
                return factory;

            return newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
        } catch (Exception ex) {
            throw new SOAPException(
                    "Unable to create message factory for SOAP: "
                                    +ex.getMessage());
        }

    }
=1=

= PAGE 1 = NEXT > |2

UP TO ROOT | UP TO DIR

Google
 


E-mail Facebook Google Digg del.icio.us BlinkList Fark Furl Ma.gnolia Netscape NewsVine Reddit Slashdot Spurl StumbleUpon Technorati YahooMyWeb LiveJournal Blogmarks TwitThis Live News2.ru BobrDobr.ru Memori.ru MoeMesto.ru

2.51084 wallclock secs ( 0.00 usr + 0.00 sys = 0.00 CPU)