This file contains hidden or 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
| @Stateless | |
| public class ShortenService { | |
| @PersistenceContext EntityManager em; | |
| public List<Shorten> all() { | |
| return em.createQuery("select o from Shorten o").getResultList(); | |
| } | |
| public long count() { |
This file contains hidden or 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 javax.enterprise.context.RequestScoped; | |
| import javax.inject.Named; | |
| import javax.inject.Inject; | |
| @Named | |
| @RequestScoped | |
| public class MonControleur { | |
| @Inject MonModele modele; | |
This file contains hidden or 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 controllers | |
| import play.api._ | |
| import play.api.mvc._ | |
| import play.api.libs._ | |
| import play.api.libs.iteratee._ | |
| import play.api.libs.concurrent.Promise | |
| import java.util.concurrent.TimeUnit | |
| import scala.concurrent.stm._ |
This file contains hidden or 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
| @Path("index") | |
| @Stateless | |
| public class App { | |
| @Inject IndexTemplate index; | |
| @GET @Produces(MediaType.TEXT_HTML) | |
| public IndexTemplate index() { | |
| return index.title("Tasks").addTasks(Task.all); | |
| } |
This file contains hidden or 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
| flow { | |
| println "\nTriggered by ${cause.build}\n" | |
| a = build("Job1") | |
| b = build("Job2", param1: "troulala", param2: "machin") | |
| c = build("Job3") | |
| println "\n${a.result()} ${b.result()} ${c.result()}\n" | |
| par = parallel { |
This file contains hidden or 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
| String myValue = "loser"; | |
| Field f = MyClass.class.getDeclaredField("jerem"); | |
| f.setAccessible(true); | |
| f.set(null, myValue); |
This file contains hidden or 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 abstract class Option<T> implements Iterable<T>, Serializable { | |
| public abstract boolean isDefined(); | |
| public abstract boolean isEmpty(); | |
| public abstract T get(); | |
| public Option<T> orElse(T value) { | |
| return isEmpty() ? Option.maybe(value) : this; |
This file contains hidden or 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 AOPConfig { | |
| public void configure(@Observes AOPConfigEvent config) { | |
| config.add( intercept(Service.class).onAllMethodsReturning(String.class) ); | |
| } | |
| } | |
| public void intercept(@Observes @Return(String.class) | |
| @MethodName("doSomething") | |
| @MethodAnnotated(CutHere.class) Before before) { |
This file contains hidden or 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 Application extends Controller { | |
| @Inject static MyBean myBean; | |
| public static void index() { | |
| myBean.currentUserId = session.get("id"); | |
| DataFromSomewhere data = myBean.getData(); | |
| render(data); | |
| } | |
| } |
This file contains hidden or 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
| @Inject @To(actor=Master.class) ActorEvent<Calculate> master; | |
| master.fire(new Calculate(4, 10000, 10000)); | |
| @ActorConfig("master") @ApplicationScoped | |
| public static class Master extends CDIActor { | |
| public void listenCalculate(@Observes Calculate message) { | |
| ... | |
| } |