- locales = asLocaleList(stateProps.get(NodeConstants.I18N_LOCALES));
- }
-
- private void initTransactionManager() {
- bitronix.tm.Configuration tmConf = TransactionManagerServices.getConfiguration();
- tmConf.setServerId(getFrameworkProp(FRAMEWORK_UUID));
-
- Bundle bitronixBundle = FrameworkUtil.getBundle(bitronix.tm.Configuration.class);
- File tmBaseDir = bitronixBundle.getDataFile(KernelConstants.DIR_TRANSACTIONS);
- File tmDir1 = new File(tmBaseDir, "btm1");
- tmDir1.mkdirs();
- tmConf.setLogPart1Filename(new File(tmDir1, tmDir1.getName() + ".tlog").getAbsolutePath());
- File tmDir2 = new File(tmBaseDir, "btm2");
- tmDir2.mkdirs();
- tmConf.setLogPart2Filename(new File(tmDir2, tmDir2.getName() + ".tlog").getAbsolutePath());
- transactionManager = getTransactionManager();
- transactionSynchronizationRegistry = getTransactionSynchronizationRegistry();
- // register
- bc.registerService(TransactionManager.class, transactionManager, null);
- bc.registerService(UserTransaction.class, transactionManager, null);
- bc.registerService(TransactionSynchronizationRegistry.class, transactionSynchronizationRegistry, null);
- }
-
- private void initRepositoryFactory() {
- // TODO rationalise RepositoryFactory
- repositoryFactory = new OsgiJackrabbitRepositoryFactory();
- repositoryFactory.setBundleContext(bc);
- // register
- bc.registerService(RepositoryFactory.class, repositoryFactory, null);
- }
-
- private void initUserAdmin() {
- userAdmin = new NodeUserAdmin();
- // register
- Dictionary<String, Object> props = userAdmin.currentState();
- props.put(Constants.SERVICE_PID, NodeConstants.NODE_REPO_PID);
- // TODO use ManagedService
- bc.registerService(UserAdmin.class, userAdmin, props);
- }
-
- private void initRepositories(Dictionary<String, ?> stateProps) throws IOException {
- nodeRepoUri = KernelUtils.getOsgiInstanceUri("repos/node");
- // register
- repositoryServiceFactory = new JackrabbitRepositoryServiceFactory();
- bc.registerService(ManagedServiceFactory.class, repositoryServiceFactory,
- LangUtils.init(Constants.SERVICE_PID, NodeConstants.JACKRABBIT_FACTORY_PID));
-
- if (cleanState) {
- Configuration newNodeConf = configurationAdmin
- .createFactoryConfiguration(NodeConstants.JACKRABBIT_FACTORY_PID);
- Dictionary<String, Object> props = getNodeConfig(stateProps);
- if (props == null) {
- if (log.isDebugEnabled())
- log.debug("No argeo.node.repo.type=localfs|h2|postgresql|memory"
- + " property defined, entering interactive mode...");
- // TODO interactive configuration
- return;
- }
- // props.put(Constants.SERVICE_PID, NodeConstants.NODE_REPO_PID);
- props.put(RepoConf.uri.name(), nodeRepoUri.toString());
- newNodeConf.update(props);
- }
- }
-
- private void initWebServer() {
- String httpPort = getFrameworkProp("org.osgi.service.http.port");
- String httpsPort = getFrameworkProp("org.osgi.service.http.port.secure");
- try {
- if (httpPort != null || httpsPort != null) {
- final Hashtable<String, Object> jettyProps = new Hashtable<String, Object>();
- if (httpPort != null) {
- jettyProps.put(JettyConstants.HTTP_PORT, httpPort);
- jettyProps.put(JettyConstants.HTTP_ENABLED, true);
- }
- if (httpsPort != null) {
- jettyProps.put(JettyConstants.HTTPS_PORT, httpsPort);
- jettyProps.put(JettyConstants.HTTPS_ENABLED, true);
- jettyProps.put(JettyConstants.SSL_KEYSTORETYPE, "PKCS12");
- // jettyProps.put(JettyConstants.SSL_KEYSTORE,
- // nodeSecurity.getHttpServerKeyStore().getCanonicalPath());
- jettyProps.put(JettyConstants.SSL_PASSWORD, "changeit");
- jettyProps.put(JettyConstants.SSL_WANTCLIENTAUTH, true);
- }
- if (configurationAdmin != null) {
- // TODO make filter more generic
- String filter = "(" + JettyConstants.HTTP_PORT + "=" + httpPort + ")";
- if (configurationAdmin.listConfigurations(filter) != null)
- return;
- Configuration jettyConf = configurationAdmin
- .createFactoryConfiguration(KernelConstants.JETTY_FACTORY_PID, null);
- jettyConf.update(jettyProps);
-
- } else {
- JettyConfigurator.startServer("default", jettyProps);
- }
- }
- } catch (Exception e) {
- throw new CmsException("Cannot initialize web server on " + httpPortsMsg(httpPort, httpsPort), e);