Search in sources :

Example 6 with AdminObjectResource

use of org.glassfish.connectors.config.AdminObjectResource in project Payara by payara.

the class AdminObjectResourceDeployer method deployResource.

/**
 * {@inheritDoc}
 */
public synchronized void deployResource(Object resource, String applicationName, String moduleName) throws Exception {
    final AdminObjectResource aor = (AdminObjectResource) resource;
    String jndiName = aor.getJndiName();
    ResourceInfo resourceInfo = new ResourceInfo(jndiName, applicationName, moduleName);
    createAdminObjectResource(aor, resourceInfo);
}
Also used : ResourceInfo(org.glassfish.resourcebase.resources.api.ResourceInfo) AdminObjectResource(org.glassfish.connectors.config.AdminObjectResource)

Example 7 with AdminObjectResource

use of org.glassfish.connectors.config.AdminObjectResource in project Payara by payara.

the class AdminObjectResourceDeployer method undeployResource.

/**
 * {@inheritDoc}
 */
public void undeployResource(Object resource, String applicationName, String moduleName) throws Exception {
    final AdminObjectResource aor = (AdminObjectResource) resource;
    ResourceInfo resourceInfo = new ResourceInfo(aor.getJndiName(), applicationName, moduleName);
    deleteAdminObjectResource(aor, resourceInfo);
}
Also used : ResourceInfo(org.glassfish.resourcebase.resources.api.ResourceInfo) AdminObjectResource(org.glassfish.connectors.config.AdminObjectResource)

Example 8 with AdminObjectResource

use of org.glassfish.connectors.config.AdminObjectResource in project Payara by payara.

the class AppSpecificConnectorClassLoaderUtil method detectResourceInRA.

private void detectResourceInRA(Application app, String moduleName, String jndiName) {
    // domain.xml
    Resource res = null;
    if (jndiName.startsWith(ConnectorConstants.JAVA_APP_SCOPE_PREFIX)) /*|| jndiName.startsWith("java:global/")*/
    {
        ApplicationInfo appInfo = appRegistry.get(app.getName());
        res = getApplicationScopedResource(jndiName, BindableResource.class, appInfo);
    } else if (jndiName.startsWith(ConnectorConstants.JAVA_MODULE_SCOPE_PREFIX)) {
        ApplicationInfo appInfo = appRegistry.get(app.getName());
        res = getModuleScopedResource(jndiName, moduleName, BindableResource.class, appInfo);
    } else {
        res = ConnectorsUtil.getResourceByName(getResources(), BindableResource.class, jndiName);
    }
    // (and .ear may refer to these resources in DD)
    if (res != null) {
        if (ConnectorResource.class.isAssignableFrom(res.getClass())) {
            ConnectorResource connResource = (ConnectorResource) res;
            String poolName = connResource.getPoolName();
            Resource pool;
            ApplicationInfo appInfo = appRegistry.get(app.getName());
            if (jndiName.startsWith(ConnectorConstants.JAVA_APP_SCOPE_PREFIX)) /*|| jndiName.startsWith("java:global/")*/
            {
                pool = getApplicationScopedResource(poolName, ResourcePool.class, appInfo);
            } else if (jndiName.startsWith(ConnectorConstants.JAVA_MODULE_SCOPE_PREFIX)) {
                pool = getModuleScopedResource(poolName, moduleName, ResourcePool.class, appInfo);
            } else {
                pool = ConnectorsUtil.getResourceByName(getResources(), ResourcePool.class, poolName);
            }
            if (ConnectorConnectionPool.class.isAssignableFrom(pool.getClass())) {
                String raName = ((ConnectorConnectionPool) pool).getResourceAdapterName();
                app.addResourceAdapter(raName);
            }
        } else if (AdminObjectResource.class.isAssignableFrom(res.getClass())) {
            String raName = ((AdminObjectResource) res).getResAdapter();
            app.addResourceAdapter(raName);
        }
    } else {
        boolean found = false;
        // detect sun-ra.xml
        // find all the standalone connector modules
        List<com.sun.enterprise.config.serverbeans.Application> applications = getApplications().getApplicationsWithSnifferType(com.sun.enterprise.config.serverbeans.ServerTags.CONNECTOR, true);
        Iterator itr = applications.iterator();
        while (itr.hasNext()) {
            com.sun.enterprise.config.serverbeans.Application application = (com.sun.enterprise.config.serverbeans.Application) itr.next();
            String appName = application.getName();
            ApplicationInfo appInfo = appRegistry.get(appName);
            if (appInfo == null) {
                // the app is not deployed on this node
                continue;
            }
            Application dolApp = appInfo.getMetaData(Application.class);
            Collection<ConnectorDescriptor> rarDescriptors = dolApp.getBundleDescriptors(ConnectorDescriptor.class);
            for (ConnectorDescriptor desc : rarDescriptors) {
                SunConnector sunraDesc = desc.getSunDescriptor();
                if (sunraDesc != null) {
                    String sunRAJndiName = (String) sunraDesc.getResourceAdapter().getValue(ResourceAdapter.JNDI_NAME);
                    if (jndiName.equals(sunRAJndiName)) {
                        app.addResourceAdapter(desc.getName());
                        found = true;
                        break;
                    }
                } else {
                    // check whether it is default resource in the connector
                    if (desc.getDefaultResourcesNames().contains(jndiName)) {
                        app.addResourceAdapter(desc.getName());
                        found = true;
                        break;
                    }
                }
            }
        }
        if (!found) {
            if (DOLUtils.getDefaultLogger().isLoggable(Level.FINEST)) {
                DOLUtils.getDefaultLogger().log(Level.FINEST, "could not find resource by name : " + jndiName);
            }
        }
    }
}
Also used : ConnectorConnectionPool(org.glassfish.connectors.config.ConnectorConnectionPool) AdminObjectResource(org.glassfish.connectors.config.AdminObjectResource) Resource(com.sun.enterprise.config.serverbeans.Resource) BindableResource(com.sun.enterprise.config.serverbeans.BindableResource) ConnectorResource(org.glassfish.connectors.config.ConnectorResource) ApplicationInfo(org.glassfish.internal.data.ApplicationInfo) ResourcePool(com.sun.enterprise.config.serverbeans.ResourcePool) ConnectorDescriptor(com.sun.enterprise.deployment.ConnectorDescriptor) BindableResource(com.sun.enterprise.config.serverbeans.BindableResource) Iterator(java.util.Iterator) SunConnector(com.sun.enterprise.deployment.runtime.connector.SunConnector) AdminObjectResource(org.glassfish.connectors.config.AdminObjectResource) Application(com.sun.enterprise.deployment.Application) ConnectorResource(org.glassfish.connectors.config.ConnectorResource)

Example 9 with AdminObjectResource

use of org.glassfish.connectors.config.AdminObjectResource in project Payara by payara.

the class AdminObjectResourceDeployer method undeployResource.

/**
 * {@inheritDoc}
 */
public synchronized void undeployResource(Object resource) throws Exception {
    final AdminObjectResource aor = (AdminObjectResource) resource;
    ResourceInfo resourceInfo = ConnectorsUtil.getResourceInfo(aor);
    deleteAdminObjectResource(aor, resourceInfo);
}
Also used : ResourceInfo(org.glassfish.resourcebase.resources.api.ResourceInfo) AdminObjectResource(org.glassfish.connectors.config.AdminObjectResource)

Example 10 with AdminObjectResource

use of org.glassfish.connectors.config.AdminObjectResource in project Payara by payara.

the class AdminObjectManager method createConfigBean.

private AdminObjectResource createConfigBean(Resources param, Properties props) throws PropertyVetoException, TransactionFailure {
    AdminObjectResource newResource = param.createChild(AdminObjectResource.class);
    newResource.setJndiName(jndiName);
    if (description != null) {
        newResource.setDescription(description);
    }
    newResource.setResAdapter(raName);
    newResource.setResType(resType);
    newResource.setClassName(className);
    newResource.setEnabled(enabled);
    if (props != null) {
        for (Map.Entry e : props.entrySet()) {
            Property prop = newResource.createChild(Property.class);
            prop.setName((String) e.getKey());
            prop.setValue((String) e.getValue());
            newResource.getProperty().add(prop);
        }
    }
    return newResource;
}
Also used : AdminObjectResource(org.glassfish.connectors.config.AdminObjectResource) HashMap(java.util.HashMap) Map(java.util.Map) Property(org.jvnet.hk2.config.types.Property)

Aggregations

AdminObjectResource (org.glassfish.connectors.config.AdminObjectResource)11 ResourceInfo (org.glassfish.resourcebase.resources.api.ResourceInfo)4 ConnectorRuntimeException (com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)2 EnvironmentProperty (com.sun.enterprise.deployment.EnvironmentProperty)2 URISyntaxException (java.net.URISyntaxException)2 PrivilegedActionException (java.security.PrivilegedActionException)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ExecutionException (java.util.concurrent.ExecutionException)2 ResourceAdapterInternalException (javax.resource.spi.ResourceAdapterInternalException)2 ActionReport (org.glassfish.api.ActionReport)2 ConnectorConnectionPool (org.glassfish.connectors.config.ConnectorConnectionPool)2 ConnectorResource (org.glassfish.connectors.config.ConnectorResource)2 MultiException (org.glassfish.hk2.api.MultiException)2 Property (org.jvnet.hk2.config.types.Property)2 BindableResource (com.sun.enterprise.config.serverbeans.BindableResource)1 Resource (com.sun.enterprise.config.serverbeans.Resource)1 ResourcePool (com.sun.enterprise.config.serverbeans.ResourcePool)1 Application (com.sun.enterprise.deployment.Application)1