Skip to content

Commit

Permalink
support ${}
Browse files Browse the repository at this point in the history
  • Loading branch information
knightliao committed Mar 22, 2015
1 parent d7cd6aa commit 739a284
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,20 +96,6 @@ public void setApplicationContext(ApplicationContext applicationContext) throws
this.applicationContext = applicationContext;
}

private String reloadingPlaceholderPrefix =
ReloadingPropertyPlaceholderConfigurer.DEFAULT_RELOADING_PLACEHOLDER_PREFIX;

private String reloadingPlaceholderSuffix =
ReloadingPropertyPlaceholderConfigurer.DEFAULT_RELOADING_PLACEHOLDER_SUFFIX;

public void setReloadingPlaceholderPrefix(String reloadingPlaceholderPrefix) {
this.reloadingPlaceholderPrefix = reloadingPlaceholderPrefix;
}

public void setReloadingPlaceholderSuffix(String reloadingPlaceholderSuffix) {
this.reloadingPlaceholderSuffix = reloadingPlaceholderSuffix;
}

protected String parseStringValue(String strVal, Properties props, Set visitedPlaceholders)
throws BeanDefinitionStoreException {

Expand All @@ -118,10 +104,9 @@ protected String parseStringValue(String strVal, Properties props, Set visitedPl
// replace reloading prefix and suffix by "normal" prefix and suffix.
// remember all the "dynamic" placeholders encountered.
StringBuffer buf = new StringBuffer(strVal);
int startIndex = strVal.indexOf(this.reloadingPlaceholderPrefix);
int startIndex = strVal.indexOf(this.placeholderPrefix);
while (startIndex != -1) {
int endIndex = buf.toString().indexOf(this.reloadingPlaceholderSuffix,
startIndex + this.reloadingPlaceholderPrefix.length());
int endIndex = buf.toString().indexOf(this.placeholderSuffix, startIndex + this.placeholderPrefix.length());
if (endIndex != -1) {
if (currentBeanName != null && currentPropertyName != null) {
String placeholder = buf.substring(startIndex + this.placeholderPrefix.length(), endIndex);
Expand All @@ -133,11 +118,9 @@ protected String parseStringValue(String strVal, Properties props, Set visitedPl
} else {
logger.warn("dynamic property outside bean property value - ignored: " + strVal);
}
buf.replace(endIndex, endIndex + this.reloadingPlaceholderSuffix.length(), placeholderSuffix);
buf.replace(startIndex, startIndex + this.reloadingPlaceholderPrefix.length(), placeholderPrefix);
startIndex = endIndex - this.reloadingPlaceholderPrefix.length() + this.placeholderPrefix.length() +
startIndex = endIndex - this.placeholderPrefix.length() + this.placeholderPrefix.length() +
this.placeholderSuffix.length();
startIndex = strVal.indexOf(this.reloadingPlaceholderPrefix, startIndex);
startIndex = strVal.indexOf(this.placeholderPrefix, startIndex);
} else {
startIndex = -1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@
</bean>

<bean id="autoService" class="com.example.disconf.demo.service.AutoService">
<property name="auto" value="#{auto=100}"/>
<property name="auto" value="${auto=100}"/>
</bean>

<bean id="autoService2" class="com.example.disconf.demo.service.AutoService2">
<property name="auto2" value="#{auto2=100}"/>
<property name="auto2" value="${auto2}"/>
</bean>

</beans>
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*/
@Controller
@RequestMapping(WebConstants.API_PREFIX + "/web/config")
public class ConfigUpdateController extends BaseController {
public class ConfigUpdateController extends BaseController {

protected static final Logger LOG = LoggerFactory.getLogger(ConfigUpdateController.class);

Expand Down

0 comments on commit 739a284

Please sign in to comment.