Repository: wicket Updated Branches: refs/heads/master d9bfc96e6 -> 0dd706949
http://git-wip-us.apache.org/repos/asf/wicket/blob/0dd70694/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/ResourceRegistrationListener.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/ResourceRegistrationListener.java b/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/ResourceRegistrationListener.java deleted file mode 100644 index cdeb439..0000000 --- a/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/ResourceRegistrationListener.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.wicket.atmosphere; - -import org.apache.wicket.Page; -import org.apache.wicket.Session; -import org.apache.wicket.request.cycle.RequestCycle; - -/** - * Listener interface for intercepting the registration of Atmosphere resources for pages. For every - * page that has an Atmosphere resource, {@link #resourceRegistered(String, Page)} will be called. - * When the suspended connection is terminated (by a page unload, session termination or a closed - * connection), {@link #resourceUnregistered(String)} is invoked. - * - * @author papegaaij - */ -public interface ResourceRegistrationListener -{ - /** - * Invoked when a new suspended connection is setup and registered for a page. This method is - * invoked in the context of a wicket request where the {@link RequestCycle} and {@link Session} - * are available. The {@code Page} is attached and it is safe to call methods on it. However, - * you should never keep a reference to the page. Not only will this create memory leaks, but - * can only be accessed from the context of a Wicket request on that page. - * - * @param uuid - * @param page - */ - public void resourceRegistered(String uuid, Page page); - - /** - * Invoked when a suspended connection is terminated and unregistered. - * - * @param uuid - */ - public void resourceUnregistered(String uuid); -} http://git-wip-us.apache.org/repos/asf/wicket/blob/0dd70694/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/Subscribe.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/Subscribe.java b/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/Subscribe.java deleted file mode 100644 index 5bf9f61..0000000 --- a/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/Subscribe.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.wicket.atmosphere; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.apache.wicket.Session; -import org.apache.wicket.ajax.AjaxRequestTarget; -import org.apache.wicket.request.cycle.RequestCycle; - -import com.google.common.base.Predicate; - -/** - * Subscribes a method on a component to receive events of a certain type. The method should have 2 - * parameters: the first must be {@link AjaxRequestTarget}, the second defines the type of events to - * receive. This method will receive any event posted to the {@link EventBus} if it matches the type - * of the second parameter and the filter accepts it. Any context a Wicket component expects to be - * available, such as the {@link RequestCycle} and {@link Session}, is accessible on invocation of - * the method. - * - * <p> - * Annotated methods will automatically be detected by {@link AtmosphereEventSubscriptionCollector}. - * The page on which the component is placed will get a {@link AtmosphereBehavior}, which sets up a - * persistent connection (for example websocket or streaming http). - * - * @author papegaaij - */ -@Target(ElementType.METHOD) -@Retention(RetentionPolicy.RUNTIME) -public @interface Subscribe { - /** - * An optional filter on events to be received by the method. The filter cannot rely on any - * context. For example, the {@link RequestCycle} may not be available. For events filtered by - * this filter, Wicket-Atmosphere will not have to setup initiate the Wicket request cycle, - * which is quite expensive. - * - * @return The filter on events, defaults to no filter. - */ - Class<? extends Predicate<AtmosphereEvent>> filter() default NoFilterPredicate.class; - - /** - * An optional filter on events to be received by the method. This filter has access to the - * Wicket context, such as the {@link Session} and the {@link RequestCycle}. If your filter does - * not require this context, you should use {@link #filter()} to prevent unnecessary setup of - * the request cycle. - * - * @return The filter on events, defaults to no filter. - */ - Class<? extends Predicate<AtmosphereEvent>> contextAwareFilter() default NoFilterPredicate.class; -} http://git-wip-us.apache.org/repos/asf/wicket/blob/0dd70694/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/SubscribeAnnotationEventSubscriptionInvoker.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/SubscribeAnnotationEventSubscriptionInvoker.java b/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/SubscribeAnnotationEventSubscriptionInvoker.java deleted file mode 100644 index 81d0a14..0000000 --- a/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/SubscribeAnnotationEventSubscriptionInvoker.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.wicket.atmosphere; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -import org.apache.wicket.WicketRuntimeException; -import org.apache.wicket.ajax.AjaxRequestTarget; - -/** - * Handles invocations of methods annotated with {@link Subscribe} annotation. - */ -public class SubscribeAnnotationEventSubscriptionInvoker implements EventSubscriptionInvoker -{ - @Override - public void invoke(AjaxRequestTarget target, EventSubscription subscription, Object base, - AtmosphereEvent event, AjaxRequestInitializer ajaxRequestInitializer) - { - for (Method curMethod : base.getClass().getMethods()) - { - if (curMethod.isAnnotationPresent(Subscribe.class) && - curMethod.getName().equals(subscription.getMethodName())) - { - ajaxRequestInitializer.initialize(); - try - { - curMethod.setAccessible(true); - curMethod.invoke(base, target, event.getPayload()); - } - catch (IllegalAccessException e) - { - throw new WicketRuntimeException(e); - } - catch (IllegalArgumentException e) - { - throw new WicketRuntimeException(e); - } - catch (InvocationTargetException e) - { - throw new WicketRuntimeException(e); - } - } - } - } - -} http://git-wip-us.apache.org/repos/asf/wicket/blob/0dd70694/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/config/AtmosphereLogLevel.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/config/AtmosphereLogLevel.java b/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/config/AtmosphereLogLevel.java deleted file mode 100644 index 57938d7..0000000 --- a/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/config/AtmosphereLogLevel.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.wicket.atmosphere.config; - -/** - * The log levels used by Atmosphere JS. - * - * @author papegaaij - */ -@SuppressWarnings("javadoc") -public enum AtmosphereLogLevel { - DEBUG("debug"), INFO("info"), ERROR("error"); - - private String name; - - AtmosphereLogLevel(String name) - { - this.name = name; - } - - @Override - public String toString() - { - return name; - } -} http://git-wip-us.apache.org/repos/asf/wicket/blob/0dd70694/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/config/AtmosphereMethod.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/config/AtmosphereMethod.java b/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/config/AtmosphereMethod.java deleted file mode 100644 index 5e7d1b6..0000000 --- a/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/config/AtmosphereMethod.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.wicket.atmosphere.config; - -/** - * The HTTP method to be used by Atmosphere to setup the connection - * - * @author papegaaij - */ -@SuppressWarnings("javadoc") -public enum AtmosphereMethod { - GET, PUT, POST, DELETE; -} http://git-wip-us.apache.org/repos/asf/wicket/blob/0dd70694/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/config/AtmosphereParameters.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/config/AtmosphereParameters.java b/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/config/AtmosphereParameters.java deleted file mode 100644 index 6be018f..0000000 --- a/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/config/AtmosphereParameters.java +++ /dev/null @@ -1,667 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.wicket.atmosphere.config; - -import java.util.List; - -import org.apache.wicket.WicketRuntimeException; -import org.json.JSONException; -import org.json.JSONObject; - -/** - * Contains the parameters passed to the Atmosphere JQuery plugin. See - * {@link "https://github.com/Atmosphere/atmosphere/wiki/jQuery.atmosphere.js-API"} for details. - * - * @author papegaaij - */ -public class AtmosphereParameters -{ - private Integer connectTimeout; - private Integer reconnectInterval; - private Integer timeout; - private AtmosphereMethod method; - private List<String> headers; - private String contentType; - private String data; - private Boolean suspend; - private Integer maxRequest; - private Long maxStreamingLength; - private AtmosphereLogLevel logLevel; - private AtmosphereTransport transport = AtmosphereTransport.WEBSOCKET; - private AtmosphereTransport fallbackTransport; - private AtmosphereMethod fallbackMethod; - private String webSocketImpl; - private String webSocketUrl; - private String webSocketPathDelimiter; - private Boolean enableXDR; - private Boolean rewriteURL; - private Boolean attachHeadersAsQueryString; - private Boolean dropAtmosphereHeaders; - private Boolean executeCallbackBeforeReconnect; - private Boolean withCredentials; - private Boolean trackMessageLength = true; - private String messageDelimiter = "<|msg|>"; - private Boolean shared; - private Boolean readResponsesHeaders; - private Integer maxReconnectOnClose; - - /** - * @return The connect timeout. If the client fail to connect, the fallbackTransport will be - * used. - */ - public Integer getConnectTimeout() - { - return connectTimeout; - } - - /** - * The connect timeout. If the client fail to connect, the fallbackTransport will be used. - * - * @param connectTimeout - */ - public void setConnectTimeout(Integer connectTimeout) - { - this.connectTimeout = connectTimeout; - } - - /** - * @return The interval before an attempt to reconnect will be made. - */ - public Integer getReconnectInterval() - { - return reconnectInterval; - } - - /** - * The interval before an attempt to reconnect will be made. - * - * @param reconnectInterval - */ - public void setReconnectInterval(Integer reconnectInterval) - { - this.reconnectInterval = reconnectInterval; - } - - /** - * @return The maximum time a connection stay opened when no message (or event) are sent or - * received. - */ - public Integer getTimeout() - { - return timeout; - } - - /** - * The maximum time a connection stay opened when no message (or event) are sent or received. - * - * @param timeout - */ - public void setTimeout(Integer timeout) - { - this.timeout = timeout; - } - - /** - * @return The HTTP method to use. - */ - public AtmosphereMethod getMethod() - { - return method; - } - - /** - * The HTTP method to use. - * - * @param method - */ - public void setMethod(AtmosphereMethod method) - { - this.method = method; - } - - /** - * @return A list of headers to send - */ - public List<String> getHeaders() - { - return headers; - } - - /** - * A list of headers to send - * - * @param headers - */ - public void setHeaders(List<String> headers) - { - this.headers = headers; - } - - /** - * @return The request's content-type - */ - public String getContentType() - { - return contentType; - } - - /** - * The request's content-type - * - * @param contentType - */ - public void setContentType(String contentType) - { - this.contentType = contentType; - } - - /** - * @return The request body (required when doing a POST or PUT) - */ - public String getData() - { - return data; - } - - /** - * The request body (required when doing a POST or PUT) - * - * @param data - */ - public void setData(String data) - { - this.data = data; - } - - /** - * @return Suspend the request, always reconnect if the connection gets closed (for whatever - * reason), independently of the transport used. - */ - public Boolean getSuspend() - { - return suspend; - } - - /** - * Suspend the request, always reconnect if the connection gets closed (for whatever reason), - * independently of the transport used. - * - * @param suspend - */ - public void setSuspend(Boolean suspend) - { - this.suspend = suspend; - } - - /** - * @return The maximum number of requests that will be executed. Once the maximum gets reached, - * the connection will be closed. - */ - public Integer getMaxRequest() - { - return maxRequest; - } - - /** - * The maximum number of requests that will be executed. Once the maximum gets reached, the - * connection will be closed. - * - * @param maxRequest - */ - public void setMaxRequest(Integer maxRequest) - { - this.maxRequest = maxRequest; - } - - /** - * @return When the streaming transport is used, the maximum size of the body received. Once - * reached the connection will be closed and re-opened - */ - public Long getMaxStreamingLength() - { - return maxStreamingLength; - } - - /** - * When the streaming transport is used, the maximum size of the body received. Once reached the - * connection will be closed and re-opened - * - * @param maxStreamingLength - */ - public void setMaxStreamingLength(Long maxStreamingLength) - { - this.maxStreamingLength = maxStreamingLength; - } - - /** - * @return The log level. Value allowed are 'info', 'debug' and 'error' - */ - public AtmosphereLogLevel getLogLevel() - { - return logLevel; - } - - /** - * The log level. Value allowed are 'info', 'debug' and 'error' - * - * @param logLevel - */ - public void setLogLevel(AtmosphereLogLevel logLevel) - { - this.logLevel = logLevel; - } - - /** - * @return The transport Atmosphere will use between the client and server. Allowed value are - * polling, long-polling, streaming, jsonp, sse and websocket - */ - public AtmosphereTransport getTransport() - { - return transport; - } - - /** - * The transport Atmosphere will use between the client and server. Allowed value are polling, - * long-polling, streaming, jsonp, sse and websocket - * - * @param transport - */ - public void setTransport(AtmosphereTransport transport) - { - this.transport = transport; - } - - /** - * @return If either the client or server isn't able to support the selected 'transport', the - * fallback value will be used. Allowed value are polling, long-polling, streaming, - * jsonp, sse and websocket - */ - public AtmosphereTransport getFallbackTransport() - { - return fallbackTransport; - } - - /** - * If either the client or server isn't able to support the selected 'transport', the fallback - * value will be used. Allowed value are polling, long-polling, streaming, jsonp, sse and - * websocket - * - * @param fallbackTransport - */ - public void setFallbackTransport(AtmosphereTransport fallbackTransport) - { - this.fallbackTransport = fallbackTransport; - } - - /** - * @return Used when the fallbackTransport gets used. - */ - public AtmosphereMethod getFallbackMethod() - { - return fallbackMethod; - } - - /** - * Used when the fallbackTransport gets used. - * - * @param fallbackMethod - */ - public void setFallbackMethod(AtmosphereMethod fallbackMethod) - { - this.fallbackMethod = fallbackMethod; - } - - /** - * @return The WebSocket API to use. As an example, you can use Flash WebSocket - */ - public String getWebSocketImpl() - { - return webSocketImpl; - } - - /** - * The WebSocket API to use. As an example, you can use Flash WebSocket - * - * @param webSocketImpl - */ - public void setWebSocketImpl(String webSocketImpl) - { - this.webSocketImpl = webSocketImpl; - } - - /** - * @return The webSocketUrl appended to the request.data when defined - */ - public String getWebSocketUrl() - { - return webSocketUrl; - } - - /** - * The webSocketUrl appended to the request.data when defined. This is useful if the Atmosphere - * Server Side Component is using a custom implementation of WebSocketProtocol implementation - * and will be appended to WebSocket messages send to the server. The message will looks like: - * - * <pre> - * data = webSocketPathDelimiter + webSocketUrl + webSocketPathDelimiter + data; - * </pre> - * - * @param webSocketUrl - */ - public void setWebSocketUrl(String webSocketUrl) - { - this.webSocketUrl = webSocketUrl; - } - - /** - * @return The token delimiter used to wrap request.data when websockets messages are sent. This - * value is used with the webSocketUrl attribute. - */ - public String getWebSocketPathDelimiter() - { - return webSocketPathDelimiter; - } - - /** - * The token delimiter used to wrap request.data when websockets messages are sent. This value - * is used with the webSocketUrl attribute. - * - * @param webSocketPathDelimiter - */ - public void setWebSocketPathDelimiter(String webSocketPathDelimiter) - { - this.webSocketPathDelimiter = webSocketPathDelimiter; - } - - /** - * @return Enable CORS Cross Origin Resource Sharing. - */ - public Boolean getEnableXDR() - { - return enableXDR; - } - - /** - * Enable CORS Cross Origin Resource Sharing. - * - * @param enableXDR - */ - public void setEnableXDR(Boolean enableXDR) - { - this.enableXDR = enableXDR; - } - - /** - * - * @return When enableXDR is set to true, the rewriteURL will be used to decide if the - * JSESSION_ID cookie be send to the remote server. - */ - public Boolean getRewriteURL() - { - return rewriteURL; - } - - /** - * When enableXDR is set to true, the rewriteURL will be used to decide if the JSESSION_ID - * cookie be send to the remote server. - * - * @param rewriteURL - */ - public void setRewriteURL(Boolean rewriteURL) - { - this.rewriteURL = rewriteURL; - } - - /** - * @return Pass all headers as query string. - */ - public Boolean getAttachHeadersAsQueryString() - { - return attachHeadersAsQueryString; - } - - /** - * Pass all headers as query string. Some browser only support the GET method with some - * transport and prevent setting headers. As an example, the WebSocket API doesn't allow setting - * headers, and instead the headers will be passed as a query string. - * - * @param attachHeadersAsQueryString - */ - public void setAttachHeadersAsQueryString(Boolean attachHeadersAsQueryString) - { - this.attachHeadersAsQueryString = attachHeadersAsQueryString; - } - - /** - * @return Enable to drop the Atmosphere headers. - */ - public Boolean getDropAtmosphereHeaders() - { - return dropAtmosphereHeaders; - } - - /** - * By default Atmosphere adds headers like X-Atmosphere-Transport, X-Cache-Date etc. used by the - * server to track the browser state. The same information is passed as a query string by - * default (attachHeadersAsQueryString) so if you aren't planning to add any extra headers, set - * that value to true and instead let the attachHeadersAsQueryString pass the same information. - * Setting that value to true also facilitate CORS requests handling because no extra headers - * are added. - * - * @param dropAtmosphereHeaders - */ - public void setDropAtmosphereHeaders(Boolean dropAtmosphereHeaders) - { - this.dropAtmosphereHeaders = dropAtmosphereHeaders; - } - - /** - * @return Execute the request's callback before or after reconnecting again to the server. - */ - public Boolean getExecuteCallbackBeforeReconnect() - { - return executeCallbackBeforeReconnect; - } - - /** - * Execute the request's callback before or after reconnecting again to the server. - * - * @param executeCallbackBeforeReconnect - */ - public void setExecuteCallbackBeforeReconnect(Boolean executeCallbackBeforeReconnect) - { - this.executeCallbackBeforeReconnect = executeCallbackBeforeReconnect; - } - - /** - * @return True when user credentials are to be included in a cross-origin request. False when - * they are to be excluded in a cross-origin request and when cookies are to be ignored - * in its response. - */ - public Boolean getWithCredentials() - { - return withCredentials; - } - - /** - * True when user credentials are to be included in a cross-origin request. False when they are - * to be excluded in a cross-origin request and when cookies are to be ignored in its response. - * - * @param withCredentials - */ - public void setWithCredentials(Boolean withCredentials) - { - this.withCredentials = withCredentials; - } - - /** - * @return Track the size of the received request. - */ - public Boolean getTrackMessageLength() - { - return trackMessageLength; - } - - /** - * Track the size of the received request. This attribute must be used with the help of the - * Atmosphere's Server Side components called TrackMessageSizeFilter. When used, the server will - * use the following protocol when sending messages back to the client - * - * <pre> - * {@literal - * <message-length><message-delimiter> message <message-delimiter>} - * </pre> - * - * This attribute is useful when your server side component send large chunked message. Using - * the trackMessageLength, the client will make sure the message has been fully received before - * invoking the callback. If not set, the callback might be invoked with partial message. - * - * @param trackMessageLength - */ - public void setTrackMessageLength(Boolean trackMessageLength) - { - this.trackMessageLength = trackMessageLength; - } - - /** - * - * @return The token that delimit the message when the trackMessageLength attribute is used. - */ - public String getMessageDelimiter() - { - return messageDelimiter; - } - - /** - * The token that delimit the message when the trackMessageLength attribute is used. - * - * @param messageDelimiter - */ - public void setMessageDelimiter(String messageDelimiter) - { - this.messageDelimiter = messageDelimiter; - } - - /** - * @return When set to true, Atmospere will share a connection between different browser tabs - * and windows. Otherwise, a new connection will be established for each tab/window. - */ - public Boolean getShared() - { - return shared; - } - - /** - * When set to true, Atmospere will share a connection between different browser tabs and - * windows. Otherwise, a new connection will be established for each tab/window. - * - * @param shared - */ - public void setShared(Boolean shared) - { - this.shared = shared; - } - - /** - * @return *undocumented* - */ - public Boolean getReadResponsesHeaders() - { - return readResponsesHeaders; - } - - /** - * *undocumented* - * - * @param readResponsesHeaders - */ - public void setReadResponsesHeaders(Boolean readResponsesHeaders) - { - this.readResponsesHeaders = readResponsesHeaders; - } - - /** - * - * @return *undocumented* - */ - public Integer getMaxReconnectOnClose() - { - return maxReconnectOnClose; - } - - /** - * *undocumented* - * - * @param maxReconnectOnClose - */ - public void setMaxReconnectOnClose(Integer maxReconnectOnClose) - { - this.maxReconnectOnClose = maxReconnectOnClose; - } - - /** - * Transforms the paramters into a JSON object. - * - * @return A JSON object with all set paramters. - */ - public JSONObject toJSON() - { - try - { - JSONObject ret = new JSONObject(); - ret.put("connectTimeout", getConnectTimeout()); - ret.put("reconnectInterval", getReconnectInterval()); - ret.put("timeout", getTimeout()); - if (getMethod() != null) - ret.put("method", getMethod().toString()); - if (getHeaders() != null) - ret.put("headers", getHeaders()); - ret.put("contentType", getContentType()); - ret.put("data", getData()); - ret.put("suspend", getSuspend()); - ret.put("maxRequest", getMaxRequest()); - ret.put("maxStreamingLength", getMaxStreamingLength()); - if (getLogLevel() != null) - ret.put("logLevel", getLogLevel().toString()); - if (getTransport() != null) - ret.put("transport", getTransport().toString()); - if (getFallbackTransport() != null) - ret.put("fallbackTransport", getFallbackTransport().toString()); - if (getFallbackMethod() != null) - ret.put("fallbackMethod", getFallbackMethod().toString()); - ret.put("webSocketImpl", getWebSocketImpl()); - ret.put("webSocketUrl", getWebSocketUrl()); - ret.put("webSocketPathDelimiter", getWebSocketPathDelimiter()); - ret.put("enableXDR", getEnableXDR()); - ret.put("rewriteURL", getRewriteURL()); - ret.put("attachHeadersAsQueryString", getAttachHeadersAsQueryString()); - ret.put("dropAtmosphereHeaders", getDropAtmosphereHeaders()); - ret.put("executeCallbackBeforeReconnect", getExecuteCallbackBeforeReconnect()); - ret.put("withCredentials", getWithCredentials()); - ret.put("trackMessageLength", getTrackMessageLength()); - ret.put("messageDelimiter", getMessageDelimiter()); - ret.put("shared", getShared()); - ret.put("readResponsesHeaders", getReadResponsesHeaders()); - ret.put("maxReconnectOnClose", getMaxReconnectOnClose()); - return ret; - } - catch (JSONException e) - { - throw new WicketRuntimeException(e); - } - } -} http://git-wip-us.apache.org/repos/asf/wicket/blob/0dd70694/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/config/AtmosphereTransport.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/config/AtmosphereTransport.java b/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/config/AtmosphereTransport.java deleted file mode 100644 index 73d538b..0000000 --- a/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/config/AtmosphereTransport.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.wicket.atmosphere.config; - -/** - * The transport to be used by Atmosphere to setup the persistent connection. - * - * @author papegaaij - */ -@SuppressWarnings("javadoc") -public enum AtmosphereTransport { - POLLING("polling"), LONG_POLLING("long-polling"), STREAMING("streaming"), JSONP("jsonp"), SSE( - "sse"), WEBSOCKET("websocket"); - - private String name; - - AtmosphereTransport(String name) - { - this.name = name; - } - - @Override - public String toString() - { - return name; - } -} http://git-wip-us.apache.org/repos/asf/wicket/blob/0dd70694/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/jquery.wicketatmosphere.js ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/jquery.wicketatmosphere.js b/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/jquery.wicketatmosphere.js deleted file mode 100644 index e5b2db3..0000000 --- a/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/jquery.wicketatmosphere.js +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -;(function($) { - 'use strict'; - - $.fn.wicketAtmosphere = function(params) { - var callbackAdded = false; - - // jquery.atmosphere.response - function callback(response) { - - if (response.transport !== 'polling' && response.state === 'messageReceived') { - $.atmosphere.log('info', [ "response.responseBody: " + response.responseBody ]); - if (response.status === 200) { - Wicket.Ajax.process(response.responseBody); - } - } else if (response.state === "opening") { - } - } - - var connectedEndpoint = $.atmosphere.subscribe(params.url, - !callbackAdded ? callback : null, $.atmosphere.request = params); - callbackAdded = true; - - $(window).on("beforeunload", function() { - callbackAdded = false; - $.atmosphere.unsubscribe(); - }); - }; -}(jQuery)); http://git-wip-us.apache.org/repos/asf/wicket/blob/0dd70694/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/tester/AtmosphereTester.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/tester/AtmosphereTester.java b/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/tester/AtmosphereTester.java deleted file mode 100644 index eee9b19..0000000 --- a/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/tester/AtmosphereTester.java +++ /dev/null @@ -1,197 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.wicket.atmosphere.tester; - -import java.util.List; - -import org.apache.wicket.Page; -import org.apache.wicket.atmosphere.AtmosphereBehavior; -import org.apache.wicket.atmosphere.EventBus; -import org.apache.wicket.protocol.http.WebApplication; -import org.apache.wicket.protocol.http.mock.MockHttpServletResponse; -import org.apache.wicket.util.tester.WicketTester; -import org.atmosphere.cpr.AtmosphereConfig; -import org.atmosphere.cpr.AtmosphereFramework; -import org.atmosphere.cpr.AtmosphereResource; -import org.atmosphere.cpr.HeaderConfig; - -/** - * A helper for testing Atmosphere enabled pages - */ -public class AtmosphereTester -{ - /** - * The EventBus that will be used to post/push messages - * to the suspended http response - */ - private final EventBus eventBus; - - private final WicketTester wicketTester; - - /** - * The response which will be suspended by Atmosphere and - * all pushes/post will go to - */ - private MockHttpServletResponse suspendedResponse; - - private MockHttpServletResponse lastResponse; - - /** - * Constructor. - * - * @param wicketTester - * The testing helper - * @param page - * The page to test - */ - public AtmosphereTester(final WicketTester wicketTester, Page page) - { - this.wicketTester = wicketTester; - - WebApplication application = wicketTester.getApplication(); - - TesterBroadcaster broadcaster = createBroadcaster(); - - if (EventBus.isInstalled(application)) - { - this.eventBus = EventBus.get(application); - this.eventBus.setBroadcaster(broadcaster); - } - else - { - this.eventBus = new EventBus(application, broadcaster); - } - - initialize(wicketTester, page); - } - - private void initialize(final WicketTester wicketTester, Page page) - { - // remove any already installed AtmosphereBehaviors on the page - List<AtmosphereBehavior> behaviors = page.getBehaviors(AtmosphereBehavior.class); - page.remove(behaviors.toArray(new AtmosphereBehavior[behaviors.size()])); - - // install AtmosphereBehavior that doesn't use Meteor - AtmosphereBehavior atmosphereBehavior = new TesterAtmosphereBehavior(wicketTester, eventBus); - page.add(atmosphereBehavior); - - // start the page to collect all @Subscribe methods in the component hierarchy - wicketTester.startPage(page); - - // pretend it is a websocket connection - wicketTester.getRequest().setHeader(HeaderConfig.X_ATMOSPHERE_TRANSPORT, AtmosphereResource.TRANSPORT.WEBSOCKET.name()); - - // start the "upgrade" connection - suspendedResponse = wicketTester.getResponse(); - wicketTester.executeBehavior(atmosphereBehavior); - } - - private TesterBroadcaster createBroadcaster() - { - TesterBroadcaster broadcaster = new TesterBroadcaster(); - - AtmosphereFramework framework = new AtmosphereFramework(); - AtmosphereConfig config = new AtmosphereConfig(framework); - - TesterBroadcasterFactory broadcasterFactory = new TesterBroadcasterFactory(config, broadcaster); - framework.setBroadcasterFactory(broadcasterFactory); - - broadcaster.initialize("wicket-atmosphere-tester", config); - - return broadcaster; - } - - /** - * @return The collected so far pushed data in the suspended response - */ - public String getPushedResponse() - { - return suspendedResponse != null ? suspendedResponse.getDocument() : null; - } - - /** - * Resets the suspended response to be empty - * @return this instance, for chaining - */ - public AtmosphereTester resetResponse() - { - if (suspendedResponse != null) - { - suspendedResponse.reset(); - } - return this; - } - - /** - * Posts a message to all suspended responses - * - * @param message - * The message to push - * @return this instance, for chaining - */ - public AtmosphereTester post(Object message) - { - eventBus.post(message); - return this; - } - - /** - * Posts a message to the suspended response with the given uuid - * - * @param message - * The message to push - * @param resourceUuid - * The identifier of the suspended http response - * @return this instance, for chaining - */ - public AtmosphereTester post(Object message, String resourceUuid) - { - eventBus.post(message, resourceUuid); - return this; - } - - /** - * Switches the current <em>lastResponse</em> with the <em>suspendedResponse</em> - * so the application test can use WicketTester's assert methods. - * - * Note: Make sure to call {@linkplain #switchOffTestMode()} later to be able to - * assert on non-Atmosphere related responses - * - * @return this instance, for chaining - */ - public AtmosphereTester switchOnTestMode() - { - lastResponse = wicketTester.getLastResponse(); - wicketTester.setLastResponse(suspendedResponse); - return this; - } - - /** - * Sets back the <em>lastResponse</em> with the saved one by {@link #switchOnTestMode()}. - * - * @return this instance, for chaining - */ - public AtmosphereTester switchOffTestMode() - { - if (lastResponse != null) - { - wicketTester.setLastResponse(lastResponse); - lastResponse = null; - } - return this; - } -} http://git-wip-us.apache.org/repos/asf/wicket/blob/0dd70694/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/tester/TesterAsyncSupport.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/tester/TesterAsyncSupport.java b/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/tester/TesterAsyncSupport.java deleted file mode 100644 index 18bb39c..0000000 --- a/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/tester/TesterAsyncSupport.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.wicket.atmosphere.tester; - -import java.io.IOException; - -import javax.servlet.ServletConfig; -import javax.servlet.ServletException; - -import org.atmosphere.cpr.Action; -import org.atmosphere.cpr.AsyncSupport; -import org.atmosphere.cpr.AtmosphereRequest; -import org.atmosphere.cpr.AtmosphereResource; -import org.atmosphere.cpr.AtmosphereResponse; - -/** - * - */ -class TesterAsyncSupport<E extends AtmosphereResource> implements AsyncSupport<E> -{ - @Override - public String getContainerName() - { - return "wicket-atmosphere-tester"; - } - - @Override - public void init(ServletConfig sc) throws ServletException - { - } - - @Override - public Action service(AtmosphereRequest req, AtmosphereResponse res) throws IOException, ServletException - { - return Action.CONTINUE; - } - - @Override - public void action(E actionEvent) - { - } - - @Override - public boolean supportWebSocket() - { - return true; - } - - @Override - public AsyncSupport complete(E r) - { - return this; - } -} http://git-wip-us.apache.org/repos/asf/wicket/blob/0dd70694/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/tester/TesterAtmosphereBehavior.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/tester/TesterAtmosphereBehavior.java b/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/tester/TesterAtmosphereBehavior.java deleted file mode 100644 index d6632fe..0000000 --- a/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/tester/TesterAtmosphereBehavior.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.wicket.atmosphere.tester; - -import org.apache.wicket.Page; -import org.apache.wicket.atmosphere.AtmosphereBehavior; -import org.apache.wicket.atmosphere.EventBus; -import org.apache.wicket.util.tester.WicketTester; -import org.atmosphere.cpr.AtmosphereRequest; -import org.atmosphere.cpr.AtmosphereResource; -import org.atmosphere.cpr.AtmosphereResourceImpl; -import org.atmosphere.cpr.AtmosphereResponse; -import org.atmosphere.handler.AtmosphereHandlerAdapter; - -/** - * A specialization that doesn't use Meteor to create AtmosphereResource - * but creates it manually by using the WicketTester's http request and response - */ -class TesterAtmosphereBehavior extends AtmosphereBehavior -{ - private final EventBus eventBus; - private final WicketTester wicketTester; - - TesterAtmosphereBehavior(WicketTester wicketTester, EventBus eventBus) - { - this.wicketTester = wicketTester; - this.eventBus = eventBus; - } - - @Override - public void onRequest() - { - TesterBroadcaster broadcaster = (TesterBroadcaster) eventBus.getBroadcaster(); - - AtmosphereResource atmosphereResource = new AtmosphereResourceImpl(); - AtmosphereRequest atmosphereRequest = AtmosphereRequest.wrap(wicketTester.getRequest()); - AtmosphereResponse atmosphereResponse = AtmosphereResponse.wrap(wicketTester.getResponse()); - TesterAsyncSupport asyncSupport = new TesterAsyncSupport(); - atmosphereResource.initialize(broadcaster.getApplicationConfig(), broadcaster, atmosphereRequest, atmosphereResponse, - asyncSupport, new AtmosphereHandlerAdapter()); - - atmosphereResource.setBroadcaster(broadcaster); - broadcaster.addAtmosphereResource(atmosphereResource); - - String uuid = atmosphereResource.uuid(); - Page page = getComponent().getPage(); - - page.setMetaData(ATMOSPHERE_UUID, uuid); - eventBus.registerPage(uuid, page); - } -} http://git-wip-us.apache.org/repos/asf/wicket/blob/0dd70694/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/tester/TesterBroadcaster.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/tester/TesterBroadcaster.java b/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/tester/TesterBroadcaster.java deleted file mode 100644 index 7ec23ac..0000000 --- a/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/tester/TesterBroadcaster.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.wicket.atmosphere.tester; - -import org.atmosphere.cpr.AtmosphereConfig; -import org.atmosphere.cpr.AtmosphereResponse; -import org.atmosphere.cpr.Deliver; -import org.atmosphere.util.SimpleBroadcaster; - -/** - * - */ -class TesterBroadcaster extends SimpleBroadcaster -{ - public AtmosphereConfig getApplicationConfig() - { - return config; - } - - @Override - protected void push(Deliver entry) - { - AtmosphereResponse response = entry.getResource().getResponse(); - String message = entry.getMessage().toString(); - response.write(message); - } -} http://git-wip-us.apache.org/repos/asf/wicket/blob/0dd70694/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/tester/TesterBroadcasterFactory.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/tester/TesterBroadcasterFactory.java b/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/tester/TesterBroadcasterFactory.java deleted file mode 100644 index ef559c1..0000000 --- a/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/tester/TesterBroadcasterFactory.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.wicket.atmosphere.tester; - -import org.atmosphere.cpr.AtmosphereConfig; -import org.atmosphere.cpr.Broadcaster; -import org.atmosphere.cpr.BroadcasterLifeCyclePolicy; -import org.atmosphere.cpr.DefaultBroadcasterFactory; -import org.atmosphere.util.SimpleBroadcaster; - -/** -* -*/ -class TesterBroadcasterFactory extends DefaultBroadcasterFactory -{ - private final TesterBroadcaster singleBroadcaster; - - TesterBroadcasterFactory(AtmosphereConfig c, TesterBroadcaster broadcaster) - { - super(SimpleBroadcaster.class, BroadcasterLifeCyclePolicy.ATMOSPHERE_RESOURCE_POLICY.NEVER.name(), c); - - this.singleBroadcaster = broadcaster; - - // expose myself as BroadcasterFactory.getDefault(); - factory = this; - } - - @SuppressWarnings("unchecked") - @Override - public <T extends Broadcaster> T lookup(Class<T> c, Object id, boolean createIfNull, boolean unique) - { - return (T) singleBroadcaster; - } -} http://git-wip-us.apache.org/repos/asf/wicket/blob/0dd70694/wicket-experimental/wicket-atmosphere/src/main/resources/META-INF/services/org.apache.wicket.IInitializer ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-atmosphere/src/main/resources/META-INF/services/org.apache.wicket.IInitializer b/wicket-experimental/wicket-atmosphere/src/main/resources/META-INF/services/org.apache.wicket.IInitializer deleted file mode 100644 index 69885be..0000000 --- a/wicket-experimental/wicket-atmosphere/src/main/resources/META-INF/services/org.apache.wicket.IInitializer +++ /dev/null @@ -1 +0,0 @@ -org.apache.wicket.atmosphere.Initializer http://git-wip-us.apache.org/repos/asf/wicket/blob/0dd70694/wicket-experimental/wicket-atmosphere/src/test/java/org/apache/wicket/atmosphere/AtmosphereTesterTest.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-atmosphere/src/test/java/org/apache/wicket/atmosphere/AtmosphereTesterTest.java b/wicket-experimental/wicket-atmosphere/src/test/java/org/apache/wicket/atmosphere/AtmosphereTesterTest.java deleted file mode 100644 index 0d24910..0000000 --- a/wicket-experimental/wicket-atmosphere/src/test/java/org/apache/wicket/atmosphere/AtmosphereTesterTest.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.wicket.atmosphere; - -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.not; - -import java.util.Date; -import java.util.concurrent.atomic.AtomicBoolean; - -import org.apache.wicket.ajax.AjaxRequestTarget; -import org.apache.wicket.atmosphere.tester.AtmosphereTester; -import org.apache.wicket.request.mapper.parameter.PageParameters; -import org.apache.wicket.util.tester.FormTester; -import org.apache.wicket.util.tester.WicketTester; -import org.junit.Assert; -import org.junit.Test; - -/** - * - */ -public class AtmosphereTesterTest extends Assert -{ - final AtomicBoolean updateTimeCalled = new AtomicBoolean(false); - final AtomicBoolean receiveMessageCalled = new AtomicBoolean(false); - - @Test - public void atmospherePush() - { - final String updateTimeIsExecuted = "updateTime is executed!"; - - WicketTester tester = new WicketTester(); - HomePage page = new HomePage(new PageParameters()) - { - @Subscribe - public void updateTime(AjaxRequestTarget target, Date event) - { - super.updateTime(target, event); - - updateTimeCalled.set(true); - - target.appendJavaScript(updateTimeIsExecuted); - } - - @Subscribe(contextAwareFilter = ReceiverFilter.class) - public void receiveMessage(AjaxRequestTarget target, ChatMessage message) - { - super.receiveMessage(target, message); - receiveMessageCalled.set(true); - } - }; - - AtmosphereTester waTester = new AtmosphereTester(tester, page); - - assertThat(updateTimeCalled.get(), is(false)); - assertThat(receiveMessageCalled.get(), is(false)); - - Date payload = new Date(); - waTester.post(payload); - - assertThat(updateTimeCalled.get(), is(true)); - assertThat(receiveMessageCalled.get(), is(false)); - - tester.assertContains(updateTimeIsExecuted); - - final FormTester form = tester.newFormTester("form"); - - form.setValue("input", "Atmosphere rocks!"); - - form.submit("send"); - - assertThat(updateTimeCalled.get(), is(true)); - assertThat(receiveMessageCalled.get(), is(true)); - - // get the the collected so far content of the suspended response - // Note: it may contain several <ajax-response>s. - // use waTester.resetResponse() to remove the collected data - String atmosphereResponse = waTester.getPushedResponse(); -// System.out.println("RES:" + atmosphereResponse); - - // assert - assertThat(atmosphereResponse, - is(not(equalTo("<?xml version=\"1.0\" encoding=\"UTF-8\"?><ajax-response></ajax-response>")))); - - waTester.switchOnTestMode(); - // now the assertions are against the Atmosphere's suspended response data - tester.assertComponentOnAjaxResponse("message"); - waTester.switchOffTestMode(); - // now the assertions will be the real last response - - tester.assertLabel("message", "Atmosphere rocks!"); - - tester.destroy(); - } -} http://git-wip-us.apache.org/repos/asf/wicket/blob/0dd70694/wicket-experimental/wicket-atmosphere/src/test/java/org/apache/wicket/atmosphere/ChatMessage.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-atmosphere/src/test/java/org/apache/wicket/atmosphere/ChatMessage.java b/wicket-experimental/wicket-atmosphere/src/test/java/org/apache/wicket/atmosphere/ChatMessage.java deleted file mode 100644 index c59039f..0000000 --- a/wicket-experimental/wicket-atmosphere/src/test/java/org/apache/wicket/atmosphere/ChatMessage.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.wicket.atmosphere; - -import java.io.Serializable; - -public class ChatMessage implements Serializable -{ - - private String receiver; - private String message; - - public ChatMessage(String receiver, String message) - { - this.receiver = receiver; - this.message = message; - } - - public String getReceiver() - { - return receiver; - } - - public String getMessage() - { - return message; - } -} http://git-wip-us.apache.org/repos/asf/wicket/blob/0dd70694/wicket-experimental/wicket-atmosphere/src/test/java/org/apache/wicket/atmosphere/HomePage.html ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-atmosphere/src/test/java/org/apache/wicket/atmosphere/HomePage.html b/wicket-experimental/wicket-atmosphere/src/test/java/org/apache/wicket/atmosphere/HomePage.html deleted file mode 100644 index a3e4dac..0000000 --- a/wicket-experimental/wicket-atmosphere/src/test/java/org/apache/wicket/atmosphere/HomePage.html +++ /dev/null @@ -1,24 +0,0 @@ -<!DOCTYPE html> -<html xmlns:wicket="http://wicket.apache.org"> -<head> -<title>Wicket Examples - atmosphere</title> -<link rel="stylesheet" type="text/css" href="style.css" /> -</head> -<body> - <p> - The current time is (updated every 2 seconds from the server using push): <span wicket:id="time"></span> - </p> - <p>This page also shows a very simple 'chat' client. Type a message in the - second input field and send it to everyone. To send a private message, paste - the session id (you can find this in the session cookie) of the receiver in - the first input field and send a message.</p> - <p> - Message received: <span wicket:id="message"></span> - </p> - <form wicket:id="form"> - <div>Session id of receiver: <input wicket:id="receiver" /></div> - Message: <input wicket:id="input" /> <a href="#" wicket:id="send">Send - message</a> - </form> -</body> -</html> http://git-wip-us.apache.org/repos/asf/wicket/blob/0dd70694/wicket-experimental/wicket-atmosphere/src/test/java/org/apache/wicket/atmosphere/HomePage.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-atmosphere/src/test/java/org/apache/wicket/atmosphere/HomePage.java b/wicket-experimental/wicket-atmosphere/src/test/java/org/apache/wicket/atmosphere/HomePage.java deleted file mode 100644 index f2e4e6c..0000000 --- a/wicket-experimental/wicket-atmosphere/src/test/java/org/apache/wicket/atmosphere/HomePage.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.wicket.atmosphere; - -import java.util.Date; - -import org.apache.wicket.Component; -import org.apache.wicket.ajax.AjaxRequestTarget; -import org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink; -import org.apache.wicket.markup.html.WebPage; -import org.apache.wicket.markup.html.basic.Label; -import org.apache.wicket.markup.html.form.Form; -import org.apache.wicket.markup.html.form.TextField; -import org.apache.wicket.model.Model; -import org.apache.wicket.request.mapper.parameter.PageParameters; - -public class HomePage extends WebPage -{ - private static final long serialVersionUID = 1L; - - private Component timeLabel; - private Component messageLabel; - private TextField<String> receiver; - private TextField<String> input; - - public HomePage(final PageParameters parameters) - { - super(parameters); - - add(timeLabel = new Label("time", Model.of("start")).setOutputMarkupId(true)); - add(messageLabel = new Label("message", Model.of("-")).setOutputMarkupId(true)); - - Form<Void> form = new Form<Void>("form"); - add(form); - form.add(receiver = new TextField<String>("receiver", Model.of(""))); - form.add(input = new TextField<String>("input", Model.of(""))); - form.add(new AjaxSubmitLink("send", form) - { - private static final long serialVersionUID = 1L; - - @Override - protected void onSubmit(AjaxRequestTarget target) - { - EventBus.get().post( - new ChatMessage(receiver.getModelObject(), input.getModelObject())); - } - - @Override - protected void onError(AjaxRequestTarget target) - { - } - }); - - setVersioned(false); - } - - @Subscribe - public void updateTime(AjaxRequestTarget target, Date event) - { - timeLabel.setDefaultModelObject(event.toString()); - target.add(timeLabel); - } - - @Subscribe(contextAwareFilter = ReceiverFilter.class) - public void receiveMessage(AjaxRequestTarget target, ChatMessage message) - { - messageLabel.setDefaultModelObject(message.getMessage()); - target.add(messageLabel); - } -} http://git-wip-us.apache.org/repos/asf/wicket/blob/0dd70694/wicket-experimental/wicket-atmosphere/src/test/java/org/apache/wicket/atmosphere/ReceiverFilter.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-atmosphere/src/test/java/org/apache/wicket/atmosphere/ReceiverFilter.java b/wicket-experimental/wicket-atmosphere/src/test/java/org/apache/wicket/atmosphere/ReceiverFilter.java deleted file mode 100644 index f035433..0000000 --- a/wicket-experimental/wicket-atmosphere/src/test/java/org/apache/wicket/atmosphere/ReceiverFilter.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.wicket.atmosphere; - -import org.apache.wicket.Session; - -import com.google.common.base.Predicate; - -public class ReceiverFilter implements Predicate<AtmosphereEvent> -{ - public ReceiverFilter() - { - } - - @Override - public boolean apply(AtmosphereEvent input) - { - if (input.getPayload() instanceof ChatMessage) - { - ChatMessage msg = (ChatMessage)input.getPayload(); - return msg.getReceiver() == null || msg.getReceiver().isEmpty() || - msg.getReceiver().equals(Session.get().getId()); - } - return false; - } -} http://git-wip-us.apache.org/repos/asf/wicket/blob/0dd70694/wicket-experimental/wicket-atmosphere/src/test/java/org/apache/wicket/util/license/ApacheLicenceHeaderTest.java ---------------------------------------------------------------------- diff --git a/wicket-experimental/wicket-atmosphere/src/test/java/org/apache/wicket/util/license/ApacheLicenceHeaderTest.java b/wicket-experimental/wicket-atmosphere/src/test/java/org/apache/wicket/util/license/ApacheLicenceHeaderTest.java deleted file mode 100644 index b0ff693..0000000 --- a/wicket-experimental/wicket-atmosphere/src/test/java/org/apache/wicket/util/license/ApacheLicenceHeaderTest.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.wicket.util.license; - -/** - * Test that the license headers are in place in this project. The tests are run from - * {@link org.apache.wicket.util.license.ApacheLicenseHeaderTestCase}, but you can add project - * specific tests here if needed. - */ -public class ApacheLicenceHeaderTest extends ApacheLicenseHeaderTestCase -{ - /** - * Construct. - */ - public ApacheLicenceHeaderTest() - { - // addHeaders = true; - - javaScriptIgnore.add("src/main/java/org/apache/wicket/atmosphere/jquery.atmosphere.js"); - } -}
