Skip to content

Instantly share code, notes, and snippets.

@dmitrygusev
dmitrygusev / XeroObjectMapperContextResolver.java
Created Jun 20, 2013
Example of calling Xero API using JSON format via Resteasy client with custom ObjectMapper
View XeroObjectMapperContextResolver.java
import java.text.DateFormat;
import java.text.FieldPosition;
import java.text.ParsePosition;
import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.ws.rs.ext.ContextResolver;
import org.codehaus.jackson.map.ObjectMapper;
@dmitrygusev
dmitrygusev / AppModule.java
Created May 12, 2013
Eager load Tapestry5 services on startup
View AppModule.java
public void contributeApplicationInitializer(OrderedConfiguration<ApplicationInitializerFilter> configuration,
@Symbol(TapestryEagerLoadInitializer.FORCE_EAGER_LOAD) boolean forceEagerLoad)
{
if (forceEagerLoad)
{
configuration.addInstance("EagerLoad", TapestryEagerLoadInitializer.class, "before:*");
}
}
View CompanyBlocks.java
import x.y.z.entities.Company;
import org.apache.tapestry5.Block;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.ioc.annotations.Inject;
public class CompanyBlocks
{
@Property private Company company;
View EventResponseRenderer.java
public interface EventResponseRenderer
{
String render(RenderEvent renderEvent);
}
@dmitrygusev
dmitrygusev / AppModule.java
Created Mar 30, 2013
Tapestry5 Skicky Forms
View AppModule.java
import java.util.List;
public class AppModule
{
public static void bind(ServiceBinder binder) throws ClassNotFoundException
{
binder.bind(StickyFormSource.class, StickyFormSourceImpl.class);
}
@Contribute(StickyFormSource.class)
View snippet.java
private Map<String, List<String>> traces = new HashMap<String, List<String>>();
private void writeSummary(final List<String> headers) throws IOException {
SortHandler<Integer> handler = new SortHandler<Integer>() {
public int to() {
return headers.size() - 1;
}
public void swap(int i, int j) {
Collections.swap(headers, i, j);
View SortHandlerTest.java
package com.anjlab.ssf4j;
import static org.junit.Assert.assertArrayEquals;
import org.junit.Test;
public class SortHandlerTest {
@Test
public void testSort() {
View junit-test.java
package com.anjlab.sat3;
import java.util.Properties;
import org.junit.BeforeClass;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import cern.colt.list.ObjectArrayList;