コード例 #1
0
  protected void registerAcAnnotations(
      ConfigurableApplicationContext context, final AcServiceConfig serviceConfig) {
    // Process Annotation AcStatusSubscriber
    AcMethodAnnotationProcessor statusSubscriberAnnotationProcessor =
        new AcMethodAnnotationProcessor(AcStatusSubscriber.class) {

          @Override
          protected void processBean(Object bean) {
            serviceConfig.getStatusListenerRegistry().processStatusListener(bean);
          }
        };
    context.addBeanFactoryPostProcessor(statusSubscriberAnnotationProcessor);
    context.addApplicationListener(statusSubscriberAnnotationProcessor);
    // Process Annotation AcDataSubscriber
    AcMethodAnnotationProcessor dataSubscriberAnnotationProcessor =
        new AcMethodAnnotationProcessor(AcDataSubscriber.class) {

          @Override
          protected void processBean(Object bean) {
            serviceConfig.getDispatchRegistry().processRegister(bean, metadata().getServiceId());
          }
        };
    context.addBeanFactoryPostProcessor(dataSubscriberAnnotationProcessor);
    context.addApplicationListener(dataSubscriberAnnotationProcessor);
  }
コード例 #2
0
  @Before
  public void setUp() throws Exception {

    if (server != null) {
      return;
    }

    int port =
        testingPropertiesHelper.getPropertyValueAsInt(
            testingProperties, RestTestingProperties.REST_PORT_PROPERTY);
    server = new TJWSEmbeddedJaxrsServer();
    server.setPort(port);
    ResteasyDeployment deployment = server.getDeployment();

    server.start();
    Dispatcher dispatcher = deployment.getDispatcher();
    SpringBeanProcessor processor =
        new SpringBeanProcessor(
            dispatcher, deployment.getRegistry(), deployment.getProviderFactory());
    ((ConfigurableApplicationContext) applicationContext).addBeanFactoryPostProcessor(processor);

    SpringResourceFactory noDefaults =
        new SpringResourceFactory("userService", applicationContext, UserService.class);
    dispatcher.getRegistry().addResourceFactory(noDefaults);
  }
コード例 #3
0
 protected void initPropertiesPlaceHolder(
     ConfigurableApplicationContext context, AcServiceConfig serviceConfig) {
   // prepare properties from service config
   Properties prop = new Properties();
   for (String key : serviceConfig.getKeys()) {
     // NOTE: use data from service property (preferences + default)
     prop.setProperty(key, serviceConfig.getProperty(key));
   }
   // TODO (other better way) other core reserved properties
   prop.setProperty(
       "ac.context.sessionId",
       String.valueOf(serviceConfig.getCoreContext().getSession().getSessionId()));
   prop.setProperty(
       "ac.context.profileId",
       String.valueOf(serviceConfig.getCoreContext().getSession().getProfile().getProfileId()));
   PropertyPlaceholderConfigurer propConfig = new PropertyPlaceholderConfigurer();
   propConfig.setProperties(prop);
   context.addBeanFactoryPostProcessor(propConfig);
 }
コード例 #4
0
 /**
  * Add appropriate post-processors to post-configure the property-sources.
  *
  * @param context the context to configure
  */
 protected void addPostProcessors(ConfigurableApplicationContext context) {
   context.addBeanFactoryPostProcessor(new PropertySourceOrderingPostProcessor(context));
 }