<commit_before>/*******************************************************************************
 * Copyright (c) 1998, 2009 Oracle. All rights reserved.
 * This program and the accompanying materials are made available under the 
 * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 
 * which accompanies this distribution. 
 * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
 * and the Eclipse Distribution License is available at 
 * http://www.eclipse.org/org/documents/edl-v10.php.
 *
 * Contributors:
 *     Oracle - initial API and implementation from Oracle TopLink
 *     tware - 1.0RC1 - refactor for OSGi
 ******************************************************************************/  
package org.eclipse.persistence.internal.jpa.deployment;

import java.util.*;
import java.net.URL;
import java.net.URLClassLoader;
import java.net.URLDecoder;
import java.io.UnsupportedEncodingException;
import java.lang.instrument.*;
import java.security.ProtectionDomain;

import org.eclipse.persistence.logging.AbstractSessionLog;
import org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider;
import org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl;
import org.eclipse.persistence.config.PersistenceUnitProperties;
import org.eclipse.persistence.exceptions.*;
import org.eclipse.persistence.logging.SessionLog;

import javax.persistence.PersistenceException;
import javax.persistence.spi.ClassTransformer;
import javax.persistence.spi.PersistenceUnitInfo;

/**
 * INTERNAL:
 *
 * JavaSECMPInitializer is used to bootstrap the deployment of EntityBeans in EJB 3.0
 * when deployed in a non-managed setting
 *
 * It is called internally by our Provider
 *
 * @see org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider
 */
public class JavaSECMPInitializer extends JPAInitializer {

    // Used when byte code enhancing
    public static Instrumentation globalInstrumentation;
    // Adding this flag because globalInstrumentation could be set to null after weaving is done.
    protected static boolean usesAgent;
    // Indicates whether has been initialized - that could be done only once.
    protected static boolean isInitialized;
    // Indicates whether puInfos of the initial emSetupImpls (EntityManagerFactoryProvider.initialEmSetupImpls)
    // should be cached forever in EntityManagerFactoryProvider.initialPuInfos.
    // The flag is only relevant in usesAgent case - puInfos never kept otherwise.
    // In useAgent case both cases settings could work: 
    //   true is obviously more efficient (puInfo is read only once);
    //   false will work the same way as in non agent case (app. server case) - good for testing.
    public static boolean keepInitialPuInfos = true;

    /**
     * Get the singleton entityContainer.
     */
    public static synchronized JavaSECMPInitializer getJavaSECMPInitializer() {
        if(!isInitialized) {
            initializeTopLinkLoggingFile();  
            JavaSECMPInitializer initializer = new JavaSECMPInitializer();
            initializer.initialize(new HashMap());
            return initializer;
        }  else {
            return new JavaSECMPInitializer();
        }
    }

    public static synchronized JavaSECMPInitializer getJavaSECMPInitializer(ClassLoader loader) {
        if(!isInitialized) {
            initializeTopLinkLoggingFile();        
        }
        return new JavaSECMPInitializer(loader);
    }

    /**
     * User should not instantiate JavaSECMPInitializer.
     */
    protected JavaSECMPInitializer() {<commit_msg>Bug 293354 - Generating session names from connection properties and SE deployment changes  Correction 2 for standalone SE case (globalInstrumentation != null) Initialization never happened if postponed until main  (-javaagent:eclipselink.jar=main)<commit_after>/*******************************************************************************
 * Copyright (c) 1998, 2009 Oracle. All rights reserved.
 * This program and the accompanying materials are made available under the 
 * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 
 * which accompanies this distribution. 
 * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
 * and the Eclipse Distribution License is available at 
 * http://www.eclipse.org/org/documents/edl-v10.php.
 *
 * Contributors:
 *     Oracle - initial API and implementation from Oracle TopLink
 *     tware - 1.0RC1 - refactor for OSGi
 ******************************************************************************/  
package org.eclipse.persistence.internal.jpa.deployment;

import java.util.*;
import java.net.URL;
import java.net.URLClassLoader;
import java.net.URLDecoder;
import java.io.UnsupportedEncodingException;
import java.lang.instrument.*;
import java.security.ProtectionDomain;

import org.eclipse.persistence.logging.AbstractSessionLog;
import org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider;
import org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl;
import org.eclipse.persistence.config.PersistenceUnitProperties;
import org.eclipse.persistence.exceptions.*;
import org.eclipse.persistence.logging.SessionLog;

import javax.persistence.PersistenceException;
import javax.persistence.spi.ClassTransformer;
import javax.persistence.spi.PersistenceUnitInfo;

/**
 * INTERNAL:
 *
 * JavaSECMPInitializer is used to bootstrap the deployment of EntityBeans in EJB 3.0
 * when deployed in a non-managed setting
 *
 * It is called internally by our Provider
 *
 * @see org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider
 */
public class JavaSECMPInitializer extends JPAInitializer {

    // Used when byte code enhancing
    public static Instrumentation globalInstrumentation;
    // Adding this flag because globalInstrumentation could be set to null after weaving is done.
    protected static boolean usesAgent;
    // Indicates whether has been initialized - that could be done only once.
    protected static boolean isInitialized;
    // Indicates whether puInfos of the initial emSetupImpls (EntityManagerFactoryProvider.initialEmSetupImpls)
    // should be cached forever in EntityManagerFactoryProvider.initialPuInfos.
    // The flag is only relevant in usesAgent case - puInfos never kept otherwise.
    // In useAgent case both cases settings could work: 
    //   true is obviously more efficient (puInfo is read only once);
    //   false will work the same way as in non agent case (app. server case) - good for testing.
    public static boolean keepInitialPuInfos = true;

    /**
     * Get the singleton entityContainer.
     */
    public static synchronized JavaSECMPInitializer getJavaSECMPInitializer() {
        if(!isInitialized) {
            initializeTopLinkLoggingFile();  
            JavaSECMPInitializer initializer = new JavaSECMPInitializer();
            initializer.initialize(new HashMap());
            return initializer;
        }  else {
            return new JavaSECMPInitializer();
        }
    }

    public static synchronized JavaSECMPInitializer getJavaSECMPInitializer(ClassLoader loader) {
        if(!isInitialized) {
            initializeTopLinkLoggingFile();  
            JavaSECMPInitializer initializer = new JavaSECMPInitializer(loader);
            initializer.initialize(new HashMap());
            return initializer;
        }  else {
            return new JavaSECMPInitializer(loader);
        }
    }

    /**
     * User should not instantiate JavaSECMPInitializer.
     */
    protected JavaSECMPInitializer() {
{'fraction_non_alphanumeric': 0.10940976312001047, 'fraction_numerical': 0.006412773197225494, 'mean_word_length': 3.8153749212350347, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2376864', 'n_tokens_mistral': 1934, 'n_tokens_neox': 1857, 'n_words': 604}