Package org.springframework.beans.factory.config

Examples of org.springframework.beans.factory.config.Scope


        registerDisposableBean(beanName,
            new DisposableBeanAdapter(bean, beanName, mbd, getBeanPostProcessors()));
      }
      else {
        // A bean with a custom scope...
        Scope scope = (Scope) this.scopes.get(mbd.getScope());
        if (scope == null) {
          throw new IllegalStateException("No Scope registered for scope '" + mbd.getScope() + "'");
        }
        scope.registerDestructionCallback(beanName,
            new DisposableBeanAdapter(bean, beanName, mbd, getBeanPostProcessors()));
      }
    }
  }
View Full Code Here


            throw new OrchestraException(
                "Error while processing bean " + beanName
                + ": view controller " + viewControllerName + " has no scope.");
        }

        Scope registeredScope = beanFactory.getRegisteredScope(scopeName);
        if (registeredScope == null)
        {
            throw new OrchestraException(
                "Error while processing bean " + beanName
                + ": view controller " + viewControllerName
                + " has unknown scope " + scopeName);
        }

        if (registeredScope instanceof AbstractSpringOrchestraScope)
        {
            return ((AbstractSpringOrchestraScope) registeredScope).getConversationNameForBean(viewControllerName);
        }

        throw new OrchestraException(
            "Error while processing bean " + beanName
            + ": the scope " + scopeName
            + " should be of type AbstractSpringOrchestraScope"
            + ", but is type " + registeredScope.getClass().getName());
    }
View Full Code Here

        bean = getObjectForBeanInstance(prototypeInstance, name, beanName, mbd);
      }

      else {
        String scopeName = mbd.getScope();
        final Scope scope = (Scope) this.scopes.get(scopeName);
        if (scope == null) {
          throw new IllegalStateException("No Scope registered for scope '" + scopeName + "'");
        }
        try {
          Object scopedInstance = scope.get(beanName, new ObjectFactory() {
            public Object getObject() throws BeansException {
              beforePrototypeCreation(beanName);
              try {
                return createBean(beanName, mbd, args);
              }
View Full Code Here

    if (mbd.isSingleton() || mbd.isPrototype()) {
      throw new IllegalArgumentException(
          "Bean name '" + beanName + "' does not correspond to an object in a Scope");
    }
    String scopeName = mbd.getScope();
    Scope scope = (Scope) this.scopes.get(scopeName);
    if (scope == null) {
      throw new IllegalStateException("No Scope registered for scope '" + scopeName + "'");
    }
    Object bean = scope.remove(beanName);
    if (bean != null) {
      destroyBean(beanName, bean, mbd);
    }
  }
View Full Code Here

        registerDisposableBean(beanName,
            new DisposableBeanAdapter(bean, beanName, mbd, getBeanPostProcessors()));
      }
      else {
        // A bean with a custom scope...
        Scope scope = (Scope) this.scopes.get(mbd.getScope());
        if (scope == null) {
          throw new IllegalStateException("No Scope registered for scope '" + mbd.getScope() + "'");
        }
        scope.registerDestructionCallback(beanName,
            new DisposableBeanAdapter(bean, beanName, mbd, getBeanPostProcessors()));
      }
    }
  }
View Full Code Here

      // beanFactory = new FileSystemXmlApplicationContext(configFile);
      File f = new File( configFile );
      FileSystemResource fsr = new FileSystemResource( f );
      GenericApplicationContext appCtx = new GenericApplicationContext();

      Scope requestScope = new ThreadLocalScope();
      appCtx.getBeanFactory().registerScope( "request", requestScope );
      Scope sessionScope = new ThreadLocalScope();
      appCtx.getBeanFactory().registerScope( "session", sessionScope );

      XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader( appCtx );
      xmlReader.loadBeanDefinitions( fsr );

      beanFactory = appCtx;
    } else {
      if ( !( context instanceof ConfigurableApplicationContext ) ) {
        String msg =
          Messages.getInstance()
            .getErrorString( "StandalonePentahoObjectFactory.ERROR_0001_CONTEXT_NOT_SUPPORTED", //$NON-NLS-1$
              getClass().getSimpleName(), "GenericApplicationContext", context.getClass().getName() ); //$NON-NLS-1$
        throw new IllegalArgumentException( msg );
      }

      ConfigurableApplicationContext configAppCtx = (ConfigurableApplicationContext) context;

      if ( configAppCtx.getBeanFactory().getRegisteredScope( "request" ) == null ) {
        Scope requestScope = new ThreadLocalScope();
        configAppCtx.getBeanFactory().registerScope( "request", requestScope );
      }
      if ( configAppCtx.getBeanFactory().getRegisteredScope( "session" ) == null ) {
        Scope sessionScope = new ThreadLocalScope();
        configAppCtx.getBeanFactory().registerScope( "session", sessionScope );
      }

      setBeanFactory( configAppCtx );
    }
View Full Code Here

            throw new OrchestraException(
                "Error while processing bean " + beanName
                + ": view controller " + viewControllerName + " has no scope.");
        }

        Scope registeredScope = beanFactory.getRegisteredScope(scopeName);
        if (registeredScope == null)
        {
            throw new OrchestraException(
                "Error while processing bean " + beanName
                + ": view controller " + viewControllerName
                + " has unknown scope " + scopeName);
        }

        if (registeredScope instanceof AbstractSpringOrchestraScope)
        {
            return ((AbstractSpringOrchestraScope) registeredScope).getConversationNameForBean(viewControllerName);
        }

        throw new OrchestraException(
            "Error while processing bean " + beanName
            + ": the scope " + scopeName
            + " should be of type AbstractSpringOrchestraScope"
            + ", but is type " + registeredScope.getClass().getName());
    }
View Full Code Here

  @Test
  public void genericApplicationContext() throws Exception {
    GenericApplicationContext ac = new GenericApplicationContext();
    AnnotationConfigUtils.registerAnnotationConfigProcessors(ac);

    ac.getBeanFactory().registerScope("myScope", new Scope() {
      @Override
      public Object get(String name, ObjectFactory<?> objectFactory) {
        return objectFactory.getObject();
      }
      @Override
View Full Code Here

          bean = getObjectForBeanInstance(prototypeInstance, name, beanName, mbd);
        }

        else {
          String scopeName = mbd.getScope();
          final Scope scope = this.scopes.get(scopeName);
          if (scope == null) {
            throw new IllegalStateException("No Scope registered for scope '" + scopeName + "'");
          }
          try {
            Object scopedInstance = scope.get(beanName, new ObjectFactory<Object>() {
              @Override
              public Object getObject() throws BeansException {
                beforePrototypeCreation(beanName);
                try {
                  return createBean(beanName, mbd, args);
View Full Code Here

    if (mbd.isSingleton() || mbd.isPrototype()) {
      throw new IllegalArgumentException(
          "Bean name '" + beanName + "' does not correspond to an object in a mutable scope");
    }
    String scopeName = mbd.getScope();
    Scope scope = this.scopes.get(scopeName);
    if (scope == null) {
      throw new IllegalStateException("No Scope SPI registered for scope '" + scopeName + "'");
    }
    Object bean = scope.remove(beanName);
    if (bean != null) {
      destroyBean(beanName, bean, mbd);
    }
  }
View Full Code Here

TOP

Related Classes of org.springframework.beans.factory.config.Scope

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.