Пример #1
0
  public static Object export(Remote obj) {
    try {
      Exporter remoteMeemExporter = getExporter();

      return remoteMeemExporter.export(obj);
    } catch (ConfigurationException e) {
      e.printStackTrace();
    } catch (ExportException e) {
      e.printStackTrace();
    }

    return null;
  }
 /**
  * Registers a new database service or attaches it to an existing.
  *
  * @param dbname The name of the database file to open.
  */
 protected final void startServer(final String dbname) {
   if (System.getSecurityManager() == null) {
     System.setSecurityManager(new RMISecurityManager());
   }
   try {
     this._registry = LocateRegistry.createRegistry(_port);
     _remoteDataDAOImpl = new RemoteDataDAOImpl(dbname);
     _clients = _remoteDataDAOImpl.getClients();
     this._registry.rebind(DataDAO.SERVICENAME, _remoteDataDAOImpl);
     _logger.log(
         Level.INFO, ServerController.resources.getString("ServerController.INFO.D") + this._port);
   } catch (ExportException e) {
     _logger.log(Level.WARNING, e.getMessage());
     try {
       this._registry = LocateRegistry.getRegistry(this._port);
       _logger.log(Level.INFO, ServerController.resources.getString("ServerController.INFO.F"));
       boolean serviceAlreadyBound = false;
       String[] service = this._registry.list();
       for (int i = 0; i < service.length; i++) {
         _logger.log(Level.INFO, service[i]);
         if (service[i].equals(DataDAO.SERVICENAME)) {
           serviceAlreadyBound = true;
         }
         if (serviceAlreadyBound) {
           _logger.log(
               Level.INFO,
               ServerController.resources.getString("ServerController.INFO.G") + this._port);
         }
       }
       throw new RuntimeException(e.getMessage());
     } catch (RemoteException e1) {
       _logger.log(Level.WARNING, e.getMessage());
       throw new RuntimeException(e.getMessage());
     }
   } catch (RemoteException e) {
     _logger.log(Level.WARNING, e.getMessage());
     throw new RuntimeException(e.getMessage());
   } catch (IOException e) {
     _logger.log(Level.WARNING, e.getMessage());
     throw new RuntimeException(e.getMessage());
   }
 }