001/* Strategy to be able to switch class loading mechanisms, depending on the needs for a runtime environment. 002 003Copyright (c) 2015-2016 The Regents of the University of California; iSencia Belgium NV. 004All rights reserved. 005 006Permission is hereby granted, without written agreement and without 007license or royalty fees, to use, copy, modify, and distribute this 008software and its documentation for any purpose, provided that the above 009copyright notice and the following two paragraphs appear in all copies 010of this software. 011 012IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA LIABLE TO ANY PARTY 013FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 014ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF 015THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF 016SUCH DAMAGE. 017 018THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, 019INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 020MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE 021PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF 022CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, 023ENHANCEMENTS, OR MODIFICATIONS. 024 025PT_COPYRIGHT_VERSION_2 026COPYRIGHTENDKEY 027*/ 028 029package org.ptolemy.classloading; 030 031import org.ptolemy.commons.VersionSpecification; 032 033import ptolemy.kernel.CompositeEntity; 034 035/** 036 * Strategy to be able to switch class loading mechanisms, depending 037 * on the needs for a runtime environment (especially for actors and 038 * other model entities), 039 * <p> 040 * In a "plain" Java SE runtime, a default implementation would use 041 * simple <code>Class.forName()</code> (for Java classes) or local 042 * file-lookup (for actor-oriented classes) or similar. 043 * </p> 044 * <p> 045 * In an OSGi-based runtime, more advanced options can be implemented 046 * to allow dynamic actor class updates, version management etc. 047 * </p> 048 * @author ErwinDL 049 * @version $Id$ 050 * @since Ptolemy II 11.0 051 * @Pt.ProposedRating Yellow (ErwinDL) 052 * @Pt.AcceptedRating Yellow (ErwinDL) 053 */ 054public interface ClassLoadingStrategy { 055 056 /** 057 * Load a Java class. 058 * @param className The namee of the class. 059 * @param versionSpec The version 060 * @return the Class for the given name. 061 * @exception ClassNotFoundException If the class is not found. 062 */ 063 @SuppressWarnings("rawtypes") 064 Class loadJavaClass(String className, VersionSpecification versionSpec) 065 throws ClassNotFoundException; 066 067 /** 068 * Load an actor-oriented class, which is typically a .moml file. 069 * @param className The namee of the class. 070 * @param versionSpec The version 071 * @return the Class for the given name. 072 * @exception ClassNotFoundException If the class is not found. 073 */ 074 CompositeEntity loadActorOrientedClass(String className, 075 VersionSpecification versionSpec) throws ClassNotFoundException; 076}