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 Provider extends SpringProvider { | |
private static final Logger logger = LoggerFactory.getLogger(Provider.class); | |
@Override | |
protected SpringBasedContainer getContainer() { | |
final SpringBasedContainer delegate = super.getContainer(); | |
final ConfigurableWebApplicationContext parentContext = new Mirror().on(delegate).get().field("parentContext"); | |
return new SpringBasedContainer(parentContext) { | |
@Override | |
public <T> T instanceFor(Class<T> type) { |
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 | |
class ScalaTypeFinder(provider:ParameterNameProvider) extends TypeFinder { | |
implicit def class2raw(klass: Class[_]) = new { | |
def raw = klass.asInstanceOf[Class[AnyRef]] | |
} | |
implicit def isRoot(name: String) = new { | |
def isRootOf(path: String) = path.startsWith(name + ".") || path.equals(name) | |
} |
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 | |
class ActiveRecord[T](session:Session) { | |
implicit def obj2AR(obj:T) = new AR(session, obj) | |
} | |
class AR[T](session:Session, obj:T) { | |
def save = session.save(obj) | |
} |
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 Calculadora { | |
private static final Prova _ = of(Prova.class); | |
public double mediaDeProvas(List<Prova> provas) { | |
return mediaPonderada(provas, function(_.getNota()), function(_.getPeso())); | |
} | |
public <T> double mediaPonderada(List<T> lista, Function<T, Double> valor, Function<T, Double> peso) { | |
double soma = 0.0; | |
double somaPesos = 0.0; |
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 my.apps.package; | |
public class CustomProvider extends GuiceProvider { | |
static class CustomModule extends AbstractModule { | |
private final Module module; | |
CustomModule(Module module) { | |
this.module = module; | |
} |
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 TenantRoutesParser implements RoutesParser { | |
private final RoutesParser parser; | |
public TenantRoutesParser(RoutesParser parser) { | |
this.parser = parser; | |
} |
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
@Documented | |
@Retention(RetentionPolicy.RUNTIME) | |
@Target(ElementType.FIELD) | |
public @interface Out { | |
} |
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 Basket implements HypermediaResource { | |
private int id; | |
private String name; | |
public void configureRelations(RelationBuilder builder) { | |
builder.relation("self").uses(ItemController.class).showItem(id); | |
builder.relation("basket").at("/Basket/add/"+id); | |
} |
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
@Target(ElementType.METHOD) | |
@Retention(RetentionType.RUNTIME) | |
public @interface DisplayTag { | |
String value(); | |
} |
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 FreemarkerPathResolver extends DefaultPathResolver { | |
//delegate constructor | |
@Override | |
protected String getPrefix() { | |
return "/WEB-INF/freemarker/"; | |
} | |