Skip to content

Instantly share code, notes, and snippets.

Christian Kaltepoth chkal

Block or report user

Report or block chkal

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@chkal
chkal / NoopServletFilter.java
Created Feb 17, 2018
NoopServletFilter.java
View NoopServletFilter.java
@WebFilter("/*")
public class NoopServletFilter implements Filter {
@Override
public void init(FilterConfig filterConfig) throws ServletException {
// empty
}
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
View SimpleController.java
@Controller
@Path("/simple")
public class SimpleController {
@GET
public String get() {
return "simple.jsp";
}
}
View Sample.java
// some interface
public interface Plugin {
// ...
}
// standard bean
public class FirstPlugin implements Plugin {
// ...
}
@chkal
chkal / Message.java
Last active Nov 23, 2015
Draft: MVC 1.0 support for message handling
View Message.java
public class Message implements Serializable {
private static final long serialVersionUID = 2518143831776562527L;
public enum Severity {
INFO,
WARN,
ERROR
}
View AdditionalViewEngine.java
/**
* 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() {
@chkal
chkal / CustomConfigurationProducer.java
Last active Aug 29, 2015
Customization of the configuration used by FreemarkerViewEngine
View CustomConfigurationProducer.java
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;
View SomeController.java
@Controller
@Path("/somepage")
public class SomeController {
@Inject
private Result result;
@Inject
private Validator validation;
@chkal
chkal / UserClientIpActivationStrategy.java
Created Sep 30, 2013
Example for a custom activation strategy that combines two existing strategies
View UserClientIpActivationStrategy.java
public class UserClientIpActivationStrategy implements ActivationStrategy {
private final ActivationStrategy userStrategy = new UsernameActivationStrategy();
private final ActivationStrategy ipStrategy = new ClientIpActivationStrategy();
@Override
public String getId() {
return "user-ip";
}
@chkal
chkal / FeatureServlet.java
Created Jul 31, 2013
Simple Servlet to control Togglz features using GET requests
View FeatureServlet.java
@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" ) );
@chkal
chkal / MultiEnumFeatureProvider.java
Created May 21, 2013
Using multiple feature enums with Togglz
View MultiEnumFeatureProvider.java
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 );
}
}
You can’t perform that action at this time.