Senior Project Design
Jini Service UIs in SORCER

Agenda


Service Oriented Architecture (SOA)


Service Object-Oriented Architecture (SOOA)


User Agent and Service UI


Bundles of Functionality


Client UI


Service UI


The ServiceUI Project


User Adapters


UI Descriptors


Class UIDescriptor

package net.jini.lookup.entry;

// imports...

public class UIDescriptor extends AbstractEntry {

    public String role;
    public String toolkit;
    public Set attributes;
    public MarshalledObject factory;

    //...
}

UI Role

package net.jini.lookup.ui;

public interface MainUI {

    String ROLE = "net.jini.lookup.ui.MainUI";
}

The Role Interface

package sorcer.arithmetic.ui;
import javax.swing.JFrame;
import net.jini.lookup.ui.MainUI;

public class ArithmeticFrameUI extends JFrame
    implements MainUI {

    //...
}

UI Attributes


AccessibleUI Attribute

package net.jini.lookup.ui.attribute;

public class AccessibleUI
    implements java.io.Serializable {

    public boolean equals(Object o) {}
    public int hashCode() {}
}

Locales Attribute

package net.jini.lookup.ui.attribute;
import java.util.*;

public class Locales
    implements java.io.Serializable {

    public boolean isLocaleSupported(Locale locale) {}
    public Locale getFirstSupportedLocale(
        List locales) {}
    public Iterator iterator() {}
    public Set getLocales() {}
    //...
}

RequiredPackages Attribute

package net.jini.lookup.ui.attribute;

import java.util.*;

public class RequiredPackages
    implements java.io.Serializable {

    public Iterator iterator() {}
    public String getVersion(String packageName) {}
    public Map getRequiredPackages() {}
}

UI Factories


UIFactoryTypes Attribute

package net.jini.lookup.ui.attribute;

import java.util.*;

public class UIFactoryTypes
    implements java.io.Serializable {

    public boolean isAssignableTo(Class classObj) {}
    public Iterator iterator() {}
    public Set getTypeNames() {}
}

UI Toolkit


UI Factory Interfaces


JFrameFactory

package net.jini.lookup.ui.factory;

import javax.swing.JFrame;

public interface JFrameFactory
    extends java.io.Serializable {

    String TOOLKIT = "javax.swing";
    String TYPE_NAME =
        "net.jini.lookup.ui.factory.JFrameFactory";

    JFrame getJFrame(Object roleObject);
}

Separating Codebases

public String role;
public String toolkit;
public Set attributes;
public MarshalledObject factory;

Marshalling the UI Factory

UIDescriptor descriptor = new UIDescriptor();

Class c = RMIClassLoader.loadClass(
    "http://sorcer.cs.ttu.edu:9000/arithmetic-ui.jar",
    "package sorcer.ui.serviceui.UIFrameFactory");

Object factory = c.newInstance();
descriptor.factory = new MarshalledObject(factory);

Unmarshalling the UI Factory

public final Object getUIFactory(final ClassLoader parentLoader)
        throws IOException, ClassNotFoundException {}
Object uiFactory = selectedDescriptor.getUIFactory(
    serviceItem.service.getClass().getClassLoader());

Generating the UI

JFrameFactory frameFactory = (JFrameFactory) uiFactory;

JFrame jff = frameFactory.getJFrame(serviceItem);

jff.setLocation(100, 100);
jff.setVisible(true);
//...

UI Talks to the Service

public class AritmeticUI extends JPanel {

    private ArithmeticRemote server;

    public AritmeticUI (Object obj) {

        this.servcer = (ArithmeticRemote)obj;

    //...

Arithmetic Service UI - Component Type

public UIDescriptor getMainUIDescriptor() {
	// Associate the service UI as a component
	UIDescriptor uiDesc = null;
		try {
			uiDesc = UIDescriptorFactory.getUIDescriptor(
				MainUI.ROLE,
				new UIComponentFactory(new URL[]{new URL(urlbase + 
					"arithmetic-ui.jar")},
				"sorcer.arithmetic.ui.ArithmeticUI"));
		} catch(Exception ex) {
			ex.printStackTrace();
		}
	return uiDesc;
}

Cataloger Service UI - Frame Type

public UIDescriptor getMainUIDescriptor() {
     	UIDescriptor uiDesc = null;
        	try {
            		uiDesc = UIDescriptorFactory.getUIDescriptor(
				MainUI.ROLE,
                    		new UIFrameFactory(new URL[] {new URL(Env.getHttpCodebase() + 
					"cataloger-ui.jar")},
                            	"sorcer.core.provider.catalog.CatalogerUI"));
        	} catch (Exception ex) {
            		ex.printStackTrace();
        	}
        return uiDesc;
}

Cataloger Service UI - Component Type as Frame via a Button

public UIDescriptor getMainUIDescriptor() {
		UIDescriptor uiDesc = null;
		try {
			uiDesc = UIDescriptorFactory.getUIDescriptor(MainUI.ROLE,
					new UIComponentFactory(new URL[] { new URL(Env
							.getWebsterUrl()
							+ "/cataloger-ui.jar") }, CatalogerUI.class
							.getName(), true));
		} catch (Exception ex) {
			ex.printStackTrace();
		}
		return uiDesc;
	}

Arithmetic UI - Configuration Entry

sorcer.core.provider.ServiceProvider {
        /* service provider genetic properties */
		name = "Smart Arithmetic";
		description = "Example of a SORCER smart proxy provider";
		interfaces = new String[] { "sorcer.arithmetic.provider.Arithmetic" };
		entries = new Entry[] { ArithmeticUI.getUIDescriptor(), 
			ServiceProvider.getUIDescriptor(), 
			new Comment("It uses sorcer.arithmetic.Arithmometer for smart proxying"), 
			new Location("3", "310", "CP TTU") };

		// smart proxy		
		smartProxy = new SmartArithmometer();
}

Conclusion