| | |
| | | private final class DefaultManagedObjectFactory implements |
| | | RelationDefinitionVisitor<Void, Void> { |
| | | |
| | | // Possible exceptions. |
| | | /** Possible exceptions. */ |
| | | private AuthorizationException ae; |
| | | private ManagedObjectAlreadyExistsException moaee; |
| | | private MissingMandatoryPropertiesException mmpe; |
| | |
| | | private OperationRejectedException ore; |
| | | private CommunicationException ce; |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public <C extends ConfigurationClient, S extends Configuration> |
| | | Void visitInstantiable( |
| | | InstantiableRelationDefinition<C, S> rd, Void p) { |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public <C extends ConfigurationClient, S extends Configuration> |
| | | Void visitOptional( |
| | | OptionalRelationDefinition<C, S> rd, Void p) { |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public <C extends ConfigurationClient, S extends Configuration> |
| | | Void visitSingleton( |
| | | SingletonRelationDefinition<C, S> rd, Void p) { |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public <C extends ConfigurationClient, S extends Configuration> |
| | | Void visitSet( |
| | | SetRelationDefinition<C, S> rd, Void p) { |
| | |
| | | |
| | | |
| | | |
| | | // Create the child managed object. |
| | | /** Create the child managed object. */ |
| | | private void createDefaultManagedObject(ManagedObjectDefinition<?, ?> d, |
| | | ManagedObject<?> child, DefaultManagedObject<?, ?> dmo) { |
| | | for (PropertyDefinition<?> pd : d.getAllPropertyDefinitions()) { |
| | |
| | | |
| | | |
| | | |
| | | // Set property values. |
| | | /** Set property values. */ |
| | | private <PD> void setPropertyValues(ManagedObject<?> mo, |
| | | PropertyDefinition<PD> pd, DefaultManagedObject<?, ?> dmo) { |
| | | mo.setPropertyValues(pd, dmo.getPropertyValues(pd)); |
| | |
| | | |
| | | |
| | | |
| | | // The managed object definition associated with this managed |
| | | // object. |
| | | /** The managed object definition associated with this managed object. */ |
| | | private final ManagedObjectDefinition<T, ? extends Configuration> definition; |
| | | |
| | | // Indicates whether or not this managed object exists on the server |
| | | // (false means the managed object is new and has not been |
| | | // committed). |
| | | /** |
| | | * Indicates whether or not this managed object exists on the server |
| | | * (false means the managed object is new and has not been committed). |
| | | */ |
| | | private boolean existsOnServer; |
| | | |
| | | // Optional naming property definition. |
| | | /** Optional naming property definition. */ |
| | | private final PropertyDefinition<?> namingPropertyDefinition; |
| | | |
| | | // The path associated with this managed object. |
| | | /** The path associated with this managed object. */ |
| | | private ManagedObjectPath<T, ? extends Configuration> path; |
| | | |
| | | // The managed object's properties. |
| | | /** The managed object's properties. */ |
| | | private final PropertySet properties; |
| | | |
| | | |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public final void commit() throws ManagedObjectAlreadyExistsException, |
| | | MissingMandatoryPropertiesException, ConcurrentModificationException, |
| | | OperationRejectedException, AuthorizationException, |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public final <C extends ConfigurationClient, S extends Configuration, |
| | | CC extends C> |
| | | ManagedObject<CC> createChild( |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public final <C extends ConfigurationClient, |
| | | S extends Configuration, CC extends C> |
| | | ManagedObject<CC> createChild( |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public final <C extends ConfigurationClient, S extends Configuration, |
| | | CC extends C> |
| | | ManagedObject<CC> createChild( |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public final <C extends ConfigurationClient, S extends Configuration> |
| | | ManagedObject<? extends C> getChild( |
| | | InstantiableRelationDefinition<C, S> r, String name) |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public final <C extends ConfigurationClient, S extends Configuration> |
| | | ManagedObject<? extends C> getChild( |
| | | OptionalRelationDefinition<C, S> r) throws IllegalArgumentException, |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public final <C extends ConfigurationClient, S extends Configuration> |
| | | ManagedObject<? extends C> getChild( |
| | | SingletonRelationDefinition<C, S> r) throws IllegalArgumentException, |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public final <C extends ConfigurationClient, S extends Configuration> |
| | | ManagedObject<? extends C> getChild( |
| | | SetRelationDefinition<C, S> r, String name) |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public final T getConfiguration() { |
| | | return definition.createClientConfiguration(this); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public final ManagedObjectDefinition<T, ? extends Configuration> |
| | | getManagedObjectDefinition() { |
| | | return definition; |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public final ManagedObjectPath<T, ? extends Configuration> |
| | | getManagedObjectPath() { |
| | | return path; |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public final <PD> SortedSet<PD> getPropertyDefaultValues( |
| | | PropertyDefinition<PD> pd) throws IllegalArgumentException { |
| | | return new TreeSet<PD>(getProperty(pd).getDefaultValues()); |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public final <PD> PD getPropertyValue(PropertyDefinition<PD> pd) |
| | | throws IllegalArgumentException { |
| | | Set<PD> values = getProperty(pd).getEffectiveValues(); |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public final <PD> SortedSet<PD> getPropertyValues(PropertyDefinition<PD> pd) |
| | | throws IllegalArgumentException { |
| | | return new TreeSet<PD>(getProperty(pd).getEffectiveValues()); |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public final <C extends ConfigurationClient, S extends Configuration> |
| | | boolean hasChild( |
| | | OptionalRelationDefinition<C, S> r) throws IllegalArgumentException, |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public final boolean isPropertyPresent(PropertyDefinition<?> pd) |
| | | throws IllegalArgumentException { |
| | | return !getProperty(pd).isEmpty(); |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public final <C extends ConfigurationClient, S extends Configuration> |
| | | String[] listChildren( |
| | | InstantiableRelationDefinition<C, S> r) throws IllegalArgumentException, |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public final <C extends ConfigurationClient, S extends Configuration> |
| | | String[] listChildren( |
| | | InstantiableRelationDefinition<C, S> r, |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public final <C extends ConfigurationClient, S extends Configuration> |
| | | String[] listChildren( |
| | | SetRelationDefinition<C, S> r) throws IllegalArgumentException, |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public final <C extends ConfigurationClient, S extends Configuration> |
| | | String[] listChildren( |
| | | SetRelationDefinition<C, S> r, |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public final <C extends ConfigurationClient, S extends Configuration> |
| | | void removeChild( |
| | | InstantiableRelationDefinition<C, S> r, String name) |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public final <C extends ConfigurationClient, S extends Configuration> |
| | | void removeChild( |
| | | OptionalRelationDefinition<C, S> r) throws IllegalArgumentException, |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public final <C extends ConfigurationClient, S extends Configuration> |
| | | void removeChild( |
| | | SetRelationDefinition<C, S> r, String name) |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public final <PD> void setPropertyValue(PropertyDefinition<PD> pd, PD value) |
| | | throws PropertyException, PropertyException, |
| | | PropertyException, IllegalArgumentException { |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | public final <PD> void setPropertyValues(PropertyDefinition<PD> pd, |
| | | Collection<PD> values) throws PropertyException, |
| | | PropertyException, PropertyException, |
| | |
| | | |
| | | |
| | | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public String toString() { |
| | | StringBuilder builder = new StringBuilder(); |
| | |
| | | |
| | | |
| | | |
| | | // Creates a new managed object with no active values, just default |
| | | // values. |
| | | /** |
| | | * Creates a new managed object with no active values, just default |
| | | * values. |
| | | */ |
| | | private <M extends ConfigurationClient, PD> ManagedObject<M> |
| | | createNewManagedObject( |
| | | ManagedObjectDefinition<M, ?> d, ManagedObjectPath<M, ?> p, |
| | |
| | | |
| | | |
| | | |
| | | // Create an empty property. |
| | | /** Create an empty property. */ |
| | | private <PD> void createProperty(PropertySet properties, |
| | | ManagedObjectPath<?, ?> p, PropertyDefinition<PD> pd) |
| | | throws PropertyException { |
| | |
| | | |
| | | |
| | | |
| | | // Makes sure that this managed object exists. |
| | | /** Makes sure that this managed object exists. */ |
| | | private void ensureThisManagedObjectExists() |
| | | throws ConcurrentModificationException, CommunicationException, |
| | | AuthorizationException { |
| | |
| | | |
| | | |
| | | |
| | | // Validate that a relation definition belongs to this managed |
| | | // object. |
| | | /** Validate that a relation definition belongs to this managed object. */ |
| | | private void validateRelationDefinition(RelationDefinition<?, ?> rd) |
| | | throws IllegalArgumentException { |
| | | ManagedObjectDefinition<T, ?> d = getManagedObjectDefinition(); |