private Method getNamedMethod( Class serverClass, String methodName ) { Class argTypes[] = new Class[] { org.omg.CORBA.ORB.class } ; Method method = null ; try { method = serverClass.getDeclaredMethod( methodName, argTypes ) ; } catch (Exception exc) { return null ; } if (!isPublicStaticVoid( method )) return null ; return method ; }
public boolean processCommand( String[] cmdArgs, ORB orb, PrintStream out ) { if ((cmdArgs.length == 2) && cmdArgs[0].equals( "-applicationName" )) { String str = (String)cmdArgs[1] ; try { Repository repository = RepositoryHelper.narrow( orb.resolve_initial_references( ORBConstants.SERVER_REPOSITORY_NAME )); try { int result = repository.getServerID( str ) ; out.println() ; out.println(CorbaResourceUtil.getText("servertool.getserverid2", str, Integer.toString(result))); out.println() ; } catch (ServerNotRegistered e) { out.println(CorbaResourceUtil.getText("servertool.nosuchserver")); } } catch (Exception ex) { ex.printStackTrace() ; } return commandDone ; } else return parseError ; }
public boolean processCommand(String[] cmdArgs, ORB orb, PrintStream out) { try { Repository repository = RepositoryHelper.narrow( orb.resolve_initial_references( ORBConstants.SERVER_REPOSITORY_NAME )); String[] applicationNames = repository.getApplicationNames(); out.println(CorbaResourceUtil.getText("servertool.listappnames2")); out.println(); for (int i=0; i < applicationNames.length; i++) out.println( "\t" + applicationNames[i] ) ; } catch (Exception ex) { ex.printStackTrace(); } return commandDone; }
public static void main(String[] args) { Properties systemProperties = System.getProperties(); systemProperties.setProperty("org.omg.CORBA.ORBSingletonClass", "com.sun.corba.se.impl.orb.ORBSingleton"); System.setSecurityManager(new SecurityManager()); Properties props = new Properties(); props.put("org.omg.CORBA.ORBClass", "com.sun.corba.se.impl.orb.ORBImpl"); ORB orb = ORB.init(args, props); Class<?> orbClass = orb.getClass(); if (orbClass.getName().equals("com.sun.corba.se.impl.orb.ORBImpl")) { System.out.println("orbClass is com.sun.corba.se.impl.orb.ORBimpl as expected"); } else { throw new RuntimeException("com.sun.corba.se.impl.orb.ORBimpl class expected for ORBImpl"); } ORB singletonORB = ORB.init(); Class<?> singletoneOrbClass = singletonORB.getClass(); if (singletoneOrbClass.getName().equals("com.sun.corba.se.impl.orb.ORBSingleton")) { System.out.println("singeletonOrbClass is com.sun.corba.se.impl.orb.ORBSingleton as expected"); } else { throw new RuntimeException("com.sun.corba.se.impl.orb.ORBSingleton class expected for ORBSingleton"); } }
/** * Constructs a new TransientNamingContext object. * @param orb an orb object. * @param initial the initial naming context. * @exception Exception a Java exception thrown of the base class cannot * initialize. */ public TransientNamingContext(com.sun.corba.se.spi.orb.ORB orb, org.omg.CORBA.Object initial, POA nsPOA ) throws java.lang.Exception { super(orb, nsPOA ); wrapper = NamingSystemException.get( orb, CORBALogDomains.NAMING ) ; this.localRoot = initial; readLogger = orb.getLogger( CORBALogDomains.NAMING_READ); updateLogger = orb.getLogger( CORBALogDomains.NAMING_UPDATE); lifecycleLogger = orb.getLogger( CORBALogDomains.NAMING_LIFECYCLE); lifecycleLogger.fine( "Root TransientNamingContext LIFECYCLE.CREATED" ); }
public Object readResolve() { String repositoryId = ior.getRepositoryId() ; String cname = RepositoryId.cache.getId( repositoryId ).getClassName() ; Class cls = null ; try { cls = JDKBridge.loadClass( cname, null, null ) ; } catch (ClassNotFoundException exc) { // XXX log this } PresentationManager pm = com.sun.corba.se.spi.orb.ORB.getPresentationManager() ; PresentationManager.ClassData classData = pm.getClassData( cls ) ; InvocationHandlerFactoryImpl ihfactory = (InvocationHandlerFactoryImpl)classData.getInvocationHandlerFactory() ; return ihfactory.getInvocationHandler( this ) ; }
/** * Creates a new CodecFactory implementation. Stores the ORB that * created this factory, for later use by the Codec. */ public CodecFactoryImpl( ORB orb ) { this.orb = orb; wrapper = ORBUtilSystemException.get( (com.sun.corba.se.spi.orb.ORB)orb, CORBALogDomains.RPC_PROTOCOL ) ; // Precreate a codec for version 1.0 through // 1.(MAX_MINOR_VERSION_SUPPORTED). This can be // done since Codecs are immutable in their current implementation. // This is an optimization that eliminates the overhead of creating // a new Codec each time create_codec is called. for( int minor = 0; minor <= MAX_MINOR_VERSION_SUPPORTED; minor++ ) { codecs[minor] = new CDREncapsCodec( orb, 1, minor ); } }
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 ) ; }
public static TypeCode getPrimitiveTypeCodeForClass (ORB orb, Class c, ValueHandler vh) { if (c == Integer.TYPE) { return orb.get_primitive_tc (TCKind.tk_long); } else if (c == Byte.TYPE) { return orb.get_primitive_tc (TCKind.tk_octet); } else if (c == Long.TYPE) { return orb.get_primitive_tc (TCKind.tk_longlong); } else if (c == Float.TYPE) { return orb.get_primitive_tc (TCKind.tk_float); } else if (c == Double.TYPE) { return orb.get_primitive_tc (TCKind.tk_double); } else if (c == Short.TYPE) { return orb.get_primitive_tc (TCKind.tk_short); } else if (c == Character.TYPE) { return orb.get_primitive_tc (((ValueHandlerImpl)vh).getJavaCharTCKind()); } else if (c == Boolean.TYPE) { return orb.get_primitive_tc (TCKind.tk_boolean); } else { // _REVISIT_ Not sure if this is right. return orb.get_primitive_tc (TCKind.tk_any); } }
ServerCallback(ORB orb, Method installMethod, Method uninstallMethod, Method shutdownMethod ) { this.orb = orb; this.installMethod = installMethod ; this.uninstallMethod = uninstallMethod ; this.shutdownMethod = shutdownMethod ; orb.connect( this ) ; methodArgs = new Object[] { orb } ; }
private static TypeCode createTypeCodeForClassInternal (ORB orb, java.lang.Class c, ValueHandler vh, IdentityKeyValueStack createdIDs) { // This wrapper method is the protection against infinite recursion. TypeCode tc = null; String id = (String)createdIDs.get(c); if (id != null) { return orb.create_recursive_tc(id); } else { id = vh.getRMIRepositoryID(c); if (id == null) id = ""; // cache the rep id BEFORE creating a new typecode. // so that recursive tc can look up the rep id. createdIDs.push(c, id); tc = createTypeCodeInternal(orb, c, vh, id, createdIDs); createdIDs.pop(); return tc; } }
/** * Allows the servant to obtain the object reference for * the target CORBA Object it is incarnating for that request. * @param orb ORB with which the servant is associated. * @return <code>_this_object</code> reference associated with the request. */ final public org.omg.CORBA.Object _this_object(ORB orb) { try { ((org.omg.CORBA_2_3.ORB)orb).set_delegate(this); } catch(ClassCastException e) { throw new org.omg.CORBA.BAD_PARAM ("POA Servant requires an instance of org.omg.CORBA_2_3.ORB"); } return _this_object(); }
public static ORB getORB( Object stub ) { if (stub instanceof DynamicStub) return ((DynamicStub)stub).getORB() ; else if (stub instanceof ObjectImpl) return (ORB)((ObjectImpl)stub)._orb() ; else throw wrapper.getOrbRequiresStub() ; }
public static void connect( Object stub, ORB orb ) throws java.rmi.RemoteException { if (stub instanceof DynamicStub) ((DynamicStub)stub).connect( (com.sun.corba.se.spi.orb.ORB)orb ) ; else if (stub instanceof javax.rmi.CORBA.Stub) ((javax.rmi.CORBA.Stub)stub).connect( orb ) ; else if (stub instanceof ObjectImpl) orb.connect( (org.omg.CORBA.Object)stub ) ; else throw wrapper.connectRequiresStub() ; }
static int getServerIdForAlias( ORB orb, String applicationName ) throws ServerNotRegistered { try { Repository rep = RepositoryHelper.narrow( orb.resolve_initial_references( ORBConstants.SERVER_REPOSITORY_NAME ) ) ; int serverid = rep.getServerID(applicationName); return rep.getServerID( applicationName ) ; } catch (Exception ex) { throw (new ServerNotRegistered()); } }
public boolean processCommand(String[] cmdArgs, ORB orb, PrintStream out) { ServerDef serverDef; // process the list active servers command try { Repository repository = RepositoryHelper.narrow( orb.resolve_initial_references( ORBConstants.SERVER_REPOSITORY_NAME )); Activator activator = ActivatorHelper.narrow( orb.resolve_initial_references( ORBConstants.SERVER_ACTIVATOR_NAME )); int[] servers = activator.getActiveServers(); out.println(CorbaResourceUtil.getText("servertool.list2")); ListServers.sortServers(servers); for (int i=0; i < servers.length; i++) { try { serverDef = repository.getServer(servers[i]); out.println("\t " + servers[i] + "\t\t" + serverDef.serverName + "\t\t" + serverDef.applicationName); } catch (ServerNotRegistered e) {} } } catch (Exception ex) { ex.printStackTrace(); } return commandDone; }
/** * Constructs a new TransientNameService, and creates an initial * NamingContext, whose object * reference can be obtained by the initialNamingContext method. * @param orb The ORB object * @exception org.omg.CORBA.INITIALIZE Thrown if * the TransientNameService cannot initialize. */ public TransientNameService(com.sun.corba.se.spi.orb.ORB orb ) throws org.omg.CORBA.INITIALIZE { // Default constructor uses "NameService" as the key for the Root Naming // Context. If default constructor is used then INS's object key for // Transient Name Service is "NameService" initialize( orb, "NameService" ); }
/** * Create a binding iterator servant. * runs the super constructor. * @param orb an ORB object. * @exception java.lang.Exception a Java exception. */ public BindingIteratorImpl(ORB orb) throws java.lang.Exception { super(); this.orb = orb ; }
/** * Constructs a new TransientBindingIterator object. * @param orb a org.omg.CORBA.ORB object. * @param aTable A hashtable containing InternalBindingValues which is * the content of the TransientNamingContext. * @param java.lang.Exception a Java exception. * @exception Exception a Java exception thrown of the base class cannot * initialize. */ public TransientBindingIterator(ORB orb, Hashtable aTable, POA thePOA ) throws java.lang.Exception { super(orb); theHashtable = aTable; theEnumeration = this.theHashtable.elements(); currentSize = this.theHashtable.size(); this.nsPOA = thePOA; }
/** * Convert the given any into a CDR encapsulated octet sequence. * If sendTypeCode is true, the type code is sent with the message, as in * a standard encapsulation. If it is false, only the data is sent. * Either way, the endian type is sent as the first part of the message. */ private byte[] encodeImpl( Any data, boolean sendTypeCode ) throws InvalidTypeForEncoding { if( data == null ) throw wrapper.nullParam() ; // _REVISIT_ Note that InvalidTypeForEncoding is never thrown in // the body of this method. This is due to the fact that CDR*Stream // will never throw an exception if the encoding is invalid. To // fix this, the CDROutputStream must know the version of GIOP it // is encoding for and it must check to ensure that, for example, // wstring cannot be encoded in GIOP 1.0. // // As part of the GIOP 1.2 work, the CDRInput and OutputStream will // be versioned. This can be handled once this work is complete. // Create output stream with default endianness. EncapsOutputStream cdrOut = sun.corba.OutputStreamFactory.newEncapsOutputStream( (com.sun.corba.se.spi.orb.ORB)orb, giopVersion ); // This is an encapsulation, so put out the endian: cdrOut.putEndian(); // Sometimes encode type code: if( sendTypeCode ) { cdrOut.write_TypeCode( data.type() ); } // Encode value and return. data.write_value( cdrOut ); return cdrOut.toByteArray(); }
public static TypeCode createTypeCodeForClass (ORB orb, java.lang.Class c, ValueHandler vh) { // Maps classes to repositoryIDs strings. This is used to detect recursive types. IdentityKeyValueStack createdIDs = new IdentityKeyValueStack(); // Stores all types created for resolving indirect types at the end. TypeCode tc = createTypeCodeForClassInternal(orb, c, vh, createdIDs); return tc; }
/** * Copies or connects an array of objects. Used by local stubs * to copy any number of actual parameters, preserving sharing * across parameters as necessary to support RMI semantics. * @param obj the objects to copy or connect. * @param orb the ORB. * @return the copied or connected objects. * @exception RemoteException if any object could not be copied or connected. */ public static Object[] copyObjects (Object[] obj, ORB orb) throws RemoteException { if (utilDelegate != null) { return utilDelegate.copyObjects(obj, orb); } return null; }
/** * Connects this stub to an ORB. Required after the stub is deserialized * but not after it is demarshalled by an ORB stream. If an unconnected * stub is passed to an ORB stream for marshalling, it is implicitly * connected to that ORB. Application code should not call this method * directly, but should call the portable wrapper method * {@link javax.rmi.PortableRemoteObject#connect}. * @param orb the ORB to connect to. * @exception RemoteException if the stub is already connected to a different * ORB, or if the stub does not represent an exported remote or local object. */ public void connect(ORB orb) throws RemoteException { if (stubDelegate == null) { setDefaultDelegate(); } if (stubDelegate != null) { stubDelegate.connect(this, orb); } }
OrbReuseTracker(ORB orb) { this.orb = orb; referenceCnt++; if (debug) { System.out.println("New OrbReuseTracker created"); } }
/** * Constructs a new PersistentBindingIterator object. * @param orb a org.omg.CORBA.ORB object. * @param aTable A hashtable containing InternalBindingValues which is * the content of the PersistentNamingContext. * @exception Exception a Java exception thrown of the base class cannot * initialize. */ public PersistentBindingIterator(org.omg.CORBA.ORB orb, Hashtable aTable, POA thePOA ) throws java.lang.Exception { super(orb); this.orb = orb; theHashtable = aTable; theEnumeration = this.theHashtable.keys(); currentSize = this.theHashtable.size(); biPOA = thePOA; }
public static void main(String[] args) throws Exception { updateOrbPropertiesFile(); // create and initialize the ORB ORB orb = ORB.init(args, null); if (!(orb instanceof TestOrbImpl)) { throw new RuntimeException("org.omg.CORBA.ORBClass property not set as expected"); } ORB singletonOrb = ORB.init(); System.out.println("singletonOrb class == " + singletonOrb.getClass().getName()); if (!(singletonOrb instanceof TestSingletonOrbImpl)) { throw new RuntimeException("org.omg.CORBA.ORBSingletonClass property not set as expected"); } }
private void registerCallback( Class serverClass ) { Method installMethod = getNamedMethod( serverClass, "install" ) ; Method uninstallMethod = getNamedMethod( serverClass, "uninstall" ) ; Method shutdownMethod = getNamedMethod( serverClass, "shutdown" ) ; Properties props = new Properties() ; props.put( "org.omg.CORBA.ORBClass", "com.sun.corba.se.impl.orb.ORBImpl" ) ; // NOTE: Very important to pass this property, otherwise the // Persistent Server registration will be unsucessfull. props.put( ORBConstants.ACTIVATED_PROPERTY, "false" ); String args[] = null ; ORB orb = ORB.init( args, props ) ; ServerCallback serverObj = new ServerCallback( orb, installMethod, uninstallMethod, shutdownMethod ) ; int serverId = getServerId() ; try { Activator activator = ActivatorHelper.narrow( orb.resolve_initial_references( ORBConstants.SERVER_ACTIVATOR_NAME )); activator.active(serverId, serverObj); } catch (Exception ex) { logTerminal( "exception " + ex.getMessage(), REGISTRATION_FAILED ) ; } }