Search in sources :

Example 46 with ConnectorRuntimeException

use of com.sun.appserv.connectors.internal.api.ConnectorRuntimeException in project Payara by payara.

the class ConnectorMessageBeanClient method getResourceAdapterMid.

/**
 * derive the resource-adapter-mid in the following order <br/>
 * a) specified in the glassfish-ejb-jar / sun-ejb-jar descriptor<br/>
 * b) jms-ra message-listener of type javax.jms.MessageListener<br/>
 * c) Check the resource-adapters supporting the message-listener-type and
 * if there is only one use it, otherwise fail.<br/>
 * @param descriptor_ EJB Descriptor
 * @return resource-adapter-mid (resource-adapter-name)
 * @throws ConnectorRuntimeException
 */
private String getResourceAdapterMid(EjbMessageBeanDescriptor descriptor_) throws ConnectorRuntimeException {
    String resourceAdapterMid = descriptor_.getResourceAdapterMid();
    if (resourceAdapterMid == null) {
        resourceAdapterMid = System.getProperty(RA_MID);
    }
    if (resourceAdapterMid == null) {
        String messageListener = descriptor_.getMessageListenerType();
        // will take care of the case when the message-listener-type is not specified in the DD
        if (ConnectorConstants.JMS_MESSAGE_LISTENER.equals(messageListener)) {
            resourceAdapterMid = ConnectorRuntime.DEFAULT_JMS_ADAPTER;
            logger.fine("No ra-mid is specified, using default JMS Resource Adapter for message-listener-type " + "[" + descriptor_.getMessageListenerType() + "]");
        } else {
            List<String> resourceAdapters = ConnectorRegistry.getInstance().getConnectorsSupportingMessageListener(messageListener);
            if (resourceAdapters.size() == 1) {
                resourceAdapterMid = resourceAdapters.get(0);
                String message = localStrings.getString("msg-bean-client.defaulting.message-listener.supporting.rar", resourceAdapterMid, messageListener);
                logger.info(message);
            } else if (resourceAdapters.size() <= 0) {
                String message = localStrings.getString("msg-bean-client.could-not-detect-ra-mid", descriptor_.getMessageListenerType());
                throw new ConnectorRuntimeException(message);
            } else {
                String message = localStrings.getString("msg-bean-client.multiple-ras-supporting-message-listener", messageListener);
                throw new ConnectorRuntimeException(message);
            }
        }
    }
    return resourceAdapterMid;
}
Also used : ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)

Example 47 with ConnectorRuntimeException

use of com.sun.appserv.connectors.internal.api.ConnectorRuntimeException in project Payara by payara.

the class ConnectorDescriptorProxy method create.

public Object create(Context ic) throws NamingException {
    // of this particular connector descriptor and also only for first time (initialization)
    synchronized (this) {
        if (desc == null) {
            try {
                desc = getConnectorRuntime().getConnectorDescriptor(rarName);
                ic.rebind(jndiName, desc);
            } catch (ConnectorRuntimeException e) {
                NamingException ne = new NamingException(e.getMessage());
                ne.initCause(e);
                throw ne;
            }
        }
    }
    return desc;
}
Also used : ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) NamingException(javax.naming.NamingException)

Example 48 with ConnectorRuntimeException

use of com.sun.appserv.connectors.internal.api.ConnectorRuntimeException 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 49 with ConnectorRuntimeException

use of com.sun.appserv.connectors.internal.api.ConnectorRuntimeException in project Payara by payara.

the class ActiveOutboundResourceAdapter method addAdminObject.

/**
 * Creates an admin object.
 *
 * @param appName         Name of application, in case of embedded rar.
 * @param connectorName   Module name of the resource adapter.
 * @param jndiName        JNDI name to be registered.
 * @param adminObjectType Interface name of the admin object.
 * @param props           <code>Properties</code> object containing name/value
 *                        pairs of properties.
 */
public void addAdminObject(String appName, String connectorName, ResourceInfo resourceInfo, String adminObjectType, String adminObjectClassName, Properties props) throws ConnectorRuntimeException {
    if (props == null) {
        // empty properties
        props = new Properties();
    }
    ConnectorRegistry registry = ConnectorRegistry.getInstance();
    ConnectorDescriptor desc = registry.getDescriptor(connectorName);
    AdminObject aoDesc = null;
    // or the combination of the both names.
    if (adminObjectClassName == null || adminObjectClassName.trim().equals("")) {
        // get AO through interface name
        List<AdminObject> adminObjects = desc.getAdminObjectsByType(adminObjectType);
        if (adminObjects.size() > 1) {
            String msg = localStrings.getString("aor.could_not_determine_aor_type", adminObjectType);
            throw new ConnectorRuntimeException(msg);
        } else {
            aoDesc = adminObjects.get(0);
        }
    } else if (adminObjectType == null || adminObjectType.trim().equals("")) {
        // get AO through class name
        List<AdminObject> adminObjects = desc.getAdminObjectsByClass(adminObjectClassName);
        if (adminObjects.size() > 1) {
            String msg = localStrings.getString("aor.could_not_determine_aor_class", adminObjectClassName);
            throw new ConnectorRuntimeException(msg);
        } else {
            aoDesc = adminObjects.get(0);
        }
    } else {
        // get AO through interface name and class name
        aoDesc = desc.getAdminObject(adminObjectType, adminObjectClassName);
    }
    if (aoDesc == null) {
        String msg = localStrings.getString("aor.could_not_determine_aor", adminObjectType, adminObjectClassName);
        throw new ConnectorRuntimeException(msg);
    }
    AdministeredObjectResource aor = new AdministeredObjectResource(resourceInfo);
    aor.initialize(aoDesc);
    aor.setResourceAdapter(connectorName);
    Object[] envProps = aoDesc.getConfigProperties().toArray();
    // Override them if same config properties are provided by the user
    for (int i = 0; i < envProps.length; i++) {
        ConnectorConfigProperty envProp = (ConnectorConfigProperty) envProps[i];
        String name = envProp.getName();
        String userValue = (String) props.remove(name);
        if (userValue != null)
            aor.addConfigProperty(new ConnectorConfigProperty(name, userValue, userValue, envProp.getType()));
        else
            aor.addConfigProperty(envProp);
    }
    // Add non-default config properties provided by the user to aor
    Iterator iter = props.keySet().iterator();
    while (iter.hasNext()) {
        String name = (String) iter.next();
        String userValue = props.getProperty(name);
        if (userValue != null)
            aor.addConfigProperty(new ConnectorConfigProperty(name, userValue, userValue));
    }
    // bind to JNDI namespace
    try {
        Reference ref = aor.createAdminObjectReference();
        connectorRuntime_.getResourceNamingService().publishObject(resourceInfo, ref, true);
    } catch (NamingException ex) {
        String i18nMsg = localStrings.getString("aira.cannot_bind_admin_obj");
        throw new ConnectorRuntimeException(i18nMsg, ex);
    }
}
Also used : ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) Reference(javax.naming.Reference) ConnectorConfigProperty(com.sun.enterprise.deployment.ConnectorConfigProperty) ConnectorDescriptor(com.sun.enterprise.deployment.ConnectorDescriptor) AdminObject(com.sun.enterprise.deployment.AdminObject) NamingException(javax.naming.NamingException) AdministeredObjectResource(com.sun.enterprise.resource.beans.AdministeredObjectResource) AdminObject(com.sun.enterprise.deployment.AdminObject)

Example 50 with ConnectorRuntimeException

use of com.sun.appserv.connectors.internal.api.ConnectorRuntimeException in project Payara by payara.

the class ActiveOutboundResourceAdapter method validateWorkContextSupport.

/**
 * check whether the <i>required-work-context</i> list mandated by the resource-adapter
 * is supported by the application server
 * @param desc ConnectorDescriptor
 * @throws ConnectorRuntimeException when unable to support any of the requested work-context type.
 */
private void validateWorkContextSupport(ConnectorDescriptor desc) throws ConnectorRuntimeException {
    Set workContexts = desc.getRequiredWorkContexts();
    Iterator workContextsIterator = workContexts.iterator();
    WorkContextHandler workContextHandler = connectorRuntime_.getWorkContextHandler();
    workContextHandler.init(moduleName_, jcl_);
    while (workContextsIterator.hasNext()) {
        String ic = (String) workContextsIterator.next();
        boolean supported = workContextHandler.isContextSupported(true, ic);
        if (!supported) {
            String errorMsg = "Unsupported work context [ " + ic + " ] ";
            Object[] params = new Object[] { ic, desc.getName() };
            _logger.log(Level.WARNING, "unsupported.work.context", params);
            throw new ConnectorRuntimeException(errorMsg);
        }
    }
}
Also used : ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException) AdminObject(com.sun.enterprise.deployment.AdminObject) WorkContextHandler(com.sun.appserv.connectors.internal.api.WorkContextHandler)

Aggregations

ConnectorRuntimeException (com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)69 NamingException (javax.naming.NamingException)16 URISyntaxException (java.net.URISyntaxException)13 PoolInfo (org.glassfish.resourcebase.resources.api.PoolInfo)12 ConnectorDescriptor (com.sun.enterprise.deployment.ConnectorDescriptor)10 PrivilegedActionException (java.security.PrivilegedActionException)9 ExecutionException (java.util.concurrent.ExecutionException)8 ResourceAdapterInternalException (javax.resource.spi.ResourceAdapterInternalException)8 MultiException (org.glassfish.hk2.api.MultiException)8 JmsService (com.sun.enterprise.connectors.jms.config.JmsService)7 ConnectorConfigProperty (com.sun.enterprise.deployment.ConnectorConfigProperty)7 ManagedConnectionFactory (javax.resource.spi.ManagedConnectionFactory)7 ActiveResourceAdapter (com.sun.enterprise.connectors.ActiveResourceAdapter)5 ConnectorRuntime (com.sun.enterprise.connectors.ConnectorRuntime)5 ConnectorConnectionPool (com.sun.enterprise.connectors.ConnectorConnectionPool)4 IOException (java.io.IOException)4 ResourceInfo (org.glassfish.resourcebase.resources.api.ResourceInfo)4 Resource (com.sun.enterprise.config.serverbeans.Resource)3 ResourcePool (com.sun.enterprise.config.serverbeans.ResourcePool)3 File (java.io.File)3