001/** 002 * Copyright 2013 John Ericksen 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.androidtransfuse.processor; 017 018import com.sun.codemodel.JDefinedClass; 019import org.androidtransfuse.adapter.ASTType; 020import org.androidtransfuse.transaction.TransactionFactory; 021import org.androidtransfuse.transaction.TransactionProcessor; 022import org.androidtransfuse.transaction.TransactionProcessorBuilder; 023import org.androidtransfuse.transaction.TransactionProcessorPool; 024 025import javax.inject.Provider; 026 027/** 028 * @author John Ericksen 029 */ 030public class FactoryProcessor implements TransactionProcessorBuilder<Provider<ASTType>, JDefinedClass> { 031 032 private final TransactionProcessor processor; 033 private final TransactionProcessorPool<Provider<ASTType>, JDefinedClass> factoryProcessor; 034 private final TransactionFactory<Provider<ASTType>, JDefinedClass> factoryTransactionFactory; 035 036 public FactoryProcessor(TransactionProcessor processor, 037 TransactionProcessorPool<Provider<ASTType>, JDefinedClass> factoryProcessor, 038 TransactionFactory<Provider<ASTType>, JDefinedClass> factoryTransactionFactory) { 039 this.processor = processor; 040 this.factoryProcessor = factoryProcessor; 041 this.factoryTransactionFactory = factoryTransactionFactory; 042 } 043 044 public void submit(Provider<ASTType> parcel) { 045 factoryProcessor.submit(factoryTransactionFactory.buildTransaction(parcel)); 046 } 047 048 public void execute() { 049 processor.execute(); 050 } 051 052 public TransactionProcessor<Provider<ASTType>, JDefinedClass> getTransactionProcessor() { 053 return processor; 054 } 055}