You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Robert Marcano <ro...@promca.com> on 2001/02/22 14:30:46 UTC

Latest CocoonServlet and ParanoidServlet changes problem

The latest changes in this classes defines the method "getClassPath" as 
private, so the overriden in ParanoidServlet is never called

See attached diff.txt

Re: Latest CocoonServlet and ParanoidServlet changes problem

Posted by Berin Loritsch <bl...@apache.org>.
Robert Marcano wrote:
> 
> Berin Loritsch wrote:
> 
> > Robert Marcano wrote:
> >
> >> The latest changes in this classes defines the method "getClassPath" as
> >> private, so the overriden in ParanoidServlet is never called
> >>
> >> See attached diff.txt
> >
> >
> > Thanks alot.  The patch is committed.
> 
> There is a problem using the RepositoryClassLoader, the overriden method
> getClasspath does not tell to ClassUtils about the new instance of
> RespositoryClassLoader
> 
> In order to no repeat the ClassUtil.setClassLoader method call, i
> created a somethng like a factory method called "buildInitClassLoader"
> in order to tell the servlet wich classLoader must intantiate if  required.


Done.

> 
> >
> 
>   ------------------------------------------------------------------------------------------------------------------------------------
> Index: ParanoidCocoonServlet.java
> ===================================================================
> RCS file: /home/cvspublic/xml-cocoon/src/org/apache/cocoon/servlet/Attic/ParanoidCocoonServlet.java,v
> retrieving revision 1.1.2.4
> diff -u -r1.1.2.4 ParanoidCocoonServlet.java
> --- ParanoidCocoonServlet.java  2001/02/22 13:34:35     1.1.2.4
> +++ ParanoidCocoonServlet.java  2001/02/22 14:16:23
> @@ -38,6 +38,13 @@
>  public class ParanoidCocoonServlet extends CocoonServlet {
> 
>      /**
> +     * get the classloader to use for Cocoon instantiation
> +     */
> +     protected ClassLoader buildInitClassLoader() {
> +        return new RepositoryClassLoader(new URL[] {}, this.getClass().getClassLoader());
> +     }
> +
> +    /**
>       * This builds the important ClassPath used by this Servlet.  It
>       * does so in a Servlet Engine neutral way.  It uses the
>       * <code>ServletContext</code>'s <code>getRealPath</code> method
> @@ -55,7 +62,7 @@
>       */
>       protected String getClassPath(final ServletContext context)
>       throws ServletException {
> -        RepositoryClassLoader classloader = new RepositoryClassLoader(new URL[] {}, (ClassLoader) this.appContext.get(Constants.CONTEXT_CLASS_LOADER));
> +        RepositoryClassLoader classloader = (RepositoryClassLoader)this.appContext.get(Constants.CONTEXT_CLASS_LOADER);
>          StringBuffer buildClassPath = new StringBuffer();
>          String classDirPath = getInitParameter("class-dir");
>          String libDirPath = getInitParameter("lib-dir");
> @@ -96,8 +103,6 @@
>                  }
>              }
>          }
> -
> -        this.appContext.put(Constants.CONTEXT_CLASS_LOADER, classloader);
> 
>          buildClassPath.append(File.pathSeparatorChar)
>                        .append(System.getProperty("java.class.path"));
> Index: CocoonServlet.java
> ===================================================================
> RCS file: /home/cvspublic/xml-cocoon/src/org/apache/cocoon/servlet/Attic/CocoonServlet.java,v
> retrieving revision 1.1.4.65
> diff -u -r1.1.4.65 CocoonServlet.java
> --- CocoonServlet.java  2001/02/22 14:03:48     1.1.4.65
> +++ CocoonServlet.java  2001/02/22 14:16:24
> @@ -43,7 +43,6 @@
>  import org.apache.cocoon.util.ClassUtils;
>  import org.apache.cocoon.util.NetUtils;
>  import org.apache.cocoon.util.IOUtils;
> -import org.apache.cocoon.components.classloader.RepositoryClassLoader;
> 
>  import org.apache.log.Logger;
>  import org.apache.log.LogKit;
> @@ -98,7 +97,7 @@
>      throws ServletException {
> 
>          super.init(conf);
> -        ClassLoader classloader = this.getClass().getClassLoader();
> +       ClassLoader classloader = this.buildInitClassLoader();
>          ServletContext context = conf.getServletContext();
> 
>          ClassUtils.setClassLoader(classloader);
> @@ -124,6 +123,14 @@
> 
>          this.createCocoon();
>      }
> +
> +    /**
> +     * get the classloader to use for Cocoon instantiation
> +     */
> +     protected ClassLoader buildInitClassLoader() {
> +        return this.getClass().getClassLoader();
> +     }
> +
> 
>      /**
>       * This builds the important ClassPath used by this Servlet.  It
> 
>   ------------------------------------------------------------------------------------------------------------------------------------
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
> For additional commands, email: cocoon-dev-help@xml.apache.org

Re: Latest CocoonServlet and ParanoidServlet changes problem

Posted by Robert Marcano <ro...@promca.com>.
Berin Loritsch wrote:

> Robert Marcano wrote:
> 
>> The latest changes in this classes defines the method "getClassPath" as
>> private, so the overriden in ParanoidServlet is never called
>> 
>> See attached diff.txt
> 
> 
> Thanks alot.  The patch is committed.

There is a problem using the RepositoryClassLoader, the overriden method 
getClasspath does not tell to ClassUtils about the new instance of 
RespositoryClassLoader

In order to no repeat the ClassUtil.setClassLoader method call, i 
created a somethng like a factory method called "buildInitClassLoader" 
in order to tell the servlet wich classLoader must intantiate if  required.

> 

Re: Latest CocoonServlet and ParanoidServlet changes problem

Posted by Berin Loritsch <bl...@apache.org>.
Robert Marcano wrote:
> 
> The latest changes in this classes defines the method "getClassPath" as
> private, so the overriden in ParanoidServlet is never called
> 
> See attached diff.txt

Thanks alot.  The patch is committed.

> 
>   ------------------------------------------------------------------------------------------------------------------------------------
> Index: ParanoidCocoonServlet.java
> ===================================================================
> RCS file: /home/cvspublic/xml-cocoon/src/org/apache/cocoon/servlet/Attic/ParanoidCocoonServlet.java,v
> retrieving revision 1.1.2.3
> diff -u -r1.1.2.3 ParanoidCocoonServlet.java
> --- ParanoidCocoonServlet.java  2001/02/21 15:08:47     1.1.2.3
> +++ ParanoidCocoonServlet.java  2001/02/22 13:19:51
> @@ -53,7 +53,7 @@
>       *
>       * @throws ServletException
>       */
> -     private String getClassPath(final ServletContext context)
> +     protected String getClassPath(final ServletContext context)
>       throws ServletException {
>          RepositoryClassLoader classloader = new RepositoryClassLoader(new URL[] {}, (ClassLoader) this.appContext.get(Constants.CONTEXT_CLASS_LOADER));
>          StringBuffer buildClassPath = new StringBuffer();
> Index: CocoonServlet.java
> ===================================================================
> RCS file: /home/cvspublic/xml-cocoon/src/org/apache/cocoon/servlet/Attic/CocoonServlet.java,v
> retrieving revision 1.1.4.63
> diff -u -r1.1.4.63 CocoonServlet.java
> --- CocoonServlet.java  2001/02/21 15:53:37     1.1.4.63
> +++ CocoonServlet.java  2001/02/22 13:19:53
> @@ -133,7 +133,7 @@
>       *
>       * @throws ServletException
>       */
> -     private String getClassPath(final ServletContext context)
> +     protected String getClassPath(final ServletContext context)
>       throws ServletException {
>          StringBuffer buildClassPath = new StringBuffer();
>          String classDir = context.getRealPath("/WEB-INF/classes");
> 
>   ------------------------------------------------------------------------------------------------------------------------------------
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
> For additional commands, email: cocoon-dev-help@xml.apache.org