本文整理了Java中javax.ejb.Startup
类的一些代码示例,展示了Startup
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Startup
类的具体详情如下:
包路径:javax.ejb.Startup
类名称:Startup
暂无
代码示例来源:origin: javaee-samples/javaee7-samples
/**
* @author Jacek Jackowiak
*/
@Startup
@Singleton
public class SchedulesTimerBean {
@Inject
Event<Ping> pingEvent;
@Schedules({
@Schedule(hour = "*", minute = "*", second = "*/5", info = "Every 5 second timer"),
@Schedule(hour = "*", minute = "*", second = "*/10", info = "Every 10 second timer")
})
public void automaticallyScheduled(Timer timer) {
pingEvent.fire(new Ping(timer.getInfo().toString()));
}
}
代码示例来源:origin: javaee-samples/javaee7-samples
/**
* @author Arun Gupta
*/
@Startup
@Singleton
public class AutomaticTimerBean {
@Resource
SessionContext ctx;
@Inject
Event<Ping> pingEvent;
@Schedule(hour = "*", minute = "*", second = "*/5", info = "Every 5 second timer")
public void printDate() {
Collection<Timer> timers = ctx.getTimerService().getAllTimers();
for (Timer t : timers) {
pingEvent.fire(new Ping(t.getInfo().toString()));
}
}
}
代码示例来源:origin: akquinet/jbosscc-as7-examples
@Singleton
@Startup
public class TimerApiExample {
private final static Logger LOG = LoggerFactory
.getLogger(TimerApiExample.class);
@Resource
private TimerService timerService;
@PostConstruct
public void init() {
timerService.createCalendarTimer(new ScheduleExpression().second("*/1")
.minute("*").hour("*"));
}
@Timeout
public void schedule(Timer timer) {
LOG.info("invoke method {}", new Date());
}
}
代码示例来源:origin: org.javabeanstack/jbs-business
@Startup
@Lock(LockType.READ)
public class DBManager implements IDBManager{
@Resource
SessionContext context;
代码示例来源:origin: javaee-samples/javaee7-samples
/**
* @author arungupta
*/
@Startup
@Singleton
public class MyTimerScheduleBean extends AbstractTimerBatch {
}
代码示例来源:origin: com.caucho/resin
/**
* Top-level JMS connection
*/
@Singleton
@Startup
public class JmsConnectionFactory
extends com.caucho.jms.connection.ConnectionFactoryImpl
{
}
代码示例来源:origin: javaee-samples/javaee7-samples
@Startup
@Singleton
public class ProgrammaticTimerBean {
@Inject
Event<Ping> pingEvent;
@Resource
TimerService timerService;
代码示例来源:origin: payara/Payara-Examples
/**
*
* @author steve
*/
@Singleton
@Startup
public class ProgrammaticTimer {
@Resource
TimerService ts;
static Logger logger = Logger.getLogger(SimpleTimerBean.class.getCanonicalName());
@Schedule(hour = "*", minute = "*", second = "*/10", info = "Every 10 second timer")
public void printSchedule() {
logger.info("ProgrammaticTimer Schedule Fired .... ");
ts.createTimer(5000, null);
}
@Timeout
public void timeOut() {
logger.info("Programmatic timeout fired ");
}
}
代码示例来源:origin: javaee-samples/javaee7-samples
@Startup
@Singleton
public class PingsListener {
final List<Ping> pings = new CopyOnWriteArrayList<>();
public void listen(@Observes Ping ping) {
System.out.println("ping = " + ping);
pings.add(ping);
}
public List<Ping> getPings() {
return pings;
}
}
代码示例来源:origin: com.caucho/resin
@Startup
@Singleton
public class AdminServices
代码示例来源:origin: javaee-samples/javaee7-samples
/**
* @author Jacek Jackowiak
*/
@Startup
@Singleton
public class MultipleScheduleTimerBean {
@Inject
Event<Ping> pingEvent;
@Schedule(hour = "*", minute = "*", second = "*/5", info = "Every 5 second timer")
public void fastAutomaticallyScheduled(Timer timer) {
fireEvent(timer);
}
@Schedule(hour = "*", minute = "*", second = "*/10", info = "Every 10 second timer")
public void slowlyAutomaticallyScheduled(Timer timer) {
fireEvent(timer);
}
private void fireEvent(Timer timer) {
pingEvent.fire(new Ping(timer.getInfo().toString()));
}
}
代码示例来源:origin: astefanutti/metrics-cdi
@Startup
@Singleton
public class TimedMethodTimerBean {
@Resource
private TimerService ts;
@Inject
CallCounter counter;
@PostConstruct
public void init() {
ts.createIntervalTimer(0l, TimeUnit.SECONDS.toMillis(1), new TimerConfig("a test timer", false));
}
@Timeout
@Timed(name = "schedule")
public void scheduledMethod() {
counter.count();
}
}
代码示例来源:origin: com.blazebit/blaze-storage-core-config-wildfly
/**
* This is a singleton because it seems the cache manager can't be injected into CDI beans.
* It's a startup singleton because we need to eagerly start the cache so that the synchronization starts.
*
* @author Christian Beikov
*/
@Startup
@Singleton
public class ClusteredCacheManagerProducer {
@Resource(lookup = "java:jboss/infinispan/container/storage")
private EmbeddedCacheManager cacheManager;
@PostConstruct
public void init() {
// Start caches on startup
for (String name : cacheManager.getCacheNames()) {
cacheManager.getCache(name);
}
}
@Produces
@ClusteredCache
@ApplicationScoped
public CacheManager produceJcacheCacheManager() {
// Note that we don't close the cache manager because the underlying resource is container managed
return new org.infinispan.jcache.embedded.JCacheManager(URI.create("storage"), cacheManager, Caching.getCachingProvider());
}
}
代码示例来源:origin: javaee-samples/javaee7-samples
/**
* @author Arun Gupta
*/
@Startup
@Singleton
public class MySingletonBeanManagedConcurrency {
volatile StringBuilder builder;
@PostConstruct
private void postConstruct() {
builder = new StringBuilder();
System.out.println("postConstruct");
}
public String readSomething() {
return "current timestamp: " + new Date();
}
public String writeSomething(String something) {
synchronized (builder) {
builder.append(something);
}
return builder.toString() + " : " + new Date();
}
}
代码示例来源:origin: com.caucho/resin
@Startup
@Singleton
@Configurable
代码示例来源:origin: ops4j/org.ops4j.pax.exam2
@Singleton
@Startup
public class InitializerService {
private static Logger log = LoggerFactory.getLogger(LibraryService.class);
@Inject
private LibraryService libraryService;
@PostConstruct
public void init() {
log.info("filling library");
if (libraryService.getNumBooks() != 0) {
return;
}
Author mann = libraryService.createAuthor("Thomas", "Mann");
Author steinbeck = libraryService.createAuthor("John", "Steinbeck");
libraryService.createBook("Buddenbrooks", mann);
libraryService.createBook("East of Eden", steinbeck);
}
}
代码示例来源:origin: moelholm/smallexamples
@Startup
@Singleton
public class DatabaseBootstrapBean {
@Resource
private DataSource ds;
@Inject
private EntityManager em;
@Inject
private DataSourceConnectionListenerHelper connectionListenerHelper;
代码示例来源:origin: ops4j/org.ops4j.pax.exam2
@Singleton
@Startup
public class GreeterMessageSender {
@Resource(mappedName = "jms/cf")
private ConnectionFactory cf;
@Resource(mappedName = "jms/greeter")
private Queue queue;
代码示例来源:origin: javaee-samples/javaee7-samples
/**
* @author Arun Gupta
*/
@Startup
@Singleton
public class MySingleton {
StringBuilder builder;
@PostConstruct
private void postConstruct() {
System.out.println("postConstruct");
builder = new StringBuilder();
}
@Lock(LockType.READ)
public String readSomething() {
return "current timestamp: " + new Date();
}
@Lock(LockType.WRITE)
public String writeSomething(String something) {
builder.append(something);
return builder.toString() + " : " + new Date();
}
}
代码示例来源:origin: com.caucho/resin
@Startup
public class LocalCache extends AbstractCache
内容来源于网络,如有侵权,请联系作者删除!