Skip to main content
Inspiring
March 11, 2014
Question

Any samples of the combination lightroom:// and Java

  • March 11, 2014
  • 1 reply
  • 1477 views

Due to limitations in the UI capabilities of the Lightroom SDK I would like to create a front-end in Java and have it communicate with Lightroom via a HTTP manner with lightroom://.

So sending a HTTP request with <scheme>://<authority><path>?<query>#<fragment>and then have Lightroom send the requested information.

With great interest I have looked at the LRCookmark plug-in of Rob Cole.

He uses for example "lightroom://com.robcole.lightroom.Cookmarks/iBlacks2012=-10&iShadows2012=-10&iHighlights2012=10"

I know I can connect via JDBC directly from Java to the Lightroom SQLite database, but my conviction is that this is not the way to go.

In my opinion all (write, update and delete) access to the Lightroom database should be done via the Lua API in order to use the business logic in the API.

Question: has anyone experience with this would like a very basic sample.

A very small working sample would help me getting started.

This topic has been closed for replies.

1 reply

areohbee
Legend
March 11, 2014

A couple notes:

if you use lightroom:// for communication, it's one-way.

John Ellis wrote a great post summarizing external communications possibiliities, which is worth a read if you haven't already.

Personally, I'm opting for disk-based comm these days - I've ported the Intercom messaging system from Elare Plugin Framework to a Java library (not yet released) so Java apps can communicate directly with plugins. If your messaging doesn't demand high volume and/or fast response, it has some advantages..

Rough-cut of javadoc (temporary link):

http://www.robcole.com/_temp/_IntercomJavadoc/index.html

(see Intercom doc - to & from addresses are plugin/toolkit-ID, not unlike in lightroom:// URI)

Anyway, are you sure Lr will allow connection via JDBC to currently open catalog - it would guess such connection would be denied (database is locked).

PS - Intercom has been robustened of late and not yet released anywhere, and so if you want a recent copy, I'll have to provide special for you.

PPS - I would think Cookmarks has all the sample you need for url-based messaging (plugin side anyway), no? I mean, it's very simple how it works, OS passes URL to plugin handler which, handles it... So, is it the java side you need sample for? i.e. how to submit a custom protocol url to OS? Are you familiar with this:

http://docs.oracle.com/javase/1.5.0/docs/api/java/net/URI.html

Rob

Inspiring
March 11, 2014

Hi Rob,

Thank you for your answer!

Rob Cole wrote:

John Ellis wrote a great post summarizing external communications possibiliities, which is worth a read if you haven't already.

Do you mean http://forums.adobe.com/message/6077997#6077997http:// . This one I read.

Rob Cole wrote:

Anyway, are you sure Lr will allow connection via JDBC to currently open catalog - it would guess such connection would be denied (database is locked).

No, I meant to say that I do not want to directly connect from Java to Lightroom SQLite via JDBC. I think it is not possible while Lightroom is running, but further it is not a good practice to make any changes to the Lightroom database directly. I would never do that. In my opinion this would be killing.

I already managed to communicate with Lightroom via the lightroom:// way and managed to see the URL in Lightroom. I read the post of Jeffry Friedl and looked indeed at your LRCookmark plugin.

As you can see, I used the links on your LRCookmark to test. Great sample.

What I need is to have the Java application send messages and have the Lightroom plug-in:

  1. act upon the request via the Lightroom API internally and
  2. answer the Java program with the required information.

Yes, I looked at the URI class because the standard URL class in Java will generate a MalformedURLException.

Anyway, if I understand you well, using the lightroom:// is suitable for one way communication and not two way communication as I need. Am I correct?

I have to rethink it and am open to any suggestions!

areohbee
Legend
March 11, 2014

Yeap, yeah, uh-huh, & OK to most...

Furthermore - yes: url-handler is 1-way, so won't do for your purposes.

Intercom (java side) does NOT yet have sendAndReceive(reply) method yet (like lua side does), but it could be easily implemented.

Even if you don't use Intercom code as-is directly, you could borrow the idea, which is:

* Java app writes a file that plugin reads.

* Plugin writes a response file that Java app reads.

I'm trying to make it general-purpose/reusable, but if you make custom per-app it can be simplified.

PS - Before Intercom I used xml-rpc over http. It has the advantage of less proprietary code required on the app side (you still need a proprietary implementation of xml-rpc in lua, since you can't use external lua libs), but then you need to find a tcp-ip port to communicate with, and to be honest (not that I'm not always honest ) - I had problems just reliably starting & stopping app with open http connection (granted that was Python, not Java).

Cheers,

Rob