Creates and returns a new native KeyFactory. If a namespace was specified using {@link Tenant},
the returned KeyFactory will have the specified namespace.

@return a {@link KeyFactory}
346902
KeyFactory newNativeKeyFactory() {
    KeyFactory keyFactory = datastore.newKeyFactory();
    String namespace = Tenant.getNamespace();
    if (namespace != null) {
      keyFactory.setNamespace(namespace);
    }
    return keyFactory;
  }
86341
public static NamespaceContext createNamespaceContext() {
    return new NamespaceContext() {
      private HashMap<String, String> namespaces = new HashMap<String, String>(1);

      {
        namespaces.put(DEFAULT_NAMESPACE_PREFIX, DEFAULT_NAMESPACE_URI);
      }

      public String getNamespaceURI(String prefix) {
        if (namespaces.isEmpty() || StringUtil.isNullOrEmpty(prefix) || !namespaces.containsKey(prefix))
          return StringUtil.empty;
        return namespaces.get(prefix);
      }

      public Iterator getPrefixes(String namespaceURI) {
        return namespaces.values().iterator();
      }

      public String getPrefix(String namespaceURI) {
        if (StringUtil.isNullOrEmpty(namespaceURI))
          return StringUtil.empty;

        for(Entry<String, String> entry : namespaces.entrySet())
          if (namespaceURI.equals(entry.getValue()))
            return entry.getKey();

        return StringUtil.empty;
      }
    };
  }
140581
private XMLInputFactory factory() {
        XMLInputFactory factory = XMLInputFactory.newInstance();
        factory.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, false);
        factory.setProperty(XMLInputFactory.SUPPORT_DTD, false);
        return factory;
    }
1200146
public <S extends io.sarl.lang.core.Space> S createSpace(SpaceID spaceID,
			Class<? extends SpaceSpecification<S>> spec, Object... creationParams) {
		synchronized (getSpaceRepositoryMutex()) {
			if (!this.spaces.containsKey(spaceID)) {
				return createSpaceInstance(spec, spaceID, true, creationParams);
			}
		}
		return null;
	}
324192
static public ContentHandleFactory newFactory() {
    return new ContentHandleFactory() {
      @Override
      public Class<?>[] getHandledClasses() {
        return new Class<?>[]{ Document.class };
      }
      @Override
      public boolean isHandled(Class<?> type) {
        return Document.class.isAssignableFrom(type);
      }
      @Override
      public <C> ContentHandle<C> newHandle(Class<C> type) {
        @SuppressWarnings("unchecked")
        ContentHandle<C> handle = isHandled(type) ?
          (ContentHandle<C>) new DOM4JHandle() : null;
        return handle;
      }
    };
  }
921613
public Configuration create() {
        Configuration configuration;
        try {
            InputStream stream = null;
            try {
                // Search the user configuration
                stream = Utils.openResourceStream(DEFAULT_USER_CONFIGURATION_FILE);

                // If user configuration not found then use default
                if (stream == null) {
                    stream = Utils.openResourceStream(DEFAULT_CONFIGURATION_FILE);
                }

                if (stream != null) {
                    configuration = create(stream);
                } else {
                    throw new TextProcessorFactoryException("Can't find or open default configuration resource.");
                }
            } finally {
                if (stream != null) {
                    stream.close();
                }
            }

            Properties properties = new Properties();

            // Load properties from .property file
            InputStream propertiesStream = null;
            try {
                propertiesStream = Utils.openResourceStream(DEFAULT_PROPERTIES_FILE);
                if (propertiesStream != null) {
                    properties.load(propertiesStream);
                }
            } finally {
                if (propertiesStream != null) {
                    propertiesStream.close();
                }
            }

            // Load properties from xml file
            InputStream xmlPropertiesStream = null;
            try {
                xmlPropertiesStream = Utils.openResourceStream(DEFAULT_PROPERTIES_XML_FILE);
                if (xmlPropertiesStream != null) {
                    properties.loadFromXML(xmlPropertiesStream);
                }
            } finally {
                if (xmlPropertiesStream != null) {
                    xmlPropertiesStream.close();
                }
            }

            if (!properties.isEmpty()) {
                Map<String, CharSequence> params = new HashMap<String, CharSequence>();
                params.putAll(configuration.getParams());
                for (Map.Entry<Object, Object> entry : properties.entrySet()) {
                    Object key = entry.getKey();
                    if (key != null) {
                        params.put(key.toString(), entry.getValue().toString());
                    }
                }
                configuration.setParams(params);
            }
        } catch (IOException e) {
            throw new TextProcessorFactoryException(e);
        }

        return configuration;
    }
319785
public void createKeyspace(String keyspace) {
        Map<String, String> replicationSimpleOneExtra = new HashMap<>();
        replicationSimpleOneExtra.put("'class'", "'SimpleStrategy'");
        replicationSimpleOneExtra.put("'replication_factor'", "1");
        String query = this.cassandraqueryUtils.createKeyspaceQuery(true,
                keyspace, this.cassandraqueryUtils
                        .createKeyspaceReplication(replicationSimpleOneExtra),
                "");
        LOGGER.debug(query);
        executeQuery(query);
    }
692463
protected ServerCnxnFactory createServerFactory() {
        try {
            ServerCnxnFactory serverFactory = new NIOServerCnxnFactory();
            serverFactory.configure(new InetSocketAddress(zookeeperPort), 5000);
            return serverFactory;
        } catch (IOException e) {
            throw new CitrusRuntimeException("Failed to create default zookeeper server factory", e);
        }
    }
1360401
@Override
    public void createNamespace() {
        // Use a temporary, no-keyspace session
        try (DBConn dbConn = createAndConnectConn(null)) {
            synchronized (m_schemaLock) {
                if (!m_schemaMgr.keyspaceExists(dbConn, m_keyspace)) {
                    m_schemaMgr.createKeyspace(dbConn, m_keyspace);
                }
            }
        }
    }
75529
public KeyStore newInstance() throws KeyStoreException, NoSuchProviderException, NoSuchAlgorithmException, CertificateException, IOException {
        if (data == null) {
            throw new IllegalStateException("data property is not set.");
        }

        KeyStore ks;
        if (provider == null) {
            ks = KeyStore.getInstance(type);
        } else {
            ks = KeyStore.getInstance(type, provider);
        }

        InputStream is = new ByteArrayInputStream(data);
        try {
            ks.load(is, password);
        } finally {
            try {
                is.close();
            } catch (IOException ignored) {
                // Do nothing
            }
        }

        return ks;
    }
530576
@SuppressWarnings("unchecked")
    public SearchKeyFactory<S> getSearchKeyFactory(OrderedProperty<S>[] properties) {
        // This KeyFactory makes arrays work as hashtable keys.
        Object key = KeyFactory.createKey(new Object[] {mCodecKey, properties});

        synchronized (cCodecSearchKeyFactories) {
            SearchKeyFactory<S> factory = (SearchKeyFactory<S>) cCodecSearchKeyFactories.get(key);
            if (factory == null) {
                factory = generateSearchKeyFactory(properties);
                cCodecSearchKeyFactories.put(key, factory);
            }
            return factory;
        }
    }
543832
private ComponentManager createComponentManager(String namespace)
    {
        String prefix = NamespaceUtils.getPrefix(namespace);

        ComponentManagerFactory componentManagerFactory;
        try {
            componentManagerFactory = this.rootComponentManager.getInstance(ComponentManagerFactory.class, prefix);
        } catch (ComponentLookupException e) {
            componentManagerFactory = this.defaultComponentManagerFactory;
        }

        return componentManagerFactory.createComponentManager(namespace, this.rootComponentManager);
    }
918737
public static Keyspace createKeyspace(String keyspace, Cluster cluster,
      ConsistencyLevelPolicy consistencyLevelPolicy,
      FailoverPolicy failoverPolicy) {
    return new ExecutingKeyspace(keyspace, cluster.getConnectionManager(),
        consistencyLevelPolicy, failoverPolicy, cluster.getCredentials());
  }
502155
public static Keyspace createKeyspace(String keyspace, Cluster cluster,
      ConsistencyLevelPolicy consistencyLevelPolicy) {
    return createKeyspace(keyspace, cluster, consistencyLevelPolicy,
        FailoverPolicy.ON_FAIL_TRY_ALL_AVAILABLE);
  }
1299514
@Override
  public ConnectionFactory build()
  {
    return new DefaultConnectionFactory()
    {
      @Override
      public NodeLocator createLocator(List<MemcachedNode> nodes)
      {
        switch (locator) {
          case ARRAY_MOD:
            return new ArrayModNodeLocator(nodes, getHashAlg());
          case CONSISTENT:
            return new KetamaNodeLocator(
                nodes,
                getHashAlg(),
                new DefaultKetamaNodeLocatorConfiguration()
                {
                  @Override
                  public int getNodeRepetitions()
                  {
                    return repetitions;
                  }
                }
            );
          default:
            throw new IllegalStateException("Unhandled locator type: " + locator);
        }
      }

      @Override
      public BlockingQueue<Operation> createOperationQueue()
      {
        return opQueueFactory == null ? super.createOperationQueue() : opQueueFactory.create();
      }

      @Override
      public BlockingQueue<Operation> createReadOperationQueue()
      {
        return readQueueFactory == null ? super.createReadOperationQueue() : readQueueFactory.create();
      }

      @Override
      public BlockingQueue<Operation> createWriteOperationQueue()
      {
        return writeQueueFactory == null ? super.createReadOperationQueue() : writeQueueFactory.create();
      }

      @Override
      public Transcoder<Object> getDefaultTranscoder()
      {
        return transcoder == null ? super.getDefaultTranscoder() : transcoder;
      }

      @Override
      public FailureMode getFailureMode()
      {
        return failureMode == null ? super.getFailureMode() : failureMode;
      }

      @Override
      public HashAlgorithm getHashAlg()
      {
        return hashAlg == null ? super.getHashAlg() : hashAlg;
      }

      @Override
      public Collection<ConnectionObserver> getInitialObservers()
      {
        return initialObservers;
      }

      @Override
      public OperationFactory getOperationFactory()
      {
        return opFact == null ? super.getOperationFactory() : opFact;
      }

      @Override
      public long getOperationTimeout()
      {
        return opTimeout == -1 ? super.getOperationTimeout() : opTimeout;
      }

      @Override
      public int getReadBufSize()
      {
        return readBufSize == -1 ? super.getReadBufSize() : readBufSize;
      }

      @Override
      public boolean isDaemon()
      {
        return isDaemon;
      }

      @Override
      public boolean shouldOptimize()
      {
        return shouldOptimize;
      }

      @Override
      public boolean useNagleAlgorithm()
      {
        return useNagle;
      }

      @Override
      public long getMaxReconnectDelay()
      {
        return maxReconnectDelay;
      }

      @Override
      public AuthDescriptor getAuthDescriptor()
      {
        return authDescriptor;
      }

      @Override
      public long getOpQueueMaxBlockTime()
      {
        return opQueueMaxBlockTime > -1 ? opQueueMaxBlockTime : super.getOpQueueMaxBlockTime();
      }

      @Override
      public int getTimeoutExceptionThreshold()
      {
        return timeoutExceptionThreshold;
      }

      @Override
      public MetricType enableMetrics()
      {
        return metricType == null ? super.enableMetrics() : metricType;
      }

      @Override
      public MetricCollector getMetricCollector()
      {
        return collector == null ? super.getMetricCollector() : collector;
      }

      @Override
      public ExecutorService getListenerExecutorService()
      {
        return executorService == null ? super.getListenerExecutorService() : executorService;
      }

      @Override
      public boolean isDefaultExecutorService()
      {
        return executorService == null;
      }

      @Override
      public long getAuthWaitTime()
      {
        return authWaitTime;
      }
    };
  }
468036
@Override
    public Namespace createNamespace(Namespace namespace) {
        requireNotDisposed();
        requireArgument(namespace != null, "null namespace cannot be created.");
        
        if (!_validateQualifier(namespace.getQualifier())) {
            throw new SystemException(new IllegalArgumentException(
                    "Illegal characters found while generating namespace. Cannot generate a namespace with this qualifier."));
        }
        
        if (Namespace.findByQualifier(emf.get(), namespace.getQualifier()) != null) {
            throw new SystemException(new IllegalArgumentException("Namespace already exists. Please try a different namespace."));
        }
        
        namespace = updateNamespace(namespace);
        _logger.debug("Generated namespace {}.", namespace);
        return namespace;
    }
1139339
static public ContentHandleFactory newFactory() {
    return new ContentHandleFactory() {
      @Override
      public Class<?>[] getHandledClasses() {
        return new Class<?>[]{ XMLEventReader.class };
      }
      @Override
      public boolean isHandled(Class<?> type) {
        return XMLEventReader.class.isAssignableFrom(type);
      }
      @Override
      public <C> ContentHandle<C> newHandle(Class<C> type) {
        @SuppressWarnings("unchecked")
        ContentHandle<C> handle = isHandled(type) ?
                                  (ContentHandle<C>) new XMLEventReaderHandle() : null;
        return handle;
      }
    };
  }