Package org.jboss.seam.core

Examples of org.jboss.seam.core.Init


      {
         chain.doFilter(servletRequest, servletResponse);
      }
      else
      {
           Init init = (Init) getServletContext().getAttribute( Seam.getComponentName(Init.class) );
               /*
                * We initialize the delegate on the first actual request and any time the
                * init timestamp changes, so that the WicketFilter gets reinitialized whenever the
                * hot deployment classloader detects changes, enabling wicket components to be hot deployed.
                */
           if (init != null && lastInitTime != init.getTimestamp())
               {
                  delegate.destroy();
     
                  Map<String, String> parameters = new HashMap<String, String>();
                  if ( getApplicationClass() != null )
                  {
                     parameters.put( "applicationClassName", getApplicationClass() );
                  }
                  if ( getUrlPattern() != null )
                  {
                     parameters.put("filterMappingUrlPattern", getUrlPattern());
                  }
                 else
                 {
                    parameters.put("filterMappingUrlPattern", "/*");
                 }
                 
                  /* Let the seam debug flag control the wicket configuration flag (deployment vs. development) */
                  parameters.put("configuration",init.isDebug() ? "development" : "deployment");
                 
                 if (getApplicationFactoryClass() != null)
                 {
                    parameters.put("applicationFactoryClassName", getApplicationFactoryClass());
                 }
                 if (isDetectPortletContext())
                 {
                    parameters.put("detectPortletContext", "true");
                 }
              
               //We have no way of passing the hot deploy classLoader to the delegate filter created by
               //WicketFilterInstantiator, because it is unwrapped as a plain filter, which only takes string
               //pairs as configuration.  In addition, it is a STATELESS component, so it can't listen for the
               //reinitialization events and store the classloader itself.  So we set it as the thread's contextClassLoader,
               //and reset that afterwards
              
               ClassLoader previousClassLoader = Thread.currentThread().getContextClassLoader();
               if (hotDeployClassLoader != null)
                  Thread.currentThread().setContextClassLoader(hotDeployClassLoader);
               try {
                  delegate.init(new FilterConfigWrapper(savedConfig, parameters));
               }
               finally {
                  if (hotDeployClassLoader != null)
                     Thread.currentThread().setContextClassLoader(previousClassLoader);
               }
              lastInitTime = init.getTimestamp();
               }
               delegate.doFilter(servletRequest, servletResponse, chain);
            }
      }
View Full Code Here


   public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
            throws IOException, ServletException
   {
      if (request instanceof HttpServletRequest)
      {
         Init init = (Init) getServletContext().getAttribute(Seam.getComponentName(Init.class));
         if (init != null)
         {
            try
            {
               new Initialization(getServletContext()).redeploy((HttpServletRequest) request, init);
View Full Code Here

         throw new IllegalStateException("No deployment strategy!");
      }
      ServletLifecycle.beginInitialization();
      Contexts.getApplicationContext().set(Component.PROPERTIES, properties);
      addComponent( new ComponentDescriptor(Init.class), Contexts.getApplicationContext());
      Init init = (Init) Component.getInstance(Init.class, ScopeType.APPLICATION);
      // Make the deployment strategies available in the contexts. This gives
      // access to custom deployment handlers for processing custom annotations
      Contexts.getEventContext().set(StandardDeploymentStrategy.NAME, standardDeploymentStrategy);
      scanForComponents();
      ComponentDescriptor desc = findDescriptor(Jbpm.class);
      if (desc != null && desc.isInstalled())
      {
         init.setJbpmInstalled(true);
      }
      init.checkDefaultInterceptors();
      init.setTimestamp(System.currentTimeMillis());
      addSpecialComponents(init);
     
      // Add the war root deployment
      warRootDeploymentStrategy = new WarRootDeploymentStrategy(
            Thread.currentThread().getContextClassLoader(), warRoot,servletContext, new File[] { warClassesDirectory, warLibDirectory, hotDeployDirectory });
      Contexts.getEventContext().set(WarRootDeploymentStrategy.NAME, warRootDeploymentStrategy);
      warRootDeploymentStrategy.scan();
      init.setWarTimestamp(System.currentTimeMillis());
     
      hotDeploymentStrategy = createHotDeployment(Thread.currentThread().getContextClassLoader(), isHotDeployEnabled(init));
      Contexts.getEventContext().set(HotDeploymentStrategy.NAME, hotDeploymentStrategy);
      init.setHotDeployPaths( hotDeploymentStrategy.getHotDeploymentPaths() );
     
      if (hotDeploymentStrategy.available())
      {
         hotDeploymentStrategy.scan();
         installHotDeployableComponents();
      }
     
      installComponents(init);
          
      for (String globalImport: globalImports)
      {
         init.importNamespace(globalImport);
      }
     
      ServletLifecycle.endInitialization();
      log.debug("done initializing Seam");
      return this;
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) )
            {
               if(!getBeanClass().isAnnotationPresent(BypassInterceptors.class))
                  throw new IllegalStateException("Converter " + getBeanClass().getName()
                        + " must be annotated with @BypassInterceptors");
              
               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) )
            {
               if(!getBeanClass().isAnnotationPresent(BypassInterceptors.class))
                  throw new IllegalStateException("Validator " + getBeanClass().getName()
                        + " must be annotated with @BypassInterceptors");

               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 );
        
         if ( contextVariable.equals(name) )
         {
            throw new IllegalStateException("@Factory method can not share name with its containing component: " + contextVariable);
         }
        
         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

      return getInstanceFromFactory(name, null);
   }

   private static synchronized Object getInstanceFromFactory(String name, ScopeType scope)
   {
      Init init = Init.instance();
      if (init==null) //for unit tests, yew!
      {
         return null;
      }
      else
      {
         // check whether there has been created an instance by another thread while waiting for this function's lock
         if (scope != STATELESS) {
            Object value = (scope == null) ? Contexts.lookupInStatefulContexts(name) : scope.getContext().get(name);
            if (value != null) {
               return value;
            }
         }
         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

            // 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) )
            {
               if(!getBeanClass().isAnnotationPresent(BypassInterceptors.class))
                  throw new IllegalStateException("Converter " + getBeanClass().getName()
                        + " must be annotated with @BypassInterceptors");
              
               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) )
            {
               if(!getBeanClass().isAnnotationPresent(BypassInterceptors.class))
                  throw new IllegalStateException("Validator " + getBeanClass().getName()
                        + " must be annotated with @BypassInterceptors");

               Validator validator = getBeanClass().getAnnotation(Validator.class);
               String id = validator.id().equals("") ? getName() : validator.id();
               init.getValidators().put( id, getName() );
            }
         }
      }
   }
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.