You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by mo...@apache.org on 2015/11/08 18:15:06 UTC

[07/50] wicket git commit: WICKET-5997 Compatibility problem with Websphere liberty profile

WICKET-5997 Compatibility problem with Websphere liberty profile

Use ServiceLoader instead of collecting the wicket.properties files in the classpath with custom logic


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/8ed4f8e0
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/8ed4f8e0
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/8ed4f8e0

Branch: refs/heads/lambdas
Commit: 8ed4f8e0619e08c688ec53620fbd3ac1a47785cd
Parents: c2ba28d
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Sun Oct 18 12:02:10 2015 +0200
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Sun Oct 18 12:02:10 2015 +0200

----------------------------------------------------------------------
 .../java/org/apache/wicket/Application.java     | 57 +++++++++++++++-----
 .../services/org.apache.wicket.IInitializer     |  1 +
 .../wicket/org.apache.wicket.core.properties    | 15 ------
 .../services/org.apache.wicket.IInitializer     |  1 +
 .../org.apache.wicket.devutils.properties       | 15 ------
 .../services/org.apache.wicket.IInitializer     |  1 +
 .../org.apache.wicket.atmosphere.properties     | 15 ------
 .../services/org.apache.wicket.IInitializer     |  1 +
 .../org.apache.wicket.extensions.properties     | 15 ------
 .../services/org.apache.wicket.IInitializer     |  1 +
 .../wicket/org.apache.wicket.jmx.properties     | 15 ------
 .../services/org.apache.wicket.IInitializer     |  1 +
 .../org.apache.wicket.velocity.properties       | 15 ------
 13 files changed, 50 insertions(+), 103 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/8ed4f8e0/wicket-core/src/main/java/org/apache/wicket/Application.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/Application.java b/wicket-core/src/main/java/org/apache/wicket/Application.java
index f6c3f33..55035aa 100644
--- a/wicket-core/src/main/java/org/apache/wicket/Application.java
+++ b/wicket-core/src/main/java/org/apache/wicket/Application.java
@@ -29,6 +29,7 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
+import java.util.ServiceLoader;
 import java.util.Set;
 import java.util.jar.JarEntry;
 import java.util.jar.JarFile;
@@ -489,7 +490,10 @@ public abstract class Application implements UnboundListener, IEventSink
 	 *
 	 * @throws IOException When there is a problem reading the content of the properties file
 	 * @throws URISyntaxException When the url to the properties file cannot be translated to a file system path
+	 * @deprecated The collection of wicket.properties in the classpath is broken in OSGi and single-jar
+	 *             environments. It is deprecated and will be removed in Wicket 7.3.0. Please see WICKET-5997
 	 */
+	@Deprecated
 	private void collectWicketProperties() throws IOException, URISyntaxException
 	{
 		Iterator<URL> wicketResources = getApplicationSettings().getClassResolver().getResources("META-INF/wicket/");
@@ -500,21 +504,31 @@ public abstract class Application implements UnboundListener, IEventSink
 
 			if ("jar".equals(protocol) || "wsjar".equals(protocol))
 			{
-				JarURLConnection jarURLConnection = (JarURLConnection) metaInfWicket.openConnection();
-				JarFile jarFile = jarURLConnection.getJarFile();
-				Enumeration<JarEntry> jarEntries = jarFile.entries();
-				while (jarEntries.hasMoreElements())
+				// some versions of WebSphere use JarURL connections, others don't. WICKET-5997
+				final URLConnection urlConnection = metaInfWicket.openConnection();
+				if (urlConnection instanceof JarURLConnection)
 				{
-					JarEntry jarEntry = jarEntries.nextElement();
-					String entryName = jarEntry.getName();
-					if (entryName.startsWith("META-INF/wicket/") && entryName.endsWith(".properties"))
+					JarURLConnection jarURLConnection = (JarURLConnection) urlConnection;
+					JarFile jarFile = jarURLConnection.getJarFile();
+					Enumeration<JarEntry> jarEntries = jarFile.entries();
+					while (jarEntries.hasMoreElements())
 					{
-						try (InputStream jarEntryStream = jarFile.getInputStream(jarEntry))
+						JarEntry jarEntry = jarEntries.nextElement();
+						String entryName = jarEntry.getName();
+						if (entryName.startsWith("META-INF/wicket/") && entryName.endsWith(".properties"))
 						{
-							Properties properties = new Properties();
-							properties.load(jarEntryStream);
-							load(properties);
-							break; // atm there is no need to have more than one .properties file
+							try (InputStream jarEntryStream = jarFile.getInputStream(jarEntry))
+							{
+								log.warn("Found '{}' in '{}'. /META-INF/wicket/*.properties doesn't work in OSGi " +
+										"and single-jar environments and is not supported anymore! " +
+										"Please see https://issues.apache.org/jira/browse/WICKET-5997 for more details " +
+										"and report a issue for the library that still uses it.",
+										entryName, metaInfWicket);
+								Properties properties = new Properties();
+								properties.load(jarEntryStream);
+								load(properties);
+								break; // atm there is no need to have more than one .properties file
+							}
 						}
 					}
 				}
@@ -535,6 +549,11 @@ public abstract class Application implements UnboundListener, IEventSink
 						int read = inputStream.read(buf, offset, size);
 						if (read == size)
 						{
+							log.warn("Found '{}' in '{}'. /META-INF/wicket/*.properties doesn't work in OSGi " +
+											"and single-jar environments and is not supported anymore! " +
+											"Please see https://issues.apache.org/jira/browse/WICKET-5997 for more " +
+											"details and report a issue for the library that still uses it.",
+									jarEntryName, metaInfWicket);
 							Properties properties = new Properties();
 							properties.load(new ByteArrayInputStream(buf));
 							load(properties);
@@ -564,6 +583,11 @@ public abstract class Application implements UnboundListener, IEventSink
 				{
 					try (InputStream stream = wicketPropertiesFile.inputStream())
 					{
+						log.warn("Found '{}'. /META-INF/wicket/*.properties doesn't work in OSGi " +
+										"and single-jar environments and is not supported anymore! " +
+										"Please see https://issues.apache.org/jira/browse/WICKET-5997 for more " +
+										"details and report a issue for the library that still uses it.",
+								wicketPropertiesFile);
 						Properties properties = new Properties();
 						properties.load(stream);
 						load(properties);
@@ -707,9 +731,16 @@ public abstract class Application implements UnboundListener, IEventSink
 	{
 		for (IInitializer initializer : initializers)
 		{
-			log.info("[" + getName() + "] init: " + initializer);
+			log.info("[{}] init: {}", getName(), initializer);
 			initializer.init(this);
 		}
+
+		final ServiceLoader<IInitializer> serviceLoaderInitializers = ServiceLoader.load(IInitializer.class);
+		for (IInitializer serviceLoaderInitializer : serviceLoaderInitializers) {
+			log.info("[{}] init: {}", getName(), serviceLoaderInitializer);
+			serviceLoaderInitializer.init(this);
+			initializers.add(serviceLoaderInitializer);
+		}
 	}
 
 	/**

http://git-wip-us.apache.org/repos/asf/wicket/blob/8ed4f8e0/wicket-core/src/main/resources/META-INF/services/org.apache.wicket.IInitializer
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/resources/META-INF/services/org.apache.wicket.IInitializer b/wicket-core/src/main/resources/META-INF/services/org.apache.wicket.IInitializer
new file mode 100644
index 0000000..1c52f2d
--- /dev/null
+++ b/wicket-core/src/main/resources/META-INF/services/org.apache.wicket.IInitializer
@@ -0,0 +1 @@
+org.apache.wicket.Initializer

http://git-wip-us.apache.org/repos/asf/wicket/blob/8ed4f8e0/wicket-core/src/main/resources/META-INF/wicket/org.apache.wicket.core.properties
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/resources/META-INF/wicket/org.apache.wicket.core.properties b/wicket-core/src/main/resources/META-INF/wicket/org.apache.wicket.core.properties
deleted file mode 100644
index d004034..0000000
--- a/wicket-core/src/main/resources/META-INF/wicket/org.apache.wicket.core.properties
+++ /dev/null
@@ -1,15 +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.
-initializer=org.apache.wicket.Initializer

http://git-wip-us.apache.org/repos/asf/wicket/blob/8ed4f8e0/wicket-devutils/src/main/resources/META-INF/services/org.apache.wicket.IInitializer
----------------------------------------------------------------------
diff --git a/wicket-devutils/src/main/resources/META-INF/services/org.apache.wicket.IInitializer b/wicket-devutils/src/main/resources/META-INF/services/org.apache.wicket.IInitializer
new file mode 100644
index 0000000..0672d71
--- /dev/null
+++ b/wicket-devutils/src/main/resources/META-INF/services/org.apache.wicket.IInitializer
@@ -0,0 +1 @@
+org.apache.wicket.devutils.debugbar.DebugBarInitializer

http://git-wip-us.apache.org/repos/asf/wicket/blob/8ed4f8e0/wicket-devutils/src/main/resources/META-INF/wicket/org.apache.wicket.devutils.properties
----------------------------------------------------------------------
diff --git a/wicket-devutils/src/main/resources/META-INF/wicket/org.apache.wicket.devutils.properties b/wicket-devutils/src/main/resources/META-INF/wicket/org.apache.wicket.devutils.properties
deleted file mode 100644
index 4c38496..0000000
--- a/wicket-devutils/src/main/resources/META-INF/wicket/org.apache.wicket.devutils.properties
+++ /dev/null
@@ -1,15 +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.
-initializer=org.apache.wicket.devutils.debugbar.DebugBarInitializer

http://git-wip-us.apache.org/repos/asf/wicket/blob/8ed4f8e0/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
new file mode 100644
index 0000000..69885be
--- /dev/null
+++ b/wicket-experimental/wicket-atmosphere/src/main/resources/META-INF/services/org.apache.wicket.IInitializer
@@ -0,0 +1 @@
+org.apache.wicket.atmosphere.Initializer

http://git-wip-us.apache.org/repos/asf/wicket/blob/8ed4f8e0/wicket-experimental/wicket-atmosphere/src/main/resources/META-INF/wicket/org.apache.wicket.atmosphere.properties
----------------------------------------------------------------------
diff --git a/wicket-experimental/wicket-atmosphere/src/main/resources/META-INF/wicket/org.apache.wicket.atmosphere.properties b/wicket-experimental/wicket-atmosphere/src/main/resources/META-INF/wicket/org.apache.wicket.atmosphere.properties
deleted file mode 100644
index c07947f..0000000
--- a/wicket-experimental/wicket-atmosphere/src/main/resources/META-INF/wicket/org.apache.wicket.atmosphere.properties
+++ /dev/null
@@ -1,15 +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.
-initializer=org.apache.wicket.atmosphere.Initializer

http://git-wip-us.apache.org/repos/asf/wicket/blob/8ed4f8e0/wicket-extensions/src/main/resources/META-INF/services/org.apache.wicket.IInitializer
----------------------------------------------------------------------
diff --git a/wicket-extensions/src/main/resources/META-INF/services/org.apache.wicket.IInitializer b/wicket-extensions/src/main/resources/META-INF/services/org.apache.wicket.IInitializer
new file mode 100644
index 0000000..31d1a35
--- /dev/null
+++ b/wicket-extensions/src/main/resources/META-INF/services/org.apache.wicket.IInitializer
@@ -0,0 +1 @@
+org.apache.wicket.extensions.Initializer

http://git-wip-us.apache.org/repos/asf/wicket/blob/8ed4f8e0/wicket-extensions/src/main/resources/META-INF/wicket/org.apache.wicket.extensions.properties
----------------------------------------------------------------------
diff --git a/wicket-extensions/src/main/resources/META-INF/wicket/org.apache.wicket.extensions.properties b/wicket-extensions/src/main/resources/META-INF/wicket/org.apache.wicket.extensions.properties
deleted file mode 100644
index 7874436..0000000
--- a/wicket-extensions/src/main/resources/META-INF/wicket/org.apache.wicket.extensions.properties
+++ /dev/null
@@ -1,15 +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.
-initializer=org.apache.wicket.extensions.Initializer

http://git-wip-us.apache.org/repos/asf/wicket/blob/8ed4f8e0/wicket-jmx/src/main/resources/META-INF/services/org.apache.wicket.IInitializer
----------------------------------------------------------------------
diff --git a/wicket-jmx/src/main/resources/META-INF/services/org.apache.wicket.IInitializer b/wicket-jmx/src/main/resources/META-INF/services/org.apache.wicket.IInitializer
new file mode 100644
index 0000000..b8439d4
--- /dev/null
+++ b/wicket-jmx/src/main/resources/META-INF/services/org.apache.wicket.IInitializer
@@ -0,0 +1 @@
+org.apache.wicket.jmx.Initializer

http://git-wip-us.apache.org/repos/asf/wicket/blob/8ed4f8e0/wicket-jmx/src/main/resources/META-INF/wicket/org.apache.wicket.jmx.properties
----------------------------------------------------------------------
diff --git a/wicket-jmx/src/main/resources/META-INF/wicket/org.apache.wicket.jmx.properties b/wicket-jmx/src/main/resources/META-INF/wicket/org.apache.wicket.jmx.properties
deleted file mode 100644
index 534efb7..0000000
--- a/wicket-jmx/src/main/resources/META-INF/wicket/org.apache.wicket.jmx.properties
+++ /dev/null
@@ -1,15 +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.
-initializer=org.apache.wicket.jmx.Initializer
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/wicket/blob/8ed4f8e0/wicket-velocity/src/main/resources/META-INF/services/org.apache.wicket.IInitializer
----------------------------------------------------------------------
diff --git a/wicket-velocity/src/main/resources/META-INF/services/org.apache.wicket.IInitializer b/wicket-velocity/src/main/resources/META-INF/services/org.apache.wicket.IInitializer
new file mode 100644
index 0000000..da1ab61
--- /dev/null
+++ b/wicket-velocity/src/main/resources/META-INF/services/org.apache.wicket.IInitializer
@@ -0,0 +1 @@
+org.apache.wicket.velocity.Initializer

http://git-wip-us.apache.org/repos/asf/wicket/blob/8ed4f8e0/wicket-velocity/src/main/resources/META-INF/wicket/org.apache.wicket.velocity.properties
----------------------------------------------------------------------
diff --git a/wicket-velocity/src/main/resources/META-INF/wicket/org.apache.wicket.velocity.properties b/wicket-velocity/src/main/resources/META-INF/wicket/org.apache.wicket.velocity.properties
deleted file mode 100644
index 0b36808..0000000
--- a/wicket-velocity/src/main/resources/META-INF/wicket/org.apache.wicket.velocity.properties
+++ /dev/null
@@ -1,15 +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.
-initializer=org.apache.wicket.velocity.Initializer