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

org.coos.messaging.Endpoint Maven / Gradle / Ivy

The newest version!
/**
 * COOS - Connected Objects Operating System (www.connectedobjects.org).
 *
 * Copyright (C) 2009 Telenor ASA and Tellu AS. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This library is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published
 * by the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see .
 *
 * You may also contact one of the following for additional information:
 * Telenor ASA, Snaroyveien 30, N-1331 Fornebu, Norway (www.telenor.no)
 * Tellu AS, Hagalokkveien 13, N-1383 Asker, Norway (www.tellu.no)
 */
package org.coos.messaging;

import java.util.Hashtable;
import java.util.Vector;


/**
 * The Endpoint that can receive and send messages to the bus and exchanges towards the consumer/producer.
 *
 * @author Knut Eilif Husa, Tellu AS
 */
public interface Endpoint extends Processor, Service, Connectable {

    // framework plugins with fixed uuids that the Default endpoint communicates
    // with
    String ACCESS_CONTROL_ADDRESS = "coos://ac";
    String LIFE_CYCLE_MANGER_ADDRESS = "coos://localcoos.lcm/lcm@LifeCycleManager"; // Actorframe

    // type
    // of
    // endpoint
    String NOTIFICATION_BROKER_ADDRESS = "coos://nb";

    // properties that this plugin uses
    // the time time that the process exchange waits before it returns an error
    String PROP_EXCHANGE_TIMEOUT = "coosEndpointTimeout";
    int DEFAULT_TIMEOUT = 10000; // 10 sec
    String PROP_MAX_POOL_SIZE = "coosEndpointMaxPoolSize";
    int DEFAULT_MAX_POOL_SIZE = 2; //

    // login properties
    String PROP_LOGIN_REQUIRED = "loginRequired";
    String PROP_LOGIN_NAME = "loginname";
    String PROP_PASSWORD = "password";

    // LCM properties
    String PROP_LCM_REGISTRATION_ENABLED = "lcmRegEnabled";
    String PROP_LCM_REGISTRATION_REQUIRED = "lcmRegRequired";
    String PROP_LCM_POLLING_INTERVAL = "lcmPollingInterval";
    long DEFAULT_LCM_POLLING_INTERVAL = 0; // Default off
    String PROP_LCM_HEARTBEAT_INTERVAL = "lcmHeartbeatInterval";

    // LCM States
    String STATE_RUNNING = "Running";
    String STATE_STARTUP_FAILED = "StartupFailed";
    String STATE_STOPPING = "Stopping";
    String STATE_STARTING = "Starting";
    String STATE_INSTALLED = "Installed";
    String STATE_PAUSED = "Paused";
    String STATE_READY = "Ready";
    String STATE_UPDATING = "Updating";
    String STATE_UPGRADING = "Upgrading";
    String STATE_UNINNSTALLED = "Uninstalled";

    // Nameserver properties
    String PROP_REG_REQUIRED = "registrationRequired";

    // messages that the default endpoint handles

    // EPRMEssageConstants

    public void addAlias(String alias);

    public void removeAlias(String alias);

    public Vector getAliases();

    /**
     * Setter method for the uuid
     *
     * @param uuid
     *            the uuid
     */
    public void setEndpointUuid(String uuid);

    /**
     * Getter for the endpoint uuid
     *
     * @return the uuid
     */
    public String getEndpointUuid();


    /**
     * Creates a new consumer that consumes exchanges from the endpoint. An
     * endpoint will only have one consumer associated
     *
     * @return a newly created consumer
     */
    Consumer createConsumer();

    /**
     * Creates a new producer which is used send messages into the message bus
     *
     * @return a newly created producer
     */
    Producer createProducer();

    /**
     * Create a new exchange for communicating with this endpoint
     */
    Exchange createExchange();

    /**
     * Create a new exchange for communicating with this endpoint with the
     * specified {@link ExchangePattern} such as whether its going to be an
     * {@link ExchangePattern#OutOnly} or {@link ExchangePattern#OutIn} exchange
     *
     * @param pattern
     *            the message exchange pattern for the exchange
     */
    Exchange createExchange(ExchangePattern pattern);

    /**
     * Returns the string representation of the endpoint URI
     *
     * @return the uri iString representation
     */
    String getEndpointUri();

    /**
     * Setter for the endpoint Uri
     *
     * @param endpointUri
     *            the endpoint Uri
     */
    void setEndpointUri(String endpointUri);

    /**
     * Processing the outwards exchange
     *
     * @param exchange
     *            the exchange to be processed
     * @return the processed exchange
     */
    public Exchange processExchange(Exchange exchange);

    /**
     * Processing the exchange with asynchronous notification when the exchange
     * is ready
     *
     * @param exchange
     *            the exchange to be processed
     * @param callback
     *            the callback
     */
    public void processExchange(Exchange exchange, AsyncCallback callback);

    /**
     * This method initalizes the endpoint
     */
    public void initializeEndpoint();

    /**
     * This method shuts down the endpoint
     */
    public void shutDownEndpoint();

    /**
     * Returns the endpoint state, Can be one of: STATE_RUNNING,
     * STATE_STARTUP_FAILED, STATE_STOPPING, STATE_STARTING, STATE_INSTALLED,
     * STATE_PAUSED, STATE_READY, STATE_UPDATING, STATE_UPGRADING,
     * STATE_UNINNSTALLED
     *
     * @return the state
     */
    public String getEndpointState();

    /**
     * Sets the Endpoint state. Can be one of: STATE_RUNNING,
     * STATE_STARTUP_FAILED, STATE_STOPPING, STATE_STARTING, STATE_INSTALLED,
     * STATE_PAUSED, STATE_READY, STATE_UPDATING, STATE_UPGRADING,
     * STATE_UNINNSTALLED
     *
     * @param endpointState
     */
    public void setEndpointState(String endpointState);

    /**
     * If this Endpoint contains a complex structure this method allows for
     * setting the State on a inner child
     *
     * @param childName
     * @param state
     */
    public void setChildEndpointState(String childName, String state);

    /**
     * Reports the state of your endpoint to the LCM
     */
    public void reportState() throws EndpointException;

    /**
     * Reports the state of the given child to the LCM
     *
     * @param childName
     */
    public void reportChildState(String childName) throws EndpointException;

    /**
     * If this Endpoint contains a complex structure this method returns the
     * State of a inner child
     *
     * @param childName
     * @return the State
     */
    public String getChildEndpointState(String childName);

    /**
     * This method allows you to subscribe for notifications using a
     * {@link SubscriptionFilter}
     *
     * @param filter
     *            the subscription filter
     */
    public boolean subscribe(SubscriptionFilter filter);

    /**
     * Unsubscribes a specific subscription
     *
     * @param filter
     *            the subscription to be cancelled
     */
    public void unsubscribe(SubscriptionFilter filter);

    /**
     * Unsubscribes all current subscritpions
     */
    public void unsubscribe();

    /**
     * Publish notifications using {@link Notification}.
     *
     * @param notification
     *            the notification
     */
    public void publish(Notification notification);

    /**
     * Returns the properties
     * @return properties
     */
    public Hashtable getProperties();

    /**
     * Sets the plugin
     * @param plugin
     */
    public void setPlugin(Plugin plugin);

    /**
     * Returns the plugin
     * @return Plugin
     */
    public Plugin getPlugin();

    /**
     * Sets the request timout for the endpoint in ms
     * @param timeout timeout in ms
     */
    public void setTimeout(long timeout);

    /**
     * Sets the maxPoolSize of executor threads for the endpoint
     * @param maxPoolSize 
     */
    public void setMaxPoolSize(int maxPoolSize);

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy