incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r782554 - in /incubator/sling/whiteboard/portal/container/src/main/java/org/apache/sling/portal/container/internal: EventImpl.java EventProviderImpl.java request/LinkTransformerFactory.java
Date Mon, 08 Jun 2009 08:06:07 GMT
Author: cziegeler
Date: Mon Jun  8 08:06:07 2009
New Revision: 782554

URL: http://svn.apache.org/viewvc?rev=782554&view=rev
Log:
Update to new rewriter.

Modified:
    incubator/sling/whiteboard/portal/container/src/main/java/org/apache/sling/portal/container/internal/EventImpl.java
    incubator/sling/whiteboard/portal/container/src/main/java/org/apache/sling/portal/container/internal/EventProviderImpl.java
    incubator/sling/whiteboard/portal/container/src/main/java/org/apache/sling/portal/container/internal/request/LinkTransformerFactory.java

Modified: incubator/sling/whiteboard/portal/container/src/main/java/org/apache/sling/portal/container/internal/EventImpl.java
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/portal/container/src/main/java/org/apache/sling/portal/container/internal/EventImpl.java?rev=782554&r1=782553&r2=782554&view=diff
==============================================================================
--- incubator/sling/whiteboard/portal/container/src/main/java/org/apache/sling/portal/container/internal/EventImpl.java
(original)
+++ incubator/sling/whiteboard/portal/container/src/main/java/org/apache/sling/portal/container/internal/EventImpl.java
Mon Jun  8 08:06:07 2009
@@ -16,37 +16,46 @@
  */
 package org.apache.sling.portal.container.internal;
 
+import java.io.Serializable;
+
 import javax.portlet.Event;
 import javax.xml.namespace.QName;
 
 /**
- * Implementation of JSR-286 <code>Event</code>.
- *
- * @since 2.0
+ * Implementation of the event.
  */
 public class EventImpl implements Event {
 
-	private QName _qname;
-	private java.io.Serializable _value;
-	
+	private final QName qname;
+	private final Serializable value;
+
 	public EventImpl(QName qname){
-		_qname = qname;
+        this(qname, null);
 	}
-	
+
 	public EventImpl(QName qname, java.io.Serializable value){
-		this(qname);
-		_value = value;
+        this.qname = qname;
+		this.value = value;
 	}
 
+	/**
+	 * @see javax.portlet.Event#getQName()
+	 */
 	public QName getQName() {
-		return _qname;
+		return qname;
 	}
 
-	public java.io.Serializable getValue() {
-		return _value;
+	/**
+	 * @see javax.portlet.Event#getValue()
+	 */
+	public Serializable getValue() {
+		return value;
 	}
 
+	/**
+	 * @see javax.portlet.Event#getName()
+	 */
 	public String getName() {
-		return _qname.getLocalPart();
+		return qname.getLocalPart();
 	}
 }

Modified: incubator/sling/whiteboard/portal/container/src/main/java/org/apache/sling/portal/container/internal/EventProviderImpl.java
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/portal/container/src/main/java/org/apache/sling/portal/container/internal/EventProviderImpl.java?rev=782554&r1=782553&r2=782554&view=diff
==============================================================================
--- incubator/sling/whiteboard/portal/container/src/main/java/org/apache/sling/portal/container/internal/EventProviderImpl.java
(original)
+++ incubator/sling/whiteboard/portal/container/src/main/java/org/apache/sling/portal/container/internal/EventProviderImpl.java
Mon Jun  8 08:06:07 2009
@@ -17,84 +17,39 @@
 package org.apache.sling.portal.container.internal;
 
 import java.io.Serializable;
-import java.io.StringWriter;
-import java.io.Writer;
 import java.util.List;
 
 import javax.portlet.Event;
-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.pluto.container.EventProvider;
 import org.apache.pluto.container.PortletWindow;
 import org.apache.pluto.container.om.portlet.EventDefinition;
 import org.apache.pluto.container.om.portlet.EventDefinitionReference;
 import org.apache.pluto.container.om.portlet.PortletApplicationDefinition;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 public class EventProviderImpl implements EventProvider {
 
-    private final Logger LOGGER = LoggerFactory.getLogger(this.getClass().getName());
-
     private PortletWindow portletWindow;
 
     public EventProviderImpl(PortletWindow portletWindow) {
         this.portletWindow = portletWindow;
     }
 
-    @SuppressWarnings("unchecked")
-    public Event createEvent(QName qname, Serializable value) throws IllegalArgumentException
-    {
-        if (isDeclaredAsPublishingEvent(qname))
-        {
-            if (value != null && !isValueInstanceOfDefinedClass(qname, value))
-            {
+    /**
+     * @see org.apache.pluto.container.EventProvider#createEvent(javax.xml.namespace.QName,
java.io.Serializable)
+     */
+    public Event createEvent(QName qname, Serializable value) throws IllegalArgumentException
{
+        if (isDeclaredAsPublishingEvent(qname)) {
+            if (value != null && !isValueInstanceOfDefinedClass(qname, value)) {
                 throw new IllegalArgumentException("Payload has not the right class");
             }
-            try
-            {
-                if (value == null)
-                {
-                    return new EventImpl(qname, value);
-                }
-                ClassLoader cl = Thread.currentThread().getContextClassLoader();
-                Writer out = new StringWriter();
-                Class clazz = value.getClass();
-                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);
-                }
-                finally
-                {
-                    Thread.currentThread().setContextClassLoader(cl);
-                }
-                return new EventImpl(qname, out.toString());
-            }
-            catch (JAXBException e)
-            {
-                // maybe there is no valid jaxb binding
-                // TODO wsrp:eventHandlingFailed
-                LOGGER.error("Event handling failed", e);
-            }
-            catch (FactoryConfigurationError e)
-            {
-                LOGGER.warn("Configuration error.", e);
-            }
+            return new EventImpl(qname, value);
         }
         return null;
     }
 
-    private boolean isDeclaredAsPublishingEvent(QName qname)
-    {
+    private boolean isDeclaredAsPublishingEvent(QName qname) {
         final List<? extends EventDefinitionReference> events = portletWindow.getPortletDefinition().getSupportedPublishingEvents();
         if (events != null)
         {
@@ -116,8 +71,7 @@
         return false;
     }
 
-    private boolean isValueInstanceOfDefinedClass(QName qname, Serializable value)
-    {
+    private boolean isValueInstanceOfDefinedClass(QName qname, Serializable value) {
         PortletApplicationDefinition app = portletWindow.getPortletDefinition().getApplication();
         List<? extends EventDefinition> events = app.getEventDefinitions();
         if (events != null)

Modified: incubator/sling/whiteboard/portal/container/src/main/java/org/apache/sling/portal/container/internal/request/LinkTransformerFactory.java
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/portal/container/src/main/java/org/apache/sling/portal/container/internal/request/LinkTransformerFactory.java?rev=782554&r1=782553&r2=782554&view=diff
==============================================================================
--- incubator/sling/whiteboard/portal/container/src/main/java/org/apache/sling/portal/container/internal/request/LinkTransformerFactory.java
(original)
+++ incubator/sling/whiteboard/portal/container/src/main/java/org/apache/sling/portal/container/internal/request/LinkTransformerFactory.java
Mon Jun  8 08:06:07 2009
@@ -27,8 +27,8 @@
 import org.apache.sling.portal.container.internal.impl.DefaultPortalURLFactory;
 import org.apache.sling.rewriter.ProcessingComponentConfiguration;
 import org.apache.sling.rewriter.ProcessingContext;
-import org.apache.sling.rewriter.RewriterTransformerFactory;
 import org.apache.sling.rewriter.Transformer;
+import org.apache.sling.rewriter.TransformerFactory;
 import org.xml.sax.Attributes;
 import org.xml.sax.ContentHandler;
 import org.xml.sax.SAXException;
@@ -40,14 +40,15 @@
  * In addition it splits up an action url into the path and
  * hidden parameters.
  *
- * @scr.component
+ * @scr.component metatype="no"
  * @scr.service
+ * @scr.property name="pipeline.mode" value="global"
  * @scr.property name="service.ranking" value="999"
  */
-public class LinkTransformerFactory implements RewriterTransformerFactory {
+public class LinkTransformerFactory implements TransformerFactory {
 
     /**
-     * @see org.apache.sling.rewriter.RewriterTransformerFactory#createTransformer()
+     * @see org.apache.sling.rewriter.TransformerFactory#createTransformer()
      */
     public Transformer createTransformer() {
         return new LinkTransformer();



Mime
View raw message