|
| 1 | +/* |
| 2 | + * Copyright (C) 2019 Warkdev |
| 3 | + * |
| 4 | + * This program is free software: you can redistribute it and/or modify |
| 5 | + * it under the terms of the GNU General Public License as published by |
| 6 | + * the Free Software Foundation, either version 3 of the License, or |
| 7 | + * (at your option) any later version. |
| 8 | + * |
| 9 | + * This program is distributed in the hope that it will be useful, |
| 10 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | + * GNU General Public License for more details. |
| 13 | + * |
| 14 | + * You should have received a copy of the GNU General Public License |
| 15 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | + */ |
| 17 | +package eu.jangos.extractor.di; |
| 18 | + |
| 19 | +import dagger.Module; |
| 20 | +import dagger.Provides; |
| 21 | +import eu.jangos.extractor.file.mpq.MPQManager; |
| 22 | +import javax.inject.Singleton; |
| 23 | +import org.slf4j.Logger; |
| 24 | +import org.slf4j.LoggerFactory; |
| 25 | + |
| 26 | +/** |
| 27 | + * |
| 28 | + * @author Warkdev |
| 29 | + */ |
| 30 | +@Module |
| 31 | +public class ExtractorModule { |
| 32 | + |
| 33 | + private static final Logger logger = LoggerFactory.getLogger(ExtractorModule.class); |
| 34 | + |
| 35 | + private final String directory; |
| 36 | + |
| 37 | + public ExtractorModule(String directory) { |
| 38 | + this.directory = directory; |
| 39 | + } |
| 40 | + |
| 41 | + @Provides |
| 42 | + @Singleton |
| 43 | + public MPQManager provideMPQManager() { |
| 44 | + try { |
| 45 | + return new MPQManager(this.directory); |
| 46 | + } catch (Exception e) { |
| 47 | + logger.error("Error while generating MPQManager"); |
| 48 | + } |
| 49 | + |
| 50 | + return null; |
| 51 | + } |
| 52 | + |
| 53 | +} |
0 commit comments