The RemoteProfiles class contains a number of utility methods to greatly ease working with SLEE profile management operations.

There are methods to:

  • get proxies to ProfileMBeans

  • create and commit a new profile

  • create an uncommitted profile that can have its attributes set before it is committed

  • get attribute names, values and types.

These methods are in addition to the standard management operations available on ProfileProvisioningMBean.

Creating a profile table

This can be done using the ProfileProvisioningMBean, but RemoteProfiles has a utility method to check if a profile table exists:

ProfileSpecificationID profileSpecID =
        new ProfileSpecificationID("AddressProfileSpec", "javax.slee", "1.0");

if(RemoteProfiles.profileTableExists(connection, "TstProfTbl")) {
    profileProvisioning.removeProfileTable("TstProfTbl");
}
profileProvisioning.createProfileTable(profileSpecID, "TstProfTbl");

Creating a profile

Option 1: Supply the attributes when creating the profile and have it committed

AttributeList list = new AttributeList();
list.add(new Attribute("Addresses",
                       new Address[] { new Address(AddressPlan.IP, "127.0.0.1") }));
RemoteProfiles.createCommittedProfile(connection, "TstProfTbl", "TstProfile1", list);

Option 2: Create the profile in the uncommitted state, and use a proxy to the Profile Management interface to set the attributes, then call commitProfile

RemoteProfiles.UncommittedProfile<AddressProfileManagement> uncommittedA;
uncommittedA = RemoteProfiles.createUncommittedProfile(connection, "TstProfTbl", "TstProfile2",
                      AddressProfileManagement.class);

AddressProfileManagement addressProfile = uncommittedA.getProfileProxy();
addressProfile.setAddresses(new Address[] { new Address(AddressPlan.IP, "127.0.0.2") });
uncommittedA.getProfileMBean().commitProfile();

Option 3: Create the profile in the uncommitted state, and use the setAttribute method on the connection, then call commitProfile

RemoteProfiles.UncommittedProfile uncommittedB;
uncommittedB = RemoteProfiles.createUncommittedProfile(connection, "TstProfTbl", "TstProfile3");
connection.setAttribute(uncommittedB.getObjectName(),
                        new Attribute("Addresses",
                                      new Address[] { new Address(AddressPlan.IP, "127.0.0.3") }));

uncommittedB.getProfileMBean().commitProfile();

Editing a profile

Using the profile management interface as a proxy to the profile object allows set methods to be invoked directly:

ProfileMBean profile
        = RemoteProfiles.getProfileMBean(connection, "TstProfTbl", profileName);
profileMBean.editProfile();

AddressProfileManagement addrProfMng
        = RemoteProfiles.getProfile(connection, "TstProfTbl", profileName,
                                    AddressProfileManagement.class);

addrProfMng.setAddresses(new Address[] { new Address(AddressPlan.IP, "127.0.1.1") });
profileMBean.commitProfile();

Inspecting profile tables

Using RemoteProfiles methods to get the attribute names and types for a given profile table:

String[] names = RemoteProfiles.getAttributeNames(connection, "TstProfTbl");
System.out.println("Profile attributes:");
for (String name : names) {
    String type = RemoteProfiles.getAttributeType(connection, "TstProfTbl", name);
    System.out.println("    " + name + " (" + type + ")");
}
Previous page Next page
Rhino Version 2.6.0