Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/RemoteObject.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/RemoteObject.java?rev=407625&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/RemoteObject.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/RemoteObject.java Thu May 18 13:01:22 2006
@@ -0,0 +1,159 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Mikhail A. Markov
+ * @version $Revision: 1.10.4.3 $
+ */
+package java.rmi.server;
+
+import java.io.Serializable;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.rmi.MarshalException;
+import java.rmi.NoSuchObjectException;
+import java.rmi.Remote;
+import java.rmi.UnmarshalException;
+
+import org.apache.harmony.rmi.common.RMIUtil;
+import org.apache.harmony.rmi.server.ExportManager;
+
+
+/**
+ * @com.intel.drl.spec_ref
+ *
+ * @author Mikhail A. Markov
+ * @version $Revision: 1.10.4.3 $
+ */
+public abstract class RemoteObject implements Remote, Serializable {
+
+ private static final long serialVersionUID = -3215090123894869218L;
+
+ /** @com.intel.drl.spec_ref */
+ protected transient RemoteRef ref;
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ protected RemoteObject() {
+ ref = null;
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ protected RemoteObject(RemoteRef ref) {
+ this.ref = ref;
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public RemoteRef getRef() {
+ return ref;
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public String toString() {
+ String clName = RMIUtil.getShortName(getClass());
+ return (ref == null) ? clName
+ : clName + "[" + ref.remoteToString() + "]";
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public boolean equals(Object obj) {
+ if (!(obj instanceof RemoteObject)) {
+ return (obj == null) ? false : obj.equals(this);
+ }
+
+ if (ref != null) {
+ return ref.remoteEquals(((RemoteObject) obj).ref);
+ }
+ return (this == obj);
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public int hashCode() {
+ return (ref != null) ? ref.remoteHashCode() : super.hashCode();
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public static Remote toStub(Remote obj) throws NoSuchObjectException {
+ if (obj instanceof RemoteStub) {
+ return (RemoteStub) obj;
+ }
+ return ExportManager.getStub(obj);
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ private void writeObject(ObjectOutputStream out)
+ throws IOException {
+ if (ref == null) {
+ throw new MarshalException(
+ "Invalid remote object: RemoteRef = null");
+ }
+ String refType = ref.getRefClass(out);
+
+ if (refType != null && refType.length() != 0) {
+ out.writeUTF(refType);
+ ref.writeExternal(out);
+ } else {
+ out.writeUTF("");
+ out.writeObject(ref);
+ }
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ private void readObject(ObjectInputStream in)
+ throws IOException, ClassNotFoundException {
+ String refName = null;
+
+ try {
+ refName = in.readUTF();
+
+ if (refName.length() == 0) {
+ // read RemoteRef object
+ ref = (RemoteRef) in.readObject();
+ return;
+ }
+
+ // well-known RemoteRef types
+ // TODO: the following line is a temporary solution. Line after
+ // that should be uncommented later.
+ String refClName = "org.apache.harmony.rmi.remoteref." + refName;
+ //String refClName = RemoteRef.packagePrefix + "." + refName;
+ ref = ((RemoteRef) Class.forName(refClName).newInstance());
+ ref.readExternal(in);
+ } catch (Exception ex) {
+ throw new UnmarshalException("Unable to create RemoteRef instance",
+ ex);
+ }
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/RemoteObject.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/RemoteObjectInvocationHandler.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/RemoteObjectInvocationHandler.java?rev=407625&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/RemoteObjectInvocationHandler.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/RemoteObjectInvocationHandler.java Thu May 18 13:01:22 2006
@@ -0,0 +1,138 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Mikhail A. Markov
+ * @version $Revision: 1.4.4.3 $
+ */
+package java.rmi.server;
+
+import java.io.InvalidObjectException;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.rmi.Remote;
+import java.rmi.UnexpectedException;
+
+import org.apache.harmony.rmi.common.RMIHash;
+
+
+/**
+ * @com.intel.drl.spec_ref
+ *
+ * @author Mikhail A. Markov
+ * @version $Revision: 1.4.4.3 $
+ */
+public class RemoteObjectInvocationHandler extends RemoteObject
+ implements InvocationHandler {
+
+ private static final long serialVersionUID = 2L;
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public RemoteObjectInvocationHandler(RemoteRef ref) {
+ super(ref);
+
+ if (ref == null) {
+ throw new NullPointerException(
+ "RemoteRef parameter could not be null.");
+ }
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public Object invoke(Object proxy, Method m, Object[] args)
+ throws Throwable {
+ Class mClass = m.getDeclaringClass();
+
+ if (m.getDeclaringClass() == Object.class) {
+ return invokeObjectMethod(proxy, m, args);
+ } else if (!(proxy instanceof Remote)) {
+ throw new IllegalArgumentException(
+ "Proxy does not implement Remote interface.");
+ } else {
+ return invokeRemoteMethod(proxy, m, args);
+ }
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ private void readObjectNoData() throws InvalidObjectException {
+ throw new InvalidObjectException("No data in stream for class "
+ + this.getClass().getName());
+ }
+
+ /*
+ * Invokes methods from Object class.
+ */
+ private Object invokeObjectMethod(Object proxy, Method m, Object[] args) {
+ String mName = m.getName();
+
+ if (mName.equals("hashCode")) {
+ // return result of hashCode method call from RemoteObject class
+ return new Integer(hashCode());
+ } else if (mName.equals("equals")) {
+ Object obj = args[0];
+ return new Boolean((proxy == obj) // the same object?
+ || (obj != null && Proxy.isProxyClass(obj.getClass())
+ && equals(Proxy.getInvocationHandler(obj))));
+ } else if (mName.equals("toString")) {
+ Class[] interf = proxy.getClass().getInterfaces();
+
+ if (interf.length == 0) {
+ return "Proxy[" + toString() + "]";
+ }
+ String str = "Proxy[interf:[";
+
+ for (int i = 0; i < interf.length - 1; ++i) {
+ str += interf[i].getName() + ", ";
+ }
+ return str + interf[interf.length - 1].getName() + "], "
+ + toString() + "]";
+ } else {
+ throw new IllegalArgumentException(
+ "Illegal method from Object class: " + m);
+ }
+ }
+
+ /*
+ * Invokes Remote methods.
+ */
+ private Object invokeRemoteMethod(Object proxy, Method m, Object[] args)
+ throws Throwable {
+ try {
+ return ref.invoke((Remote) proxy, m, args,
+ RMIHash.getMethodHash(m));
+ } catch (RuntimeException re) {
+ throw re;
+ } catch (Exception ex) {
+ Method m1 = proxy.getClass().getMethod(m.getName(),
+ m.getParameterTypes());
+ Class[] declaredEx = m1.getExceptionTypes();
+
+ for (int i = 0; i < declaredEx.length; ++i) {
+ if (declaredEx[i].isAssignableFrom(ex.getClass())) {
+ throw ex;
+ }
+ }
+ throw new UnexpectedException("Unexpected exception", ex);
+ }
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/RemoteObjectInvocationHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/RemoteRef.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/RemoteRef.java?rev=407625&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/RemoteRef.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/RemoteRef.java Thu May 18 13:01:22 2006
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Mikhail A. Markov
+ * @version $Revision: 1.6.4.2 $
+ */
+package java.rmi.server;
+
+import java.lang.reflect.Method;
+import java.io.Externalizable;
+import java.io.ObjectOutput;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+
+/**
+ * @com.intel.drl.spec_ref
+ *
+ * @author Mikhail A. Markov
+ * @version $Revision: 1.6.4.2 $
+ */
+public interface RemoteRef extends Externalizable {
+
+ public static final long serialVersionUID = 3632638527362204081L;
+
+ /** @com.intel.drl.spec_ref */
+ public static final String packagePrefix =
+ "org.apache.harmony.rmi.remoteref";
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public Object invoke(Remote obj,
+ Method m,
+ Object[] params,
+ long h)
+ throws Exception;
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public RemoteCall newCall(RemoteObject obj,
+ Operation[] op,
+ int a1,
+ long a2)
+ throws RemoteException;
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public String getRefClass(ObjectOutput out);
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public boolean remoteEquals(RemoteRef ref);
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public void invoke(RemoteCall call) throws Exception;
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public void done(RemoteCall call) throws RemoteException;
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public String remoteToString();
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public int remoteHashCode();
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/RemoteRef.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/RemoteServer.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/RemoteServer.java?rev=407625&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/RemoteServer.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/RemoteServer.java Thu May 18 13:01:22 2006
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Mikhail A. Markov
+ * @version $Revision: 1.7.4.3 $
+ */
+package java.rmi.server;
+
+import java.io.OutputStream;
+import java.io.PrintStream;
+import java.util.logging.LoggingPermission;
+
+import org.apache.harmony.rmi.common.RMILog;
+import org.apache.harmony.rmi.server.ServerConnectionManager;
+
+
+/**
+ * @com.intel.drl.spec_ref
+ *
+ * @author Mikhail A. Markov
+ * @version $Revision: 1.7.4.3 $
+ */
+public abstract class RemoteServer extends RemoteObject {
+
+ private static final long serialVersionUID = -4100238210092549637L;
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ protected RemoteServer(RemoteRef ref) {
+ super(ref);
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ protected RemoteServer() {
+ super();
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public static String getClientHost() throws ServerNotActiveException {
+ String host = ServerConnectionManager.getClientHost();
+
+ if (host == null) {
+ throw new ServerNotActiveException(
+ "There are no in-progress RMI calls in this thread.");
+ }
+ return host;
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public static PrintStream getLog() {
+ return RMILog.getServerCallsLog().getPrintStream();
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public static void setLog(OutputStream out) {
+ SecurityManager mgr = System.getSecurityManager();
+
+ if (mgr != null) {
+ mgr.checkPermission(new LoggingPermission("control", null));
+ }
+ RMILog.getServerCallsLog().setOutputStream(out);
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/RemoteServer.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/RemoteStub.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/RemoteStub.java?rev=407625&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/RemoteStub.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/RemoteStub.java Thu May 18 13:01:22 2006
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Mikhail A. Markov
+ * @version $Revision: 1.5.4.2 $
+ */
+package java.rmi.server;
+
+
+/**
+ * @com.intel.drl.spec_ref
+ *
+ * @author Mikhail A. Markov
+ * @version $Revision: 1.5.4.2 $
+ */
+public abstract class RemoteStub extends RemoteObject {
+
+ private static final long serialVersionUID = -1585587260594494182L;
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ protected RemoteStub(RemoteRef ref) {
+ super(ref);
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ protected RemoteStub() {
+ super();
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ protected static void setRef(RemoteStub stub, RemoteRef ref) {
+ stub.ref = ref;
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/RemoteStub.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/ServerCloneException.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/ServerCloneException.java?rev=407625&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/ServerCloneException.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/ServerCloneException.java Thu May 18 13:01:22 2006
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Mikhail A. Markov
+ * @version $Revision: 1.7.4.2 $
+ */
+package java.rmi.server;
+
+
+/**
+ * @com.intel.drl.spec_ref
+ *
+ * @author Mikhail A. Markov
+ * @version $Revision: 1.7.4.2 $
+ */
+public class ServerCloneException extends CloneNotSupportedException {
+
+ private static final long serialVersionUID = 6617456357664815945L;
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public Exception detail;
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public ServerCloneException(String msg, Exception cause) {
+ super(msg);
+ detail = cause;
+ initCause(null);
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public ServerCloneException(String msg) {
+ this(msg, null);
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public Throwable getCause() {
+ return detail;
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public String getMessage() {
+ if (detail == null) {
+ return super.getMessage();
+ } else {
+ return super.getMessage() + " Caused by: " + detail.getMessage();
+ }
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/ServerCloneException.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/ServerNotActiveException.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/ServerNotActiveException.java?rev=407625&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/ServerNotActiveException.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/ServerNotActiveException.java Thu May 18 13:01:22 2006
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Mikhail A. Markov
+ * @version $Revision: 1.4.4.2 $
+ */
+package java.rmi.server;
+
+
+/**
+ * @com.intel.drl.spec_ref
+ *
+ * @author Mikhail A. Markov
+ * @version $Revision: 1.4.4.2 $
+ */
+public class ServerNotActiveException extends Exception {
+
+ private static final long serialVersionUID = 4687940720827538231L;
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public ServerNotActiveException(String msg) {
+ super(msg);
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public ServerNotActiveException() {
+ super();
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/ServerNotActiveException.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/ServerRef.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/ServerRef.java?rev=407625&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/ServerRef.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/ServerRef.java Thu May 18 13:01:22 2006
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Mikhail A. Markov
+ * @version $Revision: 1.4.4.2 $
+ */
+package java.rmi.server;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+
+/**
+ * @com.intel.drl.spec_ref
+ *
+ * @author Mikhail A. Markov
+ * @version $Revision: 1.4.4.2 $
+ */
+public interface ServerRef extends RemoteRef {
+
+ public static final long serialVersionUID = -4557750989390278438l;
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public RemoteStub exportObject(Remote obj, Object data)
+ throws RemoteException;
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public String getClientHost() throws ServerNotActiveException;
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/ServerRef.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/Skeleton.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/Skeleton.java?rev=407625&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/Skeleton.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/Skeleton.java Thu May 18 13:01:22 2006
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Mikhail A. Markov
+ * @version $Revision: 1.3.4.2 $
+ */
+package java.rmi.server;
+
+import java.rmi.Remote;
+
+
+/**
+ * @com.intel.drl.spec_ref
+ *
+ * @author Mikhail A. Markov
+ * @version $Revision: 1.3.4.2 $
+ */
+public interface Skeleton {
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public Operation[] getOperations();
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public void dispatch(Remote impl, RemoteCall call, int opnum, long hash)
+ throws Exception;
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/Skeleton.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/SkeletonMismatchException.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/SkeletonMismatchException.java?rev=407625&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/SkeletonMismatchException.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/SkeletonMismatchException.java Thu May 18 13:01:22 2006
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Mikhail A. Markov
+ * @version $Revision: 1.4.4.2 $
+ */
+package java.rmi.server;
+
+import java.rmi.RemoteException;
+
+
+/**
+ * @com.intel.drl.spec_ref
+ *
+ * @author Mikhail A. Markov
+ * @version $Revision: 1.4.4.2 $
+ */
+public class SkeletonMismatchException extends RemoteException {
+
+ private static final long serialVersionUID = -7780460454818859281L;
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public SkeletonMismatchException(String msg) {
+ super(msg);
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/SkeletonMismatchException.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/SkeletonNotFoundException.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/SkeletonNotFoundException.java?rev=407625&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/SkeletonNotFoundException.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/SkeletonNotFoundException.java Thu May 18 13:01:22 2006
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Mikhail A. Markov
+ * @version $Revision: 1.4.4.2 $
+ */
+package java.rmi.server;
+
+import java.rmi.RemoteException;
+
+
+/**
+ * @com.intel.drl.spec_ref
+ *
+ * @author Mikhail A. Markov
+ * @version $Revision: 1.4.4.2 $
+ */
+public class SkeletonNotFoundException extends RemoteException {
+
+ private static final long serialVersionUID = -7860299673822761231L;
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public SkeletonNotFoundException(String msg, Exception cause) {
+ super(msg, cause);
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public SkeletonNotFoundException(String msg) {
+ super(msg);
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/SkeletonNotFoundException.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/SocketSecurityException.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/SocketSecurityException.java?rev=407625&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/SocketSecurityException.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/SocketSecurityException.java Thu May 18 13:01:22 2006
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Mikhail A. Markov
+ * @version $Revision: 1.4.4.2 $
+ */
+package java.rmi.server;
+
+
+/**
+ * @com.intel.drl.spec_ref
+ *
+ * @author Mikhail A. Markov
+ * @version $Revision: 1.4.4.2 $
+ */
+public class SocketSecurityException extends ExportException {
+
+ private static final long serialVersionUID = -7622072999407781979L;
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public SocketSecurityException(String msg, Exception cause) {
+ super(msg, cause);
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public SocketSecurityException(String msg) {
+ super(msg);
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/SocketSecurityException.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/UID.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/UID.java?rev=407625&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/UID.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/UID.java Thu May 18 13:01:22 2006
@@ -0,0 +1,137 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Mikhail A. Markov
+ * @version $Revision: 1.7.4.3 $
+ */
+package java.rmi.server;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.io.Serializable;
+
+
+/**
+ * @com.intel.drl.spec_ref
+ *
+ * @author Mikhail A. Markov
+ * @version $Revision: 1.7.4.3 $
+ */
+public final class UID implements Serializable {
+
+ private static final long serialVersionUID = 1086053664494604050L;
+ private int unique;
+ private long time;
+ private short count;
+
+ // Sequentially increasing counter for initializing count field.
+ private static short countCounter = Short.MIN_VALUE;
+
+ // Time when last UID was created.
+ private static long lastCreationTime = System.currentTimeMillis();
+
+ // Lock object for synchronization.
+ private static final Object lock = new Object();
+
+ // unique identifier for this VM.
+ private static final int vmUnique = lock.hashCode();
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public UID(short num) {
+ unique = 0;
+ time = 0;
+ count = num;
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public UID() {
+ synchronized (lock) {
+ if (countCounter == Short.MAX_VALUE) {
+ long curTime = System.currentTimeMillis();
+
+ while (curTime - lastCreationTime < 1000) {
+ try {
+ // sleep for a while
+ Thread.sleep(1000);
+ } catch (InterruptedException ie) {
+ }
+ curTime = System.currentTimeMillis();
+ }
+ lastCreationTime = curTime;
+ countCounter = Short.MIN_VALUE;
+ }
+ unique = vmUnique;
+ time = lastCreationTime;
+ count = countCounter++;
+ }
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public String toString() {
+ return "UID[" + Integer.toString(unique, 16) + ":"
+ + Long.toString(time, 16) + ":"
+ + Integer.toString(count, 16) + "]";
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public boolean equals(Object obj) {
+ if (obj != null && (obj instanceof UID)) {
+ UID uid = (UID) obj;
+ return (unique == uid.unique)
+ && (time == uid.time)
+ && (count == uid.count);
+ }
+ return false;
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public void write(DataOutput out) throws IOException {
+ out.writeInt(unique);
+ out.writeLong(time);
+ out.writeShort(count);
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public int hashCode() {
+ return (int) (time ^ count);
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public static UID read(DataInput in) throws IOException {
+ UID uid = new UID((short) -1);
+ uid.unique = in.readInt();
+ uid.time = in.readLong();
+ uid.count = in.readShort();
+ return uid;
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/UID.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/UnicastRemoteObject.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/UnicastRemoteObject.java?rev=407625&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/UnicastRemoteObject.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/UnicastRemoteObject.java Thu May 18 13:01:22 2006
@@ -0,0 +1,179 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Mikhail A. Markov
+ * @version $Revision: 1.11.4.3 $
+ */
+package java.rmi.server;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.rmi.NoSuchObjectException;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+import org.apache.harmony.rmi.remoteref.UnicastServerRef;
+import org.apache.harmony.rmi.remoteref.UnicastServerRef2;
+import org.apache.harmony.rmi.server.ExportManager;
+
+
+/**
+ * @com.intel.drl.spec_ref
+ *
+ * @author Mikhail A. Markov
+ * @version $Revision: 1.11.4.3 $
+ */
+public class UnicastRemoteObject extends RemoteServer {
+
+ private static final long serialVersionUID = 4974527148936298033L;
+ private int port;
+ private RMIClientSocketFactory csf = null;
+ private RMIServerSocketFactory ssf = null;
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ protected UnicastRemoteObject(int port,
+ RMIClientSocketFactory csf,
+ RMIServerSocketFactory ssf)
+ throws RemoteException {
+ this.csf = csf;
+ this.ssf = ssf;
+ this.port = port;
+ exportObject(this, port, csf, ssf);
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ protected UnicastRemoteObject(int port) throws RemoteException {
+ this.port = port;
+ exportObject(this, port);
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ protected UnicastRemoteObject() throws RemoteException {
+ this(0);
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public Object clone() throws CloneNotSupportedException {
+ try {
+ UnicastRemoteObject clonedObj = (UnicastRemoteObject) super.clone();
+ clonedObj.export();
+ return clonedObj;
+ } catch (RemoteException re) {
+ throw new ServerCloneException("Unable to clone the object", re);
+ }
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public static Remote exportObject(Remote obj,
+ int port,
+ RMIClientSocketFactory csf,
+ RMIServerSocketFactory ssf)
+ throws RemoteException {
+ return exportObject(obj, port, csf, ssf, true);
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public static RemoteStub exportObject(Remote obj) throws RemoteException {
+ return (RemoteStub) exportObject(obj, 0, null, null, false);
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public static Remote exportObject(Remote obj, int port)
+ throws RemoteException {
+ return exportObject(obj, port, null, null, true);
+ }
+
+ /*
+ * Exports the given remote object.
+ *
+ * @param obj Remote object to be exported.
+ * @param port Port to export object on.
+ * @param csf Client-side socket factory
+ * @param ssf Server-side socket factory
+ * @param useProxyStubs If true then Proxy stubs will be generated if stub
+ * class could not be found in classpath and codebase; if false Proxy
+ * stubs will not be tried (this is needed for exportObject(Remote)
+ * method because it returns RemoteStub class (but Proxy class could
+ * not be casted to it)
+ *
+ * @return stub for exportec object
+ *
+ * @throws RemoteException if any error occured while exporting object
+ */
+ private static Remote exportObject(Remote obj,
+ int port,
+ RMIClientSocketFactory csf,
+ RMIServerSocketFactory ssf,
+ boolean useProxyStubs)
+ throws RemoteException {
+ UnicastServerRef sref;
+
+ if (csf != null || ssf != null) {
+ sref = new UnicastServerRef2(port, csf, ssf);
+ } else {
+ sref = new UnicastServerRef(port, csf, ssf);
+ }
+ Remote stub = ExportManager.exportObject(obj, sref,
+ useProxyStubs);
+
+ if (obj instanceof UnicastRemoteObject) {
+ ((UnicastRemoteObject) obj).ref = sref;
+ }
+ return stub;
+ }
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public static boolean unexportObject(Remote obj, boolean force)
+ throws NoSuchObjectException {
+ return ExportManager.unexportObject(obj, force);
+ }
+
+ private void readObject(ObjectInputStream in)
+ throws IOException, ClassNotFoundException {
+ in.defaultReadObject();
+ export();
+ }
+
+ /*
+ * Exports this UnicastRemoteObject from pre-initialized fields. This method
+ * is used by readObject() and clone() methods.
+ */
+ private void export() throws RemoteException {
+ if (csf != null || ssf != null) {
+ exportObject(this, port, csf, ssf);
+ } else {
+ exportObject(this, port);
+ }
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/UnicastRemoteObject.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/Unreferenced.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/Unreferenced.java?rev=407625&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/Unreferenced.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/Unreferenced.java Thu May 18 13:01:22 2006
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Mikhail A. Markov
+ * @version $Revision: 1.3.4.1 $
+ */
+package java.rmi.server;
+
+
+/**
+ * @com.intel.drl.spec_ref
+ *
+ * @author Mikhail A. Markov
+ * @version $Revision: 1.3.4.1 $
+ */
+public interface Unreferenced {
+
+ /**
+ * @com.intel.drl.spec_ref
+ */
+ public void unreferenced();
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/Unreferenced.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/package.html
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/package.html?rev=407625&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/package.html (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/package.html Thu May 18 13:01:22 2006
@@ -0,0 +1,25 @@
+<html>
+<!--
+Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+<!--
+Author: Vasily Zakharov
+Version: $Revision: 1.1.2.1 $
+-->
+<body>
+RMI server side package.
+</body>
+</html>
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/java/rmi/server/package.html
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/DefaultRMIClassLoaderSpi.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/DefaultRMIClassLoaderSpi.java?rev=407625&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/DefaultRMIClassLoaderSpi.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/DefaultRMIClassLoaderSpi.java Thu May 18 13:01:22 2006
@@ -0,0 +1,797 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Mikhail A. Markov
+ * @version $Revision: 1.1.2.2 $
+ */
+package org.apache.harmony.rmi;
+
+import java.lang.ref.WeakReference;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.Proxy;
+import java.io.File;
+import java.io.FilePermission;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.StringTokenizer;
+import java.net.MalformedURLException;
+import java.net.SocketPermission;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.security.AccessControlContext;
+import java.security.AccessController;
+import java.security.CodeSource;
+import java.security.Permission;
+import java.security.PermissionCollection;
+import java.security.Permissions;
+import java.security.Policy;
+import java.security.PrivilegedAction;
+import java.security.ProtectionDomain;
+import java.security.cert.Certificate;
+import java.rmi.server.LoaderHandler;
+import java.rmi.server.RMIClassLoaderSpi;
+
+import org.apache.harmony.rmi.common.GetStringPropAction;
+import org.apache.harmony.rmi.common.RMILog;
+import org.apache.harmony.rmi.common.RMIProperties;
+
+
+/**
+ * Default implementation of RMIClassLoaderSpi.
+ *
+ * @author Mikhail A. Markov
+ * @version $Revision: 1.1.2.2 $
+ */
+public class DefaultRMIClassLoaderSpi extends RMIClassLoaderSpi
+ implements LoaderHandler {
+
+ // value of codebase property
+ private static String userCodeBase;
+
+ // table holding list of URLLoader-s
+ private static Hashtable table = new Hashtable();
+
+ static {
+ String codebaseVal = (String) AccessController.doPrivileged(
+ new GetStringPropAction(RMIProperties.CODEBASE_PROP));
+ userCodeBase = (codebaseVal == null || codebaseVal.trim().length() == 0)
+ ? null : codebaseVal.trim();
+ }
+
+ // Logger where to write loader messages.
+ private static final RMILog loaderLog = RMILog.getLoaderLog();
+
+ /**
+ * Constructs DefaultRMIClassLoaderSpi.
+ */
+ public DefaultRMIClassLoaderSpi() {
+ }
+
+ /**
+ * @see RMIClassLoaderSpi.loadProxyClass(String, String[], ClassLoader)
+ */
+ public Class loadProxyClass(String codebase,
+ String[] interf,
+ ClassLoader defaultLoader)
+ throws MalformedURLException, ClassNotFoundException {
+ if (loaderLog.isLoggable(RMILog.VERBOSE)) {
+ loaderLog.log(RMILog.VERBOSE, "Loading proxy class: interf=["
+ + Arrays.asList(interf) + "], codebase=\""
+ + ((codebase == null) ? "" : codebase)
+ + "\", defaultLoader=" + defaultLoader);
+ }
+ Class[] interfCl = new Class[interf.length];
+ ClassLoader codebaseLoader = null;
+ Exception ex = null;
+
+ try {
+ codebaseLoader = getClassLoader1(codebase);
+ } catch (SecurityException se) {
+ if (loaderLog.isLoggable(RMILog.BRIEF)) {
+ loaderLog.log(RMILog.BRIEF,
+ "Could not obtain classloader for codebase \""
+ + ((codebase == null) ? "" : codebase)
+ + "\" (access denied).");
+ }
+ ex = se;
+ }
+ boolean failed = false;
+
+ // try to resolve all interfaces
+ if (defaultLoader != null) {
+ for (int i = 0; i < interf.length; ++i) {
+ try {
+ interfCl[i] = Class.forName(interf[i], false,
+ defaultLoader);
+ } catch (Exception ex1) {
+ if (loaderLog.isLoggable(RMILog.VERBOSE)) {
+ loaderLog.log(RMILog.VERBOSE,
+ "Unable to load interface " + interf[i]
+ + " via default loader " + defaultLoader + ":"
+ + ex1);
+ }
+ failed = true;
+ }
+ }
+ }
+
+ if (failed || (defaultLoader == null)) {
+ if (ex != null) {
+ ClassLoader curLoader =
+ Thread.currentThread().getContextClassLoader();
+
+ if (loaderLog.isLoggable(RMILog.VERBOSE)) {
+ loaderLog.log(RMILog.VERBOSE,
+ "Trying thread context classloader ("
+ + curLoader + ").");
+ }
+ codebaseLoader = curLoader;
+
+ }
+
+ for (int i = 0; i < interf.length; ++i) {
+ try {
+ interfCl[i] = Class.forName(interf[i], false,
+ codebaseLoader);
+ } catch (Exception ex1) {
+ if (loaderLog.isLoggable(RMILog.BRIEF)) {
+ loaderLog.log(RMILog.BRIEF,
+ "Unable to load interface " + interf[i]
+ + " via " + codebaseLoader);
+ }
+
+ if (ex != null) {
+ String msg = "Could not load proxy class "
+ + "(access to loader for codebase \""
+ + ((codebase == null) ? "" : codebase)
+ + "\" denied).";
+
+ if (loaderLog.isLoggable(RMILog.BRIEF)) {
+ loaderLog.log(RMILog.BRIEF, msg);
+ }
+ throw new ClassNotFoundException(msg, ex);
+ } else {
+ throw new ClassNotFoundException(
+ "Unable to load proxy class", ex1);
+ }
+ }
+ }
+ }
+
+ // successfully loaded all interfaces
+ boolean allPublic = true;
+ ClassLoader interfLoader = null;
+ boolean sameLoader = true;
+
+ // check if all interfaces are public
+ for (int i = 0; i < interfCl.length; ++i) {
+ if (!Modifier.isPublic(interfCl[i].getModifiers())) {
+ allPublic = false;
+ ClassLoader loader = interfCl[i].getClassLoader();
+
+ if (interfLoader == null) {
+ interfLoader = loader;
+ } else if (!interfLoader.equals(loader)) {
+ if (loaderLog.isLoggable(RMILog.BRIEF)) {
+ loaderLog.log(RMILog.BRIEF, "Non-public interface "
+ + interfCl[i] + " is loaded by another loader ("
+ + loader + ") then others (" + interfLoader
+ + ")");
+ }
+ sameLoader = false;
+ }
+ }
+ }
+
+ if (allPublic) {
+ // all interfaces are public
+ Class proxyCl = null;
+
+ try {
+ proxyCl = Proxy.getProxyClass(codebaseLoader, interfCl);
+
+ if (loaderLog.isLoggable(RMILog.BRIEF)) {
+ loaderLog.log(RMILog.BRIEF, "Loaded proxy class "
+ + proxyCl + " via " + codebaseLoader);
+ }
+ } catch (IllegalArgumentException iae) {
+ try {
+ proxyCl = Proxy.getProxyClass(defaultLoader, interfCl);
+
+ if (loaderLog.isLoggable(RMILog.BRIEF)) {
+ loaderLog.log(RMILog.BRIEF, "Loaded proxy class "
+ + proxyCl + " via " + defaultLoader);
+ }
+ } catch (IllegalArgumentException iae1) {
+ if (loaderLog.isLoggable(RMILog.BRIEF)) {
+ loaderLog.log(RMILog.BRIEF,
+ "Unable to load proxy class via both "
+ + "loaders (" + codebaseLoader + ", "
+ + defaultLoader + ")");
+ }
+ throw new ClassNotFoundException(
+ "Unable to load proxy class", iae1);
+ }
+ }
+ return proxyCl;
+ }
+
+ // there are non-public interfaces
+ if (sameLoader) {
+ // they are defined in the same ClassLoader
+ Class proxyCl = Proxy.getProxyClass(interfLoader, interfCl);
+
+ if (loaderLog.isLoggable(RMILog.BRIEF)) {
+ loaderLog.log(RMILog.BRIEF, "Loaded proxy class "
+ + proxyCl + " via " + interfLoader);
+ }
+ return proxyCl;
+ }
+ throw new LinkageError("Unable to load proxy class");
+ }
+
+ /**
+ * @see RMIClassLoaderSpi.loadClass(String, String, ClassLoader)
+ */
+ public Class loadClass(String codebase,
+ String name,
+ ClassLoader defaultLoader)
+ throws MalformedURLException, ClassNotFoundException {
+ if (loaderLog.isLoggable(RMILog.VERBOSE)) {
+ loaderLog.log(RMILog.VERBOSE, "Loading class: name=\"" + name
+ + "\", codebase=\"" + ((codebase == null) ? "" : codebase)
+ + "\", defaultLoader=" + defaultLoader);
+ }
+
+ try {
+ if (defaultLoader != null) {
+ Class c = Class.forName(name, false, defaultLoader);
+
+ if (loaderLog.isLoggable(RMILog.BRIEF)) {
+ loaderLog.log(RMILog.BRIEF, "Loaded class: " + name
+ + " via default loader: " + defaultLoader);
+ }
+ return c;
+ }
+ } catch (ClassNotFoundException cnfe) {
+ // we ignore this exception and proceed
+ }
+ ClassLoader codebaseLoader = null;
+ Exception ex = null;
+
+ try {
+ codebaseLoader = getClassLoader1(codebase);
+ } catch (SecurityException se) {
+ if (loaderLog.isLoggable(RMILog.BRIEF)) {
+ loaderLog.log(RMILog.BRIEF,
+ "Could not obtain classloader for codebase \""
+ + ((codebase == null) ? "" : codebase)
+ + "\" (access denied).");
+ }
+ ex = se;
+ }
+ Class c;
+
+ if (ex != null) {
+ ClassLoader curLoader =
+ Thread.currentThread().getContextClassLoader();
+
+ if (loaderLog.isLoggable(RMILog.VERBOSE)) {
+ loaderLog.log(RMILog.VERBOSE,
+ "Trying thread context classloader ("
+ + curLoader + ").");
+ }
+
+ try {
+ c = Class.forName(name, false, curLoader);
+ } catch (ClassNotFoundException cnfe1) {
+ if (loaderLog.isLoggable(RMILog.VERBOSE)) {
+ loaderLog.log(RMILog.VERBOSE,
+ "Could not load class " + name
+ + " via thread context classloader "
+ + "(access to codebase loader is denied).");
+ }
+ throw new ClassNotFoundException("Could not load class " + name
+ + "(access to loader for codebase \""
+ + ((codebase == null) ? "" : codebase) + "\" denied).",
+ ex);
+ }
+
+ if (loaderLog.isLoggable(RMILog.BRIEF)) {
+ loaderLog.log(RMILog.BRIEF, "Loaded class: " + name
+ + " via thread context classloader.");
+ }
+ } else {
+ c = Class.forName(name, false, codebaseLoader);
+
+ if (loaderLog.isLoggable(RMILog.VERBOSE)) {
+ loaderLog.log(RMILog.VERBOSE, "Loaded class: " + name
+ + " via " + codebaseLoader);
+ }
+ }
+ return c;
+ }
+
+ /**
+ * @see RMIClassLoaderSpi.getClassAnnotation(Class)
+ */
+ public String getClassAnnotation(Class cl) {
+ ClassLoader loader = cl.getClassLoader();
+ ClassLoader systemLoader = ClassLoader.getSystemClassLoader();
+
+ if (loader == systemLoader || (systemLoader != null
+ && loader == systemLoader.getParent())) {
+ return userCodeBase;
+ }
+
+ if (loader instanceof URLLoader) {
+ return ((URLLoader) loader).getAnnotations();
+ } else if (loader instanceof URLClassLoader) {
+ URL[] urls = ((URLClassLoader) loader).getURLs();
+ String annot = urlsToCodebase(urls);
+
+ if (annot == null) {
+ return userCodeBase;
+ }
+ SecurityManager mgr = System.getSecurityManager();
+
+ if (mgr != null) {
+ try {
+ for (int i = 0; i < urls.length; ++i) {
+ Permission p = urls[i].openConnection().getPermission();
+
+ if (p != null) {
+ mgr.checkPermission(p);
+ }
+ }
+ } catch (SecurityException se) {
+ return userCodeBase;
+ } catch (IOException ioe) {
+ return userCodeBase;
+ }
+ }
+ return annot;
+ } else {
+ return userCodeBase;
+ }
+ }
+
+ /**
+ * @see RMIClassLoaderSpi.getClassLoader(String)
+ */
+ public ClassLoader getClassLoader(String codebase)
+ throws MalformedURLException {
+ SecurityManager mgr = System.getSecurityManager();
+
+ if (mgr == null) {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ mgr.checkPermission(new RuntimePermission("getClassLoader"));
+ return getClassLoader1(codebase);
+ }
+
+ /**
+ * @see LoaderHandler.loadClass(String)
+ */
+ public Class loadClass(String name)
+ throws MalformedURLException, ClassNotFoundException {
+ return loadClass(null, name, null);
+ }
+
+ /**
+ * @see LoaderHandler.loadClass(URL, String)
+ */
+ public Class loadClass(URL codebase, String name)
+ throws MalformedURLException, ClassNotFoundException {
+ return loadClass(codebase.toExternalForm(), name, null);
+ }
+
+ /**
+ * Always returns null.
+ * This method came from LoaderHandler class and not used.
+ *
+ * @see LoaderHandler.getSecurityContext(ClassLoader)
+ */
+ public Object getSecurityContext(ClassLoader loader) {
+ return null;
+ }
+
+ /*
+ * Finds loader in classloaders table. Returns it as a result if it's not
+ * null, otherwise creates URLLoader, adds it to the table and returns it
+ * as a result.
+ *
+ * @param codebase list of URLs separated by spaces
+ *
+ * @return ClassLoader found/created
+ *
+ * @throws MalformedURLException if the method was unable to parse one of
+ * provided URLs
+ */
+ private static ClassLoader getClassLoader1(String codebase)
+ throws MalformedURLException {
+ SecurityManager mgr = System.getSecurityManager();
+ ClassLoader parentLoader =
+ Thread.currentThread().getContextClassLoader();
+
+ if (mgr == null) {
+ return parentLoader;
+ }
+
+ if (codebase == null) {
+ if (userCodeBase != null) {
+ codebase = userCodeBase;
+ } else {
+ return parentLoader;
+ }
+ }
+ TableKey key = new TableKey(parentLoader, codebase);
+ URLLoader loader = null;
+
+ if (table.containsKey(key)) {
+ loader = (URLLoader) ((WeakReference) table.get(key)).get();
+
+ if (loader == null) {
+ table.remove(key);
+ } else {
+ if (loader != null) {
+ loader.checkPermissions();
+ }
+ return loader;
+ }
+ }
+ AccessControlContext ctx = createLoaderACC(key.getURLs());
+
+ // PrivilegedAction for URLLoader creation
+ class CreateLoaderAction implements PrivilegedAction {
+ URL[] urls;
+ ClassLoader parentLoader;
+
+ public CreateLoaderAction(URL[] urls, ClassLoader parentLoader) {
+ this.urls = urls;
+ this.parentLoader = parentLoader;
+ }
+
+ public Object run() {
+ return new URLLoader(urls, parentLoader);
+ }
+ }
+ loader = (URLLoader) AccessController.doPrivileged(
+ new CreateLoaderAction(key.getURLs(), parentLoader), ctx);
+ table.put(key, new WeakReference(loader));
+
+ if (loader != null) {
+ loader.checkPermissions();
+ }
+ return loader;
+ }
+
+ /*
+ * Creates and returns AccessControlContext required to create
+ * URLClassLoader (i.e. context containing permissions sufficient
+ * to create URLClassLoader).
+ *
+ * @param urls list of URLs permissions for which should be granted in
+ * created ACC
+ *
+ * @return AccessControlContext required to create URLClassLoader passing
+ * specified URLs to it's constructor
+ */
+ private static AccessControlContext createLoaderACC(URL[] urls) {
+ // get existing permissions from the installed policy
+ PermissionCollection perms = (PermissionCollection)
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ CodeSource cs =
+ new CodeSource(null, (Certificate []) null);
+ Policy policy = Policy.getPolicy();
+
+ if (policy != null) {
+ return policy.getPermissions(cs);
+ }
+ return new Permissions();
+ }
+ });
+
+ // add permissions for URLs
+ addURLsPerms(urls, perms, true);
+
+ // grant permission for ClassLoader creation
+ perms.add(new RuntimePermission("createClassLoader"));
+
+ // create AccessControlContext from created Permissions
+ ProtectionDomain[] domains;
+
+ if (urls.length == 0) {
+ domains = new ProtectionDomain[] { new ProtectionDomain(
+ new CodeSource(null, (Certificate []) null), perms) };
+ } else {
+ domains = new ProtectionDomain[urls.length];
+
+ for (int i = 0; i < urls.length; ++i) {
+ domains[i] = new ProtectionDomain(new CodeSource(
+ urls[i], (Certificate []) null), perms);
+ }
+ }
+ return new AccessControlContext(domains);
+ }
+
+ /*
+ * Adds Permissions required to access provided list of URLs to specified
+ * PermissionCollection and returns this collection as a result.
+ *
+ * @param urls list of URLs for which Permissions should be added
+ * @param perms PermissionCollection where permissions should be added
+ * @param forACC if true then this method was called for creating loader's
+ * AccessControlContext and additional SocketPermission should be
+ * added in case if url is not "file:///"
+ *
+ * @return updated Permissioncollection as a result
+ */
+ private static PermissionCollection addURLsPerms(
+ URL[] urls, PermissionCollection perms, boolean forACC) {
+ for (int i = 0; i < urls.length; ++i) {
+ Permission perm = null;
+
+ try {
+ perm = urls[i].openConnection().getPermission();
+ } catch (IOException ioe) {
+ continue;
+ }
+
+ if (perm == null) {
+ continue;
+ }
+
+ if (perm instanceof FilePermission) {
+ /*
+ * For proper handling of codebases like: file:///c:/tmp/,
+ * where tmp is a directory, we should add '-' symbol to allow
+ * the classloader to read this directory and all subdirectories
+ * if the classes with packages are in this directory unpacked
+ * (not in .jar file).
+ */
+ String str = perm.getName();
+ int idx = str.lastIndexOf(File.separatorChar);
+
+ if (!str.endsWith(File.separator)) {
+ perms.add(perm);
+ } else {
+ perms.add(new FilePermission(str + "-", "read"));
+ }
+ } else {
+ perms.add(perm);
+
+ if (forACC) {
+ /*
+ * This method was called in 'createLoaderACC()' method
+ * for loader's AccessControlContext creation and additional
+ * SocketPermission allowing connecting to url's host and
+ * accepting connections from it should be added.
+ */
+ String host = urls[i].getHost();
+
+ if (host != null) {
+ perms.add(new SocketPermission(host,
+ "connect, accept"));
+ }
+ }
+ }
+ }
+ return perms;
+ }
+
+ /*
+ * Converts string representation of urls to sorted array of URLs.
+ *
+ * @param list list of urls separated by spaces
+ *
+ * @return sorted array of URLs from specified list
+ */
+ private static URL[] getSortedURLs(String list)
+ throws MalformedURLException {
+ if (list == null) {
+ return null;
+ }
+ StringTokenizer tok = new StringTokenizer(list);
+ String[] strs = new String[tok.countTokens()];
+
+ for (int i = 0; i < strs.length; ++i) {
+ strs[i] = tok.nextToken();
+ }
+ Arrays.sort(strs);
+ URL[] urls = new URL[strs.length];
+
+ for (int i = 0; i < strs.length; ++i) {
+ urls[i] = new URL(strs[i]);
+ }
+ return urls;
+ }
+
+ /*
+ * Converts list of URLs to a string, where URLs are separated by spaces.
+ *
+ * @param list of URLs to be converted
+ *
+ * @return string containing specified URLs separated by spaces
+ */
+ private static String urlsToCodebase(URL[] urls) {
+ if (urls == null || urls.length == 0) {
+ return null;
+ }
+ String str = "";
+
+ for (int i = 0; i < urls.length - 1; ++i) {
+ str += urls[i].toExternalForm() + " ";
+ }
+ return str + urls[urls.length - 1].toExternalForm();
+ }
+
+
+ /*
+ * This class is a subclass of URLClassLoader. It containts annotations for
+ * classes and also permissions to be checked if requested.
+ */
+ private static class URLLoader extends URLClassLoader {
+ // annotations for classes
+ private String annot;
+
+ // permissions to be checked if requested
+ private Permissions perms;
+
+ /*
+ * Constructs URLLoader from sorted list of URLs and parent ClassLoader.
+ *
+ * @param urls sorted list of URLs
+ * @param parent parent ClassLoader
+ */
+ URLLoader(URL[] urls, ClassLoader parent) {
+ super(urls, parent);
+ perms = new Permissions();
+ addURLsPerms(urls, perms, false);
+ annot = urlsToCodebase(urls);
+ }
+
+ /*
+ * Returns annotations for classes.
+ *
+ * @return annotations for classes
+ */
+ String getAnnotations() {
+ return annot;
+ }
+
+ /*
+ * Checks permissions contained in this loader if SecurityManager
+ * installed is not null. The method will throw SecurityException
+ * (as SecurityManager does) if one of the permissions is not granted.
+ */
+ void checkPermissions() {
+ SecurityManager mgr = System.getSecurityManager();
+
+ if (mgr != null) {
+ for (Enumeration en = perms.elements(); en.hasMoreElements();
+ mgr.checkPermission((Permission) en.nextElement())) {
+ }
+ }
+ }
+
+ /**
+ * Returns string representation of this loader.
+ *
+ * @return string representation of this loader
+ */
+ public String toString() {
+ return getClass().getName() + "[annot:\"" + annot + "\"]";
+ }
+ }
+
+
+ /*
+ * Class representing key for storing classloaders in Hashtable. It consists
+ * of a pair: loader/URL[].
+ */
+ private static class TableKey {
+ private ClassLoader loader;
+ private URL[] urls;
+ private int hashCode;
+
+ /*
+ * Constructs TableKey from string representation of the list of URLs.
+ *
+ * @param loader ClassLoader
+ * @param codebase String represented codebase list (possibly unsorted)
+ * separated by <space>
+ */
+ TableKey(ClassLoader loader, String codebase)
+ throws MalformedURLException {
+ this(loader, getSortedURLs(codebase));
+ }
+
+ /*
+ * Constructs TableKey from the specified sorted array of URLs.
+ *
+ * @param loader ClassLoader
+ * @param urls array of URLs (possibly unsorted)
+ */
+ TableKey(ClassLoader loader, URL[] urls) {
+ this.loader = loader;
+ this.urls = urls;
+
+ // calculate hashCode
+ hashCode = (loader == null) ? 0 : loader.hashCode();
+
+ for (int i = 0; i < urls.length; ++i) {
+ hashCode ^= urls[i].hashCode();
+ }
+ }
+
+ /*
+ * Returns ClassLoader contained in this TableKey.
+ *
+ * @return ClassLoader contained in this TableKey
+ */
+ ClassLoader getLoader() {
+ return loader;
+ }
+
+ /*
+ * Returns sorted list of URLs contained in this TableKey.
+ *
+ * @return sorted list of URLs contained in this TableKey
+ */
+ public URL[] getURLs() {
+ return urls;
+ }
+
+ /**
+ * Compares this object with another one. Returns true if the object for
+ * comparison is an instance of TableKey and they contained the same
+ * loader and urls fields.
+ *
+ * @param obj object for comparison
+ *
+ * @return true if object specified is equal to this TableKey and false
+ * otherwise
+ */
+ public boolean equals(Object obj) {
+ if (!(obj instanceof TableKey)) {
+ return false;
+ }
+ TableKey key = (TableKey) obj;
+
+ if (hashCode() != key.hashCode()) {
+ return false;
+ }
+ return ((loader != null) ? loader.equals(key.loader)
+ : (key.loader == null)) && ((urls != null)
+ ? Arrays.equals(urls, key.urls) : (key.urls == null));
+ }
+
+ /**
+ * Returns hash code for this TableKey.
+ *
+ * @return hash code for this TableKey
+ */
+ public int hashCode() {
+ return hashCode;
+ }
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/DefaultRMIClassLoaderSpi.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/MarshalledObjectInputStream.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/MarshalledObjectInputStream.java?rev=407625&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/MarshalledObjectInputStream.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/MarshalledObjectInputStream.java Thu May 18 13:01:22 2006
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Mikhail A. Markov
+ * @version $Revision: 1.1.2.2 $
+ */
+package org.apache.harmony.rmi;
+
+import java.io.IOException;
+import java.io.ByteArrayInputStream;
+import java.io.ObjectInputStream;
+
+import org.apache.harmony.rmi.transport.RMIObjectInputStream;
+
+
+/**
+ * The MarshalledObjectInputStream uses the same deserialization rules as it's
+ * predecessor RMIObjectInputStream. It is intended to be used by
+ * java.rmi.MarshalledObject class.
+ *
+ * @author Mikhail A. Markov
+ * @version $Revision: 1.1.2.2 $
+ *
+ * @see RMIObjectInputStream
+ */
+public class MarshalledObjectInputStream extends RMIObjectInputStream {
+
+ /**
+ * Constructs a MarshalledObjectOutputStream from 2 arrays: array with
+ * serialized objects, and array with annotations for the objects.
+ *
+ * @param objBytes serialized objects array
+ * @param locBytes annotations for serialized objects
+ *
+ * @throws IOException if an I/O error occured during streams initialization
+ */
+ public MarshalledObjectInputStream(byte[] objBytes, byte[] locBytes)
+ throws IOException {
+ super(new ByteArrayInputStream(objBytes));
+ setLocStream((locBytes == null) ? null : new ObjectInputStream(
+ new ByteArrayInputStream(locBytes)));
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/MarshalledObjectInputStream.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/MarshalledObjectOutputStream.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/MarshalledObjectOutputStream.java?rev=407625&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/MarshalledObjectOutputStream.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/MarshalledObjectOutputStream.java Thu May 18 13:01:22 2006
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation or its licensors, as applicable
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @author Mikhail A. Markov
+ * @version $Revision: 1.1.2.1 $
+ */
+package org.apache.harmony.rmi;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.ObjectOutputStream;
+import java.io.ByteArrayOutputStream;
+
+import org.apache.harmony.rmi.transport.RMIObjectOutputStream;
+
+
+/**
+ * The MarshalledObjectOutputStream uses the same serialization rules as it's
+ * predecessor RMIObjectOutputStream, but it holds annotations for classes
+ * separately from the main stream. It is intended to be used by
+ * java.rmi.MarshalledObject class.
+ *
+ * @author Mikhail A. Markov
+ * @version $Revision: 1.1.2.1 $
+ *
+ * @see RMIObjectOutputStream
+ */
+public class MarshalledObjectOutputStream extends RMIObjectOutputStream {
+
+ // ByteArrayOutputStream to write annotations.
+ private ByteArrayOutputStream locStream;
+
+ /**
+ * Constructs a MarshalledObjectOutputStream that writes to the specified
+ * OutputStream.
+ *
+ * @param out underlying OutputStream
+ *
+ * @throws IOException if an I/O error occured during stream initialization
+ */
+ public MarshalledObjectOutputStream(OutputStream out) throws IOException {
+ super(out);
+ locStream = new ByteArrayOutputStream();
+ setLocStream(new ObjectOutputStream(locStream));
+ }
+
+ /**
+ * Returns location annotations.
+ *
+ * @return location annotations.
+ */
+ public byte[] getLocBytes() {
+ return hasAnnotations() ? locStream.toByteArray() : null;
+ }
+}
Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi3/src/common/javasrc/org/apache/harmony/rmi/MarshalledObjectOutputStream.java
------------------------------------------------------------------------------
svn:eol-style = native
|