You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pivot.apache.org by Thomas Guretzki <Th...@tik.info> on 2009/08/21 16:42:34 UTC

Persistence (was: Re: Preferences Demo)

Hello Pivoteers,

the current discussion about preferences and persistence 
just inspired me to pose a question:

Is there currently a possibility, or could it be made possible,
to bind Entity Objects (used in a pivot application as storage for the ui)
via JDBC to Rows in a Database? Without going through the
web services of an application server?
An ORM Framework could be used, though.

Would be great for our in-house enterprise application.

And another one: is it possible (there might even be a sample somewhere)
to easily create a transparent web service on some "dumb" appserver,
which just routes the requests via JDBC to a database? 
Maybe even with authentication of the database passed through
(perhaps as a simple "https://login"-Webservice). 
No session pooling wanted, just 1:1 cookie-sessions : db-sessions.
I have found http://sqlrest.sourceforge.net/ , but has anyone
tried such a thing, maybe with Pivot?

Apache Pivot is really great work, I'm considering the platform
as a replacement for Oracle Forms in our enterprise.

Greetings

Thomas


------------------------------------------------------------
Thomas Guretzki
Telefon +49 511 7631 334; Fax +49 511 7631 718
T.I.K. GmbH - Datenbankadministration & Softwareentwicklung
Königsworther Platz 6    30167 Hannover     Germany
Steuer-Nr. 2520601056
Geschäftsführer: Dr. Rainer Koch, Sitz: Hannover
Registereintrag: HRB 58144, Amtsgericht Hannover 

-----Ursprüngliche Nachricht-----
Von: Greg Brown [mailto:gkbrown@mac.com] 
Gesendet: Freitag, 21. August 2009 16:14
An: pivot-dev@incubator.apache.org
Cc: pivot-user@incubator.apache.org
Betreff: Re: Preferences Demo

X-ESAFE-STATUS:[dschafar] Mail clean
X-ESAFE-DETAILS:[dschafar] 

>> Since preferences APIs are generally built on top of persistence  
>> APIs, it might be more valuable to write a persistence demo - I'd  
>> especially like to see an example that uses the JNLP APIs to  
>> support local storage in untrusted code. That way, readers can  
>> apply the example to a wider range of use cases.
>
> Ok, that's why I was thinking of a simple TODO List ... otherwise
> ideas (as you said, saving/loading the current window position, etc
> could be enough) ?

I think it would be more valuable to show a "persistence" example than  
a "preferences" example, since you can build preferences on top of  
persistence.

> And a last thing, to use Web Start, I have to put also a jnlp file
> (and jnlp files must have the right codebase path inside them, or
> there should be a servlet that handle this ...), but we need to
> publish also this stuff inside the demos, if i remember well you or
> Todd have done an ant task to package a webapp, right ? Or put this
> only on wiki with only an on-line demo (with source code) ?
> Should i use something like this ? Ideas / suggestions ?

You should be able to add a JSP to the demos WAR that generates a JNLP  
file with the correct codebase.


Re: Persistence (was: Re: Preferences Demo)

Posted by Sandro Martini <sa...@gmail.com>.
Hi Thomas,
sorry for the delay in the answer ... I'm come more from Java
Enterprise than in core Pivot, but I'll try to give an answer. Tell me
if some things are not clear, or for problems.

> Is there currently a possibility, or could it be made possible,
> to bind Entity Objects (used in a pivot application as storage for the ui)
> via JDBC to Rows in a Database? Without going through the
> web services of an application server?
> An ORM Framework could be used, though.
Here you are speaking of EJB Entity, right ?

I don't think it's the right thing to make JDBC calls directly (in
intranet environments could be right, but via Internet not, for
firewall polices, etc).
If I remember well, EJB could be published in remote (via their Remote
interface, if implemented) via RMI, but probably in this case you'll
have to bind to some vendor-specific class (like for JNDI lookup,
etc).

Otherwise I suggest to you to use other ways to publish your remote
objects, for example you can use Spring Remoting, Hessian, Burlap,
RMI, or one solution that i like very much: cajo (
https://cajo.dev.java.net/ ).
Or expose them as Web Services (for example XFire, or the newer Apache
CXF), or an in-house solution to expose your data in xml, json, or
other formats.

Many time ago I wrote an application that used Java Serialization to
exchange Java (Serializable) Objects (for example a Map containing all
your business data with any record contained in a POJO) between a Java
Client (Applet or Web Start) and a Java Server, via HTTP, and in Pivot
this is done using the BinarySerializer.
And in Pivot now we have other Serializers.

As a sample you can read this:
http://cwiki.apache.org/PIVOT/web-queries.html
on Web Query and related classes (some for Client and some for Server).


> And another one: is it possible (there might even be a sample somewhere)
> to easily create a transparent web service on some "dumb" appserver,
> which just routes the requests via JDBC to a database?
This depends on your server-side architecture, but many modern
frameworks have something like this, but always transforming the data,
and not with straight JDBC (time ago I've seen some products that
implements a sort of DB Proxy, and let your application connect to it
instead of the real DB, but I've never used them, sorry).
In any case, in Pivot something is done by the
org.apache.pivot.web.server.QueryServlet.
For this Todd or Greg can explain better how it work, but we should
have a Tutorial on this.


> Maybe even with authentication of the database passed through
> (perhaps as a simple "https://login"-Webservice).
> No session pooling wanted, just 1:1 cookie-sessions : db-sessions.
This is a complex problem: if you use Basic authentication, ok.
We have in stand-by something for Digest authentication, but at the
moment it's not tested on many environments, and it's not public.
Then, if you use other authentication methods (usually application
server specific) this could become difficult, or require to use some
vendor-specific code and libraries.


> I have found http://sqlrest.sourceforge.net/ , but has anyone
> tried such a thing, maybe with Pivot?
I don't know, it looks interesting, but I've never used it ... maybe
in the future.


Comments ?


Bye,
Sandro

Re: Persistence (was: Re: Preferences Demo)

Posted by Todd Volkert <tv...@gmail.com>.
I realized that Thomas probably intended to only send the message to
pivot-user, so he may not have gotten the reply on pivot-dev...

-T

On Fri, Aug 21, 2009 at 11:52 AM, Greg Brown <gk...@mac.com> wrote:

> Is there currently a possibility, or could it be made possible,
>> to bind Entity Objects (used in a pivot application as storage for the ui)
>> via JDBC to Rows in a Database? Without going through the
>> web services of an application server?
>> An ORM Framework could be used, though.
>>
>
> I'm not terribly familiar with Java EE terminology, but are the entity
> objects Java Beans? If so, you should already be able to bind to them.
>
>  And another one: is it possible (there might even be a sample somewhere)
>> to easily create a transparent web service on some "dumb" appserver,
>> which just routes the requests via JDBC to a database?
>> Maybe even with authentication of the database passed through
>> (perhaps as a simple "https://login"-Webservice).
>> No session pooling wanted, just 1:1 cookie-sessions : db-sessions.
>> I have found http://sqlrest.sourceforge.net/ , but has anyone
>> tried such a thing, maybe with Pivot?
>>
>
> I have toyed with the idea of creating something like this for a couple of
> years. For standalone tables, it's pretty easy to visualize. When you get
> into joined tables, though, it gets tougher. It would be useful, though.
>
>
>

Re: Persistence (was: Re: Preferences Demo)

Posted by Greg Brown <gk...@mac.com>.
> Is there currently a possibility, or could it be made possible,
> to bind Entity Objects (used in a pivot application as storage for  
> the ui)
> via JDBC to Rows in a Database? Without going through the
> web services of an application server?
> An ORM Framework could be used, though.

I'm not terribly familiar with Java EE terminology, but are the entity  
objects Java Beans? If so, you should already be able to bind to them.

> And another one: is it possible (there might even be a sample  
> somewhere)
> to easily create a transparent web service on some "dumb" appserver,
> which just routes the requests via JDBC to a database?
> Maybe even with authentication of the database passed through
> (perhaps as a simple "https://login"-Webservice).
> No session pooling wanted, just 1:1 cookie-sessions : db-sessions.
> I have found http://sqlrest.sourceforge.net/ , but has anyone
> tried such a thing, maybe with Pivot?

I have toyed with the idea of creating something like this for a  
couple of years. For standalone tables, it's pretty easy to visualize.  
When you get into joined tables, though, it gets tougher. It would be  
useful, though.



Re: Persistence (was: Re: Preferences Demo)

Posted by Sandro Martini <sa...@gmail.com>.
Hi Thomas,
sorry for the delay in the answer ... I'm come more from Java
Enterprise than in core Pivot, but I'll try to give an answer. Tell me
if some things are not clear, or for problems.

> Is there currently a possibility, or could it be made possible,
> to bind Entity Objects (used in a pivot application as storage for the ui)
> via JDBC to Rows in a Database? Without going through the
> web services of an application server?
> An ORM Framework could be used, though.
Here you are speaking of EJB Entity, right ?

I don't think it's the right thing to make JDBC calls directly (in
intranet environments could be right, but via Internet not, for
firewall polices, etc).
If I remember well, EJB could be published in remote (via their Remote
interface, if implemented) via RMI, but probably in this case you'll
have to bind to some vendor-specific class (like for JNDI lookup,
etc).

Otherwise I suggest to you to use other ways to publish your remote
objects, for example you can use Spring Remoting, Hessian, Burlap,
RMI, or one solution that i like very much: cajo (
https://cajo.dev.java.net/ ).
Or expose them as Web Services (for example XFire, or the newer Apache
CXF), or an in-house solution to expose your data in xml, json, or
other formats.

Many time ago I wrote an application that used Java Serialization to
exchange Java (Serializable) Objects (for example a Map containing all
your business data with any record contained in a POJO) between a Java
Client (Applet or Web Start) and a Java Server, via HTTP, and in Pivot
this is done using the BinarySerializer.
And in Pivot now we have other Serializers.

As a sample you can read this:
http://cwiki.apache.org/PIVOT/web-queries.html
on Web Query and related classes (some for Client and some for Server).


> And another one: is it possible (there might even be a sample somewhere)
> to easily create a transparent web service on some "dumb" appserver,
> which just routes the requests via JDBC to a database?
This depends on your server-side architecture, but many modern
frameworks have something like this, but always transforming the data,
and not with straight JDBC (time ago I've seen some products that
implements a sort of DB Proxy, and let your application connect to it
instead of the real DB, but I've never used them, sorry).
In any case, in Pivot something is done by the
org.apache.pivot.web.server.QueryServlet.
For this Todd or Greg can explain better how it work, but we should
have a Tutorial on this.


> Maybe even with authentication of the database passed through
> (perhaps as a simple "https://login"-Webservice).
> No session pooling wanted, just 1:1 cookie-sessions : db-sessions.
This is a complex problem: if you use Basic authentication, ok.
We have in stand-by something for Digest authentication, but at the
moment it's not tested on many environments, and it's not public.
Then, if you use other authentication methods (usually application
server specific) this could become difficult, or require to use some
vendor-specific code and libraries.


> I have found http://sqlrest.sourceforge.net/ , but has anyone
> tried such a thing, maybe with Pivot?
I don't know, it looks interesting, but I've never used it ... maybe
in the future.


Comments ?


Bye,
Sandro