0 Replies Latest reply on Jan 4, 2007 12:30 PM by Juan Giovanolli

    interceptor in ejb-jar.xml doesn't works

    Juan Giovanolli Newbie

      Hi:
      i created a new interceptor and i add it in ejb-jar.xml. this interceptor is a global interceptor, as you can see in my ejb-jar.xml shown below.
      The problem is that the interceptor is never reached, That is, the workflowinterceptor is never loaded.
      Any ideas???

      <ejb-jar xmlns="http://java.sun.com/xml/ns/javaee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
       version="3.0">
      
      
       <interceptors>
       <interceptor>
       <interceptor-class>
       org.jboss.seam.ejb.SeamInterceptor
       </interceptor-class>
       </interceptor>
       <interceptor>
       <interceptor-class>
       com.santex.darwin.service.interceptor.WorkflowInterceptor
       </interceptor-class>
       </interceptor>
      
       </interceptors>
      
      
       <assembly-descriptor>
       <interceptor-binding>
       <ejb-name>*</ejb-name>
       <interceptor-class>
       org.jboss.seam.ejb.SeamInterceptor
       </interceptor-class>
       <interceptor-class>
       com.santex.darwin.service.interceptor.WorkflowInterceptor
       </interceptor-class>
       </interceptor-binding>
       </assembly-descriptor>
      
      
      </ejb-jar>
      


      my workflowInterceptor is:

      package com.santex.darwin.service.interceptor;
      
      import javax.interceptor.AroundInvoke;
      import javax.interceptor.InvocationContext;
      
      import org.jboss.seam.contexts.Contexts;
      
      /**
       *
       * @author Juan Giovanolli
       * 29/12/2006
       */
      public class WorkflowInterceptor
      {
       @AroundInvoke
       public Object manageWorkflowRuntime(final InvocationContext invocation) throws Exception {
      
       if (invocation.getMethod().isAnnotationPresent(StartActivity.class)) {
       System.out.println("tiene el start");
       }
       if (invocation.getMethod().isAnnotationPresent(EndActivity.class)) {
       System.out.println("tiene el end");
       }
      
       return invocation.proceed();
       }
      }
      
      


      and my startActivity and endactivity annotations are

      /**
       *
       */
      package com.santex.darwin.service.interceptor;
      
      import java.lang.annotation.ElementType;
      import java.lang.annotation.Retention;
      import java.lang.annotation.RetentionPolicy;
      import java.lang.annotation.Target;
      
      import javax.interceptor.Interceptors;
      
      /**
       * @author Juan Giovanolli
       * 02/01/2007
       */
      @Target(ElementType.METHOD)
      @Retention(RetentionPolicy.RUNTIME)
      
      //@Interceptors(WorkflowInterceptor.class)
      public @interface StartActivity
      {
      
      }
      
      


      /**
       *
       */
      package com.santex.darwin.service.interceptor;
      
      import java.lang.annotation.ElementType;
      import java.lang.annotation.Retention;
      import java.lang.annotation.RetentionPolicy;
      import java.lang.annotation.Target;
      
      import javax.interceptor.Interceptors;
      
      /**
       * @author Juan Giovanolli
       * 02/01/2007
       */
      @Target(ElementType.METHOD)
      @Retention(RetentionPolicy.RUNTIME)
      
      //@Interceptors(WorkflowInterceptor.class)
      public @interface EndActivity
      {
      
      }
      
      


      the class where i testing this is this:

      package com.santex.darwin.example;
      
      import javax.ejb.Remove;
      import javax.interceptor.Interceptors;
      
      import org.jboss.seam.ScopeType;
      import org.jboss.seam.annotations.CreateProcess;
      import org.jboss.seam.annotations.Destroy;
      import org.jboss.seam.annotations.EndTask;
      import org.jboss.seam.annotations.In;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.annotations.Out;
      import org.jboss.seam.annotations.StartTask;
      import org.jboss.seam.core.TaskInstance;
      import org.jboss.seam.ejb.SeamInterceptor;
      
      import com.santex.darwin.core.workflow.Task;
      import com.santex.darwin.service.core.workflow.WorkflowManager;
      import com.santex.darwin.service.interceptor.EndActivity;
      import com.santex.darwin.service.interceptor.StartActivity;
      import com.santex.darwin.service.interceptor.WorkflowActivity;
      import com.santex.darwin.service.interceptor.WorkflowInterceptor;
      
      /**
       *
       * @author Juan Giovanolli 29/11/2006
       */
      
      @Name("taskManager")
      //@WorkflowActivity
      //@Interceptors(WorkflowInterceptor.class)
      public class TaskBeanExample implements Task
      {
      
       private String description;
      
       @In(create = true)
       WorkflowManager workflowManager;
      
       @Out(scope = ScopeType.BUSINESS_PROCESS)
       private String a = "S S";
      
       @In(create = true, required = false)
       org.jbpm.taskmgmt.exe.TaskInstance taskInstance;
      
       public String getA()
       {
       return a;
       }
      
       public void setA(String a)
       {
       this.a = a;
       }
      
      
      
       /**
       * @return the description
       */
       public String getDescription()
       {
       return description;
       }
      
       /**
       * @param description
       * the description to set
       */
       public void setDescription(String pDescription)
       {
       this.description = pDescription;
       }
      
       @StartTask
       @StartActivity
       public String startTask()
       {
       // System.out.println(workflowManagerImpl.getPendingTasks("sdfg"));
       System.out.println("ddddddddddddddddddddddddddddddddd" + a);
       a = ">>>>>VAR IN START<<<<<";
       try {
       System.out.println(">>>>>>>>>>startTask1" + taskInstance.getId() + " VARIABLES: "
       + taskInstance.getVariables().toString());
       taskInstance.setVariable("a1", a);
       System.out.println(">>>>>>>>>>startTask2" + taskInstance.getId() + " VARIABLES: "
       + taskInstance.getVariables().toString());
       }
       catch (Exception e) {
       e.printStackTrace();
       }
       return "";
       }
      
       @EndTask
       @EndActivity
       public String endTask()
       {
       System.out.println("ddddddddddddddddddddddddddddddddd" + a);
       a = ">>>>>VAR IN END<<<<<";
       try {
       System.out.println(">>>>>>>>>>endTask1" + taskInstance.getId() + " VARIABLES: "
       + taskInstance.getVariables().toString());
      
       taskInstance.setVariable("a2", a);
       System.out.println(">>>>>>>>>>endTask2" + taskInstance.getId() + " VARIABLES: "
       + taskInstance.getVariables().toString());
      
       }
       catch (Exception e) {
       e.printStackTrace();
       }
       return "";
       }
      
       @Remove
       @Destroy
       public void destroy()
       {
      
       }
      
       @CreateProcess(definition = "ProcessAbstract")
       public String startProcess()
       {
       return "";
       }
      
      }