private EjbBundleDescriptor getEjbBundleFromContext(DeploymentContext context) { EjbBundleDescriptor ejbBundle = context.getModuleMetaData(EjbBundleDescriptor.class); if( ejbBundle == null ) { WebBundleDescriptor wDesc = context.getModuleMetaData(WebBundleDescriptor.class); if( wDesc != null ) { Collection<EjbBundleDescriptor> ejbBundles = wDesc.getExtensionsDescriptors(EjbBundleDescriptor.class); if (ejbBundles.iterator().hasNext()) { ejbBundle = ejbBundles.iterator().next(); } } } return ejbBundle; }
private ArrayList<EjbEndpoint> getEjbEndpoints() { ejbendpoints = new ArrayList<EjbEndpoint>(); Application app = deploymentCtx.getModuleMetaData(Application.class); Set<BundleDescriptor> bundles = app.getBundleDescriptors(); for(BundleDescriptor bundle : bundles) { collectEjbEndpoints(bundle); } return ejbendpoints; }
private boolean webServiceInContext(WebService webService) { BundleDescriptor contextBundleDescriptor = context.getModuleMetaData(BundleDescriptor.class); String moduleId = contextBundleDescriptor.getModuleID(); return moduleId.equals(webService.getBundleDescriptor().getModuleID()); }
@Override public WebServicesApplication load(WebServicesContainer container, DeploymentContext context) { Set<String> publishedFiles = null; Application app = context.getModuleMetaData(Application.class); try { publishedFiles = populateWsdlFilesForPublish(context, app.getWebServiceDescriptors()); } catch(Exception e) { throw new RuntimeException(e); } return new WebServicesApplication(context, env, dispatcher, config, habitat,publishedFiles); }
/** * Loads a previously prepared application in its execution environment and * return a ContractProvider instance that will identify this environment in * future communications with the application's container runtime. * @param container in which the application will reside * @param context of the deployment * @return an ApplicationContainer instance identifying the running application */ public U load(T container, DeploymentContext context) { // reset classloader on DOL object before loading so we have a // valid classloader set on DOL Application app = context.getModuleMetaData(Application.class); if (app != null) { app.setClassLoader(context.getClassLoader()); } return null; }
@Override public <T> T getModuleMetaData(Class<T> metadataType) { try { return metadataType.cast(application.getModuleByUri(moduleUri)); } catch (Exception e) { // let's first try the extensions mechanisms... if (RootDeploymentDescriptor.class.isAssignableFrom(metadataType)) { for (RootDeploymentDescriptor extension : application.getModuleByUri(moduleUri).getExtensionsDescriptors((Class<RootDeploymentDescriptor>) metadataType)) { // we assume there can only be one type of if (extension!=null) { try { return metadataType.cast(extension); } catch (Exception e1) { // next one... } } } } return context.getModuleMetaData(metadataType); } } };
public boolean start(ApplicationContext startupContext) throws Exception { cl = startupContext.getClassLoader(); try { app = deploymentCtx.getModuleMetaData(Application.class); Iterator<EjbEndpoint> iter = ejbendpoints.iterator(); EjbEndpoint ejbendpoint = null; while(iter.hasNext()) { ejbendpoint = iter.next(); String contextRoot = ejbendpoint.contextRoot; dispatcher.registerEndpoint(contextRoot, (com.sun.grizzly.tcp.Adapter)adapter, this); logger.info(format(rb.getString("enterprise.deployment.ejbendpoint.registration"), app.getAppName(), new WsUtil().getWebServerInfoForDAS().getWebServerRootURL(ejbendpoint.isSecure).toString() + contextRoot) ); } } catch (EndpointRegistrationException e) { logger.log(Level.SEVERE, format(rb.getString("error.registering.endpoint"),e.toString())); } return true; }
@Override public void event(Event event) { if (event.is(Deployment.AFTER_APPLICATION_CLASSLOADER_CREATION)) { dc = (DeploymentContext) event.hook(); application = dc.getModuleMetaData(Application.class); DeployCommandParameters commandParams = dc.getCommandParameters(DeployCommandParameters.class); target = commandParams.target; if (System.getProperty("deployment.resource.validation", "true").equals("false")) { deplLogger.log(Level.INFO, SKIP_RESOURCE_VALIDATION); return; } if (application == null) return; AppResources appResources = new AppResources(); parseResources(appResources); validateResources(appResources); } }
private WebModuleConfig loadWebModuleConfig(DeploymentContext dc) { WebModuleConfig wmInfo = new WebModuleConfig(); try { DeployCommandParameters params = dc.getCommandParameters(DeployCommandParameters.class); wmInfo.setDescriptor(dc.getModuleMetaData(WebBundleDescriptor.class)); wmInfo.setVirtualServers(params.virtualservers); wmInfo.setLocation(dc.getSourceDir()); wmInfo.setObjectType(dc.getAppProps().getProperty(ServerTags.OBJECT_TYPE)); } catch (Exception ex) { String msg = rb.getString("webdeployer.loadWebModuleConfig"); msg = MessageFormat.format(msg, wmInfo.getName()); logger.log(Level.WARNING, msg, ex); } return wmInfo; }
private void addWeldListenerToAllWars(DeploymentContext context) { // if there's at least 1 ejb jar then add the listener to all wars ApplicationHolder applicationHolder = context.getModuleMetaData(ApplicationHolder.class); if ( applicationHolder != null ) { if ( applicationHolder.app.getBundleDescriptors(EjbBundleDescriptor.class).size() > 0 ) { Set<WebBundleDescriptor> webBundleDescriptors = applicationHolder.app.getBundleDescriptors(WebBundleDescriptor.class); for ( WebBundleDescriptor oneWebBundleDescriptor : webBundleDescriptors ) { // Add the Weld Listener if it does not already exist.. // we have to do this regardless because the war may not be cdi-enabled but an ejb is. oneWebBundleDescriptor.addAppListenerDescriptorToFirst(new AppListenerDescriptorImpl(WELD_LISTENER)); oneWebBundleDescriptor.addAppListenerDescriptor(new AppListenerDescriptorImpl(WELD_TERMINATION_LISTENER)); } } } }
@Override public DummyApplication load(SecurityContainer container, DeploymentContext context) { DeployCommandParameters dparams = context.getCommandParameters(DeployCommandParameters.class); Application app = context.getModuleMetaData(Application.class); handleCNonceCacheBSInit(app.getAppName(), app.getBundleDescriptors(WebBundleDescriptor.class), dparams.availabilityenabled); return new DummyApplication(); }
public static BundleDescriptor getCurrentBundleForContext( DeploymentContext context) { ExtendedDeploymentContext ctx = (ExtendedDeploymentContext)context; Application application = context.getModuleMetaData(Application.class); if (application == null) return null; // this can happen for non-JavaEE type deployment. e.g., issue 15869 if (ctx.getParentContext() == null) { if (application.isVirtual()) { // standalone module return application.getStandaloneBundleDescriptor(); } else { // top level return application; } } else { // a sub module of ear return application.getModuleByUri(ctx.getModuleUri()); } }
public static BundleDescriptor getCurrentBundleForContext( DeploymentContext context) { ExtendedDeploymentContext ctx = (ExtendedDeploymentContext)context; Application application = context.getModuleMetaData(Application.class); if (application == null) return null; // this can happen for non-JavaEE type deployment. e.g., issue 15869 if (ctx.getParentContext() == null) { if (application.isVirtual()) { // standalone module return application.getStandaloneBundleDescriptor(); } else { // top level return application; } } else { // a sub module of ear return application.getModuleByUri(ctx.getModuleUri()); } } }
@Override protected void generateArtifacts(DeploymentContext dc) throws DeploymentException { OpsParams params = dc.getCommandParameters(OpsParams.class); if (params.origin != OpsParams.Origin.deploy) { return; } String appName = params.name(); try { Application app = dc.getModuleMetaData(Application.class); Set<WebBundleDescriptor> webDesc = app.getWebBundleDescriptors(); if (webDesc == null) { return; } for (WebBundleDescriptor webBD : webDesc) { loadPolicy(webBD, false); } } catch (Exception se) { String msg = "Error in generating security policy for " + appName; throw new DeploymentException(msg, se); } }
/** * @see CMPGenerator#init(org.glassfish.ejb.deployment.descriptor.EjbBundleDescriptorImpl, DeploymentContext, String, String) */ public void init(EjbBundleDescriptorImpl bundle, DeploymentContext ctx, String bundlePathName, String generatedXmlsPathName) throws GeneratorException { if (logger.isLoggable(Logger.FINE)) logger.fine("cmp gen init"); // NOI18N this.ctx = ctx; this.generatedXmlsPath = generatedXmlsPathName; this.inputFilesPath = bundlePathName; this.classout = ctx.getScratchDir("ejb"); // "generated/ejb" dir this.appName = ctx.getModuleMetaData(Application.class).getRegistrationName(); init(bundle, ctx.getClassLoader(), bundlePathName, false); }
@Override public WebApplication load(WebContainer container, DeploymentContext dc) { super.load(container, dc); WebBundleDescriptor wbd = dc.getModuleMetaData( WebBundleDescriptor.class); if (wbd != null) { wbd.setClassLoader(dc.getClassLoader()); } WebModuleConfig wmInfo = loadWebModuleConfig(dc); WebApplication webApp = new WebApplication(container, wmInfo, new ApplicationConfigInfo(dc.getAppProps())); return webApp; }
@Override protected void generateArtifacts(DeploymentContext dc) throws DeploymentException { OpsParams params = dc.getCommandParameters(OpsParams.class); if (params.origin.isArtifactsPresent()) { return; } String appName = params.name(); try { Application app = dc.getModuleMetaData(Application.class); Set<WebBundleDescriptor> webDesc = app.getBundleDescriptors(WebBundleDescriptor.class); if (webDesc == null) { return; } for (WebBundleDescriptor webBD : webDesc) { loadPolicy(webBD, false); } } catch (Exception se) { String msg = "Error in generating security policy for " + appName; throw new DeploymentException(msg, se); } }
@Override public void run(Habitat habitat, DeploymentContext context, String cp) throws Exception { rootLocation_ = new FileArchive(); BundleDescriptor bundle = DOLUtils.getCurrentBundleForContext(context); if (bundle.hasWebServiceClients() && (bundle instanceof ApplicationClientDescriptor)) { hasWebServiceClients = true; } if(bundle.isStandalone()) { rootLocation_.open(context.getSourceDir().toURI()); } else { rootLocation_.open(context.getSource().getParentArchive().getURI()); } this.context = context; this.habitat = habitat; this.moduleClassPath = cp; Application application = context.getModuleMetaData(Application.class); application.visit((ApplicationVisitor) this); }
public void event(Event event) { if (event.is(Deployment.APPLICATION_LOADED) ) { ApplicationInfo info = Deployment.APPLICATION_LOADED.getHook(event); loadManagedBeans(info); registerAppLevelDependencies(info); } else if( event.is(Deployment.APPLICATION_UNLOADED) ) { ApplicationInfo info = Deployment.APPLICATION_UNLOADED.getHook(event); Application app = info.getMetaData(Application.class); doCleanup(app); } else if( event.is(Deployment.DEPLOYMENT_FAILURE) ) { Application app = Deployment.DEPLOYMENT_FAILURE.getHook(event).getModuleMetaData(Application.class); doCleanup(app); } }
public void event(Event event) { if (event.is(Deployment.APPLICATION_LOADED) ) { ApplicationInfo info = Deployment.APPLICATION_LOADED.getHook(event); loadManagedBeans(info); registerAppLevelDependencies(info); } else if( event.is(Deployment.APPLICATION_UNLOADED) ) { ApplicationInfo info = Deployment.APPLICATION_UNLOADED.getHook(event); Application app = info.getMetaData(Application.class); doCleanup(app); } else if( event.is(Deployment.DEPLOYMENT_FAILURE) ) { Application app = Deployment.DEPLOYMENT_FAILURE.getHook(event).getModuleMetaData(Application.class); doCleanup(app); } }