예제 #1
0
  @Override
  public void loadAS5Data(MigrationContext ctx) throws LoadMigrationException {

    // TBC: Maybe use FileUtils and list all files with that name?
    File file =
        Utils.createPath(
            super.getGlobalConfig().getAS5Config().getDir(),
            "server",
            super.getGlobalConfig().getAS5Config().getProfileName(),
            "deploy",
            "jbossweb.sar",
            "server.xml");

    if (!file.canRead())
      throw new LoadMigrationException(
          "Cannot find/open file: " + file.getAbsolutePath(), new FileNotFoundException());

    try {
      Unmarshaller unmarshaller = JAXBContext.newInstance(ServerAS5Bean.class).createUnmarshaller();

      ServerAS5Bean serverAS5 = (ServerAS5Bean) unmarshaller.unmarshal(file);

      MigrationData mData = new MigrationData();
      for (ServiceBean s : serverAS5.getServices()) {
        mData.getConfigFragments().add(s.getEngine());
        mData.getConfigFragments().addAll(s.getConnectorAS5s());
      }

      ctx.getMigrationData().put(ServerMigrator.class, mData);
    } catch (JAXBException e) {
      throw new LoadMigrationException("Failed parsing logging config file: " + file.getPath(), e);
    }
  }