private void setRuntimeManager(RuntimeDelegate runtimeDelegate) { this.runtimeDelegate=checkNotNull(runtimeDelegate,"Resource factory cannot be null"); this.transactionManager=runtimeDelegate.getTransactionManager(); }
private ApplicationContextOperationController() { this.transactionManager = RuntimeDelegate.getInstance().getTransactionManager(); }
private WriteSessionService(final TemplateManagementService templateManagementService, final EndpointManagementService endointManagementService) { this.templateManagementService = templateManagementService; this.endpointManagementService = endointManagementService; this.resourceRepository=RuntimeDelegate.getInstance().getResourceRepository(); this.transactionManager=RuntimeDelegate.getInstance().getTransactionManager(); }
private ApplicationLoader(Class<? extends Application<T>> appClass) { this.appClass=appClass; RuntimeDelegate instance = RuntimeDelegate.getInstance(); this.transactionManager=instance.getTransactionManager(); this.modelFactory=instance.getModelFactory(); ServiceRegistry serviceRegistry=ServiceRegistry.getInstance(); this.writeSessionService=serviceRegistry.getService(WriteSessionService.class); this.templateManagementService=serviceRegistry.getService(TemplateManagementService.class); }
public <T> T transactional(Callable<T> callable) throws Exception { Transaction transaction = RuntimeDelegate.getInstance().getTransactionManager().currentTransaction(); transaction.begin(); try { return callable.call(); } catch(Exception e) { e.printStackTrace(); throw e; } finally { try { assertThat(transaction.isActive(),equalTo(false)); } catch (Exception e) { e.printStackTrace(); transaction.rollback(); } } }
private <T extends Resource> T publishResource(Class<? extends T> clazz, String templateId, Name<?> resourceName, String path) { Transaction transaction = RuntimeDelegate.getInstance().getTransactionManager().currentTransaction(); transaction.begin(); Resource newResource=this.modelFactory.createResource(this.tms.templateOfId(templateId),resourceName); T resource=clazz.cast(newResource); RuntimeDelegate.getInstance().getResourceRepository().add(resource); Endpoint endpoint=this.modelFactory.createEndpoint(path,resource,new Date(),EntityTag.createStrong(path)); RuntimeDelegate.getInstance().getEndpointRepository().add(endpoint); transaction.commit(); return resource; }
private void doPrepareSession(final org.ldp4j.application.kernel.resource.Resource resource) { this.transaction=RuntimeDelegate.getInstance().getTransactionManager().currentTransaction(); this.transaction.begin(); this.sut = this.writeSessionService.createSession( WriteSessionConfiguration. builder(). withTarget(resource). build() ); this.uow = UnitOfWork.getCurrent(); }
private Resource initialize(final String id, final String path) { final Transaction transaction= RuntimeDelegate. getInstance(). getTransactionManager(). currentTransaction(); transaction.begin(); try { this.uow = UnitOfWork.newCurrent(); final Resource resource= this.modelFactory.createResource( this.templateManagementService.templateOfId("personTemplate"), name(id)); final Endpoint endpoint=this.modelFactory.createEndpoint(path,resource,new Date(),EntityTag.createStrong(path)); RuntimeDelegate.getInstance().getResourceRepository().add(resource); RuntimeDelegate.getInstance().getEndpointRepository().add(endpoint); UnitOfWork.setCurrent(null); transaction.commit(); return resource; } finally { if(transaction.isActive()) { transaction.rollback(); } } }