title: how to get a String value called token from method in order to use spring AOP to write a shorter code
body: <p>for example in my project i have class called AdminController that have lots of methods with code that repeat itself in all of the methods and have a class variable, one of the methods + class variable is this:</p>
  <pre><code>   private Map&lt;String, OurSession&gt; clientSessions;
  
      public AdminController(Map&lt;String, OurSession&gt; clientSessions) {
          this.clientSessions = clientSessions;
      }
  
      @PostMapping(&quot;addCompany/{token}&quot;)
      public ResponseEntity&lt;?&gt; addCompany(@PathVariable String token, @RequestBody Company company){
          OurSession session = clientSessions.get(token);
          if(session != null){
              AdminFacade admin = (AdminFacade) session.getFacade();
              if(System.currentTimeMillis() - session.getLastAccessed() &gt; 1000 * 60 * 30)
                  return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body(&quot;UNAUTHORIZED login&quot;);
              session.setLastAccessed(System.currentTimeMillis());
              try {
                  admin.addCompany(company);
                  return ResponseEntity.ok(company);
              } catch (CompanyAlreadyExistsException e) {
                  return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(e.getMessage());
              }
          }else
              return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body(&quot;UNAUTHORIZED login&quot;);
      }
  </code></pre>
  <p>now inside this method all of this code is repeat itself in all of this class methods:</p>
  <pre><code> OurSession session = clientSessions.get(token);
          if(session != null){
              AdminFacade admin = (AdminFacade) session.getFacade();
              if(System.currentTimeMillis() - session.getLastAccessed() &gt; 1000 * 60 * 30)
                  return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body(&quot;UNAUTHORIZED login&quot;);
              session.setLastAccessed(System.currentTimeMillis());
  </code></pre>
  <p>this code can be inserted in a AOP method in another class to help me write less code:</p>
  <pre><code>
      @Before(&quot;execution(* com.example.couponproject.controller.AdminController*(..) )&quot;)
      public void runBefore(JoinPoint joinPoint) {
          code here that repeat itself
  
      }
  </code></pre>
  <p>but my problem is that you notice that all of the method get a String value called token and i dont know how to get the AOP method use that, how do i sent this token value each time the AOP method runs?</p>
  <p>in other word i need the AOP method use this token value from each controller method that called the AOP method</p>
  <p>thanks for helpers!</p>