Modified: river/jtsk/modules/modularize/apache-river/river-services/mahalo/mahalo-dl/src/main/java/org/apache/river/mahalo/proxy/MahaloPermission.java URL: http://svn.apache.org/viewvc/river/jtsk/modules/modularize/apache-river/river-services/mahalo/mahalo-dl/src/main/java/org/apache/river/mahalo/proxy/MahaloPermission.java?rev=1879521&r1=1879520&r2=1879521&view=diff ============================================================================== --- river/jtsk/modules/modularize/apache-river/river-services/mahalo/mahalo-dl/src/main/java/org/apache/river/mahalo/proxy/MahaloPermission.java (original) +++ river/jtsk/modules/modularize/apache-river/river-services/mahalo/mahalo-dl/src/main/java/org/apache/river/mahalo/proxy/MahaloPermission.java Sun Jul 5 11:41:39 2020 @@ -1,59 +1,59 @@ -/* - * 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; - -import net.jini.security.AccessPermission; - -/** - * Represents permissions that can be used to express the access control policy - * for the Mahalo server exported with a - * {@link net.jini.jeri.BasicJeriExporter}. This class - * can be passed to {@link net.jini.jeri.BasicInvocationDispatcher}, - * and then used in security policy permission grants. <p> - * - * An instance contains a name (also referred to as a "target name") but no - * actions list; you either have the named permission or you don't. The - * convention is that the target name is the non-qualified name of the remote - * method being invoked. Wildcard matches are supported using the syntax - * specified by {@link AccessPermission}. <p> - * - * The possible target names for use with a Mahalo server are specified in the - * package documentation for - * <a href="package-summary.html"><code>org.apache.river.mahalo</code></a> - * - * @author Sun Microsystems, Inc. - * @since 2.0 - */ -public class MahaloPermission extends AccessPermission { - - private static final long serialVersionUID = 1L; - - /** - * Creates an instance with the specified target name. - * - * @param name the target name - * @throws NullPointerException if the target name is <code>null</code> - * @throws IllegalArgumentException if the target name does not match - * the syntax specified in the comments at the beginning of the {@link - * AccessPermission} class - */ - public MahaloPermission(String name) { - super(name); - } -} +/* + * 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.proxy; + +import net.jini.security.AccessPermission; + +/** + * Represents permissions that can be used to express the access control policy + * for the Mahalo server exported with a + * {@link net.jini.jeri.BasicJeriExporter}. This class + * can be passed to {@link net.jini.jeri.BasicInvocationDispatcher}, + * and then used in security policy permission grants. <p> + * + * An instance contains a name (also referred to as a "target name") but no + * actions list; you either have the named permission or you don't. The + * convention is that the target name is the non-qualified name of the remote + * method being invoked. Wildcard matches are supported using the syntax + * specified by {@link AccessPermission}. <p> + * + * The possible target names for use with a Mahalo server are specified in the + * package documentation for + * <a href="package-summary.html"><code>org.apache.river.mahalo</code></a> + * + * @author Sun Microsystems, Inc. + * @since 2.0 + */ +public class MahaloPermission extends AccessPermission { + + private static final long serialVersionUID = 1L; + + /** + * Creates an instance with the specified target name. + * + * @param name the target name + * @throws NullPointerException if the target name is <code>null</code> + * @throws IllegalArgumentException if the target name does not match + * the syntax specified in the comments at the beginning of the {@link + * AccessPermission} class + */ + public MahaloPermission(String name) { + super(name); + } +}
Modified: river/jtsk/modules/modularize/apache-river/river-services/mahalo/mahalo-dl/src/main/java/org/apache/river/mahalo/proxy/ProxyVerifier.java URL: http://svn.apache.org/viewvc/river/jtsk/modules/modularize/apache-river/river-services/mahalo/mahalo-dl/src/main/java/org/apache/river/mahalo/proxy/ProxyVerifier.java?rev=1879521&r1=1879520&r2=1879521&view=diff ============================================================================== --- river/jtsk/modules/modularize/apache-river/river-services/mahalo/mahalo-dl/src/main/java/org/apache/river/mahalo/proxy/ProxyVerifier.java (original) +++ river/jtsk/modules/modularize/apache-river/river-services/mahalo/mahalo-dl/src/main/java/org/apache/river/mahalo/proxy/ProxyVerifier.java Sun Jul 5 11:41:39 2020 @@ -1,135 +1,135 @@ -/* - * 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; - -import org.apache.river.landlord.ConstrainableLandlordLease; -import org.apache.river.landlord.Landlord; -import org.apache.river.landlord.LandlordProxyVerifier; -import net.jini.core.constraint.MethodConstraints; -import net.jini.core.constraint.RemoteMethodControl; -import net.jini.id.ReferentUuid; -import net.jini.id.Uuid; -import net.jini.security.TrustVerifier; -import net.jini.security.proxytrust.TrustEquivalence; -import java.io.Serializable; -import java.rmi.RemoteException; -import java.util.logging.Level; -import java.util.logging.Logger; - -/** Defines a trust verifier for the smart proxies of a Mahalo server. */ -final class ProxyVerifier implements TrustVerifier, Serializable { - - private static final long serialVersionUID = 1L; - - /** Logger for logging information about this instance */ - private static final Logger logger = - Logger.getLogger("net.jini.security.trust"); - - /** The Mahalo server proxy. */ - private final RemoteMethodControl serverProxy; - - /** - * The unique identifier associated with the backend server referenced - * by the <code>serverProxy</code>, used for comparison with the IDs - * extracted from the smart proxies being verified. - * - * @serial - */ - private final Uuid proxyID; - - /** - * Returns a verifier for the smart proxies of the specified Mahalo server - * proxy. - * - * @param serverProxy the Mahalo server proxy - * @throws UnsupportedOperationException if <code>serverProxy</code> does - * not implement both {@link RemoteMethodControl} and {@link - * TrustEquivalence} - */ - ProxyVerifier(TxnManager serverProxy, Uuid proxyID) { - if (!(serverProxy instanceof RemoteMethodControl)) { - throw new UnsupportedOperationException( - "No verifier available for non-constrainable service"); - } else if (!(serverProxy instanceof TrustEquivalence)) { - throw new UnsupportedOperationException( - "Verifier requires service proxy to implement " + - "TrustEquivalence"); - } else if (proxyID == null) { - throw new IllegalArgumentException( - "Proxy id cannot be null"); - } - this.serverProxy = (RemoteMethodControl) serverProxy; - this.proxyID = proxyID; - } - - /** - * @throws NullPointerException {@inheritDoc} - */ - public boolean isTrustedObject(Object obj, TrustVerifier.Context ctx) - throws RemoteException - { - if (logger.isLoggable(Level.FINER)) { - logger.entering(ProxyVerifier.class.getName(), "isTrustedObject", - new Object[] { obj, ctx }); - } - if (obj == null || ctx == null) { - throw new NullPointerException("Arguments must not be null"); - } - RemoteMethodControl otherServerProxy; - Uuid inputProxyID = null; - if (obj instanceof TxnMgrProxy.ConstrainableTxnMgrProxy) { - otherServerProxy = (RemoteMethodControl) - ((TxnMgrProxy)obj).backend; - inputProxyID = ((ReferentUuid)obj).getReferentUuid(); - } else if (obj instanceof ConstrainableLandlordLease) { - final LandlordProxyVerifier lpv = - new LandlordProxyVerifier((Landlord)serverProxy, proxyID); - return lpv.isTrustedObject(obj, ctx); - } else if ( - obj instanceof TxnMgrAdminProxy.ConstrainableTxnMgrAdminProxy) { - otherServerProxy = (RemoteMethodControl) - ((TxnMgrAdminProxy)obj).server; - inputProxyID = ((ReferentUuid)obj).getReferentUuid(); - } else if (obj instanceof TxnManager && - obj instanceof RemoteMethodControl) { - otherServerProxy = (RemoteMethodControl)obj; - inputProxyID = proxyID; - } else { - logger.log(Level.FINEST, "Object {0} is not a supported type", - obj); - return false; - } - - // For top-level proxies, quickly verify proxy Uuid - if ((inputProxyID != null) && - !(proxyID.equals(inputProxyID))) { - return false; - } - - MethodConstraints mc = otherServerProxy.getConstraints(); - TrustEquivalence trusted = - (TrustEquivalence) serverProxy.setConstraints(mc); - boolean result = trusted.checkTrustEquivalence(otherServerProxy); - if (logger.isLoggable(Level.FINER)) { - logger.exiting(ProxyVerifier.class.getName(), "isTrustedObject", - Boolean.valueOf(result)); - } - return result; - } -} +/* + * 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.proxy; + +import org.apache.river.landlord.ConstrainableLandlordLease; +import org.apache.river.landlord.Landlord; +import org.apache.river.landlord.LandlordProxyVerifier; +import net.jini.core.constraint.MethodConstraints; +import net.jini.core.constraint.RemoteMethodControl; +import net.jini.id.ReferentUuid; +import net.jini.id.Uuid; +import net.jini.security.TrustVerifier; +import net.jini.security.proxytrust.TrustEquivalence; +import java.io.Serializable; +import java.rmi.RemoteException; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** Defines a trust verifier for the smart proxies of a Mahalo server. */ +public final class ProxyVerifier implements TrustVerifier, Serializable { + + private static final long serialVersionUID = 1L; + + /** Logger for logging information about this instance */ + private static final Logger logger = + Logger.getLogger("net.jini.security.trust"); + + /** The Mahalo server proxy. */ + private final RemoteMethodControl serverProxy; + + /** + * The unique identifier associated with the backend server referenced + * by the <code>serverProxy</code>, used for comparison with the IDs + * extracted from the smart proxies being verified. + * + * @serial + */ + private final Uuid proxyID; + + /** + * Returns a verifier for the smart proxies of the specified Mahalo server + * proxy. + * + * @param serverProxy the Mahalo server proxy + * @throws UnsupportedOperationException if <code>serverProxy</code> does + * not implement both {@link RemoteMethodControl} and {@link + * TrustEquivalence} + */ + public ProxyVerifier(TxnManager serverProxy, Uuid proxyID) { + if (!(serverProxy instanceof RemoteMethodControl)) { + throw new UnsupportedOperationException( + "No verifier available for non-constrainable service"); + } else if (!(serverProxy instanceof TrustEquivalence)) { + throw new UnsupportedOperationException( + "Verifier requires service proxy to implement " + + "TrustEquivalence"); + } else if (proxyID == null) { + throw new IllegalArgumentException( + "Proxy id cannot be null"); + } + this.serverProxy = (RemoteMethodControl) serverProxy; + this.proxyID = proxyID; + } + + /** + * @throws NullPointerException {@inheritDoc} + */ + public boolean isTrustedObject(Object obj, TrustVerifier.Context ctx) + throws RemoteException + { + if (logger.isLoggable(Level.FINER)) { + logger.entering(ProxyVerifier.class.getName(), "isTrustedObject", + new Object[] { obj, ctx }); + } + if (obj == null || ctx == null) { + throw new NullPointerException("Arguments must not be null"); + } + RemoteMethodControl otherServerProxy; + Uuid inputProxyID = null; + if (obj instanceof TxnMgrProxy.ConstrainableTxnMgrProxy) { + otherServerProxy = (RemoteMethodControl) + ((TxnMgrProxy)obj).backend; + inputProxyID = ((ReferentUuid)obj).getReferentUuid(); + } else if (obj instanceof ConstrainableLandlordLease) { + final LandlordProxyVerifier lpv = + new LandlordProxyVerifier((Landlord)serverProxy, proxyID); + return lpv.isTrustedObject(obj, ctx); + } else if ( + obj instanceof TxnMgrAdminProxy.ConstrainableTxnMgrAdminProxy) { + otherServerProxy = (RemoteMethodControl) + ((TxnMgrAdminProxy)obj).server; + inputProxyID = ((ReferentUuid)obj).getReferentUuid(); + } else if (obj instanceof TxnManager && + obj instanceof RemoteMethodControl) { + otherServerProxy = (RemoteMethodControl)obj; + inputProxyID = proxyID; + } else { + logger.log(Level.FINEST, "Object {0} is not a supported type", + obj); + return false; + } + + // For top-level proxies, quickly verify proxy Uuid + if ((inputProxyID != null) && + !(proxyID.equals(inputProxyID))) { + return false; + } + + MethodConstraints mc = otherServerProxy.getConstraints(); + TrustEquivalence trusted = + (TrustEquivalence) serverProxy.setConstraints(mc); + boolean result = trusted.checkTrustEquivalence(otherServerProxy); + if (logger.isLoggable(Level.FINER)) { + logger.exiting(ProxyVerifier.class.getName(), "isTrustedObject", + Boolean.valueOf(result)); + } + return result; + } +} Modified: river/jtsk/modules/modularize/apache-river/river-services/mahalo/mahalo-dl/src/main/java/org/apache/river/mahalo/proxy/TxnManager.java URL: http://svn.apache.org/viewvc/river/jtsk/modules/modularize/apache-river/river-services/mahalo/mahalo-dl/src/main/java/org/apache/river/mahalo/proxy/TxnManager.java?rev=1879521&r1=1879520&r2=1879521&view=diff ============================================================================== --- river/jtsk/modules/modularize/apache-river/river-services/mahalo/mahalo-dl/src/main/java/org/apache/river/mahalo/proxy/TxnManager.java (original) +++ river/jtsk/modules/modularize/apache-river/river-services/mahalo/mahalo-dl/src/main/java/org/apache/river/mahalo/proxy/TxnManager.java Sun Jul 5 11:41:39 2020 @@ -1,58 +1,58 @@ -/* - * 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; - -import net.jini.admin.Administrable; -import net.jini.admin.JoinAdmin; -import org.apache.river.admin.DestroyAdmin; -import org.apache.river.landlord.Landlord; -import org.apache.river.start.ServiceProxyAccessor; -import java.rmi.Remote; -import java.rmi.RemoteException; -import net.jini.core.transaction.Transaction; -import net.jini.core.transaction.UnknownTransactionException; -import net.jini.core.transaction.server.TransactionManager; - -/** - * Encapsulates the interface of an implementation of - * a <code>TransactionManager</code>. - * - * @author Sun Microsystems, Inc. - * - */ -public interface TxnManager extends Remote, Landlord, DestroyAdmin, - Administrable, JoinAdmin, ServiceProxyAccessor, TransactionManager -{ - /** Logger and configuration component name for Norm */ - public static final String MAHALO = "org.apache.river.mahalo"; - - /** - * Returns a reference to the <code>TransactionManager</code> - * interface. - */ - public TransactionManager manager() throws RemoteException; - - /** - * Retrieves a <code>Transaction</code> given the - * transaction's ID. - * - * @param id the id - */ - public Transaction getTransaction(long id) - throws RemoteException, UnknownTransactionException; -} +/* + * 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.proxy; + +import net.jini.admin.Administrable; +import net.jini.admin.JoinAdmin; +import org.apache.river.admin.DestroyAdmin; +import org.apache.river.landlord.Landlord; +import org.apache.river.start.moveMe.ServiceProxyAccessor; +import java.rmi.Remote; +import java.rmi.RemoteException; +import net.jini.core.transaction.Transaction; +import net.jini.core.transaction.UnknownTransactionException; +import net.jini.core.transaction.server.TransactionManager; + +/** + * Encapsulates the interface of an implementation of + * a <code>TransactionManager</code>. + * + * @author Sun Microsystems, Inc. + * + */ +public interface TxnManager extends Remote, Landlord, DestroyAdmin, + Administrable, JoinAdmin, ServiceProxyAccessor, TransactionManager +{ + /** Logger and configuration component name for Norm */ + public static final String MAHALO = "org.apache.river.mahalo"; + + /** + * Returns a reference to the <code>TransactionManager</code> + * interface. + */ + public TransactionManager manager() throws RemoteException; + + /** + * Retrieves a <code>Transaction</code> given the + * transaction's ID. + * + * @param id the id + */ + public Transaction getTransaction(long id) + throws RemoteException, UnknownTransactionException; +} Modified: river/jtsk/modules/modularize/apache-river/river-services/mahalo/mahalo-dl/src/main/java/org/apache/river/mahalo/proxy/TxnManagerInternalException.java URL: http://svn.apache.org/viewvc/river/jtsk/modules/modularize/apache-river/river-services/mahalo/mahalo-dl/src/main/java/org/apache/river/mahalo/proxy/TxnManagerInternalException.java?rev=1879521&r1=1879520&r2=1879521&view=diff ============================================================================== --- river/jtsk/modules/modularize/apache-river/river-services/mahalo/mahalo-dl/src/main/java/org/apache/river/mahalo/proxy/TxnManagerInternalException.java (original) +++ river/jtsk/modules/modularize/apache-river/river-services/mahalo/mahalo-dl/src/main/java/org/apache/river/mahalo/proxy/TxnManagerInternalException.java Sun Jul 5 11:41:39 2020 @@ -1,38 +1,38 @@ -/* - * 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; - - -/** - * - * @author Sun Microsystems, Inc. - * - */ - -class TxnManagerInternalException extends RuntimeException { - static final long serialVersionUID = 2550880955101045165L; - - - TxnManagerInternalException() { - super(); - } - - TxnManagerInternalException(String msg) { - super(msg); - } -} +/* + * 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.proxy; + + +/** + * + * @author Sun Microsystems, Inc. + * + */ + +class TxnManagerInternalException extends RuntimeException { + static final long serialVersionUID = 2550880955101045165L; + + + TxnManagerInternalException() { + super(); + } + + TxnManagerInternalException(String msg) { + super(msg); + } +} Modified: river/jtsk/modules/modularize/apache-river/river-services/mahalo/mahalo-dl/src/main/java/org/apache/river/mahalo/proxy/TxnMgrAdminProxy.java URL: http://svn.apache.org/viewvc/river/jtsk/modules/modularize/apache-river/river-services/mahalo/mahalo-dl/src/main/java/org/apache/river/mahalo/proxy/TxnMgrAdminProxy.java?rev=1879521&r1=1879520&r2=1879521&view=diff ============================================================================== --- river/jtsk/modules/modularize/apache-river/river-services/mahalo/mahalo-dl/src/main/java/org/apache/river/mahalo/proxy/TxnMgrAdminProxy.java (original) +++ river/jtsk/modules/modularize/apache-river/river-services/mahalo/mahalo-dl/src/main/java/org/apache/river/mahalo/proxy/TxnMgrAdminProxy.java Sun Jul 5 11:41:39 2020 @@ -1,320 +1,320 @@ -/* - * 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; - -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.io.InvalidObjectException; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.io.ObjectStreamException; -import java.io.Serializable; -import java.rmi.RemoteException; - - -import net.jini.admin.JoinAdmin; -import net.jini.core.discovery.LookupLocator; -import net.jini.core.entry.Entry; - -/** - * A <tt>TxnMgrAdminProxy</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>TxnMgrAdmin</tt> interface. - * - * @author Sun Microsystems, Inc. - * - * @since 1.1 - */ -class TxnMgrAdminProxy implements DestroyAdmin, JoinAdmin, - Serializable, ReferentUuid -{ - - private static final long serialVersionUID = 2L; - - /** - * The backend server reference - * - * @serial - */ - final TxnManager server; - - /** - * The backend's service ID - * - * @serial - */ - final Uuid proxyID; - - /** - * Creates an administrable transaction manager proxy, - * returning an instance - * that implements RemoteMethodControl if the server does too. - * - * @param txnMgr the server proxy - * @param id the ID of the server - */ - static TxnMgrAdminProxy create(TxnManager txnMgr, Uuid id) { - if (txnMgr instanceof RemoteMethodControl) { - return new ConstrainableTxnMgrAdminProxy(txnMgr, id, null); - } else { - return new TxnMgrAdminProxy(txnMgr, id); - } - } - - /** Simple constructor. */ - private TxnMgrAdminProxy(TxnManager 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 ID 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("TxnMgrAdminProxy.readObject " - +"failure - server " - +"field is null"); - }//endif - /* Verify proxyID */ - if(proxyID == null) { - throw new InvalidObjectException("TxnMgrAdminProxy.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 ConstrainableTxnMgrAdminProxy extends TxnMgrAdminProxy - implements RemoteMethodControl - { - private static final long serialVersionUID = 2L; - - /** Constructs a new <code>ConstrainableTxnMgrAdminProxy</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 ConstrainableTxnMgrAdminProxy(TxnManager 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 TxnManager constrainServer(TxnManager server, - MethodConstraints constraints) - { - RemoteMethodControl constrainedServer = - ((RemoteMethodControl)server).setConstraints(constraints); - - return ((TxnManager)constrainedServer); - }//end constrainServer - - /** Returns a new copy of this proxy class - * (<code>ConstrainableTxnMgrAdminProxy</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 ConstrainableTxnMgrAdminProxy(server, - proxyID, constraints)); - }//end setConstraints - - /** Returns the client constraints placed on the current instance - * of this proxy class (<code>ConstrainableTxnMgrAdminProxy</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 - ("TxnMgrAdminProxy.readObject failure - server " - +"does not implement RemoteMethodControl"); - }//endif - }//end readObject - - }//end class ConstrainableTxnMgrAdminProxy -} - +/* + * 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.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.io.InvalidObjectException; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectStreamException; +import java.io.Serializable; +import java.rmi.RemoteException; + + +import net.jini.admin.JoinAdmin; +import net.jini.core.discovery.LookupLocator; +import net.jini.core.entry.Entry; + +/** + * A <tt>TxnMgrAdminProxy</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>TxnMgrAdmin</tt> interface. + * + * @author Sun Microsystems, Inc. + * + * @since 1.1 + */ +public class TxnMgrAdminProxy implements DestroyAdmin, JoinAdmin, + Serializable, ReferentUuid +{ + + private static final long serialVersionUID = 2L; + + /** + * The backend server reference + * + * @serial + */ + final TxnManager server; + + /** + * The backend's service ID + * + * @serial + */ + final Uuid proxyID; + + /** + * Creates an administrable transaction manager proxy, + * returning an instance + * that implements RemoteMethodControl if the server does too. + * + * @param txnMgr the server proxy + * @param id the ID of the server + */ + public static TxnMgrAdminProxy create(TxnManager txnMgr, Uuid id) { + if (txnMgr instanceof RemoteMethodControl) { + return new ConstrainableTxnMgrAdminProxy(txnMgr, id, null); + } else { + return new TxnMgrAdminProxy(txnMgr, id); + } + } + + /** Simple constructor. */ + private TxnMgrAdminProxy(TxnManager 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 ID 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("TxnMgrAdminProxy.readObject " + +"failure - server " + +"field is null"); + }//endif + /* Verify proxyID */ + if(proxyID == null) { + throw new InvalidObjectException("TxnMgrAdminProxy.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 ConstrainableTxnMgrAdminProxy extends TxnMgrAdminProxy + implements RemoteMethodControl + { + private static final long serialVersionUID = 2L; + + /** Constructs a new <code>ConstrainableTxnMgrAdminProxy</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 ConstrainableTxnMgrAdminProxy(TxnManager 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 TxnManager constrainServer(TxnManager server, + MethodConstraints constraints) + { + RemoteMethodControl constrainedServer = + ((RemoteMethodControl)server).setConstraints(constraints); + + return ((TxnManager)constrainedServer); + }//end constrainServer + + /** Returns a new copy of this proxy class + * (<code>ConstrainableTxnMgrAdminProxy</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 ConstrainableTxnMgrAdminProxy(server, + proxyID, constraints)); + }//end setConstraints + + /** Returns the client constraints placed on the current instance + * of this proxy class (<code>ConstrainableTxnMgrAdminProxy</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 + ("TxnMgrAdminProxy.readObject failure - server " + +"does not implement RemoteMethodControl"); + }//endif + }//end readObject + + }//end class ConstrainableTxnMgrAdminProxy +} + Modified: river/jtsk/modules/modularize/apache-river/river-services/mahalo/mahalo-dl/src/main/java/org/apache/river/mahalo/proxy/TxnMgrProxy.java URL: http://svn.apache.org/viewvc/river/jtsk/modules/modularize/apache-river/river-services/mahalo/mahalo-dl/src/main/java/org/apache/river/mahalo/proxy/TxnMgrProxy.java?rev=1879521&r1=1879520&r2=1879521&view=diff ============================================================================== --- river/jtsk/modules/modularize/apache-river/river-services/mahalo/mahalo-dl/src/main/java/org/apache/river/mahalo/proxy/TxnMgrProxy.java (original) +++ river/jtsk/modules/modularize/apache-river/river-services/mahalo/mahalo-dl/src/main/java/org/apache/river/mahalo/proxy/TxnMgrProxy.java Sun Jul 5 11:41:39 2020 @@ -1,298 +1,298 @@ -/* - * 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; - -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.io.IOException; -import java.io.InvalidObjectException; -import java.io.ObjectInputStream; -import java.io.ObjectStreamException; -import java.io.Serializable; -import java.rmi.RemoteException; - -import net.jini.admin.Administrable; -import net.jini.core.lease.LeaseDeniedException; -import net.jini.core.transaction.server.CrashCountException; -import net.jini.core.transaction.server.TransactionManager; -import net.jini.core.transaction.server.TransactionManager.Created; -import net.jini.core.transaction.server.TransactionParticipant; -import net.jini.core.transaction.CannotAbortException; -import net.jini.core.transaction.CannotCommitException; -import net.jini.core.transaction.CannotJoinException; -import net.jini.core.transaction.TimeoutExpiredException; -import net.jini.core.transaction.UnknownTransactionException; - -/** - * A <code>TxnMgrProxy</code> is a proxy for the - * transaction manager service. - * This is the object passed to clients of this service. - * It implements the <code>TransactionManager</code> and the - * <code>Administrable</code> interfaces. - * - * @author Sun Microsystems, Inc. - * - * @since 1.1 - */ -class TxnMgrProxy implements TransactionManager, Administrable, Serializable, - ReferentUuid -{ - - private static final long serialVersionUID = 2L; - - /** - * The reference to the transaction manager service implementation - * - * @serial - */ - final TxnManager backend; - - /** - * The proxy's <code>Uuid</code> - * - * @serial - */ - final Uuid proxyID; - - /** - * Creates a transaction manager proxy, returning an instance - * that implements RemoteMethodControl if the server does too. - * - * @param txnMgr the server proxy - * @param id the ID of the server - */ - static TxnMgrProxy create(TxnManager txnMgr, Uuid id) { - if (txnMgr instanceof RemoteMethodControl) { - return new ConstrainableTxnMgrProxy(txnMgr, id, null); - } else { - return new TxnMgrProxy(txnMgr, id); - } - } - - /** Convenience constructor. */ - private TxnMgrProxy(TxnManager txnMgr, Uuid id) { - if (txnMgr == null || id == null) { - throw new IllegalArgumentException("Cannot accept null arguments"); - } - this.backend = txnMgr; - this.proxyID = id; - } - - public Created create(long lease) - throws LeaseDeniedException, RemoteException - { - return backend.create(lease); - } - - public void join(long id, TransactionParticipant part, long crashCount) - throws UnknownTransactionException, CannotJoinException, - CrashCountException, RemoteException - { - backend.join(id, part, crashCount); - } - - public int getState(long id) - throws UnknownTransactionException, RemoteException - { - return backend.getState(id); - } - - public void commit(long id) - throws UnknownTransactionException, CannotCommitException, - RemoteException - { - backend.commit(id); - } - - public void commit(long id, long waitFor) - throws UnknownTransactionException, CannotCommitException, - TimeoutExpiredException, RemoteException - { - backend.commit(id, waitFor); - } - - public void abort(long id) - throws UnknownTransactionException, CannotAbortException, - RemoteException - { - backend.abort(id); - } - - public void abort(long id, long waitFor) - throws UnknownTransactionException, CannotAbortException, - TimeoutExpiredException, RemoteException - { - backend.abort(id, waitFor); - } - - // inherit javadoc from parent - public Object getAdmin() throws RemoteException { - return backend.getAdmin(); - } - - /* 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; - } - - /** Proxies for servers with the same proxyID have the same hash code. */ - public int hashCode() { - return proxyID.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(backend == null) { - throw new InvalidObjectException("TxnMgrProxy.readObject " - +"failure - backend " - +"field is null"); - }//endif - /* Verify proxyID */ - if(proxyID == null) { - throw new InvalidObjectException("TxnMgrProxy.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 TxnMgrProxy instance"); - }//end readObjectNoData - - - /** A subclass of TxnMgrProxy that implements RemoteMethodControl. */ - final static class ConstrainableTxnMgrProxy extends TxnMgrProxy - implements RemoteMethodControl - { - private static final long serialVersionUID = 2L; - - /** Creates an instance of this class. */ - private ConstrainableTxnMgrProxy(TxnManager txnMgr, Uuid id, - MethodConstraints methodConstraints) - { - super(constrainServer(txnMgr, methodConstraints), - id); - } - - /** - * Returns a copy of the server proxy with the specified client - * constraints and methods mapping. - */ - private static TxnManager constrainServer( - TxnManager txnMgr, - MethodConstraints methodConstraints) - { - return (TxnManager) - ((RemoteMethodControl)txnMgr).setConstraints(methodConstraints); - } - - /** {@inheritDoc} */ - public RemoteMethodControl setConstraints( - MethodConstraints constraints) - { - return new ConstrainableTxnMgrProxy(backend, proxyID, - constraints); - } - - /** {@inheritDoc} */ - public MethodConstraints getConstraints() { - return ((RemoteMethodControl) backend).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(backend); - }//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( !(backend instanceof RemoteMethodControl) ) { - throw new InvalidObjectException( - "ConstrainableTxnMgrProxy.readObject failure - backend " + - "does not implement constrainable functionality "); - }//endif - }//end readObject - } -} +/* + * 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.proxy; + +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.io.IOException; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; +import java.io.ObjectStreamException; +import java.io.Serializable; +import java.rmi.RemoteException; + +import net.jini.admin.Administrable; +import net.jini.core.lease.LeaseDeniedException; +import net.jini.core.transaction.server.CrashCountException; +import net.jini.core.transaction.server.TransactionManager; +import net.jini.core.transaction.server.TransactionManager.Created; +import net.jini.core.transaction.server.TransactionParticipant; +import net.jini.core.transaction.CannotAbortException; +import net.jini.core.transaction.CannotCommitException; +import net.jini.core.transaction.CannotJoinException; +import net.jini.core.transaction.TimeoutExpiredException; +import net.jini.core.transaction.UnknownTransactionException; + +/** + * A <code>TxnMgrProxy</code> is a proxy for the + * transaction manager service. + * This is the object passed to clients of this service. + * It implements the <code>TransactionManager</code> and the + * <code>Administrable</code> interfaces. + * + * @author Sun Microsystems, Inc. + * + * @since 1.1 + */ +public class TxnMgrProxy implements TransactionManager, Administrable, Serializable, + ReferentUuid +{ + + private static final long serialVersionUID = 2L; + + /** + * The reference to the transaction manager service implementation + * + * @serial + */ + final TxnManager backend; + + /** + * The proxy's <code>Uuid</code> + * + * @serial + */ + final Uuid proxyID; + + /** + * Creates a transaction manager proxy, returning an instance + * that implements RemoteMethodControl if the server does too. + * + * @param txnMgr the server proxy + * @param id the ID of the server + */ + public static TxnMgrProxy create(TxnManager txnMgr, Uuid id) { + if (txnMgr instanceof RemoteMethodControl) { + return new ConstrainableTxnMgrProxy(txnMgr, id, null); + } else { + return new TxnMgrProxy(txnMgr, id); + } + } + + /** Convenience constructor. */ + private TxnMgrProxy(TxnManager txnMgr, Uuid id) { + if (txnMgr == null || id == null) { + throw new IllegalArgumentException("Cannot accept null arguments"); + } + this.backend = txnMgr; + this.proxyID = id; + } + + public Created create(long lease) + throws LeaseDeniedException, RemoteException + { + return backend.create(lease); + } + + public void join(long id, TransactionParticipant part, long crashCount) + throws UnknownTransactionException, CannotJoinException, + CrashCountException, RemoteException + { + backend.join(id, part, crashCount); + } + + public int getState(long id) + throws UnknownTransactionException, RemoteException + { + return backend.getState(id); + } + + public void commit(long id) + throws UnknownTransactionException, CannotCommitException, + RemoteException + { + backend.commit(id); + } + + public void commit(long id, long waitFor) + throws UnknownTransactionException, CannotCommitException, + TimeoutExpiredException, RemoteException + { + backend.commit(id, waitFor); + } + + public void abort(long id) + throws UnknownTransactionException, CannotAbortException, + RemoteException + { + backend.abort(id); + } + + public void abort(long id, long waitFor) + throws UnknownTransactionException, CannotAbortException, + TimeoutExpiredException, RemoteException + { + backend.abort(id, waitFor); + } + + // inherit javadoc from parent + public Object getAdmin() throws RemoteException { + return backend.getAdmin(); + } + + /* 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; + } + + /** Proxies for servers with the same proxyID have the same hash code. */ + public int hashCode() { + return proxyID.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(backend == null) { + throw new InvalidObjectException("TxnMgrProxy.readObject " + +"failure - backend " + +"field is null"); + }//endif + /* Verify proxyID */ + if(proxyID == null) { + throw new InvalidObjectException("TxnMgrProxy.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 TxnMgrProxy instance"); + }//end readObjectNoData + + + /** A subclass of TxnMgrProxy that implements RemoteMethodControl. */ + final static class ConstrainableTxnMgrProxy extends TxnMgrProxy + implements RemoteMethodControl + { + private static final long serialVersionUID = 2L; + + /** Creates an instance of this class. */ + private ConstrainableTxnMgrProxy(TxnManager txnMgr, Uuid id, + MethodConstraints methodConstraints) + { + super(constrainServer(txnMgr, methodConstraints), + id); + } + + /** + * Returns a copy of the server proxy with the specified client + * constraints and methods mapping. + */ + private static TxnManager constrainServer( + TxnManager txnMgr, + MethodConstraints methodConstraints) + { + return (TxnManager) + ((RemoteMethodControl)txnMgr).setConstraints(methodConstraints); + } + + /** {@inheritDoc} */ + public RemoteMethodControl setConstraints( + MethodConstraints constraints) + { + return new ConstrainableTxnMgrProxy(backend, proxyID, + constraints); + } + + /** {@inheritDoc} */ + public MethodConstraints getConstraints() { + return ((RemoteMethodControl) backend).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(backend); + }//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( !(backend instanceof RemoteMethodControl) ) { + throw new InvalidObjectException( + "ConstrainableTxnMgrProxy.readObject failure - backend " + + "does not implement constrainable functionality "); + }//endif + }//end readObject + } +} Modified: river/jtsk/modules/modularize/apache-river/river-services/mahalo/mahalo-service/pom.xml URL: http://svn.apache.org/viewvc/river/jtsk/modules/modularize/apache-river/river-services/mahalo/mahalo-service/pom.xml?rev=1879521&r1=1879520&r2=1879521&view=diff ============================================================================== --- river/jtsk/modules/modularize/apache-river/river-services/mahalo/mahalo-service/pom.xml (original) +++ river/jtsk/modules/modularize/apache-river/river-services/mahalo/mahalo-service/pom.xml Sun Jul 5 11:41:39 2020 @@ -1,44 +1,57 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- -~ Copyright (C) 2014 the original author or authors. -~ -~ 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. ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.apache.river</groupId> - <artifactId>mahalo</artifactId> - <version>3.0-SNAPSHOT</version> - </parent> - - <groupId>org.apache.river.mahalo</groupId> - <artifactId>mahalo-service</artifactId> - <url>http://river.apache.org</url> - <name>Module :: Mahalo Service Implementation</name> - - <dependencies> - <dependency> - <groupId>org.apache.river.mahalo</groupId> - <artifactId>mahalo-dl</artifactId> - <version>${project.version}</version> - </dependency> - - <dependency> - <groupId>org.apache.river</groupId> - <artifactId>river-lib</artifactId> - <version>${project.version}</version> - </dependency> - </dependencies> -</project> +<?xml version="1.0" encoding="UTF-8"?> +<!-- +~ Copyright (C) 2014 the original author or authors. +~ +~ 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. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.river</groupId> + <artifactId>mahalo</artifactId> + <version>3.0-SNAPSHOT</version> + </parent> + + <groupId>org.apache.river.mahalo</groupId> + <artifactId>mahalo-service</artifactId> + <url>http://river.apache.org</url> + <name>Module :: Mahalo Service Implementation</name> + + <dependencies> + <dependency> + <groupId>org.apache.river.mahalo</groupId> + <artifactId>mahalo-dl</artifactId> + <version>${project.version}</version> + </dependency> + + <dependency> + <groupId>org.apache.river</groupId> + <artifactId>river-logging</artifactId> + <version>${project.version}</version> + </dependency> + + <dependency> + <groupId>org.apache.river</groupId> + <artifactId>river-lib</artifactId> + <version>${project.version}</version> + </dependency> + + <dependency> + <groupId>org.apache.river</groupId> + <artifactId>river-activation</artifactId> + <version>${project.version}</version> + </dependency> + + </dependencies> +</project> Modified: river/jtsk/modules/modularize/apache-river/river-services/mahalo/mahalo-service/src/main/java/org/apache/river/mahalo/AbortJob.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/AbortJob.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/AbortJob.java (original) +++ river/jtsk/modules/modularize/apache-river/river-services/mahalo/mahalo-service/src/main/java/org/apache/river/mahalo/AbortJob.java Sun Jul 5 11:41:39 2020 @@ -18,7 +18,7 @@ package org.apache.river.mahalo; import org.apache.river.mahalo.log.ClientLog; -import org.apache.river.thread.WakeupManager; +import org.apache.river.thread.wakeup.WakeupManager; import java.rmi.activation.ActivateFailedException; import java.rmi.RemoteException; Modified: river/jtsk/modules/modularize/apache-river/river-services/mahalo/mahalo-service/src/main/java/org/apache/river/mahalo/AbortRecord.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/AbortRecord.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/AbortRecord.java (original) +++ river/jtsk/modules/modularize/apache-river/river-services/mahalo/mahalo-service/src/main/java/org/apache/river/mahalo/AbortRecord.java Sun Jul 5 11:41:39 2020 @@ -20,6 +20,7 @@ package org.apache.river.mahalo; import org.apache.river.mahalo.log.CannotRecoverException; import java.util.logging.Level; import java.util.logging.Logger; +import org.apache.river.mahalo.proxy.InternalManagerException; /** * An <code>AbortRecord</code> represents the logged state of Modified: river/jtsk/modules/modularize/apache-river/river-services/mahalo/mahalo-service/src/main/java/org/apache/river/mahalo/CommitJob.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/CommitJob.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/CommitJob.java (original) +++ river/jtsk/modules/modularize/apache-river/river-services/mahalo/mahalo-service/src/main/java/org/apache/river/mahalo/CommitJob.java Sun Jul 5 11:41:39 2020 @@ -18,7 +18,7 @@ package org.apache.river.mahalo; import org.apache.river.mahalo.log.ClientLog; -import org.apache.river.thread.WakeupManager; +import org.apache.river.thread.wakeup.WakeupManager; import java.rmi.activation.ActivateFailedException; import java.rmi.RemoteException; Modified: river/jtsk/modules/modularize/apache-river/river-services/mahalo/mahalo-service/src/main/java/org/apache/river/mahalo/CommitRecord.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/CommitRecord.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/CommitRecord.java (original) +++ river/jtsk/modules/modularize/apache-river/river-services/mahalo/mahalo-service/src/main/java/org/apache/river/mahalo/CommitRecord.java Sun Jul 5 11:41:39 2020 @@ -19,6 +19,7 @@ package org.apache.river.mahalo; import org.apache.river.mahalo.log.CannotRecoverException; import net.jini.core.transaction.server.TransactionParticipant; +import org.apache.river.mahalo.proxy.InternalManagerException; import java.util.logging.Level; import java.util.logging.Logger; Modified: river/jtsk/modules/modularize/apache-river/river-services/mahalo/mahalo-service/src/main/java/org/apache/river/mahalo/Job.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/Job.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/Job.java (original) +++ river/jtsk/modules/modularize/apache-river/river-services/mahalo/mahalo-service/src/main/java/org/apache/river/mahalo/Job.java Sun Jul 5 11:41:39 2020 @@ -17,7 +17,7 @@ */ package org.apache.river.mahalo; -import org.apache.river.thread.WakeupManager; +import org.apache.river.thread.wakeup.WakeupManager; import java.util.Iterator; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; Modified: river/jtsk/modules/modularize/apache-river/river-services/mahalo/mahalo-service/src/main/java/org/apache/river/mahalo/JoinStateManager.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/JoinStateManager.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/JoinStateManager.java (original) +++ river/jtsk/modules/modularize/apache-river/river-services/mahalo/mahalo-service/src/main/java/org/apache/river/mahalo/JoinStateManager.java Sun Jul 5 11:41:39 2020 @@ -52,6 +52,8 @@ import org.apache.river.logging.Levels; import org.apache.river.reliableLog.LogHandler; import org.apache.river.reliableLog.ReliableLog; import net.jini.io.MarshalledInstance; +import org.apache.river.mahalo.proxy.TxnManager; + /** * <code>JoinStateManager</code> provides a utility that manages Modified: river/jtsk/modules/modularize/apache-river/river-services/mahalo/mahalo-service/src/main/java/org/apache/river/mahalo/LeaseExpirationMgr.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/LeaseExpirationMgr.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/LeaseExpirationMgr.java (original) +++ river/jtsk/modules/modularize/apache-river/river-services/mahalo/mahalo-service/src/main/java/org/apache/river/mahalo/LeaseExpirationMgr.java Sun Jul 5 11:41:39 2020 @@ -22,7 +22,7 @@ import java.lang.ref.WeakReference; import net.jini.core.lease.UnknownLeaseException; import net.jini.id.Uuid; -import org.apache.river.thread.WakeupManager; +import org.apache.river.thread.wakeup.WakeupManager; import org.apache.river.collection.WeakTable; import org.apache.river.landlord.LeasedResource; import java.util.logging.Level;
