SlideShare ist ein Scribd-Unternehmen logo
1 von 19
Wie der CosmoShop mit generischen
Hookpoints in Perl-Objekten „umspringt“
How the CosmoShop handles
generic Hook Points in Perl Objects
Product
Development
• new features
• security updates
• most recent third party packages
• adapted frame conditions (EU regulations)
• more modern source code
• state-of-the-art design
Timeline
of
The
Windows
Versions
Reservations
About
Updates
• technical risk: never change a running system
• usability improvements: changed interfaces cause confusion
• new mechanics: changed workflows to get used to
• state-of-the-art design: looks "different"
•incompatible custom changes
Outsource
to
Plugins
• modularity by hooks
• compatibility for many release versions
• reusability for multiple installations
Custom Changes in Plugins
Classic
Manual
Hook
Points
dedicated hook points at the beginning
and end of a function
sub myFunction {
&hook_before_myFunction(@_);
my $result = […]
&hook_after_myFunction($result, @_);
}
BUT:
Can you hook into
a function call
dynamically?
$AUTOLOAD
1st
Try
package MyObject;
our $AUTOLOAD;
sub AUTOLOAD {
return &myFunction() + 2;
}
sub myFunction {
return 1;
}
print &myFunction(); ## result: 1
AUTOLOAD won't
be executed as the
called function
already exists
2nd
Try
package MyObject;
our $AUTOLOAD;
sub AUTOLOAD {
my $function = $AUTOLOAD;
$function =~ s/^(.*)::(.+?)$/$2/sg;
my $hookableFunction = 'hookable_'.$function;
return &$hookableFunction() + 2;
}
sub hookable_myFunction {
return 1;
}
print &myFunction(); ## result: 3
AUTOLOAD is executed
as the current function
doesn't exist!
BUT:
unpleasant prefix
in the function name
Object
to
Hook
package My::Object;
sub myFunction {
my $self = shift;
return $self->myOtherFunction();
}
sub myOtherFunction {
[…]
}
1;
Our
Solution:
Twins
!
dummy object in original namespace actual object in the twin namespace Core
package My::Object;
use base My::HookBase;
1;
package My::Core::Object;
use base My::BaseObject;
sub myFunction {
my $self = shift;
return $self->{hookclass}->myOtherFunction();
}
sub myOtherFunction {
[…]
}
1;
here
comes
the
Hip-Hop
$myObject->myFunction()
My::Core::Object
sub myFunction {
my $self = shift;
return $self->{hookclass}-
>myOtherFunction();
}
sub myOtherFunction {
[…]
}
My::Object
AUTOLOAD Dummy
$Hooks->addCoreHook({
coreObject => 'My::Object',
coreFunction => 'myFunction',
runlevel => 100,
hookFunction => sub {
my $self = shift;
my $hookQueue = shift;
my @param = @_;
## code before: can manipulate @param
my $result = $self->nextHook($hookQueue, @param);
## code afterwards: can manipulate $result
return $result;
}
});
in
the
plugin:
sub addCoreHook {
my $self = shift;
my $param = shift;
my $coreObject = $param->{coreObject};
my $coreFunction = $param->{coreFunction};
push @{$self->{coreHooks}->{$coreObject}->{$coreFunction}}, {
hookFunction => $param->{hookFunction},
runlevel => $param->{runlevel},
};
}
sub getCoreHooks {
my $self = shift;
my $coreObject = shift;
my $coreFunction = shift;
return {
hookFunctions => $self->sortByRunlevel($self->{coreHooks}->{$coreObject}->{$coreFunction}),
coreFunction => $coreFunction,
};
}
in
Hooks.pm
package My::HookBase;
sub new {
my $class = shift;
my $params = shift;
my $self = {};
bless ($self, $class);
my $coreClass = $class;
$coreClass =~ s/^My::/My::Core::/sg;
my $corePath = $coreClass;
$corePath =~ s/::///sg;
require $corePath.'.pm';
$params->{hookclass} = $self;
$self->{corebase} = $coreClass->new($params);
return $self;
}
our $AUTOLOAD;
sub AUTOLOAD {
my $self = shift;
my $function = $AUTOLOAD;
$function =~ s/^(.*)::(.+?)$/$2/sg;
my $package = $1;
return $self->parseHooks($package, $function, @_);
}
in
the
dummy
object:
sub parseHooks {
my $self = shift;
my $package = shift;
my $function = shift;
my @param = @_;
my $hookQueue = $self->getCoreHooks($package, $function);
return $self->nextHook($hookQueue, @param);
}
sub nextHook {
my $self = shift;
my $hookQueue = shift;
my @params = @_;
my $hookFunctions = $hookQueue->{hookFunctions}; ## sorted list of hooks
if (my $thisHook = shift @$hookFunctions) { ## one hook after another
my $hookFunction = $thisHook->{hookFunction};
return &$hookFunction($self, $hookQueue, @param); ## run the hook function
} else {
my $coreFunction = $hookQueue->{coreFunction}; ## function to hook
return $self->{corebase}->$coreFunction(@param); ## run the base function
}
}
in the plugin:
$Hooks->addCoreHook({
coreObject => 'My::Object',
coreFunction => 'myFunction',
runlevel => 100,
hookFunction => sub {
my $self = shift;
my $hookQueue = shift;
my @param = @_;
## code before: can manipulate @param
my $result = $self->nextHook($hookQueue, @param);
## code afterwards: can manipulate $result
return $result;
}
});
in
the
dummy
object:
How do we get the
hook system in existing
software installations?
With patience !
The hook system has already
been implemented in the year
2014
and all current CosmoShop
installations
have it ready to use

Weitere ähnliche Inhalte

Kürzlich hochgeladen

Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Russian Call Girls in Kolkata Ishita 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Ishita 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Ishita 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Ishita 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
Gram Darshan PPT cyber rural in villages of india
Gram Darshan PPT cyber rural  in villages of indiaGram Darshan PPT cyber rural  in villages of india
Gram Darshan PPT cyber rural in villages of indiaimessage0108
 
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...Diya Sharma
 
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.soniya singh
 
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark WebGDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark WebJames Anderson
 
VIP Kolkata Call Girl Salt Lake 👉 8250192130 Available With Room
VIP Kolkata Call Girl Salt Lake 👉 8250192130  Available With RoomVIP Kolkata Call Girl Salt Lake 👉 8250192130  Available With Room
VIP Kolkata Call Girl Salt Lake 👉 8250192130 Available With Roomishabajaj13
 
AlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsAlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsThierry TROUIN ☁
 
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls KolkataVIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024APNIC
 
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Radiant Call girls in Dubai O56338O268 Dubai Call girls
Radiant Call girls in Dubai O56338O268 Dubai Call girlsRadiant Call girls in Dubai O56338O268 Dubai Call girls
Radiant Call girls in Dubai O56338O268 Dubai Call girlsstephieert
 
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine ServiceHot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Servicesexy call girls service in goa
 
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort ServiceEnjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort ServiceDelhi Call girls
 
On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024APNIC
 
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 
Low Rate Call Girls Kolkata Avani 🤌 8250192130 🚀 Vip Call Girls Kolkata
Low Rate Call Girls Kolkata Avani 🤌  8250192130 🚀 Vip Call Girls KolkataLow Rate Call Girls Kolkata Avani 🤌  8250192130 🚀 Vip Call Girls Kolkata
Low Rate Call Girls Kolkata Avani 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
Russian Call girls in Dubai +971563133746 Dubai Call girls
Russian  Call girls in Dubai +971563133746 Dubai  Call girlsRussian  Call girls in Dubai +971563133746 Dubai  Call girls
Russian Call girls in Dubai +971563133746 Dubai Call girlsstephieert
 

Kürzlich hochgeladen (20)

Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Ashram Chowk Delhi 💯Call Us 🔝8264348440🔝
 
Russian Call Girls in Kolkata Ishita 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Ishita 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Ishita 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Ishita 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
Gram Darshan PPT cyber rural in villages of india
Gram Darshan PPT cyber rural  in villages of indiaGram Darshan PPT cyber rural  in villages of india
Gram Darshan PPT cyber rural in villages of india
 
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
 
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
 
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark WebGDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
 
VIP Kolkata Call Girl Salt Lake 👉 8250192130 Available With Room
VIP Kolkata Call Girl Salt Lake 👉 8250192130  Available With RoomVIP Kolkata Call Girl Salt Lake 👉 8250192130  Available With Room
VIP Kolkata Call Girl Salt Lake 👉 8250192130 Available With Room
 
AlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsAlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with Flows
 
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
 
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls KolkataVIP Call Girls Kolkata Ananya 🤌  8250192130 🚀 Vip Call Girls Kolkata
VIP Call Girls Kolkata Ananya 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
 
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
 
Radiant Call girls in Dubai O56338O268 Dubai Call girls
Radiant Call girls in Dubai O56338O268 Dubai Call girlsRadiant Call girls in Dubai O56338O268 Dubai Call girls
Radiant Call girls in Dubai O56338O268 Dubai Call girls
 
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine ServiceHot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
 
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort ServiceEnjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
 
On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024On Starlink, presented by Geoff Huston at NZNOG 2024
On Starlink, presented by Geoff Huston at NZNOG 2024
 
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
Low Rate Call Girls Kolkata Avani 🤌 8250192130 🚀 Vip Call Girls Kolkata
Low Rate Call Girls Kolkata Avani 🤌  8250192130 🚀 Vip Call Girls KolkataLow Rate Call Girls Kolkata Avani 🤌  8250192130 🚀 Vip Call Girls Kolkata
Low Rate Call Girls Kolkata Avani 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
Russian Call girls in Dubai +971563133746 Dubai Call girls
Russian  Call girls in Dubai +971563133746 Dubai  Call girlsRussian  Call girls in Dubai +971563133746 Dubai  Call girls
Russian Call girls in Dubai +971563133746 Dubai Call girls
 

Empfohlen

Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationErica Santiago
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellSaba Software
 

Empfohlen (20)

Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
 

Hip-Hop-Hooks_english_v2_16-04-2024.pptx

  • 1. Wie der CosmoShop mit generischen Hookpoints in Perl-Objekten „umspringt“ How the CosmoShop handles generic Hook Points in Perl Objects
  • 2. Product Development • new features • security updates • most recent third party packages • adapted frame conditions (EU regulations) • more modern source code • state-of-the-art design
  • 4. Reservations About Updates • technical risk: never change a running system • usability improvements: changed interfaces cause confusion • new mechanics: changed workflows to get used to • state-of-the-art design: looks "different" •incompatible custom changes
  • 5. Outsource to Plugins • modularity by hooks • compatibility for many release versions • reusability for multiple installations Custom Changes in Plugins
  • 6. Classic Manual Hook Points dedicated hook points at the beginning and end of a function sub myFunction { &hook_before_myFunction(@_); my $result = […] &hook_after_myFunction($result, @_); }
  • 7. BUT: Can you hook into a function call dynamically?
  • 9. 1st Try package MyObject; our $AUTOLOAD; sub AUTOLOAD { return &myFunction() + 2; } sub myFunction { return 1; } print &myFunction(); ## result: 1 AUTOLOAD won't be executed as the called function already exists
  • 10. 2nd Try package MyObject; our $AUTOLOAD; sub AUTOLOAD { my $function = $AUTOLOAD; $function =~ s/^(.*)::(.+?)$/$2/sg; my $hookableFunction = 'hookable_'.$function; return &$hookableFunction() + 2; } sub hookable_myFunction { return 1; } print &myFunction(); ## result: 3 AUTOLOAD is executed as the current function doesn't exist! BUT: unpleasant prefix in the function name
  • 11. Object to Hook package My::Object; sub myFunction { my $self = shift; return $self->myOtherFunction(); } sub myOtherFunction { […] } 1;
  • 12. Our Solution: Twins ! dummy object in original namespace actual object in the twin namespace Core package My::Object; use base My::HookBase; 1; package My::Core::Object; use base My::BaseObject; sub myFunction { my $self = shift; return $self->{hookclass}->myOtherFunction(); } sub myOtherFunction { […] } 1;
  • 13. here comes the Hip-Hop $myObject->myFunction() My::Core::Object sub myFunction { my $self = shift; return $self->{hookclass}- >myOtherFunction(); } sub myOtherFunction { […] } My::Object AUTOLOAD Dummy
  • 14. $Hooks->addCoreHook({ coreObject => 'My::Object', coreFunction => 'myFunction', runlevel => 100, hookFunction => sub { my $self = shift; my $hookQueue = shift; my @param = @_; ## code before: can manipulate @param my $result = $self->nextHook($hookQueue, @param); ## code afterwards: can manipulate $result return $result; } }); in the plugin:
  • 15. sub addCoreHook { my $self = shift; my $param = shift; my $coreObject = $param->{coreObject}; my $coreFunction = $param->{coreFunction}; push @{$self->{coreHooks}->{$coreObject}->{$coreFunction}}, { hookFunction => $param->{hookFunction}, runlevel => $param->{runlevel}, }; } sub getCoreHooks { my $self = shift; my $coreObject = shift; my $coreFunction = shift; return { hookFunctions => $self->sortByRunlevel($self->{coreHooks}->{$coreObject}->{$coreFunction}), coreFunction => $coreFunction, }; } in Hooks.pm
  • 16. package My::HookBase; sub new { my $class = shift; my $params = shift; my $self = {}; bless ($self, $class); my $coreClass = $class; $coreClass =~ s/^My::/My::Core::/sg; my $corePath = $coreClass; $corePath =~ s/::///sg; require $corePath.'.pm'; $params->{hookclass} = $self; $self->{corebase} = $coreClass->new($params); return $self; } our $AUTOLOAD; sub AUTOLOAD { my $self = shift; my $function = $AUTOLOAD; $function =~ s/^(.*)::(.+?)$/$2/sg; my $package = $1; return $self->parseHooks($package, $function, @_); } in the dummy object:
  • 17. sub parseHooks { my $self = shift; my $package = shift; my $function = shift; my @param = @_; my $hookQueue = $self->getCoreHooks($package, $function); return $self->nextHook($hookQueue, @param); } sub nextHook { my $self = shift; my $hookQueue = shift; my @params = @_; my $hookFunctions = $hookQueue->{hookFunctions}; ## sorted list of hooks if (my $thisHook = shift @$hookFunctions) { ## one hook after another my $hookFunction = $thisHook->{hookFunction}; return &$hookFunction($self, $hookQueue, @param); ## run the hook function } else { my $coreFunction = $hookQueue->{coreFunction}; ## function to hook return $self->{corebase}->$coreFunction(@param); ## run the base function } } in the plugin: $Hooks->addCoreHook({ coreObject => 'My::Object', coreFunction => 'myFunction', runlevel => 100, hookFunction => sub { my $self = shift; my $hookQueue = shift; my @param = @_; ## code before: can manipulate @param my $result = $self->nextHook($hookQueue, @param); ## code afterwards: can manipulate $result return $result; } }); in the dummy object:
  • 18. How do we get the hook system in existing software installations?
  • 19. With patience ! The hook system has already been implemented in the year 2014 and all current CosmoShop installations have it ready to use