Search in sources :

Example 1 with AbstractConfiguredObject

use of org.apache.qpid.server.model.AbstractConfiguredObject in project qpid-broker-j by apache.

the class VirtualHostLoggerTest method testLoggersRemovedOnVirtualHostStop.

@Test
public void testLoggersRemovedOnVirtualHostStop() {
    VirtualHostLogger logger = createVirtualHostLogger();
    ((AbstractConfiguredObject<?>) _virtualHost).stop();
    Appender<ILoggingEvent> appender = ((ch.qos.logback.classic.Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME)).getAppender(logger.getName());
    assertNull("Appender was not deleted", appender);
}
Also used : AbstractConfiguredObject(org.apache.qpid.server.model.AbstractConfiguredObject) VirtualHostLogger(org.apache.qpid.server.model.VirtualHostLogger) ILoggingEvent(ch.qos.logback.classic.spi.ILoggingEvent) EventLogger(org.apache.qpid.server.logging.EventLogger) Logger(org.slf4j.Logger) VirtualHostLogger(org.apache.qpid.server.model.VirtualHostLogger) Test(org.junit.Test)

Example 2 with AbstractConfiguredObject

use of org.apache.qpid.server.model.AbstractConfiguredObject in project qpid-broker-j by apache.

the class VirtualHostStoreUpgraderAndRecoverer method recover.

private void recover(final ConfiguredObject<?> recoveryRoot, final DurableConfigurationStore durableConfigurationStore, final List<ConfiguredObjectRecord> records, final boolean isNew) {
    new GenericRecoverer(recoveryRoot).recover(records, isNew);
    final StoreConfigurationChangeListener configChangeListener = new StoreConfigurationChangeListener(durableConfigurationStore);
    if (_virtualHostNode.getVirtualHost() != null) {
        applyRecursively(_virtualHostNode.getVirtualHost(), new RecursiveAction<ConfiguredObject<?>>() {

            @Override
            public boolean applyToChildren(final ConfiguredObject<?> object) {
                return object.isDurable();
            }

            @Override
            public void performAction(final ConfiguredObject<?> object) {
                object.addChangeListener(configChangeListener);
            }
        });
    }
    if (recoveryRoot instanceof VirtualHostNode) {
        _virtualHostNode.addChangeListener(new AbstractConfigurationChangeListener() {

            @Override
            public void childAdded(final ConfiguredObject<?> object, final ConfiguredObject<?> child) {
                if (child instanceof VirtualHost) {
                    applyRecursively(child, new RecursiveAction<ConfiguredObject<?>>() {

                        @Override
                        public boolean applyToChildren(final ConfiguredObject<?> object) {
                            return object.isDurable();
                        }

                        @Override
                        public void performAction(final ConfiguredObject<?> object) {
                            if (object.isDurable()) {
                                durableConfigurationStore.update(true, object.asObjectRecord());
                                object.addChangeListener(configChangeListener);
                            }
                        }
                    });
                }
            }

            @Override
            public void childRemoved(final ConfiguredObject<?> object, final ConfiguredObject<?> child) {
                if (child instanceof VirtualHost) {
                    child.removeChangeListener(configChangeListener);
                }
            }
        });
        if (isNew) {
            if (_virtualHostNode instanceof AbstractConfiguredObject) {
                ((AbstractConfiguredObject) _virtualHostNode).forceUpdateAllSecureAttributes();
            }
        }
    }
}
Also used : AbstractConfiguredObject(org.apache.qpid.server.model.AbstractConfiguredObject) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) AbstractConfiguredObject(org.apache.qpid.server.model.AbstractConfiguredObject) VirtualHost(org.apache.qpid.server.model.VirtualHost) VirtualHostNode(org.apache.qpid.server.model.VirtualHostNode) StoreConfigurationChangeListener(org.apache.qpid.server.configuration.store.StoreConfigurationChangeListener) AbstractConfigurationChangeListener(org.apache.qpid.server.model.AbstractConfigurationChangeListener)

Aggregations

AbstractConfiguredObject (org.apache.qpid.server.model.AbstractConfiguredObject)2 ILoggingEvent (ch.qos.logback.classic.spi.ILoggingEvent)1 StoreConfigurationChangeListener (org.apache.qpid.server.configuration.store.StoreConfigurationChangeListener)1 EventLogger (org.apache.qpid.server.logging.EventLogger)1 AbstractConfigurationChangeListener (org.apache.qpid.server.model.AbstractConfigurationChangeListener)1 ConfiguredObject (org.apache.qpid.server.model.ConfiguredObject)1 VirtualHost (org.apache.qpid.server.model.VirtualHost)1 VirtualHostLogger (org.apache.qpid.server.model.VirtualHostLogger)1 VirtualHostNode (org.apache.qpid.server.model.VirtualHostNode)1 Test (org.junit.Test)1 Logger (org.slf4j.Logger)1