/// <summary>
 /// Creates a new <code>RemoteObjectInvocationHandler</code> constructed
 /// with the specified <code>RemoteRef</code>.
 /// </summary>
 /// <param name="ref"> the remote ref
 /// </param>
 /// <exception cref="NullPointerException"> if <code>ref</code> is <code>null</code>
 ///  </exception>
 public RemoteObjectInvocationHandler(RemoteRef @ref) : base(@ref)
 {
     if (@ref == null)
     {
         throw new NullPointerException();
     }
 }
Example #2
0
        public GithubRef(RemoteRef remoteRef, bool useSourceArchive, bool usePrerelease)
            : base(remoteRef)
        {
            var match = Pattern.Match(remoteRef.Id);

            if (match.Success)
            {
                Account    = match.Groups["account"].Value;
                Project    = match.Groups["project"].Value;
                Repository = string.Format("{0}/{1}", Account, Project);

                Filter = match.Groups["filter"].Success ?
                         new Regex(match.Groups["filter"].Value, RegexOptions.Compiled) :
                         Constants.DefaultAssetMatchPattern;

                VersionFromAsset = match.Groups["versionFromAsset"].Success ?
                                   new Regex(match.Groups["versionFromAsset"].Value, RegexOptions.Compiled) :
                                   null;

                UseSourceArchive = useSourceArchive;
                UsePrerelease    = usePrerelease;
            }
            else
            {
                throw new Kraken(string.Format(@"Could not parse reference: ""{0}""", remoteRef));
            }
        }
Example #3
0
        /// <summary>
        /// <code>readObject</code> for custom serialization.
        ///
        /// <para>This method reads this object's serialized form for this class
        /// as follows:
        ///
        /// </para>
        /// <para>The <code>readUTF</code> method is invoked on <code>in</code>
        /// to read the external ref type name for the <code>RemoteRef</code>
        /// instance to be filled in to this object's <code>ref</code> field.
        /// If the string returned by <code>readUTF</code> has length zero,
        /// the <code>readObject</code> method is invoked on <code>in</code>,
        /// and than the value returned by <code>readObject</code> is cast to
        /// <code>RemoteRef</code> and this object's <code>ref</code> field is
        /// set to that value.
        /// Otherwise, this object's <code>ref</code> field is set to a
        /// <code>RemoteRef</code> instance that is created of an
        /// implementation-specific class corresponding to the external ref
        /// type name returned by <code>readUTF</code>, and then
        /// the <code>readExternal</code> method is invoked on
        /// this object's <code>ref</code> field.
        ///
        /// </para>
        /// <para>If the external ref type name is
        /// <code>"UnicastRef"</code>, <code>"UnicastServerRef"</code>,
        /// <code>"UnicastRef2"</code>, <code>"UnicastServerRef2"</code>,
        /// or <code>"ActivatableRef"</code>, a corresponding
        /// implementation-specific class must be found, and its
        /// <code>readExternal</code> method must read the serial data
        /// for that external ref type name as specified to be written
        /// in the <b>serialData</b> documentation for this class.
        /// If the external ref type name is any other string (of non-zero
        /// length), a <code>ClassNotFoundException</code> will be thrown,
        /// unless the implementation provides an implementation-specific
        /// class corresponding to that external ref type name, in which
        /// case this object's <code>ref</code> field will be set to an
        /// instance of that implementation-specific class.
        /// </para>
        /// </summary>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException
        private void ReadObject(java.io.ObjectInputStream @in)
        {
            String refClassName = @in.ReadUTF();

            if (refClassName == null || refClassName.Length() == 0)
            {
                /*
                 * No reference class name specified, so construct
                 * remote reference from its serialized form.
                 */
                @ref = (RemoteRef)@in.ReadObject();
            }
            else
            {
                /*
                 * Built-in reference class specified, so delegate to
                 * internal reference class to initialize its fields from
                 * its external form.
                 */
                String internalRefClassName = RemoteRef_Fields.PackagePrefix + "." + refClassName;
                Class  refClass             = Class.ForName(internalRefClassName);
                try
                {
                    @ref = (RemoteRef)refClass.NewInstance();

                    /*
                     * If this step fails, assume we found an internal
                     * class that is not meant to be a serializable ref
                     * type.
                     */
                }
                catch (InstantiationException e)
                {
                    throw new ClassNotFoundException(internalRefClassName, e);
                }
                catch (IllegalAccessException e)
                {
                    throw new ClassNotFoundException(internalRefClassName, e);
                }
                catch (ClassCastException e)
                {
                    throw new ClassNotFoundException(internalRefClassName, e);
                }
                @ref.ReadExternal(@in);
            }
        }
Example #4
0
        /// <summary>
        /// <code>readObject</code> for custom serialization.
        ///
        /// <para>This method reads this object's serialized form for this
        /// class as follows:
        ///
        /// </para>
        /// <para>The <code>readObject</code> method is invoked on
        /// <code>in</code> to read this object's unique identifier
        /// (a <seealso cref="java.rmi.server.UID UID"/> instance).
        ///
        /// </para>
        /// <para>Next, the <code>readUTF</code> method is invoked on
        /// <code>in</code> to read the external ref type name of the
        /// <code>RemoteRef</code> instance for this object's
        /// activator.  Next, the <code>RemoteRef</code>
        /// instance is created of an implementation-specific class
        /// corresponding to the external ref type name (returned by
        /// <code>readUTF</code>), and the <code>readExternal</code>
        /// method is invoked on that <code>RemoteRef</code> instance
        /// to read the external form corresponding to the external
        /// ref type name.
        ///
        /// </para>
        /// <para>Note: If the external ref type name is
        /// <code>"UnicastRef"</code>, <code>"UnicastServerRef"</code>,
        /// <code>"UnicastRef2"</code>, <code>"UnicastServerRef2"</code>,
        /// or <code>"ActivatableRef"</code>, a corresponding
        /// implementation-specific class must be found, and its
        /// <code>readExternal</code> method must read the serial data
        /// for that external ref type name as specified to be written
        /// in the <b>serialData</b> documentation for this class.
        /// If the external ref type name is any other string (of non-zero
        /// length), a <code>ClassNotFoundException</code> will be thrown,
        /// unless the implementation provides an implementation-specific
        /// class corresponding to that external ref type name, in which
        /// case the <code>RemoteRef</code> will be an instance of
        /// that implementation-specific class.
        /// </para>
        /// </summary>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException
        private void ReadObject(ObjectInputStream @in)
        {
            Uid = (UID)@in.ReadObject();

            try
            {
                Class     refClass = Class.ForName(java.rmi.server.RemoteRef_Fields.PackagePrefix + "." + @in.ReadUTF()).AsSubclass(typeof(RemoteRef));
                RemoteRef @ref     = refClass.NewInstance();
                @ref.ReadExternal(@in);
                Activator = (Activator)Proxy.newProxyInstance(null, new Class[] { typeof(Activator) }, new RemoteObjectInvocationHandler(@ref));
            }
            catch (InstantiationException e)
            {
                throw (IOException)(new InvalidObjectException("Unable to create remote reference")).InitCause(e);
            }
            catch (IllegalAccessException e)
            {
                throw (IOException)(new InvalidObjectException("Unable to create remote reference")).InitCause(e);
            }
        }
Example #5
0
        /// <summary>
        /// Returns a locally created remote reference to the remote object
        /// <code>Registry</code> on the specified <code>host</code> and
        /// <code>port</code>.  Communication with this remote registry will
        /// use the supplied <code>RMIClientSocketFactory</code> <code>csf</code>
        /// to create <code>Socket</code> connections to the registry on the
        /// remote <code>host</code> and <code>port</code>.
        /// </summary>
        /// <param name="host"> host for the remote registry </param>
        /// <param name="port"> port on which the registry accepts requests </param>
        /// <param name="csf">  client-side <code>Socket</code> factory used to
        ///      make connections to the registry.  If <code>csf</code>
        ///      is null, then the default client-side <code>Socket</code>
        ///      factory will be used in the registry stub. </param>
        /// <returns> reference (a stub) to the remote registry </returns>
        /// <exception cref="RemoteException"> if the reference could not be created
        /// @since 1.2 </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static Registry getRegistry(String host, int port, java.rmi.server.RMIClientSocketFactory csf) throws java.rmi.RemoteException
        public static Registry GetRegistry(String host, int port, RMIClientSocketFactory csf)
        {
            Registry registry = null;

            if (port <= 0)
            {
                port = Registry_Fields.REGISTRY_PORT;
            }

            if (host == null || host.Length() == 0)
            {
                // If host is blank (as returned by "file:" URL in 1.0.2 used in
                // java.rmi.Naming), try to convert to real local host name so
                // that the RegistryImpl's checkAccess will not fail.
                try
                {
                    host = java.net.InetAddress.LocalHost.HostAddress;
                }
                catch (Exception)
                {
                    // If that failed, at least try "" (localhost) anyway...
                    host = "";
                }
            }

            /*
             * Create a proxy for the registry with the given host, port, and
             * client socket factory.  If the supplied client socket factory is
             * null, then the ref type is a UnicastRef, otherwise the ref type
             * is a UnicastRef2.  If the property
             * java.rmi.server.ignoreStubClasses is true, then the proxy
             * returned is an instance of a dynamic proxy class that implements
             * the Registry interface; otherwise the proxy returned is an
             * instance of the pregenerated stub class for RegistryImpl.
             **/
            LiveRef   liveRef = new LiveRef(new ObjID(ObjID.REGISTRY_ID), new TCPEndpoint(host, port, csf, null), false);
            RemoteRef @ref    = (csf == null) ? new UnicastRef(liveRef) : new UnicastRef2(liveRef);

            return((Registry)Util.createProxy(typeof(RegistryImpl), @ref, false));
        }
Example #6
0
        public GithubRef(RemoteRef remoteRef, bool usePrelease = false)
            : base(remoteRef)
        {
            var match = Pattern.Match(remoteRef.Id);

            if (match.Success)
            {
                Account    = match.Groups["account"].Value;
                Project    = match.Groups["project"].Value;
                Repository = string.Format("{0}/{1}", Account, Project);

                Filter = match.Groups["filter"].Success ?
                         new Regex(match.Groups["filter"].Value, RegexOptions.Compiled) :
                         DefaultFilterPattern;

                UsePrelease = usePrelease;
            }
            else
            {
                throw new Kraken(string.Format(@"Could not parse reference: ""{0}""", remoteRef));
            }
        }
Example #7
0
 /// <summary>
 /// Constructs a <code>RemoteServer</code> with the given reference type.
 /// </summary>
 /// <param name="ref"> the remote reference
 /// @since JDK1.1 </param>
 protected internal RemoteServer(RemoteRef @ref) : base(@ref)
 {
 }
Example #8
0
 public JenkinsRef(RemoteRef remoteRef)
     : base(remoteRef)
 {
     BaseUri = new Uri(remoteRef.Id);
 }
Example #9
0
 protected internal static void SetRef(RemoteStub stub, RemoteRef @ref)
 {
     throw new UnsupportedOperationException();
 }
Example #10
0
 /// <summary>
 /// Constructs a {@code RemoteStub} with the specified remote
 /// reference.
 /// </summary>
 /// <param name="ref"> the remote reference
 /// @since JDK1.1 </param>
 protected internal RemoteStub(RemoteRef @ref) : base(@ref)
 {
 }
Example #11
0
 /// <summary>
 /// Creates a remote object, initialized with the specified remote
 /// reference. </summary>
 /// <param name="newref"> remote reference </param>
 protected internal RemoteObject(RemoteRef newref)
 {
     @ref = newref;
 }
Example #12
0
 /// <summary>
 /// Creates a remote object.
 /// </summary>
 protected internal RemoteObject()
 {
     @ref = null;
 }