[Bonnes Pratiques] Interfaces home/locale et remote
Bonjour,
Je voulais savoir de quelle manière il faut définir nos interfaces home et remote, celles qui permettent d'accéder à un EJB distant. En effet j'ai vu plusieurs versions :
Code:
1 2 3 4 5 6 7 8
|
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.ejb.EJBHome;
public interface LoggerHome extends EJBHome {
Logger create() throws RemoteException, CreateException;
} |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
import java.rmi.RemoteException;
import javax.ejb.EJBObject;
/**
* Accepts simple String log messages and prints
* them on the server.
*/
public interface Logger extends EJBObject {
/**
* Logs the given message on the server with
* the current server time.
*/
void logString(String message) throws RemoteException;
} |
qui respectivement sont les sources de sun pour l'interface home et l'interface remote (d'après ce que j'ai pu comprendre, mais corrigez moi si je me trompe :aie:)
L'autre version préconise l'utilisation des annotations @Local @Remote
Code:
1 2 3 4 5 6 7
|
import javax.ejb.Local;
@Local
public interface IAgenceHome {
public Agence create();
} |
import javax.ejb.Local;
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
import javax.ejb.Remote;
@Remote
/**
* Interface Remote, possilibité de définir une interface Local
* avec @Local
*/
public interface IAgenceRemote {
public String getName();
public void setName(String nom);
public String[] getBiens();
public Double getMeilleurPrix();
} |
Après je mélange peut être tout...
Si vous pouvez m'apportez quelques précisions n'hésitez pas ! merci à vous