Java Code Examples for com.sun.xml.internal.ws.util.ServiceFinder#find()

The following examples show how to use com.sun.xml.internal.ws.util.ServiceFinder#find() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PolicyResolverFactory.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public static PolicyResolver create(){
    for (PolicyResolverFactory factory : ServiceFinder.find(PolicyResolverFactory.class)) {
        PolicyResolver policyResolver = factory.doCreate();
        if (policyResolver != null) {
            return policyResolver;
        }
    }
     // return default policy resolver.
    return DEFAULT_POLICY_RESOLVER;
}
 
Example 2
Source File: MessageContextFactory.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
static public MessageContextFactory createFactory(ClassLoader cl, WebServiceFeature ...f) {
    for (MessageContextFactory factory : ServiceFinder.find(MessageContextFactory.class, cl)) {
        MessageContextFactory newfac = factory.newFactory(f);
        if (newfac != null) return newfac;
    }
    return new com.sun.xml.internal.ws.api.message.MessageContextFactory(f);
}
 
Example 3
Source File: PipelineAssemblerFactory.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Locates {@link PipelineAssemblerFactory}s and create
 * a suitable {@link PipelineAssembler}.
 *
 * @param bindingId
 *      The binding ID string for which the new {@link PipelineAssembler}
 *      is created. Must not be null.
 * @return
 *      Always non-null, since we fall back to our default {@link PipelineAssembler}.
 */
public static PipelineAssembler create(ClassLoader classLoader, BindingID bindingId) {
    for (PipelineAssemblerFactory factory : ServiceFinder.find(PipelineAssemblerFactory.class,classLoader)) {
        PipelineAssembler assembler = factory.doCreate(bindingId);
        if(assembler!=null) {
            logger.fine(factory.getClass()+" successfully created "+assembler);
            return assembler;
        }
    }

    // default binding IDs that are known
    // TODO: replace this with proper ones
    return new com.sun.xml.internal.ws.util.pipe.StandalonePipeAssembler();
}
 
Example 4
Source File: WsimportOptions.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Looks for all "META-INF/services/[className]" files and
 * create one instance for each class name found inside this file.
 */
private static <T> T[] findServices(Class<T> clazz, ClassLoader classLoader) {
    ServiceFinder<T> serviceFinder = ServiceFinder.find(clazz, classLoader);
    List<T> r = new ArrayList<T>();
    for (T t : serviceFinder) {
        r.add(t);
    }
    return r.toArray((T[]) Array.newInstance(clazz, r.size()));
}
 
Example 5
Source File: SAAJFactory.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Reads Message as SOAPMessage.  After this call message is consumed.
 * @param soapVersion SOAP version
 * @param message Message
 * @return Created SOAPMessage
 * @throws SOAPException if SAAJ processing fails
 */
public static SOAPMessage read(SOAPVersion soapVersion, Message message) throws SOAPException {
        for (SAAJFactory s : ServiceFinder.find(SAAJFactory.class)) {
                SOAPMessage msg = s.readAsSOAPMessage(soapVersion, message);
                if (msg != null)
                        return msg;
        }

return instance.readAsSOAPMessage(soapVersion, message);
}
 
Example 6
Source File: DatabindingFactoryImpl.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
static private List<DatabindingProvider> providers() {
    List<DatabindingProvider> factories = new java.util.ArrayList<DatabindingProvider>();
    for (DatabindingProvider p : ServiceFinder.find(DatabindingProvider.class)) {
        factories.add(p);
    }
    return factories;
}
 
Example 7
Source File: SAAJFactory.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Reads the message within the Packet to a SAAJMessage.  After this call message is consumed.
 * @param packet Packet
 * @return Created SAAJPMessage
 * @throws SOAPException if SAAJ processing fails
 */
public static SAAJMessage read(Packet packet) throws SOAPException {
    // Use the Component from the Packet if it exists.  Note the logic
    // in the ServiceFinder is such that find(Class) is not equivalent
    // to find (Class, null), so the ternary operator is needed.
    ServiceFinder<SAAJFactory> factories = (packet.component != null ?
            ServiceFinder.find(SAAJFactory.class, packet.component) :
            ServiceFinder.find(SAAJFactory.class));
    for (SAAJFactory s : factories) {
        SAAJMessage msg = s.readAsSAAJ(packet);
        if (msg != null) return msg;
    }
    return instance.readAsSAAJ(packet);
}
 
Example 8
Source File: PipelineAssemblerFactory.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Locates {@link PipelineAssemblerFactory}s and create
 * a suitable {@link PipelineAssembler}.
 *
 * @param bindingId
 *      The binding ID string for which the new {@link PipelineAssembler}
 *      is created. Must not be null.
 * @return
 *      Always non-null, since we fall back to our default {@link PipelineAssembler}.
 */
public static PipelineAssembler create(ClassLoader classLoader, BindingID bindingId) {
    for (PipelineAssemblerFactory factory : ServiceFinder.find(PipelineAssemblerFactory.class,classLoader)) {
        PipelineAssembler assembler = factory.doCreate(bindingId);
        if(assembler!=null) {
            logger.fine(factory.getClass()+" successfully created "+assembler);
            return assembler;
        }
    }

    // default binding IDs that are known
    // TODO: replace this with proper ones
    return new com.sun.xml.internal.ws.util.pipe.StandalonePipeAssembler();
}
 
Example 9
Source File: MessageContextFactory.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Deprecated
private static MessageContext serviceFinder(final ClassLoader[] classLoader, final Creator creator) {
    final ClassLoader cl = classLoader.length == 0 ? null : classLoader[0];
    for (MessageContextFactory factory : ServiceFinder.find(MessageContextFactory.class, cl)) {
        final MessageContext messageContext = creator.create(factory);
        if (messageContext != null)
            return messageContext;
    }
    return creator.create(DEFAULT);
}
 
Example 10
Source File: PolicyResolverFactory.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public static PolicyResolver create(){
    for (PolicyResolverFactory factory : ServiceFinder.find(PolicyResolverFactory.class)) {
        PolicyResolver policyResolver = factory.doCreate();
        if (policyResolver != null) {
            return policyResolver;
        }
    }
     // return default policy resolver.
    return DEFAULT_POLICY_RESOLVER;
}
 
Example 11
Source File: WsgenOptions.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public WsgenOptions() {
    protocols.add(SOAP11);
    protocols.add(X_SOAP12);
    nonstdProtocols.put(X_SOAP12, SOAPBindingImpl.X_SOAP12HTTP_BINDING);
    ServiceFinder<WsgenExtension> extn = ServiceFinder.find(WsgenExtension.class);
    for(WsgenExtension ext : extn) {
        Class clazz = ext.getClass();
        WsgenProtocol pro = (WsgenProtocol)clazz.getAnnotation(WsgenProtocol.class);
        protocols.add(pro.token());
        nonstdProtocols.put(pro.token(), pro.lexical());
    }
}
 
Example 12
Source File: SAAJFactory.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Reads Message as SOAPMessage.  After this call message is consumed.
 * @param soapVersion SOAP version
 * @param message Message
 * @param packet The packet that owns the Message
 * @return Created SOAPMessage
 * @throws SOAPException if SAAJ processing fails
 */
public static SOAPMessage read(SOAPVersion soapVersion, Message message, Packet packet) throws SOAPException {
    for (SAAJFactory s : ServiceFinder.find(SAAJFactory.class)) {
        SOAPMessage msg = s.readAsSOAPMessage(soapVersion, message, packet);
        if (msg != null)
            return msg;
    }

    return instance.readAsSOAPMessage(soapVersion, message, packet);
}
 
Example 13
Source File: StreamSOAPCodec.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private StreamDecoder selectStreamDecoder() {
    for (StreamDecoder sd : ServiceFinder.find(StreamDecoder.class)) {
        return sd;
    }

    return new StreamDecoderImpl();
}
 
Example 14
Source File: BindingContextFactory.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public static Iterator<BindingContextFactory> serviceIterator() {
    final ServiceFinder<BindingContextFactory> sf = ServiceFinder
            .find(BindingContextFactory.class);
    final Iterator<BindingContextFactory> ibcf = sf.iterator();

    return new Iterator<BindingContextFactory>() {
        private BindingContextFactory bcf;

        public boolean hasNext() {
            while (true) {
                try {
                    if (ibcf.hasNext()) {
                        bcf = ibcf.next();
                        return true;
                    } else
                        return false;
                } catch (ServiceConfigurationError e) {
                    LOGGER.warning("skipping factory: ServiceConfigurationError: "
                            + e.getMessage());
                } catch (NoClassDefFoundError ncdfe) {
                    LOGGER.fine("skipping factory: NoClassDefFoundError: "
                            + ncdfe.getMessage());
                }
            }
        }

        public BindingContextFactory next() {
            if (LOGGER.isLoggable(Level.FINER))
                LOGGER.finer("SPI found provider: " +
                        bcf.getClass().getName());
            return bcf;
        }

        public void remove() {
            throw new UnsupportedOperationException();
        }
    };
}
 
Example 15
Source File: SAAJFactory.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Reads the message within the Packet to a SAAJMessage.  After this call message is consumed.
 * @param packet Packet
 * @return Created SAAJPMessage
 * @throws SOAPException if SAAJ processing fails
 */
public static SAAJMessage read(Packet packet) throws SOAPException {
    // Use the Component from the Packet if it exists.  Note the logic
    // in the ServiceFinder is such that find(Class) is not equivalent
    // to find (Class, null), so the ternary operator is needed.
    ServiceFinder<SAAJFactory> factories = (packet.component != null ?
            ServiceFinder.find(SAAJFactory.class, packet.component) :
            ServiceFinder.find(SAAJFactory.class));
    for (SAAJFactory s : factories) {
        SAAJMessage msg = s.readAsSAAJ(packet);
        if (msg != null) return msg;
    }
    return instance.readAsSAAJ(packet);
}
 
Example 16
Source File: WsgenOptions.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public WsgenOptions() {
    protocols.add(SOAP11);
    protocols.add(X_SOAP12);
    nonstdProtocols.put(X_SOAP12, SOAPBindingImpl.X_SOAP12HTTP_BINDING);
    ServiceFinder<WsgenExtension> extn = ServiceFinder.find(WsgenExtension.class);
    for(WsgenExtension ext : extn) {
        Class clazz = ext.getClass();
        WsgenProtocol pro = (WsgenProtocol)clazz.getAnnotation(WsgenProtocol.class);
        protocols.add(pro.token());
        nonstdProtocols.put(pro.token(), pro.lexical());
    }
}
 
Example 17
Source File: SAAJFactory.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Reads Message as SOAPMessage.  After this call message is consumed.
 * @param soapVersion SOAP version
 * @param message Message
 * @return Created SOAPMessage
 * @throws SOAPException if SAAJ processing fails
 */
public static SOAPMessage read(SOAPVersion soapVersion, Message message) throws SOAPException {
        for (SAAJFactory s : ServiceFinder.find(SAAJFactory.class)) {
                SOAPMessage msg = s.readAsSOAPMessage(soapVersion, message);
                if (msg != null)
                        return msg;
        }

return instance.readAsSOAPMessage(soapVersion, message);
}
 
Example 18
Source File: MessageContextFactory.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
static public MessageContextFactory createFactory(ClassLoader cl, WebServiceFeature ...f) {
    for (MessageContextFactory factory : ServiceFinder.find(MessageContextFactory.class, cl)) {
        MessageContextFactory newfac = factory.newFactory(f);
        if (newfac != null) return newfac;
    }
    return new com.sun.xml.internal.ws.api.message.MessageContextFactory(f);
}
 
Example 19
Source File: SAAJFactory.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates Message from SOAPMessage
 * @param saaj SOAPMessage
 * @return created Message
 */
public static Message create(SOAPMessage saaj) {
        for (SAAJFactory s : ServiceFinder.find(SAAJFactory.class)) {
                Message m = s.createMessage(saaj);
                if (m != null)
                        return m;
        }

return instance.createMessage(saaj);
}
 
Example 20
Source File: SAAJFactory.java    From openjdk-jdk9 with GNU General Public License v2.0 3 votes vote down vote up
/**
* Creates a new <code>MessageFactory</code> object that is an instance
* of the specified implementation.  May be a dynamic message factory,
* a SOAP 1.1 message factory, or a SOAP 1.2 message factory. A dynamic
* message factory creates messages based on the MIME headers specified
* as arguments to the <code>createMessage</code> method.
*
* This method uses the SAAJMetaFactory to locate the implementation class
* and create the MessageFactory instance.
*
* @return a new instance of a <code>MessageFactory</code>
*
* @param protocol  a string constant representing the class of the
*                   specified message factory implementation. May be
*                   either <code>DYNAMIC_SOAP_PROTOCOL</code>,
*                   <code>DEFAULT_SOAP_PROTOCOL</code> (which is the same
*                   as) <code>SOAP_1_1_PROTOCOL</code>, or
*                   <code>SOAP_1_2_PROTOCOL</code>.
*
* @exception SOAPException if there was an error in creating the
*            specified implementation of  <code>MessageFactory</code>.
* @see SAAJMetaFactory
*/
   public static MessageFactory getMessageFactory(String protocol) throws SOAPException {
           for (SAAJFactory s : ServiceFinder.find(SAAJFactory.class)) {
                   MessageFactory mf = s.createMessageFactory(protocol);
                   if (mf != null)
                           return mf;
           }

   return instance.createMessageFactory(protocol);
   }