revised expression parser API design

This commit is contained in:
Juergen Hoeller
2009-02-12 23:03:58 +00:00
parent 2bdb62f4c2
commit 08dd18df58
147 changed files with 3053 additions and 4402 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2009 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@
package org.springframework.beans.factory.config;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.util.Assert;
/**
* Context object for evaluating an expression within a bean definition.
@@ -32,6 +33,7 @@ public class BeanExpressionContext {
public BeanExpressionContext(BeanFactory beanFactory, Scope scope) {
Assert.notNull(beanFactory, "BeanFactory must not be null");
this.beanFactory = beanFactory;
this.scope = scope;
}
@@ -47,16 +49,37 @@ public class BeanExpressionContext {
public boolean containsObject(String key) {
return (this.beanFactory.containsBean(key) ||
this.scope.resolveContextualObject(key) != null);
(this.scope != null && this.scope.resolveContextualObject(key) != null));
}
public Object getObject(String key) {
if (this.beanFactory.containsBean(key)) {
return this.beanFactory.getBean(key);
}
else {
else if (this.scope != null){
return this.scope.resolveContextualObject(key);
}
else {
return null;
}
}
@Override
public boolean equals(Object other) {
if (this == other) {
return true;
}
if (!(other instanceof BeanExpressionContext)) {
return false;
}
BeanExpressionContext otherContext = (BeanExpressionContext) other;
return (this.beanFactory == otherContext.beanFactory && this.scope == otherContext.scope);
}
@Override
public int hashCode() {
return this.beanFactory.hashCode();
}
}