BedCon 2013 - FeatureToggle Pattern with Togglz

BedCon 2013 - FeatureToggle Pattern with Togglz

Continuous Deployment with FeatureToggle Pattern, Implementation with Togglz Library.
My Short-Talk from http://bed-con.org/

395d9a1bac6f64d04bbd713d5b6bc433?s=128

Niko Köbler

April 04, 2013
Tweet

Transcript

  1. FeatureToggle Pattern with Togglz Niko Köbler @dasniko

  2. None
  3. Which direction?

  4. FeatureToggle http://martinfowler.com/bliki/FeatureToggle.html

  5. • togglz.org • Open Source Java Library • Apache v2.0

    Licence • Current release: 2.0.0.Alpha1 • Download via Website or Central Maven Repository
  6. Maven Dependencies <!-- Togglz for Web applications --> <dependency> <groupId>org.togglz</groupId>

    <artifactId>togglz-servlet</artifactId> <version>1.1.0.Final</version> </dependency> <!-- CDI Integration (optional) --> <dependency> <groupId>org.togglz</groupId> <artifactId>togglz-cdi</artifactId> <version>1.1.0.Final</version> </dependency> <!-- JSF Integration (optional) --> <dependency> <groupId>org.togglz</groupId> <artifactId>togglz-jsf</artifactId> <version>1.1.0.Final</version> </dependency>
  7. FeatureEnum public enum MyFeatures implements Feature { @EnabledByDefault @Label("Smart First

    Feature") FIRST_FEATURE, @Label("Cool Second Feature") SECOND_FEATURE; @Override public boolean isActive() { return FeatureContext .getFeatureManager() .isActive(this); } }
  8. TogglzConfig public class MyTogglzConfiguration implements TogglzConfig { @Override public Class<?

    extends Feature> getFeatureClass() { return MyFeatures.class; } @Override public StateRepository getStateRepository() { return new FileBasedStateRepository( new File("/path/to/features.properties") ); } @Override public UserProvider getUserProvider() { return new NoOpUserProvider(); } }
  9. Java if (MyFeatures.FIRST_FEATURE.isActive()) { // … }

  10. JSF <h:panelGroup rendered="#{features['FIRST_FEATURE']}"> <!– Smart and fancy new UI element

    --> </h:panelGroup>
  11. FeatureProxyFactoryBean <bean id="fancyService“ class="com.example.myapp.services.NewFancyService" /> <bean id="boringService" class="com.example.myapp.services.BoringService" /> <bean

    id="myService" class="org.togglz.spring.proxy.FeatureProxyFactoryBean"> <property name="feature" value="FANCY_FEATURE" /> <property name="active" ref="fancyService" /> <property name="inactive" ref="boringService" /> </bean>
  12. Admin Console Source: togglz.org

  13. Go ahead and use it!