private static void setJobConf(Object theObject, Configuration conf) {
        //If JobConf and JobConfigurable are in classpath, AND
        //theObject is of type JobConfigurable AND
        //conf is of type JobConf then
        //invoke configure on theObject
        try {
            Class<?> jobConfClass = conf.getClassByName("org.apache.hadoop.mapred.JobConf");
            Class<?> jobConfigurableClass = conf.getClassByName("org.apache.hadoop.mapred.JobConfigurable");
            if (jobConfClass.isAssignableFrom(conf.getClass())
                    && jobConfigurableClass.isAssignableFrom(theObject.getClass())) {
                Method configureMethod = jobConfigurableClass.getMethod("configure", jobConfClass);
                configureMethod.invoke(theObject, conf);
            }
        } catch (ClassNotFoundException e) {
            //JobConf/JobConfigurable not in classpath. no need to configure
        } catch (Exception e) {
            throw new RuntimeException("Error in configuring object", e);
        }
    }
private static void setJobConf ( Object theObject , Configuration conf ) { try { Class < ? > jobConfClass = conf . getClassByName ( "org.apache.hadoop.mapred.JobConf" ) ; Class < ? > jobConfigurableClass = conf . getClassByName ( "org.apache.hadoop.mapred.JobConfigurable" ) ; if ( jobConfClass . isAssignableFrom ( conf . getClass ( ) ) && jobConfigurableClass . isAssignableFrom ( theObject . getClass ( ) ) ) { Method configureMethod = jobConfigurableClass . getMethod ( "configure" , jobConfClass ) ; configureMethod . invoke ( theObject , conf ) ; } } catch ( ClassNotFoundException e ) { } catch ( Exception e ) { throw new RuntimeException ( "Error in configuring object" , e ) ; } }
This code is to support backward compatibility and break the compile
time dependency of core on mapred.
This should be made deprecated along with the mapred package HADOOP-1230.
Should be removed when mapred package is removed.