Gianugo Rabellino wrote:

On Jul 6, 2004, at 11:35 AM, Sylvain Wallez wrote:

I changed that to

private String getSitemapPath() throws Exception {
return ObjectModelHelper.getRequest(
EnvironmentHelper.getCurrentEnvironment().getObjectModel()).getSitemap UR I();
}



Aargh! You should absolutely avoid to use the very-internal-and-private EnvironmentHelper class! ContextHelper is your friend ;-)


Good to know, even though this very class is very-internal-and-private as well. :-)

but being a freshman on Cocoon flow internals, I'm afraid this is going to introduce a nasty set of regressions. Can anyone more knowleadgeable verify the problem and possibly provide a more clever solution?


There is a solution, though: there's a different FlowIntepreter for each Processor instance (they are SingleThreaded), and so each interpreter instance could produce a unique identifier and use it as the result of getSitemapPath (which should therefore be renamed).


Any suggestions for a good unique identifier?

Thanks so much,


Since ID uniqueness doesn't have to survive JVM restart, a date-based generator like this should do the job (sorry, no time to commit it myself):

public class IDGenerator {
   private static long lastKey = 0;

   public static String getNewID() {
       long result;
       synchronized(IDGenerator.class) {
           while ((result = System.currentTimeMillis()) <= lastKey) {
               Thread.yeld(); // wait a bit
           }
           lastKey = result;
       }
       return String.valueOf(result);
   }
}

Sylvain

--
Sylvain Wallez                                  Anyware Technologies
http://www.apache.org/~sylvain           http://www.anyware-tech.com
{ XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects }



Reply via email to