[jboss-cvs] JBossAS SVN: r105470 - projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/visitor.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Jun 1 08:28:44 EDT 2010


Author: alesj
Date: 2010-06-01 08:28:43 -0400 (Tue, 01 Jun 2010)
New Revision: 105470

Added:
   projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/visitor/CachingReflectProvider.java
Log:
Add caching reflect provider.

Copied: projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/visitor/CachingReflectProvider.java (from rev 104079, projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/visitor/ConfiguratorReflectProvider.java)
===================================================================
--- projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/visitor/CachingReflectProvider.java	                        (rev 0)
+++ projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/visitor/CachingReflectProvider.java	2010-06-01 12:28:43 UTC (rev 105470)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.scanning.plugins.visitor;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.classloading.spi.visitor.ResourceContext;
+import org.jboss.reflect.spi.TypeInfo;
+
+/**
+ * Cache type info directly.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class CachingReflectProvider implements ReflectProvider
+{
+   private ReflectProvider delegate;
+   private Map<ResourceContext, TypeInfo> cache = new HashMap<ResourceContext, TypeInfo>();
+
+   public CachingReflectProvider(ReflectProvider delegate)
+   {
+      if (delegate == null)
+         throw new IllegalArgumentException("Null delegate");
+      this.delegate = delegate;
+   }
+
+   public TypeInfo getTypeInfo(ResourceContext resource) throws Throwable
+   {
+      TypeInfo result = cache.get(resource);
+      if (result == null)
+      {
+         result = delegate.getTypeInfo(resource);
+         cache.put(resource, result);
+      }
+      return result;
+   }
+}
\ No newline at end of file




More information about the jboss-cvs-commits mailing list