CVS: Tapestry/framework/src/net/sf/tapestry/util AdaptorRegistry.java,1.3.2.1,1.3.2.2

Howard Lewis Ship <[email protected]>
Newsgroups gmane.comp.java.tapestry.cvs
Message-ID <[email protected]>
Update of /cvsroot/tapestry/Tapestry/framework/src/net/sf/tapestry/util
In directory sc8-pr-cvs1:/tmp/cvs-serv16197/framework/src/net/sf/tapestry/util

Modified Files:
      Tag: hship-2-3
	AdaptorRegistry.java 
Log Message:
Remove some dead code from AdaptorRegistry.

Index: AdaptorRegistry.java
===================================================================
RCS file: /cvsroot/tapestry/Tapestry/framework/src/net/sf/tapestry/util/AdaptorRegistry.java,v
retrieving revision 1.3.2.1
retrieving revision 1.3.2.2
diff -C2 -d -r1.3.2.1 -r1.3.2.2
*** AdaptorRegistry.java	30 Dec 2002 03:04:58 -0000	1.3.2.1
--- AdaptorRegistry.java	2 Jan 2003 13:25:34 -0000	1.3.2.2
***************
*** 78,91 ****
       **/
  
!     public void register(Class registrationClass, Object adaptor)
      {
!         synchronized (registrations)
!         {
!             if (registrations.containsKey(registrationClass))
!                 throw new IllegalArgumentException(
!                     Tapestry.getString("AdaptorRegistry.duplicate-registration", registrationClass.getName()));
  
!             registrations.put(registrationClass, adaptor);
!         }
  
          if (LOG.isInfoEnabled())
--- 78,88 ----
       **/
  
!     public synchronized void register(Class registrationClass, Object adaptor)
      {
!         if (registrations.containsKey(registrationClass))
!             throw new IllegalArgumentException(
!                 Tapestry.getString("AdaptorRegistry.duplicate-registration", registrationClass.getName()));
  
!         registrations.put(registrationClass, adaptor);
  
          if (LOG.isInfoEnabled())
***************
*** 96,103 ****
          // are searched for, so this is not a big deal.
  
!         synchronized (cache)
!         {
!             cache.clear();
!         }
      }
  
--- 93,97 ----
          // are searched for, so this is not a big deal.
  
!         cache.clear();
      }
  
***************
*** 109,113 ****
       **/
  
!     public Object getAdaptor(Class subjectClass)
      {
          Object result;
--- 103,107 ----
       **/
  
!     public synchronized Object getAdaptor(Class subjectClass)
      {
          Object result;
***************
*** 116,130 ****
              LOG.debug("Getting adaptor for class " + subjectClass.getName());
  
!         synchronized (cache)
!         {
!             result = cache.get(subjectClass);
  
!             if (result != null)
!             {
!                 if (LOG.isDebugEnabled())
!                     LOG.debug("Found " + result + " in cache");
  
!                 return result;
!             }
          }
  
--- 110,121 ----
              LOG.debug("Getting adaptor for class " + subjectClass.getName());
  
!         result = cache.get(subjectClass);
  
!         if (result != null)
!         {
!             if (LOG.isDebugEnabled())
!                 LOG.debug("Found " + result + " in cache");
  
!             return result;
          }
  
***************
*** 133,140 ****
          // Record the result in the cache
  
!         synchronized (cache)
!         {
!             cache.put(subjectClass, result);
!         }
  
          if (LOG.isDebugEnabled())
--- 124,128 ----
          // Record the result in the cache
  
!         cache.put(subjectClass, result);
  
          if (LOG.isDebugEnabled())
***************
*** 165,168 ****
--- 153,160 ----
       * </ul>
       *
+      *  <p>
+      *  This method is only called from a synchronized block, so it is
+      *  implicitly synchronized.
+      * 
       **/
  
***************
*** 170,249 ****
      {
          LinkedList queue = null;
!         Class[] interfaces;
!         Class searchClass;
!         Object result;
!         int length;
! 
!         if (registrations == null)
!             throw new IllegalArgumentException(Tapestry.getString("AdaptorRegistry.nothing-registered"));
  
          if (LOG.isDebugEnabled())
              LOG.debug("Searching for adaptor for class " + subjectClass.getName());
  
!         synchronized (registrations)
!         {
!             // Step one: work up through the class inheritance.
  
!             searchClass = subjectClass;
  
!             // Primitive types have null, not Object, as their parent
!             // class.
  
!             while (searchClass != Object.class && searchClass != null)
!             {
!                 result = registrations.get(searchClass);
!                 if (result != null)
!                     return result;
  
!                 // Not an exact match.  If the search class
!                 // implements any interfaces, add them to the queue.
  
!                 interfaces = searchClass.getInterfaces();
!                 length = interfaces.length;
  
!                 if (queue == null && length > 0)
!                     queue = new LinkedList();
  
!                 for (int i = 0; i < length; i++)
!                     queue.addLast(interfaces[i]);
  
!                 // Advance up to the next superclass
  
!                 searchClass = searchClass.getSuperclass();
  
!             }
  
!             // Ok, the easy part failed, lets start searching
!             // interfaces.
  
!             if (queue != null)
              {
!                 while (!queue.isEmpty())
!                 {
!                     searchClass = (Class) queue.removeFirst();
  
!                     result = registrations.get(searchClass);
!                     if (result != null)
!                         return result;
  
!                     // Interfaces can extend other interfaces; add them
!                     // to the queue.
  
!                     interfaces = searchClass.getInterfaces();
!                     length = interfaces.length;
  
!                     for (int i = 0; i < length; i++)
!                         queue.addLast(interfaces[i]);
!                 }
              }
  
!             // Not a match on interface; our last gasp is to check
!             // for a registration for java.lang.Object
! 
!             result = registrations.get(Object.class);
!             if (result != null)
!                 return result;
  
!         }
  
          // No match?  That's rare ... and an error.
--- 162,231 ----
      {
          LinkedList queue = null;
!         Object result = null;
  
          if (LOG.isDebugEnabled())
              LOG.debug("Searching for adaptor for class " + subjectClass.getName());
  
!         // Step one: work up through the class inheritance.
  
!         Class searchClass = subjectClass;
  
!         // Primitive types have null, not Object, as their parent
!         // class.
  
!         while (searchClass != Object.class && searchClass != null)
!         {
!             result = registrations.get(searchClass);
!             if (result != null)
!                 return result;
  
!             // Not an exact match.  If the search class
!             // implements any interfaces, add them to the queue.
  
!             Class[] interfaces = searchClass.getInterfaces();
!             int length = interfaces.length;
  
!             if (queue == null && length > 0)
!                 queue = new LinkedList();
  
!             for (int i = 0; i < length; i++)
!                 queue.addLast(interfaces[i]);
  
!             // Advance up to the next superclass
  
!             searchClass = searchClass.getSuperclass();
  
!         }
  
!         // Ok, the easy part failed, lets start searching
!         // interfaces.
  
!         if (queue != null)
!         {
!             while (!queue.isEmpty())
              {
!                 searchClass = (Class) queue.removeFirst();
  
!                 result = registrations.get(searchClass);
!                 if (result != null)
!                     return result;
  
!                 // Interfaces can extend other interfaces; add them
!                 // to the queue.
  
!                 Class[] interfaces = searchClass.getInterfaces();
!                 int length = interfaces.length;
  
!                 for (int i = 0; i < length; i++)
!                     queue.addLast(interfaces[i]);
              }
+         }
  
!         // Not a match on interface; our last gasp is to check
!         // for a registration for java.lang.Object
  
!         result = registrations.get(Object.class);
!         if (result != null)
!             return result;
  
          // No match?  That's rare ... and an error.
***************
*** 253,284 ****
      }
  
!     public String toString()
      {
          StringBuffer buffer = new StringBuffer();
          buffer.append("AdaptorRegistry[");
  
!         if (registrations != null)
!         {
!             synchronized (registrations)
!             {
!                 Iterator i = registrations.entrySet().iterator();
!                 boolean first = true;
  
!                 while (i.hasNext())
!                 {
!                     if (!first)
!                         buffer.append(' ');
  
!                     Map.Entry entry = (Map.Entry) i.next();
  
!                     Class registeredClass = (Class) entry.getKey();
  
!                     buffer.append(registeredClass.getName());
!                     buffer.append("=");
!                     buffer.append(entry.getValue());
  
!                     first = false;
!                 }
!             }
          }
  
--- 235,260 ----
      }
  
!     public synchronized String toString()
      {
          StringBuffer buffer = new StringBuffer();
          buffer.append("AdaptorRegistry[");
  
!         Iterator i = registrations.entrySet().iterator();
!         boolean showSep = false;
  
!         while (i.hasNext())
!         {
!             if (showSep)
!                 buffer.append(' ');
  
!             Map.Entry entry = (Map.Entry) i.next();
  
!             Class registeredClass = (Class) entry.getKey();
  
!             buffer.append(registeredClass.getName());
!             buffer.append("=");
!             buffer.append(entry.getValue());
  
!             showSep = true;
          }
  
***************
*** 286,290 ****
  
          return buffer.toString();
- 
      }
  }
--- 262,265 ----



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.