Class XmlRpcKit

  • Direct Known Subclasses:
    XmlRpcKit.AvailableKit, XmlRpcKit.UnavailableKit

    public abstract class XmlRpcKit
    extends java.lang.Object
    Encapsulates the provision of XML-RPC client and server capabilities. Two implementations are provided in the JSAMP package; the pluggable architecture allows others to be provided.
    Since:
    27 Aug 2008
    Author:
    Mark Taylor
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      private static class  XmlRpcKit.AvailableKit
      XmlRpcKit implementation which is available.
      private static class  XmlRpcKit.UnavailableKit
      XmlRpcKit implementation which always returns false from isAvailable and throws exceptions from getServer/Client factory methods.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static XmlRpcKit APACHE
      Implementation based on Apache XML-RPC.
      private static XmlRpcKit defaultInstance_  
      static java.lang.String IMPL_PROP
      Property which is examined to determine which implementation to use by default.
      static XmlRpcKit INTERNAL
      Implementation which requires no external libraries.
      static XmlRpcKit[] KNOWN_IMPLS
      Array of available known implementations of this class.
      private static java.util.logging.Logger logger_  
      static XmlRpcKit RPC_LOGGING
      Internal implementation variant with verbose logging of RPC calls.
      static XmlRpcKit XML_LOGGING
      Internal implementation variant with verbose logging of XML I/O.
    • Constructor Summary

      Constructors 
      Constructor Description
      XmlRpcKit()  
    • Field Detail

      • APACHE

        public static final XmlRpcKit APACHE
        Implementation based on Apache XML-RPC.
      • INTERNAL

        public static final XmlRpcKit INTERNAL
        Implementation which requires no external libraries.
      • XML_LOGGING

        public static final XmlRpcKit XML_LOGGING
        Internal implementation variant with verbose logging of XML I/O.
      • RPC_LOGGING

        public static final XmlRpcKit RPC_LOGGING
        Internal implementation variant with verbose logging of RPC calls.
      • KNOWN_IMPLS

        public static XmlRpcKit[] KNOWN_IMPLS
        Array of available known implementations of this class.
      • IMPL_PROP

        public static final java.lang.String IMPL_PROP
        Property which is examined to determine which implementation to use by default. Property values may be one of the elements of KNOWN_IMPLS, currently:
        • internal
        • xml-log
        • rpc-log
        • apache
        Alternatively, it may be the classname of a class which implements XmlRpcKit and has a no-arg constructor. The property name is "jsamp.xmlrpc.impl".
        See Also:
        Constant Field Values
      • defaultInstance_

        private static XmlRpcKit defaultInstance_
      • logger_

        private static java.util.logging.Logger logger_
    • Constructor Detail

      • XmlRpcKit

        public XmlRpcKit()
    • Method Detail

      • getClientFactory

        public abstract SampXmlRpcClientFactory getClientFactory()
        Returns an XML-RPC client factory.
        Returns:
        client factory
      • getServerFactory

        public abstract SampXmlRpcServerFactory getServerFactory()
        Returns an XML-RPC server factory.
        Returns:
        server factory
      • isAvailable

        public abstract boolean isAvailable()
        Indicates whether this object is ready for use. If it returns false (perhaps because some classes are unavailable at runtime) then getClientFactory() and getServerFactory() may throw exceptions rather than behaving as documented.
        Returns:
        true if this object works
      • getName

        public abstract java.lang.String getName()
        Returns the name of this kit.
        Returns:
        implementation name
      • getInstance

        public static XmlRpcKit getInstance()
        Returns the default instance of this class. What implementation this is normally depends on what classes are present at runtime. However, if the system property IMPL_PROP is set this will determine the implementation used. It may be one of:
        • apache: implementation based on the Apache XML-RPC library
        • internal: implementation which requires no libraries beyond JSAMP itself
        • the classname of an implementation of this class which has a no-arg constructor
        Returns:
        default instance of this class
      • getInstanceByName

        public static XmlRpcKit getInstanceByName​(java.lang.String name)
        Returns an XmlRpcKit instance given its name.
        Parameters:
        name - name of one of the known implementations, or classname of an XmlRpcKit implementatation with a no-arg constructor
        Returns:
        named implementation object
        Throws:
        java.lang.IllegalArgumentException - if none by that name can be found
      • createDefaultInstance

        private static XmlRpcKit createDefaultInstance()
        Constructs the default instance of this class based on system property and class availability.
        Returns:
        XmlRpcKit object
        See Also:
        getInstance()
      • createReflectionKit

        public static XmlRpcKit createReflectionKit​(java.lang.String name,
                                                    java.lang.String clientFactoryClassName,
                                                    java.lang.String serverFactoryClassName)
        Returns a new XmlRpcKit given classnames for the client and server factory classes. If the classes are not available, a kit which returns isAvailable()()=false will be returned.
        Parameters:
        name - kit name
        clientFactoryClassName - name of class implementing SampXmlRpcClientFactory which has a no-arg constructor
        serverFactoryClassName - name of class implementing SampXmlRpcServerFactory which has a no-arg constructor
        Returns:
        new XmlRpcKit constructed using reflection
      • createApacheKit

        private static XmlRpcKit createApacheKit​(java.lang.String name)
        Returns an available or unavailable XmlRpcKit based on Apache XML-RPC version 1.2.
        Parameters:
        name - kit name
        Returns:
        new kit