Java ClassLoader Load getProhibitedProxyInterfaces()

Here you can find the source of getProhibitedProxyInterfaces()

Description

Returns collection of prohibited proxy interfaces read from resources.

License

Apache License

Declaration

private static Collection getProhibitedProxyInterfaces() 

Method Source Code


//package com.java2s;
/*//from  w w  w  . j  a  va  2  s  .c o  m
 * 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.
 */

import java.io.BufferedReader;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

import java.net.URL;

import java.util.Collection;
import java.util.Enumeration;
import java.util.HashSet;

public class Main {
    /** name of the resource containing prohibited proxy interfaces */
    private static final String prohibitedProxyInterfacesResource = "com/sun/jini/proxy/resources/"
            + "InvocationHandler.moreProhibitedProxyInterfaces";

    /**
     * Returns collection of prohibited proxy interfaces read from resources.
     */
    private static Collection getProhibitedProxyInterfaces() {
        Collection names = new HashSet();
        names.add("javax.management.MBeanServerConnection");
        Enumeration resources;
        try {
            resources = ClassLoader.getSystemResources(prohibitedProxyInterfacesResource);
        } catch (IOException e) {
            throw new ExceptionInInitializerError(
                    new IOException("problem getting resources: " + prohibitedProxyInterfacesResource)
                            .initCause(e));
        }
        while (resources.hasMoreElements()) {
            URL url = (URL) resources.nextElement();
            try {
                InputStream in = url.openStream();
                try {
                    BufferedReader r = new BufferedReader(new InputStreamReader(in, "utf-8"));
                    while (true) {
                        String s = r.readLine();
                        if (s == null) {
                            break;
                        }
                        int i = s.indexOf('#');
                        if (i >= 0) {
                            s = s.substring(0, i);
                        }
                        s = s.trim();
                        int n = s.length();
                        if (n == 0) {
                            continue;
                        }
                        char prev = '.';
                        for (i = 0; i < n; i++) {
                            char c = s.charAt(i);
                            if (prev == '.' ? !Character.isJavaIdentifierStart(c)
                                    : !(Character.isJavaIdentifierPart(c) || (c == '.' && i < n - 1))) {
                                throw new ExceptionInInitializerError(
                                        "illegal interface name in " + url + ": " + s);
                            }
                            prev = c;
                        }
                        names.add(s);
                    }
                } finally {
                    try {
                        in.close();
                    } catch (IOException e) {
                    }
                }
            } catch (IOException e) {
                throw new ExceptionInInitializerError(new IOException("problem reading " + url).initCause(e));
            }
        }
        return names;
    }
}

Related

  1. getLog4jPropertiesLocation()
  2. getManifestInfo()
  3. getMetadataSpecialSymbolsXml()
  4. getPath(final String fileName)
  5. getPath(String resoureLocation)
  6. getProperties(String bundleName, String fileName)
  7. getProperty(String propertyName)
  8. getReader(final String name, final String encoding)
  9. getRootPath()