Package org.jboss.seam

Examples of org.jboss.seam.Component


      callPostConstruct();
   }

   private void callPostConstruct()
   {
      final Component component = getComponent();
      if (!component.hasPostConstructMethod())
      {
         return;
      }
     
      InvocationContext context = new RootInvocationContext( bean, component.getPostConstructMethod(), new Object[0] )
      {
         @Override
         public Object proceed() throws Exception
         {
            component.callPostConstructMethod(bean);
            return null;
         }
        
      };
      invokeAndHandle(context, EventType.POST_CONSTRUCT);
View Full Code Here


      invokeAndHandle(context, EventType.POST_CONSTRUCT);
   }

   private void callPrePassivate()
   {
      final Component component = getComponent();
      if (!component.hasPrePassivateMethod())
      {
         return;
      }
     
      InvocationContext context = new RootInvocationContext( bean, component.getPrePassivateMethod(), new Object[0] )
      {
         @Override
         public Object proceed() throws Exception
         {
            component.callPrePassivateMethod(bean);
            return null;
         }
        
      };
      invokeAndHandle(context, EventType.PRE_PASSIVATE);
View Full Code Here

      invokeAndHandle(context, EventType.PRE_PASSIVATE);
   }

   private void callPostActivate()
   {
      final Component component = getComponent();
      if (!component.hasPostActivateMethod())
      {
         return;
      }
     
      RootInvocationContext context = new RootInvocationContext(bean, component.getPostActivateMethod(), new Object[0])
      {
         @Override
         public Object proceed() throws Exception
         {
            component.callPostActivateMethod(bean);
            return null;
         }
        
      };
      invokeAndHandle(context, EventType.POST_ACTIVATE);
View Full Code Here

   }
  
   // TODO: copy/paste from ClientSide interceptor
   Object readResolve()
   {
      Component comp = null;
      try
      {
         comp = getComponent();
      }
      catch (IllegalStateException ise) {
         //this can occur when tomcat deserializes persistent sessions
      }
     
      try
      {
         if (comp==null)
         {
            ProxyObject proxy = Component.createProxyFactory(
                  ComponentType.JAVA_BEAN,
                  beanClass,
                  Component.getBusinessInterfaces(beanClass)
               ).newInstance();
            proxy.setHandler(this);
            return proxy;
         }
         else
         {
            return comp.wrap(bean, this);
         }
      }
      catch (Exception e)
      {
         throw new RuntimeException(e);
View Full Code Here

            {
               log.debug("redeploying components");
               Seam.clearComponentNameCache();
               for ( String name: init.getHotDeployableComponents() )
               {
                  Component component = Component.forName(name);
                  if (component!=null)
                  {
                     ScopeType scope = component.getScope();
                     if ( scope!=ScopeType.STATELESS && scope.isContextActive() )
                     {
                        scope.getContext().remove(name);
                     }
                     init.removeObserverMethods(component);
View Full Code Here

   {
      String name = descriptor.getName();
      String componentName = name + COMPONENT_SUFFIX;
      try
      {
         Component component = new Component(
               descriptor.getComponentClass(),
               name,
               descriptor.getScope(),
               descriptor.isStartup(),
               descriptor.getStartupDependencies(),
               descriptor.getJndiName()
            );
         context.set(componentName, component);
         if ( hotDeploymentStrategy != null && hotDeploymentStrategy.isEnabled() && hotDeploymentStrategy.isFromHotDeployClassLoader( descriptor.getComponentClass() ) )
         {
            Init.instance().addHotDeployableComponent( component.getName() );
         }
      }
      catch (Throwable e)
      {
         throw new RuntimeException("Could not create Component: " + name, e);
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

   }
  
   //TODO: copy/paste from JavaBean interceptor
   Object readResolve()
   {
      Component comp = null;
      try
      {
         comp = getComponent();
      }
      catch (IllegalStateException ise) {
         //this can occur when tomcat deserializes persistent sessions
      }
     
      try
      {
         if (comp==null)
         {
            ProxyObject proxy = Component.createProxyFactory(
                  ComponentType.STATEFUL_SESSION_BEAN,
                  beanClass,
                  Component.getBusinessInterfaces(beanClass)
               ).newInstance();
            proxy.setHandler(this);
            return proxy;
         }
         else
         {
            return comp.wrap(bean, this);
         }
      }
      catch (Exception e)
      {
         throw new RuntimeException(e);
View Full Code Here

   }
  
   @PostConstruct
   public void postConstruct(InvocationContext invocation)
   {
      Component invokingComponent = SessionBeanInterceptor.COMPONENT.get();
      Object bean = invocation.getTarget();
      if ( invokingComponent!=null && invokingComponent.getBeanClass().isInstance(bean) )
      {
         //the session bean was obtained by the application by
         //calling Component.getInstance(), could be a role
         //other than the default role
         //note: minor bug here, since if we got another instance of the same
         //      bean from JNDI or @EJB while constructing a component,
         //      or in an interceptor while calling a component,
         //      this will cause that bean to think it is an instance of the
         //      component role (rather than the default role)
         if ( log.isTraceEnabled() )
         {
            log.trace("post construct phase for instance of component: " + invokingComponent.getName());
         }
         init(invokingComponent);
      }
      else if ( bean.getClass().isAnnotationPresent(Name.class) )
      {
View Full Code Here

   }
     
   @AroundInvoke
   public Object aroundInvoke(InvocationContext invocation) throws Exception
   {
      Component component = getComponent();
      boolean enforceRequired = !component.isLifecycleMethod( invocation.getMethod() );     
     
      try
      {   
         lock.lock();
         try
         {
            if (!injected)
            {             
               if (injecting)
               {
                  throw new CyclicDependencyException();
               }

               injecting = true;
               try
               {
                  component.inject(invocation.getTarget(), enforceRequired);
               }
               finally
               {
                  injecting = false;
               }
               injected = true;
            }
           
            clients++;
         }
         finally
         {
            lock.unlock();
         }
                          
         Object result = invocation.proceed();
           
         lock.lock();
         try
         {
            if (clients == 1)
            {
               try
               {                    
                  component.outject( invocation.getTarget(), enforceRequired );
               }
               finally
               {
                  // Avoid an extra lock by disinjecting here instead of the finally block
                  if (injected)
                  {
                     injected = false;
                     clients--;
                     component.disinject( invocation.getTarget() );
                  }
               }  
            }
         }
         finally
         {
            lock.unlock();
         }
        
         return result;
      }
      catch (Exception e)
      {
         Exception root = e;
         while (Exceptions.getCause(root) != null)
         {
            root = Exceptions.getCause(root);
         }
         if (root instanceof CyclicDependencyException)
         {
            CyclicDependencyException cyclicDependencyException = (CyclicDependencyException) root;
            cyclicDependencyException.addInvocation(getComponent().getName(), invocation.getMethod());
         }
         throw e;
      }
      finally
      {           
         if (injected)
         {
            lock.lock();
            try
            {
               clients--;
              
               if (clients == 0)
               {
                  injected = false;
                  component.disinject( invocation.getTarget() );    
               }
            }
            finally
            {
               lock.unlock();
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.