Package javax.resource.spi

Examples of javax.resource.spi.ActivationSpec


            for (Map.Entry<String, String> entry : activationProperties.entrySet()) {
                objectRecipe.setMethodProperty(entry.getKey(), entry.getValue());
            }

            // create the activationSpec
            ActivationSpec activationSpec = (ActivationSpec) objectRecipe.create(activationSpecClass.getClassLoader());

            // verify all properties except "destination" and "destinationType" were consumed
            Set<String> unusedProperties = new TreeSet<String>(objectRecipe.getUnsetProperties().keySet());
            unusedProperties.remove("destination");
            unusedProperties.remove("destinationType");
            if (!unusedProperties.isEmpty()) {
                throw new IllegalArgumentException("No setter found for the activation spec properties: " + unusedProperties);
            }


            // validate the activation spec
            try {
                activationSpec.validate();
            } catch (UnsupportedOperationException uoe) {
                logger.info("ActivationSpec does not support validate. Implementation of validate is optional");
            }
            // also try validating using Bean Validation if there is a Validator available in the context.
            try {
                Validator validator = (Validator)beanContext.getJndiContext().lookup("comp/Validator");

                Set generalSet = validator.validate(activationSpec);
                if (!generalSet.isEmpty()) {
                    throw new ConstraintViolationException("Constraint violation for ActivationSpec " + activationSpecClass.getName(), generalSet);
                }
            } catch (NamingException e) {
                logger.debug("No Validator bound to JNDI context");
            }


            // set the resource adapter into the activation spec
            activationSpec.setResourceAdapter(resourceAdapter);

            return activationSpec;
        } catch (Exception e) {
            throw new OpenEJBException("Unable to create activation spec", e);
        }
View Full Code Here


      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);
View Full Code Here

    // Stub code for ActivationSpec support that throws appropriate errors
    private void lookupActivationSpec() {       
        if ( jmsBinding.getActivationSpecName() != null )  {
          String createMode = jmsBinding.getActivationSpecCreate();
          if ( JMSBindingConstants.CREATE_ALWAYS.equals(createMode) ) {
            ActivationSpec spec = jmsResourceFactory.lookupActivationSpec(jmsBinding.getActivationSpecName());
            if ( spec != null ) {
              throw new JMSBindingException("ActivationSpec specifies create mode of \"always\" but resource already exists.");
            }
            throw new JMSBindingException("Can not create ActivationSpec");
          } else if ( JMSBindingConstants.CREATE_IF_NOT_EXIST.equals(createMode)) {
            ActivationSpec spec = jmsResourceFactory.lookupActivationSpec(jmsBinding.getActivationSpecName());
            if ( spec == null ) {
              throw new JMSBindingException("Can not create ActivationSpec");
            }
          } else if ( JMSBindingConstants.CREATE_NEVER.equals(createMode)) {
            ActivationSpec spec = jmsResourceFactory.lookupActivationSpec(jmsBinding.getActivationSpecName());
            if ( spec == null )
              throw new JMSBindingException("ActivationSpec specifies create mode of \"never\" but resource does not exist at jndiName " + jmsBinding.getActivationSpecName());
             
          } // end if
        } // end if
View Full Code Here

    // Stub code for ActivationSpec support that throws appropriate errors
    private void lookupActivationSpec() {       
        if ( jmsBinding.getActivationSpecName() != null )  {
          String createMode = jmsBinding.getActivationSpecCreate();
          if ( JMSBindingConstants.CREATE_ALWAYS.equals(createMode) ) {
            ActivationSpec spec = jmsResourceFactory.lookupActivationSpec(jmsBinding.getActivationSpecName());
            if ( spec != null ) {
              throw new JMSBindingException("ActivationSpec specifies create mode of \"always\" but resource already exists.");
            }
            throw new JMSBindingException("Can not create ActivationSpec");
          } else if ( JMSBindingConstants.CREATE_IF_NOT_EXIST.equals(createMode)) {
            ActivationSpec spec = jmsResourceFactory.lookupActivationSpec(jmsBinding.getActivationSpecName());
            if ( spec == null ) {
              throw new JMSBindingException("Can not create ActivationSpec");
            }
          } else if ( JMSBindingConstants.CREATE_NEVER.equals(createMode)) {
            ActivationSpec spec = jmsResourceFactory.lookupActivationSpec(jmsBinding.getActivationSpecName());
            if ( spec == null )
              throw new JMSBindingException("ActivationSpec specifies create mode of \"never\" but resource does not exist at jndiName " + jmsBinding.getActivationSpecName());
             
          }
                 
View Full Code Here

      throw new IllegalArgumentException("Property 'resourceAdapter' is required");
    }
    if (getMessageEndpointFactory() == null) {
      throw new IllegalArgumentException("Property 'messageEndpointFactory' is required");
    }
    ActivationSpec activationSpec = getActivationSpec();
    if (activationSpec == null) {
      throw new IllegalArgumentException("Property 'activationSpec' is required");
    }

    if (activationSpec.getResourceAdapter() == null) {
      activationSpec.setResourceAdapter(getResourceAdapter());
    }
    else if (activationSpec.getResourceAdapter() != getResourceAdapter()) {
      throw new IllegalArgumentException("ActivationSpec [" + activationSpec +
          "] is associated with a different ResourceAdapter: " + activationSpec.getResourceAdapter());
    }

    if (this.autoStartup) {
      start();
    }
View Full Code Here

            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();
            PropertyEditors.mapJavaBeanProperties(activationSpec, validActivationConfigProps);

            return activationSpec;

        } catch (IllegalAccessException e) {
View Full Code Here

        // Match configured value to the actual RA names
        final String activeResourceAdapterName = searchActiveResourceAdapterName(configuredResourceAdapterName);


        final ActivationSpec activationSpec = getEndpointDeployer().createActivationSpecs(activeResourceAdapterName, messageListenerInterface, activationProps, getDeploymentClassLoader());
        final MessageDrivenComponent component = new MessageDrivenComponent(this, messageListenerInterface, activationSpec, deliveryActive);
        // set the resource adapter
        final ResourceAdapter resourceAdapter = this.resourceAdapterInjectedValue.getValue();
        component.setResourceAdapter(resourceAdapter);
        // set the endpoint
View Full Code Here

            String msgListenerType = descriptor.getMessageListenerType();
           
            // start resource adapter and get ActivationSpec class for
            // the given message listener type from the ConnectorRuntime

                        ActivationSpec aspec = (ActivationSpec) (Class.forName(
                                                       cr.getActivationSpecClass(raMid,
                                                       msgListenerType), false,
                                                       resourceAdapter.getClass().getClassLoader()).newInstance());
                        aspec.setResourceAdapter(resourceAdapter);
           
            // Populate ActivationSpec class with ActivationConfig properties
            SetMethodAction sma =
              new SetMethodAction(aspec,activationConfigProps);
          sma.run();
View Full Code Here

    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.info("AS:" + tas + "//1//" + tas.getFirst() + "//2//"
        + tas.getSecond());
    assertEquals(new Character('U'), tas.getFirst());
View Full Code Here

        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);
View Full Code Here

TOP

Related Classes of javax.resource.spi.ActivationSpec

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.