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 final RuntimeDelegate runtimeDelegate() { if(this.runtimeDelegate!=null) { return this.runtimeDelegate; } else { return 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); }
private Endpoint endpoint(Resource resource) { EndpointRepository er = RuntimeDelegate.getInstance().getEndpointRepository(); Endpoint endpoint = er.endpointOfResource(resource.id()); return endpoint; }
/** * Obtain a {@code RuntimeInstance} instance using the method described in * {@link #getInstance}. * * @return an instance of {@code RuntimeInstance}. */ private static RuntimeDelegate findDelegate() { try { RuntimeDelegate result=createRuntimeInstanceFromSPI(); if(result==null) { result=createRuntimeInstanceFromConfigurationFile(); } if(result==null) { String delegateClassName = System.getProperty(LDP4J_APPLICATION_SPI_PROPERTY); if(delegateClassName!=null) { result=createRuntimeInstanceForClassName(delegateClassName); } } if(result==null) { result=new DefaultRuntimeInstance(); } return result; } catch (Exception ex) { throw new IllegalStateException("Could not find runtime delegate",ex); } }
@After public void tearDown() throws Exception { RuntimeDelegate.setInstance(null); }
private Resource createResource(Class<? extends ResourceHandler> handlerClass, Name<?> name) { return this.modelFactory. createResource( this.templateManagementService.templateOfHandler(handlerClass), name); }
private Endpoint createEndpoint(String path, Resource resource) { return this.modelFactory. createEndpoint(path, resource, new Date(), EntityTag.createStrong("etag")); }
protected final ModelFactory modelFactory() { if(this.modelFactory==null) { this.modelFactory=runtimeDelegate().getModelFactory(); } return this.modelFactory; }
private void setRuntimeManager(RuntimeDelegate runtimeDelegate) { this.runtimeDelegate=checkNotNull(runtimeDelegate,"Resource factory cannot be null"); this.transactionManager=runtimeDelegate.getTransactionManager(); }
private static RuntimeDelegate createRuntimeInstanceForClassName(String delegateClassName) { RuntimeDelegate result = null; try { Class<?> delegateClass = Class.forName(delegateClassName); if(RuntimeDelegate.class.isAssignableFrom(delegateClass)) { Object impl = delegateClass.newInstance(); result = RuntimeDelegate.class.cast(impl); } } catch (ClassNotFoundException e) { handleFailure(delegateClassName, "find", e); } catch (InstantiationException e) { handleFailure(delegateClassName, INSTANTIATE_ACTION, e); } catch (IllegalAccessException e) { handleFailure(delegateClassName, INSTANTIATE_ACTION, e); } return result; }
public ServiceRegistry() { this.services=MutableClassToInstanceMap.<Service>create(); this.builders=new LinkedHashMap<Class<?>, ServiceBuilder<?>>(); this.delegate=RuntimeDelegate.getInstance(); }
@AfterClass public static void tearDownAfter() throws Exception { RuntimeDelegate.setInstance(null); }
@Before public void setUp() throws LifecycleException { this.delegate=(JPARuntimeDelegate)RuntimeDelegate.getInstance(); this.delegate.init(); this.txManager=delegate.getTransactionManager(); this.sut=getSubjectUnderTest(this.delegate); }
@After public void tearDown() throws Exception { RuntimeDelegate.setInstance(null); }
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)); }
@AfterClass public static void tearDownAfter() throws Exception { RuntimeDelegate.setInstance(null); }