/** * Loads and instantiates skel class for the given remote class. * * @param c Class whose skel should be loaded and instantiated * * @return created skel class or null if any Exception occurred during * skel loading or instantiating */ protected Skeleton getSkelInstance(Class c) { String skelName = c.getName() + "_Skel"; //$NON-NLS-1$ ClassLoader cl = c.getClassLoader(); try { Class skelClass; if (cl != null) { skelClass = cl.loadClass(skelName); } else { skelClass = Class.forName(skelName); } return (Skeleton) skelClass.newInstance(); } catch (Exception ex) { } return null; }
/** * Export object and ensure it is present in the server activation table as * well. * * @param aClass the class being exported, must implement Remote. */ public Remote exportClass(Class aClass) throws RemoteException { if (!Remote.class.isAssignableFrom(aClass)) throw new InternalError(aClass.getName()+" must implement Remote"); String ignoreStubs; ClassLoader loader =aClass.getClassLoader(); // Stubs are always searched for the bootstrap classes that may have // obsolete pattern and may still need also skeletons. if (loader==null) ignoreStubs = "false"; else ignoreStubs = System.getProperty("java.rmi.server.ignoreStubClasses", "false"); if (! ignoreStubs.equals("true")) { // Find and install the stub Class cls = aClass; // where ist the _Stub? (check superclasses also) Class expCls = findStubSkelClass(cls); if (expCls != null) { stub = (RemoteStub) getHelperClass(expCls, "_Stub"); // Find and install the skeleton (if there is one) skel = (Skeleton) getHelperClass(expCls, "_Skel"); } } if (stub == null) stub = createProxyStub(aClass, this); // Build hash of methods which may be called. buildMethodHash(aClass, true); UnicastServer.registerActivatable(this); return stub; }
/** * Export the object and return its remote stub. The method tries to locate * existing stubs and skeletons. If this fails, the method instantiates the * proxy stub class. * * Stubs and skeletons are always ignored (even if present) if the * java.rmi.server.ignoreStubClasses property is set to true. * * @param obj the object being exported. * @return the stub (existing class or proxy) of the exported object. * @throws RemoteException if the export failed due any reason */ public Remote exportObject(Remote obj) throws RemoteException { if (myself == null) { myself = obj; // Save it to server manager, to let client calls in the same VM to // issue local call manager.serverobj = obj; String ignoreStubs; ClassLoader loader =obj.getClass().getClassLoader(); // Stubs are always searched for the bootstrap classes that may have // obsolete pattern and may still need also skeletons. if (loader==null) ignoreStubs = "false"; else ignoreStubs = System.getProperty("java.rmi.server.ignoreStubClasses", "false"); if (! ignoreStubs.equals("true")) { // Find and install the stub Class cls = obj.getClass(); // where ist the _Stub? (check superclasses also) Class expCls = findStubSkelClass(cls); if (expCls != null) { stub = (RemoteStub) getHelperClass(expCls, "_Stub"); // Find and install the skeleton (if there is one) skel = (Skeleton) getHelperClass(expCls, "_Skel"); } } if (stub == null) stub = createProxyStub(obj.getClass(), this); // Build hash of methods which may be called. buildMethodHash(obj.getClass(), true); // Export it. UnicastServer.exportObject(this); } return stub; }