owenb       2002/06/12 09:42:19

  Modified:    java/src/org/apache/wsif/util WSIFUtils.java
  Log:
  Changed to use the WSIFConstants.WSDLFACTORY_PROPERTY_NAME 
  constant rather than its own private version
  
  Revision  Changes    Path
  1.3       +115 -51   xml-axis-wsif/java/src/org/apache/wsif/util/WSIFUtils.java
  
  Index: WSIFUtils.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/src/org/apache/wsif/util/WSIFUtils.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- WSIFUtils.java    12 Jun 2002 10:27:23 -0000      1.2
  +++ WSIFUtils.java    12 Jun 2002 16:42:19 -0000      1.3
  @@ -114,9 +114,6 @@
    * @author Mark Whitlock <[EMAIL PROTECTED]>
    */
   public class WSIFUtils {
  -    private final static String DEF_FACTORY_PROPERTY_NAME =
  -        "javax.wsdl.factory.WSDLFactory";
  -        
       private static Class initContextClass;
       private static final String SLASH = "/";
       private static final String DOT = ".";
  @@ -126,7 +123,7 @@
       private static final String FORMATBINDING = "formatbinding/";
       private static final String XMLSEPARATORS =
           "\u002D\u002E\u003A\u005F\u00B7\u0387\u06DD\u06DE";
  -        
  +
       private static final String lookupPrefix = "java:comp/env/";
       private static final String emptyString = "";
   
  @@ -192,7 +189,13 @@
               Class[] lookupSig = new Class[] { String.class };
               Object[] lookupArgs =
                   new String[] {
  -                     serviceNS + "::" + serviceName + "::" + portTypeNS + "::" + 
portTypeName };
  +                    serviceNS
  +                        + "::"
  +                        + serviceName
  +                        + "::"
  +                        + portTypeNS
  +                        + "::"
  +                        + portTypeName };
               Method m = initContextClass.getMethod("lookup", lookupSig);
               ws = (WSIFService) m.invoke(ic, lookupArgs);
           } catch (Exception e) {
  @@ -215,7 +218,8 @@
               ((serviceNS != null && serviceName != null)
                   ? new QName(serviceNS, serviceName)
                   : null);
  -        Service service = (Service) getNamedItem(services, serviceQName, "Service");
  +        Service service =
  +            (Service) getNamedItem(services, serviceQName, "Service");
   
           Tr.exit(service);
           return service;
  @@ -296,7 +300,10 @@
           Tr.exit();
       }
   
  -    private static void getAllItems(Definition def, String itemType, Map toItems) {
  +    private static void getAllItems(
  +        Definition def,
  +        String itemType,
  +        Map toItems) {
           Tr.entry(null, def, itemType, toItems);
           Map items = null;
   
  @@ -376,7 +383,8 @@
                   Tr.exit(o);
                   return o;
               } else if (size == 0) {
  -                throw new WSIFException("WSDL document contains no " + itemType + 
"s.");
  +                throw new WSIFException(
  +                    "WSDL document contains no " + itemType + "s.");
               } else {
                   throw new WSIFException(
                       "Please specify a "
  @@ -417,9 +425,12 @@
           initializeProviders();
   
           Properties props = System.getProperties();
  -        String oldPropValue = props.getProperty(DEF_FACTORY_PROPERTY_NAME);
  +        String oldPropValue =
  +            props.getProperty(WSIFConstants.WSDLFACTORY_PROPERTY_NAME);
   
  -        props.setProperty(DEF_FACTORY_PROPERTY_NAME, 
WSIFConstants.WSIF_WSDLFACTORY);
  +        props.setProperty(
  +            WSIFConstants.WSDLFACTORY_PROPERTY_NAME,
  +            WSIFConstants.WSIF_WSDLFACTORY);
   
           WSDLFactory factory = WSDLFactory.newInstance();
           WSDLReader wsdlReader = factory.newWSDLReader();
  @@ -428,16 +439,20 @@
               Definition def = wsdlReader.readWSDL(contextURL, wsdlLoc);
   
               if (oldPropValue != null) {
  -                props.setProperty(DEF_FACTORY_PROPERTY_NAME, oldPropValue);
  +                props.setProperty(
  +                    WSIFConstants.WSDLFACTORY_PROPERTY_NAME,
  +                    oldPropValue);
               } else {
  -                props.remove(DEF_FACTORY_PROPERTY_NAME);
  +                props.remove(WSIFConstants.WSDLFACTORY_PROPERTY_NAME);
               }
               Tr.exitExpandWsdl(def);
               return def;
           } catch (WSDLException e) {
               // Log message
               MessageLogger messageLog =
  -                MessageLogger.newMessageLogger("WSIF", 
"org.apache.wsif.catalog.Messages");
  +                MessageLogger.newMessageLogger(
  +                    "WSIF",
  +                    "org.apache.wsif.catalog.Messages");
               messageLog.message(
                   WSIFConstants.TYPE_ERROR,
                   "WSIF.0002E",
  @@ -464,28 +479,36 @@
           initializeProviders();
   
           Properties props = System.getProperties();
  -        String oldPropValue = props.getProperty(DEF_FACTORY_PROPERTY_NAME);
  +        String oldPropValue =
  +            props.getProperty(WSIFConstants.WSDLFACTORY_PROPERTY_NAME);
   
  -        props.setProperty(DEF_FACTORY_PROPERTY_NAME, 
WSIFConstants.WSIF_WSDLFACTORY);
  +        props.setProperty(
  +            WSIFConstants.WSDLFACTORY_PROPERTY_NAME,
  +            WSIFConstants.WSIF_WSDLFACTORY);
   
           WSDLFactory factory = WSDLFactory.newInstance();
           WSDLReader wsdlReader = factory.newWSDLReader();
           wsdlReader.setFeature(Constants.FEATURE_VERBOSE, false);
           try {
               String url = (contextURL == null) ? null : contextURL.toString();
  -            Definition def = wsdlReader.readWSDL(url, new InputSource(reader), cl);
  +            Definition def =
  +                wsdlReader.readWSDL(url, new InputSource(reader), cl);
   
               if (oldPropValue != null) {
  -                props.setProperty(DEF_FACTORY_PROPERTY_NAME, oldPropValue);
  +                props.setProperty(
  +                    WSIFConstants.WSDLFACTORY_PROPERTY_NAME,
  +                    oldPropValue);
               } else {
  -                props.remove(DEF_FACTORY_PROPERTY_NAME);
  +                props.remove(WSIFConstants.WSDLFACTORY_PROPERTY_NAME);
               }
               Tr.exitExpandWsdl(def);
               return def;
           } catch (WSDLException e) {
               // Log message
               MessageLogger messageLog =
  -                MessageLogger.newMessageLogger("WSIF", 
"org.apache.wsif.catalog.Messages");
  +                MessageLogger.newMessageLogger(
  +                    "WSIF",
  +                    "org.apache.wsif.catalog.Messages");
               messageLog.message(
                   WSIFConstants.TYPE_ERROR,
                   "WSIF.0002E",
  @@ -512,9 +535,12 @@
           initializeProviders();
   
           Properties props = System.getProperties();
  -        String oldPropValue = props.getProperty(DEF_FACTORY_PROPERTY_NAME);
  +        String oldPropValue =
  +            props.getProperty(WSIFConstants.WSDLFACTORY_PROPERTY_NAME);
   
  -        props.setProperty(DEF_FACTORY_PROPERTY_NAME, 
WSIFConstants.WSIF_WSDLFACTORY);
  +        props.setProperty(
  +            WSIFConstants.WSDLFACTORY_PROPERTY_NAME,
  +            WSIFConstants.WSIF_WSDLFACTORY);
   
           WSDLFactory factory = WSDLFactory.newInstance();
           WSDLReader wsdlReader = factory.newWSDLReader();
  @@ -525,16 +551,20 @@
               Definition def = wsdlReader.readWSDL(url, wsdlLoc, cl);
   
               if (oldPropValue != null) {
  -                props.setProperty(DEF_FACTORY_PROPERTY_NAME, oldPropValue);
  +                props.setProperty(
  +                    WSIFConstants.WSDLFACTORY_PROPERTY_NAME,
  +                    oldPropValue);
               } else {
  -                props.remove(DEF_FACTORY_PROPERTY_NAME);
  +                props.remove(WSIFConstants.WSDLFACTORY_PROPERTY_NAME);
               }
               Tr.exitExpandWsdl(def);
               return def;
           } catch (WSDLException e) {
               // Log message
               MessageLogger messageLog =
  -                MessageLogger.newMessageLogger("WSIF", 
"org.apache.wsif.catalog.Messages");
  +                MessageLogger.newMessageLogger(
  +                    "WSIF",
  +                    "org.apache.wsif.catalog.Messages");
               messageLog.message(
                   WSIFConstants.TYPE_ERROR,
                   "WSIF.0002E",
  @@ -557,19 +587,25 @@
           initializeProviders();
   
           Properties props = System.getProperties();
  -        String oldPropValue = props.getProperty(DEF_FACTORY_PROPERTY_NAME);
  +        String oldPropValue =
  +            props.getProperty(WSIFConstants.WSDLFACTORY_PROPERTY_NAME);
   
  -        props.setProperty(DEF_FACTORY_PROPERTY_NAME, 
WSIFConstants.WSIF_WSDLFACTORY);
  +        props.setProperty(
  +            WSIFConstants.WSDLFACTORY_PROPERTY_NAME,
  +            WSIFConstants.WSIF_WSDLFACTORY);
   
           WSDLFactory factory = WSDLFactory.newInstance();
           WSDLReader wsdlReader = factory.newWSDLReader();
           wsdlReader.setFeature(Constants.FEATURE_VERBOSE, false);
  -        Definition def = wsdlReader.readWSDL(contextURL, new InputSource(reader));
  +        Definition def =
  +            wsdlReader.readWSDL(contextURL, new InputSource(reader));
   
           if (oldPropValue != null) {
  -            props.setProperty(DEF_FACTORY_PROPERTY_NAME, oldPropValue);
  +            props.setProperty(
  +                WSIFConstants.WSDLFACTORY_PROPERTY_NAME,
  +                oldPropValue);
           } else {
  -            props.remove(DEF_FACTORY_PROPERTY_NAME);
  +            props.remove(WSIFConstants.WSDLFACTORY_PROPERTY_NAME);
           }
   
           Tr.exitExpandWsdl(def);
  @@ -588,9 +624,12 @@
           initializeProviders();
   
           Properties props = System.getProperties();
  -        String oldPropValue = props.getProperty(DEF_FACTORY_PROPERTY_NAME);
  +        String oldPropValue =
  +            props.getProperty(WSIFConstants.WSDLFACTORY_PROPERTY_NAME);
   
  -        props.setProperty(DEF_FACTORY_PROPERTY_NAME, 
WSIFConstants.WSIF_WSDLFACTORY);
  +        props.setProperty(
  +            WSIFConstants.WSDLFACTORY_PROPERTY_NAME,
  +            WSIFConstants.WSIF_WSDLFACTORY);
   
           WSDLFactory factory = WSDLFactory.newInstance();
           WSDLReader wsdlReader = factory.newWSDLReader();
  @@ -598,9 +637,11 @@
           Definition def = wsdlReader.readWSDL(contextURL, wsdlDocument);
   
           if (oldPropValue != null) {
  -            props.setProperty(DEF_FACTORY_PROPERTY_NAME, oldPropValue);
  +            props.setProperty(
  +                WSIFConstants.WSDLFACTORY_PROPERTY_NAME,
  +                oldPropValue);
           } else {
  -            props.remove(DEF_FACTORY_PROPERTY_NAME);
  +            props.remove(WSIFConstants.WSDLFACTORY_PROPERTY_NAME);
           }
   
           Tr.exitExpandWsdl(def);
  @@ -621,9 +662,12 @@
           initializeProviders();
   
           Properties props = System.getProperties();
  -        String oldPropValue = props.getProperty(DEF_FACTORY_PROPERTY_NAME);
  +        String oldPropValue =
  +            props.getProperty(WSIFConstants.WSDLFACTORY_PROPERTY_NAME);
   
  -        props.setProperty(DEF_FACTORY_PROPERTY_NAME, 
WSIFConstants.WSIF_WSDLFACTORY);
  +        props.setProperty(
  +            WSIFConstants.WSDLFACTORY_PROPERTY_NAME,
  +            WSIFConstants.WSIF_WSDLFACTORY);
   
           WSDLFactory factory = WSDLFactory.newInstance();
           WSDLReader wsdlReader = factory.newWSDLReader();
  @@ -631,9 +675,11 @@
           Definition def = wsdlReader.readWSDL(contextURL, wsdlServicesElement);
   
           if (oldPropValue != null) {
  -            props.setProperty(DEF_FACTORY_PROPERTY_NAME, oldPropValue);
  +            props.setProperty(
  +                WSIFConstants.WSDLFACTORY_PROPERTY_NAME,
  +                oldPropValue);
           } else {
  -            props.remove(DEF_FACTORY_PROPERTY_NAME);
  +            props.remove(WSIFConstants.WSDLFACTORY_PROPERTY_NAME);
           }
   
           Tr.exitExpandWsdl(def);
  @@ -649,18 +695,23 @@
           throws WSDLException {
           Tr.entry(null, def, sink);
           Properties props = System.getProperties();
  -        String oldPropValue = props.getProperty(DEF_FACTORY_PROPERTY_NAME);
  +        String oldPropValue =
  +            props.getProperty(WSIFConstants.WSDLFACTORY_PROPERTY_NAME);
   
  -        props.setProperty(DEF_FACTORY_PROPERTY_NAME, 
WSIFConstants.WSIF_WSDLFACTORY);
  +        props.setProperty(
  +            WSIFConstants.WSDLFACTORY_PROPERTY_NAME,
  +            WSIFConstants.WSIF_WSDLFACTORY);
   
           WSDLFactory factory = WSDLFactory.newInstance();
           WSDLWriter wsdlWriter = factory.newWSDLWriter();
           wsdlWriter.writeWSDL(def, sink);
   
           if (oldPropValue != null) {
  -            props.setProperty(DEF_FACTORY_PROPERTY_NAME, oldPropValue);
  +            props.setProperty(
  +                WSIFConstants.WSDLFACTORY_PROPERTY_NAME,
  +                oldPropValue);
           } else {
  -            props.remove(DEF_FACTORY_PROPERTY_NAME);
  +            props.remove(WSIFConstants.WSDLFACTORY_PROPERTY_NAME);
           }
           Tr.exit();
       }
  @@ -743,12 +794,14 @@
           String formatHandlerName = typePackageName;
   
           String bindingShortName =
  -            
getPackageNameFromXMLName(definition.getPrefix(getBindingNamespace(binding)));
  +            getPackageNameFromXMLName(
  +                definition.getPrefix(getBindingNamespace(binding)));
           if (bindingShortName != null)
               formatHandlerName = formatHandlerName + DOT + bindingShortName;
   
           if (getFormatStylePackage(binding) != null)
  -            formatHandlerName = formatHandlerName + DOT + 
getFormatStylePackage(binding);
  +            formatHandlerName =
  +                formatHandlerName + DOT + getFormatStylePackage(binding);
   
           String formatHandlerShortName =
               formatHandlerName
  @@ -766,7 +819,8 @@
                   ClassLoader cl = Thread.currentThread().getContextClassLoader();
                   formatHandler =
                       (WSIFFormatHandler) cl
  -                        .loadClass(formatHandlerShortName + ELEMENT_FORMAT_HANDLER)
  +                        .loadClass(
  +                            formatHandlerShortName + ELEMENT_FORMAT_HANDLER)
                           .newInstance();
               } catch (ClassNotFoundException exn2) {
                   try {
  @@ -778,7 +832,9 @@
                       //try {
                       formatHandler =
                           (WSIFFormatHandler) Class
  -                            .forName(formatHandlerShortName + 
ELEMENT_FORMAT_HANDLER)
  +                            .forName(
  +                                formatHandlerShortName
  +                                    + ELEMENT_FORMAT_HANDLER)
                               .newInstance();
                       //}
                       //catch (ClassNotFoundException exn4) {
  @@ -825,7 +881,8 @@
                       if (buffer.length() != 0)
                           buffer.append('.');
                       String nextSegment = (String) hi.next();
  -                    if 
(!Character.isJavaIdentifierStart(nextSegment.toCharArray()[0]))
  +                    if (!Character
  +                        .isJavaIdentifierStart(nextSegment.toCharArray()[0]))
                           nextSegment = "_" + nextSegment;
                       buffer.append(nextSegment);
                   }
  @@ -850,7 +907,9 @@
           return packageNameBuffer.toString();
       }
   
  -    public static String getJavaNameFromXMLName(String xmlName, String delims) {
  +    public static String getJavaNameFromXMLName(
  +        String xmlName,
  +        String delims) {
           Tr.entry(null, xmlName, delims);
           StringTokenizer tokenizer = new StringTokenizer(xmlName, delims);
           StringBuffer buffer = new StringBuffer();
  @@ -879,7 +938,9 @@
   
           // Tokenize, don't consider '.' as a delimiter here
           String name =
  -            getJavaNameFromXMLName(xmlName, 
"\u002D\u003A\u005F\u00B7\u0387\u06DD\u06DE");
  +            getJavaNameFromXMLName(
  +                xmlName,
  +                "\u002D\u003A\u005F\u00B7\u0387\u06DD\u06DE");
   
           // Tokenize using delimiter '.' and add the tokens separated by '.'
           // This is to ensure that we have no heading/trailing/dup '.' in the string
  @@ -932,7 +993,8 @@
               ExtensibilityElement ee = (ExtensibilityElement) iterator.next();
               if (returnNamespace == null) {
                   String namespace = ee.getElementType().getNamespaceURI();
  -                if (!namespace.endsWith(PHYSICALREP) && 
!namespace.endsWith(FORMATBINDING)) {
  +                if (!namespace.endsWith(PHYSICALREP)
  +                    && !namespace.endsWith(FORMATBINDING)) {
                       returnNamespace = namespace;
                   }
               }
  @@ -989,12 +1051,14 @@
           String formatHandlerName = typePackageName;
   
           String bindingShortName =
  -            
getPackageNameFromXMLName(definition.getPrefix(getBindingNamespace(binding)));
  +            getPackageNameFromXMLName(
  +                definition.getPrefix(getBindingNamespace(binding)));
           if (bindingShortName != null)
               formatHandlerName = formatHandlerName + DOT + bindingShortName;
   
           if (getFormatStylePackage(binding) != null)
  -            formatHandlerName = formatHandlerName + DOT + 
getFormatStylePackage(binding);
  +            formatHandlerName =
  +                formatHandlerName + DOT + getFormatStylePackage(binding);
   
           formatHandlerName =
               formatHandlerName
  
  
  


Reply via email to