You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by si...@apache.org on 2012/07/26 16:17:08 UTC
svn commit: r1366010 [1/2] - in /commons/sandbox/beanutils2/trunk/src:
changes/ main/java/org/apache/commons/beanutils2/
test/java/org/apache/commons/beanutils2/
test/java/org/apache/commons/beanutils2/testbeans/
Author: simonetripodi
Date: Thu Jul 26 14:17:06 2012
New Revision: 1366010
URL: http://svn.apache.org/viewvc?rev=1366010&view=rev
Log:
[SANDBOX-422] Wrap checked exceptions into unchecked exception - patch provided by Benedikt Ritter
Added:
commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/BeanClassNotFoundException.java (with props)
commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/BeanInstantiationException.java (with props)
commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/BeanReflectionException.java (with props)
commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/ConstructorInvocationException.java (with props)
commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/ConstructorNotAccessibleException.java (with props)
commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/MethodInvocationException.java (with props)
commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/MethodNotAccessibleException.java (with props)
commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/NoSuchBeanMethodException.java (with props)
commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/NoSuchConstructorException.java (with props)
commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/NoSuchPropertyException.java (with props)
commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/PropertyGetterInvocationException.java (with props)
commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/PropertyGetterNotAccessibleException.java (with props)
commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/PropertyNotReadableException.java (with props)
commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/PropertyNotWritableException.java (with props)
commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/PropertySetterInvocationException.java (with props)
commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/PropertySetterNotAccessibleException.java (with props)
commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/GetIndexedPropertyTestCase.java (with props)
commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/testbeans/AbstractTestBean.java (with props)
Modified:
commons/sandbox/beanutils2/trunk/src/changes/changes.xml
commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/ArgumentsAccessor.java
commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/BeanAccessor.java
commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/BeanProperties.java
commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/BeanPropertySetter.java
commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/ClassAccessor.java
commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/ClassLoaderBuilder.java
commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/DefaultArgumentsAccessor.java
commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/DefaultBeanAccessor.java
commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/DefaultBeanProperties.java
commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/DefaultBeanPropertySetter.java
commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/DefaultClassAccessor.java
commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/DefaultClassLoaderBuilder.java
commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/DefaultIndexedPropertyGetterAccessor.java
commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/DefaultIndexedPropertySetter.java
commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/DefaultIndexedPropertySetterAccessor.java
commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/IndexedPropertyGetterAccessor.java
commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/IndexedPropertySetterAccessor.java
commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/NullBeanAccessor.java
commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/ConstructorsTestCase.java
commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/GetPropertyTestCase.java
commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/MethodsTestCase.java
commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/OnClassNameTestCase.java
commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/SetIndexedPropertyTestCase.java
commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/SetPropertyTestCase.java
commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/StaticMethodsTestCase.java
Modified: commons/sandbox/beanutils2/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/changes/changes.xml?rev=1366010&r1=1366009&r2=1366010&view=diff
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/changes/changes.xml (original)
+++ commons/sandbox/beanutils2/trunk/src/changes/changes.xml Thu Jul 26 14:17:06 2012
@@ -35,6 +35,9 @@
<action dev="simonetripodi" type="add" issue="SANDBOX-426" due-to="Benedikt Ritter">
Add Cobertura Test Coverage Report to build
</action>
+ <action dev="simonetripodi" type="add" issue="SANDBOX-422" due-to="Benedikt Ritter">
+ Wrap checked exceptions into unchecked exception
+ </action>
<action dev="simonetripodi" type="add" issue="SANDBOX-421" due-to="Benedikt Ritter">
Make sure VoidMethodsTestCase uses a NullBeanAcessor
</action>
Modified: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/ArgumentsAccessor.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/ArgumentsAccessor.java?rev=1366010&r1=1366009&r2=1366010&view=diff
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/ArgumentsAccessor.java (original)
+++ commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/ArgumentsAccessor.java Thu Jul 26 14:17:06 2012
@@ -32,7 +32,7 @@ public interface ArgumentsAccessor
* arguments, you have to call {@link Argument#argument(Class, Object)} and pass the primitive class. This
* especially applies if you called {@link ClassAccessor#invokeExactConstructor(Argument...)},
* {@link ClassAccessor#invokeExactStatic(String)} or {@link BeanAccessor#invokeExact(String)} before.
- *
+ *
* @param arguments the arguments to be passed. May be empty.
* @return a {@link BeanAccessor} for the result of the method invocation.
* @throws IllegalArgumentException if the invoking the constructor or method would throw one.
@@ -40,7 +40,6 @@ public interface ArgumentsAccessor
* @throws InvocationTargetException TODO
* @throws NoSuchMethodException if no method with a fitting signature can be found.
*/
- BeanAccessor<?> withArguments( Argument<?>... arguments )
- throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, NoSuchMethodException;
+ BeanAccessor<?> withArguments( Argument<?>... arguments );
}
Modified: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/BeanAccessor.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/BeanAccessor.java?rev=1366010&r1=1366009&r2=1366010&view=diff
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/BeanAccessor.java (original)
+++ commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/BeanAccessor.java Thu Jul 26 14:17:06 2012
@@ -19,7 +19,6 @@ package org.apache.commons.beanutils2;
* under the License.
*/
-import java.beans.IntrospectionException;
import java.lang.reflect.InvocationTargetException;
import java.util.Map;
@@ -28,14 +27,11 @@ public interface BeanAccessor<B>
// get
- BeanAccessor<?> get( String propertyName )
- throws IllegalAccessException, IntrospectionException, InvocationTargetException, NoSuchMethodException;
+ BeanAccessor<?> get( String propertyName );
- IndexedPropertyGetterAccessor getIndexed( String propertyName )
- throws IntrospectionException, NoSuchMethodException;
+ IndexedPropertyGetterAccessor<?> getIndexed( String propertyName );
- MappedPropertyGetterAccessor getMapped( String propertyName )
- throws InvocationTargetException, NoSuchMethodException;
+ MappedPropertyGetterAccessor getMapped( String propertyName );
B get();
@@ -43,14 +39,11 @@ public interface BeanAccessor<B>
// set
- BeanPropertySetter<B> set( String propertyName )
- throws IllegalAccessException, IntrospectionException, InvocationTargetException, NoSuchMethodException;
+ BeanPropertySetter<B> set( String propertyName );
- IndexedPropertySetterAccessor<B> setIndexed( String propertyName )
- throws IllegalAccessException, IntrospectionException, InvocationTargetException, NoSuchMethodException;
+ IndexedPropertySetterAccessor<B> setIndexed( String propertyName );
- IndexedPropertySetterAccessor<B> setMapped( String propertyName )
- throws IllegalAccessException, IntrospectionException, InvocationTargetException, NoSuchMethodException;
+ IndexedPropertySetterAccessor<B> setMapped( String propertyName );
// clone
@@ -71,9 +64,7 @@ public interface BeanAccessor<B>
* @throws NoSuchMethodException if an accessor method for this property cannot be found
* @throws IntrospectionException
*/
- B cloneBean()
- throws IllegalAccessException, InstantiationException, IntrospectionException,
- InvocationTargetException, NoSuchMethodException;
+ B cloneBean();
/**
* <p>Copies property values from the bean wrapped by this BeanAccessor
@@ -99,8 +90,7 @@ public interface BeanAccessor<B>
* @throws InvocationTargetException if any of the property accessor methods throws an exception
* @throws NoSuchMethodException if an accessor method for a property cannot be found
*/
- <T extends B> void copyPropertiesTo( T target )
- throws IllegalAccessException, IntrospectionException, InvocationTargetException, NoSuchMethodException;
+ <T extends B> void copyPropertiesTo( T target );
// description
@@ -133,6 +123,7 @@ public interface BeanAccessor<B>
* </p>
* @return Map that contains the property names as keys and property values as values.
*
+ * TODO update to Wrapper Exceptions
* @exception IllegalAccessException if the caller does not have
* access to the property accessor method
* @exception InvocationTargetException if one of the property accessor methods
@@ -142,12 +133,9 @@ public interface BeanAccessor<B>
* property cannot be found
* @throws IntrospectionException TODO
*/
- Map<String, Object> describe()
- throws IllegalAccessException, InvocationTargetException, NoSuchMethodException, IntrospectionException;
+ Map<String, Object> describe();
- void populate( Map<String, Object> properties )
- throws IllegalAccessException, IllegalArgumentException, IntrospectionException, InvocationTargetException,
- NoSuchMethodException;
+ void populate( Map<String, Object> properties );
// methods invocation
@@ -161,8 +149,7 @@ public interface BeanAccessor<B>
* @throws IllegalAccessException if the method is not visible to the caller
* @throws InvocationTargetException TODO
*/
- ArgumentsAccessor invoke( String methodName )
- throws NoSuchMethodException, IllegalAccessException, InvocationTargetException;
+ ArgumentsAccessor invoke( String methodName );
/**
* Invoke the method with name {@code methodName} and the exact arguments.
@@ -174,7 +161,6 @@ public interface BeanAccessor<B>
* @throws IllegalAccessException if the method is not visible to the caller
* @throws InvocationTargetException TODO
*/
- ArgumentsAccessor invokeExact( String methodName )
- throws NoSuchMethodException, IllegalAccessException, InvocationTargetException;
+ ArgumentsAccessor invokeExact( String methodName );
}
Added: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/BeanClassNotFoundException.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/BeanClassNotFoundException.java?rev=1366010&view=auto
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/BeanClassNotFoundException.java (added)
+++ commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/BeanClassNotFoundException.java Thu Jul 26 14:17:06 2012
@@ -0,0 +1,33 @@
+package org.apache.commons.beanutils2;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+public class BeanClassNotFoundException
+ extends BeanReflectionException
+{
+
+ private static final long serialVersionUID = 201207122218L;
+
+ public BeanClassNotFoundException( String beanTypeName, Throwable cause )
+ {
+ super( cause, null, "Bean class '%s' could not be found!", beanTypeName );
+ }
+
+}
Propchange: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/BeanClassNotFoundException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/BeanClassNotFoundException.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/BeanClassNotFoundException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/BeanInstantiationException.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/BeanInstantiationException.java?rev=1366010&view=auto
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/BeanInstantiationException.java (added)
+++ commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/BeanInstantiationException.java Thu Jul 26 14:17:06 2012
@@ -0,0 +1,33 @@
+package org.apache.commons.beanutils2;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+public class BeanInstantiationException
+ extends BeanReflectionException
+{
+
+ private static final long serialVersionUID = 201212072136L;
+
+ public BeanInstantiationException( Class<?> beanType, Throwable cause )
+ {
+ super( cause, beanType, "Could not create a new instance of type '%s'.", beanType );
+ }
+
+}
Propchange: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/BeanInstantiationException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/BeanInstantiationException.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/BeanInstantiationException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/BeanProperties.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/BeanProperties.java?rev=1366010&r1=1366009&r2=1366010&view=diff
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/BeanProperties.java (original)
+++ commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/BeanProperties.java Thu Jul 26 14:17:06 2012
@@ -79,7 +79,7 @@ public interface BeanProperties<B>
* @throws NoSuchMethodException
*/
Method getReadPropertyMethod( String propertyName )
- throws IntrospectionException, NoSuchMethodException;
+ throws IntrospectionException;
/**
*
@@ -89,7 +89,7 @@ public interface BeanProperties<B>
* @throws IntrospectionException
*/
Method getWriteMethod( String name )
- throws NoSuchMethodException, IntrospectionException;
+ throws IntrospectionException;
/**
*
@@ -99,7 +99,7 @@ public interface BeanProperties<B>
* @throws IntrospectionException
*/
IndexedPropertyDescriptor getIndexedPropertyDescriptor( String propertyName )
- throws NoSuchMethodException, IntrospectionException;
+ throws IntrospectionException;
/**
*
@@ -109,7 +109,7 @@ public interface BeanProperties<B>
* @throws IntrospectionException
*/
Method getIndexedReadMethod( String propertyName )
- throws NoSuchMethodException, IntrospectionException;
+ throws IntrospectionException;
/**
*
@@ -119,7 +119,7 @@ public interface BeanProperties<B>
* @throws IntrospectionException
*/
Method getIndexedWriteMethod( String propertyName )
- throws NoSuchMethodException, IntrospectionException;
+ throws IntrospectionException;
/**
*
Modified: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/BeanPropertySetter.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/BeanPropertySetter.java?rev=1366010&r1=1366009&r2=1366010&view=diff
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/BeanPropertySetter.java (original)
+++ commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/BeanPropertySetter.java Thu Jul 26 14:17:06 2012
@@ -19,12 +19,10 @@ package org.apache.commons.beanutils2;
* under the License.
*/
-import java.lang.reflect.InvocationTargetException;
public interface BeanPropertySetter<B>
{
- <V> BeanAccessor<B> with( V value )
- throws IllegalAccessException, IllegalArgumentException, InvocationTargetException;
+ <V> BeanAccessor<B> with( V value );
}
Added: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/BeanReflectionException.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/BeanReflectionException.java?rev=1366010&view=auto
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/BeanReflectionException.java (added)
+++ commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/BeanReflectionException.java Thu Jul 26 14:17:06 2012
@@ -0,0 +1,62 @@
+package org.apache.commons.beanutils2;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+import static java.lang.String.format;
+
+public class BeanReflectionException
+ extends RuntimeException
+{
+ private static final long serialVersionUID = 201206182113L;
+
+ private final Class<?> beanType;
+
+ /**
+ * Constructs a new instance of BeanReflectionException.
+ *
+ * @param cause the throwable that caused the exception
+ * @param beanType the bean type, the exception is associated with
+ * @param messagePattern the message pattern for the exception's message
+ * @param arguments the arguments referenced by the format specifiers in the message pattern
+ */
+ public BeanReflectionException( Throwable cause, Class<?> beanType, String messagePattern, Object... arguments )
+ {
+ super( format( messagePattern, arguments ), cause );
+ this.beanType = beanType;
+ }
+
+ /**
+ * Constructs a new instance of BeanReflectionException.
+ *
+ * @param cause the throwable that caused the exception
+ * @param beanType the bean type, the exception is associated with
+ */
+ public BeanReflectionException( Throwable cause, Class<?> beanType )
+ {
+ super( cause );
+ this.beanType = beanType;
+ }
+
+ public Class<?> getBeanType()
+ {
+ return beanType;
+ }
+
+}
Propchange: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/BeanReflectionException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/BeanReflectionException.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/BeanReflectionException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/ClassAccessor.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/ClassAccessor.java?rev=1366010&r1=1366009&r2=1366010&view=diff
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/ClassAccessor.java (original)
+++ commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/ClassAccessor.java Thu Jul 26 14:17:06 2012
@@ -19,24 +19,16 @@ package org.apache.commons.beanutils2;
* under the License.
*/
-import java.lang.reflect.InvocationTargetException;
-
public interface ClassAccessor<B>
{
// constructors
- BeanAccessor<B> newInstance()
- throws InstantiationException, IllegalAccessException;
+ BeanAccessor<B> newInstance();
- BeanAccessor<B> invokeConstructor( Argument<?>... arguments )
- throws IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException,
- NoSuchMethodException;
-
- BeanAccessor<B> invokeExactConstructor( Argument<?>...arguments )
- throws IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException,
- NoSuchMethodException;
+ BeanAccessor<B> invokeConstructor( Argument<?>... arguments );
+ BeanAccessor<B> invokeExactConstructor( Argument<?>...arguments );
// bean properties
BeanProperties<B> getProperties();
Modified: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/ClassLoaderBuilder.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/ClassLoaderBuilder.java?rev=1366010&r1=1366009&r2=1366010&view=diff
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/ClassLoaderBuilder.java (original)
+++ commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/ClassLoaderBuilder.java Thu Jul 26 14:17:06 2012
@@ -22,13 +22,10 @@ package org.apache.commons.beanutils2;
public interface ClassLoaderBuilder
{
- ClassAccessor<?> loadWithThreadContextClassLoader()
- throws ClassNotFoundException;
+ ClassAccessor<?> loadWithThreadContextClassLoader();
- ClassAccessor<?> loadWithBeanUtilsClassLoader()
- throws ClassNotFoundException;
+ ClassAccessor<?> loadWithBeanUtilsClassLoader();
- ClassAccessor<?> loadWithClassLoader( ClassLoader classLoader )
- throws ClassNotFoundException;
+ ClassAccessor<?> loadWithClassLoader( ClassLoader classLoader );
}
Added: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/ConstructorInvocationException.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/ConstructorInvocationException.java?rev=1366010&view=auto
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/ConstructorInvocationException.java (added)
+++ commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/ConstructorInvocationException.java Thu Jul 26 14:17:06 2012
@@ -0,0 +1,33 @@
+package org.apache.commons.beanutils2;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+public class ConstructorInvocationException
+ extends BeanReflectionException
+{
+
+ private static final long serialVersionUID = 201207122148L;
+
+ public ConstructorInvocationException( Class<?> beanType, Throwable cause )
+ {
+ super( cause, beanType, "Invocation of constructor on '%s' caused an exception!", beanType.getName() );
+ }
+
+}
Propchange: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/ConstructorInvocationException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/ConstructorInvocationException.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/ConstructorInvocationException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/ConstructorNotAccessibleException.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/ConstructorNotAccessibleException.java?rev=1366010&view=auto
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/ConstructorNotAccessibleException.java (added)
+++ commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/ConstructorNotAccessibleException.java Thu Jul 26 14:17:06 2012
@@ -0,0 +1,33 @@
+package org.apache.commons.beanutils2;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+public class ConstructorNotAccessibleException
+ extends BeanReflectionException
+{
+
+ private static final long serialVersionUID = 201212072138L;
+
+ public ConstructorNotAccessibleException( Class<?> beanType, Throwable cause )
+ {
+ super( cause, beanType, "Parameterless constructor of type '%s' is not accessible!", beanType );
+ }
+
+}
Propchange: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/ConstructorNotAccessibleException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/ConstructorNotAccessibleException.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/ConstructorNotAccessibleException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/DefaultArgumentsAccessor.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/DefaultArgumentsAccessor.java?rev=1366010&r1=1366009&r2=1366010&view=diff
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/DefaultArgumentsAccessor.java (original)
+++ commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/DefaultArgumentsAccessor.java Thu Jul 26 14:17:06 2012
@@ -19,7 +19,6 @@ package org.apache.commons.beanutils2;
* under the License.
*/
-import static java.lang.String.format;
import static org.apache.commons.beanutils2.Argument.getParameterTypes;
import static org.apache.commons.beanutils2.Argument.getParameters;
import static org.apache.commons.beanutils2.Assertions.checkNoneIsNull;
@@ -52,7 +51,6 @@ final class DefaultArgumentsAccessor
}
public BeanAccessor<?> withArguments( Argument<?>... arguments )
- throws IllegalArgumentException, IllegalAccessException, InvocationTargetException, NoSuchMethodException
{
arguments = checkNotNull( arguments,
"Impossible to invoke %s.%s with null arguments, use empty parameters instead",
@@ -64,16 +62,32 @@ final class DefaultArgumentsAccessor
if ( method == null )
{
- throw new NoSuchMethodException( format( "No such accessible method: %s() on object: %s",
- methodName, beanType.getName() ) );
+ throw new NoSuchBeanMethodException( methodName, beanType, null );
}
- Object result = method.invoke( bean, getParameters( arguments ) );
- if ( method.getReturnType() == void.class || result == null)
+ Object result = invoke( method, arguments );
+
+ if ( method.getReturnType() == void.class || result == null )
{
- return new NullBeanAccessor<Object>(beanType.getName(), methodName);
+ return new NullBeanAccessor<Object>( beanType.getName(), methodName );
}
return new DefaultBeanAccessor<Object>( result );
}
+ private Object invoke( Method method, Argument<?>... arguments )
+ {
+ try
+ {
+ return method.invoke( bean, getParameters( arguments ) );
+ }
+ catch ( IllegalAccessException e )
+ {
+ throw new MethodNotAccessibleException( method.getName(), beanType, e );
+ }
+ catch ( InvocationTargetException e )
+ {
+ throw new MethodInvocationException( method.getName(), beanType, e );
+ }
+ }
+
}
Modified: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/DefaultBeanAccessor.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/DefaultBeanAccessor.java?rev=1366010&r1=1366009&r2=1366010&view=diff
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/DefaultBeanAccessor.java (original)
+++ commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/DefaultBeanAccessor.java Thu Jul 26 14:17:06 2012
@@ -25,6 +25,7 @@ import static org.apache.commons.beanuti
import java.beans.IntrospectionException;
import java.beans.PropertyDescriptor;
import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
@@ -51,29 +52,56 @@ final class DefaultBeanAccessor<B>
* {@inheritDoc}
*/
public BeanAccessor<?> get( String propertyName )
- throws IllegalAccessException, IntrospectionException, InvocationTargetException, NoSuchMethodException
{
checkNotNull( propertyName, "Parameter 'propertyName' must not be null!" );
- Object newBean = properties.getReadPropertyMethod( propertyName ).invoke( bean );
+ Method readMethod;
+ try
+ {
+ readMethod = properties.getReadPropertyMethod( propertyName );
+ }
+ catch ( IntrospectionException e )
+ {
+ throw new NoSuchPropertyException( propertyName, bean.getClass(), e );
+ }
+
+ Object newBean;
+ try
+ {
+ newBean = readMethod.invoke( bean );
+ }
+ catch ( IllegalAccessException e )
+ {
+ throw new PropertyGetterNotAccessibleException( propertyName, readMethod.getName(), bean.getClass(), e );
+ }
+ catch ( InvocationTargetException e )
+ {
+ throw new PropertyGetterInvocationException( propertyName, readMethod.getName(), bean.getClass(), e );
+ }
return new DefaultBeanAccessor<Object>( newBean );
}
/**
* {@inheritDoc}
*/
- public IndexedPropertyGetterAccessor getIndexed( String propertyName )
- throws IntrospectionException, NoSuchMethodException
+ public IndexedPropertyGetterAccessor<B> getIndexed( String propertyName )
{
checkNotNull( propertyName, "Parameter 'propertyName' must not be null!" );
- return new DefaultIndexedPropertyGetterAccessor( bean, propertyName,
- properties.getIndexedReadMethod( propertyName ) );
+ Method indexedReadMethod;
+ try
+ {
+ indexedReadMethod = properties.getIndexedReadMethod( propertyName );
+ }
+ catch ( IntrospectionException e )
+ {
+ throw new NoSuchPropertyException( propertyName, getBeanClass(), e );
+ }
+ return new DefaultIndexedPropertyGetterAccessor<B>( bean, propertyName, indexedReadMethod );
}
/**
* {@inheritDoc}
*/
public MappedPropertyGetterAccessor getMapped( String propertyName )
- throws InvocationTargetException, NoSuchMethodException
{
// TODO
return null;
@@ -103,28 +131,42 @@ final class DefaultBeanAccessor<B>
* {@inheritDoc}
*/
public BeanPropertySetter<B> set( String propertyName )
- throws IllegalAccessException, IntrospectionException, InvocationTargetException, NoSuchMethodException
{
checkNotNull( propertyName, "Parameter 'propertyName' must not be null!" );
- return new DefaultBeanPropertySetter<B>( bean, properties.getWriteMethod( propertyName ) );
+ Method writeMethod;
+ try
+ {
+ writeMethod = properties.getWriteMethod( propertyName );
+ }
+ catch ( IntrospectionException e )
+ {
+ throw new NoSuchPropertyException( propertyName, getBeanClass(), e );
+ }
+ return new DefaultBeanPropertySetter<B>( bean, writeMethod, propertyName );
}
/**
* {@inheritDoc}
*/
public IndexedPropertySetterAccessor<B> setIndexed( String propertyName )
- throws IllegalAccessException, IntrospectionException, InvocationTargetException, NoSuchMethodException
{
checkNotNull( propertyName, "Parameter 'propertyName' must not be null!" );
- return new DefaultIndexedPropertySetterAccessor<B>( bean, propertyName,
- properties.getIndexedWriteMethod( propertyName ) );
+ Method indexedWriteMethod;
+ try
+ {
+ indexedWriteMethod = properties.getIndexedWriteMethod( propertyName );
+ }
+ catch ( IntrospectionException e )
+ {
+ throw new NoSuchPropertyException( propertyName, getBeanClass(), e );
+ }
+ return new DefaultIndexedPropertySetterAccessor<B>( bean, propertyName, indexedWriteMethod );
}
/**
* {@inheritDoc}
*/
public IndexedPropertySetterAccessor<B> setMapped( String propertyName )
- throws IllegalAccessException, IntrospectionException, InvocationTargetException, NoSuchMethodException
{
// TODO
return null;
@@ -134,8 +176,6 @@ final class DefaultBeanAccessor<B>
* {@inheritDoc}
*/
public B cloneBean()
- throws IllegalAccessException, InstantiationException, IntrospectionException, InvocationTargetException,
- NoSuchMethodException
{
BeanAccessor<B> cloneAccessor = on( getBeanClass() ).newInstance();
cloneAccessor.populate( describe() );
@@ -153,7 +193,6 @@ final class DefaultBeanAccessor<B>
* {@inheritDoc}
*/
public <T extends B> void copyPropertiesTo( T target )
- throws IllegalAccessException, IntrospectionException, InvocationTargetException, NoSuchMethodException
{
checkNotNull( target, "Can not copy properties to null!" );
on( target ).populate( describe() );
@@ -163,9 +202,18 @@ final class DefaultBeanAccessor<B>
* {@inheritDoc}
*/
public Map<String, Object> describe()
- throws IllegalAccessException, IntrospectionException, InvocationTargetException, NoSuchMethodException
{
- final Map<String, PropertyDescriptor> propertiesIndex = properties.getPropertiesIndex();
+ Map<String, PropertyDescriptor> propertiesIndex;
+ try
+ {
+ propertiesIndex = properties.getPropertiesIndex();
+ }
+ catch ( IntrospectionException e )
+ {
+ // FIXME can we throw something more specific?
+ throw new BeanReflectionException( e, getBeanClass(),
+ "Error while reading out properties index of type '%s'", getBeanClass() );
+ }
final Map<String, Object> result = new HashMap<String, Object>( propertiesIndex.size() );
for ( Entry<String, PropertyDescriptor> key : propertiesIndex.entrySet() )
@@ -173,7 +221,7 @@ final class DefaultBeanAccessor<B>
PropertyDescriptor propertyDescriptor = key.getValue();
if ( propertyDescriptor.getReadMethod() != null )
{
- Object value = propertyDescriptor.getReadMethod().invoke( bean );
+ Object value = invoke( propertyDescriptor );
result.put( key.getKey(), value );
}
}
@@ -181,12 +229,31 @@ final class DefaultBeanAccessor<B>
return result;
}
+ private Object invoke( PropertyDescriptor propertyDescriptor )
+ {
+ Method readMethod = propertyDescriptor.getReadMethod();
+ Object value;
+ try
+ {
+ value = readMethod.invoke( bean );
+ }
+ catch ( IllegalAccessException e )
+ {
+ throw new PropertyGetterNotAccessibleException( propertyDescriptor.getName(), readMethod.getName(),
+ getBeanClass(), e );
+ }
+ catch ( InvocationTargetException e )
+ {
+ throw new PropertyGetterInvocationException( propertyDescriptor.getName(), readMethod.getName(),
+ getBeanClass(), e );
+ }
+ return value;
+ }
+
/**
* {@inheritDoc}
*/
public void populate( Map<String, Object> properties )
- throws IllegalAccessException, IllegalArgumentException, IntrospectionException, InvocationTargetException,
- NoSuchMethodException
{
for ( Entry<String, Object> entry : properties.entrySet() )
{
@@ -198,11 +265,17 @@ final class DefaultBeanAccessor<B>
}
private void setIfWritable( String propertyName, Object propertyValue )
- throws IntrospectionException, IllegalAccessException, InvocationTargetException, NoSuchMethodException
{
- if ( properties.hasProperty( propertyName ) && properties.isWritable( propertyName ) )
+ try
+ {
+ if ( properties.hasProperty( propertyName ) && properties.isWritable( propertyName ) )
+ {
+ set( propertyName ).with( propertyValue );
+ }
+ }
+ catch ( IntrospectionException e )
{
- set( propertyName ).with( propertyValue );
+ throw new NoSuchPropertyException( propertyName, getBeanClass(), e );
}
}
@@ -210,7 +283,6 @@ final class DefaultBeanAccessor<B>
* {@inheritDoc}
*/
public ArgumentsAccessor invoke( String methodName )
- throws NoSuchMethodException, IllegalAccessException, InvocationTargetException
{
Class<B> beanClass = getBeanClass();
checkNotNull( methodName, "Impossible to execute null method in %s", beanClass.getName() );
@@ -221,7 +293,6 @@ final class DefaultBeanAccessor<B>
* {@inheritDoc}
*/
public ArgumentsAccessor invokeExact( String methodName )
- throws NoSuchMethodException, IllegalAccessException, InvocationTargetException
{
Class<B> beanClass = getBeanClass();
checkNotNull( methodName, "Impossible to execute null method in %s", beanClass.getName() );
Modified: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/DefaultBeanProperties.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/DefaultBeanProperties.java?rev=1366010&r1=1366009&r2=1366010&view=diff
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/DefaultBeanProperties.java (original)
+++ commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/DefaultBeanProperties.java Thu Jul 26 14:17:06 2012
@@ -114,33 +114,29 @@ final class DefaultBeanProperties<B>
* {@inheritDoc}
*/
public Method getReadPropertyMethod( String propertyName )
- throws IntrospectionException, NoSuchMethodException
+ throws IntrospectionException
{
PropertyDescriptor propertyDescriptor = getPropertyDescriptor( propertyName );
- return checkMethod( propertyDescriptor.getReadMethod(),
- "Bean of type %s does not provide a getter for property '%s'!",
- beanClass.getName(), propertyName );
+ return checkGetterMethod( propertyDescriptor.getReadMethod(), propertyName );
}
/**
* {@inheritDoc}
*/
public Method getWriteMethod( String name )
- throws NoSuchMethodException, IntrospectionException
+ throws IntrospectionException
{
PropertyDescriptor propertyDescriptor = getPropertyDescriptor( name );
- return checkMethod( propertyDescriptor.getWriteMethod(),
- "Bean of type %s does not provide a setter for property '%s'!",
- beanClass.getName(), name );
+ return checkSetterMethod( propertyDescriptor.getWriteMethod(), name );
}
/**
* {@inheritDoc}
*/
public IndexedPropertyDescriptor getIndexedPropertyDescriptor( String propertyName )
- throws NoSuchMethodException, IntrospectionException
+ throws IntrospectionException
{
PropertyDescriptor propertyDescriptor = getPropertyDescriptor( propertyName );
checkArgument( propertyDescriptor instanceof IndexedPropertyDescriptor,
@@ -152,34 +148,39 @@ final class DefaultBeanProperties<B>
* {@inheritDoc}
*/
public Method getIndexedReadMethod( String propertyName )
- throws NoSuchMethodException, IntrospectionException
+ throws IntrospectionException
{
IndexedPropertyDescriptor indexedPropertyDescriptor = getIndexedPropertyDescriptor( propertyName );
- return checkMethod( indexedPropertyDescriptor.getIndexedReadMethod(),
- "Bean of type %s does not provide a getter for indexed property '%s'!",
- beanClass.getName(), propertyName );
+ return checkGetterMethod( indexedPropertyDescriptor.getIndexedReadMethod(), propertyName );
}
/**
* {@inheritDoc}
*/
public Method getIndexedWriteMethod( String propertyName )
- throws NoSuchMethodException, IntrospectionException
+ throws IntrospectionException
{
IndexedPropertyDescriptor indexedPropertyDescriptor = getIndexedPropertyDescriptor( propertyName );
- return checkMethod( indexedPropertyDescriptor.getIndexedWriteMethod(),
- "Bean of type %s does not provide a getter for indexed property '%s'!",
- beanClass.getName(), propertyName );
+ return checkSetterMethod( indexedPropertyDescriptor.getIndexedWriteMethod(), propertyName );
+ }
+
+ private Method checkSetterMethod( Method method, String propertyName )
+ {
+ if ( method == null )
+ {
+ throw new PropertyNotWritableException( propertyName, beanClass, null );
+ }
+
+ return method;
}
- private static Method checkMethod( Method method, String errorMessageTemplate, Object...arsg )
- throws NoSuchMethodException
+ private Method checkGetterMethod( Method method, String propertyName )
{
if ( method == null )
{
- throw new NoSuchMethodException( format( errorMessageTemplate, arsg ) );
+ throw new PropertyNotReadableException( propertyName, beanClass, null );
}
return method;
Modified: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/DefaultBeanPropertySetter.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/DefaultBeanPropertySetter.java?rev=1366010&r1=1366009&r2=1366010&view=diff
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/DefaultBeanPropertySetter.java (original)
+++ commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/DefaultBeanPropertySetter.java Thu Jul 26 14:17:06 2012
@@ -33,17 +33,19 @@ final class DefaultBeanPropertySetter<B>
private final Method setterMethod;
- public DefaultBeanPropertySetter( B bean, Method setterMethod )
+ private final String propertyName;
+
+ public DefaultBeanPropertySetter( B bean, Method setterMethod, String propertyName )
{
this.bean = bean;
this.setterMethod = setterMethod;
+ this.propertyName = propertyName;
}
/**
* {@inheritDoc}
*/
public <V> BeanAccessor<B> with( V value )
- throws IllegalAccessException, IllegalArgumentException, InvocationTargetException
{
Class<?> paramType = setterMethod.getParameterTypes()[0];
@@ -58,9 +60,25 @@ final class DefaultBeanPropertySetter<B>
value.getClass().getName(), paramType.getName() );
}
- setterMethod.invoke( bean, value );
+ invokeSetter( value );
return new DefaultBeanAccessor<B>( bean );
}
+ private <V> void invokeSetter( V value )
+ {
+ try
+ {
+ setterMethod.invoke( bean, value );
+ }
+ catch ( IllegalAccessException e )
+ {
+ throw new PropertySetterNotAccessibleException( propertyName, setterMethod.getName(), bean.getClass(), e );
+ }
+ catch ( InvocationTargetException e )
+ {
+ throw new PropertySetterInvocationException( propertyName, setterMethod.getName(), bean.getClass(), e );
+ }
+ }
+
}
Modified: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/DefaultClassAccessor.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/DefaultClassAccessor.java?rev=1366010&r1=1366009&r2=1366010&view=diff
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/DefaultClassAccessor.java (original)
+++ commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/DefaultClassAccessor.java Thu Jul 26 14:17:06 2012
@@ -49,10 +49,20 @@ final class DefaultClassAccessor<B>
* {@inheritDoc}
*/
public BeanAccessor<B> newInstance()
- throws InstantiationException, IllegalAccessException
{
- B bean = (B) beanClass.newInstance();
- return new DefaultBeanAccessor<B>( bean );
+ try
+ {
+ B bean = beanClass.newInstance();
+ return new DefaultBeanAccessor<B>( bean );
+ }
+ catch ( InstantiationException e )
+ {
+ throw new BeanInstantiationException( beanClass, e );
+ }
+ catch ( IllegalAccessException e )
+ {
+ throw new ConstructorNotAccessibleException( beanClass, e );
+ }
}
// constructors
@@ -61,8 +71,6 @@ final class DefaultClassAccessor<B>
* {@inheritDoc}
*/
public BeanAccessor<B> invokeConstructor( Argument<?>... arguments )
- throws IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException,
- NoSuchMethodException
{
arguments = checkNotNull( arguments,
"Null arguments not admitted - don't pass any argument to use %s empty constructor",
@@ -75,8 +83,6 @@ final class DefaultClassAccessor<B>
* {@inheritDoc}
*/
public BeanAccessor<B> invokeExactConstructor( Argument<?>... arguments )
- throws IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException,
- NoSuchMethodException
{
arguments = checkNotNull( arguments,
"Null arguments not admitted - don't pass any argument to use %s empty constructor",
@@ -97,8 +103,6 @@ final class DefaultClassAccessor<B>
* @throws NoSuchMethodException
*/
private BeanAccessor<B> invokeConstructor( boolean exact, Argument<?>... arguments )
- throws IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException,
- NoSuchMethodException
{
@SuppressWarnings( "unchecked" ) // type driven by beanClass
Constructor<B> constructor = (Constructor<B>) constructorRegistry.get( exact,
@@ -107,7 +111,7 @@ final class DefaultClassAccessor<B>
if ( null == constructor )
{
- throw new NoSuchMethodException( "No such accessible constructor on class: " + beanClass );
+ throw new NoSuchConstructorException( beanClass, null );
}
int argumentsLength = arguments.length;
@@ -117,10 +121,30 @@ final class DefaultClassAccessor<B>
parameterObjects[i] = arguments[i].getValue();
}
- B bean = constructor.newInstance( parameterObjects );
+ B bean = doInvokeConstructor( constructor, parameterObjects );
return new DefaultBeanAccessor<B>( bean );
}
+ private B doInvokeConstructor( Constructor<B> constructor, Object[] parameterObjects )
+ {
+ try
+ {
+ return constructor.newInstance( parameterObjects );
+ }
+ catch ( InstantiationException e )
+ {
+ throw new BeanInstantiationException( beanClass, e );
+ }
+ catch ( IllegalAccessException e )
+ {
+ throw new ConstructorNotAccessibleException( beanClass, e );
+ }
+ catch ( InvocationTargetException e )
+ {
+ throw new ConstructorInvocationException( beanClass, e );
+ }
+ }
+
// bean properties
public BeanProperties<B> getProperties()
Modified: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/DefaultClassLoaderBuilder.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/DefaultClassLoaderBuilder.java?rev=1366010&r1=1366009&r2=1366010&view=diff
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/DefaultClassLoaderBuilder.java (original)
+++ commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/DefaultClassLoaderBuilder.java Thu Jul 26 14:17:06 2012
@@ -37,7 +37,6 @@ final class DefaultClassLoaderBuilder
* {@inheritDoc}
*/
public ClassAccessor<?> loadWithThreadContextClassLoader()
- throws ClassNotFoundException
{
return loadWithClassLoader( currentThread().getContextClassLoader() );
}
@@ -46,7 +45,6 @@ final class DefaultClassLoaderBuilder
* {@inheritDoc}
*/
public ClassAccessor<?> loadWithBeanUtilsClassLoader()
- throws ClassNotFoundException
{
return loadWithClassLoader( getClass().getClassLoader() );
}
@@ -55,11 +53,18 @@ final class DefaultClassLoaderBuilder
* {@inheritDoc}
*/
public ClassAccessor<?> loadWithClassLoader( ClassLoader classLoader )
- throws ClassNotFoundException
{
classLoader = checkNotNull( classLoader, "No ClassLoader specified" );
- Class<?> beanType = classLoader.loadClass( beanTypeName );
+ Class<?> beanType;
+ try
+ {
+ beanType = classLoader.loadClass( beanTypeName );
+ }
+ catch ( ClassNotFoundException e )
+ {
+ throw new BeanClassNotFoundException( beanTypeName, e );
+ }
@SuppressWarnings( { "rawtypes", "unchecked" } ) // ClassAccessor raw type is unknown
DefaultClassAccessor<?> accessor = new DefaultClassAccessor( beanType );
Modified: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/DefaultIndexedPropertyGetterAccessor.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/DefaultIndexedPropertyGetterAccessor.java?rev=1366010&r1=1366009&r2=1366010&view=diff
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/DefaultIndexedPropertyGetterAccessor.java (original)
+++ commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/DefaultIndexedPropertyGetterAccessor.java Thu Jul 26 14:17:06 2012
@@ -24,17 +24,17 @@ import static org.apache.commons.beanuti
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
-final class DefaultIndexedPropertyGetterAccessor
- implements IndexedPropertyGetterAccessor
+final class DefaultIndexedPropertyGetterAccessor<B>
+ implements IndexedPropertyGetterAccessor<B>
{
- private final Object bean;
+ private final B bean;
private final String propertyName;
private final Method indexedReadMethod;
- public DefaultIndexedPropertyGetterAccessor( Object bean, String propertyName, Method indexedReadMethod )
+ public DefaultIndexedPropertyGetterAccessor( B bean, String propertyName, Method indexedReadMethod )
{
this.bean = bean;
this.propertyName = propertyName;
@@ -45,12 +45,27 @@ final class DefaultIndexedPropertyGetter
* {@inheritDoc}
*/
public BeanAccessor<?> at( int index )
- throws IllegalArgumentException, IllegalAccessException, InvocationTargetException
{
checkArgument( index >= 0, "Indexed property '%s' in bean of type %s cannot be get from a negative index %s",
propertyName, bean.getClass().getName(), index );
- Object indexedValue = indexedReadMethod.invoke( bean, index );
+ Object indexedValue = invokeGetter( index );
return new DefaultBeanAccessor<Object>( indexedValue );
}
+ private Object invokeGetter( int index )
+ {
+ try
+ {
+ return indexedReadMethod.invoke( bean, index );
+ }
+ catch ( IllegalAccessException e )
+ {
+ throw new PropertyGetterNotAccessibleException( propertyName, indexedReadMethod.getName(), bean.getClass(), e );
+ }
+ catch ( InvocationTargetException e )
+ {
+ throw new PropertyGetterInvocationException( propertyName, indexedReadMethod.getName(), bean.getClass(), e );
+ }
+ }
+
}
Modified: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/DefaultIndexedPropertySetter.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/DefaultIndexedPropertySetter.java?rev=1366010&r1=1366009&r2=1366010&view=diff
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/DefaultIndexedPropertySetter.java (original)
+++ commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/DefaultIndexedPropertySetter.java Thu Jul 26 14:17:06 2012
@@ -17,8 +17,8 @@ package org.apache.commons.beanutils2;
* limitations under the License.
*/
-import static org.apache.commons.beanutils2.TypeUtils.isAssignmentCompatible;
import static org.apache.commons.beanutils2.Assertions.checkArgument;
+import static org.apache.commons.beanutils2.TypeUtils.isAssignmentCompatible;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -33,9 +33,12 @@ final class DefaultIndexedPropertySetter
private final int index;
- public DefaultIndexedPropertySetter( B bean, Method indexedSetterMethod, int index )
+ private final String propertyName;
+
+ public DefaultIndexedPropertySetter( B bean, String propertyName, Method indexedSetterMethod, int index )
{
this.bean = bean;
+ this.propertyName = propertyName;
this.setterMethod = indexedSetterMethod;
this.index = index;
}
@@ -44,7 +47,6 @@ final class DefaultIndexedPropertySetter
* {@inheritDoc}
*/
public <V> BeanAccessor<B> with( V value )
- throws IllegalAccessException, IllegalArgumentException, InvocationTargetException
{
// TODO this assumes, that the index is the first parameter, and the value to set is the second.
// will this always be the case or do we have to check if one parameter either of the parameters
@@ -62,9 +64,25 @@ final class DefaultIndexedPropertySetter
value.getClass().getName(), paramType.getName() );
}
- setterMethod.invoke( bean, index, value );
+ invokeSetter( value );
return new DefaultBeanAccessor<B>( bean );
}
+ private <V> void invokeSetter( V value )
+ {
+ try
+ {
+ setterMethod.invoke( bean, index, value );
+ }
+ catch ( IllegalAccessException e )
+ {
+ throw new PropertySetterNotAccessibleException( propertyName, setterMethod.getName(), bean.getClass(), e );
+ }
+ catch ( InvocationTargetException e )
+ {
+ throw new PropertySetterInvocationException( propertyName, setterMethod.getName(), bean.getClass(), e );
+ }
+ }
+
}
Modified: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/DefaultIndexedPropertySetterAccessor.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/DefaultIndexedPropertySetterAccessor.java?rev=1366010&r1=1366009&r2=1366010&view=diff
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/DefaultIndexedPropertySetterAccessor.java (original)
+++ commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/DefaultIndexedPropertySetterAccessor.java Thu Jul 26 14:17:06 2012
@@ -21,7 +21,6 @@ package org.apache.commons.beanutils2;
import static org.apache.commons.beanutils2.Assertions.checkArgument;
-import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
final class DefaultIndexedPropertySetterAccessor<B>
@@ -45,11 +44,10 @@ final class DefaultIndexedPropertySetter
* {@inheritDoc}
*/
public BeanPropertySetter<B> at( int index )
- throws IllegalArgumentException, IllegalAccessException, InvocationTargetException
{
checkArgument( index >= 0, "Indexed property '%s' in bean of type %s cannot be get from a negative index %s",
propertyName, bean.getClass().getName(), index );
- return new DefaultIndexedPropertySetter<B>( bean, indexedSetterMethod, index );
+ return new DefaultIndexedPropertySetter<B>( bean, propertyName, indexedSetterMethod, index );
}
}
Modified: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/IndexedPropertyGetterAccessor.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/IndexedPropertyGetterAccessor.java?rev=1366010&r1=1366009&r2=1366010&view=diff
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/IndexedPropertyGetterAccessor.java (original)
+++ commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/IndexedPropertyGetterAccessor.java Thu Jul 26 14:17:06 2012
@@ -1,7 +1,5 @@
package org.apache.commons.beanutils2;
-import java.lang.reflect.InvocationTargetException;
-
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -21,10 +19,9 @@ import java.lang.reflect.InvocationTarge
* under the License.
*/
-public interface IndexedPropertyGetterAccessor
+public interface IndexedPropertyGetterAccessor<B>
{
- BeanAccessor<?> at( int index )
- throws IllegalArgumentException, IllegalAccessException, InvocationTargetException;
+ BeanAccessor<?> at( int index );
}
Modified: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/IndexedPropertySetterAccessor.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/IndexedPropertySetterAccessor.java?rev=1366010&r1=1366009&r2=1366010&view=diff
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/IndexedPropertySetterAccessor.java (original)
+++ commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/IndexedPropertySetterAccessor.java Thu Jul 26 14:17:06 2012
@@ -19,12 +19,9 @@ package org.apache.commons.beanutils2;
* under the License.
*/
-import java.lang.reflect.InvocationTargetException;
-
public interface IndexedPropertySetterAccessor<B>
{
- BeanPropertySetter<B> at( int index )
- throws IllegalArgumentException, IllegalAccessException, InvocationTargetException;
+ BeanPropertySetter<B> at( int index );
}
Added: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/MethodInvocationException.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/MethodInvocationException.java?rev=1366010&view=auto
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/MethodInvocationException.java (added)
+++ commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/MethodInvocationException.java Thu Jul 26 14:17:06 2012
@@ -0,0 +1,51 @@
+package org.apache.commons.beanutils2;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+/**
+ * An exception that indicates that calling a method by reflection threw an exception.
+ */
+public class MethodInvocationException
+ extends BeanReflectionException
+{
+
+ private static final long serialVersionUID = 201206192249L;
+
+ private final String methodName;
+
+ /**
+ * Constructs a new instance of MethodInvocationException.
+ *
+ * @param methodName the name of the method that threw the exception
+ * @param beanType the type the method is defined on
+ * @param cause the exception's cause
+ */
+ public MethodInvocationException( String methodName, Class<?> beanType, Throwable cause )
+ {
+ super( cause, beanType, "Method %s of type %s threw an exception", methodName, beanType );
+ this.methodName = methodName;
+ }
+
+ public String getMethodName()
+ {
+ return this.methodName;
+ }
+
+}
Propchange: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/MethodInvocationException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/MethodInvocationException.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/MethodInvocationException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/MethodNotAccessibleException.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/MethodNotAccessibleException.java?rev=1366010&view=auto
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/MethodNotAccessibleException.java (added)
+++ commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/MethodNotAccessibleException.java Thu Jul 26 14:17:06 2012
@@ -0,0 +1,33 @@
+package org.apache.commons.beanutils2;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+public class MethodNotAccessibleException
+ extends BeanReflectionException
+{
+
+ private static final long serialVersionUID = 201207112209L;
+
+ public MethodNotAccessibleException( String methodName, Class<?> target, Throwable cause )
+ {
+ super( cause, target, "Method '%s' of type '%s' is not accessbile!", methodName, target );
+ }
+
+}
Propchange: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/MethodNotAccessibleException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/MethodNotAccessibleException.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/MethodNotAccessibleException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/NoSuchBeanMethodException.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/NoSuchBeanMethodException.java?rev=1366010&view=auto
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/NoSuchBeanMethodException.java (added)
+++ commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/NoSuchBeanMethodException.java Thu Jul 26 14:17:06 2012
@@ -0,0 +1,33 @@
+package org.apache.commons.beanutils2;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+public class NoSuchBeanMethodException
+ extends BeanReflectionException
+{
+
+ private static final long serialVersionUID = 201207112201L;
+
+ public NoSuchBeanMethodException( String methodName, Class<?> target, Throwable cause )
+ {
+ super( cause, target, "No such accessible method: %s() on object: %s", methodName, target );
+ }
+
+}
Propchange: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/NoSuchBeanMethodException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/NoSuchBeanMethodException.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/NoSuchBeanMethodException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/NoSuchConstructorException.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/NoSuchConstructorException.java?rev=1366010&view=auto
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/NoSuchConstructorException.java (added)
+++ commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/NoSuchConstructorException.java Thu Jul 26 14:17:06 2012
@@ -0,0 +1,33 @@
+package org.apache.commons.beanutils2;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+public class NoSuchConstructorException
+ extends BeanReflectionException
+{
+
+ private static final long serialVersionUID = 201207122142L;
+
+ public NoSuchConstructorException( Class<?> beanType, Throwable cause )
+ {
+ super( cause, beanType, "No such accessible constructor on class '%s'.", beanType );
+ }
+
+}
Propchange: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/NoSuchConstructorException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/NoSuchConstructorException.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/NoSuchConstructorException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/NoSuchPropertyException.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/NoSuchPropertyException.java?rev=1366010&view=auto
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/NoSuchPropertyException.java (added)
+++ commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/NoSuchPropertyException.java Thu Jul 26 14:17:06 2012
@@ -0,0 +1,51 @@
+package org.apache.commons.beanutils2;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+/**
+ * An exception that indicates that a property could not be found.
+ */
+public class NoSuchPropertyException
+ extends BeanReflectionException
+{
+
+ private static final long serialVersionUID = 201206192222L;
+
+ private final String propertyName;
+
+ /**
+ * Constructs a new instance of NoSuchPropertyException.
+ *
+ * @param propertyName the name of the property that couldn't be found
+ * @param beanType the class the property was searched for
+ * @param cause the cause of this exception
+ */
+ public NoSuchPropertyException( String propertyName, Class<?> beanType, Throwable cause )
+ {
+ super( cause, beanType, "No property %s available in type %s", propertyName, beanType.getName() );
+ this.propertyName = propertyName;
+ }
+
+ public String getPropertyName()
+ {
+ return propertyName;
+ }
+
+}
Propchange: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/NoSuchPropertyException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/NoSuchPropertyException.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/NoSuchPropertyException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/NullBeanAccessor.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/NullBeanAccessor.java?rev=1366010&r1=1366009&r2=1366010&view=diff
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/NullBeanAccessor.java (original)
+++ commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/NullBeanAccessor.java Thu Jul 26 14:17:06 2012
@@ -20,7 +20,6 @@ package org.apache.commons.beanutils2;
import static java.lang.String.format;
import java.beans.IntrospectionException;
-import java.lang.reflect.InvocationTargetException;
import java.util.Map;
final class NullBeanAccessor<B>
@@ -38,7 +37,6 @@ final class NullBeanAccessor<B>
* {@inheritDoc}
*/
public BeanAccessor<?> get( String propertyName )
- throws IllegalAccessException, IntrospectionException, InvocationTargetException, NoSuchMethodException
{
throw new NullPointerException( errorMessage );
}
@@ -46,8 +44,7 @@ final class NullBeanAccessor<B>
/**
* {@inheritDoc}
*/
- public IndexedPropertyGetterAccessor getIndexed( String propertyName )
- throws IntrospectionException, NoSuchMethodException
+ public IndexedPropertyGetterAccessor<?> getIndexed( String propertyName )
{
throw new NullPointerException( errorMessage );
}
@@ -56,7 +53,6 @@ final class NullBeanAccessor<B>
* {@inheritDoc}
*/
public MappedPropertyGetterAccessor getMapped( String propertyName )
- throws InvocationTargetException, NoSuchMethodException
{
throw new NullPointerException( errorMessage );
}
@@ -81,7 +77,6 @@ final class NullBeanAccessor<B>
* {@inheritDoc}
*/
public BeanPropertySetter<B> set( String propertyName )
- throws IllegalAccessException, IntrospectionException, InvocationTargetException, NoSuchMethodException
{
throw new NullPointerException( errorMessage );
}
@@ -90,7 +85,6 @@ final class NullBeanAccessor<B>
* {@inheritDoc}
*/
public IndexedPropertySetterAccessor<B> setIndexed( String propertyName )
- throws IllegalAccessException, IntrospectionException, InvocationTargetException, NoSuchMethodException
{
throw new NullPointerException( errorMessage );
}
@@ -99,7 +93,6 @@ final class NullBeanAccessor<B>
* {@inheritDoc}
*/
public IndexedPropertySetterAccessor<B> setMapped( String propertyName )
- throws IllegalAccessException, IntrospectionException, InvocationTargetException, NoSuchMethodException
{
throw new NullPointerException( errorMessage );
}
@@ -126,8 +119,6 @@ final class NullBeanAccessor<B>
* {@inheritDoc}
*/
public B cloneBean()
- throws IllegalAccessException, InstantiationException, IntrospectionException, InvocationTargetException,
- NoSuchMethodException
{
return null;
}
@@ -136,7 +127,6 @@ final class NullBeanAccessor<B>
* {@inheritDoc}
*/
public <T extends B> void copyPropertiesTo( T target )
- throws IllegalAccessException, InvocationTargetException, NoSuchMethodException
{
throw new NullPointerException( errorMessage );
}
@@ -145,7 +135,6 @@ final class NullBeanAccessor<B>
* {@inheritDoc}
*/
public Map<String, Object> describe()
- throws IllegalAccessException, InvocationTargetException, NoSuchMethodException, IntrospectionException
{
throw new NullPointerException( errorMessage );
}
@@ -154,8 +143,6 @@ final class NullBeanAccessor<B>
* {@inheritDoc}
*/
public void populate( Map<String, Object> properties )
- throws IllegalAccessException, IllegalArgumentException, IntrospectionException, InvocationTargetException,
- NoSuchMethodException
{
throw new NullPointerException( errorMessage );
}
@@ -164,7 +151,6 @@ final class NullBeanAccessor<B>
* {@inheritDoc}
*/
public ArgumentsAccessor invoke( String methodName )
- throws NoSuchMethodException, IllegalAccessException, InvocationTargetException
{
throw new NullPointerException( errorMessage );
}
@@ -173,7 +159,6 @@ final class NullBeanAccessor<B>
* {@inheritDoc}
*/
public ArgumentsAccessor invokeExact( String methodName )
- throws NoSuchMethodException, IllegalAccessException, InvocationTargetException
{
throw new NullPointerException( errorMessage );
}
Added: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/PropertyGetterInvocationException.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/PropertyGetterInvocationException.java?rev=1366010&view=auto
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/PropertyGetterInvocationException.java (added)
+++ commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/PropertyGetterInvocationException.java Thu Jul 26 14:17:06 2012
@@ -0,0 +1,45 @@
+package org.apache.commons.beanutils2;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+/**
+ * An exception indicating that calling the getter of a property caused an exception.
+ */
+public class PropertyGetterInvocationException
+ extends MethodInvocationException
+{
+
+ private static final long serialVersionUID = 201206192258L;
+
+ private final String propertyName;
+
+ public PropertyGetterInvocationException( String propertyName, String getterMethodName, Class<?> target,
+ Throwable cause )
+ {
+ super( getterMethodName, target, cause );
+ this.propertyName = propertyName;
+ }
+
+ public String getPropertyName()
+ {
+ return propertyName;
+ }
+
+}
Propchange: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/PropertyGetterInvocationException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/PropertyGetterInvocationException.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/sandbox/beanutils2/trunk/src/main/java/org/apache/commons/beanutils2/PropertyGetterInvocationException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain