1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.monitor;
14
15 import java.beans.PropertyDescriptor;
16 import java.util.Properties;
17
18 import org.apache.commons.beanutils.BeanUtils;
19 import org.apache.commons.beanutils.PropertyUtils;
20
21 import com.eviware.soapui.SoapUI;
22 import com.eviware.soapui.model.ModelItem;
23 import com.eviware.soapui.model.propertyexpansion.DefaultPropertyExpansionContext;
24
25 public class PropertySupport
26 {
27 public static void applySystemProperties( Object target, String scope, ModelItem modelItem )
28 {
29 PropertyDescriptor[] descriptors = PropertyUtils.getPropertyDescriptors( target );
30 DefaultPropertyExpansionContext context = new DefaultPropertyExpansionContext( modelItem );
31 Properties properties = System.getProperties();
32
33 for( PropertyDescriptor descriptor : descriptors )
34 {
35 String name = descriptor.getName();
36 String key = scope + "." + name;
37 if( PropertyUtils.isWriteable( target, name ) && properties.containsKey( key ) )
38 {
39 try
40 {
41 String value = context.expand( String.valueOf( properties.get( key ) ) );
42 BeanUtils.setProperty( target, name, value );
43 SoapUI.log.info( "Set property [" + name + "] to [" + value + "] in scope [" + scope + "]" );
44 }
45 catch( Throwable e )
46 {
47 SoapUI.logError( e );
48 }
49 }
50 }
51 }
52
53 }