org.rhq.enterprise.server.sync.importers
Interface Importer<Entity,ExportedType>

All Known Implementing Classes:
MetricTemplateImporter, SystemSettingsImporter

public interface Importer<Entity,ExportedType>

Implementations of this interface are used to import entities into the database.

The implementations MUST provide a no-arg public constructor.

Author:
Lukas Krejci

Method Summary
 void configure(org.rhq.core.domain.configuration.Configuration importConfiguration)
          Configures the importer.
 String finishImport()
          Finishes the import.
 Set<EntityValidator<ExportedType>> getEntityValidators()
          The set of entity validators that should be called on each entity before the import actually starts.
 ExportedEntityMatcher<Entity,ExportedType> getExportedEntityMatcher()
          Returns an entity matcher that can match the entities from the export file with the real entities in the database.
 org.rhq.core.domain.configuration.definition.ConfigurationDefinition getImportConfigurationDefinition()
          A configuration definition describing the configuration of the importer and the default values for individual properties.
 ExportedType unmarshallExportedEntity(ExportReader reader)
          Unmarshalls an entity from the provided reader.
 void update(Entity entity, ExportedType exportedEntity)
          Updates the entity with the data from the export.
 

Method Detail

getImportConfigurationDefinition

org.rhq.core.domain.configuration.definition.ConfigurationDefinition getImportConfigurationDefinition()
A configuration definition describing the configuration of the importer and the default values for individual properties.

The returned configuration definition MUST define a default template.


configure

void configure(org.rhq.core.domain.configuration.Configuration importConfiguration)
Configures the importer.

Parameters:
importConfiguration - the configuration of the import as defined by the getImportConfigurationDefinition()

getExportedEntityMatcher

ExportedEntityMatcher<Entity,ExportedType> getExportedEntityMatcher()
Returns an entity matcher that can match the entities from the export file with the real entities in the database.

Returns:

getEntityValidators

Set<EntityValidator<ExportedType>> getEntityValidators()
The set of entity validators that should be called on each entity before the import actually starts.


update

void update(Entity entity,
            ExportedType exportedEntity)
            throws Exception
Updates the entity with the data from the export.

This method is responsible for persisting the entity in the database using the provided entityManager. Note that the actual persist can also be delayed until the finishImport() method is called so that the importer can take advantage of batching.

Parameters:
entity - the entity to persist (may be null if the getExportedEntityMatcher() returned null of if the entity matcher didn't find a match)
exportedEntity - the entity found in the export file that should be used to update the entity in the database
Throws:
Exception

unmarshallExportedEntity

ExportedType unmarshallExportedEntity(ExportReader reader)
                                      throws XMLStreamException
Unmarshalls an entity from the provided reader.

Parameters:
reader -
Returns:
Throws:
XMLStreamException

finishImport

String finishImport()
                    throws Exception
Finishes the import. This method is called after all entities from the export file have been updated.

This is useful for importers that need to batch the updates to the database.

Returns:
notes that should be transfered to the user. These should be any warnings and other messages that are not errors (which should throw an exception) but are deemed important for the (human) caller to be aware of.
Throws:
Exception


Copyright © 2008-2012 Red Hat, Inc.. All Rights Reserved.