Announcement Announcement Module
Collapse
No announcement yet.
Web Bundles and Fragments Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Web Bundles and Fragments

    Hi,

    I am trying out slices and trying to find best way to attach static content to the host bundle. I would like to provide theme support and experimenting right now with different approaches. Fragments seem to be out of the question.

    Can fragments be attached to shared services web bundles?
    What is the final symbolic name of the deployed web bundle? Is it even treated as a bundle?
    Looking at osgi console I did not see a deployed war file. (this is most likely an RTFM issue on my part, but still please help )

    Thanks in advance

  • #2
    Originally posted by dsklyut View Post
    Hi,

    I am trying out slices and trying to find best way to attach static content to the host bundle. I would like to provide theme support and experimenting right now with different approaches. Fragments seem to be out of the question.
    We were actually talking about exactly this sort of thing in the office yesterday: we were discussing ways of making the styling of a Web bundle pluggable. The two candidates were to use a fragment that attaches to the Web bundle, and to make the Web bundle a Slice Host and use a Slice to provide the styling. We didn't get much beyond this in the discussion so we don't have any definitive recommendations to make at this stage.

    A key thing to note is that in the fragment bundle approach, the fragment will only add things to the classpath of the Web bundle, it won't add entries to the area on the filesystem that Tomcat can see, and from which it can directly serve static content. This means that you'd have to use some form of ResourceServlet that used the Web application's classloader to locate and server static resources. Using a Slice would not have this restriction and is probably a more elegant approach.

    Can fragments be attached to shared services web bundles?
    Yes, they can.

    What is the final symbolic name of the deployed web bundle? Is it even treated as a bundle?
    Yes, they are treated as bundles.

    If no Bundle-SymbolicName is specified, then one is generated. The generated BSN is simply the name of the war file that you installed, e.g. if you install foo.war the bundle that's generated from the war will have a Bundle-SymbolicName: foo.war header.

    Rather than relying on this generation, you can update the MANIFEST.MF in your WAR file to specifying a Bundle-SymbolicName. The installation of the WAR will only generated a Bundle-SymbolicName if one is not already present in the manifest.

    Looking at osgi console I did not see a deployed war file. (this is most likely an RTFM issue on my part, but still please help )
    The bundle that's generated from the WAR should definitely be visible in the console. Hopefully now that you know what the bundle's BSN will be, it'll be a little easier to spot it.

    Comment


    • #3
      Andy,

      First off thank you for detailed response.

      Here is some things that I found through experimenting with different deployment scenarios :

      NOTE:
      Host Bundle is a Slice Host web app
      Fragment is some arbitrary file that I am attaching to that bundle (just for testing)

      When dropping a slice host into pickup directory first and then a fragment,
      that fragment is never attached to the host bundle.
      Host bundle is active, fragment is installed. Maybe there is a need for an update on the host bundle in this case?

      If including both artifacts in a plan - works like expected. Host bundle is Active, Fragment is resolved and attached to Host bundle.


      On the fragment vs. slice for static resources:
      Major reason that I was going for a fragment is support for Spring Themes.
      This might sound old fashioned but I like themes because of inherent localization support when using ResourceBundleThemeSource and abstraction of the underlying theme artifact names behind keys in a bundle.

      So with a theme bundle I was trying to attach a theme.properties to the host and also all of the theme resources. Host already has a ResourceServlet defined so it should be able to resolve the attached artifact.

      I am not 100% sure how theme support will work within a child slice. Does Host Slice has access to the class space of Child Slice? Better yet, is Child Slice is treated as a fragment by the platform? Resource resolution will work fine on the http level, but how to get that theme descriptor (i.e. theme.properties) into class space of a host bundle so ThemeResolver will pick it up? Going to look at the Slices implementation now.

      Thanks again for your help.
      Last edited by dsklyut; Jul 9th, 2009, 07:18 PM.

      Comment


      • #4
        Fragments work.

        Followed example from Rob's blog post on slices.
        Create Host. Make sure to keep ResourceServlet
        Create Fragment for the Host SymbolicName.
        In fragment bundle, place resources under META-INF. ResourceServlet is able to access them.

        I am not sure if that is the most scalable solution in terms of performance and maintenance but this should hold me over while you guys come up with something wizbang!

        Comment

        Working...
        X