This week's book giveaway is in the Spring forum.
We're giving away four copies of Spring in Action (5th edition) and have Craig Walls on-line!
See this thread for details.
Win a copy of Spring in Action (5th edition) this week in the Spring 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
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

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
 
Bartender
Posts: 9494
184
  • 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: 61756
193
  • 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
Bartender
Posts: 9494
184
  • 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
Bartender
Posts: 9494
184
  • 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: 5448
147
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:
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!