title: Drools: How to Declare and Assign Global
body: <p>I want to declare a global variable in a drools rule file (mvel).  This is because this global is used in all the rules as a parameter to another function.  I could easily pass this string explicitly in every call to the function, but this makes it hard if the string changes.</p>
  
  <p>I thought I could do a:</p>
  
  <pre><code>global String someStr = "some string";
  </code></pre>
  
  <p>But on compile, I get:</p>
  
  <pre><code>[11,31]: [ERR 107] Line 11:31 mismatched input '=' expecting one of the following tokens: '[package, import, global, declare, function, rule, query]'.
  </code></pre>
  
  <p>So obviously, I can't assign it this way.  Nor do I seem to be able to declare a class and a string in that class to reference through the class.</p>
  
  <p>So I found I could so something that seems silly:</p>
  
  <pre><code>global String someStr;
  rule "Initialize"
  when
  then
     someStr = "some string";
  end
  </code></pre>
  
  <p>This seems to work, but, this will log every single time this rule matches (always) to just assign a global.</p>
  
  <p>Is there a better way that I'm missing???</p>