tuscany-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Simon Laws" <simonsl...@googlemail.com>
Subject Re: svn commit: r673298 - in /tuscany/java/sca: modules/contribution-java/src/test/java/org/apache/tuscany/sca/contribution/java/impl/ modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/ modules/databinding/src/main/java/o
Date Wed, 02 Jul 2008 09:23:30 GMT
On Wed, Jul 2, 2008 at 7:47 AM, <rfeng@apache.org> wrote:

> Author: rfeng
> Date: Tue Jul  1 23:47:40 2008
> New Revision: 673298
>
> URL: http://svn.apache.org/viewvc?rev=673298&view=rev
> Log:
> Fix for TUSCANY-2444
>
> Modified:
>
>  tuscany/java/sca/modules/contribution-java/src/test/java/org/apache/tuscany/sca/contribution/java/impl/ContributionClassLoaderTestCase.java
>
>  tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/BeanXMLStreamReaderImpl.java
>
>  tuscany/java/sca/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/BeanXMLStreamReaderImpl.java
>
>  tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/JavaIntrospectionHelper.java
>
>  tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/invocation/OSGiImplementationProvider.java
>
>  tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/test/OSGiTestBundles.java
>
>  tuscany/java/sca/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/CodeGenerationHelper.java
>
>  tuscany/java/sca/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSFaultExceptionMapper.java
>
>  tuscany/java/sca/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessor.java
>
>  tuscany/java/sca/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/WrapperBeanGenerator.java
>
>  tuscany/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceUtil.java
>
>  tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/util/JavaXMLMapper.java
>
>  tuscany/java/sca/tools/java2wsdl/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/SchemaBuilder.java
>
> Modified:
> tuscany/java/sca/modules/contribution-java/src/test/java/org/apache/tuscany/sca/contribution/java/impl/ContributionClassLoaderTestCase.java
> URL:
> http://svn.apache.org/viewvc/tuscany/java/sca/modules/contribution-java/src/test/java/org/apache/tuscany/sca/contribution/java/impl/ContributionClassLoaderTestCase.java?rev=673298&r1=673297&r2=673298&view=diff
>
> ==============================================================================
> ---
> tuscany/java/sca/modules/contribution-java/src/test/java/org/apache/tuscany/sca/contribution/java/impl/ContributionClassLoaderTestCase.java
> (original)
> +++
> tuscany/java/sca/modules/contribution-java/src/test/java/org/apache/tuscany/sca/contribution/java/impl/ContributionClassLoaderTestCase.java
> Tue Jul  1 23:47:40 2008
> @@ -134,6 +134,11 @@
>
>     }
>
> +    private static String getPackageName(Class<?> cls) {
> +        String name = cls.getName();
> +        int index = name.lastIndexOf('.');
> +        return index == -1 ? "" : name.substring(0, index);
> +    }
>
>     @Test
>     public void testClassLoadingFromImportedContribution() throws
> ClassNotFoundException, MalformedURLException {
> @@ -146,7 +151,7 @@
>         exportContribList.add(contribC);
>
>         JavaImport import_ = javaImportExportFactory.createJavaImport();
> -        import_.setPackage(this.getClass().getPackage().getName());
> +        import_.setPackage(getPackageName(getClass()));
>         import_.setModelResolver(new
> JavaImportModelResolver(exportContribList, null));
>         contribB.getImports().add(import_);
>         import_ = javaImportExportFactory.createJavaImport();
> @@ -155,7 +160,7 @@
>         contribB.getImports().add(import_);
>
>         JavaExport export = javaImportExportFactory.createJavaExport();
> -        export.setPackage(this.getClass().getPackage().getName());
> +        export.setPackage(getPackageName(getClass()));
>         contribA.getExports().add(export);
>         export = javaImportExportFactory.createJavaExport();
>         export.setPackage("calculator");
> @@ -197,7 +202,7 @@
>
>         // Try to load non-existent class from imported package - should
> throw ClassNotFoundException
>         try {
> -
>  contribB.getClassLoader().loadClass(this.getClass().getPackage().getName()
> + ".NonExistentClass");
> +            contribB.getClassLoader().loadClass(getPackageName(getClass())
> + ".NonExistentClass");
>
>             Assert.assertTrue("ClassNotFoundException not thrown as
> expected", false);
>
> @@ -218,7 +223,7 @@
>         exportContribList.add(contribC);
>
>         JavaImport import_ = javaImportExportFactory.createJavaImport();
> -        import_.setPackage(this.getClass().getPackage().getName());
> +        import_.setPackage(getPackageName(getClass()));
>         import_.setModelResolver(new
> JavaImportModelResolver(exportContribList, null));
>         contribB.getImports().add(import_);
>         JavaImport import1_ = javaImportExportFactory.createJavaImport();
> @@ -227,7 +232,7 @@
>         contribB.getImports().add(import1_);
>
>         JavaExport export = javaImportExportFactory.createJavaExport();
> -        export.setPackage(this.getClass().getPackage().getName());
> +        export.setPackage(getPackageName(getClass()));
>         contribA.getExports().add(export);
>         JavaExport export1 = javaImportExportFactory.createJavaExport();
>         export1.setPackage("calculator");
>
> Modified:
> tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/BeanXMLStreamReaderImpl.java
> URL:
> http://svn.apache.org/viewvc/tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/BeanXMLStreamReaderImpl.java?rev=673298&r1=673297&r2=673298&view=diff
>
> ==============================================================================
> ---
> tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/BeanXMLStreamReaderImpl.java
> (original)
> +++
> tuscany/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/BeanXMLStreamReaderImpl.java
> Tue Jul  1 23:47:40 2008
> @@ -196,16 +196,24 @@
>             return getStringValue(value);
>         }
>
> +        private static String getPackageName(Class<?> cls) {
> +            String name = cls.getName();
> +            int index = name.lastIndexOf('.');
> +            return index == -1 ? "" : name.substring(0, index);
> +        }
> +
>         public static QName getName(Class<?> cls) {
>             if (cls == null) {
>                 return null;
>             }
> -            Package pkg = cls.getPackage();
> -            if (pkg == null) {
> +
> +            String packageName = getPackageName(cls);
> +
> +            if ("".equals(packageName)) {
>                 return new QName("", cls.getSimpleName());
>             }
>             StringBuffer ns = new StringBuffer("http://");
> -            String[] names = pkg.getName().split("\\.");
> +            String[] names = packageName.split("\\.");
>             for (int i = names.length - 1; i >= 0; i--) {
>                 ns.append(names[i]);
>                 if (i != 0) {
> @@ -215,7 +223,6 @@
>             ns.append('/');
>             return new QName(ns.toString(), cls.getSimpleName());
>         }
> -
>     }
>
>     public BeanXMLStreamReaderImpl(QName name, Object bean) {
>
> Modified:
> tuscany/java/sca/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/BeanXMLStreamReaderImpl.java
> URL:
> http://svn.apache.org/viewvc/tuscany/java/sca/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/BeanXMLStreamReaderImpl.java?rev=673298&r1=673297&r2=673298&view=diff
>
> ==============================================================================
> ---
> tuscany/java/sca/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/BeanXMLStreamReaderImpl.java
> (original)
> +++
> tuscany/java/sca/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/BeanXMLStreamReaderImpl.java
> Tue Jul  1 23:47:40 2008
> @@ -150,17 +150,25 @@
>         public String getValue() {
>             return getStringValue(value);
>         }
> +
> +        private static String getPackageName(Class<?> cls) {
> +            String name = cls.getName();
> +            int index = name.lastIndexOf('.');
> +            return index == -1 ? "" : name.substring(0, index);
> +        }
>
>         public static QName getName(Class<?> cls) {
>             if (cls == null) {
>                 return null;
>             }
> -            Package pkg = cls.getPackage();
> -            if (pkg == null) {
> +
> +            String packageName = getPackageName(cls);
> +
> +            if ("".equals(packageName)) {
>                 return new QName("", cls.getSimpleName());
>             }
>             StringBuffer ns = new StringBuffer("http://");
> -            String[] names = pkg.getName().split("\\.");
> +            String[] names = packageName.split("\\.");
>             for (int i = names.length - 1; i >= 0; i--) {
>                 ns.append(names[i]);
>                 if (i != 0) {
>
> Modified:
> tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/JavaIntrospectionHelper.java
> URL:
> http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/JavaIntrospectionHelper.java?rev=673298&r1=673297&r2=673298&view=diff
>
> ==============================================================================
> ---
> tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/JavaIntrospectionHelper.java
> (original)
> +++
> tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/JavaIntrospectionHelper.java
> Tue Jul  1 23:47:40 2008
> @@ -68,7 +68,7 @@
>
>     private static void checkInvalidAnnotations(AnnotatedElement element) {
>         for (Annotation a : element.getAnnotations()) {
> -            if
> ("org.osoa.sca.annotations".equals(a.annotationType().getPackage().getName()))
> {
> +            if
> (a.annotationType().getName().startsWith("org.osoa.sca.annotations.")) {
>                 logger.warning("Invalid annotation " + a + " is found on "
> + element);
>             }
>         }
>
> Modified:
> tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/invocation/OSGiImplementationProvider.java
> URL:
> http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/invocation/OSGiImplementationProvider.java?rev=673298&r1=673297&r2=673298&view=diff
>
> ==============================================================================
> ---
> tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/invocation/OSGiImplementationProvider.java
> (original)
> +++
> tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/invocation/OSGiImplementationProvider.java
> Tue Jul  1 23:47:40 2008
> @@ -550,7 +550,7 @@
>         String EOL = System.getProperty("line.separator");
>
>         String interfaceName = interfaceClass.getName();
> -        String packageName = interfaceClass.getPackage().getName();
> +        String packageName = getPackageName(interfaceClass);
>         String bundleName = "dummy.sca." + packageName;
>
>         String manifestStr = "Manifest-Version: 1.0" + EOL
> @@ -645,6 +645,11 @@
>             return exp.getExportingBundle();
>     }
>
> +    private static String getPackageName(Class<?> cls) {
> +        String name = cls.getName();
> +        int index = name.lastIndexOf('.');
> +        return index == -1 ? "" : name.substring(0, index);
> +    }
>
>     private Bundle installDummyBundle(Class<?> interfaceClass)
>             throws Exception {
> @@ -660,7 +665,7 @@
>         ArrayList<Class<?>> dummyClasses = new ArrayList<Class<?>>();
>
>         String interfaceName = interfaceClass.getName();
> -        String packageName = interfaceClass.getPackage().getName();
> +        String packageName = getPackageName(interfaceClass);
>         String bundleName = "dummy.sca." + interfaceName;
>
>
>
> Modified:
> tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/test/OSGiTestBundles.java
> URL:
> http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/test/OSGiTestBundles.java?rev=673298&r1=673297&r2=673298&view=diff
>
> ==============================================================================
> ---
> tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/test/OSGiTestBundles.java
> (original)
> +++
> tuscany/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/test/OSGiTestBundles.java
> Tue Jul  1 23:47:40 2008
> @@ -36,6 +36,11 @@
>  * @version $Rev$ $Date$
>  */
>  public class OSGiTestBundles {
> +    private static String getPackageName(Class<?> cls) {
> +        String name = cls.getName();
> +        int index = name.lastIndexOf('.');
> +        return index == -1 ? "" : name.substring(0, index);
> +    }
>
>     public static void createBundle(String jarName,
>             Class<?> interfaceClass, Class<?> implClass) throws Exception
{
> @@ -44,7 +49,7 @@
>
>         String EOL = System.getProperty("line.separator");
>
> -        String packageName = interfaceClass.getPackage().getName();
> +        String packageName = getPackageName(interfaceClass);
>         String bundleName = interfaceClass.getName();
>
>         String manifestStr = "Manifest-Version: 1.0" + EOL
>
> Modified:
> tuscany/java/sca/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/CodeGenerationHelper.java
> URL:
> http://svn.apache.org/viewvc/tuscany/java/sca/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/CodeGenerationHelper.java?rev=673298&r1=673297&r2=673298&view=diff
>
> ==============================================================================
> ---
> tuscany/java/sca/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/CodeGenerationHelper.java
> (original)
> +++
> tuscany/java/sca/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/CodeGenerationHelper.java
> Tue Jul  1 23:47:40 2008
> @@ -261,5 +261,20 @@
>         return Opcodes.ARETURN;
>
>     }
> +
> +    /**
> +     * Get the package prefix for generated JAXWS artifacts
> +     * @param cls
> +     * @return
> +     */
> +    public static String getPackagePrefix(Class<?> cls) {
> +        String name = cls.getName();
> +        int index = name.lastIndexOf('.');
> +        if (index == -1) {
> +            return "jaxws.";
> +        } else {
> +            return name.substring(0, index) + ".jaxws.";
> +        }
> +    }
>
>  }
>
> Modified:
> tuscany/java/sca/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSFaultExceptionMapper.java
> URL:
> http://svn.apache.org/viewvc/tuscany/java/sca/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSFaultExceptionMapper.java?rev=673298&r1=673297&r2=673298&view=diff
>
> ==============================================================================
> ---
> tuscany/java/sca/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSFaultExceptionMapper.java
> (original)
> +++
> tuscany/java/sca/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSFaultExceptionMapper.java
> Tue Jul  1 23:47:40 2008
> @@ -293,7 +293,7 @@
>         }
>
>         if (faultBean == null) {
> -            final String faultBeanClassName = cls.getPackage().getName() +
> ".jaxws." + cls.getSimpleName() + "Bean";
> +            final String faultBeanClassName =
> CodeGenerationHelper.getPackagePrefix(cls) + cls.getSimpleName() + "Bean";
>             final QName qname = faultName;
>             faultType = AccessController.doPrivileged(new
> PrivilegedAction<DataType<XMLType>>() {
>                 public DataType<XMLType> run() {
>
> Modified:
> tuscany/java/sca/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessor.java
> URL:
> http://svn.apache.org/viewvc/tuscany/java/sca/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessor.java?rev=673298&r1=673297&r2=673298&view=diff
>
> ==============================================================================
> ---
> tuscany/java/sca/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessor.java
> (original)
> +++
> tuscany/java/sca/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessor.java
> Tue Jul  1 23:47:40 2008
> @@ -188,7 +188,7 @@
>                     requestWrapper == null ? operationName :
> getValue(requestWrapper.localName(), operationName);
>                 String wrapperBeanName = requestWrapper == null ? "" :
> requestWrapper.className();
>                 if ("".equals(wrapperBeanName)) {
> -                    wrapperBeanName = clazz.getPackage().getName() +
> ".jaxws." + capitalize(method.getName());
> +                    wrapperBeanName =
> CodeGenerationHelper.getPackagePrefix(clazz) + capitalize(method.getName());
>                 }
>
>                 DataType<XMLType> inputWrapperDT = null;
> @@ -222,7 +222,7 @@
>                 wrapperBeanName = responseWrapper == null ? "" :
> responseWrapper.className();
>                 if ("".equals(wrapperBeanName)) {
>                     wrapperBeanName =
> -                        clazz.getPackage().getName() + ".jaxws." +
> capitalize(method.getName()) + "Response";
> +                        CodeGenerationHelper.getPackagePrefix(clazz) +
> capitalize(method.getName()) + "Response";
>                 }
>
>                 DataType<XMLType> outputWrapperDT = null;
>
> Modified:
> tuscany/java/sca/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/WrapperBeanGenerator.java
> URL:
> http://svn.apache.org/viewvc/tuscany/java/sca/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/WrapperBeanGenerator.java?rev=673298&r1=673297&r2=673298&view=diff
>
> ==============================================================================
> ---
> tuscany/java/sca/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/WrapperBeanGenerator.java
> (original)
> +++
> tuscany/java/sca/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/WrapperBeanGenerator.java
> Tue Jul  1 23:47:40 2008
> @@ -50,7 +50,7 @@
>         String wrapperNamespace = JavaInterfaceUtil.getNamespace(sei);
>         String wrapperName = m.getName();
>         String wrapperBeanName = capitalize(wrapperName);
> -        String wrapperClassName = sei.getPackage().getName() + ".jaxws." +
> wrapperBeanName;
> +        String wrapperClassName =
> CodeGenerationHelper.getPackagePrefix(sei) + wrapperBeanName;
>
>         return generateRequestWrapper(m, wrapperClassName,
> wrapperNamespace, wrapperName, cl);
>     }
> @@ -111,7 +111,7 @@
>
>         String wrapperName = m.getName() + "Response";
>         String wrapperBeanName = capitalize(wrapperName);
> -        String wrapperClassName = sei.getPackage().getName() + ".jaxws." +
> wrapperBeanName;
> +        String wrapperClassName =
> CodeGenerationHelper.getPackagePrefix(sei) + wrapperBeanName;
>         return generateResponseWrapper(m, wrapperClassName,
> wrapperNamespace, wrapperName, cl);
>
>     }
>
> Modified:
> tuscany/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceUtil.java
> URL:
> http://svn.apache.org/viewvc/tuscany/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceUtil.java?rev=673298&r1=673297&r2=673298&view=diff
>
> ==============================================================================
> ---
> tuscany/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceUtil.java
> (original)
> +++
> tuscany/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceUtil.java
> Tue Jul  1 23:47:40 2008
> @@ -147,13 +147,19 @@
>
>     }
>
> +    private static String getPackageName(Class<?> cls) {
> +        String name = cls.getName();
> +        int index = name.lastIndexOf('.');
> +        return index == -1 ? "" : name.substring(0, index);
> +    }
> +
>     public static String getNamespace(Class<?> cls) {
> -        Package pkg = cls.getPackage();
> -        if (pkg == null) {
> +        String packageName = getPackageName(cls);
> +        if ("".equals(packageName)) {
>             return "";
>         }
>         StringBuffer ns = new StringBuffer("http://");
> -        String[] names = pkg.getName().split("\\.");
> +        String[] names = packageName.split("\\.");
>         for (int i = names.length - 1; i >= 0; i--) {
>             ns.append(names[i]);
>             if (i != 0) {
>
> Modified:
> tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/util/JavaXMLMapper.java
> URL:
> http://svn.apache.org/viewvc/tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/util/JavaXMLMapper.java?rev=673298&r1=673297&r2=673298&view=diff
>
> ==============================================================================
> ---
> tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/util/JavaXMLMapper.java
> (original)
> +++
> tuscany/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/util/JavaXMLMapper.java
> Tue Jul  1 23:47:40 2008
> @@ -117,13 +117,19 @@
>         return JAVA2XML.get(javaType);
>     }
>
> +    private static String getPackageName(Class<?> cls) {
> +        String name = cls.getName();
> +        int index = name.lastIndexOf('.');
> +        return index == -1 ? "" : name.substring(0, index);
> +    }
> +
>     public static String getNamespace(Class<?> cls) {
> -        Package pkg = cls.getPackage();
> -        if (pkg == null) {
> +        String packageName = getPackageName(cls);
> +        if ("".equals(packageName)) {
>             return "";
>         }
>         StringBuffer ns = new StringBuffer("http://");
> -        String[] names = pkg.getName().split("\\.");
> +        String[] names = packageName.split("\\.");
>         for (int i = names.length - 1; i >= 0; i--) {
>             ns.append(names[i]);
>             if (i != 0) {
>
> Modified:
> tuscany/java/sca/tools/java2wsdl/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/SchemaBuilder.java
> URL:
> http://svn.apache.org/viewvc/tuscany/java/sca/tools/java2wsdl/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/SchemaBuilder.java?rev=673298&r1=673297&r2=673298&view=diff
>
> ==============================================================================
> ---
> tuscany/java/sca/tools/java2wsdl/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/SchemaBuilder.java
> (original)
> +++
> tuscany/java/sca/tools/java2wsdl/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/SchemaBuilder.java
> Tue Jul  1 23:47:40 2008
> @@ -554,14 +554,19 @@
>         this.elementFormDefault = elementFormDefault;
>     }
>
> -
> +    private static String getPackageName(Class<?> cls) {
> +        String name = cls.getName();
> +        int index = name.lastIndexOf('.');
> +        return index == -1 ? "" : name.substring(0, index);
> +    }
> +
>     /**
>      * Recognize the pattern of generated SDO type names vs. SDO factory
> names.
>      * E.g. SDO class:   test.sca.w2j.gen.Company will be associated with
>      *      SDO factory: test.sca.w2j.gen.GenFactory
>      */
>     private void detectAndRegisterFactory(Class sdoClass) {
> -        String pkgName = sdoClass.getPackage().getName();
> +        String pkgName = getPackageName(sdoClass);
>
>         // Find last segment, e.g. from 'test.sca.w2j.gen' produce 'gen'.
>         int lastDot = pkgName.lastIndexOf('.');
>
>
>
Looking at TUSCANY-2444 is this a fix we should have in R1.3 while we still
have the chance?

Simon

Mime
View raw message