本文整理汇总了Java中javax.ejb.TransactionAttribute类的典型用法代码示例。如果您正苦于以下问题:Java TransactionAttribute类的具体用法?Java TransactionAttribute怎么用?Java TransactionAttribute使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TransactionAttribute类属于javax.ejb包,在下文中一共展示了TransactionAttribute类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateMarketplaceName
import javax.ejb.TransactionAttribute; //导入依赖的package包/类
@Override
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public void updateMarketplaceName(Marketplace marketplace,
String newMarketplaceName) throws OperationNotPermittedException {
LocalizerFacade facade = new LocalizerFacade(localizer,
ds.getCurrentUser().getLocale());
String persistedMarketplaceName = facade.getText(marketplace.getKey(),
LocalizedObjectTypes.MARKETPLACE_NAME);
if (!persistedMarketplaceName.equals(newMarketplaceName)) {
if (!ds.getCurrentUser().hasRole(UserRoleType.MARKETPLACE_OWNER)) {
throw new OperationNotPermittedException();
}
checkMarketplaceOwner(marketplace.getMarketplaceId());
localizer.storeLocalizedResource(ds.getCurrentUser().getLocale(),
marketplace.getKey(), LocalizedObjectTypes.MARKETPLACE_NAME,
newMarketplaceName);
}
}
示例2: activateInstance
import javax.ejb.TransactionAttribute; //导入依赖的package包/类
@Override
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public InstanceStatus activateInstance(String instanceId,
ProvisioningSettings settings) throws APPlatformException {
try {
PropertyHandler paramHandler = new PropertyHandler(settings);
if (paramHandler.isVirtualSystemProvisioning()) {
paramHandler.setOperation(Operation.VSYSTEM_ACTIVATION);
paramHandler.setState(FlowState.VSYSTEM_ACTIVATION_REQUESTED);
} else {
paramHandler.setOperation(Operation.VSERVER_ACTIVATION);
paramHandler.setState(FlowState.VSERVER_ACTIVATION_REQUESTED);
}
InstanceStatus result = new InstanceStatus();
result.setChangedParameters(settings.getParameters());
result.setChangedAttributes(settings.getAttributes());
return result;
} catch (Exception e) {
logger.error("Error while scheduling instance activation", e);
throw getPlatformException(e, "error_activation_overall");
}
}
示例3: incStepToTotal
import javax.ejb.TransactionAttribute; //导入依赖的package包/类
@Override
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public void incStepToTotal(Long taskId) {
Connection connection = null;
try {
connection = ds.getConnection();
Column currentTimestamp = new ColumnFunction("id", "current_timestamp", DataType.DATE);
new H2SqlBuilder().update(connection, Query
.UPDATE(TABLE.JMD_TASK())
.SET(JMD_TASK.LAST_UPDATE(), currentTimestamp)
.SET(JMD_TASK.ACTUAL_STEP(), JMD_TASK.TOTAL_STEP())
.WHERE(JMD_TASK.ID(), Condition.EQUALS, taskId)
);
} catch (SQLException e) {
LOGGER.log(Level.SEVERE, e.toString(), e);
throw new RuntimeException(e);
} finally {
SqlUtil.close(connection);
}
}
示例4: initTimers_internal
import javax.ejb.TransactionAttribute; //导入依赖的package包/类
/**
* Initialize the timer for polling for the services
*/
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public void initTimers_internal() {
Collection<Timer> timers = timerService.getTimers();
boolean appTimerExist = false;
for (Timer timerAPP : timers) {
if (APP_TIMER_INFO.equals(timerAPP.getInfo())) {
appTimerExist = true;
}
}
if (!appTimerExist) {
logger.info("Timer create.");
try {
String timerIntervalSetting = configService
.getProxyConfigurationSetting(
PlatformConfigurationKey.APP_TIMER_INTERVAL);
long interval = Long.parseLong(timerIntervalSetting);
timerService.createTimer(0, interval, APP_TIMER_INFO);
} catch (ConfigurationException e) {
timerService.createTimer(0, DEFAULT_TIMER_INTERVAL,
APP_TIMER_INFO);
logger.info(
"Timer interval not set, switch to default 15 sec.");
}
}
}
示例5: getLastValidGroupHistory
import javax.ejb.TransactionAttribute; //导入依赖的package包/类
@Override
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public UserGroupHistory getLastValidGroupHistory(long groupKey,
long endOfBillingPeriod) {
Query query = dm
.createNamedQuery("UserGroupHistory.findLastValidForEndPeriod");
query.setParameter("objKey", Long.valueOf(groupKey));
query.setParameter("endDate", new Date(endOfBillingPeriod));
query.setMaxResults(1);
List<?> qryresult = query.getResultList();
if (qryresult.size() == 0) {
return null;
} else {
return (UserGroupHistory) qryresult.get(0);
}
}
示例6: loadNextActiveSubscriptionHistoryForPriceModel
import javax.ejb.TransactionAttribute; //导入依赖的package包/类
@Override
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public SubscriptionHistory loadNextActiveSubscriptionHistoryForPriceModel(
final long priceModelKey, final long timeMillis) {
TypedQuery<SubscriptionHistory> query = dm.createNamedQuery(
"SubscriptionHistory.findNextForPriceModelAndState",
SubscriptionHistory.class);
query.setParameter("priceModelKey", Long.valueOf(priceModelKey));
query.setParameter("modDate", new Date(timeMillis));
query.setParameter("subscriptionStates", EnumSet.of(
SubscriptionStatus.ACTIVE, SubscriptionStatus.PENDING_UPD));
List<SubscriptionHistory> resultList = query.getResultList();
if (resultList.size() > 0) {
return resultList.get(0);
} else {
return null;
}
}
示例7: setInterruptFlag
import javax.ejb.TransactionAttribute; //导入依赖的package包/类
@Override
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public void setInterruptFlag(Long taskId, Boolean interruptFlag) {
Connection connection = null;
try {
connection = ds.getConnection();
new OraSqlBuilder().update(connection, Query
.UPDATE(TABLE.JMD_TASK())
.SET(JMD_TASK.INTERRUPT_FLAG(), interruptFlag)
.WHERE(JMD_TASK.ID(), Condition.EQUALS, taskId)
);
} catch (SQLException e) {
LOGGER.log(Level.SEVERE, e.toString(), e);
throw new RuntimeException(e);
} finally {
SqlUtil.close(connection);
}
}
示例8: unlockServiceInstance
import javax.ejb.TransactionAttribute; //导入依赖的package包/类
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public void unlockServiceInstance(String controllerId, String instanceId)
throws APPlatformException {
ServiceInstance service = null;
try {
service = instanceDAO.getInstanceById(controllerId, instanceId);
} catch (ServiceInstanceNotFoundException e) {
throw new APPlatformException(e.getMessage());
}
if (service.isLocked()) {
LOGGER.debug("unlock service instance {}", instanceId);
service.setLocked(false);
em.flush();
}
}
示例9: notifyAboutTimedoutSubscriptions
import javax.ejb.TransactionAttribute; //导入依赖的package包/类
@Override
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public boolean notifyAboutTimedoutSubscriptions(long currentTime) {
// we could also use a separate query inclusing the checked conditions
List<Subscription> subscriptions = getSubscriptionDao()
.getSubscriptionsByStatus(SubscriptionStatus.PENDING);
for (Subscription subscription : subscriptions) {
Long timeout = subscription.getProduct().getTechnicalProduct()
.getProvisioningTimeout();
if (!subscription.isTimeoutMailSent()
&& subscription.getCreationDate().longValue()
+ timeout.longValue() < currentTime) {
List<PlatformUser> users = subscription.getProduct()
.getTechnicalProduct().getOrganization()
.getPlatformUsers();
if (notifyTechnicalAdminsAboutTimeout(subscription, users)) {
// if at least one mail was sent, set the mail sent flag of
// the subscription
subscription.setTimeoutMailSent(true);
}
}
}
return true;
}
示例10: setStatus
import javax.ejb.TransactionAttribute; //导入依赖的package包/类
@Override
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public void setStatus(Long taskId, TaskStatus status) {
Connection connection = null;
try {
connection = ds.getConnection();
new H2SqlBuilder().update(connection, Query
.UPDATE(TABLE.JMD_TASK())
.SET(JMD_TASK.STATUS(), status.name())
.WHERE(JMD_TASK.ID(), Condition.EQUALS, taskId)
);
} catch (SQLException e) {
LOGGER.log(Level.SEVERE, e.toString(), e);
throw new RuntimeException(e);
} finally {
SqlUtil.close(connection);
}
}
示例11: getAvailableUserRolesForUser
import javax.ejb.TransactionAttribute; //导入依赖的package包/类
@Override
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public Set<UserRoleType> getAvailableUserRolesForUser(PlatformUser pu) {
Query query = dm.createNamedQuery("UserRole.getAllUserRoles");
List<UserRole> userRoleList = ParameterizedTypes
.list(query.getResultList(), UserRole.class);
Organization org = pu.getOrganization();
Set<UserRoleType> roleList = new HashSet<>();
for (UserRole userRole : userRoleList) {
if (isAllowedUserRole(org, userRole.getRoleName())) {
roleList.add(userRole.getRoleName());
}
}
return roleList;
}
示例12: setQueueNum
import javax.ejb.TransactionAttribute; //导入依赖的package包/类
@Override
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public void setQueueNum(Long taskId, Integer queueNum) {
Connection connection = null;
try {
connection = ds.getConnection();
new OraSqlBuilder().update(connection, Query
.UPDATE(TABLE.JMD_TASK())
.SET(JMD_TASK.QUEUE_NUM(), queueNum)
.WHERE(JMD_TASK.ID(), Condition.EQUALS, taskId)
);
} catch (SQLException e) {
LOGGER.log(Level.SEVERE, e.toString(), e);
throw new RuntimeException(e);
} finally {
SqlUtil.close(connection);
}
}
示例13: countProgress
import javax.ejb.TransactionAttribute; //导入依赖的package包/类
@Override
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public Integer countProgress(Integer totalStep, Integer actualStep) {
if (totalStep == null || totalStep <= 0) {
totalStep = Integer.MAX_VALUE;
}
if (actualStep == null || actualStep <= 0) {
actualStep = 0;
}
if (actualStep > totalStep) {
actualStep = totalStep - 1;
}
BigDecimal step = new BigDecimal(100);
BigDecimal divider = new BigDecimal(totalStep);
step = step.divide(divider, totalStep.toString().length(), RoundingMode.HALF_UP);
step = step.multiply(new BigDecimal(actualStep));
return step.intValue();
}
示例14: setStopEnabled
import javax.ejb.TransactionAttribute; //导入依赖的package包/类
@Override
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public void setStopEnabled(Long taskId, Boolean stopEnabled) {
Connection connection = null;
try {
connection = ds.getConnection();
new H2SqlBuilder().update(connection, Query
.UPDATE(TABLE.JMD_TASK())
.SET(JMD_TASK.STOP_ENABLED(), stopEnabled)
.WHERE(JMD_TASK.ID(), Condition.EQUALS, taskId)
);
} catch (SQLException e) {
LOGGER.log(Level.SEVERE, e.toString(), e);
throw new RuntimeException(e);
} finally {
SqlUtil.close(connection);
}
}
示例15: getOrganizationForDiscountEndNotificiation
import javax.ejb.TransactionAttribute; //导入依赖的package包/类
/**
* Getting list of organization to sending info mail about ending discount
* in one week (seven days).
*
* @param currentTimeMillis
* Current millisecond.
* @return Organization list for sending notification.
*/
@Override
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public List<OrganizationReference> getOrganizationForDiscountEndNotificiation(
long currentTimeMillis) {
// define the first and the last millisecond of needed day:
// define date + 7 days
long firstMillis = getMillisecondInFuture(currentTimeMillis, 7);
long lastMillis = getMillisecondInFuture(currentTimeMillis, 8) - 1;
// getting list of organization to sending info mail about ending
// discount
Query query = dm.createNamedQuery(
"OrganizationReference.findOrganizationForDiscountEndNotification");
query.setParameter("firstMillis", Long.valueOf(firstMillis));
query.setParameter("lastMillis", Long.valueOf(lastMillis));
List<OrganizationReference> list = ParameterizedTypes
.list(query.getResultList(), OrganizationReference.class);
return list;
}