Apache-Tika-Async

 view release on metacpan or  search on metacpan

lib/Apache/Tika/Server.pm  view on Meta::CPAN

package Apache::Tika::Server;
use strict;
use Carp qw(croak);
use Moo 2;
use Apache::Tika::DocInfo;
use Data::Dumper;
use Future;
# Consider if we really want/need it, instead of simply staying
# callback-based
#use Future::AsyncAwait;

#use Filter::signatures;
use feature 'signatures';
no warnings 'experimental::signatures';

=head1 NAME

Apache::Tika::Server - Fire up/stop a Tika instance

=head1 SYNOPSIS

  use Apache::Tika::Server;

  # Launch our own Apache Tika instance
  my $tika= Apache::Tika::Server->new(
      jarfile => $tika_path,
  );
  $tika->launch;

  my $fn= shift;

  use Data::Dumper;
  my $info = $tika->get_all( $fn );
  print Dumper $info->meta($fn);
  print $info->content($fn);
  # <html><body>...
  print $info->meta->{"meta:language"};
  # en

=cut

our $VERSION = '0.11';

extends 'Apache::Tika::Async';

sub load_module {
    my( $module ) = @_;
    $module =~ s!::!/!g;
    require "$module.pm"
}

has pid => (
    is => 'rw',
    #isa => 'Int',
);

has host => (
    is => 'ro',

    # this should be 127.0.0.1 or [::1] , depending on whether we
    # are IPv4 or IPv6 ...
    default => sub { 'localhost' },
);

has port => (
    is => 'ro',
    #isa => 'Int',
    default => sub { 9998 },
);

has loglevel => (
    is => 'ro',
    #isa => 'Int',
    default => sub { 'info' },
);

has connection_class => (
    is => 'ro',
    default => 'Apache::Tika::Connection::Future',
);

has ua => (
    is => 'ro',
    #isa => 'Str',
    default => sub { load_module( $_[0]->connection_class ); $_[0]->connection_class->new },
);

sub cmdline {
    my( $self )= @_;
    $self->java,
    @{$self->java_args},
    '-jar',



( run in 2.399 seconds using v1.01-cache-2.11-cpan-d8267643d1d )