Java Code Examples for org.apache.directory.server.core.api.partition.Partition#setSchemaManager()
The following examples show how to use
org.apache.directory.server.core.api.partition.Partition#setSchemaManager() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ApacheDSStartStopListener.java From syncope with Apache License 2.0 | 6 votes |
private void initSystemPartition() throws Exception { JdbmPartitionFactory partitionFactory = new JdbmPartitionFactory(); Partition systemPartition = partitionFactory.createPartition( service.getSchemaManager(), service.getDnFactory(), "system", ServerDNConstants.SYSTEM_DN, 500, new File(service.getInstanceLayout().getPartitionsDirectory(), "system")); systemPartition.setSchemaManager(service.getSchemaManager()); partitionFactory.addIndex(systemPartition, SchemaConstants.OBJECT_CLASS_AT, 100); service.setSystemPartition(systemPartition); }
Example 2
Source File: InMemoryDirectoryServiceFactory.java From bouncr with Eclipse Public License 1.0 | 4 votes |
/** * {@inheritDoc} */ public void init(String name) throws Exception { if ((directoryService != null) && directoryService.isStarted()) { return; } directoryService.setInstanceId(name); // instance layout InstanceLayout instanceLayout = new InstanceLayout(System.getProperty("java.io.tmpdir") + "/server-work-" + name); if (instanceLayout.getInstanceDirectory().exists()) { try { FileUtils.deleteDirectory(instanceLayout.getInstanceDirectory()); } catch (IOException e) { LOG.warn("couldn't delete the instance directory before initializing the DirectoryService", e); } } directoryService.setInstanceLayout(instanceLayout); // EhCache in disabled-like-mode Configuration ehCacheConfig = new Configuration(); CacheConfiguration defaultCache = new CacheConfiguration("default", 1).eternal(false).timeToIdleSeconds(30) .timeToLiveSeconds(30).overflowToDisk(false); ehCacheConfig.addDefaultCache(defaultCache); CacheService cacheService = new CacheService(new CacheManager(ehCacheConfig)); directoryService.setCacheService(cacheService); // Init the schema // SchemaLoader loader = new SingleLdifSchemaLoader(); SchemaLoader loader = new JarLdifSchemaLoader(); SchemaManager schemaManager = new DefaultSchemaManager(loader); schemaManager.loadAllEnabled(); ComparatorRegistry comparatorRegistry = schemaManager.getComparatorRegistry(); for (LdapComparator<?> comparator : comparatorRegistry) { if (comparator instanceof NormalizingComparator) { ((NormalizingComparator) comparator).setOnServer(); } } directoryService.setSchemaManager(schemaManager); InMemorySchemaPartition inMemorySchemaPartition = new InMemorySchemaPartition(schemaManager); SchemaPartition schemaPartition = new SchemaPartition(schemaManager); schemaPartition.setWrappedPartition(inMemorySchemaPartition); directoryService.setSchemaPartition(schemaPartition); List<Throwable> errors = schemaManager.getErrors(); if (errors.size() != 0) { throw new Exception(I18n.err(I18n.ERR_317, Exceptions.printErrors(errors))); } // Init system partition Partition systemPartition = partitionFactory.createPartition(directoryService.getSchemaManager(), directoryService.getDnFactory(), "system", ServerDNConstants.SYSTEM_DN, 500, new File(directoryService.getInstanceLayout().getPartitionsDirectory(), "system")); systemPartition.setSchemaManager(directoryService.getSchemaManager()); partitionFactory.addIndex(systemPartition, SchemaConstants.OBJECT_CLASS_AT, 100); directoryService.setSystemPartition(systemPartition); directoryService.startup(); }
Example 3
Source File: InMemoryDirectoryServiceFactory.java From activemq-artemis with Apache License 2.0 | 4 votes |
/** * {@inheritDoc} */ @Override public void init(String name) throws Exception { if ((directoryService == null) || directoryService.isStarted()) { return; } directoryService.setInstanceId(name); // instance layout InstanceLayout instanceLayout = new InstanceLayout(System.getProperty("java.io.tmpdir") + "/server-work-" + name); if (instanceLayout.getInstanceDirectory().exists()) { try { FileUtils.deleteDirectory(instanceLayout.getInstanceDirectory()); } catch (IOException e) { LOG.warn("couldn't delete the instance directory before initializing the DirectoryService", e); } } directoryService.setInstanceLayout(instanceLayout); // EhCache in disabled-like-mode Configuration ehCacheConfig = new Configuration(); CacheConfiguration defaultCache = new CacheConfiguration("default", 1).eternal(false).timeToIdleSeconds(30).timeToLiveSeconds(30).overflowToDisk(false); ehCacheConfig.addDefaultCache(defaultCache); CacheService cacheService = new CacheService(new CacheManager(ehCacheConfig)); directoryService.setCacheService(cacheService); // Init the schema // SchemaLoader loader = new SingleLdifSchemaLoader(); SchemaLoader loader = new JarLdifSchemaLoader(); SchemaManager schemaManager = new DefaultSchemaManager(loader); schemaManager.loadAllEnabled(); ComparatorRegistry comparatorRegistry = schemaManager.getComparatorRegistry(); for (LdapComparator<?> comparator : comparatorRegistry) { if (comparator instanceof NormalizingComparator) { ((NormalizingComparator) comparator).setOnServer(); } } directoryService.setSchemaManager(schemaManager); InMemorySchemaPartition inMemorySchemaPartition = new InMemorySchemaPartition(schemaManager); SchemaPartition schemaPartition = new SchemaPartition(schemaManager); schemaPartition.setWrappedPartition(inMemorySchemaPartition); directoryService.setSchemaPartition(schemaPartition); List<Throwable> errors = schemaManager.getErrors(); if (errors.size() != 0) { throw new Exception(I18n.err(I18n.ERR_317, Exceptions.printErrors(errors))); } // Init system partition Partition systemPartition = partitionFactory.createPartition(directoryService.getSchemaManager(), directoryService.getDnFactory(), "system", ServerDNConstants.SYSTEM_DN, 500, new File(directoryService.getInstanceLayout().getPartitionsDirectory(), "system")); systemPartition.setSchemaManager(directoryService.getSchemaManager()); partitionFactory.addIndex(systemPartition, SchemaConstants.OBJECT_CLASS_AT, 100); directoryService.setSystemPartition(systemPartition); directoryService.startup(); }
Example 4
Source File: InMemoryDirectoryServiceFactory.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
/** * {@inheritDoc} */ @Override public void init(String name) throws Exception { if ((directoryService != null) && directoryService.isStarted()) { return; } directoryService.setInstanceId(name); // instance layout InstanceLayout instanceLayout = new InstanceLayout(System.getProperty("java.io.tmpdir") + "/server-work-" + name); if (instanceLayout.getInstanceDirectory().exists()) { try { FileUtils.deleteDirectory(instanceLayout.getInstanceDirectory()); } catch (IOException e) { LOG.warn("couldn't delete the instance directory before initializing the DirectoryService", e); } } directoryService.setInstanceLayout(instanceLayout); // EhCache in disabled-like-mode Configuration ehCacheConfig = new Configuration(); CacheConfiguration defaultCache = new CacheConfiguration("ApacheDSTestCache", 1).eternal(false).timeToIdleSeconds(30) .timeToLiveSeconds(30).overflowToDisk(false); ehCacheConfig.addDefaultCache(defaultCache); cacheManager = new CacheManager(ehCacheConfig); CacheService cacheService = new CacheService(cacheManager); directoryService.setCacheService(cacheService); // Init the schema // SchemaLoader loader = new SingleLdifSchemaLoader(); SchemaLoader loader = new JarLdifSchemaLoader(); SchemaManager schemaManager = new DefaultSchemaManager(loader); schemaManager.loadAllEnabled(); ComparatorRegistry comparatorRegistry = schemaManager.getComparatorRegistry(); for (LdapComparator<?> comparator : comparatorRegistry) { if (comparator instanceof NormalizingComparator) { ((NormalizingComparator) comparator).setOnServer(); } } directoryService.setSchemaManager(schemaManager); InMemorySchemaPartition inMemorySchemaPartition = new InMemorySchemaPartition(schemaManager); SchemaPartition schemaPartition = new SchemaPartition(schemaManager); schemaPartition.setWrappedPartition(inMemorySchemaPartition); directoryService.setSchemaPartition(schemaPartition); List<Throwable> errors = schemaManager.getErrors(); if (errors.size() != 0) { throw new Exception(I18n.err(I18n.ERR_317, Exceptions.printErrors(errors))); } // Init system partition Partition systemPartition = partitionFactory.createPartition(directoryService.getSchemaManager(), "system", ServerDNConstants.SYSTEM_DN, 500, new File(directoryService.getInstanceLayout().getPartitionsDirectory(), "system")); systemPartition.setSchemaManager(directoryService.getSchemaManager()); partitionFactory.addIndex(systemPartition, SchemaConstants.OBJECT_CLASS_AT, 100); directoryService.setSystemPartition(systemPartition); directoryService.startup(); }
Example 5
Source File: InMemoryDirectoryServiceFactory.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
/** * {@inheritDoc} */ @Override public void init(String name) throws Exception { if ((directoryService != null) && directoryService.isStarted()) { return; } directoryService.setInstanceId(name); // instance layout InstanceLayout instanceLayout = new InstanceLayout(System.getProperty("java.io.tmpdir") + "/server-work-" + name); if (instanceLayout.getInstanceDirectory().exists()) { try { FileUtils.deleteDirectory(instanceLayout.getInstanceDirectory()); } catch (IOException e) { LOG.warn("couldn't delete the instance directory before initializing the DirectoryService", e); } } directoryService.setInstanceLayout(instanceLayout); // EhCache in disabled-like-mode Configuration ehCacheConfig = new Configuration(); CacheConfiguration defaultCache = new CacheConfiguration("ApacheDSTestCache", 1).eternal(false).timeToIdleSeconds(30) .timeToLiveSeconds(30).overflowToDisk(false); ehCacheConfig.addDefaultCache(defaultCache); cacheManager = new CacheManager(ehCacheConfig); CacheService cacheService = new CacheService(cacheManager); directoryService.setCacheService(cacheService); // Init the schema // SchemaLoader loader = new SingleLdifSchemaLoader(); SchemaLoader loader = new JarLdifSchemaLoader(); SchemaManager schemaManager = new DefaultSchemaManager(loader); schemaManager.loadAllEnabled(); ComparatorRegistry comparatorRegistry = schemaManager.getComparatorRegistry(); for (LdapComparator<?> comparator : comparatorRegistry) { if (comparator instanceof NormalizingComparator) { ((NormalizingComparator) comparator).setOnServer(); } } directoryService.setSchemaManager(schemaManager); InMemorySchemaPartition inMemorySchemaPartition = new InMemorySchemaPartition(schemaManager); SchemaPartition schemaPartition = new SchemaPartition(schemaManager); schemaPartition.setWrappedPartition(inMemorySchemaPartition); directoryService.setSchemaPartition(schemaPartition); List<Throwable> errors = schemaManager.getErrors(); if (errors.size() != 0) { throw new Exception(I18n.err(I18n.ERR_317, Exceptions.printErrors(errors))); } // Init system partition Partition systemPartition = partitionFactory.createPartition(directoryService.getSchemaManager(), "system", ServerDNConstants.SYSTEM_DN, 500, new File(directoryService.getInstanceLayout().getPartitionsDirectory(), "system")); systemPartition.setSchemaManager(directoryService.getSchemaManager()); partitionFactory.addIndex(systemPartition, SchemaConstants.OBJECT_CLASS_AT, 100); directoryService.setSystemPartition(systemPartition); directoryService.startup(); }
Example 6
Source File: InMemoryDirectoryServiceFactory.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
/** * {@inheritDoc} */ @Override public void init(String name) throws Exception { if ((directoryService != null) && directoryService.isStarted()) { return; } directoryService.setInstanceId(name); // instance layout InstanceLayout instanceLayout = new InstanceLayout(System.getProperty("java.io.tmpdir") + "/server-work-" + name); if (instanceLayout.getInstanceDirectory().exists()) { try { FileUtils.deleteDirectory(instanceLayout.getInstanceDirectory()); } catch (IOException e) { LOG.warn("couldn't delete the instance directory before initializing the DirectoryService", e); } } directoryService.setInstanceLayout(instanceLayout); // EhCache in disabled-like-mode Configuration ehCacheConfig = new Configuration(); CacheConfiguration defaultCache = new CacheConfiguration("ApacheDSTestCache", 1).eternal(false).timeToIdleSeconds(30) .timeToLiveSeconds(30).overflowToDisk(false); ehCacheConfig.addDefaultCache(defaultCache); cacheManager = new CacheManager(ehCacheConfig); CacheService cacheService = new CacheService(cacheManager); directoryService.setCacheService(cacheService); // Init the schema // SchemaLoader loader = new SingleLdifSchemaLoader(); SchemaLoader loader = new JarLdifSchemaLoader(); SchemaManager schemaManager = new DefaultSchemaManager(loader); schemaManager.loadAllEnabled(); ComparatorRegistry comparatorRegistry = schemaManager.getComparatorRegistry(); for (LdapComparator<?> comparator : comparatorRegistry) { if (comparator instanceof NormalizingComparator) { ((NormalizingComparator) comparator).setOnServer(); } } directoryService.setSchemaManager(schemaManager); InMemorySchemaPartition inMemorySchemaPartition = new InMemorySchemaPartition(schemaManager); SchemaPartition schemaPartition = new SchemaPartition(schemaManager); schemaPartition.setWrappedPartition(inMemorySchemaPartition); directoryService.setSchemaPartition(schemaPartition); List<Throwable> errors = schemaManager.getErrors(); if (errors.size() != 0) { throw new Exception(I18n.err(I18n.ERR_317, Exceptions.printErrors(errors))); } // Init system partition Partition systemPartition = partitionFactory.createPartition(directoryService.getSchemaManager(), "system", ServerDNConstants.SYSTEM_DN, 500, new File(directoryService.getInstanceLayout().getPartitionsDirectory(), "system")); systemPartition.setSchemaManager(directoryService.getSchemaManager()); partitionFactory.addIndex(systemPartition, SchemaConstants.OBJECT_CLASS_AT, 100); directoryService.setSystemPartition(systemPartition); directoryService.startup(); }
Example 7
Source File: InMemoryDirectoryServiceFactory.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
/** * {@inheritDoc} */ @Override public void init(String name) throws Exception { if ((directoryService != null) && directoryService.isStarted()) { return; } directoryService.setInstanceId(name); // instance layout InstanceLayout instanceLayout = new InstanceLayout(System.getProperty("java.io.tmpdir") + "/server-work-" + name); if (instanceLayout.getInstanceDirectory().exists()) { try { FileUtils.deleteDirectory(instanceLayout.getInstanceDirectory()); } catch (IOException e) { LOG.warn("couldn't delete the instance directory before initializing the DirectoryService", e); } } directoryService.setInstanceLayout(instanceLayout); // EhCache in disabled-like-mode Configuration ehCacheConfig = new Configuration(); CacheConfiguration defaultCache = new CacheConfiguration("ApacheDSTestCache", 1).eternal(false).timeToIdleSeconds(30) .timeToLiveSeconds(30).overflowToDisk(false); ehCacheConfig.addDefaultCache(defaultCache); cacheManager = new CacheManager(ehCacheConfig); CacheService cacheService = new CacheService(cacheManager); directoryService.setCacheService(cacheService); // Init the schema // SchemaLoader loader = new SingleLdifSchemaLoader(); SchemaLoader loader = new JarLdifSchemaLoader(); SchemaManager schemaManager = new DefaultSchemaManager(loader); schemaManager.loadAllEnabled(); ComparatorRegistry comparatorRegistry = schemaManager.getComparatorRegistry(); for (LdapComparator<?> comparator : comparatorRegistry) { if (comparator instanceof NormalizingComparator) { ((NormalizingComparator) comparator).setOnServer(); } } directoryService.setSchemaManager(schemaManager); InMemorySchemaPartition inMemorySchemaPartition = new InMemorySchemaPartition(schemaManager); SchemaPartition schemaPartition = new SchemaPartition(schemaManager); schemaPartition.setWrappedPartition(inMemorySchemaPartition); directoryService.setSchemaPartition(schemaPartition); List<Throwable> errors = schemaManager.getErrors(); if (errors.size() != 0) { throw new Exception(I18n.err(I18n.ERR_317, Exceptions.printErrors(errors))); } // Init system partition Partition systemPartition = partitionFactory.createPartition(directoryService.getSchemaManager(), "system", ServerDNConstants.SYSTEM_DN, 500, new File(directoryService.getInstanceLayout().getPartitionsDirectory(), "system")); systemPartition.setSchemaManager(directoryService.getSchemaManager()); partitionFactory.addIndex(systemPartition, SchemaConstants.OBJECT_CLASS_AT, 100); directoryService.setSystemPartition(systemPartition); directoryService.startup(); }