| <!DOCTYPE html |
| PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| <html lang="en-us" xml:lang="en-us"> |
| <head> |
| <link rel="stylesheet" type="text/css" href="../../org.eclipse.wst.doc.user/common.css" /> |
| <title>Promoting methods to an interface</title> |
| </head> |
| <body id="tepromoteinterfacemethod"><a name="tepromoteinterfacemethod"><!-- --></a> |
| |
| <h1 class="topictitle1">Promoting methods to an interface</h1> |
| <div><p>You can promote methods to the remote interface from an enterprise |
| bean class without editing the remote interface directly.</p><div class="p">In order to use this functionality, you must turn on the Advanced |
| J2EE capability in the workbench preferences (<span class="menucascade"><span class="uicontrol">Window</span> > <span class="uicontrol">Preferences</span> > <span class="uicontrol">Workbench</span> > <span class="uicontrol">Capabilities</span></span>).</div> |
| <div class="skipspace"><p>When you create an enterprise bean, a set of required methods |
| for the bean is automatically created. You can modify these required methods |
| and add new remote (business) methods of your own.</p> |
| <p>After you create |
| these remote methods, you can promote the methods to the remote interface |
| from the enterprise bean class without editing the remote interface directly. |
| When exposing an API from the bean class to the remote interface, performance |
| needs to be considered. Several calls to methods on a remote object could |
| slow performance. In some cases, combining several operations into a single |
| batch method can improve performance.</p> |
| <p>Other method-level extensions |
| can be added on the Beans page of the deployment descriptor editor.</p> |
| <p>To |
| promote an existing method to an interface:</p> |
| </div> |
| <ol><li class="skipspace"><span>Open the Java editor in one of the following ways:</span><ul><li>In the Project Explorer view of the J2EE perspective, select the Java file |
| for the bean class that contains the method to be promoted. Select <span class="menucascade"><span class="uicontrol">Open with</span> > <span class="uicontrol">Java Editor</span></span>.</li> |
| <li>In the Project Explorer view of the J2EE perspective, expand the ejbModule |
| folder and the package for your bean class, then double-click the .java file |
| for your bean class.</li> |
| <li>On the Beans page of the deployment descriptor editor, in the Class |
| and Interface Files section, select the desired class and click <span class="uicontrol">Open</span>. |
| The class opens in the Java editor.</li> |
| </ul> |
| </li> |
| <li class="skipspace"><span>In the Outline view of the J2EE perspective, right-click the business |
| method that you want to promote. On the pop-up menu, select one of |
| the following options, depending on which interfaces are available and the |
| type of bean that you are working with:</span><ul><li><span class="menucascade"><span class="uicontrol">Enterprise Bean</span> > <span class="uicontrol">Promote |
| to Local Interface</span></span></li> |
| <li><span class="menucascade"><span class="uicontrol">Enterprise Bean</span> > <span class="uicontrol">Promote |
| to Local Home Interface</span></span></li> |
| <li><span class="menucascade"><span class="uicontrol">Enterprise Bean</span> > <span class="uicontrol">Promote |
| to Remote Interface</span></span></li> |
| <li><span class="menucascade"><span class="uicontrol">Enterprise Bean</span> > <span class="uicontrol">Promote |
| to Home Interface</span></span></li> |
| <li><span class="menucascade"><span class="uicontrol">Enterprise Bean</span> > <span class="uicontrol">Promote |
| to Service Endpoint Interface</span></span></li> |
| </ul> |
| If you promote to the remote interface, the generated promoted method |
| will throw the <samp class="codeph">javax.ejb.RemoteException</samp> exception. If the |
| remote interface is already opened in a Java editor, it will appear dirty, and |
| the Java editor |
| will not show up with an "R" next to the method in the outline view until |
| the editor holding the remote interface is saved.</li> |
| <li class="skipspace"><span>Save your changes and close the editor.</span></li> |
| </ol> |
| </div> |
| |
| <div><p><b class="reltaskshd">Related tasks</b><br /> |
| <a href="../topics/teinterfacemethods.html" title="When you create an enterprise bean, a set of required methods for the bean is automatically created. You can use the Java editor to modify methods.">Working with a bean's client interface methods</a><br /> |
| <a href="../topics/teaddhomeinterfacemethod.html" title="You can use the Java editor to add a new home method.">Adding methods to the home interface</a><br /> |
| <a href="../topics/tedemoteinterfacemethod.html" title="If you promote a method to an interface, you can easily demote the method.">Demoting methods from an interface</a><br /> |
| </p> |
| </div> <br /> |
| (C) Copyright IBM Corporation 2000, 2005. All Rights Reserved. |
| </body> |
| </html> |