Search in sources :

Example 1 with NotFoundException

use of org.jboss.jca.core.spi.rar.NotFoundException in project wildfly by wildfly.

the class EJBUtilities method createActivationSpecs.

public ActivationSpec createActivationSpecs(final String resourceAdapterName, final Class<?> messageListenerInterface, final Properties activationConfigProperties, final ClassLoader classLoader) {
    try {
        // first get the ra "identifier" (with which it is registered in the resource adapter repository) for the
        // ra name
        final String raIdentifier = ConnectorServices.getRegisteredResourceAdapterIdentifier(resourceAdapterName);
        if (raIdentifier == null) {
            throw EjbLogger.ROOT_LOGGER.unknownResourceAdapter(resourceAdapterName);
        }
        final ResourceAdapterRepository resourceAdapterRepository = getResourceAdapterRepository();
        if (resourceAdapterRepository == null) {
            throw EjbLogger.ROOT_LOGGER.resourceAdapterRepositoryUnAvailable();
        }
        // now get the message listeners for this specific ra identifier
        final List<MessageListener> messageListeners = resourceAdapterRepository.getMessageListeners(raIdentifier);
        if (messageListeners == null || messageListeners.isEmpty()) {
            throw EjbLogger.ROOT_LOGGER.unknownMessageListenerType(messageListenerInterface.getName(), resourceAdapterName);
        }
        MessageListener requiredMessageListener = null;
        // now find the expected message listener from the list of message listeners for this resource adapter
        for (final MessageListener messageListener : messageListeners) {
            if (messageListenerInterface.equals(messageListener.getType())) {
                requiredMessageListener = messageListener;
                break;
            }
        }
        if (requiredMessageListener == null) {
            throw EjbLogger.ROOT_LOGGER.unknownMessageListenerType(messageListenerInterface.getName(), resourceAdapterName);
        }
        // found the message listener, now finally create the activation spec
        final Activation activation = requiredMessageListener.getActivation();
        // filter out the activation config properties, specified on the MDB, which aren't accepted by the resource
        // adaptor
        final Properties validActivationConfigProps = this.filterUnknownActivationConfigProperties(resourceAdapterName, activation, activationConfigProperties);
        // now set the activation config properties on the ActivationSpec
        final ActivationSpec activationSpec = activation.createInstance();
        BeanUtils.mapJavaBeanProperties(activationSpec, validActivationConfigProps);
        return activationSpec;
    } catch (IllegalAccessException e) {
        throw new RuntimeException(e);
    } catch (ResourceException e) {
        throw new RuntimeException(e);
    } catch (InstantiationException e) {
        throw new RuntimeException(e);
    } catch (NotFoundException e) {
        throw new RuntimeException(e);
    } catch (IntrospectionException e) {
        throw new RuntimeException(e);
    }
}
Also used : MessageListener(org.jboss.jca.core.spi.rar.MessageListener) IntrospectionException(java.beans.IntrospectionException) NotFoundException(org.jboss.jca.core.spi.rar.NotFoundException) Activation(org.jboss.jca.core.spi.rar.Activation) Properties(java.util.Properties) ActivationSpec(javax.resource.spi.ActivationSpec) ResourceAdapterRepository(org.jboss.jca.core.spi.rar.ResourceAdapterRepository) ResourceException(javax.resource.ResourceException)

Example 2 with NotFoundException

use of org.jboss.jca.core.spi.rar.NotFoundException in project wildfly by wildfly.

the class EJBUtilities method getEndpoint.

/**
     * Returns the {@link org.jboss.jca.core.spi.rar.Endpoint} corresponding to the passed <code>resourceAdapterName</code>
     *
     * @param resourceAdapterName The resource adapter name
     * @return
     */
public Endpoint getEndpoint(final String resourceAdapterName) {
    // first get the ra "identifier" (with which it is registered in the resource adapter repository) for the
    // ra name
    final String raIdentifier = ConnectorServices.getRegisteredResourceAdapterIdentifier(resourceAdapterName);
    if (raIdentifier == null) {
        throw EjbLogger.ROOT_LOGGER.unknownResourceAdapter(resourceAdapterName);
    }
    final ResourceAdapterRepository resourceAdapterRepository = getResourceAdapterRepository();
    if (resourceAdapterRepository == null) {
        throw EjbLogger.ROOT_LOGGER.resourceAdapterRepositoryUnAvailable();
    }
    try {
        return resourceAdapterRepository.getEndpoint(raIdentifier);
    } catch (NotFoundException nfe) {
        throw EjbLogger.ROOT_LOGGER.noSuchEndpointException(resourceAdapterName, nfe);
    }
}
Also used : ResourceAdapterRepository(org.jboss.jca.core.spi.rar.ResourceAdapterRepository) NotFoundException(org.jboss.jca.core.spi.rar.NotFoundException)

Aggregations

NotFoundException (org.jboss.jca.core.spi.rar.NotFoundException)2 ResourceAdapterRepository (org.jboss.jca.core.spi.rar.ResourceAdapterRepository)2 IntrospectionException (java.beans.IntrospectionException)1 Properties (java.util.Properties)1 ResourceException (javax.resource.ResourceException)1 ActivationSpec (javax.resource.spi.ActivationSpec)1 Activation (org.jboss.jca.core.spi.rar.Activation)1 MessageListener (org.jboss.jca.core.spi.rar.MessageListener)1