Simplify CMS_SERVICE initialization, and CMS server (launcher).

Renamed "layout" lib as "app_env" with APPLICATION_ENVIRONMENT interface.
  applied changed to callers.
Added CMS_THEME.has_region (a_name): BOOLEAN to know if a region is declared in a defined theme.
This commit is contained in:
2015-04-29 23:01:42 +02:00
parent 0eb2b70d0f
commit 6ff7a6493c
34 changed files with 214 additions and 154 deletions

View File

@@ -0,0 +1,119 @@
note
description: "Provide access to json configuration"
date: "$Date: 2015-01-27 19:15:02 +0100 (mar., 27 janv. 2015) $"
revision: "$Revision: 96542 $"
class
APPLICATION_JSON_CONFIGURATION_HELPER
feature -- Application Configuration
new_smtp_configuration (a_path: PATH): READABLE_STRING_32
-- Build a new database configuration.
local
l_parser: JSON_PARSER
do
Result := ""
if attached json_file_from (a_path) as json_file then
l_parser := new_json_parser (json_file)
l_parser.parse_content
if
l_parser.is_valid and then
attached {JSON_OBJECT} l_parser.parsed_json_value as jv and then
attached {JSON_OBJECT} jv.item ("smtp") as l_smtp and then
attached {JSON_STRING} l_smtp.item ("server") as l_server
then
Result := l_server.item
end
end
end
new_database_configuration (a_path: PATH): detachable DATABASE_CONFIGURATION
-- Build a new database configuration.
local
l_parser: JSON_PARSER
do
if attached json_file_from (a_path) as json_file then
l_parser := new_json_parser (json_file)
l_parser.parse_content
if
l_parser.is_valid and then
attached {JSON_OBJECT} l_parser.parsed_json_value as jv and then
attached {JSON_OBJECT} jv.item ("database") as l_database and then
attached {JSON_OBJECT} l_database.item ("datasource") as l_datasource and then
attached {JSON_STRING} l_datasource.item ("driver") as l_driver and then
attached {JSON_STRING} l_datasource.item ("environment") as l_envrionment and then
attached {JSON_OBJECT} l_database.item ("environments") as l_environments and then
attached {JSON_OBJECT} l_environments.item (l_envrionment.item) as l_environment_selected and then
attached {JSON_STRING} l_environment_selected.item ("connection_string") as l_connection_string
then
create Result.make (l_driver.item, l_connection_string.unescaped_string_32)
end
end
end
new_logger_level_configuration (a_path: PATH): READABLE_STRING_32
-- Retrieve a new logger level configuration.
-- By default, level is set to `DEBUG'.
local
l_parser: JSON_PARSER
do
Result := "DEBUG"
if attached json_file_from (a_path) as json_file then
l_parser := new_json_parser (json_file)
l_parser.parse_content
if
l_parser.is_valid and then
attached {JSON_OBJECT} l_parser.parsed_json_value as jv and then
attached {JSON_OBJECT} jv.item ("logger") as l_logger and then
attached {JSON_STRING} l_logger.item ("level") as l_level
then
Result := l_level.item
end
end
end
new_database_configuration_test (a_path: PATH): detachable DATABASE_CONFIGURATION
-- Build a new database configuration for testing purposes.
local
l_parser: JSON_PARSER
do
if attached json_file_from (a_path) as json_file then
l_parser := new_json_parser (json_file)
l_parser.parse_content
if
l_parser.is_valid and then
attached {JSON_OBJECT} l_parser.parsed_json_value as jv and then
l_parser.is_parsed and then
attached {JSON_OBJECT} jv.item ("database") as l_database and then
attached {JSON_OBJECT} l_database.item ("datasource") as l_datasource and then
attached {JSON_STRING} l_datasource.item ("driver") as l_driver and then
attached {JSON_STRING} l_datasource.item ("environment") as l_envrionment and then
attached {JSON_STRING} l_datasource.item ("trusted") as l_trusted and then
attached {JSON_OBJECT} l_database.item ("environments") as l_environments and then
attached {JSON_OBJECT} l_environments.item ("test") as l_environment_selected and then
attached {JSON_STRING} l_environment_selected.item ("connection_string") as l_connection_string and then
attached {JSON_STRING} l_environment_selected.item ("name") as l_name
then
create Result.make (l_driver.item, l_connection_string.unescaped_string_8)
end
end
end
feature {NONE} -- JSON
json_file_from (a_fn: PATH): detachable STRING
do
Result := (create {JSON_FILE_READER}).read_json_from (a_fn.name.out)
end
new_json_parser (a_string: STRING): JSON_PARSER
do
create Result.make_with_string (a_string)
end
note
copyright: "2011-2015, Javier Velilla, Jocelyn Fiat, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
end

View File

@@ -0,0 +1,97 @@
note
description: "Object that represent Database configuration settings"
date: "$Date: 2015-02-09 22:29:56 +0100 (lun., 09 févr. 2015) $"
revision: "$Revision: 96596 $"
class
DATABASE_CONFIGURATION
create
make
feature {NONE} -- Initialization
make (a_driver: READABLE_STRING_32; a_connection: READABLE_STRING_32)
-- Create a database configuration setting: `driver' with `a_driver',
-- `database_string' with `a_connection'.
do
driver := a_driver
database_string := a_connection
ensure
driver_set: driver = a_driver
server_set: database_string = a_connection
end
feature -- Access
driver: READABLE_STRING_32
--Database driver.
database_string: READABLE_STRING_32
-- Database connection.
connection_string: READABLE_STRING_32
-- Connection string
do
Result := {STRING_32} "Driver={" + driver + {STRING_32} "};" + database_string
end
item (a_param: READABLE_STRING_GENERAL): detachable READABLE_STRING_32
local
s: READABLE_STRING_32
lower_s: READABLE_STRING_32
i,j: INTEGER
k: STRING_32
do
create k.make_from_string_general (a_param)
k.to_lower
s := database_string
lower_s := s.as_lower
i := lower_s.substring_index (k + {STRING_32} "=", 1)
if i > 0 then
if i = 1 or else s[i-1] = ';' then
j := s.index_of (';', i + k.count + 1)
if j = 0 then
j := s.count + 1
end
Result := s.substring (i + k.count + 1, j - 1)
end
end
end
server_name: detachable READABLE_STRING_32
do
Result := item ("Server")
end
port: INTEGER
do
if
attached item ("Port") as l_port and then
l_port.is_integer
then
Result := l_port.to_integer
end
end
database_name: detachable READABLE_STRING_32
do
Result := item ("Database")
end
user_id: detachable READABLE_STRING_32
do
Result := item ("Uid")
end
user_password: detachable READABLE_STRING_32
do
Result := item ("Pwd")
end
note
copyright: "2011-2015, Javier Velilla, Jocelyn Fiat, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
end

View File

@@ -0,0 +1,102 @@
note
description: "Object that represents Logger configuration settings"
date: "$Date: 2015-02-03 19:11:23 +0100 (mar., 03 févr. 2015) $"
revision: "$Revision: 96575 $"
class
LOGGER_CONFIGURATION
inherit
LOG_PRIORITY_CONSTANTS
rename
default_create as log_default_create
end
ANY
redefine
default_create
select
default_create
end
create
default_create
feature -- Initialization
default_create
-- Initialize a Logger Instance configuration with default values
-- backups = `4' and level = `DEBUG'.
do
backup_count := 4
level := Log_debug
location := Void
ensure then
backup_count_set: backup_count = 4
level_set: level = Log_debug
end
feature -- Access
location: detachable PATH
-- Location for logs files, if none use default logs location.
backup_count: NATURAL
-- Max number of backup files.
-- When 0, no backup files are created, and the log file is simply truncated when it becomes larger than `max_file_size'.
-- When non-zero, the value specifies the maximum number of backup files.
level: INTEGER
-- Logger level.
feature -- Element Change
set_location (a_location: detachable PATH)
-- Set `location' to `a_location'.
do
location := a_location
ensure
location_set: a_location ~ location
end
set_location_with_string (a_location: READABLE_STRING_GENERAL)
require
a_location /= Void and then not a_location.is_whitespace
do
set_location (create {PATH}.make_from_string (a_location))
end
set_backup_count (a_backup: NATURAL)
-- Set backup_count to `a_backup'.
do
backup_count := a_backup
ensure
backup_count_set: backup_count = a_backup
end
set_level (a_level: READABLE_STRING_GENERAL)
-- Set a level based on `a_level'.
do
if a_level.is_case_insensitive_equal (emerg_str) then
level := log_emergency
elseif a_level.is_case_insensitive_equal (alert_str) then
level := log_alert
elseif a_level.is_case_insensitive_equal (crit_str) then
level := log_critical
elseif a_level.is_case_insensitive_equal (error_str) then
level := log_error
elseif a_level.is_case_insensitive_equal (warn_str) then
level := log_warning
elseif a_level.is_case_insensitive_equal (notic_str) then
level := log_notice
elseif a_level.is_case_insensitive_equal (info_str) then
level := log_information
elseif a_level.is_case_insensitive_equal (debug_str) then
level := log_debug
else
level := 0
end
end
note
copyright: "2011-2015, Javier Velilla, Jocelyn Fiat, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
end