/** * Set the properties of an object passed as a parameter in one go. The <code>properties</code> * are parsed relative to a <code>prefix</code>. * <p> * @param obj The object to configure. * @param properties A java.util.Properties containing keys and values. * @param prefix Only keys having the specified prefix will be set. */ public static void setProperties( Object obj, Properties properties, String prefix ) { new PropertySetter( obj ).setProperties( properties, prefix ); }
cacheEventLogger = OptionConverter.instantiateByKey( props, eventLoggerClassName, null ); if ( cacheEventLogger != null ) PropertySetter.setProperties( cacheEventLogger, props, cacheEventLoggerAttributePrefix + "." ); if ( log.isInfoEnabled() )
/** * Gets the propertyDescriptor attribute of the PropertySetter object * @param name * @return The propertyDescriptor value */ protected PropertyDescriptor getPropertyDescriptor( String name ) { if ( props == null ) { introspect(); } for ( int i = 0; i < props.length; i++ ) { if ( name.equals( props[i].getName() ) ) { return props[i]; } } return null; } }
/** * Set the properties for the object that match the <code>prefix</code> passed as parameter. * <p> * @param properties The new properties value * @param prefix The new properties value */ public void setProperties( Properties properties, String prefix ) { int len = prefix.length(); for ( Enumeration<?> e = properties.propertyNames(); e.hasMoreElements(); ) { String key = (String) e.nextElement(); // handle only properties that start with the desired prefix. if ( key.startsWith( prefix ) ) { // ignore key if it contains dots after the prefix if ( key.indexOf( '.', len + 1 ) > 0 ) { //System.err.println("----------Ignoring---["+key // +"], prefix=["+prefix+"]."); continue; } String value = OptionConverter.findAndSubst( key, properties ); key = key.substring( len ); setProperty( key, value ); } } }
/** * Configure. * <p> * jcs.remotehttpcache.serverattributes.ATTRIBUTENAME=ATTRIBUTEVALUE * <p> * @param prop * @return RemoteCacheServerAttributesconfigureRemoteCacheServerAttributes */ protected RemoteHttpCacheServerAttributes configureRemoteHttpCacheServerAttributes( Properties prop ) { RemoteHttpCacheServerAttributes rcsa = new RemoteHttpCacheServerAttributes(); // configure automatically PropertySetter.setProperties( rcsa, prop, IRemoteHttpCacheConstants.HTTP_CACHE_SERVER_ATTRIBUTES_PROPERTY_PREFIX + "." ); return rcsa; }
/** * Set the default aux list for new caches. * <p> * @param props */ protected void setDefaultAuxValues( Properties props ) { String value = OptionConverter.findAndSubst( DEFAULT_REGION, props ); compositeCacheManager.setDefaultAuxValues(value); if ( log.isInfoEnabled() ) { log.info( "Setting default auxiliaries to " + value ); } }
/** * This configures an object specific custom factory. This will be configured for just this * object in the registry. This can be null. * <p> * @param props * @return RMISocketFactory */ protected static RMISocketFactory configureObjectSpecificCustomFactory( Properties props ) { RMISocketFactory customRMISocketFactory = OptionConverter.instantiateByKey( props, CUSTOM_RMI_SOCKET_FACTORY_PROPERTY_PREFIX, null ); if ( customRMISocketFactory != null ) { PropertySetter.setProperties( customRMISocketFactory, props, CUSTOM_RMI_SOCKET_FACTORY_PROPERTY_PREFIX + "." ); if ( log.isInfoEnabled() ) { log.info( "Will use server specific custom socket factory. " + customRMISocketFactory ); } } else { if ( log.isInfoEnabled() ) { log.info( "No server specific custom socket factory defined." ); } } return customRMISocketFactory; }
/** * Set the properties of an object passed as a parameter in one go. The <code>properties</code> * are parsed relative to a <code>prefix</code>. * <p> * @param obj The object to configure. * @param properties A java.util.Properties containing keys and values. * @param prefix Only keys having the specified prefix will be set. */ public static void setProperties( Object obj, Properties properties, String prefix ) { new PropertySetter( obj ).setProperties( properties, prefix ); }
/** * Set the properties for the object that match the <code>prefix</code> passed as parameter. * <p> * @param properties The new properties value * @param prefix The new properties value */ public void setProperties( Properties properties, String prefix ) { int len = prefix.length(); for ( Enumeration<?> e = properties.propertyNames(); e.hasMoreElements(); ) { String key = (String) e.nextElement(); // handle only properties that start with the desired prefix. if ( key.startsWith( prefix ) ) { // ignore key if it contains dots after the prefix if ( key.indexOf( '.', len + 1 ) > 0 ) { //System.err.println("----------Ignoring---["+key // +"], prefix=["+prefix+"]."); continue; } String value = OptionConverter.findAndSubst( key, properties ); key = key.substring( len ); setProperty( key, value ); } } }
/** * Configure. * <p> * jcs.remotehttpcache.serverattributes.ATTRIBUTENAME=ATTRIBUTEVALUE * <p> * @param prop * @return RemoteCacheServerAttributesconfigureRemoteCacheServerAttributes */ protected static RemoteHttpCacheServerAttributes configureRemoteHttpCacheServerAttributes( Properties prop ) { RemoteHttpCacheServerAttributes rcsa = new RemoteHttpCacheServerAttributes(); // configure automatically PropertySetter.setProperties( rcsa, prop, IRemoteHttpCacheConstants.HTTP_CACHE_SERVER_ATTRIBUTES_PROPERTY_PREFIX + "." ); return rcsa; } }
/** * This configures an object specific custom factory. This will be configured for just this * object in the registry. This can be null. * <p> * @param props * @return RMISocketFactory */ protected static RMISocketFactory configureObjectSpecificCustomFactory( Properties props ) { RMISocketFactory customRMISocketFactory = OptionConverter.instantiateByKey( props, CUSTOM_RMI_SOCKET_FACTORY_PROPERTY_PREFIX, null ); if ( customRMISocketFactory != null ) { PropertySetter.setProperties( customRMISocketFactory, props, CUSTOM_RMI_SOCKET_FACTORY_PROPERTY_PREFIX + "." ); if ( log.isInfoEnabled() ) { log.info( "Will use server specific custom socket factory. " + customRMISocketFactory ); } } else { if ( log.isInfoEnabled() ) { log.info( "No server specific custom socket factory defined." ); } } return customRMISocketFactory; }
/** * Configures the attributes using the properties. * <p> * @param poolName the name of the pool * @param props the configuration properties for the pool * @return JDBCDiskCachePoolAccessAttributes */ protected JDBCDiskCachePoolAccessAttributes configurePoolAccessAttributes( String poolName, Properties props ) { JDBCDiskCachePoolAccessAttributes poolAttributes = new JDBCDiskCachePoolAccessAttributes(); String poolAccessAttributePrefix = POOL_CONFIGURATION_PREFIX + poolName + ATTRIBUTE_PREFIX; PropertySetter.setProperties( poolAttributes, props, poolAccessAttributePrefix + "." ); poolAttributes.setPoolName( poolName ); if ( log.isInfoEnabled() ) { log.info( "Configured attributes " + poolAttributes ); } return poolAttributes; }
cacheEventLogger = OptionConverter.instantiateByKey( props, eventLoggerClassName, null ); if ( cacheEventLogger != null ) PropertySetter.setProperties( cacheEventLogger, props, cacheEventLoggerAttributePrefix + "." ); if ( log.isInfoEnabled() )
/** * Configure. * <p> * jcs.remotecache.serverattributes.ATTRIBUTENAME=ATTRIBUTEVALUE * <p> * @param prop * @return RemoteCacheServerAttributesconfigureRemoteCacheServerAttributes */ protected static RemoteCacheServerAttributes configureRemoteCacheServerAttributes( Properties prop ) { RemoteCacheServerAttributes rcsa = new RemoteCacheServerAttributes(); // configure automatically PropertySetter.setProperties( rcsa, prop, CACHE_SERVER_ATTRIBUTES_PROPERTY_PREFIX + "." ); configureManuallyIfValuesArePresent( prop, rcsa ); return rcsa; }
eAttr = OptionConverter.instantiateByKey( props, attrName, null ); if ( eAttr == null ) PropertySetter.setProperties( eAttr, props, attrName + "." );
/** * Configure. * <p> * jcs.remotecache.serverattributes.ATTRIBUTENAME=ATTRIBUTEVALUE * <p> * @param prop * @return RemoteCacheServerAttributesconfigureRemoteCacheServerAttributes */ protected static RemoteCacheServerAttributes configureRemoteCacheServerAttributes( Properties prop ) { RemoteCacheServerAttributes rcsa = new RemoteCacheServerAttributes(); // configure automatically PropertySetter.setProperties( rcsa, prop, CACHE_SERVER_ATTRIBUTES_PROPERTY_PREFIX + "." ); configureManuallyIfValuesArePresent( prop, rcsa ); return rcsa; }
IKeyMatcher<K> keyMatcher = OptionConverter.instantiateByKey( props, keyMatcherClassName, null ); if ( keyMatcher != null ) PropertySetter.setProperties( keyMatcher, props, attributePrefix + "." ); if ( log.isInfoEnabled() )
elementSerializer = OptionConverter.instantiateByKey( props, elementSerializerClassName, null ); if ( elementSerializer != null ) PropertySetter.setProperties( elementSerializer, props, attributePrefix + "." ); if ( log.isInfoEnabled() )
IKeyMatcher<K> keyMatcher = OptionConverter.instantiateByKey( props, keyMatcherClassName, null ); if ( keyMatcher != null ) PropertySetter.setProperties( keyMatcher, props, attributePrefix + "." ); if ( log.isInfoEnabled() )
elementSerializer = OptionConverter.instantiateByKey( props, elementSerializerClassName, null ); if ( elementSerializer != null ) PropertySetter.setProperties( elementSerializer, props, attributePrefix + "." ); if ( log.isInfoEnabled() )