[opencms-dev] DbAccess for a custom file type

Christian Steinert christian_steinert at web.de
Thu Nov 2 13:16:11 CET 2006


Andy Bicksbo schrieb:
> Hi
>
> I want to build a backend adminmodule, for example a newsletter module
> or a Module, which synchronices users data wich another database, or a
> shop, or a Module which manages a big amount of similiar websites,
> which should run on one ocms instance.
But it sounds as if you want to build your own content management system
on top of a content management system.
For example, you can already have micro sites within a website and/or
several websites in one opencms installation.

If you want to create users, then you should be able to create them by
using the class CmsObject.
> So these Module should has it's own datatables of course. So there
> would be cases, where a good db connection is not important, for
> example for the shop Module, or the newsletter Module (it only would
> be beatyfuller to have the same implementation than ocms has) but i
> think, in the other to cases, it is important that there's a good why
> to connect to db. There's actually a possibility to get a dbpool
> connection with CmsSqlManager.getConnection(String dbPoolName), but i
> don#t know, if it#s good to use just a random conn out of the pool(to
> not slow down the whole cms, or invoke other problems with the
> connection, if there's a big aplication, which uses this way to
> connect), cause Ocms never uses this without a specific CmsDbContext.
> They use getConnection(CmsDbConext dbc). So my question is :
>  
But what is the problem with getting a connection from the pool then?
You can increase the amont of connections that are requested from the
database, if you are afraid that you use too many connections. And if
your database connections are clean (i.e. all changes are properly
committed) when you return them to opencms, then I don't see any problem.

Otherwise you would have to write your own connection pool which does
exactly the same as the connection pool of opencms - speak to the
database, request connections, store them for re-use, release them if
they are unused for a while, etc. etc.

So the getConnection -  method seems perfect to me. Then, on top of such
a connection you can access whatever information you want to store.
I would not re-implement the complete database access layer of opencms.
And if you don't like the connection pool, then you can configure your
database information for your module individually and connect to your
database individually. What would then be the use of modifying the
database layer of opencms, if you don't want to do what it does - you
could manage database connections on your own, if you really want (using
the opencms connection pool seems to be by far the better idea from my
point of view, but even if you whatever you want to do is really so
_totally_ different from all the existing stuff and if you don't want to
use the connection pool of opencms -- why do you want to push something
totally new into the core, if you can leave the core completely aside
and speak with the database directly?).

However - even for an online shop you could just use your own xml
content type to store products, use the normal opencms APIs to access
your data and not do any database programming whatsoever.

So the question is really which types of information you want to store
that can *not* be adequately expressed with mechanisms that exist
already in opencms. Maybe there is such information, but take a close
look first at what opencms has to offer. Then, for whatever you cannot
do with existing opencms servicces, or in areas where you think that
opencms introduces too much overhead, it seems adequate for me to
communicate with the database directly. For all other areas (user
management, content that can be expressed by Xml content types, Projects
maybe) you could probably re-use some existing mechanisms and use the
existing, tested code that is there - code that provides a separation
between online and offline, provides file versioning, provides lots of
checks, is available for different database systems, etc., etc...

> how to get this DbContext and implement the new Driver correctly to
> Opencms?
Implementing new drivers is probably meant for supporting a new database
plattform (e.g. mysql, oracle, maxdb, ms sql, ...) that can then be used
for a complete installation of opencms. If you want to to push new
concepts through those layers into the standard API of opencms, then you
are going to have very hard time an little benefit. If you really need
your own database access, then you should not all other parts of opencms
force to know what your doing. It is enough that your module knows it.

> How would the opencms team build a new adminModule with db connection?
> Would they alter the core classes?(CmsObject, CmsSecurityManager,
> CmsDriverManager)?
If you alter the core classes lighly you block your path for future
updates. That is not a good idea and should be only done if you totally
need it and have no other choice of creating the needed functionality.
Accessing a database directly (if you -really- -really- -really-
-really- need it) *is* possible without changing the core, because you
can just bypass the core.


Regards
christian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20061102/02e317a1/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3269 bytes
Desc: S/MIME Cryptographic Signature
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20061102/02e317a1/attachment.bin>


More information about the opencms-dev mailing list