Announcement Announcement Module
Collapse
No announcement yet.
struts 2 shared services web app in s2ap Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • struts 2 shared services web app in s2ap

    Hi,

    Wondering if anyone has running in s2ap a Struts 2 web app in which the actions are held in a separate bundle and imported as osgi services per Spring-DM conventions by the war-bundle's app context?

    Thanks,
    Jason

  • #2
    struts 2 shared services web app in s2ap

    Two questions:
    * Struts 2 actions are not Spring beans, right? How would Spring know about them?
    * Aren't Struts 2 action instances created new for each request? They're not singletons like in Struts 1, right? So how could they be used as a global service anyways?

    I fail to see why you want to publish them as OSGi-services because of these issues.

    Joris

    Comment


    • #3
      struts 2 shared services web app in s2ap

      The motivation for wanting to take this approach is that we're looking to build multiple applications, some web some not, which utilize the actions. It'd be convenient therefore if we could deploy the shared resources in a separate OSGI bundle rather than build them into each application. Indeed, XWork actions are not singletons, but plugins have enabled Spring to serve nicely as their dependency provider for some time. Wondering whether anyone has attempted a similar arrangement under S2AP.

      Comment


      • #4
        struts 2 shared services web app in s2ap

        Sounds to me like your actions contain logic that should be implemented in a middle-tier service instead. Calling out to Struts2 actions from a non-web application makes absolutely no sense and violates all design principles that come with a properly layered architecture.

        Instead, simply define normal Spring beans that implement your shared logic, make them available as OSGi-services and call them from both your Struts2 actions as well as from your non-web code. You can still use the DI features of Struts2 to give your action instances a reference to the Spring service, but it would really be a Spring-DM proxy to the OSGi service. That makes much more sense and is certainly possbile.

        Joris

        Comment


        • #5
          struts 2 shared services web app in s2ap

          Thing is, actions in Struts 2 are just command objects, typically extensions of XWork framework objects, and have inherently nothing to do with the web. (See www.opensymphony.com/xwork.) I see no reason that objects which process user input and handle interaction with business services shouldn't be deployed in a shared OSGI bundle.

          Please feel free to initiate another thread on proper uses of OSGI, Spring-DM or S2AP. My question here wasn't so much whether I should take this approach as whether others already have...

          Thanks!

          Jason

          Comment


          • #6
            struts 2 shared services web app in s2ap

            I have a use case where I want to dynamically add new struts actions using hot-deploy provided by the spring application platform. Now my only option is to redeploy the WAR. Is this the model one should adopt.

            1. Move as much of the shared logic to the Shared OSGI services
            2. In case new struts actions need to be added then redeply the WAR or Web Module which has them

            Comment


            • #7
              struts 2 shared services web app in s2ap

              You could use a fragment bundle to make the Action classes available to the application. I don't know if that's enough for your purposes, or if you also need some configuration for those Actions. Fragments can only be used to add classpath resources, but those can include config files as well if Struts2 can be triggered to use them at runtime.

              Joris

              Comment


              • #8
                struts 2 shared services web app in s2ap

                Thanks. This is what would be ideal for me

                1. Instead of the classic WAR model where all the functionality that defines a Web application goes , ability to physically seperate each of the functions of the web application into seperate bundles.
                2. My definition of a individual function would mean the JSP files and the associate configutaion and the action/business logic classes
                3. My overall webapplications is a composition of the smaller functional components defined in step 2
                4. At run time I should have the ability to just redeploy only one of the functional component defined in step 2

                Looking at the structure of the current web application in S2AP (WebModule), there is at most one bundle which has all the JSP pages. So any time any changes are there to any of the functional components I need to redeply this WebModule.

                Is there any way out of this. Since most of the complex web application have atleast 10 - 15 different functional components. So even though I can seperate the NON-UI logic of these functionaly components into OSGI bundles still there is only 1 Web Module which has all the JSP pages required by all these functional components.

                Sriram C

                Comment


                • #9
                  struts 2 shared services web app in s2ap

                  Hi Sriram,

                  I think many people want what you're describing, as it is the logical thing to expect from a modular platform for web applications. However, I don't think this is currently possible.
                  Could you please raise an issue in JIRA with an enhancement request? Needing to define all your web resources in a single module is a show stopper for truly modular web apps, as far as I'm concerned.

                  Joris

                  Comment


                  • #10
                    struts 2 shared services web app in s2ap

                    Done.

                    https://issuetracker.springsource.com/browse/PLATFORM-167

                    Comment


                    • #11
                      struts 2 shared services web app in s2ap

                      If you're using Struts 2, you might be interested in this:

                      http://cwiki.apache.org/S2PLUGINS/osgi-plugin.html

                      Though, it's still experimental...

                      Comment

                      Working...
                      X