public WeldApplicationContainer load(WeldContainer container, DeploymentContext context) {
DeployCommandParameters deployParams = context.getCommandParameters(DeployCommandParameters.class);
ApplicationInfo appInfo = applicationRegistry.get(deployParams.name);
ReadableArchive archive = context.getSource();
// See if a WeldBootsrap has already been created - only want one per app.
WeldBootstrap bootstrap = context.getTransientAppMetaData(WELD_BOOTSTRAP,
WeldBootstrap.class);
if ( bootstrap == null) {
bootstrap = new WeldBootstrap();
Application app = context.getModuleMetaData(Application.class);
appToBootstrap.put(app, bootstrap);
// Stash the WeldBootstrap instance, so we may access the WeldManager later..
context.addTransientAppMetaData(WELD_BOOTSTRAP, bootstrap);
appInfo.addTransientAppMetaData(WELD_BOOTSTRAP, bootstrap);
// Making sure that if WeldBootstrap is added, shutdown is set to false, as it is/would not have been called.
appInfo.addTransientAppMetaData(WELD_BOOTSTRAP_SHUTDOWN, "false");
}
EjbBundleDescriptor ejbBundle = getEjbBundleFromContext(context);
EjbServices ejbServices = null;
Set<EjbDescriptor> ejbs = new HashSet<EjbDescriptor>();
if( ejbBundle != null ) {
ejbs.addAll(ejbBundle.getEjbs());
ejbServices = new EjbServicesImpl(services);
}
// Create a Deployment Collecting Information From The ReadableArchive (archive)
DeploymentImpl deploymentImpl = context.getTransientAppMetaData(WELD_DEPLOYMENT, DeploymentImpl.class);
if (deploymentImpl == null) {
deploymentImpl = new DeploymentImpl(archive, ejbs, context, archiveFactory);
// Add services
TransactionServices transactionServices = new TransactionServicesImpl(services);
deploymentImpl.getServices().add(TransactionServices.class, transactionServices);
// JJS: commented out next 2 lines as the new hibernate validator provides this via their
// portable extensions.
//ValidationServices validationServices = new ValidationServicesImpl();
//deploymentImpl.getServices().add(ValidationServices.class, validationServices);
SecurityServices securityServices = new SecurityServicesImpl();
deploymentImpl.getServices().add(SecurityServices.class, securityServices);
ProxyServices proxyServices = new ProxyServicesImpl(services);
deploymentImpl.getServices().add(ProxyServices.class, proxyServices);
BootstrapConfigurationImpl bootstrapConfiguration = new BootstrapConfigurationImpl();
deploymentImpl.getServices().add(BootstrapConfiguration.class, bootstrapConfiguration);
} else {
deploymentImpl.scanArchive(archive, ejbs, context);
}
deploymentImpl.addDeployedEjbs(ejbs);
if( ejbBundle != null && (!deploymentImpl.getServices().contains(EjbServices.class))) {
// EJB Services is registered as a top-level service
deploymentImpl.getServices().add(EjbServices.class, ejbServices);
}
BeanDeploymentArchive bda = deploymentImpl.getBeanDeploymentArchiveForArchive(archive.getName());
if (bda != null && !bda.getBeansXml().getBeanDiscoveryMode().equals(BeanDiscoveryMode.NONE)) {
WebBundleDescriptor wDesc = context.getModuleMetaData(WebBundleDescriptor.class);
if( wDesc != null) {
wDesc.setExtensionProperty(WELD_EXTENSION, "true");