All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.vii.brillien.kernel.axiom.atomic.Presence Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (c) 2012 Imre Fazekas.
 *  All rights reserved.
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice, this
 *  list of conditions and the following disclaimer.
 *
 *  Redistributions in binary form must reproduce the above copyright notice,
 *  this list of conditions and the following disclaimer in the documentation
 *  and/or other materials provided with the distribution.
 *  Neither the name of the Brillien nor the names of its
 *  terms and concepts may be used to endorse or promote products derived from this
 *  software without specific prior written permission.
 *
 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 *  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 *  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 *  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 *  POSSIBILITY OF SUCH DAMAGE.
 */

package com.vii.brillien.kernel.axiom.atomic;

import com.vii.brillien.kernel.BrillienException;
import com.vii.brillien.kernel.axiom.transport.Communication;

import java.util.Collection;

/**
 * This is the most basic extension of the axiomatic Presence term. It could be considered as the basics for all Brillien implementation.
 */
public interface Presence extends com.vii.brillien.kernel.axiom.Presence {

    /**
     * Singleton will be made only once.
     */
    final int               RESIDENT    = 0;

    /**
     * Consonant will be instanciated in every process meaning different transaction id.
     */
    final int               CONSONANT   = 1;

    /**
     * Sparklink will be instantiated in every incoming communication
     */
    final int               SPARKLE = 2;

    /**
     * Gets the flow referece of the Presence. It is an important field during transaction-based business processes.
     * @return Presence's Flow reference
     */
    Flow                    getFlow();

    /**
     * Gets the flow ID of the Presence.
     */
    String                  getFlowID();

    /**
     * Sets the flow ID of the Presence. This operation is required during every instance creation.
     * @param flow Presence's Flow reference
     */
    void                    setFlow( Flow flow ) throws BrillienException;

    /**
     * Gets superunits instances. This includes container units, flow, contexts.
     * @return superunits
     */
    Collection        getSuperUnits();

    /**
     * Adds new superunits.
     * @param ses array of new superunits
     */
    void                    addSuperUnits( Unit... ses) throws BrillienException;

    /**
     * Removes superunits.
     * @param ses array of superunits to remove
     */
    void                    removeSuperUnits( Unit... ses) throws BrillienException;

    /**
     * Clears all subunits
     */
    void                    clearSuperUnits() throws BrillienException;

    /**
     * Getter method for the instantiating manager for that component
     */
    PresenceManager         getPresenceManager();

    /**
     * Retrieves the version of the given presence published
     */
    String                  getApiVersion();

    /**
     * Sets the version of the given presence published
     */
    void                    setApiVersion(String apiVersion);

    /**
     * Setter method for the instantiating manager for that component
     * @param manager instantiating manager
     */
    void                    setPresenceManager( PresenceManager manager );

    /**
     * Makes this presence to be retrieved by the proper Presencemanager
     */
    void                    retrieve() throws BrillienException;

    /**
     * Activates all activity of the Presence (messaging, aspiring).
     */
    void                    activateAll( ) throws BrillienException;

    /**
     * Passivates all activity of the Presence (messaging, aspiring).
     */
    void                    passivateAll( ) throws BrillienException;


    String                  printErrorStates( );

    /**
     * Tries to retrieve a shared Resource.
     * @param key key of the sharing
     * @param  Generic type of the resource
     * @return The shared resource if exists, null otherwise
     */
     S                   getSharing(Object key);

    /**
     * Gets the name of the Presence providing SSO functionality
     * @return name of the SSO Presence if exists, null otherwise
     */
    String                  getSSOPresenceName();


    /**
     * Gets the name of the presence providing API_KEY functionality
     * @return name of the API_KEY Presence if exists, null otherwise
     */
    String                  getApiKeyPresenceName();


    /**
     * Sends the sessionId - User association the the SSOPresence if available
     */
     void                loginUser(String sessionId, T user) throws BrillienException;


    /**
     * Retrieves the logged entity - if available - associated to the given sessionId
     */
     T                   getLoggedUser( ) throws BrillienException;

    /**
     * Retrieves the logged entity - if available - associated to the given sessionId
     * The entity's type need to be assigned from the given type. This will be validated by this method.
     */
     T                   getLoggedUser( Class type ) throws BrillienException;


    /**
     * Gets a reference of an entity with the given name
     */
     T  getPresence(String name) throws BrillienException;

}