Refine search
/** * @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())); } } }
/** * @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())); } }
@Singleton public class JoynrShutdownServiceBean implements JoynrShutdownService { @Inject private JoynrIntegrationBean joynrIntegrationBean; @Override public void prepareForShutdown() { joynrIntegrationBean.getRuntime().prepareForShutdown(); } @Override public void shutdown() { joynrIntegrationBean.destroy(); } }
@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()); } }
/** * @author Jaikiran Pai */ @Startup @Singleton @LocalBean public class StartupSingleton { private List<String> invocationLog; @Resource(lookup = "java:module/ModuleName") private String moduleName; @EJB private CallTrackerSingletonBean callTrackerSingletonBean; public static final String STARTUP_SINGLETON_POST_CONSTRUCT = "StartupSingleton_PostConstruct"; @PostConstruct public void postConstruct() throws Exception { this.callTrackerSingletonBean.addToInvocationLog(STARTUP_SINGLETON_POST_CONSTRUCT); } }
/** * JAX-RS resource that keeps number of reloads. * * @author Jakub Podlesak (jakub.podlesak at oracle.com) */ @Provider @Singleton public class ContainerListener extends AbstractContainerLifecycleListener { @EJB EjbReloaderService reloader; @Override public void onStartup(final Container container) { reloader.setContainer(container); } }
@Singleton @Startup @ConcurrencyManagement(ConcurrencyManagementType.BEAN) @TransactionAttribute(TransactionAttributeType.REQUIRED) @ProcessApplication
@Singleton @ConcurrencyManagement(ConcurrencyManagementType.CONTAINER) public class ClassCacheManagerEJBImpl extends ClassCacheManager { @Override @PreDestroy public void dispose() { super.dispose(); } }
@Singleton @ConcurrencyManagement(ConcurrencyManagementType.BEAN) public class ServiceIdentityManagerBean { @EJB private ConfigurationDAO configurationDAO;
@Singleton public class BeanMessage implements BeanMessageInterface { private String message = ""; @Override public String getMessage() { return message; } @Override public void setMessage(String message) { this.message = message; System.out.println("BeanMessage: setMessage=" + this.message); } @Override public void appendMessage(String message) { this.message += message; System.out.println("BeanMessage: appendMessage=" + this.message); } @Override public String sayHello() { return "Hello from: " + this.getClass().getName() + "; " + System.identityHashCode(this); } }
Singleton singleton = findAnnotation(annotatedType.getJavaClass(),Singleton.class); if (singleton != null) { processClass(builder, singleton.name(), true, scopeIsPresent); modified = true; if (annotatedType.getAnnotation(Startup.class) != null) { builder.addToField(field, new ResourceQualifier.ResourceQualifierLiteral(resource.name(), resource.lookup(), resource.mappedName()) { private static final long serialVersionUID = 1L;
Singleton singleton = annotatedType.getAnnotation(Singleton.class); if (singleton != null) { processClass(builder, singleton.name()); modified = true; builder.removeFromMethod(method, EJB.class); modified = true; if (!ejb.beanName().isEmpty()) { builder.addToMethod(method,new EJbNameLiteral(ejb.beanName())); } else { builder.addToMethod(method,DefaultLiteral.INSTANCE); if (!ejb.beanName().isEmpty()) { builder.addToField(field,new EJbNameLiteral(ejb.beanName())); } else {
/** * Return the name attribute of given annotation. * @param annotation * @return name */ protected String getAnnotatedName(Annotation annotation) { Singleton slAn = (Singleton) annotation; return slAn.name(); }
/** * Set Annotation information to Descriptor. * This method will also be invoked for an existing descriptor with * annotation as user may not specific a complete xml. * @param ejbDesc * @param ainfo * @return HandlerProcessingResult */ protected HandlerProcessingResult setEjbDescriptorInfo( EjbDescriptor ejbDesc, AnnotationInfo ainfo) throws AnnotationProcessorException { EjbSessionDescriptor ejbSingletonDescriptor = (EjbSessionDescriptor) ejbDesc; Class ejbClass = (Class) ainfo.getAnnotatedElement(); Singleton singleton = (Singleton) ainfo.getAnnotation(); // set session bean type in case it wasn't set in a sparse ejb-jar.xml. if( !ejbSingletonDescriptor.isSessionTypeSet() ) { ejbSingletonDescriptor.setSessionType(EjbSessionDescriptor.SINGLETON); } doDescriptionProcessing(singleton.description(), ejbDesc); doMappedNameProcessing(singleton.mappedName(), ejbDesc); doSingletonSpecificProcessing(ejbSingletonDescriptor, ejbClass); return setBusinessAndHomeInterfaces(ejbDesc, ainfo); }
sessionBean.setSessionType(SessionType.SINGLETON); if (singleton.mappedName() != null) { sessionBean.setMappedName(singleton.mappedName());
/** * @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())); } }
@Singleton public class DeleteOldPushMessageInformationScheduler { private static final Logger logger = LoggerFactory.getLogger(DeleteOldPushMessageInformationScheduler.class); @Inject private PushMessageMetricsService service; /** * Job that triggers a delete of outdated metric information from the Server. * * Note: Occurring every day at midnight in the default time zone associated with the container * in which the application is executing. These are the default values from the @Schedule annotation. */ @Schedule public void deleteOutdatedFlatMetrics(){ logger.trace("scheduled deletion for outdated push info data"); service.deleteOutdatedFlatPushInformationData(); } }