-package OpenILS;
+package OpenSRF;
use strict;
use Error;
use vars qw/$VERSION $AUTOLOAD/;
$VERSION = do { my @r=(q$Revision$=~/\d+/g); sprintf "%d."."%02d"x$#r,@r };
-=head1 OpenILS
+=head1 OpenSRF
=cut
=head2 Overview
- Top level class for OpenILS perl modules.
+ Top level class for OpenSRF perl modules.
=cut
# Exception base classes
#use Exception::Class
-# ( OpenILSException => { fields => [ 'errno' ] });
+# ( OpenSRFException => { fields => [ 'errno' ] });
#push @Exception::Class::ISA, 'Error';
=head3 AUTOLOAD()
die " * Call to abstract method $method at $file, line $line";
}
-sub class {
- return scalar(caller);
-}
+sub class { return scalar(caller); }
1;
my $r_id = $conf->$app->transport_target ||
die("No remote id for $app!");
+ my $peer_handle = OpenSRF::Transport::PeerHandle->retrieve("client");
+ if( ! $peer_handle ) {
+ $peer_handle = OpenSRF::Transport::PeerHandle->retrieve("system_client");
+ }
+
my $self = bless { app_name => $app,
#client_auth => $auth,
#recv_queue => [],
session_id => $sess_id,
remote_id => $r_id,
orig_remote_id => $r_id,
- # peer_handle => OpenSRF::Transport::PeerHandle->retrieve($app),
- peer_handle => OpenSRF::Transport::PeerHandle->retrieve("client"),
+ peer_handle => $peer_handle,
session_threadTrace => 0,
} => $class;
my $self = shift;
my $class = ref($self) || $self;
+ if ( ref( $self ) and $self->state && $self->state == CONNECTED ) {
+ $logger->transport("ABC AppSession already connected", DEBUG );
+ } else {
+ $logger->transport("ABC AppSession not connected, connecting..", DEBUG );
+ }
return $self if ( ref( $self ) and $self->state && $self->state == CONNECTED );
my $app = shift;
sub finish {
my $self = shift;
+ if( ! $self->session_id ) {
+ return 0;
+ }
#$self->disconnect if ($self->endpoint == CLIENT);
for my $ses ( @_CLIENT_CACHE ) {
if ($ses->[2]->session_id eq $self->session_id) {
my $self = shift;
OpenSRF::Utils::Logger->debug(
"I'm resending the request for threadTrace ". $self->threadTrace, DEBUG);
- OpenSRF::Utils::Logger->debug($self->payload->toString,INTERNAL);
+ if($self->payload) {
+ OpenSRF::Utils::Logger->debug($self->payload->toString,INTERNAL);
+ }
return $self->session->send('REQUEST', $self->payload, $self->threadTrace );
}
$e->throw();
};
- $log->error("response is $resp");
if ( defined($resp) and $resp and $resp->class->isa('OpenSRF::DomainObject::oilsResult') ){
$log->debug( "Math server returned " . $resp->toString(1), INTERNAL );
return $self->$meth(@args);
} catch Error with {
my $e = shift;
- OpenSRF::Utils::Logger->error( $@ . $e);
+ if( $e ) {
+ OpenSRF::Utils::Logger->error( $@ . $e);
+ } else {
+ OpenSRF::Utils::Logger->error( $@ );
+ }
die $@;
};
my $self = shift;
my $part = shift;
- $logger->debug( "DomainObject:_attr_get_set: ". $self->toString, INTERNAL );
-
my $node = $self->attrNode($part);
- $logger->debug( "DomainObject:_attr_get_set " . $node->toString(), INTERNAL ) if ($node);
-
-
if (defined(my $new_value = shift)) {
if (defined $node) {
my $old_val = $node->getAttribute( "value" );
$self->payload->throw();
}
- $log->debug("Passing to OpenSRF::Application::handler()\n" . $self->payload->toString(1), INTERNAL);
+ if( $self->payload ) {
+ $log->debug("Passing to OpenSRF::Application::handler()\n" . $self->payload->toString(1), INTERNAL);
+ }
$log->debug("oilsMessage passing to Application: " . $self->type." : ".$session->remote_id, INFO );
return 1;
use OpenSRF::DOM;
use OpenSRF::EX qw/:try/;
use POSIX ":sys_wait_h";
-use OpenSRF::Utils::Config;
+use OpenSRF::Utils::Config;
use strict;
=head2 Name/Description
my $config = OpenSRF::Utils::Config->load(
config_file => "/pines/conf/opensrf.conf" );
- warn "Setting config " . $config->transport->implementation ."\n";
-
if( ! $config ) { throw OpenSRF::EX::Config "System could not load config"; }
my $tran = $config->transport->implementation;
my $self = __PACKAGE__->instance();
my $config = OpenSRF::Utils::Config->current;
- my $app = "client";
+ my $client_type = shift;
+ my $app;
+
+ if( defined($client_type) and $client_type ) {
+ $app = $client_type;
+ } else {
+ $app = "client";
+ }
OpenSRF::Transport::PeerHandle->construct( $app );
Home-brewed slimmed down jabber connection agent. Supports SSL connections
with a config file options:
- transport->server->port # the ssl port
+ transport->server->sslport # the ssl port
transport->server->ssl # is this ssl?
=cut
my $conf = OpenSRF::Utils::Config->current;
- my $host = $conf->transport->server->primary;
+ my $host;
+
my $port = $conf->transport->server->port;
my $username = $params{'username'} || return undef;
my $resource = $params{'resource'} || return undef;
my $password = $params{'password'} || return undef;
- my $jid = "$username\@$host\/$resource";
+ if( $params{host} ) {
+ $host = $params{host};
+ } else {
+ $host = $conf->transport->server->system_primary;
+ }
+ my $jid = "$username\@$host\/$resource";
my $self = bless {} => $class;
sub construct {
my( $class, $app ) = @_;
- $logger->transport("Constructing new Jabber connection for $app", INTERNAL );
+ $logger->transport("Constructing new Jabber connection for $app, my class $class", INTERNAL );
$class->peer_handle(
$class->new( $app )->initialize() );
}
my( $class, $app ) = @_;
my @keys = keys %apps_hash;
OpenSRF::Utils::Logger->transport(
- "Requesting peer for $app and we have @keys", INTERNAL );
+ "Requesting peer for $app and we have @keys", INFO );
return $apps_hash{$app};
}
my $username = $config->transport->users->$app;
my $password = $config->transport->auth->password;
my $resource = $config->env->hostname . "_$$";
+ my $server;
+
+ my $host;
+ if( $app eq "client" ) {
+ $host = $config->transport->server->client_primary;
+ } else {
+ $host = "";
+ }
OpenSRF::EX::Config->throw( "JPeer could not load all necesarry values from config" )
unless ( $username and $password and $resource );
-
my $self = __PACKAGE__->SUPER::new(
username => $username,
resource => $resource,
password => $password,
+ host => $host,
);
bless( $self, $class );
$logger->transport(
"Creating PeerHandle from UnixServer child_init_hook", INTERNAL );
OpenSRF::Transport::PeerHandle->construct( $self->app() );
- my $peer_handle = OpenSRF::System::bootstrap_client();
+ my $peer_handle = OpenSRF::System::bootstrap_client("system_client");
OpenSRF::Application->application_implementation->child_init
if (OpenSRF::Application->application_implementation->can('child_init'));
return $peer_handle;