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

      rar.endpointDeactivation(endpointFactory, spec);
   }
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

   protected void startService() throws Exception
   {
      if (mcf != null)
         throw new DeploymentException("Stop the RARDeployment before restarting it");

      ResourceAdapter resourceAdapter = null;
      ConnectionDefinitionMetaData cdmd = cmd.getConnectionDefinition(dmd.getConnectionDefinition());
     
      try
      {
         resourceAdapter = (ResourceAdapter) getServer().getAttribute(oldRarDeployment, "ResourceAdapter");
View Full Code Here

      if (mcf != null)
         throw new DeploymentException("Stop the RARDeployment before restarting it");

      ConnectorMetaData cmd = null;
      ConnectionDefinitionMetaData cdmd = null;
      ResourceAdapter resourceAdapter = null;
      if (oldRarDeployment != null)
      {
         try
         {
            resourceAdapter = (ResourceAdapter) getServer().getAttribute(oldRarDeployment, "ResourceAdapter");
View Full Code Here

            activeResourceAdapterName = resourceAdapterName;
        }
        final ActivationSpec activationSpec = getEndpointDeployer().createActivationSpecs(activeResourceAdapterName, messageListenerInterface, activationProps, getDeploymentClassLoader());
        final MessageDrivenComponent component = new MessageDrivenComponent(this, messageListenerInterface, activationSpec);
        // set the resource adapter
        final ResourceAdapter resourceAdapter = this.resourceAdapterInjectedValue.getValue();
        component.setResourceAdapter(resourceAdapter);
        // set the endpoint
        final EJBUtilities ejbUtilities = this.ejbUtilitiesInjectedValue.getValue();
        final Endpoint endpoint = ejbUtilities.getEndpoint(activeResourceAdapterName);
        component.setEndpoint(endpoint);
View Full Code Here

    * @return the resource adapter
    * @throws Exception
    */
   public static ResourceAdapter createResourceAdapter(RARDeploymentMetaData ramd) throws Exception
   {
      ResourceAdapter adapter = createResourceAdapter(ramd.getConnectorMetaData());
     
      for(Iterator iter = ramd.getRaXmlMetaData().getProperties().iterator(); iter.hasNext();)
      {
         ConfigPropertyMetaData cpmd = (ConfigPropertyMetaData)iter.next();
         applyProperty(cpmd, adapter.getClass(), adapter);
        
      }
           
      return adapter;
   }
View Full Code Here

     
      // Load the class
      Class raClass = Thread.currentThread().getContextClassLoader().loadClass(className);
      if (ResourceAdapter.class.isAssignableFrom(raClass) == false)
         throw new DeploymentException(raClass.getName() + " is not a resource adapter class");
      ResourceAdapter result = (ResourceAdapter) raClass.newInstance();
     
      // Apply the properties
      for (Iterator i = cmd.getProperties().iterator(); i.hasNext();)
      {
         ConfigPropertyMetaData cpmd = (ConfigPropertyMetaData) i.next();
View Full Code Here

                // no resource adapters were created
            }
            while (namingEnumeration != null && namingEnumeration.hasMoreElements()) {
                Binding binding = namingEnumeration.nextElement();
                Object object = binding.getObject();
                ResourceAdapter resourceAdapter = (ResourceAdapter) object;
                try {
                    resourceAdapter.stop();
                } catch (Exception e) {
                    logger.fatal("ResourceAdapter Shutdown Failed: "+binding.getName(), e);
                }
            }
        } catch (Throwable 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;

            // resource adapters only work with a geronimo transaction manager
            if (!(transactionManager instanceof GeronimoTransactionManager)) {
                throw new OpenEJBException("The use of a resource adapter requires a Geronimo transaction manager");
            }
            GeronimoTransactionManager geronimoTransactionManager = (GeronimoTransactionManager) transactionManager;

            // create a thead pool
            int threadPoolSize = getIntProperty(serviceInfo.properties, "threadPoolSize", 30);
            if (threadPoolSize <= 0) throw new IllegalArgumentException("threadPoolSizes <= 0: " + threadPoolSize);
            Executor threadPool = Executors.newFixedThreadPool(threadPoolSize, new ResourceAdapterThreadFactory(serviceInfo.id));

            // create a work manager which the resource adapter can use to dispatch messages or perform tasks
            WorkManager workManager = new GeronimoWorkManager(threadPool, threadPool, threadPool, geronimoTransactionManager);

            // wrap the work mananger and transaction manager in a bootstrap context (connector spec thing)
            BootstrapContext bootstrapContext = new GeronimoBootstrapContext(workManager, geronimoTransactionManager);

            // 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.