private ApplicationInfo getApplicationInfo(EjbContainerUtil ejbUtil) throws NamingException { ApplicationRegistry appRegistry = ejbUtil.getServices().getService(ApplicationRegistry.class); Applications applications = ejbUtil.getServices().getService(Applications.class); String appNamePrefix = (String) initialContext.lookup("java:app/AppName"); Set<String> appNames = appRegistry.getAllApplicationNames(); Set<String> disabledApps = new TreeSet<>(); for (String appName : appNames) { if (appName.startsWith(appNamePrefix)) { Application appDesc = applications.getApplication(appName); if (appDesc != null && !ejbUtil.getDeployment().isAppEnabled(appDesc)) { // skip disabled version of the app disabledApps.add(appName); } else { return ejbUtil.getDeployment().get(appName); } } } // grab the latest one, there is no way to make // sure which one the user is actually enabling, // so use the best case, i.e. upgrade Iterator<String> it = disabledApps.iterator(); String lastDisabledApp = null; while (it.hasNext()) { lastDisabledApp = it.next(); } if (lastDisabledApp != null) { return ejbUtil.getDeployment().get(lastDisabledApp); } throw new NamingException("Application Information Not Found"); }
public static List<Application> getApplicationsInTarget(Domain me, String target) { if (target.equals("domain")) { // special target domain return me.getApplications().getApplications(); } List<Application> apps = new ArrayList<Application>(); List<ApplicationRef> applicationRefs = me.getApplicationRefsInTarget(target); for (ApplicationRef ref : applicationRefs) { Application app = me.getApplications().getApplication(ref.getRef()); if (app != null) { apps.add(app); } } return apps; }
public boolean isRegistered(String appName) { return applications.getApplication(appName)!=null; }
public static List<Application> getApplicationsInTarget(Domain me, String target) { if (target.equals("domain")) { // special target domain return me.getApplications().getApplications(); } List<Application> apps = new ArrayList<Application>(); List<ApplicationRef> applicationRefs = me.getApplicationRefsInTarget(target); for (ApplicationRef ref : applicationRefs) { Application app = me.getApplications().getApplication(ref.getRef()); if (app != null) { apps.add(app); } } return apps; }
public boolean isRegistered(String appName) { return applications.getApplication(appName)!=null; }
public Resources getResources(String applicationName){ Application app = applications.getApplication(applicationName); if(app != null){ return app.getResources(); } return null; }
private boolean isApplicationEnabled(String appId) { if (appId != null) { Application app = applications.getApplication(appId); if (app != null) return deployment.isAppEnabled(app); } return false; }
public void validateUndeploymentTarget(String target, String name) { List<String> referencedTargets = domain.getAllReferencedTargetsForApplication(name); if (referencedTargets.size() > 1) { Application app = applications.getApplication(name); if (!DeploymentUtils.isDomainTarget(target)) { if (app.isLifecycleModule()) { throw new IllegalArgumentException(localStrings.getLocalString("delete_lifecycle_on_multiple_targets", "Lifecycle module {0} is referenced by more than one targets. Please remove other references before attempting delete operation.", name)); } else { throw new IllegalArgumentException(localStrings.getLocalString("undeploy_on_multiple_targets", "Application {0} is referenced by more than one targets. Please remove other references or specify all targets (or domain target if using asadmin command line) before attempting undeploy operation.", name)); } } } }
public void validateUndeploymentTarget(String target, String name) { List<String> referencedTargets = domain.getAllReferencedTargetsForApplication(name); if (referencedTargets.size() > 1) { Application app = applications.getApplication(name); if (!DeploymentUtils.isDomainTarget(target)) { if (app.isLifecycleModule()) { throw new IllegalArgumentException(localStrings.getLocalString("delete_lifecycle_on_multiple_targets", "Lifecycle module {0} is referenced by more than one targets. Please remove other references before attempting delete operation.", name)); } else { throw new IllegalArgumentException(localStrings.getLocalString("undeploy_on_multiple_targets", "Application {0} is referenced by more than one targets. Please remove other references or specify all targets (or domain target if using asadmin command line) before attempting undeploy operation.", name)); } } } }
private boolean isRarEnabled(String raName) { if(raName == null || raName.length() == 0) return false; Application application = getDomain().getApplications().getApplication(raName); if(application != null) { return isApplicationReferenceEnabled(raName); } else if(ConnectorsUtil.belongsToSystemRA(raName)) { return true; } else { return belongToEmbeddedRarAndEnabled(raName); } }
public void unregisterTenantWithAppInDomainXML( final String appName, final String tenantName ) throws TransactionFailure, RetryableException { final com.sun.enterprise.config.serverbeans.Application app = applications.getApplication(appName); if (app == null) { throw new IllegalArgumentException("Application " + appName + " not found"); } final AppTenants appTenants = app.getAppTenants(); final AppTenant appTenant = appTenants.getAppTenant(tenantName); if (appTenant == null) { throw new IllegalArgumentException("Tenant " + tenantName + " not provisioned for application " + appName); } Transaction t = new Transaction(); final AppTenants appTenants_w = t.enroll(appTenants); appTenants_w.getAppTenant().remove(appTenant); t.commit(); }
private void handleOtherAppConfigChanges(Object parent, String appName) { Application application = applications.getApplication(appName); if (application.isLifecycleModule()) { return; } // reload the application for other application related // config changes if the application is in enabled state if (isCurrentInstanceMatchingTarget(parent) && deployment.isAppEnabled(application)) { disableApplication(appName); enableApplication(appName); } }
public Resources getResources(ResourceInfo resourceInfo){ if(ConnectorsUtil.isModuleScopedResource(resourceInfo)){ Application application = getApplications().getApplication(resourceInfo.getApplicationName()); Module module = application.getModule(resourceInfo.getModuleName()); return module.getResources(); }else if(ConnectorsUtil.isApplicationScopedResource(resourceInfo)){ Application application = getApplications().getApplication(resourceInfo.getApplicationName()); return application.getResources(); } return getResources(); }
public void undeployResources(String applicationName){ Application app = applications.getApplication(applicationName); if(app != null){ List<Module> modules = app.getModule(); if(modules != null){ for(Module module : modules){ Resources moduleScopedResources = module.getResources(); if(moduleScopedResources != null){ undeployResources(moduleScopedResources); } } } Resources appScopedResources = app.getResources(); if(appScopedResources != null){ undeployResources(appScopedResources); } } }
private void handleAppEnableChange(Object parent, String appName, boolean enabled) { Application application = applications.getApplication(appName); if (application.isLifecycleModule()) { return; } if (enabled) { if (isCurrentInstanceMatchingTarget(parent)) { enableApplication(appName); } } else { if (isCurrentInstanceMatchingTarget(parent)) { disableApplication(appName); } } }
private boolean belongToEmbeddedRarAndEnabled(String resourceAdapterName) { String appName = getAppNameToken(resourceAdapterName); if(appName==null) return false; Applications apps = getDomain().getApplications(); Application app = apps.getApplication(appName); if(app == null || !ConnectorsUtil.parseBoolean(app.getEnabled())) return false; return isApplicationReferenceEnabled(appName); }
public Resources getResources(PoolInfo poolInfo){ Resources resources; if(ConnectorsUtil.isModuleScopedResource(poolInfo)){ Application application = getApplications().getApplication(poolInfo.getApplicationName()); if(application != null){ Module module = application.getModule(poolInfo.getModuleName()); return module.getResources(); }else{ return null; } }else if(ConnectorsUtil.isApplicationScopedResource(poolInfo)){ Application application = getApplications().getApplication(poolInfo.getApplicationName()); if(application != null){ return application.getResources(); }else{ return null; } } return getResources(); }
public void deployResources(String applicationName){ Application app = applications.getApplication(applicationName); if(app != null){ Resources appScopedResources = app.getResources(); if(appScopedResources != null){ deployResources(appScopedResources.getResources()); } List<Module> modules = app.getModule(); if(modules != null){ for(Module module : modules){ Resources moduleScopedResources = module.getResources(); if(moduleScopedResources != null){ deployResources(moduleScopedResources.getResources()); } } } } }
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); } } } } }