Package org.jboss.seam.core

Examples of org.jboss.seam.core.Init


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

   }

   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

      ServletLifecycle.beginInitialization();
      Contexts.getApplicationContext().set(Component.PROPERTIES, properties);
      hotDeploymentStrategy = createHotDeployment(Thread.currentThread().getContextClassLoader());
      scanForComponents();
      addComponent( new ComponentDescriptor(Init.class), Contexts.getApplicationContext());
      Init init = (Init) Component.getInstance(Init.class, ScopeType.APPLICATION);
      init.setHotDeployPaths( hotDeploymentStrategy.getHotDeploymentPaths() );
      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);
      warRootDeploymentStrategy.scan();
     
      // Make the deployment strategies available in the contexts. This gives
      // access to custom deployment handlers for processing custom annotations
      // etc.
      Contexts.getEventContext().set(StandardDeploymentStrategy.NAME, standardDeploymentStrategy);
      Contexts.getEventContext().set(HotDeploymentStrategy.NAME, hotDeploymentStrategy);
      Contexts.getEventContext().set(WarRootDeploymentStrategy.NAME, warRootDeploymentStrategy);
     
      if (hotDeploymentStrategy.isEnabled())
      {
         hotDeploymentStrategy.scan();
         if (hotDeploymentStrategy.isHotDeployClassLoaderEnabled())
         {
            installHotDeployableComponents();
         }
      }
     
      installComponents(init);
          
      for (String globalImport: globalImports)
      {
         init.importNamespace(globalImport);
      }
     
      ServletLifecycle.endInitialization();
      log.info("done initializing Seam");
      return this;
View Full Code Here

         {
            hotDeploymentStrategy = createHotDeployment(Thread.currentThread().getContextClassLoader());
            if (hotDeploymentStrategy.isEnabled())
            {
               hotDeploymentStrategy.scan();
               Init init = (Init) ServletLifecycle.getServletContext().getAttribute( Seam.getComponentName(Init.class) );
              
               if (init.getTimestamp() < hotDeploymentStrategy.getTimestamp())
               {
                  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);
                     }
                     Contexts.getApplicationContext().remove(name + COMPONENT_SUFFIX);
                  }
              
                  if (hotDeploymentStrategy.isHotDeployClassLoaderEnabled())
                  {
                     installHotDeployableComponents();
                  }
                  Contexts.getEventContext().set(HotDeploymentStrategy.NAME, hotDeploymentStrategy);
                  init.setTimestamp( System.currentTimeMillis() );
                  installComponents(init);
                  ServletLifecycle.endReinitialization();
                  log.info("done redeploying");
               }
              
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

      {
         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

      return ScopeType.BUSINESS_PROCESS;
   }

   public BusinessProcessContext()
   {
      Init init = Init.instance();
      if (init == null)
      {
         enabled = false;
      }
      else
      {
         enabled = init.isJbpmInstalled();
      }
   }
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.