Archive for the 'j2ee' Category

Grails AcegiSecurity Create User on BootStrap

June 05th, 2008 | Category: grails, j2ee, java

To create users on startup with a blank database:

Read more

2 comments

Using services from bootstrap.groovy in grails

June 04th, 2008 | Category: j2ee, java

I’m currently writing an application for some upcoming strutta.com functionality using grails.  During development though, I have it setup to recreate my data everytime I restart the server, and then I repopulate from a seperate source.

I do have a controller setup to manually import specific ids from the head end server, but its useful if I didn’t have to do this everything I hit ctrl-c in the wrong window.  Using a services orientated design, you seperate out logic from controllers (and is recommended by the grails guys), but if you need to call this from the bootup, you could follow the instructions on http://grails.org/Services (which doesn’t work…) or you could do:

import org.codehaus.groovy.grails.web.servlet.GrailsApplicationAttributes

class BootStrap {

  def init = { servletContext ->
    def ctx = servletContext.getAttribute(
GrailsApplicationAttributes.APPLICATION_CONTEXT);
    def ss = ctx.getBean("feedService");

    ss.loadFromFeed();
  }
  def destroy = {
  }
}
2 comments