Examples of EventInvocation


Examples of org.gatein.pc.api.invocation.EventInvocation

   public PortletInvocationResponse invoke(PortletInvocation invocation) throws IllegalArgumentException, PortletInvokerException
   {
      if (invocation instanceof EventInvocation)
      {
         EventInvocation eventInvocation = (EventInvocation)invocation;

         //
         Serializable srcPayload = eventInvocation.getPayload();

         //
         Serializable dstPayload = null;
         if (srcPayload != null)
         {
            PortletContainer container = (PortletContainer)invocation.getAttribute(ContainerPortletInvoker.PORTLET_CONTAINER);

            //
            PortletApplication application = container.getPortletApplication();
            PortletApplicationContext applicationContext = application.getContext();
            ClassLoader applicationClassLoader = applicationContext.getClassLoader();
            String srcPayloadClassName = srcPayload.getClass().getName();
            boolean trace = log.isTraceEnabled();
            QName eventName = eventInvocation.getName();
            String containerId = container.getId();
            String applicationId = application.getId();

            //
            PortletInfo info = container.getInfo();
            EventingInfo eventingInfo = info.getEventing();
            Map<QName, ? extends EventInfo> consumedEventInfos = eventingInfo.getConsumedEvents();
            EventInfo eventInfo = consumedEventInfos.get(eventName);

            //
            if (trace)
            {
               log.trace("Attempt to obtain for event " + eventName + " its payload class " + srcPayloadClassName + " in the application " + applicationId +
                  " for portlet " + container.getInfo());
            }

            //
            Class dstPayloadClass = null;
            if (eventInfo != null)
            {
               ContainerTypeInfo typeInfo = (ContainerTypeInfo)eventInfo.getType();

               //
               if (typeInfo != null)
               {
                  dstPayloadClass = typeInfo.getType();
                  if (trace)
                  {
                     log.trace("Obtained for event " + eventName + " its payload class " + dstPayloadClass.getName() + " declared by the portlet meta data "
                        + containerId);
                  }
               }
               else
               {
                  if (trace)
                  {
                     log.trace("No type declared for event " + eventName + " declared by the portlet meta data " + containerId);
                  }
               }
            }


            //
            if (dstPayloadClass == null)
            {
               if (trace)
               {
                  log.trace("No event meta data declared by portlet " + containerId + " for event " + eventName + " will attempty " +
                     " to load same class name from the application " + applicationId + " classloader");
               }

               // We try to load the same class from the applicaton class loader
               try
               {
                  dstPayloadClass = applicationClassLoader.loadClass(srcPayloadClassName);
                  if (trace)
                  {
                     log.trace("Obtained matching event class " + dstPayloadClass.getName() + " in application " + applicationId + " for event " + eventName);
                  }
               }
               catch (ClassNotFoundException e)
               {
                  return new ErrorResponse("The application " + applicationId + " does not have access to the event payload class"
                     + srcPayloadClassName, e);
               }
               catch (NoClassDefFoundError e)
               {
                  return new ErrorResponse("The application " + applicationId + " does not have access to the event payload class"
                     + srcPayloadClassName, e);
               }
            }

            // We need maybe to perform some serialization to the classloader
            if (dstPayloadClass != srcPayload.getClass())
            {
               if (trace)
               {
                  log.trace("Need to convert event payload from class " + srcPayloadClassName + " to " + dstPayloadClass.getName());
               }
               try
               {
                  dstPayload = IOTools.clone(srcPayload, applicationClassLoader);
               }
               catch (ClassNotFoundException e)
               {
                  return new ErrorResponse("Could not convert the event payload from class " + srcPayloadClassName + " to class " + dstPayloadClass.getName(), e);
               }
               catch (IOException e)
               {
                  // The cause is likely a non compatible changes in class version
                  return new ErrorResponse("Could not convert the event payload from class " + srcPayloadClassName + " to class " + dstPayloadClass.getName(), e);
               }
            }
            else
            {
               dstPayload = srcPayload;
            }
         }

         // Set payload
         eventInvocation.setPayload(dstPayload);

         //
         try
         {
            return super.invoke(invocation);
         }
         finally
         {
            eventInvocation.setPayload(srcPayload);
         }
      }
      else
      {
         return super.invoke(invocation);
View Full Code Here

Examples of org.gatein.pc.api.invocation.EventInvocation

            resourceInvocation.setForm(allParams);

            invocation = type.cast(resourceInvocation);
        } else if (type.equals(EventInvocation.class)) {
            invocation = type.cast(new EventInvocation(pic));
        } else if (type.equals(RenderInvocation.class)) {
            invocation = type.cast(new RenderInvocation(pic));
        } else {
            throw new AssertionError();
        }
View Full Code Here

Examples of org.gatein.pc.api.invocation.EventInvocation

            resourceInvocation.setForm(allParams);

            invocation = type.cast(resourceInvocation);
        } else if (type.equals(EventInvocation.class)) {
            invocation = type.cast(new EventInvocation(pic));
        } else if (type.equals(RenderInvocation.class)) {
            invocation = type.cast(new RenderInvocation(pic));
        } else {
            throw new AssertionError();
        }
View Full Code Here

Examples of org.gatein.pc.api.invocation.EventInvocation

        log.trace("Process Event: " + event.getName() + " for portlet: " + uiPortlet.getState());
        try {
            PortalRequestContext context = (PortalRequestContext) WebuiRequestContext.getCurrentInstance();

            //
            EventInvocation eventInvocation = uiPortlet.create(EventInvocation.class, context);

            //
            eventInvocation.setName(event.getQName());
            eventInvocation.setPayload(event.getValue());

            //
            PortletInvocationResponse piResponse = uiPortlet.invoke(eventInvocation);

            //
            ExoPortletInstanceContext instanceCtx = (ExoPortletInstanceContext) eventInvocation.getInstanceContext();
            if (instanceCtx.getModifiedContext() != null) {
                StatefulPortletContext<C> updatedCtx = (StatefulPortletContext<C>) instanceCtx.getModifiedContext();
                C portletState = updatedCtx.getState();
                uiPortlet.update(portletState);
            }
View Full Code Here

Examples of org.gatein.pc.api.invocation.EventInvocation

   }

   @Override
   PortletInvocation initInvocation(WSRPPortletInvocationContext context)
   {
      EventInvocation eventInvocation = new EventInvocation(context);

      final EventParams eventParams = request.getEventParams();
      List<Event> events = eventParams.getEvents();

      if (events.size() > 1)
      {
         throw new NotYetImplemented("Need to support multiple events at once...");
      }

      // since we currently don't support sending multiple events to process at once, assume there's only one
      Event event = events.get(0);

      eventInvocation.setName(event.getName());
      eventInvocation.setPayload(PayloadUtils.getPayloadAsSerializable(event));

      // Extensions
      processExtensionsFrom(eventParams.getClass(), eventParams.getExtensions());

      return eventInvocation;
View Full Code Here

Examples of org.gatein.pc.api.invocation.EventInvocation

      //
      Map<String, String[]> publicNS = pageNavigationalState.getPortletPublicNavigationalState(event.getWindowId());

      //
      PortletInvocationContext portletInvocationContext = context.createPortletInvocationContext(event.getWindowId(), pageNavigationalState);
      EventInvocation eventInvocation = new EventInvocation(portletInvocationContext);

      //
      eventInvocation.setMode(windowNS.getMode());
      eventInvocation.setWindowState(windowNS.getWindowState());
      eventInvocation.setNavigationalState(windowNS.getPortletNavigationalState());
      eventInvocation.setPublicNavigationalState(publicNS);
      eventInvocation.setName(event.getName());
      eventInvocation.setPayload(event.getPayload());

      //
      return context.invoke(requestCookies, eventInvocation);
   }
View Full Code Here

Examples of org.gatein.pc.api.invocation.EventInvocation

        log.trace("Process Event: " + event.getName() + " for portlet: " + uiPortlet.getState());
        try {
            PortalRequestContext context = (PortalRequestContext) WebuiRequestContext.getCurrentInstance();

            //
            EventInvocation eventInvocation = uiPortlet.create(EventInvocation.class, context);

            //
            eventInvocation.setName(event.getQName());
            eventInvocation.setPayload(event.getValue());

            //
            PortletInvocationResponse piResponse = uiPortlet.invoke(eventInvocation);

            //
            ExoPortletInstanceContext instanceCtx = (ExoPortletInstanceContext) eventInvocation.getInstanceContext();
            if (instanceCtx.getModifiedContext() != null) {
                StatefulPortletContext<C> updatedCtx = (StatefulPortletContext<C>) instanceCtx.getModifiedContext();
                C portletState = updatedCtx.getState();
                uiPortlet.update(portletState);
            }
View Full Code Here

Examples of org.gatein.pc.api.invocation.EventInvocation

      try
      {
         PortalRequestContext context = (PortalRequestContext)WebuiRequestContext.getCurrentInstance();

         //
         EventInvocation eventInvocation = uiPortlet.create(EventInvocation.class, context);

         //
         eventInvocation.setName(event.getQName());
         eventInvocation.setPayload(event.getValue());

         //
         PortletInvocationResponse piResponse = uiPortlet.invoke(eventInvocation);

         //
         ExoPortletInstanceContext instanceCtx = (ExoPortletInstanceContext)eventInvocation.getInstanceContext();
         if (instanceCtx.getModifiedContext() != null)
         {
            StatefulPortletContext<C> updatedCtx = (StatefulPortletContext<C>)instanceCtx.getModifiedContext();
            C portletState = updatedCtx.getState();
            uiPortlet.update(portletState);
View Full Code Here

Examples of org.gatein.pc.api.invocation.EventInvocation

         invocation = type.cast(resourceInvocation);
      }
      else if (type.equals(EventInvocation.class))
      {
         invocation = type.cast(new EventInvocation(pic));
      }
      else if (type.equals(RenderInvocation.class))
      {
         invocation = type.cast(new RenderInvocation(pic));
      }
View Full Code Here

Examples of org.gatein.pc.api.invocation.EventInvocation

            resourceInvocation.setForm(allParams);

            invocation = type.cast(resourceInvocation);
        } else if (type.equals(EventInvocation.class)) {
            invocation = type.cast(new EventInvocation(pic));
        } else if (type.equals(RenderInvocation.class)) {
            invocation = type.cast(new RenderInvocation(pic));
        } else {
            throw new AssertionError();
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.