justinedelson closed pull request #2: SLING-7307 - remove embedded BeanUtils
URL: https://github.com/apache/sling-org-apache-sling-models-impl/pull/2
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/pom.xml b/pom.xml
index e670769..ee61eca 100644
--- a/pom.xml
+++ b/pom.xml
@@ -52,9 +52,6 @@
                 <extensions>true</extensions>
                 <configuration>
                   <instructions>
-                    <Embed-Dependency>
-                      *;artifactId=commons-beanutils;groupId=commons-beanutils
-                    </Embed-Dependency>
                     <!-- Remove those package imports because embedded and 
relocated via shade plugin (see below) -->
                     <Import-Package>
                       !org.apache.sling.commons.osgi,
@@ -224,13 +221,6 @@
             <version>2.0.20</version>
             <scope>compile</scope>
         </dependency>
-        <!-- Artifact is shaded and inlined, only some classes included (see 
above) -->
-        <dependency>
-            <groupId>commons-beanutils</groupId>
-            <artifactId>commons-beanutils</artifactId>
-            <version>1.8.3</version>
-            <scope>compile</scope>
-        </dependency>
         <dependency>
             <groupId>commons-lang</groupId>
             <artifactId>commons-lang</artifactId>
diff --git 
a/src/main/java/org/apache/sling/models/impl/via/BeanPropertyViaProvider.java 
b/src/main/java/org/apache/sling/models/impl/via/BeanPropertyViaProvider.java
index 6b6949b..337ee12 100644
--- 
a/src/main/java/org/apache/sling/models/impl/via/BeanPropertyViaProvider.java
+++ 
b/src/main/java/org/apache/sling/models/impl/via/BeanPropertyViaProvider.java
@@ -16,7 +16,6 @@
  */
 package org.apache.sling.models.impl.via;
 
-import org.apache.commons.beanutils.PropertyUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.felix.scr.annotations.Component;
 import org.apache.felix.scr.annotations.Service;
@@ -26,6 +25,10 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.beans.BeanInfo;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+
 @Component
 @Service
 public class BeanPropertyViaProvider implements ViaProvider {
@@ -43,10 +46,15 @@ public Object getAdaptable(Object original, String value) {
             return ORIGINAL;
         }
         try {
-            return PropertyUtils.getProperty(original, value);
+            BeanInfo beanInfo = Introspector.getBeanInfo(original.getClass());
+            for (PropertyDescriptor desc : beanInfo.getPropertyDescriptors()) {
+                if (desc.getName().equals(value)) {
+                    return desc.getReadMethod().invoke(original);
+                }
+            }
         } catch (Exception e) {
             log.error("Unable to execution projection " + value, e);
-            return null;
         }
+        return null;
     }
 }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to