Package org.gatein.wsrp

Examples of org.gatein.wsrp.WSRPConsumer


      {
         String id = attrs.getValue("id");
         ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(id, "producer identifier", "Configuring a producer");

         // check that the consumer doesn't exist in the database first
         WSRPConsumer consumer = consumerRegistry.getConsumer(id);
         if (consumer != null)
         {
            String message = "Added consumer for producer '" + id + "' with status: ";

            // if consumer is active, add it to the list of services
            if (consumer.getProducerInfo().isActive())
            {
               consumers.put(id, consumer);
               message += "active";
            }
            else
            {
               message += "inactive";
            }

            log.info(message + " (loaded from database).");

            // consumer already exists, do not further process this producer and use the DB configuration instead
            return null;
         }

         String expirationCache = attrs.getValue("expiration-cache");
         Integer expirationCacheSeconds = null;
         if (expirationCache != null)
         {
            try
            {
               expirationCacheSeconds = new Integer(expirationCache);
            }
            catch (NumberFormatException e)
            {
               log.info("Ignoring bad expiration cache value " + expirationCache + " for producer '" + id + "'");
            }
         }

         String wsTimeout = attrs.getValue("ws-timeout");
         Integer wsTimeoutMS = ServiceFactory.DEFAULT_TIMEOUT_MS;
         if (wsTimeout != null)
         {
            try
            {
               wsTimeoutMS = new Integer(wsTimeout);
            }
            catch (NumberFormatException e)
            {
               log.info("Ignoring bad WS timeout value " + wsTimeout + " for producer '" + id + "'");
            }
         }

         // consumer didn't exist in the database, so create one and configure it
         consumer = consumerRegistry.createConsumer(id, expirationCacheSeconds, null);
         consumer.getProducerInfo().getEndpointConfigurationInfo().setWSOperationTimeOut(wsTimeoutMS);

         return consumer;
      }
      else
      {
View Full Code Here


   }

   @Override
   public WSRPConsumer createConsumerFrom(ProducerInfo producerInfo, boolean putInCache)
   {
      WSRPConsumer consumer = super.createConsumerFrom(producerInfo, putInCache);

      String id = consumer.getProducerId();
      consumers.put(id, consumer);
      ProducerInfo info = consumer.getProducerInfo();
      keysToIds.put(info.getKey(), id);

      return consumer;
   }
View Full Code Here

         return null;
      }
      else
      {
         keysToIds.put(key, newId);
         WSRPConsumer consumer = consumers.get(oldId);
         consumers.put(newId, consumer);
         return oldId;
      }
   }
View Full Code Here

   public void destroyConsumer(String id)
   {
      ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(id, "Consumer identifier", "Destroying a Consumer");

      WSRPConsumer consumer = getConsumer(id);
      if (consumer != null)
      {
         ProducerInfo info = consumer.getProducerInfo();

         try
         {
            consumer.releaseSessions();
         }
         catch (PortletInvokerException e)
         {
            log.debug("releaseSessions failed when attempting to destroy " + CONSUMER_WITH_ID + id + "'");
         }
View Full Code Here

      this.federatingPortletInvoker = federatingPortletInvoker;
   }

   private WSRPConsumer createConsumerFrom(ProducerInfo producerInfo)
   {
      WSRPConsumer consumer = new WSRPConsumerImpl(producerInfo);
      consumers.put(producerInfo.getId(), consumer);

      return consumer;
   }
View Full Code Here

         startOrStopConsumer(id, true);
      }
      else
      {
         // todo: fix-me federated portlet invoker gets desynchronized...
         WSRPConsumer consumer = getConsumer(id);
         if (consumer != null && !consumer.isActive())
         {
            federatingPortletInvoker.unregisterInvoker(id);
            startOrStopConsumer(id, true);
         }
      }
View Full Code Here

         startOrStopConsumer(id, false);
      }
      else
      {
         // todo: fix-me federated portlet invoker gets desynchronized...
         WSRPConsumer consumer = getConsumer(id);
         if (consumer != null && consumer.isActive())
         {
            federatingPortletInvoker.registerInvoker(id, consumer);
            startOrStopConsumer(id, false);
         }
      }
View Full Code Here

      String oldId = update(producerInfo);

      // if we updated and oldId is not null, we need to update the local consumers map
      if (oldId != null)
      {
         WSRPConsumer consumer = consumers.remove(oldId);
         consumers.put(producerInfo.getId(), consumer);
      }
   }
View Full Code Here

   public void registerOrDeregisterConsumerWith(String id, boolean register)
   {
      ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(id, "Consumer identifier", "Registering or deregistering a Consumer");

      WSRPConsumer consumer = getConsumer(id);

      if (consumer == null)
      {
         throw new ConsumerException(CONSUMER_WITH_ID + id + "' doesn't exist!");
      }

      try
      {
         if (register)
         {
            consumer.getProducerInfo().register();
         }
         else
         {
            consumer.getProducerInfo().deregister();
         }
      }
      catch (Exception e)
      {
         // unexpected exception: deactivate the consumer
View Full Code Here

      }
   }

   private void startOrStopConsumer(String id, boolean start)
   {
      WSRPConsumer consumer;

      try
      {
         if (start)
         {
            consumer = getConsumer(id);

            if (consumer == null)
            {
               throw new IllegalArgumentException(CONSUMER_WITH_ID + id + "' doesn't exist!");
            }

            consumer.activate();
            federatingPortletInvoker.registerInvoker(id, consumer);
            sessionEventBroadcaster.registerListener(getListenerIdFrom(id), consumer);
         }
         else
         {
            FederatedPortletInvoker fedInvoker = federatingPortletInvoker.getFederatedInvoker(id);
            if (fedInvoker != null)
            {
               PortletInvoker invoker = fedInvoker.getPortletInvoker();
               if (invoker instanceof WSRPConsumer)
               {
                  consumer = (WSRPConsumer)invoker;
                  consumer.deactivate();
                  federatingPortletInvoker.unregisterInvoker(id);
                  sessionEventBroadcaster.unregisterListener(getListenerIdFrom(id));
               }
               else
               {
                  throw new IllegalArgumentException("PortletInvoker with id '" + id + "' is not a WSRPConsumer!");
               }
            }
            else
            {
               throw new IllegalArgumentException("There is no registered PortletInvoker with id '" + id + "'");
            }
         }
      }
      catch (Exception e)
      {
         throw new ConsumerException("Couldn't " + (start ? "start" : "stop") + " Consumer service '" + id + "'", e);
      }

      // update ProducerInfo
      updateProducerInfo(consumer.getProducerInfo());
   }
View Full Code Here

TOP

Related Classes of org.gatein.wsrp.WSRPConsumer

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.