One time initialization for persistence unit metadata.

@param persistenceUnit
Persistence Unit/ Comma separated persistence units
347103
private void configurePersistenceUnit(String persistenceUnit, Map props)
    {
        // Invoke Persistence unit MetaData
        if (persistenceUnit == null)
        {
            throw new KunderaException("Persistence unit name should not be null");
        }
        if (logger.isInfoEnabled())
        {
            logger.info("Loading Persistence Unit MetaData For Persistence Unit(s) {}.", persistenceUnit);
        }

        String[] persistenceUnits = persistenceUnit.split(Constants.PERSISTENCE_UNIT_SEPARATOR);

        new PersistenceUnitConfiguration(props, kunderaMetadata, persistenceUnits).configure();
    }
128589
private static void initialize(final boolean _restart)
        throws CacheReloadException
    {
        if (InfinispanCache.get().exists(IndexDefinition.UUIDCACHE)) {
            if (_restart) {
                InfinispanCache.get().<UUID, IndexDefinition>getCache(IndexDefinition.UUIDCACHE).clear();
            }
        } else {
            InfinispanCache.get().<UUID, Type>getCache(IndexDefinition.UUIDCACHE).addListener(new CacheLogListener(
                            IndexDefinition.LOG));
        }
    }
1179018
private static PersistenceUnit newPersistenceUnit(final String fJndiName, final String fUnitName)
    {
        return new PersistenceUnit()
        {
            @Override
            public String name()
            {
                return fJndiName;
            }

            @Override
            public Class<? extends Annotation> annotationType()
            {
                return javax.persistence.PersistenceUnit.class;
            }

            @Override
            public String unitName()
            {
                return fUnitName;
            }

            @Override
            public String toString()
            {
                return "JPA.PersistenceUnit(name=" + fJndiName +
                       ", unitName=" + fUnitName + ")";
            }
        };
    }
893965
protected function initializeDependencies()
    {
        if ($this->persistenceManager === null) {
            $this->persistenceManager = Bootstrap::$staticObjectManager->get(PersistenceManagerInterface::class);
            $this->reflectionService = Bootstrap::$staticObjectManager->get(ReflectionService::class);
        }
    }
985359
@VisibleForTesting
  protected void initMetadata(HttpHeaders headers) throws IOException {
    checkState(
        !metadataInitialized,
        "can not initialize metadata, it already initialized for '%s'", resourceIdString);

    long sizeFromMetadata;
    String range = headers.getContentRange();
    if (range != null) {
      sizeFromMetadata = Long.parseLong(range.substring(range.lastIndexOf('/') + 1));
    } else {
      sizeFromMetadata = headers.getContentLength();
    }

    String generation = headers.getFirstHeaderStringValue("x-goog-generation");

    initMetadata(headers.getContentEncoding(), sizeFromMetadata, generation);
  }
315972
public static PersistenceUnitMetadata getPersistenceUnitMetadata(final KunderaMetadata kunderaMetadata,
            String persistenceUnit)
    {
        if (persistenceUnit != null && kunderaMetadata != null)
        {
            return kunderaMetadata.getApplicationMetadata().getPersistenceUnitMetadata(persistenceUnit);
        }
        return null;
    }
653623
public static void initialize(BeanManagerImpl deploymentManager, ServiceRegistry deploymentServices) {
        Container instance = new Container(RegistrySingletonProvider.STATIC_INSTANCE, deploymentManager, deploymentServices);
        Container.instance.set(RegistrySingletonProvider.STATIC_INSTANCE, instance);
    }
1043719
public void process() {
		try {
			Enumeration<URL> urls = Thread.currentThread().getContextClassLoader().getResources("META-INF/persistence.xml");
			XMLInputFactory factory = XMLInputFactory.newInstance();
			List<String> persistenceUnits = new ArrayList<String>();
			
			while (urls.hasMoreElements()) {
				URL url = urls.nextElement();
				XMLStreamReader reader = factory.createXMLStreamReader(url.openStream());
				
				while (reader.hasNext()) {
					if (reader.next() == XMLStreamConstants.START_ELEMENT 
							&& reader.getName().getLocalPart().equals("persistence-unit")) {
						for (int i = 0; i < reader.getAttributeCount(); i++) {
							if (reader.getAttributeLocalName(i).equals("name")) {
								persistenceUnits.add(reader.getAttributeValue(i));
								break;
							}
						}
					}
				}
			}
			
			this.persistenceUnits = persistenceUnits;
		} catch (Exception e) {
			logger.error("Failed to parse persistence.xml", e);
		}
	}
1317853
@Override
    public CompletableFuture<Void> initialize(Duration timeout) {
        Preconditions.checkState(!this.initialized.get(), "TableMetadataStore is already initialized.");

        // Invoke submitAssignment(), which will ensure that the Metadata Segment is mapped in memory and pinned.
        // If this is the first time we initialize the TableMetadataStore for this SegmentContainer, a new id will be
        // assigned to it.
        val attributes = TableAttributes.DEFAULT_VALUES
                .entrySet().stream()
                .map(e -> new AttributeUpdate(e.getKey(), AttributeUpdateType.None, e.getValue()))
                .collect(Collectors.toList());
        return submitAssignment(SegmentInfo.newSegment(this.metadataSegmentName, attributes), true, timeout)
                .thenAccept(segmentId -> {
                    this.initialized.set(true);
                    log.info("{}: Metadata Segment pinned. Name = '{}', Id = '{}'", this.metadataSegmentName, segmentId);
                });
    }
286510
private void setBatchSize(String persistenceUnit, Map<String, Object> puProperties) {
        String batch_Size = null;

        PersistenceUnitMetadata puMetadata =
            KunderaMetadataManager.getPersistenceUnitMetadata(kunderaMetadata, persistenceUnit);

        String externalBatchSize =
            puProperties != null ? (String) puProperties.get(PersistenceProperties.KUNDERA_BATCH_SIZE) : null;

        Integer intbatch = null;
        if (puMetadata.getBatchSize() > 0) {
            intbatch = new Integer(puMetadata.getBatchSize());
        }
        batch_Size =
            (String) (externalBatchSize != null ? externalBatchSize : intbatch != null ? intbatch.toString() : null);

        setBatchSize(batch_Size);
    }
598990
public static Object initialize(EntityMetadata m, Object entity, Object id)
    {
        try
        {
            if (entity == null)
            {
                entity = createNewInstance(m.getEntityClazz());
            }
            if (id != null)
            {
                PropertyAccessorHelper.setId(entity, m, id);
            }
            return entity;
        }
        catch (Exception e)
        {
            throw new PersistenceException("Error occured while instantiating entity.", e);
        }
    }
694843
private function initializeMapper() {
    // set the mapper
    $persistenceFacade = ObjectFactory::getInstance('persistenceFacade');
    if ($persistenceFacade->isKnownType($this->type)) {
      $this->mapper = $persistenceFacade->getMapper($this->type);
    }
    else {
      // initialize null mapper if not done already
      if (self::$nullMapper == null) {
        self::$nullMapper = new NullMapper();
      }
      $this->mapper = self::$nullMapper;
    }
  }
167010
@Override
    protected Client<?> instantiateClient(String persistenceUnit)
    {
        return new DSClient(this, persistenceUnit, externalProperties, kunderaMetadata, reader, timestampGenerator);
    }
860242
public void init (Properties config, ConnectionProvider conprov, RunQueue pruneQueue)
        throws PersistenceException
    {
        // save this for later
        _config = config;

        // create the user repository
        _repository = createRepository(conprov);

        // fetch the login URL from the properties
        _loginURL = config.getProperty("login_url");
        if (_loginURL == null) {
            log.warning("No login_url supplied in user manager config. Authentication won't work.");
            _loginURL = "/missing_login_url";
        }

        // look up any override to our user auth cookie
        String authCook = config.getProperty("auth_cookie.name");
        if (!StringUtil.isBlank(authCook)) {
            _userAuthCookie = authCook;
        }

        if (USERMGR_DEBUG) {
            log.info("UserManager initialized", "acook", _userAuthCookie, "login", _loginURL);
        }

        // register a cron job to prune the session table every hour
        if (pruneQueue != null) {
            _pruner = new Interval(pruneQueue) {
                @Override public void expired () {
                    try {
                        _repository.pruneSessions();
                    } catch (PersistenceException pe) {
                        log.warning("Error pruning session table.", pe);
                    }
                }
            };
            _pruner.schedule(SESSION_PRUNE_INTERVAL, true);
        }
    }
27272
private Map<String, PersistenceUnitMetadata> findPersistenceMetadatas() throws InvalidConfigurationException
    {
        String puLocation = (String) (externalPropertyMap != null
                && externalPropertyMap.get(Constants.PERSISTENCE_UNIT_LOCATIION) != null ? externalPropertyMap
                .get(Constants.PERSISTENCE_UNIT_LOCATIION) : Constants.DEFAULT_PERSISTENCE_UNIT_LOCATIION);

        Enumeration<URL> xmls = null;
        try
        {
            xmls = this.getClass().getClassLoader().getResources(puLocation);
        }
        catch (IOException ioex)
        {
            log.warn("Error while loading persistence.xml, Caused by: {}.", ioex);
        }

        if (xmls == null || !xmls.hasMoreElements())
        {
            log.error("Could not find any META-INF/persistence.xml file in the classpath");
            throw new InvalidConfigurationException("Could not find any META-INF/persistence.xml file in the classpath");
        }

        Set<String> persistenceUnitNames = new HashSet<String>();
        Map<String, PersistenceUnitMetadata> persistenceUnitMap = new HashMap<String, PersistenceUnitMetadata>();
        while (xmls.hasMoreElements())
        {
            URL url = xmls.nextElement();

            log.trace("Analysing persistence.xml: " + url);
            List<PersistenceUnitMetadata> metadataFiles = PersistenceXMLLoader.findPersistenceUnits(url, persistenceUnits, 
                    PersistenceUnitTransactionType.RESOURCE_LOCAL);

            // Pick only those that have Kundera Provider
            for (PersistenceUnitMetadata metadata : metadataFiles)
            {
                // check for unique names
                if (persistenceUnitNames.contains(metadata.getPersistenceUnitName()))
                {
                    if (log.isWarnEnabled())
                    {
                        log.warn("Duplicate persistence-units for name: " + metadata.getPersistenceUnitName()
                                + ". verify your persistence.xml file");
                    }
                }

                // check for provider
                if (metadata.getPersistenceProviderClassName() == null
                        || PROVIDER_IMPLEMENTATION_NAME.equalsIgnoreCase(metadata.getPersistenceProviderClassName()))
                {
                    persistenceUnitMap.put(metadata.getPersistenceUnitName(), metadata);
                }

                // add to check for duplicate persistence unit.
                persistenceUnitNames.add(metadata.getPersistenceUnitName());
            }
        }
        return persistenceUnitMap;
    }
1283334
@Override
    public void initialize(Map<String, Object> puProperties)
    {
        reader = new KuduDBEntityReader(kunderaMetadata);
        setExternalProperties(puProperties);
        initializePropertyReader();
        PersistenceUnitMetadata pum = kunderaMetadata.getApplicationMetadata()
                .getPersistenceUnitMetadata(getPersistenceUnit());

        Properties pumProps = pum.getProperties();

        if (puProperties != null)
        {
            pumProps.putAll(puProperties);
        }

        String kuduMasterHost = (String) pumProps.getProperty("kundera.nodes");

        String kuduMasterPort = (String) pumProps.getProperty("kundera.port");

        if (kuduMasterHost == null || kuduMasterPort == null)
        {
            throw new KunderaException("Hostname/IP or Port is null.");
        }

        kuduClient = new KuduClient.KuduClientBuilder(kuduMasterHost + ":" + kuduMasterPort).build();
    }
616488
public void init(ServletContext context) {
        if (profiles != null) {
            for (IDiagramProfile profile : profiles) {
                profile.init(context);
                _registry.put(profile.getName(),
                              profile);
            }
        }
    }