portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From woon...@apache.org
Subject svn commit: r771941 - in /portals/jetspeed-2/applications/j2-admin/trunk/src: main/java/org/apache/jetspeed/portlets/wicket/ webapp/WEB-INF/
Date Tue, 05 May 2009 17:44:46 GMT
Author: woonsan
Date: Tue May  5 17:44:44 2009
New Revision: 771941

URL: http://svn.apache.org/viewvc?rev=771941&view=rev
Log:
Allow *JetspeedPrincipalManagementPortlet* in j2-admin to access portal context class loader
because the portlet is dependent on serializable/deserializable objects which can be created
by jetspeed classloader only.
I think this is definitely not good practice, but anyway Wicketfilter allows to customize
the classloader. ;-)
We need to replace all the models by detachable ones later.

Added:
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/JetspeedContextAwareWicketFilter.java
  (with props)
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/MockPortletApplication.java
  (with props)
Modified:
    portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/web.xml

Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/JetspeedContextAwareWicketFilter.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/JetspeedContextAwareWicketFilter.java?rev=771941&view=auto
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/JetspeedContextAwareWicketFilter.java
(added)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/JetspeedContextAwareWicketFilter.java
Tue May  5 17:44:44 2009
@@ -0,0 +1,96 @@
+/*
+ * 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.portlets.wicket;
+
+import org.apache.jetspeed.Jetspeed;
+import org.apache.jetspeed.factory.PortletFactory;
+import org.apache.wicket.protocol.http.WicketFilter;
+
+/**
+ * A special wicket filter to allow access portal context class loader.
+ * <P>
+ * <EM>NOTE: Don't use this filter outside j2-admin and it is not really desirable
to use this filter.</EM>
+ * Instead of using this filter, please make your models detachable!
+ * </P>
+ * 
+ * @version $Id$
+ */
+public class JetspeedContextAwareWicketFilter extends WicketFilter
+{
+    
+    private JetspeedContextAwareClassLoader jetspeedContextAwareClassLoader;
+    
+    public JetspeedContextAwareWicketFilter()
+    {
+        super();
+    }
+    
+    @Override
+    protected ClassLoader getClassLoader()
+    {
+        if (jetspeedContextAwareClassLoader == null)
+        {
+            try
+            {
+                ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
+                PortletFactory portletFactory = (PortletFactory) Jetspeed.getComponentManager().getComponent("portletFactory");
+                MockPortletApplication layoutApp = new MockPortletApplication();
+                layoutApp.setName("jetspeed-layouts");
+                ClassLoader jetspeedContextClassLoader = portletFactory.getPortletApplicationClassLoader(layoutApp);
+                jetspeedContextAwareClassLoader = new JetspeedContextAwareClassLoader(contextClassLoader,
jetspeedContextClassLoader);
+            }
+            catch (Exception e)
+            {
+                e.printStackTrace();
+            }
+        }
+        
+        return jetspeedContextAwareClassLoader;
+    }
+
+    private class JetspeedContextAwareClassLoader extends ClassLoader
+    {
+        private ClassLoader parent;
+        private ClassLoader altParent;
+        
+        public JetspeedContextAwareClassLoader(ClassLoader parent, ClassLoader altParent)
+        {
+            super(parent);
+            this.altParent = altParent;
+        }
+        
+        protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException

+        {
+            Class<?> result = null;
+            
+            try
+            {
+                result = super.loadClass(name, resolve);
+            }
+            catch (ClassNotFoundException cnfe)
+            {
+                if (altParent != null)
+                {
+                    result = altParent.loadClass(name);
+                }
+            }
+            
+            return result;
+        }
+
+    }
+}

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/JetspeedContextAwareWicketFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/JetspeedContextAwareWicketFilter.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/JetspeedContextAwareWicketFilter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/MockPortletApplication.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/MockPortletApplication.java?rev=771941&view=auto
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/MockPortletApplication.java
(added)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/MockPortletApplication.java
Tue May  5 17:44:44 2009
@@ -0,0 +1,497 @@
+/*
+ * 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.portlets.wicket;
+
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.portlet.PortletMode;
+import javax.portlet.WindowState;
+import javax.xml.namespace.QName;
+
+import org.apache.jetspeed.om.portlet.ContainerRuntimeOption;
+import org.apache.jetspeed.om.portlet.CustomPortletMode;
+import org.apache.jetspeed.om.portlet.CustomWindowState;
+import org.apache.jetspeed.om.portlet.Description;
+import org.apache.jetspeed.om.portlet.DisplayName;
+import org.apache.jetspeed.om.portlet.EventDefinition;
+import org.apache.jetspeed.om.portlet.Filter;
+import org.apache.jetspeed.om.portlet.FilterMapping;
+import org.apache.jetspeed.om.portlet.GenericMetadata;
+import org.apache.jetspeed.om.portlet.JetspeedServiceReference;
+import org.apache.jetspeed.om.portlet.Listener;
+import org.apache.jetspeed.om.portlet.PortletApplication;
+import org.apache.jetspeed.om.portlet.PortletDefinition;
+import org.apache.jetspeed.om.portlet.PublicRenderParameter;
+import org.apache.jetspeed.om.portlet.SecurityConstraint;
+import org.apache.jetspeed.om.portlet.SecurityRole;
+import org.apache.jetspeed.om.portlet.UserAttribute;
+import org.apache.jetspeed.om.portlet.UserAttributeRef;
+
+public class MockPortletApplication implements PortletApplication
+{
+    private String name;
+
+    public ContainerRuntimeOption addContainerRuntimeOption(String name)
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public CustomPortletMode addCustomPortletMode(String name)
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public CustomWindowState addCustomWindowState(String name)
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public Description addDescription(String lang)
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public DisplayName addDisplayName(String lang)
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public EventDefinition addEventDefinition(String name)
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public EventDefinition addEventDefinition(QName qname)
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public Filter addFilter(String filterName)
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public FilterMapping addFilterMapping(String filterName)
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public void addJetspeedServiceReference(String name)
+    {
+        // TODO Auto-generated method stub
+        
+    }
+
+    public Listener addListener(String listenerClass)
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public PortletDefinition addPortlet(String name)
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public PublicRenderParameter addPublicRenderParameter(String name, String identifier)
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public PublicRenderParameter addPublicRenderParameter(QName qname, String identifier)
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public SecurityConstraint addSecurityConstraint(String transportGuarantee)
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public SecurityRole addSecurityRole(String name)
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public UserAttribute addUserAttribute(String name)
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public UserAttributeRef addUserAttributeRef(String name)
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public int getApplicationType()
+    {
+        // TODO Auto-generated method stub
+        return 0;
+    }
+
+    public long getChecksum()
+    {
+        // TODO Auto-generated method stub
+        return 0;
+    }
+
+    public ContainerRuntimeOption getContainerRuntimeOption(String name)
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public List<ContainerRuntimeOption> getContainerRuntimeOptions()
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public CustomPortletMode getCustomPortletMode(String name)
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public PortletMode getCustomPortletMode(PortletMode mode)
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public List<CustomPortletMode> getCustomPortletModes()
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public CustomWindowState getCustomWindowState(String name)
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public WindowState getCustomWindowState(WindowState state)
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public List<CustomWindowState> getCustomWindowStates()
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public Description getDescription(Locale locale)
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public List<Description> getDescriptions()
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public DisplayName getDisplayName(Locale locale)
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public List<DisplayName> getDisplayNames()
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public List<EventDefinition> getEventDefinitions()
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public Filter getFilter(String filterName)
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public FilterMapping getFilterMapping(String filterName)
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public List<FilterMapping> getFilterMappings()
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public List<Filter> getFilters()
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public String getJetspeedSecurityConstraint()
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public List<JetspeedServiceReference> getJetspeedServices()
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public List<Listener> getListeners()
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public String getLocalContextPath()
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public PortletMode getMappedPortletMode(PortletMode mode)
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public WindowState getMappedWindowState(WindowState state)
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public GenericMetadata getMetadata()
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public PortletDefinition getPortlet(String name)
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public List<PortletDefinition> getPortlets()
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public PublicRenderParameter getPublicRenderParameter(String identifier)
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public List<PublicRenderParameter> getPublicRenderParameters()
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public long getRevision()
+    {
+        // TODO Auto-generated method stub
+        return 0;
+    }
+
+    public List<SecurityConstraint> getSecurityConstraints()
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public List<SecurityRole> getSecurityRoles()
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public List<PortletMode> getSupportedPortletModes()
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public List<WindowState> getSupportedWindowStates()
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public UserAttribute getUserAttribute(String name)
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public UserAttributeRef getUserAttributeRef(String name)
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public List<UserAttributeRef> getUserAttributeRefs()
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public List<UserAttribute> getUserAttributes()
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public boolean isLayoutApplication()
+    {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    public void setApplicationType(int type)
+    {
+        // TODO Auto-generated method stub
+        
+    }
+
+    public void setChecksum(long checksum)
+    {
+        // TODO Auto-generated method stub
+        
+    }
+
+    public void setJetspeedSecurityConstraint(String constraint)
+    {
+        // TODO Auto-generated method stub
+        
+    }
+
+    public void setLocalContextPath(String localContextPath)
+    {
+        // TODO Auto-generated method stub
+        
+    }
+
+    public void setRevision(long revision)
+    {
+        // TODO Auto-generated method stub
+        
+    }
+
+    public void addLocaleEncodingMapping(Locale locale, String encoding)
+    {
+        // TODO Auto-generated method stub
+        
+    }
+
+    public String getContextPath()
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public String getDefaultNamespace()
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public Map<Locale, String> getLocaleEncodingMappings()
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public String getName()
+    {
+        return this.name;
+    }
+
+    public String getResourceBundle()
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public String getVersion()
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public void setContextPath(String contextPath)
+    {
+        // TODO Auto-generated method stub
+        
+    }
+
+    public void setDefaultNamespace(String defaultNamespace)
+    {
+        // TODO Auto-generated method stub
+        
+    }
+
+    public void setName(String name)
+    {
+        this.name = name;
+    }
+
+    public void setResourceBundle(String resourceBundle)
+    {
+        // TODO Auto-generated method stub
+        
+    }
+
+    public void setVersion(String version)
+    {
+        // TODO Auto-generated method stub
+        
+    }
+}

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/MockPortletApplication.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/MockPortletApplication.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/wicket/MockPortletApplication.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/web.xml?rev=771941&r1=771940&r2=771941&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/web.xml (original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/webapp/WEB-INF/web.xml Tue May  5 17:44:44
2009
@@ -43,7 +43,7 @@
     
     <filter>
       <filter-name>JetspeedPrincipalManagementPortlet</filter-name>
-      <filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
+      <filter-class>org.apache.jetspeed.portlets.wicket.JetspeedContextAwareWicketFilter</filter-class>
       <init-param>
         <param-name>applicationClassName</param-name>
         <param-value>org.apache.jetspeed.portlets.security.JetspeedPrincipalManagementApplication</param-value>



---------------------------------------------------------------------
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