geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r502224 - /geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/LazyTestResult.groovy
Date Thu, 01 Feb 2007 14:29:23 GMT
Author: jdillon
Date: Thu Feb  1 06:29:22 2007
New Revision: 502224

URL: http://svn.apache.org/viewvc?view=rev&rev=502224
Log:
Add a magical test result thingy which will dynamically load a real result, bound to a softref
to prevent memory explosion, and proxy to it

Added:
    geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/LazyTestResult.groovy
  (with props)

Added: geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/LazyTestResult.groovy
URL: http://svn.apache.org/viewvc/geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/LazyTestResult.groovy?view=auto&rev=502224
==============================================================================
--- geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/LazyTestResult.groovy
(added)
+++ geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/LazyTestResult.groovy
Thu Feb  1 06:29:22 2007
@@ -0,0 +1,80 @@
+/*
+ * 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.
+ */
+
+//
+// $Id$
+//
+
+package gbuild.config.projects.Geronimo_CTS.report
+
+import java.lang.ref.SoftReference
+
+/**
+ * A lazy loading test result which is heap friendly.
+ */
+class LazyTestResult
+{
+    //
+    // NOTE: Do not extend from anything to prevent weird muck since were
+    //       have the magic going on...
+    //
+    
+    private File file
+    
+    private SoftReference target
+    
+    def LazyTestResult(file) {
+        assert file
+        
+        this.file = new File(String.valueOf(file)).canonicalFile
+    }
+    
+    def load() {
+        def obj
+        
+        if (target) {
+            obj = target.get()
+            if (obj) {
+                return obj
+            }
+        }
+        
+        obj = new TestResult(file)
+        this.target = new SoftReference(obj)
+        
+        return obj
+    }
+    
+    //
+    // NOTE: Use groovy magic to dynamically load the target, delegate property and methods?
+    //
+    
+    public Object invokeMethod(String name, Object args) {
+        return load().invokeMethod(name, args)
+    }
+    
+    def getProperty(String name) {
+        return load().getProperty(name)
+    }
+    
+    void setProperty(String name, Object value) {
+        load().setProperty(name, value)
+    }
+}
+

Propchange: geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/LazyTestResult.groovy
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/LazyTestResult.groovy
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/build-support/libraries/system/1/groovy/gbuild/config/projects/Geronimo_CTS/report/LazyTestResult.groovy
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message