GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
OpenXPKI::Server::Context(3) User Contributed Perl Documentation OpenXPKI::Server::Context(3)

 OpenXPKI::Server::Context (Singleton)

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.

The following Context objects are always created and can be retrieved by calling CTX('...') once create() has been called:
  • xml_config
  • crypto_layer
  • pki_realm
  • volatile_vault
  • log
  • dbi

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().
  • api2
  • server

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

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');

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

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

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,
    api2   => OpenXPKI::Server::API2->new(),
  });

Check if the requested entry is available from the context.

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

Resets the context, i.e. deletes all context objects by resetting the file scope ("static") variables to their initial state.

Used to re-initialize the server in tests.

2022-05-14 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.