KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > scripting > support > RefreshableScriptTargetSource


1 /*
2  * Copyright 2002-2006 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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 BeanFactoryRefreshableTargetSource {
33
34     private final ScriptSource scriptSource;
35
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, String JavaDoc beanName, ScriptSource scriptSource) {
45         super(beanFactory, beanName);
46         Assert.notNull(scriptSource, "ScriptSource must not be null");
47         this.scriptSource = scriptSource;
48     }
49
50     /**
51      * Determine whether a refresh is required through calling
52      * ScriptSource's <code>isModified()</code> method.
53      * @see org.springframework.scripting.ScriptSource#isModified()
54      */

55     protected boolean requiresRefresh() {
56         return this.scriptSource.isModified();
57     }
58
59 }
60
Popular Tags