Example usage for javax.naming.spi ObjectFactory getClass

List of usage examples for javax.naming.spi ObjectFactory getClass

Introduction

In this page you can find the example usage for javax.naming.spi ObjectFactory getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:com.funambol.server.db.RoutingDataSource.java

/**
 * Returns a DataSource instance created using the given properties
 * @param properties the properties to use
 * @return a DataSource instance created using the given properties
 * @throws DataSourceConfigurationException if an error occurs
 * @throws Exception if an error occurs/* w w  w . j a  va  2  s. co  m*/
 */
private DataSource createDataSource(Properties properties) throws DataSourceConfigurationException, Exception {
    ObjectFactory dataSourceFactory = getObjectFactory();

    //
    // The DataSourceFactory is a TOMCAT_DATASOURCE_FACTORY or
    // a STANDARD_DATASOURCE_FACTORY. In both cases the method
    // createDataSource should be used. In order to avoid a dependecy
    // from tomcat, the method is called using reflection.
    //
    Method m = dataSourceFactory.getClass().getDeclaredMethod("createDataSource", Properties.class);
    return (DataSource) m.invoke(dataSourceFactory, properties);
}