📄 corbadriver.java
字号:
break; } catch (Throwable e) { log.severe("Can't register CORBA NameService context '" + OrbInstanceFactory.getString(nameXmlBlaster) + "', #"+i+"/"+numTries+": " + e.toString()); } } } if (relativeContext != null) { String clusterId = this.addressServer.getEnv("NameService.node.id", glob.getStrippedId()).getValue(); String clusterKind = this.addressServer.getEnv("NameService.node.kind", "MOM").getValue(); nameNode = new NameComponent[] { new NameComponent(clusterId, clusterKind) }; relativeContext.rebind(nameNode, this.authRef); } else { // delegate error handling throw new XmlBlasterException(glob, ErrorCode.RESOURCE_UNAVAILABLE, ME, "Can't bind to naming service"); } log.info("Published AuthServer IOR to NameService ORBInitRef='" + System.getProperty("ORBInitRef") + "' with name '" + OrbInstanceFactory.getString(nameXmlBlaster) + "/" + OrbInstanceFactory.getString(nameNode) + "'"); } catch (XmlBlasterException e) { log.warning(e.getMessage()); namingContextExt = null; if (glob.getBootstrapAddress().getBootstrapPort() > 0) { log.info("You don't need the naming service, i'll switch to builtin http IOR download"); } else if (iorFile != null) { log.info("You don't need the naming service, i'll switch to plugin/ior/iorFile = " + iorFile); } else { usage(); log.severe("You switched off the internal http server and you didn't specify a file name for IOR dump nor a Naming Service was found!"); } } catch (org.omg.CORBA.COMM_FAILURE e) { namingContextExt = null; if (glob.getBootstrapAddress().getBootstrapPort() > 0) { log.info("Can't publish AuthServer to naming service, is your naming service really running?\n" + e.toString() + "\nYou don't need the naming service, i'll switch to builtin http IOR download"); } else if (iorFile != null) { log.info("Can't publish AuthServer to naming service, is your naming service really running?\n" + e.toString() + "\nYou don't need the naming service, i'll switch to plugin/ior/iorFile = " + iorFile); } else { usage(); log.severe("Can't publish AuthServer to naming service, is your naming service really running?\n" + e.toString() + "\nYou switched off the internal http server and you didn't specify a file name for IOR dump!"); } } } // if useNameService } catch (org.omg.CORBA.COMM_FAILURE e) { throw new XmlBlasterException(glob, ErrorCode.RESOURCE_CONFIGURATION, ME, "Could not initialize CORBA, do you use the SUN-JDK delivered ORB instead of JacORB or ORBaccus? Try 'jaco org.xmlBlaster.Main' and read instructions in xmlBlaster/bin/jaco", e); } catch (Throwable e) { e.printStackTrace(); throw new XmlBlasterException(glob, ErrorCode.RESOURCE_CONFIGURATION, ME, "Could not initialize CORBA", e); } // orbacus needs this if (orb.work_pending()) orb.perform_work(); this.isActive = true; } /** * JMX * Deactivate xmlBlaster access (standby), no clients can connect. */ public synchronized void deActivate() { if (log.isLoggable(Level.FINER)) log.finer("Entering deActivate"); this.isActive = false; try { glob.getHttpServer().removeRequest(urlPath); } catch(XmlBlasterException e) { log.severe(e.getMessage()); } try { if (namingContextExt != null && nameXmlBlaster != null) { NamingContext relativeContext = null; try { org.omg.CORBA.Object obj = namingContextExt.resolve(nameXmlBlaster); relativeContext = org.omg.CosNaming.NamingContextExtHelper.narrow(obj); } catch (Throwable e) { log.warning("Can't unregister CORBA NameService context id=" + nameXmlBlaster[0].id + " kind=" + nameXmlBlaster[0].kind + " failed: " + e.toString()); } if (relativeContext != null) { relativeContext.unbind(nameNode); } } namingContextExt = null; } catch (Throwable e) { log.warning("Problems during ORB cleanup: " + e.toString()); e.printStackTrace(); } try { if (iorFile != null) FileLocator.deleteFile(null, iorFile); iorFile = null; } catch (Throwable e) { log.warning("Problems during ORB cleanup: " + e.toString()); } if (this.authRef != null) this.authRef._release(); } /** * Instructs the ORB to shut down, which causes all object adapters to shut down. * <p /> * JacORB behavior:<br /> * The POA is not "connected" to the ORB in any particular way * other than that is exists. You can call destroy() on a POA * to make it disappear. Calling shutdown() on the ORB will * implicitly destroy all POAs. * <p /> * Ports are not linked to POAs in JacORB. Rather, there is a single * master port in any server-side ORB which gets created when the * root poa is retrieved for the first time. The server process * accepts incoming connections on this port and creates new * ports for every client process. Because of this connection * multiplexing, ports are not released when POAs are destroyed, * but when clients exit, or when server-side timouts occur. */ public void shutdown() throws XmlBlasterException { if (log.isLoggable(Level.FINER)) log.finer("Shutting down ..."); deActivate(); this.glob.unregisterMBean(this.mbeanHandle); if (this.authServer != null) { this.authServer.shutdown(); } if (rootPOA != null && this.authRef != null) { try { log.fine("Deactivate POA ..."); this.authRef._release(); // poa.deactivate_object(poa.servant_to_id(this.authRef)); rootPOA.deactivate_object(rootPOA.reference_to_id(this.authRef)); } catch(Exception e) { log.warning("POA deactivate authentication servant failed"); } } if (rootPOA != null) { /* try { log.trace(ME, "Deactivate POA Manager ..."); rootPOA.the_POAManager().deactivate(false, true); } catch(Exception e) { log.warn(ME, "rootPOA deactivate failed: " + e.toString()); } rootPOA deactivate failed: org.omg.PortableServer.POAManagerPackage.AdapterInactive: IDL:omg.org/PortableServer/POAManager/AdapterInactive:1.0 */ /* try { log.trace(ME, "_release POA Manager ..."); rootPOA.the_POAManager()._release(); } catch(Exception e) { log.warn(ME, "rootPOA _release failed: " + e.toString()); } rootPOA _release failed: org.omg.CORBA.NO_IMPLEMENT: This is a locally constrained object. vmcid: 0x0 minor code: 0 completed: No */ try { this.rootPOA.destroy(true, true); } catch (Exception ex) { log.warning("shutdown:exception occured rootPOA.destroy(): " + ex.toString()); } rootPOA = null; } this.authRef = null; if (this.orb != null) { boolean wait_for_completion = false; try { this.orb.shutdown(wait_for_completion); this.orb = null; } catch (Throwable ex) { log.warning("shutdown: Exception occured during orb.shutdown("+wait_for_completion+"): " + ex.toString()); } } log.info("POA and ORB are down, CORBA resources released."); } public boolean isShutdown() { return this.orb == null; } /** * Locate the CORBA Naming Service. * <p /> * The found naming service is cached, for better performance in subsequent calls * @return NamingContextExt, reference on name service<br /> * Note that this reference may be invalid, because the naming service is not running any more * @exception XmlBlasterException * CORBA error handling if no naming service is found */ private NamingContextExt getNamingService() throws XmlBlasterException { if (log.isLoggable(Level.FINER)) log.finer("getNamingService() ..."); if (namingContextExt != null) return namingContextExt; NamingContextExt nameService = null; try { // Get a reference to the Name Service, CORBA compliant: org.omg.CORBA.Object nameServiceObj = orb.resolve_initial_references("NameService"); if (nameServiceObj == null) { //log.warn(ME + ".NoNameService", "Can't access naming service, is there any running?"); throw new XmlBlasterException(glob, ErrorCode.RESOURCE_CONFIGURATION, ME + ".NoNameService", "Can't access naming service, is there any running?"); } if (log.isLoggable(Level.FINE)) log.fine("Successfully accessed initial orb references for naming service (IOR)"); nameService = org.omg.CosNaming.NamingContextExtHelper.narrow(nameServiceObj); if (nameService == null) { log.severe("Can't access naming service == null"); throw new XmlBlasterException(glob, ErrorCode.RESOURCE_CONFIGURATION, ME + ".NoNameService", "Can't access naming service (narrow problem)"); } if (log.isLoggable(Level.FINE)) log.fine("Successfully narrowed handle for naming service"); return nameService; // Note: the naming service IOR is successfully evaluated (from a IOR), // but it is not sure that the naming service is really running } catch (XmlBlasterException e) { throw e; } catch (Exception e) { if (log.isLoggable(Level.FINE)) log.fine(e.toString() + ": " + e.getMessage()); throw XmlBlasterException.convert(glob, ErrorCode.RESOURCE_CONFIGURATION, ME + ".NoNameService", "No CORBA naming service found - start <xmlBlaster/bin/ns ns.ior> and specify <-ORBInitRef NameService=...> if you want one.", e); //throw new XmlBlasterException(ME + ".NoNameService", "No CORBA naming service found - read docu at <http://www.jacorb.org> if you want one."); } } /** * Command line usage. */ public String usage() { String text = "\n"; text += "CorbaDriver options:\n"; text += " -bootstrapHostname IP address where the builtin http server publishes its AuthServer IOR\n"; text += " This is useful for multihomed hosts or dynamic dial in IPs.\n"; text += " -bootstrapPort Port number where the builtin http server publishes its AuthServer IOR.\n"; text += " Default is bootstrap port "+Constants.XMLBLASTER_PORT+", the port 0 switches this feature off.\n"; text += " -plugin/ior/iorFile\n"; text += " Specify a file where to dump the IOR of the AuthServer (for client access).\n"; text += " -plugin/ior/iorString\n"; text += " Clients can specify the raw IOR string directly (for client access).\n"; text += " -plugin/ior/useNameService true/false [true]\n"; text += " Publish the IOR to a naming service.\n"; text += " -plugin/ior/hostname\n"; text += " Allows to force the corba server IP address for multi-homed hosts.\n"; text += " -plugin/ior/port Allows to force the corba server port number.\n"; text += " " + Global.getJmxUsageLinkInfo(this.getClass().getName(), null); text += "\n"; text += " For JacORB only:\n"; text += " java -DOAIAddr=<ip> Use '-plugin/ior/hostname'\n"; text += " java -DOAPort=<nr> Use '-plugin/ior/port'\n"; text += " java -Djacorb.log.default.verbosity=3 Switch CORBA debugging on\n"; text += " java ... -ORBInitRef NameService=corbaloc:iiop:localhost:7608/StandardNS/NameServer-POA/_root\n"; text += "\n"; return text; } /** * @return A link for JMX usage */ public java.lang.String getUsageUrl() { return Global.getJavadocUrl(this.getClass().getName(), null); } /* dummy to have a copy/paste functionality in jconsole */ public void setUsageUrl(java.lang.String url) { } /** * JMX * @see org.xmlBlaster.util.admin.I_AdminService#isActive() */ public boolean isActive() { return this.isActive; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -