Below is my question in a nutshell, using the framework for a batch apex class:
global class ActOn_Batchable implements Database.Batchable<sObject>{
string query = 'query here';
**CAN I INSERT CODE HERE THAT WILL BE ACCESSIBLE BY THE BATCHES?**
for example:
string AuthKey = SomeOtherClass.callout_for_AuthKey();
global Database.QueryLocator start(Database.BatchableContext BC){
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext BC, List<sObject> scope){
}
global void finish(Database.BatchableContext BC){
}
}
To clarify the example shown in the code: In my current scenario I'm using batch to get around the 10 callout limit. Since each batch is going to need an AuthKey, my thought was to get the AuthKey with a callout prior to executing on the batches, rather than include the AuthKey callout in each batch (and waste 1 of the 10 callouts allowed per batch).
In my example above, would the string AuthKey be available to each batch if I then reference that string within the 'execute' method? If so, how would the callout used by "callout_for_AuthKey()" count towards governors limits? I'm wondering if the overall class "ActOn_Batchable" has its own set of limits, and then the limits reset for each batch that is executed as well.