use of jakarta.annotation.PostConstruct in project tomee by apache.
the class Movies method construct.
@PostConstruct
private void construct() throws Exception {
Connection connection = movieDatabase.getConnection();
try {
PreparedStatement stmt = connection.prepareStatement("CREATE TABLE movie ( director VARCHAR(255), title VARCHAR(255), year integer)");
stmt.execute();
} finally {
connection.close();
}
}
use of jakarta.annotation.PostConstruct in project tomee by apache.
the class Alternative method postConstruct.
@PostConstruct
public <T> void postConstruct() throws MBeanRegistrationException {
final String name = properties.remove("name").toString();
final String iface = properties.remove("interface").toString();
final String prefix = properties.remove("prefix").toString();
requireNotNull(name);
requireNotNull(iface);
try {
final Class<T> ifaceCls = (Class<T>) Class.forName(iface, true, Thread.currentThread().getContextClassLoader());
final StandardMBean mBean = new StandardMBean((T) this, ifaceCls);
for (String attributeName : properties.stringPropertyNames()) {
final Object value = properties.remove(attributeName);
if (prefix != null) {
if (!attributeName.startsWith(prefix + ".")) {
continue;
} else {
attributeName = attributeName.substring(prefix.length() + 1);
}
}
final Class<?> targetType = findAttributeType(mBean.getMBeanInfo(), attributeName);
final Object targetValue = Converter.convert(value, targetType, null);
final Attribute attribute = new Attribute(attributeName, targetValue);
mBean.setAttribute(attribute);
}
final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
final ObjectName objectName = new ObjectName(name);
mbs.registerMBean(this, objectName);
} catch (final Exception e) {
LOGGER.severe("Unable to register mbean " + e.getMessage());
throw new MBeanRegistrationException(e);
}
}
use of jakarta.annotation.PostConstruct in project tomee by apache.
the class SampleDataManager method createSomeData.
@PostConstruct
public void createSomeData() {
final User tomee = users.create("tomee", "tomee", "tomee@apache.org");
final User openejb = users.create("openejb", "openejb", "openejb@apache.org");
final Post tomeePost = posts.create("TomEE", "TomEE is a cool JEE App Server", tomee.getId());
posts.create("OpenEJB", "OpenEJB is a cool embedded container", openejb.getId());
comments.create("visitor", "nice post!", tomeePost.getId());
}
use of jakarta.annotation.PostConstruct in project tomee by apache.
the class FarmerBrown method construct.
@PostConstruct
private void construct() {
final TimerConfig plantTheCorn = new TimerConfig("plantTheCorn", false);
timerService.createCalendarTimer(new ScheduleExpression().month(5).dayOfMonth("20-Last").minute(0).hour(8), plantTheCorn);
timerService.createCalendarTimer(new ScheduleExpression().month(6).dayOfMonth("1-10").minute(0).hour(8), plantTheCorn);
final TimerConfig harvestTheCorn = new TimerConfig("harvestTheCorn", false);
timerService.createCalendarTimer(new ScheduleExpression().month(9).dayOfMonth("20-Last").minute(0).hour(8), harvestTheCorn);
timerService.createCalendarTimer(new ScheduleExpression().month(10).dayOfMonth("1-10").minute(0).hour(8), harvestTheCorn);
final TimerConfig checkOnTheDaughters = new TimerConfig("checkOnTheDaughters", false);
timerService.createCalendarTimer(new ScheduleExpression().second("*").minute("*").hour("*"), checkOnTheDaughters);
}
use of jakarta.annotation.PostConstruct in project cdi-tck by jakartaee.
the class Farm method postConstruct.
@PostConstruct
protected void postConstruct() {
founded = new Date();
initialStaff = farmOffice.noOfStaff;
}
Aggregations