Home » openejb-3.1.2-src » org.apache » openejb » server » webservices » saaj » [javadoc | source]

    1   /**
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements.  See the NOTICE file distributed with
    4    * this work for additional information regarding copyright ownership.
    5    * The ASF licenses this file to You under the Apache License, Version 2.0
    6    * (the "License"); you may not use this file except in compliance with
    7    * the License.  You may obtain a copy of the License at
    8    *
    9    *     http://www.apache.org/licenses/LICENSE-2.0
   10    *
   11    * Unless required by applicable law or agreed to in writing, software
   12    * distributed under the License is distributed on an "AS IS" BASIS,
   13    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   14    * See the License for the specific language governing permissions and
   15    * limitations under the License.
   16    */
   17   package org.apache.openejb.server.webservices.saaj;
   18   
   19   import java.util.LinkedList;
   20   
   21   import org.apache.openejb.util.Logger;
   22   import org.apache.openejb.util.LogCategory;
   23   
   24   public class SaajUniverse {
   25       private static final Logger logger = Logger.getInstance(LogCategory.OPENEJB_WS, SaajUniverse.class);
   26       
   27       static {
   28           setProperty("javax.xml.soap.MessageFactory", "org.apache.openejb.server.webservices.saaj.MessageFactoryImpl");
   29           setProperty("javax.xml.soap.SOAPFactory", "org.apache.openejb.server.webservices.saaj.SoapFactoryImpl");
   30           setProperty("javax.xml.soap.SOAPConnectionFactory", "org.apache.openejb.server.webservices.saaj.SoapConnectionFactoryImpl");
   31           setProperty("javax.xml.soap.MetaFactory", "org.apache.openejb.server.webservices.saaj.SaajMetaFactoryImpl");
   32       }
   33   
   34       private static void setProperty(String name, String value) {
   35           if (System.getProperty(name) == null) {
   36               System.setProperty(name, value);
   37           }
   38       }
   39   
   40       enum Type { DEFAULT, AXIS1, AXIS2, SUN }
   41       
   42       public static final Type DEFAULT = Type.DEFAULT;
   43       public static final Type SUN = Type.SUN;
   44       public static final Type AXIS1 = Type.AXIS1;
   45       public static final Type AXIS2 = Type.AXIS2;
   46       
   47       private static final ThreadLocal<LinkedList<Type>> currentUniverse = 
   48           new InheritableThreadLocal<LinkedList<Type>>();
   49           
   50       public void set(Type newUniverse) {
   51           LinkedList<Type> universeList = currentUniverse.get();
   52           if (universeList == null) {
   53               universeList = new LinkedList<Type>();
   54               currentUniverse.set(universeList);
   55           }
   56           universeList.add(newUniverse);
   57           if (logger.isDebugEnabled()) {
   58               logger.debug("Set universe: " + Thread.currentThread() + " " + newUniverse);
   59           }
   60       }
   61       
   62       public void unset() {
   63           LinkedList<Type> universeList = currentUniverse.get();
   64           if (universeList != null && !universeList.isEmpty()) {
   65               universeList.removeLast();
   66               if (logger.isDebugEnabled()) {
   67                   logger.debug("Restored universe: " + Thread.currentThread());
   68               }
   69           }
   70       }
   71       
   72       static Type getCurrentUniverse() {
   73           LinkedList<Type> universeList = currentUniverse.get();
   74           if (universeList != null && !universeList.isEmpty()) {
   75               return universeList.getLast();
   76           } else {
   77               return null;
   78           }                
   79       }
   80          
   81   }

Home » openejb-3.1.2-src » org.apache » openejb » server » webservices » saaj » [javadoc | source]