Results 1 to 6 of 6

Thread: Addons calling other addons - best practice?

  1. #1
    Join Date
    Jan 2006
    Posts
    23

    Default Addons calling other addons - best practice?

    I'm working on a few addons that basically enhance some of the standard Roo addons for our internal use. Ie, I am creating an addon that configures a project's security setup to use our LDAP server and specific Spring Security settings we use.

    I'm wondering what the best approach is for dealing with a situation where I want another addon's command to run before mine. I see a few ways this could work:

    1) Inject the component from the addon I want to use and call the code directly

    This is what I'm doing now, and it works, but I'm a little worried about maintenance. I am worried that the addons I depend on may change down the road and cause problems for those trying to use my addon. Probably not a huge deal, since this is for internal use, though.

    2) Invoke another command somehow

    Is there a generic way to invoke, say "security setup"? This wouldn't totally solve the maintenance issue, but it would at least make the code itself decoupled.

    3) Don't do anything, require the user to run "security setup" first

    This is the most reliable, but it requires more documentation and extra work on the part of the end-user. There are also cases where the user may try to run one of our commands, find it unavailable, and not know why (I have a patch for this in Roo's JIRA, but I'm not sure if it will be used or not).

    Any ideas on what the best practice should be?

  2. #2
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    2,768

    Default

    I'd suggest using the mechanism described in https://jira.springframework.org/browse/ROO-1343 to monitor when "security setup" is successfully executed and then complete your extra work then.
    Ben Alex
    Project Founder, Spring UAA, Spring Roo and Spring Security

  3. #3
    Join Date
    Nov 2010
    Location
    2k/10, Aditya Garden City, Warje, Pune-411052, India
    Posts
    22

    Default

    Hi,
    i agree here, I also need a way to create bigger addons which interm call existing addons.

    I want to call following addons in my addon (which is a complete security solution for a web site - registration, captcha , user login, forgot password, remember me)
    1. entity addon
    2. security setup
    3. controller addon

    Can we not get an object of roo shell and run commands on it "entity -class ~.model.User --test automatically" ?

    Also, once I have done that, I would like to monitor the objects created ( I think there is a way of doing that, but any documentation on that would be great).

    There should be some way of doing this.

    Cheers,
    Rohit

  4. #4
    Join Date
    Nov 2010
    Location
    2k/10, Aditya Garden City, Warje, Pune-411052, India
    Posts
    22

    Default

    In short I am talking about implement what is mentioned in this jira - https://jira.springsource.org/browse/ROO-532

  5. #5
    Join Date
    Nov 2010
    Location
    2k/10, Aditya Garden City, Warje, Pune-411052, India
    Posts
    22

    Default

    I was going through Spring Roo existing addons and saw this

    shell.executeCommand("osgi start --url " + url);

    I believe I may be able to do as follows

    shell.executeCommand("entity -class ~.model.WebUser --testAutomatically")


    Will update here once I am one with my investigation.

    Cheers,
    Roit

  6. #6
    Join Date
    Mar 2008
    Location
    Sydney, AU
    Posts
    974

    Default

    I would not recommend to use the shell.executeCommand approach. This would be quite fragile in case someone changes a command (remember with this approach you have no type safety). A much better approach is to get hold of the relevant *Operations interface and invoke the relevant methods there. So all you need to do is to create a dependency on the relevant add-on in your pom.xml and use the Felix @Reference annotation.

    Also, you should only really depend on core add-ons (the add-ons that Roo ships) since the user may not have other third party add-ons installed (unless you make it very clear to him that you need that add-on installed for yours to work).

    HTH,
    Stefan
    Stefan Schmidt
    Software Engineer, Spring Roo
    SpringSource - a division of VMware
    twitter @schmidtstefan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •