public void setUp() throws Exception { mockInitializer = mock(Initializer.class); mockPropertyManager = mock(PropertyManager.class); mockNotificationDispatcher = mock(NotificationDispatcher.class); mockTransactionRegistryManager = mock(TransactionRegistryManager.class); mockTransactionParticipantManager = mock(TransactionParticipantManager.class); mockTransactionSynchronizationRegistry = mock(TransactionSynchronizationRegistry.class); BeanContext.set(getModule() + ".initializer", mockInitializer); BeanContext.set(getModule() + ".propertyManager", mockPropertyManager); BeanContext.set(getDomain() + ".notificationDispatcher", mockNotificationDispatcher); BeanContext.set(getDomain() + ".jaxbSessionCache", new JAXBSessionCache(getDomain())); if (getMockServiceContext() != null) FieldUtil.setFieldValue( getMockServiceContext(), "transactionRegistryManager", mockTransactionRegistryManager); when(mockPropertyManager.get("aries.port.rmi")).thenReturn("1098"); MBeanServer mbeanServer = MBeanServerFactory.createMBeanServer(); MBeanUtil.setMBeanServer(mbeanServer); setGlobalTransactionActive(false); super.setUp(); }
public void initializeFrameworkComponents() throws Exception { if (!initialized.get()) { if (BeanContext.get(domainName + ".proxyLocator") == null) BeanContext.set(domainName + ".proxyLocator", new ProxyLocator()); if (BeanContext.get(domainName + ".jaxbSessionCache") == null) BeanContext.set(domainName + ".jaxbSessionCache", new JAXBSessionCache(domainName)); if (BeanContext.get(domainName + ".namespaceContext") == null) BeanContext.set(domainName + ".namespaceContext", new NamespaceContext(domainName)); if (BeanContext.get("org.aries.processRegistry") == null) BeanContext.set("org.aries.processRegistry", new ProcessRegistry()); if (BeanContext.get("org.aries.processLocator") == null) BeanContext.set("org.aries.processLocator", new ProcessLocator()); if (BeanContext.get("org.aries.serviceFactory") == null) BeanContext.set("org.aries.serviceFactory", new ServiceFactoryImpl()); if (BeanContext.get("org.aries.serviceRepository") == null) BeanContext.set("org.aries.serviceRepository", new ServiceRepositoryImpl()); if (BeanContext.get("org.aries.serviceRegistry") == null) BeanContext.set("org.aries.serviceRegistry", new ServiceRegistry()); if (BeanContext.get("org.aries.serviceLocator") == null) BeanContext.set("org.aries.serviceLocator", new ServiceLocator()); if (BeanContext.get("org.aries.serviceProxyFactory") == null) BeanContext.set("org.aries.serviceProxyFactory", new ServiceProxyFactory()); if (BeanContext.get("org.aries.linkStateRegistry") == null) BeanContext.set("org.aries.linkStateRegistry", new LinkStateRegistry()); if (BeanContext.get("org.aries.executorService") == null) BeanContext.set("org.aries.executorService", Executors.newFixedThreadPool(10)); TaskInvokerFactory taskInvokerFactory = new TaskInvokerFactory(); TaskExecutorFactory taskExecutorFactory = new TaskExecutorFactory(); taskInvokerFactory.setTaskInvokerClassName("org.aries.task.TaskInvokerImpl"); taskExecutorFactory.setTaskExecutorClassName("common.tx.util.TaskExecutorImpl"); if (BeanContext.get("org.aries.invokerFactory") == null) BeanContext.set("org.aries.invokerFactory", taskInvokerFactory); if (BeanContext.get("org.aries.executorFactory") == null) BeanContext.set("org.aries.executorFactory", taskExecutorFactory); if (BeanContext.get("org.aries.providerCache") == null) BeanContext.set("org.aries.providerCache", new ProviderCache()); initialized.set(true); } }
// TODO rename runtime location to tempFileLocation public void initializePropertyManager() throws Exception { // Establish working location if (workingLocation == null) workingLocation = DEFAULT_WORKING_LOCATION; workingLocation = FileUtil.normalizePath(workingLocation); log.info("Application working Location: " + workingLocation); // Establish application home Assert.notNull(applicationHome, "Application home location must be specified"); applicationHome = FileUtil.normalizePath(applicationHome); log.info("Application home location: " + applicationHome); // Establish runtime location // if (runtimeLocation == null) runtimeLocation = applicationHome; runtimeLocation = FileUtil.normalizePath(runtimeLocation); log.info("Application runtime location: " + runtimeLocation); // Establish cache location // if (cacheLocation == null) cacheLocation = applicationHome + "/cache"; cacheLocation = FileUtil.normalizePath(cacheLocation); log.info("Application cache location: " + cacheLocation); // Establish property location propertyLocation = establishGlobalPropertyLocation(applicationHome); log.info("Application runtime property Location: " + propertyLocation); propertyLocation = FileUtil.normalizePath(propertyLocation); // File sourceLocation = new File(runtimeLocation + "/model"); // Set<String> subFolders = ImportUtil.getImportedFileFolders(sourceLocation); // Iterator<String> iterator = subFolders.iterator(); // while (iterator.hasNext()) { // String subFolder = iterator.next(); // PropertyInitializer propertyInitializer = new PropertyInitializer(); // propertyInitializer.setRuntimeLocation(runtimeLocation); // propertyInitializer.setWorkingLocation(workingLocation); // propertyInitializer.setPropertyLocation(propertyLocation); // if (!subFolder.startsWith("/model")) // subFolder = "/model" + subFolder; // propertyInitializer.setSubFolder(subFolder); // propertyInitializer.initialize(); // // } // TODO establish source and target property locations per module PropertyInitializer propertyInitializer = new PropertyInitializer(); propertyInitializer.setRuntimeLocation(runtimeLocation); propertyInitializer.setWorkingLocation(workingLocation); propertyInitializer.setPropertyLocation(propertyLocation); propertyInitializer.initialize(); String propertyManagerKey = getModuleName() + ".propertyManager"; PropertyManager propertyManager = BeanContext.get(propertyManagerKey); if (propertyManager == null) propertyManager = new PropertyManager(); // BeanContext.set("org.aries.propertyManager", propertyManager); BeanContext.set(propertyManagerKey, propertyManager); propertyManager.setPropertyLocation(propertyLocation); propertyManager.initialize(); Object object1 = propertyManager.get("bookshop2.shipper.transport"); Object object2 = propertyManager.get("bookshop2.supplier.transport"); System.out.println(); // ServletContext servletContext = RuntimeContext.getInstance().getServletContext(); // if (servletContext != null) { // propertyInitializer.initialize(servletContext); // } else { // propertyInitializer.initialize(); // } }