当前位置: 首页>>代码示例>>Java>>正文


Java SchemaLoader类代码示例

本文整理汇总了Java中org.apache.directory.api.ldap.model.schema.registries.SchemaLoader的典型用法代码示例。如果您正苦于以下问题:Java SchemaLoader类的具体用法?Java SchemaLoader怎么用?Java SchemaLoader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SchemaLoader类属于org.apache.directory.api.ldap.model.schema.registries包,在下文中一共展示了SchemaLoader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: DefaultSchemaManager

import org.apache.directory.api.ldap.model.schema.registries.SchemaLoader; //导入依赖的package包/类
/**
 * Creates a new instance of DefaultSchemaManager with the default schema schemaLoader
 * 
 * @param schemaLoader The schemaLoader containing the schemas to load
 */
public DefaultSchemaManager( SchemaLoader schemaLoader )
{
    // Default to the the root (one schemaManager for all the entries
    namingContext = Dn.ROOT_DSE;
    
    for ( Schema schema : schemaLoader.getAllSchemas() )
    {
        schemaMap.put( schema.getSchemaName(), schema );
    }
    
    errors = new ArrayList<>();
    registries = new Registries();
    factory = new SchemaEntityFactory();
    isRelaxed = STRICT;
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:21,代码来源:DefaultSchemaManager.java

示例2: loadSchema

import org.apache.directory.api.ldap.model.schema.registries.SchemaLoader; //导入依赖的package包/类
/**
 * loads schema using the specified schema loader
 *
 * @param loader the {@link SchemaLoader} to be used to load schema
 * @throws LdapException If the schema loading failed
 */
public void loadSchema( SchemaLoader loader ) throws LdapException
{
    try
    {
        SchemaManager tmp = new DefaultSchemaManager( loader );

        tmp.loadAllEnabled();

        if ( !tmp.getErrors().isEmpty() && loader.isStrict() )
        {
            String msg = "there are errors while loading the schema";
            LOG.error( msg + " {}", tmp.getErrors() );
            throw new LdapException( msg );
        }

        schemaManager = tmp;

        // Change the container's BinaryDetector
        ldapSession.setAttribute( LdapDecoder.MESSAGE_CONTAINER_ATTR,
            new LdapMessageContainer<MessageDecorator<? extends Message>>( codec,
                new SchemaBinaryAttributeDetector( schemaManager ) ) );

    }
    catch ( LdapException le )
    {
        throw le;
    }
    catch ( Exception e )
    {
        LOG.error( "failed to load the schema", e );
        throw new LdapException( e );
    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:40,代码来源:LdapNetworkConnection.java

示例3: init

import org.apache.directory.api.ldap.model.schema.registries.SchemaLoader; //导入依赖的package包/类
/**
 * Initialize the Schema Service
 *
 * @param directoryService the directory service core
 * @throws Exception if there are problems during initialization
 */
public void init( DirectoryService directoryService ) throws LdapException
{
    if ( IS_DEBUG )
    {
        LOG.debug( "Initializing SchemaInterceptor..." );
    }

    super.init( directoryService );

    nexus = directoryService.getPartitionNexus();
    topFilter = new TopFilter();
    filters.add( topFilter );

    schemaBaseDn = directoryService.getDnFactory().create( SchemaConstants.OU_SCHEMA );

    // stuff for dealing with subentries (garbage for now)
    Value<?> subschemaSubentry = nexus.getRootDse( null ).get( SchemaConstants.SUBSCHEMA_SUBENTRY_AT ).get();
    subschemaSubentryDn = directoryService.getDnFactory().create( subschemaSubentry.getString() );
    subschemaSubentryDn.apply( schemaManager );
    subschemaSubentryDnNorm = subschemaSubentryDn.getNormName();

    schemaModificationAttributesDn = directoryService.getDnFactory().create(
        SchemaConstants.SCHEMA_MODIFICATIONS_DN );
    schemaModificationAttributesDn.apply( schemaManager );

    computeSuperiors();

    // Initialize the schema manager
    SchemaLoader loader = directoryService.getSchemaManager().getLoader();
    schemaSubEntryManager = new SchemaSubentryManager( schemaManager, loader, directoryService.getDnFactory() );

    if ( IS_DEBUG )
    {
        LOG.debug( "SchemaInterceptor Initialized !" );
    }
}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:43,代码来源:SchemaInterceptor.java

示例4: init

import org.apache.directory.api.ldap.model.schema.registries.SchemaLoader; //导入依赖的package包/类
/**
 * Initialize the Schema Service
 *
 * @param directoryService the directory service core
 * @throws Exception if there are problems during initialization
 */
public void init( DirectoryService directoryService ) throws LdapException
{
    if ( IS_DEBUG )
    {
        LOG.debug( "Initializing SchemaInterceptor..." );
    }

    super.init( directoryService );

    nexus = directoryService.getPartitionNexus();
    topFilter = new TopFilter();
    filters.add( topFilter );

    schemaBaseDn = dnFactory.create( SchemaConstants.OU_SCHEMA );

    // stuff for dealing with subentries (garbage for now)
    Value<?> subschemaSubentry = nexus.getRootDseValue( SUBSCHEMA_SUBENTRY_AT );
    subschemaSubentryDn = dnFactory.create( subschemaSubentry.getString() );
    subschemaSubentryDnNorm = subschemaSubentryDn.getNormName();

    schemaModificationAttributesDn = dnFactory.create(
        SchemaConstants.SCHEMA_MODIFICATIONS_DN );

    computeSuperiors();

    // Initialize the schema manager
    SchemaLoader loader = directoryService.getSchemaManager().getLoader();
    schemaSubEntryManager = new SchemaSubentryManager( schemaManager, loader, dnFactory );

    if ( IS_DEBUG )
    {
        LOG.debug( "SchemaInterceptor Initialized !" );
    }
}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:41,代码来源:SchemaInterceptor.java

示例5: initSchemaPartition

import org.apache.directory.api.ldap.model.schema.registries.SchemaLoader; //导入依赖的package包/类
private void initSchemaPartition() throws IOException, LdapException, KerberosException {
    InstanceLayout instanceLayout = directoryService.getInstanceLayout();
    File schemaPartitionDirectory = new File(instanceLayout.getPartitionsDirectory(), "schema");
    // Extract the schema on disk (a brand new one) and load the registries
    if (schemaPartitionDirectory.exists()) {
        LOGGER.info("schema partition already exists, skipping schema extraction");
    } else {
        SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor(instanceLayout.getPartitionsDirectory());
        extractor.extractOrCopy();
    }
    SchemaLoader loader = new LdifSchemaLoader(schemaPartitionDirectory);
    SchemaManager schemaManager = new DefaultSchemaManager(loader);
    // We have to load the schema now, otherwise we won't be able
    // to initialize the Partitions, as we won't be able to parse
    // and normalize their suffix Dn
    schemaManager.loadAllEnabled();
    List<Throwable> errors = schemaManager.getErrors();
    if (errors.size() != 0) {
        throw new KerberosException(I18n.err(I18n.ERR_317, Exceptions.printErrors(errors)));
    }
    directoryService.setSchemaManager(schemaManager);
    // Init the LdifPartition with schema
    LdifPartition schemaLdifPartition = new LdifPartition(schemaManager, directoryService.getDnFactory());
    schemaLdifPartition.setPartitionPath(schemaPartitionDirectory.toURI());
    // The schema partition
    SchemaPartition schemaPartition = new SchemaPartition(schemaManager);
    schemaPartition.setWrappedPartition(schemaLdifPartition);
    directoryService.setSchemaPartition(schemaPartition);
}
 
开发者ID:intropro,项目名称:prairie,代码行数:30,代码来源:KerberosServer.java

示例6: initSchemaPartition

import org.apache.directory.api.ldap.model.schema.registries.SchemaLoader; //导入依赖的package包/类
private void initSchemaPartition() throws Exception {
 	InstanceLayout instanceLayout = directoryService.getInstanceLayout();
 	File schemaPartitionDirectory = new File( instanceLayout.getPartitionsDirectory(), "schema" );

     if ( schemaPartitionDirectory.exists() ) {
         System.out.println( "schema partition already exists, skipping schema extraction" );
     } else {
         SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor(instanceLayout.getPartitionsDirectory());
         try {
	extractor.extractOrCopy();
} catch (IOException e) {
	log.error("Extracting schema partition failed " + e.getMessage());
	throw new Exception();
}
     }
     SchemaLoader loader = new LdifSchemaLoader(schemaPartitionDirectory);
     SchemaManager schemaManager = new DefaultSchemaManager( loader );
     
     log.info("loading schmea partition... ");
     schemaManager.loadAllEnabled();
     
     List<Throwable> errors = schemaManager.getErrors();
     if (errors.size() != 0) {
     	log.error("Error creating schema partition");
         throw new Exception(I18n.err(I18n.ERR_317, Exceptions.printErrors(errors)));
     }
     
     directoryService.setSchemaManager(schemaManager);
     
     LdifPartition schemaLdifPartition = new LdifPartition(schemaManager, directoryService.getDnFactory());
     schemaLdifPartition.setPartitionPath(schemaPartitionDirectory.toURI());
     SchemaPartition schemaPartition = new SchemaPartition(schemaManager);
     schemaPartition.setWrappedPartition(schemaLdifPartition);
     
     directoryService.setSchemaPartition(schemaPartition);
 }
 
开发者ID:ztarbug,项目名称:apacheds-embedded,代码行数:37,代码来源:DirectoryRunner.java

示例7: initSchemaPartition

import org.apache.directory.api.ldap.model.schema.registries.SchemaLoader; //导入依赖的package包/类
/**
 * Initialize the schema manager and add the schema partition to directory service.
 *
 * @throws Exception if the schema LDIF files are not found on the classpath
 */
private void initSchemaPartition() throws Exception {
    InstanceLayout instanceLayout = service.getInstanceLayout();

    File schemaPartitionDirectory = new File(instanceLayout.getPartitionsDirectory(), "schema");

    // Extract the schema on disk (a brand new one) and load the registries
    if (schemaPartitionDirectory.exists()) {
        LOG.debug("schema partition already exists, skipping schema extraction");
    } else {
        SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor(instanceLayout.getPartitionsDirectory());
        extractor.extractOrCopy();
    }

    SchemaLoader loader = new LdifSchemaLoader(schemaPartitionDirectory);
    SchemaManager schemaManager = new DefaultSchemaManager(loader);

    // We have to load the schema now, otherwise we won't be able
    // to initialize the Partitions, as we won't be able to parse
    // and normalize their suffix Dn
    schemaManager.loadAllEnabled();

    List<Throwable> errors = schemaManager.getErrors();
    if (!errors.isEmpty()) {
        throw new IllegalStateException(I18n.err(I18n.ERR_317, Exceptions.printErrors(errors)));
    }

    service.setSchemaManager(schemaManager);

    // Init the LdifPartition with schema
    LdifPartition schemaLdifPartition = new LdifPartition(schemaManager, service.getDnFactory());
    schemaLdifPartition.setPartitionPath(schemaPartitionDirectory.toURI());

    // The schema partition
    SchemaPartition schemaPartition = new SchemaPartition(schemaManager);
    schemaPartition.setWrappedPartition(schemaLdifPartition);
    service.setSchemaPartition(schemaPartition);
}
 
开发者ID:apache,项目名称:syncope,代码行数:43,代码来源:ApacheDSStartStopListener.java

示例8: initSchemaPartition

import org.apache.directory.api.ldap.model.schema.registries.SchemaLoader; //导入依赖的package包/类
/**
 * initialize the schema manager and add the schema partition to directory
 * service
 *
 * @throws Exception if the schema LDIF files are not found on the classpath
 */
protected void initSchemaPartition() throws Exception {
  InstanceLayout instanceLayout = service.getInstanceLayout();

  File schemaPartitionDirectory = new File(instanceLayout.getPartitionsDirectory(), "schema");

  // Extract the schema on disk (a brand new one) and load the registries
  if (schemaPartitionDirectory.exists()) {
    LOG.log(Level.INFO, "schema partition already exists, skipping schema extraction");
  } else {
    SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor(instanceLayout.getPartitionsDirectory());
    extractor.extractOrCopy();
  }

  SchemaLoader loader = new LdifSchemaLoader(schemaPartitionDirectory);
  SchemaManager schemaManager = new DefaultSchemaManager(loader);

  // We have to load the schema now, otherwise we won't be able
  // to initialize the Partitions, as we won't be able to parse
  // and normalize their suffix Dn
  schemaManager.loadAllEnabled();

  List<Throwable> errors = schemaManager.getErrors();

  if (!errors.isEmpty()) {
    throw new Exception(I18n.err(I18n.ERR_317, Exceptions.printErrors(errors)));
  }

  service.setSchemaManager(schemaManager);

  // Init the LdifPartition with schema
  LdifPartition schemaLdifPartition = new LdifPartition(schemaManager, service.getDnFactory());
  schemaLdifPartition.setPartitionPath(schemaPartitionDirectory.toURI());

  // The schema partition
  SchemaPartition schemaPartition = new SchemaPartition(schemaManager);
  schemaPartition.setWrappedPartition(schemaLdifPartition);
  service.setSchemaPartition(schemaPartition);
}
 
开发者ID:camunda,项目名称:camunda-bpm-platform,代码行数:45,代码来源:LdapTestEnvironment.java

示例9: initDirectoryService

import org.apache.directory.api.ldap.model.schema.registries.SchemaLoader; //导入依赖的package包/类
private void initDirectoryService() throws Exception {
  ds = new DefaultDirectoryService();
  ds.setInstanceLayout(new InstanceLayout(workDir));

  CacheService cacheService = new CacheService();
  ds.setCacheService(cacheService);

  // first load the schema
  InstanceLayout instanceLayout = ds.getInstanceLayout();
  File schemaPartitionDirectory = new File(
          instanceLayout.getPartitionsDirectory(), "schema");
  SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor(
          instanceLayout.getPartitionsDirectory());
  extractor.extractOrCopy();

  SchemaLoader loader = new LdifSchemaLoader(schemaPartitionDirectory);
  SchemaManager schemaManager = new DefaultSchemaManager(loader);
  schemaManager.loadAllEnabled();
  ds.setSchemaManager(schemaManager);
  // Init the LdifPartition with schema
  LdifPartition schemaLdifPartition = new LdifPartition(schemaManager);
  schemaLdifPartition.setPartitionPath(schemaPartitionDirectory.toURI());

  // The schema partition
  SchemaPartition schemaPartition = new SchemaPartition(schemaManager);
  schemaPartition.setWrappedPartition(schemaLdifPartition);
  ds.setSchemaPartition(schemaPartition);

  JdbmPartition systemPartition = new JdbmPartition(ds.getSchemaManager());
  systemPartition.setId("system");
  systemPartition.setPartitionPath(new File(
          ds.getInstanceLayout().getPartitionsDirectory(),
          systemPartition.getId()).toURI());
  systemPartition.setSuffixDn(new Dn(ServerDNConstants.SYSTEM_DN));
  systemPartition.setSchemaManager(ds.getSchemaManager());
  ds.setSystemPartition(systemPartition);

  ds.getChangeLog().setEnabled(false);
  ds.setDenormalizeOpAttrsEnabled(true);
  ds.addLast(new KeyDerivationInterceptor());

  // create one partition
  String orgName= conf.getProperty(ORG_NAME).toLowerCase(Locale.ENGLISH);
  String orgDomain = conf.getProperty(ORG_DOMAIN).toLowerCase(Locale.ENGLISH);

  JdbmPartition partition = new JdbmPartition(ds.getSchemaManager());
  partition.setId(orgName);
  partition.setPartitionPath(new File(
          ds.getInstanceLayout().getPartitionsDirectory(), orgName).toURI());
  partition.setSuffixDn(new Dn("dc=" + orgName + ",dc=" + orgDomain));
  ds.addPartition(partition);
  // indexes
  Set<Index<?, ?, String>> indexedAttributes = new HashSet<Index<?, ?, String>>();
  indexedAttributes.add(new JdbmIndex<String, Entry>("objectClass", false));
  indexedAttributes.add(new JdbmIndex<String, Entry>("dc", false));
  indexedAttributes.add(new JdbmIndex<String, Entry>("ou", false));
  partition.setIndexedAttributes(indexedAttributes);

  // And start the ds
  ds.setInstanceId(conf.getProperty(INSTANCE));
  ds.startup();
  // context entry, after ds.startup()
  Dn dn = new Dn("dc=" + orgName + ",dc=" + orgDomain);
  Entry entry = ds.newEntry(dn);
  entry.add("objectClass", "top", "domain");
  entry.add("dc", orgName);
  ds.getAdminSession().add(entry);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:69,代码来源:MiniKdc.java

示例10: initDirectoryService

import org.apache.directory.api.ldap.model.schema.registries.SchemaLoader; //导入依赖的package包/类
private void initDirectoryService() throws Exception {
    ds = new DefaultDirectoryService();
    ds.setInstanceLayout(new InstanceLayout(workDir));

    CacheService cacheService = new CacheService();
    ds.setCacheService(cacheService);

    // first load the schema
    InstanceLayout instanceLayout = ds.getInstanceLayout();
    File schemaPartitionDirectory = new File(instanceLayout.getPartitionsDirectory(), "schema");
    SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor(instanceLayout.getPartitionsDirectory());
    extractor.extractOrCopy();

    SchemaLoader loader = new LdifSchemaLoader(schemaPartitionDirectory);
    SchemaManager schemaManager = new DefaultSchemaManager(loader);
    schemaManager.loadAllEnabled();
    ds.setSchemaManager(schemaManager);
    // Init the LdifPartition with schema
    LdifPartition schemaLdifPartition = new LdifPartition(schemaManager);
    schemaLdifPartition.setPartitionPath(schemaPartitionDirectory.toURI());

    // The schema partition
    SchemaPartition schemaPartition = new SchemaPartition(schemaManager);
    schemaPartition.setWrappedPartition(schemaLdifPartition);
    ds.setSchemaPartition(schemaPartition);

    JdbmPartition systemPartition = new JdbmPartition(ds.getSchemaManager());
    systemPartition.setId("system");
    systemPartition.setPartitionPath(
            new File(ds.getInstanceLayout().getPartitionsDirectory(), systemPartition.getId()).toURI());
    systemPartition.setSuffixDn(new Dn(ServerDNConstants.SYSTEM_DN));
    systemPartition.setSchemaManager(ds.getSchemaManager());
    ds.setSystemPartition(systemPartition);

    ds.getChangeLog().setEnabled(false);
    ds.setDenormalizeOpAttrsEnabled(true);
    ds.addLast(new KeyDerivationInterceptor());

    // create one partition
    String orgName = conf.getProperty(ORG_NAME).toLowerCase(Locale.ENGLISH);
    String orgDomain = conf.getProperty(ORG_DOMAIN).toLowerCase(Locale.ENGLISH);

    JdbmPartition partition = new JdbmPartition(ds.getSchemaManager());
    partition.setId(orgName);
    partition.setPartitionPath(new File(ds.getInstanceLayout().getPartitionsDirectory(), orgName).toURI());
    partition.setSuffixDn(new Dn("dc=" + orgName + ",dc=" + orgDomain));
    ds.addPartition(partition);
    // indexes
    Set<Index<?, ?, String>> indexedAttributes = new HashSet<Index<?, ?, String>>();
    indexedAttributes.add(new JdbmIndex<String, Entry>("objectClass", false));
    indexedAttributes.add(new JdbmIndex<String, Entry>("dc", false));
    indexedAttributes.add(new JdbmIndex<String, Entry>("ou", false));
    partition.setIndexedAttributes(indexedAttributes);

    // And start the ds
    ds.setInstanceId(conf.getProperty(INSTANCE));
    ds.startup();
    // context entry, after ds.startup()
    Dn dn = new Dn("dc=" + orgName + ",dc=" + orgDomain);
    Entry entry = ds.newEntry(dn);
    entry.add("objectClass", "top", "domain");
    entry.add("dc", orgName);
    ds.getAdminSession().add(entry);
}
 
开发者ID:l294265421,项目名称:ZooKeeper,代码行数:65,代码来源:MiniKdc.java

示例11: init

import org.apache.directory.api.ldap.model.schema.registries.SchemaLoader; //导入依赖的package包/类
/**
 * {@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();
}
 
开发者ID:kawasima,项目名称:bouncr,代码行数:62,代码来源:InMemoryDirectoryServiceFactory.java

示例12: initSchemaPartition

import org.apache.directory.api.ldap.model.schema.registries.SchemaLoader; //导入依赖的package包/类
/**
 * initialize the schema manager and add the schema partition to diectory service
 *
 * @throws Exception if the schema LDIF files are not found on the classpath
 */
private void initSchemaPartition() throws Exception
{
    InstanceLayout instanceLayout = directoryService.getInstanceLayout();
    
    File schemaPartitionDirectory = new File( instanceLayout.getPartitionsDirectory(), "schema" );

    // Extract the schema on disk (a brand new one) and load the registries
    if ( schemaPartitionDirectory.exists() )
    {
        System.out.println( "schema partition already exists, skipping schema extraction" );
    }
    else
    {
        SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor( instanceLayout.getPartitionsDirectory() );
        extractor.extractOrCopy();
    }

    SchemaLoader loader = new LdifSchemaLoader( schemaPartitionDirectory );
    SchemaManager schemaManager = new DefaultSchemaManager( loader );

    // We have to load the schema now, otherwise we won't be able
    // to initialize the Partitions, as we won't be able to parse
    // and normalize their suffix Dn
    schemaManager.loadAllEnabled();

    List<Throwable> errors = schemaManager.getErrors();

    if ( errors.size() != 0 )
    {
        throw new Exception( I18n.err( I18n.ERR_317, Exceptions.printErrors( errors ) ) );
    }

    directoryService.setSchemaManager( schemaManager );
    
    // Init the LdifPartition with schema
    LdifPartition schemaLdifPartition = new LdifPartition( schemaManager );
    schemaLdifPartition.setPartitionPath( schemaPartitionDirectory.toURI() );

    // The schema partition
    SchemaPartition schemaPartition = new SchemaPartition( schemaManager );
    schemaPartition.setWrappedPartition( schemaLdifPartition );
    directoryService.setSchemaPartition( schemaPartition );
}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:49,代码来源:Server.java

示例13: initSchemaPartition

import org.apache.directory.api.ldap.model.schema.registries.SchemaLoader; //导入依赖的package包/类
/**
 * initialize the schema manager and add the schema partition to diectory service
 *
 * @throws Exception if the schema LDIF files are not found on the classpath
 */
private void initSchemaPartition() throws Exception
{
    InstanceLayout instanceLayout = directoryService.getInstanceLayout();
    
    File schemaPartitionDirectory = new File( instanceLayout.getPartitionsDirectory(), "schema" );

    // Extract the schema on disk (a brand new one) and load the registries
    if ( schemaPartitionDirectory.exists() )
    {
        System.out.println( "schema partition already exists, skipping schema extraction" );
    }
    else
    {
        SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor( instanceLayout.getPartitionsDirectory() );
        extractor.extractOrCopy();
    }

    SchemaLoader loader = new LdifSchemaLoader( schemaPartitionDirectory );
    SchemaManager schemaManager = new DefaultSchemaManager( loader );

    // We have to load the schema now, otherwise we won't be able
    // to initialize the Partitions, as we won't be able to parse
    // and normalize their suffix Dn
    schemaManager.loadAllEnabled();

    List<Throwable> errors = schemaManager.getErrors();

    if ( errors.size() != 0 )
    {
        throw new Exception( I18n.err( I18n.ERR_317, Exceptions.printErrors( errors ) ) );
    }

    directoryService.setSchemaManager( schemaManager );
    
    if (this.dnFactory == null) {
    	this.dnFactory = new DefaultDnFactory(schemaManager,new net.sf.ehcache.Cache(new CacheConfiguration("myvd-apacheds-dns",10000)));
    }
    
    // Init the LdifPartition with schema
    LdifPartition schemaLdifPartition = new LdifPartition( schemaManager, this.dnFactory );
    schemaLdifPartition.setPartitionPath( schemaPartitionDirectory.toURI() );

    // The schema partition
    SchemaPartition schemaPartition = new SchemaPartition( schemaManager );
    schemaPartition.setWrappedPartition( schemaLdifPartition );
    directoryService.setSchemaPartition( schemaPartition );
}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:53,代码来源:Server.java

示例14: init

import org.apache.directory.api.ldap.model.schema.registries.SchemaLoader; //导入依赖的package包/类
/**
 * {@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();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:60,代码来源:InMemoryDirectoryServiceFactory.java

示例15: init

import org.apache.directory.api.ldap.model.schema.registries.SchemaLoader; //导入依赖的package包/类
/**
 * {@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();
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:64,代码来源:InMemoryDirectoryServiceFactory.java


注:本文中的org.apache.directory.api.ldap.model.schema.registries.SchemaLoader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。