summaryrefslogtreecommitdiffstats
path: root/java/sca/modules
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2008-07-02 06:47:40 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2008-07-02 06:47:40 +0000
commit8d7cb21ef3c6cf4a39ee77e3358d2eeb129864fe (patch)
tree6bb016d2eaa7d5254232ffcb735872e94ab8c14c /java/sca/modules
parent02f18503f2e2707b6ed535929bcd412877512419 (diff)
Fix for TUSCANY-2444
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@673298 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules')
-rw-r--r--java/sca/modules/contribution-java/src/test/java/org/apache/tuscany/sca/contribution/java/impl/ContributionClassLoaderTestCase.java15
-rw-r--r--java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/BeanXMLStreamReaderImpl.java15
-rw-r--r--java/sca/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/BeanXMLStreamReaderImpl.java14
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/JavaIntrospectionHelper.java2
-rw-r--r--java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/invocation/OSGiImplementationProvider.java9
-rw-r--r--java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/test/OSGiTestBundles.java7
-rw-r--r--java/sca/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/CodeGenerationHelper.java15
-rw-r--r--java/sca/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSFaultExceptionMapper.java2
-rw-r--r--java/sca/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessor.java4
-rw-r--r--java/sca/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/WrapperBeanGenerator.java4
-rw-r--r--java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceUtil.java12
-rw-r--r--java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/util/JavaXMLMapper.java12
12 files changed, 84 insertions, 27 deletions
diff --git a/java/sca/modules/contribution-java/src/test/java/org/apache/tuscany/sca/contribution/java/impl/ContributionClassLoaderTestCase.java b/java/sca/modules/contribution-java/src/test/java/org/apache/tuscany/sca/contribution/java/impl/ContributionClassLoaderTestCase.java
index 314af5fc75..3ae161642d 100644
--- a/java/sca/modules/contribution-java/src/test/java/org/apache/tuscany/sca/contribution/java/impl/ContributionClassLoaderTestCase.java
+++ b/java/sca/modules/contribution-java/src/test/java/org/apache/tuscany/sca/contribution/java/impl/ContributionClassLoaderTestCase.java
@@ -134,6 +134,11 @@ public class ContributionClassLoaderTestCase {
}
+ 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 @@ public class ContributionClassLoaderTestCase {
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 @@ public class ContributionClassLoaderTestCase {
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 @@ public class ContributionClassLoaderTestCase {
// 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 @@ public class ContributionClassLoaderTestCase {
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 @@ public class ContributionClassLoaderTestCase {
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");
diff --git a/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/BeanXMLStreamReaderImpl.java b/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/BeanXMLStreamReaderImpl.java
index 730f9e4a66..0fde2ee9a5 100644
--- a/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/BeanXMLStreamReaderImpl.java
+++ b/java/sca/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/BeanXMLStreamReaderImpl.java
@@ -196,16 +196,24 @@ public class BeanXMLStreamReaderImpl extends XmlTreeStreamReaderImpl {
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 @@ public class BeanXMLStreamReaderImpl extends XmlTreeStreamReaderImpl {
ns.append('/');
return new QName(ns.toString(), cls.getSimpleName());
}
-
}
public BeanXMLStreamReaderImpl(QName name, Object bean) {
diff --git a/java/sca/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/BeanXMLStreamReaderImpl.java b/java/sca/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/BeanXMLStreamReaderImpl.java
index d6a699390f..b97abda2b0 100644
--- a/java/sca/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/BeanXMLStreamReaderImpl.java
+++ b/java/sca/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/BeanXMLStreamReaderImpl.java
@@ -150,17 +150,25 @@ public class BeanXMLStreamReaderImpl extends XmlTreeStreamReaderImpl {
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) {
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/JavaIntrospectionHelper.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/JavaIntrospectionHelper.java
index 6a1876fc5d..6039bd91f8 100644
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/JavaIntrospectionHelper.java
+++ b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/JavaIntrospectionHelper.java
@@ -68,7 +68,7 @@ public final class JavaIntrospectionHelper {
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);
}
}
diff --git a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/invocation/OSGiImplementationProvider.java b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/invocation/OSGiImplementationProvider.java
index 3bd18c3239..3b08bbc7dc 100644
--- a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/invocation/OSGiImplementationProvider.java
+++ b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/invocation/OSGiImplementationProvider.java
@@ -550,7 +550,7 @@ public class OSGiImplementationProvider implements ScopedImplementationProvider
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 @@ public class OSGiImplementationProvider implements ScopedImplementationProvider
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 @@ public class OSGiImplementationProvider implements ScopedImplementationProvider
ArrayList<Class<?>> dummyClasses = new ArrayList<Class<?>>();
String interfaceName = interfaceClass.getName();
- String packageName = interfaceClass.getPackage().getName();
+ String packageName = getPackageName(interfaceClass);
String bundleName = "dummy.sca." + interfaceName;
diff --git a/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/test/OSGiTestBundles.java b/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/test/OSGiTestBundles.java
index 2fd163aab6..93b4dee033 100644
--- a/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/test/OSGiTestBundles.java
+++ b/java/sca/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/test/OSGiTestBundles.java
@@ -36,6 +36,11 @@ import java.util.zip.ZipEntry;
* @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 @@ public class OSGiTestBundles {
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
diff --git a/java/sca/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/CodeGenerationHelper.java b/java/sca/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/CodeGenerationHelper.java
index a23036db7c..b05715b54e 100644
--- a/java/sca/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/CodeGenerationHelper.java
+++ b/java/sca/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/CodeGenerationHelper.java
@@ -261,5 +261,20 @@ public class CodeGenerationHelper {
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.";
+ }
+ }
}
diff --git a/java/sca/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSFaultExceptionMapper.java b/java/sca/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSFaultExceptionMapper.java
index fa32060447..a4f2facb4b 100644
--- a/java/sca/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSFaultExceptionMapper.java
+++ b/java/sca/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSFaultExceptionMapper.java
@@ -293,7 +293,7 @@ public class JAXWSFaultExceptionMapper implements FaultExceptionMapper {
}
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() {
diff --git a/java/sca/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessor.java b/java/sca/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessor.java
index 758dcb5dd7..1e1a0c4e94 100644
--- a/java/sca/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessor.java
+++ b/java/sca/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessor.java
@@ -188,7 +188,7 @@ public class JAXWSJavaInterfaceProcessor implements JavaInterfaceVisitor {
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 @@ public class JAXWSJavaInterfaceProcessor implements JavaInterfaceVisitor {
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;
diff --git a/java/sca/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/WrapperBeanGenerator.java b/java/sca/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/WrapperBeanGenerator.java
index 785496f7b6..764c10ff00 100644
--- a/java/sca/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/WrapperBeanGenerator.java
+++ b/java/sca/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/WrapperBeanGenerator.java
@@ -50,7 +50,7 @@ public class WrapperBeanGenerator extends BaseBeanGenerator {
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 @@ public class WrapperBeanGenerator extends BaseBeanGenerator {
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);
}
diff --git a/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceUtil.java b/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceUtil.java
index f8d705be13..2a9e3c5329 100644
--- a/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceUtil.java
+++ b/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceUtil.java
@@ -147,13 +147,19 @@ public final class JavaInterfaceUtil {
}
+ 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) {
diff --git a/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/util/JavaXMLMapper.java b/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/util/JavaXMLMapper.java
index 811bb09fc4..54c0a3ec11 100644
--- a/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/util/JavaXMLMapper.java
+++ b/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/util/JavaXMLMapper.java
@@ -117,13 +117,19 @@ public final class JavaXMLMapper {
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) {