Improved service providing and app hosting

This commit is contained in:
2020-11-26 18:58:08 +01:00
parent cd7c12bba4
commit c6d1dce577
11 changed files with 118 additions and 79 deletions

View File

@@ -1,11 +1,12 @@
import sys
from datetime import datetime
from sh_edraft.hosting.hosting_environment import HostingEnvironment
from sh_edraft.configuration.configuration import Configuration
from sh_edraft.configuration.base.configuration_base import ConfigurationBase
from sh_edraft.hosting.application_runtime import ApplicationRuntime
from sh_edraft.hosting.base.application_host_base import ApplicationHostBase
from sh_edraft.hosting.base.environment_base import EnvironmentBase
from sh_edraft.service.base import ServiceProviderBase
from sh_edraft.service.service_provider import ServiceProvider
from sh_edraft.service.base.service_provider_base import ServiceProviderBase
class ApplicationHost(ApplicationHostBase):
@@ -13,41 +14,25 @@ class ApplicationHost(ApplicationHostBase):
def __init__(self, name: str):
ApplicationHostBase.__init__(self)
self._name: str = name
self._environment = HostingEnvironment()
self._args: list[str] = sys.argv
self._services = ServiceProvider(self)
self._config = Configuration()
self._app_runtime = ApplicationRuntime(self._config)
self._services = ServiceProvider(self._app_runtime)
self._start_time: datetime = datetime.now()
self._end_time: datetime = datetime.now()
@property
def name(self) -> str:
return self._name
@property
def environment(self) -> EnvironmentBase:
return self._environment
@property
def end_time(self) -> datetime:
return self._end_time
def configuration(self) -> ConfigurationBase:
return self._config
@end_time.setter
def end_time(self, end_time: datetime):
self._end_time = end_time
@property
def start_time(self) -> datetime:
return self._start_time
@start_time.setter
def start_time(self, start_time: datetime):
self._start_time = start_time
@property
def date_time_now(self) -> datetime:
return datetime.now()
@property
def services(self) -> ServiceProviderBase:
return self._services
def create(self): pass

View File

@@ -0,0 +1,38 @@
from datetime import datetime
from sh_edraft.configuration.base import ConfigurationBase
from sh_edraft.hosting.base.application_runtime_base import ApplicationRuntimeBase
class ApplicationRuntime(ApplicationRuntimeBase):
def __init__(self, config: ConfigurationBase):
ApplicationRuntimeBase.__init__(self)
self._configuration = config
self._start_time: datetime = datetime.now()
self._end_time: datetime = datetime.now()
@property
def configuration(self) -> ConfigurationBase:
return self._configuration
@property
def start_time(self) -> datetime:
return self._start_time
@start_time.setter
def start_time(self, start_time: datetime):
self._start_time = start_time
@property
def end_time(self) -> datetime:
return self._end_time
@end_time.setter
def end_time(self, end_time: datetime):
self._end_time = end_time
@property
def date_time_now(self) -> datetime:
return datetime.now()

View File

@@ -1,3 +1,4 @@
# imports:
from .application_host_base import ApplicationHostBase
from .environment_base import EnvironmentBase
from .application_base import ApplicationBase

View File

@@ -6,6 +6,9 @@ class ApplicationBase(ABC):
@abstractmethod
def __init__(self): pass
@abstractmethod
def create_application_host(self): pass
@abstractmethod
def create_configuration(self): pass

View File

@@ -1,7 +1,7 @@
from abc import ABC, abstractmethod
from datetime import datetime
from sh_edraft.hosting.base.environment_base import EnvironmentBase
from sh_edraft.configuration.base.configuration_base import ConfigurationBase
from sh_edraft.service.base.service_provider_base import ServiceProviderBase
class ApplicationHostBase(ABC):
@@ -12,27 +12,14 @@ class ApplicationHostBase(ABC):
@property
@abstractmethod
def name(self) -> str: pass
@property
@abstractmethod
def environment(self) -> EnvironmentBase: pass
@property
@abstractmethod
def start_time(self) -> datetime: pass
@start_time.setter
@abstractmethod
def start_time(self, start_time: datetime): pass
def configuration(self) -> ConfigurationBase: pass
@property
@abstractmethod
def end_time(self): pass
def services(self) -> ServiceProviderBase: pass
@end_time.setter
@abstractmethod
def end_time(self, end_time: datetime): pass
@property
@abstractmethod
def date_time_now(self) -> datetime: pass
def create(self): pass

View File

@@ -0,0 +1,34 @@
from abc import ABC, abstractmethod
from datetime import datetime
from sh_edraft.configuration.base import ConfigurationBase
class ApplicationRuntimeBase(ABC):
@abstractmethod
def __init__(self): pass
@property
@abstractmethod
def configuration(self) -> ConfigurationBase: pass
@property
@abstractmethod
def start_time(self) -> datetime: pass
@start_time.setter
@abstractmethod
def start_time(self, start_time: datetime): pass
@property
@abstractmethod
def end_time(self): pass
@end_time.setter
@abstractmethod
def end_time(self, end_time: datetime): pass
@property
@abstractmethod
def date_time_now(self) -> datetime: pass