Ejemplo n.º 1
0
  @Override
  protected void registerCustomComponents(ComponentRegistry registry) {
    registry.register(SessionCreator.class, SessionCreator.class);
    registry.register(SessionFactoryCreator.class, SessionFactoryCreator.class);

    registry.register(HibernateTransactionInterceptor.class, HibernateTransactionInterceptor.class);
  }
Ejemplo n.º 2
0
 private void registerAnnotatedComponents(Scanner scanner, ComponentRegistry componentRegistry) {
   Collection<Class<?>> collection = scanner.getTypesWithAnnotation(Component.class);
   for (Class<?> componentType : collection) {
     if (ComponentFactory.class.isAssignableFrom(componentType)) {
       if (logger.isDebugEnabled()) {
         logger.debug("Registering found component factory " + componentType);
       }
       componentRegistry.register(componentType, componentType);
     } else {
       if (logger.isDebugEnabled()) {
         logger.debug("Deeply registering found component " + componentType);
       }
       componentRegistry.deepRegister(componentType);
     }
   }
 }
Ejemplo n.º 3
0
  /** Register default vraptor-pico implementation components. */
  protected void registerBundledComponents(ComponentRegistry registry) {
    logger.debug("Registering base pico container related implementation components");
    for (Class<? extends StereotypeHandler> entry : BaseComponents.getStereotypeHandlers()) {
      registry.register(entry, entry);
    }
    //	    registry.register(ComponentHandler.class, ComponentHandler.class);
    for (Map.Entry<Class<?>, Class<?>> entry : BaseComponents.getApplicationScoped().entrySet()) {
      registry.register(entry.getKey(), entry.getValue());
      registry.register(entry.getValue(), entry.getValue());
    }
    for (Map.Entry<Class<?>, Class<?>> entry : BaseComponents.getRequestScoped().entrySet()) {
      registry.register(entry.getKey(), entry.getValue());
      registry.register(entry.getValue(), entry.getValue());
    }
    for (Class<? extends Converter<?>> converterType : BaseComponents.getBundledConverters()) {
      registry.register(converterType, converterType);
    }

    registry.register(ResourceRegistrar.class, ResourceRegistrar.class);
    registry.register(InterceptorRegistrar.class, InterceptorRegistrar.class);
    registry.register(ConverterRegistrar.class, ConverterRegistrar.class);
    registry.register(ComponentFactoryRegistrar.class, ComponentFactoryRegistrar.class);
    registry.register(StereotypedComponentRegistrar.class, StereotypedComponentRegistrar.class);

    try {
      Class.forName("org.joda.time.LocalDate");
      registry.register(LocalDateConverter.class, LocalDateConverter.class);
      registry.register(LocalTimeConverter.class, LocalTimeConverter.class);
    } catch (ClassNotFoundException e) {
      // OK, only register jodatime converters if jodatime is imported
    }
  }