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.bean.builtin;
 
 import static org.jboss.weld.ContainerState.SHUTDOWN;
 
 import java.util.List;
 import java.util.Set;
 
 
Client view of org.jboss.weld.manager.BeanManagerImpl.

Author(s):
Martin Kouba
 
 public class BeanManagerProxy extends ForwardingBeanManager implements WeldManager {
 
     private static final String GET_BEANS_METHOD_NAME = "getBeans()";
 
     private static final long serialVersionUID = -6990849486568169846L;
 
     private final BeanManagerImpl manager;
     private transient volatile Container container;
     private final boolean nonPortableMode;
 
     public BeanManagerProxy(BeanManagerImpl manager) {
         this. = manager;
             this. = true;
         } else {
             this. = manager.getServices().get(BootstrapConfiguration.class).isNonPortableModeEnabled();
         }
     }
 
     @Override
     public BeanManagerImpl delegate() {
         return ;
     }
 
     @Override
     public Object getReference(Bean<?> beanType beanTypeCreationalContext<?> ctx) {
         checkContainerState("getReference()".);
         return super.getReference(beanbeanTypectx);
     }
 
     @Override
         checkContainerState("getInjectableReference()".);
         return super.getInjectableReference(ijctx);
     }
 
     @Override
     public Set<Bean<?>> getBeans(Type beanTypeAnnotation... qualifiers) {
        return super.getBeans(beanTypequalifiers);
    }
    @Override
    public Set<Bean<?>> getBeans(String name) {
        return super.getBeans(name);
    }
    @Override
    public Bean<?> getPassivationCapableBean(String id) {
        checkContainerState("getPassivationCapableBean()");
        return super.getPassivationCapableBean(id);
    }
    @Override
    public <X> Bean<? extends X> resolve(Set<Bean<? extends X>> beans) {
        checkContainerState("resolve()");
        return super.resolve(beans);
    }
    @Override
    public void validate(InjectionPoint injectionPoint) {
        checkContainerState("validate()");
        super.validate(injectionPoint);
    }
    @Override
    public <T> Set<ObserverMethod<? super T>> resolveObserverMethods(T eventAnnotation... qualifiers) {
        checkContainerState("resolveObserverMethods()");
        return super.resolveObserverMethods(eventqualifiers);
    }
    @Override
    public List<Decorator<?>> resolveDecorators(Set<TypetypesAnnotation... qualifiers) {
        checkContainerState("resolveDecorators()");
        return super.resolveDecorators(typesqualifiers);
    }
    @Override
    public List<Interceptor<?>> resolveInterceptors(InterceptionType typeAnnotation... interceptorBindings) {
        checkContainerState("resolveInterceptors()");
        return super.resolveInterceptors(typeinterceptorBindings);
    }
    @Override
    public WeldManager createActivity() {
        return delegate().createActivity();
    }
    @Override
    public WeldManager setCurrent(Class<? extends AnnotationscopeType) {
        return delegate().setCurrent(scopeType);
    }
    @Override
    public <T> InjectionTarget<T> createInjectionTarget(EjbDescriptor<T> descriptor) {
        return delegate().createInjectionTarget(descriptor);
    }
    @Override
    public <T> Bean<T> getBean(EjbDescriptor<T> descriptor) {
        return delegate().getBean(descriptor);
    }
    @Override
    public <T> EjbDescriptor<T> getEjbDescriptor(String ejbName) {
        return delegate().getEjbDescriptor(ejbName);
    }
    @Override
    public ServiceRegistry getServices() {
        return delegate().getServices();
    }
    @Override
    public WeldManager getCurrent() {
        return delegate().getCurrent();
    }
    @Override
    public <X> InjectionTarget<X> fireProcessInjectionTarget(AnnotatedType<X> type) {
        return delegate().fireProcessInjectionTarget(type);
    }
    @Override
    public <X> InjectionTarget<X> fireProcessInjectionTarget(AnnotatedType<X> annotatedTypeInjectionTarget<X> injectionTarget) {
        return delegate().fireProcessInjectionTarget(annotatedTypeinjectionTarget);
    }
    @Override
    public String getId() {
        return delegate().getId();
    }
    @Override
    public Instance<Objectinstance() {
        return delegate().instance();
    }
    @Override
    public Bean<?> getPassivationCapableBean(BeanIdentifier identifier) {
        return delegate().getPassivationCapableBean(identifier);
    }
    @Override
        return delegate().createInjectionTargetBuilder(type);
    }
    @Override
    public <T> WeldInjectionTargetFactory<T> getInjectionTargetFactory(AnnotatedType<T> annotatedType) {
        return delegate().getInjectionTargetFactory(annotatedType);
    }
    @Override
    public <T> WeldCreationalContext<T> createCreationalContext(Contextual<T> contextual) {
        return delegate().createCreationalContext(contextual);
    }
    protected Object readResolve() throws ObjectStreamException {
        return new BeanManagerProxy(this.);
    }

    
When in portable mode (default) this method verifies that the container has reached the specified minimal state. If it hasn't, an org.jboss.weld.exceptions.IllegalStateException is thrown. When in non-portable mode this method is no-op.

Parameters:
methodName
minimalState the minimal state
Throws:
org.jboss.weld.exceptions.IllegalStateException If the application initialization is not finished yet
    private void checkContainerState(String methodNameContainerState minimalState) {
        if () {
            return;
        }
        if (this. == null) {
            this. = Container.instance();
        }
        ContainerState state = .getState();
        if (.equals(state)) {
            throw ..methodNotAvailableAfterShutdown(methodName);
        }
        if (state.compareTo(minimalState) < 0) {
            throw ..methodNotAvailableDuringInitialization(methodName);
        }
    }
    private void checkContainerState(String methodName) {
        checkContainerState(methodName.);
    }
    public static BeanManagerImpl unwrap(BeanManager manager) {
        if (manager instanceof ForwardingBeanManager) {
            manager = Reflections.<ForwardingBeanManagercast(manager).delegate();
        }
        if (manager instanceof BeanManagerImpl) {
            return (BeanManagerImplmanager;
        }
        throw new IllegalArgumentException("Unknown BeanManager " + manager);
    }
    @Override
    public BeanManagerImpl unwrap() {
        return delegate();
    }
New to GrepCode? Check out our FAQ X