portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wea...@apache.org
Subject cvs commit: jakarta-jetspeed-2/jetspeed-api/src/java/org/apache/jetspeed/factory PortletFactory.java
Date Thu, 27 Jan 2005 21:27:53 GMT
weaver      2005/01/27 13:27:52

  Modified:    portal/src/java/org/apache/jetspeed/request
                        JetspeedRequestContext.java
                        JetspeedRequestContextComponent.java
               portal/src/webapp/WEB-INF/assembly jetspeed-spring.xml
               portal/src/test/org/apache/jetspeed/container/state
                        TestNavigationalState.java
               components/registry/src/java/org/apache/jetspeed/om/impl
                        LanguageSetImpl.java
               components/portlet-factory/src/java/org/apache/jetspeed/factory
                        JetspeedPortletFactory.java
               jetspeed-api/src/java/org/apache/jetspeed/factory
                        PortletFactory.java
  Log:
  Fix for http://issues.apache.org/jira/browse/JS2-202
  
  Revision  Changes    Path
  1.37      +6 -1      jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/request/JetspeedRequestContext.java
  
  Index: JetspeedRequestContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/request/JetspeedRequestContext.java,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- JetspeedRequestContext.java	4 Jan 2005 16:19:42 -0000	1.36
  +++ JetspeedRequestContext.java	27 Jan 2005 21:27:51 -0000	1.37
  @@ -36,6 +36,7 @@
   import org.apache.jetspeed.container.url.PortalURL;
   import org.apache.jetspeed.engine.servlet.ServletRequestFactory;
   import org.apache.jetspeed.engine.servlet.ServletResponseFactory;
  +import org.apache.jetspeed.factory.PortletFactory;
   import org.apache.jetspeed.om.common.MutableLanguage;
   import org.apache.jetspeed.om.impl.LanguageImpl;
   import org.apache.jetspeed.om.page.Fragment;
  @@ -46,6 +47,7 @@
   import org.apache.pluto.om.common.LanguageSet;
   import org.apache.pluto.om.common.ObjectID;
   import org.apache.pluto.om.portlet.PortletDefinition;
  +import org.apache.pluto.om.portlet.PortletDefinitionCtrl;
   import org.apache.pluto.om.window.PortletWindow;
   
   /**
  @@ -84,6 +86,7 @@
       private Fragment rootFragment;
       private Map fragments;
       private JetspeedPowerTool jpt;
  +    private PortletFactory portletFactory;
   
       /**
        * Create a new Request Context
  @@ -94,7 +97,7 @@
        * @param config
        */
       public JetspeedRequestContext( HttpServletRequest request, HttpServletResponse response,
ServletConfig config,
  -            UserInfoManager userInfoMgr )
  +            UserInfoManager userInfoMgr, PortletFactory portletFactory )
       {
           this.request = request;
           this.response = response;
  @@ -103,6 +106,7 @@
           this.requestsForWindows = new HashMap();
           this.responsesForWindows = new HashMap();
           this.fragments = new LinkedHashMap();
  +        this.portletFactory = portletFactory;
   
           // set context in Request for later use
           if (null != this.request)
  @@ -490,6 +494,7 @@
           // {
           //     return language;
           // }
  +        ((PortletDefinitionCtrl) portlet).setPortletClassLoader(portletFactory.getPortletClassLoader(portlet));
           LanguageSet languageSet = portlet.getLanguageSet();
           Language language = languageSet.get(locale);
   
  
  
  
  1.10      +8 -4      jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/request/JetspeedRequestContextComponent.java
  
  Index: JetspeedRequestContextComponent.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/request/JetspeedRequestContextComponent.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- JetspeedRequestContextComponent.java	4 Jan 2005 16:20:52 -0000	1.9
  +++ JetspeedRequestContextComponent.java	27 Jan 2005 21:27:52 -0000	1.10
  @@ -25,6 +25,7 @@
   import org.apache.commons.logging.LogFactory;
   
   import org.apache.jetspeed.PortalReservedParameters;
  +import org.apache.jetspeed.factory.PortletFactory;
   import org.apache.jetspeed.userinfo.UserInfoManager;
   
   /**
  @@ -42,16 +43,18 @@
       private ThreadLocal tlRequestContext = new ThreadLocal();
   
       private final static Log log = LogFactory.getLog(JetspeedRequestContextComponent.class);
  +    private PortletFactory portletFactory;
   
       public JetspeedRequestContextComponent(String contextClassName)
       {
       }
   
       public JetspeedRequestContextComponent(String contextClassName, 
  -                                           UserInfoManager userInfoMgr)
  +                                           UserInfoManager userInfoMgr, PortletFactory
portletFactory)
       {
           this.contextClassName = contextClassName;
           this.userInfoMgr = userInfoMgr;
  +        this.portletFactory = portletFactory;
       }
   
       public RequestContext create(HttpServletRequest req, HttpServletResponse resp, ServletConfig
config)
  @@ -72,8 +75,9 @@
                           HttpServletRequest.class,
                           HttpServletResponse.class,
                           ServletConfig.class,
  -                        UserInfoManager.class });
  -            context = (RequestContext) constructor.newInstance(new Object[] { req, resp,
config, userInfoMgr });
  +                        UserInfoManager.class,
  +                        PortletFactory.class});
  +            context = (RequestContext) constructor.newInstance(new Object[] { req, resp,
config, userInfoMgr, portletFactory });
   
           }
           catch (Exception e)
  
  
  
  1.40      +2 -1      jakarta-jetspeed-2/portal/src/webapp/WEB-INF/assembly/jetspeed-spring.xml
  
  Index: jetspeed-spring.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/webapp/WEB-INF/assembly/jetspeed-spring.xml,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- jetspeed-spring.xml	19 Jan 2005 03:26:02 -0000	1.39
  +++ jetspeed-spring.xml	27 Jan 2005 21:27:52 -0000	1.40
  @@ -585,7 +585,8 @@
     	   class="org.apache.jetspeed.request.JetspeedRequestContextComponent"
     >  	   
     	   <constructor-arg ><value>org.apache.jetspeed.request.JetspeedRequestContext</value></constructor-arg>
  -  	   <constructor-arg ><ref bean="org.apache.jetspeed.userinfo.UserInfoManager"
/></constructor-arg>  	   
  +  	   <constructor-arg ><ref bean="org.apache.jetspeed.userinfo.UserInfoManager"
/></constructor-arg>
  +  	   <constructor-arg ><ref bean="portletFactory" /></constructor-arg>
 	      
     </bean>
     
     <!-- Portlet Window Component -->
  
  
  
  1.3       +3 -3      jakarta-jetspeed-2/portal/src/test/org/apache/jetspeed/container/state/TestNavigationalState.java
  
  Index: TestNavigationalState.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/test/org/apache/jetspeed/container/state/TestNavigationalState.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TestNavigationalState.java	17 Oct 2004 14:02:38 -0000	1.2
  +++ TestNavigationalState.java	27 Jan 2005 21:27:52 -0000	1.3
  @@ -164,7 +164,7 @@
           request.setPathInfo("stuff");
           request.setRequestURI("/jetspeed/portal/stuff");
   
  -        JetspeedRequestContext context = new JetspeedRequestContext(request, response,
config, null );
  +        JetspeedRequestContext context = new JetspeedRequestContext(request, response,
config, null, null );
           
           // create base PortletURL
           PortalURL url = component.createURL(context.getRequest(), context.getCharacterEncoding());
  @@ -190,7 +190,7 @@
               request.setPathInfo(portletURL.substring(portletURL.indexOf("/portal")+7));
           }
           
  -        context = new JetspeedRequestContext(request, response, config, null );
  +        context = new JetspeedRequestContext(request, response, config, null, null );
                   
           url = component.createURL(context.getRequest(), context.getCharacterEncoding());
           context.setPortalURL(url);
  
  
  
  1.9       +58 -47    jakarta-jetspeed-2/components/registry/src/java/org/apache/jetspeed/om/impl/LanguageSetImpl.java
  
  Index: LanguageSetImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/components/registry/src/java/org/apache/jetspeed/om/impl/LanguageSetImpl.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- LanguageSetImpl.java	6 Oct 2004 01:50:49 -0000	1.8
  +++ LanguageSetImpl.java	27 Jan 2005 21:27:52 -0000	1.9
  @@ -24,7 +24,6 @@
   import java.util.MissingResourceException;
   import java.util.ResourceBundle;
   
  -
   import org.apache.commons.lang.StringUtils;
   import org.apache.jetspeed.util.JetspeedLocale;
   import org.apache.jetspeed.om.common.MutableLanguage;
  @@ -36,15 +35,15 @@
    * 
    * LanguageSetImpl
    * 
  - * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
  + * @author <a href="mailto:weaver@apache.org">Scott T. Weaver </a>
    * @version $Id$
  - *
  + *  
    */
   public class LanguageSetImpl implements LanguageSet, Serializable, Support
   {
   
       private ClassLoader classLoader = null;
  -    
  +
       private String resources;
       protected Collection innerCollection;
   
  @@ -52,7 +51,7 @@
        * 
        * @param wrappedSet
        */
  -    public LanguageSetImpl(Collection collection)
  +    public LanguageSetImpl( Collection collection )
       {
           super();
           this.innerCollection = collection;
  @@ -91,29 +90,25 @@
       /**
        * @see org.apache.pluto.om.common.LanguageSet#get(java.util.Locale)
        */
  -    public Language get(Locale locale)
  +    public Language get( Locale locale )
       {
  -		Language fallBack = null;
  +        Language fallBack = null;
           Iterator searchItr = innerCollection.iterator();
           while (searchItr.hasNext())
           {
  -			Language lang = (Language) searchItr.next();
  -            
  +            Language lang = (Language) searchItr.next();
  +
               if (lang.getLocale().equals(locale))
               {
                   if (resources != null)
                   {
  -                    return createLanguage(
  -                        lang.getLocale(),
  -                        loadResourceBundle(lang.getLocale()),
  -                        lang.getTitle(),
  -                        lang.getShortTitle(),
  -                        StringUtils.join(lang.getKeywords(), ","));
  +                    return createLanguage(lang.getLocale(), loadResourceBundle(lang.getLocale()),
lang.getTitle(), lang
  +                            .getShortTitle(), StringUtils.join(lang.getKeywords(), ","));
                   }
                   else
                   {
  -                return lang;
  -            }
  +                    return lang;
  +                }
               }
               else if (lang.getLocale().getLanguage().equals(locale.getLanguage()))
               {
  @@ -124,13 +119,8 @@
   
           if (fallBack != null && resources != null)
           {
  -            fallBack =
  -                createLanguage(
  -                    fallBack.getLocale(),
  -                    loadResourceBundle(fallBack.getLocale()),
  -                    fallBack.getTitle(),
  -                    fallBack.getShortTitle(),
  -                    StringUtils.join(fallBack.getKeywords(), ","));
  +            fallBack = createLanguage(fallBack.getLocale(), loadResourceBundle(fallBack.getLocale()),
fallBack
  +                    .getTitle(), fallBack.getShortTitle(), StringUtils.join(fallBack.getKeywords(),
","));
           }
   
           if (fallBack == null)
  @@ -152,23 +142,23 @@
       /**
        * @see java.util.Collection#add(java.lang.Object)
        */
  -    public boolean add(Object o)
  +    public boolean add( Object o )
       {
           Language language = (Language) o;
           if (language.getLocale() == null)
           {
               ((MutableLanguage) o).setLocale(JetspeedLocale.getDefaultLocale());
           }
  -        
  +
           return innerCollection.add(o);
       }
   
       /**
        * @see java.util.Collection#remove(java.lang.Object)
        */
  -    public boolean remove(Object o)
  +    public boolean remove( Object o )
       {
  -        Language language = (Language) o;        
  +        Language language = (Language) o;
           return innerCollection.remove(language);
       }
   
  @@ -183,28 +173,30 @@
       /**
        * @param collection
        */
  -    public void setInnerCollection(Collection collection)
  +    public void setInnerCollection( Collection collection )
       {
           innerCollection = collection;
       }
  -    
  +
       public int size()
       {
  -    	return innerCollection.size();
  +        return innerCollection.size();
       }
   
       /**
        * @param string
        */
  -    public void setResources(String string)
  +    public void setResources( String string )
       {
           resources = string;
       }
   
  -    /* (non-Javadoc)
  +    /*
  +     * (non-Javadoc)
  +     * 
        * @see org.apache.jetspeed.om.common.Support#postLoad(java.lang.Object)
        */
  -    public void postLoad(Object parameter) throws Exception
  +    public void postLoad( Object parameter ) throws Exception
       {
           Iterator iter = ((Collection) parameter).iterator();
           while (iter.hasNext())
  @@ -216,7 +208,7 @@
           }
       }
   
  -    protected ResourceBundle loadResourceBundle(Locale locale)
  +    protected ResourceBundle loadResourceBundle( Locale locale )
       {
           ResourceBundle resourceBundle = null;
           try
  @@ -225,11 +217,12 @@
               {
                   if (classLoader != null)
                   {
  -                    resourceBundle=ResourceBundle.getBundle(resources, locale, classLoader);
  +                    resourceBundle = ResourceBundle.getBundle(resources, locale, classLoader);
                   }
                   else
                   {
  -                    resourceBundle=ResourceBundle.getBundle(resources, locale, Thread.currentThread().getContextClassLoader());
  +                    resourceBundle = ResourceBundle.getBundle(resources, locale, Thread.currentThread()
  +                            .getContextClassLoader());
                   }
               }
           }
  @@ -246,7 +239,7 @@
        * 
        * @param loader
        */
  -    public void setClassLoader(ClassLoader loader)
  +    public void setClassLoader( ClassLoader loader )
       {
           classLoader = loader;
       }
  @@ -258,7 +251,7 @@
        * @param bundle
        * @return
        */
  -    private Language createLanguage(Locale locale, ResourceBundle bundle)
  +    private Language createLanguage( Locale locale, ResourceBundle bundle )
       {
           String title = "";
           String shortTitle = "";
  @@ -273,7 +266,7 @@
           }
           return createLanguage(locale, bundle, title, shortTitle, keywords);
       }
  -    
  +
       /**
        * Creates Language instance.
        * 
  @@ -284,13 +277,31 @@
        * @param keywords
        * @return
        */
  -    private Language createLanguage(
  -        Locale locale,
  -        ResourceBundle bundle,
  -        String title,
  -        String shortTitle,
  -        String keywords)
  +    private Language createLanguage( Locale locale, ResourceBundle bundle, String title,
String shortTitle,
  +            String keywords )
       {
  +        if (!locale.equals(getDefaultLocale()))
  +        {
  +            Language defaultLang = get(getDefaultLocale());
  +
  +            if (defaultLang != null)
  +            {
  +                if (title == null || title.length() < 1)
  +                {
  +                    title = defaultLang.getTitle();
  +                }
  +
  +                if (shortTitle == null || shortTitle.length() < 1)
  +                {
  +                    shortTitle = defaultLang.getShortTitle();
  +                }
  +
  +                if (keywords == null || keywords.length() < 1)
  +                {
  +                    keywords = StringUtils.join(defaultLang.getKeywords(), ",");
  +                }
  +            }
  +        }
           LanguageImpl lang = new LanguageImpl(locale, bundle, title, shortTitle, keywords);
           return (Language) lang;
       }
  
  
  
  1.6       +15 -1     jakarta-jetspeed-2/components/portlet-factory/src/java/org/apache/jetspeed/factory/JetspeedPortletFactory.java
  
  Index: JetspeedPortletFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/components/portlet-factory/src/java/org/apache/jetspeed/factory/JetspeedPortletFactory.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- JetspeedPortletFactory.java	12 Oct 2004 19:44:36 -0000	1.5
  +++ JetspeedPortletFactory.java	27 Jan 2005 21:27:52 -0000	1.6
  @@ -30,6 +30,7 @@
   import org.apache.commons.logging.LogFactory;
   import org.apache.jetspeed.cache.PortletCache;
   import org.apache.jetspeed.container.PortalAccessor;
  +import org.apache.pluto.om.common.ObjectID;
   import org.apache.pluto.om.portlet.PortletDefinition;
   import org.apache.pluto.om.portlet.PortletDefinitionCtrl;
   
  @@ -202,5 +203,18 @@
   
           return portlet;
       }
  +    
  +    public ClassLoader getPortletClassLoader(PortletDefinition portletDef)
  +    {
  +        String appId = portletDef.getPortletApplicationDefinition().getId().toString();
  +        if(classLoaderMap.containsKey(appId))
  +        {
  +            return (ClassLoader) classLoaderMap.get(appId);
  +        }
  +        else
  +        {
  +            throw new IllegalStateException("No classloader has been defined for portlet
application "+appId);
  +        }
  +    }
   
   }
  
  
  
  1.3       +3 -1      jakarta-jetspeed-2/jetspeed-api/src/java/org/apache/jetspeed/factory/PortletFactory.java
  
  Index: PortletFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/jetspeed-api/src/java/org/apache/jetspeed/factory/PortletFactory.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PortletFactory.java	19 Sep 2004 22:28:10 -0000	1.2
  +++ PortletFactory.java	27 Jan 2005 21:27:52 -0000	1.3
  @@ -40,5 +40,7 @@
       Portlet loadPortletClass( String className ) throws InstantiationException, IllegalAccessException;
   
       Portlet getPortlet( ServletConfig servletConfig, PortletDefinition portletDefinition
) throws PortletException;
  +    
  +    ClassLoader getPortletClassLoader(PortletDefinition portletDef);
   
   }
  \ No newline at end of file
  
  
  

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


Mime
View raw message