Repository: wicket Updated Branches: refs/heads/WICKET-6056-client-properties 44e1e4303 -> a81272f5e
WICKET-6056 constructor argument instead of factory method, requires to subclass ClientProperties only Project: http://git-wip-us.apache.org/repos/asf/wicket/repo Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/a81272f5 Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/a81272f5 Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/a81272f5 Branch: refs/heads/WICKET-6056-client-properties Commit: a81272f5ea7771e9ef84939e2af91ba055180c15 Parents: 44e1e43 Author: Sven Meier <svenme...@apache.org> Authored: Tue Nov 29 17:03:30 2016 +0100 Committer: Sven Meier <svenme...@apache.org> Committed: Tue Nov 29 17:03:30 2016 +0100 ---------------------------------------------------------------------- .../protocol/http/request/WebClientInfo.java | 35 ++++++++--- .../ajaxhellobrowser/AjaxHelloBrowser.java | 2 +- .../ajaxhellobrowser/ExtendedClientInfo.java | 61 -------------------- .../ExtendedClientProperties.java | 49 ++++++++++++++++ 4 files changed, 78 insertions(+), 69 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/wicket/blob/a81272f5/wicket-core/src/main/java/org/apache/wicket/protocol/http/request/WebClientInfo.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/main/java/org/apache/wicket/protocol/http/request/WebClientInfo.java b/wicket-core/src/main/java/org/apache/wicket/protocol/http/request/WebClientInfo.java index 5561226..2b0747c 100644 --- a/wicket-core/src/main/java/org/apache/wicket/protocol/http/request/WebClientInfo.java +++ b/wicket-core/src/main/java/org/apache/wicket/protocol/http/request/WebClientInfo.java @@ -62,8 +62,19 @@ public class WebClientInfo extends ClientInfo */ public WebClientInfo(RequestCycle requestCycle) { + this(requestCycle, new ClientProperties()); + } + + /** + * Construct. + * + * @param requestCycle + * the request cycle + */ + public WebClientInfo(RequestCycle requestCycle, ClientProperties properties) + { this(requestCycle, ((ServletWebRequest)requestCycle.getRequest()).getContainerRequest() - .getHeader("User-Agent")); + .getHeader("User-Agent"), properties); } /** @@ -76,11 +87,26 @@ public class WebClientInfo extends ClientInfo */ public WebClientInfo(final RequestCycle requestCycle, final String userAgent) { + this(requestCycle, userAgent, new ClientProperties()); + } + + /** + * Construct. + * + * @param requestCycle + * the request cycle + * @param userAgent + * The User-Agent string + * @param properties + * properties of client + */ + public WebClientInfo(final RequestCycle requestCycle, final String userAgent, final ClientProperties properties) + { super(); this.userAgent = userAgent; - properties = newClientProperties(); + this.properties = properties; properties.setRemoteAddress(getRemoteAddr(requestCycle)); init(); @@ -96,11 +122,6 @@ public class WebClientInfo extends ClientInfo return properties; } - protected ClientProperties newClientProperties() - { - return new ClientProperties(); - } - /** * returns the user agent string. * http://git-wip-us.apache.org/repos/asf/wicket/blob/a81272f5/wicket-examples/src/main/java/org/apache/wicket/examples/ajaxhellobrowser/AjaxHelloBrowser.java ---------------------------------------------------------------------- diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/ajaxhellobrowser/AjaxHelloBrowser.java b/wicket-examples/src/main/java/org/apache/wicket/examples/ajaxhellobrowser/AjaxHelloBrowser.java index 258103c..8a44d21 100644 --- a/wicket-examples/src/main/java/org/apache/wicket/examples/ajaxhellobrowser/AjaxHelloBrowser.java +++ b/wicket-examples/src/main/java/org/apache/wicket/examples/ajaxhellobrowser/AjaxHelloBrowser.java @@ -97,7 +97,7 @@ public class AjaxHelloBrowser extends WicketExamplePage @Override protected WebClientInfo newWebClientInfo(RequestCycle requestCycle) { - return new ExtendedClientInfo(requestCycle); + return new WebClientInfo(requestCycle, new ExtendedClientProperties()); } @Override http://git-wip-us.apache.org/repos/asf/wicket/blob/a81272f5/wicket-examples/src/main/java/org/apache/wicket/examples/ajaxhellobrowser/ExtendedClientInfo.java ---------------------------------------------------------------------- diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/ajaxhellobrowser/ExtendedClientInfo.java b/wicket-examples/src/main/java/org/apache/wicket/examples/ajaxhellobrowser/ExtendedClientInfo.java deleted file mode 100644 index 849aed8..0000000 --- a/wicket-examples/src/main/java/org/apache/wicket/examples/ajaxhellobrowser/ExtendedClientInfo.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.examples.ajaxhellobrowser; - -import org.apache.wicket.protocol.http.ClientProperties; -import org.apache.wicket.protocol.http.request.WebClientInfo; -import org.apache.wicket.request.IRequestParameters; -import org.apache.wicket.request.cycle.RequestCycle; - - -public class ExtendedClientInfo extends WebClientInfo -{ - - public ExtendedClientInfo(RequestCycle requestCycle) - { - super(requestCycle); - } - - @Override - protected ClientProperties newClientProperties() - { - return new ExtendedClientProperties(); - } - - public class ExtendedClientProperties extends ClientProperties - { - private String extendedProperty; - - public String getExtendedProperty() - { - return extendedProperty; - } - - public void setExtendedProperty(String extendedProperty) - { - this.extendedProperty = extendedProperty; - } - - @Override - public void read(IRequestParameters parameters) - { - super.read(parameters); - - setExtendedProperty(parameters.getParameterValue("extendedProperty").toString("N/A")); - } - } -} http://git-wip-us.apache.org/repos/asf/wicket/blob/a81272f5/wicket-examples/src/main/java/org/apache/wicket/examples/ajaxhellobrowser/ExtendedClientProperties.java ---------------------------------------------------------------------- diff --git a/wicket-examples/src/main/java/org/apache/wicket/examples/ajaxhellobrowser/ExtendedClientProperties.java b/wicket-examples/src/main/java/org/apache/wicket/examples/ajaxhellobrowser/ExtendedClientProperties.java new file mode 100644 index 0000000..1d301f3 --- /dev/null +++ b/wicket-examples/src/main/java/org/apache/wicket/examples/ajaxhellobrowser/ExtendedClientProperties.java @@ -0,0 +1,49 @@ +/* + * 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.examples.ajaxhellobrowser; + +import org.apache.wicket.protocol.http.ClientProperties; +import org.apache.wicket.request.IRequestParameters; + +/** + * Showcase for extended properties of a client. + */ +public class ExtendedClientProperties extends ClientProperties +{ + private String extendedProperty; + + public String getExtendedProperty() + { + return extendedProperty; + } + + public void setExtendedProperty(String extendedProperty) + { + this.extendedProperty = extendedProperty; + } + + /** + * Overridden to read additional properties. + */ + @Override + public void read(IRequestParameters parameters) + { + super.read(parameters); + + setExtendedProperty(parameters.getParameterValue("extendedProperty").toString("N/A")); + } +} \ No newline at end of file