001// Copyright 2004, 2005 The Apache Software Foundation
002//
003// Licensed under the Apache License, Version 2.0 (the "License");
004// you may not use this file except in compliance with the License.
005// You may obtain a copy of the License at
006//
007//     http://www.apache.org/licenses/LICENSE-2.0
008//
009// Unless required by applicable law or agreed to in writing, software
010// distributed under the License is distributed on an "AS IS" BASIS,
011// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012// See the License for the specific language governing permissions and
013// limitations under the License.
014
015package org.apache.hivemind.lib.groovy;
016
017import java.util.List;
018
019import org.apache.hivemind.ClassResolver;
020import org.apache.hivemind.ErrorHandler;
021import org.apache.hivemind.ModuleDescriptorProvider;
022import org.apache.hivemind.Resource;
023import org.apache.hivemind.impl.XmlModuleDescriptorProvider;
024import org.apache.hivemind.parse.XmlResourceProcessor;
025
026/**
027 * This {@link org.apache.hivemind.ModuleDescriptorProvider} processes Groovy scripts defining
028 * module descriptors. To all Groovy scripts executed by the provider a variable
029 * <code>processor</code> will be bound. This variable references the
030 * {@link HiveMindBuilder HiveMind GroovyMarkup builder}.
031 * 
032 * @see org.apache.hivemind.lib.groovy.HiveMindBuilder
033 * @author Knut Wannheden
034 * @since 1.1
035 */
036public class GroovyModuleDescriptorProvider extends XmlModuleDescriptorProvider implements
037        ModuleDescriptorProvider
038{
039    /**
040     * Constructs an GroovyModuleDescriptorProvider only loading the ModuleDescriptor identified by
041     * the given {@link org.apache.hivemind.Resource}.
042     */
043    public GroovyModuleDescriptorProvider(ClassResolver resolver, Resource resource)
044    {
045        super(resolver, resource);
046    }
047
048    /**
049     * Constructs an GroovyModuleDescriptorProvider loading all ModuleDescriptors identified by the
050     * given List of {@link org.apache.hivemind.Resource} objects.
051     */
052    public GroovyModuleDescriptorProvider(ClassResolver resolver, List resources)
053    {
054        super(resolver, resources);
055    }
056
057    protected XmlResourceProcessor getResourceProcessor(ClassResolver resolver, ErrorHandler handler)
058    {
059        return new GroovyScriptProcessor(resolver, handler);
060    }
061}