Class InstanceKeyDataSourceFactory

  • All Implemented Interfaces:
    javax.naming.spi.ObjectFactory
    Direct Known Subclasses:
    PerUserPoolDataSourceFactory, SharedPoolDataSourceFactory

    abstract class InstanceKeyDataSourceFactory
    extends java.lang.Object
    implements javax.naming.spi.ObjectFactory
    A JNDI ObjectFactory which creates SharedPoolDataSources or PerUserPoolDataSources
    Since:
    2.0
    • Field Detail

    • Constructor Detail

      • InstanceKeyDataSourceFactory

        InstanceKeyDataSourceFactory()
    • Method Detail

      • removeInstance

        static void removeInstance​(java.lang.String key)
      • getObjectInstance

        public java.lang.Object getObjectInstance​(java.lang.Object refObj,
                                                  javax.naming.Name name,
                                                  javax.naming.Context context,
                                                  java.util.Hashtable<?,​?> env)
                                           throws java.io.IOException,
                                                  java.lang.ClassNotFoundException
        Implements ObjectFactory to create an instance of SharedPoolDataSource or PerUserPoolDataSource
        Specified by:
        getObjectInstance in interface javax.naming.spi.ObjectFactory
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException
      • setCommonProperties

        private void setCommonProperties​(javax.naming.Reference ref,
                                         InstanceKeyDataSource ikds)
                                  throws java.io.IOException,
                                         java.lang.ClassNotFoundException
        Throws:
        java.io.IOException
        java.lang.ClassNotFoundException
      • isCorrectClass

        protected abstract boolean isCorrectClass​(java.lang.String className)
        Parameters:
        className - The class name to test.
        Returns:
        true if and only if className is the value returned from getClass().getName().toString()
      • getNewInstance

        protected abstract InstanceKeyDataSource getNewInstance​(javax.naming.Reference ref)
                                                         throws java.io.IOException,
                                                                java.lang.ClassNotFoundException
        Creates an instance of the subclass and sets any properties contained in the Reference.
        Parameters:
        ref - The properties to be set on the created DataSource
        Returns:
        A configured DataSource of the appropriate type.
        Throws:
        java.lang.ClassNotFoundException - If a class cannot be found during the deserialization of a configuration parameter.
        java.io.IOException - If an I/O error occurs during the deserialization of a configuration parameter.
      • deserialize

        protected static final java.lang.Object deserialize​(byte[] data)
                                                     throws java.io.IOException,
                                                            java.lang.ClassNotFoundException
        Deserializes the provided byte array to create an object.
        Parameters:
        data - Data to deserialize to create the configuration parameter.
        Returns:
        The Object created by deserializing the data.
        Throws:
        java.lang.ClassNotFoundException - If a class cannot be found during the deserialization of a configuration parameter.
        java.io.IOException - If an I/O error occurs during the deserialization of a configuration parameter.