18 #define AFW_IMPLEMENTATION_ID "adaptor"
23 afw_adaptor_internal_get_cache(
afw_xctx_t *xctx)
44 impl_set_instance_active(
65 adaptor_id, xctx->env->
p, xctx);
67 adaptor->adaptor_type_id, xctx->env->
p, xctx);
69 adaptor->service_id, xctx->env->
p, xctx);
95 &afw_s__AdaptiveAdaptorMetrics_, adaptor_id,
149 instance = impl_get_reference(adaptor_id, xctx);
154 &afw_s_adaptor, &afw_s_a_dash,
157 instance = impl_get_reference(adaptor_id, xctx);
185 adaptor_id, object_type_id, journal_entry, xctx);
188 query_criteria, object_type, p, xctx);
209 adaptor_id, object_type_id, journal_entry, xctx);
212 url_encoded_rql_string, object_type, p, xctx);
234 &instance->adaptor_id, xctx),
235 previous_anchor = NULL;
236 anchor && anchor->
adaptor != instance;
237 previous_anchor = anchor,
245 if (!previous_anchor) {
290 adaptor = session->adaptor;
293 cache = afw_adaptor_internal_get_cache(xctx);
295 session_cache = apr_hash_get(cache->session_cache,
296 adaptor->adaptor_id.s, adaptor->adaptor_id.len);
297 if (session_cache && session == session_cache->session) {
298 apr_hash_set(cache->session_cache,
299 adaptor->adaptor_id.s, adaptor->adaptor_id.len, NULL);
311 impl_get_adaptor_session_cache(
const afw_utf8_t *adaptor_id,
321 cache = afw_adaptor_internal_get_cache(xctx);
322 session_cache = apr_hash_get(cache->session_cache,
323 adaptor_id->s, adaptor_id->len);
326 if (!session_cache) {
330 if (session_cache->session) {
331 apr_hash_set(cache->session_cache, adaptor_id->s, adaptor_id->len,
337 if (session_cache->session && begin_transaction) {
338 for (i = 0; i < cache->transactions->nelts; i++) {
339 transaction = APR_ARRAY_IDX(cache->transactions, i,
346 if (i >= cache->transactions->nelts) {
348 session_cache->session,
350 if (new_transaction) {
353 transaction->adaptor_id =
354 &session_cache->session->adaptor->adaptor_id;
355 transaction->transaction = new_transaction;
356 APR_ARRAY_PUSH(cache->transactions,
363 if (!session_cache->session) {
365 "Unable to start session for adaptor id %" AFW_UTF8_FMT,
370 return session_cache;
380 session_cache = impl_get_adaptor_session_cache(adaptor_id,
381 begin_transaction, xctx);
384 return (session_cache) ? session_cache->session : NULL;
398 apr_hash_index_t *hi;
407 cache->transactions->elts - 1,
408 t = t0 + cache->transactions->nelts; t > t0; t--)
418 hi; hi = apr_hash_next(hi))
420 apr_hash_this(hi, &key, &klen, (
void **)&session_cache);
425 if (cache->runtime_adaptor_session) {
457 session_cache = impl_get_adaptor_session_cache(adaptor_id,
false, xctx);
458 if (!session_cache) {
461 adaptor = session_cache->session->adaptor;
464 final_result =
false;
468 session_cache->session, xctx);
471 adaptor_cache, object_type_id, &final_result, xctx);
478 if (adaptor_cache->all_object_types_immutable) {
484 else if (session_cache->object_types_ht) {
485 result = apr_hash_get(session_cache->object_types_ht,
486 object_type_id->s, object_type_id->len);
494 if (
afw_utf8_equal(object_type_id, &afw_s__AdaptiveObjectType_) ||
498 &afw_s__AdaptiveObjectType_, object_type_id, xctx);
500 adaptor,
object, p, xctx);
508 &afw_s__AdaptiveObjectType_,
510 NULL, journal_entry, NULL, p, xctx);
519 adaptor,
object, p, xctx);
525 if (result && adaptor_cache && adaptor_cache->all_object_types_immutable)
530 if (!session_cache->object_types_ht) {
531 session_cache->object_types_ht =
534 apr_hash_set(session_cache->object_types_ht,
535 object_type_id->s, object_type_id->len, result);
553 afw_adaptor_internal_register_afw_adaptor(
afw_xctx_t *xctx)
561 &afw_s_type, &afw_s_adaptor, xctx);
563 &afw_s_adaptorType, &afw_s_afw_runtime, xctx);
565 &afw_s_adaptorId, &afw_s_afw, xctx);
567 &afw_s_sourceLocation, &afw_s_a_Core_afw_adaptor, xctx);
568 afw_adaptor_internal_conf_type_create_cede_p(&afw_s_adaptor,
569 conf, &afw_s_a_Core_afw_adaptor, p, xctx);
575 afw_adaptor_internal_conf_type_create_cede_p(
586 &afw_s_adaptorId, xctx);
590 "adaptorId properties is required",
602 "adaptor id afw is automatically defined. Entry ignored.",
611 source_location->len, source_location->s,
612 adaptor_id->len, adaptor_id->s);
618 conf, source_location, p, xctx);
635 *adapted_object = object;
651 ctx->options, p, xctx);
659 afw_adaptor_internal_register_service_type(
afw_xctx_t *xctx)
664 self->inf = &impl_afw_service_type_inf;
667 if (!self->conf_type) {
671 self->title = &afw_s_a_service_type_adaptor_title;
673 &afw_s_adaptor, xctx);
683 impl_afw_service_type_related_instance_count (
722 impl_afw_service_type_start_cede_p (
733 &afw_s_adaptorType, p, xctx);
736 "parameter adaptorType missing",
744 " is not a registered adaptor type",
750 properties, p, xctx);
753 impl_set_instance_active(&adaptor->adaptor_id, adaptor, xctx);
762 impl_afw_service_type_stop (
767 impl_set_instance_active(
id, NULL, xctx);
776 impl_afw_service_type_restart_cede_p (
783 impl_afw_service_type_start_cede_p(instance, properties, p, xctx);
AFW_DEFINE(const afw_object_t *)
Adaptive Framework Core Internal.
Interface afw_interface implementation declares.
#define afw_adaptor_factory_create_adaptor_cede_p(instance, properties, p, xctx)
Call method create_adaptor_cede_p of interface afw_adaptor_factory.
#define afw_adaptor_create_adaptor_session(instance, xctx)
Call method create_adaptor_session of interface afw_adaptor.
#define afw_adaptor_destroy(instance, xctx)
Call method destroy of interface afw_adaptor.
void afw_adaptor_internal_process_object_from_adaptor(const afw_object_t **adapted_object, const afw_object_t **view, afw_adaptor_internal_object_cb_context_t *ctx, const afw_object_t *object, const afw_pool_t *p, afw_xctx_t *xctx)
#define afw_adaptor_object_type_cache_get(instance, object_type_id, final_result, xctx)
Call method get of interface afw_adaptor_object_type_cache.
#define afw_adaptor_object_type_cache_set(instance, object_type, xctx)
Call method set of interface afw_adaptor_object_type_cache.
#define afw_adaptor_session_begin_transaction(instance, xctx)
Call method begin_transaction of interface afw_adaptor_session.
#define afw_adaptor_session_destroy(instance, xctx)
Call method destroy of interface afw_adaptor_session.
#define afw_adaptor_session_get_object_type_cache_interface(instance, xctx)
Call method get_object_type_cache_interface of interface afw_adaptor_session.
#define afw_adaptor_transaction_release(instance, xctx)
Call method release of interface afw_adaptor_transaction.
#define afw_adaptor_transaction_commit(instance, xctx)
Call method commit of interface afw_adaptor_transaction.
afw_adaptor_session_release(const afw_adaptor_session_t *session, afw_xctx_t *xctx)
Release an adaptor session created by afw_adaptor_session_create().
afw_adaptor_session_create(const afw_utf8_t *adaptor_id, afw_xctx_t *xctx)
Create an adaptor session.
afw_adaptor_release(const afw_adaptor_t *instance, afw_xctx_t *xctx)
Release an adaptor accessed by afw_adaptor_get_reference().
afw_adaptor_session_get_cached(const afw_utf8_t *adaptor_id, afw_boolean_t begin_transaction, afw_xctx_t *xctx)
Get/create an active cached session for adaptor_id.
afw_adaptor_get_object_type(const afw_utf8_t *adaptor_id, const afw_utf8_t *object_type_id, const afw_object_t *journal_entry, afw_xctx_t *xctx)
Get and cache AdaptiveObjectType object.
afw_adaptor_session_commit_and_release_cache(afw_boolean_t abort, afw_xctx_t *xctx)
Commit/Abort changes and release cached sessions and objects.
afw_adaptor_query_criteria_parse_object(const afw_object_t *query_criteria, const afw_utf8_t *adaptor_id, const afw_utf8_t *object_type_id, const afw_object_t *journal_entry, const afw_pool_t *p, afw_xctx_t *xctx)
Parse query criteria object appropriate for an adaptor.
afw_adaptor_get_reference(const afw_utf8_t *adaptor_id, afw_xctx_t *xctx)
Get an adaptor and make sure it is started.
afw_adaptor_get_object(const afw_utf8_t *adaptor_id, const afw_utf8_t *object_type_id, const afw_utf8_t *object_id, const afw_object_options_t *options, const afw_query_criteria_t *criteria, const afw_object_t *journal_entry, const afw_object_t *adaptor_type_specific, const afw_pool_t *p, afw_xctx_t *xctx)
Get and cache object.
afw_adaptor_query_criteria_parse_url_encoded_rql_string(const afw_utf8_t *url_encoded_rql_string, const afw_utf8_t *adaptor_id, const afw_utf8_t *object_type_id, const afw_object_t *journal_entry, const afw_pool_t *p, afw_xctx_t *xctx)
Parse URL encoded RQL query string appropriate for an adaptor.
#define afw_object_old_get_property_as_string(object, property_name, xctx)
Get property function for data type string value.
afw_object_set_property_as_string(const afw_object_t *object, const afw_utf8_t *property_name, const afw_utf8_t *internal, afw_xctx_t *xctx)
Set property function for data type string values.
#define AFW_UTF8_FMT_ARG(A_STRING)
Convenience Macro for use with AFW_UTF8_FMT to specify arg.
#define AFW_UTF8_CONTEXTUAL_LABEL_FMT
Format string used for source location.
#define AFW_UTF8_FMT
Format string specifier used for afw_utf8_t.
apr_int64_t afw_integer_t
typedef for big signed int.
void afw_environment_register_service_type(const afw_utf8_t *service_type_id, const afw_service_type_t *service_type, afw_xctx_t *xctx)
Register a service type.
void afw_environment_register_adaptor_id(const afw_utf8_t *adaptor_id, const afw_adaptor_id_anchor_t *anchor, afw_xctx_t *xctx)
Register an adaptor id anchor.
const afw_environment_conf_type_t * afw_environment_get_conf_type(const afw_utf8_t *type, afw_xctx_t *xctx)
Get the conf_type associated with type.
const afw_adaptor_factory_t * afw_environment_get_adaptor_type(const afw_utf8_t *adaptor_type, afw_xctx_t *xctx)
Get the adaptor factory instance associated with adaptor type.
const afw_adaptor_id_anchor_t * afw_environment_get_adaptor_id(const afw_utf8_t *adaptor_id, afw_xctx_t *xctx)
Get the adaptor id anchor associated with adaptor id.
#define AFW_ENDTRY
Ends an AFW try block.
#define AFW_TRY
Begin an AFW TRY block.
#define AFW_THROW_ERROR_FZ(code, xctx, format_z,...)
Macro used to set error and 0 rv in xctx and throw it.
#define AFW_THROW_ERROR_Z(code, message_z, xctx)
Macro used to set error and 0 rv in xctx and throw it.
#define AFW_CATCH(__CODE_)
Catch a particular error that occurs in a AFW_TRY block.
#define AFW_LOCK_BEGIN(instance)
Macro to begin a lock section.
#define AFW_LOCK_END
Macro to end a lock section.
#define AFW_LOG_FZ(priority, xctx, format_z,...)
Log an message to environment's log using a printf style format and parameters.
#define afw_memory_copy(to, from)
Copy to preallocated memory of same type.
#define afw_object_add_reference(instance, xctx)
Call method add_reference of interface afw_object.
afw_object_options_composite_and_defaults
Object processing options - composite only and defaults.
afw_object_path_make(const afw_utf8_t *adaptor_id, const afw_utf8_t *object_type_id, const afw_utf8_t *object_id, const afw_pool_t *p, afw_xctx_t *xctx)
Construct an object path in a specified pool.
const afw_object_type_t * afw_object_type_internal_create(const afw_adaptor_t *adaptor, const afw_object_t *object_type_object, const afw_pool_t *p, afw_xctx_t *xctx)
Create an object type.
afw_object_view_create(const afw_object_t *instance, const afw_utf8_t *entity_path, const afw_object_options_t *options, const afw_pool_t *p, afw_xctx_t *xctx)
Create an object view of an object in specified pool.
afw_object_old_get_property_as_utf8(const afw_object_t *instance, const afw_utf8_t *property_name, const afw_pool_t *p, afw_xctx_t *xctx)
Get an object's property value as a string in specified pool.
#define afw_object_create(p, xctx)
Create an empty unmanaged object in memory.
#define afw_pool_get_apr_pool(instance)
Call method get_apr_pool of interface afw_pool.
#define afw_pool_calloc_type(instance, type, xctx)
Macro to allocate cleared memory to hold type in pool.
const afw_pool_t * afw_pool_create_multithreaded(const afw_pool_t *parent, afw_xctx_t *xctx)
Create a new multithreaded pool.
afw_query_criteria_parse_AdaptiveQueryCriteria_object(const afw_object_t *query_object, const afw_object_type_t *object_type, const afw_pool_t *p, afw_xctx_t *xctx)
Parse URI encoded query string.
afw_query_criteria_parse_url_encoded_rql_string(const afw_utf8_t *url_encoded_rql_string, const afw_object_type_t *object_type, const afw_pool_t *p, afw_xctx_t *xctx)
Parse URI encoded RQL query string.
afw_runtime_env_set_object(const afw_object_t *object, afw_boolean_t overwrite, afw_xctx_t *xctx)
Set an object pointer in the environment's runtime objects.
afw_runtime_remove_object(const afw_utf8_t *object_type_id, const afw_utf8_t *object_id, afw_xctx_t *xctx)
Remove object by object type id and object id.
afw_runtime_get_object(const afw_utf8_t *object_type_id, const afw_utf8_t *object_id, afw_xctx_t *xctx)
Get a runtime object.
afw_service_start_using_AdaptiveConf_cede_p(const afw_object_t *conf, const afw_utf8_t *source_location, const afw_pool_t *p, afw_xctx_t *xctx)
Start a service using AdaptiveConf object and cede p.
afw_service_start(const afw_utf8_t *service_id, afw_boolean_t manual_start, afw_xctx_t *xctx)
Start a service.
const afw_utf8_t * afw_utf8_concat(const afw_pool_t *p, afw_xctx_t *xctx,...)
Concatenate strings with result in specifed pool.
afw_boolean_t afw_utf8_equal(const afw_utf8_t *s1, const afw_utf8_t *s2)
Check to see if a string equals another string.
const afw_utf8_t * afw_utf8_clone(const afw_utf8_t *string, const afw_pool_t *p, afw_xctx_t *xctx)
Clone a utf-8 string into a specific pool.
#define afw_xctx_calloc_type(type, xctx)
Macro to allocate cleared memory to hold type in xctx's pool.
Interface afw_adaptor_factory public struct.
const afw_utf8_t * service_id
Associated service id or NULL.
afw_integer_t reference_count
Reference count for this instance of adaptor.
const afw_utf8_t * adaptor_type_id
Adaptor type id.
const afw_adaptor_t * adaptor
Adaptor instance or NULL.
const afw_object_t * properties
Associated properties.
const afw_utf8_t * adaptor_id
Adaptor id.
afw_adaptor_id_anchor_t * stopping
First/next stopping adaptor or NULL.
const afw_object_t * metrics_object
Metrics object.
Adaptor id and associated transaction.
Interface afw_adaptor_object_type_cache public struct.
Interface afw_adaptor public struct.
Interface afw_adaptor_session public struct.
Interface afw_adaptor_transaction public struct.
const afw_pool_t * p
Pool used to hold environment.
const afw_lock_t * adaptor_id_anchor_lock
Lock for protecting changes to adaptor id anchors.
Interface afw_object public struct.
Struct for afw_object_type_t.
Interface afw_pool public struct.
Interface afw_service_type public struct.
NFC normalized UTF-8 string.
Interface afw_xctx public struct.