dev@glassfish.java.net

[ASK] Any confusion about the _at_Decorate annotation in HK2

From: lvsongping <lvsongping_at_cn.fujitsu.com>
Date: Fri, 10 May 2013 16:33:23 +0900

Hi, John:

Cc: Tom, Hong, Dev:

 

   I feel a little confused about the annotation which exist in
nucleus\admin\config-api\src\main\java\org\glassfish\config\support\Create.j
ava, The Decorate has been removed in the latest version of HK2 but the
instance here is still using the @Decorate annotation alongside to specify
the parent's method used to add the element to the parent. Here's the some
comments in Create.java:

*

* Sometimes, the @Create annotation cannot be used in the parent

* configuration object because the parent cannot have a direct

* reference its children types.

*

* For instance, if you have a declaration like

* <code>

* public interface ParentContainer {

* @Element("*)

* List<ParentConfigType> children();

* }

* </code>

*

* you cannot use the @Create annotation in such declaration because

* you do not know which subtypes of ParentConfigType will exist.

*

* In such cases, you should place the @Create on the child type

* and use the @Decorate annotation alongside to specify the parent's

* method used to add the element to the parent.

*

* <code>

* @Create(....)

* @Decorate(parentType=ParentContainer.class, methodName="children",

* with={Create.class})

* public interface SomeChild extends ParentConfigType {

* ...

* }

* </code>

*

 

After all, I have some questions about this:

1). Will the @Create annotation can be used in such declaration in the
latest version of glassfish? If it does, why not change the comments here
because many externel developers will confused about this instance when they
are preparing to develop such cases?

 

2).If the @Decorate has been changed to the other mode. Pls. tell me how to
use it and change the instance in Create.java so that I can know how to use
the @Create annotation in such declaration. I have search the internet and
found the John has simple replied that the PopulatorPostProcessor can
replace the Decorate. Could you clarify about this for me? Pls. write a
similar instance as it is descripted in Create.java

 

Thanks a lot

 

-Jeremy