01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: package org.drools.commons.jci.compilers;
19:
20: import org.drools.commons.jci.problems.CompilationProblemHandler;
21: import org.drools.commons.jci.readers.ResourceReader;
22: import org.drools.commons.jci.stores.ResourceStore;
23:
24: /**
25: * The general compiler interface. All compilers implementing
26: * this interface should read the resources from the reader
27: * and store the java class files into the ResourceStore.
28: *
29: * The actual compilation language does not matter. But the
30: * contract is that the result of the compilation will be a
31: * class file.
32: *
33: * If possible the compiler should notify the optional
34: * CompilationProblemHandler as soon as a problem is found.
35: *
36: * @author tcurdt
37: */
38: public interface JavaCompiler {
39:
40: /**
41: * Set the the handler that gets the notification of an error
42: * or warning as soon as this information is available from
43: * the compiler.
44: * Note: Some compilers might not support this feature.
45: *
46: * @param pHandler
47: */
48: void setCompilationProblemHandler(
49: final CompilationProblemHandler pHandler);
50:
51: /**
52: * factory method to create the underlying default settings
53: */
54: JavaCompilerSettings createDefaultSettings();
55:
56: /**
57: * uses the default compiler settings and the current classloader
58: */
59: CompilationResult compile(final String[] pResourcePaths,
60: final ResourceReader pReader, final ResourceStore pStore);
61:
62: /**
63: * uses the default compiler settings
64: */
65: CompilationResult compile(final String[] pResourcePaths,
66: final ResourceReader pReader, final ResourceStore pStore,
67: final ClassLoader pClassLoader);
68:
69: /**
70: * Compiles the java resources "some/path/to/MyJava.java"
71: * read through the ResourceReader and then stores the resulting
72: * classes in the ResourceStore under "some/path/to/MyJava.class".
73: * Note: As these are resource path you always have to use "/"
74: *
75: * The result of the compilation run including detailed error
76: * information is returned as CompilationResult. If you need to
77: * get notified already during the compilation process you can
78: * register a CompilationProblemHandler.
79: * Note: Not all compilers might support this notification mechanism.
80: *
81: * @param pResourcePaths
82: * @param pReader
83: * @param pStore
84: * @param pClassLoader
85: * @param pSettings
86: * @return always a CompilationResult
87: */
88: CompilationResult compile(final String[] pResourcePaths,
89: final ResourceReader pReader, final ResourceStore pStore,
90: final ClassLoader pClassLoader,
91: final JavaCompilerSettings pSettings);
92:
93: }
|