Modified: river/jtsk/modules/modularize/apache-river/river-services/mahalo/mahalo-service/src/main/java/org/apache/river/mahalo/log/TransientLogFile.java URL: http://svn.apache.org/viewvc/river/jtsk/modules/modularize/apache-river/river-services/mahalo/mahalo-service/src/main/java/org/apache/river/mahalo/log/TransientLogFile.java?rev=1879521&r1=1879520&r2=1879521&view=diff ============================================================================== --- river/jtsk/modules/modularize/apache-river/river-services/mahalo/mahalo-service/src/main/java/org/apache/river/mahalo/log/TransientLogFile.java (original) +++ river/jtsk/modules/modularize/apache-river/river-services/mahalo/mahalo-service/src/main/java/org/apache/river/mahalo/log/TransientLogFile.java Sun Jul 5 11:41:39 2020 @@ -1,150 +1,150 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ - -package org.apache.river.mahalo.log; - -import org.apache.river.mahalo.log.MultiLogManager.LogRemovalManager; -import org.apache.river.mahalo.TxnManager; - -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * An implementation of a non-persistent <code>Log</code>. - * - * @author Sun Microsystems, Inc. - * - * @see org.apache.river.mahalo.log.Log - */ -public class TransientLogFile implements Log { - /** Unique ID associated with this log */ - private final long cookie; - - /** - * Reference to <code>LogRemovalManager</code>, which is called - * to remove this log from the managed set of logs. - */ - private final LogRemovalManager logMgr; - - /** Logger for persistence related messages */ - private static final Logger persistenceLogger = - Logger.getLogger(TxnManager.MAHALO + ".persistence"); - - /** Logger for operations related messages */ - private static final Logger operationsLogger = - Logger.getLogger(TxnManager.MAHALO + ".operations"); - - /** - * Simple constructor that simply assigns the given parameter to - * an internal field. - * @param id the unique identifier for this log - * - * @see org.apache.river.mahalo.log.Log - * @see org.apache.river.mahalo.log.LogManager - * @see org.apache.river.mahalo.log.MultiLogManager - * @see org.apache.river.mahalo.log.MultiLogManager.LogRemovalManager - */ - public TransientLogFile(long id, LogRemovalManager lrm) { - if (operationsLogger.isLoggable(Level.FINER)) { - operationsLogger.entering(TransientLogFile.class.getName(), - "TransientLogFile", new Object[] {Long.valueOf(id), lrm}); - } - cookie = id; - logMgr = lrm; - if (operationsLogger.isLoggable(Level.FINER)) { - operationsLogger.exiting(TransientLogFile.class.getName(), - "TransientLogFile"); - } - } - - /** - * Returns the identifier associated with information in - * this <code>Log</code>. - * - * @see org.apache.river.mahalo.log.Log - */ - public long cookie() { - return cookie; - } - - /** - * Add a <code>LogRecord</code> to the <code>Log</code>. - * This method does nothing with the provided argument. - * - * @param rec the record to be ignored. - * - * @see org.apache.river.mahalo.log.LogRecord - */ - public void write(LogRecord rec) throws LogException { - if (operationsLogger.isLoggable(Level.FINER)) { - operationsLogger.entering(TransientLogFile.class.getName(), - "write", rec); - } - if (persistenceLogger.isLoggable(Level.FINEST)) { - persistenceLogger.log(Level.FINEST, - "(ignored) write called for cookie: {0}", Long.valueOf(cookie)); - } - if (operationsLogger.isLoggable(Level.FINER)) { - operationsLogger.exiting(TransientLogFile.class.getName(), - "write"); - } - } - - /** - * Invalidate the log. - */ - public void invalidate() throws LogException { - if (operationsLogger.isLoggable(Level.FINER)) { - operationsLogger.entering(TransientLogFile.class.getName(), - "invalidate"); - } - - if (persistenceLogger.isLoggable(Level.FINEST)) { - persistenceLogger.log(Level.FINEST, - "Calling logMgr to release cookie: {0}", Long.valueOf(cookie)); - } - logMgr.release(cookie); - - if (operationsLogger.isLoggable(Level.FINER)) { - operationsLogger.exiting(TransientLogFile.class.getName(), - "invalidate"); - } - } - - /** - * Recover information from the log. Does nothing. - * - * @param client who to inform with information from the log. - * - * @see org.apache.river.mahalo.log.LogRecovery - */ - public void recover(LogRecovery client) throws LogException { - if (operationsLogger.isLoggable(Level.FINER)) { - operationsLogger.entering(MultiLogManager.class.getName(), - "recover", client); - } - if (persistenceLogger.isLoggable(Level.FINEST)) { - persistenceLogger.log(Level.FINEST, - "(ignored) Recovering for: {0}", Long.valueOf(cookie)); - } - if (operationsLogger.isLoggable(Level.FINER)) { - operationsLogger.exiting(MultiLogManager.class.getName(), - "recover"); - } - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ + +package org.apache.river.mahalo.log; + +import org.apache.river.mahalo.log.MultiLogManager.LogRemovalManager; +import org.apache.river.mahalo.proxy.TxnManager; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * An implementation of a non-persistent <code>Log</code>. + * + * @author Sun Microsystems, Inc. + * + * @see org.apache.river.mahalo.log.Log + */ +public class TransientLogFile implements Log { + /** Unique ID associated with this log */ + private final long cookie; + + /** + * Reference to <code>LogRemovalManager</code>, which is called + * to remove this log from the managed set of logs. + */ + private final LogRemovalManager logMgr; + + /** Logger for persistence related messages */ + private static final Logger persistenceLogger = + Logger.getLogger(TxnManager.MAHALO + ".persistence"); + + /** Logger for operations related messages */ + private static final Logger operationsLogger = + Logger.getLogger(TxnManager.MAHALO + ".operations"); + + /** + * Simple constructor that simply assigns the given parameter to + * an internal field. + * @param id the unique identifier for this log + * + * @see org.apache.river.mahalo.log.Log + * @see org.apache.river.mahalo.log.LogManager + * @see org.apache.river.mahalo.log.MultiLogManager + * @see org.apache.river.mahalo.log.MultiLogManager.LogRemovalManager + */ + public TransientLogFile(long id, LogRemovalManager lrm) { + if (operationsLogger.isLoggable(Level.FINER)) { + operationsLogger.entering(TransientLogFile.class.getName(), + "TransientLogFile", new Object[] {Long.valueOf(id), lrm}); + } + cookie = id; + logMgr = lrm; + if (operationsLogger.isLoggable(Level.FINER)) { + operationsLogger.exiting(TransientLogFile.class.getName(), + "TransientLogFile"); + } + } + + /** + * Returns the identifier associated with information in + * this <code>Log</code>. + * + * @see org.apache.river.mahalo.log.Log + */ + public long cookie() { + return cookie; + } + + /** + * Add a <code>LogRecord</code> to the <code>Log</code>. + * This method does nothing with the provided argument. + * + * @param rec the record to be ignored. + * + * @see org.apache.river.mahalo.log.LogRecord + */ + public void write(LogRecord rec) throws LogException { + if (operationsLogger.isLoggable(Level.FINER)) { + operationsLogger.entering(TransientLogFile.class.getName(), + "write", rec); + } + if (persistenceLogger.isLoggable(Level.FINEST)) { + persistenceLogger.log(Level.FINEST, + "(ignored) write called for cookie: {0}", Long.valueOf(cookie)); + } + if (operationsLogger.isLoggable(Level.FINER)) { + operationsLogger.exiting(TransientLogFile.class.getName(), + "write"); + } + } + + /** + * Invalidate the log. + */ + public void invalidate() throws LogException { + if (operationsLogger.isLoggable(Level.FINER)) { + operationsLogger.entering(TransientLogFile.class.getName(), + "invalidate"); + } + + if (persistenceLogger.isLoggable(Level.FINEST)) { + persistenceLogger.log(Level.FINEST, + "Calling logMgr to release cookie: {0}", Long.valueOf(cookie)); + } + logMgr.release(cookie); + + if (operationsLogger.isLoggable(Level.FINER)) { + operationsLogger.exiting(TransientLogFile.class.getName(), + "invalidate"); + } + } + + /** + * Recover information from the log. Does nothing. + * + * @param client who to inform with information from the log. + * + * @see org.apache.river.mahalo.log.LogRecovery + */ + public void recover(LogRecovery client) throws LogException { + if (operationsLogger.isLoggable(Level.FINER)) { + operationsLogger.entering(MultiLogManager.class.getName(), + "recover", client); + } + if (persistenceLogger.isLoggable(Level.FINEST)) { + persistenceLogger.log(Level.FINEST, + "(ignored) Recovering for: {0}", Long.valueOf(cookie)); + } + if (operationsLogger.isLoggable(Level.FINER)) { + operationsLogger.exiting(MultiLogManager.class.getName(), + "recover"); + } + } +}
Modified: river/jtsk/modules/modularize/apache-river/river-services/mercury/mercury-dl/src/main/java/org/apache/river/mercury/proxy/InternalMailboxException.java URL: http://svn.apache.org/viewvc/river/jtsk/modules/modularize/apache-river/river-services/mercury/mercury-dl/src/main/java/org/apache/river/mercury/proxy/InternalMailboxException.java?rev=1879521&r1=1879520&r2=1879521&view=diff ============================================================================== --- river/jtsk/modules/modularize/apache-river/river-services/mercury/mercury-dl/src/main/java/org/apache/river/mercury/proxy/InternalMailboxException.java (original) +++ river/jtsk/modules/modularize/apache-river/river-services/mercury/mercury-dl/src/main/java/org/apache/river/mercury/proxy/InternalMailboxException.java Sun Jul 5 11:41:39 2020 @@ -1,95 +1,95 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ -package org.apache.river.mercury; - -import java.io.PrintStream; -import java.io.PrintWriter; - -/** - * This exception denotes a problem with the local implementation of the - * <code>EventMailbox</code> interface. The <code>detail</code> field - * will give a description that can be reported to the mailbox developer - * (and may be documented in that mailbox's external documentation). - * - * @author Sun Microsystems, Inc. - * - * @since 1.1 - */ -public class InternalMailboxException extends RuntimeException { - - private static final long serialVersionUID = 1L; - - /** - * The exception (if any) that triggered the internal exception. This - * field may be <code>null</code>. - * - * @serial - */ - public final Throwable nestedException; - - /** - * Create an exception, passing the string to the superclass' - * constructor. The nested exception will be <code>null</code>. - */ - public InternalMailboxException(String str) { - super(str); - nestedException = null; - } - - /** - * Create an exception, passing the string to the superclass' - * constructor. The nested exception will be set to the provided - * <tt>Throwable</tt> argument. - */ - public InternalMailboxException(String str, Throwable ex) { - super(str); - nestedException = ex; - } - - /** - * Print the stack trace of this exception and that of the nested - * exception, if any. - */ - public void printStackTrace() { - printStackTrace(System.err); - } - - /** - * Print the stack trace of this exception and that of the nested - * exception, if any. - */ - public void printStackTrace(PrintStream out) { - super.printStackTrace(out); - if (nestedException != null) { - out.println("nested exception:"); - nestedException.printStackTrace(out); - } - } - - /** - * Print the stack trace of this exception and that of the nested - * exception, if any. - */ - public void printStackTrace(PrintWriter out) { - super.printStackTrace(out); - if (nestedException != null) { - out.println("nested exception:"); - nestedException.printStackTrace(out); - } - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ +package org.apache.river.mercury.proxy; + +import java.io.PrintStream; +import java.io.PrintWriter; + +/** + * This exception denotes a problem with the local implementation of the + * <code>EventMailbox</code> interface. The <code>detail</code> field + * will give a description that can be reported to the mailbox developer + * (and may be documented in that mailbox's external documentation). + * + * @author Sun Microsystems, Inc. + * + * @since 1.1 + */ +public class InternalMailboxException extends RuntimeException { + + private static final long serialVersionUID = 1L; + + /** + * The exception (if any) that triggered the internal exception. This + * field may be <code>null</code>. + * + * @serial + */ + public final Throwable nestedException; + + /** + * Create an exception, passing the string to the superclass' + * constructor. The nested exception will be <code>null</code>. + */ + public InternalMailboxException(String str) { + super(str); + nestedException = null; + } + + /** + * Create an exception, passing the string to the superclass' + * constructor. The nested exception will be set to the provided + * <tt>Throwable</tt> argument. + */ + public InternalMailboxException(String str, Throwable ex) { + super(str); + nestedException = ex; + } + + /** + * Print the stack trace of this exception and that of the nested + * exception, if any. + */ + public void printStackTrace() { + printStackTrace(System.err); + } + + /** + * Print the stack trace of this exception and that of the nested + * exception, if any. + */ + public void printStackTrace(PrintStream out) { + super.printStackTrace(out); + if (nestedException != null) { + out.println("nested exception:"); + nestedException.printStackTrace(out); + } + } + + /** + * Print the stack trace of this exception and that of the nested + * exception, if any. + */ + public void printStackTrace(PrintWriter out) { + super.printStackTrace(out); + if (nestedException != null) { + out.println("nested exception:"); + nestedException.printStackTrace(out); + } + } +} Modified: river/jtsk/modules/modularize/apache-river/river-services/mercury/mercury-dl/src/main/java/org/apache/river/mercury/proxy/ListenerProxy.java URL: http://svn.apache.org/viewvc/river/jtsk/modules/modularize/apache-river/river-services/mercury/mercury-dl/src/main/java/org/apache/river/mercury/proxy/ListenerProxy.java?rev=1879521&r1=1879520&r2=1879521&view=diff ============================================================================== --- river/jtsk/modules/modularize/apache-river/river-services/mercury/mercury-dl/src/main/java/org/apache/river/mercury/proxy/ListenerProxy.java (original) +++ river/jtsk/modules/modularize/apache-river/river-services/mercury/mercury-dl/src/main/java/org/apache/river/mercury/proxy/ListenerProxy.java Sun Jul 5 11:41:39 2020 @@ -1,274 +1,274 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ -package org.apache.river.mercury; - -import org.apache.river.proxy.ConstrainableProxyUtil; -import org.apache.river.proxy.ThrowThis; -import net.jini.core.constraint.MethodConstraints; -import net.jini.core.constraint.RemoteMethodControl; -import net.jini.id.ReferentUuid; -import net.jini.id.ReferentUuids; -import net.jini.id.Uuid; -import net.jini.security.proxytrust.ProxyTrustIterator; -import net.jini.security.proxytrust.SingletonProxyTrustIterator; -import net.jini.security.TrustVerifier; - -import java.io.IOException; -import java.io.InvalidObjectException; -import java.io.ObjectInputStream; -import java.io.ObjectStreamException; -import java.io.Serializable; -import java.lang.reflect.Method; -import java.rmi.RemoteException; - -import javax.security.auth.Subject; - -import net.jini.core.event.RemoteEventListener; -import net.jini.core.event.RemoteEvent; -import net.jini.core.event.UnknownEventException; - -/** - * The <code>ListenerProxy</code> class implements the - * <code>RemoteEventListener</code> interface. - * Instances of this class are provided as the event "forwarding" - * target to clients of the mailbox service. - * - * @author Sun Microsystems, Inc. - * - * @since 1.1 - */ - -class ListenerProxy implements RemoteEventListener, Serializable, ReferentUuid { - - private static final long serialVersionUID = 2L; - - /** - * The reference to the event mailbox service implementation - * - * @serial - */ - final MailboxBackEnd server; - - /** - * The proxy's <code>Uuid</code> - * - * @serial - */ - final Uuid registrationID; - - /** - * Creates a mailbox listener proxy, returning an instance - * that implements RemoteMethodControl if the server does too. - * - * @param id the ID of the proxy - * @param server the server's listener proxy - */ - static ListenerProxy create(Uuid id, MailboxBackEnd server) { - if (server instanceof RemoteMethodControl) { - return new ConstrainableListenerProxy(server, id, null); - } else { - return new ListenerProxy(server, id); - } - } - - /** Simple constructor */ - private ListenerProxy(MailboxBackEnd ref, Uuid regID) { - if (ref == null || regID == null) - throw new IllegalArgumentException("Cannot accept null arguments"); - server = ref; - registrationID = regID; - } - - // documentation inherited from supertype - public void notify(RemoteEvent theEvent) - throws UnknownEventException, RemoteException - { - try { - server.notify(registrationID, theEvent); - } catch (ThrowThis tt) { - tt.throwRemoteException(); - } - - } - - /* From net.jini.id.ReferentUuid */ - /** - * Returns the universally unique identifier that has been assigned to the - * resource this proxy represents. - * - * @return the instance of <code>Uuid</code> that is associated with the - * resource this proxy represents. This method will not return - * <code>null</code>. - * - * @see net.jini.id.ReferentUuid - */ - // Final to ensure safety. Called by enableDeliveryDo() w/i lock - public final Uuid getReferentUuid() { - return registrationID; - } - - /** Proxies for servers with the same proxyID have the same hash code. */ - public int hashCode() { - return registrationID.hashCode(); - } - - /** - * Proxies for servers with the same <code>proxyID</code> are - * considered equal. - */ - public boolean equals(Object o) { - return ReferentUuids.compare(this,o); - } - - /** When an instance of this class is deserialized, this method is - * automatically invoked. This implementation of this method validates - * the state of the deserialized instance. - * - * @throws <code>InvalidObjectException</code> if the state of the - * deserialized instance of this class is found to be invalid. - */ - private void readObject(ObjectInputStream s) - throws IOException, ClassNotFoundException - { - s.defaultReadObject(); - /* Verify server */ - if(server == null) { - throw new InvalidObjectException("ListenerProxy.readObject " - +"failure - server " - +"field is null"); - }//endif - /* Verify registrationID */ - if(registrationID == null) { - - throw new InvalidObjectException("ListenerProxy.readObject " - +"failure - registrationID " - +"field is null"); - }//endif - }//end readObject - - /** During deserialization of an instance of this class, if it is found - * that the stream contains no data, this method is automatically - * invoked. Because it is expected that the stream should always - * contain data, this implementation of this method simply declares - * that something must be wrong. - * - * @throws <code>InvalidObjectException</code> to indicate that there - * was no data in the stream during deserialization of an - * instance of this class; declaring that something is wrong. - */ - private void readObjectNoData() throws ObjectStreamException { - throw new InvalidObjectException("no data found when attempting to " - +"deserialize ListenerProxy instance"); - }//end readObjectNoData - - - - /** A subclass of ListenerProxy that implements RemoteMethodControl. */ - final static class ConstrainableListenerProxy extends ListenerProxy - implements RemoteMethodControl - { - private static final long serialVersionUID = 2L; - - // Mappings from client to server methods, - private static final Method[] methodMap1 = { - ProxyUtil.getMethod(RemoteEventListener.class, - "notify", new Class[] {RemoteEvent.class}), - ProxyUtil.getMethod(MailboxBackEnd.class, - "notify", new Class[] {Uuid.class, RemoteEvent.class}), - }; - - /** - * The client constraints placed on this proxy or <code>null</code>. - * - * @serial - */ - private MethodConstraints methodConstraints; - - /** Creates an instance of this class. */ - private ConstrainableListenerProxy(MailboxBackEnd server, Uuid id, - MethodConstraints methodConstraints) - { - super(constrainServer(server, methodConstraints), id); - this.methodConstraints = methodConstraints; - } - - /** - * Returns a copy of the server proxy with the specified client - * constraints and methods mapping. - */ - private static MailboxBackEnd constrainServer( - MailboxBackEnd server, - MethodConstraints methodConstraints) - { - return (MailboxBackEnd) - ((RemoteMethodControl)server).setConstraints( - ConstrainableProxyUtil.translateConstraints( - methodConstraints, methodMap1)); - } - /** {@inheritDoc} */ - public RemoteMethodControl setConstraints( - MethodConstraints constraints) - { - return new ConstrainableListenerProxy(server, registrationID, - constraints); - } - - /** {@inheritDoc} */ - public MethodConstraints getConstraints() { - return methodConstraints; - } - - /* Note that the superclass's hashCode method is OK as is. */ - /* Note that the superclass's equals method is OK as is. */ - - /** - * Returns a proxy trust iterator that is used in - * <code>ProxyTrustVerifier</code> to retrieve this object's - * trust verifier. - */ - private ProxyTrustIterator getProxyTrustIterator() { - return new SingletonProxyTrustIterator(server); - }//end getProxyTrustIterator - - /** - * Verifies that the registrationID and server fields are - * not null, that server implements RemoteMethodControl, and that the - * server proxy has the appropriate method constraints. - * - * @throws InvalidObjectException if registrationID or mailbox - * is null, if server does not implement RemoteMethodControl, - * or if server has the wrong constraints - */ - - private void readObject(ObjectInputStream s) - throws IOException, ClassNotFoundException - { - /* Note that basic validation of the fields of this class was - * already performed in the readObject() method of this class' - * super class. - */ - s.defaultReadObject(); - /* Verify the server and its constraints */ - ConstrainableProxyUtil.verifyConsistentConstraints(methodConstraints, - server, - methodMap1); - } - } -} - - +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ +package org.apache.river.mercury.proxy; + +import org.apache.river.proxy.ConstrainableProxyUtil; +import org.apache.river.proxy.ThrowThis; +import net.jini.core.constraint.MethodConstraints; +import net.jini.core.constraint.RemoteMethodControl; +import net.jini.id.ReferentUuid; +import net.jini.id.ReferentUuids; +import net.jini.id.Uuid; +import net.jini.security.proxytrust.ProxyTrustIterator; +import net.jini.security.proxytrust.SingletonProxyTrustIterator; +import net.jini.security.TrustVerifier; + +import java.io.IOException; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; +import java.io.ObjectStreamException; +import java.io.Serializable; +import java.lang.reflect.Method; +import java.rmi.RemoteException; + +import javax.security.auth.Subject; + +import net.jini.core.event.RemoteEventListener; +import net.jini.core.event.RemoteEvent; +import net.jini.core.event.UnknownEventException; + +/** + * The <code>ListenerProxy</code> class implements the + * <code>RemoteEventListener</code> interface. + * Instances of this class are provided as the event "forwarding" + * target to clients of the mailbox service. + * + * @author Sun Microsystems, Inc. + * + * @since 1.1 + */ + +public class ListenerProxy implements RemoteEventListener, Serializable, ReferentUuid { + + private static final long serialVersionUID = 2L; + + /** + * The reference to the event mailbox service implementation + * + * @serial + */ + final MailboxBackEnd server; + + /** + * The proxy's <code>Uuid</code> + * + * @serial + */ + final Uuid registrationID; + + /** + * Creates a mailbox listener proxy, returning an instance + * that implements RemoteMethodControl if the server does too. + * + * @param id the ID of the proxy + * @param server the server's listener proxy + */ + static ListenerProxy create(Uuid id, MailboxBackEnd server) { + if (server instanceof RemoteMethodControl) { + return new ConstrainableListenerProxy(server, id, null); + } else { + return new ListenerProxy(server, id); + } + } + + /** Simple constructor */ + private ListenerProxy(MailboxBackEnd ref, Uuid regID) { + if (ref == null || regID == null) + throw new IllegalArgumentException("Cannot accept null arguments"); + server = ref; + registrationID = regID; + } + + // documentation inherited from supertype + public void notify(RemoteEvent theEvent) + throws UnknownEventException, RemoteException + { + try { + server.notify(registrationID, theEvent); + } catch (ThrowThis tt) { + tt.throwRemoteException(); + } + + } + + /* From net.jini.id.ReferentUuid */ + /** + * Returns the universally unique identifier that has been assigned to the + * resource this proxy represents. + * + * @return the instance of <code>Uuid</code> that is associated with the + * resource this proxy represents. This method will not return + * <code>null</code>. + * + * @see net.jini.id.ReferentUuid + */ + // Final to ensure safety. Called by enableDeliveryDo() w/i lock + public final Uuid getReferentUuid() { + return registrationID; + } + + /** Proxies for servers with the same proxyID have the same hash code. */ + public int hashCode() { + return registrationID.hashCode(); + } + + /** + * Proxies for servers with the same <code>proxyID</code> are + * considered equal. + */ + public boolean equals(Object o) { + return ReferentUuids.compare(this,o); + } + + /** When an instance of this class is deserialized, this method is + * automatically invoked. This implementation of this method validates + * the state of the deserialized instance. + * + * @throws <code>InvalidObjectException</code> if the state of the + * deserialized instance of this class is found to be invalid. + */ + private void readObject(ObjectInputStream s) + throws IOException, ClassNotFoundException + { + s.defaultReadObject(); + /* Verify server */ + if(server == null) { + throw new InvalidObjectException("ListenerProxy.readObject " + +"failure - server " + +"field is null"); + }//endif + /* Verify registrationID */ + if(registrationID == null) { + + throw new InvalidObjectException("ListenerProxy.readObject " + +"failure - registrationID " + +"field is null"); + }//endif + }//end readObject + + /** During deserialization of an instance of this class, if it is found + * that the stream contains no data, this method is automatically + * invoked. Because it is expected that the stream should always + * contain data, this implementation of this method simply declares + * that something must be wrong. + * + * @throws <code>InvalidObjectException</code> to indicate that there + * was no data in the stream during deserialization of an + * instance of this class; declaring that something is wrong. + */ + private void readObjectNoData() throws ObjectStreamException { + throw new InvalidObjectException("no data found when attempting to " + +"deserialize ListenerProxy instance"); + }//end readObjectNoData + + + + /** A subclass of ListenerProxy that implements RemoteMethodControl. */ + final static class ConstrainableListenerProxy extends ListenerProxy + implements RemoteMethodControl + { + private static final long serialVersionUID = 2L; + + // Mappings from client to server methods, + private static final Method[] methodMap1 = { + ProxyUtil.getMethod(RemoteEventListener.class, + "notify", new Class[] {RemoteEvent.class}), + ProxyUtil.getMethod(MailboxBackEnd.class, + "notify", new Class[] {Uuid.class, RemoteEvent.class}), + }; + + /** + * The client constraints placed on this proxy or <code>null</code>. + * + * @serial + */ + private MethodConstraints methodConstraints; + + /** Creates an instance of this class. */ + private ConstrainableListenerProxy(MailboxBackEnd server, Uuid id, + MethodConstraints methodConstraints) + { + super(constrainServer(server, methodConstraints), id); + this.methodConstraints = methodConstraints; + } + + /** + * Returns a copy of the server proxy with the specified client + * constraints and methods mapping. + */ + private static MailboxBackEnd constrainServer( + MailboxBackEnd server, + MethodConstraints methodConstraints) + { + return (MailboxBackEnd) + ((RemoteMethodControl)server).setConstraints( + ConstrainableProxyUtil.translateConstraints( + methodConstraints, methodMap1)); + } + /** {@inheritDoc} */ + public RemoteMethodControl setConstraints( + MethodConstraints constraints) + { + return new ConstrainableListenerProxy(server, registrationID, + constraints); + } + + /** {@inheritDoc} */ + public MethodConstraints getConstraints() { + return methodConstraints; + } + + /* Note that the superclass's hashCode method is OK as is. */ + /* Note that the superclass's equals method is OK as is. */ + + /** + * Returns a proxy trust iterator that is used in + * <code>ProxyTrustVerifier</code> to retrieve this object's + * trust verifier. + */ + private ProxyTrustIterator getProxyTrustIterator() { + return new SingletonProxyTrustIterator(server); + }//end getProxyTrustIterator + + /** + * Verifies that the registrationID and server fields are + * not null, that server implements RemoteMethodControl, and that the + * server proxy has the appropriate method constraints. + * + * @throws InvalidObjectException if registrationID or mailbox + * is null, if server does not implement RemoteMethodControl, + * or if server has the wrong constraints + */ + + private void readObject(ObjectInputStream s) + throws IOException, ClassNotFoundException + { + /* Note that basic validation of the fields of this class was + * already performed in the readObject() method of this class' + * super class. + */ + s.defaultReadObject(); + /* Verify the server and its constraints */ + ConstrainableProxyUtil.verifyConsistentConstraints(methodConstraints, + server, + methodMap1); + } + } +} + + Modified: river/jtsk/modules/modularize/apache-river/river-services/mercury/mercury-dl/src/main/java/org/apache/river/mercury/proxy/MailboxAdmin.java URL: http://svn.apache.org/viewvc/river/jtsk/modules/modularize/apache-river/river-services/mercury/mercury-dl/src/main/java/org/apache/river/mercury/proxy/MailboxAdmin.java?rev=1879521&r1=1879520&r2=1879521&view=diff ============================================================================== --- river/jtsk/modules/modularize/apache-river/river-services/mercury/mercury-dl/src/main/java/org/apache/river/mercury/proxy/MailboxAdmin.java (original) +++ river/jtsk/modules/modularize/apache-river/river-services/mercury/mercury-dl/src/main/java/org/apache/river/mercury/proxy/MailboxAdmin.java Sun Jul 5 11:41:39 2020 @@ -1,37 +1,37 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ -package org.apache.river.mercury; - -import org.apache.river.admin.DestroyAdmin; - -import net.jini.admin.JoinAdmin; - -/** - * An administrative interface for the mercury implementation - * of the event mailbox service. - * - * @author Sun Microsystems, Inc. - * - * @since 1.1 - */ -public interface MailboxAdmin - extends DestroyAdmin, JoinAdmin -{ - // No additional methods -} - +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ +package org.apache.river.mercury.proxy; + +import org.apache.river.admin.DestroyAdmin; + +import net.jini.admin.JoinAdmin; + +/** + * An administrative interface for the mercury implementation + * of the event mailbox service. + * + * @author Sun Microsystems, Inc. + * + * @since 1.1 + */ +public interface MailboxAdmin + extends DestroyAdmin, JoinAdmin +{ + // No additional methods +} + Modified: river/jtsk/modules/modularize/apache-river/river-services/mercury/mercury-dl/src/main/java/org/apache/river/mercury/proxy/MailboxAdminProxy.java URL: http://svn.apache.org/viewvc/river/jtsk/modules/modularize/apache-river/river-services/mercury/mercury-dl/src/main/java/org/apache/river/mercury/proxy/MailboxAdminProxy.java?rev=1879521&r1=1879520&r2=1879521&view=diff ============================================================================== --- river/jtsk/modules/modularize/apache-river/river-services/mercury/mercury-dl/src/main/java/org/apache/river/mercury/proxy/MailboxAdminProxy.java (original) +++ river/jtsk/modules/modularize/apache-river/river-services/mercury/mercury-dl/src/main/java/org/apache/river/mercury/proxy/MailboxAdminProxy.java Sun Jul 5 11:41:39 2020 @@ -1,319 +1,319 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ -package org.apache.river.mercury; - -import org.apache.river.admin.DestroyAdmin; -import net.jini.core.constraint.MethodConstraints; -import net.jini.core.constraint.RemoteMethodControl; -import net.jini.id.ReferentUuid; -import net.jini.id.ReferentUuids; -import net.jini.id.Uuid; -import net.jini.security.proxytrust.ProxyTrustIterator; -import net.jini.security.proxytrust.SingletonProxyTrustIterator; - -import java.lang.reflect.Method; -import java.io.InvalidObjectException; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectStreamException; -import java.io.Serializable; -import java.rmi.RemoteException; - -import javax.security.auth.Subject; - -import net.jini.admin.JoinAdmin; -import net.jini.core.discovery.LookupLocator; -import net.jini.core.entry.Entry; - -/** - * A <tt>MailboxAdminProxy</tt> is a client-side proxy for a mailbox service. - * This interface provides access to the administrative functions - * of the mailbox service as defined by the <tt>MailboxAdmin</tt> interface. - * - * @author Sun Microsystems, Inc. - * - * @since 1.1 - */ -class MailboxAdminProxy implements MailboxAdmin, Serializable, ReferentUuid { - - private static final long serialVersionUID = 2L; - - /** - * The registrar - * - * @serial - */ - final MailboxBackEnd server; - - /** - * The registrar's service ID - * - * @serial - */ - final Uuid proxyID; - - /** - * Creates a mailbox proxy, returning an instance - * that implements RemoteMethodControl if the server does too. - * - * @param mailbox the server proxy - * @param id the ID of the server - */ - static MailboxAdminProxy create(MailboxBackEnd mailbox, Uuid id) { - if (mailbox instanceof RemoteMethodControl) { - return new ConstrainableMailboxAdminProxy(mailbox, id, null); - } else { - return new MailboxAdminProxy(mailbox, id); - } - } - - /** Simple constructor. */ - private MailboxAdminProxy(MailboxBackEnd server, Uuid serviceProxyID) { - this.server = server; - this.proxyID = serviceProxyID; - } - - // This method's javadoc is inherited from an interface of this class - public Entry[] getLookupAttributes() throws RemoteException { - return server.getLookupAttributes(); - } - - // This method's javadoc is inherited from an interface of this class - public void addLookupAttributes(Entry[] attrSets) throws RemoteException { - server.addLookupAttributes(attrSets); - } - - // This method's javadoc is inherited from an interface of this class - public void modifyLookupAttributes(Entry[] attrSetTemplates, - Entry[] attrSets) - throws RemoteException - { - server.modifyLookupAttributes(attrSetTemplates, attrSets); - } - - // This method's javadoc is inherited from an interface of this class - public String[] getLookupGroups() throws RemoteException { - return server.getLookupGroups(); - } - - // This method's javadoc is inherited from an interface of this class - public void addLookupGroups(String[] groups) throws RemoteException { - server.addLookupGroups(groups); - } - - // This method's javadoc is inherited from an interface of this class - public void removeLookupGroups(String[] groups) throws RemoteException { - server.removeLookupGroups(groups); - } - - // This method's javadoc is inherited from an interface of this class - public void setLookupGroups(String[] groups) throws RemoteException { - server.setLookupGroups(groups); - } - - // This method's javadoc is inherited from an interface of this class - public LookupLocator[] getLookupLocators() throws RemoteException { - return server.getLookupLocators(); - } - - // This method's javadoc is inherited from an interface of this class - public void addLookupLocators(LookupLocator[] locators) - throws RemoteException - { - server.addLookupLocators(locators); - } - - // This method's javadoc is inherited from an interface of this class - public void removeLookupLocators(LookupLocator[] locators) - throws RemoteException - { - server.removeLookupLocators(locators); - } - - // This method's javadoc is inherited from an interface of this class - public void setLookupLocators(LookupLocator[] locators) - throws RemoteException - { - server.setLookupLocators(locators); - } - - // This method's javadoc is inherited from an interface of this class - public void destroy() throws RemoteException { - server.destroy(); - } - - /* From net.jini.id.ReferentUuid */ - /** - * Returns the universally unique identifier that has been assigned to the - * resource this proxy represents. - * - * @return the instance of <code>Uuid</code> that is associated with the - * resource this proxy represents. This method will not return - * <code>null</code>. - * - * @see net.jini.id.ReferentUuid - */ - public Uuid getReferentUuid() { - return proxyID; - } - - // documentation inherited from supertype - public int hashCode() { - return proxyID.hashCode(); - } - - /** Proxies for servers with the same serviceProxyID are considered equal. */ - public boolean equals(Object o) { - return ReferentUuids.compare(this,o); - } - - /** When an instance of this class is deserialized, this method is - * automatically invoked. This implementation of this method validates - * the state of the deserialized instance. - * - * @throws <code>InvalidObjectException</code> if the state of the - * deserialized instance of this class is found to be invalid. - */ - private void readObject(ObjectInputStream s) - throws IOException, ClassNotFoundException - { - s.defaultReadObject(); - /* Verify server */ - if(server == null) { - throw new InvalidObjectException("MailboxProxy.readObject " - +"failure - server " - +"field is null"); - }//endif - /* Verify proxyID */ - if(proxyID == null) { - throw new InvalidObjectException("MailboxProxy.proxyID " - +"failure - proxyID " - +"field is null"); - }//endif - }//end readObject - - /** During deserialization of an instance of this class, if it is found - * that the stream contains no data, this method is automatically - * invoked. Because it is expected that the stream should always - * contain data, this implementation of this method simply declares - * that something must be wrong. - * - * @throws <code>InvalidObjectException</code> to indicate that there - * was no data in the stream during deserialization of an - * instance of this class; declaring that something is wrong. - */ - private void readObjectNoData() throws ObjectStreamException { - throw new InvalidObjectException("no data found when attempting to " - +"deserialize MailboxProxy instance"); - }//end readObjectNoData - - static final class ConstrainableMailboxAdminProxy extends MailboxAdminProxy - implements RemoteMethodControl - { - private static final long serialVersionUID = 2L; - - /** Constructs a new <code>ConstrainableMailboxAdminProxy</code> - * instance. - * <p> - * For a description of all but the <code>methodConstraints</code> - * argument (provided below), refer to the description for the - * constructor of this class' super class. - * - * @param methodConstraints the client method constraints to place on - * this proxy (may be <code>null</code>). - */ - private ConstrainableMailboxAdminProxy(MailboxBackEnd server, - Uuid proxyID, - MethodConstraints methodConstraints) - { - super( constrainServer(server, methodConstraints), proxyID); - }//end constructor - - /** Returns a copy of the given server proxy having the client method - * constraints that result after the specified method mapping is - * applied to the given client method constraints. - */ - private static MailboxBackEnd constrainServer( MailboxBackEnd server, - MethodConstraints constraints) - { - RemoteMethodControl constrainedServer = - ((RemoteMethodControl)server).setConstraints(constraints); - - return ((MailboxBackEnd)constrainedServer); - }//end constrainServer - - /** Returns a new copy of this proxy class - * (<code>ConstrainableMailboxAdminProxy</code>) with its client - * constraints set to the specified constraints. A <code>null</code> - * value is interpreted as mapping all methods to empty constraints. - */ - public RemoteMethodControl setConstraints - (MethodConstraints constraints) - { - return (new ConstrainableMailboxAdminProxy(server, - proxyID, constraints)); - }//end setConstraints - - /** Returns the client constraints placed on the current instance - * of this proxy class (<code>ConstrainableMailboxAdminProxy</code>). - * The value returned by this method can be <code>null</code>, - * which is interpreted as mapping all methods to empty constraints. - */ - public MethodConstraints getConstraints() { - return ( ((RemoteMethodControl)server).getConstraints() ); - }//end getConstraints - - /* Note that the superclass's hashCode method is OK as is. */ - /* Note that the superclass's equals method is OK as is. */ - - /** Returns a proxy trust iterator that is used in - * <code>ProxyTrustVerifier</code> to retrieve this object's - * trust verifier. - */ - private ProxyTrustIterator getProxyTrustIterator() { - return new SingletonProxyTrustIterator(server); - }//end getProxyTrustIterator - - - /** Performs various functions related to the trust verification - * process for the current instance of this proxy class, as - * detailed in the description for this class. - * - * @throws <code>InvalidObjectException</code> if any of the - * requirements for trust verification (as detailed in the - * class description) are not satisfied. - */ - private void readObject(ObjectInputStream s) - throws IOException, ClassNotFoundException - { - /* Note that basic validation of the fields of this class was - * already performed in the readObject() method of this class' - * super class. - */ - s.defaultReadObject(); - // Verify that the server implements RemoteMethodControl - if( !(server instanceof RemoteMethodControl) ) { - throw new InvalidObjectException - ("MailboxAdminProxy.readObject failure - server " - +"does not implement RemoteMethodControl"); - }//endif - }//end readObject - - }//end class ConstrainableMailboxAdminProxy -} - +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ +package org.apache.river.mercury.proxy; + +import org.apache.river.admin.DestroyAdmin; +import net.jini.core.constraint.MethodConstraints; +import net.jini.core.constraint.RemoteMethodControl; +import net.jini.id.ReferentUuid; +import net.jini.id.ReferentUuids; +import net.jini.id.Uuid; +import net.jini.security.proxytrust.ProxyTrustIterator; +import net.jini.security.proxytrust.SingletonProxyTrustIterator; + +import java.lang.reflect.Method; +import java.io.InvalidObjectException; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectStreamException; +import java.io.Serializable; +import java.rmi.RemoteException; + +import javax.security.auth.Subject; + +import net.jini.admin.JoinAdmin; +import net.jini.core.discovery.LookupLocator; +import net.jini.core.entry.Entry; + +/** + * A <tt>MailboxAdminProxy</tt> is a client-side proxy for a mailbox service. + * This interface provides access to the administrative functions + * of the mailbox service as defined by the <tt>MailboxAdmin</tt> interface. + * + * @author Sun Microsystems, Inc. + * + * @since 1.1 + */ +public class MailboxAdminProxy implements MailboxAdmin, Serializable, ReferentUuid { + + private static final long serialVersionUID = 2L; + + /** + * The registrar + * + * @serial + */ + final MailboxBackEnd server; + + /** + * The registrar's service ID + * + * @serial + */ + final Uuid proxyID; + + /** + * Creates a mailbox proxy, returning an instance + * that implements RemoteMethodControl if the server does too. + * + * @param mailbox the server proxy + * @param id the ID of the server + */ + public static MailboxAdminProxy create(MailboxBackEnd mailbox, Uuid id) { + if (mailbox instanceof RemoteMethodControl) { + return new ConstrainableMailboxAdminProxy(mailbox, id, null); + } else { + return new MailboxAdminProxy(mailbox, id); + } + } + + /** Simple constructor. */ + private MailboxAdminProxy(MailboxBackEnd server, Uuid serviceProxyID) { + this.server = server; + this.proxyID = serviceProxyID; + } + + // This method's javadoc is inherited from an interface of this class + public Entry[] getLookupAttributes() throws RemoteException { + return server.getLookupAttributes(); + } + + // This method's javadoc is inherited from an interface of this class + public void addLookupAttributes(Entry[] attrSets) throws RemoteException { + server.addLookupAttributes(attrSets); + } + + // This method's javadoc is inherited from an interface of this class + public void modifyLookupAttributes(Entry[] attrSetTemplates, + Entry[] attrSets) + throws RemoteException + { + server.modifyLookupAttributes(attrSetTemplates, attrSets); + } + + // This method's javadoc is inherited from an interface of this class + public String[] getLookupGroups() throws RemoteException { + return server.getLookupGroups(); + } + + // This method's javadoc is inherited from an interface of this class + public void addLookupGroups(String[] groups) throws RemoteException { + server.addLookupGroups(groups); + } + + // This method's javadoc is inherited from an interface of this class + public void removeLookupGroups(String[] groups) throws RemoteException { + server.removeLookupGroups(groups); + } + + // This method's javadoc is inherited from an interface of this class + public void setLookupGroups(String[] groups) throws RemoteException { + server.setLookupGroups(groups); + } + + // This method's javadoc is inherited from an interface of this class + public LookupLocator[] getLookupLocators() throws RemoteException { + return server.getLookupLocators(); + } + + // This method's javadoc is inherited from an interface of this class + public void addLookupLocators(LookupLocator[] locators) + throws RemoteException + { + server.addLookupLocators(locators); + } + + // This method's javadoc is inherited from an interface of this class + public void removeLookupLocators(LookupLocator[] locators) + throws RemoteException + { + server.removeLookupLocators(locators); + } + + // This method's javadoc is inherited from an interface of this class + public void setLookupLocators(LookupLocator[] locators) + throws RemoteException + { + server.setLookupLocators(locators); + } + + // This method's javadoc is inherited from an interface of this class + public void destroy() throws RemoteException { + server.destroy(); + } + + /* From net.jini.id.ReferentUuid */ + /** + * Returns the universally unique identifier that has been assigned to the + * resource this proxy represents. + * + * @return the instance of <code>Uuid</code> that is associated with the + * resource this proxy represents. This method will not return + * <code>null</code>. + * + * @see net.jini.id.ReferentUuid + */ + public Uuid getReferentUuid() { + return proxyID; + } + + // documentation inherited from supertype + public int hashCode() { + return proxyID.hashCode(); + } + + /** Proxies for servers with the same serviceProxyID are considered equal. */ + public boolean equals(Object o) { + return ReferentUuids.compare(this,o); + } + + /** When an instance of this class is deserialized, this method is + * automatically invoked. This implementation of this method validates + * the state of the deserialized instance. + * + * @throws <code>InvalidObjectException</code> if the state of the + * deserialized instance of this class is found to be invalid. + */ + private void readObject(ObjectInputStream s) + throws IOException, ClassNotFoundException + { + s.defaultReadObject(); + /* Verify server */ + if(server == null) { + throw new InvalidObjectException("MailboxProxy.readObject " + +"failure - server " + +"field is null"); + }//endif + /* Verify proxyID */ + if(proxyID == null) { + throw new InvalidObjectException("MailboxProxy.proxyID " + +"failure - proxyID " + +"field is null"); + }//endif + }//end readObject + + /** During deserialization of an instance of this class, if it is found + * that the stream contains no data, this method is automatically + * invoked. Because it is expected that the stream should always + * contain data, this implementation of this method simply declares + * that something must be wrong. + * + * @throws <code>InvalidObjectException</code> to indicate that there + * was no data in the stream during deserialization of an + * instance of this class; declaring that something is wrong. + */ + private void readObjectNoData() throws ObjectStreamException { + throw new InvalidObjectException("no data found when attempting to " + +"deserialize MailboxProxy instance"); + }//end readObjectNoData + + static final class ConstrainableMailboxAdminProxy extends MailboxAdminProxy + implements RemoteMethodControl + { + private static final long serialVersionUID = 2L; + + /** Constructs a new <code>ConstrainableMailboxAdminProxy</code> + * instance. + * <p> + * For a description of all but the <code>methodConstraints</code> + * argument (provided below), refer to the description for the + * constructor of this class' super class. + * + * @param methodConstraints the client method constraints to place on + * this proxy (may be <code>null</code>). + */ + private ConstrainableMailboxAdminProxy(MailboxBackEnd server, + Uuid proxyID, + MethodConstraints methodConstraints) + { + super( constrainServer(server, methodConstraints), proxyID); + }//end constructor + + /** Returns a copy of the given server proxy having the client method + * constraints that result after the specified method mapping is + * applied to the given client method constraints. + */ + private static MailboxBackEnd constrainServer( MailboxBackEnd server, + MethodConstraints constraints) + { + RemoteMethodControl constrainedServer = + ((RemoteMethodControl)server).setConstraints(constraints); + + return ((MailboxBackEnd)constrainedServer); + }//end constrainServer + + /** Returns a new copy of this proxy class + * (<code>ConstrainableMailboxAdminProxy</code>) with its client + * constraints set to the specified constraints. A <code>null</code> + * value is interpreted as mapping all methods to empty constraints. + */ + public RemoteMethodControl setConstraints + (MethodConstraints constraints) + { + return (new ConstrainableMailboxAdminProxy(server, + proxyID, constraints)); + }//end setConstraints + + /** Returns the client constraints placed on the current instance + * of this proxy class (<code>ConstrainableMailboxAdminProxy</code>). + * The value returned by this method can be <code>null</code>, + * which is interpreted as mapping all methods to empty constraints. + */ + public MethodConstraints getConstraints() { + return ( ((RemoteMethodControl)server).getConstraints() ); + }//end getConstraints + + /* Note that the superclass's hashCode method is OK as is. */ + /* Note that the superclass's equals method is OK as is. */ + + /** Returns a proxy trust iterator that is used in + * <code>ProxyTrustVerifier</code> to retrieve this object's + * trust verifier. + */ + private ProxyTrustIterator getProxyTrustIterator() { + return new SingletonProxyTrustIterator(server); + }//end getProxyTrustIterator + + + /** Performs various functions related to the trust verification + * process for the current instance of this proxy class, as + * detailed in the description for this class. + * + * @throws <code>InvalidObjectException</code> if any of the + * requirements for trust verification (as detailed in the + * class description) are not satisfied. + */ + private void readObject(ObjectInputStream s) + throws IOException, ClassNotFoundException + { + /* Note that basic validation of the fields of this class was + * already performed in the readObject() method of this class' + * super class. + */ + s.defaultReadObject(); + // Verify that the server implements RemoteMethodControl + if( !(server instanceof RemoteMethodControl) ) { + throw new InvalidObjectException + ("MailboxAdminProxy.readObject failure - server " + +"does not implement RemoteMethodControl"); + }//endif + }//end readObject + + }//end class ConstrainableMailboxAdminProxy +} + Modified: river/jtsk/modules/modularize/apache-river/river-services/mercury/mercury-dl/src/main/java/org/apache/river/mercury/proxy/MailboxBackEnd.java URL: http://svn.apache.org/viewvc/river/jtsk/modules/modularize/apache-river/river-services/mercury/mercury-dl/src/main/java/org/apache/river/mercury/proxy/MailboxBackEnd.java?rev=1879521&r1=1879520&r2=1879521&view=diff ============================================================================== --- river/jtsk/modules/modularize/apache-river/river-services/mercury/mercury-dl/src/main/java/org/apache/river/mercury/proxy/MailboxBackEnd.java (original) +++ river/jtsk/modules/modularize/apache-river/river-services/mercury/mercury-dl/src/main/java/org/apache/river/mercury/proxy/MailboxBackEnd.java Sun Jul 5 11:41:39 2020 @@ -1,124 +1,124 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ -package org.apache.river.mercury; - -import org.apache.river.landlord.Landlord; -import org.apache.river.proxy.ThrowThis; -import org.apache.river.start.ServiceProxyAccessor; - - -import java.rmi.RemoteException; -import java.util.Collection; - -import net.jini.admin.Administrable; -import net.jini.core.event.RemoteEventListener; -import net.jini.core.event.RemoteEvent; -import net.jini.core.event.UnknownEventException; -import net.jini.event.InvalidIteratorException; -import net.jini.event.MailboxRegistration; -import net.jini.event.PullEventMailbox; -import net.jini.id.Uuid; - -/** - * MailboxBackEnd defines the private protocol between the various client-side - * proxies and the event mailbox server. - * <p> - * The declared methods are pretty straightforward mappings of the - * <tt>PullEventMailbox</tt> and <tt>MailboxPullRegistration</tt> interfaces. - * <p> - * Note: The <tt>Landlord</tt> interface extends <tt>Remote</tt>, - * which implicitly makes this interface Remote as well. - * - * @author Sun Microsystems, Inc. - * - * @since 1.1 - */ -interface MailboxBackEnd extends Landlord, Administrable, MailboxAdmin, - PullEventMailbox, ServiceProxyAccessor -{ - - /** - * Enable delivery of events for the given registration - * to the specified target - * - * @param registrationID The unique registration identifier - * - * @param target The designated delivery target for event notifications - * - * @see net.jini.event.MailboxRegistration#enableDelivery - */ - public void enableDelivery(Uuid registrationID, RemoteEventListener target) - throws RemoteException, ThrowThis; - - /** - * Disable delivery of events for the given registration - * - * @param registrationID The unique registration identifier - * - * @see net.jini.event.MailboxRegistration#disableDelivery - */ - - public void disableDelivery(Uuid registrationID) - throws RemoteException, ThrowThis; - - /** - * Get events for the given registration via the returned iterator. - * - * @param uuid The unique registration identifier - * - * @see net.jini.event.MailboxPullRegistration#getRemoteEvents - */ - public RemoteEventIteratorData getRemoteEvents(Uuid uuid) - throws RemoteException, ThrowThis; - - /** - * Get next batch of events for the given registration. - * - * @param regId The unique registration identifier - * - */ - public Collection getNextBatch(Uuid regId, Uuid iterId, - long timeout, Object lastEventCookie) - throws RemoteException, InvalidIteratorException, ThrowThis; - - /** - * Get events for the given registration - * - * @param uuid The unique registration identifier - * - * @param unknownEvents collection of unknown events to be added to - * the associated registration's unknown event list. - * - * @see net.jini.event.MailboxPullRegistration#getRemoteEvents - */ - public void addUnknownEvents( - Uuid uuid, Collection unknownEvents) - throws RemoteException, ThrowThis; - - /** - * Collect remote events for the associated registration. - * - * @param registrationID The unique registration identifier - * - * @param theEvent The event to store and/or forward - * - * @see net.jini.core.event.RemoteEventListener#notify - */ - public void notify(Uuid registrationID, RemoteEvent theEvent) - throws UnknownEventException, RemoteException, ThrowThis; -} +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ +package org.apache.river.mercury.proxy; + +import org.apache.river.landlord.Landlord; +import org.apache.river.proxy.ThrowThis; +import org.apache.river.start.moveMe.ServiceProxyAccessor; + + +import java.rmi.RemoteException; +import java.util.Collection; + +import net.jini.admin.Administrable; +import net.jini.core.event.RemoteEventListener; +import net.jini.core.event.RemoteEvent; +import net.jini.core.event.UnknownEventException; +import net.jini.event.InvalidIteratorException; +import net.jini.event.MailboxRegistration; +import net.jini.event.PullEventMailbox; +import net.jini.id.Uuid; + +/** + * MailboxBackEnd defines the private protocol between the various client-side + * proxies and the event mailbox server. + * <p> + * The declared methods are pretty straightforward mappings of the + * <tt>PullEventMailbox</tt> and <tt>MailboxPullRegistration</tt> interfaces. + * <p> + * Note: The <tt>Landlord</tt> interface extends <tt>Remote</tt>, + * which implicitly makes this interface Remote as well. + * + * @author Sun Microsystems, Inc. + * + * @since 1.1 + */ +public interface MailboxBackEnd extends Landlord, Administrable, MailboxAdmin, + PullEventMailbox, ServiceProxyAccessor +{ + + /** + * Enable delivery of events for the given registration + * to the specified target + * + * @param registrationID The unique registration identifier + * + * @param target The designated delivery target for event notifications + * + * @see net.jini.event.MailboxRegistration#enableDelivery + */ + public void enableDelivery(Uuid registrationID, RemoteEventListener target) + throws RemoteException, ThrowThis; + + /** + * Disable delivery of events for the given registration + * + * @param registrationID The unique registration identifier + * + * @see net.jini.event.MailboxRegistration#disableDelivery + */ + + public void disableDelivery(Uuid registrationID) + throws RemoteException, ThrowThis; + + /** + * Get events for the given registration via the returned iterator. + * + * @param uuid The unique registration identifier + * + * @see net.jini.event.MailboxPullRegistration#getRemoteEvents + */ + public RemoteEventIteratorData getRemoteEvents(Uuid uuid) + throws RemoteException, ThrowThis; + + /** + * Get next batch of events for the given registration. + * + * @param regId The unique registration identifier + * + */ + public Collection getNextBatch(Uuid regId, Uuid iterId, + long timeout, Object lastEventCookie) + throws RemoteException, InvalidIteratorException, ThrowThis; + + /** + * Get events for the given registration + * + * @param uuid The unique registration identifier + * + * @param unknownEvents collection of unknown events to be added to + * the associated registration's unknown event list. + * + * @see net.jini.event.MailboxPullRegistration#getRemoteEvents + */ + public void addUnknownEvents( + Uuid uuid, Collection unknownEvents) + throws RemoteException, ThrowThis; + + /** + * Collect remote events for the associated registration. + * + * @param registrationID The unique registration identifier + * + * @param theEvent The event to store and/or forward + * + * @see net.jini.core.event.RemoteEventListener#notify + */ + public void notify(Uuid registrationID, RemoteEvent theEvent) + throws UnknownEventException, RemoteException, ThrowThis; +}
