Package org.jboss.seam

Examples of org.jboss.seam.Component


      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)
         );

      FacesLifecycle.beginRequest( externalContext );
      Contexts.getSessionContext().set( "foo", new Foo() );
     
      RemoveInterceptor ri = new RemoveInterceptor();
      ri.setComponent( new Component(Foo.class, appContext) );
     
      ri.aroundInvoke( new MockInvocationContext() {
         @Override
         public Method getMethod()
         {
View Full Code Here


      installComponent(appContext, TestActions.class);
   }

   private void installComponent(Context appContext, Class clazz)
   {
      appContext.set(Seam.getComponentName(clazz) + ".component", new Component(clazz));
   }
View Full Code Here

   }
  
   @Test
   public void testComponent()
   {
      Component c = new Component(Bar.class);
      assert c.getName().equals("bar");
      assert c.getBeanClass()==Bar.class;
      assert c.getType()==ComponentType.JAVA_BEAN;
      assert c.getScope()==ScopeType.CONVERSATION;
      assert c.hasDestroyMethod();
      assert c.hasCreateMethod();
      assert c.getCreateMethod().getName().equals("create");
      assert c.getDestroyMethod().getName().equals("destroy");
      assert c.getInAttributes().size()==2;
      assert c.getUnwrapMethod()==null;
      assert c.getOutAttributes().size()==2;
      assert c.getRemoveMethods().size()==0;
      assert c.isInstance( new Bar() );

      c = new Component(Foo.class);
      assert c.getName().equals("foo");
      assert c.getBeanClass()==Foo.class;
      assert c.getType()==ComponentType.JAVA_BEAN;
      assert c.getScope()==ScopeType.SESSION;
      assert !c.hasDestroyMethod();
      assert !c.hasCreateMethod();
      assert c.getCreateMethod()==null;
      assert c.getDestroyMethod()==null;
      assert c.getInAttributes().size()==0;
      assert c.getUnwrapMethod()==null;
      assert c.getOutAttributes().size()==0;
      assert c.getRemoveMethods().size()==1;
      assert c.isInstance( new Foo() );
     
      c = new Component(EjbBean.class);
      assert c.getName().equals("ejb");
      assert c.getBeanClass()==EjbBean.class;
      assert c.getType()==ComponentType.STATEFUL_SESSION_BEAN;
      assert c.getScope()==ScopeType.EVENT;
      assert c.hasDestroyMethod();
      assert !c.hasDefaultRemoveMethod();
      assert !c.hasCreateMethod();
      assert c.getCreateMethod()==null;
      assert c.getDestroyMethod()!=null;
      assert c.getDefaultRemoveMethod()==null;
      assert c.getInAttributes().size()==0;
      assert c.getUnwrapMethod()==null;
      assert c.getOutAttributes().size()==0;
      assert c.getRemoveMethods().size()==1;
      assert c.isInstance( new Ejb() {
         public void destroy() {}
         public void foo() {}
      } );
   }
View Full Code Here

      } );
   }
  
   public void testBuiltInComponents()
   {
      Component c = new Component(Manager.class);
      assert c.getName().equals("org.jboss.seam.conversationManager");
      assert c.getBeanClass()==Manager.class;
      assert c.getType()==ComponentType.JAVA_BEAN;
      assert c.getScope()==ScopeType.EVENT;
      assert c.hasDestroyMethod();
      assert !c.hasCreateMethod();
      assert c.getCreateMethod()==null;
      assert c.getDestroyMethod().getName().equals("destroy");
      assert c.getInAttributes().size()==0;
      assert c.getUnwrapMethod()==null;
      assert c.getOutAttributes().size()==0;
      assert c.getRemoveMethods().size()==0;

      c = new Component(Init.class);
      assert c.getName().equals("org.jboss.seam.settings");
      assert c.getBeanClass()==Init.class;
      assert c.getType()==ComponentType.JAVA_BEAN;
      assert c.getScope()==ScopeType.APPLICATION;
      assert !c.hasDestroyMethod();
      assert !c.hasCreateMethod();
      assert c.getCreateMethod()==null;
      assert c.getDestroyMethod()==null;
      assert c.getInAttributes().size()==0;
      assert c.getUnwrapMethod()==null;
      assert c.getOutAttributes().size()==0;
      assert c.getRemoveMethods().size()==0;
      c = new Component(ManagedPersistenceContext.class, "pc");
      assert c.getName().equals("pc");
      assert c.getBeanClass()==ManagedPersistenceContext.class;
      assert c.getType()==ComponentType.JAVA_BEAN;
      assert c.getScope()==ScopeType.CONVERSATION;
      assert c.hasDestroyMethod();
      assert c.hasCreateMethod();
      assert c.getCreateMethod().getName().equals("create");
      assert c.getDestroyMethod().getName().equals("destroy");
      assert c.getInAttributes().size()==0;
      assert c.getUnwrapMethod().getName().equals("getEntityManager");
      assert c.getOutAttributes().size()==0;
      assert c.getRemoveMethods().size()==0;

      c = new Component(ManagedHibernateSession.class, "pc");
      assert c.getName().equals("pc");
      assert c.getBeanClass()==ManagedHibernateSession.class;
      assert c.getType()==ComponentType.JAVA_BEAN;
      assert c.getScope()==ScopeType.CONVERSATION;
      assert c.hasDestroyMethod();
      assert c.hasCreateMethod();
      assert c.getCreateMethod().getName().equals("create");
      assert c.getDestroyMethod().getName().equals("destroy");
      assert c.getInAttributes().size()==0;
      assert c.getUnwrapMethod().getName().equals("getSession");
      assert c.getOutAttributes().size()==0;
      assert c.getRemoveMethods().size()==0;
   }
View Full Code Here

public class ContextTest
{
   private void installComponent(Context appContext, Class clazz)
   {
      appContext.set( Seam.getComponentName(clazz) + ".component", new Component(clazz) );
   }
View Full Code Here

      installComponent(appContext, ResourceLoader.class);
   }
  
   private void installComponent(Context appContext, Class clazz)
   {
      appContext.set( Seam.getComponentName(clazz) + ".component", new Component(clazz) );
   }
View Full Code Here

      Lifecycle.startDestroying();
      try
      {
         for ( String name: context.getNames() )
         {
            Component component = Component.forName(name);
            log.debug("destroying: " + name);
            if ( component!=null )
            {
               Object object = context.get(name);
               if (object!=null) //in a portal environment, this is possible
               {
                  if ( Events.exists() ) Events.instance().raiseEvent("org.jboss.seam.preDestroy." + name);
                  component.destroy(object);
               }
            }
         }
      }
      finally
View Full Code Here

      for ( String name: context.getNames() )
      {
         Object object = context.get(name);
         if ( object!=null && (object instanceof Component) )
         {
            Component component = (Component) object;
            if ( component.isStartup() && component.getScope()==scopeType )
            {
               startup(component);
            }
         }
      }
View Full Code Here

   {
      if ( component.isStartup() )
      {
         for ( String dependency: component.getDependencies() )
         {
            Component dependentComponent = Component.forName(dependency);
            if (dependentComponent!=null)
            {
               startup(dependentComponent);
            }
         }
View Full Code Here

      return new RootInvocationContext(bean, method, params)
      {
         @Override
         public Object proceed() throws Exception
         {
            Component old = SessionBeanInterceptor.COMPONENT.get();
            SeamInterceptor.COMPONENT.set( getComponent() );
            try
            {
               return super.proceed();
            }
View Full Code Here

TOP

Related Classes of org.jboss.seam.Component

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.