@SuppressWarnings("unchecked")
@Override
public synchronized <T> void swap(Class<T> target, Class<? extends T> implementationType) throws HotSwapException {
Key targetKey = Locksmith.makeKey(target);
ComponentStrategy<T> currentStrategy = (ComponentStrategy<T>) getStrategy(targetKey);
if (!(currentStrategy instanceof HotSwappableProxyStrategy)) {
throw new HotSwapException(target, currentStrategy.getComponentType(), implementationType);
}
ComponentProxyHandler<T> proxyHandler = ((HotSwappableProxyStrategy) currentStrategy).getProxyHandler();
ComponentStrategy<T> newStrategy = (ComponentStrategy<T>) strategyFactory.create(implementationType, targetKey.getQualifier(), Scopes.SINGLETON);
if (!(newStrategy instanceof HotSwappableProxyStrategy)) {
throw new HotSwapException(target, newStrategy.getComponentType(), implementationType);
}