+1 kind regards
Tobias > Am 17.11.2016 um 11:07 schrieb Emond Papegaaij <emond.papega...@topicus.nl>: > > +1 > >> On Thu, Nov 17, 2016 at 12:37 AM, Martin Grigorov <mgrigo...@apache.org> >> wrote: >> Yes. This discussion is about exactly what I propose. >> I like the idea. >> >> Other opinions ? >> >> Martin Grigorov >> Wicket Training and Consulting >> https://twitter.com/mtgrigorov >> >>> On Wed, Nov 16, 2016 at 11:00 AM, Sven Meier <s...@meiers.net> wrote: >>> >>> Here's a discussion about on this topic: >>> >>> http://stackoverflow.com/questions/32440873/is-it-ok-to-add- >>> default-implementations-to-methods-of-an-interface-which-represe >>> >>> It's something new to get used to, but +1 for getting rid of all adapter >>> classes. >>> >>> Have fun >>> Sven >>> >>> >>> >>>> Am 15.11.2016 um 21:53 schrieb Martin Grigorov: >>>> >>>> What do you think about making methods like >>>> IApplicationListener#onAfterInitialized() a 'default' method with empty >>>> body ? Same for #onBeforeDestroyed() and all other similar methods in >>>> other >>>> classes >>>> >>>> This way there won't be a need to create adapters like >>>> AjaxRequestTarger.AbstractListener and there won't be a need to implement >>>> methods in which the application is not interested in like I do below with >>>> #onAfterInitialized(). >>>> >>>> Martin Grigorov >>>> Wicket Training and Consulting >>>> https://twitter.com/mtgrigorov >>>> >>>> On Tue, Nov 15, 2016 at 9:43 PM, <mgrigo...@apache.org> wrote: >>>> >>>> Repository: wicket >>>>> Updated Branches: >>>>> refs/heads/master 498f185ed -> 21837bccc >>>>> >>>>> >>>>> WICKET-6277 Broadcasting ClosedMessage about the JSR 356 WebSocket >>>>> connection after the container was turned off >>>>> >>>>> Do not notify the websocket behaviors/resources when the application is >>>>> already destroyed. >>>>> Add non-null checks for IPageStore in PageStoreManager. >>>>> >>>>> >>>>> Project: http://git-wip-us.apache.org/repos/asf/wicket/repo >>>>> Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/21837bcc >>>>> Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/21837bcc >>>>> Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/21837bcc >>>>> >>>>> Branch: refs/heads/master >>>>> Commit: 21837bcccd78bb529c2f33fbcd947ff5b9732739 >>>>> Parents: 498f185 >>>>> Author: Martin Tzvetanov Grigorov <mgrigo...@apache.org> >>>>> Authored: Tue Nov 15 21:41:26 2016 +0100 >>>>> Committer: Martin Tzvetanov Grigorov <mgrigo...@apache.org> >>>>> Committed: Tue Nov 15 21:41:26 2016 +0100 >>>>> >>>>> ---------------------------------------------------------------------- >>>>> .../apache/wicket/page/PageStoreManager.java | 20 +++++++--- >>>>> .../protocol/ws/javax/WicketEndpoint.java | 40 >>>>> +++++++++++++++++++- >>>>> 2 files changed, 53 insertions(+), 7 deletions(-) >>>>> ---------------------------------------------------------------------- >>>>> >>>>> >>>>> http://git-wip-us.apache.org/repos/asf/wicket/blob/ >>>>> 21837bcc/wicket-core/src/main/java/org/apache/wicket/page/ >>>>> PageStoreManager.java >>>>> ---------------------------------------------------------------------- >>>>> diff --git a/wicket-core/src/main/java/org/apache/wicket/page/PageStore >>>>> Manager.java >>>>> b/wicket-core/src/main/java/org/apache/wicket/page/PageStoreManager.java >>>>> index 9585669..88bffa4 100644 >>>>> --- a/wicket-core/src/main/java/org/apache/wicket/page/ >>>>> PageStoreManager.java >>>>> +++ b/wicket-core/src/main/java/org/apache/wicket/page/ >>>>> PageStoreManager.java >>>>> @@ -167,10 +167,14 @@ public class PageStoreManager extends >>>>> AbstractPageManager >>>>> sessionCache = new ArrayList<>(); >>>>> } >>>>> >>>>> - for (Object o : afterReadObject) >>>>> + final IPageStore pageStore = getPageStore(); >>>>> + if (pageStore != null) >>>>> { >>>>> - IManageablePage page = >>>>> getPageStore().convertToPage(o); >>>>> - addPage(page); >>>>> + for (Object o : afterReadObject) >>>>> + { >>>>> + IManageablePage page = >>>>> pageStore.convertToPage(o); >>>>> + addPage(page); >>>>> + } >>>>> } >>>>> >>>>> afterReadObject = null; >>>>> @@ -189,10 +193,11 @@ public class PageStoreManager extends >>>>> AbstractPageManager >>>>> convertAfterReadObjects(); >>>>> } >>>>> >>>>> + IManageablePage page = null; >>>>> // try to find page with same id >>>>> if (sessionCache != null) >>>>> { >>>>> - IManageablePage page = findPage(id); >>>>> + page = findPage(id); >>>>> if (page != null) >>>>> { >>>>> return page; >>>>> @@ -200,7 +205,12 @@ public class PageStoreManager extends >>>>> AbstractPageManager >>>>> } >>>>> >>>>> // not found, ask pagestore for the page >>>>> - return getPageStore().getPage(sessionId, id); >>>>> + final IPageStore pageStore = getPageStore(); >>>>> + if (pageStore != null) >>>>> + { >>>>> + page = pageStore.getPage(sessionId, id); >>>>> + } >>>>> + return page; >>>>> } >>>>> >>>>> /** >>>>> >>>>> http://git-wip-us.apache.org/repos/asf/wicket/blob/21837bcc/ >>>>> wicket-native- >>>>> websocket/wicket-native-websocket-javax/src/main/java/ >>>>> org/apache/wicket/protocol/ws/javax/WicketEndpoint.java >>>>> ---------------------------------------------------------------------- >>>>> diff --git a/wicket-native-websocket/wicket-native-websocket-javax/ >>>>> src/main/java/org/apache/wicket/protocol/ws/javax/WicketEndpoint.java >>>>> b/wicket-native-websocket/wicket-native-websocket-javax/ >>>>> src/main/java/org/apache/wicket/protocol/ws/javax/WicketEndpoint.java >>>>> index 9de80f1..dec2c3e 100644 >>>>> --- a/wicket-native-websocket/wicket-native-websocket-javax/ >>>>> src/main/java/org/apache/wicket/protocol/ws/javax/WicketEndpoint.java >>>>> +++ b/wicket-native-websocket/wicket-native-websocket-javax/ >>>>> src/main/java/org/apache/wicket/protocol/ws/javax/WicketEndpoint.java >>>>> @@ -18,12 +18,15 @@ package org.apache.wicket.protocol.ws.javax; >>>>> >>>>> import java.util.List; >>>>> import java.util.Map; >>>>> +import java.util.concurrent.atomic.AtomicBoolean; >>>>> >>>>> import javax.websocket.CloseReason; >>>>> import javax.websocket.Endpoint; >>>>> import javax.websocket.EndpointConfig; >>>>> import javax.websocket.Session; >>>>> >>>>> +import org.apache.wicket.Application; >>>>> +import org.apache.wicket.IApplicationListener; >>>>> import org.apache.wicket.ThreadContext; >>>>> import org.apache.wicket.protocol.http.WebApplication; >>>>> import org.apache.wicket.util.lang.Checks; >>>>> @@ -43,6 +46,8 @@ public class WicketEndpoint extends Endpoint >>>>> */ >>>>> private static final String WICKET_APP_PARAM_NAME = >>>>> "wicket-app-name"; >>>>> >>>>> + private final AtomicBoolean applicationDestroyed = new >>>>> AtomicBoolean(false); >>>>> + >>>>> private JavaxWebSocketProcessor javaxWebSocketProcessor; >>>>> >>>>> @Override >>>>> @@ -51,6 +56,7 @@ public class WicketEndpoint extends Endpoint >>>>> String appName = getApplicationName(session); >>>>> >>>>> WebApplication app = (WebApplication) >>>>> WebApplication.get(appName); >>>>> + app.getApplicationListeners().add(new >>>>> ApplicationListener( >>>>> applicationDestroyed)); >>>>> >>>>> try >>>>> { >>>>> @@ -68,7 +74,10 @@ public class WicketEndpoint extends Endpoint >>>>> { >>>>> super.onClose(session, closeReason); >>>>> >>>>> - javaxWebSocketProcessor.onClo >>>>> se(closeReason.getCloseCode().getCode(), >>>>> closeReason.getReasonPhrase()); >>>>> + if (isApplicationAlive()) >>>>> + { >>>>> + javaxWebSocketProcessor.onClo >>>>> se(closeReason.getCloseCode().getCode(), >>>>> closeReason.getReasonPhrase()); >>>>> + } >>>>> } >>>>> >>>>> @Override >>>>> @@ -77,7 +86,14 @@ public class WicketEndpoint extends Endpoint >>>>> LOG.error("An error occurred in web socket connection >>>>> with >>>>> id : " + session.getId(), t); >>>>> super.onError(session, t); >>>>> >>>>> - javaxWebSocketProcessor.onError(t); >>>>> + if (isApplicationAlive()) >>>>> + { >>>>> + javaxWebSocketProcessor.onError(t); >>>>> + } >>>>> + } >>>>> + >>>>> + private boolean isApplicationAlive() { >>>>> + return applicationDestroyed.get() == false; >>>>> } >>>>> >>>>> private String getApplicationName(Session session) >>>>> @@ -113,4 +129,24 @@ public class WicketEndpoint extends Endpoint >>>>> return appName; >>>>> } >>>>> >>>>> + private static class ApplicationListener implements >>>>> IApplicationListener >>>>> + { >>>>> + private final AtomicBoolean applicationDestroyed; >>>>> + >>>>> + private ApplicationListener(AtomicBoolean >>>>> applicationDestroyed) >>>>> + { >>>>> + this.applicationDestroyed = applicationDestroyed; >>>>> + } >>>>> + >>>>> + @Override >>>>> + public void onAfterInitialized(Application application) >>>>> + { >>>>> + } >>>>> + >>>>> + @Override >>>>> + public void onBeforeDestroyed(Application application) >>>>> + { >>>>> + applicationDestroyed.set(true); >>>>> + } >>>>> + } >>>>> } >>>>> >>>>> >>>>> >>>