Search in sources :

Example 11 with ConnectorRuntime

use of com.sun.enterprise.connectors.ConnectorRuntime in project Payara by payara.

the class DefaultJMSConnectionFactory method handle.

@Override
public Object handle(String name) throws NamingException {
    ConnectionFactory cachedCF = null;
    boolean isCFPM = false;
    if (name != null && name.endsWith(ConnectorConstants.PM_JNDI_SUFFIX)) {
        cachedCF = connectionFactoryPM;
        isCFPM = true;
    } else {
        cachedCF = connectionFactory;
    }
    if (cachedCF == null) {
        javax.naming.Context ctx = new javax.naming.InitialContext();
        if (isCFPM) {
            ConnectorRuntime connectorRuntime = ConnectorRuntime.getRuntime();
            cachedCF = (ConnectionFactory) connectorRuntime.lookupPMResource(DEFAULT_CF_PHYS, false);
            connectionFactoryPM = cachedCF;
        } else {
            cachedCF = (ConnectionFactory) ctx.lookup(DEFAULT_CF_PHYS);
            connectionFactory = cachedCF;
        }
    }
    return cachedCF;
}
Also used : ConnectionFactory(javax.jms.ConnectionFactory) ConnectorRuntime(com.sun.enterprise.connectors.ConnectorRuntime)

Example 12 with ConnectorRuntime

use of com.sun.enterprise.connectors.ConnectorRuntime 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 13 with ConnectorRuntime

use of com.sun.enterprise.connectors.ConnectorRuntime 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

ConnectorRuntime (com.sun.enterprise.connectors.ConnectorRuntime)13 ConnectorRuntimeException (com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)7 PoolInfo (org.glassfish.resourcebase.resources.api.PoolInfo)3 ActiveResourceAdapter (com.sun.enterprise.connectors.ActiveResourceAdapter)2 ConnectorApplication (com.sun.enterprise.connectors.module.ConnectorApplication)2 ConnectorDescriptor (com.sun.enterprise.deployment.ConnectorDescriptor)2 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)2 NamingException (javax.naming.NamingException)2 ResourceException (javax.resource.ResourceException)2 UnavailableException (javax.resource.spi.UnavailableException)2 ResourceAdapterConfig (org.glassfish.connectors.config.ResourceAdapterConfig)2 ResourceInfo (org.glassfish.resourcebase.resources.api.ResourceInfo)2 Resource (com.sun.enterprise.config.serverbeans.Resource)1 ConnectorRegistry (com.sun.enterprise.connectors.ConnectorRegistry)1 ConnectorArchivist (com.sun.enterprise.connectors.deployment.util.ConnectorArchivist)1 FileArchive (com.sun.enterprise.deploy.shared.FileArchive)1 Application (com.sun.enterprise.deployment.Application)1 MessageListener (com.sun.enterprise.deployment.MessageListener)1 ResourcePrincipal (com.sun.enterprise.deployment.ResourcePrincipal)1 AdministeredObjectResource (com.sun.enterprise.resource.beans.AdministeredObjectResource)1