GRAILS-1019: Allowing expressions to be used with the 'disabled' attribute for g...
[grails.git] / src / commons / org / codehaus / groovy / grails / compiler / injection / GrailsAwareClassLoader.java
bloba87436db4b3a5a2de29f86232267dacf04753bc6
1 /* Copyright 2006-2007 Graeme Rocher
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
15 package org.codehaus.groovy.grails.compiler.injection;
17 import groovy.lang.GroovyClassLoader;
18 import org.apache.commons.logging.Log;
19 import org.apache.commons.logging.LogFactory;
20 import org.codehaus.groovy.control.CompilationUnit;
21 import org.codehaus.groovy.control.CompilerConfiguration;
22 import org.codehaus.groovy.control.Phases;
25 import java.security.CodeSource;
27 /**
28 * A class loader that is aware of Groovy sources and injection operations
30 * @author Graeme Rocher
31 * @since 0.6
32 * <p/>
33 * Created: Jul 27, 2007
34 * Time: 8:57:15 AM
36 public class GrailsAwareClassLoader extends GroovyClassLoader {
38 public GrailsAwareClassLoader() {
41 public GrailsAwareClassLoader(ClassLoader loader) {
42 super(loader);
45 public GrailsAwareClassLoader(GroovyClassLoader parent) {
46 super(parent);
49 public GrailsAwareClassLoader(ClassLoader parent, CompilerConfiguration config, boolean useConfigurationClasspath) {
50 super(parent, config, useConfigurationClasspath);
53 public GrailsAwareClassLoader(ClassLoader loader, CompilerConfiguration config) {
54 super(loader, config);
57 private static final Log LOG = LogFactory.getLog(GrailsAwareClassLoader.class);
59 private ClassInjector[] classInjectors = new ClassInjector[0];
61 public void setClassInjectors(ClassInjector[] classInjectors) {
62 this.classInjectors = classInjectors;
65 /**
66 * @see groovy.lang.GroovyClassLoader#createCompilationUnit(org.codehaus.groovy.control.CompilerConfiguration, java.security.CodeSource)
68 protected CompilationUnit createCompilationUnit(CompilerConfiguration config, CodeSource source) {
69 CompilationUnit cu = super.createCompilationUnit(config, source);
70 cu.addPhaseOperation(new GrailsAwareInjectionOperation(getResourceLoader(), classInjectors), Phases.CONVERSION);
71 return cu;