mach        2003/12/10 14:48:53

  Modified:    lib/Apache/AxKit Tag: axkit-pipeline-2 PipeCtrl.pm
  Log:
  getting rid of Pipeline::Tail, fixing trace
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.1.2.5   +53 -46    xml-axkit/lib/Apache/AxKit/Attic/PipeCtrl.pm
  
  Index: PipeCtrl.pm
  ===================================================================
  RCS file: /home/cvs/xml-axkit/lib/Apache/AxKit/Attic/PipeCtrl.pm,v
  retrieving revision 1.1.2.4
  retrieving revision 1.1.2.5
  diff -u -r1.1.2.4 -r1.1.2.5
  --- PipeCtrl.pm       28 Oct 2003 00:10:09 -0000      1.1.2.4
  +++ PipeCtrl.pm       10 Dec 2003 22:48:53 -0000      1.1.2.5
  @@ -4,7 +4,6 @@
   use Apache::AxKit::Pipeline::Trace;
   use Apache::AxKit::Pipeline::Language;
   use Apache::AxKit::Pipeline::Head;
  -use Apache::AxKit::Pipeline::Tail;
   use Apache::AxKit::Pipeline::Cache;
   use Apache::AxKit::Pipeline::DoStyles;
   use Apache::AxKit::Pipeline::Transformer;
  @@ -77,50 +76,53 @@
                my @passthru = splice( @styles, 0, $p - 1 );
                @styles = @passthru;
        }
  -             
  -     # Add a pipeline head at the top of the pipeline.
  -     # Allows for cleaner interface into provider.
  -
  +     
  +     my $i = 1;
  +     
  +     # Set pipeline stage id.
  +     # Do this before trace, so trace picks up upstream stage id.
  +     
  +     foreach (@styles) {
  +             $_->{'stage'} = $i++;
  +     }
  +     
  +     # Cleaner interface between provider and pipeline.
  +     # Ideal would be to extend providers, or have a ProviderPlus
  +     # which inherits from Pipeline.
  +     
        unshift(@styles, {
  -             module => 'Apache::AxKit::Pipeline::Head',
  -             href   => undef,
  +             module  => 'Apache::AxKit::Pipeline::Head',
  +             href    => undef,
        });
  -     
  +             
        if( $AxKit::Cfg->TraceIntermediate ) {
                
                # Add a trace module between each style.
  +             # No stage id, will use upstream() id.
                                
                @styles = map { 
  -                     ( {     module  => 'Apache::AxKit::Pipeline::Trace',
  -                                     href    => undef }, 
  -                       $_ 
  -                     ) }   @styles;
  +                     ( $_, 
  +                             {       module  => 
'Apache::AxKit::Pipeline::Trace',
  +                                     href    => undef },                     
  
  +                     ) }   @styles;                  
        }
   
  -     # Tail adds and late added styles into the pipeline.
  -     # Note: This currently breaks any sax passthru nature
  -     # and so needs to be worked on a bit in that way.
  -     # or an alternative pipeline creator class could be built.
  -     
  -     push(@styles, {
  -             module  => 'Apache::AxKit::Pipeline::Tail',
  -             href    => undef,
  -     });
        
        my $pipeline = $provider;
  -             
  -     foreach my $style ( @styles ) {
  -             $pipeline = $self->create_processor($r, $style 
)->upstream($pipeline);          
  +     
  +     foreach ( @styles ) {
  +             $pipeline = $self->create_processor($r, $_ )->upstream( 
$pipeline );            
                if($pipeline->enable_dynamic_styles()) {
                        $pipeline = 
Apache::AxKit::Pipeline::DoStyles->new()->upstream( $pipeline );
                } 
        }
  +
                                
        # always ensure pipeline is cache enabled.
        # so add one on the end, unless either there already is a cache 
somewhere in the pipeline
        # or the cache is disabled.
        
  -     if($pipeline->cache_required() && !$AxKit::Cfg->NoCache()) {
  +     if( !$AxKit::Cfg->NoCache() && $pipeline->cache_required()) {
                 AxKit::Debug(4, "PipeCtrl: adding final cache");
                $pipeline = 
Apache::AxKit::Pipeline::Cache->new()->upstream($pipeline);
        }
  @@ -137,13 +139,11 @@
                }
        }
        
  -     # initialise the pipeline. (very important).
  -
  -     $pipeline->set_stage();
        
        AxKit::Debug(4, "PipeCtrl: Running Initialisation phase");
  -     $pipeline->init($r);
  -             
  +
  +     $pipeline->pipeline_init($r);   # allow things like XSP to build code 
before cache runs.
  +     
        return $pipeline;
   }
   
  @@ -163,11 +163,16 @@
        my @styles = @{$self->{'pre_styles'}};
        $self->{'pre_styles'}   = [];
   
  +     my $i = 1;
  +     foreach (@styles) {
  +             $_->{'stage'} = $i++;
  +     }
  +
        unshift(@styles, {
  -             module => 'Apache::AxKit::Pipeline::Head',
  -             href   => undef,
  +             module  => 'Apache::AxKit::Pipeline::Head',
  +             href    => undef,
        });
  -     
  +
        my $pipeline = $provider;
                
        foreach my $style ( @styles ) {
  @@ -178,9 +183,8 @@
                        
        }
        
  -     $pipeline->set_stage();
        AxKit::Debug(4, "PipeCtrl: Running Initialisation phase");      
  -     $pipeline->init($r);
  +     $pipeline->pipeline_init($r);
        
        return $pipeline;
   }
  @@ -192,16 +196,18 @@
        my @styles = @{$self->{'post_styles'}};
        $self->{'post_styles'}  = [];
   
  -     unshift(@styles, {
  -             module => 'Apache::AxKit::Pipeline::Head',
  -             href   => undef,
  -     });
   
  -     push(@styles, {
  -             module  => 'Apache::AxKit::Pipeline::Tail',
  +     my $i = 1;
  +     foreach (@styles) {
  +             $_->{'stage'} = $i++;
  +     }
  +
  +     unshift(@styles, {
  +             module  => 'Apache::AxKit::Pipeline::Head',
                href    => undef,
        });
  -     
  +
  +
        my $pipeline = $provider;
                
        foreach my $style ( @styles ) {
  @@ -213,9 +219,8 @@
        
        }
   
  -     $pipeline->set_stage();
        AxKit::Debug(4, "PipeCtrl: Running Initialisation phase");      
  -     $pipeline->init($r);
  +     $pipeline->pipeline_init($r);
        
        return $pipeline;
   
  @@ -232,12 +237,14 @@
        
        return UNIVERSAL::isa( $processor, 'Apache::AxKit::Language') ? 
                Apache::AxKit::Pipeline::Language->new(
  -                     href            => $style->{href},
  +                     href            => $style->{'href'},
                        module          => $processor,
  +                     stage           => $style->{'stage'},
                        
                ) : 
                $processor->new(
  -                     href            => $style->{href},
  +                     stage           => $style->{'stage'},
  +                     href            => $style->{'href'},
                );      
                                        
   }    
  
  
  

Reply via email to