Runtime rewriting configuration

Splash Forums Rewrite Users Runtime rewriting configuration

This topic contains 9 replies, has 2 voices, and was last updated by  Christian Kaltepoth 1 year, 10 months ago.

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #26401

    andreaCataniac
    Participant

    I’m developing a web application that provides some pages. I require to rewrite the URL of these pages and I would like to use this framework ocpsoft rewrite.

    All works fine, but the problem is that I need invoke the configuration in a particular moment of startup so I can send a list of link to be rewrited.

    I know that is possible but I haven’t some experience with this framework..

    Thakns for all Bye.

    #26403

    If you implement a ConfigurationProvider you can do whatever you want to build the rules. You could for example load data from a database or something like that. There should be no problem with doing so.

    #26404

    andreaCataniac
    Participant

    Thanks for good answer,
    But the problem is that I use a startup class for initialize the webapp, this class will start a connection pool, then only after this moment can be performed actions to the DB.

    So the problem is how can I be sure that the class “HttpConfigurationProvider” is started after my startup class?

    Thanks in advance

    #26405

    This depends on how you create/bootstrap your startup class. 😉

    Rewrite initialization is performed, when RewriteFilter.init() is called by the container. And I think there is now way to change this.

    #26406

    andreaCataniac
    Participant

    Can you show me the way please?

    #26412

    Just have a look at chapter 2 of the installation guide. It describes in detail how to setup your first ConfigurationProvider.

    http://ocpsoft.org/rewrite/docs/configuration/install

    Feel free to ask if you have any specific questions.

    #26417

    andreaCataniac
    Participant

    Yes mate I know how to write this ConfigurationProvider…
    But i don’t know how to start it myself in my startup class…

    #26418

    You cannot start it yourself. As I said, Rewrite is initialized by the RewriteFilter. Whenever the container initializes the Servlet filters, Rewrite will start up.

    Could you tell more about your startup class? How is it initialized?

    #26419

    andreaCataniac
    Participant

    yes of course,
    The startup class is an implementations of ServletContextListener, and start the connection pool, the config for log4j and other minor configs.

    #26428

    I think Rewrite will initialize before any ServletContextListeners, so your startup class won’t be ready when Rewrite initializes.

    If you really need the startup class for Rewrite configuration, you should find some other way of initialization. If you are using CDI or Spring, there are many better ways to do this compared to a ServletContextListeners. And manually setting up a connection pool is also not very common. This should be done by the container which will take care of preparing it before the application is deployed.

    If you show me the code of your startup class, I could try to give some thoughts for improvement.

Viewing 10 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic.

Comments are closed.