You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Andreas Hartmann <an...@apache.org> on 2008/06/19 13:46:43 UTC

Managing application code (scripts etc.)

Hi Sling devs,

I'm sorry if this basic question has already been answered, I couldn't 
find something in the list.

My understanding of the "standard scheme" of developing apps with Sling 
is as follows:

Option A: Use scripts which are stored in the JCR repository under /apps

Option B: Use Java classes (servlets) in OSGi bundles

Is this correct?


Option A seems suitable if all developers have access to a common Sling 
server, and one would probably use the JCR capabilities for code 
versioning. But for a distributed development environment, I'd rather 
use the good old SVN. Is it possible to keep the scripts outside the JCR 
repository? Or would I have to do a roundtrip (export from JCR, commit 
to SVN, update form SVN, import to JCR)? How do you handle this when you 
change for instance the lauchpad webapp code?

Thanks a lot in advance for any clarification!

-- Andreas


-- 
Andreas Hartmann, CTO
BeCompany GmbH
http://www.becompany.ch
Tel.: +41 (0) 43 818 57 01


Re: Managing application code (scripts etc.)

Posted by Bertrand Delacretaz <bd...@apache.org>.
Hi,

On Thu, Jun 19, 2008 at 4:19 PM, Andreas Hartmann <an...@apache.org> wrote:
> ...How do you edit the scripts in the JCR workspace?
>
> I tried the JCR Eclipse plug-in from Day and WebDAV, this seems to be
> convenient enough...

Yes, WebDAV is certainly the most convenient way of editing scripts in
the repository.

> ...Viewing and changing property values is not supported yet
> by the Eclipse plugin, isn't it?...

Not sure about this, I'll let someone else answer.
-Bertrand

Re: Managing application code (scripts etc.)

Posted by Andreas Hartmann <an...@apache.org>.
Hi Felix,

Felix Meschberger schrieb:

[…]

>>  Viewing and changing property values is not supported 
>> yet by the Eclipse plugin, isn't it?
> 
> Yes, there is. If you select a property in the tree view, the details of
> the property including the property's value(s) are displayed in the
> "Properties" view. You might have to open this view to see that.

great, thanks for the hint!

-- Andreas


-- 
Andreas Hartmann, CTO
BeCompany GmbH
http://www.becompany.ch
Tel.: +41 (0) 43 818 57 01


Re: Managing application code (scripts etc.)

Posted by Felix Meschberger <fm...@gmail.com>.
Hi Andreas,

Am Donnerstag, den 19.06.2008, 16:19 +0200 schrieb Andreas Hartmann:
> This sounds very reasonable.
> 
> How do you edit the scripts in the JCR workspace?
> 
> I tried the JCR Eclipse plug-in from Day and WebDAV, this seems to be 
> convenient enough.

This is how I also do it.

>  Viewing and changing property values is not supported 
> yet by the Eclipse plugin, isn't it?

Yes, there is. If you select a property in the tree view, the details of
the property including the property's value(s) are displayed in the
"Properties" view. You might have to open this view to see that.

In the Properties View you may also click into the property value and
edit it.

Regards
Felix


Re: Managing application code (scripts etc.)

Posted by Andreas Hartmann <an...@apache.org>.
Hi Felix,

thanks for your reply!

Felix Meschberger schrieb:

[…]

> My favourite is the following though:
> 
>   * Each developper works in his scripts in his local JCR workspace
>   * When done the scripts are copied to the bundle and used from within
>     the bundle without copying them to the repository.

This sounds very reasonable.

How do you edit the scripts in the JCR workspace?

I tried the JCR Eclipse plug-in from Day and WebDAV, this seems to be 
convenient enough. Viewing and changing property values is not supported 
yet by the Eclipse plugin, isn't it?

Or is there an even more straightforward approach?

 > For both approaches you will find an example in the
 > samples/simple-demo module:
 >
 >   * Scripts to be loaded under src/main/resources/SLING-INF/content
 >   * Scripts loaded from the bundle under src/main/scripts

Thanks a lot for the pointers!

-- Andreas


-- 
Andreas Hartmann, CTO
BeCompany GmbH
http://www.becompany.ch
Tel.: +41 (0) 43 818 57 01


Re: Managing application code (scripts etc.)

Posted by Felix Meschberger <fm...@gmail.com>.
Hi Andreas,

This is kind of a controversial issue ;-)

Am Donnerstag, den 19.06.2008, 13:46 +0200 schrieb Andreas Hartmann:
> Hi Sling devs,
> 
> I'm sorry if this basic question has already been answered, I couldn't 
> find something in the list.
> 
> My understanding of the "standard scheme" of developing apps with Sling 
> is as follows:
> 
> Option A: Use scripts which are stored in the JCR repository under /apps
> 
> Option B: Use Java classes (servlets) in OSGi bundles
> 
> Is this correct?

Both options are valid and :

> Option A seems suitable if all developers have access to a common Sling 
> server, and one would probably use the JCR capabilities for code 
> versioning.

This is exactly a problem right now. Day is currently working on a
commercial solution to this problem, which is able to export/import data
to/from an revision control system...

I personally prefer a different approach outline below.

>  But for a distributed development environment, I'd rather 
> use the good old SVN. Is it possible to keep the scripts outside the JCR 
> repository? Or would I have to do a roundtrip (export from JCR, commit 
> to SVN, update form SVN, import to JCR)? How do you handle this when you 
> change for instance the lauchpad webapp code?

You can export your scripts into a JCR system view export file or a JSON
file which you embed into your bundle(s) as content to be loaded when
the bundle is installed. See [1] for more information. You can of course
also just provide the files in as initial content without requiring
more-or-less complex JSON/system view exports.


My favourite is the following though:

  * Each developper works in his scripts in his local JCR workspace
  * When done the scripts are copied to the bundle and used from within
    the bundle without copying them to the repository.

The advantage of this approach is, that the scripts are managed in terms
of OSGi lifecycle management just like any other class in the bundles.
There is no danger of some user tampering with the scripts: You know
exactly what is there. Another advantage used to be easier upgrade
(today, loaded content may also be updated easily) -- still loaded
content has absolutely no versioning guarantees. Thirdly: scripts in the
repository are always available whereas scripts in the bundle are only
available when the respective bundle is active.

The disadvantage of this mechanism is of course, that changing and
testing scripts directly in the repository is much easier. This is why I
suggest using JCR-based scripts during development and bundle-based
scripts for release deployment.

For both approaches you will find an example in the samples/simple-demo
module:

  * Scripts to be loaded under src/main/resources/SLING-INF/content
  * Scripts loaded from the bundle under src/main/scripts

Hope this helps.

Regards
Felix

[1] http://incubator.apache.org/sling/site/content-loading.html