use of com.sun.enterprise.deployment.Application in project Payara by payara.
the class EjbSessionDescriptor method getPortableJndiName.
/**
* Return the fully-qualified portable JNDI name for a given
* client view (Remote, Local, or no-interface).
*/
public String getPortableJndiName(String clientViewType) {
String appName = null;
Application app = getEjbBundleDescriptor().getApplication();
if (!app.isVirtual()) {
appName = app.getAppName();
}
String modName = getEjbBundleDescriptor().getModuleDescriptor().getModuleName();
StringBuffer javaGlobalPrefix = new StringBuffer("java:global/");
if (appName != null) {
javaGlobalPrefix.append(appName);
javaGlobalPrefix.append("/");
}
javaGlobalPrefix.append(modName);
javaGlobalPrefix.append("/");
javaGlobalPrefix.append(getName());
javaGlobalPrefix.append("!");
javaGlobalPrefix.append(clientViewType);
return javaGlobalPrefix.toString();
}
use of com.sun.enterprise.deployment.Application in project Payara by payara.
the class SecurityUtil method createUniquePseudoModuleID.
/**
* create pseudo module context id, and make sure it is unique, by chacking it against the names of all the other
* modules in the app.
*
* @param ejbDesc
* @return
*/
private static String createUniquePseudoModuleID(EjbBundleDescriptor ejbDesc) {
Application app = ejbDesc.getApplication();
Collection<WebBundleDescriptor> webModules = app.getBundleDescriptors(WebBundleDescriptor.class);
Collection<EjbBundleDescriptor> ejbModules = app.getBundleDescriptors(EjbBundleDescriptor.class);
String moduleName = ejbDesc.getUniqueFriendlyId();
String pseudonym;
int uniquifier = 0;
boolean unique;
do {
unique = true;
pseudonym = moduleName + (uniquifier == 0 ? "_internal" : "_internal_" + uniquifier);
if (webModules != null) {
for (WebBundleDescriptor w : webModules) {
if (pseudonym.equals(w.getUniqueFriendlyId())) {
unique = false;
break;
}
}
}
if (unique && ejbModules != null) {
for (EjbBundleDescriptor e : ejbModules) {
if (pseudonym.equals(e.getUniqueFriendlyId())) {
unique = false;
break;
}
}
}
uniquifier += 1;
} while (!unique);
return VersioningUtils.getRepositoryName(app.getRegistrationName()) + "/" + pseudonym;
}
use of com.sun.enterprise.deployment.Application in project Payara by payara.
the class RoleMapper method getAppDefaultRoleMapping.
private boolean getAppDefaultRoleMapping() {
if (appDefaultMapping != null) {
return appDefaultMapping;
}
appDefaultMapping = false;
if (secService != null) {
appDefaultMapping = Boolean.parseBoolean(secService.getActivateDefaultPrincipalToRoleMapping());
if (appDefaultMapping) {
// if set explicitly in the security service allow default mapping
return appDefaultMapping;
}
}
ApplicationRegistry appRegistry = Globals.getDefaultHabitat().getService(ApplicationRegistry.class);
ApplicationInfo appInfo = appRegistry.get(appName);
if (appInfo == null) {
return appDefaultMapping;
}
Application app = appInfo.getMetaData(Application.class);
BundleDescriptor bd = app.getModuleByUri(appName);
appDefaultMapping = bd == null ? app.isDefaultGroupPrincipalMapping() : app.getModuleByUri(appName).isDefaultGroupPrincipalMapping();
return appDefaultMapping;
}
use of com.sun.enterprise.deployment.Application in project Payara by payara.
the class JDOCodeGeneratorHelper method getModuleName.
/**
* Calculate module name from a bundle.
* @return module name.
*/
public static String getModuleName(EjbBundleDescriptor bundle) {
String moduleName = null;
Application application = bundle.getApplication();
if (application.isVirtual()) {
// Stand-alone module is deployed.
moduleName = application.getRegistrationName();
} else {
// Module is deployed as a part of an Application.
String jarName = bundle.getModuleDescriptor().getArchiveUri();
int l = jarName.length();
// Remove ".jar" from the bundle's jar name.
moduleName = jarName.substring(0, l - 4);
}
return moduleName;
}
use of com.sun.enterprise.deployment.Application in project Payara by payara.
the class WarHandler method getClassLoader.
@Override
public ClassLoader getClassLoader(final ClassLoader parent, final DeploymentContext context) {
Application applicationTemp = context.getModuleMetaData(Application.class);
final Application application = applicationTemp == null ? Application.createApplication() : applicationTemp;
WebappClassLoader cloader = AccessController.doPrivileged(new PrivilegedAction<WebappClassLoader>() {
@Override
public WebappClassLoader run() {
return new WebappClassLoader(parent, application);
}
});
try {
WebDirContext r = new WebDirContext();
File base = new File(context.getSource().getURI());
r.setDocBase(base.getAbsolutePath());
cloader.setResources(r);
cloader.addRepository("WEB-INF/classes/", new File(base, "WEB-INF/classes/"));
if (context.getScratchDir("ejb") != null) {
cloader.addRepository(context.getScratchDir("ejb").toURI().toURL().toString().concat("/"));
}
if (context.getScratchDir("jsp") != null) {
cloader.setWorkDir(context.getScratchDir("jsp"));
}
// add libraries referenced from manifest
for (URL url : getManifestLibraries(context)) {
cloader.addRepository(url.toString());
}
WebXmlParser webXmlParser = getWebXmlParser(context.getSource(), application);
configureLoaderAttributes(cloader, webXmlParser, base);
configureLoaderProperties(cloader, webXmlParser, base);
configureContextXmlAttribute(cloader, base, context);
try {
final DeploymentContext dc = context;
final ClassLoader cl = cloader;
AccessController.doPrivileged(new PermsArchiveDelegate.SetPermissionsAction(SMGlobalPolicyUtil.CommponentType.war, dc, cl));
} catch (PrivilegedActionException e) {
throw new SecurityException(e.getException());
}
} catch (XMLStreamException xse) {
logger.log(Level.SEVERE, xse.getMessage());
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, xse.getMessage(), xse);
}
xse.printStackTrace();
} catch (IOException ioe) {
logger.log(Level.SEVERE, ioe.getMessage());
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, ioe.getMessage(), ioe);
}
ioe.printStackTrace();
}
cloader.start();
return cloader;
}
Aggregations