Package org.jboss.seam

Examples of org.jboss.seam.Component$ELInitialValue


   {
      if (type != null)
      {
         return type;
      }
      Component component = getComponent();
      if (component == null)
      {
         return null;
      }
      if (component.hasUnwrapMethod())
      {
         return component.getUnwrapMethod().getReturnType();
      }
      return component.getBeanClass();
   }
View Full Code Here


   }

   public List<Class> getSeamInterfaces()
   {
      List<Class> interfaces = new ArrayList<Class>();
      Component component = getComponent();
      // Attempt to piece together all of the possible interfaces to apply
      // to our proxy.
      if ( component != null && component.isInterceptionEnabled() )
      {
         if (component.getType().isSessionBean())
         {
            interfaces.addAll(component.getBusinessInterfaces());
         }
         else
         {
            interfaces.add(HttpSessionActivationListener.class);
            interfaces.add(Mutable.class);
View Full Code Here

            Lifecycle.setupApplication();
            unmockApplication = true;
         }
         try
         {
            Component component = Component.forName(name);
            if (component == null)
            {
               throw new IllegalStateException("Cannot find targetClass for seam component: "
                        + name + ".  Make sure Seam is being configured before Spring.");
            }
View Full Code Here

    public Object get(String name, ObjectFactory objectFactory)
    {
        try
        {
            SpringComponent.setObjectFactory(objectFactory);
            Component component = SpringComponent.forSpringBeanName(name);
            return Component.getInstance(component.getName(), scope, true);
        }
        finally
        {
            SpringComponent.setObjectFactory(null);
        }
View Full Code Here

     */
    public Object remove(String name) {
        // copied from Component.callDestory should be able to reuse. Needed because if remove is called then for some
        // reason spring doesn't use the destroy callback.
        log.debug("destroying: " + name);
        Component component = SpringComponent.forSpringBeanName(name);
        Object bean = null;
        if (component != null)
        {
            bean = scope.getContext().get(component.getName());
            if (bean != null) // in a portal environment, this is possible
            {
                if (Events.exists())
                {
                    Events.instance().raiseEvent("org.jboss.seam.preDestroy." + name);
                }
                try
                {
                    if (component.hasDestroyMethod())
                    {
                        component.callComponentMethod(bean, component.getDestroyMethod());
                    }
                }
                catch (Exception e)
                {
                    log.warn("Could not destroy component: " + component.getName(), e);
                }
            }
            scope.getContext().remove(component.getName());
        }
        return bean;
    }
View Full Code Here

            Class<?> d = changed.get(i);

            // if the class is a seam component
            if (d.isAnnotationPresent(Name.class)) {
                String name = d.getAnnotation(Name.class).value();
                Component component = Component.forName(name);
                if (component != null) {
                    ScopeType scope = component.getScope();
                    if (scope != ScopeType.STATELESS && scope.isContextActive()) {
                        scope.getContext().remove(name);
                    }
                    Init.instance().removeObserverMethods(component);
                }
View Full Code Here

      MockExternalContext externalContext = new MockExternalContext(servletContext);
      Context appContext = new ApplicationContext( externalContext.getApplicationMap() );
      appContext.set( Seam.getComponentName(Init.class), new Init() );
      appContext.set(
            Seam.getComponentName(ConversationEntries.class) + ".component",
            new Component(ConversationEntries.class, appContext)
         );
      appContext.set(
            Seam.getComponentName(Manager.class) + ".component",
            new Component(Manager.class, appContext)
         );
      appContext.set(
            Seam.getComponentName(Foo.class) + ".component",
            new Component(Foo.class, appContext)
         );
      appContext.set(
            Seam.getComponentName(Factory.class) + ".component",
            new Component(Factory.class, appContext)
         );

      FacesLifecycle.beginRequest(externalContext);
      Manager.instance().setCurrentConversationId("1");
      FacesLifecycle.resumeConversation(externalContext);
      FacesLifecycle.setPhaseId(PhaseId.RENDER_RESPONSE);
     
      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

      MockExternalContext externalContext = new MockExternalContext(servletContext);
      Context appContext = new ApplicationContext( externalContext.getApplicationMap() );
      appContext.set( Seam.getComponentName(Init.class), new Init() );
      appContext.set(
            Seam.getComponentName(ConversationEntries.class) + ".component",
            new Component(ConversationEntries.class, appContext)
         );
      appContext.set(
            Seam.getComponentName(PersistenceContexts.class) + ".component",
            new Component(PersistenceContexts.class, appContext)
         );
      appContext.set(
            Seam.getComponentName(Manager.class) + ".component",
            new Component(Manager.class, appContext)
         );
      FacesLifecycle.beginRequest( externalContext );
      Manager.instance().setCurrentConversationId("1");
      FacesLifecycle.resumeConversation(externalContext);

      ConversationInterceptor ci = new ConversationInterceptor();
      ci.setComponent( new Component(Foo.class, appContext) );
     
      assert !Manager.instance().isLongRunningConversation();

      String result = (String) ci.aroundInvoke( new MockInvocationContext() {
         @Override
View Full Code Here

      MockExternalContext externalContext = new MockExternalContext(servletContext);
      Context appContext = new ApplicationContext( externalContext.getApplicationMap() );
      appContext.set( Seam.getComponentName(Init.class), new Init() );
      appContext.set(
            Seam.getComponentName(ConversationEntries.class) + ".component",
            new Component(ConversationEntries.class, appContext)
         );
      appContext.set(
            Seam.getComponentName(Manager.class) + ".component",
            new Component(Manager.class, appContext)
         );
      appContext.set(
            Seam.getComponentName(FacesMessages.class) + ".component",
            new Component(FacesMessages.class, appContext)
         );
      appContext.set(
               Seam.getComponentName(Events.class) + ".component",
               new Component(Events.class, appContext)
            );
      FacesLifecycle.setPhaseId(PhaseId.INVOKE_APPLICATION);
      FacesLifecycle.beginRequest( externalContext );
      Manager.instance().setCurrentConversationId("1");
      FacesLifecycle.resumeConversation(externalContext);
     
      ConversationalInterceptor ci = new ConversationalInterceptor();
      ci.setComponent( new Component(Bar.class, appContext) );
     
      assert !Manager.instance().isLongRunningConversation();
     
      try
      {
View Full Code Here

     
      Context appContext = new ApplicationContext( externalContext.getApplicationMap() );
      appContext.set( Seam.getComponentName(Init.class), new Init() );
      appContext.set(
            Seam.getComponentName(ConversationEntries.class) + ".component",
            new Component(ConversationEntries.class, appContext)
         );
      appContext.set(
            Seam.getComponentName(Manager.class) + ".component",
            new Component(Manager.class, appContext)
         );
      appContext.set(
            Seam.getComponentName(FacesMessages.class) + ".component",
            new Component(FacesMessages.class, appContext)
         );
      appContext.set(
            Seam.getComponentName(Interpolator.class) + ".component",
            new Component(Interpolator.class, appContext)
         );
      FacesLifecycle.setPhaseId(PhaseId.INVOKE_APPLICATION);
      FacesLifecycle.beginRequest(externalContext);
      Manager.instance().setCurrentConversationId("1");
      FacesLifecycle.resumeConversation(externalContext);
View Full Code Here

TOP

Related Classes of org.jboss.seam.Component$ELInitialValue

Copyright © 2018 www.massapicom. 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.