Package javax.resource.spi

Examples of javax.resource.spi.ResourceAdapter


         throw new IllegalArgumentException("MessageEndpointFactory is null");

      if (spec == null)
         throw new IllegalArgumentException("ActivationSpec is null");

      ResourceAdapter rar = ra.get();

      if (rar == null)
         throw new ResourceException(bundle.resourceAdapterInstanceNotActive());

      if (is16 && bvEnabled)
      {
         ClassLoader oldTCCL = SecurityActions.getThreadContextClassLoader();
         try
         {
            SecurityActions.setThreadContextClassLoader(rar.getClass().getClassLoader());
           
            List<Class<?>> groups = new ArrayList<Class<?>>(1);

            if (beanValidationGroups != null)
            {
               for (String group : beanValidationGroups)
               {
                  try
                  {
                     Class<?> clz = Class.forName(group, true, rar.getClass().getClassLoader());
                     groups.add(clz);
                  }
                  catch (Throwable t)
                  {
                     log.debug("Unable to load bean validation group: " + group, t);
                  }
               }
            }

            if (groups.isEmpty())
               groups.add(Default.class);

            Validator validator = BeanValidationUtil.createValidator();
            Class[] vargs = groups.toArray(new Class[groups.size()]);

            Set errors = validator.validate(spec, vargs);

            if (errors != null && errors.size() > 0)
            {
               throw new ResourceException(bundle.validationException(), new ConstraintViolationException(errors));
            }
         }
         catch (RuntimeException re)
         {
            throw new ResourceException(bundle.validationException(), re);
         }
         finally
         {
            SecurityActions.setThreadContextClassLoader(oldTCCL);
         }
      }

      try
      {
         spec.validate();
      }
      catch (UnsupportedOperationException uoe)
      {
         // Ignore
      }

      rar.endpointActivation(endpointFactory, spec);

      if (transactionIntegration != null && transactionIntegration.getRecoveryRegistry() != null)
      {
         XAResourceRecovery xrr = transactionIntegration.createXAResourceRecovery(rar, spec,
                                                                                  productName, productVersion);
View Full Code Here


         throw new IllegalArgumentException("MessageEndpointFactory is null");

      if (spec == null)
         throw new IllegalArgumentException("ActivationSpec is null");

      ResourceAdapter rar = ra.get();

      if (rar == null)
         throw new ResourceException(bundle.resourceAdapterInstanceNotActive());

      if (transactionIntegration != null && transactionIntegration.getRecoveryRegistry() != null)
      {
         XAResourceRecovery xrr = recovery.remove(spec);
         if (xrr != null)
         {
            if (trace)
               log.tracef("Removing %s for recovery", xrr);

            transactionIntegration.getRecoveryRegistry().removeXAResourceRecovery(xrr);
         }
      }

      rar.endpointDeactivation(endpointFactory, spec);
   }
View Full Code Here

        }

    }

    private void addResourceAdapter(ResourceAdapterWrapper resourceAdapterWrapper) {
        ResourceAdapter resourceAdapter = resourceAdapterWrapper.getResourceAdapter();
        if (resourceAdapter == null) {
            return;
        }
        if (registeredResouceAdapters.contains(resourceAdapterWrapper.getName())) {
            // already registered
            return;
        }
        registeredResouceAdapters.add(resourceAdapterWrapper.getName());
       
        Map<String, String> listenerToActivationSpecMap = resourceAdapterWrapper.getMessageListenerToActivationSpecMap();
        if (listenerToActivationSpecMap == null) {
            return;
        }

        ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
        Thread.currentThread().setContextClassLoader(classLoader);
        try {
            for (Map.Entry<String, String> entry : listenerToActivationSpecMap.entrySet()) {
                String messageListenerInterface = entry.getKey();
                String activationSpecClass = entry.getValue();

                // only process RA if not previously processed
                String containerName = getResourceAdapterId(resourceAdapterWrapper) + "-" + messageListenerInterface;
                if (processedResourceAdapterWrappers.putIfAbsent(containerName,  resourceAdapterWrapper) == null) {
                    try {
                        // get default mdb config
                        ContainerInfo containerInfo = configurationFactory.configureService(MdbContainerInfo.class, containerName, null, null, "Container");
                        containerInfo.id = containerName;
                        containerInfo.displayName = containerName;
                        properties = (properties == null)?new Properties():properties;                       
                        String instanceLimit = (String)properties.get(containerName + "." + "InstanceLimit");                                               
                        if(instanceLimit != null){
                            containerInfo.properties.put("InstanceLimit", instanceLimit);
                        }

                        // set ra specific properties
                        containerInfo.properties.put("MessageListenerInterface",
                                resourceAdapter.getClass().getClassLoader().loadClass(messageListenerInterface));
                        containerInfo.properties.put("ActivationSpecClass",
                                resourceAdapter.getClass().getClassLoader().loadClass(activationSpecClass));
                        containerInfo.properties.put("ResourceAdapter", resourceAdapter);
                       // containerInfo.properties.put("TxRecovery", true);
                        // create the container
                        assembler.createContainer(containerInfo);
View Full Code Here

        }

    }

    private void addResourceAdapter(ResourceAdapterWrapper resourceAdapterWrapper) {
        ResourceAdapter resourceAdapter = resourceAdapterWrapper.getResourceAdapter();
        if (resourceAdapter == null) {
            return;
        }
        if (registeredResouceAdapters.contains(resourceAdapterWrapper.getName())) {
            // already registered
            return;
        }
        registeredResouceAdapters.add(resourceAdapterWrapper.getName());
       
        Map<String, String> listenerToActivationSpecMap = resourceAdapterWrapper.getMessageListenerToActivationSpecMap();
        if (listenerToActivationSpecMap == null) {
            return;
        }

        ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
        Thread.currentThread().setContextClassLoader(classLoader);
        try {
            for (Map.Entry<String, String> entry : listenerToActivationSpecMap.entrySet()) {
                String messageListenerInterface = entry.getKey();
                String activationSpecClass = entry.getValue();

                // only process RA if not previously processed
                String containerName = getResourceAdapterId(resourceAdapterWrapper) + "-" + messageListenerInterface;
                if (processedResourceAdapterWrappers.putIfAbsent(containerName,  resourceAdapterWrapper) == null) {
                    try {
                        // get default mdb config
                        ContainerInfo containerInfo = configurationFactory.configureService(MdbContainerInfo.class, containerName, null, null, "Container");
                        containerInfo.id = containerName;
                        containerInfo.displayName = containerName;
                        properties = (properties == null)?new Properties():properties;                       
                        String instanceLimit = (String)properties.get(containerName + "." + "InstanceLimit");                                               
                        if(instanceLimit != null){
                            containerInfo.properties.put("InstanceLimit", instanceLimit);
                        }

                        // set ra specific properties
                        containerInfo.properties.put("MessageListenerInterface",
                                resourceAdapter.getClass().getClassLoader().loadClass(messageListenerInterface));
                        containerInfo.properties.put("ActivationSpecClass",
                                resourceAdapter.getClass().getClassLoader().loadClass(activationSpecClass));
                        containerInfo.properties.put("ResourceAdapter", resourceAdapter);
                       // containerInfo.properties.put("TxRecovery", true);
                        // create the container
                        assembler.createContainer(containerInfo);
View Full Code Here

    }


    //GBeanLifecycle implementation
    public void activate(final MessageEndpointFactory messageEndpointFactory) throws ResourceException {
        ResourceAdapter resourceAdapter = activationSpec.getResourceAdapter();
        if (resourceAdapter == null) {
            resourceAdapterWrapper.registerResourceAdapterAssociation(activationSpec);
        }
        resourceAdapterWrapper.endpointActivation(messageEndpointFactory, activationSpec);
    }
View Full Code Here

        }
        resourceAdapterWrapper.endpointActivation(messageEndpointFactory, activationSpec);
    }

    public void deactivate(final MessageEndpointFactory messageEndpointFactory) {
        ResourceAdapter resourceAdapter = activationSpec.getResourceAdapter();
        if (resourceAdapter != null) {
            resourceAdapterWrapper.endpointDeactivation(messageEndpointFactory, activationSpec);
        } else {
            //this should never happen, activation spec should have been registered with r.a.
            throw new IllegalStateException("ActivationSpec was never registered with ResourceAdapter");
View Full Code Here

         String raKey = entry.getKey();
         WeakReference<ResourceAdapter> ra = entry.getValue();

         if (ra.get() != null)
         {
            ResourceAdapter rar = ra.get();
            Connector md = null;

            Set<String> mdrKeys = mdr.getResourceAdapters();
            Iterator<String> mdrIt = mdrKeys.iterator();

            while (md == null && mdrIt.hasNext())
            {
               String mdrId = mdrIt.next();
               try
               {
                  Connector c = mdr.getResourceAdapter(mdrId);
           
                  if (c.getResourceadapter() != null && c.getResourceadapter() instanceof ResourceAdapter1516)
                  {
                     ResourceAdapter1516 ra1516 = (ResourceAdapter1516)c.getResourceadapter();
                     String clz = ra1516.getResourceadapterClass();

                     if (rar.getClass().getName().equals(clz))
                        md = c;
                  }
               }
               catch (Throwable t)
               {
                  // We will ignore
                  log.debugf("Resource adapter %s is ignored", rar.getClass().getName());
               }
            }

            if (md != null && md.getResourceadapter() != null && md.getResourceadapter() instanceof ResourceAdapter1516)
            {
               ResourceAdapter1516 ra1516 = (ResourceAdapter1516)md.getResourceadapter();

               if (ra1516.getInboundResourceadapter() != null &&
                   ra1516.getInboundResourceadapter().getMessageadapter() != null &&
                   ra1516.getInboundResourceadapter().getMessageadapter().getMessagelisteners() != null &&
                   ra1516.getInboundResourceadapter().getMessageadapter().getMessagelisteners().size() > 0)
               {
                  List<org.jboss.jca.common.api.metadata.ra.MessageListener> listeners =
                     ra1516.getInboundResourceadapter().getMessageadapter().getMessagelisteners();

                  for (org.jboss.jca.common.api.metadata.ra.MessageListener ml : listeners)
                  {
                     try
                     {
                        ClassLoader cl = rar.getClass().getClassLoader();
                        Class<?> mlType = Class.forName(ml.getMessagelistenerType().getValue(), true, cl);

                        if (mlType.isAssignableFrom(messageListenerType))
                           result.add(raKey);
                     }
View Full Code Here

         throw new NotFoundException(bundle.keyNotRegistered(uniqueId));

      if (mdr == null)
         throw new IllegalStateException("MDR is null");
     
      ResourceAdapter rar = ra.get();
      Connector md = null;

      Set<String> mdrKeys = mdr.getResourceAdapters();
      Iterator<String> mdrIt = mdrKeys.iterator();

      while (md == null && mdrIt.hasNext())
      {
         String mdrId = mdrIt.next();
         try
         {
            Connector c = mdr.getResourceAdapter(mdrId);
           
            if (c.getResourceadapter() != null && c.getResourceadapter() instanceof ResourceAdapter1516)
            {
               ResourceAdapter1516 ra1516 = (ResourceAdapter1516)c.getResourceadapter();
               String clz = ra1516.getResourceadapterClass();

               if (rar.getClass().getName().equals(clz))
                  md = c;
            }
         }
         catch (Throwable t)
         {
View Full Code Here

        }
        while (namingEnumeration != null && namingEnumeration.hasMoreElements()) {
            Binding binding = namingEnumeration.nextElement();
            Object object = binding.getObject();
            if (object instanceof ResourceAdapter) {
                ResourceAdapter resourceAdapter = (ResourceAdapter) object;
                try {
                    logger.info("Stopping ResourceAdapter: " + binding.getName());
                    resourceAdapter.stop();
                } catch (Exception e) {
                    logger.fatal("ResourceAdapter Shutdown Failed: " + binding.getName(), e);
                }
            }
        }
View Full Code Here

        Object service = serviceRecipe.create();


        // Java Connector spec ResourceAdapters and ManagedConnectionFactories need special activation
        if (service instanceof ResourceAdapter) {
            ResourceAdapter resourceAdapter = (ResourceAdapter) service;

            // Create a thead pool for work manager
            int threadPoolSize = getIntProperty(serviceInfo.properties, "threadPoolSize", 30);
            Executor threadPool;
            if (threadPoolSize <= 0) {
                threadPool = Executors.newCachedThreadPool(new ResourceAdapterThreadFactory(serviceInfo.id));
            } else {
                threadPool = Executors.newFixedThreadPool(threadPoolSize, new ResourceAdapterThreadFactory(serviceInfo.id));
            }

            // WorkManager: the resource adapter can use this to dispatch messages or perform tasks
            WorkManager workManager;
            if (transactionManager instanceof GeronimoTransactionManager) {
                GeronimoTransactionManager geronimoTransactionManager = (GeronimoTransactionManager) transactionManager;
                workManager = new GeronimoWorkManager(threadPool, threadPool, threadPool, geronimoTransactionManager);
            } else {
                workManager = new SimpleWorkManager(threadPool);
            }


            // BootstrapContext: wraps the WorkMananger and XATerminator
            BootstrapContext bootstrapContext;
            if (transactionManager instanceof XATerminator) {
                bootstrapContext = new SimpleBootstrapContext(workManager, (XATerminator) transactionManager);
            } else {
                bootstrapContext = new SimpleBootstrapContext(workManager);
            }

            // start the resource adapter
            try {
                logger.debug("createResource.startingResourceAdapter", serviceInfo.id, service.getClass().getName());
                resourceAdapter.start(bootstrapContext);
            } catch (ResourceAdapterInternalException e) {
                throw new OpenEJBException(e);
            }

            Map<String, Object> unset = serviceRecipe.getUnsetProperties();
View Full Code Here

TOP

Related Classes of javax.resource.spi.ResourceAdapter

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.