use of com.sun.enterprise.deployment.BundleDescriptor in project Payara by payara.
the class RolesAllowedAutoDiscoverable method configure.
@Override
public void configure(FeatureContext context) {
boolean shouldRegister = true;
BundleDescriptor descriptor = getCurrentBundleForContext(getDefaultHabitat().getService(Deployment.class).getCurrentDeploymentContext());
if (descriptor instanceof WebBundleDescriptor) {
shouldRegister = ((WebBundleDescriptor) descriptor).isJaxrsRolesAllowedEnabled();
}
if (shouldRegister && !context.getConfiguration().isRegistered(RolesAllowedDynamicFeature.class)) {
context.register(RolesAllowedDynamicFeature.class);
}
}
use of com.sun.enterprise.deployment.BundleDescriptor in project Payara by payara.
the class AppClientGroupFacadeGenerator method generateGroupFacade.
private void generateGroupFacade() {
final Application application = dc.getModuleMetaData(Application.class);
final Collection<ModuleDescriptor<BundleDescriptor>> appClients = application.getModuleDescriptorsByType(carType);
final StringBuilder appClientGroupListSB = new StringBuilder();
/*
/*
* For each app client, get its facade's URI to include in the
* generated EAR facade's client group listing.
*/
for (Iterator<ModuleDescriptor<BundleDescriptor>> it = appClients.iterator(); it.hasNext(); ) {
ModuleDescriptor<BundleDescriptor> md = it.next();
appClientGroupListSB.append((appClientGroupListSB.length() > 0) ? " " : "").append(earDirUserURIText(dc)).append(appClientFacadeUserURI(md.getArchiveUri()));
}
try {
addTopLevelContentToGroupFacade();
/*
* Pass the EAR's generated/xml directory for where to generated the
* group facade. Because the directories are flattened, even if the
* client is actually x/y/z.jar its expanded directory will be just
* one level lower than the EAR's directory.
*/
generateAndRecordEARFacadeContents(dc, appClientGroupListSB.toString());
recordGroupFacadeGeneration();
} catch (Exception e) {
throw new DeploymentException(e);
}
}
use of com.sun.enterprise.deployment.BundleDescriptor in project Payara by payara.
the class ManagedBeanManagerImpl method getBundle.
private BundleDescriptor getBundle() {
ComponentEnvManager compEnvManager = habitat.getService(ComponentEnvManager.class);
JndiNameEnvironment env = compEnvManager.getCurrentJndiNameEnvironment();
BundleDescriptor bundle = null;
if (env instanceof BundleDescriptor) {
bundle = (BundleDescriptor) env;
} else if (env instanceof EjbDescriptor) {
bundle = (BundleDescriptor) ((EjbDescriptor) env).getEjbBundleDescriptor().getModuleDescriptor().getDescriptor();
}
if (bundle == null) {
throw new IllegalStateException("Invalid context for managed bean creation");
}
return bundle;
}
use of com.sun.enterprise.deployment.BundleDescriptor in project Payara by payara.
the class ManagedBeanManagerImpl method createManagedBean.
/**
* @param desc can be null if JCDI enabled bundle.
* @param managedBeanClass
* @return
* @throws Exception
*/
public <T> T createManagedBean(ManagedBeanDescriptor desc, Class<T> managedBeanClass) throws Exception {
JCDIService jcdiService = habitat.getService(JCDIService.class);
BundleDescriptor bundleDescriptor = null;
if (desc == null) {
bundleDescriptor = getBundle();
} else {
bundleDescriptor = desc.getBundleDescriptor();
}
if (bundleDescriptor == null) {
throw new IllegalStateException("Class " + managedBeanClass + " is not a valid EE ManagedBean class");
}
T callerObject = null;
if ((jcdiService != null) && jcdiService.isJCDIEnabled(bundleDescriptor)) {
// Have 299 create, inject, and call PostConstruct on managed bean
JCDIService.JCDIInjectionContext jcdiContext = jcdiService.createManagedObject(managedBeanClass, bundleDescriptor);
callerObject = (T) jcdiContext.getInstance();
// Need to keep track of context in order to destroy properly
Map<Object, JCDIService.JCDIInjectionContext> bundleNonManagedObjs = jcdiManagedBeanInstanceMap.get(bundleDescriptor);
bundleNonManagedObjs.put(callerObject, jcdiContext);
} else {
JavaEEInterceptorBuilder interceptorBuilder = (JavaEEInterceptorBuilder) desc.getInterceptorBuilder();
InterceptorInvoker interceptorInvoker = interceptorBuilder.createInvoker(null);
// This is the object passed back to the caller.
callerObject = (T) interceptorInvoker.getProxy();
Object[] interceptorInstances = interceptorInvoker.getInterceptorInstances();
// Inject interceptor instances
for (int i = 0; i < interceptorInstances.length; i++) {
inject(interceptorInstances[i], desc);
}
interceptorInvoker.invokeAroundConstruct();
// This is the managed bean class instance
Object managedBean = interceptorInvoker.getTargetInstance();
inject(managedBean, desc);
interceptorInvoker.invokePostConstruct();
desc.addBeanInstanceInfo(managedBean, interceptorInvoker);
}
return callerObject;
}
use of com.sun.enterprise.deployment.BundleDescriptor in project Payara by payara.
the class Java2DBProcessorHelper method getDDLNamePrefix.
/**
* Returns name prefix for DDL files extracted from the info instance by the
* Sun-specific code.
*
* @param info the instance to use for the name generation.
* @return name prefix as String.
*/
public static String getDDLNamePrefix(Object info) {
StringBuffer rc = new StringBuffer();
if (info instanceof BundleDescriptor && !(info instanceof Application)) {
BundleDescriptor bundle = (BundleDescriptor) info;
rc.append(bundle.getApplication().getRegistrationName());
Application application = bundle.getApplication();
if (!application.isVirtual()) {
String modulePath = bundle.getModuleDescriptor().getArchiveUri();
int l = modulePath.length();
// Remove ".jar" from the module's jar name.
rc.append(DatabaseConstants.NAME_SEPARATOR).append(modulePath.substring(0, l - 4));
}
}
return (rc.length() == 0) ? DEFAULT_NAME : rc.toString();
}
Aggregations