Tue, 12 Sep 2017 16:53:35 +0100
8160104: CORBA communication improvements
Reviewed-by: dfuchs, msheppar
aefimov@1618 | 1 | /* |
aefimov@1618 | 2 | * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. |
aefimov@1618 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
aefimov@1618 | 4 | * |
aefimov@1618 | 5 | * This code is free software; you can redistribute it and/or modify it |
aefimov@1618 | 6 | * under the terms of the GNU General Public License version 2 only, as |
aefimov@1618 | 7 | * published by the Free Software Foundation. Oracle designates this |
aefimov@1618 | 8 | * particular file as subject to the "Classpath" exception as provided |
aefimov@1618 | 9 | * by Oracle in the LICENSE file that accompanied this code. |
aefimov@1618 | 10 | * |
aefimov@1618 | 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
aefimov@1618 | 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
aefimov@1618 | 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
aefimov@1618 | 14 | * version 2 for more details (a copy is included in the LICENSE file that |
aefimov@1618 | 15 | * accompanied this code). |
aefimov@1618 | 16 | * |
aefimov@1618 | 17 | * You should have received a copy of the GNU General Public License version |
aefimov@1618 | 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
aefimov@1618 | 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
aefimov@1618 | 20 | * |
aefimov@1618 | 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
aefimov@1618 | 22 | * or visit www.oracle.com if you need additional information or have any |
aefimov@1618 | 23 | * questions. |
aefimov@1618 | 24 | */ |
aefimov@1618 | 25 | |
aefimov@1618 | 26 | package com.sun.corba.se.impl.ior; |
aefimov@1618 | 27 | |
aefimov@1618 | 28 | import java.util.Arrays; |
aefimov@1618 | 29 | import java.util.Collections; |
aefimov@1618 | 30 | import java.util.HashSet; |
aefimov@1618 | 31 | import java.util.Set; |
aefimov@1618 | 32 | |
aefimov@1618 | 33 | import com.sun.corba.se.impl.orbutil.ORBUtility; |
aefimov@1618 | 34 | import com.sun.corba.se.spi.ior.IORTypeCheckRegistry; |
aefimov@1618 | 35 | import com.sun.corba.se.spi.orb.ORB; |
aefimov@1618 | 36 | |
aefimov@1618 | 37 | public class IORTypeCheckRegistryImpl implements IORTypeCheckRegistry { |
aefimov@1618 | 38 | |
aefimov@1618 | 39 | private final Set<String> iorTypeNames; |
aefimov@1618 | 40 | private static final Set<String> builtinIorTypeNames; |
aefimov@1618 | 41 | private ORB theOrb; |
aefimov@1618 | 42 | |
aefimov@1618 | 43 | static { |
aefimov@1618 | 44 | builtinIorTypeNames = initBuiltinIorTypeNames(); |
aefimov@1618 | 45 | } |
aefimov@1618 | 46 | |
aefimov@1618 | 47 | public IORTypeCheckRegistryImpl(String filterProperties, ORB orb) { |
aefimov@1618 | 48 | theOrb = orb; |
aefimov@1618 | 49 | iorTypeNames = parseIorClassNameList(filterProperties); |
aefimov@1618 | 50 | } |
aefimov@1618 | 51 | |
aefimov@1618 | 52 | /* |
aefimov@1618 | 53 | * |
aefimov@1618 | 54 | * A note on the validation flow: |
aefimov@1618 | 55 | * 1. against the filter class name list |
aefimov@1618 | 56 | * 2. against the builtin class name list |
aefimov@1618 | 57 | */ |
aefimov@1618 | 58 | @Override |
aefimov@1618 | 59 | public boolean isValidIORType(String iorClassName) { |
aefimov@1618 | 60 | dprintTransport(".isValidIORType : iorClassName == " + iorClassName); |
aefimov@1618 | 61 | return validateIorTypeByName(iorClassName); |
aefimov@1618 | 62 | } |
aefimov@1618 | 63 | |
aefimov@1618 | 64 | |
aefimov@1618 | 65 | private boolean validateIorTypeByName(String iorClassName) { |
aefimov@1618 | 66 | dprintTransport(".validateIorTypeByName : iorClassName == " + iorClassName); |
aefimov@1618 | 67 | boolean isValidType; |
aefimov@1618 | 68 | |
aefimov@1618 | 69 | isValidType = checkIorTypeNames(iorClassName); |
aefimov@1618 | 70 | |
aefimov@1618 | 71 | if (!isValidType) { |
aefimov@1618 | 72 | isValidType = checkBuiltinClassNames(iorClassName); |
aefimov@1618 | 73 | } |
aefimov@1618 | 74 | |
aefimov@1618 | 75 | dprintTransport(".validateIorTypeByName : isValidType == " + isValidType); |
aefimov@1618 | 76 | return isValidType; |
aefimov@1618 | 77 | } |
aefimov@1618 | 78 | |
aefimov@1618 | 79 | |
aefimov@1618 | 80 | /* |
aefimov@1618 | 81 | * check if the class name corresponding to an IOR Type name |
aefimov@1618 | 82 | * is in the ior class name list as generated from the filter property. |
aefimov@1618 | 83 | * So if the IOR type is recorded in the registry then allow the creation of the |
aefimov@1618 | 84 | * stub factory and let it resolve and load the class. That is if current |
aefimov@1618 | 85 | * type check deliberation permits. |
aefimov@1618 | 86 | * IOR Type names are configured by the filter property |
aefimov@1618 | 87 | */ |
aefimov@1618 | 88 | private boolean checkIorTypeNames( |
aefimov@1618 | 89 | String theIorClassName) { |
aefimov@1618 | 90 | return (iorTypeNames != null) && (iorTypeNames.contains(theIorClassName)); |
aefimov@1618 | 91 | } |
aefimov@1618 | 92 | |
aefimov@1618 | 93 | /* |
aefimov@1618 | 94 | * Check the IOR interface class name against the set of |
aefimov@1618 | 95 | * class names that correspond to the builtin JDK IDL stub classes. |
aefimov@1618 | 96 | */ |
aefimov@1618 | 97 | private boolean checkBuiltinClassNames( |
aefimov@1618 | 98 | String theIorClassName) { |
aefimov@1618 | 99 | return builtinIorTypeNames.contains(theIorClassName); |
aefimov@1618 | 100 | } |
aefimov@1618 | 101 | |
aefimov@1618 | 102 | private Set<String> parseIorClassNameList(String filterProperty) { |
aefimov@1618 | 103 | Set<String> _iorTypeNames = null; |
aefimov@1618 | 104 | if (filterProperty != null) { |
aefimov@1618 | 105 | String[] tempIorClassNames = filterProperty.split(";"); |
aefimov@1618 | 106 | _iorTypeNames = Collections.unmodifiableSet(new HashSet<>(Arrays |
aefimov@1618 | 107 | .asList(tempIorClassNames))); |
aefimov@1618 | 108 | if (theOrb.orbInitDebugFlag) { |
aefimov@1618 | 109 | dprintConfiguredIorTypeNames(); |
aefimov@1618 | 110 | } |
aefimov@1618 | 111 | } |
aefimov@1618 | 112 | return _iorTypeNames; |
aefimov@1618 | 113 | } |
aefimov@1618 | 114 | |
aefimov@1618 | 115 | private static Set<String> initBuiltinIorTypeNames() { |
aefimov@1618 | 116 | Set<Class<?>> builtInCorbaStubTypes = initBuiltInCorbaStubTypes(); |
aefimov@1618 | 117 | String[] tempBuiltinIorTypeNames = new String[builtInCorbaStubTypes.size()]; |
aefimov@1618 | 118 | int i = 0; |
aefimov@1618 | 119 | for (Class<?> _stubClass : builtInCorbaStubTypes) { |
aefimov@1618 | 120 | tempBuiltinIorTypeNames[i++] = _stubClass.getName(); |
aefimov@1618 | 121 | } |
aefimov@1618 | 122 | return Collections.unmodifiableSet(new HashSet<>(Arrays |
aefimov@1618 | 123 | .asList(tempBuiltinIorTypeNames))); |
aefimov@1618 | 124 | } |
aefimov@1618 | 125 | |
aefimov@1618 | 126 | private static Set<Class<?>> initBuiltInCorbaStubTypes() { |
aefimov@1618 | 127 | Class<?> tempBuiltinCorbaStubTypes[] = { |
aefimov@1618 | 128 | com.sun.corba.se.spi.activation.Activator.class, |
aefimov@1618 | 129 | com.sun.corba.se.spi.activation._ActivatorStub.class, |
aefimov@1618 | 130 | com.sun.corba.se.spi.activation._InitialNameServiceStub.class, |
aefimov@1618 | 131 | com.sun.corba.se.spi.activation._LocatorStub.class, |
aefimov@1618 | 132 | com.sun.corba.se.spi.activation._RepositoryStub.class, |
aefimov@1618 | 133 | com.sun.corba.se.spi.activation._ServerManagerStub.class, |
aefimov@1618 | 134 | com.sun.corba.se.spi.activation._ServerStub.class, |
aefimov@1618 | 135 | org.omg.CosNaming.BindingIterator.class, |
aefimov@1618 | 136 | org.omg.CosNaming._BindingIteratorStub.class, |
aefimov@1618 | 137 | org.omg.CosNaming.NamingContextExt.class, |
aefimov@1618 | 138 | org.omg.CosNaming._NamingContextExtStub.class, |
aefimov@1618 | 139 | org.omg.CosNaming.NamingContext.class, |
aefimov@1618 | 140 | org.omg.CosNaming._NamingContextStub.class, |
aefimov@1618 | 141 | org.omg.DynamicAny.DynAnyFactory.class, |
aefimov@1618 | 142 | org.omg.DynamicAny._DynAnyFactoryStub.class, |
aefimov@1618 | 143 | org.omg.DynamicAny.DynAny.class, |
aefimov@1618 | 144 | org.omg.DynamicAny._DynAnyStub.class, |
aefimov@1618 | 145 | org.omg.DynamicAny.DynArray.class, |
aefimov@1618 | 146 | org.omg.DynamicAny._DynArrayStub.class, |
aefimov@1618 | 147 | org.omg.DynamicAny.DynEnum.class, |
aefimov@1618 | 148 | org.omg.DynamicAny._DynEnumStub.class, |
aefimov@1618 | 149 | org.omg.DynamicAny.DynFixed.class, |
aefimov@1618 | 150 | org.omg.DynamicAny._DynFixedStub.class, |
aefimov@1618 | 151 | org.omg.DynamicAny.DynSequence.class, |
aefimov@1618 | 152 | org.omg.DynamicAny._DynSequenceStub.class, |
aefimov@1618 | 153 | org.omg.DynamicAny.DynStruct.class, |
aefimov@1618 | 154 | org.omg.DynamicAny._DynStructStub.class, |
aefimov@1618 | 155 | org.omg.DynamicAny.DynUnion.class, |
aefimov@1618 | 156 | org.omg.DynamicAny._DynUnionStub.class, |
aefimov@1618 | 157 | org.omg.DynamicAny._DynValueStub.class, |
aefimov@1618 | 158 | org.omg.DynamicAny.DynValue.class, |
aefimov@1618 | 159 | org.omg.PortableServer.ServantActivator.class, |
aefimov@1618 | 160 | org.omg.PortableServer._ServantActivatorStub.class, |
aefimov@1618 | 161 | org.omg.PortableServer.ServantLocator.class, |
aefimov@1618 | 162 | org.omg.PortableServer._ServantLocatorStub.class}; |
aefimov@1618 | 163 | return new HashSet<>( |
aefimov@1618 | 164 | Arrays.asList(tempBuiltinCorbaStubTypes)); |
aefimov@1618 | 165 | } |
aefimov@1618 | 166 | |
aefimov@1618 | 167 | private void dprintConfiguredIorTypeNames() { |
aefimov@1618 | 168 | if (iorTypeNames != null) { |
aefimov@1618 | 169 | for (String iorTypeName : iorTypeNames) { |
aefimov@1618 | 170 | ORBUtility.dprint(this, ".dprintConfiguredIorTypeNames: " + iorTypeName); |
aefimov@1618 | 171 | } |
aefimov@1618 | 172 | } |
aefimov@1618 | 173 | } |
aefimov@1618 | 174 | |
aefimov@1618 | 175 | private void dprintTransport(String msg) { |
aefimov@1618 | 176 | if (theOrb.transportDebugFlag) { |
aefimov@1618 | 177 | ORBUtility.dprint(this, msg); |
aefimov@1618 | 178 | } |
aefimov@1618 | 179 | } |
aefimov@1618 | 180 | } |