public static Module getModule(Application instance, String name) { for (Module module : instance.getModule()) { if (module.getName().equals(name)) { return module; } } return null; }
public static Module getModule(Application instance, String name) { for (Module module : instance.getModule()) { if (module.getName().equals(name)) { return module; } } return null; }
private String webModuleList(final Application app) { /* * Build a list of web module names to include in the error message. */ final StringBuilder moduleNames = new StringBuilder(); for (Module m : app.getModule()) { if (m.getEngine("web") != null) { moduleNames.append((moduleNames.length() > 0 ? ", " : "")). append(m.getName()); } } return moduleNames.toString(); }
private void preserveResources(Application app) { String appName = app.getName(); Map<String, Resources> allResources = new HashMap<String, Resources>(); Resources appScopedResources = app.getResources(); if(appScopedResources != null){ allResources.put(appName, appScopedResources); } List<Module> modules = app.getModule(); if(modules != null){ for(Module module : modules){ Resources moduleScopedResources = module.getResources(); if(moduleScopedResources != null){ allResources.put(module.getName(), moduleScopedResources); } } } //store the resource-configuration resourceConfigurations.put(appName, allResources); }
public static Map<String, Properties> getModulePropertiesMap( Application me) { Map<String, Properties> modulePropertiesMap = new HashMap<String, Properties>(); for (Module module: me.getModule()) { if (module.getProperty() != null) { Properties moduleProps = new Properties(); for (Property property : module.getProperty()) { moduleProps.put(property.getName(), property.getValue()); } modulePropertiesMap.put(module.getName(), moduleProps); } } return modulePropertiesMap; }
private void preserveResources(Application app) { String appName = app.getName(); Map<String, Resources> allResources = new HashMap<String, Resources>(); Resources appScopedResources = app.getResources(); if(appScopedResources != null){ allResources.put(appName, appScopedResources); } List<Module> modules = app.getModule(); if(modules != null){ for(Module module : modules){ Resources moduleScopedResources = module.getResources(); if(moduleScopedResources != null){ allResources.put(module.getName(), moduleScopedResources); } } } //store the resource-configuration ResourcesRegistry.putResources(appName, allResources); }
public static Map<String, Properties> getModulePropertiesMap( Application me) { Map<String, Properties> modulePropertiesMap = new HashMap<String, Properties>(); for (Module module : me.getModule()) { if (module.getProperty() != null) { Properties moduleProps = new Properties(); for (Property property : module.getProperty()) { if (property.getValue() != null) { moduleProps.put(property.getName(), property.getValue()); } } modulePropertiesMap.put(module.getName(), moduleProps); } } return modulePropertiesMap; }
private void createModuleScopedResources(Application app, Module module, List<org.glassfish.resources.api.Resource> resources, DeploymentContext dc, boolean embedded) throws ResourceException { try { if (resources != null) { Resources msc = dc.getTransientAppMetaData(module.getName()+"-resources", Resources.class); if (msc == null) { msc = module.createChild(Resources.class); module.setResources(msc); dc.addTransientAppMetaData(module.getName()+"-resources", msc); ApplicationInfo appInfo = appRegistry.get(app.getName()); if(appInfo != null){ appInfo.addTransientAppMetaData(module.getName()+"-resources", msc); } } createConfig(msc, resources, embedded); preserveResources(msc, app.getName(), module.getName()); } } catch (Exception e) { Object params[] = new Object[]{module.getName(),app.getName(), e}; _logger.log(Level.SEVERE, "gf.resources.module.scope.deployment.failure", params); throw new ResourceException(e); } }
private static void createModuleScopedResources(Application app, Module module, List<org.glassfish.resource.common.Resource> resources, DeploymentContext dc, boolean embedded) throws ResourceException { try { if (resources != null) { Resources msc = dc.getTransientAppMetaData(module.getName()+"-resources", Resources.class); if (msc == null) { msc = module.createChild(Resources.class); module.setResources(msc); dc.addTransientAppMetaData(module.getName()+"-resources", msc); ApplicationInfo appInfo = appRegistry.get(app.getName()); if(appInfo != null){ appInfo.addTransientAppMetaData(module.getName()+"-resources", msc); } } createConfig(msc, resources, embedded); preserveResources(msc, app.getName(), module.getName()); } } catch (Exception e) { Object params[] = new Object[]{module.getName(),app.getName(), e}; _logger.log(Level.SEVERE, "gf.resources.module.scope.deployment.failure", params); throw new ResourceException(e); } }
/** * 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); } } } } }
public ApplicationConfigInfo(final Application app) { moduleToEngineToAppConfig = createNewMap(); if (app != null) { for (Module m : app.getModule()) { for (Engine e : m.getEngines()) { put(m.getName(), e.getSniffer(), e.getApplicationConfig()); } } } }
/** * 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); } } } } }
public void deployResourcesFromConfiguration(String appName, boolean embedded) throws Exception { Application application = applications.getApplication(appName); ApplicationInfo appInfo = appRegistry.get(appName); if(application != null && appInfo != null){ Resources appScopedResources = application.getResources(); if(appScopedResources != null){ deployResources(appName, null, appScopedResources.getResources(), embedded); } List<Module> modules = application.getModule(); if(modules != null){ for(Module module : modules){ Resources moduleScopedResources = module.getResources(); String moduleName = module.getName(); if(moduleScopedResources != null){ deployResources(appName, moduleName, moduleScopedResources.getResources(), embedded); } } } } }
public static void deployResourcesFromConfiguration(String appName, boolean embedded) throws Exception { Application application = applications.getApplication(appName); ApplicationInfo appInfo = appRegistry.get(appName); if(application != null && appInfo != null){ Resources appScopedResources = application.getResources(); if(appScopedResources != null){ deployResources(appName, null, appScopedResources.getResources(), embedded); } List<Module> modules = application.getModule(); if(modules != null){ for(Module module : modules){ Resources moduleScopedResources = module.getResources(); String moduleName = module.getName(); if(moduleScopedResources != null){ deployResources(appName, moduleName, moduleScopedResources.getResources(), embedded); } } } } }
public static ResourceInfo getGenericResourceInfo(Resource resource, String resourceName){ if(resource.getParent() != null && resource.getParent().getParent() instanceof Application){ Application application = (Application)resource.getParent().getParent(); return new ResourceInfo(resourceName, application.getName()); }else if(resource.getParent() != null && resource.getParent().getParent() instanceof Module){ Module module = (Module)resource.getParent().getParent(); Application application = (Application)module.getParent(); return new ResourceInfo(resourceName, application.getName(), module.getName()); }else{ return new ResourceInfo(resourceName); } }
public static ResourceInfo getGenericResourceInfo(Resource resource, String resourceName){ if(resource.getParent() != null && resource.getParent().getParent() instanceof Application){ Application application = (Application)resource.getParent().getParent(); return new ResourceInfo(resourceName, application.getName()); }else if(resource.getParent() != null && resource.getParent().getParent() instanceof Module){ Module module = (Module)resource.getParent().getParent(); Application application = (Application)module.getParent(); return new ResourceInfo(resourceName, application.getName(), module.getName()); }else{ return new ResourceInfo(resourceName); } }
public static ResourceInfo getResourceInfo(BindableResource resource){ if(resource.getParent() != null && resource.getParent().getParent() instanceof Application){ Application application = (Application)resource.getParent().getParent(); return new ResourceInfo(resource.getJndiName(), application.getName()); }else if(resource.getParent() != null && resource.getParent().getParent() instanceof Module){ Module module = (Module)resource.getParent().getParent(); Application application = (Application)module.getParent(); return new ResourceInfo(resource.getJndiName(), application.getName(), module.getName()); }else{ return new ResourceInfo(resource.getJndiName()); } }
public static PoolInfo getPoolInfo(ResourcePool resource){ if(resource.getParent() != null && resource.getParent().getParent() instanceof Application){ Application application = (Application)resource.getParent().getParent(); return new PoolInfo(resource.getName(), application.getName()); }else if(resource.getParent() != null && resource.getParent().getParent() instanceof Module){ Module module = (Module)resource.getParent().getParent(); Application application = (Application)module.getParent(); return new PoolInfo(resource.getName(), application.getName(), module.getName()); }else{ return new PoolInfo(resource.getName()); } }
public static ResourceInfo getResourceInfo(BindableResource resource){ if(resource.getParent() != null && resource.getParent().getParent() instanceof Application){ Application application = (Application)resource.getParent().getParent(); return new ResourceInfo(resource.getJndiName(), application.getName()); }else if(resource.getParent() != null && resource.getParent().getParent() instanceof Module){ Module module = (Module)resource.getParent().getParent(); Application application = (Application)module.getParent(); return new ResourceInfo(resource.getJndiName(), application.getName(), module.getName()); }else{ return new ResourceInfo(resource.getJndiName()); } }
public static PoolInfo getPoolInfo(ResourcePool resource){ if(resource.getParent() != null && resource.getParent().getParent() instanceof Application){ Application application = (Application)resource.getParent().getParent(); return new PoolInfo(resource.getName(), application.getName()); }else if(resource.getParent() != null && resource.getParent().getParent() instanceof Module){ Module module = (Module)resource.getParent().getParent(); Application application = (Application)module.getParent(); return new PoolInfo(resource.getName(), application.getName(), module.getName()); }else{ return new PoolInfo(resource.getName()); } }