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

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Mar 24 19:33:27 EDT 2010


Author: alesj
Date: 2010-03-24 19:33:27 -0400 (Wed, 24 Mar 2010)
New Revision: 102929

Added:
   projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/helpers/ClassResourceOwnerFinder.java
Modified:
   projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/helpers/ResourceOwnerFinder.java
Log:
Add class url owner finder.

Copied: projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/helpers/ClassResourceOwnerFinder.java (from rev 102927, projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/helpers/CachingResourceOwnerFinder.java)
===================================================================
--- projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/helpers/ClassResourceOwnerFinder.java	                        (rev 0)
+++ projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/helpers/ClassResourceOwnerFinder.java	2010-03-24 23:33:27 UTC (rev 102929)
@@ -0,0 +1,54 @@
+/*
+ * 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.helpers;
+
+import java.net.URL;
+import java.security.CodeSource;
+import java.security.ProtectionDomain;
+
+import org.jboss.classloading.spi.visitor.ResourceContext;
+
+/**
+ * Direct class source location fnder.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class ClassResourceOwnerFinder implements ResourceOwnerFinder
+{
+   /**
+    * This one loads the class.
+    *
+    * @param resource the resource
+    * @return the owner url
+    */
+   public URL findOwnerURL(ResourceContext resource)
+   {
+      if (resource.isClass() == false)
+         throw new IllegalArgumentException("Can only handle classes: " + resource);
+
+      Class<?> clazz = resource.loadClass();
+      ProtectionDomain domain = clazz.getProtectionDomain();
+      CodeSource source = domain.getCodeSource();
+      return source.getLocation();
+   }
+}
\ No newline at end of file

Modified: projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/helpers/ResourceOwnerFinder.java
===================================================================
--- projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/helpers/ResourceOwnerFinder.java	2010-03-24 22:24:57 UTC (rev 102928)
+++ projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/helpers/ResourceOwnerFinder.java	2010-03-24 23:33:27 UTC (rev 102929)
@@ -14,6 +14,11 @@
    /**
     * Find the resource owner.
     *
+    * There must be clear distinction between
+    * wheather the finder loads the resource (e.g. class) or not.
+    * Since not all finders are appropriate for resource lookup.
+    * e.g. eventual bytecode manipulation afterwards 
+    *
     * @param resource the resource
     * @return resource owner url
     */




More information about the jboss-cvs-commits mailing list