You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@geronimo.apache.org by Ivan <xh...@gmail.com> on 2011/05/05 08:42:29 UTC

Re: svn commit: r1099252 - in /geronimo/server/trunk/plugins: jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/ myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/webapp/ tomcat/geronimo-tomcat7/src/main/java/or

Hi, Jarek
    I am wondering why is required to unwrap the bundle ? If the hack for
spring framework needs the native bundle instance, we could just wrapper
this for it. It looks to me that the DelegatingBundle somewhat plays the
same role with context classloader, it could be used to load those classes
are not imported by the bundle itself, while they are required by the
runtime. e.g. In the o.a.geronimo,myfaces.GeronimoWebXml, it is used to load
all the servlet class in the web.xml, with the native bundle, it failed to
load those added classes from other bundles, e.g.
org.apache.catalina.servlets.DefaultServlet.
Thanks.

2011/5/4 <ga...@apache.org>

> Author: gawor
> Date: Tue May  3 21:12:05 2011
> New Revision: 1099252
>
> URL: http://svn.apache.org/viewvc?rev=1099252&view=rev
> Log:
> use unwrapped bundle for osgi-bundlecontext attribute
>
> Modified:
>
>  geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/GeronimoWebAppContext.java
>
>  geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/webapp/MyFacesWebAppContext.java
>
>  geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatContainer.java
>
> Modified:
> geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/GeronimoWebAppContext.java
> URL:
> http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/GeronimoWebAppContext.java?rev=1099252&r1=1099251&r2=1099252&view=diff
>
> ==============================================================================
> ---
> geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/GeronimoWebAppContext.java
> (original)
> +++
> geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/GeronimoWebAppContext.java
> Tue May  3 21:12:05 2011
> @@ -98,13 +98,16 @@ public class GeronimoWebAppContext exten
>         this.integrationContext = integrationContext;
>         setClassLoader(classLoader);
>         this.classLoader = classLoader;
> +
> +        Bundle bundle =
> BundleUtils.unwrapBundle(integrationContext.getBundle());
> +
>         setAttribute(WebApplicationConstants.BUNDLE_CONTEXT_ATTRIBUTE,
> -                     integrationContext.getBundle().getBundleContext());
> +                     bundle.getBundleContext());
>
>         setAttribute(WebAttributeName.WEB_APP_INFO.name(), webAppInfo);
>
>         setAttribute("org.springframework.osgi.web." +
> BundleContext.class.getName(),
> -                     integrationContext.getBundle().getBundleContext());
> +                     bundle.getBundleContext());
>
>         // now set the module context ValidatorFactory in a context
> property.
>         try {
>
> Modified:
> geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/webapp/MyFacesWebAppContext.java
> URL:
> http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/webapp/MyFacesWebAppContext.java?rev=1099252&r1=1099251&r2=1099252&view=diff
>
> ==============================================================================
> ---
> geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/webapp/MyFacesWebAppContext.java
> (original)
> +++
> geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/webapp/MyFacesWebAppContext.java
> Tue May  3 21:12:05 2011
> @@ -33,6 +33,7 @@ import org.apache.geronimo.gbean.annotat
>  import org.apache.geronimo.myfaces.config.resource.ConfigurationResource;
>  import
> org.apache.geronimo.myfaces.config.resource.osgi.api.ConfigRegistry;
>  import org.apache.myfaces.config.element.FacesConfigData;
> +import org.apache.xbean.osgi.bundle.util.BundleUtils;
>  import org.osgi.framework.Bundle;
>  import org.osgi.framework.ServiceReference;
>  import org.slf4j.Logger;
> @@ -59,7 +60,7 @@ public class MyFacesWebAppContext implem
>     public MyFacesWebAppContext(@ParamAttribute(name = "facesConfigData")
> FacesConfigData facesConfigData,
>             @ParamAttribute(name = "faceletConfigResources")
> Set<ConfigurationResource> faceletConfigResources, @ParamSpecial(type =
> SpecialAttributeType.bundle) Bundle bundle,
>             @ParamSpecial(type = SpecialAttributeType.classLoader)
> ClassLoader classLoader) {
> -        this.bundle = bundle;
> +        this.bundle = BundleUtils.unwrapBundle(bundle);
>         this.facesConfigData = facesConfigData;
>         this.classLoader = classLoader;
>         ServiceReference serviceReference = null;
>
> Modified:
> geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatContainer.java
> URL:
> http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatContainer.java?rev=1099252&r1=1099251&r2=1099252&view=diff
>
> ==============================================================================
> ---
> geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatContainer.java
> (original)
> +++
> geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatContainer.java
> Tue May  3 21:12:05 2011
> @@ -54,6 +54,8 @@ import org.apache.geronimo.web.info.WebA
>  import org.apache.geronimo.webservices.SoapHandler;
>  import org.apache.geronimo.webservices.WebServiceContainer;
>  import org.apache.tomcat.InstanceManager;
> +import org.apache.xbean.osgi.bundle.util.BundleUtils;
> +import org.osgi.framework.Bundle;
>  import org.osgi.framework.BundleContext;
>  import org.slf4j.Logger;
>  import org.slf4j.LoggerFactory;
> @@ -275,13 +277,15 @@ public class TomcatContainer implements
>             throw new IllegalArgumentException("Invalid virtual host '" +
> virtualServer + "'.  Do you have a matching Host entry in the plan?");
>         }
>         context.setParent(host);
> +
> +        Bundle bundle = BundleUtils.unwrapBundle(contextInfo.getBundle());
>         // set the bundle context attribute in the servlet context
>
> context.getServletContext().setAttribute(WebApplicationConstants.BUNDLE_CONTEXT_ATTRIBUTE,
> -
> contextInfo.getBundle().getBundleContext());
> +
> bundle.getBundleContext());
>         context.getServletContext().setAttribute(
> WebAttributeName.WEB_APP_INFO.name(), contextInfo.getWebAppInfo());
>
>
> context.getServletContext().setAttribute("org.springframework.osgi.web." +
> BundleContext.class.getName(),
> -
> contextInfo.getBundle().getBundleContext());
> +
> bundle.getBundleContext());
>
>         // now set the module context ValidatorFactory in a context
> property.
>         try {
>
>
>


-- 
Ivan