Examples of BijectionInterceptor


Examples of org.jboss.seam.core.BijectionInterceptor

     
      final Bar bar = new Bar();
      final Foo foo = new Foo();
      Contexts.getSessionContext().set("otherFoo", foo);
     
      BijectionInterceptor bi = new BijectionInterceptor();
      bi.setComponent( new Component(Bar.class, appContext) );
      String result = (String) bi.aroundInvoke( new MockInvocationContext() {
         @Override
         public Object getTarget()
         {
            return bar;
         }

         @Override
         public Object proceed() throws Exception
         {
            assert bar.otherFoo==foo;
            assert bar.foo!=null;
            return bar.foo();
         }
      });
      assert "foo".equals(result);
      assert Contexts.getEventContext().get("otherString").equals("outAgain");
      assert Contexts.getConversationContext().get("string").equals("out");
      assert Contexts.getSessionContext().isSet("foo");
      assert bar.foo==null;
      assert bar.otherFoo==null;
     
      final Method method;
      try
      {
         method = Bar.class.getMethod("foo");
      }
      catch (Exception e)
      {
         throw new RuntimeException(e);
      }

      bi.aroundInvoke( new MockInvocationContext() {
         @Override
         public Object getTarget()
         {
            return bar;
         }

         @Override
         public Object proceed() throws Exception
         {
            assert bar.otherFoo==foo;
            assert bar.foo!=null;
            return bar.foo();
         }
         @Override
         public Method getMethod()
         {
            return method;
         }
      });
      assert bar.foo==null;
      assert bar.otherFoo==null;
     
      try
      {
         Contexts.getSessionContext().remove("otherFoo");
         bi.aroundInvoke( new MockInvocationContext() {
            @Override
            public Object getTarget()
            {
               return bar;
            }
            @Override
            public Object proceed() throws Exception
            {
               assert false;
               return null;
            }
            @Override
            public Method getMethod()
            {
               return method;
            }
         });
         assert false;
      }
      catch (Exception e)
      {
         assert e instanceof RequiredException;
      }
     
      final Method method2;
      try
      {
         method2 = BrokenAction.class.getMethod("go");
      }
      catch (Exception e)
      {
         throw new RuntimeException(e);
      }

      final BrokenAction brokenAction = new BrokenAction();
      BijectionInterceptor biba = new BijectionInterceptor();
      biba.setComponent( new Component(BrokenAction.class, appContext) );
      try
      {
         biba.aroundInvoke( new MockInvocationContext() {
  
            @Override
            public Object getTarget() {
               return brokenAction;
            }  
            @Override
            public Object proceed() throws Exception {
               assert false;
               return null;
            }
           
            @Override
            public Method getMethod()
            {
               return method2;
            }
         
         } );
         assert false;
      }
      catch (Exception e)
      {
         assert e instanceof RequiredException;
      }
     
      final Method method3;
      try
      {
         method3 = Action.class.getMethod("go");
      }
      catch (Exception e)
      {
         throw new RuntimeException(e);
      }

      final Action action = new Action();
      BijectionInterceptor bia = new BijectionInterceptor();
      bia.setComponent( new Component(Action.class, appContext) );
      result = (String) bia.aroundInvoke( new MockInvocationContext() {

         @Override
         public Object getTarget() {
            return action;
         }
View Full Code Here

Examples of org.jboss.seam.core.BijectionInterceptor

            new Component(FooBar.class, appContext) );          
     
      final Foo foo = new Foo();
      final FooBar fooBar = new FooBar();
     
      final BijectionInterceptor bi = new BijectionInterceptor();
      bi.setComponent( new Component(FooBar.class, appContext) );
     
      final Method m = FooBar.class.getMethod("delayedGetFoo", InvocationControl.class);
     
      final InvocationControl invocationAControl = new InvocationControl("A");
      final InvocationControl invocationBControl = new InvocationControl("B");
      final InvocationControl invocationCControl = new InvocationControl("C");
     
      final Map<String, Foo> invocationResults = new HashMap<String, Foo>();
     
      final InvocationContext invocationA = new MockInvocationContext() {
         @Override public Object getTarget() { return fooBar; }        
         @Override public Method getMethod() { return m; }
         @Override public Object[] getParameters() { return new Object[] { invocationAControl }; }
         @Override public Object proceed() throws Exception { return Reflections.invoke(getMethod(), getTarget(), getParameters()); }
      };

      final InvocationContext invocationB = new MockInvocationContext() {
         @Override public Object getTarget() { return fooBar; }        
         @Override public Method getMethod() { return m; }
         @Override public Object[] getParameters() { return new Object[] { invocationBControl }; }
         @Override public Object proceed() throws Exception { return Reflections.invoke(getMethod(), getTarget(), getParameters()); }
      };
     
      final InvocationContext invocationC = new MockInvocationContext() {
         @Override public Object getTarget() { return fooBar; }        
         @Override public Method getMethod() { return m; }
         @Override public Object[] getParameters() { return new Object[] { invocationCControl }; }
         @Override public Object proceed() throws Exception { return Reflections.invoke(getMethod(), getTarget(), getParameters()); }
      };
     
      final WrappedException thread1Exception = new WrappedException();
      final WrappedException thread2Exception = new WrappedException();
      final WrappedException thread3Exception = new WrappedException();
                 
      new Thread(new Runnable() {
         public void run() {
            try
            {
               FacesLifecycle.beginRequest(externalContext);
               Manager.instance().setCurrentConversationId("1");
               FacesLifecycle.resumeConversation(externalContext);
               FacesLifecycle.setPhaseId(PhaseId.RENDER_RESPONSE);

               Contexts.getSessionContext().set("foo", foo);
               Foo result = (Foo) bi.aroundInvoke( invocationA );
               invocationResults.put("A", result);
            }
            catch (Exception ex)
            {
               thread1Exception.exception = ex;
            }
            finally
            {
               invocationAControl.markFinished();
            }
         }    
      }).start();   
     
      new Thread(new Runnable() {
         public void run() {
            try
            {
               FacesLifecycle.beginRequest(externalContext);
               Manager.instance().setCurrentConversationId("1");
               FacesLifecycle.resumeConversation(externalContext);
               FacesLifecycle.setPhaseId(PhaseId.RENDER_RESPONSE);
              
               Contexts.getSessionContext().set("foo", foo);              
              
               Foo result = (Foo) bi.aroundInvoke( invocationB );
               invocationResults.put("B", result);
            }
            catch (Exception ex)
            {
               thread2Exception.exception = ex;
            }
            finally
            {
               invocationBControl.markFinished();
            }
         }    
      }).start();
     
      new Thread(new Runnable() {
         public void run() {
            try
            {
               FacesLifecycle.beginRequest(externalContext);
               Manager.instance().setCurrentConversationId("1");
               FacesLifecycle.resumeConversation(externalContext);
               FacesLifecycle.setPhaseId(PhaseId.RENDER_RESPONSE);
              
               Contexts.getSessionContext().set("foo", foo);              
              
               Foo result = (Foo) bi.aroundInvoke( invocationC );
               invocationResults.put("C", result);
            }
            catch (Exception ex)
            {
               thread3Exception.exception = ex;
View Full Code Here

Examples of org.jboss.seam.core.BijectionInterceptor

      FacesLifecycle.setPhaseId(PhaseId.RENDER_RESPONSE);
     
      final CyclicFoo cyclicFoo = new CyclicFoo();
      final CyclicBar cyclicBar = new CyclicBar();
     
      final BijectionInterceptor cyclicFooBijectionInterceptor = new BijectionInterceptor();
      cyclicFooBijectionInterceptor.setComponent( new Component(CyclicFoo.class, appContext) );
      final Method cyclicFooGetName = CyclicFoo.class.getMethod("getName");
      final MockInvocationContext callGetName = new MockInvocationContext() {
         @Override
         public Object getTarget()
         {
            return cyclicFoo;
         }

         @Override
         public Object proceed() throws Exception
         {
            return cyclicFoo.getName();
         }
        
         @Override
         public Method getMethod()
         {
            return cyclicFooGetName;
         }
      };
     
      final Method cyclicFooGetFooBar = CyclicFoo.class.getMethod("getFooBar");
      final MockInvocationContext callGetCyclicFooBar = new MockInvocationContext() {
         @Override
         public Object getTarget()
         {
            return cyclicFoo;
         }
        
         @Override
         public Object proceed() throws Exception
         {
            return cyclicFoo.getFooBar();
         }
        
         @Override
         public Method getMethod()
         {
            return cyclicFooGetFooBar;
         }
      };
     
      CyclicFoo cyclicFooProxy = new CyclicFoo()
      {
         @Override
         public String getName() throws Exception
         {
            return (String) cyclicFooBijectionInterceptor.aroundInvoke(callGetName);
         }
        
         @Override
         public String getFooBar() throws Exception
         {
            return (String) cyclicFooBijectionInterceptor.aroundInvoke(callGetCyclicFooBar);
         }
      };
     
     
      final BijectionInterceptor cyclicBarBijectionInterceptor = new BijectionInterceptor();
      cyclicBarBijectionInterceptor.setComponent( new Component(CyclicBar.class, appContext) );
      final Method cyclicBarProvideCyclicFooBar = CyclicBar.class.getMethod("provideCyclicFooBar");
      final MockInvocationContext callProvideCyclicFooBar = new MockInvocationContext() {
         @Override
         public Object getTarget()
         {
View Full Code Here

Examples of org.jboss.seam.core.BijectionInterceptor

     
      final Bar bar = new Bar();
      final Foo foo = new Foo();
      Contexts.getSessionContext().set("otherFoo", foo);
     
      BijectionInterceptor bi = new BijectionInterceptor();
      bi.setComponent( new Component(Bar.class, appContext) );
      String result = (String) bi.aroundInvoke( new MockInvocationContext() {
         @Override
         public Object getTarget()
         {
            return bar;
         }

         @Override
         public Object proceed() throws Exception
         {
            assert bar.otherFoo==foo;
            assert bar.foo!=null;
            return bar.foo();
         }
      });
      assert "foo".equals(result);
      assert Contexts.getEventContext().get("otherString").equals("outAgain");
      assert Contexts.getConversationContext().get("string").equals("out");
      assert Contexts.getSessionContext().isSet("foo");
      assert bar.foo==null;
      assert bar.otherFoo==null;
     
      final Method method;
      try
      {
         method = Bar.class.getMethod("foo");
      }
      catch (Exception e)
      {
         throw new RuntimeException(e);
      }

      bi.aroundInvoke( new MockInvocationContext() {
         @Override
         public Object getTarget()
         {
            return bar;
         }

         @Override
         public Object proceed() throws Exception
         {
            assert bar.otherFoo==foo;
            assert bar.foo!=null;
            return bar.foo();
         }
         @Override
         public Method getMethod()
         {
            return method;
         }
      });
      assert bar.foo==null;
      assert bar.otherFoo==null;
     
      try
      {
         Contexts.getSessionContext().remove("otherFoo");
         bi.aroundInvoke( new MockInvocationContext() {
            @Override
            public Object getTarget()
            {
               return bar;
            }
            @Override
            public Object proceed() throws Exception
            {
               assert false;
               return null;
            }
            @Override
            public Method getMethod()
            {
               return method;
            }
         });
         assert false;
      }
      catch (Exception e)
      {
         assert e instanceof RequiredException;
      }
     
      final Method method2;
      try
      {
         method2 = BrokenAction.class.getMethod("go");
      }
      catch (Exception e)
      {
         throw new RuntimeException(e);
      }

      final BrokenAction brokenAction = new BrokenAction();
      BijectionInterceptor biba = new BijectionInterceptor();
      biba.setComponent( new Component(BrokenAction.class, appContext) );
      try
      {
         biba.aroundInvoke( new MockInvocationContext() {
  
            @Override
            public Object getTarget() {
               return brokenAction;
            }  
            @Override
            public Object proceed() throws Exception {
               assert false;
               return null;
            }
           
            @Override
            public Method getMethod()
            {
               return method2;
            }
         
         } );
         assert false;
      }
      catch (Exception e)
      {
         assert e instanceof RequiredException;
      }
     
      final Method method3;
      try
      {
         method3 = Action.class.getMethod("go");
      }
      catch (Exception e)
      {
         throw new RuntimeException(e);
      }

      final Action action = new Action();
      BijectionInterceptor bia = new BijectionInterceptor();
      bia.setComponent( new Component(Action.class, appContext) );
      result = (String) bia.aroundInvoke( new MockInvocationContext() {

         @Override
         public Object getTarget() {
            return action;
         }
View Full Code Here

Examples of org.jboss.seam.core.BijectionInterceptor

      {
         addInterceptor( new Interceptor( new ConversationInterceptor(), this ) );
      }
      if ( needsInjection() || needsOutjection() )
      {
         addInterceptor( new Interceptor( new BijectionInterceptor(), this ) );
      }
      addInterceptor( new Interceptor( new RollbackInterceptor(), this ) );
      if ( getType()==JAVA_BEAN && beanClassHasAnnotation(Transactional.class))
      {
         addInterceptor( new Interceptor( new TransactionInterceptor(), this ) );
View Full Code Here

Examples of org.jboss.seam.core.BijectionInterceptor

      {
         addInterceptor( new Interceptor( new ConversationInterceptor(), this ) );
      }
      if ( needsInjection() || needsOutjection() )
      {
         addInterceptor( new Interceptor( new BijectionInterceptor(), this ) );
      }
      addInterceptor( new Interceptor( new RollbackInterceptor(), this ) );
      if ( getType()==JAVA_BEAN && beanClassHasAnnotation(Transactional.class))
      {
         addInterceptor( new Interceptor( new TransactionInterceptor(), this ) );
View Full Code Here

Examples of org.jboss.seam.core.BijectionInterceptor

      {
         addInterceptor( new Interceptor( new ConversationInterceptor(), this ) );
      }
      if ( needsInjection() || needsOutjection() )
      {
         addInterceptor( new Interceptor( new BijectionInterceptor(), this ) );
      }
      addInterceptor( new Interceptor( new RollbackInterceptor(), this ) );
      if ( getType()==JAVA_BEAN && beanClassHasAnnotation(Transactional.class))
      {
         addInterceptor( new Interceptor( new TransactionInterceptor(), this ) );
View Full Code Here

Examples of org.jboss.seam.interceptors.BijectionInterceptor

     
      final Bar bar = new Bar();
      final Foo foo = new Foo();
      Contexts.getSessionContext().set("otherFoo", foo);
     
      BijectionInterceptor bi = new BijectionInterceptor();
      bi.setComponent( new Component(Bar.class, appContext) );
      String result = (String) bi.aroundInvoke( new MockInvocationContext() {
         @Override
         public Object getTarget()
         {
            return bar;
         }

         @Override
         public Object proceed() throws Exception
         {
            assert bar.otherFoo==foo;
            assert bar.foo!=null;
            return bar.foo();
         }
      });
      assert "foo".equals(result);
      assert Contexts.getEventContext().get("otherString").equals("outAgain");
      assert Contexts.getConversationContext().get("string").equals("out");
      assert Contexts.getSessionContext().isSet("foo");
      assert bar.foo==null;
      assert bar.otherFoo==null;
     
      final Method method;
      try
      {
         method = Bar.class.getMethod("foo");
      }
      catch (Exception e)
      {
         throw new RuntimeException(e);
      }

      bi.aroundInvoke( new MockInvocationContext() {
         @Override
         public Object getTarget()
         {
            return bar;
         }

         @Override
         public Object proceed() throws Exception
         {
            assert bar.otherFoo==foo;
            assert bar.foo!=null;
            return bar.foo();
         }
         @Override
         public Method getMethod()
         {
            return method;
         }
      });
      assert bar.foo==null;
      assert bar.otherFoo==null;
     
      try
      {
         Contexts.getSessionContext().remove("otherFoo");
         bi.aroundInvoke( new MockInvocationContext() {
            @Override
            public Object getTarget()
            {
               return bar;
            }
            @Override
            public Object proceed() throws Exception
            {
               assert false;
               return null;
            }
            @Override
            public Method getMethod()
            {
               return method;
            }
         });
         assert false;
      }
      catch (Exception e)
      {
         assert e instanceof RequiredException;
      }
     
      final Method method2;
      try
      {
         method2 = BrokenAction.class.getMethod("go");
      }
      catch (Exception e)
      {
         throw new RuntimeException(e);
      }

      final BrokenAction brokenAction = new BrokenAction();
      BijectionInterceptor biba = new BijectionInterceptor();
      biba.setComponent( new Component(BrokenAction.class, appContext) );
      try
      {
         biba.aroundInvoke( new MockInvocationContext() {
  
            @Override
            public Object getTarget() {
               return brokenAction;
            }  
            @Override
            public Object proceed() throws Exception {
               assert false;
               return null;
            }
           
            @Override
            public Method getMethod()
            {
               return method2;
            }
         
         } );
         assert false;
      }
      catch (Exception e)
      {
         assert e instanceof RequiredException;
      }
     
      final Method method3;
      try
      {
         method3 = Action.class.getMethod("go");
      }
      catch (Exception e)
      {
         throw new RuntimeException(e);
      }

      final Action action = new Action();
      BijectionInterceptor bia = new BijectionInterceptor();
      bia.setComponent( new Component(Action.class, appContext) );
      result = (String) bia.aroundInvoke( new MockInvocationContext() {

         @Override
         public Object getTarget() {
            return action;
         }
View Full Code Here

Examples of org.jboss.seam.interceptors.BijectionInterceptor

      {
         addInterceptor( new Interceptor( new ConversationInterceptor(), this ) );
      }
      if ( needsInjection() || needsOutjection() )
      {
         addInterceptor( new Interceptor( new BijectionInterceptor(), this ) );
      }
      if ( beanClassHasAnnotation(IfInvalid.class) )
      {
         addInterceptor( new Interceptor( new ValidationInterceptor(), this ) );
      }
View Full Code Here

Examples of org.jboss.seam.wicket.ioc.BijectionInterceptor

  

   private void initInterceptors()
   {
      // TODO Add a check to see whether we really need this
      interceptors.add(new BijectionInterceptor());
      if (!conversationManagementMembers.isEmpty())
      {
         interceptors.add(new ConversationInterceptor());
      }
      if (anyMethodHasRaiseEvent)
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.