New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add automatic java lib mappings #731

Closed
neokoenig opened this Issue Mar 7, 2017 · 9 comments

Comments

3 participants
@neokoenig
Member

neokoenig commented Mar 7, 2017

Would make plugins more powerful if there was a way to have /plugins/pluginName/lib/ automatically added to the this.javamappings: that way you could easily deploy javalib based plugins without additional configuration.

yay? nay?

@perdjurner

This comment has been minimized.

Contributor

perdjurner commented Mar 8, 2017

Not familiar with this, can you give me a real world example?
Can the plugin itself add the mapping or is that impossible currently?

@neokoenig

This comment has been minimized.

Member

neokoenig commented Mar 8, 2017

i.e, lets say you wanted to make a bCrypt plugin. The easiest way is via

this.javaSettings = {
    	LoadPaths = ["miscellaneous"]
  	};

in config/app.cfm

Chuck your .class file in, the do bCrypt = CreateObject( "java", "BCrypt" );

So what I'm saying is it would be great if /lib or /java as auto-added to this.javasettings if it exists: that way you don't need to change code outside of the plugin to use it.

@neokoenig

This comment has been minimized.

Member

neokoenig commented Mar 14, 2017

The more I think about this the more I like it: it means you could very easily add plugins which just expose java libs and add a few convenience functions. Bycrypt, iCal4J, MarkdownJ would be some easy wins for new plugins (I've actually already written these too).

I'll implement unless there are any strong objections.

@neokoenig neokoenig self-assigned this Mar 14, 2017

@neokoenig neokoenig added this to the 2.0.0 milestone Mar 14, 2017

@andybellenie

This comment has been minimized.

Contributor

andybellenie commented Mar 14, 2017

I thought you could use a path on CreateObject() but I've just checked and it's a Lucee only feature, so I agree this would be useful.

I got this to work but recursing over plugin directories and adding them all to JavaSettings.LoadPaths. Then all a plugin author has to do is place the java file directly in a plugin directory or subdirectory.

@neokoenig

This comment has been minimized.

Member

neokoenig commented Mar 14, 2017

Cool, that was pretty much my thinking. Have you done this got the code already? If so that would be fab, otherwise I'm happy to do it

@andybellenie

This comment has been minimized.

Contributor

andybellenie commented Mar 14, 2017

No problem

param name="this.javaSettings.loadPaths" default=ArrayNew(1);
for (file in DirectoryList(path=ExpandPath("/#application.$wheels.pluginPath#"), recurse="true", filter="*.class|*.jar|*.java")) {
	ArrayAppend(this.javaSettings.loadPaths, GetDirectoryFromPath(file)); 
}

It needs to go in /wheels/events/onapplicationstart.cfm somewhere so as not to override any paths the user may have set themselves

@neokoenig

This comment has been minimized.

Member

neokoenig commented Mar 14, 2017

hmm. I can get the folder path into the loadpaths array, but for the life of my can't work out why the .class etc files refuse to load. @andybellenie you're using this in lucee 4.5.x?

@andybellenie

This comment has been minimized.

Contributor

andybellenie commented Mar 14, 2017

Lucee 4.5.3.020

neokoenig added a commit that referenced this issue Mar 14, 2017

Adds automatic java lib mappings for Plugins #731
Not 100% convinced by the implementation here; it would mean the developer has to use `arrayAppend()` when adding their own javaSettings.LoadPaths, as the danger is they override what we've set unintentionally.

neokoenig added a commit that referenced this issue Mar 14, 2017

@neokoenig

This comment has been minimized.

Member

neokoenig commented Mar 15, 2017

Added in 3c4a231
Leaving open to document

@neokoenig neokoenig added the docs label Mar 15, 2017

@neokoenig neokoenig modified the milestones: 2.0.0 Beta, 2.0.0 Mar 15, 2017

@neokoenig neokoenig modified the milestones: 2.0.0, 2.0.0 Beta Apr 19, 2017

@neokoenig neokoenig closed this Aug 31, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment