The Deploy Example

This example shows how to interact with the Novell exteNd WSSDK Server using a Java RMI client. The client invokes the built-in deploy server running at the root page.

1 Deploy RMI Interface

The remote interface for the Deploy service is shown below:
/*
 * $Id: Deploy.java,v 1.1.1.1 2003/06/13 01:42:40 vijay Exp $
 *
 * Copyright 2001-2002 by Novell, Inc.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * Novell, Inc. ("Confidential Information"). You shall
 * not disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with Novell.
 */
                                                                           
package com.sssw.jbroker.web.server;
                                                                           
import java.rmi.Remote;
import java.rmi.RemoteException;
                                                                           
public interface Deploy extends Remote
{
    /**
       Deploy a service.
       @param location Desired location.
       @param war Byte array with WAR file.
     */
    void deploy(String location, byte[] war) throws RemoteException;
                                                                           
    /**
       Un-deploy a service.
       @param location Web Service location.
     */
    void undeploy(String location) throws RemoteException;
                                                                           
    /**
       List all deployed services.
       @return Array of locations.
     */
    String[] list() throws RemoteException;
}
The deploy method takes a byte array, which is assumed to be a WAR file image.

2 Deploy Client

A client for the Deploy service is listed below:
package deploy;
                                                                           
import java.rmi.Remote;
import java.rmi.RemoteException;
                                                                           
import java.io.File;
import java.io.FileInputStream;
                                                                           
import javax.naming.InitialContext;
                                                                           
public class Client
{
    static final String _ds = "com.sssw.jbroker.web.server.DeployService";
                                                                           
    public static void main(String[] args) throws Exception
    {
    |   // get the deploy service
    |   InitialContext ctx = new InitialContext();
    |   com.sssw.jbroker.web.server.DeployService svc =
    |       (com.sssw.jbroker.web.server.DeployService)
    |           ctx.lookup("xmlrpc:soap:" + _ds + "@" + 
    |               ((args.length > 0) ? args[0] : "http://localhost:9090"));
    |   com.sssw.jbroker.web.server.Deploy deploy =
    |       (com.sssw.jbroker.web.server.Deploy) svc.getDeployPort();
    |                                                                      
    |   String[] list = deploy.list();
    |   for (int i = 0; i < list.length; i++)
    |       System.out.println(list[i]);
    |                                                                      
    |   File file = new File(".." + File.separatorChar + "hello" +
    |       File.separatorChar + "services.war");
    |   FileInputStream fis = new FileInputStream(file);
    |   byte[] b = new byte[fis.available()];
    |   fis.read(b);
    |   fis.close();
    |                                                                      
    |   System.out.println("uploading " + b.length + " bytes from " + file);
    |                                                                      
    |   deploy.deploy("/hello", b);
    }
}
To run the client against a Novell exteNd WSSDK Server running on the default port 8888, you can issue the following command:
java deploy.Client http://localhost:8888
The client assumes a file called services.war in the current directory. You can for instance copy the services.war file from the Hello World example.
Copyright © 2000-2003, Novell, Inc. All rights reserved.