cleanup TODOs for decoration

Signed-off-by: Greg Wilkins <gregw@webtide.com>
This commit is contained in:
Greg Wilkins 2023-02-07 07:46:03 +11:00
parent 5cc07994c0
commit 461c306fcf
3 changed files with 7 additions and 5 deletions

View File

@ -32,7 +32,7 @@ import org.slf4j.LoggerFactory;
* <p>
* Can be found in the ServletContext Attributes at the {@link #ATTR DecoratedObjectFactory.ATTR} key.
*/
public class DecoratedObjectFactory implements Iterable<Decorator>
public class DecoratedObjectFactory implements Iterable<Decorator>, Decorator
{
private static final Logger LOG = LoggerFactory.getLogger(DecoratedObjectFactory.class);
@ -43,8 +43,6 @@ public class DecoratedObjectFactory implements Iterable<Decorator>
private static final ThreadLocal<Object> decoratorInfo = new ThreadLocal<>();
private List<Decorator> decorators = new ArrayList<>();
public static void associateInfo(Object info)
{
decoratorInfo.set(info);
@ -60,6 +58,9 @@ public class DecoratedObjectFactory implements Iterable<Decorator>
return decoratorInfo.get();
}
private final List<Decorator> decorators = new ArrayList<>();
public void addDecorator(Decorator decorator)
{
LOG.debug("Adding Decorator: {}", decorator);

View File

@ -2137,8 +2137,8 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
{
try
{
// TODO object factory!
return clazz.getDeclaredConstructor().newInstance();
T instance = clazz.getDeclaredConstructor().newInstance();
return getCoreContext().decorate(instance);
}
catch (Exception e)
{

View File

@ -173,6 +173,7 @@ public class ServletContextHandler extends ContextHandler
_servletHandler = servletHandler;
_objFactory = new DecoratedObjectFactory();
addBean(_objFactory, true);
// Link the handlers
relinkHandlers();