Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
OpenXPKI::Server::ContUser3Contributed Perl DocumeOpenXPKI::Server::Context(3)

Name
	OpenXPKI::Server::Context (Singleton)

Description
       This package provices a globally	accessible Context singleton that
       holds object references for the OpenXPKI	base infrastructure.
       Typically the package is	included in every module that needs to access
       basic functions such as logging or database operations.

       During startup of the system this Context package must be initialized
       once by passing in the configuration file (see create()).  After
       initialization has completed the	package	holds a	global context that
       can be accessed from anywhere within the	OpenXPKI code structure.

       Callers typically use the CTX() function	to access this context.	See
       below for usage hints.

   Basic objects (always available)
       The following Context objects are always	created	and can	be retrieved
       by calling CTX('...') once create() has been called:

       o   xml_config

       o   crypto_layer

       o   pki_realm

       o   volatile_vault

       o   log

       o   dbi_backend

       o   dbi_workflow

   Auxiliary objects (only available after explicit addition)
       In addition to the above	objects	that are guaranteed to exist after
       initialization has happened, the	following can be retrieved if they
       have been explicitly added to the Context after initialization via
       setcontext().

       o   api

       o   server

       These objects are usually created and attached by the OpenXPKI Server
       initialization procedure	in order to make the objects available
       globally.

Functions
   CTX($)
       Allows to retrieve an object reference for the specified	name.  If
       called before initialization has	happened (see create() function)
       calling CTX() yields an exception.  CTX() returns the associated	object
       in the global context.

       Usage:

	 use OpenXPKI::Server::Context;
	 my $config = OpenXPKI::Server::Context::CTX('xml_config');

       or simpler:

	 use OpenXPKI::Server::Context qw( CTX );
	 my $config = CTX('xml_config');

   CTX(@)
       It is also possible to call CTX() in array context to obtain multiple
       context entries at once:

	 my ($config, $log, $dbi) = CTX('xml_config', 'log', 'dbi_backend');

   setcontext(%)
       Allows to set additional	globally available Context information after
       the Context has been initialized	via create().

       To prevent abuse	(storing arbitrary stuff globally) the Context module
       only allows to set Context entries that are allowed explicitly.	Only
       the keys	mentioned above	are accepted, trying to	set an unsupported
       Context object yields an	exception.

       Please note that	it is NOT possible to overwrite	a Context object once
       it has been set once. setcontext() will throw an	exception if somebody
       tries to	set an object that has already been attached.

       Usage:

	 # attach this server object and the API to the	global context
	 OpenXPKI::Server::Context::setcontext({
	   server => $self,
	   api	  => OpenXPKI::Server::API->new(),
	 });

   hascontext
       Check if	the requested entry is available from the context.

   killsession
       Delete the recorded session from	the context. Used during server
       startup where we	start with a mock session and need a real one later.

perl v5.24.1			  2017-07-03	  OpenXPKI::Server::Context(3)

Name | Description | Functions

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=OpenXPKI::Server::Context&sektion=3&manpath=FreeBSD+12.0-RELEASE+and+Ports>

home | help