Hi Emmanuel,

Thanks for your answer. But I have an additional question.

I like your alternative with the BlockingParticipant.
Could you tell me more about the implementation of this.
I added a new participant before the site file in the participants.xml: 

        <!-- create the database structure -->
        <participant param="com.acrolinx.portal.generic.Setup"
 
blocking="true">CreateDatabaseStructureParticipant</participant>

Must the class that is given in 'param' be an implementation of the
Participant interface?
Do you have a sample implementation for me?
What's the function of the value? e.g.:
'CreateDatabaseStructureParticipant'

Cheers,
Lars

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Emmanuel Okyere
> Sent: 19 December 2005 23:12
> To: RIFE users list : questions, bug reports and suggestions.
> Subject: Re: [Rife-users] run java code directly after 
> starting the web server
> 
> 
> Look at the ~.engine.ElementDeployer class. A typical 
> implementation (this an earlier version of something I had 
> for my Account element) looks like the one i've pasted below.
> 
> Alternatively, you could create a BlockingParticipant (maybe called
> Setup) and put all the setup-specific code there, and add it 
> to the repository configuration.
> 
> hth,
> -- eokyere
> 
>       public static class Deployer extends ElementDeployer {
>               public void deploy() throws EngineException {
>                       Datasource ds = (Datasource) 
> getElementInfo().getProperty(DATASOURCE);
>                       try {
>                               
> DatabaseContentFactory.getInstance(ds).install();             
>               
>                       } catch (InstallContentErrorException e) {
>                               
> logger.warning(ExceptionUtils.getExceptionStackTraceMessages(e));
>                       }
> 
>                       ContentQueryManager<Account> accounts = 
> new ContentQueryManager<Account>(ds, Account.class);
>                       try {
>                               accounts.install();
>                       } catch (DatabaseException e) {
>                               
> logger.warning(ExceptionUtils.getExceptionStackTraceMessages(e));
>                       }
>                       
>                       try {
>                               
> //DatabaseUsersFactory.getInstance(ds).install();
>                               
>                               DatabaseUsers users = 
> DatabaseUsersFactory.getInstance(ds);
>                               users.install();
>                               
>                               users.addRole("admin");
>                               users.addRole("user");
> 
>                               
> DatabaseSessionsFactory.getInstance(ds).install();
>                               
> //DatabaseSessionsFactory.getInstance(ds).
> 
>                               logger.info("---------- user 
> tbls created ---------- ");
>                       } catch (DatabaseException e) {
>                               
> logger.warning(ExceptionUtils.getExceptionStackTraceMessag
> es(e));                               
>                       } catch (SessionManagerException e) {
>                               
> logger.warning(ExceptionUtils.getExceptionStackTraceMessag
> es(e));                               
>                       }
>                       
>                       
>               }
> 
>               private Logger logger = 
> Logger.getLogger(Deployer.class.getPackage().getName());
>       }
> 
> On 12/19/05, Lars Grupe <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > I would like to know if I can run java code directly after starting 
> > the web application. I would like to install the users 
> table and the 
> > sessions table in the database, directly after starting the web 
> > application the first time. Earlier I have no simple access to the 
> > config to get the datasource. And my arrival element inherits an 
> > authentication element.
> >
> > If there is no easy way to do it, I will generate the 
> database earlier 
> > and copy them into my project. But maybe there is an easy way, that 
> > you can tell me?
> >
> > Cheers,
> > Lars
> > _______________________________________________
> > Rife-users mailing list
> > [email protected] http://www.uwyn.com/mailman/listinfo/rife-users
> >
> _______________________________________________
> Rife-users mailing list
> [email protected] http://www.uwyn.com/mailman/listinfo/rife-users
> 
_______________________________________________
Rife-users mailing list
[email protected]
http://www.uwyn.com/mailman/listinfo/rife-users

Reply via email to