Is there any document for ratpack.properties config?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Is there any document for ratpack.properties config?

markone
rus
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Is there any document for ratpack.properties config?

rus
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Is there any document for ratpack.properties config?

markone
I mean, how can i config a ratpack server out of java code, I put a ratpack.properties file in resource folder of my project, but I don't know what property I can put in this file.
I have tried some properties, but only "port" property works.
So ,is there any specification for ratpack's properties file?
Just like: http://dev.mysql.com/doc/connector-j/en/connector-j-reference-configuration-properties.html
rus
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Is there any document for ratpack.properties config?

rus
ratpack.properties is just for properties related to the server config.  You can see the settings available here http://www.ratpack.io/manual/current/api/ratpack/server/ServerConfig.html e.g. port, number of threads

If you need to define application properties then the best place to start is here http://www.ratpack.io/manual/current/api/ratpack/config/ConfigData.html

In very simple terms, you need to depend on ratpack-config, create a class to hold your application properties, create a property source (e.g. a property file) and bind the source to the class.  You can see an exmaple here https://github.com/ratpack/example-books/blob/latest/src/ratpack/ratpack.groovy#L43  It's Groovy but you'll get the idea.

So, we have a file application.properties and configure it like
    ConfigData configData = ConfigData.of(new JSR310Module())
        .props("$serverConfig.baseDir.file/application.properties")
        .env()
        .sysProps()
        .build()

The we bind properties starting with isbndb to a class IsbndbConfig and that is then available in the registry
    bindInstance(IsbndbConfig, configData.get("/isbndb", IsbndbConfig))
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Is there any document for ratpack.properties config?

markone
Simple and clear, thanks!
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Is there any document for ratpack.properties config?

Sergio Pedraza
Hi Guys, I want to ask you, what if I have Ratpack using spring and the idea is to load properties depending on the environment profiles, just like:

        public static void main(String... args) throws Exception {
                RxRatpack.initialize();

                Registry registry = Spring.spring(Application.class);


                RatpackServer.start(

                        server -> server
                                .registry(registry)
                                .handlers(chain -> chain
                                        .all(AuthenticationHandler.class)
                                        .path(PingHandler.class)
                                        .path(PING, PingHandler.class)
                                        .prefix(MYSERVICE, MyServiceActions.class)) );
        }

and I have different values for each property:

- application-dev.properties
- application-qa.properties
- application-prod.properties

The files above are the Spring properties files about the environment-profiles config and I want to load the values for the properties according the profile. All I want is to load the properties values for each environment respective.
Do you know how I can do that? or, is there another way in ratpack in order to achieve that goal?
Thanks in advance
Loading...