mil.dod.th.ose.core/src/mil/dod/th/ose/core/factory/api/FactoryRegistry.java
@SuppressWarnings("unchecked")
    protected T createOrRestoreObject(final FactoryInternal factory, final UUID uuid) 
            throws IllegalArgumentException, FactoryException, FactoryObjectInformationException
    {
        //get the object name 
        final String objectName = m_FactoryObjectDataManager.getName(uuid);
        
        //check if there is a PID (and hence a configuration) already known for the given UUID
        final String pid = m_FactoryObjectDataManager.getPid(uuid);
        
        //fetch properties from the config admin
        final Configuration config = FactoryServiceUtils.getFactoryConfiguration(m_ConfigAdmin, pid);
        Dictionary<String, Object> properties = new Hashtable<String, Object>();
        if (config != null)
        {
            properties = config.getProperties();
        }
        
        //the properties will be checked, to see if the object is satisfied
        final Dictionary<String, Object> withDefltProperties = getAllDeps(properties, factory);
        //evaluate if the object's deps are satisfied
        final DependencyState state = isSatisfied(uuid, withDefltProperties);
        if (state == DependencyState.INVALID)
        {
            // dependencies are invalid, will not create object ever, so do clean up
            m_FactoryObjectDataManager.tryRemove(uuid);
            tryDeleteConfiguration(uuid);
            throw new FactoryException(String.format("Unable to create/restore %s {%s}, unknown dependency.", 
                    m_BaseType, uuid));
        }
        else if (state == DependencyState.UNSATISFIED)
        {
            // missing dependency, don't create the object now, but add to the list of pending objects
            final PendingFactoryObject pendingObject =  new PendingFactoryObject(uuid, properties, factory); 
            m_PendingObjects.add(pendingObject);
            throw new FactoryException(String.format("Unable to create/restore %s {%s}, unsatisfied dependency.", 
                    m_BaseType, uuid));
        }
        
        final ComponentInstance compInst = m_ServiceProxy.createFactoryObjectInternal(factory);
        final T object = (T)compInst.getInstance();
        final FactoryObjectProxy proxy = factory.create();
        
        //proxy has not been initialized and should not be used yet, just sending for later use
        object.initialize(this, proxy, factory, m_ConfigAdmin, m_EventAdmin, m_PowerInternal, uuid,
                objectName, pid, m_BaseType);
        
        //this callback is used to allow lookup services to initialize any accessory
        //items that are needed before the object can be released into circulation
        try
        {
            m_Callback.preObjectInitialize(object);
            m_ServiceProxy.initializeProxy(object, proxy, ConfigurationUtils.convertDictionaryPropsToMap(properties));
            m_Callback.postObjectInitialize(object);
        }
        catch (final ConfigurationException ex)
        {
            m_Callback.onRemovedObject(object);
            throw new FactoryException(
                    String.format("Unable to update %s object", m_BaseType), ex);
        }
        
        // add factory object instance 
        addObject(object);
        
        //add component instance to map
        m_ComponentMap.put(object.getUuid(), compInst);

        // Call method on object to notify that creation is complete (e.g. then post asset status, etc.)
        object.postCreation();

        // return the object
        return object;
    }
/**
     * Default implementation to create or restore a factory object.
     * 
     * @param factory
     *      factory used to create the object
     * @param uuid
     *      the UUID for the newly created object, the same UUID should be associated with the object's name, PID, etc.
     * @return
     *      the object that was created
     * @throws FactoryException
     *      if there was an error with the creation of the object or its configuration
     * @throws IllegalArgumentException
     *      if the name is the duplicate of a name already in the data store
     * @throws FactoryObjectInformationException
     *      if a problem occurs saving the object's data
     */
Default implementation to create or restore a factory object.

@param factory
factory used to create the object
@param uuid
the UUID for the newly created object, the same UUID should be associated with the object's name, PID, etc.
@return
the object that was created
@throws FactoryException
if there was an error with the creation of the object or its configuration
@throws IllegalArgumentException
if the name is the duplicate of a name already in the data store
@throws FactoryObjectInformationException
if a problem occurs saving the object's data
Default implementation to create or restore a factory object . @param factory factory used to create the object @param uuid the UUID for the newly created object the same UUID should be associated with the object ' s name PID etc . @return the object that was created @throws FactoryException if there was an error with the creation of the object or its configuration @throws IllegalArgumentException if the name is the duplicate of a name already in the data store @throws FactoryObjectInformationException if a problem occurs saving the object ' s data
@SuppressWarnings("unchecked")
    protected T createOrRestoreObject(final FactoryInternal factory, final UUID uuid) 
            throws IllegalArgumentException, FactoryException, FactoryObjectInformationException
    {
        final String objectName = m_FactoryObjectDataManager.getName(uuid);
        final String pid = m_FactoryObjectDataManager.getPid(uuid);
        final Configuration config = FactoryServiceUtils.getFactoryConfiguration(m_ConfigAdmin, pid);
        Dictionary<String, Object> properties = new Hashtable<String, Object>();
        if (config != null)
        {
            properties = config.getProperties();
        }
        final Dictionary<String, Object> withDefltProperties = getAllDeps(properties, factory);
        final DependencyState state = isSatisfied(uuid, withDefltProperties);
        if (state == DependencyState.INVALID)
        {
            m_FactoryObjectDataManager.tryRemove(uuid);
            tryDeleteConfiguration(uuid);
            throw new FactoryException(String.format("Unable to create/restore %s {%s}, unknown dependency.", 
                    m_BaseType, uuid));
        }
        else if (state == DependencyState.UNSATISFIED)
        {
            final PendingFactoryObject pendingObject =  new PendingFactoryObject(uuid, properties, factory); 
            m_PendingObjects.add(pendingObject);
            throw new FactoryException(String.format("Unable to create/restore %s {%s}, unsatisfied dependency.", 
                    m_BaseType, uuid));
        }
        final ComponentInstance compInst = m_ServiceProxy.createFactoryObjectInternal(factory);
        final T object = (T)compInst.getInstance();
        final FactoryObjectProxy proxy = factory.create();
        object.initialize(this, proxy, factory, m_ConfigAdmin, m_EventAdmin, m_PowerInternal, uuid,
                objectName, pid, m_BaseType);
        try
        {
            m_Callback.preObjectInitialize(object);
            m_ServiceProxy.initializeProxy(object, proxy, ConfigurationUtils.convertDictionaryPropsToMap(properties));
            m_Callback.postObjectInitialize(object);
        }
        catch (final ConfigurationException ex)
        {
            m_Callback.onRemovedObject(object);
            throw new FactoryException(
                    String.format("Unable to update %s object", m_BaseType), ex);
        }
        addObject(object);
        m_ComponentMap.put(object.getUuid(), compInst);
        object.postCreation();
        return object;
    }
@ SuppressWarnings ( "unchecked" ) protected T createOrRestoreObject ( final FactoryInternal factory , final UUID uuid ) throws IllegalArgumentException , FactoryException , FactoryObjectInformationException { final String objectName = m_FactoryObjectDataManager . getName ( uuid ) ; final String pid = m_FactoryObjectDataManager . getPid ( uuid ) ; final Configuration config = FactoryServiceUtils . getFactoryConfiguration ( m_ConfigAdmin , pid ) ; Dictionary < String , Object > properties = new Hashtable < String , Object > ( ) ; if ( config != null ) { properties = config . getProperties ( ) ; } final Dictionary < String , Object > withDefltProperties = getAllDeps ( properties , factory ) ; final DependencyState state = isSatisfied ( uuid , withDefltProperties ) ; if ( state == DependencyState . INVALID ) { m_FactoryObjectDataManager . tryRemove ( uuid ) ; tryDeleteConfiguration ( uuid ) ; throw new FactoryException ( String . format ( "Unable to create/restore %s {%s}, unknown dependency." , m_BaseType , uuid ) ) ; } else if ( state == DependencyState . UNSATISFIED ) { final PendingFactoryObject pendingObject = new PendingFactoryObject ( uuid , properties , factory ) ; m_PendingObjects . add ( pendingObject ) ; throw new FactoryException ( String . format ( "Unable to create/restore %s {%s}, unsatisfied dependency." , m_BaseType , uuid ) ) ; } final ComponentInstance compInst = m_ServiceProxy . createFactoryObjectInternal ( factory ) ; final T object = ( T ) compInst . getInstance ( ) ; final FactoryObjectProxy proxy = factory . create ( ) ; object . initialize ( this , proxy , factory , m_ConfigAdmin , m_EventAdmin , m_PowerInternal , uuid , objectName , pid , m_BaseType ) ; try { m_Callback . preObjectInitialize ( object ) ; m_ServiceProxy . initializeProxy ( object , proxy , ConfigurationUtils . convertDictionaryPropsToMap ( properties ) ) ; m_Callback . postObjectInitialize ( object ) ; } catch ( final ConfigurationException ex ) { m_Callback . onRemovedObject ( object ) ; throw new FactoryException ( String . format ( "Unable to update %s object" , m_BaseType ) , ex ) ; } addObject ( object ) ; m_ComponentMap . put ( object . getUuid ( ) , compInst ) ; object . postCreation ( ) ; return object ; }
Default implementation to create or restore a factory object.
Default implementation to create or restore a factory object .
//get the object name  //check if there is a PID (and hence a configuration) already known for the given UUID //fetch properties from the config admin //the properties will be checked, to see if the object is satisfied //evaluate if the object's deps are satisfied // dependencies are invalid, will not create object ever, so do clean up // missing dependency, don't create the object now, but add to the list of pending objects //proxy has not been initialized and should not be used yet, just sending for later use //this callback is used to allow lookup services to initialize any accessory //items that are needed before the object can be released into circulation // add factory object instance  //add component instance to map // Call method on object to notify that creation is complete (e.g. then post asset status, etc.) // return the object