use of org.jboss.jca.core.spi.rar.ResourceAdapterRepository 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);
}
}
use of org.jboss.jca.core.spi.rar.ResourceAdapterRepository 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());
}
use of org.jboss.jca.core.spi.rar.ResourceAdapterRepository 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);
}
use of org.jboss.jca.core.spi.rar.ResourceAdapterRepository in project wildfly by wildfly.
the class PositiveValidationTestCase method testRegistryConfiguration.
@Test
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);
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);
}
use of org.jboss.jca.core.spi.rar.ResourceAdapterRepository in project wildfly by wildfly.
the class InflowJarTestCase 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());
}
Aggregations