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 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(); }
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); } }
RuntimeDelegate. getInstance(). getEndpointRepository(); this.modelFactory = RuntimeDelegate.getInstance().getModelFactory(); Class<? extends ResourceHandler> handlerClass = PersonHandler.class;
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(); } } }