Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Multiple Classes ... Should I inject, or make Global?


I am starting to create "packages" so that my scripting is more stable and more scalable. I am using Jira Server / Scriptrunner as my means of executing said scripts.

For instance, I created a "logger" package to control default behavior on what gets logged and what does not.  "debug" and "info" are normally toggled off, but "error" is normally toggled on


import utils.LogThis

log = new LogThis()
log.debug("This will log because I just turned debug on")"This will NOT log because info is toggled off by default")

Backstory: I have a "controller" script that imports two other classes.  Logger and Assignee.  Logger is what I just explained, and the Assignee Class handles logic to "re-assign" an issue to another person.  Simple enough.

Issue: I want to set the "log level" for my class in the initial script and have both Logger and Assignee instruction to respect that state.  This is not going to happen if I am "newing" up LogThis in each of the two classes.

Normally, to solve this, I would "inject" the Logger into each class when I "new it up". 

assignee = new Assignee(log, $issue, $assignee)

Is that best way to handle this in Groovy?  I like injection and would normally make a "system" object where I store any / all frameworky objects and just inject that as SOP.

system = new System()

system.log = new LogThis()


assignee = newAssignee(system, $issue, $assignee)

As each "script" is compiled to an object, I am thinking I can not really "global" the LogThis as it is probably not available to another "imported" script just by not typecasting / def'ing the variable.

Just looking for "Best Practices" on something like this.   

Thanks in advance

0 answers

Suggest an answer

Log in or Sign up to answer
Community showcase

The benefits of using Jira in different departments

Jira is a great tool to use across different departments. Forget that paperwork – switch to Jira and get that tasks done smoothly. Marketing Jira allows for a complete digital transformation of you...

81 views 0 4
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you