Package org.ptolemy.classloading.osgi
Class OSGiClassLoadingStrategy
- java.lang.Object
-
- org.ptolemy.classloading.osgi.OSGiClassLoadingStrategy
-
- All Implemented Interfaces:
ClassLoadingStrategy
public class OSGiClassLoadingStrategy extends java.lang.Object implements ClassLoadingStrategy
This is the preferredClassLoadingStrategy
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
andActorOrientedClassProvider
.- Since:
- Ptolemy II 11.0
- Version:
- $Id$
- Author:
- ErwinDL
- Pt.AcceptedRating:
- Yellow (ErwinDL)
- Pt.ProposedRating:
- Yellow (ErwinDL)
-
-
Constructor Summary
Constructors Constructor Description OSGiClassLoadingStrategy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addActorOrientedClassProvider(ActorOrientedClassProvider classProvider)
Adds the given provider to the set of registered ActorOrientedClassProviders.boolean
addModelElementClassProvider(ModelElementClassProvider classProvider)
Add the given provider to the set of registered ModelElementClassProviders.void
clearActorOrientedClassProviders()
Clear the set of registered ActorOrientedClassProviders.void
clearModelElementClassProviders()
Clears the set of registered ModelElementClassProviders.CompositeEntity
loadActorOrientedClass(java.lang.String className, VersionSpecification versionSpec)
Load an actor-oriented class, which is typically a .moml file.java.lang.Class<?>
loadJavaClass(java.lang.String className, VersionSpecification versionSpec)
Load a Java class.boolean
removeActorOrientedClassProvider(ActorOrientedClassProvider classProvider)
Removes the given provider from the set of registered ActorOrientedClassProviders.boolean
removeModelElementClassProvider(ModelElementClassProvider classProvider)
Remove the given provider from the set of registered ModelElementClassProviders.
-
-
-
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 interfaceClassLoadingStrategy
- 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 interfaceClassLoadingStrategy
- 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.
-
-