Extension configuration settings inside of Lucee Admin


#1

I am creating an extension that has many configurable options and I would like the ability to configure it from within the Lucee server admin. I believe what I need is an admin plugin which I have successfully created with a couple “dummy” options but I don’t see how I can access those settings from within the Java extension itself. Is this possible or is there a better way?


#2

Are you storing your data in the “app” variable that’s made available to the CFC “controllers” in your plugin? I’m not actually sure how to access that right off. I thought I was doing this in the Lucee Couchbase Cache Extension I write, but it turns out all the things I save like license keys I write out to a file and then read the same file. This was so people could automate the setting of these things from the file system when they deployed. So I guess I never actually used the app struct to store things.

@micstriit can you help here?


#3

Also, I should add-- what specific functionality are you adding that is written in Java. Lucee allows you to contribute tags and functions purely in CFML which I’ve found to be several millions times easier than writing them in Java :slight_smile:


#4

I am creating a distributed locking extension based on reddison and there are numerous configuration options that I would like to be able to set from the server admin. However after playing around with it last night I think it might be easier just to pass in a configuration file which I already started implementing just because of the shear number of options available. The reason for Java tag implementation is mostly because I want to learn a lot more about Java and how Lucee operates but also because the library I am using is built in Java.

Even though I abandoned the idea of configuring the extension from the Lucee admin it would still be cool to know if there is a way to do it.


#5

I am creating a distributed locking extension

That actually sounds pretty cool.

it might be easier just to pass in a configuration file

As cool as admin plugins are, I would tend to agree for the sole sake of allowing your application to be completely portable. If you can’t script out the config, how would you deploy it on Docker, etc?

The reason for Java tag implementation is mostly because I want to learn a lot more about Java and how Lucee operates

No worries there, it’s just more work!

but also because the library I am using is built in Java.

That doesn’t mean anything! You can use Java just as easily (actually WAY easier from CFML). Just to do simple things like create native CFML structs and arrays or to call native CFML functions from Java are a pain since you have to use reflection to bridge the core/loader divide. Just use the extension to load up the jars/OSGI bundles and do the rest in CFML. It will be soo much less work.

FWIW and just to document this since it’s part of the closed source Couchbase ext I wrote, this is how I wrote properties file from inside my plugin:

// web context
if( request.adminType == 'web' ) {
	return expandPath( '/lucee/ortus/couchbase/license.properties' );
// server context
} else {
	return expandPath( '/lucee-server/ortus/couchbase/license.properties' );
} 

And here’s now I read the file from java. Note, this requires you to get a page context object first.

Resource serverProps = pc.getConfig().getConfigServerDir().getRealResource("context/ortus/couchbase/license.properties");
Resource webProps = pc.getConfig().getConfigDir().getRealResource("context/ortus/couchbase/license.properties");

Even though I abandoned the idea of configuring the extension from the Lucee admin it would still be cool to know if there is a way to do it.

I agree. Hopefully @micstriit or @isapir will chime in and clarify how to access the persistent storage for an extension from Java. I could probably find out if I took the time to dig into the Java code but I need to do somet other stuff ATM :slight_smile: Once you figure it out, please add the information to this page:


I wrote that page of docs out of the information I gleaned from Micha’s brain while writing my cache extension because it wasn’t documented anywhere!