Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed GatewayObserverApi interface to have default methods #877

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@
import org.kaazing.gateway.management.monitoring.configuration.MonitoringDataManagerInjector;
import org.kaazing.gateway.management.monitoring.configuration.impl.MonitoringDataManagerInjectorImpl;
import org.kaazing.gateway.management.monitoring.service.impl.MonitoredServiceImpl;
import org.kaazing.gateway.server.GatewayObserverFactorySpiPrototype;
import org.kaazing.gateway.server.GatewayObserverFactorySpi;
import org.kaazing.gateway.server.context.GatewayContext;
import org.kaazing.gateway.service.MonitoringEntityFactory;
import org.kaazing.gateway.service.Service;
import org.kaazing.gateway.service.ServiceContext;
import org.kaazing.mina.core.session.IoSessionEx;

public class ManagementGatewayObserver extends GatewayObserverFactorySpiPrototype {
public class ManagementGatewayObserver implements GatewayObserverFactorySpi {

private ManagementContext managementContext;
private Properties configuration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,95 +80,95 @@ private static void injectResources(Object target, Map<String, Object> values) {

@Override
public void initingService(ServiceContext serviceContext) {
for (GatewayObserverApi gatewayListener : gatewayListenerSpi) {
for (GatewayObserverFactorySpi gatewayListener : gatewayListenerSpi) {
gatewayListener.initingService(serviceContext);
}
}

@Override
public void initedService(ServiceContext serviceContext) {
for (GatewayObserverApi gatewayListener : gatewayListenerSpi) {
for (GatewayObserverFactorySpi gatewayListener : gatewayListenerSpi) {
gatewayListener.initedService(serviceContext);
}
}

@Override
public void startingService(ServiceContext serviceContext) {
for (GatewayObserverApi gatewayListener : gatewayListenerSpi) {
for (GatewayObserverFactorySpi gatewayListener : gatewayListenerSpi) {
gatewayListener.startingService(serviceContext);
}
}

@Override
public void startedService(ServiceContext serviceContext) {
for (GatewayObserverApi gatewayListener : gatewayListenerSpi) {
for (GatewayObserverFactorySpi gatewayListener : gatewayListenerSpi) {
gatewayListener.startedService(serviceContext);
}
}

@Override
public void stopingService(ServiceContext serviceContext) {
for (GatewayObserverApi gatewayListener : gatewayListenerSpi) {
for (GatewayObserverFactorySpi gatewayListener : gatewayListenerSpi) {
gatewayListener.stopingService(serviceContext);
}
}

@Override
public void stoppedService(ServiceContext serviceContext) {
for (GatewayObserverApi gatewayListener : gatewayListenerSpi) {
for (GatewayObserverFactorySpi gatewayListener : gatewayListenerSpi) {
gatewayListener.stoppedService(serviceContext);
}
}

@Override
public void quiesceingService(ServiceContext serviceContext) {
for (GatewayObserverApi gatewayListener : gatewayListenerSpi) {
for (GatewayObserverFactorySpi gatewayListener : gatewayListenerSpi) {
gatewayListener.quiesceingService(serviceContext);
}
}

@Override
public void quiescedService(ServiceContext serviceContext) {
for (GatewayObserverApi gatewayListener : gatewayListenerSpi) {
for (GatewayObserverFactorySpi gatewayListener : gatewayListenerSpi) {
gatewayListener.quiescedService(serviceContext);
}
}

@Override
public void destroyingService(ServiceContext serviceContext) {
for (GatewayObserverApi gatewayListener : gatewayListenerSpi) {
for (GatewayObserverFactorySpi gatewayListener : gatewayListenerSpi) {
gatewayListener.destroyingService(serviceContext);
}
}

@Override
public void destroyedService(ServiceContext serviceContext) {
for (GatewayObserverApi gatewayListener : gatewayListenerSpi) {
for (GatewayObserverFactorySpi gatewayListener : gatewayListenerSpi) {
gatewayListener.destroyedService(serviceContext);
}
}

@Override
public void startingGateway(GatewayContext gatewayContext) {
for (GatewayObserverFactorySpi gatewayListenerSpi : gatewayListenerSpi) {
injectResources(gatewayListenerSpi, gatewayContext.getInjectables());
for (GatewayObserverFactorySpi gatewayListener : gatewayListenerSpi) {
injectResources(gatewayListener, gatewayContext.getInjectables());
}

for (GatewayObserverApi gatewayListener : gatewayListenerSpi) {
for (GatewayObserverFactorySpi gatewayListener : gatewayListenerSpi) {
gatewayListener.startingGateway(gatewayContext);
}
}

@Override
public void initingGateway(Properties configuration, Map<String, Object> injectables) {
for (GatewayObserverApi gatewayListener : gatewayListenerSpi) {
for (GatewayObserverFactorySpi gatewayListener : gatewayListenerSpi) {
gatewayListener.initingGateway(configuration, injectables);
}
}

@Override
public void stoppedGateway(GatewayContext gatewayContext) {
for (GatewayObserverApi gatewayListener : gatewayListenerSpi) {
for (GatewayObserverFactorySpi gatewayListener : gatewayListenerSpi) {
gatewayListener.stoppedGateway(gatewayContext);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
import org.kaazing.gateway.service.ServiceContext;

/**
* GatewayObserverApi that allows classes to observe major gateway events. Implementing classes can be injected, @see
* {@link GatewayObserverFactorySpi}.
* GatewayObserverApi that allows classes to observe major gateway events.
*
*/
public interface GatewayObserverApi {
Expand All @@ -32,73 +31,73 @@ public interface GatewayObserverApi {
* Notification for when a service is being initiated
* @param serviceContext
*/
void initingService(ServiceContext serviceContext);
default void initingService(ServiceContext serviceContext){}

/**
* Notification that a service has been initiated
* @param serviceContext
*/
void initedService(ServiceContext serviceContext);
default void initedService(ServiceContext serviceContext){}

/**
* Notification that a service is starting
* @param serviceContext
*/
void startingService(ServiceContext serviceContext);
default void startingService(ServiceContext serviceContext){}

/**
* Notification that a service started
* @param serviceContext
*/
void startedService(ServiceContext serviceContext);
default void startedService(ServiceContext serviceContext){}

/**
* Notification that a service is being stopped
* @param serviceContext
*/
void stopingService(ServiceContext serviceContext);
default void stopingService(ServiceContext serviceContext){}

/**
* Notification that a service has been stopped
* @param serviceContext
*/
void stoppedService(ServiceContext serviceContext);
default void stoppedService(ServiceContext serviceContext){}

/**
* Notification that a service is being quiesced
* @param serviceContext
*/
void quiesceingService(ServiceContext serviceContext);
default void quiesceingService(ServiceContext serviceContext){}

/**
* Notification that a service has been quiesced
* @param serviceContext
*/
void quiescedService(ServiceContext serviceContext);
default void quiescedService(ServiceContext serviceContext){}

/**
* Notification that a service is being destroyed
* @param serviceContext
*/
void destroyingService(ServiceContext serviceContext);
default void destroyingService(ServiceContext serviceContext){}

/**
* Notification that a service has been destroyed
* @param serviceContext
*/
void destroyedService(ServiceContext serviceContext);
default void destroyedService(ServiceContext serviceContext){}

/**
* Notification that the gateway is starting
* @param gatewayContext
*/
void startingGateway(GatewayContext gatewayContext);
default void startingGateway(GatewayContext gatewayContext){}

/**
* Notification that the gateway is stopped
* @param gatewayContext
*/
void stoppedGateway(GatewayContext gatewayContext);
default void stoppedGateway(GatewayContext gatewayContext){}

/**
* Notification that the gateway is being initialized.
Expand All @@ -107,7 +106,7 @@ public interface GatewayObserverApi {
* @param configuration
* @param injectables
*/
void initingGateway(Properties configuration, Map<String, Object> injectables);
default void initingGateway(Properties configuration, Map<String, Object> injectables){}


}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
/**
* Gateway observers can be loaded via the ServiceLoader by extending this class
*/
public abstract class GatewayObserverFactorySpi implements GatewayObserverApi {
public interface GatewayObserverFactorySpi extends GatewayObserverApi {

}

This file was deleted.

4 changes: 2 additions & 2 deletions server/src/main/java/org/kaazing/gateway/server/Launcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ public class Launcher {

private GatewayContext context;

private final GatewayObserver gatewayListener;
private final GatewayObserverApi gatewayListener;

public Launcher(GatewayObserver gatewayListener) {
public Launcher(GatewayObserverApi gatewayListener) {
this.gatewayListener = gatewayListener;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.kaazing.gateway.server.ConfigurationObserver;
import org.kaazing.gateway.server.Gateway;
import org.kaazing.gateway.server.GatewayObserver;
import org.kaazing.gateway.server.GatewayObserverApi;
import org.kaazing.gateway.server.Launcher;
import org.kaazing.gateway.server.api.GatewayAlreadyRunningException;
import org.kaazing.gateway.server.config.june2016.GatewayConfigDocument;
Expand Down Expand Up @@ -292,7 +293,7 @@ public void launch() throws Exception {

LOGGER.info("Configuration file: " + gatewayConfigFile.getCanonicalPath());

GatewayObserver gatewayObserver = GatewayObserver.newInstance();
GatewayObserverApi gatewayObserver = GatewayObserver.newInstance();
GatewayConfigParser parser = new GatewayConfigParser(configuration);
GatewayConfigDocument config = parser.parse(gatewayConfigFile);
GatewayContextResolver resolver = new GatewayContextResolver(configDir, webRootDir, tempDir, jmxMBeanServer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import javax.management.MBeanServer;

import org.kaazing.gateway.server.GatewayObserver;
import org.kaazing.gateway.server.GatewayObserverApi;
import org.kaazing.gateway.server.Launcher;
import org.kaazing.gateway.server.config.june2016.AuthenticationType;
import org.kaazing.gateway.server.config.june2016.AuthenticationType.AuthorizationMode;
Expand Down Expand Up @@ -81,7 +82,7 @@ private enum State {
STARTING, STARTED, STOPPING, STOPPED
}

private final GatewayObserver gatewayObserver = GatewayObserver.newInstance();
private final GatewayObserverApi gatewayObserver = GatewayObserver.newInstance();
private final Launcher launcher = new Launcher(gatewayObserver);
private volatile State state = State.STOPPED;
private GatewayConfigDocument gatewayConfigXml;
Expand Down
Loading