01: /*
02: * Copyright 2005 Joe Walker
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: package org.directwebremoting.impl;
17:
18: import org.directwebremoting.Container;
19: import org.directwebremoting.extend.InitializingBean;
20:
21: /**
22: * An implementation of some of the simpler methods from {@link Container}
23: * This class has nothing whatsoever to do with
24: * {@link org.directwebremoting.extend.ContainerAbstraction}.
25: * @author Joe Walker [joe at getahead dot ltd dot uk]
26: */
27: public abstract class AbstractContainer implements Container {
28: /**
29: * Used after setup to call {@link InitializingBean#afterContainerSetup(Container)}
30: * on all the contained beans.
31: */
32: protected void callInitializingBeans() {
33: for (String name : getBeanNames()) {
34: Object bean = getBean(name);
35:
36: if (bean instanceof InitializingBean) {
37: InitializingBean startMeUp = (InitializingBean) bean;
38: startMeUp.afterContainerSetup(this );
39: }
40: }
41: }
42:
43: /* (non-Javadoc)
44: * @see org.directwebremoting.Container#getBean(java.lang.Class)
45: */
46: public <T> T getBean(Class<T> type) {
47: return type.cast(getBean(type.getName()));
48: }
49: }
|