/** * This method overrides the org.omg.CORBA.portable.Delegate.equals method, * and does the equality check based on IOR equality. */ public boolean equals(org.omg.CORBA.Object self, java.lang.Object other) { if (other == null) return false ; if (!StubAdapter.isStub(other)) { return false; } Delegate delegate = StubAdapter.getDelegate( other ) ; if (delegate == null) return false ; if (delegate instanceof CorbaClientDelegateImpl) { CorbaClientDelegateImpl otherDel = (CorbaClientDelegateImpl) delegate ; IOR otherIor = otherDel.contactInfoList.getTargetIOR(); return this.contactInfoList.getTargetIOR().equals(otherIor); } // Come here if other is not implemented by our ORB. return false; }
private boolean isLocal() { boolean result = false ; Delegate delegate = StubAdapter.getDelegate( stub ) ; if (delegate instanceof CorbaClientDelegate) { CorbaClientDelegate cdel = (CorbaClientDelegate)delegate ; ContactInfoList cil = cdel.getContactInfoList() ; if (cil instanceof CorbaContactInfoList) { CorbaContactInfoList ccil = (CorbaContactInfoList)cil ; LocalClientRequestDispatcher lcrd = ccil.getLocalClientRequestDispatcher() ; result = lcrd.useLocalInvocation( null ) ; } } return result ; }
public Delegate getDelegate( ORB orb ) { // write the IOR components to an org.omg.CORBA.portable.OutputStream OutputStream ostr = orb.create_output_stream(); ostr.write_long(typeData.length); ostr.write_octet_array(typeData, 0, typeData.length); ostr.write_long(profileTags.length); for (int i = 0; i < profileTags.length; i++) { ostr.write_long(profileTags[i]); ostr.write_long(profileData[i].length); ostr.write_octet_array(profileData[i], 0, profileData[i].length); } InputStream istr = ostr.create_input_stream() ; // read the IOR back from the stream org.omg.CORBA.Object obj = (org.omg.CORBA.Object)istr.read_Object(); return StubAdapter.getDelegate( obj ) ; }
/** * Cast the passed object into the Policy. If the * object has a different java type, create an instance * of the _PolicyStub, using the same delegate, as for * the passed parameter. Hence, unlike java type cast, * this method may return a different object, than has been passed. * * @param obj the object to narrow. * @return narrowed instance. * @throws BAD_PARAM if the passed object is not a Policy. */ public static Policy narrow(org.omg.CORBA.Object obj) { if (obj == null) return null; else if (obj instanceof Policy) return (Policy) obj; else { // Check for the policy id cannot be performed because // this helper must read various subclasses of the Policy, // and the IOR profile currently supports only one id. Delegate delegate = ((ObjectImpl) obj)._get_delegate(); return new _PolicyStub(delegate); } }
/** * Cast the passed object into the NamingContext. If the * object has a different java type, create an instance * of the NamingContext, using the same delegate, as for * the passed parameter. * * If the object repository Id indicates that it is an instance of * {@link NamingContextExt} that is a subclass of the NamingContext, * the functionality is delegated to {@link NamingContextHelper#narrow}. * * @param obj the object to cast. * @return casted instance. * * @throws BAD_PARAM if the passed object is not an instance of * {@link NamingContext} or {@link NamingContextExt}. */ public static NamingContext narrow(org.omg.CORBA.Object obj) { if (obj == null) return null; else if (obj instanceof NamingContext) return (NamingContext) obj; else if (obj._is_a(id())) { Delegate delegate = ((ObjectImpl) obj)._get_delegate(); return new _NamingContextStub(delegate); } else if (obj._is_a(NamingContextExtHelper.id())) return NamingContextExtHelper.narrow(obj); else throw new BAD_PARAM(); }
/** * Get the IOR reference string for the given object. The string embeds * information about the object repository Id, its access key and the server * internet address and port. With this information, the object can be found * by another ORB, possibly located on remote computer. * * @param forObject CORBA object * @return the object IOR representation. * * @throws BAD_PARAM if the object has not been previously connected to this * ORB. * * @throws BAD_OPERATION in the unlikely case if the local host address cannot * be resolved. * * @see string_to_object(String) */ public String object_to_string(org.omg.CORBA.Object forObject) { // Handle the case when the object is known, but not local. if (forObject instanceof ObjectImpl) { Delegate delegate = ((ObjectImpl) forObject)._get_delegate(); if (delegate instanceof SimpleDelegate) return ((SimpleDelegate) delegate).getIor().toStringifiedReference(); } // Handle the case when the object is local. Connected_objects.cObject rec = connected_objects.getKey(forObject); if (rec == null) throw new BAD_PARAM("The object " + forObject + " has not been previously connected to this ORB" ); IOR ior = createIOR(rec); return ior.toStringifiedReference(); }