<commit_before>/*******************************************************************************
* Copyright (c) 1998, 2008 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:
* dmccann - June 4/2008 - 1.0M8 - Initial implementation
******************************************************************************/
package org.eclipse.persistence.sdo.helper.delegates;

import java.util.ArrayList;

import org.eclipse.persistence.sdo.SDOConstants;

import commonj.sdo.helper.HelperContext;
import commonj.sdo.impl.HelperProvider;

/**
 * Abstract class for SDO helper delegators.
 * 
 */
public abstract class AbstractHelperDelegator {
    // Hold the context containing all helpers so that we can preserve inter-helper relationships
    protected HelperContext aHelperContext;

    /**
     * INTERNAL:
     * This method returns the application ClassLoader.
     * 
     * The parent application ClassLoader is returned when running in a J2EE client 
     * either in a web or ejb container to match a weak reference to a particular 
     * HelperContext.
     */
    protected ClassLoader getContextClassLoader() {

        /**
         * ClassLoader levels: 
         * 	oc4j:
         *  	0 - APP.web (servlet/jsp) or APP.wrapper (ejb) or
         *  	1 - APP.root (parent for helperContext)
         *  	2 - default.root
         *  	3 - system.root
         *  	4 - oc4j.10.1.3 (remote EJB) or org.eclipse.persistence:172.16.17.32.0
         *  	5 - api:1.4.0
         *  	6 - jre.extension:0.0.0
         *  	7 - jre.bootstrap:1.5.0_07 (with various J2SE versions)
         *  WebLogic:
         *  	0 - WEB & EJB module loaders (these can be customized up to 3 layers deep)
         *  	1 - Application root loader
         *  	2 - WebLogic filtering loader
         *  	3 - Root WebLogic loader
         *  	4 - URL loader
         *  	5 - System loader
         *  	5 - Extensions loader
         *  	6 - Bootstrap loader
         */

        // Kludge for running in OC4J (from WebServices group), and WebLogic
        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
        String classLoaderName = classLoader.getClass().getName();
        // Handle oracle ClassLoader structure
        if (classLoaderName.startsWith("oracle")) {
        	// Check to see if we are running in a Servlet container or a local EJB container
            if ((classLoader.getParent() != null) //
            		&& ((classLoader.toString().indexOf(SDOConstants.CLASSLOADER_WEB_FRAGMENT) != -1) //
            		||  (classLoader.toString().indexOf(SDOConstants.CLASSLOADER_EJB_FRAGMENT) != -1))) {
                classLoader = classLoader.getParent();
            }
        // Handle WebLogic ClassLoader structure
        } else if (classLoaderName.startsWith("weblogic")) {
        	final int systemLoaderOffest = 4; // indicates the number of child loaders between system and application
        	ClassLoader systemLoader = ClassLoader.getSystemClassLoader();
        	ClassLoader currentLoader = classLoader;
        	ArrayList<ClassLoader> loaders = new ArrayList<ClassLoader>();
        	loaders.add(currentLoader);
        	while (currentLoader.getParent() != null) {
        		currentLoader = currentLoader.getParent();
            	loaders.add(currentLoader);<commit_msg>Fix for bug#244233 (SDO - WLS: XMLMARSHALEXCEPTION WHEN PASSING SDO'S IN EJB METHODS)<commit_after>/*******************************************************************************
* Copyright (c) 1998, 2008 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:
* dmccann - June 4/2008 - 1.0M8 - Initial implementation
******************************************************************************/
package org.eclipse.persistence.sdo.helper.delegates;

import java.util.ArrayList;

import org.eclipse.persistence.sdo.SDOConstants;

import commonj.sdo.helper.HelperContext;
import commonj.sdo.impl.HelperProvider;

/**
 * Abstract class for SDO helper delegators.
 * 
 */
public abstract class AbstractHelperDelegator {
    // Hold the context containing all helpers so that we can preserve inter-helper relationships
    protected HelperContext aHelperContext;

    /**
     * INTERNAL:
     * This method returns the application ClassLoader.
     * 
     * The parent application ClassLoader is returned when running in a J2EE client 
     * either in a web or ejb container to match a weak reference to a particular 
     * HelperContext.
     */
    protected ClassLoader getContextClassLoader() {

        /**
         * ClassLoader levels: 
         * 	oc4j:
         *  	0 - APP.web (servlet/jsp) or APP.wrapper (ejb) or
         *  	1 - APP.root (parent for helperContext)
         *  	2 - default.root
         *  	3 - system.root
         *  	4 - oc4j.10.1.3 (remote EJB) or org.eclipse.persistence:11.1.1.0.0
         *  	5 - api:1.4.0
         *  	6 - jre.extension:0.0.0
         *  	7 - jre.bootstrap:1.5.0_07 (with various J2SE versions)
         *  WebLogic:
         *  	0 - WEB & EJB module loaders (these can be customized up to 3 layers deep)
         *  	1 - Application root loader
         *  	2 - WebLogic filtering loader
         *  	3 - Root WebLogic loader
         *  	X - URL loader (was in 10.3 Beta, but not in 10.3)
         *  	4 - System loader
         *  	5 - Extensions loader
         *  	6 - Bootstrap loader
         */

        // Kludge for running in OC4J (from WebServices group), and WebLogic
        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
        String classLoaderName = classLoader.getClass().getName();
        // Handle oracle ClassLoader structure
        if (classLoaderName.startsWith("oracle")) {
        	// Check to see if we are running in a Servlet container or a local EJB container
            if ((classLoader.getParent() != null) //
            		&& ((classLoader.toString().indexOf(SDOConstants.CLASSLOADER_WEB_FRAGMENT) != -1) //
            		||  (classLoader.toString().indexOf(SDOConstants.CLASSLOADER_EJB_FRAGMENT) != -1))) {
                classLoader = classLoader.getParent();
            }
        // Handle WebLogic ClassLoader structure
        } else if (classLoaderName.startsWith("weblogic")) {
        	final int systemLoaderOffest = 3; // indicates the number of child loaders between system and application
        	ClassLoader systemLoader = ClassLoader.getSystemClassLoader();
        	ClassLoader currentLoader = classLoader;
        	ArrayList<ClassLoader> loaders = new ArrayList<ClassLoader>();
        	loaders.add(currentLoader);
        	while (currentLoader.getParent() != null) {
        		currentLoader = currentLoader.getParent();
            	loaders.add(currentLoader);
{'fraction_non_alphanumeric': 0.1290192926045016, 'fraction_numerical': 0.020766345123258305, 'mean_word_length': 2.616763565891473, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 2, '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': '6445924', 'n_tokens_mistral': 2141, 'n_tokens_neox': 2029, 'n_words': 606}