Logo
Distributed Genetic Programming Framework
print print

File org.sfc.code.CodeRepository.java

Here you can find all the information about the file org.sfc.code.CodeRepository.java. You may explore it here or download it onto your local disk.
/*
 * Copyright (c) 2006 Thomas Weise
 * 
 * E-Mail           : tweise@gmx.de
 * Creation Date    : 2006-06-14 05:10:48
 * Original Filename: org.sfc.code.CodeRepository.java
 * Version          : 1.0.1
 * Last modification: 2006-06-16
 *                by: Thomas Weise
 * 
 * License          : GNU LESSER GENERAL PUBLIC LICENSE
 *                    Version 2.1, February 1999
 *                    You should have received a copy of this license along
 *                    with this library; if not, write to the Free Software
 *                    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *                    MA 02111-1307, USA or download the license under
 *                    http://www.gnu.org/copyleft/lesser.html.
 *                    
 * Warranty         : This software is provided "as is" without any
 *                    warranty; without even the implied warranty of
 *                    merchantability or fitness for a particular purpose.
 *                    See the Gnu Lesser General Public License for more
 *                    details.
 */

 
package org.sfc.code;

import java.net.URL;
import java.util.List;

import org.sfc.collections.Collections;
import org.sfc.utils.Typesafe;

/**
 * A dynamic class loader allows you to load and unload classes and
 * archives dynamically.
 *
 * @author Thomas Weise
 */

public class CodeRepository extends SharedSession
  {
/**
 * The list with the code sessions.
 */

  private final List<SharedSession> m_sessions  ;
  
/**
 * Create a new dynamic class loader.
 */

  public  CodeRepository()
    {
    this(null);
    }
   
/**
 * Create a new dynamic class loader.
 * @param p_owner The owning class loader.
 */

  CodeRepository(final CodeRepository p_owner)
    {
    super(p_owner);
    this.m_sessions = Collections.create_list(-1);
    }
  
/**
 * Internally try to find a class.
 * @param p_name    The name of the class to be loaded.
 * @param p_except  The classloader not to query.
 * @return  The newly loaded class.
 */

  synchronized final Class<?> find_class_except(
                                  final String      p_name,
                                  final SharedSession p_except)
    {
    Class<?>                  l_c;
    SharedInternalClassLoader l_x;
    
    l_c = super.get_class(p_name);
    if(l_c != null) return l_c;
    
    for(SharedSession l_s : this.m_sessions)
      {
      if(l_s != p_except)
        {
        try
          {
          l_x = Typesafe.cast(l_s.m_loader);
          return l_x.non_rec_load_class(p_name);
          }
        catch(ClassNotFoundException l_cnfe)
          {
          //
          }
        }
      }
    
    return null;
    }
  
/**
 * Internally try to find a resource.
 * @param p_name    The name of the resource to be obtained.
 * @param p_except  The classloader not to query.
 * @return  The url to the resource, or <code>null</code> if it couldn't be
 *          found.
 */

  synchronized final URL find_resource_except(final String      p_name,
                                              final SharedSession p_except)
    {
    URL                       l_u;
    SharedInternalClassLoader l_x;
    
    l_u = super.get_resource(p_name);
    if(l_u != null) return l_u;
    
    for(SharedSession l_s : this.m_sessions)
      {
      if(l_s != p_except)
        {
        l_x = Typesafe.cast(l_s.m_loader);
        l_u = l_x.non_rec_get_res(p_name);
        if(l_u != null) return l_u;
        }
      }
    
    return null;
    }
  
/**
 * Remove a code session from the internal session list.
 * @param p_session The session to be removed.
 */

  synchronized  final void  remove_session(final SharedSession p_session)
    {
    this.m_sessions.remove(p_session);
    }

/**
 * Create a new shared code session.
 * @return The new shared code session.
 */

  public  synchronized final SharedSession create_session()
    {
    this.add_ref();
    return new SharedSession(this);
    }
  
  
/**
 * Create a new sub code repository.
 * @return The new sub code repository.
 */

  public  synchronized  final CodeRepository  create_sub_repository()
    {
    this.add_ref();
    return new CodeRepository(this);
    }
  }

File Information:

file name:CodeRepository.java
package:org.sfc.code
qualified name:org.sfc.code.CodeRepository.java
file type:Java Source File
download location:download http://dgpf.sourceforge.net/source/org/sfc/code/CodeRepository.java
size:4.250 KB (4353 B)
uploaded: 2015-07-22 04:11:11 GMT+0000
last update: 2006-06-16 05:26:43 GMT+0000
last access: 2018-01-23 15:38:22 GMT+0000

statistics online since 2006-01-02.   RSS Feed
Contact us by sending an email to tweise@gmx.de to receive further information, to report errors, or to join our project.
All content on this site (http://dgpf.sourceforge.net/) is LGPL-licensed.
http://dgpf.sourceforge.net/scripts/source/source.php last modified at 2015-07-22 04:10:53 GMT+0000 served at 2018-01-23 15:38:22 GMT+0000.
Valid CSS Valid XHTML 1.1
Valid RSS SourceForge.net Logo