![JAR search and dependency download from the Maven repository](/logo.png)
org.picocontainer.gems.behaviors.HotSwapping Maven / Gradle / Ivy
The newest version!
/*****************************************************************************
* Copyright (c) PicoContainer Organization. All rights reserved. *
* ------------------------------------------------------------------------- *
* The software in this package is published under the terms of the BSD *
* style license a copy of which has been included with this distribution in *
* the LICENSE.txt file. *
* *
* Idea by Rachel Davies, Original code by Aslak Hellesoy and Paul Hammant *
*****************************************************************************/
package org.picocontainer.gems.behaviors;
import org.picocontainer.ComponentAdapter;
import org.picocontainer.Parameter;
import org.picocontainer.PicoCompositionException;
import org.picocontainer.ComponentMonitor;
import org.picocontainer.LifecycleStrategy;
import org.picocontainer.behaviors.AbstractBehaviorFactory;
import org.picocontainer.gems.GemsCharacteristics;
import java.util.Properties;
/**
* Hides implementation.
*
* @author Paul Hammant
* @author Aslak Hellesøy
* @see HotSwappable
*/
@SuppressWarnings("serial")
public class HotSwapping extends AbstractBehaviorFactory {
@Override
public ComponentAdapter createComponentAdapter(final ComponentMonitor componentMonitor, final LifecycleStrategy lifecycleStrategy, final Properties componentProperties, final Object componentKey, final Class componentImplementation, final Parameter... parameters)
throws PicoCompositionException {
ComponentAdapter delegateAdapter = super.createComponentAdapter(componentMonitor, lifecycleStrategy,
componentProperties, componentKey, componentImplementation, parameters);
if (AbstractBehaviorFactory.removePropertiesIfPresent(componentProperties, GemsCharacteristics.NO_HOT_SWAP)) {
return delegateAdapter;
}
AbstractBehaviorFactory.removePropertiesIfPresent(componentProperties, GemsCharacteristics.HOT_SWAP);
return componentMonitor.newBehavior(new HotSwappable(delegateAdapter));
}
@Override
public ComponentAdapter addComponentAdapter(final ComponentMonitor componentMonitor,
final LifecycleStrategy lifecycleStrategy,
final Properties componentProperties,
final ComponentAdapter adapter) {
if (AbstractBehaviorFactory.removePropertiesIfPresent(componentProperties, GemsCharacteristics.NO_HOT_SWAP)) {
return super.addComponentAdapter(componentMonitor,
lifecycleStrategy,
componentProperties,
adapter);
}
AbstractBehaviorFactory.removePropertiesIfPresent(componentProperties, GemsCharacteristics.HOT_SWAP);
return componentMonitor.newBehavior(new HotSwappable(super.addComponentAdapter(componentMonitor,
lifecycleStrategy,
componentProperties,
adapter)));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy