3D PLM Enterprise Architecture

Webtop

Sending a PortalURL

Sending a PortalURL to the Portal
Use Case

Abstract

This article shows how to create and send a PortalURL


What You Will Learn With This Use Case

This use case is intended to show how to create and send PortalURL to the Portal.

[Top]

The PublishBillCommand Use Case

The PublishBillCommand is a use case of the CAAJApplicationFrame.edu framework that illustrates the creation of a PortalURL and the sending to the Portal applications. This use case use the Command and PortalURL classes from the PortalBase framework.

[Top]

What Does PublishBillCommand Do

The PublishBillCommand use case creates a file which contains the bill of the food store, and send the URL bill file in order to visualize it in the embedded browser (the default text file viewer in this use case).

 

The Command creates the bill file and writes it on the temporary directory of the local disk. It creates a PortalURL on the file (as "file://c:\tmp\StoreFoodBill.txt"), and sends a PortalURLEvent (which encapsulates the created PortalURL) to the Portal desktop. The Portal desktop receives this event and searches in the PortalRegistry (See how to use the Portal Registry [3]) the bean able to receive this type of file document. When the viewer bean is found, the Portal desktop gives to it the PortalURL to the file document.

The PortalURL is the most important file access exchange between Portal applications (See how to receive PortalURLs [2]). PortalURL contains the access file of the document, and parameters (in the query part) interpreted by the Portal or by the url receiver application.

[Top]

How to Launch PublishBillCommand

To launch the PublishBillCommand, you will need to set up the build time environment, then compile PublishBillCommand and FoodStoreCATlet along with their prerequisites, set up the run time environment, and then execute the use case [1].

Specify the FilePrefix CAAGw0 in the Portal launching command, logon to the Portal and do the following steps:

Publish Bill
FoodStorePublishBill.jpg
Display published bill
FoodStorePublishedBill.jpg

[Top]

Where to Find the PublishBillCommand Code

The PublishBillCommand use case is one part of the Food Store use case. The PublishBillCommand class is located in the CAAGw0FoodStore.mj module of the CAAJApplicationFrame.edu framework:

Windows InstallRootDirectory\CAAJApplicationFrame.edu\CAAGw0FoodStore.mj\
Unix InstallRootDirectory/CAAJApplicationFrame.edu/CAAGw0FoodStore.mj/

where InstallRootDirectory is the directory where the CAA CD-ROM is installed.

Top]

Step-by-Step

To create a PortalURL from a bean and to send it to the Portal, there are 3 steps:

# Step Where
1 Declare the bean as a PortalURL publisher to the Hookup PublishBillCommand.java
2 Declare the PortalURLEvent as a published event of the bean PublishBillCommandBeanInfo.java
3 Create the PortalURL and send it PublishBillCommand.java

[Top]

Declaring the bean as a PortalURL Publisher

The PublishBillCommand class declares itself to the Hookup as an event publisher, as follows:

package com.dassault_systemes.japplicationframe.caa.catlet.command;
...
public class PublishBillCommand extends Command
                                implements ActionListener
{
  ...
  public PublishBillCommand()
  {
    // --- creates a vector for the PortalURLListener storage
    portalListeners = new Vector();
  }

  public void initialize()
  {
    // --- declares itself as an event publisher
    Hookup.addPublisher(this);
  }
  ...
  public void addPortalURLListener(PortalURLListener listener)
  {
    portalListeners.addElement(listener);
  }

  public void removePortalURLListener(PortalURLListener listener)
  {
    portalListeners.removeElement(listener);
  }

  private void firePortalURLEvent(PortalURLEvent evt)
  {
    Vector clone;
    synchronized(this) 
    {
      clone = (Vector) portalListeners.clone();
    } 
    for (int i=0; i<clone.size(); i++)
	((PortalURLListener)clone.elementAt(i)).portalURLSelected(evt);
  }
  ...
}

The PublishBillCommand class declares itself as an event Publisher in its initialize method. The command implements 2 methods for the subscriptions of the PortalURLListener (addPortalURLListener and removePortalURLListener), and a method for sending PortalURLEvents to each listener registered to the PublishBillCommand (in this use case, there is only one listener, the Portal desktop).

[Top]

Declaring the PortalURLEvent as a Published Event of the bean

The PublishBillCommandBeanInfo defines its list of published events as follows:

package com.dassault_systemes.japplicationframe.caa.catlet.command;
...
public class PublishBillCommandBeanInfo extends CommandBeanInfo
{
  private Class beanClass;

  public PublishBillCommandBeanInfo()
  {
    beanClass = getClass("com.dassault_systemes.japplicationframe.caa.catlet.command.PublishBillCommand");
  }

  protected EventSetDescriptor[] getPublishedEventDescriptors()
  { 
    try
    {
      // --- listener interface class of the published event PortalURLEvent
      Class urlListenerClass=getClass("com.dassault_systemes.catweb.base.net.url.event.PortalURLListener");

      // --- methods of the PortalURLListener interface
      String[] methods = {"portalURLSelected"};

      // --- descriptor for the PortalURLEvent
      EventSetDescriptor eventSetDescriptor = new EventSetDescriptor( beanClass, "PortalURL", urlListenerClass, methods, 
                                                                      "addPortalURLListener", "removePortalURLListener" );
      eventSetDescriptor.setDisplayName("PortalURL Selected");

      EventSetDescriptor[] eventSetDescriptors = { eventSetDescriptor };
      return eventSetDescriptors;
    }
    catch (IntrospectionException e)
    {
      throw new Error(e.toString());
    }
  }
  ...
}

The PublishBillCommandBeanInfo extends the CommandBeanInfo class. It overrides the getPublishEventDesciptor method , in order to specify the list of events than the PublishBillCommand is able to publish, in this use case the PortalURLEvent. This method is called by the Hookup, when the PublishBillCommand defines itself as an event publisher to it.

[Top]

Creating the PortalURL and Sending the PortalURLEvent

The PublishBillCommand creates a file on the local disk in the temporary directory, creates a file URL and sends it as follows:

package com.dassault_systemes.japplicationframe.caa.catlet.command;
...
public class PublishBillCommand extends Command
                                implements ActionListener
{
  ...
  protected void sendPortalURL(String filePath)
  {
    try
    {
      // --- creates a PortalURL for the bill file created
      PortalURL portalURL = new PortalURL("file://"+filePath);
       
      // --- creates the PortalURLEvent
      PortalURL[] urls = {portalURL};
      PortalURLEvent event = new PortalURLEvent(this, urls, PortalURLEvent.PORTAL_URL_SELECTED, getMasterCATlet());

      // --- sends the PortalURL in order to open the file in the default text editor defined in the MIMETypes file
      firePortalURLEvent(event);
    }     
    catch(MalformedURLException ex)
    {
      System.out.println("Can't publish File "+filePath);
    }
  }
  ...
}

The PublishBillCommand has created a file (filePath) on the local disk. In the sendPortalURL method, it creates an URL with the file protocol and with the file path of the bill file. In order to send this URL to the Portal desktop, the command creates a PortalURLEvent with the created PortalURL, and send it to all the PortalURLListener registered to the command (in this use case, the Portal desktop). The Portal desktop receives this event and extracts the PortalURL. The Portal desktop gets the MIME Type of the PortalURL, and gets the default application associated with it in the PortalRegistry. It launches this application and gives it to the PortalURL for display purpose.

[Top]


In Short

The PublishBillCommand shows all necessary step for creating a PortalURL and sending it to a default viewer. The PortalURL is created with a simple URL string as "file://c:\tmp\StoreFoodBill.txt", the PortalURLEvent is sent without directly knowing the PortalURLListener and the PublishBillCommand allows to view the StoreFoodFile in the default text viewer without knowing it. The PortalURL is the most important file access exchange between Portal applications (See how to receive PortalURLs [2])

[Top]


References

[1] Building and Launching a CAA Enovia V5 Use Case
[2] Receiving PortalURL
[3] Using the PortalRegistry
[Top]

History

Version: 1 [Sep 2000] Document created
[Top]

Copyright © 2000, Dassault Systèmes. All rights reserved.