Revision: 815
          http://stripes.svn.sourceforge.net/stripes/?rev=815&view=rev
Author:   bengunter
Date:     2008-01-30 07:41:25 -0800 (Wed, 30 Jan 2008)

Log Message:
-----------
Fixed STS-472. Removed ActionClassCache and added a new method 
getActionBeanClasses() to ActionResolver to replace it.

Modified Paths:
--------------
    trunk/stripes/src/net/sourceforge/stripes/controller/ActionResolver.java
    
trunk/stripes/src/net/sourceforge/stripes/controller/AnnotatedClassActionResolver.java
    trunk/stripes/src/net/sourceforge/stripes/controller/UrlBindingFactory.java

Removed Paths:
-------------
    trunk/stripes/src/net/sourceforge/stripes/controller/ActionClassCache.java

Deleted: 
trunk/stripes/src/net/sourceforge/stripes/controller/ActionClassCache.java
===================================================================
--- trunk/stripes/src/net/sourceforge/stripes/controller/ActionClassCache.java  
2008-01-29 14:08:37 UTC (rev 814)
+++ trunk/stripes/src/net/sourceforge/stripes/controller/ActionClassCache.java  
2008-01-30 15:41:25 UTC (rev 815)
@@ -1,75 +0,0 @@
-/* Copyright 2005-2006 Tim Fennell
- *
- * 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 net.sourceforge.stripes.controller;
-
-import net.sourceforge.stripes.action.ActionBean;
-
-import java.util.Set;
-
-/**
- * Quick and dirty class which caches the Class objects representing 
ActionBeans since it is
- * expensive to look these up using the ResolverUtil.
- *
- * @author Tim Fennell
- */
[EMAIL PROTECTED]
-public class ActionClassCache {
-    /** The static singleton instance of this class. */
-    private static ActionClassCache cache;
-
-    /**
-     * The caches set of ActionBeans so that they are available to all 
necessary classes without
-     * repeating the classloader scanning that is necessary to find them.
-     */
-    Set<Class<? extends ActionBean>> beans;
-
-    /**
-     * Protected initializer that initializes the cached set of bean Class 
objects. While
-     * ResolverUtil does not appear to throw any exceptions, it can throw 
runtime exceptions which
-     * would cause classloading to fail if this initalization were done 
statically.
-     */
-    protected static synchronized void init(Set<Class<? extends ActionBean>> 
actionBeans) {
-        ActionClassCache instance = new ActionClassCache();
-        instance.beans = actionBeans;
-        ActionClassCache.cache = instance;
-    }
-
-    /** Private constructor that stops anyone else from initialzing an 
ActionClassCache. */
-    private ActionClassCache() {
-        // Do nothing
-    }
-
-    /**
-     * Gets access to the singleton instance of this class.
-     */
-    public static ActionClassCache getInstance() {
-        if (ActionClassCache.cache == null) {
-            throw new IllegalStateException
-                    ("Attempt made to access ActionClassCache before it has 
been initialized.");
-        }
-        else {
-            return ActionClassCache.cache;
-        }
-    }
-
-    /**
-     * Returns the set of beans in the classpath that implement ActionBean. 
This set is cached
-     * after the first lookup, so it can be accessed repeatedly without any 
performance impact.
-     * The set is an un-modifiable set.
-     */
-    public Set<Class<? extends ActionBean>> getActionBeanClasses() {
-        return this.beans;
-    }
-}

Modified: 
trunk/stripes/src/net/sourceforge/stripes/controller/ActionResolver.java
===================================================================
--- trunk/stripes/src/net/sourceforge/stripes/controller/ActionResolver.java    
2008-01-29 14:08:37 UTC (rev 814)
+++ trunk/stripes/src/net/sourceforge/stripes/controller/ActionResolver.java    
2008-01-30 15:41:25 UTC (rev 815)
@@ -20,6 +20,7 @@
 import net.sourceforge.stripes.config.ConfigurableComponent;
 
 import java.lang.reflect.Method;
+import java.util.Collection;
 
 /**
  * <p>Resolvers are responsible for locating ActionBean instances that can 
handle the submitted
@@ -149,4 +150,11 @@
      *         not mapped to this method.
      */
     String getHandledEvent(Method handler) throws StripesServletException;
+
+    /**
+     * Get all the classes implementing [EMAIL PROTECTED] ActionBean} that are 
recognized by this
+     * [EMAIL PROTECTED] ActionResolver}. This method must return the full set 
of [EMAIL PROTECTED] ActionBean} classes
+     * after the call to init().
+     */
+    Collection<Class<? extends ActionBean>> getActionBeanClasses();
 }

Modified: 
trunk/stripes/src/net/sourceforge/stripes/controller/AnnotatedClassActionResolver.java
===================================================================
--- 
trunk/stripes/src/net/sourceforge/stripes/controller/AnnotatedClassActionResolver.java
      2008-01-29 14:08:37 UTC (rev 814)
+++ 
trunk/stripes/src/net/sourceforge/stripes/controller/AnnotatedClassActionResolver.java
      2008-01-30 15:41:25 UTC (rev 815)
@@ -32,6 +32,7 @@
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -590,4 +591,12 @@
         resolver.findImplementations(ActionBean.class, pkgs);
         return resolver.getClasses();
     }
+
+    /**
+     * Get all the classes implementing [EMAIL PROTECTED] ActionBean} that are 
recognized by this
+     * [EMAIL PROTECTED] ActionResolver}.
+     */
+    public Collection<Class<? extends ActionBean>> getActionBeanClasses() {
+        return UrlBindingFactory.getInstance().getActionBeanClasses();
+    }
 }

Modified: 
trunk/stripes/src/net/sourceforge/stripes/controller/UrlBindingFactory.java
===================================================================
--- trunk/stripes/src/net/sourceforge/stripes/controller/UrlBindingFactory.java 
2008-01-29 14:08:37 UTC (rev 814)
+++ trunk/stripes/src/net/sourceforge/stripes/controller/UrlBindingFactory.java 
2008-01-30 15:41:25 UTC (rev 815)
@@ -11,6 +11,8 @@
 import java.io.UnsupportedEncodingException;
 import java.net.URLDecoder;
 import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
 import java.util.Comparator;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -78,6 +80,13 @@
     }
 
     /**
+     * Get all the classes implementing [EMAIL PROTECTED] ActionBean}
+     */
+    public Collection<Class<? extends ActionBean>> getActionBeanClasses() {
+        return Collections.unmodifiableSet(classCache.keySet());
+    }
+
+    /**
      * Get the [EMAIL PROTECTED] UrlBinding} prototype associated with the 
given [EMAIL PROTECTED] ActionBean} type. This
      * method may return null if no binding is associated with the given type.
      * 


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development

Reply via email to