SRMProvider.java revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* ident "%Z%%M% %I% %E% SMI"
*
* Copyright (c) 2001 by Sun Microsystems, Inc.
* All rights reserved.
*
*/
/**
* This is the base class for the SRM providers.
* It contains default implementations of the WBEM provider API methods which
* return the CIM_ERR_NOTSUPPORTED error. Each concrete user manager provider
* subclass overrides the methods with its own implementation. This class also
* contains several utility methods which may be useful to the individual
* provider classes.
* @author Sun Microsystems
* @version %I% %G%
*/
public abstract class SRMProvider
/**
* The handle to the CIMOM.
*/
/**
* Handle to the log service.
*/
/**
* Some often used exception are defined here to save some memory.
*/
protected static final CIMProviderException notFoundEx =
protected static final CIMProviderException generalEx =
protected static final CIMException notSupported =
/**
* Severity indicator 'ERROR' for logging.
*/
/**
* Severity indicator 'WARNING' for logging.
*/
/**
* Severity indicator 'INFO' for logging.
*/
/**
* Classname of resource messages for logging.
*/
protected static final String RESOURCEBUNDLE =
"com.sun.wbem.solarisprovider.srm.resources.LogMessages";
/**
* Handle to the resource monitor, which controls the access
* into the resource data cache (DataModel).
*/
/**
* This must be implemented by each subclass to make its
* class name visible.
* @returns String provider class name
*/
protected abstract String getProviderName();
//
// Default implementations of the WBEM Provider API methods
//
/**
* Called by the CIMOM when the provider is initialized.
*
* @exception CIMException the client connection failed
*/
throws CIMException {
int updateTime = -1;
int rdsTimeout = -1;
int rdsInterval = -1;
// Save the cimomhandle.
this.cimomhandle = cimomhandle;
// Establish the logging facility
try {
}
}
}
} catch (Exception e) { };
try {
} catch (Exception e) {
}
} // end initialize
/**
* Called by the CIMOM when the provider is removed. Currently the CIMOM
* does not remove providers, but this method is provided for future
* versions.
*
* @exception CIMException The method cleanup() throws a CIMException.
*/
public void cleanup() throws CIMException {
}
/**
* This method must be implemented by instance providers to create
* the instance specified in the object path. If the instance does
* exist, CIMInstanceException with ID CIM_ERR_ALREADY_EXISTS
* must be thrown. The parameter should be the instance name.
*
* @param op The path of the instance to be set. The important part
* in this parameter is the namespace component.
* @param ci The instance to be set.
* @return CIMObjectPath of the instance that was created.
* @exception CIMException This method throws a CIMException.
*/
throws CIMException {
throw notSupported;
}
/**
* Retrieves the instance specified in the argument CIMObjectPath.
*
* @param op - the name of the instance to be retrieved. This must include
* all of the keys and values for the instance.
* @param localOnly - if true, only the local properties of the class are
* returned, otherwise all properties are required
* @param includeQualifiers - if true, the qualifiers are returned as part
* of of the returned instancei, otherwise no qualifiers will be returned
* @param includeClassOrigin - if true, the class origin of each property
* will be returned
* @param String[] - if null, all properties are returned, otherwise only
* the properties specified will be returned. Any duplicate properties will
* be ignored.
* @param cc - the class reference
*
* @return CIMInstance the retrieved instance.
* @exception CIMException - the method getInstance throws a CIMException
* if the CIMObjectPath is incorrect or does not exist.
*/
boolean localOnly,
boolean includeQualifiers,
boolean includeClassOrigin,
throws CIMException {
throw notSupported;
}
/**
* This method must be implemented by instance providers to set
* the instance specified in the object path. If the instance does
* not exist, CIMInstanceException with ID CIM_ERR_NOT_FOUND
* must be thrown. The parameter should be the instance name.
*
* @param op The path of the instance to be set. The important part
* in this parameter is the namespace component.
* @param ci The instance to be set.
* @exception CIMException The setInstance method throws a CIMException.
*/
throws CIMException {
throw notSupported;
}
/**
* This method must be implemented by instance providers to delete
* the instance specified in the object path.
*
* @param ci The instance to be deleted.
* @exception CIMException The deleteInstance method throws a
* CIMException.
*/
throws CIMException {
throw notSupported;
}
/**
* Enumerates all instances of the class which is specified by the
* CIMObjectPath argument. The entire instances and not just the names
* are returned.
*
* @param op - the object path specifies the class to be enumerated
* localOnly - if true, only the local properties of the class are returned,
* otherwise all properties are required
* @param includeQualifiers - if true, the qualifiers are returned as part
* of of the returned instancei, otherwise no qualifiers will be returned
* @param includeClassOrigin - if true, the class origin of each property
* will be returned
* @param String[] - if null, all properties are returned, otherwise only
* the properties specified will be
* returned. Any duplicate properties will be ignored.
* @param cc - the class reference
* @return An array of CIMInstance
* @exception CIMException - if the CIMObjectPath is incorrect or does not
* exist.
*/
boolean localOnly,
boolean includeQualifiers,
boolean includeClassOrigin,
throws CIMException {
throw notSupported;
}
/**
* Enumerates all of the instances of the class which is specified by
* the CIMObjectPath argument. Only the class name portion of the
* CIMObjectPath argument is used, any additional information will be
* ignored
*
* @param op - the class name to enumerate the instances
* @param cc - the class reference passed to the provider
* @return an array of CIMObjectPath containing names of the enumerated
* instances.
* @exception CIMException - if the classname is null or does not exist.
*/
boolean deep,
throws CIMException {
throw notSupported;
}
/**
* This method must be implemented by instance providers to enumerate
* instances of the class which is specified in op which meet the criteria
* defined by the query string.
*
* @param op The object path specifies the class that must
* be enumerated.
* @param query The criteria.
* @param ql The CIM query.
* @param cc The class reference.
* @return CIMInstance The retrieved instance.
* @exception CIMException This method throws a CIMException message if the
* if operation is not supported.
*/
throws CIMException {
"SRM_0001",
"SRM_5003",
throw notSupported;
}
/**
* This method contains the implementation for the method. The CIMOM calls
* this method when the method specified in the parameters is to be invoked.
* @param op Contains the path to the instance whose method must be
* invoked.
* @param methodName The name of the method.
* @param inParams This is a vector of CIMValues which are the input
* parameters for the method.
* @param outParams This is a vector of CIMValues which are the output
* parameters for the method.
* @return CIMValue The return value of the method. If the method has no
* return value, it must return null.
* @exception CIMException This method throws a CIMException
*/
throws CIMException {
return getBulkData(outParams);
} else {
}
} // end invokeMethod
/**
* This method contains the implementation for the method. The CIMOM calls
* this method when the method specified in the parameters is to be invoked.
* @param op Contains the path to the instance whose method must be
* invoked.
* @param methodName The name of the method.
* @param outParams This is a vector of CIMValues which are the output
* parameters for the method.
* @return CIMValue The return value of the method. If the method has
* no return value, it must return null.
* @exception CIMException The invokeMethod method throws a CIMException.
*/
throws CIMException {
throw notSupported;
}
//
// Logging methods.
//
/**
* Utility logging method.
* @return the log message.
* @param severity the reported severity level.
* @param x an Exception to be logged.
*/
}
/**
* Utility logging method.
* @return the log message.
* @param severity the reported severity level.
* @param summary the short summary to be logged.
* @param x an Exception to be logged.
*/
Exception x) {
}
/**
* Utility logging method.
* @return the log message.
* @param severity the reported severity level.
* @param summary the short summary to be logged.
* @param detail the detailed message to be logged.
* @param x an Exception to be logged.
*/
Exception x) {
}
/**
* Utility logging method.
* @return the log message.
* @param severity the reported severity level.
* @param summary the short summary to be logged.
*/
null,
null,
null,
null,
null);
}
/**
* Utility logging method.
* @return the log message.
* @param severity the reported severity level.
* @param summary the short summary to be logged.
* @param detail the detailed message to be logged.
*/
null,
null,
null,
null);
}
/**
* Utility logging method.
* @return the log message.
* @param severity the reported severity level.
* @param summary the short summary to be logged.
* @param detail the detailed message to be logged.
* @param arg1 the first parameter to substitute
* into the logged message.
*/
arg1,
null,
null,
null);
}
/**
* Utility logging method.
* @return the log message.
* @param severity the reported severity level.
* @param summary the short summary to be logged.
* @param detail the detailed message to be logged.
* @param arg1 the first parameter to substitute
* into the logged message.
* @param arg2 the second parameter to substitute
* into the logged message.
*/
arg1,
arg2,
null,
null);
}
/**
* Utility logging method.
* @return the log message.
* @param severity the reported severity level.
* @param summary the short summary to be logged.
* @param detail the detailed message to be logged.
* @param arg1 the first parameter to substitute
* into the logged message.
* @param arg2 the second parameter to substitute
* into the logged message.
* @param arg3 the third parameter to substitute
* into the logged message.
*/
arg1,
arg2,
arg3,
null);
}
/**
* Utility logging method (bottom-level implementation).
* @return a formatted version of the log message
* (<providerName>: <summaryMessage>).
* @param severity the reported severity level.
* @param summary the short summary to be logged.
* @param detail the detailed message to be logged.
* @param arg1 the first parameter to substitute into the logged message.
* @param arg2 the second parameter to substitute into the logged message.
* @param arg3 the third parameter to substitute into the logged message.
* @param arg4 the fourth parameter to substitute into the logged message.
*/
try {
args,
"",
true,
logmsg = getProviderName() +
": " +
} catch (Exception x) {
x.printStackTrace();
}
return logmsg;
}
protected static String getBundleName() {
return (RESOURCEBUNDLE);
}
} // end class SRMProvider