[Seasar-user:20466] Re: Interceptorを用いた際のIllegalAutoBindingPropertyRuntimeException

Shouta Morimoto [E-MAIL ADDRESS DELETED]
2010年 12月 30日 (木) 00:25:52 JST


$B5HEDMM(B

$B$*@$OC$K$J$j$^$9!"?9K\$G$9!#(B


$B$4O"Mm$"$j$,$H$&$4$6$$$^$7$?!#(B
$B$4;XE&$NDL$j!"(BUser$B%*%V%8%'%/%H$O(Bentity$B$K$J$j$^$9!#(B
$B;n$7$K(BUser$B%*%V%8%'%/%H$G$O$J$/!"(Bform$B0J2<$K(BLoginForm$B%/%i%9$r(B
$B:[E-MAIL ADDRESS DELETED]$7$F$_$F!"$=$l$r(BAdminAuthInterceptor$B$GMQ$$$l$P%(%i!<$O(B
$B=P$J$/$J$j$^$7$?!#(B

$BK\7o$H$OD>@\4X78$J$$$N$G$9$,!";d(BDI$B$H$$$&$b$N$,$h$/$o$+$C$F$$$J$$$h$&$G$9!#(B
$B6qBNE*$K(BAdminAuthInterceptor$B$r0J2<$N$h$&$KJQ99$7$^$7$?!#(B

============================================================================
package scoreupgolf.interceptor;

import javax.annotation.Resource;

import org.aopalliance.intercept.MethodInvocation;
import org.seasar.framework.aop.interceptors.AbstractInterceptor;
import org.seasar.struts.annotation.Execute;

import scoreupgolf.dto.Role;
import scoreupgolf.form.LoginForm;

//import scoreupgolf.dto.UserDto;

public class AdminAuthInterceptor extends AbstractInterceptor {
  private static final long serialVersionUID = 1L;

  @Resource
  protected LoginForm loginForm = null;

  // protected User user;

  @Override
  public Object invoke(MethodInvocation invocation) throws Throwable {
    // $B$3$3$N>r7o$,(Btrue$B$G$"$l$P%m%0%$%s:Q$_$HH=CG(B
    // $B$3$3$N>r7o$,(Bfalse$B$G$"$l$P%m%0%$%s%Z!<%8$X0\F0(B
    String loginURL = "/login/";
    return (!isExecuteMethod(invocation) || isLoggedIn()) ? invocation
        .proceed() : loginURL;
  }

  private boolean isExecuteMethod(MethodInvocation invocation) {
    return invocation.getMethod().isAnnotationPresent(Execute.class);
  }

  private boolean isLoggedIn() {
    // Session$B$K%f!<%6!<>pJs$,EPO?$5$l$F$$$k$+%A%'%C%/(B
    // $B:GDc8B$N$b$N$N$_%A%'%C%/(B
    // return (user != null && user.role == Role.ADMIN);
    if (loginForm != null) {
      return true;
    }
    return false;
  }
}
============================================================================

$B$3$&$7$?$H$3$m!"(BloginForm$B$O!V(B/login$B!W$K0\F0$9$kA0$K$b4X$o$i$:(B
$B4{$K(Bnew$B$5$l$F$7$^$C$F$$$k$h$&$G!"%m%0%$%s$7$F$$$J$/$H$bG'>Z$r$9$jH4$1$F(B
$B$7$^$$$^$9!#(B

$B$3$l$H$OJL$K(BAction$B%/%i%9$G%/%i%9JQ?t$H$7$F(B

($B%"%N%F!<%7%g%s$J$7$G(B)
public UserService userService;
public User user;
public String abc;

$B$H$9$k$H!"$I$3$G$b(Bnew UserService()$B$H$7$F$$$J$$$N$K(B
userService$B$O$$$D$N4V$K$+(Bnew$B$5$l$F$$$k$h$&$K8+$($^$9!#(B
$B5U$K(Buser, abc$B$O(Bnull$B$N$^$^$G$9!#(B

$B$b$7$4B8$8$G$7$?$i!"(B

$B-!%U%l!<%`%o!<%/$O$$$D$I$N%?%$%_%s%0$G%*%V%8%'%/%H$r(Bnew$B$9$k$N$+(B
$B-"(Bnew$B$9$kJQ?t$H$=$&$G$J$$JQ?t$N0c$$$O2?$+!)(B

$B$r65$($FD:$1$^$;$s$G$7$g$&$+!)(B
$B$3$l$i$N4pAC$rJY6/$G$-$kK\$J$I65$($FD:$1$k$@$1$G$b7k9=$G$9!#(B

$B0J>e!"$h$m$7$/$*4j$$$$$?$7$^$9!#(B

(2010/12/27 9:37), Takafumi Yoshida wrote:
> $B$$$D$b$*@$OC$K$J$j$^$9!#5HED(B(zephiransas)$B$G$9!#(B
> 
> AdminAuthInterceptor$B$K$"$k(B
>>    @Resource
>>    protected User user;
> $B$N;H$$J}$,$A$,$$$^$9$M!#(B
> 
> User$B%/%i%9$O%k!<%H%Q%C%1!<%8!J(Bscoreupgolf?).entity$B$K$"$k$h$&$G$9$,IaDL(Bentity$B$O(B
> $B%;%C%7%g%s4IM}$K$O;H$$$^$;$s!#(B
> 
> $B$^$:!"(BSeasar$B$G%;%C%7%g%s4IM}$9$k%/%i%9$r(Bscoreupgolf.form$B$K(BLoginInfoForm$B$H$+$G(B
> $B:[E-MAIL ADDRESS DELETED]$7!"$3$l$K(B
> @Component(instance = InstanceType.SESSION)
> $B$rDI2C$7$^$9!#(BSerializable$B$rK:$l$:$K!#(B
> 
> http://s2container.seasar.org/2.4/ja/DIContainer.html#ComponentAnnotation
> http://s2container.seasar.org/2.4/ja/DIContainer.html#InstanceMode
> 
> $B%m%0%$%s=hM}$r9T$&(BService$B$G>e5-$N(BLoginInfoForm$B$r(BDI$B$7!"%m%0%$%[E-MAIL ADDRESS DELETED];~$K3F<o%W%m%Q%F%#(B
> ($B%f!<%6(BID$B$H$+;aL>$H$+%m!<%k$H$+(Betc...)$B$r%;%C%H$7$F$*$-$^$9!#(B
> 
> AdminAuthInterceptor$B$G$O(B
> $B!!([E-MAIL ADDRESS DELETED]
> $B!!(Bprotected LoginInfoForm loginInfoForm
> $B$G%;%C%7%g%s$+$i(BDI$B$7!"$3$l$r;HMQ$7$F!"%m%0%$%s$7$F$$$k$+!)(Badmin$B%m!<%k$,$"$k$+!)$r%A%'%C%/$9$k(B
> $B$H$$$C$?%Q%?!<%s$,0lHLE*$G$O$J$$$+$H;W$$$^$9!#(B
> 
> #$B$=$l$K$7$F$b(BScoreupGolf$B!&!&!&5$$K$J$kL>>N$G$9(Bw
> _______________________________________________
> Seasar-user mailing list
> [E-MAIL ADDRESS DELETED]
> https://ml.seasar.org/mailman/listinfo/seasar-user


-- 
$B?9K\!!UrB@(B
e-mail: [E-MAIL ADDRESS DELETED]


Seasar-user メーリングリストの案内