activate()
); and
- maintain a dispatch pipeline and servants that handle the requests (see add(com.zeroc.Ice.Object, com.zeroc.Ice.Identity)
,
addDefaultServant(com.zeroc.Ice.Object, java.lang.String)
,
and use(java.util.function.Function<com.zeroc.Ice.Object, com.zeroc.Ice.Object>)
).
An object adapter can dispatch "bidirectional requests"--requests it receives over an outgoing connection instead of a more common incoming connection. It can also dispatch collocated requests (with no connection at all).
-
Method Summary
Modifier and TypeMethodDescriptionvoid
activate()
Starts receiving and dispatching requests received over incoming connections.Adds a servant to this object adapter's Active Servant Map (ASM).void
addDefaultServant
(Object servant, String category) Adds a default servant to handle requests for a specific category.Adds a servant to this object adapter's Active Servant Map (ASM), while specifying a facet.addFacetWithUUID
(Object servant, String facet) Adds a servant to this object adapter's Active Servant Map (ASM), using an automatically generated UUID as its identity.void
addServantLocator
(ServantLocator locator, String category) Adds a ServantLocator to this object adapter for a specific category.addWithUUID
(Object servant) Adds a servant to this object adapter's Active Servant Map (ASM), using an automatically generated UUID as its identity.createDirectProxy
(Identity identity) Creates a direct proxy from an Ice identity.createIndirectProxy
(Identity identity) Creates an indirect proxy for an Ice identity.createProxy
(Identity identity) Creates a proxy from an Ice identity.void
Deactivates this object adapter: stops accepting new connections from clients and closes gracefully all incoming connections created by this object adapter once all outstanding dispatches have completed.void
Decrements the count of direct method calls using this object adapter.void
destroy()
Destroys this object adapter and cleans up all resources associated with it.Gets the dispatch pipeline of this object adapter.protected void
finalize()
Looks up a servant.findAllFacets
(Identity identity) Finds all facets for a given identity in the Active Servant Map.findByProxy
(ObjectPrx proxy) Looks up a servant with an identity and a facet.findDefaultServant
(String category) Finds the default servant for a specific category.Looks up a servant with an identity and facet.findServantLocator
(String category) Finds a ServantLocator registered with this object adapter.void
flushAsyncBatchRequests
(CompressBatch compressBatch, com.zeroc.Ice.CommunicatorFlushBatch outAsync) Flushes any pending batch requests for this object adapter.Gets the communicator that created this object adapter.Endpoint[]
Gets the set of endpoints configured on this object adapter.Gets the Ice locator used by this object adapter.getName()
Gets the name of this object adapter.Endpoint[]
Gets the set of endpoints that proxies created by this object adapter will contain.Gets the SSL engine factory used by this object adapter.com.zeroc.Ice.ThreadPool
Gets the thread pool used by this object adapter.void
hold()
Stops reading requests from incoming connections.void
Increments the count of direct method calls using this object adapter.boolean
Checks whether or notdeactivate()
was called on this object adapter.boolean
isLocal
(com.zeroc.Ice.Reference ref) Checks whether the specified reference refers to a local object.int
Gets the maximum message size for this object adapter.Removes a servant from the object adapter's Active Servant Map.removeAllFacets
(Identity identity) Removes all facets with the given identity from the Active Servant Map.removeDefaultServant
(String category) Removes the default servant for a specific category.removeFacet
(Identity identity, String facet) Removes a servant from the object adapter's Active Servant Map, while specifying a facet.removeServantLocator
(String category) Removes a ServantLocator from this object adapter.void
setAdapterOnConnection
(com.zeroc.Ice.ConnectionI connection) Sets this object adapter on the specified connection.void
setLocator
(LocatorPrx locator) Sets an Ice locator on this object adapter.void
setPublishedEndpoints
(Endpoint[] newEndpoints) Sets the endpoints that proxies created by this object adapter will contain.void
Updates the connection observers for all incoming connection factories.void
Updates the thread observers for the thread pool.Adds a middleware to the dispatch pipeline of this object adapter.void
Waits untildeactivate()
is called on this object adapter and all connections accepted by this object adapter are closed.void
Waits until the object adapter is in the holding state (seehold()
) and the dispatch of requests received over incoming connection has completed.
-
Method Details
-
getName
Gets the name of this object adapter.- Returns:
- This object adapter's name.
-
getCommunicator
Gets the communicator that created this object adapter.- Returns:
- This object adapter's communicator.
- See Also:
-
activate
public void activate()Starts receiving and dispatching requests received over incoming connections.When this object adapter is an indirect object adapter configured with a locator proxy, this method also registers the object adapter's published endpoints with this locator.
- See Also:
-
hold
public void hold()Stops reading requests from incoming connections. Outstanding dispatches are not affected. The object adapter can be reactivated withactivate()
.This method is provided for backward compatibility with older versions of Ice. Don't use it in new applications.
- See Also:
-
waitForHold
public void waitForHold()Waits until the object adapter is in the holding state (seehold()
) and the dispatch of requests received over incoming connection has completed.This method is provided for backward compatibility with older versions of Ice. Don't use it in new applications.
-
deactivate
public void deactivate()Deactivates this object adapter: stops accepting new connections from clients and closes gracefully all incoming connections created by this object adapter once all outstanding dispatches have completed. If this object adapter is indirect, this method also unregisters the object adapter from the locator (seeactivate()
). This method does not cancel outstanding dispatches: it lets them execute until completion. A deactivated object adapter cannot be reactivated again; it can only be destroyed.- See Also:
-
waitForDeactivate
public void waitForDeactivate()Waits untildeactivate()
is called on this object adapter and all connections accepted by this object adapter are closed. A connection is closed only after all outstanding dispatches on this connection have completed. -
isDeactivated
public boolean isDeactivated()Checks whether or notdeactivate()
was called on this object adapter.- Returns:
true
ifdeactivate()
was called on this object adapter,false
otherwise.- See Also:
-
destroy
public void destroy()Destroys this object adapter and cleans up all resources associated with it. Once this method has returned, you can recreate another object adapter with the same name. -
use
Adds a middleware to the dispatch pipeline of this object adapter.All middleware must be installed before the first dispatch.
The middleware are executed in the order they are installed.
- Parameters:
middleware
- The middleware factory that creates the new middleware when this object adapter creates its dispatch pipeline. A middleware factory is a function that takes an Object (the next element in the dispatch pipeline) and returns a new Object (the middleware you want to install in the pipeline).- Returns:
- This object adapter.
- Throws:
IllegalStateException
- Thrown if the object adapter's dispatch pipeline has already been created. This creation typically occurs the first time the object adapter dispatches an incoming request.
-
add
Adds a servant to this object adapter's Active Servant Map (ASM). The ASM is a map {identity, facet} -> servant.This method is equivalent to calling
addFacet(com.zeroc.Ice.Object, com.zeroc.Ice.Identity, java.lang.String)
with an empty facet.- Parameters:
servant
- The servant to add.identity
- The identity of the Ice object that is implemented by the servant.- Returns:
- A proxy for the identity created by this object adapter.
- Throws:
AlreadyRegisteredException
- Thrown when a servant with the same identity is already registered.- See Also:
-
addFacet
Adds a servant to this object adapter's Active Servant Map (ASM), while specifying a facet. The ASM is a map {identity, facet} -> servant.- Parameters:
servant
- The servant to add.identity
- The identity of the Ice object that is implemented by the servant.facet
- The facet of the Ice object that is implemented by the servant.- Returns:
- A proxy for the identity and facet created by this object adapter.
- Throws:
AlreadyRegisteredException
- Thrown when a servant with the same identity and facet is already registered.- See Also:
-
addWithUUID
Adds a servant to this object adapter's Active Servant Map (ASM), using an automatically generated UUID as its identity.- Parameters:
servant
- The servant to add.- Returns:
- A proxy with the generated UUID identity created by this object adapter.
- See Also:
-
addFacetWithUUID
Adds a servant to this object adapter's Active Servant Map (ASM), using an automatically generated UUID as its identity. Also specifies a facet.- Parameters:
servant
- The servant to add.facet
- The facet of the Ice object that is implemented by the servant.- Returns:
- A proxy with the generated UUID identity and the specified facet.
- See Also:
-
addDefaultServant
Adds a default servant to handle requests for a specific category. When an object adapter dispatches an incoming request, it tries to find a servant for the identity and facet carried by the request in the following order: - The object adapter tries to find a servant for the identity and facet in the Active Servant Map. - If this fails, the object adapter tries to find a default servant for the category component of the identity. - If this fails, the object adapter tries to find a default servant for the empty category, regardless of the category contained in the identity. - If this fails, the object adapter tries to find a servant locator for the category component of the identity. If there is no such servant locator, the object adapter tries to find a servant locator for the empty category. - If a servant locator is found, the object adapter tries to find a servant using this servant locator. - If all the previous steps fail, the object adapter gives up and the caller receives anObjectNotExistException
or aFacetNotExistException
.- Parameters:
servant
- The default servant to add.category
- The category for which the default servant is registered. The empty category means it handles all categories.- Throws:
AlreadyRegisteredException
- Thrown when a default servant with the same category is already registered.- See Also:
-
remove
Removes a servant from the object adapter's Active Servant Map.- Parameters:
identity
- The identity of the Ice object that is implemented by the servant.- Returns:
- The removed servant.
- Throws:
NotRegisteredException
- Thrown when no servant with the given identity is registered.- See Also:
-
removeFacet
Removes a servant from the object adapter's Active Servant Map, while specifying a facet.- Parameters:
identity
- The identity of the Ice object that is implemented by the servant.facet
- The facet. An empty facet means the default facet.- Returns:
- The removed servant.
- Throws:
NotRegisteredException
- Thrown when no servant with the given identity and facet is registered.- See Also:
-
removeAllFacets
Removes all facets with the given identity from the Active Servant Map. The method completely removes the Ice object, including its default facet.- Parameters:
identity
- The identity of the Ice object to be removed.- Returns:
- A collection containing all the facet names and servants of the removed Ice object.
- Throws:
NotRegisteredException
- Thrown when no servant with the given identity is registered.- See Also:
-
removeDefaultServant
Removes the default servant for a specific category.- Parameters:
category
- The category of the default servant to remove.- Returns:
- The default servant.
- Throws:
NotRegisteredException
- Thrown when no default servant is registered for the given category.- See Also:
-
find
Looks up a servant.This method only tries to find the servant in the ASM and among the default servants. It does not attempt to locate a servant using servant locators.
- Parameters:
identity
- The identity of an Ice object.- Returns:
- The servant that implements the Ice object with the given identity, or null if no such servant has been found.
- See Also:
-
findFacet
Looks up a servant with an identity and facet.This method only tries to find the servant in the ASM and among the default servants. It does not attempt to locate a servant using servant locators.
- Parameters:
identity
- The identity of an Ice object.facet
- The facet of an Ice object. An empty facet means the default facet.- Returns:
- The servant that implements the Ice object with the given identity and facet, or null if no such servant has been found.
- See Also:
-
findAllFacets
Finds all facets for a given identity in the Active Servant Map.- Parameters:
identity
- The identity.- Returns:
- A collection containing all the facet names and servants that have been found. Can be empty.
- See Also:
-
findByProxy
Looks up a servant with an identity and a facet. It's equivalent to callingfindFacet(com.zeroc.Ice.Identity, java.lang.String)
.- Parameters:
proxy
- The proxy that provides the identity and facet to search.- Returns:
- The servant that matches the identity and facet carried by the proxy, or null if no such servant has been found.
- See Also:
-
addServantLocator
Adds a ServantLocator to this object adapter for a specific category.- Parameters:
locator
- The servant locator to add.category
- The category. The empty category means the locator handles all categories.- Throws:
AlreadyRegisteredException
- Thrown when a servant locator with the same category is already registered.- See Also:
-
removeServantLocator
Removes a ServantLocator from this object adapter.- Parameters:
category
- The category.- Returns:
- The servant locator.
- Throws:
NotRegisteredException
- Thrown when no ServantLocator with the given category is registered.- See Also:
-
findServantLocator
Finds a ServantLocator registered with this object adapter.- Parameters:
category
- The category.- Returns:
- The servant locator, or null if not found.
- See Also:
-
findDefaultServant
Finds the default servant for a specific category.- Parameters:
category
- The category.- Returns:
- The default servant, or null if not found.
- See Also:
-
dispatchPipeline
Gets the dispatch pipeline of this object adapter.- Returns:
- The dispatch pipeline. The returned value is never null.
-
createProxy
Creates a proxy from an Ice identity. If this object adapter is configured with an adapter ID, the proxy is an indirect proxy that refers to this adapter ID. If a replica group ID is also defined, the proxy is an indirect proxy that refers to this replica group ID. Otherwise, the proxy is a direct proxy containing this object adapter's published endpoints.- Parameters:
identity
- An Ice identity.- Returns:
- A proxy with the given identity.
- See Also:
-
createDirectProxy
Creates a direct proxy from an Ice identity.- Parameters:
identity
- An Ice identity.- Returns:
- A proxy with the given identity and this published endpoints of this object adapter.
- See Also:
-
createIndirectProxy
Creates an indirect proxy for an Ice identity.- Parameters:
identity
- An Ice identity.- Returns:
- An indirect proxy with the given identity. If this object adapter is not configured with an adapter ID or a replica group ID, the new proxy is a well-known proxy (i.e., an identity-only proxy).
- See Also:
-
setLocator
Sets an Ice locator on this object adapter.- Parameters:
locator
- The locator used by this object adapter.- See Also:
-
getLocator
Gets the Ice locator used by this object adapter.- Returns:
- The locator used by this object adapter, or null if no locator is used by this object adapter.
- See Also:
-
getEndpoints
Gets the set of endpoints configured on this object adapter.This method remains usable after the object adapter has been deactivated.
- Returns:
- The set of endpoints.
- See Also:
-
getPublishedEndpoints
Gets the set of endpoints that proxies created by this object adapter will contain.This method remains usable after the object adapter has been deactivated.
- Returns:
- The set of published endpoints.
- See Also:
-
setPublishedEndpoints
Sets the endpoints that proxies created by this object adapter will contain.- Parameters:
newEndpoints
- The new set of endpoints that the object adapter will embed in proxies.- See Also:
-
isLocal
public boolean isLocal(com.zeroc.Ice.Reference ref) Checks whether the specified reference refers to a local object.- Parameters:
ref
- the reference to check- Returns:
- true if the reference refers to a local object, false otherwise
-
flushAsyncBatchRequests
public void flushAsyncBatchRequests(CompressBatch compressBatch, com.zeroc.Ice.CommunicatorFlushBatch outAsync) Flushes any pending batch requests for this object adapter.- Parameters:
compressBatch
- indicates whether to compress the batch requestsoutAsync
- the callback for the asynchronous flush operation
-
updateConnectionObservers
public void updateConnectionObservers()Updates the connection observers for all incoming connection factories. -
updateThreadObservers
public void updateThreadObservers()Updates the thread observers for the thread pool. -
incDirectCount
public void incDirectCount()Increments the count of direct method calls using this object adapter. -
decDirectCount
public void decDirectCount()Decrements the count of direct method calls using this object adapter. -
getThreadPool
public com.zeroc.Ice.ThreadPool getThreadPool()Gets the thread pool used by this object adapter.- Returns:
- the thread pool used by this object adapter
-
setAdapterOnConnection
public void setAdapterOnConnection(com.zeroc.Ice.ConnectionI connection) Sets this object adapter on the specified connection.- Parameters:
connection
- the connection to set the adapter on
-
messageSizeMax
public int messageSizeMax()Gets the maximum message size for this object adapter.- Returns:
- the maximum message size in bytes
-
getSSLEngineFactory
Gets the SSL engine factory used by this object adapter.- Returns:
- the SSL engine factory
-
finalize
-