Example usage for org.springframework.context.support StaticApplicationContext registerPrototype

List of usage examples for org.springframework.context.support StaticApplicationContext registerPrototype

Introduction

In this page you can find the example usage for org.springframework.context.support StaticApplicationContext registerPrototype.

Prototype

public void registerPrototype(String name, Class<?> clazz) throws BeansException 

Source Link

Document

Register a prototype bean with the underlying bean factory.

Usage

From source file:de.itsvs.cwtrpc.controller.PreparedRemoteServiceConfigBuilderTest.java

@BeforeClass
public static void initClass() {
    StaticApplicationContext appContext;

    appContext = new StaticApplicationContext();
    appContext.registerSingleton("testService1", TestService1Impl.class);
    appContext.registerPrototype("testService2", TestService2Impl.class);
    appContext.registerSingleton("testService3", TestService3Impl.class);
    appContext.registerPrototype("testService4", TestService4Impl.class);
    appContext.registerSingleton("testService5", TestService5Impl.class);
    appContext.registerPrototype("testService10", TestService10Impl.class);
    appContext.registerSingleton("testService20", TestService20Impl.class);
    appContext.registerSingleton("rpcTokenValidatorXyz", TestRpcTokenValidator1Impl.class);
    appContext.registerSingleton("rpcTokenValidator100", TestRpcTokenValidator1Impl.class);
    appContext.registerSingleton("rpcTokenValidator200", TestRpcTokenValidator1Impl.class);
    appContext.registerSingleton("rpcTokenService", DefaultXsrfTokenService.class);

    PreparedRemoteServiceConfigBuilderTest.appContext = appContext;
}

From source file:ch.rasc.wampspring.method.WampAnnotationMethodMessageHandlerTest.java

@Before
public void setup() {
    MockitoAnnotations.initMocks(this);
    when(this.clientOutboundChannel.send(any(WampMessage.class))).thenReturn(true);

    DefaultFormattingConversionService conversionService = new DefaultFormattingConversionService();
    MethodParameterConverter paramConverter = new MethodParameterConverter(new ObjectMapper(),
            conversionService);//from w w  w  .ja v a  2  s  . c o  m
    this.messageHandler = new WampAnnotationMethodMessageHandler(this.clientInboundChannel,
            this.clientOutboundChannel, this.eventMessenger, conversionService, paramConverter,
            new AntPathMatcher(), WampMessageSelectors.ACCEPT_ALL);

    @SuppressWarnings("resource")
    StaticApplicationContext applicationContext = new StaticApplicationContext();
    applicationContext.registerPrototype("annotatedTestService", AnnotatedTestService.class);
    applicationContext.refresh();
    this.messageHandler.setApplicationContext(applicationContext);
    this.messageHandler.afterPropertiesSet();

    this.messageHandler.start();
}

From source file:org.springframework.aop.target.CommonsPoolTargetSourceTests.java

private void prepareTargetSource(CommonsPoolTargetSource targetSource) {
    String beanName = "target";

    StaticApplicationContext applicationContext = new StaticApplicationContext();
    applicationContext.registerPrototype(beanName, SerializablePerson.class);

    targetSource.setTargetBeanName(beanName);
    targetSource.setBeanFactory(applicationContext);
}