Search in sources :

Example 6 with ResourceAdapterConfig

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

the class ActiveOutboundResourceAdapter method init.

/**
 * Creates an active inbound resource adapter. Sets all RA java bean
 * properties and issues a start.
 *
 * @param ra         <code>ResourceAdapter<code> java bean.
 * @param desc       <code>ConnectorDescriptor</code> object.
 * @param moduleName Resource adapter module name.
 * @param jcl        <code>ClassLoader</code> instance.
 * @throws ConnectorRuntimeException If there is a failure in loading
 *                                   or starting the resource adapter.
 */
public void init(ResourceAdapter ra, ConnectorDescriptor desc, String moduleName, ClassLoader jcl) throws ConnectorRuntimeException {
    super.init(ra, desc, moduleName, jcl);
    this.resourceadapter_ = ra;
    if (resourceadapter_ != null) {
        try {
            loadRAConfiguration();
            // now the RA bean would have been fully configured (taking into account, resource-adapter-config),
            // validate the RA bean now.
            beanValidator.validateJavaBean(ra, moduleName);
            ConnectorRegistry registry = ConnectorRegistry.getInstance();
            String poolId = null;
            ResourceAdapterConfig raConfig = registry.getResourceAdapterConfig(moduleName_);
            if (raConfig != null) {
                poolId = raConfig.getThreadPoolIds();
            }
            this.bootStrapContextImpl = new BootstrapContextImpl(poolId, moduleName_, jcl);
            validateWorkContextSupport(desc);
            startResourceAdapter(bootStrapContextImpl);
        } catch (ResourceAdapterInternalException ex) {
            _logger.log(Level.SEVERE, "rardeployment.start_failed", ex);
            String i18nMsg = localStrings.getString("rardeployment.start_failed", ex.getMessage());
            ConnectorRuntimeException cre = new ConnectorRuntimeException(i18nMsg);
            cre.initCause(ex);
            throw cre;
        } catch (Throwable t) {
            _logger.log(Level.SEVERE, "rardeployment.start_failed", t);
            String i18nMsg = localStrings.getString("rardeployment.start_failed", t.getMessage());
            ConnectorRuntimeException cre = new ConnectorRuntimeException(i18nMsg);
            if (t.getCause() != null) {
                cre.initCause(t.getCause());
            } else {
                cre.initCause(t);
            }
            throw cre;
        }
    }
}
Also used : ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) ResourceAdapterConfig(org.glassfish.connectors.config.ResourceAdapterConfig)

Example 7 with ResourceAdapterConfig

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

the class ListResourceAdapterConfigs method execute.

/**
 * Executes the command with the command parameters passed as Properties
 * where the keys are the paramter names and the values the parameter values
 *
 * @param context information
 */
public void execute(AdminCommandContext context) {
    final ActionReport report = context.getActionReport();
    try {
        HashMap<String, List<Property>> raMap = new HashMap<String, List<Property>>();
        boolean raExists = false;
        Collection<ResourceAdapterConfig> resourceAdapterConfigs = domain.getResources().getResources(ResourceAdapterConfig.class);
        for (ResourceAdapterConfig r : resourceAdapterConfigs) {
            if (raName != null && !raName.isEmpty()) {
                if (r.getResourceAdapterName().equals(raName)) {
                    raMap.put(raName, r.getProperty());
                    raExists = true;
                    break;
                }
            } else {
                raMap.put(r.getResourceAdapterName(), r.getProperty());
            }
        }
        if (raName != null && !raName.isEmpty() && !raExists) {
            report.setMessage(localStrings.getLocalString("delete.resource.adapter.config.notfound", "Resource adapter {0} not found.", raName));
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            return;
        }
        /**
         *              get the properties if long_opt=true. Otherwise return the name.
         */
        if (long_opt) {
            for (Entry<String, List<Property>> raEntry : raMap.entrySet()) {
                final ActionReport.MessagePart part = report.getTopMessagePart().addChild();
                part.setMessage(raEntry.getKey());
                for (Property prop : raEntry.getValue()) {
                    final ActionReport.MessagePart propPart = part.addChild();
                    propPart.setMessage("\t" + prop.getName() + "=" + prop.getValue());
                }
            }
        } else {
            for (String ra : raMap.keySet()) {
                final ActionReport.MessagePart part = report.getTopMessagePart().addChild();
                part.setMessage(ra);
            }
        }
    } catch (Exception e) {
        String failMsg = localStrings.getLocalString("list.resource.adapter.configs.fail", "Unable to list resource adapter configs.");
        Logger.getLogger(ListResourceAdapterConfigs.class.getName()).log(Level.SEVERE, failMsg, e);
        report.setMessage(failMsg + " " + e.getLocalizedMessage());
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        report.setFailureCause(e);
        return;
    }
    report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
Also used : HashMap(java.util.HashMap) ResourceAdapterConfig(org.glassfish.connectors.config.ResourceAdapterConfig) ActionReport(org.glassfish.api.ActionReport) List(java.util.List) Property(org.jvnet.hk2.config.types.Property)

Example 8 with ResourceAdapterConfig

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

the class ActiveOutboundResourceAdapter method loadRAConfiguration.

/**
 * Loads RA javabean. This method is protected, so that any system
 * resource adapter can have specific configuration done during the
 * loading.
 *
 * @throws ConnectorRuntimeException if there is a failure.
 */
protected void loadRAConfiguration() throws ConnectorRuntimeException {
    try {
        Set mergedProps;
        ConnectorRegistry registry = ConnectorRegistry.getInstance();
        ResourceAdapterConfig raConfig = registry.getResourceAdapterConfig(moduleName_);
        List<Property> raConfigProps = new ArrayList<Property>();
        mergedProps = mergeRAConfiguration(raConfig, raConfigProps);
        logMergedProperties(mergedProps);
        SetMethodAction setMethodAction = new SetMethodAction(this.resourceadapter_, mergedProps);
        setMethodAction.run();
    } catch (Exception e) {
        String i18nMsg = localStrings.getString("ccp_adm.wrong_params_for_create", e.getMessage());
        ConnectorRuntimeException cre = new ConnectorRuntimeException(i18nMsg);
        cre.initCause(e);
        throw cre;
    }
}
Also used : ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) ResourceAdapterConfig(org.glassfish.connectors.config.ResourceAdapterConfig) ConnectorConfigProperty(com.sun.enterprise.deployment.ConnectorConfigProperty) Property(org.jvnet.hk2.config.types.Property) ResourceException(javax.resource.ResourceException) NamingException(javax.naming.NamingException) ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) SetMethodAction(com.sun.enterprise.connectors.util.SetMethodAction)

Example 9 with ResourceAdapterConfig

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

the class ResourceAdapterConfigDeployer method undeployResource.

/**
 * {@inheritDoc}
 */
public synchronized void undeployResource(Object resource) throws Exception {
    ResourceAdapterConfig domainConfig = (ResourceAdapterConfig) resource;
    String rarName = domainConfig.getResourceAdapterName();
    ConnectorRuntime crt = getConnectorRuntime();
    crt.deleteResourceAdapterConfig(rarName);
}
Also used : ResourceAdapterConfig(org.glassfish.connectors.config.ResourceAdapterConfig) ConnectorRuntime(com.sun.enterprise.connectors.ConnectorRuntime)

Example 10 with ResourceAdapterConfig

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

the class ResourceAdapterConfigDeployer method deployResource.

/**
 * {@inheritDoc}
 */
public synchronized void deployResource(Object resource) throws Exception {
    ResourceAdapterConfig domainConfig = (ResourceAdapterConfig) resource;
    String rarName = domainConfig.getResourceAdapterName();
    ConnectorRuntime crt = getConnectorRuntime();
    if (_logger.isLoggable(Level.FINE)) {
        _logger.log(Level.FINE, "Calling backend to add resource adapterConfig ", rarName);
    }
    crt.addResourceAdapterConfig(rarName, domainConfig);
    if (_logger.isLoggable(Level.FINE)) {
        _logger.log(Level.FINE, "Added resource adapterConfig in backend", rarName);
    }
}
Also used : ResourceAdapterConfig(org.glassfish.connectors.config.ResourceAdapterConfig) ConnectorRuntime(com.sun.enterprise.connectors.ConnectorRuntime)

Aggregations

ResourceAdapterConfig (org.glassfish.connectors.config.ResourceAdapterConfig)11 Resources (com.sun.enterprise.config.serverbeans.Resources)4 Property (org.jvnet.hk2.config.types.Property)4 ConnectorRuntimeException (com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)2 BindableResource (com.sun.enterprise.config.serverbeans.BindableResource)2 Resource (com.sun.enterprise.config.serverbeans.Resource)2 ResourcePool (com.sun.enterprise.config.serverbeans.ResourcePool)2 ConnectorRuntime (com.sun.enterprise.connectors.ConnectorRuntime)2 HashMap (java.util.HashMap)2 Iterator (java.util.Iterator)2 ActionReport (org.glassfish.api.ActionReport)2 AdminObjectResource (org.glassfish.connectors.config.AdminObjectResource)2 ConnectorResource (org.glassfish.connectors.config.ConnectorResource)2 WorkSecurityMap (org.glassfish.connectors.config.WorkSecurityMap)2 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)2 Module (com.sun.enterprise.config.serverbeans.Module)1 SetMethodAction (com.sun.enterprise.connectors.util.SetMethodAction)1 ConnectorConfigProperty (com.sun.enterprise.deployment.ConnectorConfigProperty)1 PropertyVetoException (java.beans.PropertyVetoException)1 List (java.util.List)1