示例#1
0
  /** {@inheritDoc} */
  public ActivationSpec createInstance()
      throws NotFoundException, InstantiationException, IllegalAccessException, ResourceException {
    Class<?> clz = activationSpecClass.get();

    if (clz == null) throw new NotFoundException(bundle.activationSpecClassNotAvailable());

    ResourceAdapter ra = rar.get();

    if (ra == null) throw new NotFoundException(bundle.resourceAdapterNotAvailable());

    ActivationSpec instance = ActivationSpec.class.cast(clz.newInstance());
    instance.setResourceAdapter(ra);

    if (valueProperties != null && valueProperties.size() > 0) {
      Injection injector = new Injection();
      Iterator<Map.Entry<String, String>> it = valueProperties.entrySet().iterator();
      while (it.hasNext()) {
        String propertyName = null;
        String propertyValue = null;
        try {
          Map.Entry<String, String> entry = it.next();

          propertyName = entry.getKey();
          propertyValue = entry.getValue();

          injector.inject(instance, propertyName, propertyValue);
        } catch (Throwable t) {
          log.debugf(t, "Ignoring: %s (%s)", propertyName, propertyValue);
        }
      }
    }

    return instance;
  }
示例#2
0
  /**
   * Test configuration
   *
   * @throws Throwable Thrown if case of an error
   */
  @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);
    int pureInflowListener = 0;
    for (String id : ids) {
      if (id.indexOf("PureInflow") != -1) {
        pureInflowListener++;
      }
    }
    assertEquals(1, pureInflowListener);

    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());
  }