Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * JBoss, Home of Professional Open Source
   * Copyright 2008, 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;
 
 import java.util.Map;
 
A Weld application container

Author(s):
pmuir
 
 public class Container {
     public static final String CONTEXT_ID_KEY = "WELD_CONTEXT_ID_KEY";
 
     public static final ThreadLocal<StringcurrentId = new ThreadLocal<String>();
 
     private static Singleton<Containerinstance;
 
     static {
          = SingletonProvider.instance().create(Container.class);
     }

    
Get the container for the current application deployment

Returns:
 
     public static Container instance() {
     }
 
     public static boolean available() {
         return .isSet(id) && .get(id) != null
                 && .get(id).getState().isAvailable();
     }
 
     public static Container instance(String contextId) {
         return .get(contextId);
     }
 
     public static Container instance(BeanManagerImpl manager) {
         return instance(manager.getContextId());
     }
 
     public static Container instance(AnnotatedTypeIdentifier identifier) {
         return instance(identifier.getContextId());
     }
 
     public static boolean available(String contextId) {
         boolean b = .isSet(contextId) && instance(contextId) != null
                 && instance(contextId).getState().isAvailable();
         return b;
     }

    
Initialize the container for the current application deployment

Parameters:
deploymentManager
deploymentServices
 
     public static void initialize(BeanManagerImpl deploymentManagerServiceRegistry deploymentServices) {
         Container instance = new Container(.deploymentManagerdeploymentServices);
     }
 
     public static void initialize(String contextIdBeanManagerImpl deploymentManagerServiceRegistry deploymentServices) {
         Container instance = new Container(contextIddeploymentManagerdeploymentServices);
         ..set(contextIdinstance);
     }
 
     private final String contextId;
 
    // The deployment bean manager
    private final BeanManagerImpl deploymentManager;
    // A map of managers keyed by ID, used for activities and serialization
    private final Map<StringBeanManagerImplmanagers;
    // A map of BDA -> bean managers
    private final ServiceRegistry deploymentServices;
    public Container(String contextIdBeanManagerImpl deploymentManagerServiceRegistry deploymentServices) {
        this. = deploymentManager;
        this. = new ConcurrentHashMap<StringBeanManagerImpl>();
        this..put(deploymentManager.getId(), deploymentManager);
        this. = deploymentServices;
        this. = contextId;
    }
    public Container(BeanManagerImpl deploymentManagerServiceRegistry deploymentServices) {
        this. = deploymentManager;
        this. = new ConcurrentHashMap<StringBeanManagerImpl>();
        this..put(deploymentManager.getId(), deploymentManager);
        this. = deploymentServices;
    }

    
Cause the container to be cleaned up, including all registered bean managers, and all deployment services
    public void cleanup() {
        // TODO We should probably cleanup the bean managers for activities?
        .clear();
        for (BeanManagerImpl beanManager : .values()) {
            beanManager.cleanup();
        }
        .clear();
        .cleanup();
        .cleanup();
        .clear();
    }

    
Gets the manager for this application deployment
        return ;
    }
        return ;
    }

    
Get the activity manager for a given key

Parameters:
key
Returns:
    public BeanManagerImpl activityManager(String key) {
        return .get(key);
    }

    
Add an activity

Parameters:
manager
Returns:
    public String addActivity(BeanManagerImpl manager) {
        String id = manager.getId();
        if (manager.getId() == null) {
            throw ..nullBeanManagerId();
        }
        .put(idmanager);
        return id;
    }

    
Get the services for this application deployment

Returns:
the deploymentServices
    public ServiceRegistry services() {
        return ;
    }

    
Add sub-deployment units to the container

Parameters:
bdaMapping
    public void putBeanDeployments(BeanDeploymentArchiveMapping bdaMapping) {
        for (Entry<BeanDeploymentArchiveBeanManagerImplentry : bdaMapping.getBdaToBeanManagerMap().entrySet()) {
            .put(entry.getKey(), entry.getValue());
            addActivity(entry.getValue());
        }
    }
    public ContainerState getState() {
        return ;
    }
    public void setState(ContainerState state) {
        this. = state;
    }
New to GrepCode? Check out our FAQ X