4

小さなモジュールに分割したい大規模なモノリシック Web アプリケーションがあります。最初のステップとして、現在のように見えるパッケージ階層を変更したいと思います:

 - com.companyname.project
  - dao
     - bean
         - booking // possibly containing more sub packages
         - core   
         ... etc etc (there are a bunch of others as well)
     - service
         - booking // possibly containing more sub packages
         - core   
         ... etc etc  
  - logic
     - bean
         - booking // possibly containing more sub packages
         - core   
         ... etc etc
     - service
         - booking
         - core   
         ... etc etc
  - web
     - bean  // same substructure as above...
     - service  // same substructure as above...
     - taglib  // same substructure as above...
     - util

bookingたとえば、パッケージ構造が以下のパッケージ名として使用されている場合は、それを希望しますcom.companyname.project

たとえば、単純な正規表現を使用して再構築を行うことができるツールがあるかどうか疑問に思っています。

たとえば、次の
com.companyname.project.dao.bean.booking
ようになります。
com.companyname.project.booking.dao.bean

com.companyname.project.dao.service.booking
次のようになります。
com.companyname.project.booking.dao.service

Eclipse を使用してパッケージをドラッグ アンド ドロップすることもできますが、非常に反復的な作業になるため、最小限の関与でこれを実行できるものを探しています。

4

2 に答える 2

1

リファクタリング互換性がある Java IDE のいずれかを使用できます。

  • IntelliJ IDEA (最高のリファクタリング サポート)。オープン ソースのコミュニティ エディションとクローズド ソースの究極のエディションがあります。
  • エクリプス (オープンソース)
  • NetBeans (オープンソース)

エラーが発生しやすいため、正規表現の検索/置換を使用することはお勧めしません。

于 2012-03-01T12:40:13.427 に答える
-1

Why not use Java itself? I believe in your current scenario, you could easily write a small Java program to do the exact refactorings you're talking about and ensure that nothing is missed along the way.

You could write a method that takes "pre" (i.e. "com.companyname.project.dao.bean.booking") and "post" (i.e. "com.companyname.project.booking.dao.bean") params and copies the "pre" structure appropriately into the "post" structure.

In this program, I envision a main method and a "convertPackage(pre,post)" method. You could then have an array of your "pre" and "post" structures and loop through converting them over to the new. It would be best to do this copying into some sort of temp directory and not muck with the original as an added safety measure.

Maybe my thinking is too simple on this, but I could see a program built to do this refactoring in 1/2 a day or less.

You'll get the added benefit of knowing exactly what is changing rather than the insecurity that comes with these automated tools that may do it right for you or may not...

于 2012-03-28T12:58:22.707 に答える