Modified: river/jtsk/modules/modularize/apache-river/river-services/reggie/reggie-dl/src/main/java/org/apache/river/reggie/proxy/ClassMapper.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/ClassMapper.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/ClassMapper.java (original) +++ river/jtsk/modules/modularize/apache-river/river-services/reggie/reggie-dl/src/main/java/org/apache/river/reggie/proxy/ClassMapper.java Sun Jul 5 11:41:39 2020 @@ -1,251 +1,251 @@ -/* - * 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.lang.reflect.Field; -import java.lang.reflect.Modifier; -import java.util.Arrays; -import java.util.Comparator; -import java.util.WeakHashMap; -import java.lang.ref.SoftReference; -import java.rmi.MarshalException; - -/** - * Maps Class to ServiceType/Base, Class to EntryClass/Base, and Class to - * Field[], with caching for efficiency. - * - * @author Sun Microsystems, Inc. - * - */ -class ClassMapper { - - /** Weak Map from Class to SoftReference(ServiceTypeBase) */ - private static final WeakHashMap serviceMap = new WeakHashMap(23); - /** Weak Map from Class to SoftReference(EntryClassBase) */ - private static final WeakHashMap entryMap = new WeakHashMap(17); - /** Weak Map from Class to SoftReference(sorted Field[]) */ - private static final WeakHashMap fieldMap = new WeakHashMap(17); - /** Comparator for sorting fields */ - private static final FieldComparator comparator = new FieldComparator(); - private static final ServiceType[] empty = {}; - private static final Class[] noArg = new Class[0]; - - private ClassMapper() {} - - /** Returns a ServiceTypeBase descriptor for a class. */ - public static ServiceTypeBase toServiceTypeBase(Class cls) - throws MarshalException - { - synchronized (serviceMap) { - return toServiceTypeBase(cls, true); - } - } - - /** - * Returns a ServiceTypeBase descriptor for a class. If needCodebase - * is false, the returned descriptor's codebase may be null. - */ - private static ServiceTypeBase toServiceTypeBase(Class cls, - boolean needCodebase) - throws MarshalException - { - if (cls == null) - return null; - SoftReference cref = (SoftReference)serviceMap.get(cls); - ServiceTypeBase stype = null; - if (cref != null) - stype = (ServiceTypeBase)cref.get(); - if (stype == null) { - stype = new ServiceTypeBase( - new ServiceType(cls, - toServiceType(cls.getSuperclass()), - toServiceType(cls.getInterfaces())), - null); - serviceMap.put(cls, new SoftReference(stype)); - } - if (needCodebase && stype.codebase == null) - stype.setCodebase(cls); - return stype; - } - - /** Returns a ServiceType descriptor for a class. */ - private static ServiceType toServiceType(Class cls) - throws MarshalException - { - if (cls != null) - return toServiceTypeBase(cls, false).type; - return null; - } - - /** Converts an array of Class to an array of ServiceType. */ - public static ServiceType[] toServiceType(Class[] classes) - throws MarshalException - { - if (classes == null) - return null; - if (classes.length == 0) - return empty; - ServiceType[] stypes = new ServiceType[classes.length]; - synchronized (serviceMap) { - for (int i = classes.length; --i >= 0; ) { - stypes[i] = toServiceType(classes[i]); - } - } - return stypes; - } - - /** Returns a EntryClassBase descriptor for a class. */ - public static EntryClassBase toEntryClassBase(Class cls) - throws MarshalException - { - synchronized (entryMap) { - return toEntryClassBase(cls, true); - } - } - - /** - * Returns a EntryClassBase descriptor for a class. If base is false, - * the returned descriptor's codebase may be null, and the class need - * not be public and need not have a no-arg constructor. - */ - private static EntryClassBase toEntryClassBase(Class cls, boolean base) - throws MarshalException - { - if (cls == null) - return null; - SoftReference cref = (SoftReference)entryMap.get(cls); - EntryClassBase eclass = null; - if (cref != null) - eclass = (EntryClassBase)cref.get(); - if (eclass == null) { - if (base) { - if (!Modifier.isPublic(cls.getModifiers())) - throw new IllegalArgumentException("entry class " + - cls.getName() + - " is not public"); - try { - cls.getConstructor(noArg); - } catch (NoSuchMethodException e) { - throw new IllegalArgumentException("entry class " + - cls.getName() + - " does not have a public no-arg constructor"); - } - } - eclass = new EntryClassBase( - new EntryClass(cls, - toEntryClass(cls.getSuperclass())), - null); - entryMap.put(cls, new SoftReference(eclass)); - } - if (base && eclass.codebase == null) - eclass.setCodebase(cls); - return eclass; - } - - /** Returns an EntryClass descriptor for a class. */ - private static EntryClass toEntryClass(Class cls) throws MarshalException { - if (cls != null) - return toEntryClassBase(cls, false).eclass; - return null; - } - - /** Field of an Entry class, with marshalling information */ - static class EntryField { - /** Field for the field */ - public final Field field; - /** - * True if instances of the field need to be converted - * to MarshalledWrapper. False if the type of the field - * is String, Integer, Boolean, Character, Long, Float, - * Double, Byte, or Short. - */ - public final boolean marshal; - - /** - * Basic constructor. - */ - public EntryField(Field field) { - this.field = field; - Class c = field.getType(); - marshal = !(c == String.class || - c == Integer.class || - c == Boolean.class || - c == Character.class || - c == Long.class || - c == Float.class || - c == Double.class || - c == Byte.class || - c == Short.class); - } - } - - /** - * Returns public fields, in super to subclass order, sorted - * alphabetically within a given class. - */ - public static EntryField[] getFields(Class cls) { - synchronized (fieldMap) { - SoftReference cref = (SoftReference)fieldMap.get(cls); - EntryField[] efields = null; - if (cref != null) - efields = (EntryField[])cref.get(); - if (efields == null) { - Field[] fields = cls.getFields(); - Arrays.sort(fields, comparator); - int len = 0; - for (int i = 0; i < fields.length; i++) { - if ((fields[i].getModifiers() & - (Modifier.STATIC|Modifier.FINAL|Modifier.TRANSIENT)) - == 0) - { - if (fields[i].getType().isPrimitive()) - throw new IllegalArgumentException("entry class " + - cls.getName() + - " has a primitive field"); - fields[len++] = fields[i]; - } - } - efields = new EntryField[len]; - while (--len >= 0) { - efields[len] = new EntryField(fields[len]); - } - fieldMap.put(cls, new SoftReference(efields)); - } - return efields; - } - } - - /** Comparator for sorting fields. */ - private static class FieldComparator implements Comparator { - public FieldComparator() {} - - /** Super before subclass, alphabetical within a given class */ - public int compare(Object o1, Object o2) { - Field f1 = (Field)o1; - Field f2 = (Field)o2; - if (f1 == f2) - return 0; - if (f1.getDeclaringClass() == f2.getDeclaringClass()) - return f1.getName().compareTo(f2.getName()); - if (f1.getDeclaringClass().isAssignableFrom( - f2.getDeclaringClass())) - return -1; - return 1; - } - } -} +/* + * 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.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.util.Arrays; +import java.util.Comparator; +import java.util.WeakHashMap; +import java.lang.ref.SoftReference; +import java.rmi.MarshalException; + +/** + * Maps Class to ServiceType/Base, Class to EntryClass/Base, and Class to + * Field[], with caching for efficiency. + * + * @author Sun Microsystems, Inc. + * + */ +class ClassMapper { + + /** Weak Map from Class to SoftReference(ServiceTypeBase) */ + private static final WeakHashMap serviceMap = new WeakHashMap(23); + /** Weak Map from Class to SoftReference(EntryClassBase) */ + private static final WeakHashMap entryMap = new WeakHashMap(17); + /** Weak Map from Class to SoftReference(sorted Field[]) */ + private static final WeakHashMap fieldMap = new WeakHashMap(17); + /** Comparator for sorting fields */ + private static final FieldComparator comparator = new FieldComparator(); + private static final ServiceType[] empty = {}; + private static final Class[] noArg = new Class[0]; + + private ClassMapper() {} + + /** Returns a ServiceTypeBase descriptor for a class. */ + public static ServiceTypeBase toServiceTypeBase(Class cls) + throws MarshalException + { + synchronized (serviceMap) { + return toServiceTypeBase(cls, true); + } + } + + /** + * Returns a ServiceTypeBase descriptor for a class. If needCodebase + * is false, the returned descriptor's codebase may be null. + */ + private static ServiceTypeBase toServiceTypeBase(Class cls, + boolean needCodebase) + throws MarshalException + { + if (cls == null) + return null; + SoftReference cref = (SoftReference)serviceMap.get(cls); + ServiceTypeBase stype = null; + if (cref != null) + stype = (ServiceTypeBase)cref.get(); + if (stype == null) { + stype = new ServiceTypeBase( + new ServiceType(cls, + toServiceType(cls.getSuperclass()), + toServiceType(cls.getInterfaces())), + null); + serviceMap.put(cls, new SoftReference(stype)); + } + if (needCodebase && stype.codebase == null) + stype.setCodebase(cls); + return stype; + } + + /** Returns a ServiceType descriptor for a class. */ + private static ServiceType toServiceType(Class cls) + throws MarshalException + { + if (cls != null) + return toServiceTypeBase(cls, false).type; + return null; + } + + /** Converts an array of Class to an array of ServiceType. */ + public static ServiceType[] toServiceType(Class[] classes) + throws MarshalException + { + if (classes == null) + return null; + if (classes.length == 0) + return empty; + ServiceType[] stypes = new ServiceType[classes.length]; + synchronized (serviceMap) { + for (int i = classes.length; --i >= 0; ) { + stypes[i] = toServiceType(classes[i]); + } + } + return stypes; + } + + /** Returns a EntryClassBase descriptor for a class. */ + public static EntryClassBase toEntryClassBase(Class cls) + throws MarshalException + { + synchronized (entryMap) { + return toEntryClassBase(cls, true); + } + } + + /** + * Returns a EntryClassBase descriptor for a class. If base is false, + * the returned descriptor's codebase may be null, and the class need + * not be public and need not have a no-arg constructor. + */ + private static EntryClassBase toEntryClassBase(Class cls, boolean base) + throws MarshalException + { + if (cls == null) + return null; + SoftReference cref = (SoftReference)entryMap.get(cls); + EntryClassBase eclass = null; + if (cref != null) + eclass = (EntryClassBase)cref.get(); + if (eclass == null) { + if (base) { + if (!Modifier.isPublic(cls.getModifiers())) + throw new IllegalArgumentException("entry class " + + cls.getName() + + " is not public"); + try { + cls.getConstructor(noArg); + } catch (NoSuchMethodException e) { + throw new IllegalArgumentException("entry class " + + cls.getName() + + " does not have a public no-arg constructor"); + } + } + eclass = new EntryClassBase( + new EntryClass(cls, + toEntryClass(cls.getSuperclass())), + null); + entryMap.put(cls, new SoftReference(eclass)); + } + if (base && eclass.codebase == null) + eclass.setCodebase(cls); + return eclass; + } + + /** Returns an EntryClass descriptor for a class. */ + private static EntryClass toEntryClass(Class cls) throws MarshalException { + if (cls != null) + return toEntryClassBase(cls, false).eclass; + return null; + } + + /** Field of an Entry class, with marshalling information */ + static class EntryField { + /** Field for the field */ + public final Field field; + /** + * True if instances of the field need to be converted + * to MarshalledWrapper. False if the type of the field + * is String, Integer, Boolean, Character, Long, Float, + * Double, Byte, or Short. + */ + public final boolean marshal; + + /** + * Basic constructor. + */ + public EntryField(Field field) { + this.field = field; + Class c = field.getType(); + marshal = !(c == String.class || + c == Integer.class || + c == Boolean.class || + c == Character.class || + c == Long.class || + c == Float.class || + c == Double.class || + c == Byte.class || + c == Short.class); + } + } + + /** + * Returns public fields, in super to subclass order, sorted + * alphabetically within a given class. + */ + public static EntryField[] getFields(Class cls) { + synchronized (fieldMap) { + SoftReference cref = (SoftReference)fieldMap.get(cls); + EntryField[] efields = null; + if (cref != null) + efields = (EntryField[])cref.get(); + if (efields == null) { + Field[] fields = cls.getFields(); + Arrays.sort(fields, comparator); + int len = 0; + for (int i = 0; i < fields.length; i++) { + if ((fields[i].getModifiers() & + (Modifier.STATIC|Modifier.FINAL|Modifier.TRANSIENT)) + == 0) + { + if (fields[i].getType().isPrimitive()) + throw new IllegalArgumentException("entry class " + + cls.getName() + + " has a primitive field"); + fields[len++] = fields[i]; + } + } + efields = new EntryField[len]; + while (--len >= 0) { + efields[len] = new EntryField(fields[len]); + } + fieldMap.put(cls, new SoftReference(efields)); + } + return efields; + } + } + + /** Comparator for sorting fields. */ + private static class FieldComparator implements Comparator { + public FieldComparator() {} + + /** Super before subclass, alphabetical within a given class */ + public int compare(Object o1, Object o2) { + Field f1 = (Field)o1; + Field f2 = (Field)o2; + if (f1 == f2) + return 0; + if (f1.getDeclaringClass() == f2.getDeclaringClass()) + return f1.getName().compareTo(f2.getName()); + if (f1.getDeclaringClass().isAssignableFrom( + f2.getDeclaringClass())) + return -1; + return 1; + } + } +}
Modified: river/jtsk/modules/modularize/apache-river/river-services/reggie/reggie-dl/src/main/java/org/apache/river/reggie/proxy/ConstrainableAdminProxy.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/ConstrainableAdminProxy.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/ConstrainableAdminProxy.java (original) +++ river/jtsk/modules/modularize/apache-river/river-services/reggie/reggie-dl/src/main/java/org/apache/river/reggie/proxy/ConstrainableAdminProxy.java Sun Jul 5 11:41:39 2020 @@ -1,174 +1,174 @@ -/* - * 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.ConstrainableProxyUtil; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.lang.reflect.Method; -import net.jini.admin.JoinAdmin; -import net.jini.core.constraint.MethodConstraints; -import net.jini.core.constraint.RemoteMethodControl; -import net.jini.core.discovery.LookupLocator; -import net.jini.core.entry.Entry; -import net.jini.core.lookup.ServiceID; -import net.jini.lookup.DiscoveryAdmin; -import net.jini.security.proxytrust.ProxyTrustIterator; -import net.jini.security.proxytrust.SingletonProxyTrustIterator; - -/** - * AdminProxy subclass that supports constraints. - * - * @author Sun Microsystems, Inc. - * - */ -final class ConstrainableAdminProxy - extends AdminProxy implements RemoteMethodControl -{ - private static final long serialVersionUID = 2L; - - /** Mappings between public admin methods and Registrar methods */ - private static final Method[] methodMappings = { - Util.getMethod(DiscoveryAdmin.class, "addMemberGroups", - new Class[]{ String[].class }), - Util.getMethod(DiscoveryAdmin.class, "addMemberGroups", - new Class[]{ String[].class }), - - Util.getMethod(DiscoveryAdmin.class, "getMemberGroups", new Class[0]), - Util.getMethod(DiscoveryAdmin.class, "getMemberGroups", new Class[0]), - - Util.getMethod(DiscoveryAdmin.class, "getUnicastPort", new Class[0]), - Util.getMethod(DiscoveryAdmin.class, "getUnicastPort", new Class[0]), - - Util.getMethod(DiscoveryAdmin.class, "removeMemberGroups", - new Class[]{ String[].class }), - Util.getMethod(DiscoveryAdmin.class, "removeMemberGroups", - new Class[]{ String[].class }), - - Util.getMethod(DiscoveryAdmin.class, "setMemberGroups", - new Class[]{ String[].class }), - Util.getMethod(DiscoveryAdmin.class, "setMemberGroups", - new Class[]{ String[].class }), - - Util.getMethod(DiscoveryAdmin.class, "setUnicastPort", - new Class[]{ int.class }), - Util.getMethod(DiscoveryAdmin.class, "setUnicastPort", - new Class[]{ int.class }), - - Util.getMethod(JoinAdmin.class, "addLookupAttributes", - new Class[]{ Entry[].class }), - Util.getMethod(JoinAdmin.class, "addLookupAttributes", - new Class[]{ Entry[].class }), - - Util.getMethod(JoinAdmin.class, "addLookupGroups", - new Class[]{ String[].class }), - Util.getMethod(JoinAdmin.class, "addLookupGroups", - new Class[]{ String[].class }), - - Util.getMethod(JoinAdmin.class, "addLookupLocators", - new Class[]{ LookupLocator[].class }), - Util.getMethod(JoinAdmin.class, "addLookupLocators", - new Class[]{ LookupLocator[].class }), - - Util.getMethod(JoinAdmin.class, "getLookupAttributes", new Class[0]), - Util.getMethod(JoinAdmin.class, "getLookupAttributes", new Class[0]), - - Util.getMethod(JoinAdmin.class, "getLookupGroups", new Class[0]), - Util.getMethod(JoinAdmin.class, "getLookupGroups", new Class[0]), - - Util.getMethod(JoinAdmin.class, "getLookupLocators", new Class[0]), - Util.getMethod(JoinAdmin.class, "getLookupLocators", new Class[0]), - - Util.getMethod(JoinAdmin.class, "modifyLookupAttributes", - new Class[]{ Entry[].class, Entry[].class }), - Util.getMethod(JoinAdmin.class, "modifyLookupAttributes", - new Class[]{ Entry[].class, Entry[].class }), - - Util.getMethod(JoinAdmin.class, "removeLookupGroups", - new Class[]{ String[].class }), - Util.getMethod(JoinAdmin.class, "removeLookupGroups", - new Class[]{ String[].class }), - - Util.getMethod(JoinAdmin.class, "removeLookupLocators", - new Class[]{ LookupLocator[].class }), - Util.getMethod(JoinAdmin.class, "removeLookupLocators", - new Class[]{ LookupLocator[].class }), - - Util.getMethod(JoinAdmin.class, "setLookupGroups", - new Class[]{ String[].class }), - Util.getMethod(JoinAdmin.class, "setLookupGroups", - new Class[]{ String[].class }), - - Util.getMethod(JoinAdmin.class, "setLookupLocators", - new Class[]{ LookupLocator[].class }), - Util.getMethod(JoinAdmin.class, "setLookupLocators", - new Class[]{ LookupLocator[].class }), - - Util.getMethod(DestroyAdmin.class, "destroy", new Class[0]), - Util.getMethod(DestroyAdmin.class, "destroy", new Class[0]) - }; - - /** Client constraints for this proxy, or null */ - private final MethodConstraints constraints; - - /** - * Creates new ConstrainableAdminProxy with given server reference, service - * ID and client constraints. - */ - ConstrainableAdminProxy(Registrar server, - ServiceID registrarID, - MethodConstraints constraints) - { - super((Registrar) ((RemoteMethodControl) server).setConstraints( - ConstrainableProxyUtil.translateConstraints( - constraints, methodMappings)), - registrarID); - this.constraints = constraints; - } - - // javadoc inherited from RemoteMethodControl.setConstraints - public RemoteMethodControl setConstraints(MethodConstraints constraints) { - return new ConstrainableAdminProxy(server, registrarID, constraints); - } - - // javadoc inherited from RemoteMethodControl.getConstraints - public MethodConstraints getConstraints() { - return constraints; - } - - /** - * Returns iterator used by ProxyTrustVerifier to retrieve a trust verifier - * for this object. - */ - private ProxyTrustIterator getProxyTrustIterator() { - return new SingletonProxyTrustIterator(server); - } - - /** - * Verifies that the client constraints for this proxy are consistent with - * those set on the underlying server ref. - */ - private void readObject(ObjectInputStream in) - throws IOException, ClassNotFoundException - { - in.defaultReadObject(); - ConstrainableProxyUtil.verifyConsistentConstraints( - constraints, server, methodMappings); - } -} +/* + * 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.ConstrainableProxyUtil; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.lang.reflect.Method; +import net.jini.admin.JoinAdmin; +import net.jini.core.constraint.MethodConstraints; +import net.jini.core.constraint.RemoteMethodControl; +import net.jini.core.discovery.LookupLocator; +import net.jini.core.entry.Entry; +import net.jini.core.lookup.ServiceID; +import net.jini.lookup.DiscoveryAdmin; +import net.jini.security.proxytrust.ProxyTrustIterator; +import net.jini.security.proxytrust.SingletonProxyTrustIterator; + +/** + * AdminProxy subclass that supports constraints. + * + * @author Sun Microsystems, Inc. + * + */ +final class ConstrainableAdminProxy + extends AdminProxy implements RemoteMethodControl +{ + private static final long serialVersionUID = 2L; + + /** Mappings between public admin methods and Registrar methods */ + private static final Method[] methodMappings = { + Util.getMethod(DiscoveryAdmin.class, "addMemberGroups", + new Class[]{ String[].class }), + Util.getMethod(DiscoveryAdmin.class, "addMemberGroups", + new Class[]{ String[].class }), + + Util.getMethod(DiscoveryAdmin.class, "getMemberGroups", new Class[0]), + Util.getMethod(DiscoveryAdmin.class, "getMemberGroups", new Class[0]), + + Util.getMethod(DiscoveryAdmin.class, "getUnicastPort", new Class[0]), + Util.getMethod(DiscoveryAdmin.class, "getUnicastPort", new Class[0]), + + Util.getMethod(DiscoveryAdmin.class, "removeMemberGroups", + new Class[]{ String[].class }), + Util.getMethod(DiscoveryAdmin.class, "removeMemberGroups", + new Class[]{ String[].class }), + + Util.getMethod(DiscoveryAdmin.class, "setMemberGroups", + new Class[]{ String[].class }), + Util.getMethod(DiscoveryAdmin.class, "setMemberGroups", + new Class[]{ String[].class }), + + Util.getMethod(DiscoveryAdmin.class, "setUnicastPort", + new Class[]{ int.class }), + Util.getMethod(DiscoveryAdmin.class, "setUnicastPort", + new Class[]{ int.class }), + + Util.getMethod(JoinAdmin.class, "addLookupAttributes", + new Class[]{ Entry[].class }), + Util.getMethod(JoinAdmin.class, "addLookupAttributes", + new Class[]{ Entry[].class }), + + Util.getMethod(JoinAdmin.class, "addLookupGroups", + new Class[]{ String[].class }), + Util.getMethod(JoinAdmin.class, "addLookupGroups", + new Class[]{ String[].class }), + + Util.getMethod(JoinAdmin.class, "addLookupLocators", + new Class[]{ LookupLocator[].class }), + Util.getMethod(JoinAdmin.class, "addLookupLocators", + new Class[]{ LookupLocator[].class }), + + Util.getMethod(JoinAdmin.class, "getLookupAttributes", new Class[0]), + Util.getMethod(JoinAdmin.class, "getLookupAttributes", new Class[0]), + + Util.getMethod(JoinAdmin.class, "getLookupGroups", new Class[0]), + Util.getMethod(JoinAdmin.class, "getLookupGroups", new Class[0]), + + Util.getMethod(JoinAdmin.class, "getLookupLocators", new Class[0]), + Util.getMethod(JoinAdmin.class, "getLookupLocators", new Class[0]), + + Util.getMethod(JoinAdmin.class, "modifyLookupAttributes", + new Class[]{ Entry[].class, Entry[].class }), + Util.getMethod(JoinAdmin.class, "modifyLookupAttributes", + new Class[]{ Entry[].class, Entry[].class }), + + Util.getMethod(JoinAdmin.class, "removeLookupGroups", + new Class[]{ String[].class }), + Util.getMethod(JoinAdmin.class, "removeLookupGroups", + new Class[]{ String[].class }), + + Util.getMethod(JoinAdmin.class, "removeLookupLocators", + new Class[]{ LookupLocator[].class }), + Util.getMethod(JoinAdmin.class, "removeLookupLocators", + new Class[]{ LookupLocator[].class }), + + Util.getMethod(JoinAdmin.class, "setLookupGroups", + new Class[]{ String[].class }), + Util.getMethod(JoinAdmin.class, "setLookupGroups", + new Class[]{ String[].class }), + + Util.getMethod(JoinAdmin.class, "setLookupLocators", + new Class[]{ LookupLocator[].class }), + Util.getMethod(JoinAdmin.class, "setLookupLocators", + new Class[]{ LookupLocator[].class }), + + Util.getMethod(DestroyAdmin.class, "destroy", new Class[0]), + Util.getMethod(DestroyAdmin.class, "destroy", new Class[0]) + }; + + /** Client constraints for this proxy, or null */ + private final MethodConstraints constraints; + + /** + * Creates new ConstrainableAdminProxy with given server reference, service + * ID and client constraints. + */ + ConstrainableAdminProxy(Registrar server, + ServiceID registrarID, + MethodConstraints constraints) + { + super((Registrar) ((RemoteMethodControl) server).setConstraints( + ConstrainableProxyUtil.translateConstraints( + constraints, methodMappings)), + registrarID); + this.constraints = constraints; + } + + // javadoc inherited from RemoteMethodControl.setConstraints + public RemoteMethodControl setConstraints(MethodConstraints constraints) { + return new ConstrainableAdminProxy(server, registrarID, constraints); + } + + // javadoc inherited from RemoteMethodControl.getConstraints + public MethodConstraints getConstraints() { + return constraints; + } + + /** + * Returns iterator used by ProxyTrustVerifier to retrieve a trust verifier + * for this object. + */ + private ProxyTrustIterator getProxyTrustIterator() { + return new SingletonProxyTrustIterator(server); + } + + /** + * Verifies that the client constraints for this proxy are consistent with + * those set on the underlying server ref. + */ + private void readObject(ObjectInputStream in) + throws IOException, ClassNotFoundException + { + in.defaultReadObject(); + ConstrainableProxyUtil.verifyConsistentConstraints( + constraints, server, methodMappings); + } +} Modified: river/jtsk/modules/modularize/apache-river/river-services/reggie/reggie-dl/src/main/java/org/apache/river/reggie/proxy/ConstrainableEventLease.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/ConstrainableEventLease.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/ConstrainableEventLease.java (original) +++ river/jtsk/modules/modularize/apache-river/river-services/reggie/reggie-dl/src/main/java/org/apache/river/reggie/proxy/ConstrainableEventLease.java Sun Jul 5 11:41:39 2020 @@ -1,131 +1,131 @@ -/* - * 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.ConstrainableProxyUtil; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.lang.reflect.Method; -import net.jini.core.constraint.MethodConstraints; -import net.jini.core.constraint.RemoteMethodControl; -import net.jini.core.lease.Lease; -import net.jini.core.lease.LeaseMap; -import net.jini.core.lookup.ServiceID; -import net.jini.id.Uuid; -import net.jini.security.proxytrust.ProxyTrustIterator; -import net.jini.security.proxytrust.SingletonProxyTrustIterator; - -/** - * EventLease subclass that supports constraints. - * - * @author Sun Microsystems, Inc. - * - */ -final class ConstrainableEventLease - extends EventLease implements RemoteMethodControl -{ - private static final long serialVersionUID = 2L; - - /** Mappings between Lease and Registrar methods */ - private static final Method[] methodMappings = { - Util.getMethod(Lease.class, "cancel", new Class[0]), - Util.getMethod(Registrar.class, "cancelEventLease", - new Class[]{ long.class, Uuid.class }), - - Util.getMethod(Lease.class, "renew", new Class[]{ long.class }), - Util.getMethod(Registrar.class, "renewEventLease", - new Class[]{ long.class, Uuid.class, long.class }) - }; - - /** Client constraints for this proxy, or null */ - private final MethodConstraints constraints; - - /** - * Creates new ConstrainableEventLease with given server reference, event - * and lease IDs, expiration time and client constraints. - */ - ConstrainableEventLease(Registrar server, - ServiceID registrarID, - long eventID, - Uuid leaseID, - long expiration, - MethodConstraints constraints) - { - super((Registrar) ((RemoteMethodControl) server).setConstraints( - ConstrainableProxyUtil.translateConstraints( - constraints, methodMappings)), - registrarID, - eventID, - leaseID, - expiration); - this.constraints = constraints; - } - - /** - * Creates a constraint-aware lease map. - */ - public LeaseMap<? extends Lease,Long> createLeaseMap(long duration) { - return new ConstrainableRegistrarLeaseMap(this, duration); - } - - /** - * Two leases can be batched if they are both RegistrarLeases, share the - * same server, and have compatible constraints. - */ - public boolean canBatch(Lease lease) { - if (!(super.canBatch(lease) && lease instanceof RemoteMethodControl)) { - return false; - } - return ConstrainableProxyUtil.equivalentConstraints( - ((RemoteMethodControl) lease).getConstraints(), - ConstrainableProxyUtil.translateConstraints( - constraints, ConstrainableRegistrarLeaseMap.methodMappings), - ConstrainableRegistrarLeaseMap.methodMappings); - } - - // javadoc inherited from RemoteMethodControl.setConstraints - public RemoteMethodControl setConstraints(MethodConstraints constraints) { - return new ConstrainableEventLease( - server, registrarID, eventID, leaseID, expiration, constraints); - } - - // javadoc inherited from RemoteMethodControl.getConstraints - public MethodConstraints getConstraints() { - return constraints; - } - - /** - * Returns iterator used by ProxyTrustVerifier to retrieve a trust verifier - * for this object. - */ - private ProxyTrustIterator getProxyTrustIterator() { - return new SingletonProxyTrustIterator(server); - } - - /** - * Verifies that the client constraints for this proxy are consistent with - * those set on the underlying server ref. - */ - private void readObject(ObjectInputStream in) - throws IOException, ClassNotFoundException - { - in.defaultReadObject(); - ConstrainableProxyUtil.verifyConsistentConstraints( - constraints, server, methodMappings); - } -} +/* + * 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.ConstrainableProxyUtil; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.lang.reflect.Method; +import net.jini.core.constraint.MethodConstraints; +import net.jini.core.constraint.RemoteMethodControl; +import net.jini.core.lease.Lease; +import net.jini.core.lease.LeaseMap; +import net.jini.core.lookup.ServiceID; +import net.jini.id.Uuid; +import net.jini.security.proxytrust.ProxyTrustIterator; +import net.jini.security.proxytrust.SingletonProxyTrustIterator; + +/** + * EventLease subclass that supports constraints. + * + * @author Sun Microsystems, Inc. + * + */ +final class ConstrainableEventLease + extends EventLease implements RemoteMethodControl +{ + private static final long serialVersionUID = 2L; + + /** Mappings between Lease and Registrar methods */ + private static final Method[] methodMappings = { + Util.getMethod(Lease.class, "cancel", new Class[0]), + Util.getMethod(Registrar.class, "cancelEventLease", + new Class[]{ long.class, Uuid.class }), + + Util.getMethod(Lease.class, "renew", new Class[]{ long.class }), + Util.getMethod(Registrar.class, "renewEventLease", + new Class[]{ long.class, Uuid.class, long.class }) + }; + + /** Client constraints for this proxy, or null */ + private final MethodConstraints constraints; + + /** + * Creates new ConstrainableEventLease with given server reference, event + * and lease IDs, expiration time and client constraints. + */ + ConstrainableEventLease(Registrar server, + ServiceID registrarID, + long eventID, + Uuid leaseID, + long expiration, + MethodConstraints constraints) + { + super((Registrar) ((RemoteMethodControl) server).setConstraints( + ConstrainableProxyUtil.translateConstraints( + constraints, methodMappings)), + registrarID, + eventID, + leaseID, + expiration); + this.constraints = constraints; + } + + /** + * Creates a constraint-aware lease map. + */ + public LeaseMap<? extends Lease,Long> createLeaseMap(long duration) { + return new ConstrainableRegistrarLeaseMap(this, duration); + } + + /** + * Two leases can be batched if they are both RegistrarLeases, share the + * same server, and have compatible constraints. + */ + public boolean canBatch(Lease lease) { + if (!(super.canBatch(lease) && lease instanceof RemoteMethodControl)) { + return false; + } + return ConstrainableProxyUtil.equivalentConstraints( + ((RemoteMethodControl) lease).getConstraints(), + ConstrainableProxyUtil.translateConstraints( + constraints, ConstrainableRegistrarLeaseMap.methodMappings), + ConstrainableRegistrarLeaseMap.methodMappings); + } + + // javadoc inherited from RemoteMethodControl.setConstraints + public RemoteMethodControl setConstraints(MethodConstraints constraints) { + return new ConstrainableEventLease( + server, registrarID, eventID, leaseID, expiration, constraints); + } + + // javadoc inherited from RemoteMethodControl.getConstraints + public MethodConstraints getConstraints() { + return constraints; + } + + /** + * Returns iterator used by ProxyTrustVerifier to retrieve a trust verifier + * for this object. + */ + private ProxyTrustIterator getProxyTrustIterator() { + return new SingletonProxyTrustIterator(server); + } + + /** + * Verifies that the client constraints for this proxy are consistent with + * those set on the underlying server ref. + */ + private void readObject(ObjectInputStream in) + throws IOException, ClassNotFoundException + { + in.defaultReadObject(); + ConstrainableProxyUtil.verifyConsistentConstraints( + constraints, server, methodMappings); + } +} Modified: river/jtsk/modules/modularize/apache-river/river-services/reggie/reggie-dl/src/main/java/org/apache/river/reggie/proxy/ConstrainableRegistrarLeaseMap.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/ConstrainableRegistrarLeaseMap.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/ConstrainableRegistrarLeaseMap.java (original) +++ river/jtsk/modules/modularize/apache-river/river-services/reggie/reggie-dl/src/main/java/org/apache/river/reggie/proxy/ConstrainableRegistrarLeaseMap.java Sun Jul 5 11:41:39 2020 @@ -1,74 +1,74 @@ -/* - * 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.ConstrainableProxyUtil; -import java.lang.reflect.Method; -import net.jini.core.constraint.RemoteMethodControl; -import net.jini.core.lease.Lease; -import net.jini.id.Uuid; - -/** - * RegistrarLeaseMap subclass that supports constraints. - * - * @author Sun Microsystems, Inc. - * - */ -final class ConstrainableRegistrarLeaseMap extends RegistrarLeaseMap { - - /** Mappings between Lease methods and Registrar lease-batching methods */ - static final Method[] methodMappings = { - Util.getMethod(Lease.class, "cancel", new Class[0]), - Util.getMethod(Registrar.class, "cancelLeases", - new Class[]{ Object[].class, Uuid[].class }), - - Util.getMethod(Lease.class, "renew", new Class[]{ long.class }), - Util.getMethod(Registrar.class, "renewLeases", - new Class[]{ Object[].class, Uuid[].class, - long[].class }) - }; - - /** - * Constructs lease map containing a mapping from the given constrainable - * lease to the specified duration. - */ - ConstrainableRegistrarLeaseMap(RegistrarLease lease, long duration) { - super((Registrar) - ((RemoteMethodControl) lease.getRegistrar()).setConstraints( - ConstrainableProxyUtil.translateConstraints( - ((RemoteMethodControl) lease).getConstraints(), - methodMappings)), - lease, - duration); - } - - /** - * Only allow leases permitted by RegistrarLeaseMap with compatible - * constraints. - */ - public boolean canContainKey(Object key) { - if (!(super.canContainKey(key) && key instanceof RemoteMethodControl)) - { - return false; - } - return ConstrainableProxyUtil.equivalentConstraints( - ((RemoteMethodControl) key).getConstraints(), - ((RemoteMethodControl) server).getConstraints(), - methodMappings); - } -} +/* + * 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.ConstrainableProxyUtil; +import java.lang.reflect.Method; +import net.jini.core.constraint.RemoteMethodControl; +import net.jini.core.lease.Lease; +import net.jini.id.Uuid; + +/** + * RegistrarLeaseMap subclass that supports constraints. + * + * @author Sun Microsystems, Inc. + * + */ +final class ConstrainableRegistrarLeaseMap extends RegistrarLeaseMap { + + /** Mappings between Lease methods and Registrar lease-batching methods */ + static final Method[] methodMappings = { + Util.getMethod(Lease.class, "cancel", new Class[0]), + Util.getMethod(Registrar.class, "cancelLeases", + new Class[]{ Object[].class, Uuid[].class }), + + Util.getMethod(Lease.class, "renew", new Class[]{ long.class }), + Util.getMethod(Registrar.class, "renewLeases", + new Class[]{ Object[].class, Uuid[].class, + long[].class }) + }; + + /** + * Constructs lease map containing a mapping from the given constrainable + * lease to the specified duration. + */ + ConstrainableRegistrarLeaseMap(RegistrarLease lease, long duration) { + super((Registrar) + ((RemoteMethodControl) lease.getRegistrar()).setConstraints( + ConstrainableProxyUtil.translateConstraints( + ((RemoteMethodControl) lease).getConstraints(), + methodMappings)), + lease, + duration); + } + + /** + * Only allow leases permitted by RegistrarLeaseMap with compatible + * constraints. + */ + public boolean canContainKey(Object key) { + if (!(super.canContainKey(key) && key instanceof RemoteMethodControl)) + { + return false; + } + return ConstrainableProxyUtil.equivalentConstraints( + ((RemoteMethodControl) key).getConstraints(), + ((RemoteMethodControl) server).getConstraints(), + methodMappings); + } +} Modified: river/jtsk/modules/modularize/apache-river/river-services/reggie/reggie-dl/src/main/java/org/apache/river/reggie/proxy/ConstrainableRegistrarProxy.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/ConstrainableRegistrarProxy.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/ConstrainableRegistrarProxy.java (original) +++ river/jtsk/modules/modularize/apache-river/river-services/reggie/reggie-dl/src/main/java/org/apache/river/reggie/proxy/ConstrainableRegistrarProxy.java Sun Jul 5 11:41:39 2020 @@ -1,147 +1,147 @@ -/* - * 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.ConstrainableProxyUtil; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.lang.reflect.Method; -import java.rmi.MarshalledObject; -import net.jini.admin.Administrable; -import net.jini.core.constraint.MethodConstraints; -import net.jini.core.constraint.RemoteMethodControl; -import net.jini.core.event.RemoteEventListener; -import net.jini.core.lookup.ServiceID; -import net.jini.core.lookup.ServiceItem; -import net.jini.core.lookup.ServiceRegistrar; -import net.jini.core.lookup.ServiceTemplate; -import net.jini.security.proxytrust.ProxyTrustIterator; -import net.jini.security.proxytrust.SingletonProxyTrustIterator; - -/** - * RegistrarProxy subclass that supports constraints. - * - * @author Sun Microsystems, Inc. - * - */ -final class ConstrainableRegistrarProxy - extends RegistrarProxy implements RemoteMethodControl -{ - private static final long serialVersionUID = 2L; - - /** Mappings between ServiceRegistrar and Registrar methods */ - private static final Method[] methodMappings = { - Util.getMethod(ServiceRegistrar.class, "getEntryClasses", - new Class[]{ ServiceTemplate.class }), - Util.getMethod(Registrar.class, "getEntryClasses", - new Class[]{ Template.class }), - - Util.getMethod(ServiceRegistrar.class, "getFieldValues", - new Class[]{ ServiceTemplate.class, int.class, - String.class }), - Util.getMethod(Registrar.class, "getFieldValues", - new Class[]{ Template.class, int.class, int.class }), - - Util.getMethod(ServiceRegistrar.class, "getGroups", new Class[0]), - Util.getMethod(Registrar.class, "getMemberGroups", new Class[0]), - - Util.getMethod(ServiceRegistrar.class, "getLocator", new Class[0]), - Util.getMethod(Registrar.class, "getLocator", new Class[0]), - - Util.getMethod(ServiceRegistrar.class, "getServiceTypes", - new Class[]{ ServiceTemplate.class, String.class }), - Util.getMethod(Registrar.class, "getServiceTypes", - new Class[]{ Template.class, String.class }), - - Util.getMethod(ServiceRegistrar.class, "lookup", - new Class[]{ ServiceTemplate.class }), - Util.getMethod(Registrar.class, "lookup", - new Class[]{ Template.class }), - - Util.getMethod(ServiceRegistrar.class, "lookup", - new Class[]{ ServiceTemplate.class, int.class }), - Util.getMethod(Registrar.class, "lookup", - new Class[]{ Template.class, int.class }), - - Util.getMethod(ServiceRegistrar.class, "notify", - new Class[]{ ServiceTemplate.class, int.class, - RemoteEventListener.class, - MarshalledObject.class, long.class }), - Util.getMethod(Registrar.class, "notify", - new Class[]{ Template.class, int.class, - RemoteEventListener.class, - MarshalledObject.class, long.class }), - - Util.getMethod(ServiceRegistrar.class, "register", - new Class[]{ ServiceItem.class, long.class }), - Util.getMethod(Registrar.class, "register", - new Class[]{ Item.class, long.class }), - - Util.getMethod(Administrable.class, "getAdmin", new Class[0]), - Util.getMethod(Administrable.class, "getAdmin", new Class[0]) - }; - - /** Client constraints for this proxy, or null */ - private final MethodConstraints constraints; - - /** - * Creates new ConstrainableRegistrarProxy with given server reference, - * service ID and client constraints. - */ - ConstrainableRegistrarProxy(Registrar server, - ServiceID registrarID, - MethodConstraints constraints) - { - super((Registrar) ((RemoteMethodControl) server).setConstraints( - ConstrainableProxyUtil.translateConstraints( - constraints, methodMappings)), - registrarID); - this.constraints = constraints; - } - - // javadoc inherited from RemoteMethodControl.setConstraints - public RemoteMethodControl setConstraints(MethodConstraints constraints) { - return new ConstrainableRegistrarProxy( - server, registrarID, constraints); - } - - // javadoc inherited from RemoteMethodControl.getConstraints - public MethodConstraints getConstraints() { - return constraints; - } - - /** - * Returns iterator used by ProxyTrustVerifier to retrieve a trust verifier - * for this object. - */ - private ProxyTrustIterator getProxyTrustIterator() { - return new SingletonProxyTrustIterator(server); - } - - /** - * Verifies that the client constraints for this proxy are consistent with - * those set on the underlying server ref. - */ - private void readObject(ObjectInputStream in) - throws IOException, ClassNotFoundException - { - in.defaultReadObject(); - ConstrainableProxyUtil.verifyConsistentConstraints( - constraints, server, methodMappings); - } -} +/* + * 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.ConstrainableProxyUtil; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.lang.reflect.Method; +import java.rmi.MarshalledObject; +import net.jini.admin.Administrable; +import net.jini.core.constraint.MethodConstraints; +import net.jini.core.constraint.RemoteMethodControl; +import net.jini.core.event.RemoteEventListener; +import net.jini.core.lookup.ServiceID; +import net.jini.core.lookup.ServiceItem; +import net.jini.core.lookup.ServiceRegistrar; +import net.jini.core.lookup.ServiceTemplate; +import net.jini.security.proxytrust.ProxyTrustIterator; +import net.jini.security.proxytrust.SingletonProxyTrustIterator; + +/** + * RegistrarProxy subclass that supports constraints. + * + * @author Sun Microsystems, Inc. + * + */ +final class ConstrainableRegistrarProxy + extends RegistrarProxy implements RemoteMethodControl +{ + private static final long serialVersionUID = 2L; + + /** Mappings between ServiceRegistrar and Registrar methods */ + private static final Method[] methodMappings = { + Util.getMethod(ServiceRegistrar.class, "getEntryClasses", + new Class[]{ ServiceTemplate.class }), + Util.getMethod(Registrar.class, "getEntryClasses", + new Class[]{ Template.class }), + + Util.getMethod(ServiceRegistrar.class, "getFieldValues", + new Class[]{ ServiceTemplate.class, int.class, + String.class }), + Util.getMethod(Registrar.class, "getFieldValues", + new Class[]{ Template.class, int.class, int.class }), + + Util.getMethod(ServiceRegistrar.class, "getGroups", new Class[0]), + Util.getMethod(Registrar.class, "getMemberGroups", new Class[0]), + + Util.getMethod(ServiceRegistrar.class, "getLocator", new Class[0]), + Util.getMethod(Registrar.class, "getLocator", new Class[0]), + + Util.getMethod(ServiceRegistrar.class, "getServiceTypes", + new Class[]{ ServiceTemplate.class, String.class }), + Util.getMethod(Registrar.class, "getServiceTypes", + new Class[]{ Template.class, String.class }), + + Util.getMethod(ServiceRegistrar.class, "lookup", + new Class[]{ ServiceTemplate.class }), + Util.getMethod(Registrar.class, "lookup", + new Class[]{ Template.class }), + + Util.getMethod(ServiceRegistrar.class, "lookup", + new Class[]{ ServiceTemplate.class, int.class }), + Util.getMethod(Registrar.class, "lookup", + new Class[]{ Template.class, int.class }), + + Util.getMethod(ServiceRegistrar.class, "notify", + new Class[]{ ServiceTemplate.class, int.class, + RemoteEventListener.class, + MarshalledObject.class, long.class }), + Util.getMethod(Registrar.class, "notify", + new Class[]{ Template.class, int.class, + RemoteEventListener.class, + MarshalledObject.class, long.class }), + + Util.getMethod(ServiceRegistrar.class, "register", + new Class[]{ ServiceItem.class, long.class }), + Util.getMethod(Registrar.class, "register", + new Class[]{ Item.class, long.class }), + + Util.getMethod(Administrable.class, "getAdmin", new Class[0]), + Util.getMethod(Administrable.class, "getAdmin", new Class[0]) + }; + + /** Client constraints for this proxy, or null */ + private final MethodConstraints constraints; + + /** + * Creates new ConstrainableRegistrarProxy with given server reference, + * service ID and client constraints. + */ + ConstrainableRegistrarProxy(Registrar server, + ServiceID registrarID, + MethodConstraints constraints) + { + super((Registrar) ((RemoteMethodControl) server).setConstraints( + ConstrainableProxyUtil.translateConstraints( + constraints, methodMappings)), + registrarID); + this.constraints = constraints; + } + + // javadoc inherited from RemoteMethodControl.setConstraints + public RemoteMethodControl setConstraints(MethodConstraints constraints) { + return new ConstrainableRegistrarProxy( + server, registrarID, constraints); + } + + // javadoc inherited from RemoteMethodControl.getConstraints + public MethodConstraints getConstraints() { + return constraints; + } + + /** + * Returns iterator used by ProxyTrustVerifier to retrieve a trust verifier + * for this object. + */ + private ProxyTrustIterator getProxyTrustIterator() { + return new SingletonProxyTrustIterator(server); + } + + /** + * Verifies that the client constraints for this proxy are consistent with + * those set on the underlying server ref. + */ + private void readObject(ObjectInputStream in) + throws IOException, ClassNotFoundException + { + in.defaultReadObject(); + ConstrainableProxyUtil.verifyConsistentConstraints( + constraints, server, methodMappings); + } +} Modified: river/jtsk/modules/modularize/apache-river/river-services/reggie/reggie-dl/src/main/java/org/apache/river/reggie/proxy/ConstrainableRegistration.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/ConstrainableRegistration.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/ConstrainableRegistration.java (original) +++ river/jtsk/modules/modularize/apache-river/river-services/reggie/reggie-dl/src/main/java/org/apache/river/reggie/proxy/ConstrainableRegistration.java Sun Jul 5 11:41:39 2020 @@ -1,112 +1,112 @@ -/* - * 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.ConstrainableProxyUtil; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.lang.reflect.Method; -import net.jini.core.constraint.MethodConstraints; -import net.jini.core.constraint.RemoteMethodControl; -import net.jini.core.entry.Entry; -import net.jini.core.lookup.ServiceID; -import net.jini.core.lookup.ServiceRegistration; -import net.jini.id.Uuid; -import net.jini.security.proxytrust.ProxyTrustIterator; -import net.jini.security.proxytrust.SingletonProxyTrustIterator; - -/** - * Registration subclass that supports constraints. - * - * @author Sun Microsystems, Inc. - * - */ -final class ConstrainableRegistration - extends Registration implements RemoteMethodControl -{ - private static final long serialVersionUID = 2L; - - /** Mappings between ServiceRegistration and Registrar methods */ - private static final Method[] methodMappings = { - Util.getMethod(ServiceRegistration.class, "addAttributes", - new Class[]{ Entry[].class }), - Util.getMethod(Registrar.class, "addAttributes", - new Class[]{ ServiceID.class, Uuid.class, - EntryRep[].class }), - - Util.getMethod(ServiceRegistration.class, "modifyAttributes", - new Class[]{ Entry[].class, Entry[].class }), - Util.getMethod(Registrar.class, "modifyAttributes", - new Class[]{ ServiceID.class, Uuid.class, - EntryRep[].class, EntryRep[].class }), - - Util.getMethod(ServiceRegistration.class, "setAttributes", - new Class[]{ Entry[].class }), - Util.getMethod(Registrar.class, "setAttributes", - new Class[]{ ServiceID.class, Uuid.class, - EntryRep[].class }), - }; - - /** Client constraints for this proxy, or null */ - private final MethodConstraints constraints; - - /** - * Creates new ConstrainableRegistration with given server reference, - * service lease and client constraints. - */ - ConstrainableRegistration(Registrar server, - ServiceLease lease, - MethodConstraints constraints) - { - super((Registrar) ((RemoteMethodControl) server).setConstraints( - ConstrainableProxyUtil.translateConstraints( - constraints, methodMappings)), - lease); - this.constraints = constraints; - } - - // javadoc inherited from RemoteMethodControl.setConstraints - public RemoteMethodControl setConstraints(MethodConstraints constraints) { - return new ConstrainableRegistration(server, lease, constraints); - } - - // javadoc inherited from RemoteMethodControl.getConstraints - public MethodConstraints getConstraints() { - return constraints; - } - - /** - * Returns iterator used by ProxyTrustVerifier to retrieve a trust verifier - * for this object. - */ - private ProxyTrustIterator getProxyTrustIterator() { - return new SingletonProxyTrustIterator(server); - } - - /** - * Verifies that the client constraints for this proxy are consistent with - * those set on the underlying server ref. - */ - private void readObject(ObjectInputStream in) - throws IOException, ClassNotFoundException - { - in.defaultReadObject(); - ConstrainableProxyUtil.verifyConsistentConstraints( - constraints, server, methodMappings); - } -} +/* + * 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.ConstrainableProxyUtil; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.lang.reflect.Method; +import net.jini.core.constraint.MethodConstraints; +import net.jini.core.constraint.RemoteMethodControl; +import net.jini.core.entry.Entry; +import net.jini.core.lookup.ServiceID; +import net.jini.core.lookup.ServiceRegistration; +import net.jini.id.Uuid; +import net.jini.security.proxytrust.ProxyTrustIterator; +import net.jini.security.proxytrust.SingletonProxyTrustIterator; + +/** + * Registration subclass that supports constraints. + * + * @author Sun Microsystems, Inc. + * + */ +final class ConstrainableRegistration + extends Registration implements RemoteMethodControl +{ + private static final long serialVersionUID = 2L; + + /** Mappings between ServiceRegistration and Registrar methods */ + private static final Method[] methodMappings = { + Util.getMethod(ServiceRegistration.class, "addAttributes", + new Class[]{ Entry[].class }), + Util.getMethod(Registrar.class, "addAttributes", + new Class[]{ ServiceID.class, Uuid.class, + EntryRep[].class }), + + Util.getMethod(ServiceRegistration.class, "modifyAttributes", + new Class[]{ Entry[].class, Entry[].class }), + Util.getMethod(Registrar.class, "modifyAttributes", + new Class[]{ ServiceID.class, Uuid.class, + EntryRep[].class, EntryRep[].class }), + + Util.getMethod(ServiceRegistration.class, "setAttributes", + new Class[]{ Entry[].class }), + Util.getMethod(Registrar.class, "setAttributes", + new Class[]{ ServiceID.class, Uuid.class, + EntryRep[].class }), + }; + + /** Client constraints for this proxy, or null */ + private final MethodConstraints constraints; + + /** + * Creates new ConstrainableRegistration with given server reference, + * service lease and client constraints. + */ + ConstrainableRegistration(Registrar server, + ServiceLease lease, + MethodConstraints constraints) + { + super((Registrar) ((RemoteMethodControl) server).setConstraints( + ConstrainableProxyUtil.translateConstraints( + constraints, methodMappings)), + lease); + this.constraints = constraints; + } + + // javadoc inherited from RemoteMethodControl.setConstraints + public RemoteMethodControl setConstraints(MethodConstraints constraints) { + return new ConstrainableRegistration(server, lease, constraints); + } + + // javadoc inherited from RemoteMethodControl.getConstraints + public MethodConstraints getConstraints() { + return constraints; + } + + /** + * Returns iterator used by ProxyTrustVerifier to retrieve a trust verifier + * for this object. + */ + private ProxyTrustIterator getProxyTrustIterator() { + return new SingletonProxyTrustIterator(server); + } + + /** + * Verifies that the client constraints for this proxy are consistent with + * those set on the underlying server ref. + */ + private void readObject(ObjectInputStream in) + throws IOException, ClassNotFoundException + { + in.defaultReadObject(); + ConstrainableProxyUtil.verifyConsistentConstraints( + constraints, server, methodMappings); + } +} Modified: river/jtsk/modules/modularize/apache-river/river-services/reggie/reggie-dl/src/main/java/org/apache/river/reggie/proxy/ConstrainableServiceLease.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/ConstrainableServiceLease.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/ConstrainableServiceLease.java (original) +++ river/jtsk/modules/modularize/apache-river/river-services/reggie/reggie-dl/src/main/java/org/apache/river/reggie/proxy/ConstrainableServiceLease.java Sun Jul 5 11:41:39 2020 @@ -1,131 +1,131 @@ -/* - * 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.ConstrainableProxyUtil; -import java.io.IOException; -import java.io.ObjectInputStream; -import java.lang.reflect.Method; -import net.jini.core.constraint.MethodConstraints; -import net.jini.core.constraint.RemoteMethodControl; -import net.jini.core.lease.Lease; -import net.jini.core.lease.LeaseMap; -import net.jini.core.lookup.ServiceID; -import net.jini.id.Uuid; -import net.jini.security.proxytrust.ProxyTrustIterator; -import net.jini.security.proxytrust.SingletonProxyTrustIterator; - -/** - * ServiceLease subclass that supports constraints. - * - * @author Sun Microsystems, Inc. - * - */ -final class ConstrainableServiceLease - extends ServiceLease implements RemoteMethodControl -{ - private static final long serialVersionUID = 2L; - - /** Mappings between Lease and Registrar methods */ - private static final Method[] methodMappings = { - Util.getMethod(Lease.class, "cancel", new Class[0]), - Util.getMethod(Registrar.class, "cancelServiceLease", - new Class[]{ ServiceID.class, Uuid.class }), - - Util.getMethod(Lease.class, "renew", new Class[]{ long.class }), - Util.getMethod(Registrar.class, "renewServiceLease", - new Class[]{ ServiceID.class, Uuid.class, long.class }) - }; - - /** Client constraints for this proxy, or null */ - private final MethodConstraints constraints; - - /** - * Creates new ConstrainableServiceLease with given server reference, event - * and lease IDs, expiration time and client constraints. - */ - ConstrainableServiceLease(Registrar server, - ServiceID registrarID, - ServiceID serviceID, - Uuid leaseID, - long expiration, - MethodConstraints constraints) - { - super((Registrar) ((RemoteMethodControl) server).setConstraints( - ConstrainableProxyUtil.translateConstraints( - constraints, methodMappings)), - registrarID, - serviceID, - leaseID, - expiration); - this.constraints = constraints; - } - - /** - * Creates a constraint-aware lease map. - */ - public LeaseMap<? extends Lease,Long> createLeaseMap(long duration) { - return new ConstrainableRegistrarLeaseMap(this, duration); - } - - /** - * Two leases can be batched if they are both RegistrarLeases, share the - * same server, and have compatible constraints. - */ - public boolean canBatch(Lease lease) { - if (!(super.canBatch(lease) && lease instanceof RemoteMethodControl)) { - return false; - } - return ConstrainableProxyUtil.equivalentConstraints( - ((RemoteMethodControl) lease).getConstraints(), - ConstrainableProxyUtil.translateConstraints( - constraints, ConstrainableRegistrarLeaseMap.methodMappings), - ConstrainableRegistrarLeaseMap.methodMappings); - } - - // javadoc inherited from RemoteMethodControl.setConstraints - public RemoteMethodControl setConstraints(MethodConstraints constraints) { - return new ConstrainableServiceLease( - server, registrarID, serviceID, leaseID, expiration, constraints); - } - - // javadoc inherited from RemoteMethodControl.getConstraints - public MethodConstraints getConstraints() { - return constraints; - } - - /** - * Returns iterator used by ProxyTrustVerifier to retrieve a trust verifier - * for this object. - */ - private ProxyTrustIterator getProxyTrustIterator() { - return new SingletonProxyTrustIterator(server); - } - - /** - * Verifies that the client constraints for this proxy are consistent with - * those set on the underlying server ref. - */ - private void readObject(ObjectInputStream in) - throws IOException, ClassNotFoundException - { - in.defaultReadObject(); - ConstrainableProxyUtil.verifyConsistentConstraints( - constraints, server, methodMappings); - } -} +/* + * 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.ConstrainableProxyUtil; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.lang.reflect.Method; +import net.jini.core.constraint.MethodConstraints; +import net.jini.core.constraint.RemoteMethodControl; +import net.jini.core.lease.Lease; +import net.jini.core.lease.LeaseMap; +import net.jini.core.lookup.ServiceID; +import net.jini.id.Uuid; +import net.jini.security.proxytrust.ProxyTrustIterator; +import net.jini.security.proxytrust.SingletonProxyTrustIterator; + +/** + * ServiceLease subclass that supports constraints. + * + * @author Sun Microsystems, Inc. + * + */ +final class ConstrainableServiceLease + extends ServiceLease implements RemoteMethodControl +{ + private static final long serialVersionUID = 2L; + + /** Mappings between Lease and Registrar methods */ + private static final Method[] methodMappings = { + Util.getMethod(Lease.class, "cancel", new Class[0]), + Util.getMethod(Registrar.class, "cancelServiceLease", + new Class[]{ ServiceID.class, Uuid.class }), + + Util.getMethod(Lease.class, "renew", new Class[]{ long.class }), + Util.getMethod(Registrar.class, "renewServiceLease", + new Class[]{ ServiceID.class, Uuid.class, long.class }) + }; + + /** Client constraints for this proxy, or null */ + private final MethodConstraints constraints; + + /** + * Creates new ConstrainableServiceLease with given server reference, event + * and lease IDs, expiration time and client constraints. + */ + ConstrainableServiceLease(Registrar server, + ServiceID registrarID, + ServiceID serviceID, + Uuid leaseID, + long expiration, + MethodConstraints constraints) + { + super((Registrar) ((RemoteMethodControl) server).setConstraints( + ConstrainableProxyUtil.translateConstraints( + constraints, methodMappings)), + registrarID, + serviceID, + leaseID, + expiration); + this.constraints = constraints; + } + + /** + * Creates a constraint-aware lease map. + */ + public LeaseMap<? extends Lease,Long> createLeaseMap(long duration) { + return new ConstrainableRegistrarLeaseMap(this, duration); + } + + /** + * Two leases can be batched if they are both RegistrarLeases, share the + * same server, and have compatible constraints. + */ + public boolean canBatch(Lease lease) { + if (!(super.canBatch(lease) && lease instanceof RemoteMethodControl)) { + return false; + } + return ConstrainableProxyUtil.equivalentConstraints( + ((RemoteMethodControl) lease).getConstraints(), + ConstrainableProxyUtil.translateConstraints( + constraints, ConstrainableRegistrarLeaseMap.methodMappings), + ConstrainableRegistrarLeaseMap.methodMappings); + } + + // javadoc inherited from RemoteMethodControl.setConstraints + public RemoteMethodControl setConstraints(MethodConstraints constraints) { + return new ConstrainableServiceLease( + server, registrarID, serviceID, leaseID, expiration, constraints); + } + + // javadoc inherited from RemoteMethodControl.getConstraints + public MethodConstraints getConstraints() { + return constraints; + } + + /** + * Returns iterator used by ProxyTrustVerifier to retrieve a trust verifier + * for this object. + */ + private ProxyTrustIterator getProxyTrustIterator() { + return new SingletonProxyTrustIterator(server); + } + + /** + * Verifies that the client constraints for this proxy are consistent with + * those set on the underlying server ref. + */ + private void readObject(ObjectInputStream in) + throws IOException, ClassNotFoundException + { + in.defaultReadObject(); + ConstrainableProxyUtil.verifyConsistentConstraints( + constraints, server, methodMappings); + } +}
