01: /*
02: * Copyright 2002-2006 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.springframework.scripting.support;
18:
19: import org.springframework.aop.target.dynamic.BeanFactoryRefreshableTargetSource;
20: import org.springframework.beans.factory.BeanFactory;
21: import org.springframework.scripting.ScriptSource;
22: import org.springframework.util.Assert;
23:
24: /**
25: * Subclass of BeanFactoryRefreshableTargetSource that determines whether a
26: * refresh is required through the given ScriptSource.
27: *
28: * @author Rob Harrop
29: * @author Rod Johnson
30: * @since 2.0
31: */
32: public class RefreshableScriptTargetSource extends
33: BeanFactoryRefreshableTargetSource {
34:
35: private final ScriptSource scriptSource;
36:
37: /**
38: * Create a new RefreshableScriptTargetSource.
39: * @param beanFactory the BeanFactory to fetch beans from
40: * @param beanName the name of the target bean
41: * @param scriptSource the ScriptSource to delegate to
42: * for determining whether a refresh is required
43: */
44: public RefreshableScriptTargetSource(BeanFactory beanFactory,
45: String beanName, ScriptSource scriptSource) {
46: super (beanFactory, beanName);
47: Assert.notNull(scriptSource, "ScriptSource must not be null");
48: this .scriptSource = scriptSource;
49: }
50:
51: /**
52: * Determine whether a refresh is required through calling
53: * ScriptSource's <code>isModified()</code> method.
54: * @see org.springframework.scripting.ScriptSource#isModified()
55: */
56: protected boolean requiresRefresh() {
57: return this.scriptSource.isModified();
58: }
59:
60: }
|