/** * retain old resource configuration for the new archive being deployed. * @param dc DeploymentContext * @param allResources all resources (app scoped, module scoped) of old application * @throws Exception when unable to retain old resource configuration. */ public static void retainResourceConfig(DeploymentContext dc, Map<String, Resources> allResources) throws Exception { String appName = getAppNameFromDeployCmdParams(dc); Application application = dc.getTransientAppMetaData(Application.APPLICATION, Application.class); Resources appScopedResources = allResources.get(appName); if(appScopedResources != null){ application.setResources(appScopedResources); } if(DeploymentUtils.isEAR(dc.getSource())){ List<Module> modules = application.getModule(); if(modules != null){ for(Module module : modules){ Resources moduleScopedResources = allResources.get(module.getName()); if(moduleScopedResources != null){ module.setResources(moduleScopedResources); } } } } }
/** * retain old resource configuration for the new archive being deployed. * @param dc DeploymentContext * @param allResources all resources (app scoped, module scoped) of old application * @throws Exception when unable to retain old resource configuration. */ public void retainResourceConfig(DeploymentContext dc, Map<String, Resources> allResources) throws Exception { String appName = getAppNameFromDeployCmdParams(dc); Application application = dc.getTransientAppMetaData(ServerTags.APPLICATION, Application.class); Resources appScopedResources = allResources.get(appName); if(appScopedResources != null){ application.setResources(appScopedResources); } if(DeploymentUtils.isArchiveOfType(dc.getSource(), DOLUtils.earType(), locator)){ List<Module> modules = application.getModule(); if(modules != null){ for(Module module : modules){ Resources moduleScopedResources = allResources.get(module.getName()); if(moduleScopedResources != null){ module.setResources(moduleScopedResources); } } } } }
private void createAppScopedResources(Application app, List<org.glassfish.resources.api.Resource> resources, DeploymentContext dc, boolean embedded) throws ResourceException { try { if (resources != null) { Application application = dc.getTransientAppMetaData(ServerTags.APPLICATION, Application.class); Resources asc = dc.getTransientAppMetaData(APP_META_DATA_RESOURCES, Resources.class); if (asc == null) { asc = application.createChild(Resources.class); application.setResources(asc); dc.addTransientAppMetaData(APP_META_DATA_RESOURCES, asc); ApplicationInfo appInfo = appRegistry.get(app.getName()); if(appInfo != null){ appInfo.addTransientAppMetaData(app.getName()+"-resources", asc); } } createConfig(asc, resources, embedded); String appName = app.getName(); preserveResources(asc, appName, appName); } } catch (Exception e) { Object params[] = new Object[]{app.getName(), e}; _logger.log(Level.SEVERE, "gf.resources.app.scope.deployment.failure", params); throw new ResourceException(e); } }
private static void createAppScopedResources(Application app, List<org.glassfish.resource.common.Resource> resources, DeploymentContext dc, boolean embedded) throws ResourceException { try { if (resources != null) { Application application = dc.getTransientAppMetaData(Application.APPLICATION, Application.class); Resources asc = dc.getTransientAppMetaData(ConnectorConstants.APP_META_DATA_RESOURCES, Resources.class); if (asc == null) { asc = application.createChild(Resources.class); application.setResources(asc); dc.addTransientAppMetaData(ConnectorConstants.APP_META_DATA_RESOURCES, asc); ApplicationInfo appInfo = appRegistry.get(app.getName()); if(appInfo != null){ appInfo.addTransientAppMetaData(app.getName()+"-resources", asc); } } createConfig(asc, resources, embedded); String appName = app.getName(); preserveResources(asc, appName, appName); } } catch (Exception e) { Object params[] = new Object[]{app.getName(), e}; _logger.log(Level.SEVERE, "gf.resources.app.scope.deployment.failure", params); throw new ResourceException(e); } }