App::Service - Provides core methods for App-Context Services
use App::Service; # never really used, because this is a base class %named = ( # named args would go here ); $service = App::Service->new(%named);
The App::Service class is a base class for all App-Context services.
* Throws: App::Exception * Since: 0.01
This constructor is used to create all objects which are App-Context services. Customized behavior for a particular service is achieved by overriding the _init() method.
* Signature: $service = App::Service->new(%named) * Return: $service App::Service * Throws: App::Exception * Since: 0.01 Sample Usage: (never used because this is a base class, but the constructors of all services follow these rules) * If the number of arguments is odd, the first arg is the service name (otherwise, "default" is assumed) * If there are remaining arguments, they are variable/value pairs * If there are no arguments at all, the "default" name is assumed * If a "name" was supplied using any of these methods, the master config is consulted to find the config for this particular service instance (service_type/name). $service = App::Service->new(); # assumes "default" name $service = App::Service->new("srv1"); # instantiate named service $service = App::Service->new( # "default" with named args arg1 => 'value1', arg2 => 'value2', );
Returns the service type (i.e. CallDispatcher, Repository, SessionObject, etc.).
* Signature: $service_type = App::Service->service_type(); * Param: void * Return: $service_type string * Since: 0.01 $service_type = $service->service_type();
* Signature: $content = $self->content(); * Param: void * Return: $content any * Throws: App::Exception * Since: 0.01 $content = $so->content(); if (ref($content)) { App::Reference->print($content); print "\n"; } else { print $content, "\n"; }
* Signature: $content_type = $service->content_type(); * Param: void * Return: $content_type string * Throws: App::Exception * Since: 0.01 Sample Usage: $content_type = $service->content_type();
* Signature: $guts = $self->internals(); * Param: void * Return: $guts {} * Throws: App::Exception * Since: 0.01 $guts = $so->internals(); App::Reference->print($guts); print App::Reference->dump($guts), "\n";
Copy the internals of the current SessionObject to a new hash and return a reference to that hash for debugging purposes. The resulting hash reference may be printed using Data::Dumper (or App::Reference). The refe
* Signature: $perl = $service->dump(); * Param: void * Return: $perl text * Throws: App::Exception * Since: 0.01 Sample Usage: $service = $context->repository(); print $service->dump(), "\n";
* Signature: $service->print(); * Param: void * Return: void * Throws: App::Exception * Since: 0.01 Sample Usage: $service->print();
* Signature: $result = $service->substitute($target); * Signature: $result = $service->substitute($target, $values); * Param: $target HASH,string * Param: $values HASH * Return: $result string * Throws: App::Exception * Since: 0.01 Sample Usage: $welcome_message = $service->substitute("Welcome, {default-user}"); my $auto_params = { user => "{default-user}", org_id => "{org_id}", }; my $auto_values = { org_id => 1, }; $params = $service->substitute($auto_params, $auto_values);
The substitute() method scans the $target string (or hash of strings) for instances of variables (i.e. "{varname}") and makes substitutions. It makes substitutions from a hash of $values if provided or from the values of SessionObjects of the same name.
The substitute() method returns a string (or hash of strings) which is the result of the substitution.
The following methods are intended to be called by subclasses of the current class.
The _init() method is called from within the standard Service constructor. It allows subclasses of the Service to customize the behavior of the constructor by overriding the _init() method. The _init() method in this class simply calls the _init() method to allow each service instance to initialize itself.
* Signature: _init($named) * Param: $named {} [in] * Return: void * Throws: App::Exception * Since: 0.01 Sample Usage: $service->_init(\%args);
* Author: Stephen Adkins <spadkins@gmail.com> * License: This is free software. It is licensed under the same terms as Perl itself.
App, App::Context, App::Conf
App
App::Context
App::Conf
To install App::Context, copy and paste the appropriate command in to your terminal.
cpanm
cpanm App::Context
CPAN shell
perl -MCPAN -e shell install App::Context
For more information on module installation, please visit the detailed CPAN module installation guide.