public class ByteBuddyProxyFactory extends Object
Feature.
public interface UserDAO { User findById(int id); }
... proxyFor(org.togglz.core.Feature, java.lang.Class<? super T>, T, T) will generate classes equivalent to the following source code ...
public class X extends TogglzSwitchableimplements UserDAO { public X(FeatureManager featureManager, Feature feature, UserDAO active, UserDAO inactive) { super(featureManager, feature, active, inactive); } public User findById(int id) { super.checkTogglzState(); return delegate.findById(id); } public String toString() { super.checkTogglzState(); return delegate.toString(); } }
Feature state is checked as part of every method call which is invisible but also
quite slow. It may also be functionally dangerous if the implementations are stateful and should not flipped in the
middle of a "session".
For these cases passiveProxyFor(...) will generate classes that never check the feature state themselves.
To be updated they must be passed to TogglzSwitchable.update(Object).
Feature-controlled proxy vs direct calls.
| Direct Call | 100% |
| Passive ByteBuddy Proxy | 70% |
| Active ByteBuddy Proxy | 15% |
| JDK Proxy | 10% |
TogglzSwitchable| Constructor and Description |
|---|
ByteBuddyProxyFactory() |
| Modifier and Type | Method and Description |
|---|---|
static <T> T |
passiveProxyFor(Feature feature,
Class<? super T> interfaceClass,
T active,
T inactive)
Generate a passive
Feature proxy. |
static <T> T |
passiveProxyFor(Feature feature,
Class<? super T> interfaceClass,
T active,
T inactive,
FeatureManager featureManager)
Generate a passive
Feature proxy. |
static <T> T |
proxyFor(Feature feature,
Class<? super T> interfaceClass,
T active,
T inactive)
Generate an active
Feature proxy. |
static <T> T |
proxyFor(Feature feature,
Class<? super T> interfaceClass,
T active,
T inactive,
FeatureManager featureManager)
Generate an active
Feature proxy. |
public static <T> T passiveProxyFor(Feature feature, Class<? super T> interfaceClass, T active, T inactive)
Feature proxy.ByteBuddyProxyFactorypublic static <T> T passiveProxyFor(Feature feature, Class<? super T> interfaceClass, T active, T inactive, FeatureManager featureManager)
Feature proxy.ByteBuddyProxyFactorypublic static <T> T proxyFor(Feature feature, Class<? super T> interfaceClass, T active, T inactive)
Feature proxy.ByteBuddyProxyFactorypublic static <T> T proxyFor(Feature feature, Class<? super T> interfaceClass, T active, T inactive, FeatureManager featureManager)
Feature proxy.ByteBuddyProxyFactoryCopyright © 2021. All rights reserved.