Package org.gwtoolbox.ioc.core.rebind.processor

Source Code of org.gwtoolbox.ioc.core.rebind.processor.AbstractComponentContainerProcessor

/*
* Copyright 2002-2008 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*       http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.gwtoolbox.ioc.core.rebind.processor;

import java.lang.annotation.Annotation;

import org.gwtoolbox.commons.generator.rebind.EasyTreeLogger;
import org.gwtoolbox.ioc.core.rebind.ComponentContainerProcessor;
import org.gwtoolbox.ioc.core.rebind.ProcessorInitializationException;
import org.gwtoolbox.ioc.core.rebind.config.MutableComponentContainerOracle;
import org.gwtoolbox.commons.generator.rebind.AnnotationWrapper;
import org.gwtoolbox.commons.generator.rebind.EasyTreeLoggerAware;
import com.google.gwt.core.ext.typeinfo.JClassType;
import com.google.gwt.core.ext.GeneratorContext;

/**
* @author Uri Boness
*/
public abstract class AbstractComponentContainerProcessor<T extends Annotation>
        implements ComponentContainerProcessor<T>, EasyTreeLoggerAware {

    private int order;

    private EasyTreeLogger logger;

    protected AbstractComponentContainerProcessor() {
        this(DEFAULT_ORDER);
    }

    protected AbstractComponentContainerProcessor(int order) {
        this.order = order;
    }

    public int getOrder() {
        return order;
    }

    public void setLogger(EasyTreeLogger logger) {
        this.logger = logger;
    }

    public final void init(T t, JClassType containerType, GeneratorContext context) throws ProcessorInitializationException {
        EasyTreeLogger newLogger = logger.branchInfo("Initializing processor '" + getClass().getName() + "'...");
        order = new AnnotationWrapper(t).getInt("order", order);
        if (newLogger.debugEnabled()) {
            newLogger.debug("Order: " + order);
        }
        doInit(newLogger, t, containerType, context);
    }


    public final void process(MutableComponentContainerOracle oracle, GeneratorContext context) throws Exception {
        EasyTreeLogger newLogger = logger.branchInfo("Processing processor '" + getClass().getName() + "'...");
        doProcess(newLogger, oracle, context);
    }

    public abstract void doInit(EasyTreeLogger logger, T t, JClassType containerType, GeneratorContext context) throws ProcessorInitializationException;

    public abstract void doProcess(EasyTreeLogger logger, MutableComponentContainerOracle oracle, GeneratorContext context) throws Exception;
}
TOP

Related Classes of org.gwtoolbox.ioc.core.rebind.processor.AbstractComponentContainerProcessor

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.