/**
 * OW2 Specifications
 * Copyright (C) 2008 Bull S.A.S.
 * Contact: easybeans@ow2.org
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
 * USA
 *
 * --------------------------------------------------------------------------
 * $Id: EndpointReference.java 5417 2010-03-24 09:04:14Z benoitf $
 * --------------------------------------------------------------------------
 */

package javax.xml.ws;

import javax.xml.bind.annotation.XmlTransient;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamResult;
import javax.xml.ws.spi.Provider;
import java.io.StringWriter;

/**
 * Created by IntelliJ IDEA.
 * User: Guillaume
 * Date: 9 déc. 2008
 * Time: 22:39:12
 * To change this template use File | Settings | File Templates.
 */
@XmlTransient
public abstract class EndpointReference {

    protected EndpointReference() {}

    public static EndpointReference readFrom(Source eprInfoset) {
        return Provider.provider().readEndpointReference(eprInfoset);
    }

    public abstract void writeTo(Result result);

    public <T> T getPort(java.lang.Class<T> serviceEndpointInterface,
                     WebServiceFeature... features) {
        return Provider.provider().getPort(this,
                                           serviceEndpointInterface,
                                           features);
    }

    @Override
    public java.lang.String toString() {
        StringWriter writer = new StringWriter();
        writeTo(new StreamResult(writer));
        return writer.toString();
    }
}
