1 | FastClass fastClass;↵ | | 1 | FastClass fastClass;↵
|
2 | BulkAccessor bulkAccessor;↵ | | 2 | BulkBean bulkBean;↵
|
3 | try {↵ | | 3 | try {↵
|
4 | fastClass = FastClass.create( clazz );↵ | | 4 | fastClass = FastClass.create( clazz );↵
|
5 | bulkAccessor = BulkAccessor.create( clazz, getterNames, setterNames, types );↵ | | 5 | bulkBean = BulkBean.create( clazz, getterNames, setterNames, types );↵
|
6 | if ( !clazz.isInterface() && !Modifier.isAbstract( clazz.getModifiers() ) ) {↵ | | 6 | if ( !clazz.isInterface() && !Modifier.isAbstract( clazz.getModifiers() ) ) {↵
|
7 | if ( fastClass == null ) {↵ | | 7 | if ( fastClass == null ) {↵
|
8 | bulkAccessor = null;↵ | | 8 | bulkBean = null;↵
|
9 | }↵ | | 9 | }↵
|
10 | else {↵ | | 10 | else {↵
|
11 | //test out the optimizer:↵ | | 11 | //test out the optimizer:↵
|
12 | Object instance = fastClass.newInstance();↵ | | 12 | Object instance = fastClass.newInstance();↵
|
13 | bulkAccessor.setPropertyValues( instance, bulkAccessor.getPropertyValues( instance ) );↵ | | 13 | bulkBean.setPropertyValues( instance, bulkBean.getPropertyValues( instance ) );↵
|
14 | }↵ | | 14 | }↵
|
15 | }↵ | | 15 | }↵
|
16 | }↵ | | 16 | }↵
|
17 | catch ( Throwable t ) {↵ | | 17 | catch( Throwable t ) {↵
|
18 | fastClass = null;↵ | | 18 | fastClass = null;↵
|
19 | bulkAccessor = null;↵ | | 19 | bulkBean = null;↵
|
20 | String message = "reflection optimizer disabled for: " +↵ | | 20 | String message = "reflection optimizer disabled for: " +↵
|
21 | clazz.getName() +↵ | | 21 | clazz.getName() +↵
|
22 | " [" +↵ | | 22 | " [" +↵
|
23 | StringHelper.unqualify( t.getClass().getName() ) +↵ | | 23 | StringHelper.unqualify( t.getClass().getName() ) +↵
|
24 | ": " +↵ | | 24 | ": " +↵
|
25 | t.getMessage();↵ | | 25 | t.getMessage();↵
|
|
26 | if ( t instanceof BulkAccessorException ) {↵ | | 26 | if (t instanceof BulkBeanException ) {↵
|
27 | int index = ( ( BulkAccessorException ) t ).getIndex();↵ | | 27 | int index = ( (BulkBeanException) t ).getIndex();↵
|
28 | if ( index >= 0 ) {↵ | | 28 | if (index >= 0) {↵
|
29 | message += " (property " + setterNames[index] + ")";↵ | | 29 | message += " (property " + setterNames[index] + ")";↵
|
30 | }↵ | | 30 | }↵
|
31 | }↵ | | 31 | }↵
|
|
32 | log.debug( message );↵ | | 32 | log.debug( message );↵
|
33 | }↵ | | 33 | }↵
|
|
34 | if ( fastClass != null && bulkAccessor != null ) {↵ | | 34 | if ( fastClass != null && bulkBean != null ) {↵
|
35 | return new ReflectionOptimizerImpl(↵ | | 35 | return new ReflectionOptimizerImpl(↵
|
36 | new InstantiationOptimizerAdapter( fastClass ),↵ | | 36 | new InstantiationOptimizerAdapter( fastClass ),↵
|
37 | new AccessOptimizerAdapter( bulkAccessor, clazz )↵ | | 37 | new AccessOptimizerAdapter( bulkBean, clazz )↵
|
38 | );↵ | | 38 | );↵
|
39 | }↵ | | 39 | }↵
|
40 | else {↵ | | 40 | else {↵
|
41 | return null;↵ | | 41 | return null;↵
|
42 | } | | 42 | }
|