Presentation is loading. Please wait.

Presentation is loading. Please wait.

Copyright © 2001 Qusay H. Mahmoud Case Study A Global Compute Engine Here we will discuss some implementation details: – Class Loaders – Compute Engine.

Similar presentations


Presentation on theme: "Copyright © 2001 Qusay H. Mahmoud Case Study A Global Compute Engine Here we will discuss some implementation details: – Class Loaders – Compute Engine."— Presentation transcript:

1 Copyright © 2001 Qusay H. Mahmoud Case Study A Global Compute Engine Here we will discuss some implementation details: – Class Loaders – Compute Engine – Security Managers Refer to Chapter 6 of the book “Distributed Programming with Java” for more details

2 Copyright © 2001 Qusay H. Mahmoud Class Loaders Java is a dynamic language capable of loading classes as they are needed (locally or from a remote machine) Classes are introduced in the Java environment when they are referenced by name in a running class The first class that gets to run is the one with main() Future attempt at loading classes is carried out by the class loader

3 Copyright © 2001 Qusay H. Mahmoud Class Loaders java.lang.ClassLoader is an abstract class It provides a number of methods, e.g.: – defineClass: converts an array of bytes to an instance of Class (final) – findSystemClass: find the system class with the specified name (final) – loadClass: resolve the specified name to a class or load a class (abstract) – Refer to docs for exact method signatures….

4 Copyright © 2001 Qusay H. Mahmoud Class Loaders When working with class loaders: – loadClass(String, boolean) must be defined by a subclass of ClassLoader. If the flag is set to true, then the method should call the resolveClass – defineClass converts an byte b[] to an instance of Class. It must be resolved before used to determine if any referenced classes are to be defined – The system class loaded by the findSystemClass method is from the local file system – To avoid loading the same class more than once, use a hashtable

5 Copyright © 2001 Qusay H. Mahmoud Building a network class loader public class NetClassLoader extends ClassLoader { } Provide impl’n for loadClass(String, boolean) – Verify the class name – Check if the class request has already been loaded – Check if class is a system class – Define the class for the JVM – Resolve the class – Return the class to the caller

6 Copyright © 2001 Qusay H. Mahmoud Network Class Loader Hidden issue: inability to cast an object created from a loaded class into its original class. The object to be returned needs to be casted. Example: NetClassLoader ncl = new NetClassLoader(); Object o; Class c; c = ncl.loadClass(“Hello”); o = c.newInstance(); ((Hello)o).someMethod(); // this is a problem

7 Copyright © 2001 Qusay H. Mahmoud Network Class Loader Solutions: – Have the loaded class extends an abstract class – Have the loaded class implements an interface public interface Compute { void run(); } If a class is to be loaded by the NetClassLoader, it must implement the Compute interface – Use Reflections APIs (explore this)

8 Copyright © 2001 Qusay H. Mahmoud Network Class Loader Example: – NetClassLoader.java – Compute.java – Fetch.java – HelloTest.java For the latest info on network class loaders, see: king/classloaders/ king/classloaders/

9 Copyright © 2001 Qusay H. Mahmoud Compute Engine Responsible for loading a remote client class It receives the URL of the class to be loaded then it uses the network class loader to load the class and all its associated classes Collects the output and sends it back to the client Security: how to protect the compute engine’s host file system from malicious client’s code??


Download ppt "Copyright © 2001 Qusay H. Mahmoud Case Study A Global Compute Engine Here we will discuss some implementation details: – Class Loaders – Compute Engine."

Similar presentations


Ads by Google