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 [34/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/reggie/reggie-dl/src/main/java/org/apache/river/reggie/proxy/EntryClass.java
URL: http://svn.apache.org/viewvc/river/jtsk/modules/modularize/apache-river/river-services/reggie/reggie-dl/src/main/java/org/apache/river/reggie/proxy/EntryClass.java?rev=1879521&r1=1879520&r2=1879521&view=diff
==============================================================================
--- river/jtsk/modules/modularize/apache-river/river-services/reggie/reggie-dl/src/main/java/org/apache/river/reggie/proxy/EntryClass.java (original)
+++ river/jtsk/modules/modularize/apache-river/river-services/reggie/reggie-dl/src/main/java/org/apache/river/reggie/proxy/EntryClass.java Sun Jul 5 11:41:39 2020
@@ -1,286 +1,286 @@
-/*
- * 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.reggie;
-
-import java.io.ByteArrayOutputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.io.InvalidObjectException;
-import java.io.ObjectInputStream;
-import java.io.Serializable;
-import java.rmi.MarshalException;
-import java.rmi.UnmarshalException;
-import java.security.DigestOutputStream;
-import java.security.MessageDigest;
-import org.apache.river.proxy.CodebaseProvider;
-import org.apache.river.proxy.MarshalledWrapper;
-
-/**
- * An EntryClass is a descriptor for an entry class, packaged up for
- * transmission between client-side proxies and the registrar server.
- * Instances are never visible to clients, they are private to the
- * communication between the proxies and the server. Note that we don't
- * transmit information about interfaces implemented by the class, because it
- * isn't necessary given the specific use of type information for entries.
- * <p>
- * This class only has a bare minimum of methods, to minimize
- * the amount of code downloaded into clients.
- * <p>
- *
- * @author Sun Microsystems, Inc.
- *
- * @see ClassMapper
- */
-class EntryClass implements Serializable {
-
- private static final long serialVersionUID = 2L;
-
- /**
- * Class name
- *
- * @serial
- */
- protected String name;
- /**
- * Hash for the type
- *
- * @serial
- */
- protected long hash;
- /**
- * Descriptor for the superclass
- *
- * @serial
- */
- protected EntryClass superclass;
- /**
- * Number of public fields
- *
- * @serial
- */
- protected int numFields;
- /** Number of instances of this class in service registrations */
- protected transient int numInstances;
- /** Number of templates of this class in event registrations */
- protected transient int numTemplates;
- /**
- * An instance containing only name and hash, no superclass info.
- * This is only used on the registrar side, to minimize the amount
- * of info transmitted back to clients.
- */
- protected transient EntryClass replacement;
- /**
- * Flag set to true if this instance was unmarshalled from an
- * integrity-protected stream, or false otherwise
- */
- private transient boolean integrity = false;
-
- /** Should only be called by ClassMapper */
- public EntryClass(Class clazz, EntryClass superclass)
- throws MarshalException
- {
- name = clazz.getName();
- this.superclass = superclass;
- ClassMapper.EntryField[] fields = ClassMapper.getFields(clazz);
- numFields = fields.length;
- computeHash(fields);
- }
-
- /**
- * Constructor used for creating replacement instances,
- * containing only name and hash.
- */
- private EntryClass(EntryClass orig) {
- name = orig.name;
- hash = orig.hash;
- }
-
- /** Return the superclass descriptor */
- public EntryClass getSuperclass() {
- return superclass;
- }
-
- /** Return the number of public fields (including superclasses) */
- public int getNumFields() {
- return numFields;
- }
-
- /** Set the number of instances of this class */
- public void setNumInstances(int numInstances) {
- this.numInstances = numInstances;
- }
-
- /** Set the number of templates of this class */
- public void setNumTemplates(int numTemplates) {
- this.numTemplates = numTemplates;
- }
-
- /** Return the replacement, if any, containing only name and rep. */
- public synchronized EntryClass getReplacement() {
- if (replacement == null)
- replacement = new EntryClass(this);
- return replacement;
- }
-
- /**
- * This is really only needed in the registrar, but it's very
- * convenient to have here.
- * @see Class#isAssignableFrom
- */
- public boolean isAssignableFrom(EntryClass cls) {
- for (EntryClass sup = cls; sup != null; sup = sup.superclass) {
- if (hash == sup.hash)
- return true;
- }
- return false;
- }
-
- /**
- * Returns the number of times this type is used in service
- * registrations
- * @return number of instances of this type in use in service
- * registrations
- */
- public int getNumInstances() {
- return numInstances;
- }
-
- /**
- * Returns the number of times this type is used in event
- * registrations
- * @return number of times this type is used in event registrations
- */
- public int getNumTemplates() {
- return numTemplates;
- }
-
- // Converts this type descriptor to a Class object
- public Class toClass(String codebase)
- throws IOException, ClassNotFoundException
- {
- Class cls =
- CodebaseProvider.loadClass(codebase, name, null, integrity, null);
- EntryClass local;
- try {
- local = ClassMapper.toEntryClassBase(cls).eclass;
- } catch (MarshalException e) {
- throw new UnmarshalException("problem obtaining local version of "
- + toString(), e);
- }
- if (hash != local.hash)
- throw new UnmarshalException("incoming entry type: " + toString()
- + " is not assignable to the local"
- + " version of the type: " + local);
- return cls;
- }
-
- /**
- * Returns the name of this type
- * @return the name of this type
- */
- public String getName() {
- return name;
- }
-
- /**
- * Returns true if the object passed in is an instance of EntryClass
- * with the same type hash as this object. Returns false otherwise.
- * @param o object to compare this object against
- * @return true if this object equals the object passed in; false
- * otherwise.
- */
- public boolean equals(Object o) {
- if (this == o) return true;
- if (!(o instanceof EntryClass))
- return false;
- EntryClass t = (EntryClass) o;
- return hash == t.hash;
- }
-
- /**
- * Return a hashcode for this type.
- * @return int the hashcode for this type
- */
- public int hashCode() {
- return (int) (hash ^ (hash >>> 32));
- }
-
- /* Inherit javadoc */
- public String toString() {
- return getClass() + "[name=" + getName() + ", hash=" + hash + "]";
- }
-
- /**
- * Computes a SHA-1 digest from the hash of the superclass, if there
- * is a superclass, followed by the name of this class, followed by
- * the name and type for each field, if any, declared by this class and
- * ordered alphabetically by field name. The first 8 bytes of the digest
- * are used to form the 64-bit hash value for this type.
- */
- private void computeHash(ClassMapper.EntryField[] fields)
- throws MarshalException
- {
- hash = 0;
- try {
- MessageDigest md = MessageDigest.getInstance("SHA");
- DataOutputStream out = new DataOutputStream(
- new DigestOutputStream(new ByteArrayOutputStream(127),md));
- if (superclass != null)
- out.writeLong(superclass.hash);
- out.writeUTF(name);
- int startDeclaredFields = superclass != null ?
- superclass.numFields : 0;
- for (int i = startDeclaredFields; i < fields.length; i++) {
- out.writeUTF(fields[i].field.getName());
- out.writeUTF(fields[i].field.getType().getName());
- }
- out.flush();
- byte[] digest = md.digest();
- for (int i = Math.min(8, digest.length); --i >= 0; ) {
- hash += ((long) (digest[i] & 0xFF)) << (i * 8);
- }
- } catch (Exception e) {
- throw new MarshalException("Unable to calculate type hash for "
- + name, e);
- }
- }
-
- /**
- * Samples integrity protection setting (if any) of the stream from which
- * this instance is being deserialized and checks that valid values
- * for this object have been read from the stream.
- */
- private void readObject(ObjectInputStream in)
- throws IOException, ClassNotFoundException
- {
- in.defaultReadObject();
- if (name == null)
- throw new InvalidObjectException("name cannot be null");
- if (hash == 0)
- throw new InvalidObjectException("hash cannot be zero");
- integrity = MarshalledWrapper.integrityEnforced(in);
- }
-
- /**
- * Throws InvalidObjectException, since data for this class is required.
- */
- private void readObjectNoData() throws InvalidObjectException {
- throw new InvalidObjectException("no data");
- }
-
-}
+/*
+ * 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.reggie.proxy;
+
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.InvalidObjectException;
+import java.io.ObjectInputStream;
+import java.io.Serializable;
+import java.rmi.MarshalException;
+import java.rmi.UnmarshalException;
+import java.security.DigestOutputStream;
+import java.security.MessageDigest;
+import org.apache.river.proxy.CodebaseProvider;
+import org.apache.river.proxy.MarshalledWrapper;
+
+/**
+ * An EntryClass is a descriptor for an entry class, packaged up for
+ * transmission between client-side proxies and the registrar server.
+ * Instances are never visible to clients, they are private to the
+ * communication between the proxies and the server. Note that we don't
+ * transmit information about interfaces implemented by the class, because it
+ * isn't necessary given the specific use of type information for entries.
+ * <p>
+ * This class only has a bare minimum of methods, to minimize
+ * the amount of code downloaded into clients.
+ * <p>
+ *
+ * @author Sun Microsystems, Inc.
+ *
+ * @see ClassMapper
+ */
+public class EntryClass implements Serializable {
+
+ private static final long serialVersionUID = 2L;
+
+ /**
+ * Class name
+ *
+ * @serial
+ */
+ protected String name;
+ /**
+ * Hash for the type
+ *
+ * @serial
+ */
+ protected long hash;
+ /**
+ * Descriptor for the superclass
+ *
+ * @serial
+ */
+ protected EntryClass superclass;
+ /**
+ * Number of public fields
+ *
+ * @serial
+ */
+ protected int numFields;
+ /** Number of instances of this class in service registrations */
+ protected transient int numInstances;
+ /** Number of templates of this class in event registrations */
+ protected transient int numTemplates;
+ /**
+ * An instance containing only name and hash, no superclass info.
+ * This is only used on the registrar side, to minimize the amount
+ * of info transmitted back to clients.
+ */
+ protected transient EntryClass replacement;
+ /**
+ * Flag set to true if this instance was unmarshalled from an
+ * integrity-protected stream, or false otherwise
+ */
+ private transient boolean integrity = false;
+
+ /** Should only be called by ClassMapper */
+ public EntryClass(Class clazz, EntryClass superclass)
+ throws MarshalException
+ {
+ name = clazz.getName();
+ this.superclass = superclass;
+ ClassMapper.EntryField[] fields = ClassMapper.getFields(clazz);
+ numFields = fields.length;
+ computeHash(fields);
+ }
+
+ /**
+ * Constructor used for creating replacement instances,
+ * containing only name and hash.
+ */
+ private EntryClass(EntryClass orig) {
+ name = orig.name;
+ hash = orig.hash;
+ }
+
+ /** Return the superclass descriptor */
+ public EntryClass getSuperclass() {
+ return superclass;
+ }
+
+ /** Return the number of public fields (including superclasses) */
+ public int getNumFields() {
+ return numFields;
+ }
+
+ /** Set the number of instances of this class */
+ public void setNumInstances(int numInstances) {
+ this.numInstances = numInstances;
+ }
+
+ /** Set the number of templates of this class */
+ public void setNumTemplates(int numTemplates) {
+ this.numTemplates = numTemplates;
+ }
+
+ /** Return the replacement, if any, containing only name and rep. */
+ public synchronized EntryClass getReplacement() {
+ if (replacement == null)
+ replacement = new EntryClass(this);
+ return replacement;
+ }
+
+ /**
+ * This is really only needed in the registrar, but it's very
+ * convenient to have here.
+ * @see Class#isAssignableFrom
+ */
+ public boolean isAssignableFrom(EntryClass cls) {
+ for (EntryClass sup = cls; sup != null; sup = sup.superclass) {
+ if (hash == sup.hash)
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Returns the number of times this type is used in service
+ * registrations
+ * @return number of instances of this type in use in service
+ * registrations
+ */
+ public int getNumInstances() {
+ return numInstances;
+ }
+
+ /**
+ * Returns the number of times this type is used in event
+ * registrations
+ * @return number of times this type is used in event registrations
+ */
+ public int getNumTemplates() {
+ return numTemplates;
+ }
+
+ // Converts this type descriptor to a Class object
+ public Class toClass(String codebase)
+ throws IOException, ClassNotFoundException
+ {
+ Class cls =
+ CodebaseProvider.loadClass(codebase, name, null, integrity, null);
+ EntryClass local;
+ try {
+ local = ClassMapper.toEntryClassBase(cls).eclass;
+ } catch (MarshalException e) {
+ throw new UnmarshalException("problem obtaining local version of "
+ + toString(), e);
+ }
+ if (hash != local.hash)
+ throw new UnmarshalException("incoming entry type: " + toString()
+ + " is not assignable to the local"
+ + " version of the type: " + local);
+ return cls;
+ }
+
+ /**
+ * Returns the name of this type
+ * @return the name of this type
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Returns true if the object passed in is an instance of EntryClass
+ * with the same type hash as this object. Returns false otherwise.
+ * @param o object to compare this object against
+ * @return true if this object equals the object passed in; false
+ * otherwise.
+ */
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (!(o instanceof EntryClass))
+ return false;
+ EntryClass t = (EntryClass) o;
+ return hash == t.hash;
+ }
+
+ /**
+ * Return a hashcode for this type.
+ * @return int the hashcode for this type
+ */
+ public int hashCode() {
+ return (int) (hash ^ (hash >>> 32));
+ }
+
+ /* Inherit javadoc */
+ public String toString() {
+ return getClass() + "[name=" + getName() + ", hash=" + hash + "]";
+ }
+
+ /**
+ * Computes a SHA-1 digest from the hash of the superclass, if there
+ * is a superclass, followed by the name of this class, followed by
+ * the name and type for each field, if any, declared by this class and
+ * ordered alphabetically by field name. The first 8 bytes of the digest
+ * are used to form the 64-bit hash value for this type.
+ */
+ private void computeHash(ClassMapper.EntryField[] fields)
+ throws MarshalException
+ {
+ hash = 0;
+ try {
+ MessageDigest md = MessageDigest.getInstance("SHA");
+ DataOutputStream out = new DataOutputStream(
+ new DigestOutputStream(new ByteArrayOutputStream(127),md));
+ if (superclass != null)
+ out.writeLong(superclass.hash);
+ out.writeUTF(name);
+ int startDeclaredFields = superclass != null ?
+ superclass.numFields : 0;
+ for (int i = startDeclaredFields; i < fields.length; i++) {
+ out.writeUTF(fields[i].field.getName());
+ out.writeUTF(fields[i].field.getType().getName());
+ }
+ out.flush();
+ byte[] digest = md.digest();
+ for (int i = Math.min(8, digest.length); --i >= 0; ) {
+ hash += ((long) (digest[i] & 0xFF)) << (i * 8);
+ }
+ } catch (Exception e) {
+ throw new MarshalException("Unable to calculate type hash for "
+ + name, e);
+ }
+ }
+
+ /**
+ * Samples integrity protection setting (if any) of the stream from which
+ * this instance is being deserialized and checks that valid values
+ * for this object have been read from the stream.
+ */
+ private void readObject(ObjectInputStream in)
+ throws IOException, ClassNotFoundException
+ {
+ in.defaultReadObject();
+ if (name == null)
+ throw new InvalidObjectException("name cannot be null");
+ if (hash == 0)
+ throw new InvalidObjectException("hash cannot be zero");
+ integrity = MarshalledWrapper.integrityEnforced(in);
+ }
+
+ /**
+ * Throws InvalidObjectException, since data for this class is required.
+ */
+ private void readObjectNoData() throws InvalidObjectException {
+ throw new InvalidObjectException("no data");
+ }
+
+}
Modified: river/jtsk/modules/modularize/apache-river/river-services/reggie/reggie-dl/src/main/java/org/apache/river/reggie/proxy/EntryClassBase.java
URL: http://svn.apache.org/viewvc/river/jtsk/modules/modularize/apache-river/river-services/reggie/reggie-dl/src/main/java/org/apache/river/reggie/proxy/EntryClassBase.java?rev=1879521&r1=1879520&r2=1879521&view=diff
==============================================================================
--- river/jtsk/modules/modularize/apache-river/river-services/reggie/reggie-dl/src/main/java/org/apache/river/reggie/proxy/EntryClassBase.java (original)
+++ river/jtsk/modules/modularize/apache-river/river-services/reggie/reggie-dl/src/main/java/org/apache/river/reggie/proxy/EntryClassBase.java Sun Jul 5 11:41:39 2020
@@ -1,77 +1,77 @@
-/*
- * 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.reggie;
-
-import java.io.Serializable;
-import org.apache.river.proxy.CodebaseProvider;
-
-/**
- * An EntryClass annotated with a codebase.
- *
- * @author Sun Microsystems, Inc.
- *
- */
-class EntryClassBase implements Serializable {
-
- private static final long serialVersionUID = 2L;
-
- /**
- * The EntryClass.
- *
- * @serial
- */
- public final EntryClass eclass;
- /**
- * The codebase.
- *
- * @serial
- */
- public String codebase;
-
- /** Simple constructor */
- public EntryClassBase(EntryClass eclass, String codebase) {
- this.eclass = eclass;
- this.codebase = codebase;
- }
-
- /** Sets the codebase to the codebase of the given class. */
- public void setCodebase(Class cls) {
- codebase = CodebaseProvider.getClassAnnotation(cls);
- }
-
- /**
- * Converts an array of EntryClassBase to an array of Class. If a
- * class cannot be loaded, it is left as null.
- */
- public static Class[] toClass(EntryClassBase[] eclasses)
- {
- Class[] classes = null;
- if (eclasses != null) {
- classes = new Class[eclasses.length];
- for (int i = eclasses.length; --i >= 0; ) {
- try {
- EntryClassBase eclass = eclasses[i];
- classes[i] = eclass.eclass.toClass(eclass.codebase);
- } catch (Throwable e) {
- RegistrarProxy.handleException(e);
- }
- }
- }
- return classes;
- }
-}
+/*
+ * 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.reggie.proxy;
+
+import java.io.Serializable;
+import org.apache.river.proxy.CodebaseProvider;
+
+/**
+ * An EntryClass annotated with a codebase.
+ *
+ * @author Sun Microsystems, Inc.
+ *
+ */
+public class EntryClassBase implements Serializable {
+
+ private static final long serialVersionUID = 2L;
+
+ /**
+ * The EntryClass.
+ *
+ * @serial
+ */
+ public final EntryClass eclass;
+ /**
+ * The codebase.
+ *
+ * @serial
+ */
+ public String codebase;
+
+ /** Simple constructor */
+ public EntryClassBase(EntryClass eclass, String codebase) {
+ this.eclass = eclass;
+ this.codebase = codebase;
+ }
+
+ /** Sets the codebase to the codebase of the given class. */
+ public void setCodebase(Class cls) {
+ codebase = CodebaseProvider.getClassAnnotation(cls);
+ }
+
+ /**
+ * Converts an array of EntryClassBase to an array of Class. If a
+ * class cannot be loaded, it is left as null.
+ */
+ public static Class[] toClass(EntryClassBase[] eclasses)
+ {
+ Class[] classes = null;
+ if (eclasses != null) {
+ classes = new Class[eclasses.length];
+ for (int i = eclasses.length; --i >= 0; ) {
+ try {
+ EntryClassBase eclass = eclasses[i];
+ classes[i] = eclass.eclass.toClass(eclass.codebase);
+ } catch (Throwable e) {
+ RegistrarProxy.handleException(e);
+ }
+ }
+ }
+ return classes;
+ }
+}
Modified: river/jtsk/modules/modularize/apache-river/river-services/reggie/reggie-dl/src/main/java/org/apache/river/reggie/proxy/EntryRep.java
URL: http://svn.apache.org/viewvc/river/jtsk/modules/modularize/apache-river/river-services/reggie/reggie-dl/src/main/java/org/apache/river/reggie/proxy/EntryRep.java?rev=1879521&r1=1879520&r2=1879521&view=diff
==============================================================================
--- river/jtsk/modules/modularize/apache-river/river-services/reggie/reggie-dl/src/main/java/org/apache/river/reggie/proxy/EntryRep.java (original)
+++ river/jtsk/modules/modularize/apache-river/river-services/reggie/reggie-dl/src/main/java/org/apache/river/reggie/proxy/EntryRep.java Sun Jul 5 11:41:39 2020
@@ -1,207 +1,207 @@
-/*
- * 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.reggie;
-
-import org.apache.river.proxy.MarshalledWrapper;
-import org.apache.river.reggie.ClassMapper.EntryField;
-import java.io.IOException;
-import java.io.Serializable;
-import java.lang.reflect.Field;
-import java.rmi.MarshalException;
-import java.rmi.RemoteException;
-import net.jini.core.entry.Entry;
-
-/**
- * An EntryRep contains the fields of an Entry packaged up for
- * transmission between client-side proxies and the registrar server.
- * Instances are never visible to clients, they are private to the
- * communication between the proxies and the server.
- * <p>
- * This class only has a bare minimum of methods, to minimize
- * the amount of code downloaded into clients.
- *
- * @author Sun Microsystems, Inc.
- *
- */
-class EntryRep implements Serializable, Cloneable {
-
- private static final long serialVersionUID = 2L;
-
- /**
- * The Class of the Entry converted to EntryClass.
- *
- * @serial
- */
- public EntryClass eclass;
- /**
- * The codebase of the entry class.
- *
- * @serial
- */
- public String codebase;
- /**
- * The public fields of the Entry, each converted as necessary to
- * a MarshalledWrapper (or left as is if of known java.lang immutable
- * type). The fields are in super- to subclass order.
- *
- * @serial
- */
- public Object[] fields;
-
- /**
- * Converts an Entry to an EntryRep. Any exception that results
- * is bundled up into a MarshalException.
- */
- public EntryRep(Entry entry) throws RemoteException {
- EntryClassBase ecb = ClassMapper.toEntryClassBase(entry.getClass());
- eclass = ecb.eclass;
- codebase = ecb.codebase;
- try {
- EntryField[] efields = ClassMapper.getFields(entry.getClass());
- fields = new Object[efields.length];
- for (int i = efields.length; --i >= 0; ) {
- EntryField f = efields[i];
- Object val = f.field.get(entry);
- if (f.marshal && val != null)
- val = new MarshalledWrapper(val);
- fields[i] = val;
- }
- } catch (IOException e) {
- throw new MarshalException("error marshalling arguments", e);
- } catch (IllegalAccessException e) {
- throw new MarshalException("error marshalling arguments", e);
- }
- }
-
- /**
- * Convert back to an Entry. If the Entry cannot be constructed,
- * null is returned. If a field cannot be unmarshalled, it is set
- * to null.
- */
- public Entry get() {
- try {
- Class clazz = eclass.toClass(codebase);
- EntryField[] efields = ClassMapper.getFields(clazz);
- Entry entry = (Entry)clazz.newInstance();
- for (int i = efields.length; --i >= 0; ) {
- Object val = fields[i];
- EntryField f = efields[i];
- Field rf = f.field;
- try {
- if (f.marshal && val != null)
- val = ((MarshalledWrapper) val).get();
- rf.set(entry, val);
- } catch (Throwable e) {
- if (e instanceof IllegalArgumentException) {
- // fix 4872566: work around empty exception message
- String msg = "unable to assign " +
- ((val != null) ?
- "value of type " + val.getClass().getName() :
- "null") +
- " to field " + rf.getDeclaringClass().getName() +
- "." + rf.getName() + " of type " +
- rf.getType().getName();
- e = new ClassCastException(msg).initCause(e);
- }
- RegistrarProxy.handleException(e);
- }
- }
- return entry;
- } catch (Throwable e) {
- RegistrarProxy.handleException(e);
- }
- return null;
- }
-
- /**
- * We don't need this in the client or the server, but since we
- * redefine equals we provide a minimal hashCode that works.
- */
- public int hashCode() {
- return eclass.hashCode();
- }
-
- /**
- * EntryReps are equal if they have the same class and the fields
- * are pairwise equal. This is really only needed in the server,
- * but it's very convenient to have here.
- */
- public boolean equals(Object obj) {
- if (obj instanceof EntryRep) {
- EntryRep entry = (EntryRep)obj;
- if (!eclass.equals(entry.eclass) ||
- fields.length != entry.fields.length)
- return false;
- for (int i = fields.length; --i >= 0; ) {
- if ((fields[i] == null && entry.fields[i] != null) ||
- (fields[i] != null && !fields[i].equals(entry.fields[i])))
- return false;
- }
- return true;
- }
- return false;
- }
-
- /**
- * Deep clone (which just means cloning the fields array too).
- * This is really only needed in the server, but it's very
- * convenient to have here.
- */
- public Object clone() {
- try {
- EntryRep entry = (EntryRep)super.clone();
- entry.fields = (Object[])entry.fields.clone();
- return entry;
- } catch (CloneNotSupportedException e) {
- throw new InternalError();
- }
- }
-
- /**
- * Converts an array of Entry to an array of EntryRep. If needCodebase
- * is false, then the codebase of every EntryRep will be null.
- */
- public static EntryRep[] toEntryRep(Entry[] entries, boolean needCodebase)
- throws RemoteException
- {
- EntryRep[] reps = null;
- if (entries != null) {
- reps = new EntryRep[entries.length];
- for (int i = entries.length; --i >= 0; ) {
- if (entries[i] != null) {
- reps[i] = new EntryRep(entries[i]);
- if (!needCodebase)
- reps[i].codebase = null;
- }
- }
- }
- return reps;
- }
-
- /** Converts an array of EntryRep to an array of Entry. */
- public static Entry[] toEntry(EntryRep[] reps) {
- Entry[] entries = null;
- if (reps != null) {
- entries = new Entry[reps.length];
- for (int i = reps.length; --i >= 0; ) {
- entries[i] = reps[i].get();
- }
- }
- return entries;
- }
-}
+/*
+ * 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.reggie.proxy;
+
+import org.apache.river.proxy.MarshalledWrapper;
+import org.apache.river.reggie.proxy.ClassMapper.EntryField;
+import java.io.IOException;
+import java.io.Serializable;
+import java.lang.reflect.Field;
+import java.rmi.MarshalException;
+import java.rmi.RemoteException;
+import net.jini.core.entry.Entry;
+
+/**
+ * An EntryRep contains the fields of an Entry packaged up for
+ * transmission between client-side proxies and the registrar server.
+ * Instances are never visible to clients, they are private to the
+ * communication between the proxies and the server.
+ * <p>
+ * This class only has a bare minimum of methods, to minimize
+ * the amount of code downloaded into clients.
+ *
+ * @author Sun Microsystems, Inc.
+ *
+ */
+public class EntryRep implements Serializable, Cloneable {
+
+ private static final long serialVersionUID = 2L;
+
+ /**
+ * The Class of the Entry converted to EntryClass.
+ *
+ * @serial
+ */
+ public EntryClass eclass;
+ /**
+ * The codebase of the entry class.
+ *
+ * @serial
+ */
+ public String codebase;
+ /**
+ * The public fields of the Entry, each converted as necessary to
+ * a MarshalledWrapper (or left as is if of known java.lang immutable
+ * type). The fields are in super- to subclass order.
+ *
+ * @serial
+ */
+ public Object[] fields;
+
+ /**
+ * Converts an Entry to an EntryRep. Any exception that results
+ * is bundled up into a MarshalException.
+ */
+ public EntryRep(Entry entry) throws RemoteException {
+ EntryClassBase ecb = ClassMapper.toEntryClassBase(entry.getClass());
+ eclass = ecb.eclass;
+ codebase = ecb.codebase;
+ try {
+ EntryField[] efields = ClassMapper.getFields(entry.getClass());
+ fields = new Object[efields.length];
+ for (int i = efields.length; --i >= 0; ) {
+ EntryField f = efields[i];
+ Object val = f.field.get(entry);
+ if (f.marshal && val != null)
+ val = new MarshalledWrapper(val);
+ fields[i] = val;
+ }
+ } catch (IOException e) {
+ throw new MarshalException("error marshalling arguments", e);
+ } catch (IllegalAccessException e) {
+ throw new MarshalException("error marshalling arguments", e);
+ }
+ }
+
+ /**
+ * Convert back to an Entry. If the Entry cannot be constructed,
+ * null is returned. If a field cannot be unmarshalled, it is set
+ * to null.
+ */
+ public Entry get() {
+ try {
+ Class clazz = eclass.toClass(codebase);
+ EntryField[] efields = ClassMapper.getFields(clazz);
+ Entry entry = (Entry)clazz.newInstance();
+ for (int i = efields.length; --i >= 0; ) {
+ Object val = fields[i];
+ EntryField f = efields[i];
+ Field rf = f.field;
+ try {
+ if (f.marshal && val != null)
+ val = ((MarshalledWrapper) val).get();
+ rf.set(entry, val);
+ } catch (Throwable e) {
+ if (e instanceof IllegalArgumentException) {
+ // fix 4872566: work around empty exception message
+ String msg = "unable to assign " +
+ ((val != null) ?
+ "value of type " + val.getClass().getName() :
+ "null") +
+ " to field " + rf.getDeclaringClass().getName() +
+ "." + rf.getName() + " of type " +
+ rf.getType().getName();
+ e = new ClassCastException(msg).initCause(e);
+ }
+ RegistrarProxy.handleException(e);
+ }
+ }
+ return entry;
+ } catch (Throwable e) {
+ RegistrarProxy.handleException(e);
+ }
+ return null;
+ }
+
+ /**
+ * We don't need this in the client or the server, but since we
+ * redefine equals we provide a minimal hashCode that works.
+ */
+ public int hashCode() {
+ return eclass.hashCode();
+ }
+
+ /**
+ * EntryReps are equal if they have the same class and the fields
+ * are pairwise equal. This is really only needed in the server,
+ * but it's very convenient to have here.
+ */
+ public boolean equals(Object obj) {
+ if (obj instanceof EntryRep) {
+ EntryRep entry = (EntryRep)obj;
+ if (!eclass.equals(entry.eclass) ||
+ fields.length != entry.fields.length)
+ return false;
+ for (int i = fields.length; --i >= 0; ) {
+ if ((fields[i] == null && entry.fields[i] != null) ||
+ (fields[i] != null && !fields[i].equals(entry.fields[i])))
+ return false;
+ }
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Deep clone (which just means cloning the fields array too).
+ * This is really only needed in the server, but it's very
+ * convenient to have here.
+ */
+ public Object clone() {
+ try {
+ EntryRep entry = (EntryRep)super.clone();
+ entry.fields = (Object[])entry.fields.clone();
+ return entry;
+ } catch (CloneNotSupportedException e) {
+ throw new InternalError();
+ }
+ }
+
+ /**
+ * Converts an array of Entry to an array of EntryRep. If needCodebase
+ * is false, then the codebase of every EntryRep will be null.
+ */
+ public static EntryRep[] toEntryRep(Entry[] entries, boolean needCodebase)
+ throws RemoteException
+ {
+ EntryRep[] reps = null;
+ if (entries != null) {
+ reps = new EntryRep[entries.length];
+ for (int i = entries.length; --i >= 0; ) {
+ if (entries[i] != null) {
+ reps[i] = new EntryRep(entries[i]);
+ if (!needCodebase)
+ reps[i].codebase = null;
+ }
+ }
+ }
+ return reps;
+ }
+
+ /** Converts an array of EntryRep to an array of Entry. */
+ public static Entry[] toEntry(EntryRep[] reps) {
+ Entry[] entries = null;
+ if (reps != null) {
+ entries = new Entry[reps.length];
+ for (int i = reps.length; --i >= 0; ) {
+ entries[i] = reps[i].get();
+ }
+ }
+ return entries;
+ }
+}
Modified: river/jtsk/modules/modularize/apache-river/river-services/reggie/reggie-dl/src/main/java/org/apache/river/reggie/proxy/EventLease.java
URL: http://svn.apache.org/viewvc/river/jtsk/modules/modularize/apache-river/river-services/reggie/reggie-dl/src/main/java/org/apache/river/reggie/proxy/EventLease.java?rev=1879521&r1=1879520&r2=1879521&view=diff
==============================================================================
--- river/jtsk/modules/modularize/apache-river/river-services/reggie/reggie-dl/src/main/java/org/apache/river/reggie/proxy/EventLease.java (original)
+++ river/jtsk/modules/modularize/apache-river/river-services/reggie/reggie-dl/src/main/java/org/apache/river/reggie/proxy/EventLease.java Sun Jul 5 11:41:39 2020
@@ -1,117 +1,117 @@
-/*
- * 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.reggie;
-
-import java.io.InvalidObjectException;
-import java.io.ObjectStreamException;
-import java.rmi.RemoteException;
-import net.jini.core.constraint.RemoteMethodControl;
-import net.jini.core.lease.UnknownLeaseException;
-import net.jini.core.lookup.ServiceID;
-import net.jini.id.Uuid;
-
-/**
- * When a registrar (lookup service) grants a lease on an event registration
- * on behalf of some object (client), a proxy is employed to allow the client
- * to interact with the lease; this class is the implementation of that proxy.
- * Clients only see instances of this class via the Lease interface.
- *
- * @author Sun Microsystems, Inc.
- *
- */
-class EventLease extends RegistrarLease {
-
- private static final long serialVersionUID = 2L;
- /** The type of the lease used in toString() calls. */
- private static final String LEASE_TYPE = "event";
-
- /**
- * The eventID returned in the EventRegistration.
- *
- * @serial
- */
- final long eventID;
-
- /**
- * Returns EventLease or ConstrainableEventLease instance, depending on
- * whether given server implements RemoteMethodControl.
- */
- static EventLease getInstance(Registrar server,
- ServiceID registrarID,
- long eventID,
- Uuid leaseID,
- long expiration)
- {
- return (server instanceof RemoteMethodControl) ?
- new ConstrainableEventLease(
- server, registrarID, eventID, leaseID, expiration, null) :
- new EventLease(server, registrarID, eventID, leaseID, expiration);
- }
-
- /** Constructor for use by getInstance(), ConstrainableEventLease. */
- EventLease(Registrar server,
- ServiceID registrarID,
- long eventID,
- Uuid leaseID,
- long expiration)
- {
- super(server, registrarID, leaseID, expiration);
- this.eventID = eventID;
- }
-
- // This method's javadoc is inherited from an interface of this class
- public void cancel() throws UnknownLeaseException, RemoteException {
- server.cancelEventLease(eventID, leaseID);
- }
-
- /**
- * Renews the event lease associated with an instance of this class.
- * Each instance of this class corresponds to a lease on an event
- * registration for a particular client. This method renews that
- * lease on behalf of the client.
- *
- * @param duration the requested duration for the lease being renewed
- * @return long value representing the new duration that was granted
- * for the renewed lease. Note that the duration returned may
- * be less than the duration requested.
- * @exception UnknownLeaseException indicates the lease does not exist;
- * typically because the lease has expired.
- */
- protected long doRenew(long duration)
- throws UnknownLeaseException, RemoteException
- {
- return server.renewEventLease(eventID, leaseID, duration);
- }
-
- // This method's javadoc is inherited from a super class of this class
- Object getRegID() {
- return Long.valueOf(eventID);
- }
-
- // inherit javadoc
- String getLeaseType() {
- return LEASE_TYPE;
- }
-
- /**
- * Throws InvalidObjectException, since data for this class is required.
- */
- private void readObjectNoData() throws ObjectStreamException {
- throw new InvalidObjectException("no data");
- }
-}
+/*
+ * 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.reggie.proxy;
+
+import java.io.InvalidObjectException;
+import java.io.ObjectStreamException;
+import java.rmi.RemoteException;
+import net.jini.core.constraint.RemoteMethodControl;
+import net.jini.core.lease.UnknownLeaseException;
+import net.jini.core.lookup.ServiceID;
+import net.jini.id.Uuid;
+
+/**
+ * When a registrar (lookup service) grants a lease on an event registration
+ * on behalf of some object (client), a proxy is employed to allow the client
+ * to interact with the lease; this class is the implementation of that proxy.
+ * Clients only see instances of this class via the Lease interface.
+ *
+ * @author Sun Microsystems, Inc.
+ *
+ */
+public class EventLease extends RegistrarLease {
+
+ private static final long serialVersionUID = 2L;
+ /** The type of the lease used in toString() calls. */
+ private static final String LEASE_TYPE = "event";
+
+ /**
+ * The eventID returned in the EventRegistration.
+ *
+ * @serial
+ */
+ final long eventID;
+
+ /**
+ * Returns EventLease or ConstrainableEventLease instance, depending on
+ * whether given server implements RemoteMethodControl.
+ */
+ public static EventLease getInstance(Registrar server,
+ ServiceID registrarID,
+ long eventID,
+ Uuid leaseID,
+ long expiration)
+ {
+ return (server instanceof RemoteMethodControl) ?
+ new ConstrainableEventLease(
+ server, registrarID, eventID, leaseID, expiration, null) :
+ new EventLease(server, registrarID, eventID, leaseID, expiration);
+ }
+
+ /** Constructor for use by getInstance(), ConstrainableEventLease. */
+ EventLease(Registrar server,
+ ServiceID registrarID,
+ long eventID,
+ Uuid leaseID,
+ long expiration)
+ {
+ super(server, registrarID, leaseID, expiration);
+ this.eventID = eventID;
+ }
+
+ // This method's javadoc is inherited from an interface of this class
+ public void cancel() throws UnknownLeaseException, RemoteException {
+ server.cancelEventLease(eventID, leaseID);
+ }
+
+ /**
+ * Renews the event lease associated with an instance of this class.
+ * Each instance of this class corresponds to a lease on an event
+ * registration for a particular client. This method renews that
+ * lease on behalf of the client.
+ *
+ * @param duration the requested duration for the lease being renewed
+ * @return long value representing the new duration that was granted
+ * for the renewed lease. Note that the duration returned may
+ * be less than the duration requested.
+ * @exception UnknownLeaseException indicates the lease does not exist;
+ * typically because the lease has expired.
+ */
+ protected long doRenew(long duration)
+ throws UnknownLeaseException, RemoteException
+ {
+ return server.renewEventLease(eventID, leaseID, duration);
+ }
+
+ // This method's javadoc is inherited from a super class of this class
+ Object getRegID() {
+ return Long.valueOf(eventID);
+ }
+
+ // inherit javadoc
+ String getLeaseType() {
+ return LEASE_TYPE;
+ }
+
+ /**
+ * Throws InvalidObjectException, since data for this class is required.
+ */
+ private void readObjectNoData() throws ObjectStreamException {
+ throw new InvalidObjectException("no data");
+ }
+}
Modified: river/jtsk/modules/modularize/apache-river/river-services/reggie/reggie-dl/src/main/java/org/apache/river/reggie/proxy/Item.java
URL: http://svn.apache.org/viewvc/river/jtsk/modules/modularize/apache-river/river-services/reggie/reggie-dl/src/main/java/org/apache/river/reggie/proxy/Item.java?rev=1879521&r1=1879520&r2=1879521&view=diff
==============================================================================
--- river/jtsk/modules/modularize/apache-river/river-services/reggie/reggie-dl/src/main/java/org/apache/river/reggie/proxy/Item.java (original)
+++ river/jtsk/modules/modularize/apache-river/river-services/reggie/reggie-dl/src/main/java/org/apache/river/reggie/proxy/Item.java Sun Jul 5 11:41:39 2020
@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.river.reggie;
+package org.apache.river.reggie.proxy;
import org.apache.river.action.GetBooleanAction;
import org.apache.river.logging.Levels;
@@ -46,7 +46,7 @@ import net.jini.security.Security;
* @author Sun Microsystems, Inc.
*
*/
-class Item implements Serializable, Cloneable {
+public class Item implements Serializable, Cloneable {
private static final long serialVersionUID = 2L;
@@ -129,7 +129,7 @@ class Item implements Serializable, Clon
attributeSets = EntryRep.toEntryRep(item.attributeSets, true);
}
- Item(ServiceID serviceID,
+ public Item(ServiceID serviceID,
ServiceType serviceType,
String codebase,
MarshalledWrapper service,
Modified: river/jtsk/modules/modularize/apache-river/river-services/reggie/reggie-dl/src/main/java/org/apache/river/reggie/proxy/Matches.java
URL: http://svn.apache.org/viewvc/river/jtsk/modules/modularize/apache-river/river-services/reggie/reggie-dl/src/main/java/org/apache/river/reggie/proxy/Matches.java?rev=1879521&r1=1879520&r2=1879521&view=diff
==============================================================================
--- river/jtsk/modules/modularize/apache-river/river-services/reggie/reggie-dl/src/main/java/org/apache/river/reggie/proxy/Matches.java (original)
+++ river/jtsk/modules/modularize/apache-river/river-services/reggie/reggie-dl/src/main/java/org/apache/river/reggie/proxy/Matches.java Sun Jul 5 11:41:39 2020
@@ -1,65 +1,65 @@
-/*
- * 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.reggie;
-
-import java.io.Serializable;
-import java.rmi.RemoteException;
-import java.util.ArrayList;
-import java.util.List;
-import net.jini.core.lookup.ServiceMatches;
-
-/**
- * A Matches contains the fields of a ServiceMatches packaged up for
- * transmission between client-side proxies and the registrar server.
- * Instances are never visible to clients, they are private to the
- * communication between the proxies and the server.
- * <p>
- * This class only has a bare minimum of methods, to minimize
- * the amount of code downloaded into clients.
- *
- * @author Sun Microsystems, Inc.
- *
- */
-class Matches implements Serializable {
-
- private static final long serialVersionUID = 2L;
-
- /**
- * ServiceMatches.items as an ArrayList of Item
- *
- * @serial
- */
- private final List items;
- /**
- * ServiceMatches.totalMatches
- *
- * @serial
- */
- private final int totalMatches;
-
- /** Simple constructor. */
- public Matches(List items, int totalMatches) {
- this.items = items;
- this.totalMatches = totalMatches;
- }
-
- /** Converts a Matches to a ServiceMatches. */
- ServiceMatches get() throws RemoteException {
- return new ServiceMatches(Item.toServiceItem(items), totalMatches);
- }
-}
+/*
+ * 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.reggie.proxy;
+
+import java.io.Serializable;
+import java.rmi.RemoteException;
+import java.util.ArrayList;
+import java.util.List;
+import net.jini.core.lookup.ServiceMatches;
+
+/**
+ * A Matches contains the fields of a ServiceMatches packaged up for
+ * transmission between client-side proxies and the registrar server.
+ * Instances are never visible to clients, they are private to the
+ * communication between the proxies and the server.
+ * <p>
+ * This class only has a bare minimum of methods, to minimize
+ * the amount of code downloaded into clients.
+ *
+ * @author Sun Microsystems, Inc.
+ *
+ */
+public class Matches implements Serializable {
+
+ private static final long serialVersionUID = 2L;
+
+ /**
+ * ServiceMatches.items as an ArrayList of Item
+ *
+ * @serial
+ */
+ private final List items;
+ /**
+ * ServiceMatches.totalMatches
+ *
+ * @serial
+ */
+ private final int totalMatches;
+
+ /** Simple constructor. */
+ public Matches(List items, int totalMatches) {
+ this.items = items;
+ this.totalMatches = totalMatches;
+ }
+
+ /** Converts a Matches to a ServiceMatches. */
+ ServiceMatches get() throws RemoteException {
+ return new ServiceMatches(Item.toServiceItem(items), totalMatches);
+ }
+}
Modified: river/jtsk/modules/modularize/apache-river/river-services/reggie/reggie-dl/src/main/java/org/apache/river/reggie/proxy/ProxyVerifier.java
URL: http://svn.apache.org/viewvc/river/jtsk/modules/modularize/apache-river/river-services/reggie/reggie-dl/src/main/java/org/apache/river/reggie/proxy/ProxyVerifier.java?rev=1879521&r1=1879520&r2=1879521&view=diff
==============================================================================
--- river/jtsk/modules/modularize/apache-river/river-services/reggie/reggie-dl/src/main/java/org/apache/river/reggie/proxy/ProxyVerifier.java (original)
+++ river/jtsk/modules/modularize/apache-river/river-services/reggie/reggie-dl/src/main/java/org/apache/river/reggie/proxy/ProxyVerifier.java Sun Jul 5 11:41:39 2020
@@ -1,154 +1,154 @@
-/*
- * 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.reggie;
-
-import java.io.IOException;
-import java.io.InvalidObjectException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
-import java.rmi.RemoteException;
-import net.jini.core.constraint.RemoteMethodControl;
-import net.jini.core.lookup.ServiceID;
-import net.jini.security.TrustVerifier;
-import net.jini.security.proxytrust.TrustEquivalence;
-
-/**
- * Trust verifier for smart proxies used by Reggie.
- *
- * @author Sun Microsystems, Inc.
- *
- */
-final class ProxyVerifier implements TrustVerifier, Serializable {
-
- private static final long serialVersionUID = 2L;
-
- /**
- * Canonical service reference, used for comparison with inner server
- * references extracted from smart proxies to verify.
- *
- * @serial
- */
- private final RemoteMethodControl server;
- /**
- * The registrar's service ID, used for comparison with registrar service
- * IDs extracted from smart proxies to verify.
- */
- private transient ServiceID registrarID;
-
- /**
- * Constructs proxy verifier which compares server references extracted
- * from smart proxies with the given canonical server reference, which must
- * implement both RemoteMethodControl and TrustEquivalence. For proxies
- * which contain a copy of the registrar's service ID, that copy is
- * compared against the given service ID to ensure consistency.
- */
- ProxyVerifier(Registrar server, ServiceID registrarID) {
- if (!(server instanceof RemoteMethodControl)) {
- throw new UnsupportedOperationException(
- "server does not implement RemoteMethodControl");
- } else if (!(server instanceof TrustEquivalence)) {
- throw new UnsupportedOperationException(
- "server does not implement TrustEquivalence");
- }
- this.server = (RemoteMethodControl) server;
- this.registrarID = registrarID;
- }
-
- /**
- * Returns true if the given object is a trusted proxy, or false otherwise.
- * The given object is trusted if it is trust equivalent to the canonical
- * server reference carried by this trust verifier, or if it is an instance
- * of one of Reggie's constrainable smart proxy classes, and all component
- * proxies it contains are trusted, and its inner server reference is trust
- * equivalent to the canonical server reference, and its inner copy of the
- * registrar's service ID (if it has one) is equal to the service ID
- * carried by this verifier.
- */
- public boolean isTrustedObject(Object obj, TrustVerifier.Context ctx)
- throws RemoteException
- {
- if (obj == null || ctx == null) {
- throw new NullPointerException();
- }
- RemoteMethodControl inputServer;
- ServiceID inputRegistrarID;
- if (obj instanceof ConstrainableRegistrarProxy) {
- RegistrarProxy proxy = (RegistrarProxy) obj;
- inputServer = (RemoteMethodControl) proxy.server;
- inputRegistrarID = proxy.registrarID;
- } else if (obj instanceof ConstrainableAdminProxy) {
- AdminProxy proxy = (AdminProxy) obj;
- inputServer = (RemoteMethodControl) proxy.server;
- inputRegistrarID = proxy.registrarID;
- } else if (obj instanceof ConstrainableRegistration) {
- Registration reg = (Registration) obj;
- if (!isTrustedObject(reg.lease, ctx)) {
- return false;
- }
- inputServer = (RemoteMethodControl) reg.server;
- inputRegistrarID = registrarID;
- } else if (obj instanceof ConstrainableEventLease ||
- obj instanceof ConstrainableServiceLease)
- {
- RegistrarLease lease = (RegistrarLease) obj;
- inputServer = (RemoteMethodControl) lease.server;
- inputRegistrarID = lease.registrarID;
- } else if (obj instanceof RemoteMethodControl) {
- inputServer = (RemoteMethodControl) obj;
- inputRegistrarID = registrarID;
- } else {
- return false;
- }
-
- TrustEquivalence trustEquiv = (TrustEquivalence)
- server.setConstraints(inputServer.getConstraints());
- return trustEquiv.checkTrustEquivalence(inputServer) &&
- registrarID.equals(inputRegistrarID);
- }
-
- /**
- * Writes the default serializable field value for this instance, followed
- * by the registrar's service ID encoded as specified by the
- * ServiceID.writeBytes method.
- */
- private void writeObject(ObjectOutputStream out) throws IOException {
- out.defaultWriteObject();
- registrarID.writeBytes(out);
- }
-
- /**
- * Reads the default serializable field value for this instance, followed
- * by the registrar's service ID encoded as specified by the
- * ServiceID.writeBytes method. Verifies that the deserialized registrar
- * reference implements both RemoteMethodControl and TrustEquivalence.
- */
- private void readObject(ObjectInputStream in)
- throws IOException, ClassNotFoundException
- {
- in.defaultReadObject();
- registrarID = new ServiceID(in);
- if (!(server instanceof RemoteMethodControl)) {
- throw new InvalidObjectException(
- "server does not implement RemoteMethodControl");
- } else if (!(server instanceof TrustEquivalence)) {
- throw new InvalidObjectException(
- "server does not 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.reggie.proxy;
+
+import java.io.IOException;
+import java.io.InvalidObjectException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.rmi.RemoteException;
+import net.jini.core.constraint.RemoteMethodControl;
+import net.jini.core.lookup.ServiceID;
+import net.jini.security.TrustVerifier;
+import net.jini.security.proxytrust.TrustEquivalence;
+
+/**
+ * Trust verifier for smart proxies used by Reggie.
+ *
+ * @author Sun Microsystems, Inc.
+ *
+ */
+public final class ProxyVerifier implements TrustVerifier, Serializable {
+
+ private static final long serialVersionUID = 2L;
+
+ /**
+ * Canonical service reference, used for comparison with inner server
+ * references extracted from smart proxies to verify.
+ *
+ * @serial
+ */
+ private final RemoteMethodControl server;
+ /**
+ * The registrar's service ID, used for comparison with registrar service
+ * IDs extracted from smart proxies to verify.
+ */
+ private transient ServiceID registrarID;
+
+ /**
+ * Constructs proxy verifier which compares server references extracted
+ * from smart proxies with the given canonical server reference, which must
+ * implement both RemoteMethodControl and TrustEquivalence. For proxies
+ * which contain a copy of the registrar's service ID, that copy is
+ * compared against the given service ID to ensure consistency.
+ */
+ public ProxyVerifier(Registrar server, ServiceID registrarID) {
+ if (!(server instanceof RemoteMethodControl)) {
+ throw new UnsupportedOperationException(
+ "server does not implement RemoteMethodControl");
+ } else if (!(server instanceof TrustEquivalence)) {
+ throw new UnsupportedOperationException(
+ "server does not implement TrustEquivalence");
+ }
+ this.server = (RemoteMethodControl) server;
+ this.registrarID = registrarID;
+ }
+
+ /**
+ * Returns true if the given object is a trusted proxy, or false otherwise.
+ * The given object is trusted if it is trust equivalent to the canonical
+ * server reference carried by this trust verifier, or if it is an instance
+ * of one of Reggie's constrainable smart proxy classes, and all component
+ * proxies it contains are trusted, and its inner server reference is trust
+ * equivalent to the canonical server reference, and its inner copy of the
+ * registrar's service ID (if it has one) is equal to the service ID
+ * carried by this verifier.
+ */
+ public boolean isTrustedObject(Object obj, TrustVerifier.Context ctx)
+ throws RemoteException
+ {
+ if (obj == null || ctx == null) {
+ throw new NullPointerException();
+ }
+ RemoteMethodControl inputServer;
+ ServiceID inputRegistrarID;
+ if (obj instanceof ConstrainableRegistrarProxy) {
+ RegistrarProxy proxy = (RegistrarProxy) obj;
+ inputServer = (RemoteMethodControl) proxy.server;
+ inputRegistrarID = proxy.registrarID;
+ } else if (obj instanceof ConstrainableAdminProxy) {
+ AdminProxy proxy = (AdminProxy) obj;
+ inputServer = (RemoteMethodControl) proxy.server;
+ inputRegistrarID = proxy.registrarID;
+ } else if (obj instanceof ConstrainableRegistration) {
+ Registration reg = (Registration) obj;
+ if (!isTrustedObject(reg.lease, ctx)) {
+ return false;
+ }
+ inputServer = (RemoteMethodControl) reg.server;
+ inputRegistrarID = registrarID;
+ } else if (obj instanceof ConstrainableEventLease ||
+ obj instanceof ConstrainableServiceLease)
+ {
+ RegistrarLease lease = (RegistrarLease) obj;
+ inputServer = (RemoteMethodControl) lease.server;
+ inputRegistrarID = lease.registrarID;
+ } else if (obj instanceof RemoteMethodControl) {
+ inputServer = (RemoteMethodControl) obj;
+ inputRegistrarID = registrarID;
+ } else {
+ return false;
+ }
+
+ TrustEquivalence trustEquiv = (TrustEquivalence)
+ server.setConstraints(inputServer.getConstraints());
+ return trustEquiv.checkTrustEquivalence(inputServer) &&
+ registrarID.equals(inputRegistrarID);
+ }
+
+ /**
+ * Writes the default serializable field value for this instance, followed
+ * by the registrar's service ID encoded as specified by the
+ * ServiceID.writeBytes method.
+ */
+ private void writeObject(ObjectOutputStream out) throws IOException {
+ out.defaultWriteObject();
+ registrarID.writeBytes(out);
+ }
+
+ /**
+ * Reads the default serializable field value for this instance, followed
+ * by the registrar's service ID encoded as specified by the
+ * ServiceID.writeBytes method. Verifies that the deserialized registrar
+ * reference implements both RemoteMethodControl and TrustEquivalence.
+ */
+ private void readObject(ObjectInputStream in)
+ throws IOException, ClassNotFoundException
+ {
+ in.defaultReadObject();
+ registrarID = new ServiceID(in);
+ if (!(server instanceof RemoteMethodControl)) {
+ throw new InvalidObjectException(
+ "server does not implement RemoteMethodControl");
+ } else if (!(server instanceof TrustEquivalence)) {
+ throw new InvalidObjectException(
+ "server does not implement TrustEquivalence");
+ }
+ }
+}
Modified: river/jtsk/modules/modularize/apache-river/river-services/reggie/reggie-dl/src/main/java/org/apache/river/reggie/proxy/Registrar.java
URL: http://svn.apache.org/viewvc/river/jtsk/modules/modularize/apache-river/river-services/reggie/reggie-dl/src/main/java/org/apache/river/reggie/proxy/Registrar.java?rev=1879521&r1=1879520&r2=1879521&view=diff
==============================================================================
--- river/jtsk/modules/modularize/apache-river/river-services/reggie/reggie-dl/src/main/java/org/apache/river/reggie/proxy/Registrar.java (original)
+++ river/jtsk/modules/modularize/apache-river/river-services/reggie/reggie-dl/src/main/java/org/apache/river/reggie/proxy/Registrar.java Sun Jul 5 11:41:39 2020
@@ -1,198 +1,198 @@
-/*
- * 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.reggie;
-
-import org.apache.river.admin.DestroyAdmin;
-import org.apache.river.proxy.MarshalledWrapper;
-import org.apache.river.start.ServiceProxyAccessor;
-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.discovery.LookupLocator;
-import net.jini.core.event.EventRegistration;
-import net.jini.core.event.RemoteEventListener;
-import net.jini.core.lease.UnknownLeaseException;
-import net.jini.core.lookup.ServiceID;
-import net.jini.core.lookup.ServiceRegistration;
-import net.jini.id.Uuid;
-import net.jini.lookup.DiscoveryAdmin;
-
-/**
- * Registrar defines the private protocol between the various client-side
- * proxies and the registrar server.
- * <p>
- * The declared methods are pretty straightforward transformations of the
- * ServiceRegistrar and ServiceRegistration interfaces, with external classes
- * (ServiceItem, ServiceTemplate, ServiceMatches, Entry) converted to internal
- * classes (Item, Template, Matches, EntryRep). In addition, there are
- * methods for transformed Lease and LeaseMap interfaces, for service and
- * event leases.
- *
- * @author Sun Microsystems, Inc.
- *
- */
-interface Registrar
- extends Remote, ServiceProxyAccessor, Administrable,
- DiscoveryAdmin, JoinAdmin, DestroyAdmin
-{
- /**
- * Register a new service or re-register an existing service.
- * @see net.jini.core.lookup.ServiceRegistrar#register
- */
- ServiceRegistration register(Item item, long leaseDuration)
- throws RemoteException;
-
- /**
- * Returns the service object (i.e., just ServiceItem.service) from an
- * item matching the template, or null if there is no match.
- * @see net.jini.core.lookup.ServiceRegistrar#lookup
- */
- MarshalledWrapper lookup(Template tmpl) throws RemoteException;
-
- /**
- * Returns at most maxMatches items matching the template, plus the total
- * number of items that match the template.
- * @see net.jini.core.lookup.ServiceRegistrar#lookup
- */
- Matches lookup(Template tmpl, int maxMatches) throws RemoteException;
-
- /**
- * Registers for event notification.
- * @see net.jini.core.lookup.ServiceRegistrar#notify
- */
- EventRegistration notify(Template tmpl,
- int transitions,
- RemoteEventListener listener,
- MarshalledObject handback,
- long leaseDuration)
- throws RemoteException;
-
- /**
- * Looks at all service items that match the specified template, finds
- * every entry (among those service items) that either doesn't match any
- * entry templates or is a subclass of at least one matching entry
- * template, and returns the set of the (most specific) classes of those
- * entries.
- * @see net.jini.core.lookup.ServiceRegistrar#getEntryClasses
- */
- EntryClassBase[] getEntryClasses(Template tmpl) throws RemoteException;
-
- /**
- * Looks at all service items that match the specified template, finds
- * every entry (among those service items) that matches
- * tmpl.attributeSetTemplates[setIndex], and returns the set of values
- * of the specified field of those entries.
- * The field name has been converted to an index (fields numbered
- * from super to subclass).
- *
- * @see net.jini.core.lookup.ServiceRegistrar#getFieldValues
- */
- Object[] getFieldValues(Template tmpl, int setIndex, int field)
- throws RemoteException;
-
- /**
- * Looks at all service items that match the specified template, and for
- * every service item finds the most specific type (class or interface)
- * or types the service item is an instance of that are neither equal to,
- * nor a superclass of, any of the service types in the template and that
- * have names that start with the specified prefix, and returns the set
- * of all such types.
- * @see net.jini.core.lookup.ServiceRegistrar#getServiceTypes
- */
- ServiceTypeBase[] getServiceTypes(Template tmpl, String prefix)
- throws RemoteException;
-
- /**
- * Returns a LookupLocator that can be used if necessary for unicast
- * discovery of the lookup service.
- * @see net.jini.core.lookup.ServiceRegistrar#getLocator
- */
- LookupLocator getLocator() throws RemoteException;
-
- /**
- * Adds the specified attribute sets (those that aren't duplicates of
- * existing attribute sets) to the registered service item.
- * @see net.jini.core.lookup.ServiceRegistration#addAttributes
- */
- void addAttributes(ServiceID serviceID, Uuid leaseID, EntryRep[] attrSets)
- throws UnknownLeaseException, RemoteException;
-
- /**
- * Modifies existing attribute sets of a registered service item.
- * @see net.jini.core.lookup.ServiceRegistration#modifyAttributes
- */
- void modifyAttributes(ServiceID serviceID,
- Uuid leaseID,
- EntryRep[] attrSetTmpls,
- EntryRep[] attrSets)
- throws UnknownLeaseException, RemoteException;
-
- /**
- * Deletes all of the service item's existing attributes, and replaces
- * them with the specified attribute sets.
- * @see net.jini.core.lookup.ServiceRegistration#setAttributes
- */
- void setAttributes(ServiceID serviceID, Uuid leaseID, EntryRep[] attrSets)
- throws UnknownLeaseException, RemoteException;
-
- /**
- * Cancels a service lease.
- * @see net.jini.core.lease.Lease#cancel
- */
- void cancelServiceLease(ServiceID serviceID, Uuid leaseID)
- throws UnknownLeaseException, RemoteException;
-
- /**
- * Renews a service lease.
- * @see net.jini.core.lease.Lease#renew
- */
- long renewServiceLease(ServiceID serviceID, Uuid leaseID, long duration)
- throws UnknownLeaseException, RemoteException;
-
- /**
- * Cancels an event lease.
- * @see net.jini.core.lease.Lease#cancel
- */
- void cancelEventLease(long eventID, Uuid leaseID)
- throws UnknownLeaseException, RemoteException;
-
- /**
- * Renews an event lease.
- * @see net.jini.core.lease.Lease#renew
- */
- long renewEventLease(long eventID, Uuid leaseID, long duration)
- throws UnknownLeaseException, RemoteException;
-
- /**
- * Renews service and event leases from a LeaseMap.
- * @see net.jini.core.lease.LeaseMap#renewAll
- */
- RenewResults renewLeases(Object[] regIDs,
- Uuid[] leaseIDs,
- long[] durations)
- throws RemoteException;
-
- /**
- * Cancels service and event leases from a LeaseMap.
- * @see net.jini.core.lease.LeaseMap#cancelAll
- */
- Exception[] cancelLeases(Object[] regIDs, Uuid[] leaseIDs)
- throws RemoteException;
-}
+/*
+ * 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.reggie.proxy;
+
+import org.apache.river.admin.DestroyAdmin;
+import org.apache.river.proxy.MarshalledWrapper;
+import org.apache.river.start.moveMe.ServiceProxyAccessor;
+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.discovery.LookupLocator;
+import net.jini.core.event.EventRegistration;
+import net.jini.core.event.RemoteEventListener;
+import net.jini.core.lease.UnknownLeaseException;
+import net.jini.core.lookup.ServiceID;
+import net.jini.core.lookup.ServiceRegistration;
+import net.jini.id.Uuid;
+import net.jini.lookup.DiscoveryAdmin;
+
+/**
+ * Registrar defines the private protocol between the various client-side
+ * proxies and the registrar server.
+ * <p>
+ * The declared methods are pretty straightforward transformations of the
+ * ServiceRegistrar and ServiceRegistration interfaces, with external classes
+ * (ServiceItem, ServiceTemplate, ServiceMatches, Entry) converted to internal
+ * classes (Item, Template, Matches, EntryRep). In addition, there are
+ * methods for transformed Lease and LeaseMap interfaces, for service and
+ * event leases.
+ *
+ * @author Sun Microsystems, Inc.
+ *
+ */
+public interface Registrar
+ extends Remote, ServiceProxyAccessor, Administrable,
+ DiscoveryAdmin, JoinAdmin, DestroyAdmin
+{
+ /**
+ * Register a new service or re-register an existing service.
+ * @see net.jini.core.lookup.ServiceRegistrar#register
+ */
+ ServiceRegistration register(Item item, long leaseDuration)
+ throws RemoteException;
+
+ /**
+ * Returns the service object (i.e., just ServiceItem.service) from an
+ * item matching the template, or null if there is no match.
+ * @see net.jini.core.lookup.ServiceRegistrar#lookup
+ */
+ MarshalledWrapper lookup(Template tmpl) throws RemoteException;
+
+ /**
+ * Returns at most maxMatches items matching the template, plus the total
+ * number of items that match the template.
+ * @see net.jini.core.lookup.ServiceRegistrar#lookup
+ */
+ Matches lookup(Template tmpl, int maxMatches) throws RemoteException;
+
+ /**
+ * Registers for event notification.
+ * @see net.jini.core.lookup.ServiceRegistrar#notify
+ */
+ EventRegistration notify(Template tmpl,
+ int transitions,
+ RemoteEventListener listener,
+ MarshalledObject handback,
+ long leaseDuration)
+ throws RemoteException;
+
+ /**
+ * Looks at all service items that match the specified template, finds
+ * every entry (among those service items) that either doesn't match any
+ * entry templates or is a subclass of at least one matching entry
+ * template, and returns the set of the (most specific) classes of those
+ * entries.
+ * @see net.jini.core.lookup.ServiceRegistrar#getEntryClasses
+ */
+ EntryClassBase[] getEntryClasses(Template tmpl) throws RemoteException;
+
+ /**
+ * Looks at all service items that match the specified template, finds
+ * every entry (among those service items) that matches
+ * tmpl.attributeSetTemplates[setIndex], and returns the set of values
+ * of the specified field of those entries.
+ * The field name has been converted to an index (fields numbered
+ * from super to subclass).
+ *
+ * @see net.jini.core.lookup.ServiceRegistrar#getFieldValues
+ */
+ Object[] getFieldValues(Template tmpl, int setIndex, int field)
+ throws RemoteException;
+
+ /**
+ * Looks at all service items that match the specified template, and for
+ * every service item finds the most specific type (class or interface)
+ * or types the service item is an instance of that are neither equal to,
+ * nor a superclass of, any of the service types in the template and that
+ * have names that start with the specified prefix, and returns the set
+ * of all such types.
+ * @see net.jini.core.lookup.ServiceRegistrar#getServiceTypes
+ */
+ ServiceTypeBase[] getServiceTypes(Template tmpl, String prefix)
+ throws RemoteException;
+
+ /**
+ * Returns a LookupLocator that can be used if necessary for unicast
+ * discovery of the lookup service.
+ * @see net.jini.core.lookup.ServiceRegistrar#getLocator
+ */
+ LookupLocator getLocator() throws RemoteException;
+
+ /**
+ * Adds the specified attribute sets (those that aren't duplicates of
+ * existing attribute sets) to the registered service item.
+ * @see net.jini.core.lookup.ServiceRegistration#addAttributes
+ */
+ void addAttributes(ServiceID serviceID, Uuid leaseID, EntryRep[] attrSets)
+ throws UnknownLeaseException, RemoteException;
+
+ /**
+ * Modifies existing attribute sets of a registered service item.
+ * @see net.jini.core.lookup.ServiceRegistration#modifyAttributes
+ */
+ void modifyAttributes(ServiceID serviceID,
+ Uuid leaseID,
+ EntryRep[] attrSetTmpls,
+ EntryRep[] attrSets)
+ throws UnknownLeaseException, RemoteException;
+
+ /**
+ * Deletes all of the service item's existing attributes, and replaces
+ * them with the specified attribute sets.
+ * @see net.jini.core.lookup.ServiceRegistration#setAttributes
+ */
+ void setAttributes(ServiceID serviceID, Uuid leaseID, EntryRep[] attrSets)
+ throws UnknownLeaseException, RemoteException;
+
+ /**
+ * Cancels a service lease.
+ * @see net.jini.core.lease.Lease#cancel
+ */
+ void cancelServiceLease(ServiceID serviceID, Uuid leaseID)
+ throws UnknownLeaseException, RemoteException;
+
+ /**
+ * Renews a service lease.
+ * @see net.jini.core.lease.Lease#renew
+ */
+ long renewServiceLease(ServiceID serviceID, Uuid leaseID, long duration)
+ throws UnknownLeaseException, RemoteException;
+
+ /**
+ * Cancels an event lease.
+ * @see net.jini.core.lease.Lease#cancel
+ */
+ void cancelEventLease(long eventID, Uuid leaseID)
+ throws UnknownLeaseException, RemoteException;
+
+ /**
+ * Renews an event lease.
+ * @see net.jini.core.lease.Lease#renew
+ */
+ long renewEventLease(long eventID, Uuid leaseID, long duration)
+ throws UnknownLeaseException, RemoteException;
+
+ /**
+ * Renews service and event leases from a LeaseMap.
+ * @see net.jini.core.lease.LeaseMap#renewAll
+ */
+ RenewResults renewLeases(Object[] regIDs,
+ Uuid[] leaseIDs,
+ long[] durations)
+ throws RemoteException;
+
+ /**
+ * Cancels service and event leases from a LeaseMap.
+ * @see net.jini.core.lease.LeaseMap#cancelAll
+ */
+ Exception[] cancelLeases(Object[] regIDs, Uuid[] leaseIDs)
+ throws RemoteException;
+}