summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--branches/sca-java-1.3/modules/contribution-java/src/test/java/org/apache/tuscany/sca/contribution/java/impl/ContributionClassLoaderTestCase.java15
-rw-r--r--branches/sca-java-1.3/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/BeanXMLStreamReaderImpl.java15
-rw-r--r--branches/sca-java-1.3/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/BeanXMLStreamReaderImpl.java14
-rw-r--r--branches/sca-java-1.3/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/JavaIntrospectionHelper.java2
-rw-r--r--branches/sca-java-1.3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/invocation/OSGiImplementationProvider.java9
-rw-r--r--branches/sca-java-1.3/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/test/OSGiTestBundles.java7
-rw-r--r--branches/sca-java-1.3/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/CodeGenerationHelper.java15
-rw-r--r--branches/sca-java-1.3/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSFaultExceptionMapper.java2
-rw-r--r--branches/sca-java-1.3/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessor.java4
-rw-r--r--branches/sca-java-1.3/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/WrapperBeanGenerator.java4
-rw-r--r--branches/sca-java-1.3/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceUtil.java12
-rw-r--r--branches/sca-java-1.3/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/util/JavaXMLMapper.java12
-rw-r--r--branches/sca-java-1.3/tools/java2wsdl/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/SchemaBuilder.java9
13 files changed, 91 insertions, 29 deletions
diff --git a/branches/sca-java-1.3/modules/contribution-java/src/test/java/org/apache/tuscany/sca/contribution/java/impl/ContributionClassLoaderTestCase.java b/branches/sca-java-1.3/modules/contribution-java/src/test/java/org/apache/tuscany/sca/contribution/java/impl/ContributionClassLoaderTestCase.java
index 314af5fc75..3ae161642d 100644
--- a/branches/sca-java-1.3/modules/contribution-java/src/test/java/org/apache/tuscany/sca/contribution/java/impl/ContributionClassLoaderTestCase.java
+++ b/branches/sca-java-1.3/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/branches/sca-java-1.3/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/BeanXMLStreamReaderImpl.java b/branches/sca-java-1.3/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/BeanXMLStreamReaderImpl.java
index 730f9e4a66..0fde2ee9a5 100644
--- a/branches/sca-java-1.3/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/BeanXMLStreamReaderImpl.java
+++ b/branches/sca-java-1.3/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/branches/sca-java-1.3/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/BeanXMLStreamReaderImpl.java b/branches/sca-java-1.3/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/BeanXMLStreamReaderImpl.java
index d6a699390f..b97abda2b0 100644
--- a/branches/sca-java-1.3/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/BeanXMLStreamReaderImpl.java
+++ b/branches/sca-java-1.3/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/branches/sca-java-1.3/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/JavaIntrospectionHelper.java b/branches/sca-java-1.3/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/JavaIntrospectionHelper.java
index 6a1876fc5d..6039bd91f8 100644
--- a/branches/sca-java-1.3/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/JavaIntrospectionHelper.java
+++ b/branches/sca-java-1.3/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/branches/sca-java-1.3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/invocation/OSGiImplementationProvider.java b/branches/sca-java-1.3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/invocation/OSGiImplementationProvider.java
index 3bd18c3239..3b08bbc7dc 100644
--- a/branches/sca-java-1.3/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/invocation/OSGiImplementationProvider.java
+++ b/branches/sca-java-1.3/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/branches/sca-java-1.3/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/test/OSGiTestBundles.java b/branches/sca-java-1.3/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/test/OSGiTestBundles.java
index 2fd163aab6..93b4dee033 100644
--- a/branches/sca-java-1.3/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/test/OSGiTestBundles.java
+++ b/branches/sca-java-1.3/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/branches/sca-java-1.3/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/CodeGenerationHelper.java b/branches/sca-java-1.3/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/CodeGenerationHelper.java
index a23036db7c..b05715b54e 100644
--- a/branches/sca-java-1.3/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/CodeGenerationHelper.java
+++ b/branches/sca-java-1.3/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/branches/sca-java-1.3/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSFaultExceptionMapper.java b/branches/sca-java-1.3/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSFaultExceptionMapper.java
index fa32060447..a4f2facb4b 100644
--- a/branches/sca-java-1.3/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSFaultExceptionMapper.java
+++ b/branches/sca-java-1.3/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/branches/sca-java-1.3/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessor.java b/branches/sca-java-1.3/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessor.java
index 758dcb5dd7..1e1a0c4e94 100644
--- a/branches/sca-java-1.3/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessor.java
+++ b/branches/sca-java-1.3/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/branches/sca-java-1.3/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/WrapperBeanGenerator.java b/branches/sca-java-1.3/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/WrapperBeanGenerator.java
index d4b1d93ba3..412e6e14a6 100644
--- a/branches/sca-java-1.3/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/WrapperBeanGenerator.java
+++ b/branches/sca-java-1.3/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/WrapperBeanGenerator.java
@@ -46,7 +46,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);
}
@@ -90,7 +90,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/branches/sca-java-1.3/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceUtil.java b/branches/sca-java-1.3/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceUtil.java
index f8d705be13..2a9e3c5329 100644
--- a/branches/sca-java-1.3/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceUtil.java
+++ b/branches/sca-java-1.3/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/branches/sca-java-1.3/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/util/JavaXMLMapper.java b/branches/sca-java-1.3/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/util/JavaXMLMapper.java
index 811bb09fc4..54c0a3ec11 100644
--- a/branches/sca-java-1.3/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/util/JavaXMLMapper.java
+++ b/branches/sca-java-1.3/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) {
diff --git a/branches/sca-java-1.3/tools/java2wsdl/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/SchemaBuilder.java b/branches/sca-java-1.3/tools/java2wsdl/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/SchemaBuilder.java
index 218d72c62d..897700ffd9 100644
--- a/branches/sca-java-1.3/tools/java2wsdl/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/SchemaBuilder.java
+++ b/branches/sca-java-1.3/tools/java2wsdl/src/main/java/org/apache/tuscany/tools/java2wsdl/generate/SchemaBuilder.java
@@ -554,14 +554,19 @@ public class SchemaBuilder implements TuscanyJava2WSDLConstants {
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('.');