Search in sources :

Example 16 with ActivationSpec

use of javax.resource.spi.ActivationSpec in project wildfly by wildfly.

the class NegativeValidationASTestCase method testRegistryConfiguration.

@Test(expected = Exception.class)
public void testRegistryConfiguration() throws Throwable {
    ServiceController<?> controller = serviceContainer.getService(ConnectorServices.RA_REPOSITORY_SERVICE);
    assertNotNull(controller);
    ResourceAdapterRepository repository = (ResourceAdapterRepository) controller.getValue();
    assertNotNull(repository);
    Set<String> ids = repository.getResourceAdapters(javax.jms.MessageListener.class);
    assertNotNull(ids);
    // assertEquals(1, ids.size());
    String piId = ids.iterator().next();
    assertNotNull(piId);
    Endpoint endpoint = repository.getEndpoint(piId);
    assertNotNull(endpoint);
    List<MessageListener> listeners = repository.getMessageListeners(piId);
    assertNotNull(listeners);
    assertEquals(1, listeners.size());
    MessageListener listener = listeners.get(0);
    ActivationSpec as = listener.getActivation().createInstance();
    assertNotNull(as);
    assertNotNull(as.getResourceAdapter());
    ValidActivationSpec vas = (ValidActivationSpec) as;
    ValidMessageEndpoint me = new ValidMessageEndpoint();
    ValidMessageEndpointFactory mef = new ValidMessageEndpointFactory(me);
    endpoint.activate(mef, vas);
    endpoint.deactivate(mef, vas);
}
Also used : ValidActivationSpec(org.jboss.as.test.integration.jca.beanvalidation.ra.ValidActivationSpec) ValidMessageEndpoint(org.jboss.as.test.integration.jca.beanvalidation.ra.ValidMessageEndpoint) Endpoint(org.jboss.jca.core.spi.rar.Endpoint) ValidActivationSpec(org.jboss.as.test.integration.jca.beanvalidation.ra.ValidActivationSpec) ActivationSpec(javax.resource.spi.ActivationSpec) MessageListener(org.jboss.jca.core.spi.rar.MessageListener) ResourceAdapterRepository(org.jboss.jca.core.spi.rar.ResourceAdapterRepository) ValidMessageEndpointFactory(org.jboss.as.test.integration.jca.beanvalidation.ra.ValidMessageEndpointFactory) ValidMessageEndpoint(org.jboss.as.test.integration.jca.beanvalidation.ra.ValidMessageEndpoint) Test(org.junit.Test)

Example 17 with ActivationSpec

use of javax.resource.spi.ActivationSpec in project wildfly by wildfly.

the class RaAnnoTestCase method testActivation.

/**
 * Test activation
 *
 * @param clazz class name
 * @throws Throwable Thrown if case of an error
 */
public void testActivation(Class clazz) throws Throwable {
    ServiceController<?> controller = serviceContainer.getService(ConnectorServices.RA_REPOSITORY_SERVICE);
    assertNotNull(controller);
    ResourceAdapterRepository raRepository = (ResourceAdapterRepository) controller.getValue();
    Set<String> ids = raRepository.getResourceAdapters(clazz);
    assertNotNull(ids);
    assertEquals(1, ids.size());
    String piId = ids.iterator().next();
    assertNotNull(piId);
    Endpoint endpoint = raRepository.getEndpoint(piId);
    assertNotNull(endpoint);
    List<MessageListener> listeners = raRepository.getMessageListeners(piId);
    assertNotNull(listeners);
    assertEquals(1, listeners.size());
    MessageListener listener = listeners.get(0);
    ActivationSpec as = listener.getActivation().createInstance();
    assertNotNull(as);
    assertNotNull(as.getResourceAdapter());
    AnnoActivationSpec tas = (AnnoActivationSpec) as;
    log.trace("AS:" + tas + "//1//" + tas.getFirst() + "//2//" + tas.getSecond());
    assertEquals(new Character('U'), tas.getFirst());
    assertEquals(new Double(4.4), tas.getSecond());
    assertTrue(tas.getResourceAdapter() instanceof AnnoResourceAdapter);
    AnnoResourceAdapter tra = (AnnoResourceAdapter) tas.getResourceAdapter();
    log.trace("RA:" + tra + "//1//" + tra.getFirst() + "//2//" + tra.getSecond());
    assertEquals("G", tra.getFirst());
    assertEquals(new Integer(99), tra.getSecond());
}
Also used : AnnoActivationSpec(org.jboss.as.test.integration.jca.annorar.AnnoActivationSpec) AnnoMessageListener(org.jboss.as.test.integration.jca.annorar.AnnoMessageListener) MessageListener(org.jboss.jca.core.spi.rar.MessageListener) Endpoint(org.jboss.jca.core.spi.rar.Endpoint) AnnoResourceAdapter(org.jboss.as.test.integration.jca.annorar.AnnoResourceAdapter) AnnoActivationSpec(org.jboss.as.test.integration.jca.annorar.AnnoActivationSpec) ActivationSpec(javax.resource.spi.ActivationSpec) ResourceAdapterRepository(org.jboss.jca.core.spi.rar.ResourceAdapterRepository)

Example 18 with ActivationSpec

use of javax.resource.spi.ActivationSpec in project wildfly by wildfly.

the class InflowFlatTestCase method testRegistryConfiguration.

/**
 * Test configuration
 *
 * @throws Throwable Thrown if case of an error
 */
@Test
public void testRegistryConfiguration() throws Throwable {
    assertNotNull(serviceContainer);
    ServiceController<?> controller = serviceContainer.getService(ConnectorServices.RA_REPOSITORY_SERVICE);
    assertNotNull(controller);
    ResourceAdapterRepository repository = (ResourceAdapterRepository) controller.getValue();
    assertNotNull(repository);
    Set<String> ids = repository.getResourceAdapters();
    assertNotNull(ids);
    String piId = getElementContaining(ids, "MultipleResourceAdapter");
    assertNotNull(piId);
    Endpoint endpoint = repository.getEndpoint(piId);
    assertNotNull(endpoint);
    List<MessageListener> listeners = repository.getMessageListeners(piId);
    assertNotNull(listeners);
    assertEquals(1, listeners.size());
    MessageListener listener = listeners.get(0);
    ActivationSpec as = listener.getActivation().createInstance();
    assertNotNull(as);
    assertNotNull(as.getResourceAdapter());
}
Also used : Endpoint(org.jboss.jca.core.spi.rar.Endpoint) ActivationSpec(javax.resource.spi.ActivationSpec) MessageListener(org.jboss.jca.core.spi.rar.MessageListener) ResourceAdapterRepository(org.jboss.jca.core.spi.rar.ResourceAdapterRepository) Test(org.junit.Test)

Example 19 with ActivationSpec

use of javax.resource.spi.ActivationSpec in project spring-framework-5.2.9.RELEASE by somepeopleHavingDream.

the class StandardJmsActivationSpecFactory method createActivationSpec.

@Override
public ActivationSpec createActivationSpec(ResourceAdapter adapter, JmsActivationSpecConfig config) {
    Class<?> activationSpecClassToUse = this.activationSpecClass;
    if (activationSpecClassToUse == null) {
        activationSpecClassToUse = determineActivationSpecClass(adapter);
        if (activationSpecClassToUse == null) {
            throw new IllegalStateException("Property 'activationSpecClass' is required");
        }
    }
    ActivationSpec spec = (ActivationSpec) BeanUtils.instantiateClass(activationSpecClassToUse);
    BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(spec);
    if (this.defaultProperties != null) {
        bw.setPropertyValues(this.defaultProperties);
    }
    populateActivationSpecProperties(bw, config);
    return spec;
}
Also used : BeanWrapper(org.springframework.beans.BeanWrapper) ActivationSpec(javax.resource.spi.ActivationSpec)

Example 20 with ActivationSpec

use of javax.resource.spi.ActivationSpec in project spring-framework-debug by Joker-5.

the class StandardJmsActivationSpecFactory method createActivationSpec.

@Override
public ActivationSpec createActivationSpec(ResourceAdapter adapter, JmsActivationSpecConfig config) {
    Class<?> activationSpecClassToUse = this.activationSpecClass;
    if (activationSpecClassToUse == null) {
        activationSpecClassToUse = determineActivationSpecClass(adapter);
        if (activationSpecClassToUse == null) {
            throw new IllegalStateException("Property 'activationSpecClass' is required");
        }
    }
    ActivationSpec spec = (ActivationSpec) BeanUtils.instantiateClass(activationSpecClassToUse);
    BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(spec);
    if (this.defaultProperties != null) {
        bw.setPropertyValues(this.defaultProperties);
    }
    populateActivationSpecProperties(bw, config);
    return spec;
}
Also used : BeanWrapper(org.springframework.beans.BeanWrapper) ActivationSpec(javax.resource.spi.ActivationSpec)

Aggregations

ActivationSpec (javax.resource.spi.ActivationSpec)20 MessageListener (org.jboss.jca.core.spi.rar.MessageListener)9 ResourceAdapterRepository (org.jboss.jca.core.spi.rar.ResourceAdapterRepository)9 Endpoint (org.jboss.jca.core.spi.rar.Endpoint)8 ResourceException (javax.resource.ResourceException)5 Set (java.util.Set)4 OpenEJBException (org.apache.openejb.OpenEJBException)4 Test (org.junit.Test)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 Map (java.util.Map)3 NamingException (javax.naming.NamingException)3 UnavailableException (javax.resource.spi.UnavailableException)3 ConstraintViolationException (javax.validation.ConstraintViolationException)3 ApplicationException (org.apache.openejb.ApplicationException)3 SystemException (org.apache.openejb.SystemException)3 ConnectorRuntimeException (com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)2 SetMethodAction (com.sun.enterprise.connectors.util.SetMethodAction)2 IntrospectionException (java.beans.IntrospectionException)2 Properties (java.util.Properties)2 TreeSet (java.util.TreeSet)2