The Artima Developer Community
Sponsored Link

Jini Seminar by Bill Venners
Jini Service UIs
Lecture Handout

Agenda


Service UI Participants

  • Ken Arnold
  • Michel Burger
  • Jeffrey Carpenter
  • Alvin Chin
  • James Cotsios
  • Bill Day
  • Cees de Groot
  • Haruo Fukuda
  • Keith Goethert
  • Brian Jeltima
  • Bruce Jackson
  • Dave Judd
  • Alan Kaminsky
  • James Kempf
  • Peter Korn
  • Adam Levin-Delson
  • Gregory M. Lewis
  • Sing Li
  • Michael Los
  • John McClain
  • Bruno Melloni
  • Mike Morris
  • Uttam Narsu
  • Jan Newmarch
  • Wiven Nettles
  • Olufisayo Omojokun
  • Hugo Jose Pinto
  • Sung Lu Ruo
  • Harry Saddler
  • Jason Sando
  • Michael Sargent
  • Bob Scheifler
  • Jerome Scheuring
  • Maurice Schoenmakers
  • James Staten
  • Keith B. Thompson
  • Jimmy Torres
  • Bill Venners
  • Jim Waldo
  • Willie Walker
  • Greg Wonderly
  • Phong Yau

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 com.artima.calcserv;
import net.jini.lookup.ui.MainUI;

public class CalcJFrame 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 descrip = new UIDescriptor();

Class c = RMIClassLoader.loadClass(
    "http://minovia:8086/calcjframe.jar",
    "com.artima.calculator.ui.CalcJFrameFactory");

Object factory = c.newInstance();
descrip.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 swingJFrameFactory = (JFrameFactory) uiFactory;

JFrame jf = swingJFrameFactory.getJFrame(serviceItem);

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

UI Talks to the Service

public class CalcPanel extends Panel {

    private CalculatorService calcService;

    public CalcPanel(CalculatorService cs) {

        this.calcService = cs;

    //...

Conclusion


Sponsored Links

Copyright © 1996-2014 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us