@Override public void init(ConfigurationProvider configurationProvider) { LOG.debug("Initializing observer configuration"); tracker = new ServiceTracker<SessionFactoryObserver, SessionFactoryObserver>(bundleContext, SessionFactoryObserver.class, null); tracker.open(); bundleContext.addBundleListener(new SynchronousBundleListener() { @Override public void bundleChanged(BundleEvent event) { if (event.getBundle().equals(bundleContext.getBundle()) && event.getType() == BundleEvent.STOPPING) { tracker.close(); tracker = null; } } }); configurationProvider.getConfiguration().setSessionFactoryObserver(this); configurationProvider.invalidate(); }
@Override public void sessionFactoryCreated(SessionFactory factory) { if ( observers == null ) { return; } for ( SessionFactoryObserver observer : observers ) { observer.sessionFactoryCreated( factory ); } }
@Override public void sessionFactoryCreated(SessionFactory factory) { LOG.debug("Session factory has been created, calling all SessionFactoryObserver services"); for (SessionFactoryObserver observer : tracker.getTracked().values()) { observer.sessionFactoryCreated(factory); } }
@Override public void sessionFactoryClosed(SessionFactory factory) { LOG.debug("Session factory has been closed, calling all SessionFactoryObserver services"); for (SessionFactoryObserver observer : tracker.getTracked().values()) { observer.sessionFactoryClosed(factory); } }
private void registerObserverServices() { LOG.debug("Registering observer services"); dialectPublisherObserver = new DialectPublisherObserver(context); listenerObserver = new ListenerObserver(context); listenerObserver.init(); serviceRegistrationStack.push(context.registerService(SessionFactoryObserver.class, dialectPublisherObserver, null)); LOG.debug("DialectPublisherObserver registered"); serviceRegistrationStack.push(context.registerService(SessionFactoryObserver.class, listenerObserver, null)); LOG.debug("ListenerObserver registered"); }
public void addObserver(SessionFactoryObserver observer) { sessionFactoryImplementor.addObserver(observer); }
public SessionFactoryObserver getSessionFactoryObserver() { return sessionFactoryObserver; }
public void setSessionFactoryObserver(SessionFactoryObserver sessionFactoryObserver) { this.sessionFactoryObserver = sessionFactoryObserver; }
public void addObserver(SessionFactoryObserver observer) { if ( observers == null ) { observers = new ArrayList<SessionFactoryObserver>(); } observers.add( observer ); }
@Override public void addObserver(SessionFactoryObserver observer) { this.observer.addObserver( observer ); }
@Override public void addObserver(SessionFactoryObserver observer) { this.observer.addObserver(observer); }
public void addObserver(SessionFactoryObserver observer);