Package org.jboss.seam.core

Examples of org.jboss.seam.core.Init


   }

   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 Object getInstanceFromFactory(String name, ScopeType scope)
   {
      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

         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 static LogProvider log = Logging.getLogProvider(HotDeployFilter.class);
  
   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) )
            {
               new Initialization( getServletContext() ).redeploy( ( (HttpServletRequest) request ).getSession(true) );
               break;
View Full Code Here

      installComponent(appContext, ConversationEntries.class);
      installComponent(appContext, Manager.class);
      installComponent(appContext, Session.class);
      installComponent(appContext, ServletContexts.class);
      installComponent(appContext, Parameters.class);
      appContext.set( Seam.getComponentName(Init.class), new Init() );
     
      installComponent(appContext, Bar.class);
      installComponent(appContext, Foo.class);
      appContext.set("otherFoo", new Foo());
     
View Full Code Here

      Map sessionAdaptor = new ServletRequestSessionMap(request);
      Map requestAdaptor = new ServletRequestMap(request);
      Context appContext = new ApplicationContext( externalContext.getApplicationMap() );
      installComponent(appContext, ConversationEntries.class);
      installComponent(appContext, Manager.class);
      appContext.set( Seam.getComponentName(Init.class), new Init() );
      FacesLifecycle.beginRequest(externalContext);
      Manager.instance().setLongRunningConversation(true);
      testContext( new ApplicationContext( externalContext.getApplicationMap() ) );
      testContext( new SessionContext(sessionAdaptor) );
      testContext( new EventContext(requestAdaptor) );
View Full Code Here

        throws Exception
    {
        new ComponentTest() {
            @Override
            protected void testComponents() throws Exception {
                Init init = Init.instance();
                init.addFactoryMethodExpression("elTest.ns3.factory", "#{elTest.fooFactory.createFoo}", ScopeType.SESSION);
               
                assert getValue("#{elTest.ns3.factory}") != null;
            }
        }.run();
    }
View Full Code Here

        throws Exception
    {
        new ComponentTest() {
            @Override
            protected void testComponents() throws Exception {
                Init init = Init.instance();
                init.addFactoryValueExpression("elTest.ns4.factory", "#{elTest.fooFactory.createFoo()}", ScopeType.SESSION);
               
                assert getValue("#{elTest.ns4.factory}") != null;
            }
        }.run();
    }
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.