diff --git a/Ice/BuiltinSequences.ice b/Ice/BuiltinSequences.ice new file mode 100644 index 0000000..1201c96 --- /dev/null +++ b/Ice/BuiltinSequences.ice @@ -0,0 +1,57 @@ +// Copyright (c) ZeroC, Inc. + +#pragma once + +[["cpp:dll-export:ICE_API"]] +[["cpp:doxygen:include:Ice/Ice.h"]] +[["cpp:header-ext:h"]] + +[["cpp:no-default-include"]] +[["cpp:include:Ice/Config.h"]] +[["cpp:include:Ice/ObjectF.h"]] +[["cpp:include:Ice/ProxyF.h"]] +[["cpp:include:Ice/ValueF.h"]] +[["cpp:include:cstdint"]] +[["cpp:include:optional"]] +[["cpp:include:string"]] +[["cpp:include:vector"]] + +[["js:module:@zeroc/ice"]] + +#ifdef __ICERPC__ +["cs:identifier:IceRpc.Slice.Ice"] +#endif +["java:identifier:com.zeroc.Ice"] +module Ice +{ + /// A sequence of bools. + sequence BoolSeq; + + /// A sequence of bytes. + sequence ByteSeq; + + /// A sequence of shorts. + sequence ShortSeq; + + /// A sequence of ints. + sequence IntSeq; + + /// A sequence of longs. + sequence LongSeq; + + /// A sequence of floats. + sequence FloatSeq; + + /// A sequence of doubles. + sequence DoubleSeq; + + /// A sequence of strings. + sequence StringSeq; + + /// A sequence of class instances. + ["deprecated:Define your own sequence instead and avoid using the term `object` to designate a class instance."] + sequence ObjectSeq; + + /// A sequence of object proxies. + sequence ObjectProxySeq; +} diff --git a/Ice/Identity.ice b/Ice/Identity.ice new file mode 100644 index 0000000..b8c74ae --- /dev/null +++ b/Ice/Identity.ice @@ -0,0 +1,39 @@ +// Copyright (c) ZeroC, Inc. + +#pragma once + +[["cpp:dll-export:ICE_API"]] +[["cpp:doxygen:include:Ice/Ice.h"]] +[["cpp:header-ext:h"]] + +[["cpp:no-default-include"]] +[["cpp:include:Ice/Config.h"]] +[["cpp:include:Ice/StreamHelpers.h"]] +[["cpp:include:Ice/TupleCompare.h"]] +[["cpp:include:string"]] +[["cpp:include:vector"]] + +[["js:module:@zeroc/ice"]] + +/// The Ice RPC framework. +#ifdef __ICERPC__ +["cs:identifier:IceRpc.Slice.Ice"] +#endif +["java:identifier:com.zeroc.Ice"] +module Ice +{ + /// Represents the identity of an Ice object. It is comparable to the path of a URI. Its string representation is + /// `name` when the category is empty, and `category/name` when the category is not empty. + ["cpp:custom-print"] + struct Identity + { + /// The name of the Ice object. An empty name is not valid. + string name; + + /// The category of the object. + string category = ""; + } + + /// A sequence of identities. + sequence IdentitySeq; +} diff --git a/Ice/Locator.ice b/Ice/Locator.ice new file mode 100644 index 0000000..26da39e --- /dev/null +++ b/Ice/Locator.ice @@ -0,0 +1,77 @@ +// Copyright (c) ZeroC, Inc. + +#pragma once + +[["cpp:dll-export:ICE_API"]] +[["cpp:doxygen:include:Ice/Ice.h"]] +[["cpp:header-ext:h"]] + +[["cpp:source-include:Ice/LocatorRegistry.h"]] + +[["js:module:@zeroc/ice"]] + +#include "Identity.ice" + +#ifdef __ICERPC__ +["cs:identifier:IceRpc.Slice.Ice"] +#endif +["java:identifier:com.zeroc.Ice"] +module Ice +{ + /// The exception that is thrown by a {@link Locator} implementation when it cannot find an object adapter with the + /// provided adapter ID. + exception AdapterNotFoundException + { + } + + /// The exception that is thrown by a {@link Locator} implementation when it cannot find an object with the provided + /// identity. + exception ObjectNotFoundException + { + } + + interface LocatorRegistry; + + /// Client applications use the Locator object to resolve Ice indirect proxies. This object also allows + /// server applications to retrieve a proxy to the associated {@link LocatorRegistry} object where they can register + /// their object adapters. + interface Locator + { + /// Finds an object by identity and returns a dummy proxy with the endpoint(s) that can be used to reach this + /// object. This dummy proxy may be an indirect proxy that requires further resolution using + /// {@link findAdapterById}. + /// @param id The identity. + /// @return A dummy proxy, or null if an object with the requested identity was not found. + /// @throws ObjectNotFoundException Thrown when an object with the requested identity was not found. The caller + /// should treat this exception like a null return value. + ["cpp:const"] + idempotent Object* findObjectById(Identity id) + throws ObjectNotFoundException; + + /// Finds an object adapter by adapter ID and returns a dummy proxy with the object adapter's endpoint(s). + /// @param id The adapter ID. + /// @return A dummy proxy with the adapter's endpoints, or null if an object adapter with @p id was not found. + /// @throws AdapterNotFoundException Thrown when an object adapter with this adapter ID was not found. The + /// caller should treat this exception like a null return value. + ["cpp:const"] + idempotent Object* findAdapterById(string id) + throws AdapterNotFoundException; + + /// Gets a proxy to the locator registry. + /// @return A proxy to the locator registry, or null if this locator has no associated registry. + ["cpp:const"] + idempotent LocatorRegistry* getRegistry(); + } + + /// Provides access to a {@link Locator} object via a fixed identity. + /// A LocatorFinder is always registered with identity `Ice/LocatorFinder`. This allows clients to obtain the + /// associated Locator proxy with just the endpoint information of the object. For example, you can use the + /// LocatorFinder proxy `Ice/LocatorFinder:tcp -h somehost -p 4061` to get the Locator proxy + /// `MyIceGrid/Locator:tcp -h somehost -p 4061`. + interface LocatorFinder + { + /// Gets a proxy to the associated {@link Locator}. The proxy might point to several replicas. + /// @return The locator proxy. This proxy is never null. + Locator* getLocator(); + } +} diff --git a/Ice/LocatorRegistry.ice b/Ice/LocatorRegistry.ice new file mode 100644 index 0000000..4e659ce --- /dev/null +++ b/Ice/LocatorRegistry.ice @@ -0,0 +1,80 @@ +// Copyright (c) ZeroC, Inc. + +#pragma once + +[["cpp:dll-export:ICE_API"]] +[["cpp:doxygen:include:Ice/Ice.h"]] +[["cpp:header-ext:h"]] + +[["cpp:source-include:Ice/Process.h"]] + +[["js:module:@zeroc/ice"]] + +#include "Locator.ice" + +#ifdef __ICERPC__ +["cs:identifier:IceRpc.Slice.Ice"] +#endif +["java:identifier:com.zeroc.Ice"] +module Ice +{ + interface Process; + + /// The exception that is thrown when a server application tries to register endpoints for an object adapter that is + /// already active. + exception AdapterAlreadyActiveException + { + } + + /// The exception that is thrown when the provided replica group is invalid. + exception InvalidReplicaGroupIdException + { + } + + /// The exception that is thrown when a server was not found. + exception ServerNotFoundException + { + } + + /// A server application registers the endpoints of its indirect object adapters with the LocatorRegistry object. + interface LocatorRegistry + { + /// Registers or unregisters the endpoints of an object adapter. + /// @param id The adapter ID. + /// @param proxy A dummy proxy created by the object adapter. @p proxy carries the object adapter's endpoints. + /// The locator considers an object adapter to be active after it has registered its endpoints. + /// When @p proxy is null, the endpoints are unregistered and the locator considers the object adapter inactive. + /// @throws AdapterNotFoundException Thrown when the locator only allows registered object adapters to register + /// their endpoints and no object adapter with this adapter ID was registered with the locator. + /// @throws AdapterAlreadyActiveException Thrown when an object adapter with the same adapter ID has already + /// registered its endpoints. Since this operation is marked idempotent, this exception may be thrown when the + /// Ice client runtime retries an invocation with a non-null @p proxy. + idempotent void setAdapterDirectProxy(string id, Object* proxy) + throws AdapterNotFoundException, AdapterAlreadyActiveException; + + /// Registers or unregisters the endpoints of an object adapter. This object adapter is a member of a replica + /// group. + /// @param adapterId The adapter ID. + /// @param replicaGroupId The replica group ID. + /// @param proxy A dummy proxy created by the object adapter. @p proxy carries the object adapter's endpoints. + /// The locator considers an object adapter to be active after it has registered its endpoints. When @p proxy is + /// null, the endpoints are unregistered and the locator considers the object adapter inactive. + /// @throws AdapterNotFoundException Thrown when the locator only allows registered object adapters to register + /// their endpoints and no object adapter with this adapter ID was registered with the locator. + /// @throws AdapterAlreadyActiveException Thrown when an object adapter with the same adapter ID has already + /// registered its endpoints. Since this operation is marked idempotent, this exception may be thrown when the + /// Ice client runtime retries an invocation with a non-null @p proxy. + /// @throws InvalidReplicaGroupIdException Thrown when the given replica group does not match the replica group + /// associated with the adapter ID in the locator's database. + idempotent void setReplicatedAdapterDirectProxy(string adapterId, string replicaGroupId, Object* proxy) + throws AdapterNotFoundException, AdapterAlreadyActiveException, InvalidReplicaGroupIdException; + + /// Registers a proxy to the {@link Process} object of a server application. + /// @param id The server ID. + /// @param proxy A proxy to the {@link Process} object of the server. This proxy is never null. + /// @throws ServerNotFoundException Thrown when the locator does not know a server application with a server ID + /// of @p id. + idempotent void setServerProcessProxy(string id, Process* proxy) + throws ServerNotFoundException; + } +} diff --git a/Ice/Object.ice b/Ice/Object.ice new file mode 100644 index 0000000..4dc5f31 --- /dev/null +++ b/Ice/Object.ice @@ -0,0 +1,26 @@ +// Copyright (c) ZeroC, Inc. + +#pragma once + +#include "BuiltinSequences.ice" + +["cs:identifier:IceRpc.Slice.Ice"] +module Ice +{ + /// Represents the implicit base interface of all Slice interfaces. + ["cs:identifier:IceObject"] + interface \Object + { + /// Gets the Slice type IDs of all the interfaces implemented by the target service. + /// @return The Slice type IDs of all these interfaces, sorted alphabetically. + idempotent StringSeq ice_ids(); + + /// Tests whether the target service implements the specified interface. + /// @param id The Slice type ID of the interface to test against. + /// @return True when the target service implements this interface; otherwise, false. + idempotent bool ice_isA(string id); + + /// Pings the service. + idempotent void ice_ping(); + } +} diff --git a/Ice/Process.ice b/Ice/Process.ice new file mode 100644 index 0000000..d2352de --- /dev/null +++ b/Ice/Process.ice @@ -0,0 +1,31 @@ +// Copyright (c) ZeroC, Inc. + +#pragma once + +[["cpp:dll-export:ICE_API"]] +[["cpp:doxygen:include:Ice/Ice.h"]] +[["cpp:header-ext:h"]] + +[["js:module:@zeroc/ice"]] + +#include "LocatorRegistry.ice" + +#ifdef __ICERPC__ +["cs:identifier:IceRpc.Slice.Ice"] +#endif +["java:identifier:com.zeroc.Ice"] +module Ice +{ + /// A server application managed by a locator implementation such as IceGrid hosts a Process object and registers a + /// proxy to this object with the locator registry. See {@link LocatorRegistry::setServerProcessProxy}. + interface Process + { + /// Initiates a graceful shutdown of the server application. + void shutdown(); + + /// Writes a message on the server application's stdout or stderr. + /// @param message The message to write. + /// @param fd 1 for stdout, 2 for stderr. + void writeMessage(string message, int fd); + } +} diff --git a/IceRpc/Internal/IceDefinitions.ice b/IceRpc/Internal/IceDefinitions.ice new file mode 100644 index 0000000..6f57fd7 --- /dev/null +++ b/IceRpc/Internal/IceDefinitions.ice @@ -0,0 +1,140 @@ +// Copyright (c) ZeroC, Inc. + +module IceRpc::Internal +{ + // These definitions help with the encoding of ice frames. + + /// Each ice frame has a type identified by this enumeration. + enum IceFrameType + { + Request = 0, + RequestBatch = 1, + Reply = 2, + ValidateConnection = 3, + CloseConnection = 4, + } + + /// The ice frame prologue. + struct IcePrologue + { + byte magic1; + byte magic2; + byte magic3; + byte magic4; + byte protocolMajor; + byte protocolMinor; + byte encodingMajor; + byte encodingMinor; + IceFrameType frameType; + byte compressionStatus; + int frameSize; + } + + /// Specifies the retry behavior of an invocation in case of a (potentially) recoverable error. OperationMode is + /// sent with each ice request to allow the server to verify the assumptions made by the caller. + enum OperationMode + { + /// An ordinary operation. The client runtime guarantees at-most-once semantics for such an operation. + Normal, + + /// Equivalent to {@link #Idempotent}, but deprecated. + ["deprecated:Use Idempotent instead."] + Nonmutating, + + /// An idempotent operation. The client runtime does not guarantee at-most-once semantics for such an + /// operation. + Idempotent, + } + + /// The payload of most request and response frames starts with an encapsulation header that specifies the size of + /// the encapsulation and its encoding. + struct EncapsulationHeader + { + int encapsulationSize; + byte payloadEncodingMajor; + byte payloadEncodingMinor; + } + + /// The identity of a service. + /// @remarks We named this internal struct IceIdentity to avoid confusion with Ice::Identity, the public version + /// of this struct. + struct IceIdentity + { + /// The name of the identity. + string name; + + /// The category of the identity. + string category; + } + + /// The facet of a service. A sequence with 0 elements corresponds to the default, empty facet; a sequence with a + /// single element corresponds to a non-empty facet; and a sequence with more than 1 element is invalid. + sequence Facet; + + /// Each ice request frame has: + /// - a frame prologue, with the frame type and the overall frame size + /// - a request ID + /// - a request header (below) + /// - a request payload, with encapsulationSize - 6 bytes + struct IceRequestHeader + { + IceIdentity identity; + Facet facet; + string operation; + OperationMode operationMode; + // Manually encoded/decoded + // Context context; + // EncapsulationHeader encapsulationHeader; + } + + /// The reply status of an ice response frame. + /// Each ice response frame has: + /// - a frame prologue, with the frame type and the overall frame size + /// - a request ID + /// - a reply status + /// - when reply status is OK or UserException, an encapsulation header followed by a response payload, with + /// encapsulationSize - 6 bytes + enum ReplyStatus + { + /// A successful reply message. + Ok = 0, + + /// A user exception reply message. + UserException = 1, + + /// The target object does not exist. + ObjectNotExistException = 2, + + /// The target object does not support the facet (treated like ObjectNotExistException by IceRPC). + FacetNotExistException = 3, + + /// The target object does not support the operation. + OperationNotExistException = 4, + + /// The dispatch failed with an Ice local exception (not applicable with IceRPC). + UnknownLocalException = 5, + + /// The dispatch failed with a Slice user exception that does not conform to the exception specification of the + /// operation (not applicable with IceRPC). + UnknownUserException = 6, + + /// The dispatch failed with some other exception. + UnknownException = 7, + + /// The dispatch failed because the request payload could not be decoded. This is typically due to a mismatch in the + /// Slice definitions used by the client and the server. + InvalidData = 8, + + /// The caller is not authorized to access the requested resource. + Unauthorized = 9, + } + + /// The data carried by a RequestFailedException (ObjectNotExistException, FacetNotExistException or + /// OperationNotExistException). + struct RequestFailedExceptionData + { + IceIdentity identity; + Facet facet; + string operation; + } +} diff --git a/IceRpc/Slice/Internal/InvocationMode.ice b/IceRpc/Slice/Internal/InvocationMode.ice new file mode 100644 index 0000000..0f5c685 --- /dev/null +++ b/IceRpc/Slice/Internal/InvocationMode.ice @@ -0,0 +1,24 @@ +// Copyright (c) ZeroC, Inc. + +module IceRpc::Slice::Internal +{ + /// A proxy encoded with Slice1 includes an InvocationMode which specifies the behavior when sending requests using + /// this proxy. + enum InvocationMode + { + /// This is the default invocation mode; a request using this mode always expects a response. + Twoway, + + /// Not used by IceRPC. + Oneway, + + /// Not used by IceRPC. + BatchOneway, + + /// Not used by IceRPC. + Datagram, + + /// Not used by IceRPC. + BatchDatagram, + } +} diff --git a/IceRpc/Slice/Internal/TcpServerAddressBody.ice b/IceRpc/Slice/Internal/TcpServerAddressBody.ice new file mode 100644 index 0000000..02a3d53 --- /dev/null +++ b/IceRpc/Slice/Internal/TcpServerAddressBody.ice @@ -0,0 +1,13 @@ +// Copyright (c) ZeroC, Inc. + +module IceRpc::Slice::Internal +{ + /// Represents the body of a tcp or ssl server address in an ice proxy. + struct TcpServerAddressBody + { + string host; + int port; + int timeout; + bool compress; + } +}