Hello,

Thanks for the information.

I will try to follow your step until the end of the week.

I will give you my feedbacks regarding your instructions (if
there is !)

kind regards,
Adrien

---------- Initial Header -----------

From      : Diego Louzán <[EMAIL PROTECTED]>
To          : [email protected]
Cc          : 
Date      : Thu, 08 Mar 2007 10:37:55 +0100
Subject : Re: How to enable DB persistence

[EMAIL PROTECTED] escribió:
> Hello,
> 
> My question is very basic... but i am a bit confused with
> the DB persistence setup. Actually I am trying to plug the
> DB persistence for my WSRP4J producer but i did not find any
> documentation.
> 
> Does somedy know where i could find some links or a posts in
> the mailing list which describes the way to enable DB
> persistence. Unfortunately, this time google does not help
> me very much :0((
> 
> If there is no documentation, if somedy who has already ue
> the DB layer can give me some information. By this way, i
> will be able to know where to start.
> 
> Basically, i have done the following steps :
>  -  i have the deployed the test portlet on the
> wsrp4j-producer using Xml file.
>   - i have started my hsqldb database.
> 
> I have seen that i have to add a filter to the portlet.xml
> of my test portlet ... something like :
>  <portlet>
>         <portlet-name>WSRP4JTestPortlet</portlet-name>
> ...
>        
>
<portlet-class>org.apache.wsrp4j.testportlet.TestPortlet</portlet-class>
>         <init-param>
>             <name>filter.hibernate</name>
>          
>
<value>org.apache.wsrp4j.persistence.db.portlet.HibernateSessionPortletFilter</value>
>         </init-param>
>         <expiration-cache>-1</expiration-cache>
> .....
>     </portlet>
> 
> But i do not know what are the following steps ?!
> 
> Thank you by advance for you help.
> Kind regards,
> Adrien


Hello Adrien, I'm sorry I don't have the time right now for
making a
decent update to the README with full info on DB persistence
configuration (you'd be surprised how long it takes to write
that
document). That'll have to wait some days.

For now, I'll try to give you some guidance on how to
configure it:


1. You'll need some knowledge about Hibernate, so read some
tutorials if
you haven't already.



2. As you probably guessed, the db module classes are on
wsrp4j-persistence-db jar. It includes the files needed to
configure the
mapping between Java persistent classes and the DB. They are
on the jar
(the files *.hbm.xml). Unless you want an specific mapping,
you can rely
on the default configurations.



3. For testing you'll need HSQLDB. Download it and run the
server on the
localhost.



4. For wsrp4j-producer, you can follow the README.txt
instructions. Then
edit the following files:

- $TOMCAT_HOME/conf/Catalina/localhost/wsrp4j-producer.xml
    This is the tomcat dataSource configuration for
producer. Edit as
needed.

-
$TOMCAT_HOME/webapps/wsrp4j-producer/WEB-INF/server-config.wsdd
    This is the Axis configuration file. You have to enable the
request/response handlers for filtering Hibernate DB-access
operations.
Follow the comments on the file.

- $TOMCAT_HOME/webapps/wsrp4j-producer/WEB-INF/web.xml
    Uncomment the Servlet <filter> that is commented out.
This enables
the Hibernate operations on the wizard app for deploying new
portlets.

-
$TOMCAT_HOME/webapps/wsrp4j-producer/WEB-INF/classes/hibernate.cfg.xml
    The main Hibernate configuration file. For the first
time, you'll
need to automatically create the db schema. Go almost to the
end of the
file and uncomment the following code:
<property name="hbm2ddl.auto">create</property>
    That way, the schema will be created on the db the first
time you
run the webapp. After this schema is created for the first
time, you
won't need to recreate it again, so you can uncomment it
again (in fact,
if you don't uncommnent it you will loose all changes in the
db each
time you rerun tomcat).

-
$TOMCAT_HOME/webapps/wsrp4j-producer/WEB-INF/classes/wsrp4j-config.xml
    You have to configure the property
wsrp4j.producer.persistent.factory to refer to the db module
factory.
Follow the comments on the file.

-
$TOMCAT_HOME/webapps/wsrp4j-producer/WEB-INF/sql/wsrp4j-producer.sql
    Before being able to use the producer, you need to
insert some
service info data on the db. Start tomcat and when the
schema is created
on the db, insert the contents on that file into the db.



5. For wsrp4j-proxyportlet, you can also follow the
README.txt and then
edit the following files:
- $TOMCAT_HOME/conf/Catalina/localhost/wsrp4j-proxyportlet.xml
    The same as in wsrp4j-producer.
- $TOMCAT_HOME/webapps/wsrp4j-proxyportlet/WEB-INF/web.xml
-
$TOMCAT_HOME/webapps/wsrp4j-proxyportlet/WEB-INF/classes/hibernate.cfg.xml
    The same configuration as in wsrp4j-producer.
-
$TOMCAT_HOME/webapps/wsrp4j-proxyportlet/WEB-INF/classes/wsrp4j-config.xml
    The same as in wsrp4j-producer but this time the property is
wsrp4j.proxyportlet.persistent.factory.
- $TOMCAT_HOME/webapps/wsrp4j-proxyportlet/WEB-INF/portlet.xml
    Ok, this is a little bit trickier. **For each** portlet
deployed on
portlet.xml you need to enable a filter created for allowing the
portlets to access Hibernate requests. The current
proxyportlet includes
a filtering system so any <init-param> created with a <name>
in the form
"filter.<id>" will create a filter with identifier <id> for
all requests
and responses instantiating the class specified on the
<value> tag. I
know this behaviour is weird, but jsr-168 doesn't specify a
standard way
of filtering for porltets, some mechanism similar as for
servlets. The
new portlet 2.0 spec addresses this issue.
    Just uncomment the filter on all portlets. Remember that
if you add
a new portlet, you'll have to add the filter info yourself
(unfortunately, the deploy webapp right now doesn't add this
filtering
information).
-
$TOMCAT_HOME/webapps/wsrp4j-proxyportlet/WEB-INF/sql/wsrp4j-proxyportlet.sql
    The same as in wsrp4j-producer, you need the actual data
inserted on
the db.


I think that's all. Hope that helps.

Regards.
Diego.


--------------------- ALICE SECURITE ENFANTS ---------------------
Protégez vos enfants des dangers d'Internet en installant Sécurité Enfants, le 
contrôle parental d'Alice.
http://www.aliceadsl.fr/securitepc/default_copa.asp


Reply via email to