Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,463,400
Community Members
 
Community Events
176
Community Groups

Use of a thirdparty jar which used ServiceLoader to load some dependent services not working

I am trying to develop a bamboo task for one of my project. The purpose of this jar is to parse the working directory and create a JSON output. For this purpose, I have also developed a java library which will take the working directory as input and provide a parsed output in JSON. Now, this java library uses java's ServiceLoader to load some dependent service classes. Independently, this library works as expected and loads all the dependencies and does its work. However, on using this library as a third party lib in the plugin, the library is not loading the dependent classes. In some post i saw the loading classes in  atlassian sdk is triky. Please advise what I am doing wrong or missing. 

the pom at the pluging:

 <dependency>
<groupId>com.abd.plug</groupId>
<artifactId>buildInspLib</artifactId>
<version>1</version>
<scope>compile</scope>
</dependency>



 

The dependencies which would be loaded by serviceLoader at the pom at the buildIspLib: 

 

 <dependency>
<groupId>com.abd.parser</groupId>
<artifactId>parser1</artifactId>
<version>1</version>
</dependency>
<dependency>
<groupId>com.abd.parser</groupId>
<artifactId>parser2</artifactId>
<version>1</version>
</dependency>

 

The code to load the service implementations. the buildInspLib has the META-INF directory which has the file with the implementing classes in it. Please note, this library works as expected if run outside of the atlassian sdk

//loads all the classes implementing ParserService
ServiceLoader<ParserService> loader = ServiceLoader.load(ParserService.class);

ExecutorService exec = Executors.newCachedThreadPool();

List<Future<ComputedData>> analysersOutput = new ArrayList<>();

System.out.println(" before distribution.."); //THIS LINE GETS PRINTED IN THE PLUGIN

for (ParserService serv : loader) {

try {

System.out.println(" distributing for : "+serv.getAnalyserType()+" );
//THIS LINE NEVER GETS PRINTED IN THE PLUGIN
....

...

How am I using this thirdparty lib?

new ParserInspector().inspect(taskContext.getWorkingDirectory().getAbsolutePath())

Please note: the library is being loaded. I can say that because, i could see the logs being printed. However, the service loader is not able to find the implementation classes  

 

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events