Search in sources :

Example 1 with CommonResourceProxy

use of org.glassfish.javaee.services.CommonResourceProxy in project Payara by payara.

the class ComponentEnvManagerImpl method addAllDescriptorBindings.

private void addAllDescriptorBindings(JndiNameEnvironment env, ScopeType scope, Collection<JNDIBinding> jndiBindings) {
    Set<ResourceDescriptor> allDescriptors = new HashSet<ResourceDescriptor>();
    Set<ResourceDescriptor> dsds = env.getResourceDescriptors(JavaEEResourceType.DSD);
    Set<ResourceDescriptor> jmscfdds = env.getResourceDescriptors(JavaEEResourceType.JMSCFDD);
    Set<ResourceDescriptor> msds = env.getResourceDescriptors(JavaEEResourceType.MSD);
    Set<ResourceDescriptor> jmsddds = env.getResourceDescriptors(JavaEEResourceType.JMSDD);
    if (!(env instanceof ApplicationClientDescriptor)) {
        Set<ResourceDescriptor> cfdds = env.getResourceDescriptors(JavaEEResourceType.CFD);
        allDescriptors.addAll(cfdds);
    } else {
        _logger.fine("Do not support connection-factory in client module.");
    }
    if (!(env instanceof ApplicationClientDescriptor)) {
        Set<ResourceDescriptor> aodd = env.getResourceDescriptors(JavaEEResourceType.AODD);
        allDescriptors.addAll(aodd);
    } else {
        _logger.fine("Do not support administered-object in client module.");
    }
    allDescriptors.addAll(dsds);
    allDescriptors.addAll(jmscfdds);
    allDescriptors.addAll(msds);
    allDescriptors.addAll(jmsddds);
    for (ResourceDescriptor descriptor : allDescriptors) {
        if (!dependencyAppliesToScope(descriptor, scope)) {
            continue;
        }
        if (descriptor.getResourceType().equals(DSD)) {
            if (((DataSourceDefinitionDescriptor) descriptor).isDeployed()) {
                continue;
            }
        }
        String resourceId = getResourceId(env, descriptor);
        descriptor.setResourceId(resourceId);
        CommonResourceProxy proxy = locator.getService(CommonResourceProxy.class);
        proxy.setDescriptor(descriptor);
        String logicalJndiName = descriptorToLogicalJndiName(descriptor);
        CompEnvBinding envBinding = new CompEnvBinding(logicalJndiName, proxy);
        jndiBindings.add(envBinding);
        // add another proxy with __PM suffix
        if (descriptor.getResourceType().equals(JavaEEResourceType.JMSCFDD)) {
            CommonResourceProxy jmscfProxy = locator.getService(JMSCFResourcePMProxy.class);
            jmscfProxy.setDescriptor(descriptor);
            CompEnvBinding jmscfEnvBinding = new CompEnvBinding(ConnectorsUtil.getPMJndiName(logicalJndiName), jmscfProxy);
            jndiBindings.add(jmscfEnvBinding);
        }
    }
}
Also used : CommonResourceProxy(org.glassfish.javaee.services.CommonResourceProxy) ResourceDescriptor(com.sun.enterprise.deployment.ResourceDescriptor)

Example 2 with CommonResourceProxy

use of org.glassfish.javaee.services.CommonResourceProxy in project Payara by payara.

the class MailSessionDeployer method registerMSDReferredByApplication.

private void registerMSDReferredByApplication(String appName, MailSessionDescriptor msd) {
    if (!msd.isDeployed()) {
        CommonResourceProxy proxy = mailSessionProxyProvider.get();
        org.glassfish.resourcebase.resources.naming.ResourceNamingService resourceNamingService = resourceNamingServiceProvider.get();
        proxy.setDescriptor(msd);
        if (msd.getName().startsWith(ConnectorConstants.JAVA_APP_SCOPE_PREFIX)) {
            msd.setResourceId(appName);
        }
        if (msd.getName().startsWith(ConnectorConstants.JAVA_GLOBAL_SCOPE_PREFIX) || msd.getName().startsWith(ConnectorConstants.JAVA_APP_SCOPE_PREFIX)) {
            ResourceInfo resourceInfo = new ResourceInfo(msd.getName(), appName);
            try {
                resourceNamingService.publishObject(resourceInfo, proxy, true);
                msd.setDeployed(true);
            } catch (NamingException e) {
                Object[] params = new Object[] { appName, msd.getName(), e };
                _logger.log(Level.WARNING, "exception while registering mail-session ", params);
            }
        }
    }
}
Also used : CommonResourceProxy(org.glassfish.javaee.services.CommonResourceProxy) ResourceInfo(org.glassfish.resourcebase.resources.api.ResourceInfo) NamingException(javax.naming.NamingException)

Example 3 with CommonResourceProxy

use of org.glassfish.javaee.services.CommonResourceProxy in project Payara by payara.

the class DataSourceDefinitionDeployer method registerDSDReferredByApplication.

private void registerDSDReferredByApplication(String appName, DataSourceDefinitionDescriptor dsd) {
    // DSD is bound to JNDI only when it is not already deployed.
    if (!dsd.isDeployed()) {
        CommonResourceProxy proxy = dataSourceDefinitionProxyProvider.get();
        ResourceNamingService resourceNamingService = resourceNamingServiceProvider.get();
        proxy.setDescriptor(dsd);
        String dsdName = dsd.getName();
        if (dsdName.startsWith(JAVA_APP_SCOPE_PREFIX)) {
            dsd.setResourceId(appName);
        }
        if (dsdName.startsWith(JAVA_GLOBAL_SCOPE_PREFIX) || dsdName.startsWith(JAVA_APP_SCOPE_PREFIX)) {
            ResourceInfo resourceInfo = new ResourceInfo(dsdName, appName, null);
            try {
                resourceNamingService.publishObject(resourceInfo, proxy, true);
                dsd.setDeployed(true);
            } catch (NamingException e) {
                _logger.log(Level.WARNING, "dsd.registration.failed", new Object[] { appName, dsdName, e });
            }
        }
    }
}
Also used : CommonResourceProxy(org.glassfish.javaee.services.CommonResourceProxy) ResourceInfo(org.glassfish.resourcebase.resources.api.ResourceInfo) ResourceNamingService(org.glassfish.resourcebase.resources.naming.ResourceNamingService) NamingException(javax.naming.NamingException)

Aggregations

CommonResourceProxy (org.glassfish.javaee.services.CommonResourceProxy)3 NamingException (javax.naming.NamingException)2 ResourceInfo (org.glassfish.resourcebase.resources.api.ResourceInfo)2 ResourceDescriptor (com.sun.enterprise.deployment.ResourceDescriptor)1 ResourceNamingService (org.glassfish.resourcebase.resources.naming.ResourceNamingService)1