Search in sources :

Example 6 with BundleDescriptor

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);
    }
}
Also used : BundleDescriptor(com.sun.enterprise.deployment.BundleDescriptor) WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor) WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor)

Example 7 with BundleDescriptor

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);
    }
}
Also used : ModuleDescriptor(org.glassfish.deployment.common.ModuleDescriptor) BundleDescriptor(com.sun.enterprise.deployment.BundleDescriptor) DeploymentException(org.glassfish.deployment.common.DeploymentException) Application(com.sun.enterprise.deployment.Application) VersioningSyntaxException(org.glassfish.deployment.versioning.VersioningSyntaxException) DeploymentException(org.glassfish.deployment.common.DeploymentException)

Example 8 with BundleDescriptor

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;
}
Also used : BundleDescriptor(com.sun.enterprise.deployment.BundleDescriptor) WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor) EjbBundleDescriptor(com.sun.enterprise.deployment.EjbBundleDescriptor) JndiNameEnvironment(com.sun.enterprise.deployment.JndiNameEnvironment) ComponentEnvManager(com.sun.enterprise.container.common.spi.util.ComponentEnvManager) EjbDescriptor(com.sun.enterprise.deployment.EjbDescriptor)

Example 9 with BundleDescriptor

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;
}
Also used : BundleDescriptor(com.sun.enterprise.deployment.BundleDescriptor) WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor) EjbBundleDescriptor(com.sun.enterprise.deployment.EjbBundleDescriptor) JCDIService(com.sun.enterprise.container.common.spi.JCDIService) JavaEEInterceptorBuilder(com.sun.enterprise.container.common.spi.JavaEEInterceptorBuilder) InterceptorInvoker(com.sun.enterprise.container.common.spi.InterceptorInvoker)

Example 10 with BundleDescriptor

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();
}
Also used : BundleDescriptor(com.sun.enterprise.deployment.BundleDescriptor) Application(com.sun.enterprise.deployment.Application)

Aggregations

BundleDescriptor (com.sun.enterprise.deployment.BundleDescriptor)51 EjbBundleDescriptor (com.sun.enterprise.deployment.EjbBundleDescriptor)24 WebBundleDescriptor (com.sun.enterprise.deployment.WebBundleDescriptor)24 Application (com.sun.enterprise.deployment.Application)17 EjbDescriptor (com.sun.enterprise.deployment.EjbDescriptor)10 ModuleDescriptor (org.glassfish.deployment.common.ModuleDescriptor)9 ManagedBeanDescriptor (com.sun.enterprise.deployment.ManagedBeanDescriptor)8 JndiNameEnvironment (com.sun.enterprise.deployment.JndiNameEnvironment)7 WeldBootstrap (org.jboss.weld.bootstrap.WeldBootstrap)7 BeanDeploymentArchive (org.jboss.weld.bootstrap.spi.BeanDeploymentArchive)7 JCDIService (com.sun.enterprise.container.common.spi.JCDIService)6 ApplicationInfo (org.glassfish.internal.data.ApplicationInfo)6 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5 RootDeploymentDescriptor (org.glassfish.deployment.common.RootDeploymentDescriptor)5 InterceptorInvoker (com.sun.enterprise.container.common.spi.InterceptorInvoker)4 HashSet (java.util.HashSet)4 JavaEEInterceptorBuilder (com.sun.enterprise.container.common.spi.JavaEEInterceptorBuilder)3 File (java.io.File)3 IOException (java.io.IOException)3