protected VipFullDataReaderPrx getVipFullDataReaderPrx(int userId) { Ice.ObjectPrx prx0 = getValidProxy(userId, service_name, 300); if (prx0 != null) { VipFullDataReaderPrx prx = VipFullDataReaderPrxHelper.uncheckedCast(prx0.ice_timeout(300).ice_twoway()); return prx; } else { return null; } }
/** * Initializes this class with the passed proxy. * * @param proxy The proxy for this instance. */ public ProxyIdentityFacetKey(Ice.ObjectPrx proxy) { _proxy = proxy; // // Cache the identity and facet, and compute the hash code. // _identity = proxy.ice_getIdentity(); _facet = proxy.ice_getFacet(); int h = _identity.hashCode(); h = 5 * h + _facet.hashCode(); _hashCode = h; }
public static HeatmapInfoPrx checkedCast(Ice.ObjectPrx __obj, String __facet) { HeatmapInfoPrx __d = null; if (__obj != null) { Ice.ObjectPrx __bb = __obj.ice_facet(__facet); try { if (__bb.ice_isA(ice_staticId())) { HeatmapInfoPrxHelper __h = new HeatmapInfoPrxHelper(); __h.__copyFrom(__bb); __d = __h; } } catch (Ice.FacetNotExistException ex) { } } return __d; }
public static LaboratoryFactoryPrx checkedCast( Ice.ObjectPrx __obj, String __facet, java.util.Map<String, String> __ctx) { LaboratoryFactoryPrx __d = null; if (__obj != null) { Ice.ObjectPrx __bb = __obj.ice_facet(__facet); try { if (__bb.ice_isA(ice_staticId(), __ctx)) { LaboratoryFactoryPrxHelper __h = new LaboratoryFactoryPrxHelper(); __h.__copyFrom(__bb); __d = __h; } } catch (Ice.FacetNotExistException ex) { } } return __d; }
private void setServerProcessProxy(Ice.ObjectAdapter adminAdapter, Ice.Identity adminIdentity) { Ice.ObjectPrx admin = adminAdapter.createProxy(adminIdentity); Ice.LocatorPrx locator = adminAdapter.getLocator(); String serverId = _initData.properties.getProperty("Ice.Admin.ServerId"); if (locator != null && !serverId.isEmpty()) { Ice.ProcessPrx process = Ice.ProcessPrxHelper.uncheckedCast(admin.ice_facet("Process")); try { // // Note that as soon as the process proxy is registered, the communicator might be // shutdown by a remote client and admin facets might start receiving calls. // locator.getRegistry().setServerProcessProxy(serverId, process); } catch (Ice.ServerNotFoundException ex) { if (_traceLevels.location >= 1) { StringBuilder s = new StringBuilder(128); s.append("couldn't register server `"); s.append(serverId); s.append("' with the locator registry:\n"); s.append("the server is not known to the locator registry"); _initData.logger.trace(_traceLevels.locationCat, s.toString()); } throw new Ice.InitializationException( "Locator knows nothing about server `" + serverId + "'"); } catch (Ice.LocalException ex) { if (_traceLevels.location >= 1) { StringBuilder s = new StringBuilder(128); s.append("couldn't register server `"); s.append(serverId); s.append("' with the locator registry:\n"); s.append(ex.toString()); _initData.logger.trace(_traceLevels.locationCat, s.toString()); } throw ex; } if (_traceLevels.location >= 1) { StringBuilder s = new StringBuilder(128); s.append("registered server `"); s.append(serverId); s.append("' with the locator registry"); _initData.logger.trace(_traceLevels.locationCat, s.toString()); } } }
public static HeatmapInfoPrx uncheckedCast(Ice.ObjectPrx __obj, String __facet) { HeatmapInfoPrx __d = null; if (__obj != null) { Ice.ObjectPrx __bb = __obj.ice_facet(__facet); HeatmapInfoPrxHelper __h = new HeatmapInfoPrxHelper(); __h.__copyFrom(__bb); __d = __h; } return __d; }
public static LaboratoryFactoryPrx uncheckedCast(Ice.ObjectPrx __obj, String __facet) { LaboratoryFactoryPrx __d = null; if (__obj != null) { Ice.ObjectPrx __bb = __obj.ice_facet(__facet); LaboratoryFactoryPrxHelper __h = new LaboratoryFactoryPrxHelper(); __h.__copyFrom(__bb); __d = __h; } return __d; }
public static HeatmapInfoPrx checkedCast(Ice.ObjectPrx __obj) { HeatmapInfoPrx __d = null; if (__obj != null) { if (__obj instanceof HeatmapInfoPrx) { __d = (HeatmapInfoPrx) __obj; } else { if (__obj.ice_isA(ice_staticId())) { HeatmapInfoPrxHelper __h = new HeatmapInfoPrxHelper(); __h.__copyFrom(__obj); __d = __h; } } } return __d; }
public static LaboratoryFactoryPrx checkedCast(Ice.ObjectPrx __obj) { LaboratoryFactoryPrx __d = null; if (__obj != null) { try { __d = (LaboratoryFactoryPrx) __obj; } catch (ClassCastException ex) { if (__obj.ice_isA(ice_staticId())) { LaboratoryFactoryPrxHelper __h = new LaboratoryFactoryPrxHelper(); __h.__copyFrom(__obj); __d = __h; } } } return __d; }
public static SourcePrx checkedCast(Ice.ObjectPrx __obj, java.util.Map<String, String> __ctx) { SourcePrx __d = null; if (__obj != null) { if (__obj instanceof SourcePrx) { __d = (SourcePrx) __obj; } else { if (__obj.ice_isA(ice_staticId(), __ctx)) { SourcePrxHelper __h = new SourcePrxHelper(); __h.__copyFrom(__obj); __d = __h; } } } return __d; }
@Override public int run(String[] args) { args = communicator().getProperties().parseCommandLineOptions("Clock", args); String topicName = "time"; String option = "None"; boolean batch = false; String id = null; String retryCount = null; int i; for (i = 0; i < args.length; ++i) { String oldoption = option; if (args[i].equals("--datagram")) { option = "Datagram"; } else if (args[i].equals("--twoway")) { option = "Twoway"; } else if (args[i].equals("--ordered")) { option = "Ordered"; } else if (args[i].equals("--oneway")) { option = "Oneway"; } else if (args[i].equals("--batch")) { batch = true; } else if (args[i].equals("--id")) { ++i; if (i >= args.length) { usage(); return 1; } id = args[i]; } else if (args[i].equals("--retryCount")) { ++i; if (i >= args.length) { usage(); return 1; } retryCount = args[i]; } else if (args[i].startsWith("--")) { usage(); return 1; } else { topicName = args[i++]; break; } if (!oldoption.equals(option) && !oldoption.equals("None")) { usage(); return 1; } } if (i != args.length) { usage(); return 1; } if (retryCount != null) { if (option.equals("None")) { option = "Twoway"; } else if (!option.equals("Twoway") && !option.equals("Ordered")) { usage(); return 1; } } if (batch && (option.equals("Twoway") || option.equals("Ordered"))) { System.err.println(appName() + ": batch can only be set with oneway or datagram"); return 1; } IceStorm.TopicManagerPrx manager = IceStorm.TopicManagerPrxHelper.checkedCast( communicator().propertyToProxy("TopicManager.Proxy")); if (manager == null) { System.err.println("invalid proxy"); return 1; } // // Retrieve the topic. // IceStorm.TopicPrx topic; try { topic = manager.retrieve(topicName); } catch (IceStorm.NoSuchTopic e) { try { topic = manager.create(topicName); } catch (IceStorm.TopicExists ex) { System.err.println(appName() + ": temporary failure, try again."); return 1; } } Ice.ObjectAdapter adapter = communicator().createObjectAdapter("Clock.Subscriber"); // // Add a servant for the Ice object. If --id is used the // identity comes from the command line, otherwise a UUID is // used. // // id is not directly altered since it is used below to detect // whether subscribeAndGetPublisher can raise // AlreadySubscribed. // Ice.Identity subId = new Ice.Identity(id, ""); if (subId.name == null) { subId.name = java.util.UUID.randomUUID().toString(); } Ice.ObjectPrx subscriber = adapter.add(new ClockI(), subId); // // Activate the object adapter before subscribing. // adapter.activate(); java.util.Map<String, String> qos = new java.util.HashMap<String, String>(); if (retryCount != null) { qos.put("retryCount", retryCount); } // // Set up the proxy. // if (option.equals("Datagram")) { if (batch) { subscriber = subscriber.ice_batchDatagram(); } else { subscriber = subscriber.ice_datagram(); } } else if (option.equals("Twoway")) { // Do nothing to the subscriber proxy. Its already twoway. } else if (option.equals("Ordered")) { // Do nothing to the subscriber proxy. Its already twoway. qos.put("reliability", "ordered"); } else if (option.equals("Oneway") || option.equals("None")) { if (batch) { subscriber = subscriber.ice_batchOneway(); } else { subscriber = subscriber.ice_oneway(); } } try { topic.subscribeAndGetPublisher(qos, subscriber); } catch (IceStorm.AlreadySubscribed e) { // If we're manually setting the subscriber id ignore. if (id == null) { e.printStackTrace(); return 1; } else { System.out.println("reactivating persistent subscriber"); } } catch (IceStorm.InvalidSubscriber e) { e.printStackTrace(); return 1; } catch (IceStorm.BadQoS e) { e.printStackTrace(); return 1; } shutdownOnInterrupt(); communicator().waitForShutdown(); topic.unsubscribe(subscriber); return 0; }
private void updateLocatorRegistry( IceInternal.LocatorInfo locatorInfo, Ice.ObjectPrx proxy, boolean registerProcess) { if (!registerProcess && _id.length() == 0) { return; // Nothing to update. } // // Call on the locator registry outside the synchronization to // blocking other threads that need to lock this OA. // LocatorRegistryPrx locatorRegistry = locatorInfo != null ? locatorInfo.getLocatorRegistry() : null; String serverId = ""; if (registerProcess) { assert (_instance != null); serverId = _instance.initializationData().properties.getProperty("Ice.ServerId"); if (locatorRegistry == null) { _instance .initializationData() .logger .warning( "object adapter `" + getName() + "' cannot register the process without a locator registry"); } else if (serverId.length() == 0) { _instance .initializationData() .logger .warning( "object adapter `" + getName() + "' cannot register the process without a value for Ice.ServerId"); } } if (locatorRegistry == null) { return; } if (_id.length() > 0) { try { if (_replicaGroupId.length() == 0) { locatorRegistry.setAdapterDirectProxy(_id, proxy); } else { locatorRegistry.setReplicatedAdapterDirectProxy(_id, _replicaGroupId, proxy); } } catch (AdapterNotFoundException ex) { if (_instance.traceLevels().location >= 1) { StringBuilder s = new StringBuilder(128); s.append("couldn't update object adapter `"); s.append(_id); s.append("' endpoints with the locator registry:\n"); s.append("the object adapter is not known to the locator registry"); _instance .initializationData() .logger .trace(_instance.traceLevels().locationCat, s.toString()); } NotRegisteredException ex1 = new NotRegisteredException(); ex1.kindOfObject = "object adapter"; ex1.id = _id; throw ex1; } catch (InvalidReplicaGroupIdException ex) { if (_instance.traceLevels().location >= 1) { StringBuilder s = new StringBuilder(128); s.append("couldn't update object adapter `"); s.append(_id); s.append("' endpoints with the locator registry:\n"); s.append("the replica group `"); s.append(_replicaGroupId); s.append("' is not known to the locator registry"); _instance .initializationData() .logger .trace(_instance.traceLevels().locationCat, s.toString()); } NotRegisteredException ex1 = new NotRegisteredException(); ex1.kindOfObject = "replica group"; ex1.id = _replicaGroupId; throw ex1; } catch (AdapterAlreadyActiveException ex) { if (_instance.traceLevels().location >= 1) { StringBuilder s = new StringBuilder(128); s.append("couldn't update object adapter `"); s.append(_id); s.append("' endpoints with the locator registry:\n"); s.append("the object adapter endpoints are already set"); _instance .initializationData() .logger .trace(_instance.traceLevels().locationCat, s.toString()); } ObjectAdapterIdInUseException ex1 = new ObjectAdapterIdInUseException(); ex1.id = _id; throw ex1; } catch (LocalException e) { if (_instance.traceLevels().location >= 1) { StringBuilder s = new StringBuilder(128); s.append("couldn't update object adapter `"); s.append(_id); s.append("' endpoints with the locator registry:\n"); s.append(e.toString()); _instance .initializationData() .logger .trace(_instance.traceLevels().locationCat, s.toString()); } throw e; // TODO: Shall we raise a special exception instead of a non obvious local // exception? } if (_instance.traceLevels().location >= 1) { StringBuilder s = new StringBuilder(128); s.append("updated object adapter `"); s.append(_id); s.append("' endpoints with the locator registry\n"); s.append("endpoints = "); if (proxy != null) { Ice.Endpoint[] endpoints = proxy.ice_getEndpoints(); for (int i = 0; i < endpoints.length; i++) { s.append(endpoints[i].toString()); if (i + 1 < endpoints.length) { s.append(":"); } } } _instance .initializationData() .logger .trace(_instance.traceLevels().locationCat, s.toString()); } } if (registerProcess && serverId.length() > 0) { synchronized (this) { if (_processId == null) { Process servant = new IceInternal.ProcessI(_communicator); _processId = addWithUUID(servant).ice_getIdentity(); } } try { locatorRegistry.setServerProcessProxy( serverId, ProcessPrxHelper.uncheckedCast(createDirectProxy(_processId))); } catch (ServerNotFoundException ex) { if (_instance.traceLevels().location >= 1) { StringBuilder s = new StringBuilder(128); s.append("couldn't register server `"); s.append(serverId); s.append("' with the locator registry:\n"); s.append("the server is not known to the locator registry"); _instance .initializationData() .logger .trace(_instance.traceLevels().locationCat, s.toString()); } NotRegisteredException ex1 = new NotRegisteredException(); ex1.id = serverId; ex1.kindOfObject = "server"; throw ex1; } catch (LocalException ex) { if (_instance.traceLevels().location >= 1) { StringBuilder s = new StringBuilder(128); s.append("couldn't register server `"); s.append(serverId); s.append("' with the locator registry:\n"); s.append(ex.toString()); _instance .initializationData() .logger .trace(_instance.traceLevels().locationCat, s.toString()); } throw ex; // TODO: Shall we raise a special exception instead of a non-obvious local // exception? } if (_instance.traceLevels().location >= 1) { StringBuilder s = new StringBuilder(128); s.append("registered server `"); s.append(serverId); s.append("' with the locator registry"); _instance .initializationData() .logger .trace(_instance.traceLevels().locationCat, s.toString()); } } }
public int run(String[] args) { String option = "None"; String topicName = "time"; int i; for (i = 0; i < args.length; ++i) { String oldoption = option; if (args[i].equals("--datagram")) { option = "Datagram"; } else if (args[i].equals("--twoway")) { option = "Twoway"; } else if (args[i].equals("--oneway")) { option = "Oneway"; } else if (args[i].startsWith("--")) { usage(); return 1; } else { topicName = args[i++]; break; } if (!oldoption.equals(option) && !oldoption.equals("None")) { usage(); return 1; } } if (i != args.length) { usage(); return 1; } IceStorm.TopicManagerPrx manager = IceStorm.TopicManagerPrxHelper.checkedCast( communicator().propertyToProxy("TopicManager.Proxy")); if (manager == null) { System.err.println("invalid proxy"); return 1; } // // Retrieve the topic. // IceStorm.TopicPrx topic; try { topic = manager.retrieve(topicName); } catch (IceStorm.NoSuchTopic e) { try { topic = manager.create(topicName); } catch (IceStorm.TopicExists ex) { System.err.println(appName() + ": temporary failure, try again."); return 1; } } // // Get the topic's publisher object, and create a Clock proxy with // the mode specified as an argument of this application. // Ice.ObjectPrx publisher = topic.getPublisher(); if (option.equals("Datagram")) { publisher = publisher.ice_datagram(); } else if (option.equals("Twoway")) { // Do nothing. } else // if(oneway) { publisher = publisher.ice_oneway(); } ClockPrx clock = ClockPrxHelper.uncheckedCast(publisher); System.out.println("publishing tick events. Press ^C to terminate the application."); try { java.text.SimpleDateFormat date = new java.text.SimpleDateFormat("MM/dd/yy HH:mm:ss:SSS"); while (true) { clock.tick(date.format(new java.util.Date())); try { Thread.currentThread().sleep(1000); } catch (java.lang.InterruptedException e) { } } } catch (Ice.CommunicatorDestroyedException ex) { // Ignore } return 0; }
@Override public Ice.ObjectPrx addFacet(Ice.Object servant, Ice.Identity ident, String facet) { checkIdentity(ident); checkServant(servant); if (facet == null) { facet = ""; } _deactivateController.lock(); try { ObjectStore store = findStore(facet, _createDb); if (store == null) { NotFoundException ex = new NotFoundException(); ex.message = _errorPrefix + "addFacet: could not open database for facet '" + facet + "'"; throw ex; } long currentTime = 0; ObjectRecord rec; if (store.keepStats()) { currentTime = IceInternal.Time.currentMonotonicTimeMillis(); rec = new ObjectRecord(servant, new Statistics(currentTime, 0, 0)); } else { rec = new ObjectRecord(servant, null); } TransactionI tx = beforeQuery(); if (store.keepStats()) { updateStats(rec.stats, currentTime); } if (!store.insert(ident, rec, tx)) { Ice.AlreadyRegisteredException ex = new Ice.AlreadyRegisteredException(); ex.kindOfObject = "servant"; ex.id = _communicator.identityToString(ident); if (facet.length() > 0) { ex.id += " -f " + IceUtilInternal.StringUtil.escapeString(facet, ""); } throw ex; } if (_trace >= 1) { String objString = "object \"" + _communicator.identityToString(ident) + "\""; if (!facet.equals("")) { objString += " with facet \"" + facet + "\""; } _communicator .getLogger() .trace("Freeze.Evictor", "added " + objString + " to Db \"" + _filename + "\""); } Ice.ObjectPrx obj = _adapter.createProxy(ident); if (facet.length() > 0) { obj = obj.ice_facet(facet); } return obj; } finally { _deactivateController.unlock(); } }