Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * JBoss, Home of Professional Open Source
   * Copyright 2012, Red Hat, Inc., and individual contributors
   * by the @authors tag. See the copyright.txt in the distribution for a
   * full listing of individual contributors.
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
  * http://www.apache.org/licenses/LICENSE-2.0
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 package org.jboss.weld.event;
 
 import java.util.Set;
 
 import  javax.servlet.ServletContextEvent;
 
 
Hosts a ObserverNotifier that uses the global TypeSafeObserverResolver which has access to every enabled observer method in the deployment. The underlying ObserverNotifier should be used every time an event is fired, except for special cases such as ServletContextEvent, where the event is only fired to BDAs accessible from the web archive.

Author(s):
Jozef Hartinger
 
 public class GlobalObserverNotifierService implements BootstrapService {
 
     private static class BeanManagerToObserverMethodIterable implements Function <BeanManagerImplIterator<ObserverMethod<?>>> {
         @Override
         public Iterator<ObserverMethod<?>> apply(BeanManagerImpl manager) {
             return manager.getObservers().iterator();
         }
     }
 
     private final Set<BeanManagerImplbeanManagers;
 
     public GlobalObserverNotifierService(ServiceRegistry servicesString contextId) {
         this. = new CopyOnWriteArraySet<BeanManagerImpl>();
         TypeSafeObserverResolver resolver = new TypeSafeObserverResolver(services.get(MetaAnnotationStore.class),
                 createGlobalObserverMethodIterable());
         this. = ObserverNotifier.of(contextIdresolverservicesfalse);
         this. = ObserverNotifier.of(contextIdresolverservicestrue);
     }
 
     private static Iterable<ObserverMethod<?>> createGlobalObserverMethodIterable(final Set<BeanManagerImplbeanManagers) {
         return new Iterable<ObserverMethod<?>>() {
             @Override
             public Iterator<ObserverMethod<?>> iterator() {
                 Iterator<Iterator<ObserverMethod<?>>> observerMethodIterators = Iterators.transform(beanManagers.iterator(), new BeanManagerToObserverMethodIterable());
                 return Iterators.concat(observerMethodIterators);
             }
         };
     }
 
     public void registerBeanManager(BeanManagerImpl manager) {
         this..add(manager);
     }
 
         return ;
     }
 
         return ;
     }
 
     public Iterable<ObserverMethod<?>> getAllObserverMethods() {
     }
 
     @Override
     public void cleanupAfterBoot() {
         this..clear();
         this..clear();
     }
 
     @Override
     public void cleanup() {
         cleanupAfterBoot();
         this..clear();
    }
New to GrepCode? Check out our FAQ X