Hey Guys,<br><br>I'm working on an extension that @Observes ProcessAnnotatedType in order to modify the typing information for fields annotated with a specific Annotation.<br><br>When I use BeanManager to later construct an instance of AnnotatedType for that modified class, however, I am not supplied with the modified AnnotatedType instance, I am given a brand new instance that does not include my extension's prior modifications.<br>
<br>If this is right, then there needs to be some way to retrieve the previously modified data from the BeanManager, otherwise, the information is effectively lost unless the BeanManager is creating a full contextual instance of the class, not merely providing injection.<br>
<br>So this doesn't seem right to me. Thoughts?<br><br>Example code below.<br>Thanks,<br>Lincoln<br><br>--------------------------------------------------------------------------------------------------------<br> public <T> void processAnnotatedType(@Observes final ProcessAnnotatedType<T> event)<br>
{<br> AnnotatedTypeBuilder<T> builder = AnnotatedTypeBuilder.newInstance(event.getAnnotatedType());<br> builder.readAnnotationsFromUnderlyingType();<br> boolean modifiedType = false;<br><br> for (AnnotatedField<?> f : event.getAnnotatedType().getFields())<br>
{<br> if (f.isAnnotationPresent(InputField.class))<br> {<br> builder.overrideFieldType(f.getJavaMember(), Object.class);<br> modifiedType = true;<br> }<br> }<br><br>
if (modifiedType)<br> {<br> AnnotatedType<T> replacement = builder.create();<br> event.setAnnotatedType(replacement);<br> }<br> }<br><br><br>Then later... the AnnotatedType created in the method below not reflect changes
made to the type in the extension above.<br><br> public void injectNonContextualInstance(final Object instance)<br> {<br> if (instance != null)<br> {<br> CreationalContext<Object> creationalContext = manager.createCreationalContext(null);<br>
InjectionTarget<Object> injectionTarget = (InjectionTarget<Object>) manager.createInjectionTarget(beanManager.createAnnotatedType(instance.getClass()));<br> injectionTarget.inject(instance, creationalContext);<br>
}<br> }<br><br><br clear="all"><br>-- <br>Lincoln Baxter, III<br><a href="http://ocpsoft.com">http://ocpsoft.com</a><br><a href="http://scrumshark.com">http://scrumshark.com</a><br>"Keep it Simple"<br>