<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java%2FEJB3%2FInjection</id>
		<title>Java/EJB3/Injection - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://jexp.ru/index.php?action=history&amp;feed=atom&amp;title=Java%2FEJB3%2FInjection"/>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/EJB3/Injection&amp;action=history"/>
		<updated>2026-04-13T08:26:16Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/EJB3/Injection&amp;diff=7755&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/EJB3/Injection&amp;diff=7755&amp;oldid=prev"/>
				<updated>2010-06-01T06:50:25Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 06:50, 1 июня 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	<entry>
		<id>http://jexp.ru/index.php?title=Java/EJB3/Injection&amp;diff=7754&amp;oldid=prev</id>
		<title> в 18:01, 31 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://jexp.ru/index.php?title=Java/EJB3/Injection&amp;diff=7754&amp;oldid=prev"/>
				<updated>2010-05-31T18:01:45Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== EJB Tutorial from JBoss: Injection ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
File: CalculatorBean.java&lt;br /&gt;
/*&lt;br /&gt;
 * JBoss, Home of Professional Open Source.&lt;br /&gt;
 * Copyright 2006, Red Hat Middleware LLC, and individual contributors&lt;br /&gt;
 * as indicated by the @author tags. See the copyright.txt file in the&lt;br /&gt;
 * distribution for a full listing of individual contributors.&lt;br /&gt;
 *&lt;br /&gt;
 * This is free software; you can redistribute it and/or modify it&lt;br /&gt;
 * under the terms of the GNU Lesser General Public License as&lt;br /&gt;
 * published by the Free Software Foundation; either version 2.1 of&lt;br /&gt;
 * the License, or (at your option) any later version.&lt;br /&gt;
 *&lt;br /&gt;
 * This software is distributed in the hope that it will be useful,&lt;br /&gt;
 * but WITHOUT ANY WARRANTY; without even the implied warranty of&lt;br /&gt;
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU&lt;br /&gt;
 * Lesser General Public License for more details.&lt;br /&gt;
 *&lt;br /&gt;
 * You should have received a copy of the GNU Lesser General Public&lt;br /&gt;
 * License along with this software; if not, write to the Free&lt;br /&gt;
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA&lt;br /&gt;
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.&lt;br /&gt;
 */&lt;br /&gt;
package org.jboss.tutorial.injection.bean;&lt;br /&gt;
import javax.ejb.Stateless;&lt;br /&gt;
@Stateless&lt;br /&gt;
public class CalculatorBean implements Calculator&lt;br /&gt;
{&lt;br /&gt;
   public int add(int x, int y)&lt;br /&gt;
   {&lt;br /&gt;
      return x + y;&lt;br /&gt;
   }&lt;br /&gt;
   public int subtract(int x, int y)&lt;br /&gt;
   {&lt;br /&gt;
      return x - y;&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
File: ShoppingCart.java&lt;br /&gt;
/*&lt;br /&gt;
 * JBoss, Home of Professional Open Source.&lt;br /&gt;
 * Copyright 2006, Red Hat Middleware LLC, and individual contributors&lt;br /&gt;
 * as indicated by the @author tags. See the copyright.txt file in the&lt;br /&gt;
 * distribution for a full listing of individual contributors.&lt;br /&gt;
 *&lt;br /&gt;
 * This is free software; you can redistribute it and/or modify it&lt;br /&gt;
 * under the terms of the GNU Lesser General Public License as&lt;br /&gt;
 * published by the Free Software Foundation; either version 2.1 of&lt;br /&gt;
 * the License, or (at your option) any later version.&lt;br /&gt;
 *&lt;br /&gt;
 * This software is distributed in the hope that it will be useful,&lt;br /&gt;
 * but WITHOUT ANY WARRANTY; without even the implied warranty of&lt;br /&gt;
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU&lt;br /&gt;
 * Lesser General Public License for more details.&lt;br /&gt;
 *&lt;br /&gt;
 * You should have received a copy of the GNU Lesser General Public&lt;br /&gt;
 * License along with this software; if not, write to the Free&lt;br /&gt;
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA&lt;br /&gt;
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.&lt;br /&gt;
 */&lt;br /&gt;
package org.jboss.tutorial.injection.bean;&lt;br /&gt;
import java.util.HashMap;&lt;br /&gt;
import javax.ejb.Remove;&lt;br /&gt;
public interface ShoppingCart&lt;br /&gt;
{&lt;br /&gt;
   void buy(String product, int quantity);&lt;br /&gt;
   HashMap&amp;lt;String, Integer&amp;gt; getCartContents();&lt;br /&gt;
   @Remove void checkout();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
File: ShoppingCartBean.java&lt;br /&gt;
/*&lt;br /&gt;
 * JBoss, Home of Professional Open Source.&lt;br /&gt;
 * Copyright 2006, Red Hat Middleware LLC, and individual contributors&lt;br /&gt;
 * as indicated by the @author tags. See the copyright.txt file in the&lt;br /&gt;
 * distribution for a full listing of individual contributors.&lt;br /&gt;
 *&lt;br /&gt;
 * This is free software; you can redistribute it and/or modify it&lt;br /&gt;
 * under the terms of the GNU Lesser General Public License as&lt;br /&gt;
 * published by the Free Software Foundation; either version 2.1 of&lt;br /&gt;
 * the License, or (at your option) any later version.&lt;br /&gt;
 *&lt;br /&gt;
 * This software is distributed in the hope that it will be useful,&lt;br /&gt;
 * but WITHOUT ANY WARRANTY; without even the implied warranty of&lt;br /&gt;
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU&lt;br /&gt;
 * Lesser General Public License for more details.&lt;br /&gt;
 *&lt;br /&gt;
 * You should have received a copy of the GNU Lesser General Public&lt;br /&gt;
 * License along with this software; if not, write to the Free&lt;br /&gt;
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA&lt;br /&gt;
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.&lt;br /&gt;
 */&lt;br /&gt;
package org.jboss.tutorial.injection.bean;&lt;br /&gt;
import java.util.HashMap;&lt;br /&gt;
import javax.ejb.EJB;&lt;br /&gt;
import javax.ejb.Remote;&lt;br /&gt;
import javax.ejb.Remove;&lt;br /&gt;
import javax.ejb.Stateful;&lt;br /&gt;
&lt;br /&gt;
@Stateful&lt;br /&gt;
@Remote(ShoppingCart.class)&lt;br /&gt;
public class ShoppingCartBean implements ShoppingCart, java.io.Serializable&lt;br /&gt;
{&lt;br /&gt;
   private HashMap&amp;lt;String, Integer&amp;gt; cart = new HashMap&amp;lt;String, Integer&amp;gt;();&lt;br /&gt;
   @EJB&lt;br /&gt;
   private Calculator calculator;&lt;br /&gt;
&lt;br /&gt;
   private Calculator set;&lt;br /&gt;
   @EJB(beanName=&amp;quot;CalculatorBean&amp;quot;)&lt;br /&gt;
   public void setCalculator(Calculator c)&lt;br /&gt;
   {&lt;br /&gt;
      set = c;&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   public void buy(String product, int quantity)&lt;br /&gt;
   {&lt;br /&gt;
      if (cart.containsKey(product))&lt;br /&gt;
      {&lt;br /&gt;
         int currq = cart.get(product);&lt;br /&gt;
         currq = calculator.add(currq, quantity);&lt;br /&gt;
         cart.put(product, currq);&lt;br /&gt;
      }&lt;br /&gt;
      else&lt;br /&gt;
      {&lt;br /&gt;
         cart.put(product, quantity);&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
   public HashMap&amp;lt;String, Integer&amp;gt; getCartContents()&lt;br /&gt;
   {&lt;br /&gt;
      return cart;&lt;br /&gt;
   }&lt;br /&gt;
   @Remove&lt;br /&gt;
   public void checkout()&lt;br /&gt;
   {&lt;br /&gt;
      System.out.println(&amp;quot;To be implemented&amp;quot;);&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
File: Calculator.java&lt;br /&gt;
/*&lt;br /&gt;
 * JBoss, Home of Professional Open Source.&lt;br /&gt;
 * Copyright 2006, Red Hat Middleware LLC, and individual contributors&lt;br /&gt;
 * as indicated by the @author tags. See the copyright.txt file in the&lt;br /&gt;
 * distribution for a full listing of individual contributors.&lt;br /&gt;
 *&lt;br /&gt;
 * This is free software; you can redistribute it and/or modify it&lt;br /&gt;
 * under the terms of the GNU Lesser General Public License as&lt;br /&gt;
 * published by the Free Software Foundation; either version 2.1 of&lt;br /&gt;
 * the License, or (at your option) any later version.&lt;br /&gt;
 *&lt;br /&gt;
 * This software is distributed in the hope that it will be useful,&lt;br /&gt;
 * but WITHOUT ANY WARRANTY; without even the implied warranty of&lt;br /&gt;
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU&lt;br /&gt;
 * Lesser General Public License for more details.&lt;br /&gt;
 *&lt;br /&gt;
 * You should have received a copy of the GNU Lesser General Public&lt;br /&gt;
 * License along with this software; if not, write to the Free&lt;br /&gt;
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA&lt;br /&gt;
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.&lt;br /&gt;
 */&lt;br /&gt;
package org.jboss.tutorial.injection.bean;&lt;br /&gt;
public interface Calculator&lt;br /&gt;
{&lt;br /&gt;
   int add(int x, int y);&lt;br /&gt;
   int subtract(int x, int y);&lt;br /&gt;
}&lt;br /&gt;
File: Client.java&lt;br /&gt;
/*&lt;br /&gt;
 * JBoss, Home of Professional Open Source.&lt;br /&gt;
 * Copyright 2006, Red Hat Middleware LLC, and individual contributors&lt;br /&gt;
 * as indicated by the @author tags. See the copyright.txt file in the&lt;br /&gt;
 * distribution for a full listing of individual contributors.&lt;br /&gt;
 *&lt;br /&gt;
 * This is free software; you can redistribute it and/or modify it&lt;br /&gt;
 * under the terms of the GNU Lesser General Public License as&lt;br /&gt;
 * published by the Free Software Foundation; either version 2.1 of&lt;br /&gt;
 * the License, or (at your option) any later version.&lt;br /&gt;
 *&lt;br /&gt;
 * This software is distributed in the hope that it will be useful,&lt;br /&gt;
 * but WITHOUT ANY WARRANTY; without even the implied warranty of&lt;br /&gt;
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU&lt;br /&gt;
 * Lesser General Public License for more details.&lt;br /&gt;
 *&lt;br /&gt;
 * You should have received a copy of the GNU Lesser General Public&lt;br /&gt;
 * License along with this software; if not, write to the Free&lt;br /&gt;
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA&lt;br /&gt;
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.&lt;br /&gt;
 */&lt;br /&gt;
package org.jboss.tutorial.injection.client;&lt;br /&gt;
&lt;br /&gt;
import org.jboss.tutorial.injection.bean.ShoppingCart;&lt;br /&gt;
import javax.naming.InitialContext;&lt;br /&gt;
import java.util.HashMap;&lt;br /&gt;
/**&lt;br /&gt;
 * Comment&lt;br /&gt;
 *&lt;br /&gt;
 * @author &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Field Injection ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
File: AnotherBean.java&lt;br /&gt;
import javax.ejb.Stateless;&lt;br /&gt;
@Stateless&lt;br /&gt;
public class AnotherBean implements AnotherBeanLocal {&lt;br /&gt;
  public void doAnother(){&lt;br /&gt;
    System.out.println(&amp;quot;from another bean&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
File: AnotherBeanLocal.java&lt;br /&gt;
&lt;br /&gt;
public interface AnotherBeanLocal {&lt;br /&gt;
  public void doAnother();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
File: Employee.java&lt;br /&gt;
&lt;br /&gt;
import javax.persistence.Entity;&lt;br /&gt;
import javax.persistence.EntityListeners;&lt;br /&gt;
import javax.persistence.GeneratedValue;&lt;br /&gt;
import javax.persistence.Id;&lt;br /&gt;
import javax.persistence.PostRemove;&lt;br /&gt;
&lt;br /&gt;
@Entity&lt;br /&gt;
public class Employee implements java.io.Serializable {&lt;br /&gt;
  private int id;&lt;br /&gt;
  private String firstName;&lt;br /&gt;
  private String lastName;&lt;br /&gt;
  @Id&lt;br /&gt;
  @GeneratedValue&lt;br /&gt;
  public int getId() {&lt;br /&gt;
    return id;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  @PostRemove&lt;br /&gt;
  public void postRemove()&lt;br /&gt;
  {&lt;br /&gt;
     System.out.println(&amp;quot;@PostRemove&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public void setId(int id) {&lt;br /&gt;
    this.id = id;&lt;br /&gt;
  }&lt;br /&gt;
  public String getFirstName() {&lt;br /&gt;
    return firstName;&lt;br /&gt;
  }&lt;br /&gt;
  public void setFirstName(String first) {&lt;br /&gt;
    this.firstName = first;&lt;br /&gt;
  }&lt;br /&gt;
  public String getLastName() {&lt;br /&gt;
    return lastName;&lt;br /&gt;
  }&lt;br /&gt;
  public void setLastName(String last) {&lt;br /&gt;
    this.lastName = last;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
File: EmployeeBean.java&lt;br /&gt;
import javax.annotation.Resource;&lt;br /&gt;
import javax.ejb.EJB;&lt;br /&gt;
import javax.ejb.SessionContext;&lt;br /&gt;
import javax.ejb.Stateless;&lt;br /&gt;
@Stateless&lt;br /&gt;
public class EmployeeBean implements EmployeeServiceLocal, EmployeeServiceRemote {&lt;br /&gt;
  @EJB AnotherBeanLocal a;&lt;br /&gt;
  public EmployeeBean() {&lt;br /&gt;
  }&lt;br /&gt;
  public void doAction() {&lt;br /&gt;
    System.out.println(&amp;quot;doAction&amp;quot;);&lt;br /&gt;
    a.doAnother();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
File: EmployeeServiceLocal.java&lt;br /&gt;
import java.util.Map;&lt;br /&gt;
import javax.ejb.Local;&lt;br /&gt;
&lt;br /&gt;
@Local&lt;br /&gt;
public interface EmployeeServiceLocal {&lt;br /&gt;
  public void doAction();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
File: EmployeeServiceRemote.java&lt;br /&gt;
&lt;br /&gt;
import javax.ejb.Remote;&lt;br /&gt;
@Remote&lt;br /&gt;
public interface EmployeeServiceRemote {&lt;br /&gt;
  public void doAction();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
File: jndi.properties&lt;br /&gt;
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory&lt;br /&gt;
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces&lt;br /&gt;
java.naming.provider.url=localhost:1099&lt;br /&gt;
&lt;br /&gt;
File: Main.java&lt;br /&gt;
import javax.ejb.EJB;&lt;br /&gt;
import javax.naming.InitialContext;&lt;br /&gt;
public class Main {&lt;br /&gt;
  &lt;br /&gt;
  public static void main(String[] a) throws Exception {&lt;br /&gt;
    EmployeeServiceRemote service = null;&lt;br /&gt;
    // Context compEnv = (Context) new InitialContext().lookup(&amp;quot;java:comp/env&amp;quot;);&lt;br /&gt;
    // service = (HelloService)new InitialContext().lookup(&amp;quot;java:comp/env/ejb/HelloService&amp;quot;);&lt;br /&gt;
    service = (EmployeeServiceRemote) new InitialContext().lookup(&amp;quot;EmployeeBean/remote&amp;quot;);&lt;br /&gt;
    service.doAction();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setter Injection ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
File: AnotherBean.java&lt;br /&gt;
import javax.ejb.Stateless;&lt;br /&gt;
@Stateless&lt;br /&gt;
public class AnotherBean implements AnotherBeanLocal {&lt;br /&gt;
  public void doAnother(){&lt;br /&gt;
    System.out.println(&amp;quot;from another bean&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
File: AnotherBeanLocal.java&lt;br /&gt;
&lt;br /&gt;
public interface AnotherBeanLocal {&lt;br /&gt;
  public void doAnother();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
File: Employee.java&lt;br /&gt;
&lt;br /&gt;
import javax.persistence.Entity;&lt;br /&gt;
import javax.persistence.EntityListeners;&lt;br /&gt;
import javax.persistence.GeneratedValue;&lt;br /&gt;
import javax.persistence.Id;&lt;br /&gt;
import javax.persistence.PostRemove;&lt;br /&gt;
&lt;br /&gt;
@Entity&lt;br /&gt;
public class Employee implements java.io.Serializable {&lt;br /&gt;
  private int id;&lt;br /&gt;
  private String firstName;&lt;br /&gt;
  private String lastName;&lt;br /&gt;
  @Id&lt;br /&gt;
  @GeneratedValue&lt;br /&gt;
  public int getId() {&lt;br /&gt;
    return id;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  @PostRemove&lt;br /&gt;
  public void postRemove()&lt;br /&gt;
  {&lt;br /&gt;
     System.out.println(&amp;quot;@PostRemove&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public void setId(int id) {&lt;br /&gt;
    this.id = id;&lt;br /&gt;
  }&lt;br /&gt;
  public String getFirstName() {&lt;br /&gt;
    return firstName;&lt;br /&gt;
  }&lt;br /&gt;
  public void setFirstName(String first) {&lt;br /&gt;
    this.firstName = first;&lt;br /&gt;
  }&lt;br /&gt;
  public String getLastName() {&lt;br /&gt;
    return lastName;&lt;br /&gt;
  }&lt;br /&gt;
  public void setLastName(String last) {&lt;br /&gt;
    this.lastName = last;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
File: EmployeeBean.java&lt;br /&gt;
import javax.annotation.Resource;&lt;br /&gt;
import javax.ejb.EJB;&lt;br /&gt;
import javax.ejb.SessionContext;&lt;br /&gt;
import javax.ejb.Stateless;&lt;br /&gt;
@Stateless&lt;br /&gt;
public class EmployeeBean implements EmployeeServiceLocal, EmployeeServiceRemote {&lt;br /&gt;
  private AnotherBeanLocal a;&lt;br /&gt;
  @EJB&lt;br /&gt;
  public void setAuditService(AnotherBeanLocal audit) {&lt;br /&gt;
      this.a = audit;&lt;br /&gt;
  }&lt;br /&gt;
  public EmployeeBean() {&lt;br /&gt;
  }&lt;br /&gt;
  public void doAction() {&lt;br /&gt;
    System.out.println(&amp;quot;doAction&amp;quot;);&lt;br /&gt;
    a.doAnother();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
File: EmployeeServiceLocal.java&lt;br /&gt;
import java.util.Map;&lt;br /&gt;
import javax.ejb.Local;&lt;br /&gt;
&lt;br /&gt;
@Local&lt;br /&gt;
public interface EmployeeServiceLocal {&lt;br /&gt;
  public void doAction();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
File: EmployeeServiceRemote.java&lt;br /&gt;
&lt;br /&gt;
import javax.ejb.Remote;&lt;br /&gt;
@Remote&lt;br /&gt;
public interface EmployeeServiceRemote {&lt;br /&gt;
  public void doAction();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
File: jndi.properties&lt;br /&gt;
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory&lt;br /&gt;
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces&lt;br /&gt;
java.naming.provider.url=localhost:1099&lt;br /&gt;
&lt;br /&gt;
File: Main.java&lt;br /&gt;
import javax.ejb.EJB;&lt;br /&gt;
import javax.naming.InitialContext;&lt;br /&gt;
public class Main {&lt;br /&gt;
  &lt;br /&gt;
  public static void main(String[] a) throws Exception {&lt;br /&gt;
    EmployeeServiceRemote service = null;&lt;br /&gt;
    // Context compEnv = (Context) new InitialContext().lookup(&amp;quot;java:comp/env&amp;quot;);&lt;br /&gt;
    // service = (HelloService)new InitialContext().lookup(&amp;quot;java:comp/env/ejb/HelloService&amp;quot;);&lt;br /&gt;
    service = (EmployeeServiceRemote) new InitialContext().lookup(&amp;quot;EmployeeBean/remote&amp;quot;);&lt;br /&gt;
    service.doAction();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Use EJB To Reference Another EJB In One EJB ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
File: AnotherBeanLocal.java&lt;br /&gt;
&lt;br /&gt;
public interface AnotherBeanLocal {&lt;br /&gt;
  public void doAnother();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
File: Employee.java&lt;br /&gt;
&lt;br /&gt;
import javax.persistence.Entity;&lt;br /&gt;
import javax.persistence.EntityListeners;&lt;br /&gt;
import javax.persistence.GeneratedValue;&lt;br /&gt;
import javax.persistence.Id;&lt;br /&gt;
import javax.persistence.PostRemove;&lt;br /&gt;
&lt;br /&gt;
@Entity&lt;br /&gt;
public class Employee implements java.io.Serializable {&lt;br /&gt;
  private int id;&lt;br /&gt;
  private String firstName;&lt;br /&gt;
  private String lastName;&lt;br /&gt;
  @Id&lt;br /&gt;
  @GeneratedValue&lt;br /&gt;
  public int getId() {&lt;br /&gt;
    return id;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  @PostRemove&lt;br /&gt;
  public void postRemove()&lt;br /&gt;
  {&lt;br /&gt;
     System.out.println(&amp;quot;@PostRemove&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public void setId(int id) {&lt;br /&gt;
    this.id = id;&lt;br /&gt;
  }&lt;br /&gt;
  public String getFirstName() {&lt;br /&gt;
    return firstName;&lt;br /&gt;
  }&lt;br /&gt;
  public void setFirstName(String first) {&lt;br /&gt;
    this.firstName = first;&lt;br /&gt;
  }&lt;br /&gt;
  public String getLastName() {&lt;br /&gt;
    return lastName;&lt;br /&gt;
  }&lt;br /&gt;
  public void setLastName(String last) {&lt;br /&gt;
    this.lastName = last;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
File: EmployeeBean.java&lt;br /&gt;
import javax.ejb.EJB;&lt;br /&gt;
import javax.ejb.EJBException;&lt;br /&gt;
import javax.ejb.Stateless;&lt;br /&gt;
import javax.naming.Context;&lt;br /&gt;
import javax.naming.InitialContext;&lt;br /&gt;
import javax.naming.NamingException;&lt;br /&gt;
@Stateless&lt;br /&gt;
@EJB(name = &amp;quot;audit&amp;quot;, beanInterface = AnotherBeanLocal.class)&lt;br /&gt;
public class EmployeeBean implements EmployeeServiceLocal, EmployeeServiceRemote {&lt;br /&gt;
  public EmployeeBean() {&lt;br /&gt;
  }&lt;br /&gt;
  public void doAction() {&lt;br /&gt;
    System.out.println(&amp;quot;doAction&amp;quot;);&lt;br /&gt;
    try {&lt;br /&gt;
      Context ctx = new InitialContext();&lt;br /&gt;
      AnotherBeanLocal a = (AnotherBeanLocal) ctx.lookup(&amp;quot;java:comp/env/audit&amp;quot;);&lt;br /&gt;
      a.doAnother();&lt;br /&gt;
    } catch (NamingException e) {&lt;br /&gt;
      throw new EJBException(e);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
File: EmployeeServiceLocal.java&lt;br /&gt;
import java.util.Map;&lt;br /&gt;
import javax.ejb.Local;&lt;br /&gt;
&lt;br /&gt;
@Local&lt;br /&gt;
public interface EmployeeServiceLocal {&lt;br /&gt;
  public void doAction();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
File: EmployeeServiceRemote.java&lt;br /&gt;
&lt;br /&gt;
import javax.ejb.Remote;&lt;br /&gt;
@Remote&lt;br /&gt;
public interface EmployeeServiceRemote {&lt;br /&gt;
  public void doAction();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
File: AnotherBean.java&lt;br /&gt;
import javax.ejb.Stateless;&lt;br /&gt;
@Stateless&lt;br /&gt;
public class AnotherBean implements AnotherBeanLocal {&lt;br /&gt;
  public void doAnother(){&lt;br /&gt;
    System.out.println(&amp;quot;from another bean&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
File: Main.java&lt;br /&gt;
import javax.ejb.EJB;&lt;br /&gt;
import javax.naming.InitialContext;&lt;br /&gt;
public class Main {&lt;br /&gt;
  &lt;br /&gt;
  public static void main(String[] a) throws Exception {&lt;br /&gt;
    EmployeeServiceRemote service = null;&lt;br /&gt;
    // Context compEnv = (Context) new InitialContext().lookup(&amp;quot;java:comp/env&amp;quot;);&lt;br /&gt;
    // service = (HelloService)new InitialContext().lookup(&amp;quot;java:comp/env/ejb/HelloService&amp;quot;);&lt;br /&gt;
    service = (EmployeeServiceRemote) new InitialContext().lookup(&amp;quot;EmployeeBean/remote&amp;quot;);&lt;br /&gt;
    service.doAction();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
File: jndi.properties&lt;br /&gt;
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory&lt;br /&gt;
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces&lt;br /&gt;
java.naming.provider.url=localhost:1099&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Use Injected Context To Loopup An other EJB ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- start source code --&amp;gt;&lt;br /&gt;
   &lt;br /&gt;
    &amp;lt;source lang=&amp;quot;java&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
File: AnotherBeanLocal.java&lt;br /&gt;
&lt;br /&gt;
public interface AnotherBeanLocal {&lt;br /&gt;
  public void doAnother();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
File: Employee.java&lt;br /&gt;
&lt;br /&gt;
import javax.persistence.Entity;&lt;br /&gt;
import javax.persistence.EntityListeners;&lt;br /&gt;
import javax.persistence.GeneratedValue;&lt;br /&gt;
import javax.persistence.Id;&lt;br /&gt;
import javax.persistence.PostRemove;&lt;br /&gt;
&lt;br /&gt;
@Entity&lt;br /&gt;
public class Employee implements java.io.Serializable {&lt;br /&gt;
  private int id;&lt;br /&gt;
  private String firstName;&lt;br /&gt;
  private String lastName;&lt;br /&gt;
  @Id&lt;br /&gt;
  @GeneratedValue&lt;br /&gt;
  public int getId() {&lt;br /&gt;
    return id;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  @PostRemove&lt;br /&gt;
  public void postRemove()&lt;br /&gt;
  {&lt;br /&gt;
     System.out.println(&amp;quot;@PostRemove&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  public void setId(int id) {&lt;br /&gt;
    this.id = id;&lt;br /&gt;
  }&lt;br /&gt;
  public String getFirstName() {&lt;br /&gt;
    return firstName;&lt;br /&gt;
  }&lt;br /&gt;
  public void setFirstName(String first) {&lt;br /&gt;
    this.firstName = first;&lt;br /&gt;
  }&lt;br /&gt;
  public String getLastName() {&lt;br /&gt;
    return lastName;&lt;br /&gt;
  }&lt;br /&gt;
  public void setLastName(String last) {&lt;br /&gt;
    this.lastName = last;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
File: EmployeeBean.java&lt;br /&gt;
import javax.annotation.Resource;&lt;br /&gt;
import javax.ejb.EJB;&lt;br /&gt;
import javax.ejb.SessionContext;&lt;br /&gt;
import javax.ejb.Stateless;&lt;br /&gt;
@Stateless&lt;br /&gt;
@EJB(name = &amp;quot;audit&amp;quot;, beanInterface = AnotherBeanLocal.class)&lt;br /&gt;
public class EmployeeBean implements EmployeeServiceLocal, EmployeeServiceRemote {&lt;br /&gt;
  @Resource SessionContext context;&lt;br /&gt;
  public EmployeeBean() {&lt;br /&gt;
  }&lt;br /&gt;
  public void doAction() {&lt;br /&gt;
    System.out.println(&amp;quot;doAction&amp;quot;);&lt;br /&gt;
    AnotherBeanLocal a = (AnotherBeanLocal) context.lookup(&amp;quot;audit&amp;quot;);;&lt;br /&gt;
    a.doAnother();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
File: EmployeeServiceLocal.java&lt;br /&gt;
import java.util.Map;&lt;br /&gt;
import javax.ejb.Local;&lt;br /&gt;
&lt;br /&gt;
@Local&lt;br /&gt;
public interface EmployeeServiceLocal {&lt;br /&gt;
  public void doAction();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
File: EmployeeServiceRemote.java&lt;br /&gt;
&lt;br /&gt;
import javax.ejb.Remote;&lt;br /&gt;
@Remote&lt;br /&gt;
public interface EmployeeServiceRemote {&lt;br /&gt;
  public void doAction();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
File: AnotherBean.java&lt;br /&gt;
import javax.ejb.Stateless;&lt;br /&gt;
@Stateless&lt;br /&gt;
public class AnotherBean implements AnotherBeanLocal {&lt;br /&gt;
  public void doAnother(){&lt;br /&gt;
    System.out.println(&amp;quot;from another bean&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
File: Main.java&lt;br /&gt;
import javax.ejb.EJB;&lt;br /&gt;
import javax.naming.InitialContext;&lt;br /&gt;
public class Main {&lt;br /&gt;
  &lt;br /&gt;
  public static void main(String[] a) throws Exception {&lt;br /&gt;
    EmployeeServiceRemote service = null;&lt;br /&gt;
    // Context compEnv = (Context) new InitialContext().lookup(&amp;quot;java:comp/env&amp;quot;);&lt;br /&gt;
    // service = (HelloService)new InitialContext().lookup(&amp;quot;java:comp/env/ejb/HelloService&amp;quot;);&lt;br /&gt;
    service = (EmployeeServiceRemote) new InitialContext().lookup(&amp;quot;EmployeeBean/remote&amp;quot;);&lt;br /&gt;
    service.doAction();&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
File: jndi.properties&lt;br /&gt;
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory&lt;br /&gt;
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces&lt;br /&gt;
java.naming.provider.url=localhost:1099&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
    &lt;br /&gt;
   &lt;br /&gt;
  &amp;lt;!-- end source code --&amp;gt;&lt;/div&gt;</summary>
			</entry>

	</feed>