@Override public long getLocatorId() { return delegate.getLocatorId(); }
@Override public long getLocatorId() { return delegate.getLocatorId(); }
@Inject private ImmediateContext(ServiceLocator locator) { this.locator = locator; validationFilter = new ImmediateLocalLocatorFilter(locator.getLocatorId()); }
@Inject private ImmediateContext(ServiceLocator locator) { this.locator = locator; validationFilter = new ImmediateLocalLocatorFilter(locator.getLocatorId()); }
@Inject private ImmediateContext(ServiceLocator locator) { this.locator = locator; validationFilter = new ImmediateLocalLocatorFilter(locator.getLocatorId()); }
@Inject private ImmediateContext(ServiceLocator locator) { this.locator = locator; validationFilter = new ImmediateLocalLocatorFilter(locator.getLocatorId()); }
/** * Takes and wraps the given {@link ServiceLocator} into an {@link ActiveDescriptor}. */ public static ActiveDescriptor<ServiceLocator> newServiceLocatorDescriptor(ServiceLocator locator) { Set<Type> contracts = Collections.<Type>singleton(ServiceLocator.class); Set<Annotation> qualifiers = Collections.emptySet(); ActiveDescriptor<ServiceLocator> descriptor = new ConstantActiveDescriptor<>( locator, contracts, PerLookup.class, null, qualifiers, DescriptorVisibility.LOCAL, 0, null, null, null, locator.getLocatorId(), null); return descriptor; }
/** * Takes and wraps the given {@link ServiceLocator} into an {@link ActiveDescriptor}. */ public static ActiveDescriptor<ServiceLocator> newServiceLocatorDescriptor(ServiceLocator locator) { Set<Type> contracts = Collections.<Type>singleton(ServiceLocator.class); Set<Annotation> qualifiers = Collections.emptySet(); ActiveDescriptor<ServiceLocator> descriptor = new ConstantActiveDescriptor<>( locator, contracts, PerLookup.class, null, qualifiers, DescriptorVisibility.LOCAL, 0, null, null, null, locator.getLocatorId(), null); return descriptor; }
/** * Returns a constant ActiveDescriptor for the basic ServiceLocator * * @param locator The service locator to get the ActiveDescriptor for * @return An active descriptor specifically for the ServiceLocator */ public static ActiveDescriptor<ServiceLocator> getLocatorDescriptor(ServiceLocator locator) { HashSet<Type> contracts = new HashSet<Type>(); contracts.add(ServiceLocator.class); Set<Annotation> qualifiers = Collections.emptySet(); ActiveDescriptor<ServiceLocator> retVal = new ConstantActiveDescriptor<ServiceLocator>( locator, contracts, PerLookup.class, null, qualifiers, DescriptorVisibility.LOCAL, 0, null, null, null, locator.getLocatorId(), null); return retVal; }
/** * @see #newThreeThirtyInjectionResolverDescriptor(ServiceLocator) * @see #newGuiceInjectionResolverDescriptor(ServiceLocator, ActiveDescriptor) */ private static <T extends Annotation> ActiveDescriptor<InjectionResolver<T>> newActiveDescriptor(ServiceLocator locator, InjectionResolver<T> resolver, Set<Annotation> qualifiers, String name, Class<? extends T> clazz) { Set<Type> contracts = Collections.<Type>singleton( new ParameterizedTypeImpl(InjectionResolver.class, clazz)); ActiveDescriptor<InjectionResolver<T>> descriptor = new ConstantActiveDescriptor<InjectionResolver<T>>( resolver, contracts, Singleton.class, name, qualifiers, DescriptorVisibility.NORMAL, 0, (Boolean)null, (Boolean)null, (String)null, locator.getLocatorId(), (Map<String, List<String>>)null); return descriptor; }
/** * @see #newThreeThirtyInjectionResolverDescriptor(ServiceLocator) * @see #newGuiceInjectionResolverDescriptor(ServiceLocator, ActiveDescriptor) */ private static <T extends Annotation> ActiveDescriptor<InjectionResolver<T>> newActiveDescriptor(ServiceLocator locator, InjectionResolver<T> resolver, Set<Annotation> qualifiers, String name, Class<? extends T> clazz) { Set<Type> contracts = Collections.<Type>singleton( new ParameterizedTypeImpl(InjectionResolver.class, clazz)); ActiveDescriptor<InjectionResolver<T>> descriptor = new ConstantActiveDescriptor<InjectionResolver<T>>( resolver, contracts, Singleton.class, name, qualifiers, DescriptorVisibility.NORMAL, 0, (Boolean)null, (Boolean)null, (String)null, locator.getLocatorId(), (Map<String, List<String>>)null); return descriptor; }
/** * @see #newThreeThirtyInjectionResolverDescriptor(ServiceLocator) * @see #newGuiceInjectionResolverDescriptor(ServiceLocator, ActiveDescriptor) */ private static <T extends Annotation> ActiveDescriptor<InjectionResolver<T>> newActiveDescriptor(ServiceLocator locator, InjectionResolver<T> resolver, Set<Annotation> qualifiers, String name, Class<? extends T> clazz) { Set<Type> contracts = Collections.<Type>singleton( new ParameterizedTypeImpl(InjectionResolver.class, clazz)); ActiveDescriptor<InjectionResolver<T>> descriptor = new ConstantActiveDescriptor<InjectionResolver<T>>( resolver, contracts, Singleton.class, name, qualifiers, DescriptorVisibility.NORMAL, 0, (Boolean)null, (Boolean)null, (String)null, locator.getLocatorId(), (Map<String, List<String>>)null); return descriptor; }
/** * @see #newThreeThirtyInjectionResolverDescriptor(ServiceLocator) * @see #newGuiceInjectionResolverDescriptor(ServiceLocator, ActiveDescriptor) */ private static <T extends Annotation> ActiveDescriptor<InjectionResolver<T>> newActiveDescriptor(ServiceLocator locator, InjectionResolver<T> resolver, Set<Annotation> qualifiers, String name, Class<? extends T> clazz) { Set<Type> contracts = Collections.<Type>singleton( new ParameterizedTypeImpl(InjectionResolver.class, clazz)); ActiveDescriptor<InjectionResolver<T>> descriptor = new ConstantActiveDescriptor<InjectionResolver<T>>( resolver, contracts, Singleton.class, name, qualifiers, DescriptorVisibility.NORMAL, 0, (Boolean)null, (Boolean)null, (String)null, locator.getLocatorId(), (Map<String, List<String>>)null); return descriptor; }
/** * Returns the service in this service locator given the current descriptor. * * @param locator The non-null locator in which to get the service associated with * this descriptor * @param descriptor The non-null descriptor to find the corresponding service for * @return The service object */ @SuppressWarnings("unchecked") public static <T> T getService(ServiceLocator locator, Descriptor descriptor) { if (locator == null || descriptor == null) throw new IllegalArgumentException(); Long locatorId = descriptor.getLocatorId(); if (locatorId != null && (locatorId.longValue() == locator.getLocatorId()) && (descriptor instanceof ActiveDescriptor)) { return locator.getServiceHandle((ActiveDescriptor<T>) descriptor).getService(); } ActiveDescriptor<T> found = findOneDescriptor(locator, descriptor); if (found == null) return null; return locator.getServiceHandle(found).getService(); }
/** * Returns the service in this service locator given the current descriptor. * * @param locator The non-null locator in which to get the service associated with * this descriptor * @param descriptor The non-null descriptor to find the corresponding service for * @return The service object */ @SuppressWarnings("unchecked") public static <T> T getService(ServiceLocator locator, Descriptor descriptor) { if (locator == null || descriptor == null) throw new IllegalArgumentException(); Long locatorId = descriptor.getLocatorId(); if (locatorId != null && (locatorId.longValue() == locator.getLocatorId()) && (descriptor instanceof ActiveDescriptor)) { return locator.getServiceHandle((ActiveDescriptor<T>) descriptor).getService(); } ActiveDescriptor<T> found = findOneDescriptor(locator, descriptor); if (found == null) return null; return locator.getServiceHandle(found).getService(); }
/** * Returns the service in this service locator given the current descriptor. * * @param locator The non-null locator in which to get the service associated with * this descriptor * @param descriptor The non-null descriptor to find the corresponding service for * @return The service object */ @SuppressWarnings("unchecked") public static <T> T getService(ServiceLocator locator, Descriptor descriptor) { if (locator == null || descriptor == null) throw new IllegalArgumentException(); Long locatorId = descriptor.getLocatorId(); if (locatorId != null && (locatorId.longValue() == locator.getLocatorId()) && (descriptor instanceof ActiveDescriptor)) { return locator.getServiceHandle((ActiveDescriptor<T>) descriptor).getService(); } ActiveDescriptor<T> found = findOneDescriptor(locator, descriptor); if (found == null) return null; return locator.getServiceHandle(found).getService(); }
/** * Returns the service in this service locator given the current descriptor. * * @param locator The non-null locator in which to get the service associated with * this descriptor * @param descriptor The non-null descriptor to find the corresponding service for * @return The service object */ @SuppressWarnings("unchecked") public static <T> T getService(ServiceLocator locator, Descriptor descriptor) { if (locator == null || descriptor == null) throw new IllegalArgumentException(); Long locatorId = descriptor.getLocatorId(); if (locatorId != null && (locatorId.longValue() == locator.getLocatorId()) && (descriptor instanceof ActiveDescriptor)) { return locator.getServiceHandle((ActiveDescriptor<T>) descriptor).getService(); } ActiveDescriptor<T> found = findOneDescriptor(locator, descriptor); if (found == null) return null; return locator.getServiceHandle(found).getService(); }
/** * This method will add the ability to use the {@link Immediate} scope to * the given locator. If the locator already has a {@link Context} implementation * that handles the {@link Immediate} scope this method does nothing. The Immediate * scope will start in the suspended state, allowing the caller to customize the * Immediate scope using the {@link ImmediateController} * <p> * * @param locator The non-null locator to enable the Immediate scope on * @return The ImmediateController that can be used to further configure * the Immediate scope * @throws MultiException if there were errors when committing the service */ public static ImmediateController enableImmediateScopeSuspended(ServiceLocator locator) { List<ServiceHandle<?>> immediateContexts = locator.getAllServiceHandles((new TypeLiteral<Context<Immediate>>() {}).getType()); for (ServiceHandle<?> immediateContext : immediateContexts) { ActiveDescriptor<?> contextDescriptor = immediateContext.getActiveDescriptor(); if (contextDescriptor.getLocatorId() == locator.getLocatorId()) { return locator.getService(ImmediateController.class); } } addClasses(locator, ImmediateContext.class, ImmediateHelper.class); return locator.getService(ImmediateController.class); }
/** * This method will add the ability to use the {@link Immediate} scope to * the given locator. If the locator already has a {@link Context} implementation * that handles the {@link Immediate} scope this method does nothing. The Immediate * scope will start in the suspended state, allowing the caller to customize the * Immediate scope using the {@link ImmediateController} * <p> * * @param locator The non-null locator to enable the Immediate scope on * @return The ImmediateController that can be used to further configure * the Immediate scope * @throws MultiException if there were errors when committing the service */ public static ImmediateController enableImmediateScopeSuspended(ServiceLocator locator) { List<ServiceHandle<?>> immediateContexts = locator.getAllServiceHandles((new TypeLiteral<Context<Immediate>>() {}).getType()); for (ServiceHandle<?> immediateContext : immediateContexts) { ActiveDescriptor<?> contextDescriptor = immediateContext.getActiveDescriptor(); if (contextDescriptor.getLocatorId() == locator.getLocatorId()) { return locator.getService(ImmediateController.class); } } addClasses(locator, ImmediateContext.class, ImmediateHelper.class); return locator.getService(ImmediateController.class); }
/** * This method will add the ability to use the {@link Immediate} scope to * the given locator. If the locator already has a {@link Context} implementation * that handles the {@link Immediate} scope this method does nothing. The Immediate * scope will start in the suspended state, allowing the caller to customize the * Immediate scope using the {@link ImmediateController} * <p> * * @param locator The non-null locator to enable the Immediate scope on * @return The ImmediateController that can be used to further configure * the Immediate scope * @throws MultiException if there were errors when committing the service */ public static ImmediateController enableImmediateScopeSuspended(ServiceLocator locator) { List<ServiceHandle<?>> immediateContexts = locator.getAllServiceHandles((new TypeLiteral<Context<Immediate>>() {}).getType()); for (ServiceHandle<?> immediateContext : immediateContexts) { ActiveDescriptor<?> contextDescriptor = immediateContext.getActiveDescriptor(); if (contextDescriptor.getLocatorId() == locator.getLocatorId()) { return locator.getService(ImmediateController.class); } } addClasses(locator, ImmediateContext.class, ImmediateHelper.class); return locator.getService(ImmediateController.class); }