[jboss-user] [JBoss AOP] - About multiple introductions and mixins

elysch do-not-reply at jboss.com
Tue May 6 10:59:14 EDT 2008


Hi all.

I hope my question is not too dumb.

I have a project in which I need to specify via AOP all the functionalities of each use case by it self.

So, I have an almost empty structure with hibernate, spring, and struts (an AndroMDA structure with jbpm, etc).

In it's various layers I need to add new methods and attributes using introductions.

My problem is that, for example, I add a new "find" method in the Dao object and when I add a method that uses it in a service object I get an error on compilation, because this new method can't be found.

I hope I can explain it clearly with code:

For example, the jboss-aop.xml has:
   <introduction class="com.mitalteli.bolsaDeTrabajo.domain.VacanteDao">
  |       <mixin>
  |          <interfaces>
  | 	       com.mitalteli.bolsaDeTrabajo.useCaseSlices.specific.consultarVacantes.IAspectoVacanteDao
  |          </interfaces>
  |          <class>com.mitalteli.bolsaDeTrabajo.useCaseSlices.specific.consultarVacantes.MixinAspectoVacanteDao</class>
  |          <construction>new com.mitalteli.bolsaDeTrabajo.useCaseSlices.specific.consultarVacantes.MixinAspectoVacanteDao(this)</construction>
  |       </mixin>
  |    </introduction>

and 

   <introduction class="com.mitalteli.bolsaDeTrabajo.service.ServicioConsultarVacantesBase">
  |       <mixin>
  |          <interfaces>
  | 	       com.mitalteli.bolsaDeTrabajo.useCaseSlices.specific.consultarVacantes.IAspectoServicioConsultarVacantesBase
  |          </interfaces>
  |          <class>com.mitalteli.bolsaDeTrabajo.useCaseSlices.specific.consultarVacantes.MixinAspectoServicioConsultarVacantesBase</class>
  |          <construction>new com.mitalteli.bolsaDeTrabajo.useCaseSlices.specific.consultarVacantes.MixinAspectoServicioConsultarVacantesBase(this)</construction>
  |       </mixin>
  |    </introduction>

and their respective mixins contain:

    /**
  |      * @see com.mitalteli.bolsaDeTrabajo.domain.VacanteDao#encuentraConCriterios(com.mitalteli.bolsaDeTrabajo.vo.CriteriosBusquedaConsultarVacantesVO)
  |      */
  |     public java.util.List encuentraConCriterios(final com.mitalteli.bolsaDeTrabajo.vo.CriteriosBusquedaConsultarVacantesVO criteria)
  |     {
  |         if (criteria == null)
  |         {
  |             throw new IllegalArgumentException(
  |                 "com.mitalteli.bolsaDeTrabajo.domain.VacanteDao.encuentraConCriterios(com.mitalteli.bolsaDeTrabajo.vo.CriteriosBusquedaConsultarVacantesVO criteria) - 'criteria' can not be null");
  |         }
  |         try
  |         {
  |             return this.handleEncuentraConCriterios(criteria);
  |         }
  |         catch (Throwable th)
  |         {
  |             throw new java.lang.RuntimeException(
  |             "Error performing 'com.mitalteli.bolsaDeTrabajo.domain.VacanteDao.encuentraConCriterios(com.mitalteli.bolsaDeTrabajo.vo.CriteriosBusquedaConsultarVacantesVO criteria)' --> " + th,
  |             th);
  |         }
  |     }

and

    /**
  |      * @see com.mitalteli.bolsaDeTrabajo.service.ServicioConsultarVacantes#encuentraVacantes(com.mitalteli.bolsaDeTrabajo.vo.CriteriosBusquedaConsultarVacantesVO)
  |      */
  |     public /*protected*/ com.mitalteli.bolsaDeTrabajo.vo.ResumenVacanteVO[] handleEncuentraVacantes(com.mitalteli.bolsaDeTrabajo.vo.CriteriosBusquedaConsultarVacantesVO criteria)
  |         throws java.lang.Exception
  |     {
  |         //List vacantes = servicioConsultarVacantesBase.getVacanteDao().encuentraConCriterios(criteria);
  |         List vacantes = getVacanteDao().encuentraConCriterios(criteria);
  |         getVacanteDao().toResumenVacanteVOCollection(vacantes);
  |         return (ResumenVacanteVO[])vacantes.toArray(new ResumenVacanteVO[0]);
  |     }

So, as I told before, the Dao class should have now a find method called: encuentraConCriterios, so the call to getVacanteDao().encuentraConCriterios(criteria); should be found, but that's not the case. I get the error message:

...\useCaseSlices\specific\consultarVacantes\MixinAspectoServicioConsultarVacantesB
  | ase.java:[162,39] cannot find symbol
  | symbol  : method encuentraConCriterios(com.mitalteli.bolsaDeTrabajo.vo.Criterios
  | BusquedaConsultarVacantesVO)
  | location: interface com.mitalteli.bolsaDeTrabajo.domain.VacanteDao

I'm trying to do loadtime waving on a jboss-4.2.1.GA with jboss-aop-1.5.6 with jdk 6 update 3, and jre 6 update 5 on my WinXP pro Service pack2 computer.

So I'm not waving the classes yet, just compiling them. I guess I'm doing some thing wrong.

Is this even possible? Maybe If I compile and wave the first mixin, and then compile and wave the second one, instead of doing loadtime waving?

Any Ideas?

I'm very very new to all this AOP technology, so maybe I don't understand something right.

Thank you all in advance.

Ely.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4148849#4148849

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4148849



More information about the jboss-user mailing list