David E Jones wrote:

The more common approach, and what would be even faster than a static method with an internal cache, is to use a factory method that is smart enough to see if an object for the given original String already exists and if so then use it.

This implies that the FlexibleStringExpander is immutable, which I looked at real quick and it appears to already be.

I was thinking about using the javolution ObjectFactory to do object recycling (like in GenericDelegator), but that really isn't needed for an immutable Object pattern like this where the objects retrieved are kept and reused and not rebuilt each time rather than being thrown away and recreated frequently.

BTW, the factory method with an actual instance pointed to in the user objects is faster than the static method doing a lookup in an internal cache mostly because it saves on the lookup.

Most excellent.

I'm working on changing service engines to cache invocations. Doing a loadClass, getMethod each time is slow; caching the looked up field is a significant speedup.

The biggest issue is that each engine and modelservice is not tied tightly; I'd like to have the model do the invocation, so that the cached invoker(whether it is a reflected method, or some other more advanced construct) can be cached and auto-cleared if the model changes.

Reply via email to