portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject svn commit: r751848 - in /portals/jetspeed-2/portal/trunk: ./ components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/providers/ components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/services/ components/jetspeed-portal/...
Date Mon, 09 Mar 2009 21:28:52 GMT
Author: taylor
Date: Mon Mar  9 21:28:50 2009
New Revision: 751848

URL: http://svn.apache.org/viewvc?rev=751848&view=rev
Log:
https://issues.apache.org/jira/browse/JS2-927
This completes the second phase of Portlet Events. I will need to refactor and comply to the new interfaces once the Pluto refactoring makes its way in. The implementation should stay the same for this release. In a future release, I would like to leverage a normalized WorkMonitor: the plan is to use the same engine to process but rendering and events

Added:
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/events/
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/events/EventCoordinationService.java   (with props)
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/events/EventCoordinationServiceImpl.java   (with props)
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/events/PortletEventQueueImpl.java   (with props)
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/events/ProcessEventImpl.java   (with props)
    portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/events/
    portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/events/PortletEventQueue.java   (with props)
    portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/events/ProcessEvent.java   (with props)
Removed:
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/providers/EventList.java
Modified:
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/providers/EventProviderImpl.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/services/JetspeedPortalCallbackServices.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PortletDefinitionImpl.java
    portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/statistics/PortalStatistics.java
    portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/pluto-services.xml
    portals/jetspeed-2/portal/trunk/pom.xml

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/providers/EventProviderImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/providers/EventProviderImpl.java?rev=751848&r1=751847&r2=751848&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/providers/EventProviderImpl.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/providers/EventProviderImpl.java Mon Mar  9 21:28:50 2009
@@ -17,42 +17,13 @@
 package org.apache.jetspeed.container.providers;
 
 import java.io.Serializable;
-import java.io.StringWriter;
-import java.io.Writer;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
 
-import javax.portlet.Event;
 import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBElement;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Marshaller;
 import javax.xml.namespace.QName;
-import javax.xml.stream.FactoryConfigurationError;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.jetspeed.PortalReservedParameters;
-import org.apache.jetspeed.aggregator.PortletAccessDeniedException;
-import org.apache.jetspeed.components.portletentity.PortletEntityNotStoredException;
-import org.apache.jetspeed.container.window.FailedToRetrievePortletWindow;
-import org.apache.jetspeed.container.window.PortletWindowAccessor;
-import org.apache.jetspeed.om.page.Fragment;
-import org.apache.jetspeed.om.portlet.PortletDefinition;
-import org.apache.jetspeed.om.window.impl.PortletWindowImpl;
-import org.apache.jetspeed.request.RequestContext;
-import org.apache.pluto.Constants;
+import org.apache.jetspeed.container.PortletWindow;
+import org.apache.jetspeed.events.EventCoordinationService;
 import org.apache.pluto.EventContainer;
-import org.apache.pluto.PortletWindow;
-import org.apache.pluto.internal.impl.EventImpl;
-import org.apache.pluto.om.portlet.EventDefinition;
-import org.apache.pluto.om.portlet.EventDefinitionReference;
-import org.apache.pluto.om.portlet.PortletApplicationDefinition;
 import org.apache.pluto.spi.EventProvider;
 
 /**
@@ -61,301 +32,31 @@
  */
 public class EventProviderImpl implements EventProvider, Cloneable
 {
-    private static Log log = LogFactory.getLog(EventProviderImpl.class);
     private final PortletWindow portletWindow;    
-    private final RequestContext rc;
-    private final PortletWindowAccessor windowAccessor;
+    private final HttpServletRequest request;
+    private final EventCoordinationService eventCoordinator;
     
-    // IMPROVEME: (a lot) this is a simple-non-production implementation of an event queue
-    private static Map<String, EventList> eventQueue = new HashMap<String, EventList>();
-    
-    public EventProviderImpl()
-    {
-        windowAccessor = null;
-        rc = null;
-        portletWindow = null;
-    }
-
-    public EventProviderImpl(final RequestContext rc, final PortletWindow window, final PortletWindowAccessor windowAccessor)
-    {
-        this.portletWindow = window;
-        this.rc = rc;
-        this.windowAccessor = windowAccessor;
-    }
-        
-    public void registerToFireEvent(QName qname, Serializable value)
-            throws IllegalArgumentException
+    public EventProviderImpl(final HttpServletRequest request, final org.apache.pluto.PortletWindow window, final EventCoordinationService eventCoordinator)
     {
-        System.out.println("registering to fire events");
-        EventList savedEvents = new EventList();        
-        if (isDeclaredAsPublishingEvent(qname)) 
-        {
-            if (value != null && !isValueInstanceOfDefinedClass(qname, value))
-            {
-                throw new IllegalArgumentException("Payload has not the right class");
-            }
-            try 
-            {
-                if (value == null) 
-                {
-                    savedEvents.addEvent(new EventImpl(qname, value));
-                } 
-                else if (!(value instanceof Serializable)) 
-                {
-                    throw new IllegalArgumentException(
-                            "Object payload must implement Serializable");
-                } 
-                else 
-                {
-                    Writer out = new StringWriter();
-                    Class clazz = value.getClass();
-                    ClassLoader cl = Thread.currentThread().getContextClassLoader();
-                    try
-                    {
-                        Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
-                        JAXBContext jc = JAXBContext.newInstance(clazz);
-                        Marshaller marshaller = jc.createMarshaller();
-                        JAXBElement<Serializable> element = new JAXBElement<Serializable>(
-                                qname, clazz, value);
-                        marshaller.marshal(element, out);
-                        // marshaller.marshal(value, out);
-                    }
-                    finally
-                    {
-                        Thread.currentThread().setContextClassLoader(cl);
-                    }
-                    out = null;
-                    if (out != null) 
-                    {
-                        savedEvents.addEvent(new EventImpl(qname,
-                                (Serializable) out.toString()));
-                    } 
-                    else 
-                    {
-                        savedEvents.addEvent(new EventImpl(qname, value));
-                    }
-                }
-            } catch (JAXBException e) 
-            {
-                // maybe there is no valid jaxb binding
-                // TODO wsrp:eventHandlingFailed
-                log.error("Event handling failed", e);
-            } 
-            catch (FactoryConfigurationError e) 
-            {
-                log.warn(e);
-            }
-        }
-        eventQueue.put(this.portletWindow.getId().toString(), savedEvents);
+        this.request = request;
+        this.portletWindow = (PortletWindow)window;
+        this.eventCoordinator = eventCoordinator;
     }
     
-    public static final int MAX_EVENTS_SIZE = 10; // TODO
+    // FOR ATE's REFACTORING:
+    //public Event createEvent(QName name, Serializable value)
+   // throws IllegalArgumentException;
     
-    public void fireEvents(EventContainer eventContainer)
-    {
-        String eventTargetWindow = this.portletWindow.getId().toString();
-        System.out.println("firing events for " + eventTargetWindow);
-        EventList savedEvents = this.eventQueue.get(eventTargetWindow);
-        if (savedEvents == null)
-            return;
-        while (savedEvents.hasMoreEvents()
-                && savedEvents.getSize() < MAX_EVENTS_SIZE) 
-        {
-            Event event = getArbitraryEvent(savedEvents);
-            savedEvents.setProcessed(event);
-            
-            List<PortletWindow> windows = getAllPortletsRegisteredForEvent(event);
-
-            // iterate all portlets in the portal
-            for (PortletWindow window : windows) 
-            {
-                
-                HttpServletRequest request = rc.getRequestForWindow((org.apache.jetspeed.container.PortletWindow)window);
-                //this.request.setAttribute(PortalReservedParameters.FRAGMENT_ATTRIBUTE, fragment);
-                request.setAttribute(PortalReservedParameters.PAGE_ATTRIBUTE, rc.getPage());
-                request.setAttribute(PortalReservedParameters.REQUEST_CONTEXT_ATTRIBUTE, rc);
-                request.setAttribute(PortalReservedParameters.REQUEST_CONTEXT_OBJECTS, rc.getObjects());    
-                try
-                {
-                    eventContainer.fireEvent(request, 
-                          rc.getResponseForWindow((org.apache.jetspeed.container.PortletWindow)window), window, event);
-                }
-                catch (Exception e)
-                {
-                    // TODO: handle
-                    e.printStackTrace();
-                }
-                this.eventQueue.remove(eventTargetWindow);    
-// TODO: threading                
-//                PortletWindow window = new PortletWindowImpl(container, config, portalURL);
-//                if (portletNames != null) {
-//                    for (String portlet : portletNames) {
-//                        if (portlet.equals(config.getId())) {
-//
-//                            // the thread now is a new one, with possible
-//                            // waiting,
-//                            // for the old to exit
-//                            
-//
-//                            PortletWindowThread portletWindowThread = getPortletWindowThread(
-//                                    eventContainer, config, window, containerServletContext);
-//
-//                            // is this event
-//                            portletWindowThread.addEvent(eActual);
-//
-//                            portletWindowThread.start();
-//                        }
-//                    }
-                }
-            }
-        
-//            waitForEventExecution();
-//            try {
-//                Thread.sleep(WAITING_CYCLE);
-//            } catch (InterruptedException e) {
-//                LOG.warn(e);
-//            }
-        
-//        waitForEventExecution();        
-    }
     
-    private boolean isDeclaredAsPublishingEvent(QName qname) 
+    public void registerToFireEvent(QName qname, Serializable value)
+            throws IllegalArgumentException
     {
-        PortletDefinition pd = (PortletDefinition)this.portletWindow.getPortletEntity().getPortletDefinition();         
-        List<? extends EventDefinitionReference> events = pd.getSupportedPublishingEvents();
-        if (events != null) 
-        {
-            String defaultNamespace = pd.getApplication().getDefaultNamespace();
-            for (EventDefinitionReference ref : events) 
-            {
-                QName name = ref.getQualifiedName(defaultNamespace);
-                if (name == null)
-                {
-                    continue;
-                }
-                if (qname.equals(name)) 
-                {
-                    return true;
-                }
-            }
-        }
-        return false;
+        eventCoordinator.registerToFireEvent(qname, value, portletWindow);
     }
 
-    private boolean isValueInstanceOfDefinedClass(QName qname, Serializable value) 
-    {
-        PortletApplicationDefinition app = portletWindow.getPortletEntity().getPortletDefinition().getApplication();
-        List<? extends EventDefinition> events = app.getEventDefinitions();
-        if (events != null) 
-        {
-            for (EventDefinition def : events)
-            {
-                if (def.getQName() != null)
-                {
-                    if (def.getQName().equals(qname))
-                    {
-                        return value.getClass().getName().equals(def.getValueType());
-                    }
-                }
-                else
-                {
-                    QName tmp = new QName(app.getDefaultNamespace(),def.getName());
-                    if (tmp.equals(qname))
-                    {
-                        return value.getClass().getName().equals(def.getValueType());
-                    }
-                }
-            }
-        }
-        return true;
-    }
-    
-    private Event getArbitraryEvent(EventList savedEvents) 
-    {
-        Event eActual = null;
-        for (Event event : savedEvents.getEvents()) 
-        {
-            if (savedEvents.isNotProcessed(event)) 
-            {
-                eActual = event;
-            }
-        }
-        return eActual;
-    }
-    
-    private boolean optionsNotifyCurrentPage = true;
-    private boolean optionsNotifyAnyPortlet = false;
-    
-    private List<PortletWindow> getAllPortletsRegisteredForEvent(Event event)
+    public void fireEvents(EventContainer eventContainer)
     {
-        if (optionsNotifyCurrentPage)
-        {
-            Fragment root = rc.getPage().getRootFragment();
-            List<PortletWindow> eventTargets = new LinkedList<PortletWindow>();            
-            return getPortletsRegisteredOnPage(root, event, eventTargets);
-        }
-        else if (optionsNotifyAnyPortlet)
-        {
-            
-        }
-        return null;
+        eventCoordinator.fireEvents(eventContainer, portletWindow, request);
     }
- 
-    private List<PortletWindow> getPortletsRegisteredOnPage(Fragment fragment, Event event, List<PortletWindow> eventTargets)
-    {
-        List<Fragment> fragments = fragment.getFragments();
-        if (fragments != null && fragments.size() > 0)
-        {
-            for (Fragment child : fragments)
-            {
-                getPortletsRegisteredOnPage(child, event, eventTargets);
-            }
-        }
-        PortletWindow portletWindow = windowAccessor.getPortletWindow(fragment.getId()); // TODO: support fragment to window id
-        if (portletWindow == null)
-            return eventTargets;
-        
-        PortletDefinition portlet = (PortletDefinition) portletWindow.getPortletEntity().getPortletDefinition();
-        
-// TODO: check security        
-//        if (checkSecurityConstraints && !checkSecurityConstraint(portletDefinition, fragment))
-//        {
-//            throw new PortletAccessDeniedException("Access Denied.");
-//        }
-        
-// TODO: check portlet tracking        
-//        if (portletTracking.isOutOfService(portletWindow))
-//        {
-//            log.info("Taking portlet out of service: " + portletDefinition.getUniqueName() + " for window " + fragment.getId());
-//            fragment.overrideRenderedContent(OUT_OF_SERVICE_MESSAGE);
-//            return;
-//        }
         
-        List<? extends EventDefinitionReference> processingEvents = portlet.getSupportedProcessingEvents();
-        if (isEventSupported(processingEvents, event.getQName(), portlet.getApplication().getDefaultNamespace())) 
-        {
-            if (portlet.getPortletName().equals(portlet.getPortletName())) // BOZO: WTF?
-            {
-                eventTargets.add(portletWindow);
-            }
-        }
-        return eventTargets;
-    }
-    
-
-    private boolean isEventSupported(List<? extends EventDefinitionReference> supportedEvents, QName eventName, String defaultNamespace)
-    {
-        if (supportedEvents != null)
-        {
-            for (EventDefinitionReference ref : supportedEvents)
-            {
-                QName refQName = ref.getQualifiedName(defaultNamespace);
-                if (refQName != null && refQName.equals(eventName))
-                {
-                    return true;
-                }
-            }
-        }
-        return false;
-    }    
 }

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/services/JetspeedPortalCallbackServices.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/services/JetspeedPortalCallbackServices.java?rev=751848&r1=751847&r2=751848&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/services/JetspeedPortalCallbackServices.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/container/services/JetspeedPortalCallbackServices.java Mon Mar  9 21:28:50 2009
@@ -21,12 +21,10 @@
 
 import org.apache.jetspeed.PortalReservedParameters;
 import org.apache.jetspeed.container.PortletEntity;
-import org.apache.jetspeed.container.providers.EventProviderImpl;
 import org.apache.jetspeed.container.providers.PortletURLProviderImpl;
 import org.apache.jetspeed.container.providers.ResourceURLProviderImpl;
-import org.apache.jetspeed.container.window.PortletWindowAccessor;
+import org.apache.jetspeed.events.EventCoordinationService;
 import org.apache.jetspeed.request.RequestContext;
-import org.apache.pluto.EventContainer;
 import org.apache.pluto.om.portlet.PortletApplicationDefinition;
 import org.apache.pluto.spi.EventProvider;
 import org.apache.pluto.spi.FilterManager;
@@ -47,24 +45,19 @@
 {
     public static final String PER_REQUEST_EVENT_PROVIDER = "org.apache.jetspeed.container.EventProvider";
 
-    PropertyManager propertyManager;   
-    FilterManager filterManager;
-    PortletURLListener urlListener;
-    PortletWindowAccessor windowAccessor;
-    EventContainer eventContainer; 
+    private PropertyManager propertyManager;   
+    private FilterManager filterManager;
+    private PortletURLListener urlListener;
+    private EventCoordinationService eventCoordinator;
     
     public JetspeedPortalCallbackServices(final PropertyManager propertyManager,
-            final FilterManager filterManager, final PortletURLListener urlListener, final PortletWindowAccessor windowAccessor)
+            final FilterManager filterManager, final PortletURLListener urlListener, 
+            final EventCoordinationService eventCoordinator)
     {
         this.propertyManager = propertyManager;
         this.filterManager = filterManager;
         this.urlListener = urlListener;
-        this.windowAccessor = windowAccessor;
-    }
-
-    public void setEventContainer(final EventContainer eventContainer)
-    {
-        this.eventContainer = eventContainer;
+        this.eventCoordinator = eventCoordinator;
     }
     
     public PortletURLProvider getPortletURLProvider(HttpServletRequest request,
@@ -92,8 +85,7 @@
     public EventProvider getEventProvider(HttpServletRequest request,
             org.apache.pluto.PortletWindow portletWindow)
     {   
-        RequestContext rc = (RequestContext) request.getAttribute(PortalReservedParameters.REQUEST_CONTEXT_ATTRIBUTE);
-        return new EventProviderImpl(rc, portletWindow, this.windowAccessor);
+        return eventCoordinator.createEventProvider(request, portletWindow);
     }
 
     public EventProvider getEventProvider()

Added: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/events/EventCoordinationService.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/events/EventCoordinationService.java?rev=751848&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/events/EventCoordinationService.java (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/events/EventCoordinationService.java Mon Mar  9 21:28:50 2009
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.events;
+
+import java.io.Serializable;
+import java.util.List;
+
+import javax.portlet.Event;
+import javax.servlet.http.HttpServletRequest;
+import javax.xml.namespace.QName;
+
+import org.apache.pluto.PortletWindow;
+import org.apache.pluto.EventContainer;
+import org.apache.pluto.spi.EventProvider;
+
+/**
+ * TODO: Extend from Pluto's service when checked in and building 
+ * Extends Pluto Event Coordination with Jetspeed specific Portlet Event processing
+ * 
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id$
+ */
+public interface EventCoordinationService
+{
+    /**
+     * Process all events for a given portlet window and given list of events. 
+     * @param portletWindow The window to processs events for
+     * @param events The list of one or more events
+     */
+    void processEvents(PortletWindow portletWindow, List<Event> events);
+    
+    /**
+     * 
+     * @param eventContainer
+     * @param window
+     * @param request
+     */
+    public void fireEvents(EventContainer eventContainer, PortletWindow window, HttpServletRequest request);
+    
+    /**
+     * 
+     * @param qname
+     * @param value
+     * @param window
+     */
+    public void registerToFireEvent(QName qname, Serializable value, PortletWindow window);
+    
+    /**
+     * 
+     * @param request
+     * @param portletWindow
+     * @return
+     */
+    public EventProvider createEventProvider(HttpServletRequest request, 
+            org.apache.pluto.PortletWindow portletWindow);
+    
+    /**
+     * Serialize an event value class representation into a Jetspeed-specific seriaizable form, such as String or XML.
+     * @param event The instance 'value' of the event. This class must be serializable.
+     * @param eventQName The QName identifying this event to the system.
+     * @return
+     */
+    public Serializable serialize(Serializable event, QName eventQName);
+    
+    /**
+     * Deserialize an event from Jetspeed's internal representation of a serialization into a class. Requires calling serialize on this event first.
+     * @param event The event holding the serialized internal form of the event value. This value will be serialized back into a defined class.
+     * @return The deserialized Event class
+     */
+    public Serializable deserialize(Event event); 
+}
\ No newline at end of file

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/events/EventCoordinationService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/events/EventCoordinationService.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/events/EventCoordinationServiceImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/events/EventCoordinationServiceImpl.java?rev=751848&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/events/EventCoordinationServiceImpl.java (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/events/EventCoordinationServiceImpl.java Mon Mar  9 21:28:50 2009
@@ -0,0 +1,365 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.events;
+
+import java.io.Serializable;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.net.URLClassLoader;
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.portlet.Event;
+import javax.servlet.http.HttpServletRequest;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.namespace.QName;
+import javax.xml.stream.FactoryConfigurationError;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jetspeed.JetspeedActions;
+import org.apache.jetspeed.PortalReservedParameters;
+import org.apache.jetspeed.aggregator.PortletTrackingManager;
+import org.apache.jetspeed.container.PortletWindow;
+import org.apache.jetspeed.container.providers.EventProviderImpl;
+import org.apache.jetspeed.container.window.PortletWindowAccessor;
+import org.apache.jetspeed.om.page.Fragment;
+import org.apache.jetspeed.om.portlet.PortletDefinition;
+import org.apache.jetspeed.request.RequestContext;
+import org.apache.jetspeed.security.SecurityAccessController;
+import org.apache.jetspeed.statistics.PortalStatistics;
+import org.apache.pluto.EventContainer;
+import org.apache.pluto.om.portlet.EventDefinition;
+import org.apache.pluto.om.portlet.EventDefinitionReference;
+import org.apache.pluto.om.portlet.PortletApplicationDefinition;
+import org.apache.pluto.spi.EventProvider;
+
+/**
+ * Event Coordination service default implementation. Uses JAXB to serialize/deserialize events.
+ * 
+ * 2.2.1 TODO: future options 
+ * (1)optionsNotifyCurrentPage, optionsNotifyAnyPortlet 
+ * (2) use WorkerMonitor to process events in parallel.
+ *   Will require the WorkMonitor polymorphically processing off of base class
+ *   'BaseMonitorJob' to both RenderingJob and new class EventJob 
+ * (3) Support fragment to window mapping
+ * 
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id$
+ */
+public class EventCoordinationServiceImpl implements EventCoordinationService
+{
+    private static Log log = LogFactory.getLog(EventProviderImpl.class);
+
+    private final PortletWindowAccessor windowAccessor;
+    private final PortletEventQueue eventQueue;
+    private final PortalStatistics statistics;
+    private final PortletTrackingManager portletTracking;
+    private final SecurityAccessController accessController;
+    private boolean checkSecurityConstraints = true;
+
+    public EventCoordinationServiceImpl(final PortletWindowAccessor windowAccessor, final PortletEventQueue eventQueue,
+            final PortalStatistics statistics, PortletTrackingManager portletTracking, SecurityAccessController accessController,
+            boolean checkSecurityConstraints)
+    {
+        this.windowAccessor = windowAccessor;
+        this.eventQueue = eventQueue;
+        this.statistics = statistics;
+        this.portletTracking = portletTracking;
+        this.accessController = accessController;
+        this.checkSecurityConstraints = checkSecurityConstraints;
+    }
+
+    public EventProvider createEventProvider(HttpServletRequest request, org.apache.pluto.PortletWindow portletWindow)
+    {
+        return new EventProviderImpl(request, portletWindow, this);
+    }
+
+    public void registerToFireEvent(QName qname, Serializable value, org.apache.pluto.PortletWindow wnd) throws IllegalArgumentException
+    {
+        PortletWindow portletWindow = (PortletWindow)wnd;
+        if (isDeclaredAsPublishingEvent(portletWindow, qname))
+        {
+            if (value != null && !isValueInstanceOfDefinedClass(portletWindow, qname, value)) 
+            { 
+                throw new IllegalArgumentException(
+                    "Payload has not the right class"); 
+            }
+            if (value == null)
+            {
+                throw new IllegalArgumentException("Object payload must be not null");
+            }
+            else if (!(value instanceof Serializable))
+            {
+                throw new IllegalArgumentException("Object payload must implement Serializable");
+            }
+            else
+            {
+                String result = null;
+                Serializable out  = serialize(value, qname);
+                if (out != null)
+                {
+                    result = out.toString();
+                }
+                if (result != null)
+                {
+                    eventQueue.publishEvent(new ProcessEventImpl(portletWindow, qname, value.getClass().getName(), (Serializable) result, this));
+                }
+                else
+                {
+                    eventQueue.publishEvent(new ProcessEventImpl(portletWindow, qname, value.getClass().getName(), value, this));
+                }
+            }
+        }
+    }
+
+    public void fireEvents(EventContainer eventContainer, org.apache.pluto.PortletWindow wnd, HttpServletRequest servletRequest)
+    {
+        PortletWindow portletWindow = (PortletWindow)wnd;
+        RequestContext rc = (RequestContext) servletRequest.getAttribute(PortalReservedParameters.REQUEST_CONTEXT_ATTRIBUTE);
+        List<ProcessEvent> events = eventQueue.dequeueEvents(portletWindow);
+        if (events == null)
+            return;
+        long start = System.currentTimeMillis();        
+        for (ProcessEvent event : events)
+        {
+            if (event.isProcessed())
+                continue;
+            event.setProcessed(true);
+            List<PortletWindow> windows = getAllPortletsRegisteredForEvent(rc, event);
+            for (PortletWindow window : windows)
+            {
+                HttpServletRequest request = rc.getRequestForWindow(window);
+                request.setAttribute(PortalReservedParameters.PAGE_ATTRIBUTE, rc.getPage());
+                request.setAttribute(PortalReservedParameters.REQUEST_CONTEXT_ATTRIBUTE, rc);
+                request.setAttribute(PortalReservedParameters.REQUEST_CONTEXT_OBJECTS, rc.getObjects());
+                try
+                {
+                    eventContainer.fireEvent(request, rc.getResponseForWindow(window), window, event);
+                }
+                catch (Exception e)
+                {
+                    log.error("Failed to process event: " + event, e);
+                }
+            }
+        }
+        long end = System.currentTimeMillis();        
+        if (statistics != null)
+        {
+            statistics.logPortletAccess(rc, portletWindow.getPortletEntity().getPortletDefinition().getUniqueName(), PortalStatistics.HTTP_EVENT, end - start);
+        }
+    }
+
+    private boolean isDeclaredAsPublishingEvent(PortletWindow portletWindow, QName qname)
+    {
+        PortletDefinition pd = (PortletDefinition) portletWindow.getPortletEntity().getPortletDefinition();
+        List<? extends EventDefinitionReference> events = pd.getSupportedPublishingEvents();
+        if (events != null)
+        {
+            String defaultNamespace = pd.getApplication().getDefaultNamespace();
+            for (EventDefinitionReference ref : events)
+            {
+                QName name = ref.getQualifiedName(defaultNamespace);
+                if (name == null)
+                {
+                    continue;
+                }
+                if (qname.equals(name)) { return true; }
+            }
+        }
+        return false;
+    }
+
+    private boolean isValueInstanceOfDefinedClass(PortletWindow portletWindow, QName qname, Serializable value)
+    {
+        PortletApplicationDefinition app = portletWindow.getPortletEntity().getPortletDefinition().getApplication();
+        List<? extends EventDefinition> events = app.getEventDefinitions();
+        if (events != null)
+        {
+            for (EventDefinition def : events)
+            {
+                if (def.getQName() != null)
+                {
+                    if (def.getQName().equals(qname)) { return value.getClass().getName().equals(def.getValueType()); }
+                }
+                else
+                {
+                    QName tmp = new QName(app.getDefaultNamespace(), def.getName());
+                    if (tmp.equals(qname)) { return value.getClass().getName().equals(def.getValueType()); }
+                }
+            }
+        }
+        return true;
+    }
+
+    private List<PortletWindow> getAllPortletsRegisteredForEvent(RequestContext rc, Event event)
+    {
+        Fragment root = rc.getPage().getRootFragment();
+        List<PortletWindow> eventTargets = new LinkedList<PortletWindow>();
+        return getPortletsRegisteredOnPage(root, event, eventTargets);
+    }
+
+    private List<PortletWindow> getPortletsRegisteredOnPage(Fragment fragment, Event event, List<PortletWindow> eventTargets)
+    {
+        List<Fragment> fragments = fragment.getFragments();
+        if (fragments != null && fragments.size() > 0)
+        {
+            for (Fragment child : fragments)
+            {
+                getPortletsRegisteredOnPage(child, event, eventTargets);
+            }
+        }
+        PortletWindow portletWindow = windowAccessor.getPortletWindow(fragment.getId());
+        if (portletWindow == null)
+            return eventTargets;
+
+        PortletDefinition portlet = (PortletDefinition) portletWindow.getPortletEntity().getPortletDefinition();
+
+        if (checkSecurityConstraints && !checkSecurityConstraint(portlet, fragment)) 
+        {
+            return eventTargets;
+        }
+
+        if (portletTracking.isOutOfService((org.apache.jetspeed.container.PortletWindow)portletWindow))
+        {
+            return eventTargets;
+        }
+        List<? extends EventDefinitionReference> processingEvents = portlet.getSupportedProcessingEvents();
+        if (isEventSupported(processingEvents, event.getQName(), portlet.getApplication().getDefaultNamespace()))
+        {
+            eventTargets.add(portletWindow);
+        }
+        return eventTargets;
+    }
+
+    protected boolean checkSecurityConstraint(PortletDefinition portlet, Fragment fragment)
+    {
+        if (fragment.getType().equals(Fragment.PORTLET))
+        {
+            
+            if (accessController != null) // TODO: MASK_EVENT 
+            { 
+                return accessController.checkPortletAccess(portlet, JetspeedActions.MASK_VIEW);
+            }
+        }
+        return true;
+    }
+
+    private boolean isEventSupported(List<? extends EventDefinitionReference> supportedEvents, QName eventName, String defaultNamespace)
+    {
+        if (supportedEvents != null)
+        {
+            for (EventDefinitionReference ref : supportedEvents)
+            {
+                QName refQName = ref.getQualifiedName(defaultNamespace);
+                if (refQName != null && refQName.equals(eventName)) { return true; }
+            }
+        }
+        return false;
+    }
+
+    // TODO: implement after Ate's refactoring completed
+    public void processEvents(org.apache.pluto.PortletWindow portletWindow, List<Event> events)
+    {
+
+    }
+
+    public Serializable serialize(Serializable value, QName eventQName) 
+    {
+        Serializable xmlData = null;
+        if (value != null) 
+        {
+            ClassLoader savedLoader = Thread.currentThread().getContextClassLoader();
+            try 
+            {                                                
+                Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());                
+                JAXBContext jaxbContext = JAXBContext.newInstance(value.getClass());
+                Marshaller marshaller = jaxbContext.createMarshaller();
+                Writer out = new StringWriter();
+                JAXBElement<Serializable> element = new JAXBElement(eventQName, value.getClass(), value);
+                marshaller.marshal(element, out);
+                xmlData = out.toString(); 
+            } 
+            catch(JAXBException e) 
+            {
+                log.error("Failed to serialize: " + value, e);
+            }
+            finally
+            {
+                Thread.currentThread().setContextClassLoader(savedLoader);
+            }
+            
+        }
+        return xmlData;
+    }    
+    
+    
+ 
+    
+    public Serializable deserialize(Event event)  
+    {
+        ProcessEvent processEvent = (ProcessEvent)event;
+        ClassLoader savedLoader = Thread.currentThread().getContextClassLoader();                
+        Serializable deserializedValue = null;
+        Serializable value = processEvent.getRawValue();
+        if (value != null) 
+        {
+            Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());                            
+            XMLStreamReader xml = null;
+            if (value instanceof String) 
+            {
+                try 
+                {                    
+                    xml = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader((String) value));
+                } 
+                catch (Exception e)
+                {
+                    log.error("Failed to stream for de-serialization: " + value, e);
+                    xml = null;
+                }
+            }           
+            if (xml != null) 
+            {
+                try 
+                {
+                    Class<? extends Serializable> clazz = savedLoader.loadClass(processEvent.getClassName()).asSubclass(Serializable.class);
+                    JAXBContext jaxbContext = JAXBContext.newInstance(clazz);
+                    Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
+                    JAXBElement result = unmarshaller.unmarshal(xml, clazz);
+                    deserializedValue = (Serializable) result.getValue();
+                } 
+                catch (Exception e)
+                {
+                    log.error("Failed to de-serializee: " + value, e);
+                    xml = null;
+                }
+
+            }
+        }
+        Thread.currentThread().setContextClassLoader(savedLoader);        
+        return deserializedValue;
+    }
+    
+}

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/events/EventCoordinationServiceImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/events/EventCoordinationServiceImpl.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/events/PortletEventQueueImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/events/PortletEventQueueImpl.java?rev=751848&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/events/PortletEventQueueImpl.java (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/events/PortletEventQueueImpl.java Mon Mar  9 21:28:50 2009
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.events;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.pluto.PortletWindow;
+
+
+/**
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id$
+ */
+public class PortletEventQueueImpl implements PortletEventQueue
+{
+    private Map<String, List<ProcessEvent>> eventQueue = Collections.synchronizedMap(new HashMap<String, List<ProcessEvent>>());
+
+    public PortletEventQueueImpl()
+    {}
+    
+    public List<ProcessEvent> dequeueEvents(PortletWindow window)
+    {
+        return eventQueue.remove(window.getId().toString());
+    }
+
+    public void publishEvent(ProcessEvent event)
+    {
+        List<ProcessEvent> events = eventQueue.get(event.getPortletWindow().getId());
+        if (events == null)
+        {
+            events = new LinkedList<ProcessEvent>();
+            eventQueue.put(event.getPortletWindow().getId().toString(), events);
+        }
+        events.add(event);        
+    }
+    
+}
\ No newline at end of file

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/events/PortletEventQueueImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/events/PortletEventQueueImpl.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/events/ProcessEventImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/events/ProcessEventImpl.java?rev=751848&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/events/ProcessEventImpl.java (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/events/ProcessEventImpl.java Mon Mar  9 21:28:50 2009
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.events;
+
+import java.io.Serializable;
+
+import javax.xml.namespace.QName;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.pluto.PortletWindow;
+
+/**
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id$
+ */
+public class ProcessEventImpl implements ProcessEvent
+{
+    private PortletWindow window;
+    private QName qname;
+    private java.io.Serializable value;
+    private String className;
+    private EventCoordinationService eventService;
+    private boolean processed = false;
+    private static Log log = LogFactory.getLog(ProcessEventImpl.class);
+    
+
+    public ProcessEventImpl(PortletWindow window, QName qname, String className, java.io.Serializable value, EventCoordinationService eventService)
+    {
+        this.window = window;
+        this.qname = qname;
+        this.value = value;
+        this.className = className;
+        this.eventService = eventService;
+    }
+
+    public QName getQName()
+    {
+        return qname;
+    }
+
+    public java.io.Serializable getRawValue()
+    {
+        return value;
+    }
+    
+    public java.io.Serializable getValue()
+    {        
+        if (value instanceof String)
+        {
+            ClassLoader cl = Thread.currentThread().getContextClassLoader();
+            try
+            {
+                Serializable object = eventService.deserialize(this);
+                return object;
+            }
+            catch (Exception e)
+            {
+                log.error(e);
+            }
+            finally
+            {
+                Thread.currentThread().setContextClassLoader(cl);
+            }
+        }
+        return value;
+    }
+
+    public String getName()
+    {
+        return qname.getLocalPart();
+    }
+
+    public void setProcessed(boolean processed)
+    {
+        this.processed = processed;
+    }
+    
+    public boolean isProcessed()
+    {
+        return processed;
+    }
+    
+    public PortletWindow getPortletWindow()
+    {
+        return this.window;
+    }
+    
+    public String getClassName()
+    {
+        return this.className;
+    }
+}

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/events/ProcessEventImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/portal/trunk/components/jetspeed-portal/src/main/java/org/apache/jetspeed/events/ProcessEventImpl.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PortletDefinitionImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PortletDefinitionImpl.java?rev=751848&r1=751847&r2=751848&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PortletDefinitionImpl.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-registry/src/main/java/org/apache/jetspeed/om/portlet/impl/PortletDefinitionImpl.java Mon Mar  9 21:28:50 2009
@@ -852,7 +852,7 @@
                 return ref;
             }
         }
-        EventDefinitionReferenceImpl edr = new ProcessingEventReferenceImpl(qname);
+        EventDefinitionReferenceImpl edr = new PublishingEventReferenceImpl(qname);
         supportedPublishingEvents.add(edr);
         return edr;
     }

Added: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/events/PortletEventQueue.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/events/PortletEventQueue.java?rev=751848&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/events/PortletEventQueue.java (added)
+++ portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/events/PortletEventQueue.java Mon Mar  9 21:28:50 2009
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.events;
+
+import java.util.List;
+
+import org.apache.pluto.PortletWindow;
+
+
+/**
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id$
+ */
+public interface PortletEventQueue
+{
+    void publishEvent(ProcessEvent event);
+    List<ProcessEvent> dequeueEvents(PortletWindow window);
+}
\ No newline at end of file

Propchange: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/events/PortletEventQueue.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/events/PortletEventQueue.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/events/ProcessEvent.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/events/ProcessEvent.java?rev=751848&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/events/ProcessEvent.java (added)
+++ portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/events/ProcessEvent.java Mon Mar  9 21:28:50 2009
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.events;
+
+import java.io.Serializable;
+
+import javax.portlet.Event;
+
+import org.apache.pluto.PortletWindow;
+
+/**
+ * ProcessEvent extends the Portlet API Event to give Jetspeed internals access to processing status as well other state information
+ * necessary to the internal implementation. 
+ * 
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id$ 
+ */
+public interface ProcessEvent extends Event
+{
+    /**
+     * Sets the current event status to processed. Should be called when the event is fully processed. 
+     * @param processed Use this boolean to set the processed flag to either true or false.
+     */
+    void setProcessed(boolean processed);
+    
+    /**
+     * Indicates whether an event has been processed by the portal, or is queued to be processed.
+     * @return The processed status of this event
+     */
+    boolean isProcessed();
+    
+    /**
+     * Retrieve the portlet window associated with this event.
+     * 
+     * @return The portlet window
+     */
+    PortletWindow getPortletWindow();
+    
+    /**
+     * Retrieve the class name of the serializable class that represents the Portlet Event.
+     * @return The class name of the event
+     */
+    public String getClassName();
+    
+    /**
+     * Retrieve the raw value of the event class instance. This is necessary to provide an alternative
+     * to kicking off the deserialziation process, if you just need the 'raw' value of the event
+     * @return the raw value of the event without deserializing the event
+     */
+    public Serializable getRawValue();
+    
+}

Propchange: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/events/ProcessEvent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/events/ProcessEvent.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/statistics/PortalStatistics.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/statistics/PortalStatistics.java?rev=751848&r1=751847&r2=751848&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/statistics/PortalStatistics.java (original)
+++ portals/jetspeed-2/portal/trunk/jetspeed-api/src/main/java/org/apache/jetspeed/statistics/PortalStatistics.java Mon Mar  9 21:28:50 2009
@@ -83,6 +83,10 @@
 
     public static final String HTTP_INTERNAL_ERROR = "500";
 
+    // Codes for logging actions and events
+    public static final String HTTP_ACTION = "900";
+    public static final String HTTP_EVENT = "901";
+    
     /**
      * Logs an access to a portlet.
      * 

Modified: portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/pluto-services.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/pluto-services.xml?rev=751848&r1=751847&r2=751848&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/pluto-services.xml (original)
+++ portals/jetspeed-2/portal/trunk/jetspeed-portal-resources/src/main/resources/assembly/pluto-services.xml Mon Mar  9 21:28:50 2009
@@ -74,7 +74,7 @@
 		<constructor-arg><ref bean="org.apache.pluto.services.PropertyManager"/></constructor-arg>
 		<constructor-arg><ref bean="org.apache.pluto.services.FilterManager"/></constructor-arg>
 		<constructor-arg><ref bean="org.apache.pluto.services.PortletURLListener"/></constructor-arg>
-		<constructor-arg><ref bean="org.apache.jetspeed.container.window.PortletWindowAccessor"/></constructor-arg>		
+		<constructor-arg><ref bean="org.apache.pluto.services.EventCoordinationService"/></constructor-arg>		
     </bean>
 
 
@@ -83,11 +83,25 @@
       <meta key="j2:cat" value="default" />		  
 	</bean>
 	
-	<bean id='org.apache.pluto.services.EventProvider'
-	      class='org.apache.jetspeed.container.providers.EventProviderImpl'>
-      <meta key="j2:cat" value="default" />
+	<bean id='org.apache.jetspeed.events.PortletEventQueue'
+	      class='org.apache.jetspeed.events.PortletEventQueueImpl'>
+      <meta key="j2:cat" value="default" />          
 	</bean>
-
+	
+	<bean id='org.apache.pluto.services.EventCoordinationService'
+		  class='org.apache.jetspeed.events.EventCoordinationServiceImpl'>
+        <meta key="j2:cat" value="default" />          		  
+		<constructor-arg><ref bean="org.apache.jetspeed.container.window.PortletWindowAccessor"/></constructor-arg>				  	
+		<constructor-arg><ref bean="org.apache.jetspeed.events.PortletEventQueue"/></constructor-arg>
+		<constructor-arg><ref bean="PortalStatistics"/></constructor-arg>
+	    <constructor-arg><ref bean="org.apache.jetspeed.aggregator.PortletTrackingManager"/></constructor-arg>
+	    <constructor-arg><ref bean="org.apache.jetspeed.security.SecurityAccessController" /></constructor-arg>
+	    <!-- flag indicating whether to check jetspeed-portlet.xml security constraints
+	      before rendering a portlet. If security check fails, do not fire events
+	    -->
+	    <constructor-arg type="boolean"><value>true</value></constructor-arg>					  	
+	</bean>
+	
 	<bean id='org.apache.pluto.services.FilterManager'
 	      class='org.apache.jetspeed.container.providers.FilterManagerImpl'>
       <meta key="j2:cat" value="default" />	      

Modified: portals/jetspeed-2/portal/trunk/pom.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/pom.xml?rev=751848&r1=751847&r2=751848&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/pom.xml (original)
+++ portals/jetspeed-2/portal/trunk/pom.xml Mon Mar  9 21:28:50 2009
@@ -299,8 +299,8 @@
     <javax.sql.version>2.0</javax.sql.version>
     <javax.transaction.version>1.0.1B</javax.transaction.version>
     <jaxen.version>1.0-FCS</jaxen.version>
-    <jaxb.version>2.1</jaxb.version>
-    <jaxb-impl.version>2.1.8</jaxb-impl.version>
+    <jaxb.version>2.1.10</jaxb.version>
+    <jaxb-impl.version>2.1.10</jaxb-impl.version>
     <jdom.version>1.0</jdom.version>
     <log4j.version>1.2.14</log4j.version>
     <lucene.version>2.0.0</lucene.version>



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message