KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > directwebremoting > create > NullCreator


1 /*
2  * Copyright 2005 Joe Walker
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 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     /**
29      * What sort of class do we create?
30      * @param classname The name of the class
31      */

32     public void setClass(String JavaDoc classname)
33     {
34         try
35         {
36             this.clazz = LocalUtil.classForName(classname);
37         }
38         catch (ClassNotFoundException JavaDoc ex)
39         {
40             throw new IllegalArgumentException JavaDoc(Messages.getString("Creator.ClassNotFound", classname));
41         }
42     }
43
44     /* (non-Javadoc)
45      * @see org.directwebremoting.Creator#getType()
46      */

47     public Class JavaDoc getType()
48     {
49         return clazz;
50     }
51
52     /* (non-Javadoc)
53      * @see org.directwebremoting.Creator#getInstance()
54      */

55     public Object JavaDoc getInstance() throws InstantiationException JavaDoc
56     {
57         throw new InstantiationException JavaDoc(Messages.getString("NullCreator.DontCallMe"));
58     }
59
60     private Class JavaDoc clazz;
61 }
62
Popular Tags