[opencms-dev] Using OpenCms objects in external Java application?

Andreas Haumer andreas at xss.co.at
Fri Oct 6 10:02:15 CEST 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Jonathan,

many thanks for your reply!

Jonathan Woods schrieb:
> Andreas -
> 
> Yes, it's all possible.  You can access multiple instances of OpenCms in
> this way by ensuring that for each one you specify the location of the
> instance's WEB-INF folder.  The fact that you weren't doing that for your

Good to know!

> single instance may explain the NullPointerException - not sure.
> 
Ah, ok.

> Anyway, a good place to start is in the source code of CmsShell.  CmsShell
> is an OpenCms class which allows you to create command shell which accepts a
> number of scripting-like commands mapped directly to core OpenCms methods

Yes, I already was aware of CmsShell and I got it to work for a test, too.

> (e.g. on CmsObject).  I don't think using a shell-like environment is
> appropriate here, even though it does allow you to manipulate the VFS,
> because you already have a full-blown Java environment which is capable of
> much more.  So instead of using CmsShell for its shell-like capabilities,
> you could hack some source code from it to do what you want.
> 
That's exactly my reasoning for not using CmsShell in it's interactive form.
Sure, I could write some glue code to talk to the shell and parse the response,
but that's just ugly.
Instead I'd rather use the Java API provided by OpenCMS directly in my program,
if possible.

> Take a look at the constructor CmsShell(String webInfPath, String
> servletMapping, String defaultWebAppName, String prompt, I_CmsShellCommands
> additionalShellCommands).  Forgetting about all the message bundle stuff,
> you should be able to crib from this code in your own Java class, starting
> with your own values for webInfPath, servletMapping and defaultWebAppName.
> 
I'll try to do that.

> If you haven't got the source code from anywhere yet, it's all over the web
> and downloadable from opencms.org.  You can also see it at Google's sexy new
> (but not yet extraordinarily useful) source code search tool,
> www.google.com/codesearch.  The URL I get is 
> 
Eclipse is currently checking out the project from
cvs.opencms.org in this very moment... :-)

Thank you!

- - andreas

- --
Andreas Haumer                     | mailto:andreas at xss.co.at
*x Software + Systeme              | http://www.xss.co.at/
Karmarschgasse 51/2/20             | Tel: +43-1-6060114-0
A-1100 Vienna, Austria             | Fax: +43-1-6060114-71
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFJg2CxJmyeGcXPhERAltIAJ0br5XRXg6Sbx9uQGs/9lNNgnHdewCfZkDN
0uWbg2dvOANISqkTR7YnLfA=
=wTpq
-----END PGP SIGNATURE-----



More information about the opencms-dev mailing list