You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Yvon Pedron <pe...@club-internet.fr> on 2000/10/10 10:26:51 UTC

Cocoon & EJB

Hello,

The list of platforms where Cocoon has been run successfully can be
updated with the following configuration:

OS:  Linux Mandrake 7.0 (Kernel 2.2.14-15mdk)  
EJB server: Orion/1.0.3 
JVM: Sun JDK 1.3.0rc1

I have been able to run most of the samples.

I had some troubles with the classpath used by Orion; the default
launcher does not allow compilation of XSP pages.

I have performed some tests with the LDAP processor (using Openldap
server) and with the SQL processor (using sybase).

Finally, I have checked the access to EJB from XSP page and I have been
able  to generate dynamically XML documents within a session bean and
post-process them with XSLT (2 methods have been used: transfering text
from EJB to the XSP page and transfering a Document object(DOM) from the
EJB to the XSP page).

I can provide details on demand. As I am new on the list, I don't know
if such topics have been addressed.

YP

Re: Cocoon & EJB

Posted by YP <pe...@club-internet.fr>.
Hello,

As I have received off-list some responses to my contribution I would
like to point that there is a need to facilitate the collaboration
between XSP pages and EJB.

As Michael suggested (Message "EJB setup") , it would be fine to start
such a work. 

Creating an EJB logicsheet could do the job but its seems to be a
tedious task. There should be a way to provide lightweight extension to
the XSP pages (similarly to JSP tags).

With respect to the insertion of computed XML in an XSP page I think it
worth opening another thread.


In addition, the FAQ does not say much on how to call EJB from XSP so
here is how I have done:

<!-- Some imports are required for the XSP to compile -->
<xsp:structure>
<xsp:include>javax.ejb.*</xsp:include>
<xsp:include>javax.naming.*</xsp:include>
<xsp:include>javax.rmi.PortableRemoteObject</xsp:include>

<!--  Remote and Home references --> 
<xsp:include>xxx.MyRemote </xsp:include>
<xsp:include>xxx.MyRemoteHome </xsp:include>
</xsp:structure>
...

<xsp:logic>
	// The remote reference is made available for the session
	MyRemote myRemote = (MyRemote)session.getAttribute("MyRemote");
	if ( myRemote == null){
		// if it does not exist create it
	 	Context context = new InitialContext();
		MyRemoteHome home = (MyRemoteHome) 
context.lookup("java:comp/env/MyRemote");
		myRemote = home.create();
		// save it in the session object
		session.setAttribute("MyRemote",myRemote);
        }

</xsp:logic>
              
...
use "myRemote" as intended


It is also possible to wrap this logic in some helper class thus
simplifying the code.

Cheers,

Yvon