LanguageModelServer implements LanguageModelServerMBean<W> { public static LanguageModel<String> connectToServer(String host, int rmiPort, String identifier) { try { LOG.info("Trying to connect to Language model service '{}' on {}:{}.", identifier, host, rmiPort); Registry registry = LocateRegistry.getRegistry(host, rmiPort); @SuppressWarnings("unchecked") LanguageModel<String> lm = (LanguageModel<String>) registry.lookup(identifier); return lm; } catch (RemoteException e) { LOG.error("Unable to connect to rmi registry on {}:{}. {}: {}.", host, rmiPort, e.getClass().getSimpleName(), e.getMessage()); } catch (NotBoundException e) { LOG.error("Unable to connect to service {}. {}: {}.", identifier, e.getClass().getSimpleName(), e.getMessage()); } return null; } LanguageModelServer();  LanguageModelServer(LanguageModel<W> language_model); @Override int getOrder(); @Override W predictNextWord(List<W> history); @Override W getWord(int wordId); @Override int getWordIndex(W word); @Override int[] getNgramAsIds(List<W> ngram); @Override List<W> getNgramAsWords(int[] ngram); @Override List<W> getNgramAsWords(List<Integer> ngram); @Override double getSequenceLogProbability(List<W>[] ngram_sequence); @Override double getNgramLogProbability(int[] ngram); @Override double getNgramLogProbability(List<W> ngram); @Override Iterator<List<W>> getNgramIterator(); @Override Iterator<List<Integer>> getNgramIdIterator(); @Override boolean ngramContainsOOV(List<W> ngram); @Override boolean ngramEndsWithOOV(List<W> ngram); @Override boolean isUnkownWord(W word); @Override boolean isUnkownWord(int wordId); @Override boolean ngramContainsOOV(int[] ngram); @Override boolean ngramEndsWithOOV(int[] ngram); @Override boolean getSourceModelReady(); @Override void setSourceModel(LanguageModel<W> model); @Override Class<?> getSourceModelClass(); void publish(Registry registry, String identifier, int port); static LanguageModel<String> connectToServer(String host, int rmiPort, String identifier);  }
@Test public void checkRemote() throws Exception { LanguageModel<String> lm = LanguageModelServer.connectToServer(_host, _rmiport, _lm_id); check(lm); }