@PostConstruct is a DependencyInjection oriented approach to attributing a
method to call after all variables have been injected and the object can
initialize knowing everything has been set. BXML does not support that, but
that's the analogy. You can actually call a depth-first traversal on your
root object and perform initialization after you call readObject() and
obtain the root object on the serializer. All of this is external to the
serializer and requires one extra method call to kick-start it.

myRoot = serializer.getRoot();
MyStaticClassUtils.initializeTree(myRoot);


But otherwise you change the serializer or use AOP. If you have written tree
events as you describe in another email, you can propagate a tunneling event
through the tree that calls initialize or checks for @PostConstruct.



-----Original Message-----
From: Michael Allman [mailto:[email protected]] 
Sent: Monday, July 26, 2010 8:41 PM
To: [email protected]
Subject: RE: [jira] Commented: (PIVOT-580) Add a Lifecycle callback
interface so that components know when they've been initialized

I don't know what @PostConstruct is.  Does it do what I want?  I just want 
to know when the serializer has finished building my component.  Jeeesh. 
You think there'd be a way...

Michael



On Mon, 26 Jul 2010, aappddeevv wrote:

> I think this is the @PostConstruct concept again. However, in a
parent-child
> tree you may have to bound the initialization process like in WPF
> (BeginInit, EndInit) because a parent component is not really initialized
> until its children are. You have to pick your semantics to figure out
what's
> right for you.
>
>
> -----Original Message-----
> From: Greg Brown (JIRA) [mailto:[email protected]]
> Sent: Monday, July 26, 2010 8:13 PM
> To: [email protected]
> Subject: [jira] Commented: (PIVOT-580) Add a Lifecycle callback interface
so
> that components know when they've been initialized
>
>
>    [
>
https://issues.apache.org/jira/browse/PIVOT-580?page=com.atlassian.jira.plug
>
in.system.issuetabpanels:comment-tabpanel&focusedCommentId=12892553#action_1
> 2892553 ]
>
> Greg Brown commented on PIVOT-580:
> ----------------------------------
>
> I understand. But keep in mind that BXML is just a shortcut to
instantiating
> and setting properties on Java objects "by hand". You wouldn't get any
such
> notifications in Java, so we don't provide them in BXML either. Your
classes
> should be able to function the same whether they are created by
> BXMLSerializer or some other means (i.e. programmatically).
>
>
>
>> Add a Lifecycle callback interface so that components know when they've
> been initialized
>>
>
----------------------------------------------------------------------------
> ------------
>>
>>                 Key: PIVOT-580
>>                 URL: https://issues.apache.org/jira/browse/PIVOT-580
>>             Project: Pivot
>>          Issue Type: New Feature
>>          Components: wtk
>>            Reporter: Michael Allman
>>
>> I just created
>> public interface Lifecycle {
>>     public void initialized();
>> }
>> because I want one of my custom components to know when it's been
> initialized.  The component takes a specific action after being
initialized.
> By "initialized", I mean "having all properties set".
>> The serializer calls this method after it has finished initializing the
> component, basically at the end of the processEndElement method.
>
> -- 
> This message is automatically generated by JIRA.
> -
> You can reply to this email to add a comment to the issue online.
>

Reply via email to