2

My project use Struts2, Spring and Hibernate.

And the project grow bigger and a lot of action never used. So related tiles and JSP also have the same issue.

Is any tools or write some code to find out all unused link. Or found the link can be reach from index page and then go though all action . found the unused action.

My action is like below :

    @Action(value = "saveClass", results = {@Result(name = SUCCESS, type = "tiles", location = ".initStep3"),
            @Result(name = "repeat",type = Constants.RESULT_NAME_TILES,location = ".repeatClassInfo"),
            @Result(name = "maintenance",type = Constants.RESULT_NAME_TILES,location = ".courseInfoModified"),
            @Result(name = INPUT, type = "tiles", location = ".saveClass")})
    public String saveClass() {
Roman C
  • 49,761
  • 33
  • 66
  • 176
Bensson
  • 4,509
  • 4
  • 19
  • 24
  • Define unused link and unused action. – Aleksandr M Jun 04 '14 at 17:28
  • used link means: my website start from index.html. index.html has hyperlink "test.html", test.html can post data to test2.html. and after post, websit will redirect to test3.html and also sometimes redirect test4.html. Those links are used links. For other unreachable links are unused link. – Bensson Jun 05 '14 at 05:09
  • BTW: for jsp. if no tiles or action referenced. we trade it as unused. – Bensson Jun 05 '14 at 05:15
  • For Link and action. link is index.html. action is Class: HomeAction.java method: index – Bensson Jun 05 '14 at 05:18
  • Take a look at the `Config Browser Plugin` for the hints how to get S2 configuration. – Aleksandr M Jun 05 '14 at 08:58
  • Thanks for reply. Config Browser Plugin only get S2 configuration, can't help me this action is really used my system. I mean can trace from index page. – Bensson Jun 05 '14 at 15:58
  • I mean you can write your own logic for finding unused actions, etc... `Config Browser Plugin` is just for a hints how to get S2 configuration. – Aleksandr M Jun 05 '14 at 16:57
  • OK, Thanks. I am looking for a tool. The logic is complex, many case need be care and will be cost huge time, waiting if any good tools for this issue:) – Bensson Jun 06 '14 at 01:37

1 Answers1

0

To find dead codes and unused methods An Eclipse plugin that works reasonably well is Unused Code Detector.

Here is

  1. unnecessary-code-detector

  2. UCDetector

Maybe this will help...

Also see How to find unused Java classes and JSP files from a project

But for struts.xml configuration and dead links finding as Alexander M suggested use Config Browser Plugin

Community
  • 1
  • 1
prem30488
  • 2,828
  • 2
  • 25
  • 57
  • Thanks for your reply, but I don’t think can solve my issue. config browser only can help me know which action I configured. But can’t help me know whether was used in my system. What I want is : Is any tool can help scan all reachable link from index.html, it’s similar to what google dose. When I know which link I already used. E.g. test1.html, test2.html…. I also can use this tool to search my action class, if I found test3 which not existing in my use link list (test1,test2). I can trade this action is unused and delete this method. – Bensson Jun 05 '14 at 15:52
  • I can see my code "@Action(value = "saveClass" this action. convert to link will be saveClass.html. how i can reach this link is click login.html and login to system. click class menu and fill data and save class data. So this action has used by our system. If other action cannot trace from index. I will trade it unused action method. – Bensson Jun 05 '14 at 15:58