Refine search
/** * Register per-deployment services which are shared across the entire application. * <p> * Weld uses services to communicate with its environment, e.g. {@link org.jboss.weld.manager.api.ExecutorServices} or * {@link org.jboss.weld.transaction.spi.TransactionServices}. * </p> * <p> * Service implementation may specify their priority using {@link Priority}. Services with higher priority have precedence. Services that do not specify * priority have the default priority of 4500. * </p> * * @param services * @return self * @see Service */ public Weld addServices(Service... services) { for (Service service : services) { for (Class<? extends Service> serviceInterface : Services.identifyServiceInterfaces(service.getClass(), new HashSet<Class<? extends Service>>())) { additionalServices.put(serviceInterface, service); } } return this; }
private static boolean shouldOverride(Class<? extends Service> key, Service previous, Service next) { return getPriority(next) > getPriority(previous); }
/** * Identifies service views for a service implementation class. A service view is either: - an interface that directly extends {@link Service} or * {@link BootstrapService} - a clazz that directly implements {@link Service} or {@link BootstrapService} * * @param clazz the given class * @param serviceInterfaces a set that this method populates with service views * @return serviceInterfaces */ public static Set<Class<? extends Service>> identifyServiceInterfaces(Class<?> clazz, Set<Class<? extends Service>> serviceInterfaces) { if (clazz == null || Object.class.equals(clazz) || BootstrapService.class.equals(clazz)) { return serviceInterfaces; } for (Class<?> interfac3 : clazz.getInterfaces()) { if (Service.class.equals(interfac3) || BootstrapService.class.equals(interfac3)) { serviceInterfaces.add(Reflections.cast(clazz)); } } for (Class<?> interfac3 : clazz.getInterfaces()) { identifyServiceInterfaces(interfac3, serviceInterfaces); } identifyServiceInterfaces(clazz.getSuperclass(), serviceInterfaces); return serviceInterfaces; }
public static <T extends Service> void put(ServiceRegistry registry, Class<T> key, Service value) { Service previous = registry.get(key); if (previous == null) { BootstrapLogger.LOG.debugv("Installing additional service {0} ({1})", key.getName(), value.getClass()); registry.add(key, Reflections.cast(value)); } else if (shouldOverride(key, previous, value)) { BootstrapLogger.LOG.debugv("Overriding service implementation for {0}. Previous implementation {1} is replaced with {2}", key.getName(), previous.getClass().getName(), value.getClass().getName()); registry.add(key, Reflections.cast(value)); } }
/** * Discovers additional services using {@link ServiceLoader} and appends them to the given service registry. * @param registry the given service registry */ void loadAdditionalServices(ServiceRegistry registry) { for (ResourceLoader loader : getResourceLoaders()) { for (Metadata<Service> metadata : ServiceLoader.load(Service.class, loader)) { Service service = metadata.getValue(); for (Class<? extends Service> serviceInterface : Services.identifyServiceInterfaces(service.getClass(), new HashSet<>())) { Services.put(registry, serviceInterface, service); } } } }
Services.put(deployment.getServices(), entry.getKey(), entry.getValue());
/** * Identifies service views for a service implementation class. A service view is either: - an interface that directly extends {@link Service} or * {@link BootstrapService} - a clazz that directly implements {@link Service} or {@link BootstrapService} * * @param clazz the given class * @param serviceInterfaces a set that this method populates with service views * @return serviceInterfaces */ public static Set<Class<? extends Service>> identifyServiceInterfaces(Class<?> clazz, Set<Class<? extends Service>> serviceInterfaces) { if (clazz == null || Object.class.equals(clazz) || BootstrapService.class.equals(clazz)) { return serviceInterfaces; } for (Class<?> interfac3 : clazz.getInterfaces()) { if (Service.class.equals(interfac3) || BootstrapService.class.equals(interfac3)) { serviceInterfaces.add(Reflections.cast(clazz)); } } for (Class<?> interfac3 : clazz.getInterfaces()) { identifyServiceInterfaces(interfac3, serviceInterfaces); } identifyServiceInterfaces(clazz.getSuperclass(), serviceInterfaces); return serviceInterfaces; }
public static <T extends Service> void put(ServiceRegistry registry, Class<T> key, Service value) { Service previous = registry.get(key); if (previous == null) { BootstrapLogger.LOG.debugv("Installing additional service {0} ({1})", key.getName(), value.getClass()); registry.add(key, Reflections.cast(value)); } else if (shouldOverride(key, previous, value)) { BootstrapLogger.LOG.debugv("Overriding service implementation for {0}. Previous implementation {1} is replaced with {2}", key.getName(), previous.getClass().getName(), value.getClass().getName()); registry.add(key, Reflections.cast(value)); } }
/** * Discovers additional services using {@link ServiceLoader} and appends them to the given service registry. * @param registry the given service registry */ void loadAdditionalServices(ServiceRegistry registry) { for (ResourceLoader loader : getResourceLoaders()) { for (Metadata<Service> metadata : ServiceLoader.load(Service.class, loader)) { Service service = metadata.getValue(); for (Class<? extends Service> serviceInterface : Services.identifyServiceInterfaces(service.getClass(), new HashSet<Class<? extends Service>>())) { Services.put(registry, serviceInterface, service); } } } }
Services.put(deployment.getServices(), entry.getKey(), entry.getValue());
/** * Identifies service views for a service implementation class. A service view is either: - an interface that directly extends {@link Service} or * {@link BootstrapService} - a clazz that directly implements {@link Service} or {@link BootstrapService} * * @param clazz the given class * @param serviceInterfaces a set that this method populates with service views * @return serviceInterfaces */ public static Set<Class<? extends Service>> identifyServiceInterfaces(Class<?> clazz, Set<Class<? extends Service>> serviceInterfaces) { if (clazz == null || Object.class.equals(clazz) || BootstrapService.class.equals(clazz)) { return serviceInterfaces; } for (Class<?> interfac3 : clazz.getInterfaces()) { if (Service.class.equals(interfac3) || BootstrapService.class.equals(interfac3)) { serviceInterfaces.add(Reflections.<Class<? extends Service>>cast(clazz)); } } for (Class<?> interfac3 : clazz.getInterfaces()) { identifyServiceInterfaces(interfac3, serviceInterfaces); } identifyServiceInterfaces(clazz.getSuperclass(), serviceInterfaces); return serviceInterfaces; }
public static <T extends Service> void put(ServiceRegistry registry, Class<T> key, Service value) { Service previous = registry.get(key); if (previous == null) { BootstrapLogger.LOG.debugv("Installing additional service {0} ({1})", key.getName(), value.getClass()); registry.add(key, Reflections.cast(value)); } else if (shouldOverride(key, previous, value)) { BootstrapLogger.LOG.debugv("Overriding service implementation for {0}. Previous implementation {1} is replaced with {2}", key.getName(), previous.getClass().getName(), value.getClass().getName()); registry.add(key, Reflections.cast(value)); } }
/** * Discovers additional services using {@link ServiceLoader} and appends them to the given service registry. * @param registry the given service registry */ void loadAdditionalServices(ServiceRegistry registry) { for (ResourceLoader loader : getResourceLoaders()) { for (Metadata<Service> metadata : ServiceLoader.load(Service.class, loader)) { Service service = metadata.getValue(); for (Class<? extends Service> serviceInterface : Services.identifyServiceInterfaces(service.getClass(), new HashSet<>())) { Services.put(registry, serviceInterface, service); } } } }
/** * Register per-deployment services which are shared across the entire application. * <p> * Weld uses services to communicate with its environment, e.g. {@link org.jboss.weld.manager.api.ExecutorServices} or * {@link org.jboss.weld.transaction.spi.TransactionServices}. * </p> * <p> * Service implementation may specify their priority using {@link Priority}. Services with higher priority have precedence. Services that do not specify * priority have the default priority of 4500. * </p> * * @param services * @return self * @see Service */ public Weld addServices(Service... services) { for (Service service : services) { for (Class<? extends Service> serviceInterface : Services.identifyServiceInterfaces(service.getClass(), new HashSet<>())) { additionalServices.put(serviceInterface, service); } } return this; }
Services.put(deployment.getServices(), entry.getKey(), entry.getValue());
private static boolean shouldOverride(Class<? extends Service> key, Service previous, Service next) { return getPriority(next) > getPriority(previous); }
/** * Identifies service views for a service implementation class. A service view is either: - an interface that directly extends {@link Service} or * {@link BootstrapService} - a clazz that directly implements {@link Service} or {@link BootstrapService} * * @param clazz the given class * @param serviceInterfaces a set that this method populates with service views * @return serviceInterfaces */ public static Set<Class<? extends Service>> identifyServiceInterfaces(Class<?> clazz, Set<Class<? extends Service>> serviceInterfaces) { if (clazz == null || Object.class.equals(clazz) || BootstrapService.class.equals(clazz)) { return serviceInterfaces; } for (Class<?> interfac3 : clazz.getInterfaces()) { if (Service.class.equals(interfac3) || BootstrapService.class.equals(interfac3)) { serviceInterfaces.add(Reflections.cast(clazz)); } } for (Class<?> interfac3 : clazz.getInterfaces()) { identifyServiceInterfaces(interfac3, serviceInterfaces); } identifyServiceInterfaces(clazz.getSuperclass(), serviceInterfaces); return serviceInterfaces; }
public static <T extends Service> void put(ServiceRegistry registry, Class<T> key, Service value) { Service previous = registry.get(key); if (previous == null) { BootstrapLogger.LOG.debugv("Installing additional service {0} ({1})", key.getName(), value.getClass()); registry.add(key, Reflections.cast(value)); } else if (shouldOverride(key, previous, value)) { BootstrapLogger.LOG.debugv("Overriding service implementation for {0}. Previous implementation {1} is replaced with {2}", key.getName(), previous.getClass().getName(), value.getClass().getName()); registry.add(key, Reflections.cast(value)); } }
/** * Discovers additional services using {@link ServiceLoader} and appends them to the given service registry. * @param registry the given service registry */ void loadAdditionalServices(ServiceRegistry registry) { for (ResourceLoader loader : getResourceLoaders()) { for (Metadata<Service> metadata : ServiceLoader.load(Service.class, loader)) { Service service = metadata.getValue(); for (Class<? extends Service> serviceInterface : Services.identifyServiceInterfaces(service.getClass(), new HashSet<>())) { Services.put(registry, serviceInterface, service); } } } }
/** * Register per-deployment services which are shared across the entire application. * <p> * Weld uses services to communicate with its environment, e.g. {@link org.jboss.weld.manager.api.ExecutorServices} or * {@link org.jboss.weld.transaction.spi.TransactionServices}. * </p> * <p> * Service implementation may specify their priority using {@link Priority}. Services with higher priority have precedence. Services that do not specify * priority have the default priority of 4500. * </p> * * @param services * @return self * @see Service */ public Weld addServices(Service... services) { for (Service service : services) { for (Class<? extends Service> serviceInterface : Services.identifyServiceInterfaces(service.getClass(), new HashSet<>())) { additionalServices.put(serviceInterface, service); } } return this; }