The only quick obvious thought is that if this is for 3.x you'll probably
find a lot of tapestry users unable to move to jdk 1.5 just yet.
On 3/23/06, Mark Stang <[EMAIL PROTECTED]> wrote:
>
> All,
> This is a 3.x mechanism for dynamically creating components at runtime. I
> am posting it for two reasons, one is to provide a mechanism for other
> developers. The second is so that people can review the implementation and
> point out any "concerns".
>
> @SuppressWarnings("unchecked")
> private <T> T newComponent(String componentName, Class<T> baseClass,
> IRequestCycle cycle)
> {
> ComponentSpecificationResolver resolver = new
> ComponentSpecificationResolver(cycle);
> resolver.resolve(cycle, cycle.getPage().getNamespace(), null,
> componentName, null);
> IComponentSpecification spec = resolver.getSpecification();
>
> IEngine engine = cycle.getEngine();
> Class c =engine.getComponentClassEnhancer().getEnhancedClass(spec,
> baseClass.getName());
>
> try
> {
> IComponent result = (IComponent)c.newInstance();
> result.setSpecification(spec);
> result.setPage(cycle.getPage());
> result.setContainer(this);
> return (T)result;
> }
> catch (Exception e)
> {
> // Toss any instantiation exceptions up the stack; there's
> nothing to be done
> throw new RuntimeException(e);
> }
> }
>
> Thoughts?
>
> thanks,
>
> Mark
>
>
>
--
Jesse Kuhnert
Tacos/Tapestry, team member/developer
Open source based consulting work centered around
dojo/tapestry/tacos/hivemind. http://opennotion.com