/*
* 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
* 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
* trunk/opends/resource/legal-notices/OpenDS.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
*
*
* Copyright 2007-2010 Sun Microsystems, Inc.
*/
/**
* Defines the structure of an abstract managed object. Abstract managed objects
* cannot be instantiated.
* <p>
* Applications can query a managed object definition in order to determine the
* overall configuration model of an application.
*
* @param <C>
* The type of client managed object configuration that this definition
* represents.
* @param <S>
* The type of server managed object configuration that this definition
* represents.
*/
public abstract class AbstractManagedObjectDefinition
<C extends ConfigurationClient, S extends Configuration> {
// The name of the definition.
// The parent managed object definition if applicable.
// The set of constraints associated with this managed object
// definition.
// The set of property definitions applicable to this managed object
// definition.
// The set of relation definitions applicable to this managed object
// definition.
// The set of relation definitions directly referencing this managed
// object definition.
// The set of all property definitions associated with this managed
// object definition including inherited property definitions.
// The set of all relation definitions associated with this managed
// object definition including inherited relation definitions.
// The set of aggregation property definitions applicable to this
// managed object definition.
// The set of aggregation property definitions directly referencing this
// managed object definition.
private final Vector<AggregationPropertyDefinition<?, ?>>
// The set of all aggregation property definitions associated with this
// managed object definition including inherited relation definitions.
// The set of tags associated with this managed object.
// Options applicable to this definition.
// The set of managed object definitions which inherit from this definition.
/**
* Create a new abstract managed object definition.
*
* @param name
* The name of the definition.
* @param parent
* The parent definition, or <code>null</code> if there
* is no parent (only the {@link TopCfgDefn} should have a
* <code>null</code> parent, unless the definition is
* being used for testing).
*/
AbstractManagedObjectDefinition<? super C, ? super S> parent) {
this.allRelationDefinitions =
new Vector<AggregationPropertyDefinition<?,?>>();
AbstractManagedObjectDefinition<? extends C, ? extends S>>();
// If we have a parent definition then inherit its features.
}
}
for (AggregationPropertyDefinition<?, ?> apd :
}
// Tag inheritance is performed during preprocessing.
}
}
/**
* Get all the child managed object definitions which inherit from
* this managed object definition.
*
* @return Returns an unmodifiable collection containing all the
* subordinate managed object definitions which inherit from
* this managed object definition.
*/
public final Collection<AbstractManagedObjectDefinition
<? extends C, ? extends S>> getAllChildren() {
new ArrayList<AbstractManagedObjectDefinition<? extends C, ? extends S>>(
for (AbstractManagedObjectDefinition<? extends C, ? extends S> child :
}
}
/**
* Get all the constraints associated with this type of managed
* object. The returned collection will contain inherited
* constraints.
*
* @return Returns a collection containing all the constraints
* associated with this type of managed object. The caller
* is free to modify the collection if required.
*/
// This method does not used a cached set of constraints because
// constraints may be updated after child definitions have been
// defined.
}
return allConstraints;
}
/**
* Get all the property definitions associated with this type of
* managed object. The returned collection will contain inherited
* property definitions.
*
* @return Returns an unmodifiable collection containing all the
* property definitions associated with this type of managed
* object.
*/
}
/**
* Get all the relation definitions associated with this type of
* managed object. The returned collection will contain inherited
* relation definitions.
*
* @return Returns an unmodifiable collection containing all the
* relation definitions associated with this type of managed
* object.
*/
public final Collection<RelationDefinition<?, ?>>
}
/**
* Get all the relation definitions which refer to this managed
* object definition. The returned collection will contain relation
* definitions which refer to parents of this managed object
* definition.
*
* @return Returns a collection containing all the relation
* definitions which refer to this managed object
* definition. The caller is free to modify the collection
* if required.
*/
public final Collection<RelationDefinition<? super C, ? super S>>
// This method does not used a cached set of relations because
// relations may be updated after child definitions have been
// defined.
new LinkedList<RelationDefinition<? super C, ? super S>>();
}
return rdlist;
}
/**
* Get all the aggregation property definitions associated with this type of
* managed object. The returned collection will contain inherited
* aggregation property definitions.
*
* @return Returns an unmodifiable collection containing all the
* aggregation property definitions associated with this type of
* managed object.
*/
public final Collection<AggregationPropertyDefinition<?, ?>>
return Collections.unmodifiableCollection(
}
/**
* Get all the aggregation property definitions which refer to this managed
* object definition. The returned collection will contain aggregation
* property definitions which refer to parents of this managed object
* definition.
*
* @return Returns a collection containing all the aggregation property
* definitions which refer to this managed object
* definition. The caller is free to modify the collection
* if required.
*/
public final Collection<AggregationPropertyDefinition<?, ?>>
// This method does not used a cached set of aggregation properties because
// aggregation properties may be updated after child definitions have been
// defined.
new LinkedList<AggregationPropertyDefinition<?, ?>>();
}
return apdlist;
}
/**
* Get all the tags associated with this type of managed object. The
* returned collection will contain inherited tags.
*
* @return Returns an unmodifiable collection containing all the
* tags associated with this type of managed object.
*/
}
/**
* Get the named child managed object definition which inherits from
* this managed object definition. This method will recursively
* search down through the inheritance hierarchy.
*
* @param name
* The name of the managed object definition sub-type.
* @return Returns the named child managed object definition which
* inherits from this managed object definition.
* @throws IllegalArgumentException
* If the specified managed object definition name was
* null or empty or if the requested subordinate managed
* object definition was not found.
*/
public final AbstractManagedObjectDefinition<? extends C, ? extends S>
throw new IllegalArgumentException("null or empty managed object name");
}
AbstractManagedObjectDefinition<? extends C, ? extends S> d = children
if (d == null) {
// Recursively search.
for (AbstractManagedObjectDefinition<? extends C, ? extends S> child :
try {
break;
} catch (IllegalArgumentException e) {
// Try the next child.
}
}
}
if (d == null) {
throw new IllegalArgumentException("child managed object definition \""
+ name + "\" not found");
}
return d;
}
/**
* Get the child managed object definitions which inherit directly
* from this managed object definition.
*
* @return Returns an unmodifiable collection containing the
* subordinate managed object definitions which inherit
* directly from this managed object definition.
*/
public final Collection<AbstractManagedObjectDefinition
<? extends C, ? extends S>> getChildren() {
}
/**
* Get the constraints defined by this managed object definition.
* The returned collection will not contain inherited constraints.
*
* @return Returns an unmodifiable collection containing the
* constraints defined by this managed object definition.
*/
}
/**
* Gets the optional description of this managed object definition
* in the default locale.
*
* @return Returns the description of this managed object definition
* in the default locale, or <code>null</code> if there is
* no description.
* @throws UnsupportedOperationException
* If this managed object definition is the
* {@link TopCfgDefn}.
*/
}
/**
* Gets the optional description of this managed object definition
* in the specified locale.
*
* @param locale
* The locale.
* @return Returns the description of this managed object definition
* in the specified locale, or <code>null</code> if there
* is no description.
* @throws UnsupportedOperationException
* If this managed object definition is the
* {@link TopCfgDefn}.
*/
throws UnsupportedOperationException {
try {
} catch (MissingResourceException e) {
return null;
}
}
/**
* Get the name of the definition.
*
* @return Returns the name of the definition.
*/
return name;
}
/**
* Get the parent managed object definition, if applicable.
*
* @return Returns the parent of this managed object definition, or
* <code>null</code> if this definition is the
* {@link TopCfgDefn}.
*/
public final AbstractManagedObjectDefinition<? super C,
? super S> getParent() {
return parent;
}
/**
* Get the specified property definition associated with this type
* of managed object. The search will include any inherited property
* definitions.
*
* @param name
* The name of the property definition to be retrieved.
* @return Returns the specified property definition associated with
* this type of managed object.
* @throws IllegalArgumentException
* If the specified property name was null or empty or if
* the requested property definition was not found.
*/
throws IllegalArgumentException {
throw new IllegalArgumentException("null or empty property name");
}
if (d == null) {
+ "\" not found");
}
return d;
}
/**
* Get the property definitions defined by this managed object
* definition. The returned collection will not contain inherited
* property definitions.
*
* @return Returns an unmodifiable collection containing the
* property definitions defined by this managed object
* definition.
*/
.values());
}
/**
* Get the specified relation definition associated with this type
* of managed object.The search will include any inherited relation
* definitions.
*
* @param name
* The name of the relation definition to be retrieved.
* @return Returns the specified relation definition associated with
* this type of managed object.
* @throws IllegalArgumentException
* If the specified relation name was null or empty or if
* the requested relation definition was not found.
*/
throws IllegalArgumentException {
throw new IllegalArgumentException("null or empty relation name");
}
if (d == null) {
+ "\" not found");
}
return d;
}
/**
* Get the relation definitions defined by this managed object
* definition. The returned collection will not contain inherited
* relation definitions.
*
* @return Returns an unmodifiable collection containing the
* relation definitions defined by this managed object
* definition.
*/
}
/**
* Get the relation definitions which refer directly to this managed
* object definition. The returned collection will not contain
* relation definitions which refer to parents of this managed
* object definition.
*
* @return Returns an unmodifiable collection containing the
* relation definitions which refer directly to this managed
* object definition.
*/
public final Collection<RelationDefinition<C, S>>
}
/**
* Get the specified aggregation property definition associated with this type
* of managed object.The search will include any inherited aggregation
* property definitions.
*
* @param name
* The name of the aggregation property definition to be retrieved.
* @return Returns the specified aggregation property definition associated
* with this type of managed object.
* @throws IllegalArgumentException
* If the specified aggregation property name was null or empty or
* if the requested aggregation property definition was not found.
*/
public final AggregationPropertyDefinition<?, ?>
throws IllegalArgumentException {
throw new IllegalArgumentException(
"null or empty aggregation property name");
}
AggregationPropertyDefinition<?, ?> d =
if (d == null) {
throw new IllegalArgumentException("aggregation property definition \""
+ name + "\" not found");
}
return d;
}
/**
* Get the aggregation property definitions defined by this managed object
* definition. The returned collection will not contain inherited
* aggregation property definitions.
*
* @return Returns an unmodifiable collection containing the
* aggregation property definitions defined by this managed object
* definition.
*/
public final Collection<AggregationPropertyDefinition<?, ?>>
return Collections.unmodifiableCollection(
}
/**
* Get the aggregation property definitions which refer directly to this
* managed object definition. The returned collection will not contain
* aggregation property definitions which refer to parents of this managed
* object definition.
*
* @return Returns an unmodifiable collection containing the
* aggregation property definitions which refer directly to this
* managed object definition.
*/
public final Collection<AggregationPropertyDefinition<?, ?>>
return Collections.unmodifiableCollection(
}
/**
* Gets the synopsis of this managed object definition in the
* default locale.
*
* @return Returns the synopsis of this managed object definition in
* the default locale.
* @throws UnsupportedOperationException
* If this managed object definition is the
* {@link TopCfgDefn}.
*/
}
/**
* Gets the synopsis of this managed object definition in the
* specified locale.
*
* @param locale
* The locale.
* @return Returns the synopsis of this managed object definition in
* the specified locale.
* @throws UnsupportedOperationException
* If this managed object definition is the
* {@link TopCfgDefn}.
*/
throws UnsupportedOperationException {
}
/**
* Gets the user friendly name of this managed object definition in
* the default locale.
*
* @return Returns the user friendly name of this managed object
* definition in the default locale.
* @throws UnsupportedOperationException
* If this managed object definition is the
* {@link TopCfgDefn}.
*/
throws UnsupportedOperationException {
}
/**
* Gets the user friendly name of this managed object definition in
* the specified locale.
*
* @param locale
* The locale.
* @return Returns the user friendly name of this managed object
* definition in the specified locale.
* @throws UnsupportedOperationException
* If this managed object definition is the
* {@link TopCfgDefn}.
*/
throws UnsupportedOperationException {
// TODO: have admin framework getMessage return a Message
}
/**
* Gets the user friendly plural name of this managed object
* definition in the default locale.
*
* @return Returns the user friendly plural name of this managed
* object definition in the default locale.
* @throws UnsupportedOperationException
* If this managed object definition is the
* {@link TopCfgDefn}.
*/
throws UnsupportedOperationException {
}
/**
* Gets the user friendly plural name of this managed object
* definition in the specified locale.
*
* @param locale
* The locale.
* @return Returns the user friendly plural name of this managed
* object definition in the specified locale.
* @throws UnsupportedOperationException
* If this managed object definition is the
* {@link TopCfgDefn}.
*/
throws UnsupportedOperationException {
}
/**
* Determine whether there are any child managed object definitions which
* inherit from this managed object definition.
*
* @return Returns <code>true</code> if this type of managed object has any
* child managed object definitions, <code>false</code> otherwise.
*/
public final boolean hasChildren() {
}
/**
* Determines whether or not this managed object definition has the
* specified option.
*
* @param option
* The option to test.
* @return Returns <code>true</code> if the option is set, or
* <code>false</code> otherwise.
*/
}
/**
* Determines whether or not this managed object definition has the
* specified tag.
*
* @param t
* The tag definition.
* @return Returns <code>true</code> if this managed object
* definition has the specified tag.
*/
}
/**
* Determines whether or not this managed object definition is a
* sub-type of the provided managed object definition. This managed
* object definition is a sub-type of the provided managed object
* definition if they are both the same or if the provided managed
* object definition can be obtained by recursive invocations of the
* {@link #getParent()} method.
*
* @param d
* The managed object definition to be checked.
* @return Returns <code>true</code> if this managed object
* definition is a sub-type of the provided managed object
* definition.
*/
AbstractManagedObjectDefinition<?, ?> i;
if (i == d) {
return true;
}
}
return false;
}
/**
* Determines whether or not this managed object definition is a
* super-type of the provided managed object definition. This
* managed object definition is a super-type of the provided managed
* object definition if they are both the same or if the provided
* managed object definition is a member of the set of children
* returned from {@link #getAllChildren()}.
*
* @param d
* The managed object definition to be checked.
* @return Returns <code>true</code> if this managed object
* definition is a super-type of the provided managed object
* definition.
*/
return d.isChildOf(this);
}
/**
* Determines whether or not this managed object definition is the
* {@link TopCfgDefn}.
*
* @return Returns <code>true</code> if this managed object
* definition is the {@link TopCfgDefn}.
*/
public final boolean isTop() {
return (this instanceof TopCfgDefn);
}
/**
* Finds a sub-type of this managed object definition which most closely
* corresponds to the matching criteria of the provided definition resolver.
*
* @param r
* The definition resolver.
* @return Returns the sub-type of this managed object definition which most
* closely corresponds to the matching criteria of the provided
* definition resolver.
* @throws DefinitionDecodingException
* If no matching sub-type could be found or if the resolved
* definition was abstract.
* @see DefinitionResolver
*/
@SuppressWarnings("unchecked")
public final ManagedObjectDefinition<? extends C, ? extends S>
DefinitionResolver r) throws DefinitionDecodingException {
AbstractManagedObjectDefinition<? extends C, ? extends S> rd;
rd = resolveManagedObjectDefinitionAux(this, r);
// Unable to resolve the definition.
throw new DefinitionDecodingException(this,
} else if (rd instanceof ManagedObjectDefinition) {
return (ManagedObjectDefinition<? extends C, ? extends S>) rd;
} else {
// Resolved definition was abstract.
throw new DefinitionDecodingException(this,
}
}
/**
* {@inheritDoc}
*/
}
/**
* Append a string representation of the managed object definition to the
* provided string builder.
*
* @param builder
* The string builder where the string representation should be
* appended.
*/
}
/**
* Initializes all of the components associated with this managed
* object definition.
*
* @throws Exception
* If this managed object definition could not be
* initialized.
*/
pd.initialize();
}
rd.initialize();
}
for (AggregationPropertyDefinition<?, ?> apd :
apd.initialize();
// Now register the aggregation property in the referenced managed object
// definition for reverse lookups.
}
}
}
/**
* Register a constraint with this managed object definition.
* <p>
* This method <b>must not</b> be called by applications.
*
* @param constraint
* The constraint to be registered.
*/
}
/**
* Register a property definition with this managed object definition,
* overriding any existing property definition with the same name.
* <p>
* This method <b>must not</b> be called by applications.
*
* @param d
* The property definition to be registered.
*/
if (d instanceof AggregationPropertyDefinition<?,?>) {
AggregationPropertyDefinition<?, ?> apd =
(AggregationPropertyDefinition<?, ?>) d;
// The key must also contain the managed object name, since several MOs
// in an inheritance tree may aggregate the same aggregation property name
}
}
/**
* Register a relation definition with this managed object definition,
* overriding any existing relation definition with the same name.
* <p>
* This method <b>must not</b> be called by applications.
*
* @param d
* The relation definition to be registered.
*/
// Register the relation in this managed object definition.
// Now register the relation in the referenced managed object
// definition for reverse lookups.
}
/**
* Register an option with this managed object definition.
* <p>
* This method <b>must not</b> be called by applications.
*
* @param option
* The option to be registered.
*/
}
/**
* Register a tag with this managed object definition.
* <p>
* This method <b>must not</b> be called by applications.
*
* @param tag
* The tag to be registered.
*/
}
/**
* Deregister a constraint from the managed object definition.
* <p>
* This method <b>must not</b> be called by applications and is
* only intended for internal testing.
*
* @param constraint
* The constraint to be deregistered.
*/
throw new RuntimeException("Failed to deregister a constraint");
}
}
/**
* Deregister a relation definition from the managed object
* definition.
* <p>
* This method <b>must not</b> be called by applications and is
* only intended for internal testing.
*
* @param d
* The relation definition to be deregistered.
*/
final void deregisterRelationDefinition(
RelationDefinition<?, ?> d) {
// Deregister the relation from this managed object definition.
// Now deregister the relation from the referenced managed object
// definition for reverse lookups.
}
/**
* Register this managed object definition in its parent.
* <p>
* This method <b>must not</b> be called by applications and is
* only intended for internal testing.
*/
final void registerInParent() {
}
}
// Register a relation definition in the referenced managed object
// definition's reverse lookup table.
}
// Register a aggregation property definition in the referenced managed object
// definition's reverse lookup table.
private void registerReverseAggregationPropertyDefinition(
AggregationPropertyDefinition<?, ?> apd) {
}
// Recursively descend definition hierarchy to find the best match definition.
private AbstractManagedObjectDefinition<? extends C, ? extends S>
AbstractManagedObjectDefinition<? extends C, ? extends S> d,
DefinitionResolver r) {
if (!r.matches(d)) {
return null;
}
for (AbstractManagedObjectDefinition<? extends C, ? extends S> child : d
.getChildren()) {
AbstractManagedObjectDefinition<? extends C, ? extends S> rd =
return rd;
}
}
return d;
}
}