Home » geronimo-2.2-source-release » org.apache.geronimo.deployment.service » [javadoc | source]

    1   /*
    2    * Licensed to the Apache Software Foundation (ASF) under one
    3    * or more contributor license agreements.  See the NOTICE file
    4    * distributed with this work for additional information
    5    * regarding copyright ownership.  The ASF licenses this file
    6    * to you under the Apache License, Version 2.0 (the
    7    * "License"); you may not use this file except in compliance
    8    * with the License.  You may obtain a copy of the License at
    9    *
   10    *  http://www.apache.org/licenses/LICENSE-2.0
   11    *
   12    * Unless required by applicable law or agreed to in writing,
   13    * software distributed under the License is distributed on an
   14    * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   15    * KIND, either express or implied.  See the License for the
   16    * specific language governing permissions and limitations
   17    * under the License.
   18    */
   19   
   20   package org.apache.geronimo.deployment.service;
   21   
   22   import java.util.HashSet;
   23   import java.util.Set;
   24   
   25   import org.apache.geronimo.deployment.xbeans.ClassFilterType;
   26   import org.apache.geronimo.deployment.xbeans.EnvironmentType;
   27   import org.apache.geronimo.kernel.repository.ClassLoadingRule;
   28   import org.apache.geronimo.kernel.repository.ClassLoadingRules;
   29   
   30   /**
   31    *
   32    * @version $Rev:$ $Date:$
   33    */
   34   public final class ClassLoadingRulesUtil {
   35   
   36       private ClassLoadingRulesUtil() {
   37       }
   38   
   39       public static void configureRules(ClassLoadingRules classLoadingRules, EnvironmentType environmentType) {
   40           classLoadingRules.setInverseClassLoading(environmentType.isSetInverseClassloading());
   41           
   42           if (null != environmentType.getHiddenClasses()) {
   43               ClassLoadingRule hiddenRule = classLoadingRules.getHiddenRule();
   44               hiddenRule.setClassPrefixes(toFilters(environmentType.getHiddenClasses()));
   45           }
   46           
   47           if (null != environmentType.getNonOverridableClasses()) {
   48               ClassLoadingRule nonOverrideableRule = classLoadingRules.getNonOverrideableRule();
   49               nonOverrideableRule.setClassPrefixes(toFilters(environmentType.getNonOverridableClasses()));
   50           }
   51           
   52           if (null != environmentType.getPrivateClasses()) {
   53               ClassLoadingRule privateRule = classLoadingRules.getPrivateRule();
   54               privateRule.setClassPrefixes(toFilters(environmentType.getPrivateClasses()));
   55           }
   56       }
   57      
   58       private static Set<String> toFilters(ClassFilterType filterType) {
   59           Set<String> filters = new HashSet<String>();
   60           if (null != filterType) {
   61               String[] filterArray = filterType.getFilterArray();
   62               for (String filter : filterArray) {
   63                   filter = filter.trim();
   64                   filters.add(filter);
   65               }
   66           }
   67           return filters;
   68       }
   69       
   70   }

Home » geronimo-2.2-source-release » org.apache.geronimo.deployment.service » [javadoc | source]