All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.googlecode.refit.osgi.OsgiFixtureLoader Maven / Gradle / Ivy

There is a newer version: 1.8.0
Show newest version
package com.googlecode.refit.osgi;
/*
 * Copyright 2011 Harald Wellmann
 *
 * This file is part of reFit.
 * 
 * reFit is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * reFit is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with reFit.  If not, see .
 */
import java.util.HashMap;
import java.util.Map;

import fit.ActionFixture;
import fit.Fixture;
import fit.FixtureLoader;
import fit.Summary;

public class OsgiFixtureLoader extends FixtureLoader {
    
    private Map fixtureMap = new HashMap();
    
    public OsgiFixtureLoader() {
        addFixture(new ActionFixture());
        addFixture(new Summary());
    }
    
    protected void addFixture(Fixture fixture) {
        fixtureMap.put(fixture.getClass().getName(), fixture);        
    }
    
    protected void removeFixture(Fixture fixture) {
        fixtureMap.remove(fixture.getClass().getName());        
    }
    
    @Override
    public Fixture loadFixture(String className) throws ClassNotFoundException,
            InstantiationException, IllegalAccessException {
        Fixture fixture = fixtureMap.get(className);
        if (fixture == null) {
            throw new InstantiationException("no Fixture Service Component of class " + className);
        }
        return fixture;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy