use of org.glassfish.ejb.config.EjbTimerService in project Payara by payara.
the class EJBTimerService method initProperties.
private void initProperties() {
try {
// Check for property settings from domain.xml
EjbContainer ejbc = ejbContainerUtil.getEjbContainer();
EjbTimerService ejbt = ejbc.getEjbTimerService();
if (ejbt != null) {
String valString = ejbt.getMinimumDeliveryIntervalInMillis();
long val = (valString != null) ? Long.parseLong(valString) : -1;
if (val > 0) {
minimumDeliveryInterval_ = val;
}
valString = ejbt.getMaxRedeliveries();
val = (valString != null) ? Long.parseLong(valString) : -1;
// EJB 2.1 specification minimum is 1
if (val > 0) {
maxRedeliveries_ = val;
}
valString = ejbt.getRedeliveryIntervalInternalInMillis();
val = (valString != null) ? Long.parseLong(valString) : -1;
if (val > 0) {
redeliveryInterval_ = val;
}
rescheduleFailedTimer = Boolean.valueOf(ejbt.getPropertyValue(RESCHEDULE_FAILED_TIMER));
// Load confing listener
ejbContainerUtil.getServices().getService(EJBTimerServiceConfigListener.class);
}
} catch (Exception e) {
logger.log(Level.FINE, "Exception converting timer service " + "domain.xml properties. Defaults will be used instead.", e);
}
logger.log(Level.FINE, "EJB Timer Service properties : " + "min delivery interval = " + getMinimumDeliveryInterval() + "\nmax redeliveries = " + maxRedeliveries_ + "\nredelivery interval = " + getRedeliveryInterval());
}
use of org.glassfish.ejb.config.EjbTimerService in project Payara by payara.
the class EJBTimerServiceUpgrade method doUpgrade.
private void doUpgrade(EjbTimerService ts) {
String value = ts.getMinimumDeliveryIntervalInMillis();
if (value == null || "7000".equals(value)) {
value = "" + EjbContainerUtil.MINIMUM_TIMER_DELIVERY_INTERVAL;
}
List<Property> properties = ts.getProperty();
if (properties != null) {
for (Property p : properties) {
if (p.getName().equals(EjbContainerUtil.TIMER_SERVICE_UPGRADED)) {
// Already set
return;
}
}
}
try {
final String minDelivery = value;
ConfigSupport.apply(new SingleConfigCode<EjbTimerService>() {
public Object run(EjbTimerService ts) throws PropertyVetoException, TransactionFailure {
Property prop = ts.createChild(Property.class);
ts.getProperty().add(prop);
prop.setName(EjbContainerUtil.TIMER_SERVICE_UPGRADED);
prop.setValue("false");
ts.setMinimumDeliveryIntervalInMillis(minDelivery);
return null;
}
}, ts);
} catch (Exception e) {
e.printStackTrace();
}
}
use of org.glassfish.ejb.config.EjbTimerService in project Payara by payara.
the class PersistentEJBTimerService method initEJBTimerService.
static void initEJBTimerService(String target) {
EJBTimerService timerService = null;
EjbContainerUtil _ejbContainerUtil = EjbContainerUtilImpl.getInstance();
EjbTimerService _ejbt = _ejbContainerUtil.getEjbTimerService(target);
String resourceName = getTimerResource(_ejbt);
File root = _ejbContainerUtil.getServerContext().getInstallRoot();
boolean is_upgrade = isUpgrade(resourceName, _ejbt, root);
File rootScratchDir = _ejbContainerUtil.getServerEnvironment().getApplicationStubPath();
File appScratchFile = new File(rootScratchDir, TIMER_SERVICE_APP_NAME);
// Remember the value before the file is created during deploy
boolean removeOldTimers = is_upgrade && !appScratchFile.exists();
boolean available = _ejbContainerUtil.getDeployment().isRegistered(TIMER_SERVICE_APP_NAME);
if (available) {
logger.log(Level.WARNING, "EJBTimerService had been explicitly deployed.");
} else {
if (resourceName != null) {
available = deployEJBTimerService(root, appScratchFile, resourceName, is_upgrade);
} else {
logger.log(Level.WARNING, "Cannot deploy EJBTimerService: Timer resource for target " + target + " is not available");
}
}
if (available) {
try {
timerService = new PersistentEJBTimerService("java:global/" + TIMER_SERVICE_APP_NAME + "/" + TIMER_SERVICE_BEAN_NAME, removeOldTimers);
logger.log(Level.INFO, "ejb.timer_service_started", new Object[] { resourceName });
} catch (Exception ex) {
logger.log(Level.WARNING, "ejb.timer_service_init_error", ex);
}
}
EJBTimerService.setPersistentTimerService(timerService);
}
use of org.glassfish.ejb.config.EjbTimerService in project Payara by payara.
the class EJBTimerServiceConfigListener method changed.
/**
*************************************************************************
*/
/**
* Implementation of org.jvnet.hk2.config.ConfigListener ********************
*/
/**
*************************************************************************
*/
public UnprocessedChangeEvents changed(PropertyChangeEvent[] events) {
// Events that we can't process now because they require server restart.
List<UnprocessedChangeEvent> unprocessedEvents = new ArrayList<UnprocessedChangeEvent>();
for (PropertyChangeEvent event : events) {
if (event.getSource() instanceof EjbTimerService) {
Object oldValue = event.getOldValue();
Object newValue = event.getNewValue();
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "Got EjbTimerService change event ==== " + event.getSource() + " " + event.getPropertyName() + " " + oldValue + " " + newValue);
}
if (oldValue != null && oldValue.equals(newValue)) {
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "Event " + event.getPropertyName() + " did not change existing value of " + oldValue);
}
} else {
unprocessedEvents.add(new UnprocessedChangeEvent(event, "Restart required to reconfigure EJB Timer Service"));
}
}
}
return (unprocessedEvents.size() > 0) ? new UnprocessedChangeEvents(unprocessedEvents) : null;
}
Aggregations