Friday, August 31, 2007

EmdeddedSCADomain : booting your SCA Domain

Today we'll see the class EmbeddedSCADomain

The first thing I inizialize it:

68 public EmbeddedSCADomain(ClassLoader runtimeClassLoader,
69 String domainURI) {
70 this.uri = domainURI;
71
72 // Create a runtime
73 runtime = new ReallySmallRuntime(runtimeClassLoader);
74 }

I set Domain's URI and I create a new SCA Runtime, providing to it a classloader in order to load all needed artifacts.
Now a client code should start the domain, i.e:

EmbeddedSCADomain myDomain = new EmbeddedSCADomain(myClassloader,"http://www.di.unipi.it");
myDomain.start();

What the start() does?

public void start() throws ActivationException {
77
78 // Start the runtime
79 runtime.start();
80
81 // Create an in-memory domain level composite
82 AssemblyFactory assemblyFactory = runtime.getAssemblyFactory();
83 domainComposite = assemblyFactory.createComposite();
84 domainComposite.setName(new QName(Constants.SCA10_NS, "domain"));
85 domainComposite.setURI(uri);
86
87 getCompositeActivator().setDomainComposite(domainComposite);
88
89 }

It does some simple things:

  1. Starts the SCA runtime.
  2. Create an empty composition, set its namespace and the domain URI.
  3. Get from the runtime the activator and set a composite for this domain.

The setDomainComposite in the file CompositeActivatorImpl;

public void setDomainComposite(Composite domainComposite) {
699 this.domainComposite = domainComposite;
700 }

What happens inside ReallySmallRuntime?

The first thing , that Tuscany does, is to create a DefaultExtensionPointRegistry which holds a Map for each extension to the Tuscany Runtime. Then Tuscany loads the core extensions with the method getExtensionPoint. If the extension is not present in the core, it gets a Java Classloader, then it gets all classes for that extension, and create their objects. The following extension are loaded as default:
* WorkerScheduler
* InterfaceContractMapper
* Model Registry Factory
* Context Registry Factory
* Proxy Factory
* Assembly Factory
* SCA Binding Factory
Then the runtime has the task of initializing the following core parts, loading as extensions:
* Make a SCA definition processor
* Make a Contribution Service
* Make a Scope Registry
* Make a Composite Builder
* Make a Composite Activator
Then it has to load all Class file, instancing their objects by reflection and adding to a listo of ModuleActivator.

That's all for now! Next time i'll continue...

No comments: