Apache-Wombat
view release on metacpan or search on metacpan
lib/Apache/Wombat/Connector.pm view on Meta::CPAN
# 2.4 HttpResponse fields
# 3 identify container
my $container = $self->getContainer();
# XXX: use Host header and $apr->location() to find an Application?
# 4+5 call invoke and return response
eval {
$container->invoke($request, $response);
};
if ($@) {
$self->log('error invoking container', $@, 'ERROR');
my $status =
Servlet::Http::HttpServletResponse::SC_INTERNAL_SERVER_ERROR;
$response->sendError($status);
$container->handleError($request, $response, $@);
}
eval {
$response->finishResponse();
$request->finishRequest();
};
if ($@) {
$self->log("error finishing up", $@, 'ERROR');
}
return 1;
}
=pod
=back
=head1 LIFECYCLE METHODS
=over
=item start()
Prepare for active use of this component. This method should be called
before any of the public methods of the component are utilized.
B<Throws:>
=over
=item B<Wombat::LifecycleException>
if the component has already been started
=back
=cut
sub start {
my $self = shift;
if ($self->{started}) {
my $msg = "start: connector already started";
Wombat::LifecycleException->throw($msg);
}
$self->{started} = 1;
$self->log(sprintf("%s started", $self->getName()), undef, 'INFO');
return 1;
}
=pod
=item stop()
Gracefully terminate active use of this component. Once this method
has been called, no public methods of the component should be
utilized.
B<Throws:>
=over
=item B<Wombat::LifecycleException>
if the component is not started
=back
=cut
sub stop {
my $self = shift;
unless ($self->{started}) {
my $msg = "stop: connector not started";
Wombat::LifecycleException->throw($msg);
}
undef $self->{started};
$self->debug(sprintf("%s stopped", $self->getName()));
return 1;
}
# private methods
sub debug {
my $self = shift;
my $msg = shift;
Wombat::Globals::DEBUG and
$self->log($msg, undef, 'DEBUG');
return 1;
}
sub log {
my $self = shift;
my $error = shift || '';
if ($self->{container}) {
$self->{container}->log(sprintf("ApacheConnector[%s]: %s",
$self->getName(), $error), @_);
}
return 1;
}
1;
__END__
=pod
=back
=head1 SEE ALSO
L<mod_perl>,
L<Apache>,
L<Apache::Request>,
L<Wombat::Container>,
L<Apache::Wombat::Request>,
L<Apache::Wombat::Response>,
L<Wombat::Exception>
=head1 AUTHOR
Brian Moseley, bcm@maz.org
=cut
( run in 0.475 second using v1.01-cache-2.11-cpan-39bf76dae61 )