You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by dj...@apache.org on 2005/11/15 22:14:47 UTC
svn commit: r344443 - in /geronimo/trunk/modules/common/src:
java/org/apache/geronimo/common/GeronimoEnvironment.java
test/org/apache/geronimo/common/GeronimoEnvironmentTest.java
Author: djencks
Date: Tue Nov 15 13:14:11 2005
New Revision: 344443
URL: http://svn.apache.org/viewcvs?rev=344443&view=rev
Log:
GERONIMO-1177 missed a couple files
Added:
geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/GeronimoEnvironment.java
geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/GeronimoEnvironmentTest.java
Added: geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/GeronimoEnvironment.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/GeronimoEnvironment.java?rev=344443&view=auto
==============================================================================
--- geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/GeronimoEnvironment.java (added)
+++ geronimo/trunk/modules/common/src/java/org/apache/geronimo/common/GeronimoEnvironment.java Tue Nov 15 13:14:11 2005
@@ -0,0 +1,48 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * Licensed 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.geronimo.common;
+
+import java.net.URL;
+import java.io.IOException;
+
+
+/**
+ * Used to perform common initialization tasks for Geronimo server, deploy, and client environments.
+ * @version $Rev: 332947 $ $Date: 2005-11-13 03:10:19 -0500 (Sun, 13 Nov 2005) $
+ */
+public class GeronimoEnvironment {
+
+ /**
+ * Performs common initialization for the various Geronimo process environments: server, deploy, and client.
+ */
+ public static void init() {
+ // Setting useCaches to false avoids a memory leak of URLJarFile instances
+ // It's a workaround for a Sun bug (see bug id 4167874). Otherwise,
+ // URLJarFiles will never be garbage collected. o.a.g.deployment.util.DeploymentUtil.readAll()
+ // causes URLJarFiles to be created
+ try {
+ // Protocol/file shouldn't matter.
+ // As long as we don't get an input/output stream, no operations should occur...
+ new URL("http://a").openConnection().setDefaultUseCaches(false);
+ }
+ catch (IOException ioe) {
+ // Can't Log this. Should we send to STDOUT/STDERR?
+ }
+ }
+
+}
Added: geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/GeronimoEnvironmentTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/GeronimoEnvironmentTest.java?rev=344443&view=auto
==============================================================================
--- geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/GeronimoEnvironmentTest.java (added)
+++ geronimo/trunk/modules/common/src/test/org/apache/geronimo/common/GeronimoEnvironmentTest.java Tue Nov 15 13:14:11 2005
@@ -0,0 +1,36 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * Licensed 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.geronimo.common;
+
+import java.net.URL;
+import java.net.URLConnection;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev: 109898 $ $Date: 2004-12-06 05:21:47 +1100 (Mon, 06 Dec 2004) $
+ */
+public class GeronimoEnvironmentTest extends TestCase {
+
+ public void testCaching() throws Exception {
+ GeronimoEnvironment.init();
+ URL url = new URL("jar:file:testFile.jar!/test");
+ URLConnection conn = url.openConnection();
+ assertFalse(conn.getUseCaches());
+ assertFalse(conn.getDefaultUseCaches());
+ }
+}