Skip to content

Instantly share code, notes, and snippets.

@chongma
Last active May 22, 2017 10:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chongma/6d06c598656a3967a2e20dfc24facb00 to your computer and use it in GitHub Desktop.
Save chongma/6d06c598656a3967a2e20dfc24facb00 to your computer and use it in GitHub Desktop.
package tld.domain.example;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;
@ApplicationScoped
public class MyApplicationScoped {
@Inject
private HttpServletRequest httpServletRequest;
public void checkUserInRole() {
httpServletRequest.isUserInRole("somerole");
}
}
package tld.domain.example;
import javax.ejb.AccessTimeout;
import javax.ejb.Asynchronous;
import javax.inject.Inject;
import javax.ejb.Lock;
import javax.ejb.LockType;
import javax.ejb.Singleton;
import tld.domain.example.MyApplicationScoped;
@Singleton
public class Save {
@Inject
private MyApplicationScoped myApplicationScoped;
@Asynchronous
@Lock(LockType.READ)
@AccessTimeout(-1)
public void addJob(String something) {
doSomething(something);
}
private void doSomething(String something) {
myApplicationScoped.checkUserInRole();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment