public IntegrationTestBase() { // in certain cases we now have to shutdown the main ApiApplicationInstance as once a profile has been activated // it doesn't remove itself, it has to be rebuilt. As such a quick request here will ensure we have a new context. // if it has been removed. if (genericApplicationContext == null) { genericApplicationContext = new CorePolicyApplicationContext(); genericApplicationContext.refresh(); } apiProperties = genericApplicationContext.getBean(ApiProperties.class); try { // let our deployment type setup the usercontext correctly. depending on iod/web switch (apiProperties.getMode()) { case "direct": case "web": { // set the real user context now! userContext = genericApplicationContext.getBean(UserContext.class); userContext.setProjectId(UUID.randomUUID().toString()); break; } } } catch (Exception ex) { getLogger().trace("Exception in IntegrationTestBase... ", ex); throw new RuntimeException(ex); } classificationApi = genericApplicationContext.getBean(ClassificationApi.class); }
public PolicyWorkerFactory(Codec codec, DataStore dataStore, PolicyWorkerConfiguration config) { this.codec = codec; this.dataStore = dataStore; this.resultQueue = config.getResultQueue(); this.workerIdentifier = config.getWorkerIdentifier(); this.workerThreads = config.getWorkerThreads(); this.configuration = config; applicationContext = new CorePolicyApplicationContext(); createBeanDefinition(WorkerResponseHolder.class, "WorkerResponseHolder", "thread"); createBeanDefinition(WorkerRequestHolder.class, "WorkerRequestHolder", "thread"); applicationContext.refresh(); taskDataConverter = new TaskDataConverter(); apiProvider = new ApiProvider(applicationContext); EngineProperties engineProperties = applicationContext.getBean(EngineProperties.class); Period period = new Period(engineProperties.getEnvironmentCacheVerifyPeriod()); workflowCache = CacheBuilder.newBuilder().expireAfterWrite(period.toStandardDuration().getMillis(), TimeUnit.MILLISECONDS) .build(new CacheLoader<Long, SequenceWorkflow>() { @Override public SequenceWorkflow load(Long key) throws Exception { logger.warn("Loading workflow from database, id: {}", key); return getWorkflow(key, apiProvider.getWorkflowApi()); } }); if (config.getRegisterHandlers()) { new PolicyHandlerSetup(applicationContext).checkBasePolicies(); } }