Class OSGiClassLoadingStrategy

  • All Implemented Interfaces:
    ClassLoadingStrategy

    public class OSGiClassLoadingStrategy
    extends java.lang.Object
    implements ClassLoadingStrategy
    This is the preferred ClassLoadingStrategy implementation in a full-blown OSGi-based runtime. It supports dynamic actor class updates through OSGi's great dynamism based on micro-services.

    This dynamism is obtained by delegating the class loading to the registered implementations of ModelElementClassProvider and ActorOrientedClassProvider.

    Since:
    Ptolemy II 11.0
    Version:
    $Id$
    Author:
    ErwinDL
    Pt.AcceptedRating:
    Yellow (ErwinDL)
    Pt.ProposedRating:
    Yellow (ErwinDL)
    • Constructor Detail

      • OSGiClassLoadingStrategy

        public OSGiClassLoadingStrategy()
    • Method Detail

      • loadJavaClass

        public java.lang.Class<?> loadJavaClass​(java.lang.String className,
                                                VersionSpecification versionSpec)
                                         throws java.lang.ClassNotFoundException
        Load a Java class.
        Specified by:
        loadJavaClass in interface ClassLoadingStrategy
        Parameters:
        className - The namee of the class.
        versionSpec - The version
        Returns:
        the Class for the given name.
        Throws:
        java.lang.ClassNotFoundException - If the class is not found.
      • loadActorOrientedClass

        public CompositeEntity loadActorOrientedClass​(java.lang.String className,
                                                      VersionSpecification versionSpec)
                                               throws java.lang.ClassNotFoundException
        Load an actor-oriented class, which is typically a .moml file.
        Specified by:
        loadActorOrientedClass in interface ClassLoadingStrategy
        Parameters:
        className - The namee of the class.
        versionSpec - The version
        Returns:
        the Class for the given name.
        Throws:
        java.lang.ClassNotFoundException - If the class is not found.
      • addModelElementClassProvider

        public boolean addModelElementClassProvider​(ModelElementClassProvider classProvider)
        Add the given provider to the set of registered ModelElementClassProviders.
        Parameters:
        classProvider - should be not-null
        Returns:
        true if the entry was added successfully
        Throws:
        java.lang.IllegalArgumentException - when the given provider is null
      • removeModelElementClassProvider

        public boolean removeModelElementClassProvider​(ModelElementClassProvider classProvider)
        Remove the given provider from the set of registered ModelElementClassProviders.
        Parameters:
        classProvider - should be not-null
        Returns:
        true if the set of registered providers contained the given instance and it was removed successfully
        Throws:
        java.lang.IllegalArgumentException - when the given provider is null
      • clearModelElementClassProviders

        public void clearModelElementClassProviders()
        Clears the set of registered ModelElementClassProviders. Does not touch the registered ActorOrientedClassProviders.
      • addActorOrientedClassProvider

        public boolean addActorOrientedClassProvider​(ActorOrientedClassProvider classProvider)
        Adds the given provider to the set of registered ActorOrientedClassProviders.
        Parameters:
        classProvider - should be not-null
        Returns:
        true if the entry was added successfully
        Throws:
        java.lang.IllegalArgumentException - when the given provider is null
      • removeActorOrientedClassProvider

        public boolean removeActorOrientedClassProvider​(ActorOrientedClassProvider classProvider)
        Removes the given provider from the set of registered ActorOrientedClassProviders.
        Parameters:
        classProvider - should be not-null
        Returns:
        true if the set of registered providers contained the given instance and it was removed successfully
        Throws:
        java.lang.IllegalArgumentException - when the given provider is null
      • clearActorOrientedClassProviders

        public void clearActorOrientedClassProviders()
        Clear the set of registered ActorOrientedClassProviders. Does not touch the registered ModelElementClassProviders.