Example #1
0
 public static Class classForName(String className, ServiceRegistry serviceRegistry) {
   ClassLoaderService classLoaderService = serviceRegistry.getService(ClassLoaderService.class);
   try {
     return classLoaderService.classForName(className);
   } catch (ClassLoadingException e) {
     throw new MappingException("Could not find class: " + className);
   }
 }
 private boolean proxoolProviderPresent(ClassLoaderService classLoaderService) {
   try {
     classLoaderService.classForName(PROXOOL_PROVIDER_CLASS_NAME);
   } catch (Exception e) {
     LOG.proxoolProviderClassNotFound(PROXOOL_PROVIDER_CLASS_NAME);
     return false;
   }
   return true;
 }
 private ConnectionProvider instantiateExplicitConnectionProvider(
     String providerClassName, ClassLoaderService classLoaderService) {
   try {
     log.info("Instantiating explicit connection provider: " + providerClassName);
     return (ConnectionProvider) classLoaderService.classForName(providerClassName).newInstance();
   } catch (Exception e) {
     throw new HibernateException(
         "Could not instantiate connection provider [" + providerClassName + "]", e);
   }
 }
 private boolean proxoolProviderPresent(ClassLoaderService classLoaderService) {
   try {
     classLoaderService.classForName(PROXOOL_PROVIDER_CLASS_NAME);
   } catch (Exception e) {
     log.warn(
         "proxool properties were encountered, but the "
             + PROXOOL_PROVIDER_CLASS_NAME
             + " provider class was not found on the classpath; these properties are going to be ignored.");
     return false;
   }
   return true;
 }
 public static Callback[] resolveCallbacks(
     Class<?> entityClass,
     Class<?> callbackClass,
     ClassLoaderService classLoaderService,
     EntityBinding binding) {
   List<Callback> callbacks = new ArrayList<Callback>();
   for (JpaCallbackClass jpaCallbackClass : binding.getJpaCallbackClasses()) {
     Object listener = classLoaderService.classForName(jpaCallbackClass.getName());
     String methodName = jpaCallbackClass.getCallbackMethod(callbackClass);
     Callback callback =
         jpaCallbackClass.isListener()
             ? createListenerCallback(entityClass, callbackClass, listener, methodName)
             : createBeanCallback(callbackClass, methodName);
     LOG.debugf(
         "Adding %s as %s callback for entity %s",
         methodName, callbackClass.getName(), entityClass.getName());
     assert callback != null;
     callbacks.add(callback);
   }
   return callbacks.toArray(new Callback[callbacks.size()]);
 }