Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update createProxy to return a non-optional ObjectPrx #1817

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cpp/include/Ice/Connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ class ICE_CLASS(ICE_API) Connection
* @return A proxy that matches the given identity and uses this connection.
* @see #setAdapter
*/
virtual std::optional<Ice::ObjectPrx> createProxy(const Identity& id) const = 0;
virtual ObjectPrx createProxy(const Identity& id) const = 0;

/**
* Explicitly set an object adapter that dispatches requests that are received over this connection. A client can
Expand Down
6 changes: 3 additions & 3 deletions cpp/include/Ice/ObjectAdapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ class ICE_CLASS(ICE_API) ObjectAdapter
* @return A proxy for the object with the given identity.
* @see Identity
*/
virtual std::optional<ObjectPrx> createProxy(const Identity& id) const = 0;
virtual ObjectPrx createProxy(const Identity& id) const = 0;

/**
* Create a direct proxy for the object with the given identity. The returned proxy contains this object adapter's
Expand All @@ -368,7 +368,7 @@ class ICE_CLASS(ICE_API) ObjectAdapter
* @return A proxy for the object with the given identity.
* @see Identity
*/
virtual std::optional<ObjectPrx> createDirectProxy(const Identity& id) const = 0;
virtual ObjectPrx createDirectProxy(const Identity& id) const = 0;

/**
* Create an indirect proxy for the object with the given identity. If this object adapter is configured with an
Expand All @@ -378,7 +378,7 @@ class ICE_CLASS(ICE_API) ObjectAdapter
* @return A proxy for the object with the given identity.
* @see Identity
*/
virtual std::optional<ObjectPrx> createIndirectProxy(const Identity& id) const = 0;
virtual ObjectPrx createIndirectProxy(const Identity& id) const = 0;

/**
* Set an Ice locator for this object adapter. By doing so, the object adapter will register itself with the
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/Glacier2/Blobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Glacier2::Blobject::updateObserver(const shared_ptr<Glacier2::Instrumentation::S
}

void
Glacier2::Blobject::invoke(ObjectPrxPtr& proxy,
Glacier2::Blobject::invoke(ObjectPrx& proxy,
const std::pair<const Byte*, const Byte*>& inParams,
function<void(bool, const pair<const Byte*, const Byte*>&)> response,
function<void(exception_ptr)> exception,
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/Glacier2/Blobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Blobject : public Ice::BlobjectArrayAsync, public std::enable_shared_from_

protected:

void invoke(Ice::ObjectPrxPtr&,
void invoke(Ice::ObjectPrx&,
const std::pair<const Ice::Byte*, const Ice::Byte*>&,
std::function<void(bool, const std::pair<const Ice::Byte*, const Ice::Byte*>&)>,
std::function<void(std::exception_ptr)>,
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/Glacier2/ClientBlobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ Glacier2::ClientBlobject::ice_invokeAsync(pair<const Byte*, const Byte*> inParam
throw ObjectNotExistException(__FILE__, __LINE__, current.id, "", "");
}

invoke(proxy, inParams, std::move(response), std::move(error), current);
invoke(proxy.value(), inParams, std::move(response), std::move(error), current);
}

shared_ptr<StringSet>
Expand Down
2 changes: 0 additions & 2 deletions cpp/src/Glacier2/ServerBlobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,5 @@ Glacier2::ServerBlobject::ice_invokeAsync(pair<const Byte*, const Byte*> inParam
const Current& current)
{
auto proxy = _reverseConnection->createProxy(current.id);
assert(proxy);

invoke(proxy, inParams, std::move(response), std::move(error), current);
}
2 changes: 1 addition & 1 deletion cpp/src/Ice/ConnectionI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1280,7 +1280,7 @@ Ice::ConnectionI::getEndpoint() const noexcept
return _endpoint; // No mutex protection necessary, _endpoint is immutable.
}

optional<ObjectPrx>
ObjectPrx
Ice::ConnectionI::createProxy(const Identity& ident) const
{
checkIdentity(ident, __FILE__, __LINE__);
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/Ice/ConnectionI.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class ConnectionI : public Connection,
virtual void setAdapter(const ObjectAdapterPtr&); // From Connection.
virtual ObjectAdapterPtr getAdapter() const noexcept; // From Connection.
virtual EndpointPtr getEndpoint() const noexcept; // From Connection.
virtual std::optional<ObjectPrx> createProxy(const Identity& ident) const; // From Connection.
virtual ObjectPrx createProxy(const Identity& ident) const; // From Connection.

void setAdapterAndServantManager(const ObjectAdapterPtr&, const IceInternal::ServantManagerPtr&);

Expand Down
4 changes: 2 additions & 2 deletions cpp/src/Ice/Instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ IceInternal::Instance::createAdmin(const ObjectAdapterPtr& adminAdapter, const I
}
}
setServerProcessProxy(adapter, adminIdentity);
return adapter->createProxy(adminIdentity).value();
return adapter->createProxy(adminIdentity);
}

std::optional<ObjectPrx>
Expand Down Expand Up @@ -702,7 +702,7 @@ IceInternal::Instance::addAllAdminFacets()
void
IceInternal::Instance::setServerProcessProxy(const ObjectAdapterPtr& adminAdapter, const Identity& adminIdentity)
{
ObjectPrx admin = adminAdapter->createProxy(adminIdentity).value();
ObjectPrx admin = adminAdapter->createProxy(adminIdentity);
optional<LocatorPrx> locator = adminAdapter->getLocator();
const string serverId = _initData.properties->getProperty("Ice.Admin.ServerId");
if(locator && serverId != "")
Expand Down
43 changes: 10 additions & 33 deletions cpp/src/Ice/ObjectAdapterI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ Ice::ObjectAdapterI::addFacet(const shared_ptr<Object>& object, const Identity&

_servantManager->addServant(object, ident, facet);

return newProxy(ident, facet).value();
return newProxy(ident, facet);
}

ObjectPrx
Expand Down Expand Up @@ -524,7 +524,7 @@ Ice::ObjectAdapterI::findServantLocator(const string& prefix) const
return _servantManager->findServantLocator(prefix);
}

optional<ObjectPrx>
ObjectPrx
Ice::ObjectAdapterI::createProxy(const Identity& ident) const
{
lock_guard lock(_mutex);
Expand All @@ -535,7 +535,7 @@ Ice::ObjectAdapterI::createProxy(const Identity& ident) const
return newProxy(ident, "");
}

optional<ObjectPrx>
ObjectPrx
Ice::ObjectAdapterI::createDirectProxy(const Identity& ident) const
{
lock_guard lock(_mutex);
Expand All @@ -546,7 +546,7 @@ Ice::ObjectAdapterI::createDirectProxy(const Identity& ident) const
return newDirectProxy(ident, "");
}

optional<ObjectPrx>
ObjectPrx
Ice::ObjectAdapterI::createIndirectProxy(const Identity& ident) const
{
lock_guard lock(_mutex);
Expand Down Expand Up @@ -1069,7 +1069,7 @@ Ice::ObjectAdapterI::~ObjectAdapterI()
}
}

std::optional<ObjectPrx>
ObjectPrx
Ice::ObjectAdapterI::newProxy(const Identity& ident, const string& facet) const
{
if(_id.empty())
Expand All @@ -1086,43 +1086,20 @@ Ice::ObjectAdapterI::newProxy(const Identity& ident, const string& facet) const
}
}

std::optional<ObjectPrx>
ObjectPrx
Ice::ObjectAdapterI::newDirectProxy(const Identity& ident, const string& facet) const
{
//
// Create a reference and return a proxy for this reference.
//
ReferencePtr ref = _instance->referenceFactory()->create(ident, facet, _reference, _publishedEndpoints);

if (ref)
{
return ObjectPrx::_fromReference(std::move(ref));
}
else
{
return std::nullopt;
}
return ObjectPrx::_fromReference(
_instance->referenceFactory()->create(ident, facet, _reference, _publishedEndpoints));
}

std::optional<ObjectPrx>
ObjectPrx
Ice::ObjectAdapterI::newIndirectProxy(const Identity& ident, const string& facet, const string& id) const
{
//
// Create an indirect reference with the given adapter id.
//
ReferencePtr ref = _instance->referenceFactory()->create(ident, facet, _reference, id);

//
// Return a proxy for the reference.
//
if (ref)
{
return ObjectPrx::_fromReference(std::move(ref));
}
else
{
return std::nullopt;
}
return ObjectPrx::_fromReference(_instance->referenceFactory()->create(ident, facet, _reference, id));
}

void
Expand Down
12 changes: 6 additions & 6 deletions cpp/src/Ice/ObjectAdapterI.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ class ObjectAdapterI final : public ObjectAdapter, public std::enable_shared_fro
std::shared_ptr<ServantLocator> removeServantLocator(const std::string&) final;
std::shared_ptr<ServantLocator> findServantLocator(const std::string&) const final;

std::optional<ObjectPrx> createProxy(const Identity&) const final;
std::optional<ObjectPrx> createDirectProxy(const Identity&) const final;
std::optional<ObjectPrx> createIndirectProxy(const Identity&) const final;
ObjectPrx createProxy(const Identity&) const final;
ObjectPrx createDirectProxy(const Identity&) const final;
ObjectPrx createIndirectProxy(const Identity&) const final;

void setLocator(const std::optional<LocatorPrx>&) final;
std::optional<LocatorPrx> getLocator() const noexcept;
Expand Down Expand Up @@ -105,9 +105,9 @@ class ObjectAdapterI final : public ObjectAdapter, public std::enable_shared_fro
void initialize(std::optional<RouterPrx>);
friend class IceInternal::ObjectAdapterFactory;

std::optional<ObjectPrx> newProxy(const Identity&, const std::string&) const;
std::optional<ObjectPrx> newDirectProxy(const Identity&, const std::string&) const;
std::optional<ObjectPrx> newIndirectProxy(const Identity&, const std::string&, const std::string&) const;
ObjectPrx newProxy(const Identity&, const std::string&) const;
ObjectPrx newDirectProxy(const Identity&, const std::string&) const;
ObjectPrx newIndirectProxy(const Identity&, const std::string&, const std::string&) const;
void checkForDeactivation() const;
std::vector<IceInternal::EndpointIPtr> parseEndpoints(const std::string&, bool) const;
std::vector<IceInternal::EndpointIPtr> computePublishedEndpoints();
Expand Down
15 changes: 3 additions & 12 deletions cpp/src/Ice/ReferenceFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ IceInternal::ReferenceFactory::create(const Identity& ident,
const ReferencePtr& tmpl,
const vector<EndpointIPtr>& endpoints)
{
if(ident.name.empty() && ident.category.empty())
{
return 0;
}
assert(!ident.name.empty());

return create(ident, facet, tmpl->getMode(), tmpl->getSecure(), tmpl->getProtocol(), tmpl->getEncoding(),
endpoints, "", "");
Expand All @@ -47,10 +44,7 @@ IceInternal::ReferenceFactory::create(const Identity& ident,
const ReferencePtr& tmpl,
const string& adapterId)
{
if(ident.name.empty() && ident.category.empty())
{
return 0;
}
assert(!ident.name.empty());

return create(ident, facet, tmpl->getMode(), tmpl->getSecure(), tmpl->getProtocol(), tmpl->getEncoding(),
vector<EndpointIPtr>(), adapterId, "");
Expand All @@ -59,10 +53,7 @@ IceInternal::ReferenceFactory::create(const Identity& ident,
ReferencePtr
IceInternal::ReferenceFactory::create(const Identity& ident, const Ice::ConnectionIPtr& connection)
{
if(ident.name.empty() && ident.category.empty())
{
return 0;
}
assert(!ident.name.empty());

//
// Create new reference
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/IceGrid/WellKnownObjectsManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ WellKnownObjectsManager::WellKnownObjectsManager(const shared_ptr<Database>& dat
}

void
WellKnownObjectsManager::add(const Ice::ObjectPrxPtr& proxy, const string& type)
WellKnownObjectsManager::add(const Ice::ObjectPrx& proxy, const string& type)
{
assert(!_initialized);
ObjectInfo info = { proxy, type };
_wellKnownObjects.push_back(std::move(info));
}

void
WellKnownObjectsManager::addEndpoint(const string& name, const Ice::ObjectPrxPtr& proxy)
WellKnownObjectsManager::addEndpoint(const string& name, const Ice::ObjectPrx& proxy)
{
_endpoints.insert(make_pair(name, proxy));
}
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/IceGrid/WellKnownObjectsManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ class WellKnownObjectsManager

WellKnownObjectsManager(const std::shared_ptr<Database>&);

void add(const Ice::ObjectPrxPtr&, const std::string&);
void addEndpoint(const std::string&, const Ice::ObjectPrxPtr&);
void add(const Ice::ObjectPrx&, const std::string&);
void addEndpoint(const std::string&, const Ice::ObjectPrx&);
void finish();

void registerAll();
Expand Down
2 changes: 1 addition & 1 deletion cpp/test/Ice/echo/BlobjectI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ BlobjectI::ice_invokeAsync(std::vector<Ice::Byte> inEncaps,
}
if(_batchProxy)
{
obj = _batchProxy;
obj = _batchProxy.value();
}

if(!current.facet.empty())
Expand Down
11 changes: 2 additions & 9 deletions swift/src/IceImpl/Connection.mm
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,8 @@ -(nullable ICEObjectPrx*) createProxy:(NSString*)name category:(NSString*)catego
{
try
{
auto cppPrx = self.connection->createProxy(Ice::Identity{fromNSString(name), fromNSString(category)});
if (cppPrx)
{
return [[ICEObjectPrx alloc] initWithCppObjectPrx:cppPrx.value()];
}
else
{
return nil;
}
auto prx = self.connection->createProxy(Ice::Identity{fromNSString(name), fromNSString(category)});
return [[ICEObjectPrx alloc] initWithCppObjectPrx:prx];
}
catch(const std::exception& ex)
{
Expand Down
27 changes: 3 additions & 24 deletions swift/src/IceImpl/ObjectAdapter.mm
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,7 @@ -(nullable ICEObjectPrx*) createProxy:(NSString*)name category:(NSString*)catego
try
{
auto prx = self.objectAdapter->createProxy(Ice::Identity{fromNSString(name), fromNSString(category)});
if (prx)
{
return [[ICEObjectPrx alloc] initWithCppObjectPrx:prx.value()];
}
else
{
return nil;
}
return [[ICEObjectPrx alloc] initWithCppObjectPrx:prx];
}
catch(const std::exception& ex)
{
Expand All @@ -120,14 +113,7 @@ -(nullable ICEObjectPrx*) createDirectProxy:(NSString*)name category:(NSString*)
try
{
auto prx = self.objectAdapter->createDirectProxy(Ice::Identity{fromNSString(name), fromNSString(category)});
if (prx)
{
return [[ICEObjectPrx alloc] initWithCppObjectPrx:prx.value()];
}
else
{
return nil;
}
return [[ICEObjectPrx alloc] initWithCppObjectPrx:prx];
}
catch(const std::exception& ex)
{
Expand All @@ -141,14 +127,7 @@ -(nullable ICEObjectPrx*) createIndirectProxy:(NSString*)name category:(NSString
try
{
auto prx = self.objectAdapter->createIndirectProxy(Ice::Identity{fromNSString(name), fromNSString(category)});
if (prx)
{
return [[ICEObjectPrx alloc] initWithCppObjectPrx:prx.value()];
}
else
{
return nil;
}
return [[ICEObjectPrx alloc] initWithCppObjectPrx:prx];
}
catch(const std::exception& ex)
{
Expand Down
Loading