
com.cookingfox.chefling.impl.command.ResetContainerCommandImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of chefling-di-java Show documentation
Show all versions of chefling-di-java Show documentation
Chefling is a very minimal dependency injection container written in pure Java.
package com.cookingfox.chefling.impl.command;
import com.cookingfox.chefling.api.CheflingContainer;
import com.cookingfox.chefling.api.command.ResetContainerCommand;
import com.cookingfox.chefling.impl.helper.CommandContainerVisitor;
import java.util.Map;
/**
* @see ResetContainerCommand
*/
public class ResetContainerCommandImpl extends AbstractCommand implements ResetContainerCommand {
//----------------------------------------------------------------------------------------------
// CONSTRUCTORS
//----------------------------------------------------------------------------------------------
public ResetContainerCommandImpl(CommandContainer container) {
super(container);
}
//----------------------------------------------------------------------------------------------
// PUBLIC METHODS
//----------------------------------------------------------------------------------------------
@Override
public void resetContainer() {
visitAll(_container, new CommandContainerVisitor() {
@Override
public void visit(CommandContainer container) {
// call destroy method for life cycle objects
for (Map.Entry entry : container.instances.entrySet()) {
lifecycleDispose(entry.getValue());
}
container.instances.clear();
container.mappings.clear();
}
});
_container.instances.put(CheflingContainer.class, _container);
_container.instances.put(CommandContainer.class, _container);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy