You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@river.apache.org by pe...@apache.org on 2020/07/05 11:41:42 UTC
svn commit: r1879521 [20/37] - in
/river/jtsk/modules/modularize/apache-river: ./ browser/
browser/src/main/java/org/apache/river/example/browser/ extra/
groovy-config/ river-activation/ river-collections/
river-collections/src/main/java/org/apache/riv...
Modified: river/jtsk/modules/modularize/apache-river/river-services/norm/norm-dl/src/main/java/org/apache/river/norm/proxy/NormProxy.java
URL: http://svn.apache.org/viewvc/river/jtsk/modules/modularize/apache-river/river-services/norm/norm-dl/src/main/java/org/apache/river/norm/proxy/NormProxy.java?rev=1879521&r1=1879520&r2=1879521&view=diff
==============================================================================
--- river/jtsk/modules/modularize/apache-river/river-services/norm/norm-dl/src/main/java/org/apache/river/norm/proxy/NormProxy.java (original)
+++ river/jtsk/modules/modularize/apache-river/river-services/norm/norm-dl/src/main/java/org/apache/river/norm/proxy/NormProxy.java Sun Jul 5 11:41:39 2020
@@ -1,133 +1,133 @@
-/*
- * 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.norm;
-
-import java.io.IOException;
-import java.io.InvalidObjectException;
-import java.io.ObjectInputStream;
-import java.rmi.RemoteException;
-import net.jini.admin.Administrable;
-import net.jini.core.constraint.MethodConstraints;
-import net.jini.core.constraint.RemoteMethodControl;
-import net.jini.id.Uuid;
-import net.jini.lease.LeaseRenewalService;
-import net.jini.lease.LeaseRenewalSet;
-import net.jini.security.proxytrust.ProxyTrustIterator;
-import net.jini.security.proxytrust.SingletonProxyTrustIterator;
-
-/**
- * Defines a client-side proxy for a Norm server.
- *
- * @author Sun Microsystems, Inc.
- * @since 2.0
- */
-class NormProxy extends AbstractProxy
- implements LeaseRenewalService, Administrable
-{
- private static final long serialVersionUID = 1;
-
- /**
- * Creates a Norm server proxy, returning an instance that implements
- * RemoteMethodControl if the server does.
- *
- * @param server the server
- * @param serverUuid the unique ID for the server
- */
- static NormProxy create(NormServer server, Uuid serverUuid) {
- if (server instanceof RemoteMethodControl) {
- return new ConstrainableNormProxy(server, serverUuid);
- } else {
- return new NormProxy(server, serverUuid);
- }
- }
-
- /** Creates an instance of this class. */
- NormProxy(NormServer server, Uuid serverUuid) {
- super(server, serverUuid);
- }
-
- /** Require fields to be non-null. */
- private void readObjectNoData() throws InvalidObjectException {
- throw new InvalidObjectException(
- "server and uuid must be non-null");
- }
-
- /* -- Implement LeaseRenewalService -- */
-
- /** inherit javadoc */
- public LeaseRenewalSet createLeaseRenewalSet(long leaseDuration)
- throws RemoteException
- {
- return server.createLeaseRenewalSet(leaseDuration);
- }
-
- /* -- Implement Administrable -- */
-
- /** inherit javadoc */
- public Object getAdmin() throws RemoteException {
- return server.getAdmin();
- }
-
- /** Defines a subclass of NormProxy that implements RemoteMethodControl. */
- static final class ConstrainableNormProxy extends NormProxy
- implements RemoteMethodControl
- {
- private static final long serialVersionUID = 1;
-
- /** Creates an instance of this class. */
- ConstrainableNormProxy(NormServer server, Uuid serverUuid) {
- super(server, serverUuid);
- if (!(server instanceof RemoteMethodControl)) {
- throw new IllegalArgumentException(
- "server must implement RemoteMethodControl");
- }
- }
-
- /** Require server to implement RemoteMethodControl. */
- private void readObject(ObjectInputStream in)
- throws IOException, ClassNotFoundException
- {
- in.defaultReadObject();
- if (!(server instanceof RemoteMethodControl)) {
- throw new InvalidObjectException(
- "server must implement RemoteMethodControl");
- }
- }
-
- /* inherit javadoc */
- public RemoteMethodControl setConstraints(
- MethodConstraints constraints)
- {
- NormServer constrainedServer = (NormServer)
- ((RemoteMethodControl) server).setConstraints(constraints);
- return new ConstrainableNormProxy(constrainedServer, uuid);
- }
-
- /* inherit javadoc */
- public MethodConstraints getConstraints() {
- return ((RemoteMethodControl) server).getConstraints();
- }
-
- /**
- * Returns a proxy trust iterator that yields this object's server.
- */
- private ProxyTrustIterator getProxyTrustIterator() {
- return new SingletonProxyTrustIterator(server);
- }
- }
-}
+/*
+ * 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.norm.proxy;
+
+import java.io.IOException;
+import java.io.InvalidObjectException;
+import java.io.ObjectInputStream;
+import java.rmi.RemoteException;
+import net.jini.admin.Administrable;
+import net.jini.core.constraint.MethodConstraints;
+import net.jini.core.constraint.RemoteMethodControl;
+import net.jini.id.Uuid;
+import net.jini.lease.LeaseRenewalService;
+import net.jini.lease.LeaseRenewalSet;
+import net.jini.security.proxytrust.ProxyTrustIterator;
+import net.jini.security.proxytrust.SingletonProxyTrustIterator;
+
+/**
+ * Defines a client-side proxy for a Norm server.
+ *
+ * @author Sun Microsystems, Inc.
+ * @since 2.0
+ */
+public class NormProxy extends AbstractProxy
+ implements LeaseRenewalService, Administrable
+{
+ private static final long serialVersionUID = 1;
+
+ /**
+ * Creates a Norm server proxy, returning an instance that implements
+ * RemoteMethodControl if the server does.
+ *
+ * @param server the server
+ * @param serverUuid the unique ID for the server
+ */
+ public static NormProxy create(NormServer server, Uuid serverUuid) {
+ if (server instanceof RemoteMethodControl) {
+ return new ConstrainableNormProxy(server, serverUuid);
+ } else {
+ return new NormProxy(server, serverUuid);
+ }
+ }
+
+ /** Creates an instance of this class. */
+ NormProxy(NormServer server, Uuid serverUuid) {
+ super(server, serverUuid);
+ }
+
+ /** Require fields to be non-null. */
+ private void readObjectNoData() throws InvalidObjectException {
+ throw new InvalidObjectException(
+ "server and uuid must be non-null");
+ }
+
+ /* -- Implement LeaseRenewalService -- */
+
+ /** inherit javadoc */
+ public LeaseRenewalSet createLeaseRenewalSet(long leaseDuration)
+ throws RemoteException
+ {
+ return server.createLeaseRenewalSet(leaseDuration);
+ }
+
+ /* -- Implement Administrable -- */
+
+ /** inherit javadoc */
+ public Object getAdmin() throws RemoteException {
+ return server.getAdmin();
+ }
+
+ /** Defines a subclass of NormProxy that implements RemoteMethodControl. */
+ static final class ConstrainableNormProxy extends NormProxy
+ implements RemoteMethodControl
+ {
+ private static final long serialVersionUID = 1;
+
+ /** Creates an instance of this class. */
+ ConstrainableNormProxy(NormServer server, Uuid serverUuid) {
+ super(server, serverUuid);
+ if (!(server instanceof RemoteMethodControl)) {
+ throw new IllegalArgumentException(
+ "server must implement RemoteMethodControl");
+ }
+ }
+
+ /** Require server to implement RemoteMethodControl. */
+ private void readObject(ObjectInputStream in)
+ throws IOException, ClassNotFoundException
+ {
+ in.defaultReadObject();
+ if (!(server instanceof RemoteMethodControl)) {
+ throw new InvalidObjectException(
+ "server must implement RemoteMethodControl");
+ }
+ }
+
+ /* inherit javadoc */
+ public RemoteMethodControl setConstraints(
+ MethodConstraints constraints)
+ {
+ NormServer constrainedServer = (NormServer)
+ ((RemoteMethodControl) server).setConstraints(constraints);
+ return new ConstrainableNormProxy(constrainedServer, uuid);
+ }
+
+ /* inherit javadoc */
+ public MethodConstraints getConstraints() {
+ return ((RemoteMethodControl) server).getConstraints();
+ }
+
+ /**
+ * Returns a proxy trust iterator that yields this object's server.
+ */
+ private ProxyTrustIterator getProxyTrustIterator() {
+ return new SingletonProxyTrustIterator(server);
+ }
+ }
+}
Modified: river/jtsk/modules/modularize/apache-river/river-services/norm/norm-dl/src/main/java/org/apache/river/norm/proxy/NormServer.java
URL: http://svn.apache.org/viewvc/river/jtsk/modules/modularize/apache-river/river-services/norm/norm-dl/src/main/java/org/apache/river/norm/proxy/NormServer.java?rev=1879521&r1=1879520&r2=1879521&view=diff
==============================================================================
--- river/jtsk/modules/modularize/apache-river/river-services/norm/norm-dl/src/main/java/org/apache/river/norm/proxy/NormServer.java (original)
+++ river/jtsk/modules/modularize/apache-river/river-services/norm/norm-dl/src/main/java/org/apache/river/norm/proxy/NormServer.java Sun Jul 5 11:41:39 2020
@@ -1,140 +1,140 @@
-/*
- * 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.norm;
-
-import java.rmi.MarshalledObject;
-import java.rmi.Remote;
-import java.rmi.RemoteException;
-
-import net.jini.admin.Administrable;
-import net.jini.admin.JoinAdmin;
-import net.jini.core.event.EventRegistration;
-import net.jini.core.event.RemoteEventListener;
-import net.jini.core.lease.Lease;
-import net.jini.id.Uuid;
-import net.jini.io.MarshalledInstance;
-import net.jini.lease.LeaseRenewalService;
-
-import org.apache.river.admin.DestroyAdmin;
-import org.apache.river.landlord.Landlord;
-import org.apache.river.proxy.ThrowThis;
-import org.apache.river.start.ServiceProxyAccessor;
-
-/**
- * This interface is the private wire protocol to that the various
- * proxy objects created by a Norm server (the lease renewal service
- * itself, sets, leases, admins, etc.) use to communicate back to the
- * server.
- *
- * @author Sun Microsystems, Inc.
- */
-interface NormServer extends Landlord, LeaseRenewalService,
- Administrable, JoinAdmin, DestroyAdmin, ServiceProxyAccessor, Remote
-{
- /**
- * If calling <code>setExpirationWarningListener</code> with a
- * <code>null</code> listener, this is the value that should be passed.
- */
- final static long NO_LISTENER = -1;
-
- /**
- * Add a lease to a set.
- *
- * @param id what set the lease should be added to
- * @param leaseToRenew the lease to be added to the set
- * @param membershipDuration how long the lease should be in the set
- * @param renewDuration how long the lease should be renewed for
- * each time it is renewed
- * @throws ThrowThis when another exception has to be thrown by the proxy
- * @throws RemoteException if a communication-related exception occurs
- */
- public void renewFor(Uuid id, Lease leaseToRenew,
- long membershipDuration, long renewDuration)
- throws RemoteException, ThrowThis;
-
- /**
- * Remove a lease from a set.
- *
- * @param id of set being operated on
- * @param leaseToRemove the lease to be removed from the set
- * @throws ThrowThis when another exception has to be thrown by the proxy
- * @throws RemoteException if a communication-related exception occurs
- */
- public Lease remove(Uuid id, Lease leaseToRemove)
- throws RemoteException, ThrowThis;
-
- /**
- * Return all the leases in the set. Returns <code>null</code>
- * or a zero-length array if there are no leases in the set.
- *
- * @param id of set being operated on
- * @return an object containing an array of {@link MarshalledInstance}s,
- * one for each lease
- * @throws ThrowThis when another exception has to be thrown by the proxy
- * @throws RemoteException if a communication-related exception occurs
- */
- public GetLeasesResult getLeases(Uuid id)
- throws RemoteException, ThrowThis;
-
- /**
- * Set the expiration warning listener for a set. Also used to
- * cancel a registration.
- *
- * @param id of set being operated on
- * @param listener listener to be notified when this event occurs.
- * Pass <code>null</code> to clear the registration.
- * @param minWarning how long be for the lease on the set expires
- * should the event be sent. Ignored if <code>listener</code>
- * is <code>null</code>.
- * @param handback an object to be handed back to the listener when
- * the warning event occurs. Ignored if <code>listener</code>
- * is <code>null</code>.
- * @return an <code>EventRegistration</code> object for the new
- * registration if <code>listener</code> is
- * non-<code>null</code> and <code>null</code> otherwise
- * @throws ThrowThis when another exception has to be thrown by the proxy
- * @throws RemoteException if a communication-related exception occurs
- */
- public EventRegistration setExpirationWarningListener(
- Uuid id,
- RemoteEventListener listener,
- long minWarning,
- MarshalledObject handback)
- throws RemoteException, ThrowThis;
-
- /**
- * Set the renewal failure listener for a set. Also used to
- * cancel a registration.
- * @param id of set being operated on
- * @param listener listener to be notified when this event occurs.
- * Pass <code>null</code> to clear the registration.
- * @param handback an object to be handed back to the listener when
- * the failure event occurs. Ignored if
- * <code>listener</code> is <code>null</code>.
- * @return an <code>EventRegistration</code> object for the new
- * registration if <code>listener</code> is
- * non-<code>null</code> and <code>null</code> otherwise.
- * @throws ThrowThis when another exception has to be thrown by the proxy
- * @throws RemoteException if a communication-related exception occurs
- */
- public EventRegistration setRenewalFailureListener(
- Uuid id,
- RemoteEventListener listener,
- MarshalledObject handback)
- throws 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.norm.proxy;
+
+import java.rmi.MarshalledObject;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+
+import net.jini.admin.Administrable;
+import net.jini.admin.JoinAdmin;
+import net.jini.core.event.EventRegistration;
+import net.jini.core.event.RemoteEventListener;
+import net.jini.core.lease.Lease;
+import net.jini.id.Uuid;
+import net.jini.io.MarshalledInstance;
+import net.jini.lease.LeaseRenewalService;
+
+import org.apache.river.admin.DestroyAdmin;
+import org.apache.river.landlord.Landlord;
+import org.apache.river.proxy.ThrowThis;
+import org.apache.river.start.moveMe.ServiceProxyAccessor;
+
+/**
+ * This interface is the private wire protocol to that the various
+ * proxy objects created by a Norm server (the lease renewal service
+ * itself, sets, leases, admins, etc.) use to communicate back to the
+ * server.
+ *
+ * @author Sun Microsystems, Inc.
+ */
+public interface NormServer extends Landlord, LeaseRenewalService,
+ Administrable, JoinAdmin, DestroyAdmin, ServiceProxyAccessor, Remote
+{
+ /**
+ * If calling <code>setExpirationWarningListener</code> with a
+ * <code>null</code> listener, this is the value that should be passed.
+ */
+ final static long NO_LISTENER = -1;
+
+ /**
+ * Add a lease to a set.
+ *
+ * @param id what set the lease should be added to
+ * @param leaseToRenew the lease to be added to the set
+ * @param membershipDuration how long the lease should be in the set
+ * @param renewDuration how long the lease should be renewed for
+ * each time it is renewed
+ * @throws ThrowThis when another exception has to be thrown by the proxy
+ * @throws RemoteException if a communication-related exception occurs
+ */
+ public void renewFor(Uuid id, Lease leaseToRenew,
+ long membershipDuration, long renewDuration)
+ throws RemoteException, ThrowThis;
+
+ /**
+ * Remove a lease from a set.
+ *
+ * @param id of set being operated on
+ * @param leaseToRemove the lease to be removed from the set
+ * @throws ThrowThis when another exception has to be thrown by the proxy
+ * @throws RemoteException if a communication-related exception occurs
+ */
+ public Lease remove(Uuid id, Lease leaseToRemove)
+ throws RemoteException, ThrowThis;
+
+ /**
+ * Return all the leases in the set. Returns <code>null</code>
+ * or a zero-length array if there are no leases in the set.
+ *
+ * @param id of set being operated on
+ * @return an object containing an array of {@link MarshalledInstance}s,
+ * one for each lease
+ * @throws ThrowThis when another exception has to be thrown by the proxy
+ * @throws RemoteException if a communication-related exception occurs
+ */
+ public GetLeasesResult getLeases(Uuid id)
+ throws RemoteException, ThrowThis;
+
+ /**
+ * Set the expiration warning listener for a set. Also used to
+ * cancel a registration.
+ *
+ * @param id of set being operated on
+ * @param listener listener to be notified when this event occurs.
+ * Pass <code>null</code> to clear the registration.
+ * @param minWarning how long be for the lease on the set expires
+ * should the event be sent. Ignored if <code>listener</code>
+ * is <code>null</code>.
+ * @param handback an object to be handed back to the listener when
+ * the warning event occurs. Ignored if <code>listener</code>
+ * is <code>null</code>.
+ * @return an <code>EventRegistration</code> object for the new
+ * registration if <code>listener</code> is
+ * non-<code>null</code> and <code>null</code> otherwise
+ * @throws ThrowThis when another exception has to be thrown by the proxy
+ * @throws RemoteException if a communication-related exception occurs
+ */
+ public EventRegistration setExpirationWarningListener(
+ Uuid id,
+ RemoteEventListener listener,
+ long minWarning,
+ MarshalledObject handback)
+ throws RemoteException, ThrowThis;
+
+ /**
+ * Set the renewal failure listener for a set. Also used to
+ * cancel a registration.
+ * @param id of set being operated on
+ * @param listener listener to be notified when this event occurs.
+ * Pass <code>null</code> to clear the registration.
+ * @param handback an object to be handed back to the listener when
+ * the failure event occurs. Ignored if
+ * <code>listener</code> is <code>null</code>.
+ * @return an <code>EventRegistration</code> object for the new
+ * registration if <code>listener</code> is
+ * non-<code>null</code> and <code>null</code> otherwise.
+ * @throws ThrowThis when another exception has to be thrown by the proxy
+ * @throws RemoteException if a communication-related exception occurs
+ */
+ public EventRegistration setRenewalFailureListener(
+ Uuid id,
+ RemoteEventListener listener,
+ MarshalledObject handback)
+ throws RemoteException, ThrowThis;
+}
Modified: river/jtsk/modules/modularize/apache-river/river-services/norm/norm-dl/src/main/java/org/apache/river/norm/proxy/ProxyVerifier.java
URL: http://svn.apache.org/viewvc/river/jtsk/modules/modularize/apache-river/river-services/norm/norm-dl/src/main/java/org/apache/river/norm/proxy/ProxyVerifier.java?rev=1879521&r1=1879520&r2=1879521&view=diff
==============================================================================
--- river/jtsk/modules/modularize/apache-river/river-services/norm/norm-dl/src/main/java/org/apache/river/norm/proxy/ProxyVerifier.java (original)
+++ river/jtsk/modules/modularize/apache-river/river-services/norm/norm-dl/src/main/java/org/apache/river/norm/proxy/ProxyVerifier.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.norm;
-
-import org.apache.river.landlord.ConstrainableLandlordLease;
-import org.apache.river.landlord.Landlord;
-import org.apache.river.landlord.LandlordProxyVerifier;
-import java.io.IOException;
-import java.io.InvalidObjectException;
-import java.io.ObjectInputStream;
-import java.io.Serializable;
-import java.rmi.RemoteException;
-import net.jini.core.constraint.MethodConstraints;
-import net.jini.core.constraint.RemoteMethodControl;
-import net.jini.id.Uuid;
-import net.jini.security.TrustVerifier;
-import net.jini.security.proxytrust.TrustEquivalence;
-
-/** Defines a trust verifier for the smart proxies of a Norm server. */
-final class ProxyVerifier implements Serializable, TrustVerifier {
- private static final long serialVersionUID = 2;
-
- /**
- * The Norm server proxy.
- *
- * @serial
- */
- private final RemoteMethodControl serverProxy;
-
- /**
- * The unique ID for the Norm server.
- *
- * @serial
- */
- private final Uuid serverUuid;
-
- /**
- * Returns a verifier for the smart proxies of a Norm server with the
- * specified proxy and unique ID.
- *
- * @param serverProxy the Norm server proxy
- * @param serverUuid the unique ID for the Norm server
- * @throws UnsupportedOperationException if <code>serverProxy</code> does
- * not implement both {@link RemoteMethodControl} and {@link
- * TrustEquivalence}
- */
- ProxyVerifier(NormServer serverProxy, Uuid serverUuid) {
- if (!(serverProxy instanceof RemoteMethodControl)) {
- throw new UnsupportedOperationException(
- "Verifier requires service proxy to implement " +
- "RemoteMethodControl");
- } else if (!(serverProxy instanceof TrustEquivalence)) {
- throw new UnsupportedOperationException(
- "Verifier requires service proxy to implement " +
- "TrustEquivalence");
- }
- this.serverProxy = (RemoteMethodControl) serverProxy;
- this.serverUuid = serverUuid;
- }
-
- /**
- * @throws NullPointerException {@inheritDoc}
- */
- public boolean isTrustedObject(Object obj, TrustVerifier.Context ctx)
- throws RemoteException
- {
- if (obj == null || ctx == null) {
- throw new NullPointerException("Arguments must not be null");
- } else if (obj instanceof ConstrainableLandlordLease) {
- return new LandlordProxyVerifier(
- (Landlord) serverProxy, serverUuid).isTrustedObject(obj, ctx);
- }
- RemoteMethodControl otherServerProxy;
- if (obj instanceof SetProxy.ConstrainableSetProxy) {
- if (!isTrustedObject(((SetProxy) obj).getRenewalSetLease(), ctx)) {
- return false;
- }
- otherServerProxy =
- (RemoteMethodControl) ((AbstractProxy) obj).server;
- } else if (obj instanceof AdminProxy.ConstrainableAdminProxy ||
- obj instanceof NormProxy.ConstrainableNormProxy)
- {
- if (!serverUuid.equals(((AbstractProxy) obj).uuid)) {
- return false;
- }
- otherServerProxy =
- (RemoteMethodControl) ((AbstractProxy) obj).server;
- } else if (obj instanceof RemoteMethodControl) {
- otherServerProxy = (RemoteMethodControl) obj;
- } else {
- return false;
- }
- MethodConstraints mc = otherServerProxy.getConstraints();
- TrustEquivalence trusted =
- (TrustEquivalence) serverProxy.setConstraints(mc);
- return trusted.checkTrustEquivalence(otherServerProxy);
- }
-
- /** Require server proxy to implement TrustEquivalence. */
- private void readObject(ObjectInputStream in)
- throws IOException, ClassNotFoundException
- {
- in.defaultReadObject();
- if (!(serverProxy instanceof TrustEquivalence)) {
- throw new InvalidObjectException(
- "serverProxy must implement TrustEquivalence");
- }
- }
-}
+/*
+ * 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.norm.proxy;
+
+import org.apache.river.landlord.ConstrainableLandlordLease;
+import org.apache.river.landlord.Landlord;
+import org.apache.river.landlord.LandlordProxyVerifier;
+import java.io.IOException;
+import java.io.InvalidObjectException;
+import java.io.ObjectInputStream;
+import java.io.Serializable;
+import java.rmi.RemoteException;
+import net.jini.core.constraint.MethodConstraints;
+import net.jini.core.constraint.RemoteMethodControl;
+import net.jini.id.Uuid;
+import net.jini.security.TrustVerifier;
+import net.jini.security.proxytrust.TrustEquivalence;
+
+/** Defines a trust verifier for the smart proxies of a Norm server. */
+public final class ProxyVerifier implements Serializable, TrustVerifier {
+ private static final long serialVersionUID = 2;
+
+ /**
+ * The Norm server proxy.
+ *
+ * @serial
+ */
+ private final RemoteMethodControl serverProxy;
+
+ /**
+ * The unique ID for the Norm server.
+ *
+ * @serial
+ */
+ private final Uuid serverUuid;
+
+ /**
+ * Returns a verifier for the smart proxies of a Norm server with the
+ * specified proxy and unique ID.
+ *
+ * @param serverProxy the Norm server proxy
+ * @param serverUuid the unique ID for the Norm server
+ * @throws UnsupportedOperationException if <code>serverProxy</code> does
+ * not implement both {@link RemoteMethodControl} and {@link
+ * TrustEquivalence}
+ */
+ public ProxyVerifier(NormServer serverProxy, Uuid serverUuid) {
+ if (!(serverProxy instanceof RemoteMethodControl)) {
+ throw new UnsupportedOperationException(
+ "Verifier requires service proxy to implement " +
+ "RemoteMethodControl");
+ } else if (!(serverProxy instanceof TrustEquivalence)) {
+ throw new UnsupportedOperationException(
+ "Verifier requires service proxy to implement " +
+ "TrustEquivalence");
+ }
+ this.serverProxy = (RemoteMethodControl) serverProxy;
+ this.serverUuid = serverUuid;
+ }
+
+ /**
+ * @throws NullPointerException {@inheritDoc}
+ */
+ public boolean isTrustedObject(Object obj, TrustVerifier.Context ctx)
+ throws RemoteException
+ {
+ if (obj == null || ctx == null) {
+ throw new NullPointerException("Arguments must not be null");
+ } else if (obj instanceof ConstrainableLandlordLease) {
+ return new LandlordProxyVerifier(
+ (Landlord) serverProxy, serverUuid).isTrustedObject(obj, ctx);
+ }
+ RemoteMethodControl otherServerProxy;
+ if (obj instanceof SetProxy.ConstrainableSetProxy) {
+ if (!isTrustedObject(((SetProxy) obj).getRenewalSetLease(), ctx)) {
+ return false;
+ }
+ otherServerProxy =
+ (RemoteMethodControl) ((AbstractProxy) obj).server;
+ } else if (obj instanceof AdminProxy.ConstrainableAdminProxy ||
+ obj instanceof NormProxy.ConstrainableNormProxy)
+ {
+ if (!serverUuid.equals(((AbstractProxy) obj).uuid)) {
+ return false;
+ }
+ otherServerProxy =
+ (RemoteMethodControl) ((AbstractProxy) obj).server;
+ } else if (obj instanceof RemoteMethodControl) {
+ otherServerProxy = (RemoteMethodControl) obj;
+ } else {
+ return false;
+ }
+ MethodConstraints mc = otherServerProxy.getConstraints();
+ TrustEquivalence trusted =
+ (TrustEquivalence) serverProxy.setConstraints(mc);
+ return trusted.checkTrustEquivalence(otherServerProxy);
+ }
+
+ /** Require server proxy to implement TrustEquivalence. */
+ private void readObject(ObjectInputStream in)
+ throws IOException, ClassNotFoundException
+ {
+ in.defaultReadObject();
+ if (!(serverProxy instanceof TrustEquivalence)) {
+ throw new InvalidObjectException(
+ "serverProxy must implement TrustEquivalence");
+ }
+ }
+}
Modified: river/jtsk/modules/modularize/apache-river/river-services/norm/norm-dl/src/main/java/org/apache/river/norm/proxy/SetProxy.java
URL: http://svn.apache.org/viewvc/river/jtsk/modules/modularize/apache-river/river-services/norm/norm-dl/src/main/java/org/apache/river/norm/proxy/SetProxy.java?rev=1879521&r1=1879520&r2=1879521&view=diff
==============================================================================
--- river/jtsk/modules/modularize/apache-river/river-services/norm/norm-dl/src/main/java/org/apache/river/norm/proxy/SetProxy.java (original)
+++ river/jtsk/modules/modularize/apache-river/river-services/norm/norm-dl/src/main/java/org/apache/river/norm/proxy/SetProxy.java Sun Jul 5 11:41:39 2020
@@ -1,460 +1,460 @@
-/*
- * 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.norm;
-
-import java.io.IOException;
-import java.io.InvalidObjectException;
-import java.io.ObjectInputStream;
-import java.lang.reflect.Method;
-import java.rmi.MarshalledObject;
-import java.rmi.RemoteException;
-import java.util.LinkedList;
-import java.util.List;
-
-import net.jini.core.constraint.MethodConstraints;
-import net.jini.core.constraint.RemoteMethodControl;
-import net.jini.core.event.EventRegistration;
-import net.jini.core.event.RemoteEventListener;
-import net.jini.core.lease.Lease;
-import net.jini.id.Uuid;
-import net.jini.io.MarshalledInstance;
-import net.jini.lease.LeaseRenewalSet;
-import net.jini.lease.LeaseUnmarshalException;
-import net.jini.security.proxytrust.ProxyTrustIterator;
-import net.jini.security.proxytrust.SingletonProxyTrustIterator;
-
-import org.apache.river.landlord.ConstrainableLandlordLease;
-import org.apache.river.proxy.ConstrainableProxyUtil;
-import org.apache.river.proxy.ThrowThis;
-
-/**
- * Client side proxy for Norm's lease renewal sets. Uses an object of
- * type NormServer to communicate back to server.
- *
- * @author Sun Microsystems, Inc.
- */
-class SetProxy extends AbstractProxy implements LeaseRenewalSet {
- private static final long serialVersionUID = 2;
-
- /**
- * Lease for this set.
- * @serial
- */
- final Lease ourLease;
-
- /**
- * Creates a lease set proxy, returning an instance that implements
- * RemoteMethodControl if the server does.
- *
- * @param server the server proxy
- * @param id the ID of the lease set
- * @param lease the lease set's lease
- */
- static SetProxy create(NormServer server, Uuid id, Lease lease) {
- if (server instanceof RemoteMethodControl) {
- return new ConstrainableSetProxy(server, id, lease, null);
- } else {
- return new SetProxy(server, id, lease);
- }
- }
-
- /** Simple constructor. */
- private SetProxy(NormServer server, Uuid id, Lease lease) {
- super(server, id);
- if (lease == null) {
- throw new NullPointerException("lease cannot be null");
- }
- ourLease = lease;
- }
-
- /** Require fields to be non-null. */
- private void readObjectNoData() throws InvalidObjectException {
- throw new InvalidObjectException(
- "server, uuid, and ourLease must be non-null");
- }
-
- /** Require lease to be non-null. */
- private void readObject(ObjectInputStream in)
- throws IOException, ClassNotFoundException
- {
- in.defaultReadObject();
- if (ourLease == null) {
- throw new InvalidObjectException("ourLease cannot be null");
- }
- }
-
- /* -- Implement LeaseRenewalSet -- */
-
- // Inherit java doc from super type
- public void renewFor(Lease leaseToRenew, long membershipDuration)
- throws RemoteException
- {
- try {
- server2().renewFor(uuid, leaseToRenew, membershipDuration,
- Lease.FOREVER);
- } catch (ThrowThis e) {
- // The server wants to throw some remote exception
- e.throwRemoteException();
- }
- }
-
- // Inherit java doc from super type
- public void renewFor(Lease leaseToRenew, long membershipDuration,
- long renewDuration)
- throws RemoteException
- {
- try {
- server.renewFor(uuid, leaseToRenew, membershipDuration,
- renewDuration);
- } catch (ThrowThis e) {
- // The server wants to throw some remote exception
- e.throwRemoteException();
- }
- }
-
- // Inherit java doc from super type
- public Lease remove(Lease leaseToRemove) throws RemoteException {
- try {
- return server.remove(uuid, leaseToRemove);
- } catch (ThrowThis e) {
- // The server wants to throw some remote exception
- e.throwRemoteException();
- // Need this because compiler does not know that
- // throwRemoteException is not going to return
- return null;
- }
- }
-
- // Inherit java doc from super type
- public Lease[] getLeases() throws LeaseUnmarshalException, RemoteException
- {
- try {
- GetLeasesResult result = server.getLeases(uuid);
- MarshalledInstance mls[] = result.marshalledLeases;
-
- if (mls == null || mls.length == 0)
- return new Lease[0];
-
- final List leases = new LinkedList();
- final List problems = new LinkedList();
- final List exceptions = new LinkedList();
- for (int i=0; i<mls.length; i++) {
- Lease l;
- final MarshalledInstance ml = mls[i];
- try {
- l = (Lease) ml.get(result.verifyCodebaseIntegrity());
- leases.add(l);
- } catch (Throwable t) {
- problems.add(ml.convertToMarshalledObject());
- exceptions.add(t);
- }
- }
-
- final Lease[] rslt =
- (Lease[]) leases.toArray(new Lease[leases.size()]);
-
- if (problems.isEmpty())
- return rslt;
-
- final MarshalledObject sml[] =
- (MarshalledObject[]) problems.toArray(
- new MarshalledObject[problems.size()]);
- final Throwable es[] =
- (Throwable[]) exceptions.toArray(
- new Throwable[exceptions.size()]);
-
- throw new LeaseUnmarshalException("Problem unmarshalling lease(s)",
- rslt, sml, es);
-
- } catch (ThrowThis e) {
- // The server wants to throw some remote exception
- e.throwRemoteException();
- // Need this because compiler does not know that
- // throwRemoteException is not going to return
- return null;
- }
- }
-
- // Inherit java doc from super type
- public EventRegistration setExpirationWarningListener(
- RemoteEventListener listener,
- long minWarning,
- MarshalledObject handback)
- throws RemoteException
- {
- // Do some client side error checking
- if (listener == null) {
- throw new NullPointerException(
- "LeaseRenewalSet.setExpirationWarningListener:Must " +
- "pass a non-null listener");
- }
-
- try {
- return server.setExpirationWarningListener(uuid,
- listener, minWarning, handback);
- } catch (ThrowThis e) {
- // The server wants to throw some remote exception
- e.throwRemoteException();
- // Need this because compiler does not know that
- // throwRemoteException is not going to return
- return null;
- }
- }
-
- // Inherit java doc from super type
- public void clearExpirationWarningListener() throws RemoteException {
- try {
- server2().setExpirationWarningListener(
- uuid, null, NormServer.NO_LISTENER, null);
- } catch (ThrowThis e) {
- // The server wants to throw some remote exception
- e.throwRemoteException();
- }
- }
-
- // Inherit java doc from super type
- public EventRegistration setRenewalFailureListener(
- RemoteEventListener listener,
- MarshalledObject handback)
- throws RemoteException
- {
- // Do some client side error checking
- if (listener == null) {
- throw new NullPointerException(
- "LeaseRenewalSet.setRenewalFailureListener:Must " +
- "pass a non-null listener");
- }
-
- try {
- return server.setRenewalFailureListener(uuid, listener, handback);
- } catch (ThrowThis e) {
- // The server wants to throw some remote exception
- e.throwRemoteException();
- // Need this because compiler does not know that
- // throwRemoteException is not going to return
- return null;
- }
- }
-
-
- // Inherit java doc from super type
- public void clearRenewalFailureListener() throws RemoteException {
- try {
- server2().setRenewalFailureListener(uuid, null, null);
- } catch (ThrowThis e) {
- // The server wants to throw some remote exception
- e.throwRemoteException();
- }
- }
-
- /**
- * Returns a second server proxy for use by methods that represent a second
- * client-side method for a single server-side method. The distinction
- * only matters for the constrainable subclass, where the different server
- * proxies need different client constraints.
- */
- NormServer server2() {
- return server;
- }
-
- // Inherit java doc from super type
- public Lease getRenewalSetLease() {
- return ourLease;
- }
-
- /** Defines a subclass of SetProxy that implements RemoteMethodControl. */
- static final class ConstrainableSetProxy extends SetProxy
- implements RemoteMethodControl
- {
- private static final long serialVersionUID = 1;
-
- /**
- * Mappings from client to server methods, using the client method with
- * more arguments for each server method when more than one client
- * method maps to a single server method.
- */
- private static final Method[] methodMap1;
- static {
- try {
- methodMap1 = new Method[] {
- LeaseRenewalSet.class.getMethod(
- "renewFor",
- new Class[] { Lease.class, long.class, long.class }),
- NormServer.class.getMethod(
- "renewFor",
- new Class[] { Uuid.class, Lease.class, long.class,
- long.class }),
- LeaseRenewalSet.class.getMethod(
- "remove", new Class[] { Lease.class }),
- NormServer.class.getMethod(
- "remove",
- new Class[] { Uuid.class, Lease.class }),
- LeaseRenewalSet.class.getMethod(
- "getLeases", new Class[] { }),
- NormServer.class.getMethod(
- "getLeases", new Class[] { Uuid.class }),
- LeaseRenewalSet.class.getMethod(
- "setExpirationWarningListener",
- new Class[] { RemoteEventListener.class,
- long.class, MarshalledObject.class }),
- NormServer.class.getMethod(
- "setExpirationWarningListener",
- new Class[] { Uuid.class, RemoteEventListener.class,
- long.class, MarshalledObject.class }),
- LeaseRenewalSet.class.getMethod(
- "setRenewalFailureListener",
- new Class[] { RemoteEventListener.class,
- MarshalledObject.class }),
- NormServer.class.getMethod(
- "setRenewalFailureListener",
- new Class[] { Uuid.class, RemoteEventListener.class,
- MarshalledObject.class })
- };
- } catch (NoSuchMethodException e) {
- throw new NoSuchMethodError(e.getMessage());
- }
- }
-
- /**
- * Second set of mappings from client to server method names, for
- * server methods with a second associated client method.
- */
- private static final Method[] methodMap2;
- static {
- try {
- methodMap2 = new Method[] {
- LeaseRenewalSet.class.getMethod(
- "renewFor",
- new Class[] { Lease.class, long.class }),
- NormServer.class.getMethod(
- "renewFor",
- new Class[] { Uuid.class, Lease.class, long.class,
- long.class } ),
- LeaseRenewalSet.class.getMethod(
- "clearExpirationWarningListener", new Class[] { }),
- NormServer.class.getMethod(
- "setExpirationWarningListener",
- new Class[] { Uuid.class, RemoteEventListener.class,
- long.class, MarshalledObject.class }),
- LeaseRenewalSet.class.getMethod(
- "clearRenewalFailureListener", new Class[] { }),
- NormServer.class.getMethod(
- "setRenewalFailureListener",
- new Class[] { Uuid.class, RemoteEventListener.class,
- MarshalledObject.class })
- };
- } catch (NoSuchMethodException e) {
- throw new NoSuchMethodError(e.getMessage());
- }
- }
-
- /**
- * The client constraints placed on this proxy or <code>null</code>.
- *
- * @serial
- */
- private MethodConstraints methodConstraints;
-
- /**
- * A second inner proxy to use when the client constraints for
- * different smart proxy methods implemented by the same inner proxy
- * methods have different constraints. This proxy is used for the
- * renewFor(Lease, long), clearExpirationWarningListener, and
- * clearRenewalFailureListener methods.
- */
- private transient NormServer server2;
-
- /** Creates an instance of this class. */
- ConstrainableSetProxy(NormServer server,
- Uuid id,
- Lease lease,
- MethodConstraints methodConstraints)
- {
- super(constrainServer(server, methodConstraints, methodMap1),
- id, lease);
- if (!(lease instanceof ConstrainableLandlordLease)) {
- throw new IllegalArgumentException(
- "lease must be a ConstrainableLandlordLease");
- }
- this.methodConstraints = methodConstraints;
- server2 = constrainServer(server, methodConstraints, methodMap2);
- }
-
- /**
- * Verifies that ourLease is a ConstrainableLandlordLease, and that
- * server implements RemoteMethodControl and has the appropriate method
- * constraints. Also sets the server2 field.
- */
- private void readObject(ObjectInputStream s)
- throws IOException, ClassNotFoundException
- {
- s.defaultReadObject();
- if (!(server instanceof RemoteMethodControl)) {
- throw new InvalidObjectException(
- "server does not implement RemoteMethodControl");
- } else if (!(ourLease instanceof ConstrainableLandlordLease)) {
- throw new InvalidObjectException(
- "ourLease is not a ConstrainableLandlordLease");
- }
- ConstrainableProxyUtil.verifyConsistentConstraints(
- methodConstraints, server, methodMap1);
- server2 = constrainServer(server, methodConstraints, methodMap2);
- }
-
-
- /**
- * Returns a copy of the server proxy with the specified client
- * constraints and methods mapping.
- */
- private static NormServer constrainServer(
- NormServer server,
- MethodConstraints methodConstraints,
- Method[] mappings)
- {
- return (NormServer) ((RemoteMethodControl) server).setConstraints(
- ConstrainableProxyUtil.translateConstraints(
- methodConstraints, mappings));
- }
-
- /** inherit javadoc */
- public RemoteMethodControl setConstraints(
- MethodConstraints constraints)
- {
- return new ConstrainableSetProxy(
- server, uuid, ourLease, constraints);
- }
-
- /** inherit javadoc */
- public MethodConstraints getConstraints() {
- return methodConstraints;
- }
-
- /** Returns the second server proxy. */
- NormServer server2() {
- return server2;
- }
-
- /**
- * Returns a proxy trust iterator that supplies the server, for use by
- * ProxyTrustVerifier.
- */
- private ProxyTrustIterator getProxyTrustIterator() {
- return new SingletonProxyTrustIterator(server);
- }
- }
-}
+/*
+ * 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.norm.proxy;
+
+import java.io.IOException;
+import java.io.InvalidObjectException;
+import java.io.ObjectInputStream;
+import java.lang.reflect.Method;
+import java.rmi.MarshalledObject;
+import java.rmi.RemoteException;
+import java.util.LinkedList;
+import java.util.List;
+
+import net.jini.core.constraint.MethodConstraints;
+import net.jini.core.constraint.RemoteMethodControl;
+import net.jini.core.event.EventRegistration;
+import net.jini.core.event.RemoteEventListener;
+import net.jini.core.lease.Lease;
+import net.jini.id.Uuid;
+import net.jini.io.MarshalledInstance;
+import net.jini.lease.LeaseRenewalSet;
+import net.jini.lease.LeaseUnmarshalException;
+import net.jini.security.proxytrust.ProxyTrustIterator;
+import net.jini.security.proxytrust.SingletonProxyTrustIterator;
+
+import org.apache.river.landlord.ConstrainableLandlordLease;
+import org.apache.river.proxy.ConstrainableProxyUtil;
+import org.apache.river.proxy.ThrowThis;
+
+/**
+ * Client side proxy for Norm's lease renewal sets. Uses an object of
+ * type NormServer to communicate back to server.
+ *
+ * @author Sun Microsystems, Inc.
+ */
+public class SetProxy extends AbstractProxy implements LeaseRenewalSet {
+ private static final long serialVersionUID = 2;
+
+ /**
+ * Lease for this set.
+ * @serial
+ */
+ final Lease ourLease;
+
+ /**
+ * Creates a lease set proxy, returning an instance that implements
+ * RemoteMethodControl if the server does.
+ *
+ * @param server the server proxy
+ * @param id the ID of the lease set
+ * @param lease the lease set's lease
+ */
+ public static SetProxy create(NormServer server, Uuid id, Lease lease) {
+ if (server instanceof RemoteMethodControl) {
+ return new ConstrainableSetProxy(server, id, lease, null);
+ } else {
+ return new SetProxy(server, id, lease);
+ }
+ }
+
+ /** Simple constructor. */
+ private SetProxy(NormServer server, Uuid id, Lease lease) {
+ super(server, id);
+ if (lease == null) {
+ throw new NullPointerException("lease cannot be null");
+ }
+ ourLease = lease;
+ }
+
+ /** Require fields to be non-null. */
+ private void readObjectNoData() throws InvalidObjectException {
+ throw new InvalidObjectException(
+ "server, uuid, and ourLease must be non-null");
+ }
+
+ /** Require lease to be non-null. */
+ private void readObject(ObjectInputStream in)
+ throws IOException, ClassNotFoundException
+ {
+ in.defaultReadObject();
+ if (ourLease == null) {
+ throw new InvalidObjectException("ourLease cannot be null");
+ }
+ }
+
+ /* -- Implement LeaseRenewalSet -- */
+
+ // Inherit java doc from super type
+ public void renewFor(Lease leaseToRenew, long membershipDuration)
+ throws RemoteException
+ {
+ try {
+ server2().renewFor(uuid, leaseToRenew, membershipDuration,
+ Lease.FOREVER);
+ } catch (ThrowThis e) {
+ // The server wants to throw some remote exception
+ e.throwRemoteException();
+ }
+ }
+
+ // Inherit java doc from super type
+ public void renewFor(Lease leaseToRenew, long membershipDuration,
+ long renewDuration)
+ throws RemoteException
+ {
+ try {
+ server.renewFor(uuid, leaseToRenew, membershipDuration,
+ renewDuration);
+ } catch (ThrowThis e) {
+ // The server wants to throw some remote exception
+ e.throwRemoteException();
+ }
+ }
+
+ // Inherit java doc from super type
+ public Lease remove(Lease leaseToRemove) throws RemoteException {
+ try {
+ return server.remove(uuid, leaseToRemove);
+ } catch (ThrowThis e) {
+ // The server wants to throw some remote exception
+ e.throwRemoteException();
+ // Need this because compiler does not know that
+ // throwRemoteException is not going to return
+ return null;
+ }
+ }
+
+ // Inherit java doc from super type
+ public Lease[] getLeases() throws LeaseUnmarshalException, RemoteException
+ {
+ try {
+ GetLeasesResult result = server.getLeases(uuid);
+ MarshalledInstance mls[] = result.marshalledLeases;
+
+ if (mls == null || mls.length == 0)
+ return new Lease[0];
+
+ final List leases = new LinkedList();
+ final List problems = new LinkedList();
+ final List exceptions = new LinkedList();
+ for (int i=0; i<mls.length; i++) {
+ Lease l;
+ final MarshalledInstance ml = mls[i];
+ try {
+ l = (Lease) ml.get(result.verifyCodebaseIntegrity());
+ leases.add(l);
+ } catch (Throwable t) {
+ problems.add(ml.convertToMarshalledObject());
+ exceptions.add(t);
+ }
+ }
+
+ final Lease[] rslt =
+ (Lease[]) leases.toArray(new Lease[leases.size()]);
+
+ if (problems.isEmpty())
+ return rslt;
+
+ final MarshalledObject sml[] =
+ (MarshalledObject[]) problems.toArray(
+ new MarshalledObject[problems.size()]);
+ final Throwable es[] =
+ (Throwable[]) exceptions.toArray(
+ new Throwable[exceptions.size()]);
+
+ throw new LeaseUnmarshalException("Problem unmarshalling lease(s)",
+ rslt, sml, es);
+
+ } catch (ThrowThis e) {
+ // The server wants to throw some remote exception
+ e.throwRemoteException();
+ // Need this because compiler does not know that
+ // throwRemoteException is not going to return
+ return null;
+ }
+ }
+
+ // Inherit java doc from super type
+ public EventRegistration setExpirationWarningListener(
+ RemoteEventListener listener,
+ long minWarning,
+ MarshalledObject handback)
+ throws RemoteException
+ {
+ // Do some client side error checking
+ if (listener == null) {
+ throw new NullPointerException(
+ "LeaseRenewalSet.setExpirationWarningListener:Must " +
+ "pass a non-null listener");
+ }
+
+ try {
+ return server.setExpirationWarningListener(uuid,
+ listener, minWarning, handback);
+ } catch (ThrowThis e) {
+ // The server wants to throw some remote exception
+ e.throwRemoteException();
+ // Need this because compiler does not know that
+ // throwRemoteException is not going to return
+ return null;
+ }
+ }
+
+ // Inherit java doc from super type
+ public void clearExpirationWarningListener() throws RemoteException {
+ try {
+ server2().setExpirationWarningListener(
+ uuid, null, NormServer.NO_LISTENER, null);
+ } catch (ThrowThis e) {
+ // The server wants to throw some remote exception
+ e.throwRemoteException();
+ }
+ }
+
+ // Inherit java doc from super type
+ public EventRegistration setRenewalFailureListener(
+ RemoteEventListener listener,
+ MarshalledObject handback)
+ throws RemoteException
+ {
+ // Do some client side error checking
+ if (listener == null) {
+ throw new NullPointerException(
+ "LeaseRenewalSet.setRenewalFailureListener:Must " +
+ "pass a non-null listener");
+ }
+
+ try {
+ return server.setRenewalFailureListener(uuid, listener, handback);
+ } catch (ThrowThis e) {
+ // The server wants to throw some remote exception
+ e.throwRemoteException();
+ // Need this because compiler does not know that
+ // throwRemoteException is not going to return
+ return null;
+ }
+ }
+
+
+ // Inherit java doc from super type
+ public void clearRenewalFailureListener() throws RemoteException {
+ try {
+ server2().setRenewalFailureListener(uuid, null, null);
+ } catch (ThrowThis e) {
+ // The server wants to throw some remote exception
+ e.throwRemoteException();
+ }
+ }
+
+ /**
+ * Returns a second server proxy for use by methods that represent a second
+ * client-side method for a single server-side method. The distinction
+ * only matters for the constrainable subclass, where the different server
+ * proxies need different client constraints.
+ */
+ NormServer server2() {
+ return server;
+ }
+
+ // Inherit java doc from super type
+ public Lease getRenewalSetLease() {
+ return ourLease;
+ }
+
+ /** Defines a subclass of SetProxy that implements RemoteMethodControl. */
+ static final class ConstrainableSetProxy extends SetProxy
+ implements RemoteMethodControl
+ {
+ private static final long serialVersionUID = 1;
+
+ /**
+ * Mappings from client to server methods, using the client method with
+ * more arguments for each server method when more than one client
+ * method maps to a single server method.
+ */
+ private static final Method[] methodMap1;
+ static {
+ try {
+ methodMap1 = new Method[] {
+ LeaseRenewalSet.class.getMethod(
+ "renewFor",
+ new Class[] { Lease.class, long.class, long.class }),
+ NormServer.class.getMethod(
+ "renewFor",
+ new Class[] { Uuid.class, Lease.class, long.class,
+ long.class }),
+ LeaseRenewalSet.class.getMethod(
+ "remove", new Class[] { Lease.class }),
+ NormServer.class.getMethod(
+ "remove",
+ new Class[] { Uuid.class, Lease.class }),
+ LeaseRenewalSet.class.getMethod(
+ "getLeases", new Class[] { }),
+ NormServer.class.getMethod(
+ "getLeases", new Class[] { Uuid.class }),
+ LeaseRenewalSet.class.getMethod(
+ "setExpirationWarningListener",
+ new Class[] { RemoteEventListener.class,
+ long.class, MarshalledObject.class }),
+ NormServer.class.getMethod(
+ "setExpirationWarningListener",
+ new Class[] { Uuid.class, RemoteEventListener.class,
+ long.class, MarshalledObject.class }),
+ LeaseRenewalSet.class.getMethod(
+ "setRenewalFailureListener",
+ new Class[] { RemoteEventListener.class,
+ MarshalledObject.class }),
+ NormServer.class.getMethod(
+ "setRenewalFailureListener",
+ new Class[] { Uuid.class, RemoteEventListener.class,
+ MarshalledObject.class })
+ };
+ } catch (NoSuchMethodException e) {
+ throw new NoSuchMethodError(e.getMessage());
+ }
+ }
+
+ /**
+ * Second set of mappings from client to server method names, for
+ * server methods with a second associated client method.
+ */
+ private static final Method[] methodMap2;
+ static {
+ try {
+ methodMap2 = new Method[] {
+ LeaseRenewalSet.class.getMethod(
+ "renewFor",
+ new Class[] { Lease.class, long.class }),
+ NormServer.class.getMethod(
+ "renewFor",
+ new Class[] { Uuid.class, Lease.class, long.class,
+ long.class } ),
+ LeaseRenewalSet.class.getMethod(
+ "clearExpirationWarningListener", new Class[] { }),
+ NormServer.class.getMethod(
+ "setExpirationWarningListener",
+ new Class[] { Uuid.class, RemoteEventListener.class,
+ long.class, MarshalledObject.class }),
+ LeaseRenewalSet.class.getMethod(
+ "clearRenewalFailureListener", new Class[] { }),
+ NormServer.class.getMethod(
+ "setRenewalFailureListener",
+ new Class[] { Uuid.class, RemoteEventListener.class,
+ MarshalledObject.class })
+ };
+ } catch (NoSuchMethodException e) {
+ throw new NoSuchMethodError(e.getMessage());
+ }
+ }
+
+ /**
+ * The client constraints placed on this proxy or <code>null</code>.
+ *
+ * @serial
+ */
+ private MethodConstraints methodConstraints;
+
+ /**
+ * A second inner proxy to use when the client constraints for
+ * different smart proxy methods implemented by the same inner proxy
+ * methods have different constraints. This proxy is used for the
+ * renewFor(Lease, long), clearExpirationWarningListener, and
+ * clearRenewalFailureListener methods.
+ */
+ private transient NormServer server2;
+
+ /** Creates an instance of this class. */
+ ConstrainableSetProxy(NormServer server,
+ Uuid id,
+ Lease lease,
+ MethodConstraints methodConstraints)
+ {
+ super(constrainServer(server, methodConstraints, methodMap1),
+ id, lease);
+ if (!(lease instanceof ConstrainableLandlordLease)) {
+ throw new IllegalArgumentException(
+ "lease must be a ConstrainableLandlordLease");
+ }
+ this.methodConstraints = methodConstraints;
+ server2 = constrainServer(server, methodConstraints, methodMap2);
+ }
+
+ /**
+ * Verifies that ourLease is a ConstrainableLandlordLease, and that
+ * server implements RemoteMethodControl and has the appropriate method
+ * constraints. Also sets the server2 field.
+ */
+ private void readObject(ObjectInputStream s)
+ throws IOException, ClassNotFoundException
+ {
+ s.defaultReadObject();
+ if (!(server instanceof RemoteMethodControl)) {
+ throw new InvalidObjectException(
+ "server does not implement RemoteMethodControl");
+ } else if (!(ourLease instanceof ConstrainableLandlordLease)) {
+ throw new InvalidObjectException(
+ "ourLease is not a ConstrainableLandlordLease");
+ }
+ ConstrainableProxyUtil.verifyConsistentConstraints(
+ methodConstraints, server, methodMap1);
+ server2 = constrainServer(server, methodConstraints, methodMap2);
+ }
+
+
+ /**
+ * Returns a copy of the server proxy with the specified client
+ * constraints and methods mapping.
+ */
+ private static NormServer constrainServer(
+ NormServer server,
+ MethodConstraints methodConstraints,
+ Method[] mappings)
+ {
+ return (NormServer) ((RemoteMethodControl) server).setConstraints(
+ ConstrainableProxyUtil.translateConstraints(
+ methodConstraints, mappings));
+ }
+
+ /** inherit javadoc */
+ public RemoteMethodControl setConstraints(
+ MethodConstraints constraints)
+ {
+ return new ConstrainableSetProxy(
+ server, uuid, ourLease, constraints);
+ }
+
+ /** inherit javadoc */
+ public MethodConstraints getConstraints() {
+ return methodConstraints;
+ }
+
+ /** Returns the second server proxy. */
+ NormServer server2() {
+ return server2;
+ }
+
+ /**
+ * Returns a proxy trust iterator that supplies the server, for use by
+ * ProxyTrustVerifier.
+ */
+ private ProxyTrustIterator getProxyTrustIterator() {
+ return new SingletonProxyTrustIterator(server);
+ }
+ }
+}
Modified: river/jtsk/modules/modularize/apache-river/river-services/norm/norm-dl/src/main/java/org/apache/river/norm/proxy/StoreException.java
URL: http://svn.apache.org/viewvc/river/jtsk/modules/modularize/apache-river/river-services/norm/norm-dl/src/main/java/org/apache/river/norm/proxy/StoreException.java?rev=1879521&r1=1879520&r2=1879521&view=diff
==============================================================================
--- river/jtsk/modules/modularize/apache-river/river-services/norm/norm-dl/src/main/java/org/apache/river/norm/proxy/StoreException.java (original)
+++ river/jtsk/modules/modularize/apache-river/river-services/norm/norm-dl/src/main/java/org/apache/river/norm/proxy/StoreException.java Sun Jul 5 11:41:39 2020
@@ -1,92 +1,92 @@
-/*
- * 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.norm;
-
-import java.io.PrintStream;
-import java.io.PrintWriter;
-
-/**
- * Base class for exceptions thrown by PersistantStore.
- *
- * @author Sun Microsystems, Inc.
- */
-class StoreException extends Exception {
- private static final long serialVersionUID = 1L;
-
- /**
- * The exception (if any) that triggered the store exception. This
- * may be <code>null</code>.
- *
- * @serial
- */
- final Throwable nestedException;
-
- /**
- * Create a store exception, forwarding a string to the superclass
- * constructor.
- * @param str a detailed message for the exception
- */
- StoreException(String str) {
- super(str);
- nestedException = null;
- }
-
- /**
- * Create an exception, forwarding a string to the
- * superclass constructor.
- * @param str a detailed message for the exception
- * @param ex root cause for the exception, may be <code>null</code>
- */
- StoreException(String str, Throwable ex) {
- super(str);
- nestedException = ex;
- }
-
- /**
- * Print the stack trace of this exception, plus that of the nested
- * exception, if any.
- */
- public void printStackTrace() {
- printStackTrace(System.err);
- }
-
- /**
- * Print the stack trace of this exception, plus 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, plus 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.norm.proxy;
+
+import java.io.PrintStream;
+import java.io.PrintWriter;
+
+/**
+ * Base class for exceptions thrown by PersistantStore.
+ *
+ * @author Sun Microsystems, Inc.
+ */
+public class StoreException extends Exception {
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * The exception (if any) that triggered the store exception. This
+ * may be <code>null</code>.
+ *
+ * @serial
+ */
+ final Throwable nestedException;
+
+ /**
+ * Create a store exception, forwarding a string to the superclass
+ * constructor.
+ * @param str a detailed message for the exception
+ */
+ StoreException(String str) {
+ super(str);
+ nestedException = null;
+ }
+
+ /**
+ * Create an exception, forwarding a string to the
+ * superclass constructor.
+ * @param str a detailed message for the exception
+ * @param ex root cause for the exception, may be <code>null</code>
+ */
+ public StoreException(String str, Throwable ex) {
+ super(str);
+ nestedException = ex;
+ }
+
+ /**
+ * Print the stack trace of this exception, plus that of the nested
+ * exception, if any.
+ */
+ public void printStackTrace() {
+ printStackTrace(System.err);
+ }
+
+ /**
+ * Print the stack trace of this exception, plus 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, plus 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/norm/norm-service/pom.xml
URL: http://svn.apache.org/viewvc/river/jtsk/modules/modularize/apache-river/river-services/norm/norm-service/pom.xml?rev=1879521&r1=1879520&r2=1879521&view=diff
==============================================================================
--- river/jtsk/modules/modularize/apache-river/river-services/norm/norm-service/pom.xml (original)
+++ river/jtsk/modules/modularize/apache-river/river-services/norm/norm-service/pom.xml Sun Jul 5 11:41:39 2020
@@ -1,51 +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>norm</artifactId>
- <version>3.0-SNAPSHOT</version>
- </parent>
-
- <groupId>org.apache.river.norm</groupId>
- <artifactId>norm-service</artifactId>
- <url>http://river.apache.org</url>
- <name>Module :: Norm Service Implementation</name>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.river.norm</groupId>
- <artifactId>norm-dl</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-start</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>norm</artifactId>
+ <version>3.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.apache.river.norm</groupId>
+ <artifactId>norm-service</artifactId>
+ <url>http://river.apache.org</url>
+ <name>Module :: Norm Service Implementation</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.river.norm</groupId>
+ <artifactId>norm-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-start</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/norm/norm-service/src/main/java/org/apache/river/norm/LeaseExpirationMgr.java
URL: http://svn.apache.org/viewvc/river/jtsk/modules/modularize/apache-river/river-services/norm/norm-service/src/main/java/org/apache/river/norm/LeaseExpirationMgr.java?rev=1879521&r1=1879520&r2=1879521&view=diff
==============================================================================
--- river/jtsk/modules/modularize/apache-river/river-services/norm/norm-service/src/main/java/org/apache/river/norm/LeaseExpirationMgr.java (original)
+++ river/jtsk/modules/modularize/apache-river/river-services/norm/norm-service/src/main/java/org/apache/river/norm/LeaseExpirationMgr.java Sun Jul 5 11:41:39 2020
@@ -27,7 +27,7 @@ import java.util.logging.Logger;
import org.apache.river.collection.WeakTable;
import org.apache.river.landlord.LeasedResource;
import org.apache.river.thread.InterruptedStatusThread;
-import org.apache.river.thread.WakeupManager;
+import org.apache.river.thread.wakeup.WakeupManager;
/**
* Lease manager that aggressively expires leases as their expiration times