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
@Component | |
@RequestScoped | |
public class SessionCreator implements ComponentFactory<Session> { | |
private final SessionFactory factory; | |
private final Proxifier proxifier; | |
private Session session; | |
public SessionCreator(SessionFactory factory, Proxifier proxifier) { | |
this.factory = factory; | |
this.proxifier = proxifier; |
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
@Intercepts | |
public class RedirectCommitInterceptor implements Interceptor { | |
private Session session; | |
private MutableResponse response; | |
public RedirectCommitInterceptor(Session session, MutableResponse response) { | |
this.session = session; | |
this.response = response; | |
} | |
public boolean accept(ResourceMethod method) { |
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
@Component | |
public class MapConverter implements Converter { //from XStream | |
//unmarshal => empty | |
public boolean canConvert(Class type) { return Map.class.isAssignableFrom(type); } | |
public void marshal(Object value, HierarchicalStreamWriter writer, MarshalingContext context) { | |
Map<String, Object> map = (Map<String, Object>) value; //assuming this |
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
package me.cavalcanti.lucas | |
import org.joda.time.LocalDate | |
import org.joda.time.format.DateTimeFormatter | |
import org.joda.time.format.DateTimeFormat | |
import scala.util.parsing.combinator.JavaTokenParsers | |
import org.joda.time.Period | |
class CalendarParser extends JavaTokenParsers { |
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
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\w$(__git_ps1 "\[\033[0;31m\](%s)")\[\033[00m\]\$ ' | |
alias branch='git br | grep "*" | sed "s/\* //"' | |
alias gc='git commit -v' | |
alias gs='git status' | |
alias gp='git push origin `branch`' | |
alias gl='git pull origin `branch`' | |
alias grl='git pull --rebase origin `branch`' | |
alias ga='git add' | |
alias gb='git branch' |
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
import java.io.IOException; | |
import java.util.Collections; | |
import java.util.Enumeration; | |
import java.util.Map; | |
import java.util.Map.Entry; | |
import javax.servlet.Filter; | |
import javax.servlet.FilterChain; | |
import javax.servlet.FilterConfig; |
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
@Convert(Calendar.class) | |
public class DateAndTimeCalendarConverter extends LocaleBasedCalendarConverter { | |
private final Localization localization; | |
public DateAndTimeCalendarConverter(Localization localization) { | |
super(localization); | |
this.localization = localization; | |
} | |
public Calendar convert(String value, Class<? extends Calendar> type, ResourceBundle bundle) { | |
if (Strings.nullToEmpty(value).length() > "dd/mm/yyyy".length()) { |
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 interface Jsonable { } |
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
@Component | |
@ApplicationScoped | |
public class LinkToHandler implements StereotypeHandler { | |
private Map<String, Map<String, Linker>> linkTo = Maps.newHashMap(); | |
private final ServletContext context; | |
private final Router router; | |
public LinkToHandler(ServletContext context, Router router) { | |
this.context = context; |
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
import com.thoughtworks.xstream.converters.basic.DateConverter; | |
@Component | |
public class CustomJSONSerialization extends XStreamJSONSerialization { | |
public CustomJSONSerialization(HttpServletResponse response,TypeNameExtractor extractor, ProxyInitializer initializer) { | |
super(response, extractor, initializer); | |
} | |
@Override | |
public XStream getXStream() { |