Permalink
Browse files

Generate type and service wrappers. Delegate service wrapper executio…

…n to the original service. Dynamically convert original types to type wrappers.
  • Loading branch information...
topolik committed Jul 2, 2014
1 parent 5ae55f0 commit c4b28b6fe1dc7d9132daa6d4f088f6b2dd313382
Showing with 1,268 additions and 1,218 deletions.
  1. +1 −1 osgi/modules/jax-ws-osgi/service-wsdl-soapui-project.xml
  2. +10 −4 osgi/modules/jaxws-cxf-services/INSTALL.txt
  3. +7 −1 osgi/modules/jaxws-cxf-services/pom.xml
  4. +18 −13 osgi/modules/jaxws-cxf-services/src/main/java/com/liferay/portal/service/osgi/Activator.java
  5. +0 −89 ...odules/jaxws-cxf-services/src/main/java/com/liferay/portal/service/osgi/wrapper/ClassWrapper.java
  6. +72 −0 ...es/jaxws-cxf-services/src/main/java/com/liferay/portal/service/osgi/wrapper/JavassistFactory.java
  7. +71 −0 ...ules/jaxws-cxf-services/src/main/java/com/liferay/portal/service/osgi/wrapper/JaxWsClassPool.java
  8. +60 −2 ...odules/jaxws-cxf-services/src/main/java/com/liferay/portal/service/osgi/wrapper/JaxWsService.java
  9. +47 −333 ...jaxws-cxf-services/src/main/java/com/liferay/portal/service/osgi/wrapper/JaxWsServiceFactory.java
  10. +0 −640 ...xws-cxf-services/src/main/java/com/liferay/portal/service/osgi/wrapper/JaxWsServiceGenerator.java
  11. +68 −0 ...es/jaxws-cxf-services/src/main/java/com/liferay/portal/service/osgi/wrapper/PrimitiveWrapper.java
  12. +0 −100 ...rvices/src/main/java/com/liferay/portal/service/osgi/wrapper/ResultWrappingInvocationHandler.java
  13. +36 −0 ...es/jaxws-cxf-services/src/main/java/com/liferay/portal/service/osgi/wrapper/TooDeepException.java
  14. +29 −0 ...modules/jaxws-cxf-services/src/main/java/com/liferay/portal/service/osgi/wrapper/TypeWrapper.java
  15. +681 −0 .../jaxws-cxf-services/src/main/java/com/liferay/portal/service/osgi/wrapper/TypeWrapperFactory.java
  16. +55 −0 ...xws-cxf-services/src/main/java/com/liferay/portal/service/osgi/wrapper/adapter/LocaleAdapter.java
  17. +2 −2 osgi/modules/jaxws-cxf-services/src/main/java/com/liferay/portal/service/remote/JAXWSService2.java
  18. +9 −1 ...modules/jaxws-cxf-services/src/main/java/com/liferay/portal/service/remote/JAXWSServiceImpl2.java
  19. +9 −32 ...odules/jaxws-cxf-services/src/main/java/com/liferay/portal/service/remote/JAXWSServiceObject.java
  20. +70 −0 ...es/jaxws-cxf-services/src/main/java/com/liferay/portal/service/remote/JaxWsServiceObjectImpl.java
  21. +23 −0 osgi/modules/jaxws-cxf-services/src/main/java/generated/package-info.java
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<con:soapui-project activeEnvironment="Default" name="service?wsdl" resourceRoot="" soapui-version="4.6.4" xmlns:con="http://eviware.com/soapui/config"><con:settings/><con:interface xsi:type="con:WsdlInterface" wsaVersion="NONE" name="JAXWSServiceImplServiceSoapBinding" type="wsdl" bindingName="{http://remote.service.portal.liferay.com/}JAXWSServiceImplServiceSoapBinding" soapVersion="1_1" anonymous="optional" definition="http://localhost:11112/soap/service?wsdl" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:settings/><con:definitionCache type="TEXT" rootPart="http://localhost:11112/soap/service?wsdl"><con:part><con:url>http://localhost:11112/soap/service?wsdl</con:url><con:content><![CDATA[<wsdl:definitions name="JAXWSServiceImplService" targetNamespace="http://remote.service.portal.liferay.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://remote.service.portal.liferay.com/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http">
<con:soapui-project activeEnvironment="Default" name="service?wsdl" resourceRoot="" soapui-version="4.6.4" abortOnError="false" runType="SEQUENTIAL" xmlns:con="http://eviware.com/soapui/config"><con:settings/><con:interface xsi:type="con:WsdlInterface" wsaVersion="NONE" name="JAXWSServiceImplServiceSoapBinding" type="wsdl" bindingName="{http://remote.service.portal.liferay.com/}JAXWSServiceImplServiceSoapBinding" soapVersion="1_1" anonymous="optional" definition="http://localhost:11112/soap/service?wsdl" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:settings/><con:definitionCache type="TEXT" rootPart="http://localhost:11112/soap/service?wsdl"><con:part><con:url>http://localhost:11112/soap/service?wsdl</con:url><con:content><![CDATA[<wsdl:definitions name="JAXWSServiceImplService" targetNamespace="http://remote.service.portal.liferay.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://remote.service.portal.liferay.com/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http">
<wsdl:types>
<xs:schema elementFormDefault="unqualified" targetNamespace="http://remote.service.portal.liferay.com/" version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="getObject" type="tns:getObject"/>
@@ -1,9 +1,6 @@
# 0. Update portal-ext.properties, configure correct versions required by CXF 3.0:
# 0. Update portal-ext.properties, configure correct version for portal-embedded spring.io:
module.framework.system.packages.extra=\
\
# CXF 3.0 dependencies
com.ctc.wstx;version="3.2.4",\
com.ctc.wstx.stax;version="3.2.4",\
org.springframework.core.io;version="3.1.0",\
... + all the current configuration from portal.properties ...
@@ -32,6 +29,7 @@ wget http://repo1.maven.org/maven2/org/apache/servicemix/bundles/org.apache.serv
wget http://repo1.maven.org/maven2/org/apache/servicemix/bundles/org.apache.servicemix.bundles.opensaml/2.6.0_3/org.apache.servicemix.bundles.opensaml-2.6.0_3.jar -O /tmp/cxf/org.apache.servicemix.bundles.opensaml-2.6.0_3.jar
# javassist-3.12.1.ga_1.jar
wget http://repo1.maven.org/maven2/org/apache/servicemix/bundles/org.apache.servicemix.bundles.javassist/3.12.1.ga_1/org.apache.servicemix.bundles.javassist-3.12.1.ga_1.jar -O /tmp/cxf/org.apache.servicemix.bundles.javassist-3.12.1.ga_1.jar
# 5: Initialize keystores in the project
cd PROJECT_DIR... (/opt/liferay.git/portal.git/osgi/modules/jaxws-cxf-services/)
cd keys
@@ -49,9 +47,17 @@ mvn package
install file:/opt/liferay.git/portal/osgi/modules/cxf-rt-ws-policy-patch/target/cxf-rt-ws-policy-patch-1.0.0.jar
refresh file:/tmp/cxf/apache-cxf-3.0.0-milestone2/lib/cxf-rt-ws-policy-3.0.0-milestone2.jar
# 8. Download nad install commons-lang
wget http://central.maven.org/maven2/commons-lang/commons-lang/2.6/commons-lang-2.6.jar -O /tmp/cxf/commons-lang-2.6.jar
install file:/tmp/cxf/commons-lang-2.6.jar
# 8: Run application
uninstall file:/opt/liferay.git/portal.git/osgi/modules/jaxws-cxf-services/target/jaxws-cxf-services-1.0.0.jar
resolve
refresh
felix:start file:/opt/liferay.git/portal.git/osgi/modules/jaxws-cxf-services/target/jaxws-cxf-services-1.0.0.jar
# 9: Go to http://localhost:11112/soap and verify WSDLs to contain some policies
@@ -21,6 +21,11 @@
<artifactId>org.apache.servicemix.bundles.javassist</artifactId>
<version>3.12.1.ga_1</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-core</artifactId>
@@ -109,7 +114,8 @@
com.liferay.portal.service.osgi,
com.liferay.portal.service.osgi.cxf,
com.liferay.portal.service.osgi.cxf.externalpolicy,
com.liferay.portal.service.osgi.wrapper,
com.liferay.portal.service.osgi.wrapper,
com.liferay.portal.service.osgi.wrapper.adapter,
com.liferay.portal.service.remote,
</Private-Package>
<!--<Import-Package>-->
@@ -30,7 +30,6 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
/**
* @author Tomas Polesovsky
@@ -57,12 +56,15 @@ public void start(BundleContext bundleContext) throws Exception {
try {
initExternalAttachmentsProvider();
registerPortalServices();
// TODO: simple test if it works with correct @WebService
JAXWSService2 service = new JAXWSServiceImpl2();
_serviceRegistration = _bundleContext.registerService(
service.getClass().getName(), service, null);
ServiceEvent artificialEvent = new ServiceEvent(
ServiceEvent.REGISTERED, _serviceRegistration.getReference());
serviceChanged(artificialEvent);
registerPortalServicesListener();
} catch (Throwable e) {
stop(_bundleContext);
@@ -75,6 +77,8 @@ public void start(BundleContext bundleContext) throws Exception {
@Override
public void stop(BundleContext bundleContext) {
_bundleContext.removeServiceListener(this);
if (_endpoints != null) {
for (Endpoint endpoint : _endpoints) {
endpoint.stop();
@@ -122,7 +126,7 @@ protected void registerPortalService(ServiceReference serviceReference) {
if (hasAnnotation(service.getClass(), PORTAL_REMOTE_SERVICE_ANNOTATION)) {
try {
// TODO: remove
if(counter==100){return;}counter++;
if(counter==2){return;}counter++;
HashMap<String, Object> configuration = new HashMap<String, Object>();
JaxWsServiceMetadata metadata = new JaxWsServiceMetadata();
@@ -216,21 +220,22 @@ protected Class getAnnotatedClass(Class cls, Class annotation) {
return getAnnotatedClass(cls.getSuperclass(), annotation);
}
protected void registerPortalServices() throws InvalidSyntaxException {
protected void registerPortalServicesListener() throws InvalidSyntaxException {
String filter = "(objectclass=*)";
_bundleContext.addServiceListener(this, filter);
ServiceReference[] existingServices =
_bundleContext.getServiceReferences(null, filter);
if (existingServices != null) {
for (int i = 0; i < existingServices.length; i++) {
ServiceEvent artificialEvent = new ServiceEvent(
ServiceEvent.REGISTERED, existingServices[i]);
serviceChanged(artificialEvent);
}
}
//TODO: make working
// if (existingServices != null) {
// for (int i = 0; i < existingServices.length; i++) {
// ServiceEvent artificialEvent = new ServiceEvent(
// ServiceEvent.REGISTERED, existingServices[i]);
//
// serviceChanged(artificialEvent);
// }
// }
}
protected void initExternalAttachmentsProvider() throws Exception {

This file was deleted.

Oops, something went wrong.
@@ -0,0 +1,72 @@
/**
* Copyright (c) 2000-present Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.portal.service.osgi.wrapper;
import javassist.ClassClassPath;
import javassist.CtClass;
import javassist.NotFoundException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author Tomas Polesovsky
*/
public class JavassistFactory {
public JavassistFactory(JaxWsClassPool pool) {
_pool = pool;
}
public CtClass asCtClass(Class aClass) throws NotFoundException {
return asCtClass(aClass.getName());
}
public CtClass asCtClass(String className) throws NotFoundException {
return _pool.getCtClass(className);
}
public boolean hasCtClass(String className) {
try {
asCtClass(className);
} catch (NotFoundException e) {
return false;
}
return true;
}
public static String generateClassName(Class serviceClass) {
return _GENERATED + serviceClass.getName();
}
protected void addClassLoader(ClassLoader classLoader) {
_pool.addClassLoader(classLoader);
}
protected void appendClassPath(Class fromClass) {
_pool.appendClassPath(new ClassClassPath(fromClass));
}
protected JaxWsClassPool getPool() {
return _pool;
}
private static final String _GENERATED = "generated.";
private JaxWsClassPool _pool;
}
@@ -0,0 +1,71 @@
/**
* Copyright (c) 2000-present Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.portal.service.osgi.wrapper;
import com.liferay.portal.kernel.util.AggregateClassLoader;
import javassist.ClassPool;
import javassist.Loader;
import java.net.URL;
import java.net.URLClassLoader;
import java.security.SecureClassLoader;
/**
* @author Tomas Polesovsky
*/
public class JaxWsClassPool extends javassist.ClassPool {
public JaxWsClassPool() {
super(true);
_aggregateClassLoader = new AggregateClassLoader(getClass().getClassLoader());
_classLoader = new DelegatingLoader(_aggregateClassLoader, this);
}
@Override
public ClassLoader getClassLoader() {
return _classLoader;
}
public void addClassLoader(ClassLoader cl) {
_aggregateClassLoader.addClassLoader(cl);
}
private AggregateClassLoader _aggregateClassLoader;
private ClassLoader _classLoader;
}
class DelegatingLoader extends Loader {
public DelegatingLoader(ClassLoader parent, ClassPool classPool) {
super(parent, classPool);
}
/**
* Always try parent first, we don't redefine existing classes.
* We also avoid ClassCastException by loading the same class only once
*/
@Override
protected Class loadClassByDelegation(String name)
throws ClassNotFoundException {
try {
return delegateToParent(name);
}
catch (ClassNotFoundException e) {
return null;
}
}
}
Oops, something went wrong.

0 comments on commit c4b28b6

Please sign in to comment.