/** * {@inheritDoc} */ public Set<String> getRARsReferredByApplication(String appName) { ApplicationInfo appInfo = appRegistry.get(appName); if (appInfo != null) { Application app = appInfo.getMetaData(Application.class); if(appInfo.isJavaEEApp()){ return app.getResourceAdapters(); } } return new HashSet<String>(); }
private void doBootstrapShutdown(ApplicationInfo appInfo){ WeldBootstrap bootstrap = appInfo.getTransientAppMetaData(WELD_BOOTSTRAP, WeldBootstrap.class); String bootstrapShutdown = appInfo.getTransientAppMetaData(WELD_BOOTSTRAP_SHUTDOWN, String.class); if (bootstrapShutdown == null || Boolean.valueOf(bootstrapShutdown).equals(Boolean.FALSE)) { bootstrap.shutdown(); appInfo.addTransientAppMetaData(WELD_BOOTSTRAP_SHUTDOWN, "true"); } } private String getDeploymentErrorMsgPrefix( Throwable t ) {
final ApplicationInfo appInfo = getApplicationInfo(ejbUtil); final List<String> tempLibNames = new LinkedList<>(); for (ModuleInfo moduleInfo : appInfo.getModuleInfos()) { final String jarName = moduleInfo.getName(); if (jarName.endsWith(".jar") || jarName.endsWith(".war")) {
ApplicationInfo tempAppInfo = new ApplicationInfo(events, tempAppInfo.addMetaData(m); tempAppInfo.setIsJavaEEApp(sortedEngineInfos); context.getSource().setExtraData(Boolean.class, tempAppInfo.isJavaEEApp()); appRegistry.add(appName, tempAppInfo); appInfo = new ApplicationInfo(events, context.getSource(), appName); appInfo.addModule(moduleInfo); appInfo.addMetaData(m); appInfo.add(ref); appRegistry.remove(appName); appInfo.setIsJavaEEApp(sortedEngineInfos); appInfo.setAppClassLoader(context.getClassLoader()); events.send(new Event<DeploymentContext>(Deployment.APPLICATION_PREPARED, context), false); appInfo.setLibraries(commandParams.libraries()); try { notifyLifecycleInterceptorsBefore(ExtendedDeploymentContext.Phase.LOAD, context); appInfo.load(context, tracker); notifyLifecycleInterceptorsAfter(ExtendedDeploymentContext.Phase.LOAD, context); appInfo.start(context, tracker);
matchedVersions = versioningService.getMatchedVersions(name, target); } catch (VersioningException e) { report.failure(logger, e.getMessage()); return; report.setMessage(localStrings.getLocalString("ref.not.referenced.target","Application {0} is not referenced by target {1}", name, target)); report.setActionExitCode(ActionReport.ExitCode.FAILURE); if (application.isLifecycleModule()) { try { deployment.unregisterAppFromDomainXML(appName, target, true); ApplicationInfo appInfo = deployment.get(appName); if (appInfo != null) { source = appInfo.getSource(); } else { File location = new File(new URI(application.getLocation())); source = archiveFactory.openArchive(location); deploymentContext.getAppProps().putAll( application.getDeployProperties()); deploymentContext.setModulePropsMap( application.getModulePropertiesMap()); deploymentContext.clean(); if (!Boolean.valueOf(application.getDirectoryDeployed()) && source.exists()) { FileUtils.whack(new File(source.getURI()));
ActionReport.MessagePart part = report.getTopMessagePart(); if (application.isLifecycleModule()) { if (!terse) { part.setMessage(localStrings.getLocalString("listsubcomponents.no.elements.to.list", "Nothing to List.")); ApplicationInfo appInfo = appRegistry.get(applicationName); com.sun.enterprise.deployment.Application app = appInfo.getMetaData(com.sun.enterprise.deployment.Application.class); subComponents = getAppLevelComponents(app, type, subComponentsMap); } else { BundleDescriptor bundleDesc = app.getModuleByUri(modulename); if (!app.isVirtual()) { subModuleInfos = getSubModulesForEar(app, type); String.format(formattedLine, new Object[]{subComponent.getKey(), subComponent.getValue()} )); if (appname == null && !app.isVirtual()) { Module module = application.getModule(subComponent.getKey()); final ParameterMap parameters = new ParameterMap(); parameters.add("appname", application.getName()); parameters.add("modulename", module.getName()); inv.parameters(parameters).execute();
private void unloadApplicationForTenants(Application app, ActionReport report) { if (app == null || app.getAppTenants() == null) { return; for (AppTenant tenant : app.getAppTenants().getAppTenant()) { UndeployCommandParameters parameters = new UndeployCommandParameters(); parameters.name = DeploymentUtils.getInternalNameForTenant(app.getName(), tenant.getTenant()); parameters.origin = UndeployCommandParameters.Origin.unload; parameters.target = server.getName(); ActionReport subReport = report.addSubActionsReport(); ExtendedDeploymentContext deploymentContext = deployment.getBuilder(KernelLoggerInfo.getLogger(), parameters, subReport).source(appInfo.getSource()).build(); deploymentContext.getAppProps().putAll( app.getDeployProperties()); deploymentContext.getAppProps().putAll( tenant.getDeployProperties()); deploymentContext.setModulePropsMap( app.getModulePropertiesMap()); subReport.setActionExitCode(ActionReport.ExitCode.FAILURE); subReport.setMessage(e.getMessage()); subReport.setFailureCause(e); appRegistry.remove(appInfo.getName());
report.setMessage( "Cannot find deployed application of name " + name); report.setActionExitCode(ActionReport.ExitCode.FAILURE); return; ReadableArchive source = appInfo.getSource(); if (source == null) { report.setMessage( "Cannot get source archive for undeployment"); report.setActionExitCode(ActionReport.ExitCode.FAILURE); for (ModuleInfo module : appInfo.getModuleInfos()) { info.map.put(module.getName(), module.getModuleProps()); deploymentContext.getModuleProps().putAll(module.getModuleProps()); deploymentContext.setModulePropsMap(info.map); deploymentContext.getAppProps().putAll(info.appProps);
Properties actionReportProps = null; if (ejbBundle.getApplication().isVirtual()) { actionReportProps = depc.getActionReport().getExtraProperties(); } else { // the application is EAR ExtendedDeploymentContext exdc = (ExtendedDeploymentContext) depc; actionReportProps = exdc.getParentContext().getActionReport().getExtraProperties(); ApplicationInfo appInfo = appRegistry.get(params.name()); appInfo.addTransientAppMetaData(KEEP_STATE, keepState); ejbBundle.getApplication().setKeepStateResolved(String.valueOf(keepState));
/** * During "load()" event (eg: app/app-ref enable, server start), * populate resource-config in app-info so that it can be used for * constructing connector-classloader for the application. * @param dc DeploymentContext */ public void populateResourceConfigInAppInfo(DeploymentContext dc){ String appName = getAppNameFromDeployCmdParams(dc); Application application = applications.getApplication(appName); ApplicationInfo appInfo = appRegistry.get(appName); if(application != null && appInfo != null){ Resources appScopedResources = application.getResources(); if(appScopedResources != null){ appInfo.addTransientAppMetaData(ServerTags.APPLICATION, application); appInfo.addTransientAppMetaData(application.getName()+"-resources", appScopedResources); } List<Module> modules = application.getModule(); if(modules != null){ for(Module module : modules){ Resources moduleScopedResources = module.getResources(); if(moduleScopedResources != null){ appInfo.addTransientAppMetaData(module.getName()+"-resources", 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 Vector getEjbDescriptors(Application application, ApplicationRegistry appsRegistry) { Vector ejbDescriptors = new Vector(); if(ResourcesUtil.createInstance().isEnabled(application)){ ApplicationInfo appInfo = appsRegistry.get(application.getName()); if(appInfo != null){ com.sun.enterprise.deployment.Application app = appInfo.getMetaData(com.sun.enterprise.deployment.Application.class); Set<BundleDescriptor> descriptors = app.getBundleDescriptors(); for (BundleDescriptor descriptor : descriptors) { if (descriptor instanceof EjbBundleDescriptor) { EjbBundleDescriptor ejbBundleDescriptor = (EjbBundleDescriptor) descriptor; Set<? extends EjbDescriptor> ejbDescriptorsSet = ejbBundleDescriptor.getEjbs(); for (EjbDescriptor ejbDescriptor : ejbDescriptorsSet) { ejbDescriptors.add(ejbDescriptor); } } } }else{ //application is enabled, but still not found in app-registry _logger.log(Level.WARNING, "application.not.started.skipping.recovery", application.getName()); } } return ejbDescriptors; }
/** * Entry point from the framework into the command execution * @param context context for the command. */ public void execute(AdminCommandContext context) { final ActionReport report = context.getActionReport(); ActionReport.MessagePart part = report.getTopMessagePart(); ApplicationInfo appInfo = appRegistry.get(appname); if (appInfo != null) { Application app = appInfo.getMetaData(Application.class); if (app != null) { BundleDescriptor bundleDesc = app.getModuleByUri(modulename); if (bundleDesc != null && bundleDesc instanceof WebBundleDescriptor) { String contextRoot = ((WebBundleDescriptor)bundleDesc).getContextRoot(); part.addProperty(DeploymentProperties.CONTEXT_ROOT, contextRoot); part.setMessage(contextRoot); } } } } }
public ExtendedDeploymentContext disable(UndeployCommandParameters commandParams, Application app, ApplicationInfo appInfo, ActionReport report, Logger logger) throws Exception { if (appInfo == null) { return null; } // if it's not on DAS and the application is not loaded, do not unload // when it's on DAS, there is some necessary clean up we need to do if (!env.isDas() && !appInfo.isLoaded()) { return null; } if (app != null) { commandParams._type = app.archiveType(); } final ExtendedDeploymentContext deploymentContext = getBuilder(logger, commandParams, report).source(appInfo.getSource()).build(); if (app != null) { deploymentContext.getAppProps().putAll( app.getDeployProperties()); deploymentContext.setModulePropsMap( app.getModulePropertiesMap()); } if (commandParams.properties != null) { deploymentContext.getAppProps().putAll(commandParams.properties); } unload(appInfo, deploymentContext); return deploymentContext; }
final ActionReport report = context.getActionReport(); ActionReport.MessagePart part = report.getTopMessagePart(); final ApplicationInfo appInfo = appRegistry.get(appname); if (appInfo.getEngineRefs().size() > 0) for (EngineRef ref : appInfo.getEngineRefs()) addToResultDDList("", appSniffer.getDeploymentConfigurations(appInfo.getSource()), part); for (ModuleInfo moduleInfo : appInfo.getModuleInfos()) ReadableArchive moduleArchive = appInfo.getSource().getSubArchive(moduleInfo.getName()); addToResultDDList(moduleInfo.getName(), moduleSniffer.getDeploymentConfigurations(moduleArchive), part); for (Sniffer sniffer : appInfo.getSniffers()) addToResultDDList(appname, sniffer.getDeploymentConfigurations(appInfo.getSource()), part);
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); } }
if (event.is(Deployment.APPLICATION_PREPARED) && isDas()) { ExtendedDeploymentContext context = (ExtendedDeploymentContext)event.hook(); OpsParams opsparams = context.getCommandParameters(OpsParams.class); DeployCommandParameters dcp = context.getCommandParameters(DeployCommandParameters.class); ApplicationInfo appInfo = appRegistry.get(opsparams.name()); Application app = appInfo.getMetaData(Application.class); if (app == null) { List<String> targets = (List<String>)context.getTransientAppMetaData(DeploymentProperties.PREVIOUS_TARGETS, List.class); for (String ref: targets) { target = ref; for (EjbBundleDescriptorImpl ejbBundle : app.getBundleDescriptors(EjbBundleDescriptorImpl.class)) { if (checkEjbBundleForTimers(ejbBundle, createTimers, target)) { isTimedApp = true; appInfo.addTransientAppMetaData(IS_TIMEOUT_APP_PROP, Boolean.TRUE);
ApplicationInfo appInfo = appRegistry.get(app.getName()); res = getApplicationScopedResource(jndiName, BindableResource.class, appInfo); }else if(jndiName.startsWith(ConnectorConstants.JAVA_MODULE_SCOPE_PREFIX)){ ApplicationInfo appInfo = appRegistry.get(app.getName()); res = getModuleScopedResource(jndiName, moduleName, BindableResource.class, appInfo); }else{ String poolName = connResource.getPoolName(); Resource pool ; ApplicationInfo appInfo = appRegistry.get(app.getName()); if(jndiName.startsWith(ConnectorConstants.JAVA_APP_SCOPE_PREFIX) /*|| jndiName.startsWith("java:global/")*/){ pool = getApplicationScopedResource(poolName, ResourcePool.class, appInfo); com.sun.enterprise.config.serverbeans.Application application = (com.sun.enterprise.config.serverbeans.Application) itr.next(); String appName = application.getName(); ApplicationInfo appInfo = appRegistry.get(appName); Application dolApp = appInfo.getMetaData(Application.class); Collection<ConnectorDescriptor> rarDescriptors = dolApp.getRarDescriptors(); for (ConnectorDescriptor desc : rarDescriptors) {
public ApplicationInfo unload(ApplicationInfo info, ExtendedDeploymentContext context) { ActionReport report = context.getActionReport(); if (info==null) { report.failure(context.getLogger(), "Application not registered", null); return null; } notifyLifecycleInterceptorsBefore(ExtendedDeploymentContext.Phase.STOP, context); if (info.isLoaded()) { info.stop(context, context.getLogger()); notifyLifecycleInterceptorsAfter(ExtendedDeploymentContext.Phase.STOP, context); notifyLifecycleInterceptorsBefore(ExtendedDeploymentContext.Phase.UNLOAD, context); info.unload(context); notifyLifecycleInterceptorsAfter(ExtendedDeploymentContext.Phase.UNLOAD, context); } events.send(new Event<ApplicationInfo>(Deployment.APPLICATION_DISABLED, info), false); try { notifyLifecycleInterceptorsBefore(ExtendedDeploymentContext.Phase.CLEAN, context); info.clean(context); notifyLifecycleInterceptorsAfter(ExtendedDeploymentContext.Phase.CLEAN, context); } catch(Exception e) { report.failure(context.getLogger(), "Exception while cleaning", e); return info; } return info; }
public static boolean isRAConnectionFactory(ServiceLocator habitat, String type, Application thisApp) { // first check if this is a connection factory defined in a resource // adapter in this application if (isRAConnectionFactory(type, thisApp)) { return true; } // then check if this is a connection factory defined in a standalone // resource adapter Applications applications = habitat.getService(Applications.class); if (applications != null) { List<com.sun.enterprise.config.serverbeans.Application> raApps = applications.getApplicationsWithSnifferType(com.sun.enterprise.config.serverbeans.ServerTags.CONNECTOR, true); ApplicationRegistry appRegistry = habitat.getService(ApplicationRegistry.class); for (com.sun.enterprise.config.serverbeans.Application raApp : raApps) { ApplicationInfo appInfo = appRegistry.get(raApp.getName()); if (appInfo == null) continue; if (isRAConnectionFactory(type, appInfo.getMetaData(Application.class))) { return true; } } } return false; }