Apache-BabyConnect

 view release on metacpan or  search on metacpan

lib/Apache/BabyConnect.pm  view on Meta::CPAN

	my $s = Apache2::ServerUtil->server;
	my $handlers_list = $s-> get_handlers('PerlChildExitHandler') || [];
	return $handlers_list;
}

sub parent_pid {
	return $parent_pid;
}

sub cpids {
	my @a = split(/\n/,`ps  --ppid $parent_pid`);
	my @cpid;
	foreach (@a) {
		if ($_ =~ m/^(\d+)/) {
			push(@cpid,$1);
		}
	}
	return @cpid;
}
########################################################################################
########################################################################################

if (MP2) {
	if (Apache2::Module::loaded('Apache2::Status')) {
		Apache2::Status->menu_item(
								   'BabyConnect' => 'BabyConnet for DBI connections',
								  );
	}
}
else {
	if ($INC{'Apache.pm'}		# is Apache loaded?
			and Apache->can('module')   # really loaded?
			and Apache->module('Apache::Status')) { # and has an Apache::Status?
		Apache::Status->menu_item(
								'BabyConnect' => 'BabyConnect for DBI connections',
								);
	}
}

1;

__END__

=head1 NAME

Apache::BabyConnect - uses DBI::BabyConnect to initiate persistent database connections


=head1 SYNOPSIS

 # Configuration in perl.conf and babystartup.pl:

 PerlSetEnv BABYCONNECT /opt/DBI-BabyConnect/configuration
 PerlRequire /opt/Apache-BabyConnect/startupscripts/babystartup.pl


=head1 DESCRIPTION

This module initiates persistent database connections using DBI::BabyConnect.

This module is best understood by going through the roadmap file and the
sample programs provided with this distribution. The roadmap file is
eg/README, and the sample programs are in eg/perl.

When loading the Apache::BabyConnect module, the
module looks if the environment variable BABYCONNECT has been set to the
URI location where it can read the configuration files, and if the 
the module DBI::BabyConnect has been loaded.
The startup script instantiates DBI::BabyConnect objects with caching
and persistence enabled. Each object is connected to a data source
that is described by the database descriptor. See L<DBI::BabyConnect> for
a clarification of database descriptors.

If you create a DBI::BabyConnect object from a Perl script, then if the
descriptor is found in the DBI::BabyConnect cache, you will be using
the cached object. Otherwise, a new DBI::BabyConnect is created with that
descriptor, and it is added to the cache.

Any Perl script can use DBI::BabyConnect to create as many DBI::BabyConnect objects;
however, DBI::BabyConnect will only create a new object if not found in the cache.
Programmers do not need to keep track of what is being cached, and they
can write code as if the script is to be run from the command prompt.

It is recommended that you use a set of prefedined database descriptors
that you load at the startup of Apache. See B<babystartup.pl> script later
in this document. However, you can always use a new database descriptor
to create a DBI::BabyObject. 

Unlike the Apache::DBI module, there is no request forwarding between
the DBI module and the Apache::BabyConnect. All caching is handled by the
DBI::BabyConnect. B<Do not load the Apache::DBI module> whenever you are using
Apache::BabyConnect, otherwise you will imply a penalty on the caching
mechanism, and you will be limited to the caching mechanism of Apache::DBI.

The Apache::BabyConnect module does not have the same limitation as Apache::DBI.
DBI::BabyConnect objects are persisted on per process basis, and a user can 
access several times a database from different http servers. The Apache::BabyConnect
objects will never share the same handle. Each Apache::BabyConnect object
contains its own handle, and DBI::db handle are never cached or shared. For this
reason B<you should not load the Apache::DBI module>.

Caching of the Apache::BabyConnect is maintained within the DBI::BabyConnect
module itself, and each entry in the cache is uniquely identified by the
concatenation of: the kernel process number of the http server + the database
descriptor.

=head1 GETTING STARTED

The Apache::BabyConnect distribution comes with a startup script (L<"babystartup.pl">), a roadmap
for installation and testing in eg/README file, and a set of sample programs to assist you in
testing your installation.

 The directory startupscripts/ contains the file startupscripts/babystartup.pl
 The directory eg/ contains the roadmap file eg/README
 The directory eg/perl contains the sample scripts

Using mod_perl, modify your perl.conf as follow:

 PerlSetEnv BABYCONNECT /opt/DBI-BabyConnect/configuration
 PerlRequire /opt/Apache-BabyConnect-0.93/startupscripts/babystartup.pl



( run in 0.511 second using v1.01-cache-2.11-cpan-5a3173703d6 )