Package com.opencloud.slee.remote
Class RemoteProfiles
- java.lang.Object
-
- com.opencloud.slee.remote.RemoteProfiles
-
public class RemoteProfiles extends Object
Create proxies for Profile-related MBeans, create new profiles, set attributes, etc.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
RemoteProfiles.UncommittedProfile<T>
Contains references and exposes utility methods needed to update and commit a newly-created profile.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
createCommittedProfile(MBeanServerConnection server, String profileTableName, String profileName, AttributeList attributes)
Creates a profile, sets the attributes, then commits it.static RemoteProfiles.UncommittedProfile<?>
createUncommittedProfile(MBeanServerConnection server, String profileTableName, String profileName)
Creates a profile but does not commit it, allowing the caller to set the attributes before committing.static <T> RemoteProfiles.UncommittedProfile<T>
createUncommittedProfile(MBeanServerConnection server, String profileTableName, String profileName, Class<T> profileInterface)
Creates a profile but does not commit it, allowing the caller to set the attributes before committing.static Map<String,Object>
getAttributeMap(MBeanServerConnection server, String profileTableName, String profileName)
Get the attributes of a profile.static Map<String,Object>
getAttributeMap(MBeanServerConnection server, String profileTableName, String profileName, String[] attributeNames)
Get the attributes of a profile.static String[]
getAttributeNames(MBeanServerConnection server, String profileTableName)
Get the attribute names for a profile table.static AttributeList
getAttributes(MBeanServerConnection server, String profileTableName, String profileName)
Get the attributes of a profile.static String
getAttributeType(MBeanServerConnection server, String profileTableName, String attributeName)
Get the attribute type for an attribute on a profile table.static String
getAttributeType(MBeanServerConnection server, ObjectName objectName, String attributeName)
Get the attribute type for an attribute of any MBean.static <T> T
getProfile(MBeanServerConnection server, String tableName, String profileName, Class<T> profileClass)
Get a proxy for a profile.static ProfileMBean
getProfileMBean(MBeanServerConnection server, String tableName, String profileName)
Creates a `Profile` proxy object for a given profile table and profile namestatic ProfileMBean
getProfileMBean(MBeanServerConnection server, ObjectName objectName)
Creates a `Profile` proxy object for a given `ObjectName`.static ProfileMBean
getProfileMBean(MBeanServerConnection server, ProfileID profileId)
Creates a `Profile` proxy object for a given profile Id.static ProfileTableUsageMBean
getProfileTableUsage(MBeanServerConnection server, String tableName)
Provides aProfileTableUsageMBean
proxy object for the given profile table.static boolean
profileTableExists(MBeanServerConnection server, String tableName)
Check if a profile table exists.static void
setAttributes(MBeanServerConnection server, String profileTableName, String profileName, AttributeList attrs)
Set the attributes of a profile using an `AttributeList`.static void
setAttributes(MBeanServerConnection server, ObjectName objectName, AttributeList attrs)
Set the attributes of a profile using an `AttributeList`.
-
-
-
Method Detail
-
createCommittedProfile
public static void createCommittedProfile(MBeanServerConnection server, String profileTableName, String profileName, AttributeList attributes) throws InvalidArgumentException, UnrecognizedProfileTableNameException, ProfileAlreadyExistsException, ManagementException, ProfileVerificationException
Creates a profile, sets the attributes, then commits it. The attribute values in the attribute list must be of the correct type for the profile. If an error occurs, the profile creation attempt is rolled back and an exception is thrown.- Parameters:
server
- a server connectionprofileTableName
- the name of the profile tableprofileName
- the name of the profileattributes
- list of attributes to create the profile with, must contain attribute values of the correct type.- Throws:
NullPointerException
- if profileTableName or profileName is `null`UnrecognizedProfileTableNameException
- if a profile table with the specified name does not exist.InvalidArgumentException
- if `profileName` is zero-length or contains illegal characters.ProfileAlreadyExistsException
- if a profile with the same name already exists in the profile table.ProfileVerificationException
- if thrown by theProfile.profileVerify()
callback method in the profile's Management Profile Abstract Class. This exception can also be thrown by the profile MBean if the deployment descriptor for the profile specification documents an indexed attribute as requiring unique values and a non-unique value has been supplied in the profile.ManagementException
- if the profile could not be created due to a system-level failure.
-
createUncommittedProfile
public static <T> RemoteProfiles.UncommittedProfile<T> createUncommittedProfile(MBeanServerConnection server, String profileTableName, String profileName, Class<T> profileInterface) throws InvalidArgumentException, UnrecognizedProfileTableNameException, ProfileAlreadyExistsException, ManagementException, InvalidStateException, ProfileVerificationException
Creates a profile but does not commit it, allowing the caller to set the attributes before committing. The returnedRemoteProfiles.UncommittedProfile
object contains the necessary references to set attributes and commit the profile.- Parameters:
server
- a server connectionprofileTableName
- the name of the profile tableprofileName
- the name of the profileprofileInterface
- the interface that the proxy for the Profile will supportexpected
- type of the profile interface- Returns:
- an instance of
RemoteProfiles.UncommittedProfile
containing references to a ProfileMBean proxy, the new profile's ObjectName and a proxy for the Profile itself - Throws:
NullPointerException
- if profileTableName or profileName is `null`UnrecognizedProfileTableNameException
- if a profile table with the specified name does not exist.InvalidArgumentException
- if `profileName` is zero-length or contains illegal characters.ProfileAlreadyExistsException
- if a profile with the same name already exists in the profile table.ManagementException
- if the profile could not be created due to a system-level failure.InvalidStateException
ProfileVerificationException
-
createUncommittedProfile
public static RemoteProfiles.UncommittedProfile<?> createUncommittedProfile(MBeanServerConnection server, String profileTableName, String profileName) throws InvalidArgumentException, UnrecognizedProfileTableNameException, ProfileAlreadyExistsException, ManagementException, InvalidStateException, ProfileVerificationException
Creates a profile but does not commit it, allowing the caller to set the attributes before committing.- Parameters:
server
- a server connectionprofileTableName
- the name of the profile tableprofileName
- the name of the profile- Returns:
- an instance of
RemoteProfiles.UncommittedProfile
containing references to a ProfileMBean proxy and the new profile's ObjectName - Throws:
NullPointerException
- if profileTableName or profileName is `null`UnrecognizedProfileTableNameException
- if a profile table with the specified name does not exist.InvalidArgumentException
- if `profileName` is zero-length or contains illegal characters.ProfileAlreadyExistsException
- if a profile with the same name already exists in the profile table.ManagementException
- if the profile could not be created due to a system-level failure.InvalidStateException
ProfileVerificationException
-
getProfileMBean
public static ProfileMBean getProfileMBean(MBeanServerConnection server, ObjectName objectName)
Creates a `Profile` proxy object for a given `ObjectName`.- Parameters:
server
- a server connectionobjectName
- the objectName of the profile.- Returns:
- a
ProfileMBean
proxy
-
getProfileMBean
public static ProfileMBean getProfileMBean(MBeanServerConnection server, ProfileID profileId) throws UnrecognizedProfileTableNameException, UnrecognizedProfileNameException, ManagementException
Creates a `Profile` proxy object for a given profile Id.- Parameters:
server
- a server connectionprofileId
- the `ProfileID`- Returns:
- A Profile proxy to the managed object
- Throws:
UnrecognizedProfileTableNameException
- if the profile table name is not recognized.UnrecognizedProfileNameException
- if the profile name is not recognized.ManagementException
- if a management exception occurs.
-
getProfileMBean
public static ProfileMBean getProfileMBean(MBeanServerConnection server, String tableName, String profileName) throws UnrecognizedProfileTableNameException, UnrecognizedProfileNameException, ManagementException
Creates a `Profile` proxy object for a given profile table and profile name- Parameters:
server
- a server connectiontableName
- the name of the table.profileName
- the name of the profile.- Returns:
- A Profile proxy to the managed object
- Throws:
UnrecognizedProfileTableNameException
- if the profile table name is not recognized.UnrecognizedProfileNameException
- if the profile name is not recognized.ManagementException
- if a management exception occurs.
-
getProfileTableUsage
public static ProfileTableUsageMBean getProfileTableUsage(MBeanServerConnection server, String tableName) throws InvalidArgumentException, UnrecognizedProfileTableNameException, ManagementException
Provides aProfileTableUsageMBean
proxy object for the given profile table.- Parameters:
server
- a server connectiontableName
- the name of the profile table- Returns:
- a `ProfileTableUsageMBean` proxy
- Throws:
UnrecognizedProfileTableNameException
- if the profile table name is unrecognized.InvalidArgumentException
- if the profile specification component that the specified profile table was created from does not define a usage parameters interface.ManagementException
- if a management exception occurs.
-
profileTableExists
public static boolean profileTableExists(MBeanServerConnection server, String tableName) throws ManagementException
Check if a profile table exists.- Parameters:
server
- a server connectiontableName
- the profile table name- Returns:
- true if the profile table exists, false if not
- Throws:
ManagementException
- if the profile table names could not be obtained due to a system-level failure.
-
getProfile
public static <T> T getProfile(MBeanServerConnection server, String tableName, String profileName, Class<T> profileClass) throws UnrecognizedProfileNameException, UnrecognizedProfileTableNameException, ManagementException
Get a proxy for a profile.- Parameters:
server
- a server connectiontableName
- the profile table nameprofileName
- the profile nameprofileClass
- the profile classexpected
- type of the profile interface- Returns:
- a proxy instance
- Throws:
UnrecognizedProfileTableNameException
- if the profile table name is not recognized.UnrecognizedProfileNameException
- if the profile name is not recognized.ManagementException
- if the profile could not be retrieved due to a system-level failure.
-
getAttributeNames
public static String[] getAttributeNames(MBeanServerConnection server, String profileTableName) throws ManagementException, UnrecognizedProfileTableNameException
Get the attribute names for a profile table. The attributes used by the SLEE, `ProfileWriteable` and `ProfileDirty`, are excluded automatically.- Parameters:
server
- a server connectionprofileTableName
- the name of the profile table- Returns:
- an array containing the attribute names
- Throws:
ManagementException
- if the profile attributes could not be retrieved due to a system-level failure.UnrecognizedProfileTableNameException
- if the profile table name is not recognized.
-
getAttributeType
public static String getAttributeType(MBeanServerConnection server, String profileTableName, String attributeName) throws AttributeNotFoundException, ManagementException, UnrecognizedProfileTableNameException
Get the attribute type for an attribute on a profile table. The string will be the value returned from MBeanAttributeInfo.getType(), which is the class name of the attribute.- Parameters:
server
- a server connectionprofileTableName
- the profile table nameattributeName
- the attribute name- Returns:
- the type of the attribute
- Throws:
AttributeNotFoundException
- if the given attribute name is not an attribute of the given profile tableManagementException
- if the profile attributes could not be retrieved due to a system-level failure.UnrecognizedProfileTableNameException
- if the profile table name is not recognized.
-
getAttributeType
public static String getAttributeType(MBeanServerConnection server, ObjectName objectName, String attributeName) throws AttributeNotFoundException, ManagementException
Get the attribute type for an attribute of any MBean. The string will be the value returned from MBeanAttributeInfo.getType(), which is the class name of the attribute.- Parameters:
server
- a server connectionobjectName
- the object name of the MBeanattributeName
- the attribute name- Returns:
- the type of the attribute
- Throws:
AttributeNotFoundException
- if the given attribute name is not an attribute of the given profile tableManagementException
- if the profile attributes could not be retrieved due to a system-level failure.
-
getAttributes
public static AttributeList getAttributes(MBeanServerConnection server, String profileTableName, String profileName) throws ManagementException, UnrecognizedProfileTableNameException, UnrecognizedProfileNameException
Get the attributes of a profile.- Parameters:
server
- a server connectionprofileTableName
- the name of the profile tableprofileName
- the name of the profile- Returns:
- a JMX AttributeList object containing the attributes
- Throws:
ManagementException
- if the profile attributes could not be retrieved due to a system-level failure.UnrecognizedProfileTableNameException
- if the profile table name is not recognized.UnrecognizedProfileNameException
- if the profile name is not recognized.
-
getAttributeMap
public static Map<String,Object> getAttributeMap(MBeanServerConnection server, String profileTableName, String profileName) throws ManagementException, UnrecognizedProfileTableNameException, UnrecognizedProfileNameException
Get the attributes of a profile.- Parameters:
server
- a server connectionprofileTableName
- the name of the profile tableprofileName
- the name of the profile- Returns:
- a map containing the attributes
- Throws:
ManagementException
- if the profile attributes could not be retrieved due to a system-level failure.UnrecognizedProfileTableNameException
- if the profile table name is not recognized.UnrecognizedProfileNameException
- if the profile name is not recognized.
-
getAttributeMap
public static Map<String,Object> getAttributeMap(MBeanServerConnection server, String profileTableName, String profileName, String[] attributeNames) throws ManagementException, UnrecognizedProfileTableNameException, UnrecognizedProfileNameException
Get the attributes of a profile. If `attributeNames` is null, the list of attributes for the given profile will be retrieved first, and the map returned will contain values for all attributes. If `attributeNames` is not null, the MBean will be queried for given attributes without checking the attributes are valid.- Parameters:
server
- a server connectionprofileTableName
- the name of the profile tableprofileName
- the name of the profileattributeNames
- the names of the attributes to return, if null all attributes are returned- Returns:
- a map containing the attributes
- Throws:
ManagementException
- if the profile attributes could not be retrieved due to a system-level failure.UnrecognizedProfileTableNameException
- if the profile table name is not recognized.UnrecognizedProfileNameException
- if the profile name is not recognized.
-
setAttributes
public static void setAttributes(MBeanServerConnection server, String profileTableName, String profileName, AttributeList attrs) throws UnrecognizedProfileTableNameException, ManagementException, UnrecognizedProfileNameException
Set the attributes of a profile using an `AttributeList`.- Parameters:
server
- a server connectionprofileTableName
- the name of the profile tableprofileName
- the name of the profileattrs
- a JMX AttributeList object containing the attributes to be set- Throws:
ManagementException
- if the profile attributes could not be set due to a system-level failure.UnrecognizedProfileTableNameException
- if the profile table name is not recognized.UnrecognizedProfileNameException
- if the profile name is not recognized.
-
setAttributes
public static void setAttributes(MBeanServerConnection server, ObjectName objectName, AttributeList attrs) throws UnrecognizedProfileTableNameException, ManagementException, UnrecognizedProfileNameException
Set the attributes of a profile using an `AttributeList`.- Parameters:
server
- a server connectionobjectName
- a managed objectattrs
- a JMX AttributeList object containing the attributes to be set- Throws:
ManagementException
- if the profile attributes could not be set due to a system-level failure.UnrecognizedProfileTableNameException
- if the profile table name is not recognized.UnrecognizedProfileNameException
- if the profile name is not recognized.
-
-