public void onBeanLifecycleEvent(BeanContextLifecycleEvent event) {
if(event.getLifecycle() == BeanLifecycle.ADD || event.getLifecycle() == BeanLifecycle.CHANGE) {
Object bean = event.getBean();
BeanMetadata beanMetadata = new BeanMetadata(bean);
Map<String, BeanWriter> beanWriters = beanWriterMap.get(bean.getClass());
Fragment source = event.getSource();
if(source != null) {
String namespaceURI = source.getNamespaceURI();
beanMetadata.setNamespace(namespaceURI);
beanMetadata.setNamespacePrefix(source.getPrefix());
beanMetadata.setCreateSource(source);
beans.add(beanMetadata);
if(source.isDOMElement()) {
beanMetadata.setPreText(UnknownElementDataReaper.getPreText(source.getDOMElement(), beans, event));
} else {
// SAX pretext is gathered by an instance of the UnknownElementDataReaper
}
if(beanWriters != null) {