You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Dwi Ardi Irawan <dw...@srw.iao.co.id> on 2007/07/18 15:36:34 UTC

Integarting EJB 3 to Tapestry 4

i've been curious on EJB...
and already search the archive in this mailing list
one of that is the post from :
http://www.nabble.com/Inject-EJB-3-into-Tapestry-4-page-tf2841494.html#a8468544

but i still don't get the idea.

i change the code (becouse it gives me some err when i follow the 
intruction from the sender above)

*hivemodule.xml*
=======================================================================

<?xml version="1.0"?>
<module id="app" version="1.0.0">
    <service-point id="EJBObjectProvider" 
interface="org.apache.hivemind.service.ObjectProvider">
    <invoke-factory>
        <construct class="hivemindModule.EJBObjectProvider">
         <set-object property="applicationStateManager" 
value="infrastructure:applicationStateManager"/>
        </construct>
    </invoke-factory>
    </service-point>
    <contribution configuration-id="hivemind.ObjectProviders">
      <provider prefix="ejb" service-id="EJBObjectProvider"/>
    </contribution> 
</module>

*EJBObjectProvider.java*
=======================================================================
package hivemindModule;

import javax.naming.InitialContext;
import javax.naming.NamingException;

import org.apache.hivemind.Location;
import org.apache.hivemind.internal.Module;
import org.apache.hivemind.service.ObjectProvider;

public class EJBObjectProvider implements ObjectProvider {
    InitialContext context;
    Object result;
   
   
    public Object provideObject(Module module, Class propertyType, 
String locator, Location location) {
        try {
            context = new InitialContext();
            result = context.lookup(locator);
        } catch (NamingException e) {
            e.printStackTrace();
        }
        return result;
    }
}


============================================================================

*Home.java

============================================================================
*
import org.apache.tapestry.annotations.InjectObject;
import org.apache.tapestry.html.BasePage;

import edu.guestbook.bean.MessageManagerBean;


public abstract class Home extends BasePage {
    @InjectObject("ejb:MessageManagerBean")
    public abstract MessageManagerBean messageManagerBean();
   
    ..........................
       
}
*

===================================================================

myQuestion :*

how can i get my my EJB Bean Interface like i did it in JSP.

try{
        InitialContext ic = new InitialContext();
        MessageLocal address = (MessageLocal)ic.lookup("AddressBean");
       address.writeMessageHello();
       
    }catch(NamingException e){
       
    }


thnx


dwi ardi irawan