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


Manual Reference Pages  -  OPENXPKI::SERVER::CONTEXT (3)

.ds Aq ’

Name



 OpenXPKI::Server::Context (Singleton)



CONTENTS

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.
Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 OPENXPKI::SERVER::CONTEXT (3) 2016-04-03

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