You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@axis.apache.org by sa...@apache.org on 2012/05/18 07:18:10 UTC
svn commit: r1339975 - in /axis/axis2/java/core/trunk/modules/kernel: ./
src/org/apache/axis2/deployment/
src/org/apache/axis2/deployment/repository/util/
src/org/apache/axis2/deployment/util/
Author: sagara
Date: Fri May 18 05:18:09 2012
New Revision: 1339975
URL: http://svn.apache.org/viewvc?rev=1339975&view=rev
Log:
AXIS2-5322, refactored WSDL 1.1/ WSDL 2.0 based service deployment as a ServiceBuilderExtension. Now it's possible to use WSDLServiceBuilderExtension with other Deployers too.
Added:
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/deployment/WSDLServiceBuilderExtension.java (with props)
Modified:
axis/axis2/java/core/trunk/modules/kernel/pom.xml
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/deployment/DeploymentEngine.java
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/deployment/ServiceBuilder.java
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/deployment/ServiceDeployer.java
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/deployment/ServiceGroupBuilder.java
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/deployment/repository/util/ArchiveReader.java
axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java
Modified: axis/axis2/java/core/trunk/modules/kernel/pom.xml
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/pom.xml?rev=1339975&r1=1339974&r2=1339975&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/pom.xml (original)
+++ axis/axis2/java/core/trunk/modules/kernel/pom.xml Fri May 18 05:18:09 2012
@@ -89,8 +89,7 @@
</dependency>
<dependency>
<groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- <scope>test</scope>
+ <artifactId>commons-io</artifactId>
</dependency>
</dependencies>
<url>http://axis.apache.org/axis2/java/core/</url>
Modified: axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/deployment/DeploymentEngine.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/deployment/DeploymentEngine.java?rev=1339975&r1=1339974&r2=1339975&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/deployment/DeploymentEngine.java (original)
+++ axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/deployment/DeploymentEngine.java Fri May 18 05:18:09 2012
@@ -935,6 +935,31 @@ public abstract class DeploymentEngine i
if (this.servicesDir != null) {
serviceDeployer.setDirectory(this.servicesDir.getName());
}
+ /*
+ * TODO - For the moment we set WSDLServiceBuilderExtension and
+ * JAXWSServiceBuilderExtension to ServiceDeployer, but
+ * this need to be moved to axis2.xml.
+ */
+ ServiceBuilderExtension wsdlExt = new WSDLServiceBuilderExtension();
+ wsdlExt.init(configContext);
+ serviceDeployer.addServiceBuilderExtensions(wsdlExt);
+ String jaxwsExtClass = "org.apache.axis2.jaxws.framework.JAXWSServiceBuilderExtension";
+ try {
+ Class<?> clazz = Class.forName(jaxwsExtClass);
+ ServiceBuilderExtension jaxwsExt = (ServiceBuilderExtension) clazz.newInstance();
+ jaxwsExt.init(configContext);
+ serviceDeployer.addServiceBuilderExtensions(jaxwsExt);
+ } catch (ClassNotFoundException e) {
+ log.info("Can not instantiate " + jaxwsExtClass
+ + ", not abale to use JAX-WS with ServiceDeployer");
+ } catch (InstantiationException e) {
+ log.info("Can not instantiate " + jaxwsExtClass
+ + ", not abale to use JAX-WS with ServiceDeployer");
+ } catch (IllegalAccessException e) {
+ log.info("Can not instantiate " + jaxwsExtClass
+ + ", not abale to use JAX-WS with ServiceDeployer");
+ }
+
for (Map<String, Deployer> extensionMap : deployerMap.values()) {
for (Deployer deployer : extensionMap.values()) {
deployer.init(configContext);
Modified: axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/deployment/ServiceBuilder.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/deployment/ServiceBuilder.java?rev=1339975&r1=1339974&r2=1339975&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/deployment/ServiceBuilder.java (original)
+++ axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/deployment/ServiceBuilder.java Fri May 18 05:18:09 2012
@@ -58,7 +58,7 @@ import java.util.Map;
public class ServiceBuilder extends DescriptionBuilder {
private static final Log log = LogFactory.getLog(ServiceBuilder.class);
private AxisService service;
- private HashMap<String,AxisService> wsdlServiceMap = new HashMap<String,AxisService>();
+ private Map<String,AxisService> wsdlServiceMap = new HashMap<String,AxisService>();
public ServiceBuilder(ConfigurationContext configCtx, AxisService service) {
this.service = service;
@@ -909,7 +909,7 @@ public class ServiceBuilder extends Desc
}
- public void setWsdlServiceMap(HashMap<String,AxisService> wsdlServiceMap) {
+ public void setWsdlServiceMap(Map<String,AxisService> wsdlServiceMap) {
this.wsdlServiceMap = wsdlServiceMap;
}
Modified: axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/deployment/ServiceDeployer.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/deployment/ServiceDeployer.java?rev=1339975&r1=1339974&r2=1339975&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/deployment/ServiceDeployer.java (original)
+++ axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/deployment/ServiceDeployer.java Fri May 18 05:18:09 2012
@@ -54,6 +54,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import javax.xml.stream.XMLStreamException;
@@ -142,21 +143,17 @@ public class ServiceDeployer extends Abs
axisConfig.getServiceClassLoader(),
(File)axisConfig.getParameterValue(Constants.Configuration.ARTIFACTS_TEMP_DIR),
axisConfig.isChildFirstClassLoading());
- HashMap<String,AxisService> wsdlservice = archiveReader.processWSDLs(deploymentFileData);
- if (wsdlservice != null && wsdlservice.size() > 0) {
- for (AxisService service : wsdlservice.values()) {
- Iterator<AxisOperation> operations = service.getOperations();
- while (operations.hasNext()) {
- AxisOperation axisOperation = operations.next();
- axisConfig.getPhasesInfo().setOperationPhases(axisOperation);
- }
- }
- }
+ OMElement serviceMetaData = archiveReader.buildServiceDescription(
+ deploymentFileData.getAbsolutePath(), configCtx, isDirectory);
+ deploymentFileData.setServiceMetaData(serviceMetaData);
+ Map<String, AxisService> serviceMap = executeServiceBuilderExtensions(
+ deploymentFileData, configCtx);
+
AxisServiceGroup serviceGroup = new AxisServiceGroup(axisConfig);
serviceGroup.setServiceGroupClassLoader(deploymentFileData.getClassLoader());
ArrayList<AxisService> serviceList = archiveReader.processServiceGroup(
- deploymentFileData.getAbsolutePath(), deploymentFileData,
- serviceGroup, isDirectory, wsdlservice,
+ serviceMetaData, deploymentFileData,
+ serviceGroup, isDirectory, serviceMap,
configCtx);
URL location = deploymentFileData.getFile().toURL();
Modified: axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/deployment/ServiceGroupBuilder.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/deployment/ServiceGroupBuilder.java?rev=1339975&r1=1339974&r2=1339975&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/deployment/ServiceGroupBuilder.java (original)
+++ axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/deployment/ServiceGroupBuilder.java Fri May 18 05:18:09 2012
@@ -32,14 +32,14 @@ import org.apache.axis2.i18n.Messages;
import javax.xml.namespace.QName;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.Iterator;
+import java.util.Map;
public class ServiceGroupBuilder extends DescriptionBuilder {
private OMElement serviceElement;
- private HashMap<String,AxisService> wsdlServices;
+ private Map<String,AxisService> wsdlServices;
- public ServiceGroupBuilder(OMElement service, HashMap<String,AxisService> wsdlServices,
+ public ServiceGroupBuilder(OMElement service, Map<String,AxisService> wsdlServices,
ConfigurationContext configCtx) {
this.serviceElement = service;
this.wsdlServices = wsdlServices;
Added: axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/deployment/WSDLServiceBuilderExtension.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/deployment/WSDLServiceBuilderExtension.java?rev=1339975&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/deployment/WSDLServiceBuilderExtension.java (added)
+++ axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/deployment/WSDLServiceBuilderExtension.java Fri May 18 05:18:09 2012
@@ -0,0 +1,50 @@
+package org.apache.axis2.deployment;
+
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.deployment.repository.util.ArchiveReader;
+import org.apache.axis2.deployment.repository.util.DeploymentFileData;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.description.AxisService;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * <p>
+ * The class WSDLServiceBuilderExtension is a ServiceBuilderExtension which
+ * facilitate to generate AxisServices based on WSDL 1.1 and WSDL 2.0 documents.
+ * </p>
+ *
+ * <p>
+ * Axis2 ServiceDeployer use this extension.
+ * </p>
+ *
+ * @since 1.7.0
+ */
+public class WSDLServiceBuilderExtension extends AbstractServiceBuilderExtension {
+
+ private static Log log = LogFactory.getLog(WSDLServiceBuilderExtension.class);
+
+ public Map<String, AxisService> buildAxisServices(DeploymentFileData deploymentFileData)
+ throws DeploymentException {
+ ArchiveReader archiveReader = new ArchiveReader();
+ Map<String, AxisService> wsdlservices = archiveReader.processWSDLs(deploymentFileData);
+ if (wsdlservices != null && wsdlservices.size() > 0) {
+ for (AxisService service : wsdlservices.values()) {
+ Iterator<AxisOperation> operations = service.getOperations();
+ while (operations.hasNext()) {
+ AxisOperation axisOperation = operations.next();
+ try {
+ getConfigurationContext().getAxisConfiguration().getPhasesInfo()
+ .setOperationPhases(axisOperation);
+ } catch (AxisFault e) {
+ throw new DeploymentException(e);
+ }
+ }
+ }
+ }
+ return wsdlservices;
+ }
+}
Propchange: axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/deployment/WSDLServiceBuilderExtension.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/deployment/repository/util/ArchiveReader.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/deployment/repository/util/ArchiveReader.java?rev=1339975&r1=1339974&r2=1339975&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/deployment/repository/util/ArchiveReader.java (original)
+++ axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/deployment/repository/util/ArchiveReader.java Fri May 18 05:18:09 2012
@@ -61,6 +61,7 @@ import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
@@ -72,9 +73,16 @@ public class ArchiveReader implements De
ConfigurationContext configCtx)
throws XMLStreamException, AxisFault {
- DescriptionBuilder builder = new DescriptionBuilder(zin, configCtx);
- OMElement rootElement = builder.buildOM();
- String elementName = rootElement.getLocalName();
+ OMElement rootElement = buildServiceDescription(zin, configCtx);
+ return buildServiceGroup(rootElement, currentFile, axisServiceGroup, wsdlServices, configCtx);
+ }
+
+ public ArrayList<AxisService> buildServiceGroup(OMElement serviceMetaData,
+ DeploymentFileData currentFile, AxisServiceGroup axisServiceGroup,
+ Map<String, AxisService> wsdlServices, ConfigurationContext configCtx)
+ throws XMLStreamException, AxisFault {
+
+ String elementName = serviceMetaData.getLocalName();
if (TAG_SERVICE.equals(elementName)) {
AxisService axisService = null;
@@ -98,14 +106,14 @@ public class ArchiveReader implements De
ServiceBuilder serviceBuilder = new ServiceBuilder(configCtx, axisService);
serviceBuilder.setWsdlServiceMap(wsdlServices);
- AxisService service = serviceBuilder.populateService(rootElement);
+ AxisService service = serviceBuilder.populateService(serviceMetaData);
ArrayList<AxisService> serviceList = new ArrayList<AxisService>();
serviceList.add(service);
return serviceList;
} else if (TAG_SERVICE_GROUP.equals(elementName)) {
- ServiceGroupBuilder groupBuilder = new ServiceGroupBuilder(rootElement, wsdlServices,
- configCtx);
+ ServiceGroupBuilder groupBuilder = new ServiceGroupBuilder(serviceMetaData, wsdlServices,
+ configCtx);
return groupBuilder.populateServiceGroup(axisServiceGroup);
}
throw new AxisFault("Invalid services.xml found");
@@ -199,6 +207,37 @@ public class ArchiveReader implements De
}
}
}
+
+ public ArrayList<AxisService> processServiceGroup(OMElement serviceMetaData,
+ DeploymentFileData currentFile, AxisServiceGroup axisServiceGroup,
+ boolean extractService, Map<String, AxisService> wsdlServices,
+ ConfigurationContext configCtx)
+ throws AxisFault {
+
+ Object serviceMetaDataObject;
+ try {
+ if (serviceMetaData == null) {
+ serviceMetaDataObject = currentFile.getServiceMetaData();
+ if (serviceMetaDataObject != null && serviceMetaDataObject instanceof OMElement) {
+ serviceMetaData = (OMElement) serviceMetaDataObject;
+ }
+ }
+ if (serviceMetaData != null) {
+ if(extractService){
+ axisServiceGroup.setServiceGroupName(
+ DescriptionBuilder.getShortFileName(currentFile.getName()));
+ } else {
+ axisServiceGroup.setServiceGroupName(currentFile.getName());
+ }
+ return buildServiceGroup(serviceMetaData, currentFile, axisServiceGroup,
+ wsdlServices, configCtx);
+ }
+ throw new DeploymentException("Can not find service meta data file");
+ } catch (XMLStreamException e) {
+ throw new DeploymentException(e);
+ }
+
+ }
/**
* Creats AxisService.
@@ -558,4 +597,65 @@ public class ArchiveReader implements De
}
}
}
+
+ public OMElement buildServiceDescription(InputStream in, ConfigurationContext configCtx)
+ throws XMLStreamException {
+ DescriptionBuilder builder = new DescriptionBuilder(in, configCtx);
+ OMElement rootElement = builder.buildOM();
+ return rootElement;
+
+ }
+
+ public OMElement buildServiceDescription(String filename, ConfigurationContext configCtx,
+ boolean extractService) throws AxisFault {
+ InputStream in = null;
+ ZipInputStream zin = null;
+ try {
+ if (!extractService) {
+ in = new FileInputStream(filename);
+ zin = new ZipInputStream(in);
+ ZipEntry entry;
+ while ((entry = zin.getNextEntry()) != null) {
+ if (entry.getName().equalsIgnoreCase(SERVICES_XML)) {
+ return buildServiceDescription(zin, configCtx);
+ }
+ }
+ throw new DeploymentException(Messages.getMessage(
+ DeploymentErrorMsgs.SERVICE_XML_NOT_FOUND, filename));
+
+ } else {
+ File file = new File(filename, SERVICES_XML);
+ if (!file.exists()) {
+ file = new File(filename, SERVICES_XML.toLowerCase());
+ }
+ if (file.exists()) {
+ in = new FileInputStream(file);
+ return buildServiceDescription(in, configCtx);
+ } else {
+ throw new DeploymentException(
+ Messages.getMessage(DeploymentErrorMsgs.SERVICE_XML_NOT_FOUND));
+ }
+ }
+
+ } catch (Exception e) {
+ throw new DeploymentException(e);
+ } finally {
+ if (zin != null) {
+ try {
+ zin.close();
+ } catch (IOException e) {
+ log.info(Messages.getMessage("errorininputstreamclose"));
+ }
+ }
+ if (in != null) {
+ try {
+ in.close();
+ } catch (IOException e) {
+ log.info(Messages.getMessage("errorininputstreamclose"));
+ }
+ }
+
+ }
+ }
+
}
Modified: axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java?rev=1339975&r1=1339974&r2=1339975&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java (original)
+++ axis/axis2/java/core/trunk/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java Fri May 18 05:18:09 2012
@@ -53,6 +53,7 @@ import org.apache.axis2.util.PolicyUtil;
import org.apache.axis2.util.FaultyServiceData;
import org.apache.axis2.wsdl.WSDLConstants;
import org.apache.axis2.wsdl.WSDLUtil;
+import org.apache.commons.io.FileUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.neethi.PolicyComponent;
@@ -1995,25 +1996,37 @@ public class Utils {
* if an error occurs while scanning the file
*/
public static List<String> getListOfClasses(DeploymentFileData deploymentFileData) throws DeploymentException {
- try {
- FileInputStream fin = new FileInputStream(deploymentFileData.getAbsolutePath());
- try {
- ZipInputStream zin = new ZipInputStream(fin);
+ try {
+ List<String> classList = null;
+ if(DeploymentFileData.isServiceArchiveFile(deploymentFileData.getAbsolutePath())){
+ FileInputStream fin = new FileInputStream(deploymentFileData.getAbsolutePath());
try {
- ZipEntry entry;
- List<String> classList = new ArrayList<String>();
- while ((entry = zin.getNextEntry()) != null) {
- String name = entry.getName();
- if (name.endsWith(".class")) {
- classList.add(getClassNameFromResourceName(name));
+ ZipInputStream zin = new ZipInputStream(fin);
+ try {
+ ZipEntry entry;
+ classList = new ArrayList<String>();
+ while ((entry = zin.getNextEntry()) != null) {
+ String name = entry.getName();
+ if (name.endsWith(".class")) {
+ classList.add(getClassNameFromResourceName(name));
+ }
}
+ return classList;
+ } finally {
+ zin.close();
}
- return classList;
} finally {
- zin.close();
+ fin.close();
+ }
+ } else {
+ File directory = deploymentFileData.getFile();
+ classList = new ArrayList<String>();
+ for(Iterator<File> fileItr= FileUtils.iterateFiles(directory, new String[]{"class"}, true); fileItr.hasNext();){
+ String fileName = fileItr.next().getPath();
+ String className = getClassNameFromResourceName(fileName.replace(directory.getPath(), "").substring(1));
+ classList.add(className);
}
- } finally {
- fin.close();
+ return classList;
}
} catch (IOException e) {
log.debug(Messages.getMessage(DeploymentErrorMsgs.DEPLOYING_EXCEPTION, e.getMessage()), e);