|
Apache CXF example source code file (PlugInClassLoader.java)
The Apache CXF PlugInClassLoader.java source code/** * 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<Object> i = filtersProps.keySet().iterator(); while (i.hasNext()) { LOG.config("get Filter " + propFile + "::" + (String)i.next()); } return (String[])filtersProps.keySet().toArray(new String[] {}); } private static Properties getProperties(ClassLoader parent, String propsFileName) throws IOException { InputStream in = parent.getResourceAsStream(propsFileName); if (null == in) { in = PlugInClassLoader.class.getResourceAsStream(propsFileName); if (null == in) { String msg = "Internal rar classloader failed to locate configuration resource: " + propsFileName; IOException ioe = new IOException(msg); LOG.warning(ioe.toString()); throw ioe; } } Properties props = new Properties(); props.load(in); LOG.fine("Contents: " + propsFileName + props); return props; } private String[] loadUrls(ClassLoader parent) throws IOException { List<String> urlList = new ArrayList Other Apache CXF examples (source code examples)Here is a short list of links related to this Apache CXF PlugInClassLoader.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.