Package org.jboss.seam.core

Examples of org.jboss.seam.core.Init


   public Initialization redeploy(HttpServletRequest request)
   {
      log.info("redeploying");
      ServletLifecycle.beginReinitialization(request);
      Init init = Init.instance();
      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);
            }
         }
         Contexts.getApplicationContext().remove(name + ".component");
      }
      //TODO open the ability to reuse the classloader by looking at the components class classloaders
      RedeployableStrategy redeployStrategy = getRedeployableInitialization();
      scanForHotDeployableComponents(redeployStrategy);
      init.setTimestamp( System.currentTimeMillis() );
      init.setHotDeployPaths(redeployStrategy.getPaths());
      installComponents(init, redeployStrategy);
      ServletLifecycle.endInitialization();
      log.info("done redeploying");
      return this;
   }
View Full Code Here


   protected void loadResourceProviders()
   {
      Context tempApplicationContext = new ApplicationContext( new ServletApplicationMap(context) );

      Init init = (Init) tempApplicationContext.get(Init.class);
      for (String name : init.getResourceProviders())
      {
         AbstractResource provider = (AbstractResource) tempApplicationContext.get(name);
         if (provider != null)
         {
            provider.setServletContext(context);
View Full Code Here

         //if no Seam contexts, bypass straight through to JSF
         return null;
      }
     
      String key = (String) property;
      Init init = Init.instance();
     
      //look for a component in the root namespace
      Object result = init.getRootNamespace().getComponentInstance(key);
      if (result!=null)
      {
         context.setPropertyResolved(true);
         return result;
      }
      else
      {
         //look for a component in the imported namespaces
         for ( Namespace ns: init.getGlobalImports() )
         {
            result = ns.getComponentInstance(key);
            if (result!=null)
            {
               context.setPropertyResolved(true);
               return result;
            }
         }
      }
     
      //look for a namespace
      Namespace namespace = init.getRootNamespace().getChild(key);
      if (namespace!=null)
      {
         context.setPropertyResolved(true);
      }
      return namespace;
View Full Code Here

  
   private void registerConverterOrValidator(Context applicationContext)
   {
      if (applicationContext!=null) //for unit tests!
      {
         Init init = (Init) applicationContext.get( Seam.getComponentName(Init.class) );
         if (init!=null)
         {
            if ( getBeanClass().isAnnotationPresent(Converter.class) )
            {
               Converter converter = getBeanClass().getAnnotation(Converter.class);
               if ( converter.forClass()!=void.class )
               {
                  init.getConvertersByClass().put( converter.forClass(), getName() );
               }
               String id = converter.id().equals("") ? getName() : converter.id();
               init.getConverters().put( id, getName() );
            }
            if ( getBeanClass().isAnnotationPresent(Validator.class) )
            {
               Validator validator = getBeanClass().getAnnotation(Validator.class);
               String id = validator.id().equals("") ? getName() : validator.id();
               init.getValidators().put( id, getName() );
            }
         }
      }
   }
View Full Code Here

   }

   private void initNamespace(String componentName, Context applicationContext)
   { 
      if (applicationContext!=null) { //for unit tests!
         Init init = (Init) applicationContext.get(Seam.getComponentName(Init.class));
         if (init!=null) {
            this.namespace = init.initNamespaceForName(componentName, true);
         }
      }
   }
View Full Code Here

  
   private void initImports(Context applicationContext)
   {
      if (applicationContext!=null) //for unit tests!
      {
         Init init = (Init) applicationContext.get( Seam.getComponentName(Init.class) );
         if (init!=null)
         {
            if ( getBeanClass().isAnnotationPresent(Import.class) )
            {
               addImport( init, getBeanClass().getAnnotation(Import.class) );
View Full Code Here

         Out out = method.getAnnotation(Out.class);
         String name = toName( out.value(), method );
         outAttributes.add( new BijectedMethod(name, method, out) );
        
         //can't use Init.instance() here because of unit tests
         Init init = (Init) applicationContext.get(Seam.getComponentName(Init.class));
         init.initNamespaceForName(name, true);
      }
     
      if ( method.isAnnotationPresent(Unwrap.class) )
      {
         if ( unwrapMethod!=null && !unwrapMethod.getName().equals( method.getName() )  )
         {
            throw new IllegalStateException("component has two @Unwrap methods: " + name);
         }
         if (unwrapMethod==null )
         {
            unwrapMethod = method;
         }
      }
     
      if ( method.isAnnotationPresent(DataModel.class) ) //TODO: generalize
      {
         checkDataModelScope( method.getAnnotation(DataModel.class) );
      }
     
      if ( method.isAnnotationPresent(org.jboss.seam.annotations.Factory.class) )
      {
         //can't use Init.instance() here because of unit tests
         Init init = (Init) applicationContext.get(Seam.getComponentName(Init.class));
         String contextVariable = toName( method.getAnnotation(org.jboss.seam.annotations.Factory.class).value(), method );
         init.addFactoryMethod(contextVariable, method, this);
         if ( method.getAnnotation(org.jboss.seam.annotations.Factory.class).autoCreate() )
         {
            init.addAutocreateVariable(contextVariable);
         }
      }
     
      if ( method.isAnnotationPresent(Observer.class) )
      {
         //can't use Init.instance() here because of unit tests
         Init init = (Init) applicationContext.get(Seam.getComponentName(Init.class));
         
         Observer observer = method.getAnnotation(Observer.class);
         for ( String eventType : observer.value() )
         {
            if ( eventType.length()==0 ) eventType = method.getName(); //TODO: new defaulting rule to map @Observer onFooEvent() -> event type "fooEvent"
            init.addObserverMethod( eventType, method, this, observer.create() );
         }
      }
     
      if ( method.isAnnotationPresent(RequestParameter.class) )
      {
View Full Code Here

   }

   public static Object getInstanceFromFactory(String name)
   {
      Init init = Init.instance();
      if (init==null) //for unit tests, yew!
      {
         return null;
      }
      else
      {
         Init.FactoryMethod factoryMethod = init.getFactory(name);
         Init.FactoryExpression methodBinding = init.getFactoryMethodExpression(name);
         Init.FactoryExpression valueBinding = init.getFactoryValueExpression(name);
         if ( methodBinding!=null && getOutScope( methodBinding.getScope(), null ).isContextActive() ) //let the XML take precedence
         {
            Object result = methodBinding.getMethodBinding().invoke();
            return handleFactoryMethodResult( name, null, result, methodBinding.getScope() );
         }
View Full Code Here

      portletBridge = null;
   }

      protected void installComponents(Context appContext)
      {
         Init init = new Init();
         init.setTransactionManagementEnabled(true);
         appContext.set( Seam.getComponentName(Init.class), init );
         installComponent(appContext, MockUserTransaction.class);
         installComponent(appContext, FacesManager.class);
         installComponent(appContext, ConversationEntries.class);
         installComponent(appContext, FacesPage.class);
View Full Code Here

  
   public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
            throws IOException, ServletException
   {
           
      Init init = (Init) getServletContext().getAttribute( Seam.getComponentName(Init.class) );
      if ( init!=null && init.hasHotDeployableComponents() )
      {
         for ( File file: init.getHotDeployPaths() )
         {
            if ( scan(request, init, file) )
            {
               Seam.clearComponentNameCache();
               new Initialization( getServletContext() ).redeploy( (HttpServletRequest) request );
View Full Code Here

TOP

Related Classes of org.jboss.seam.core.Init

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.