This week's book giveaways are in the Cloud and AI/ML forums.
We're giving away four copies each of Cloud Native Patterns and Natural Language Processing and have the authors on-line!
See this thread and this one for details.
Win a copy of Cloud Native PatternsE this week in the Cloud forum
or Natural Language Processing in the AI/ML forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Add Java code during compile phase?

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear poeple

I use a program which uses Java as a script language. (Yes not javascript is used).

Now the problem is this script files are getting huge and hard to maintain. I already have splitted in into several classes which are all in the same file, because the dynamic compiler only works with this specific script file during the runtime. This product can also work with a lot of customers, which uses the sames scripts and I have also to copy a lot.

The question is now, if it is possible to merge multiple java files into one during the runtime of the program, without  creating a jar and install it into the classpath of the tomcat server and import it as asual.

I hope you understand .

Thank you in advance.

Regards
KB
 
Saloon Keeper
Posts: 10404
223
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to CodeRanch!

I understand that the dynamic compiler is part of a web application that's hosted in Tomcat. How is the script presented to the compiler? Where is it loaded from?
 
Marshal
Posts: 65019
246
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not a beginning question; moving discussion.

And, again welcome to the Ranch
 
Kevin Brunner
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:Welcome to CodeRanch!

I understand that the dynamic compiler is part of a web application that's hosted in Tomcat. How is the script presented to the compiler? Where is it loaded from?



Dear Stephan


Thank you for your fast answer.

The files are stored on the drive of the server and some kind of workflow engine picks them up and compiles it, when the workflow arrives on the corresponding step.

Regards
Kevin

 
Stephan van Hulst
Saloon Keeper
Posts: 10404
223
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And you can't add steps to the workflow to aggregate the loose files into one?
 
Kevin Brunner
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:And you can't add steps to the workflow to aggregate the loose files into one?



Sadly, I can't. The workflow engine is executing this script. I am not able to aggregate. What I did before was to copy all classes into this script file, but the maintenance is very complicated, therefore I am looking for another way to add them. Like a href="" in html or something like that.

Regards
K
 
Stephan van Hulst
Saloon Keeper
Posts: 10404
223
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When does the engine start running? Does it detect that new files were added to some folder? How are the files added to the folder? Is it a manual operation? Are the files copied from somewhere else? Are they written by a tool?
 
Kevin Brunner
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Stephan van Hulst wrote:When does the engine start running? Does it detect that new files were added to some folder? How are the files added to the folder? Is it a manual operation? Are the files copied from somewhere else? Are they written by a tool?



The engine starts to execute, when the workflow is started. One of the steps within the workflow is the execution of this script. The scripts are stored within a specific folder per customer. For each customer separate scripts exists.

I made some tests, I was able to load an additional class via reflection.



This worked, but I have no idea how tomcat will behave if multiple workflows tries to compile and load the same java class. Do somebody has experiance?

Regards
KB
 
Sheriff
Posts: 6108
157
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're interested, I have a class called Reflector that will turn lines 8 through 13 into this:
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!