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.create;
17:
18: import org.directwebremoting.extend.Creator;
19: import org.directwebremoting.util.LocalUtil;
20: import org.directwebremoting.util.Messages;
21:
22: /**
23: * A creator that simply uses the default constructor each time it is called.
24: * @author Joe Walker [joe at getahead dot ltd dot uk]
25: */
26: public class NullCreator extends AbstractCreator implements Creator {
27: /**
28: * What sort of class do we create?
29: * @param classname The name of the class
30: */
31: public void setClass(String classname) {
32: try {
33: this .clazz = LocalUtil.classForName(classname);
34: } catch (ClassNotFoundException ex) {
35: throw new IllegalArgumentException(Messages.getString(
36: "Creator.ClassNotFound", classname));
37: }
38: }
39:
40: /* (non-Javadoc)
41: * @see org.directwebremoting.Creator#getType()
42: */
43: public Class<?> getType() {
44: return clazz;
45: }
46:
47: /* (non-Javadoc)
48: * @see org.directwebremoting.Creator#getInstance()
49: */
50: public Object getInstance() throws InstantiationException {
51: throw new InstantiationException(Messages
52: .getString("NullCreator.DontCallMe"));
53: }
54:
55: private Class<?> clazz;
56: }
|