Search in sources :

Example 1 with InstanceLifecycleEvent

use of org.glassfish.hk2.api.InstanceLifecycleEvent in project Payara by payara.

the class ConfigInstanceListener method lifecycleEvent.

/* (non-Javadoc)
     * @see org.glassfish.hk2.api.InstanceLifecycleListener#lifecycleEvent(org.glassfish.hk2.api.InstanceLifecycleEvent)
     */
@Override
public void lifecycleEvent(InstanceLifecycleEvent lifecycleEvent) {
    if (!lifecycleEvent.getEventType().equals(InstanceLifecycleEventType.POST_PRODUCTION)) {
        return;
    }
    Map<Injectee, Object> injectees = lifecycleEvent.getKnownInjectees();
    if (injectees == null)
        return;
    ConfigListener listener = (ConfigListener) lifecycleEvent.getLifecycleObject();
    for (Object injectee : injectees.values()) {
        if (!(injectee instanceof ConfigBeanProxy))
            continue;
        ConfigBeanProxy configBeanProxy = (ConfigBeanProxy) injectee;
        Object impl = ConfigSupport.getImpl(configBeanProxy);
        if (!(impl instanceof ObservableBean))
            continue;
        ObservableBean ob = (ObservableBean) impl;
        ob.addListener(listener);
    }
}
Also used : Injectee(org.glassfish.hk2.api.Injectee) ConfigBeanProxy(org.jvnet.hk2.config.ConfigBeanProxy) ConfigListener(org.jvnet.hk2.config.ConfigListener) ObservableBean(org.jvnet.hk2.config.ObservableBean)

Aggregations

Injectee (org.glassfish.hk2.api.Injectee)1 ConfigBeanProxy (org.jvnet.hk2.config.ConfigBeanProxy)1 ConfigListener (org.jvnet.hk2.config.ConfigListener)1 ObservableBean (org.jvnet.hk2.config.ObservableBean)1