001/** 002 * #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# 003 * This file is part of the LDP4j Project: 004 * http://www.ldp4j.org/ 005 * 006 * Center for Open Middleware 007 * http://www.centeropenmiddleware.com/ 008 * #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# 009 * Copyright (C) 2014-2016 Center for Open Middleware. 010 * #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# 011 * Licensed under the Apache License, Version 2.0 (the "License"); 012 * you may not use this file except in compliance with the License. 013 * You may obtain a copy of the License at 014 * 015 * http://www.apache.org/licenses/LICENSE-2.0 016 * 017 * Unless required by applicable law or agreed to in writing, software 018 * distributed under the License is distributed on an "AS IS" BASIS, 019 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 020 * See the License for the specific language governing permissions and 021 * limitations under the License. 022 * #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# 023 * Artifact : org.ldp4j.framework:ldp4j-application-kernel-mem:0.2.1 024 * Bundle : ldp4j-application-kernel-mem-0.2.1.jar 025 * #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=# 026 */ 027package org.ldp4j.application.kernel.impl; 028 029import org.ldp4j.application.kernel.constraints.ConstraintReportRepository; 030import org.ldp4j.application.kernel.endpoint.EndpointRepository; 031import org.ldp4j.application.kernel.lifecycle.LifecycleException; 032import org.ldp4j.application.kernel.resource.ResourceRepository; 033import org.ldp4j.application.kernel.spi.ModelFactory; 034import org.ldp4j.application.kernel.spi.RuntimeDelegate; 035import org.ldp4j.application.kernel.transaction.TransactionManager; 036 037public final class InMemoryRuntimeDelegate extends RuntimeDelegate { 038 039 private final InMemoryModelFactory modelFactory; 040 private final InMemoryResourceRepository resourceRepository; 041 private final InMemoryEndpointRepository endpointRepository; 042 private final InMemoryConstraintReportRepository constraintReportRepository; 043 private final InMemoryTransactionManager transactionManager; 044 045 public InMemoryRuntimeDelegate() { 046 this.modelFactory= new InMemoryModelFactory(); 047 this.resourceRepository=new InMemoryResourceRepository(); 048 this.endpointRepository=new InMemoryEndpointRepository(); 049 this.constraintReportRepository=new InMemoryConstraintReportRepository(); 050 this.transactionManager = new InMemoryTransactionManager(); 051 } 052 053 /** 054 * {@inheritDoc} 055 */ 056 @Override 057 public ModelFactory getModelFactory() { 058 return this.modelFactory; 059 } 060 061 /** 062 * {@inheritDoc} 063 */ 064 @Override 065 public ConstraintReportRepository getConstraintReportRepository() { 066 return this.constraintReportRepository; 067 } 068 069 /** 070 * {@inheritDoc} 071 */ 072 @Override 073 public EndpointRepository getEndpointRepository() { 074 return this.endpointRepository; 075 } 076 077 /** 078 * {@inheritDoc} 079 */ 080 @Override 081 public ResourceRepository getResourceRepository() { 082 return this.resourceRepository; 083 } 084 085 /** 086 * {@inheritDoc} 087 */ 088 @Override 089 public TransactionManager getTransactionManager() { 090 return this.transactionManager; 091 } 092 093 /** 094 * {@inheritDoc} 095 */ 096 @Override 097 public void init() throws LifecycleException { 098 this.resourceRepository.init(); 099 this.constraintReportRepository.init(); 100 this.endpointRepository.init(); 101 } 102 103 /** 104 * {@inheritDoc} 105 */ 106 @Override 107 public void shutdown() throws LifecycleException { 108 this.endpointRepository.shutdown(); 109 this.constraintReportRepository.shutdown(); 110 this.resourceRepository.shutdown(); 111 } 112 113}