Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Info
titleStripes EJB3 Interceptor is superseded by [ Stripes Injection Enricher]

Stripes Injection Enricher satisfies injection points specified declaratively using standard Java EE annotations (@EJB, @Inject and @Resource).

...

Code Block
languagexml
titleMaven Configuration
<dependency> 
 <dependency>   <groupId>com.samaxes.stripes.ejb3</groupId> 
    <artifactId>stripejb3</artifactId> 
    <version>1.0.3</version> 
</dependency> 

...

Code Block
languagexml
titleUsing the EJB Interceptor with Stripes >= 1.5
 
<init-param> 
    <param-name>Interceptor.Classes</param-name> 
    <param-value>com.samaxes.stripes.ejb3.EJBInterceptor</param-value> 
</init-param> 
<!-- or --> 
<init-param> 
    <param-name>Extension.Packages</param-name> 
    <param-value>com.samaxes.stripes.ejb3</param-value> 
</init-param> 
Code Block
languagexml
titleUsing the EJB Interceptor with Stripes <= 1.4
 
<init-param> 
    <param-name>Interceptor.Classes</param-name> 
    <param-value> 
        com.samaxes.stripes.ejb3.EJBInterceptor, 
        net.sourceforge.stripes.controller.BeforeAfterMethodInterceptor
    </param-value> 
</init-param> 

...

Code Block
titleInjecting a EJB bean into an ActionBean
 
// Inject any properties that are annotated 
@EJBBean("bugManager") 
private BugManager bugManager; 

// Inject any methods that are annotated 
@EJBBean("bugManager") 
public void setBugManager(BugManager bugManager) { 
    this.bugManager = bugManager; 
} 

...

Code Block
titleAuto-wiring of EJB beans in an ActionBean
 
// Inject any properties that are annotated 
@EJBBean 
private BugManager bugManager; 

// Inject any methods that are annotated 
@EJBBean 
public void setBugManager(BugManager bugManager) { 
    this.bugManager = bugManager; 
} 

...

Code Block
titleChanging the bean JNDI binding
 
// your interface 
public interface BugManager { 
} 

// your implementation 
@Stateless 
@Local(BugManager.class) 
@LocalBinding(jndiBinding = "bugManager") 
public class BugManagerBean implements BugManager { 
} 

...

Code Block
titleInjecting a local interface into an ActionBean
 
// your bean implementation 
@Stateless(name = "bugManager", mappedName = "bugManager") 
public class BugManager implements com.Manager { 
} 

// your action bean 
@EJB(name = "bugManager", beanInterface = "com.Manager") 
public class BugActionBean { 
    @EJBBean("java:comp/env/bugManager") 
    private BugManager bugManager; 
} 

...

Code Block
titleEJBInterceptor.findEJB()
 
protected static Object findEJB(String name) { 
    // Try to lookup using the name provided 
    try { 
        if (ctx == null) { 
            Properties p = new Properties(); 
            p.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.openejb.client.LocalInitialContextFactory"); 
            ctx = new InitialContext(p); 
        } 
        Object ejb = ctx.lookup(name); 
        log.debug("Found EJB bean with name [", name, "]"); 
        return ejb; 
    } catch (NamingException e) { 
        throw new StripesRuntimeException("Unable to find EJBBean with name [" + name + 
"] in the initial context."); 
    } 
} 
Code Block
titleInjecting a local interface into an ActionBean
 
@EJBBean("BugManagerLocal") 
private BugManagerLocal bugManager;