org.apache.cxf.jca.core.classloader.PlugInClassLoader Maven / Gradle / Ivy
/**
* 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.cxf.jca.core.classloader;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.security.ProtectionDomain;
import java.security.SecureClassLoader;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;
import java.util.logging.Logger;
import org.apache.cxf.common.classloader.FireWallClassLoader;
import org.apache.cxf.common.logging.LogUtils;
public class PlugInClassLoader extends SecureClassLoader {
private static final Logger LOG = LogUtils.getL7dLogger(PlugInClassLoader.class);
private static final String FILE_COLON = "file:";
private static final String ZIP_COLON = "zip:";
private static final String URL_SCHEME_COLON = "classloader:";
private static final String JARS_PROPS_FILE = "jars.properties";
private static final String FILTERS_PROPS_FILE = "filters.properties";
private static final String NEFILTERS_PROPS_FILE = "negativefilters.properties";
private String jarUrls[] = new String[0];
private final ProtectionDomain protectionDomain;
private ClassLoader ploader;
public PlugInClassLoader(ClassLoader p) throws IOException {
super(new FireWallClassLoader(p,
getFilterList(p, FILTERS_PROPS_FILE),
getFilterList(p, NEFILTERS_PROPS_FILE)));
ploader = p;
protectionDomain = getClass().getProtectionDomain();
jarUrls = loadUrls(p);
processJarUrls(jarUrls);
}
private void processJarUrls(String urls[]) {
for (int i = 0; i < urls.length; i++) {
if (urls[i].startsWith(ZIP_COLON)) {
urls[i] = FILE_COLON + urls[i].substring(ZIP_COLON.length());
}
}
}
private static String[] getFilterList(ClassLoader parent, String propFile) throws IOException {
Properties filtersProps = getProperties(parent, propFile);
Iterator