|
|
|
i do not think it's working correctly.
at the moment PicoRegistrar gets a null instead of an implementation of ParameterResolver (ie DefaultParameterResolver). i think it should be either Registrar registrar = new PicoRegistrar(delegateContainer, delegateContainer.getComponentInstance(ParamaterResolver.class), picoLifecycleStrategy, registrarMonitor); or since picoContainer is already there, we could just get ParameterResolver component from pico directly in PicoRegistrar. (http://svn.codehaus.org/waffle/trunk/waffle-core/src/main/java/org/codehaus/waffle/registrar/pico/PicoRegistrar.java when initially refactoring for this fix I accidentally had the PicoContextContainerFactory construct the PicoRegistrar with a 'null' for the ParameterResolver (in the createRegistrar method).
also, i think this one and providing setter injection are cool features, we should update the doc on the website. (do you need help with that?)
just realized that my solution is not going to work since we are passing in a session level pico not the app one which has ParameterResolver component.
my solution was to
1) expose parameterResolver vi ComponentRegistry (getParameterResolver) 2) save servletConext in a procted value in AbstractContextContainerFactory 3) get componentRegestiry from servlet context at createRegistrat i.e. ComponentRegistry componentRegistry = (ComponentRegistry) servletContext.getAttribute(ComponentRegistry.class.getName()); 4) pass along componentRegistry.getParameterResolver() left some typos in my previous comment but i hope you get the gist. (too bad i can not edit in this jira version)
mike's fix solved the issue. thank you
Peter, I've updated the registrar docs to reflect latest changes. Thanks for the heads up.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||
Waffle has been updated to support both Pico's Constant a Component Parameters as well as several custom parameter implementation provided by Waffle (RequestParameter, RequestAttribute, SessionAttribute and ServletContext). These allow for parameter values to be resolved against these contexts.
The dependency on pico is encapsulated within Waffle (allowing for alternate or additional DI frameworks to be integrated with Waffle). In order to satisfy this defect Waffle now has created a Reference object. Implementation include ComponentReference, HttpSessionAttributeReference, RequestAttributeReference, RequestParameterReference and ServletContextReference. Each of these Reference implementation provides a static method that can be statically imported in a Registrar to simplify the registration of components. Example:
class FooComponent {
private String name;
private Long value;
private MyDAO dao;
public FooComponent(String name, Long value, MyDAO dao) { this.name = name; this.value = value; this.dao = dao; }
}
class TheRegistrar .. {
public void request() { register("dao", MyDAOImpl.class); // "Mike" - is a constant // requestParameter("count") - will resolve the value from the request parameter // component("dao") - will resolve against a named component (registered with Waffle) register("foo", FooComponent.class, "Mike", requestParameter("count"), component("dao")); }
}