GX::Application - Base class for applications
package MyApp; use GX::Application; MyApp->setup( engine => 'Apache2', mode => 'development' ); MyApp->start; 1;
This module provides the GX::Application class which extends the GX::Class::Singleton class.
new
Returns the application instance.
$application = $application_class->new;
$application ( GX::Application object )
$application
GX::Exception
All public methods can be called both as instance and class methods.
action
Returns the action object that represents the specified action.
$action = $application->action( $controller_name, $action_name );
$controller_name ( string )
$controller_name
The qualified or unqualified name of the controller component the action belongs to.
$action_name ( string )
$action_name
The name of the action.
$action ( GX::Action object | undef )
$action
undef
actions
Returns all action objects.
@actions = $application->actions;
@actions ( GX::Action objects )
@actions
cache
Returns the instance of the specified cache component or, if called without arguments, the default cache component.
$cache = $application->cache( $cache_name );
$cache_name ( string ) [ optional ]
$cache_name
A qualified or unqualified cache component name.
$cache ( GX::Cache object | undef )
$cache
caches
Returns all cache component instances.
@caches = $application->caches;
@caches ( GX::Cache objects )
@caches
components
Returns a list with the class names of the application's components in the order they were registered.
@components = $application->components;
@components ( strings )
@components
controller
Returns the instance of the specified controller component.
$controller = $application->controller( $controller_name );
A qualified or unqualified controller component name.
$controller ( GX::Controller object | undef )
$controller
controllers
Returns all controller component instances.
@controllers = $application->controllers;
@controllers ( GX::Controller objects )
@controllers
database
Returns the instance of the specified database component or, if called without arguments, the default database component.
$database = $application->database( $database_name );
$database_name ( string ) [ optional ]
$database_name
A qualified or unqualified database component name.
$database ( GX::Database object | undef )
$database
databases
Returns all database component instances.
@databases = $application->databases;
@databases ( GX::Database objects )
@databases
default_encoding
Returns the application-wide default encoding.
$encoding = $application->default_encoding;
$encoding ( string )
$encoding
dispatcher
Returns the dispatcher component instance.
$dispatcher = $application->dispatcher;
$dispatcher ( GX::Dispatcher object | undef )
$dispatcher
engine
Returns the engine component instance.
$engine = $application->engine;
$engine ( GX::Engine object | undef )
$engine
handlers
Returns all handler objects.
@handlers = $application->handlers;
@handlers ( GX::Callback objects )
@handlers
hook
Returns the specified hook object.
$hook = $application->hook( $hook_name );
$hook_name ( string )
$hook_name
$hook ( GX::Callback::Hook object | undef )
$hook
hooks
Returns all hooks in order of execution.
@hooks = $application->hooks;
@hooks ( GX::Callback::Hook objects )
@hooks
log
Writes the given message to the default log (or STDERR as fallback).
STDERR
$application->log( $message );
$message ( string )
$message
The message to log.
Alternative syntax:
$application->log( $log_level, @messages );
$log_level ( string | undef )
$log_level
A string identifying the log level, for example "notice" or "error". Defaults to "notice". See GX::Logger for more information.
@messages ( strings )
@messages
A list with the messages to log.
logger
Returns the instance of the specified logger component or, if called without arguments, the default logger component.
$logger = $application->logger( $logger_name );
$logger_name ( string ) [ optional ]
$logger_name
A qualified or unqualified logger component name.
$logger ( GX::Logger object | undef )
$logger
loggers
Returns all logger component instances.
@loggers = $application->loggers;
@loggers ( GX::Logger objects )
@loggers
mode
Returns the run mode of the application.
$mode = $application->mode;
$mode ( string )
$mode
A string identifying the run mode, for example "production" or "development".
model
Returns the instance of the specified model component.
$model = $application->model( $model_name );
$model_name ( string )
$model_name
A qualified or unqualified model component name.
$model ( GX::Model object | undef )
$model
models
Returns all model component instances.
@models = $application->models;
@models ( GX::Model objects )
@models
path
Returns the absolute path to the specified application directory.
$path = $application->path( $directory );
$directory ( string )
$directory
A application directory name, for example "base", "lib" or "templates".
$path ( string | undef )
$path
paths
Returns all paths as a list of directory name / path pairs.
%paths = $application->paths;
%paths ( named list of strings )
%paths
router
Returns the router component instance.
$router = $application->router;
$router ( GX::Router object )
$router
session
Returns the specified session component or, if called without arguments, the default session component.
$session = $application->session( $session_name );
$session_name ( string ) [ optional ]
$session_name
A qualified or unqualified session component name.
$session ( string | undef )
$session
The class name of the specified / default session component, or undef if the application has no such component.
sessions
Returns all session components.
@sessions = $application->sessions;
@sessions ( strings )
@sessions
A list with the class names of the application's session components.
setup
Sets up the application.
$application->setup( %options );
default_cache ( string )
default_cache
The qualified or unqualified name of the cache component to use as the default cache component.
default_database ( string )
default_database
The qualified or unqualified name of the database component to use as the default database component.
default_encoding ( string )
The name of the application-wide default encoding, for example "utf-8" or "iso-8859-1". See Encode for a list of supported encodings. Defaults to "utf-8-strict".
default_logger ( string )
default_logger
The qualified or unqualified name of the logger component to use as the default logger component.
default_session ( string )
default_session
The qualified or unqualified name of the session component to use as the default session component.
engine ( string )
The GX::Engine::* class to use as the base class for the application's engine component, for example "Apache2" or "FCGI". This option is only relevant if the application's engine component is bootstrapped.
mode ( string )
The application run mode which can be either "production" or "development". Defaults to "production". Setting this option to "development" enables the reload mechanism.
dispatcher ( string )
For internal use only.
dispatcher_base_class ( string )
dispatcher_base_class
engine_base_class ( string )
engine_base_class
router ( string )
router_base_class ( string )
router_base_class
start
Starts the application.
$application->start;
view
Returns the instance of the specified view component.
$view = $application->view( $view_name );
$view_name ( string )
$view_name
A qualified or unqualified view component name.
$view ( GX::View object | undef )
$view
views
Returns all view component instances.
@views = $application->views;
@views ( GX::View objects )
@views
add_hook
Internal method.
$application->add_hook( $hook );
$hook ( GX::Callback::Hook object )
handle_error
$application->handle_error( $context, $error );
$context ( GX::Context object )
$context
$error ( GX::Exception object | string )
$error
process
$application->process( $context );
reload
$result = $application->reload( $force );
$force ( bool ) [ optional ]
$force
$result ( bool )
$result
remove_hook
$result = $application->remove_hook( $hook ); $result = $application->remove_hook( $hook_name );
watcher
$watcher = $application->watcher;
$watcher ( GX::File::Watcher object | undef )
$watcher
Jörg A. Uzarek <uzarek@runlevelnull.de>
Copyright (c) 2009-2011 Jörg A. Uzarek.
This module is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License Version 3 as published by the Free Software Foundation.
To install GX, copy and paste the appropriate command in to your terminal.
cpanm
cpanm GX
CPAN shell
perl -MCPAN -e shell install GX
For more information on module installation, please visit the detailed CPAN module installation guide.