Adaptive Framework  0.9.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
afw_adaptor.c
Go to the documentation of this file.
1 // See the 'COPYING' file in the project root for licensing information.
2 /*
3  * Adaptive Framework Adaptor* Interface Support and Internal Functions
4  *
5  * Copyright (c) 2010-2023 Clemson University
6  *
7  */
8 
14 #include "afw_internal.h"
15 
16 
17 /* Declares and rti/inf defines for interface afw_service_type */
18 #define AFW_IMPLEMENTATION_ID "adaptor"
20 
21 
23 afw_adaptor_internal_get_cache(afw_xctx_t *xctx)
24 {
26 
27  if (!xctx->cache) {
29  cache->session_cache = apr_hash_make(afw_pool_get_apr_pool(xctx->p));
30  cache->transactions = apr_array_make(afw_pool_get_apr_pool(xctx->p), 5,
32  xctx->cache = cache;
33  }
34 
35  return xctx->cache;
36 }
37 
38 
39 /*
40  * Set instance to the active one for its id. Instance can be NULL to stop
41  * new access to this id.
42  */
43 static void
44 impl_set_instance_active(
45  const afw_utf8_t *adaptor_id,
46  const afw_adaptor_t *adaptor,
47  afw_xctx_t *xctx)
48 {
50  afw_adaptor_id_anchor_t *stopping;
51 
52  stopping = NULL;
54 
55  /*
56  * Get anchor. If not already registered, make a new one
57  * in env->p and register it.
58  */
59  anchor = (afw_adaptor_id_anchor_t *)
60  afw_environment_get_adaptor_id(adaptor_id, xctx);
61  if (!anchor) {
62  anchor = afw_pool_calloc_type(
63  xctx->env->p, afw_adaptor_id_anchor_t, xctx);
64  anchor->adaptor_id = afw_utf8_clone(
65  adaptor_id, xctx->env->p, xctx);
67  adaptor->adaptor_type_id, xctx->env->p, xctx);
68  anchor->service_id = afw_utf8_clone(
69  adaptor->service_id, xctx->env->p, xctx);
71  anchor->adaptor_id, anchor, xctx);
72  }
73 
74  /*
75  * If there is already an active instance, make a copy of active
76  * anchor in the active instance's pool so it will go away when
77  * instance is released put it in stopping chain.
78  */
79  else if (anchor->adaptor) {
80  stopping = afw_pool_calloc_type(anchor->adaptor->p,
82  afw_memory_copy(stopping, anchor);
83  anchor->stopping = stopping;
84  }
85 
86  /* Claim anchor. Set/Remove _AdaptiveAdaptorMetrics_ as appropriate. */
87  anchor->adaptor = adaptor;
88  if (adaptor) {
89  anchor->properties = adaptor->properties;
90  afw_runtime_env_set_object(adaptor->impl->metrics_object, true, xctx);
91  anchor->reference_count = 1;
92  }
93  else {
95  &afw_s__AdaptiveAdaptorMetrics_, adaptor_id,
96  xctx);
97  anchor->properties = NULL;
98  anchor->reference_count = 0;
99  }
100 
101  }
102 
103  AFW_LOCK_END;
104 
105  /* If there was a previously active adaptor, release it. */
106  if (stopping) {
107  afw_adaptor_release(stopping->adaptor, xctx);
108  }
109 }
110 
111 
112 
113 static const afw_adaptor_t *
114 impl_get_reference(
115  const afw_utf8_t *adaptor_id,
116  afw_xctx_t *xctx)
117 {
118  afw_adaptor_id_anchor_t *anchor;
119  const afw_adaptor_t *instance;
120 
122 
123  instance = NULL;
124  anchor = (afw_adaptor_id_anchor_t *)
125  afw_environment_get_adaptor_id(adaptor_id, xctx);
126  if (anchor) {
127  instance = anchor->adaptor;
128  if (instance) {
129  anchor->reference_count++;
130  }
131  }
132  }
133 
134  AFW_LOCK_END;
135 
136  return instance;
137 }
138 
139 
140 
141 /* Get an adaptor and make sure it is started. */
142 AFW_DEFINE(const afw_adaptor_t *)
144  const afw_utf8_t *adaptor_id, afw_xctx_t *xctx)
145 {
146  const afw_adaptor_t *instance;
147  const afw_utf8_t *service_id;
148 
149  instance = impl_get_reference(adaptor_id, xctx);
150 
151  /* If adaptor is not registered, try starting it. */
152  if (!instance) {
153  service_id = afw_utf8_concat(xctx->p, xctx,
154  &afw_s_adaptor, &afw_s_a_dash,
155  adaptor_id, NULL);
156  afw_service_start(service_id, false, xctx);
157  instance = impl_get_reference(adaptor_id, xctx);
158  if (!instance) {
159  AFW_THROW_ERROR_FZ(general, xctx,
160  "Adaptor %" AFW_UTF8_FMT
161  " is not available",
162  AFW_UTF8_FMT_ARG(adaptor_id));
163  }
164  }
165 
166  return instance;
167 }
168 
169 
170 
171 /* Parse query criteria object appropriate for an adaptor. */
174  const afw_object_t *query_criteria,
175  const afw_utf8_t *adaptor_id,
176  const afw_utf8_t *object_type_id,
177  const afw_object_t *journal_entry,
178  const afw_pool_t *p,
179  afw_xctx_t *xctx)
180 {
181  const afw_object_type_t *object_type;
182  const afw_query_criteria_t *result;
183 
184  object_type = afw_adaptor_get_object_type(
185  adaptor_id, object_type_id, journal_entry, xctx);
186 
188  query_criteria, object_type, p, xctx);
189 
190  return result;
191 }
192 
193 
194 
195 /* Parse URL encoded RQL query string appropriate for an adaptor. */
198  const afw_utf8_t *url_encoded_rql_string,
199  const afw_utf8_t *adaptor_id,
200  const afw_utf8_t *object_type_id,
201  const afw_object_t *journal_entry,
202  const afw_pool_t *p,
203  afw_xctx_t *xctx)
204 {
205  const afw_object_type_t *object_type;
206  const afw_query_criteria_t *result;
207 
208  object_type = afw_adaptor_get_object_type(
209  adaptor_id, object_type_id, journal_entry, xctx);
210 
212  url_encoded_rql_string, object_type, p, xctx);
213 
214  return result;
215 }
216 
217 
218 
219 /* Release an adaptor accessed by afw_adaptor_get_reference(). */
220 AFW_DEFINE(void)
222 {
223  afw_adaptor_id_anchor_t *anchor;
224  afw_adaptor_id_anchor_t *previous_anchor;
225  afw_boolean_t destroy;
226 
227  destroy = false;
228  AFW_LOCK_BEGIN(xctx->env->adaptor_id_anchor_lock) {
229 
230  /* Find anchor for this adaptor instance. */
231  for (
232  anchor = (afw_adaptor_id_anchor_t *)
234  &instance->adaptor_id, xctx),
235  previous_anchor = NULL;
236  anchor && anchor->adaptor != instance;
237  previous_anchor = anchor,
238  anchor = anchor->stopping);
239 
240  if (anchor) {
241  anchor->reference_count--;
242  if (anchor->reference_count <= 0) {
243  destroy = true;
244  anchor->reference_count = 0;
245  if (!previous_anchor) {
246  anchor->adaptor = NULL;
247  }
248  else {
249  previous_anchor->stopping = anchor->stopping;
250  }
251  }
252  }
253  }
254 
255  AFW_LOCK_END;
256 
257  if (destroy) {
258  afw_adaptor_destroy(instance, xctx);
259  }
260 }
261 
262 
263 /* Create an adaptor session. */
266  const afw_utf8_t *adaptor_id, afw_xctx_t *xctx)
267 {
268  const afw_adaptor_t *adaptor;
269  const afw_adaptor_session_t *session;
270 
271  adaptor = afw_adaptor_get_reference(adaptor_id, xctx);
272 
274  adaptor, xctx);
275 
276  return session;
277 }
278 
279 
280 /* Release an adaptor session created by afw_adaptor_session_create(). */
281 AFW_DEFINE(void)
283  const afw_adaptor_session_t *session,
284  afw_xctx_t *xctx)
285 {
286  const afw_adaptor_t *adaptor;
287  const afw_adaptor_internal_cache_t *cache;
289 
290  adaptor = session->adaptor;
291 
292  /* If session in cache, remove it. */
293  cache = afw_adaptor_internal_get_cache(xctx);
294  if (cache) {
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);
300  }
301  }
302 
303  /* Destroy session and release adaptor. */
304  afw_adaptor_session_destroy(session, xctx);
305  afw_adaptor_release(adaptor, xctx);
306 }
307 
308 
309 /* Get an active cached session for adaptor_id. */
311 impl_get_adaptor_session_cache(const afw_utf8_t *adaptor_id,
312  afw_boolean_t begin_transaction, afw_xctx_t *xctx)
313 {
315  const afw_adaptor_internal_cache_t *cache;
317  const afw_adaptor_transaction_t *new_transaction;
318  int i;
319 
320  /* Get cached session. */
321  cache = afw_adaptor_internal_get_cache(xctx);
322  session_cache = apr_hash_get(cache->session_cache,
323  adaptor_id->s, adaptor_id->len);
324 
325  /* If there is not already one, create one. */
326  if (!session_cache) {
327  session_cache = afw_xctx_calloc_type(
329  session_cache->session = afw_adaptor_session_create(adaptor_id, xctx);
330  if (session_cache->session) {
331  apr_hash_set(cache->session_cache, adaptor_id->s, adaptor_id->len,
332  session_cache);
333  }
334  }
335 
336  /* If session and begin_transaction, make sure transactions is started. */
337  if (session_cache->session && begin_transaction) {
338  for (i = 0; i < cache->transactions->nelts; i++) {
339  transaction = APR_ARRAY_IDX(cache->transactions, i,
341  if (afw_utf8_equal(transaction->adaptor_id, adaptor_id))
342  {
343  break;
344  }
345  }
346  if (i >= cache->transactions->nelts) {
347  new_transaction = afw_adaptor_session_begin_transaction(
348  session_cache->session,
349  xctx);
350  if (new_transaction) {
351  transaction = afw_xctx_calloc_type(
353  transaction->adaptor_id =
354  &session_cache->session->adaptor->adaptor_id;
355  transaction->transaction = new_transaction;
356  APR_ARRAY_PUSH(cache->transactions,
357  const afw_adaptor_internal_transaction_t *) = transaction;
358  }
359  }
360  }
361 
362  /* Error if no valid adaptor session. */
363  if (!session_cache->session) {
364  AFW_THROW_ERROR_FZ(general, xctx,
365  "Unable to start session for adaptor id %" AFW_UTF8_FMT,
366  AFW_UTF8_FMT_ARG(adaptor_id));
367  }
368 
369  /* Return result. */
370  return session_cache;
371 }
372 
373 /* Get an active cached session for adaptor_id. */
376  afw_boolean_t begin_transaction, afw_xctx_t *xctx)
377 {
379 
380  session_cache = impl_get_adaptor_session_cache(adaptor_id,
381  begin_transaction, xctx);
382 
383  /* Return result. */
384  return (session_cache) ? session_cache->session : NULL;
385 }
386 
387 
388 
389 /* Commit changes and release cached sessions and objects. */
390 AFW_DEFINE(void)
392  afw_xctx_t *xctx)
393 {
394  const afw_adaptor_internal_cache_t *cache;
398  apr_hash_index_t *hi;
399  const void * key;
400  apr_ssize_t klen;
401 
402  cache = xctx->cache;
403  if (!cache) return;
404 
405  /* Call commit for all active transaction in reverse order of begin. */
406  for (t0 = (const afw_adaptor_internal_transaction_t **)
407  cache->transactions->elts - 1,
408  t = t0 + cache->transactions->nelts; t > t0; t--)
409  {
410  if (!abort) {
411  afw_adaptor_transaction_commit((*t)->transaction, xctx);
412  }
413  afw_adaptor_transaction_release((*t)->transaction, xctx);
414  }
415 
416  /* Release all active sessions in no particular order. */
417  for (hi = apr_hash_first(afw_pool_get_apr_pool(xctx->p), cache->session_cache);
418  hi; hi = apr_hash_next(hi))
419  {
420  apr_hash_this(hi, &key, &klen, (void **)&session_cache);
421  afw_adaptor_session_release(session_cache->session, xctx);
422  }
423 
424  /* If there is a runtime adaptor session, release it. */
425  if (cache->runtime_adaptor_session) {
426  afw_adaptor_session_release(cache->runtime_adaptor_session, xctx);
427  }
428 
429  /* Clear pointer in xctx to cache struct. */
430  xctx->cache = NULL;
431 }
432 
433 
434 
435 /* Get and cache _AdaptiveObjectType_ object. */
438  const afw_utf8_t *adaptor_id,
439  const afw_utf8_t *object_type_id,
440  const afw_object_t *journal_entry,
441  afw_xctx_t *xctx)
442 {
443  const afw_object_type_t *result;
444  const afw_object_t *object;
445  const afw_adaptor_object_type_cache_t *adaptor_cache;
447  const afw_adaptor_t *adaptor;
448  const afw_pool_t *p;
449  afw_boolean_t final_result;
450 
453  /* Pool starts out as xctx's p, but may change to adaptor's p. */
454  p = xctx->p;
455 
456  /* Get adaptor_id's session cache, adaptor, and impl. */
457  session_cache = impl_get_adaptor_session_cache(adaptor_id, false, xctx);
458  if (!session_cache) {
459  return NULL;
460  }
461  adaptor = session_cache->session->adaptor;
462 
463  result = NULL;
464  final_result = false;
465 
466  /* Return object type if already cached for life of adaptor. */
468  session_cache->session, xctx);
469  if (adaptor_cache) {
471  adaptor_cache, object_type_id, &final_result, xctx);
472  if (result) {
473  return result;
474  }
475  if (final_result) {
476  return NULL;
477  }
478  if (adaptor_cache->all_object_types_immutable) {
479  p = adaptor->p;
480  }
481  }
482 
483  /* Return object type if already cached for session. */
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);
487  if (result) {
488  return result;
489  }
490  }
491 
492  /* Get special runtime object types to prevent loop. */
493  result = NULL;
494  if (afw_utf8_equal(object_type_id, &afw_s__AdaptiveObjectType_) ||
495  afw_utf8_equal(object_type_id, &afw_s__AdaptiveValueMeta_))
496  {
497  object = afw_runtime_get_object(
498  &afw_s__AdaptiveObjectType_, object_type_id, xctx);
500  adaptor, object, p, xctx);
501  }
502 
503  /* For other object types, get object type object via adaptor. */
504  else {
505  object = NULL;
506  AFW_TRY {
507  object = afw_adaptor_get_object(adaptor_id,
508  &afw_s__AdaptiveObjectType_,
510  NULL, journal_entry, NULL, p, xctx);
511  }
512  AFW_CATCH(not_found) {
513  /* Ok, object returned will be NULL. */
514  }
515  AFW_ENDTRY;
516 
517  if (object) {
519  adaptor, object, p, xctx);
520  }
521  }
522 
523  /* If result, cache in adaptor or session. */
524  if (result) {
525  if (result && adaptor_cache && adaptor_cache->all_object_types_immutable)
526  {
527  afw_adaptor_object_type_cache_set(adaptor_cache, result, xctx);
528  }
529  else {
530  if (!session_cache->object_types_ht) {
531  session_cache->object_types_ht =
532  apr_hash_make(afw_pool_get_apr_pool(p));
533  }
534  apr_hash_set(session_cache->object_types_ht,
535  object_type_id->s, object_type_id->len, result);
536  }
537  }
538 
539  /* Return result. */
540  return result;
541 }
542 
543 
544 
545 /*
546  * {
547  * type : "adaptor",
548  * adaptorType : "afw_runtime",
549  * adaptorId : "afw"
550  * }
551  */
552 void
553 afw_adaptor_internal_register_afw_adaptor(afw_xctx_t *xctx)
554 {
555  const afw_object_t *conf;
556  const afw_pool_t *p;
557 
558  p = afw_pool_create_multithreaded(xctx->env->p, xctx);
559  conf = afw_object_create(p, 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);
570 }
571 
572 
573 /* Configuration handler for entry type "adaptor". */
574 void
575 afw_adaptor_internal_conf_type_create_cede_p(
576  const afw_utf8_t *type,
577  const afw_object_t *conf,
578  const afw_utf8_t *source_location,
579  const afw_pool_t *p, afw_xctx_t *xctx)
580 {
581  const afw_adaptor_id_anchor_t *anchor;
582  const afw_utf8_t *adaptor_id;
583 
584  /* Get adaptor_id. */
585  adaptor_id = afw_object_old_get_property_as_string(conf,
586  &afw_s_adaptorId, xctx);
587  if (!adaptor_id) {
588  AFW_THROW_ERROR_FZ(general, xctx,
590  "adaptorId properties is required",
591  AFW_UTF8_FMT_ARG(source_location));
592  }
593 
594  /* See if adaptor id already used. */
595  anchor = afw_environment_get_adaptor_id(adaptor_id, xctx);
596  if (anchor) {
597 
598  /* If adaptor id is afw, handle special. */
599  if (afw_utf8_equal(adaptor_id, &afw_s_afw)) {
600  AFW_LOG_FZ(warning, xctx,
602  "adaptor id afw is automatically defined. Entry ignored.",
603  AFW_UTF8_FMT_ARG(source_location));
604  return;
605  }
606 
607  /* Any other adaptor id already registered is an error. */
608  else {
609  AFW_THROW_ERROR_FZ(general, xctx,
610  "%" AFW_UTF8_FMT " adaptor %" AFW_UTF8_FMT " is already running",
611  source_location->len, source_location->s,
612  adaptor_id->len, adaptor_id->s);
613  }
614  }
615 
616  /* Start adaptor. */
618  conf, source_location, p, xctx);
619 }
620 
621 
622 
623 /* Adapt and apply view if requested and object is not NULL. */
624 void
626  const afw_object_t * *adapted_object,
627  const afw_object_t * *view,
629  const afw_object_t *object,
630  const afw_pool_t *p,
631  afw_xctx_t *xctx)
632 {
633  const afw_utf8_t *entity_path;
634 
635  *adapted_object = object;
636  afw_object_add_reference(object, xctx);
637  entity_path = afw_object_path_make(
638  ctx->adaptor_id,
639  ctx->object_type_id,
640  (ctx->object_id)
641  ? ctx->object_id
642  : afw_object_meta_get_object_id(object, xctx),
643  p,
644  xctx);
645 
649  /* Make view based on options. */
650  *view = afw_object_view_create(*adapted_object, entity_path,
651  ctx->options, p, xctx);
652 
654 }
655 
656 
657 
658 void
659 afw_adaptor_internal_register_service_type(afw_xctx_t *xctx)
660 {
661  afw_service_type_t *self;
662 
664  self->inf = &impl_afw_service_type_inf;
665  afw_memory_copy(&self->service_type_id, &afw_s_adaptor);
666  self->conf_type = afw_environment_get_conf_type(&afw_s_adaptor, xctx);
667  if (!self->conf_type) {
668  AFW_THROW_ERROR_Z(general, "conf_type must already be registered",
669  xctx);
670  }
671  self->title = &afw_s_a_service_type_adaptor_title;
672  self->conf_type_object = afw_runtime_get_object(&afw_s__AdaptiveConfType_,
673  &afw_s_adaptor, xctx);
674  afw_environment_register_service_type(&afw_s_adaptor, self, xctx);
675 }
676 
677 
678 
679 /*
680  * Implementation of method related_instance_count of interface afw_service_type.
681  */
683 impl_afw_service_type_related_instance_count (
684  const afw_service_type_t * instance,
685  const afw_utf8_t * id,
686  afw_xctx_t *xctx)
687 {
688  afw_adaptor_id_anchor_t *anchor;
689  afw_adaptor_id_anchor_t *stopping;
690  afw_integer_t result = 0;
691 
693 
694  anchor = (afw_adaptor_id_anchor_t *)
696  if (anchor) {
697  for (stopping = anchor->stopping;
698  stopping;
699  stopping = stopping->stopping)
700  {
701  result++;
702  }
703  if (anchor->adaptor) {
704  result++;
705  }
706  else {
707  result = -result;
708  }
709  }
710  }
711  AFW_LOCK_END;
712 
713  return result;
714 }
715 
716 
717 
718 /*
719  * Implementation of method start_cede_p of interface afw_service_type.
720  */
721 void
722 impl_afw_service_type_start_cede_p (
723  const afw_service_type_t * instance,
724  const afw_object_t * properties,
725  const afw_pool_t * p,
726  afw_xctx_t *xctx)
727 {
728  const afw_adaptor_factory_t *factory;
729  const afw_adaptor_t *adaptor;
730  const afw_utf8_t *adaptor_type;
731 
732  adaptor_type = afw_object_old_get_property_as_utf8(properties,
733  &afw_s_adaptorType, p, xctx);
734  if (!adaptor_type) {
735  AFW_THROW_ERROR_Z(general,
736  "parameter adaptorType missing",
737  xctx);
738  }
739 
740  factory = afw_environment_get_adaptor_type(adaptor_type, xctx);
741  if (!factory) {
742  AFW_THROW_ERROR_FZ(general, xctx,
743  "adaptorType %" AFW_UTF8_FMT
744  " is not a registered adaptor type",
745  AFW_UTF8_FMT_ARG(adaptor_type));
746  }
747 
748  /* Create adaptor. */
750  properties, p, xctx);
751 
752  /* Make this adaptor the active one. */
753  impl_set_instance_active(&adaptor->adaptor_id, adaptor, xctx);
754 }
755 
756 
757 
758 /*
759  * Implementation of method stop of interface afw_service_type.
760  */
761 void
762 impl_afw_service_type_stop (
763  const afw_service_type_t * instance,
764  const afw_utf8_t * id,
765  afw_xctx_t *xctx)
766 {
767  impl_set_instance_active(id, NULL, xctx);
768 }
769 
770 
771 
772 /*
773  * Implementation of method restart_cede_p of interface afw_service_type.
774  */
775 void
776 impl_afw_service_type_restart_cede_p (
777  const afw_service_type_t * instance,
778  const afw_object_t * properties,
779  const afw_pool_t * p,
780  afw_xctx_t *xctx)
781 {
782  /* Count on already running. Start will restart if necessary. */
783  impl_afw_service_type_start_cede_p(instance, properties, p, xctx);
784 }
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)
Definition: afw_adaptor.c:625
#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().
Definition: afw_adaptor.c:282
afw_adaptor_session_create(const afw_utf8_t *adaptor_id, afw_xctx_t *xctx)
Create an adaptor session.
Definition: afw_adaptor.c:265
afw_adaptor_release(const afw_adaptor_t *instance, afw_xctx_t *xctx)
Release an adaptor accessed by afw_adaptor_get_reference().
Definition: afw_adaptor.c:221
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.
Definition: afw_adaptor.c:375
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.
Definition: afw_adaptor.c:437
afw_adaptor_session_commit_and_release_cache(afw_boolean_t abort, afw_xctx_t *xctx)
Commit/Abort changes and release cached sessions and objects.
Definition: afw_adaptor.c:391
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.
Definition: afw_adaptor.c:173
afw_adaptor_get_reference(const afw_utf8_t *adaptor_id, afw_xctx_t *xctx)
Get an adaptor and make sure it is started.
Definition: afw_adaptor.c:143
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.
Definition: afw_adaptor.c:197
#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.
Definition: afw_common.h:605
#define AFW_UTF8_CONTEXTUAL_LABEL_FMT
Format string used for source location.
Definition: afw_common.h:595
_Bool afw_boolean_t
Definition: afw_common.h:373
#define AFW_UTF8_FMT
Format string specifier used for afw_utf8_t.
Definition: afw_common.h:588
apr_int64_t afw_integer_t
typedef for big signed int.
Definition: afw_common.h:321
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.
Definition: afw_error.h:727
#define AFW_TRY
Begin an AFW TRY block.
Definition: afw_error.h:634
#define AFW_THROW_ERROR_FZ(code, xctx, format_z,...)
Macro used to set error and 0 rv in xctx and throw it.
Definition: afw_error.h:319
#define AFW_THROW_ERROR_Z(code, message_z, xctx)
Macro used to set error and 0 rv in xctx and throw it.
Definition: afw_error.h:283
#define AFW_CATCH(__CODE_)
Catch a particular error that occurs in a AFW_TRY block.
Definition: afw_error.h:668
#define AFW_LOCK_BEGIN(instance)
Macro to begin a lock section.
Definition: afw_lock.h:191
#define AFW_LOCK_END
Macro to end a lock section.
Definition: afw_lock.h:202
#define AFW_LOG_FZ(priority, xctx, format_z,...)
Log an message to environment's log using a printf style format and parameters.
Definition: afw_log.h:192
#define afw_memory_copy(to, from)
Copy to preallocated memory of same type.
Definition: afw_memory.h:39
#define afw_object_add_reference(instance, xctx)
Call method add_reference of interface afw_object.
afw_object_meta_get_object_id(const afw_object_t *instance, afw_xctx_t *xctx)
Get entity object's object id.
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.
Definition: afw_object.c:531
#define afw_object_create(p, xctx)
Create an empty unmanaged object in memory.
Definition: afw_object.h:948
#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.
Definition: afw_pool.h:167
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.
Definition: afw_runtime.c:210
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.
Definition: afw_runtime.c:262
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.
Definition: afw_runtime.c:853
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.
Definition: afw_service.c:1147
afw_service_start(const afw_utf8_t *service_id, afw_boolean_t manual_start, afw_xctx_t *xctx)
Start a service.
Definition: afw_service.c:1201
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.
Definition: afw_utf8.h:347
#define afw_xctx_calloc_type(type, xctx)
Macro to allocate cleared memory to hold type in xctx's pool.
Definition: afw_xctx.h:199
Interface afw_adaptor_factory public struct.
const afw_utf8_t * service_id
Associated service id or NULL.
Definition: afw_adaptor.h:72
afw_integer_t reference_count
Reference count for this instance of adaptor.
Definition: afw_adaptor.h:75
const afw_utf8_t * adaptor_type_id
Adaptor type id.
Definition: afw_adaptor.h:63
const afw_adaptor_t * adaptor
Adaptor instance or NULL.
Definition: afw_adaptor.h:66
const afw_object_t * properties
Associated properties.
Definition: afw_adaptor.h:69
const afw_utf8_t * adaptor_id
Adaptor id.
Definition: afw_adaptor.h:60
afw_adaptor_id_anchor_t * stopping
First/next stopping adaptor or NULL.
Definition: afw_adaptor.h:78
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.
Definition: afw_common.h:1386
const afw_lock_t * adaptor_id_anchor_lock
Lock for protecting changes to adaptor id anchors.
Definition: afw_common.h:1479
Interface afw_object public struct.
Struct for afw_object_type_t.
Interface afw_pool public struct.
Parsed query criteria.
Interface afw_service_type public struct.
NFC normalized UTF-8 string.
Definition: afw_common.h:545
Interface afw_xctx public struct.