How to drop a Spaceforcibly using the Java API.

How to drop a Spaceforcibly using the Java API.

book

Article ID: KB0092969

calendar_today

Updated On:

Products Versions
TIBCO ActiveSpaces -
Not Applicable -

Description

Description:
An ActiveSpaces Space cannot be dropped if any member has already connected. To forcibly drop a Space, make all joined members leave the space iterativley.

Resolution

As there is no instance command or API to do this, use the following workarounds:

A).  Using a Command:

 1). List all joined members for a space with the command 'show space <space_name>' .
 2). Execute the 'leave space' command on each member with command 'execute on member <member_name> leave space <space_name>' .

B). Using the API:


 1). Iterate all members of a space.
 2). To invoke the Admin command, 'execute on member <member_name> leave space <space_name>' .

Here is a snippet of the code (Java):

================================

 try
        {
        // Introduce the com.tibco.as.admin.Admin
                Admin admin = Admin.create();
        String space_name = "";
            if (space != null && listener != null) space.stopListener(listener);
            if (space != null) {
            space_name = space.getName();
            if (metaspace != null) {
                        // Iterator all of members of a space
            Collection<Member> m = space.getMembers();
            Iterator it = m.iterator();
            while(it.hasNext()){
            Member _m = (Member)it.next();
            try {
                                                        // execute the 'leave space' command on each member
admin.execute(metaspace, "execute on member '"+ _m.getName() +"' leave space '"+space_name+"'");
} catch (AdminException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
            }
                space.closeAll();
                }
            }
            if (metaspace != null) {
                // drop the space
            metaspace.dropSpace(space_name);
            metaspace.closeAll();
            }
        }
        catch (ASException ex)
        {
            ex.printStackTrace();

        }

=================================

Issue/Introduction

How to drop a Spaceforcibly using the Java API.