Win a copy of Serverless Applications with Node.js this week in the NodeJS 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
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Ron McLeod
  • Tim Moores
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Vijitha Kumara

Add Java code during compile phase?  RSS feed

 
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: 9997
208
  • 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: 63843
209
  • 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: 9997
208
  • 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: 9997
208
  • 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: 5813
150
Chrome Eclipse IDE Java Postgres Database VI Editor
  • 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:
 
I am mighty! And this is a mighty small ad:
global solutions you can do in your home or backyard
https://coderanch.com/t/708587/global-solutions-home-backyard
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!