This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class CountryAndQuantity { | |
private final String country; | |
private final Long quantity; | |
public CountryAndQuantity(String country, Long quantity) { | |
this.country = country; | |
this.quantity = quantity; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class JadeTransformer extends StringTransformer | |
{ | |
@Override | |
public String transform(String src) | |
{ | |
try { | |
return new Jade().process(src, new HashMap<String, Object>()); | |
} | |
catch (IOException e) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Register the provider by creating a file 'META-INF/services/org.togglz.core.spi.FeatureManagerProvider'. | |
* The file must contains the fully-qualified name of the provider class. | |
*/ | |
public class SingletonFeatureManagerProvider implements FeatureManagerProvider { | |
private static FeatureManager featureManager; | |
@Override | |
public int priority() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Implementation of the Management interface | |
*/ | |
public class TogglzManagement implements TogglzManagementMBean { | |
@Override | |
public void toggle(String featureName, boolean enabled) { | |
// as we only know the name, wrap it into an UntypedFature | |
UntypedFeature feature = new UntypedFeature(featureName); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MultiEnumFeatureProvider implements FeatureProvider { | |
private final Set<Feature> features = new LinkedHashSet<>(); | |
public MultiEnumFeatureProvider( Class<? extends Feature>... enumTypes ) { | |
for( Class<? extends Feature> clazz : enumTypes ) { | |
for( Feature feature : clazz.getEnumConstants() ) { | |
features.add( feature ); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@WebServlet(urlPatterns = "/FeatureServlet") | |
public class FeatureServlet extends HttpServlet { | |
private static final long serialVersionUID = 1L; | |
@Override | |
protected void doGet( HttpServletRequest req, HttpServletResponse resp ) throws ServletException, IOException { | |
Feature feature = new NamedFeature( req.getParameter( "feature" ) ); | |
boolean enabled = "on".equals( req.getParameter( "state" ) ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class UserClientIpActivationStrategy implements ActivationStrategy { | |
private final ActivationStrategy userStrategy = new UsernameActivationStrategy(); | |
private final ActivationStrategy ipStrategy = new ClientIpActivationStrategy(); | |
@Override | |
public String getId() { | |
return "user-ip"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Controller | |
@Path("/somepage") | |
public class SomeController { | |
@Inject | |
private Result result; | |
@Inject | |
private Validator validation; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CustomConfigurationProducer extends DefaultConfigurationProducer { | |
@Override | |
@Specializes | |
@Produces | |
@ViewEngineConfig // <--- See my note in the mail | |
public Configuration getConfiguration() { | |
Configuration config = super.getConfiguration(); | |
// do custom initialization here | |
return config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This will result in an additional ViewEngine. The priority ensures | |
* that this implementation is preferred. | |
*/ | |
@Priority(1000) | |
public class AdditionalViewEngine extends FreemarkerViewEngine { | |
@Override | |
protected Configuration buildConfiguration() { |
OlderNewer