Here's a patch that fixes the customizer velocity portlet problem.  It does
so by removing the PortletCustomizer marker interface, adding a "public
boolean providesCustomization()" to Portlet and the Portlet extensions, and
all else to make that work.

The usual answer for providesCustomization() is false; only
CustomizerVelocityPortlet sets it to true.

All places that were testing "instanceof PortletCustomizer" now test
".providesCustomization()".

This patch can be applied to the JetspeedTip independent of any other of my
patches.

Now - I will take a look at David's point about the wrapper and proxy, and
if it makes sense patch our portlet wrapper to allow the marker interfaces
to work in the future, but for now I've removed the one marker interface we
were using.

- Glenn
 
--------------------------------------------
Glenn R. Golden, Systems Research Programmer
University of Michigan School of Information
[EMAIL PROTECTED]               734-615-1419
http://www-personal.si.umich.edu/~ggolden/
--------------------------------------------



> -----Original Message-----
> From: David Sean Taylor [mailto:[EMAIL PROTECTED]] 
> Sent: Thursday, March 28, 2002 9:01 PM
> To: 'Jetspeed Developers List'
> Subject: RE: CustomizerVelocityPortlet broken
> 
> 
> IMO - the wrapper isn't correctly implemented.
> Java now has java.lang.reflect.Proxy to proxy interfaces.
> From the javadocs:
> 
> <quote>
> A proxy instance has the following properties: 
> 
> Given a proxy instance proxy and one of the interfaces 
> implemented by its proxy class Foo, the following expression 
> will return true: 
>      proxy instanceof Foo
>  and the following cast operation will succeed (rather than throwing a
> ClassCastException): 
>      (Foo) proxy
> </quote>
> 
> I haven't had a chance to review the wrapper code, Im deep in 
> some database shiite right now and won't have time for a few days.
> 
> Could you please figure out exactly what it does, and then either:
> 
> - rewrite it 
> - get rid of it
> 
> The approach you are taking, to search for all places where 
> we use 'instanceof' will patch the problem now, that is until 
> some one comes along and codes 'instanceof' again...
> 
> > -----Original Message-----
> > From: Glenn Golden [mailto:[EMAIL PROTECTED]]
> > Sent: Thursday, March 28, 2002 4:37 PM
> > To: 'Jetspeed Developers List'
> > Subject: RE: CustomizerVelocityPortlet broken
> > 
> > 
> > The problem is that there are two design patterns in use with
> > these wrapped portlets - the wrapping, and marker interfaces 
> > (such as, in our case, PortletCustomizer).
> > 
> > These appear to be in conflict - you can't see the marker
> > interfaces that a class implements if it's wrapped.  The 
> > wrapper surfaces the wrapped class's API, but testing 
> > "instanceof" is not made explicit in the API, so it not 
> > surfaced by the wrapping.
> > 
> > I'll replace our use of PortletCustomizer marker interface
> > with some new method of the Portlet API, something like 
> > 'public boolean isOwnCustomizer()" -I'm having trouble 
> > getting a good name.
> > 
> > I'll search for other instanceof PortletCustomizer" code and
> > fix them all.
> > 
> > Do we use other marker interfaces that we should likewise fix?
> > 
> > I'll have a patch tonight or tomorrow for this.
> > 
> > - Glenn
> >  
> > --------------------------------------------
> > Glenn R. Golden, Systems Research Programmer
> > University of Michigan School of Information
> > [EMAIL PROTECTED]               734-615-1419
> > http://www-personal.si.umich.edu/~ggolden/
> > --------------------------------------------
> > 
> > 
> > 
> > > -----Original Message-----
> > > From: David Sean Taylor [mailto:[EMAIL PROTECTED]]
> > > Sent: Thursday, March 28, 2002 5:17 PM
> > > To: 'Jetspeed Developers List'
> > > Subject: RE: CustomizerVelocityPortlet broken
> > > 
> > > 
> > > Ah, my suspicions were correct.
> > > The portlet customizer was working fine up until about 
> the same time 
> > > that the wrapper stuff was committed.
> > > 
> > > > Is this CacheableStatefulPortletWrapper thing new?  It
> > looks like we
> > > > need to be able to "dig in" to this, as well as into the
> > control, to
> > > > find the real portlet hiding inside.
> > > 
> > > Its new. It should always delegate to its wrapped portlet. Its an 
> > > interceptor, meant to put 'declarative' security constraints into 
> > > portlet access.
> > > 
> > > Sounds like youre on to it -- keep digging! ;)
> > > 
> > > > -----Original Message-----
> > > > From: Glenn Golden [mailto:[EMAIL PROTECTED]]
> > > > Sent: Thursday, March 28, 2002 1:15 PM
> > > > To: Jetspeed-Dev ([EMAIL PROTECTED])
> > > > Subject: CustomizerVelocityPortlet broken
> > > > 
> > > > 
> > > > I'm fixing the bug that a CustomizerVelocityPortlet's custom
> > > > customizer is no longer being called when the user 
> customizes the 
> > > > portlet; instead the standard portlet customizer is used.
> > > > 
> > > > I've tracked this down to the JetspeedTool's
> > getCustomizer() call.
> > > > It's passed a "Portlet" which is a
> > VelocityPortletControl, and digs
> > > > in with
> > > > p.getPortlet() to get the portlet within.  The portlet is a 
> > > > CacheableStatefulPortletWrapper.
> > > > 
> > > > "If (p instanceof PortletCustomizer)" - well this thing 
> is NOT an
> > > > instance of PortletCustomizer.
> > > > 
> > > > Looking inside this CacheableStatefulPortletWrapper, I see a
> > > > wrappedPortlet, which is a CustomizerVelocityPortlet...
> > > > 
> > > > Is this CacheableStatefulPortletWrapper thing new?  It
> > looks like we
> > > > need to be able to "dig in" to this, as well as into the
> > control, to
> > > > find the real portlet hiding inside.
> > > > 
> > > > I'll keep looking, but if bells are ringing in anyone's heads so
> > > > far, please post info for me!
> > > > 
> > > > Thanks.
> > > > 
> > > > - Glenn
> > > >  
> > > > --------------------------------------------
> > > > Glenn R. Golden, Systems Research Programmer
> > > > University of Michigan School of Information
> > > > [EMAIL PROTECTED]               734-615-1419
> > > > http://www-personal.si.umich.edu/~ggolden/
> > > > --------------------------------------------
> > > > 
> > > > 
> > > > --
> > > > To unsubscribe, e-mail:   
> > > > <mailto:jetspeed-dev-> [EMAIL PROTECTED]> For
> > > > additional commands,
> > > > e-mail: <mailto:[EMAIL PROTECTED]>
> > > > 
> > > > 
> > > 
> > > 
> > > 
> > > --
> > > To unsubscribe, e-mail:   
> > > <mailto:jetspeed-dev-> [EMAIL PROTECTED]>
> > > For
> > > additional commands,
> > > e-mail: <mailto:[EMAIL PROTECTED]>
> > > 
> > 
> > --
> > To unsubscribe, e-mail:   
> > <mailto:jetspeed-dev-> [EMAIL PROTECTED]>
> > For
> > additional commands, 
> > e-mail: <mailto:[EMAIL PROTECTED]>
> > 
> > 
> 
> 
> 
> --
> To unsubscribe, e-mail:   
> <mailto:jetspeed-dev-> [EMAIL PROTECTED]>
> For 
> additional commands, 
> e-mail: <mailto:[EMAIL PROTECTED]>
> 

Index: src/java/org/apache/jetspeed/portal/BasePortletSet.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/BasePortletSet.java,v
retrieving revision 1.17
diff -u -r1.17 BasePortletSet.java
--- src/java/org/apache/jetspeed/portal/BasePortletSet.java     11 Mar 2002 07:22:11 
-0000      1.17
+++ src/java/org/apache/jetspeed/portal/BasePortletSet.java     29 Mar 2002 01:24:13 
+-0000
@@ -644,4 +644,8 @@
         this.id = id;
     }
 
+    /**
+    * @return true if the portlet does its own customization
+    */
+    public boolean providesCustomization() { return false; }
 }
Index: src/java/org/apache/jetspeed/portal/Portlet.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/Portlet.java,v
retrieving revision 1.42
diff -u -r1.42 Portlet.java
--- src/java/org/apache/jetspeed/portal/Portlet.java    6 Mar 2002 17:03:33 -0000      
 1.42
+++ src/java/org/apache/jetspeed/portal/Portlet.java    29 Mar 2002 01:24:13 -0000
@@ -207,5 +207,10 @@
     public String getID();
 
     public void setID(String id);
+
+    /**
+    * @return true if the portlet does its own customization
+    */
+    public boolean providesCustomization();
 }
 
Index: src/java/org/apache/jetspeed/portal/PortletCustomizer.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/PortletCustomizer.java,v
retrieving revision 1.2
diff -u -r1.2 PortletCustomizer.java
--- src/java/org/apache/jetspeed/portal/PortletCustomizer.java  22 Jul 2001 20:29:59 
-0000      1.2
+++ src/java/org/apache/jetspeed/portal/PortletCustomizer.java  29 Mar 2002 01:24:13 
+-0000
@@ -62,6 +62,8 @@
  * the customizer for a given portlet
  *
  * @author <a href="mailto:[EMAIL PROTECTED]";>Rapha�l Luta</a>
+ * @deprecated provide providesCustomization() from Portlet.java insted
+ * to indicate that a portlet can do its own customization.
  */
 public interface PortletCustomizer
 {
Index: src/java/org/apache/jetspeed/portal/controls/VelocityPortletControl.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/controls/VelocityPortletControl.java,v
retrieving revision 1.13
diff -u -r1.13 VelocityPortletControl.java
--- src/java/org/apache/jetspeed/portal/controls/VelocityPortletControl.java    13 Mar 
2002 05:41:15 -0000      1.13
+++ src/java/org/apache/jetspeed/portal/controls/VelocityPortletControl.java    29 Mar 
+2002 01:24:14 -0000
@@ -66,7 +66,6 @@
 import org.apache.jetspeed.portal.PortletSet;
 import org.apache.jetspeed.portal.PortletControl;
 import org.apache.jetspeed.portal.PortletState;
-import org.apache.jetspeed.portal.PortletCustomizer;
 import org.apache.jetspeed.services.TemplateLocator;
 import org.apache.jetspeed.services.PortletFactory;
 import org.apache.jetspeed.services.resources.JetspeedResources;
@@ -139,7 +138,7 @@
         TurbinePull.populateContext(context, rundata);
 
         if ( portlet.getName().equals(jdata.getCustomized())
-             && (!(portlet instanceof PortletCustomizer)) )
+             && (!portlet.providesCustomization()) )
         {            
             context.put("portlet",JetspeedTool.getCustomizer(portlet));
         }
Index: src/java/org/apache/jetspeed/portal/portlets/AbstractPortlet.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/AbstractPortlet.java,v
retrieving revision 1.54
diff -u -r1.54 AbstractPortlet.java
--- src/java/org/apache/jetspeed/portal/portlets/AbstractPortlet.java   26 Mar 2002 
09:06:54 -0000      1.54
+++ src/java/org/apache/jetspeed/portal/portlets/AbstractPortlet.java   29 Mar 2002 
+01:24:14 -0000
@@ -811,4 +811,8 @@
         this.id = id;
     }
 
+    /**
+    * @return true if the portlet does its own customization
+    */
+    public boolean providesCustomization() { return false; }
 }
Index: src/java/org/apache/jetspeed/portal/portlets/CustomizerVelocityPortlet.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/CustomizerVelocityPortlet.java,v
retrieving revision 1.1
diff -u -r1.1 CustomizerVelocityPortlet.java
--- src/java/org/apache/jetspeed/portal/portlets/CustomizerVelocityPortlet.java 31 May 
2001 17:13:26 -0000      1.1
+++ src/java/org/apache/jetspeed/portal/portlets/CustomizerVelocityPortlet.java 29 Mar 
+2002 01:24:14 -0000
@@ -54,9 +54,6 @@
 
 package org.apache.jetspeed.portal.portlets;
 
-// Jetspeed stuff
-import org.apache.jetspeed.portal.PortletCustomizer;
-
 /**
  * This subclass of VelocityPortlet should be used as base portlet
  * for all VelocityPortlets that implement their own customizer
@@ -64,9 +61,10 @@
  * @author <a href="mailto:[EMAIL PROTECTED]";>Rapha�l Luta</a>
  */
 public class CustomizerVelocityPortlet extends VelocityPortlet
-    implements PortletCustomizer
-
 {
-    // nothing to do
+    /**
+    * @return true if the portlet does its own customization
+    */
+    public boolean providesCustomization() { return true; }
 }
 
Index: src/java/org/apache/jetspeed/portal/security/portlets/PortletWrapper.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/security/portlets/PortletWrapper.java,v
retrieving revision 1.3
diff -u -r1.3 PortletWrapper.java
--- src/java/org/apache/jetspeed/portal/security/portlets/PortletWrapper.java   6 Mar 
2002 17:03:34 -0000       1.3
+++ src/java/org/apache/jetspeed/portal/security/portlets/PortletWrapper.java   29 Mar 
+2002 01:24:15 -0000
@@ -351,5 +351,12 @@
     {
         wrappedPortlet.setID(id);
     }
-   
+
+    /**
+    * @return true if the portlet does its own customization
+    */
+    public boolean providesCustomization()
+    {
+        return wrappedPortlet.providesCustomization();
+    }
 }
Index: src/java/org/apache/jetspeed/util/template/JetspeedTool.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-jetspeed/src/java/org/apache/jetspeed/util/template/JetspeedTool.java,v
retrieving revision 1.16
diff -u -r1.16 JetspeedTool.java
--- src/java/org/apache/jetspeed/util/template/JetspeedTool.java        22 Mar 2002 
18:51:57 -0000      1.16
+++ src/java/org/apache/jetspeed/util/template/JetspeedTool.java        29 Mar 2002 
+01:24:18 -0000
@@ -62,7 +62,6 @@
 import org.apache.jetspeed.portal.Portlet;
 import org.apache.jetspeed.portal.PortletSet;
 import org.apache.jetspeed.portal.PortletControl;
-import org.apache.jetspeed.portal.PortletCustomizer;
 import org.apache.jetspeed.services.PortalToolkit;
 import org.apache.jetspeed.services.PsmlManager;
 import org.apache.jetspeed.services.PortletFactory;
@@ -269,7 +268,7 @@
         }
         
         // if the portlet cannot customize itself...
-        if (! (p instanceof PortletCustomizer) )
+        if ( !p.providesCustomization() )
         {
 
             //look for the customizer name in the portlet

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to