2

Im using pretty faces to rewrite my urls and Im using com.ocpsoft.pretty.faces.rewrite.Processor; I have notice that this filter its invoque several times while loading a URL, so as I access my DB to load some data this is extremely inefficient.

What I want is to put the processor in an applicationScope so it doesn't dye and be available to all users, that way I wont have to create several times my service beans.

Any suggestions ?

Christophe Roussy
  • 16,299
  • 4
  • 85
  • 85
IturPablo
  • 1,572
  • 2
  • 22
  • 35

2 Answers2

1

Not sure if it's applicable to Processor, but you may try disabling development mode:

<context-param>
  <param-name>com.ocpsoft.pretty.DEVELOPMENT</param-name>
  <param-value>false</param-value>
</context-param>

See this thread for details.

andbi
  • 4,426
  • 5
  • 45
  • 70
  • Unfortunately, disabling development mode won't have any effect here. This particular features does not change behaviour between dev and prod modes. – Lincoln Apr 01 '12 at 05:54
  • @IturPablo, you better catch @Lincoln while he's around, nobody knows the subject better than him, he's author of `PrettyFaces` )) – andbi Apr 01 '12 at 20:29
1

The custom Processor will be created once for each request - https://github.com/ocpsoft/prettyfaces/blob/3.x/core/src/main/java/com/ocpsoft/pretty/faces/rewrite/processor/CustomClassProcessor.java

If you need to be able to do this kind of integration, particularly if you want a configuration element to live as long as your application, then I might ask what you are trying to do with it, because the PrettyFaces processor, while it can be used for this, is not very flexible, whereas...

OCPsoft Rewrite - URLRewriteFilter (the core for PrettyFaces 4) is capable of integrating CDI into your configuration, and gives you more power than you previously had with Processors from PrettyFaces, while still making things simpler... for example: you might want to use the CDI integration to scope your configuration, or inject database access classes.

https://github.com/ocpsoft/rewrite/tree/master/integration-cdi

You will have much more control using Rewrite, today (or PrettyFaces4 when it is released.)

Lincoln
  • 3,151
  • 17
  • 22
  • Hi, I manage to inject my spring dependencies already ;) (great work by the way). So now if I extend from HttpConfigurationProvider will i be able to setup the scope of it ? – IturPablo Apr 01 '12 at 15:46
  • Just implement the getConfiguration() method and return ConfigurationBuilder.create()... (add your rules here). – Lincoln Apr 03 '12 at 14:19