This is an automated email from the ASF dual-hosted git repository.
papegaaij pushed a commit to branch csp
in repository https://gitbox.apache.org/repos/asf/wicket.git
The following commit(s) were added to refs/heads/csp by this push:
new 1f554fa WICKET-6737: removed obsolete response filter from examples
1f554fa is described below
commit 1f554faedb3543a47c1beff4de6e059345aa7680
Author: Emond Papegaaij <[email protected]>
AuthorDate: Wed Feb 5 21:07:56 2020 +0100
WICKET-6737: removed obsolete response filter from examples
See WICKET-6745 for more information on similar filters. The filter
in wicket-examples was almost a duplicate of ServerAndClientTimeFilter.
---
.../examples/ServerHostNameAndTimeFilter.java | 124 ---------------------
.../examples/linkomatic/LinkomaticApplication.java | 3 -
2 files changed, 127 deletions(-)
diff --git
a/wicket-examples/src/main/java/org/apache/wicket/examples/ServerHostNameAndTimeFilter.java
b/wicket-examples/src/main/java/org/apache/wicket/examples/ServerHostNameAndTimeFilter.java
deleted file mode 100644
index 194e361..0000000
---
a/wicket-examples/src/main/java/org/apache/wicket/examples/ServerHostNameAndTimeFilter.java
+++ /dev/null
@@ -1,124 +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;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.time.Duration;
-import org.apache.wicket.core.util.string.JavaScriptUtils;
-import org.apache.wicket.request.cycle.RequestCycle;
-import org.apache.wicket.response.filter.IResponseFilter;
-import org.apache.wicket.util.lang.Args;
-import org.apache.wicket.util.string.AppendingStringBuffer;
-import org.apache.wicket.util.string.Strings;
-
-
-/**
- * Displays server host name (combination of name, IP address and unique id,
which is either based)
- * and time it took to handle the request in the browser's status bar like
this:
- * <code>window.defaultStatus = 'Host: myhost/192.168.1.66/someid, handled in:
0.01s'</code>
- *
- * @author eelco hillenius
- */
-public class ServerHostNameAndTimeFilter implements IResponseFilter
-{
- private String host;
-
- /**
- * Construct, trying system property 'examples.hostname' for the server
id or else current time
- * in millis.
- */
- public ServerHostNameAndTimeFilter()
- {
- String hostId = null;
- try
- {
- hostId = System.getProperty("examples.hostname");
- }
- catch (SecurityException ignored)
- {
- }
- if (Strings.isEmpty(hostId))
- {
- hostId = String.valueOf(System.currentTimeMillis());
- }
-
- setHostName(hostId);
- }
-
- /**
- * Construct with an id.
- *
- * @param hostId
- * a unique id identifying this server instance
- */
- public ServerHostNameAndTimeFilter(String hostId)
- {
- Args.notNull(hostId, "hostId");
-
- setHostName(hostId);
- }
-
- @Override
- public AppendingStringBuffer filter(AppendingStringBuffer
responseBuffer)
- {
- int index = responseBuffer.indexOf("<head>");
- long timeTaken = System.currentTimeMillis() -
RequestCycle.get().getStartTime();
-
- if (index != -1)
- {
- AppendingStringBuffer script = new
AppendingStringBuffer(75);
- script.append('\n');
- script.append(JavaScriptUtils.SCRIPT_OPEN_TAG);
- script.append("\n\twindow.defaultStatus='");
- script.append("Host: ");
- script.append(host);
- script.append(", handled in: ");
- script.append(Duration.ofMillis(timeTaken));
- script.append("';\n");
- script.append(JavaScriptUtils.SCRIPT_CLOSE_TAG);
- script.append('\n');
- responseBuffer.insert(index + 6, script);
- }
- return responseBuffer;
- }
-
- /**
- * Fill host name property.
- *
- * @param hostId
- */
- private void setHostName(String hostId)
- {
- try
- {
- InetAddress localMachine = InetAddress.getLocalHost();
- String hostName = localMachine.getHostName();
- String address = localMachine.getHostAddress();
- host = ((!Strings.isEmpty(hostName)) ? hostName + "/" +
address : address) + "/" +
- hostId;
- }
- catch (UnknownHostException ignored)
- {
- }
-
- if (Strings.isEmpty(host))
- {
- host = "<unknown>";
- }
- }
-}
diff --git
a/wicket-examples/src/main/java/org/apache/wicket/examples/linkomatic/LinkomaticApplication.java
b/wicket-examples/src/main/java/org/apache/wicket/examples/linkomatic/LinkomaticApplication.java
index c18133f..e5b6a29 100644
---
a/wicket-examples/src/main/java/org/apache/wicket/examples/linkomatic/LinkomaticApplication.java
+++
b/wicket-examples/src/main/java/org/apache/wicket/examples/linkomatic/LinkomaticApplication.java
@@ -17,7 +17,6 @@
package org.apache.wicket.examples.linkomatic;
import org.apache.wicket.Page;
-import org.apache.wicket.examples.ServerHostNameAndTimeFilter;
import org.apache.wicket.examples.WicketExampleApplication;
import org.apache.wicket.markup.html.image.resource.DefaultButtonImageResource;
@@ -42,7 +41,5 @@ public class LinkomaticApplication extends
WicketExampleApplication
mountPage("/home", Home.class);
getSharedResources().add("cancelButton", new
DefaultButtonImageResource("Cancel"));
- // log host name and server time in the browser's status bar
- getRequestCycleSettings().addResponseFilter(new
ServerHostNameAndTimeFilter());
}
}