KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > components > language > programming > java > JavaProgram


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
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.apache.cocoon.components.language.programming.java;
17
18 import org.apache.avalon.framework.configuration.DefaultConfiguration;
19 import org.apache.avalon.framework.component.ComponentManager;
20 import org.apache.avalon.framework.context.Context;
21
22 import org.apache.avalon.excalibur.component.ComponentHandler;
23 import org.apache.avalon.excalibur.component.RoleManager;
24 import org.apache.avalon.excalibur.component.LogkitLoggerManager;
25
26 import org.apache.cocoon.components.language.generator.CompiledComponent;
27 import org.apache.cocoon.components.language.programming.Program;
28
29 /**
30  * This represents program in Java language.
31  * It wraps Java Class object.
32  *
33  * @author <a HREF="mailto:vgritsenko@apache.org">Vadim Gritsenko</a>
34  * @version CVS $Id: JavaProgram.java 30932 2004-07-29 17:35:38Z vgritsenko $
35  */

36 public class JavaProgram implements Program {
37
38     protected Class JavaDoc program;
39
40     public JavaProgram(Class JavaDoc program) {
41         this.program = program;
42     }
43
44     public String JavaDoc getName() {
45         return program.getName();
46     }
47
48     public ComponentHandler getHandler(ComponentManager manager,
49                                        Context context,
50                                        RoleManager roles,
51                                        LogkitLoggerManager logKitManager)
52             throws Exception JavaDoc {
53
54         return ComponentHandler.getComponentHandler(
55                 program,
56                 new DefaultConfiguration("", "GeneratorSelector"),
57                 manager, context, roles, logKitManager, null, "N/A");
58     }
59
60     public CompiledComponent newInstance() throws Exception JavaDoc {
61         return (CompiledComponent)this.program.newInstance();
62     }
63 }
64
Popular Tags