Example #1
0
 /**
  * Initialize all services define in the {@link #CONF_SERVICE_CLASSES} configuration property.
  *
  * @throws ServiceException thrown if any of the services could not initialize.
  */
 @SuppressWarnings("unchecked")
 public void init() throws ServiceException {
   XLog log = new XLog(LogFactory.getLog(getClass()));
   log.trace("Initializing");
   SERVICES = this;
   try {
     Class<? extends Service>[] serviceClasses =
         (Class<? extends Service>[]) conf.getClasses(CONF_SERVICE_CLASSES);
     if (serviceClasses != null) {
       for (Class<? extends Service> serviceClass : serviceClasses) {
         setService(serviceClass);
       }
     }
   } catch (RuntimeException ex) {
     XLog.getLog(getClass()).fatal(ex.getMessage(), ex);
     throw ex;
   } catch (ServiceException ex) {
     SERVICES = null;
     throw ex;
   }
   InstrumentationService instrService = get(InstrumentationService.class);
   if (instrService != null) {
     for (Service service : services.values()) {
       if (service instanceof Instrumentable) {
         ((Instrumentable) service).instrument(instrService.get());
       }
     }
   }
   log.info("Initialized");
   log.info("Oozie System ID [{0}] started!", getSystemId());
 }
 /**
  * Get classes from a property that all implement a given interface.
  *
  * @param conf Configuration
  * @param name String name of property to fetch.
  * @param xface interface classes must implement.
  * @param defaultValue If not found, return this
  * @param <T> Generic type of interface class
  * @return array of Classes implementing interface specified.
  */
 public static <T> Class<? extends T>[] getClassesOfType(
     Configuration conf, String name, Class<T> xface, Class<? extends T>... defaultValue) {
   Class<?>[] klasses = conf.getClasses(name, defaultValue);
   for (Class<?> klass : klasses) {
     if (!xface.isAssignableFrom(klass)) {
       throw new RuntimeException(klass + " is not assignable from " + xface.getName());
     }
   }
   return (Class<? extends T>[]) klasses;
 }
 public static Class<?>[] getClasses(Configuration conf, String name) {
   return conf.getClasses(name);
 }