Пример #1
0
 private Iterable<Metadata<Extension>> getExtensions(
     ClassLoader classLoader, Bootstrap bootstrap) {
   Set<Metadata<Extension>> result = new HashSet<Metadata<Extension>>();
   if (discoveryEnabled) {
     Iterables.addAll(result, bootstrap.loadExtensions(classLoader));
   }
   if (!extensions.isEmpty()) {
     result.addAll(extensions);
   }
   // Ensure that WeldSEBeanRegistrant is present
   WeldSEBeanRegistrant weldSEBeanRegistrant = null;
   for (Metadata<Extension> metadata : result) {
     if (metadata.getValue().getClass().getName().equals(WeldSEBeanRegistrant.class.getName())) {
       weldSEBeanRegistrant = (WeldSEBeanRegistrant) metadata.getValue();
       break;
     }
   }
   if (weldSEBeanRegistrant == null) {
     try {
       weldSEBeanRegistrant = SecurityActions.newInstance(WeldSEBeanRegistrant.class);
       result.add(
           new MetadataImpl<Extension>(
               weldSEBeanRegistrant,
               SYNTHETIC_LOCATION_PREFIX + WeldSEBeanRegistrant.class.getName()));
     } catch (Exception e) {
       throw new RuntimeException(e);
     }
   }
   if (!beanBuilders.isEmpty()) {
     weldSEBeanRegistrant.setBeanBuilders(beanBuilders);
   }
   return result;
 }
Пример #2
0
 public boolean associate(HttpServletRequest request) {
   // At this point the bean store should never be set - see also
   // HttpContextLifecycle#nestedInvocationGuard
   BoundBeanStore beanStore = getBeanStore();
   if (beanStore != null) {
     ContextLogger.LOG.beanStoreLeakDuringAssociation(this.getClass().getName(), request);
     if (ContextLogger.LOG.isDebugEnabled()) {
       ContextLogger.LOG.beanStoreLeakAffectedBeanIdentifiers(
           this.getClass().getName(), Iterables.toMultiRowString(beanStore));
     }
   }
   // We always associate a new bean store to avoid possible leaks (security threats)
   beanStore = new RequestBeanStore(request, namingScheme);
   setBeanStore(beanStore);
   beanStore.attach();
   return true;
 }
Пример #3
0
 private void setExtensions(Iterable<Metadata<Extension>> extensions) {
   this.extensions = new ArrayList<Metadata<? extends Extension>>();
   Iterables.addAll(this.extensions, extensions);
 }