use of com.sun.enterprise.deployment.Application in project Payara by payara.
the class SingletonLifeCycleManager method normalizeSingletonName.
private String normalizeSingletonName(String origName, EjbSessionDescriptor sessionDesc) {
String normalizedName;
boolean fullyQualified = origName.contains("#");
Application app = sessionDesc.getEjbBundleDescriptor().getApplication();
if (fullyQualified) {
int indexOfHash = origName.indexOf("#");
String ejbName = origName.substring(indexOfHash + 1);
String relativeJarPath = origName.substring(0, indexOfHash);
BundleDescriptor bundle = app.getRelativeBundle(sessionDesc.getEjbBundleDescriptor(), relativeJarPath);
if (bundle == null) {
throw new IllegalStateException("Invalid @DependOn value = " + origName + " for Singleton " + sessionDesc.getName());
}
normalizedName = bundle.getModuleDescriptor().getArchiveUri() + "#" + ejbName;
} else {
normalizedName = sessionDesc.getEjbBundleDescriptor().getModuleDescriptor().getArchiveUri() + "#" + origName;
}
return normalizedName;
}
use of com.sun.enterprise.deployment.Application in project Payara by payara.
the class WebBundleRuntimeNode method addDescriptor.
/**
* Adds a new DOL descriptor instance to the descriptor instance associated with
* this XMLNode
*
* @param newDescriptor the new descriptor
*/
@Override
public void addDescriptor(Object newDescriptor) {
SunWebAppImpl sunWebApp = (SunWebAppImpl) descriptor.getSunDescriptor();
if (newDescriptor instanceof WebComponentDescriptor) {
WebComponentDescriptor servlet = (WebComponentDescriptor) newDescriptor;
// for backward compatibility with s1as schema2beans generated desc
Servlet s1descriptor = new Servlet();
s1descriptor.setServletName(servlet.getCanonicalName());
if (servlet.getRunAsIdentity() != null) {
s1descriptor.setPrincipalName(servlet.getRunAsIdentity().getPrincipal());
}
sunWebApp.addServlet(s1descriptor);
} else if (newDescriptor instanceof ServiceReferenceDescriptor) {
descriptor.addServiceReferenceDescriptor((ServiceReferenceDescriptor) newDescriptor);
} else if (newDescriptor instanceof SecurityRoleMapping) {
SecurityRoleMapping srm = (SecurityRoleMapping) newDescriptor;
sunWebApp.addSecurityRoleMapping(srm);
// store it in the application using pure DOL descriptors...
Application app = descriptor.getApplication();
if (app != null) {
Role role = new Role(srm.getRoleName());
SecurityRoleMapper rm = app.getRoleMapper();
if (rm != null) {
List<PrincipalNameDescriptor> principals = srm.getPrincipalNames();
for (int i = 0; i < principals.size(); i++) {
rm.assignRole(principals.get(i).getPrincipal(), role, descriptor);
}
List<String> groups = srm.getGroupNames();
for (int i = 0; i < groups.size(); i++) {
rm.assignRole(new Group(groups.get(i)), role, descriptor);
}
}
}
} else if (newDescriptor instanceof IdempotentUrlPattern) {
sunWebApp.addIdempotentUrlPattern((IdempotentUrlPattern) newDescriptor);
} else if (newDescriptor instanceof SessionConfig) {
sunWebApp.setSessionConfig((SessionConfig) newDescriptor);
} else if (newDescriptor instanceof Cache) {
sunWebApp.setCache((Cache) newDescriptor);
} else if (newDescriptor instanceof ClassLoader) {
sunWebApp.setClassLoader((ClassLoader) newDescriptor);
} else if (newDescriptor instanceof JspConfig) {
sunWebApp.setJspConfig((JspConfig) newDescriptor);
} else if (newDescriptor instanceof LocaleCharsetInfo) {
sunWebApp.setLocaleCharsetInfo((LocaleCharsetInfo) newDescriptor);
} else if (newDescriptor instanceof WebProperty) {
sunWebApp.addWebProperty((WebProperty) newDescriptor);
} else if (newDescriptor instanceof Valve) {
sunWebApp.addValve((Valve) newDescriptor);
} else
super.addDescriptor(descriptor);
}
use of com.sun.enterprise.deployment.Application in project Payara by payara.
the class ManagedBeanManagerImpl method event.
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);
}
}
use of com.sun.enterprise.deployment.Application in project Payara by payara.
the class AppSpecificConnectorClassLoaderUtil method detectReferredRARs.
/**
* {@inheritDoc}
*/
public void detectReferredRARs(String appName) {
ApplicationInfo appInfo = appRegistry.get(appName);
// call to detectReferredRAs can be called only when appInfo is available
if (appInfo == null) {
throw new IllegalStateException("ApplicationInfo is not available for application [ " + appName + " ]");
}
Application app = appInfo.getMetaData(Application.class);
if (!appInfo.isJavaEEApp()) {
if (_logger.isLoggable(Level.FINEST)) {
_logger.finest("Application [" + appName + "] is not a Java EE application, skipping " + "resource-adapter references detection");
}
return;
}
// Iterate through all bundle descriptors, ejb-descriptors, managed-bean descriptors
// for references to resource-adapters
//
// References can be via :
// resource-ref
// resource-env-ref
// ra-mid
//
// Resource definition can be found in :
// domain.xml
// sun-ra.xml
// default connector resource
// handle application.xml bundle descriptor
processDescriptorForRAReferences(app, null, app);
Collection<BundleDescriptor> bundleDescriptors = app.getBundleDescriptors();
// bundle descriptors
for (BundleDescriptor bundleDesc : bundleDescriptors) {
String moduleName = getModuleName(bundleDesc, app);
processDescriptorForRAReferences(app, bundleDesc, moduleName);
Collection<RootDeploymentDescriptor> dds = bundleDesc.getExtensionsDescriptors();
if (dds != null) {
for (RootDeploymentDescriptor dd : dds) {
processDescriptorForRAReferences(app, dd, moduleName);
}
}
}
}
use of com.sun.enterprise.deployment.Application in project Payara by payara.
the class EjbBundleValidator method checkDependsOn.
private void checkDependsOn(EjbDescriptor ejb) {
if (ejb instanceof EjbSessionDescriptor) {
EjbSessionDescriptor sessionDesc = (EjbSessionDescriptor) ejb;
if (sessionDesc.hasDependsOn()) {
if (!sessionDesc.isSingleton()) {
throw new RuntimeException("Illegal usage of DependsOn for EJB " + ejb.getName() + ". DependsOn is only supported for Singleton beans");
}
String[] dependsOn = sessionDesc.getDependsOn();
for (String next : dependsOn) {
// TODO support new EJB 3.1 syntax
boolean fullyQualified = next.contains("#");
Application app = sessionDesc.getEjbBundleDescriptor().getApplication();
if (fullyQualified) {
int indexOfHash = next.indexOf("#");
String ejbName = next.substring(indexOfHash + 1);
String relativeJarPath = next.substring(0, indexOfHash);
BundleDescriptor bundle = app.getRelativeBundle(sessionDesc.getEjbBundleDescriptor(), relativeJarPath);
if (bundle == null) {
throw new IllegalStateException("Invalid @DependOn value = " + next + " for Singleton " + sessionDesc.getName());
}
EjbBundleDescriptorImpl ejbBundle = (bundle.getModuleType() != null && bundle.getModuleType().equals(DOLUtils.warType())) ? bundle.getExtensionsDescriptors(EjbBundleDescriptorImpl.class).iterator().next() : (EjbBundleDescriptorImpl) bundle;
if (!ejbBundle.hasEjbByName(ejbName)) {
throw new RuntimeException("Invalid DependsOn dependency '" + next + "' for EJB " + ejb.getName());
}
} else {
EjbBundleDescriptorImpl bundle = ejb.getEjbBundleDescriptor();
if (!bundle.hasEjbByName(next)) {
throw new RuntimeException("Invalid DependsOn dependency '" + next + "' for EJB " + ejb.getName());
}
}
}
}
}
}
Aggregations