Package org.jboss.seam

Examples of org.jboss.seam.Component


   }
  
   // 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.info("redeploying");
                  ServletLifecycle.beginReinitialization(request);
                  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.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

   }
     
   @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;
            }
           
            counter++;
         }
         finally
         {
            lock.unlock();
         }
                          
         Object result = invocation.proceed();
           
         lock.lock();
         try
         {
            counter--;
           
            if (counter == 0)
            {
               try
               {                    
                  component.outject( invocation.getTarget(), enforceRequired );
               }
               finally
               {
                  // Avoid an extra lock by disinjecting here instead of the finally block
                  if (injected)
                  {
                     injected = false;
                     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
            {
               counter--;
              
               if (counter == 0)
               {
                  injected = false;
                  component.disinject( invocation.getTarget() );    
               }
            }
            finally
            {
               lock.unlock();
View Full Code Here

        String[] applicationContextNames = Contexts.getApplicationContext().getNames();
        for (String applicationContextName : applicationContextNames)
        {
            if (applicationContextName.endsWith(".component"))
            {
                Component seamComponent =
                        (Component) Component.getInstance(applicationContextName, ScopeType.APPLICATION);
                // TODO: This should consider EJB components/annotations on interfaces somehow?
                seamComponents.put(seamComponent.getBeanClass(), seamComponent);
            }
        }

        registerProviders(seamComponents, annotatedProviderClasses);
        registerResources(seamComponents, annotatedResourceClasses);
View Full Code Here

        for (Class providerClass : providerClasses)
        {
            // Ignore built-in providers, we register them manually later
            if (providerClass.getName().startsWith("org.resteasy.plugins.providers")) continue;

            Component seamComponent = null;
            // Check if this is also a Seam component bean class
            if (seamComponents.containsKey(providerClass))
            {
                seamComponent = seamComponents.get(providerClass);
                // Needs to be APPLICATION or STATELESS
                if (!seamComponent.getScope().equals(ScopeType.APPLICATION) &&
                        !seamComponent.getScope().equals(ScopeType.STATELESS))
                {
                    log.warn("not registering as  provider Seam component, must be APPLICATION or STATELESS scoped: "
                            + seamComponent.getName());
                    seamComponent = null;
                }
            }
            if (seamComponent != null)
            {
                log.debug("registering provider Seam component: " + seamComponent.getName());
            }
            else
            {
                log.debug("registering provider class: " + providerClass.getName());
            }
View Full Code Here

            log.error("error loading JAX-RS resource class: " + ex.getMessage());
        }
        for (Class<Object> resourceClass : resourceClasses)
        {

            Component seamComponent = null;
            // Check if this is also a Seam component bean class
            if (seamComponents.containsKey(resourceClass))
            {
                seamComponent = seamComponents.get(resourceClass);
                log.debug("registering resource Seam component: " + seamComponent.getName());
            }
            else
            {
                log.debug("registering resource class with JAX-RS default lifecycle: " + resourceClass.getName());
            }
View Full Code Here

        // Resource registration
        Registry registry = getDispatcher().getRegistry();
        for (final Class resourceClass : applicationConfig.getResourceClasses())
        {
            final Component seamComponent = applicationConfig.getResourceClassComponent(resourceClass);
            if (seamComponent != null)
            {
                // Seam component lookup when call is dispatched to resource
                registry.addResourceFactory(
                        new ResourceFactory()
                        {

                            private PropertyInjector propertyInjector;

                            public Class<?> getScannableClass()
                            {
                                return resourceClass;
                            }

                            public void registered(InjectorFactory factory)
                            {
                                this.propertyInjector = factory.createPropertyInjector(getScannableClass());
                            }

                            public Object createResource(HttpRequest request, HttpResponse response, InjectorFactory factory)
                            {
                                Object target = Component.getInstance(seamComponent.getName());
                                propertyInjector.inject(request, response, target);
                                return target;
                            }

                            public void requestFinished(HttpRequest request, HttpResponse response, Object resource)
                            {
                            }

                            public void unregistered()
                            {
                            }
                        }
                );
            }
            else
            {
                // JAX-RS default lifecycle
                registry.addResourceFactory(new POJOResourceFactory(resourceClass));
            }
        }

        // Provider registration
        if (applicationConfig.isUseBuiltinProviders())
        {
            log.info("registering built-in RESTEasy providers");
            RegisterBuiltin.register(providerFactory);
        }
        for (Class providerClass : applicationConfig.getProviderClasses())
        {
            Component seamComponent = applicationConfig.getProviderClassComponent(providerClass);
            if (seamComponent != null)
            {
                if (ScopeType.STATELESS.equals(seamComponent.getScope()))
                {
                    throw new RuntimeException(
                            "Registration of STATELESS Seam components as RESTEasy providers not implemented!"
                    );
                }
                else if (ScopeType.APPLICATION.equals(seamComponent.getScope()))
                {
                    Object providerInstance = Component.getInstance(seamComponent.getName());
                    providerFactory.registerProviderInstance(providerInstance);
                }
            }
            else
            {
View Full Code Here

                return null;
            }
        }

        private ClassLoader loaderForComponent(String name) {
            Component component = (Component) Component.getInstance(name + ".component");
            if (component == null) {
                log.debug("Couldn't find component for " + name);
                return null;
            }
           
            return component.getBeanClass().getClassLoader();
        }
View Full Code Here

         {
            throw new RequiredException("@Out attribute requires non-null value: " + out.toString());
         }
         else
         {
            Component component = null;
            if (out.getAnnotation().scope()==UNSPECIFIED)
            {
               component = Component.forName(out.getContextVariableName());
               if (value!=null && component!=null)
               {
                  if (!component.isInstance(value))
                  {
                     throw new IllegalArgumentException("attempted to bind an @Out attribute of the wrong type to: " + out.toString());
                  }
               }
            }
            else if (out.getAnnotation().scope()==STATELESS)
            {
               throw new IllegalArgumentException("cannot specify explicit scope=STATELESS on @Out: " + out.toString());
            }
        
            ScopeType outScope = component == null ? out.getAnnotation().scope() : component.getScope();
           
            if (outScope ==  null)
            {
               throw new IllegalArgumentException("cannot determine scope to outject to on @Out: " + out.toString());
            }
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.