private final RuntimeDelegate runtimeDelegate() { if(this.runtimeDelegate!=null) { return this.runtimeDelegate; } else { return RuntimeDelegate.getInstance(); } }
private WriteSessionService(final TemplateManagementService templateManagementService, final EndpointManagementService endointManagementService) { this.templateManagementService = templateManagementService; this.endpointManagementService = endointManagementService; this.resourceRepository=RuntimeDelegate.getInstance().getResourceRepository(); this.transactionManager=RuntimeDelegate.getInstance().getTransactionManager(); }
public ServiceRegistry() { this.services=MutableClassToInstanceMap.<Service>create(); this.builders=new LinkedHashMap<Class<?>, ServiceBuilder<?>>(); this.delegate=RuntimeDelegate.getInstance(); }
private ApplicationContextOperationController() { this.transactionManager = RuntimeDelegate.getInstance().getTransactionManager(); }
private EndpointManagementService(TemplateManagementService templateManagementService) { this.templateManagementService = templateManagementService; this.modelFactory=RuntimeDelegate.getInstance().getModelFactory(); this.endpointRepository=RuntimeDelegate.getInstance().getEndpointRepository(); this.resourceRepository=RuntimeDelegate.getInstance().getResourceRepository(); this.listenerManager=ListenerManager.<EndpointLifecycleListener>newInstance(); }
DefaultApplicationContext(DefaultApplicationEngine engine) { this.engine=engine; this.resourceRepository=RuntimeDelegate.getInstance().getResourceRepository(); this.endpointRepository=RuntimeDelegate.getInstance().getEndpointRepository(); this.constraintReportRepository=RuntimeDelegate.getInstance().getConstraintReportRepository(); this.factory=DefaultPublicResourceFactory.newInstance(this); this.operationController=new ApplicationContextOperationController(); this.currentOperation=new ThreadLocal<DefaultApplicationOperation>(); }
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 Endpoint endpoint(Resource resource) { EndpointRepository er = RuntimeDelegate.getInstance().getEndpointRepository(); Endpoint endpoint = er.endpointOfResource(resource.id()); return endpoint; }
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 setup(Application<T> application) throws ApplicationConfigurationException { BootstrapImpl<T> bootstrap= new BootstrapImpl<T>( this.configuration, templateManagementService()); this.lifecycleEnvironment=new DefaultLifecycleEnvironment(); EnvironmentImpl environment= new EnvironmentImpl( templateManagementService(), resourceFactory(), RuntimeDelegate.getInstance().getEndpointRepository(), RuntimeDelegate.getInstance().getResourceRepository(), lifecycleEnvironment ); try { application.setup(environment,bootstrap); bootstrap.configureTemplates(); environment.configureRootResources(); } catch (ApplicationSetupException e) { throw new ApplicationConfigurationException(e); } }
@Before public void setUp() throws LifecycleException { this.delegate=(JPARuntimeDelegate)RuntimeDelegate.getInstance(); this.delegate.init(); this.txManager=delegate.getTransactionManager(); this.sut=getSubjectUnderTest(this.delegate); }
private void initialize() { setRuntimeManager(RuntimeDelegate.getInstance()); ServiceRegistry serviceRegistry = ServiceRegistry.getInstance(); setApplicationLifecycleService(serviceRegistry.getService(ApplicationLifecycleService.class)); setTemplateManagementService(serviceRegistry.getService(TemplateManagementService.class)); setEndpointManagementService(serviceRegistry.getService(EndpointManagementService.class)); setWriteSessionService(serviceRegistry.getService(WriteSessionService.class)); setResourceControllerService(serviceRegistry.getService(ResourceControllerService.class)); }
@Before public void setUp() throws Exception { this.sut = ServiceRegistry. getInstance(). getService(ResourceControllerService.class); this.tms = ServiceRegistry. getInstance(). getService(TemplateManagementService.class); this.modelFactory= RuntimeDelegate. getInstance(). getModelFactory(); }
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(); } } }
this.resourceRepository= RuntimeDelegate. getInstance(). getResourceRepository(); this.endpointRepository= RuntimeDelegate. getInstance(). getEndpointRepository(); this.modelFactory = RuntimeDelegate.getInstance().getModelFactory(); Class<? extends ResourceHandler> handlerClass = PersonHandler.class; this.resource=createResource(handlerClass, NAME1);
@Before public void setUp() throws Exception { ServiceRegistry.setInstance(null); RuntimeDelegate.setInstance(new InMemoryRuntimeDelegate()); this.templateManagementService = ServiceRegistry. getInstance(). getService(TemplateManagementService.class); this.templateManagementService. configure( Lists.<Class<?>>newArrayList(), Arrays.<ResourceHandler>asList(new PersonHandler())); this.modelFactory= RuntimeDelegate. getInstance(). getModelFactory(); this.writeSessionService= ServiceRegistry. getInstance(). getService(WriteSessionService.class); }
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(); }