forked from gCubeSystem/common-smartgears-legacy
git-svn-id: https://svn.d4science-ii.research-infrastructures.eu/gcube/branches/common/common-smartgears/2.1@146443 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
c623abdac5
commit
58f38685a9
|
@ -136,6 +136,17 @@ public class ApplicationHandlers {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void mergeWith(ApplicationHandlers other){
|
||||||
|
List<ApplicationLifecycleHandler> lifecycles = other.lifecycleHandlers();
|
||||||
|
for (ApplicationLifecycleHandler handler : lifecycles)
|
||||||
|
if (!this.lifecycleHandlers().contains(handler))
|
||||||
|
this.lifecycleHandlers().add(handler);
|
||||||
|
|
||||||
|
List<RequestHandler> requests = other.requestHandlers();
|
||||||
|
for (RequestHandler handler : requests)
|
||||||
|
if (!this.requestHandlers().contains(handler))
|
||||||
|
this.requestHandlers().add(handler);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -15,6 +15,12 @@ public abstract class AbstractHandler {
|
||||||
return getClass().getSimpleName();
|
return getClass().getSimpleName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final boolean equals(Object obj) {
|
||||||
|
AbstractHandler handler = (AbstractHandler) obj;
|
||||||
|
return this.getClass().getCanonicalName().equals(handler.getClass().getCanonicalName());
|
||||||
|
}
|
||||||
|
|
||||||
//so far, largely a placeholder for future cross-handler behaviour
|
//so far, largely a placeholder for future cross-handler behaviour
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,4 +44,6 @@ public abstract class ApplicationLifecycleHandler extends AbstractHandler implem
|
||||||
if (e instanceof ApplicationLifecycleEvent.Stop)
|
if (e instanceof ApplicationLifecycleEvent.Stop)
|
||||||
onStop(ApplicationLifecycleEvent.Stop.class.cast(e));
|
onStop(ApplicationLifecycleEvent.Stop.class.cast(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -204,24 +204,26 @@ public class DefaultProvider implements Provider {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
InputStream config = context.application().getResourceAsStream(handlers_file_path);
|
|
||||||
|
|
||||||
if (config == null) {
|
|
||||||
|
|
||||||
log.trace("{} uses the default lifecycle as it does not include {}", context.name(), handlers_file_path);
|
|
||||||
|
|
||||||
// it's in a library, using
|
// it's in a library, using
|
||||||
config = getClass().getResourceAsStream(default_handlers_file_path);
|
InputStream defaultHandlersStream = getClass().getResourceAsStream(default_handlers_file_path);
|
||||||
|
|
||||||
if (config == null)
|
if (defaultHandlersStream == null)
|
||||||
throw new IllegalStateException("invalid distribution: cannot find " + default_handlers_file_path);
|
throw new IllegalStateException("invalid distribution: cannot find " + default_handlers_file_path);
|
||||||
|
|
||||||
} else
|
InputStream appSpecificHandlersStream = context.application().getResourceAsStream(handlers_file_path);
|
||||||
log.info("{} uses a custom lifecycle @ {}", context.name(), handlers_file_path);
|
|
||||||
|
|
||||||
ApplicationConfigurationBinder binder = new ApplicationConfigurationBinder();
|
ApplicationConfigurationBinder binder = new ApplicationConfigurationBinder();
|
||||||
|
|
||||||
return binder.bindHandlers(config);
|
ApplicationHandlers defaultHandlers = binder.bindHandlers(defaultHandlersStream);
|
||||||
|
|
||||||
|
if (appSpecificHandlersStream !=null ){
|
||||||
|
defaultHandlers.mergeWith(binder.bindHandlers(appSpecificHandlersStream));
|
||||||
|
log.trace("{} uses default lifecycle with app spceific handler as it includes {}", context.name(), handlers_file_path);
|
||||||
|
} else
|
||||||
|
log.trace("{} uses the default lifecycle as it does not include {}", context.name(), handlers_file_path);
|
||||||
|
|
||||||
|
return defaultHandlers;
|
||||||
|
|
||||||
|
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
|
|
||||||
|
@ -230,6 +232,7 @@ public class DefaultProvider implements Provider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ApplicationExtensions extensionsFor(ApplicationContext context) {
|
public ApplicationExtensions extensionsFor(ApplicationContext context) {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue