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);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -14,6 +14,12 @@ public abstract class AbstractHandler {
|
|||
public String toString() {
|
||||
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
|
||||
|
||||
|
|
|
@ -44,4 +44,6 @@ public abstract class ApplicationLifecycleHandler extends AbstractHandler implem
|
|||
if (e instanceof ApplicationLifecycleEvent.Stop)
|
||||
onStop(ApplicationLifecycleEvent.Stop.class.cast(e));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -204,24 +204,26 @@ public class DefaultProvider implements Provider {
|
|||
|
||||
try {
|
||||
|
||||
InputStream config = context.application().getResourceAsStream(handlers_file_path);
|
||||
|
||||
if (config == null) {
|
||||
// it's in a library, using
|
||||
InputStream defaultHandlersStream = getClass().getResourceAsStream(default_handlers_file_path);
|
||||
|
||||
if (defaultHandlersStream == null)
|
||||
throw new IllegalStateException("invalid distribution: cannot find " + default_handlers_file_path);
|
||||
|
||||
InputStream appSpecificHandlersStream = context.application().getResourceAsStream(handlers_file_path);
|
||||
|
||||
ApplicationConfigurationBinder binder = new ApplicationConfigurationBinder();
|
||||
|
||||
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);
|
||||
|
||||
// it's in a library, using
|
||||
config = getClass().getResourceAsStream(default_handlers_file_path);
|
||||
|
||||
if (config == null)
|
||||
throw new IllegalStateException("invalid distribution: cannot find " + default_handlers_file_path);
|
||||
|
||||
} else
|
||||
log.info("{} uses a custom lifecycle @ {}", context.name(), handlers_file_path);
|
||||
|
||||
ApplicationConfigurationBinder binder = new ApplicationConfigurationBinder();
|
||||
|
||||
return binder.bindHandlers(config);
|
||||
return defaultHandlers;
|
||||
|
||||
|
||||
} catch (RuntimeException e) {
|
||||
|
||||
|
@ -230,6 +232,7 @@ public class DefaultProvider implements Provider {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ApplicationExtensions extensionsFor(ApplicationContext context) {
|
||||
|
||||
|
|
Loading…
Reference in New Issue