Search in sources :

Example 51 with PoolInfo

use of org.glassfish.resourcebase.resources.api.PoolInfo in project Payara by payara.

the class JdbcRuntimeExtension method getPoolNameFromResourceJndiName.

/**
 * Gets the Pool name that this JDBC resource points to. In case of a PMF resource
 * gets the pool name of the pool pointed to by jdbc resource being pointed to by
 * the PMF resource
 *
 * @param resourceInfo the jndi name of the resource being used to get Connection from
 *                 This resource can either be a pmf resource or a jdbc resource
 * @return poolName of the pool that this resource directly/indirectly points to
 */
@Override
public PoolInfo getPoolNameFromResourceJndiName(ResourceInfo resourceInfo) {
    PoolInfo poolInfo = null;
    JdbcResource jdbcResource = null;
    String jndiName = resourceInfo.getName();
    ResourceInfo actualResourceInfo = new ResourceInfo(jndiName, resourceInfo.getApplicationName(), resourceInfo.getModuleName());
    ConnectorRuntime runtime = ConnectorRuntime.getRuntime();
    jdbcResource = (JdbcResource) ConnectorsUtil.getResourceByName(runtime.getResources(actualResourceInfo), JdbcResource.class, actualResourceInfo.getName());
    if (jdbcResource == null) {
        String suffix = ConnectorsUtil.getValidSuffix(jndiName);
        if (suffix != null) {
            jndiName = jndiName.substring(0, jndiName.lastIndexOf(suffix));
            actualResourceInfo = new ResourceInfo(jndiName, resourceInfo.getApplicationName(), resourceInfo.getModuleName());
        }
    }
    jdbcResource = (JdbcResource) ConnectorsUtil.getResourceByName(runtime.getResources(actualResourceInfo), JdbcResource.class, actualResourceInfo.getName());
    if (jdbcResource != null) {
        if (logger.isLoggable(Level.FINE)) {
            logger.fine("jdbcRes is ---: " + jdbcResource.getJndiName());
            logger.fine("poolName is ---: " + jdbcResource.getPoolName());
        }
    }
    if (jdbcResource != null) {
        poolInfo = new PoolInfo(jdbcResource.getPoolName(), actualResourceInfo.getApplicationName(), actualResourceInfo.getModuleName());
    }
    return poolInfo;
}
Also used : ResourceInfo(org.glassfish.resourcebase.resources.api.ResourceInfo) JdbcResource(org.glassfish.jdbc.config.JdbcResource) PoolInfo(org.glassfish.resourcebase.resources.api.PoolInfo) ConnectorRuntime(com.sun.enterprise.connectors.ConnectorRuntime)

Example 52 with PoolInfo

use of org.glassfish.resourcebase.resources.api.PoolInfo in project Payara by payara.

the class JmsHandlers method pingJms.

@Handler(id = "pingJms", input = { @HandlerInput(name = "poolName", type = String.class, required = true) })
public static void pingJms(HandlerContext handlerCtx) {
    try {
        String poolName = (String) handlerCtx.getInputValue("poolName");
        ConnectorRuntime connectorRuntime = GuiUtil.getHabitat().getService(ConnectorRuntime.class);
        PoolInfo poolInfo = new PoolInfo(poolName);
        connectorRuntime.pingConnectionPool(poolInfo);
        GuiUtil.prepareAlert("success", GuiUtil.getMessage("msg.PingSucceed"), null);
    } catch (Exception ex) {
        GuiUtil.prepareAlert("error", GuiUtil.getMessage("msg.Error"), ex.getMessage());
    }
}
Also used : PoolInfo(org.glassfish.resourcebase.resources.api.PoolInfo) ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) ConnectorRuntime(com.sun.enterprise.connectors.ConnectorRuntime) Handler(com.sun.jsftemplating.annotation.Handler)

Aggregations

PoolInfo (org.glassfish.resourcebase.resources.api.PoolInfo)52 ConnectorRuntimeException (com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)17 ResourceInfo (org.glassfish.resourcebase.resources.api.ResourceInfo)15 NamingException (javax.naming.NamingException)10 JdbcConnectionPool (org.glassfish.jdbc.config.JdbcConnectionPool)9 ConnectorConnectionPool (com.sun.enterprise.connectors.ConnectorConnectionPool)7 ManagedConnectionFactory (javax.resource.spi.ManagedConnectionFactory)7 ProbeListener (org.glassfish.external.probe.provider.annotations.ProbeListener)7 ResourceException (javax.resource.ResourceException)6 Property (org.jvnet.hk2.config.types.Property)5 PoolingException (com.sun.appserv.connectors.internal.api.PoolingException)4 Resources (com.sun.enterprise.config.serverbeans.Resources)4 ConnectionDefDescriptor (com.sun.enterprise.deployment.ConnectionDefDescriptor)4 ConnectorConfigProperty (com.sun.enterprise.deployment.ConnectorConfigProperty)4 ArrayList (java.util.ArrayList)4 JdbcResource (org.glassfish.jdbc.config.JdbcResource)4 ConnectorRegistry (com.sun.enterprise.connectors.ConnectorRegistry)3 ConnectorRuntime (com.sun.enterprise.connectors.ConnectorRuntime)3 ResourcePrincipal (com.sun.enterprise.deployment.ResourcePrincipal)3 ActionReport (org.glassfish.api.ActionReport)3