title: Access Mule global variable from a custom transformer
body: <p>How can i access a Mule global variable from my custom transformer? 
  I have a variable (in a properties file), called blaze.services.address - which is definitely being loaded (i use it in MEL). My code:</p>
  
  <pre><code>import org.mule.api.MuleContext;
  import org.mule.api.MuleMessage;
  import org.mule.api.context.MuleContextAware;
  import org.mule.api.transformer.TransformerException;
  import org.mule.api.transport.PropertyScope;
  import org.mule.transformer.AbstractMessageTransformer;
  import org.apache.commons.httpclient.HttpStatus;
  import com.vatit.blaze.esb.exception.HttpResponseException;
  
  public class HttpErrorResponseChecker extends AbstractMessageTransformer {
  
      @Override
      public Object transformMessage(MuleMessage message, String outputEncoding) throws TransformerException {
          Integer statusCode = Integer.parseInt((String)message.getProperty("http.status", PropertyScope.INBOUND));
          String payload;
              try {
                  payload = message.getPayloadAsString();
              } catch (Exception e) {
                  e.printStackTrace();  
                  payload = "Unknown payload";
              }
  
  
          muleContext.getRegistry().get("blaze.services.address");
          if (statusCode &gt;= HttpStatus.SC_BAD_REQUEST)
              throw new HttpResponseException(this, statusCode, "Exception caused by call to HTTP service", payload);
  
          return message.getPayload();
      }
  
  }
  </code></pre>
  
  <p><strong>problems</strong>:</p>
  
  <p>setMuleContext never stops on a breakpoint (never called?)
  <code>muleContext.getRegistry().get("blaze.services.address")</code> returns null</p>
  
  <p>Anyone have an idea?</p>
  
  <p><strong>EDIT (transformer config):</strong></p>
  
  <p>In response to David's comment I have removed duplicate implementation of MuleContextAware, however the result remains the same.</p>
  
  <p>My transformer config looks like this:</p>
  
  <pre><code>&lt;custom-transformer class="com.vatit.blaze.esb.transformer.HttpErrorResponseChecker" name="HttpErrorResponseChecker" doc:name="Java"&gt;
      &lt;spring:property name="blazeServicesAddress" value="${blaze.services.address}"/&gt;
  &lt;/custom-transformer&gt;
  </code></pre>
  
  <p>Which works (_blazeServicesAddress property not shown in java code), but i'd prefer to access the property directly, not have to inject.</p>
  
  <p><strong>EDIT 2 (property placeholders):</strong>
  This is the way our properties files are loaded:</p>
  
  <pre><code>&lt;spring:beans&gt;
      &lt;context:property-placeholder location="classpath:blazedefault.properties" order="0"/&gt;
      &lt;context:property-placeholder  location="classpath:blazeoverride.properties" ignore-resource-not-found="true" ignore-unresolvable="true" order="-1"/&gt;
  &lt;/spring:beans&gt;
  </code></pre>