@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 String getModuleName() { String moduleName = null; // for standalone jars, return its registration name // for applications, return the module uri if (getApplication().isVirtual()) { moduleName = getApplication().getRegistrationName(); } else { moduleName = getModuleDescriptor().getArchiveUri(); } return moduleName; }
/** * visit an application object * @param the application descriptor */ @Override public void accept(Application application) { DOLUtils.getDefaultLogger().info("Application"); DOLUtils.getDefaultLogger().info("name " + application.getName()); DOLUtils.getDefaultLogger().info("smallIcon " + application.getSmallIconUri()); }
/** * Add all the deployment information about the given application to me. */ public void addApplication(Application application) { for (ModuleDescriptor md : application.getModules()) { addModule(md); } }
@Override public boolean getKeepState() { // for standalone module, get the keep-state value specified in // module glassfish-*.xml if (isVirtual()) { BundleDescriptor bundleDesc = getStandaloneBundleDescriptor(); if (bundleDesc != null) { return bundleDesc.getKeepState(); } } return super.getKeepState(); }
/** * Removes the given role. */ public void removeRole(Role role) { getAppRoles().remove(role); for (BundleDescriptor bd : getBundleDescriptors()) { bd.removeRole(role); } }
private Application processDOL(DeploymentContext dc) throws IOException { ReadableArchive sourceArchive = dc.getSource(); sourceArchive.setExtraData(Types.class, dc.getTransientAppMetaData(Types.class.getName(), Types.class)); sourceArchive.setExtraData(Parser.class, dc.getTransientAppMetaData(Parser.class.getName(), Parser.class)); return Application.createApplication(); application = holder.app; application.setAppName(name); application.setClassLoader(cl); if (application.isVirtual()) { ModuleDescriptor md = application.getStandaloneBundleDescriptor().getModuleDescriptor(); md.setModuleName(name); name, archivist, sourceArchive, true); application.setAppName(name); ModuleDescriptor md = application.getStandaloneBundleDescriptor().getModuleDescriptor(); md.setModuleName(name); } catch(SAXException e) { throw new IOException(e); application.setRegistrationName(name); sourceArchive.removeExtraData(Types.class);
public ClassLoader getClassLoader(final ClassLoader parent, DeploymentContext context) { final ReadableArchive archive = context.getSource(); String compatProp = context.getAppProps().getProperty( DeploymentProperties.COMPATIBILITY); new GFApplicationXmlParser(context.getSource()); compatProp = gfApplicationXmlParser.getCompatibilityValue(); if (compatProp != null) { final URL[] earLibURLs = ASClassLoaderUtil.getAppLibDirLibraries(context.getSourceDir(), holder.app.getLibraryDirectory(), compatProp); final EarLibClassLoader earLibCl = AccessController.doPrivileged(new PrivilegedAction<EarLibClassLoader>() { @Override for (ModuleDescriptor md : holder.app.getModules()) { ReadableArchive sub = null; String moduleUri = md.getArchiveUri(); try { sub = archive.getSubArchive(moduleUri); if (sub instanceof InputJarArchive) { throw new IllegalArgumentException(strings.get("wrongArchType", moduleUri)); sub.setParentArchive(context.getSource()); if (md.getModuleType().equals(DOLUtils.ejbType())) { } else if (md.getModuleType().equals(DOLUtils.rarType())) { embeddedConnCl.addDelegate( (DelegatingClassLoader.ClassFinder)subCl);
classpath.append(ctx.getSourceDir().toURI().getPath()); classpath.append(File.pathSeparator); classpath.append(ctx.getScratchDir("ejb").toURI().getPath()); classpath.append(File.pathSeparator); Application app = ctx.getModuleMetaData(Application.class); if (!app.isVirtual()) { ReadableArchive parentArchive = ctx.getSource().getParentArchive(); String compatProp = ctx.getAppProps().getProperty( parentArchive.getURI()), app.getLibraryDirectory(), compatProp);
File stubsDir = ctx.getScratchDir("ejb"); //NOI18N application = ctx.getModuleMetaData(Application.class); application.getRegistrationName()); final ClassLoader jcl = application.getClassLoader(); bundle = ctx.getModuleMetaData(EjbBundleDescriptorImpl.class); String archiveUri = ctx.getSource().getURI().getSchemeSpecificPart(); _logger.fine("Java2DB processing: " + (end - start) + " msec"); _logger.fine( "cmpc.done_processing_cmp", application.getRegistrationName()); String appName = application.getRegistrationName(); String exMsg = e.getMessage(); "cmpc.cmp_app_error", eType, appName, exMsg); } else { String bundleName = bundle.getModuleDescriptor().getArchiveUri(); if (beanName == null) {
throws IOException { Vector entriesAdded = new Vector(); for (ModuleDescriptor aModule : a.getModules()) { entriesAdded.add(aModule.getArchiveUri()); ReadableArchive subSource = source.getSubArchive(aModule.getArchiveUri()); WritableArchive subTarget = target.createSubArchive(aModule.getArchiveUri()); Archivist newArchivist = archivistFactory.get().getArchivist(aModule.getModuleType()); ReadableArchive subArchive = archiveFactory.openArchive(subTarget.getURI()); subSource.setParentArchive(subArchive); newArchivist.copyInto(subSource, subTarget, overwriteManifest); target.closeEntry(subTarget); String subModulePath = subSource.getURI().getSchemeSpecificPart(); String parentPath = source.getURI().getSchemeSpecificPart(); if (subModulePath.startsWith(parentPath)) {
DeploymentContext context) { List<ReadableArchive> libJars = null; ApplicationHolder holder = context.getModuleMetaData(ApplicationHolder.class); if ((holder != null) && (holder.app != null)) { String libDir = holder.app.getLibraryDirectory(); if (libDir != null && !libDir.isEmpty()) { Enumeration<String> entries = archive.entries(libDir); while (entries.hasMoreElements()) { String entryName = entries.nextElement(); entryName.indexOf(SEPARATOR_CHAR, libDir.length() + 1 ) == -1 ) { try { ReadableArchive jarInLib = archive.getSubArchive(entryName); if (jarInLib.exists(META_INF_BEANS_XML) || WeldUtils.isImplicitBeanArchive(context, jarInLib)) { if (libJars == null) { libJars = new ArrayList<ReadableArchive>(); String libDir = holder.app.getLibraryDirectory(); for (ReadableArchive libJarArchive : libJars) { createLibJarBda(libJarArchive, ejbs, libDir);
for (ModuleDescriptor md : holder.app.getModules()) { String moduleUri = md.getArchiveUri(); ReadableArchive subArchive = null; WritableArchive subTarget = null; ReadableArchive subArchiveToExpand = null; try { subArchive = source2.getSubArchive(moduleUri); if (subArchive == null) { _logger.log(Level.WARNING, ArchiveHandler subHandler = getArchiveHandlerFromModuleType(md.getModuleType()); if (subHandler == null) { subHandler = deployment.getArchiveHandler(subArchive); context.getModuleArchiveHandlers().put( moduleUri, subHandler); if (subHandler!=null) { final String msg = MessageFormat.format( _logger.getResourceBundle().getString("enterprise.deployment.backend.badSubModPackaging"), subArchive.getURI().toASCIIString(), subArchive.getClass().getName()); throw new RuntimeException(msg); try { if (subArchive != null) { subArchive.close();
public String getGlobalJndiName() { String appName = null; if (enclosingBundle == null) return null; Application app = enclosingBundle.getApplication(); if ( !app.isVirtual() ) { appName = enclosingBundle.getApplication().getAppName(); } String modName = enclosingBundle.getModuleDescriptor().getModuleName(); StringBuffer javaGlobalPrefix = new StringBuffer("java:global/"); if (appName != null) { javaGlobalPrefix.append(appName); javaGlobalPrefix.append("/"); } javaGlobalPrefix.append(modName); javaGlobalPrefix.append("/"); // If the managed bean is named, use the name for the final component // of the managed bean global name. Otherwise, use a derived internal // name since we'll still need a way to register and lookup the bean // from within the container. String componentName = isNamed() ? name : "___internal_managed_bean_" + beanClassName; javaGlobalPrefix.append(componentName); return javaGlobalPrefix.toString(); }
/** * Decides whether we have any pu roots at ear level */ public boolean handles(DeploymentContext context) { ArchiveType archiveType = habitat.getService(ArchiveType.class, context.getArchiveHandler().getArchiveType()); if (archiveType != null && !supportsArchiveType(archiveType)) { return false; } // Scans for pu roots in the "lib" dir of an application. // We do not scan for PU roots in root of .ear. JPA 2.0 spec will clarify that it is not a portable use case. // It is not portable use case because JavaEE spec implies that jars in root of ears are not visible by default // to components (Unless an explicit Class-Path manifest entry is present) and can potentially be loaded by // different class loaders (corresponding to each component that refers to it) thus residing in different name // space. It does not make sense to make them visible at ear level (and thus in a single name space) boolean isJPAApplication = false; ApplicationHolder holder = context.getModuleMetaData(ApplicationHolder.class); ReadableArchive appRoot = context.getSource(); if (holder != null && holder.app != null) { isJPAApplication = scanForPURootsInLibDir(appRoot, holder.app.getLibraryDirectory()); if(!isJPAApplication) { if(DeploymentUtils.useV2Compatibility(context) ) { //Scan for pu roots in root of ear isJPAApplication = scanForPURRootsInEarRoot(context, holder.app.getModules()); } } } return isJPAApplication; }
public static List<URL> getLibraryJars(BundleDescriptor bundleDesc, ReadableArchive archive) throws IOException { List<URL> libraryURLs = new ArrayList<URL>(); // add libraries referenced through manifest libraryURLs.addAll(DeploymentUtils.getManifestLibraries(archive)); ReadableArchive parentArchive = archive.getParentArchive(); if (parentArchive == null || bundleDesc == null) { // ear level or standalone module return libraryURLs; } File appRoot = new File(parentArchive.getURI()); ModuleDescriptor moduleDesc = ((BundleDescriptor)bundleDesc).getModuleDescriptor(); Application app = ((BundleDescriptor)moduleDesc.getDescriptor()).getApplication(); // add libraries jars inside application lib directory libraryURLs.addAll(ASClassLoaderUtil.getAppLibDirLibrariesAsList( appRoot, app.getLibraryDirectory(), null)); return libraryURLs; }
/** * @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); }
/** * @return the module ID for this module descriptor */ public String getModuleID() { if (moduleID == null) { moduleID = getModuleDescriptor().getArchiveUri(); } if (getModuleDescriptor().isStandalone()) { return moduleID; } if (application != null && !application.isVirtual()) { return application.getRegistrationName() + "#" + getModuleDescriptor().getArchiveUri(); } else { return moduleID; } }
public Application load(DeploymentContext dc) throws IOException { DeployCommandParameters params = dc.getCommandParameters(DeployCommandParameters.class); Application application = processDOL(dc); // write out xml files if needed if (Boolean.valueOf(WRITEOUT_XML)) { saveAppDescriptor(application, dc); } if (application.isVirtual()) { dc.addModuleMetaData(application.getStandaloneBundleDescriptor()); for (RootDeploymentDescriptor extension : application.getStandaloneBundleDescriptor().getExtensionsDescriptors()) { dc.addModuleMetaData(extension); } } addModuleConfig(dc, application); validateKeepStateOption(dc, params, application); return application; }
for (ModuleDescriptor module : application.getModules()) { if (module.getModuleType().equals(DOLUtils.warType())) { Node web = appendChild(appNode, RuntimeTagNames.WEB); appendTextChild(web, RuntimeTagNames.WEB_URI, module.getArchiveUri()); appendTextChild(web, RuntimeTagNames.CONTEXT_ROOT, module.getContextRoot()); if (application.isPassByReferenceDefined()) { appendTextChild(appNode, RuntimeTagNames.PASS_BY_REFERENCE, String.valueOf(application.getPassByReference())); List<SecurityRoleMapping> roleMappings = application.getSecurityRoleMappings(); for (int i = 0; i < roleMappings.size(); i++) { SecurityRoleMappingNode srmn = new SecurityRoleMappingNode(); appendTextChild(appNode, RuntimeTagNames.REALM, application.getRealm()); appendTextChild(appNode, RuntimeTagNames.ARCHIVE_NAME, application.getArchiveName()); appendTextChild(appNode, RuntimeTagNames.COMPATIBILITY, application.getCompatibility()); appendTextChild(appNode, RuntimeTagNames.KEEP_STATE, String.valueOf(application.getKeepState()));