com.sun.enterprise.registration.impl
Class RepositoryManager

java.lang.Object
  extended by com.sun.enterprise.registration.impl.RepositoryManager

public class RepositoryManager
extends java.lang.Object

Manages a local repository for service tags and registration status.

The client code specifies (in the constructor) the file path or the File which is to hold the persisted registration repository. Note that any public method that modifies any part of the DOM for the repository also flushes the repository to the file before returning.

If the specified file exists, the manager loads its contents as the initial value of the document. If the file does not exist, the manager creates a new in-memory document containing the top-level registry element and the default registrationstatus element but does NOT write out this initial data. Writes to the file occur only in response to the client code invoking one of the methods that modifies the DOM.


Constructor Summary
RepositoryManager(java.io.File registrationFile)
          Creates a new manager which persists the registration data in the specified File.
 
Method Summary
 void add(ServiceTag serviceTag)
          Adds an element for the specified ServiceTag object (and writes the revised DOM to the file).
 java.lang.String getInstanceURN(java.lang.String productURN)
           
 RegistrationService.RegistrationReminder getRegistrationReminder()
          Returns the current registration status value.
 RegistrationService.RegistrationStatus getRegistrationStatus()
          Returns the current registration status value.
 RegistrationDescriptor.RegistrationStatus getRegistrationStatus(ServiceTag serviceTag)
           
 java.util.List<ServiceTag> getServiceTags()
          Returns a list of all service tag objects represented in the repository.
 ServiceTag.Status getStatus(ServiceTag serviceTag)
           
 void remove(ServiceTag serviceTag)
          Removes the XML element corresponding to the specified service tag (and persists the change to the file).
 boolean setInstanceURN(java.lang.String productURN, java.lang.String instanceURN)
           
 void setRegistrationReminder(RegistrationService.RegistrationReminder reminder)
          Sets the registration status value and persists the change to the on-disk repository.
 void setRegistrationStatus(RegistrationService.RegistrationStatus status)
          Sets the registration status value for all service tags and persists the change to the on-disk repository.
 void setRegistrationStatus(ServiceTag serviceTag, RegistrationDescriptor.RegistrationStatus status)
          Sets the status for the specified service tag in the repository (and persists the change to the file).
 void setStatus(ServiceTag serviceTag, ServiceTag.Status status)
           
 void updateRuntimeValues()
          Goes through all service tags in the repository, and updates runtime values if necessary.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RepositoryManager

public RepositoryManager(java.io.File registrationFile)
                  throws RegistrationException
Creates a new manager which persists the registration data in the specified File.

Throws:
RegistrationException - for any errors creating the XML parser or transformer used for reading and writing the registration data or during the initial load of the repository from the local file
Method Detail

getServiceTags

public java.util.List<ServiceTag> getServiceTags()
Returns a list of all service tag objects represented in the repository.

Returns:
List the in-memory cache (if it is not already there)

getRegistrationStatus

public RegistrationService.RegistrationStatus getRegistrationStatus()
Returns the current registration status value. Returns RegistrationService.REGISTERED if any one service tag is registered.

Returns:
RegistrationService.RegistrationStatus enum for the current registration status

setRegistrationStatus

public void setRegistrationStatus(RegistrationService.RegistrationStatus status)
                           throws RegistrationException
Sets the registration status value for all service tags and persists the change to the on-disk repository.

Parameters:
status - the new RegistrationStatus value
Throws:
RegistrationException - for errors writing the registration data to the local repository

getRegistrationReminder

public RegistrationService.RegistrationReminder getRegistrationReminder()
Returns the current registration status value.

Returns:
RegistrationService.RegistrationReminder enum for the current registration status

setRegistrationReminder

public void setRegistrationReminder(RegistrationService.RegistrationReminder reminder)
                             throws RegistrationException
Sets the registration status value and persists the change to the on-disk repository.

Parameters:
reminder - the new RegistrationReminder value
Throws:
RegistrationException - for errors writing the registration data to the local repository

add

public void add(ServiceTag serviceTag)
         throws RegistrationException
Adds an element for the specified ServiceTag object (and writes the revised DOM to the file).

Parameters:
serviceTag - the ServiceTag for which to add an XML element
Throws:
RegistrationException - for errors writing the registration data to the local repository

remove

public void remove(ServiceTag serviceTag)
            throws RegistrationException
Removes the XML element corresponding to the specified service tag (and persists the change to the file).

Parameters:
serviceTag - the ServiceTag for which the XML element should be removed
Throws:
RegistrationException - for errors writing the registration data to the local repository

setRegistrationStatus

public void setRegistrationStatus(ServiceTag serviceTag,
                                  RegistrationDescriptor.RegistrationStatus status)
                           throws RegistrationException
Sets the status for the specified service tag in the repository (and persists the change to the file).

Parameters:
serviceTag - the service tag of interest
the - status to be assigned
Throws:
RegistrationException - for errors writing the registration data to the local repository

getRegistrationStatus

public RegistrationDescriptor.RegistrationStatus getRegistrationStatus(ServiceTag serviceTag)
                                                                throws RegistrationException
Throws:
RegistrationException

setStatus

public void setStatus(ServiceTag serviceTag,
                      ServiceTag.Status status)
               throws RegistrationException
Throws:
RegistrationException

getStatus

public ServiceTag.Status getStatus(ServiceTag serviceTag)
                            throws RegistrationException
Throws:
RegistrationException

getInstanceURN

public java.lang.String getInstanceURN(java.lang.String productURN)
                                throws RegistrationException
Throws:
RegistrationException

setInstanceURN

public boolean setInstanceURN(java.lang.String productURN,
                              java.lang.String instanceURN)
                       throws RegistrationException
Throws:
RegistrationException

updateRuntimeValues

public void updateRuntimeValues()
                         throws RegistrationException
Goes through all service tags in the repository, and updates runtime values if necessary.

Throws:
RegistrationException - in case of errors writing the output


Copyright © 2012 GlassFish Community. All Rights Reserved.