コード例 #1
1
ファイル: GenericDaoImpl.java プロジェクト: zishinan/xuhuamao
    @Override
    public List<T> handle(ResultSet rs) throws SQLException {
      List<T> list = new LinkedList<>();
      while (rs.next()) {
        try {
          T t = this.clz.newInstance();
          BeanInfo beanInfo = Introspector.getBeanInfo(this.clz, Object.class);
          PropertyDescriptor[] descriptors = beanInfo.getPropertyDescriptors();

          Map<String, Object> map = new HashMap<String, Object>();
          for (PropertyDescriptor pd : descriptors) {
            String propertyName = pd.getName();
            Class<?> propertyType = pd.getPropertyType();
            if (propertyType.isAnnotationPresent(Entry.class)) {
              propertyName = propertyName + "_id";
            }
            Object value = rs.getObject(propertyName);
            if (propertyType.isAnnotationPresent(Entry.class)) {
              value = getObject(value, propertyType);
            }
            map.put(pd.getName(), value);
          }
          BeanUtils.copyProperties(t, map);
          list.add(t);

        } catch (InstantiationException
            | IllegalAccessException
            | IntrospectionException
            | InvocationTargetException e) {
          e.printStackTrace();
        }
      }
      return list;
    }
コード例 #2
0
  @Override
  public Client findClient(Integer codeClient) throws DAOException {
    Connection connection;
    Client client = new Client();

    try {
      connection = JDBCUtil.getConnection();
      PreparedStatement prepareStatement =
          connection.prepareStatement("SELECT * FROM Client c WHERE c.codecl=?");
      prepareStatement.setInt(1, codeClient);
      ResultSet resultSet = prepareStatement.executeQuery();
      resultSet.next();

      client.setCodeClient(resultSet.getInt("codecl"));
      client.setNomClient(resultSet.getString("nomcl"));
      client.setAdresse(resultSet.getString("adresse"));
      client.setVille(resultSet.getString("ville"));

    } catch (InstantiationException
        | IllegalAccessException
        | ClassNotFoundException
        | SQLException e) {
      throw new DAOException(e.getMessage(), e.getCause());
    }
    return client;
  }
コード例 #3
0
  protected void retrieveClassModelStructure() {

    this.classHandleName = objectClassModel.getAnnotation(ObjectClass.class).name();

    fields = objectClassModel.getDeclaredFields();
    Map<Class, Coder> tmpMapCoder = new HashMap<Class, Coder>();
    Coder coderTmp = null;

    try {
      for (Field f : fields) {
        if (f.isAnnotationPresent(Attribute.class)) {
          coderTmp = tmpMapCoder.get(f.getAnnotation(Attribute.class).coder());
          if (coderTmp == null) {
            coderTmp = f.getAnnotation(Attribute.class).coder().newInstance();
            tmpMapCoder.put(f.getAnnotation(Attribute.class).coder(), coderTmp);
          }
          matchingObjectCoderIsValid(f, coderTmp);
          mapFieldCoder.put(f.getAnnotation(Attribute.class).name(), coderTmp);
        }
      }
    } catch (InstantiationException | IllegalAccessException e) {
      logger.error("Error in retreving the annotations of the fields");
      e.printStackTrace();
    } finally {
      tmpMapCoder = null;
      coderTmp = null;
    }
  }
コード例 #4
0
  @Override
  public Client save(Client client) throws DAOException {

    Connection connection;
    try {
      connection = JDBCUtil.getConnection();
      PreparedStatement prepareStatement =
          connection.prepareStatement(
              "INSERT INTO Client (nomcl,adresse,ville) VALUES (?,?,?)",
              Statement.RETURN_GENERATED_KEYS);
      prepareStatement.setString(1, client.getNomClient());
      prepareStatement.setString(2, client.getAdresse());
      prepareStatement.setString(3, client.getVille());
      prepareStatement.executeUpdate();
      ResultSet keys = prepareStatement.getGeneratedKeys();
      keys.next();
      client.setCodeClient(keys.getInt(1));
    } catch (InstantiationException
        | IllegalAccessException
        | ClassNotFoundException
        | SQLException e) {

      throw new DAOException(e.getMessage(), e.getCause());
    }

    return client;
  }
コード例 #5
0
  /** @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */
  protected void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    String name = request.getParameter("name");
    String phonenumber = request.getParameter("phonenumber");
    response.getOutputStream().write(("此次填写的是" + name + "的手机号是:" + phonenumber + "").getBytes());
    String url = "jdbc:mysql://127.0.0.1:3306/haust_cs_113?user=root&password=root";

    try {
      // 创建一个数据库driver?
      Class.forName("com.mysql.jdbc.Driver").newInstance();
    } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    try {
      // 通过制定的url建立数据库连接
      Connection conn = DriverManager.getConnection(url);
      if (conn != null) System.out.println("数据库连接成功!");
      else System.out.println("数据库连接失败!");
      // 创建一个 Statement 对象来将 SQL 语句发送到数据库。
      Statement stm = conn.createStatement();
      // 执行给定 SQL 语句,该语句可能为 INSERT、UPDATE 或 DELETE 语句,或者不返回任何内容的 SQL 语句(如 SQL DDL 语句)。
      stm.executeUpdate("insert into user value('" + name + "','" + phonenumber + "');");
      response.getOutputStream().write("插入成功".getBytes());
      conn.close();
    } catch (SQLException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
コード例 #6
0
  @Override
  protected void service(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    super.service(request, response);
    // 获取请求uri
    String requestUri = request.getRequestURI().substring(request.getContextPath().length());
    // TODO
    Map<String, String[]> requestParameters = request.getParameterMap();
    Method method = requestMap.get(requestUri);

    if (null == method) {
      // TODO 重定向到404页面
      response.sendRedirect("");
      return;
    }
    Class<?>[] methodParameterClazzs = method.getParameterTypes();
    Object[] methodParameters = new Object[methodParameterClazzs.length];

    for (int i = 0; i < methodParameterClazzs.length; i++) {

      if (methodParameterClazzs[i] == HttpServletRequest.class) {
        methodParameters[i] = request;
      } else if (methodParameterClazzs[i] == HttpServletResponse.class) {
        methodParameters[i] = response;
      } else {
        try {
          // TODO 与getBean比较
          methodParameters[i] = BeanUtil.instantiateBean(methodParameterClazzs[i]);
          Field[] methodParameterFields = methodParameterClazzs[i].getDeclaredFields();

          for (Field field : methodParameterFields) {
            Object value = requestParameters.get(field.getName());

            if (null != value) {
              field.setAccessible(true);
              // TODO
              field.set(methodParameters[i], value);
              ;
            }
          }
        } catch (InstantiationException | IllegalAccessException e) {
          log.error(e);
          e.printStackTrace();
        }
      }
    }
    Object result = null;

    try {
      result =
          method.invoke(
              webApplicationContext.getBean(method.getDeclaringClass()), methodParameters);
    } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
      log.error(e);
      e.printStackTrace();
    }
    response.setContentType("application/json");
    String jsonResult = JSON.toJSONString(result);
    response.getWriter().write(jsonResult);
  }
コード例 #7
0
  @Override
  public List<Client> findAllByName() throws DAOException {
    Connection connection;
    List<Client> clients = new ArrayList<>();

    try {
      connection = JDBCUtil.getConnection();
      PreparedStatement prepareStatement =
          connection.prepareStatement("SELECT * FROM Client c ORDER BY c.nomcl");
      ResultSet resultSet = prepareStatement.executeQuery();

      while (resultSet.next()) {
        Client client = new Client();
        client.setCodeClient(resultSet.getInt("codecl"));
        client.setNomClient(resultSet.getString("nomcl"));
        client.setAdresse(resultSet.getString("adresse"));
        client.setVille(resultSet.getString("ville"));
        clients.add(client);
      }
    } catch (InstantiationException
        | IllegalAccessException
        | ClassNotFoundException
        | SQLException e) {
      throw new DAOException(e.getMessage(), e.getCause());
    }
    return clients;
  }
コード例 #8
0
ファイル: NuovoCliente.java プロジェクト: Rhuax/Carloan
  @SuppressWarnings({"unchecked", "rawtypes"})
  @FXML
  public void btnConferma(ActionEvent event) {
    tw = ((SchermataGenerale) this.getChiamante()).getTable("Cliente");
    try {
      Cliente cliente = prendiDatiDaView();
      presenter.processRequest("VerificaCliente", cliente);
      presenter.processRequest("InserimentoCliente", cliente);
      // Chiama il metodo della schermata che ha chiamato questa schermata per settare nella tabella
      // dei clienti i clienti ricavati
      ((SchermataGenerale) this.getChiamante())
          .caricaTabella((List<Cliente>) presenter.processRequest("getAllClienti", null), tw);
      chiudiFinestra();

    } catch (CommonException e) {
      e.showMessage();
    } catch (InvocationTargetException e) {
      new CommonException(e.getTargetException().getMessage()).showMessage();
    } catch (InstantiationException
        | IllegalAccessException
        | ClassNotFoundException
        | NoSuchMethodException
        | SecurityException
        | IllegalArgumentException e) {

      e.printStackTrace();
    }
  }
コード例 #9
0
ファイル: Game.java プロジェクト: FransM22/GipfGame
  public void startNGameCycles(Runnable finalAction, int nrOfRuns) {
    Class currWhitePlayer = whitePlayer.getClass();
    Class currBlackPlayer = blackPlayer.getClass();

    new Thread(
            () -> {
              for (int i = 0; i < nrOfRuns; i++) {
                progressOfNGames = OptionalDouble.of((double) i / nrOfRuns);

                GipfBoardState gipfBoardStateCopy =
                    new GipfBoardState(
                        getGipfBoardState(), gipfBoardState.getPieceMap(), gipfBoardState.players);
                Game copyOfGame = new BasicGame();
                try {
                  copyOfGame.whitePlayer = (ComputerPlayer) currWhitePlayer.newInstance();
                  copyOfGame.blackPlayer = (ComputerPlayer) currBlackPlayer.newInstance();
                } catch (InstantiationException | IllegalAccessException e) {
                  e.printStackTrace();
                }
                copyOfGame.loadState(gipfBoardStateCopy);

                GameLoopThread gameLoopThread = new GameLoopThread(copyOfGame, finalAction);
                gameLoopThread.start();
                try {
                  gameLoopThread.join();
                } catch (InterruptedException e) {
                  e.printStackTrace();
                }
              }

              progressOfNGames = OptionalDouble.empty();
            })
        .start();
  }
コード例 #10
0
  private static List<MessageTestCase> getAllTestCases(String packageName)
      throws ClassNotFoundException, IOException {
    List<MessageTestCase> classes = new ArrayList<>();
    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    String path = packageName.replace('.', '/');
    Enumeration<URL> resources = classLoader.getResources(path);
    while (resources.hasMoreElements()) {
      URL resource = resources.nextElement();
      File dir = new File(resource.getFile());
      File[] files = dir.listFiles();
      for (File f : files) {
        String name = f.getName();
        if (name.endsWith(".class") && !name.contains("$")) {
          final String[] clazz = name.split("\\.");
          try {
            MessageTestCase tc =
                (MessageTestCase) Class.forName(packageName + clazz[0]).newInstance();
            tc.setId(clazz[0]);
            classes.add(tc);
          } catch (InstantiationException | IllegalAccessException e) {
            LOG.error(e.toString());
          }
        }
      }
    }

    if (SORT_ALPHABETICALLY) {
      // Ensure the testcases are run in the same order each time.
      Collections.sort(classes, new SortTestCasesAlphabetically());
    }

    return classes;
  }
コード例 #11
0
  public void del(final UUID playerUUID, String effectName) {
    OfflinePlayer player = getPlayer(playerUUID, false);
    AbstractEffect effect = getEffect(playerUUID, effectName);
    if (effect == null) {
      throw new IllegalArgumentException(
          "The effect"
              + effectName
              + " were not associated to the player "
              + player.getName()
              + ".");
    }
    for (Class<? extends AbstractEventListener<?>> eventListenerClass : effect.getNeededEvents()) {
      AbstractEventListener<?> eventListener = null;
      try {
        eventListener = EventListenerManager.getInstance().getEventListener(eventListenerClass);
        if (eventListener == null) {
          throw new IllegalArgumentException("An error occured during the EventListener removal.");
        }
      } catch (InstantiationException
          | IllegalAccessException
          | InvocationTargetException
          | SecurityException e) {
        e.printStackTrace();
        throw new IllegalArgumentException(
            "An error occured during the EventListener removal: " + e.getClass().toString() + ".");
      }
      eventListener.deleteObserver(effect);
      if (eventListener.countObservers() == 0) {
        try {
          EventListenerManager.getInstance().removeIfNeeded(eventListener);
        } catch (IllegalAccessException e) {
          e.printStackTrace();
          throw new IllegalArgumentException(
              "An error occured during the EventListener removal: "
                  + e.getClass().toString()
                  + ".");
        }
      }
    }
    effect.onDisable();
    final AbstractEffect effectToDelete = effect;
    int disableDelay = effect.getDisableDelay();
    if (disableDelay > 0) {
      runTaskLater(
          new Runnable() {

            @Override
            public void run() {
              EffectManagerPlugin.getPlugin(EffectManagerPlugin.class)
                  .getPlayerEffectManager()
                  .getEffectsForPlayer(playerUUID)
                  .remove(effectToDelete);
            }
          },
          effect.getDisableDelay());
    } else {
      this.playersEffects.get(playerUUID).remove(effect);
    }
  }
コード例 #12
0
ファイル: XACMLPlugin.java プロジェクト: paulmillar/dcache
 /**
  * Provides for possible alternate implementations of the XACML client by delegating to an
  * implementation of {@link IMapCredentialsClient} which wraps the germane methods of the
  * privilege class ( {@link MapCredentialsClient}; privilege itself provides no interface).
  *
  * @return new instance of the class set from the <code>gplazma.xacml.client.type</code> property.
  */
 private IMapCredentialsClient newClient() throws AuthenticationException {
   try {
     IMapCredentialsClient newInstance = _clientType.newInstance();
     return newInstance;
   } catch (InstantiationException | IllegalAccessException t) {
     throw new AuthenticationException(t.getMessage(), t);
   }
 }
コード例 #13
0
ファイル: BafLogin.java プロジェクト: RoneMeng/bafserver
 /** @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */
 protected void doPost(HttpServletRequest request, HttpServletResponse response)
     throws ServletException, IOException {
   try {
     BaseProcess.create(Login_Process.class).process(request, response);
   } catch (InstantiationException | IllegalAccessException e) {
     e.printStackTrace();
   }
 }
コード例 #14
0
 @SuppressWarnings("unchecked")
 private <T> Dto<T> instanceFor(Class<T> modelClass) {
   try {
     return (Dto<T>) get(modelClass).newInstance();
   } catch (InstantiationException | IllegalAccessException e) {
     e.printStackTrace();
   }
   return null;
 }
コード例 #15
0
ファイル: TestJoinPoint.java プロジェクト: 2050utopia/frodo
 @Override
 public Object getTarget() {
   try {
     return declaringType.newInstance();
   } catch (InstantiationException | IllegalAccessException e) {
     e.printStackTrace();
   }
   return null;
 }
コード例 #16
0
ファイル: PacketManager.java プロジェクト: xinyuweb/AgarIo
 public Packet construct(byte packetId) {
   Class<? extends Packet> packet = this.packets.get(packetId);
   try {
     return packet.newInstance();
   } catch (InstantiationException | IllegalAccessException e) {
     e.printStackTrace();
   }
   return null;
 }
コード例 #17
0
 public void focus() {
   if (Launcher.instance().getScreen() != this) {
     try {
       Screen s = getClass().newInstance();
       Launcher.instance().setScreen(s);
     } catch (InstantiationException | IllegalAccessException e) {
       e.printStackTrace();
     }
   }
 }
 protected Action newInstance(ActionInstance actionInstance) {
   try {
     return actionInstance.getAction().newInstance();
   } catch (InstantiationException | IllegalAccessException e) {
     throw new RuntimeException(
         String.format(
             "Exception occurred while creating an action instance of type %s: %s",
             actionInstance.getAction(), e.getMessage()));
   }
 }
コード例 #19
0
 /** Switch between two JFrames. */
 protected final void changeView() {
   JFrame newView = null;
   actualView.dispose();
   try {
     newView = (JFrame) Class.forName(newWindowName).newInstance();
   } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
     e.printStackTrace();
   }
   if (newView != null) actualView = newView;
 }
コード例 #20
0
 public Packet getPacketFromPool(byte id) {
   if (this.packetPool.containsKey(id)) {
     try {
       return this.packetPool.get(id).newInstance();
     } catch (InstantiationException | IllegalAccessException e) {
       e.printStackTrace();
     }
   }
   return null;
 }
コード例 #21
0
 public Connection getConnection() throws SQLException {
   Connection conn = null;
   try {
     Class.forName(driver).newInstance();
   } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   conn = DriverManager.getConnection(url + dbName, userName, password);
   return conn;
 }
コード例 #22
0
  @SuppressWarnings("ConstantConditions")
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Set a Toolbar to replace the ActionBar.
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    // Find our drawer view
    mDrawer = (DrawerLayout) findViewById(R.id.drawer_layout);

    mDrawerToggle =
        new ActionBarDrawerToggle(this, mDrawer, R.string.drawer_open, R.string.drawer_closed) {
          @Override
          public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);

            invalidateOptionsMenu();
          }

          @Override
          public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);
            Log.d(TAG, "onDrawerClosed: " + getTitle());

            invalidateOptionsMenu();
          }
        };

    mDrawer.setDrawerListener(mDrawerToggle);

    // Find our drawer view
    NavigationView nvDrawer = (NavigationView) findViewById(R.id.nvView);

    // Setup drawer view
    setupDrawerContent(nvDrawer);

    // Handle for menu
    menu = nvDrawer.getMenu();

    // Insert the home fragment
    FragmentManager fragmentManager = getSupportFragmentManager();
    try {
      FragmentTransaction transaction = fragmentManager.beginTransaction();
      transaction.addToBackStack(null);
      transaction.replace(R.id.flContent, HungryHome.class.newInstance()).commit();
    } catch (InstantiationException | IllegalAccessException e) {
      e.printStackTrace();
    }
  }
コード例 #23
0
ファイル: Listener.java プロジェクト: madtomic/BattleTags
 public BattleTagsListener getListener(BattleTags plugin) {
   try {
     return (BattleTagsListener) clazz.getConstructors()[0].newInstance(plugin);
   } catch (InstantiationException
       | IllegalAccessException
       | IllegalArgumentException
       | InvocationTargetException
       | SecurityException e) {
     e.printStackTrace();
     return null;
   }
 }
コード例 #24
0
ファイル: ToolFactory.java プロジェクト: husince/gitools
  public static ITool get(String toolName) {
    try {
      if (!TOOLS.containsKey(toolName)) {
        return new HelpTool(toolName, TOOLS.keySet());
      }

      return TOOLS.get(toolName).newInstance();
    } catch (InstantiationException | IllegalAccessException e) {
      e.printStackTrace();
    }
    return null;
  }
コード例 #25
0
  @Override
  public double[] getLogLikelihoods(List<Beacon> beacons, State[] locations) {
    List<Beacon> beaconsCleansed = Beacon.filterBeacons(beacons, minRssi, maxRssi);

    beaconsCleansed = beaconFilter.setBLEBeacon(bleBeacons).filter(beaconsCleansed, locations);
    BLEBeacon.setBLEBeaconIdsToMeasuredBeacons(bleBeacons, beaconsCleansed);
    int[] activeBeaconList = ModelAdaptUtils.beaconsToActiveBeaconArray(beaconsCleansed);

    final double[] ySub = ModelAdaptUtils.beaconsToVecSubset(beaconsCleansed);
    final double[][] X = ModelAdaptUtils.locationsToMat(locations);

    // Adjust bias by average bias
    final double[] rssiBiases = ModelAdaptUtils.biasesToVec(locations);

    double logLLs[] = null;
    try {
      Class<?> cls = gpLDPL.getClass();
      Constructor<?> cst = cls.getConstructor(gpLDPL.getClass());
      final GaussianProcessLDPLMean gpLDPLtmp = (GaussianProcessLDPLMean) cst.newInstance(gpLDPL);
      gpLDPLtmp.updateByActiveBeaconList(activeBeaconList);
      int n = X.length;
      final double logpro[] = new double[n];
      Future<?>[] futures = new Future<?>[n];
      for (int i = 0; i < n; i++) {
        final int idx = i;
        futures[idx] =
            ExecutorServiceHolder.getExecutorService()
                .submit(
                    new Runnable() {
                      public void run() {
                        // Subtract bias from an observation vector.
                        double[] ySubAdjusted = ArrayUtils.addScalar(ySub, -rssiBiases[idx]);
                        logpro[idx] = gpLDPLtmp.logProbaygivenx(X[idx], ySubAdjusted);
                      }
                    });
      }
      for (int i = 0; i < n; i++) {
        futures[i].get();
      }
      logLLs = logpro;
    } catch (InstantiationException
        | IllegalAccessException
        | IllegalArgumentException
        | InvocationTargetException
        | NoSuchMethodException
        | SecurityException e) {
      e.printStackTrace();
    } catch (InterruptedException | ExecutionException e) {
      e.printStackTrace();
    }
    return logLLs;
  }
コード例 #26
0
 /**
  * If an <code>ICommand</code> has previously been registered to handle a the given <code>
  * INotification</code>, then it is executed.
  *
  * @param note The notification to send associated with the command to call.
  */
 public void executeCommand(Notification note) {
   // No reflexion in GWT
   Class<? extends Command> commandClass = commandMap.get(note.getName());
   if (commandClass != null) {
     Command command;
     try {
       command = commandClass.newInstance();
       command.execute(note);
     } catch (InstantiationException | IllegalAccessException e) {
       e.printStackTrace();
     }
   }
 }
コード例 #27
0
 public static void callStartupTasks(ClassesManager cm, ContextManager contextManager) {
   System.out.println("Call startup tasks");
   for (Class<? extends IStartupTask> startupTaskClass : cm.getClasses(IStartupTask.class)) {
     try {
       IStartupTask startupTask = startupTaskClass.newInstance();
       if (!PropertiesManager.getBoolean(startupTask.conditioningStartupTask())) continue;
       System.out.println("Startup " + startupTaskClass.getName());
       startupTask.startupTaskAction(contextManager);
     } catch (InstantiationException | IllegalAccessException e) {
       e.printStackTrace();
     }
   }
 }
コード例 #28
0
ファイル: CommandService.java プロジェクト: Coralec/NGECore2
  public BaseSWGCommand getCommandByName(String name) {
    Vector<BaseSWGCommand> commands = new Vector<BaseSWGCommand>(commandLookup);

    name = name.toLowerCase();

    for (BaseSWGCommand command : commands) {
      if (command.getCommandName().equalsIgnoreCase(name)) {
        return command;
      }
    }

    try {
      String[] tableArray =
          new String[] {
            "client_command_table",
            "command_table",
            "client_command_table_ground",
            "command_table_ground",
            "client_command_table_space",
            "command_table_space"
          };

      for (int n = 0; n < tableArray.length; n++) {
        DatatableVisitor visitor =
            ClientFileManager.loadFile(
                "datatables/command/" + tableArray[n] + ".iff", DatatableVisitor.class);

        for (int i = 0; i < visitor.getRowCount(); i++) {
          if (visitor.getObject(i, 0) != null) {
            String commandName = ((String) visitor.getObject(i, 0)).toLowerCase();

            if (commandName.equalsIgnoreCase(name)) {
              if (isCombatCommand(commandName)) {
                CombatCommand command = new CombatCommand(commandName);
                commandLookup.add(command);
                return command;
              } else {
                BaseSWGCommand command = new BaseSWGCommand(commandName);
                commandLookup.add(command);
                return command;
              }
            }
          }
        }
      }
    } catch (InstantiationException | IllegalAccessException e) {
      e.printStackTrace();
    }

    return null;
  }
コード例 #29
0
 public GameEventTrigger create() {
   Class<? extends GameEventTrigger> triggerClass = getTriggerClass();
   try {
     return triggerClass.getConstructor(EventTriggerDesc.class).newInstance(this);
   } catch (InstantiationException
       | IllegalAccessException
       | IllegalArgumentException
       | InvocationTargetException
       | NoSuchMethodException
       | SecurityException e) {
     e.printStackTrace();
   }
   return null;
 }
コード例 #30
0
ファイル: Kernel.java プロジェクト: audax/qabel-desktop
 private void initPlugins() {
   for (Class<? extends ClientPlugin> clazz : clientPlugins) {
     try {
       ClientPlugin plugin = clazz.newInstance();
       if (plugin instanceof ServiceFactoryProvider) {
         desktopServiceFactory.addServiceFactory(
             ((ServiceFactoryProvider) plugin).getServiceFactory());
       }
       AfterburnerInjector.injectMembers(plugin);
       plugin.initialize(desktopServiceFactory, services.getEventDispatcher());
     } catch (InstantiationException | IllegalAccessException e) {
       logger.error("failed to initialized plugin " + clazz.getName() + ": " + e.getMessage(), e);
     }
   }
 }