You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by di...@apache.org on 2005/12/16 18:18:08 UTC
svn commit: r357187 [8/25] - in
/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2: ./
addressing/ client/ client/async/ context/ deployment/ deployment/listener/
deployment/repository/util/ deployment/scheduler/ deployment/util/
descripti...
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/repository/util/ArchiveReader.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/repository/util/ArchiveReader.java?rev=357187&r1=357186&r2=357187&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/repository/util/ArchiveReader.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/repository/util/ArchiveReader.java Fri Dec 16 09:13:57 2005
@@ -1,22 +1,30 @@
/*
- * Copyright 2004,2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
package org.apache.axis2.deployment.repository.util;
-import org.apache.axis2.deployment.*;
+import org.apache.axis2.deployment.DeploymentConstants;
+import org.apache.axis2.deployment.DeploymentEngine;
+import org.apache.axis2.deployment.DeploymentErrorMsgs;
+import org.apache.axis2.deployment.DeploymentException;
+import org.apache.axis2.deployment.DescriptionBuilder;
+import org.apache.axis2.deployment.ModuleBuilder;
+import org.apache.axis2.deployment.ServiceBuilder;
+import org.apache.axis2.deployment.ServiceGroupBuilder;
import org.apache.axis2.description.AxisDescWSDLComponentFactory;
import org.apache.axis2.description.AxisService;
import org.apache.axis2.description.AxisServiceGroup;
@@ -35,7 +43,15 @@
import javax.wsdl.WSDLException;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamException;
-import java.io.*;
+import java.io.BufferedOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
@@ -44,40 +60,235 @@
import java.util.zip.ZipOutputStream;
public class ArchiveReader implements DeploymentConstants {
-
private Log log = LogFactory.getLog(getClass());
+ private ArrayList buildServiceGroup(InputStream zin, DeploymentEngine engine,
+ AxisServiceGroup axisServiceGroup, HashMap wsdlServices, AxisConfiguration axisConfig)
+ throws XMLStreamException, DeploymentException {
+ DescriptionBuilder builder;
+ String rootelementName;
+
+ builder = new DescriptionBuilder(zin, axisConfig);
+
+ OMElement services = builder.buildOM();
+
+ rootelementName = services.getLocalName();
+
+ if (SERVICE_ELEMENT.equals(rootelementName)) {
+ AxisService axisService = (AxisService) wsdlServices.get(
+ DescriptionBuilder.getShortFileName(
+ engine.getCurrentFileItem().getName()));
+
+ if (axisService == null) {
+ axisService = new AxisService(
+ DescriptionBuilder.getShortFileName(engine.getCurrentFileItem().getName()));
+ }
+
+ axisService.setParent(axisServiceGroup);
+ axisService.setClassLoader(engine.getCurrentFileItem().getClassLoader());
+
+ ServiceBuilder serviceBuilder = new ServiceBuilder(axisConfig, axisService);
+ AxisService service = serviceBuilder.populateService(services);
+ ArrayList serviceList = new ArrayList();
+
+ serviceList.add(service);
+
+ return serviceList;
+
+// engine.getCurrentFileItem().getDeploybleServices().add(axisService);
+ } else if (SERVICE_GROUP_ELEMENT.equals(rootelementName)) {
+ ServiceGroupBuilder groupBuilder = new ServiceGroupBuilder(services, wsdlServices,
+ axisConfig);
+
+ return groupBuilder.populateServiceGroup(axisServiceGroup);
+ }
+
+ return null;
+ }
+
+ /**
+ * This method first check whether the given module is there in the user home dirctory if so return
+ * that , else try to read the given module form classpath (from resources ) if found first get the module.mar
+ * file from the resourceStream and write that into user home/axis2home/nodule directory
+ *
+ * @param moduleName
+ * @return
+ * @throws DeploymentException
+ */
+ public File creatModuleArchivefromResource(String moduleName, String axis2repository)
+ throws DeploymentException {
+ File modulearchiveFile;
+ File modules;
+
+ try {
+ int BUFFER = 2048;
+
+ if (axis2repository == null) {
+ String userHome = System.getProperty("user.home");
+ File userHomedir = new File(userHome);
+ File repository = new File(userHomedir, ".axis2home");
+
+ modules = new File(repository, "modules");
+ } else {
+ modules = new File(axis2repository, "modules");
+ }
+
+ String modulearchiveName = moduleName + ".mar";
+
+ modulearchiveFile = new File(modules, modulearchiveName);
+
+ if (modulearchiveFile.exists()) {
+ return modulearchiveFile;
+ }
+
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ InputStream in = cl.getResourceAsStream("modules/" + moduleName + ".mar");
+
+ if (in == null) {
+ in = cl.getResourceAsStream("modules/" + moduleName + ".jar");
+ }
+
+ if (in == null) {
+ throw new DeploymentException(
+ Messages.getMessage(
+ DeploymentErrorMsgs.MODULEXML_NOT_FOUND_FOR_THE_MODULE, moduleName));
+ } else {
+ if (!modules.exists()) {
+ modules.mkdirs();
+ }
+
+ modulearchiveFile.createNewFile();
+
+ FileOutputStream dest = new FileOutputStream(modulearchiveFile);
+ ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(dest));
+ byte data[] = new byte[BUFFER];
+ ZipInputStream zin;
+
+ zin = new ZipInputStream(in);
+
+ ZipEntry entry;
+
+ while ((entry = zin.getNextEntry()) != null) {
+ ZipEntry zip = new ZipEntry(entry);
+
+ out.putNextEntry(zip);
+
+ int count;
+
+ while ((count = zin.read(data, 0, BUFFER)) != -1) {
+ out.write(data, 0, count);
+ }
+ }
+
+ out.close();
+ zin.close();
+ }
+ } catch (Exception e) {
+ throw new DeploymentException(e);
+ }
+
+ return modulearchiveFile;
+ }
+
+ /**
+ * This method will readServiceArchive the given jar or aar.
+ * it take two arguments filename and refereance to DeployEngine
+ *
+ * @param filename
+ * @param engine
+ */
+ public ArrayList processServiceGroup(String filename, DeploymentEngine engine,
+ AxisServiceGroup axisServiceGroup, boolean extractService, HashMap wsdls,
+ AxisConfiguration axisConfig)
+ throws DeploymentException {
+
+ // get attribute values
+ if (!extractService) {
+ ZipInputStream zin;
+
+ try {
+ zin = new ZipInputStream(new FileInputStream(filename));
+
+ ZipEntry entry;
+
+ while ((entry = zin.getNextEntry()) != null) {
+ if (entry.getName().equals(SERVICEXML)) {
+ axisServiceGroup.setServiceGroupName(
+ DescriptionBuilder.getShortFileName(
+ engine.getCurrentFileItem().getName()));
+
+ return buildServiceGroup(zin, engine, axisServiceGroup, wsdls, axisConfig);
+ }
+ }
+
+ // zin.close();
+ throw new DeploymentException(
+ Messages.getMessage(DeploymentErrorMsgs.SERVICE_XML_NOT_FOUND, filename));
+ } catch (Exception e) {
+ throw new DeploymentException(e);
+ }
+ } else {
+ File file = new File(filename, SERVICEXML);
+
+ if (file.exists()) {
+ InputStream in;
+
+ try {
+ in = new FileInputStream(file);
+ axisServiceGroup.setServiceGroupName(engine.getCurrentFileItem().getName());
+
+ return buildServiceGroup(in, engine, axisServiceGroup, wsdls, axisConfig);
+ } catch (FileNotFoundException e) {
+ throw new DeploymentException(
+ Messages.getMessage(DeploymentErrorMsgs.FILE_NOT_FOUND, e.getMessage()));
+ } catch (XMLStreamException e) {
+ throw new DeploymentException(
+ Messages.getMessage(DeploymentErrorMsgs.XTZX_EXCEPTION, e.getMessage()));
+ }
+ } else {
+ throw new DeploymentException(
+ Messages.getMessage(DeploymentErrorMsgs.SERVICE_XML_NOT_FOUND));
+ }
+ }
+ }
+
private AxisService processWSDLFile(InputStream in) throws DeploymentException {
try {
- WOMBuilder builder = WOMBuilderFactory.getBuilder(org.apache.wsdl.WSDLConstants.WSDL_1_1);
+ WOMBuilder builder =
+ WOMBuilderFactory.getBuilder(org.apache.wsdl.WSDLConstants.WSDL_1_1);
WSDLVersionWrapper wsdlVersionWrapper = builder.build(in,
new AxisDescWSDLComponentFactory());
WSDLDescription womDescription = wsdlVersionWrapper.getDescription();
- //removing binding
-// Map bindings = wsdlVersionWrapper.getDefinition().getBindings();
-// Iterator binfingIterator = bindings.keySet().iterator();
-// while (binfingIterator.hasNext()) {
-// Object o = binfingIterator.next();
-// bindings.remove(o) ;
-//
-// }
- Iterator iterator = womDescription.getServices().keySet()
- .iterator();
+ // removing binding
+ // Map bindings = wsdlVersionWrapper.getDefinition().getBindings();
+ // Iterator binfingIterator = bindings.keySet().iterator();
+ // while (binfingIterator.hasNext()) {
+ // Object o = binfingIterator.next();
+ // bindings.remove(o) ;
+ //
+ // }
+ Iterator iterator = womDescription.getServices().keySet().iterator();
+
if (iterator.hasNext()) {
+
// remove <wsdl:service> and <wsdl:binding> elements from the service
// description we read in as we will be replacing them anyway.
- WSDLServiceImpl serviceimpl = (WSDLServiceImpl)
- womDescription.getServices().get(iterator.next());
+ WSDLServiceImpl serviceimpl =
+ (WSDLServiceImpl) womDescription.getServices().get(iterator.next());
AxisService service = new AxisService();
+
service.setName(serviceimpl.getName().getLocalPart());
service.setWSDLDefinition(wsdlVersionWrapper.getDefinition());
+
return service;
-// depengine.getCurrentFileItem().addService(service);
+
+// depengine.getCurrentFileItem().addService(service);
}
} catch (WSDLException e) {
throw new DeploymentException(e);
}
+
return null;
}
@@ -88,34 +299,42 @@
* @param depengine <code>DeploymentEngine</code>
* @throws DeploymentException <code>DeploymentException</code>
*/
- public HashMap processWSDLs(ArchiveFileData file, DeploymentEngine depengine) throws DeploymentException {
+ public HashMap processWSDLs(ArchiveFileData file, DeploymentEngine depengine)
+ throws DeploymentException {
File serviceFile = file.getFile();
- //to store service come from wsdl files
+
+ // to store service come from wsdl files
HashMap servicesMap = new HashMap();
boolean isDirectory = serviceFile.isDirectory();
+
if (isDirectory) {
try {
File meta_inf = new File(serviceFile, META_INF);
+
if (!meta_inf.exists()) {
- throw new DeploymentException(Messages.getMessage(
- DeploymentErrorMsgs.NO_META_INF,
- serviceFile.getName()));
+ throw new DeploymentException(
+ Messages.getMessage(
+ DeploymentErrorMsgs.NO_META_INF, serviceFile.getName()));
}
- File files [] = meta_inf.listFiles();
+
+ File files[] = meta_inf.listFiles();
+
for (int i = 0; i < files.length; i++) {
File file1 = files[i];
String fileName = file1.getName();
+
if (fileName.endsWith(".wsdl") || fileName.endsWith(".WSDL")) {
InputStream in = new FileInputStream(file1);
AxisService service = processWSDLFile(in);
+
servicesMap.put(service.getName(), service);
+
try {
in.close();
} catch (IOException e) {
log.info(e);
}
}
-
}
} catch (FileNotFoundException e) {
throw new DeploymentException(e);
@@ -123,29 +342,35 @@
throw new DeploymentException(e);
}
} else {
-
ZipInputStream zin;
+
try {
zin = new ZipInputStream(new FileInputStream(serviceFile));
+
ZipEntry entry;
- byte[] buf = new byte[1024];
+ byte[] buf = new byte[1024];
int read;
ByteArrayOutputStream out;
+
while ((entry = zin.getNextEntry()) != null) {
String entryName = entry.getName();
- if ((entryName.startsWith(META_INF) ||
- entryName.startsWith(META_INF.toLowerCase()))
- && (entryName.endsWith(".wsdl")
- || entryName.endsWith(".WSDL"))) {
+
+ if ((entryName.startsWith(META_INF) || entryName.startsWith(
+ META_INF.toLowerCase())) && (entryName.endsWith(
+ ".wsdl") || entryName.endsWith(".WSDL"))) {
out = new ByteArrayOutputStream();
+
while ((read = zin.read(buf)) > 0) {
out.write(buf, 0, read);
}
+
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
AxisService service = processWSDLFile(in);
+
servicesMap.put(service.getName(), service);
}
}
+
try {
zin.close();
} catch (IOException e) {
@@ -157,224 +382,79 @@
throw new DeploymentException(e);
}
}
+
return servicesMap;
}
- /**
- * This method will readServiceArchive the given jar or aar.
- * it take two arguments filename and refereance to DeployEngine
- *
- * @param filename
- * @param engine
- */
- public ArrayList processServiceGroup(String filename,
- DeploymentEngine engine,
- AxisServiceGroup axisServiceGroup,
- boolean extractService,
- HashMap wsdls,
- AxisConfiguration axisConfig)
+ public void readModuleArchive(String filename, DeploymentEngine engine,
+ ModuleDescription module, boolean explodedDir,
+ AxisConfiguration axisConfig)
throws DeploymentException {
- // get attribute values
- if (!extractService) {
- ZipInputStream zin;
- try {
- zin = new ZipInputStream(new FileInputStream(filename));
- ZipEntry entry;
- while ((entry = zin.getNextEntry()) != null) {
- if (entry.getName().equals(SERVICEXML)) {
- axisServiceGroup.setServiceGroupName(DescriptionBuilder.getShortFileName(
- engine.getCurrentFileItem().getName()));
- return buildServiceGroup(zin, engine, axisServiceGroup, wsdls, axisConfig);
- }
- }
- // zin.close();
- throw new DeploymentException(
- Messages.getMessage(
- DeploymentErrorMsgs.SERVICE_XML_NOT_FOUND,
- filename));
- } catch (Exception e) {
- throw new DeploymentException(e);
- }
- } else {
- File file = new File(filename, SERVICEXML);
- if (file.exists()) {
- InputStream in;
- try {
- in = new FileInputStream(file);
- axisServiceGroup.setServiceGroupName(engine.getCurrentFileItem().getName());
- return buildServiceGroup(in, engine, axisServiceGroup, wsdls, axisConfig);
- } catch (FileNotFoundException e) {
- throw new DeploymentException(Messages.getMessage(DeploymentErrorMsgs.FILE_NOT_FOUND
- , e.getMessage()));
- } catch (XMLStreamException e) {
- throw new DeploymentException(Messages.getMessage(DeploymentErrorMsgs.XTZX_EXCEPTION
- , e.getMessage()));
- }
- } else {
- throw new DeploymentException(
- Messages.getMessage(DeploymentErrorMsgs.SERVICE_XML_NOT_FOUND));
- }
- }
- }
- private ArrayList buildServiceGroup(InputStream zin, DeploymentEngine engine,
- AxisServiceGroup axisServiceGroup, HashMap wsdlServices,
- AxisConfiguration axisConfig)
- throws XMLStreamException, DeploymentException {
- DescriptionBuilder builder;
- String rootelementName;
- builder = new DescriptionBuilder(zin, axisConfig);
- OMElement services = builder.buildOM();
- rootelementName = services.getLocalName();
- if (SERVICE_ELEMENT.equals(rootelementName)) {
- AxisService axisService = (AxisService) wsdlServices.get(
- DescriptionBuilder.getShortFileName(engine.getCurrentFileItem().getName()));
- if (axisService == null) {
- axisService = new AxisService(
- DescriptionBuilder.getShortFileName(engine.getCurrentFileItem().getName()));
- }
- axisService.setParent(axisServiceGroup);
- axisService.setClassLoader(engine.getCurrentFileItem().getClassLoader());
- ServiceBuilder serviceBuilder = new ServiceBuilder(axisConfig, axisService);
- AxisService service = serviceBuilder.populateService(services);
- ArrayList serviceList = new ArrayList();
- serviceList.add(service);
- return serviceList;
-// engine.getCurrentFileItem().getDeploybleServices().add(axisService);
- } else if (SERVICE_GROUP_ELEMENT.equals(rootelementName)) {
- ServiceGroupBuilder groupBuilder = new ServiceGroupBuilder(services, wsdlServices, axisConfig);
- return groupBuilder.populateServiceGroup(axisServiceGroup);
- }
- return null;
- }
-
- public void readModuleArchive(String filename,
- DeploymentEngine engine,
- ModuleDescription module, boolean explodedDir, AxisConfiguration axisConfig)
- throws DeploymentException {
// get attribute values
boolean foundmoduleXML = false;
+
if (!explodedDir) {
ZipInputStream zin;
+
try {
zin = new ZipInputStream(new FileInputStream(filename));
+
ZipEntry entry;
+
while ((entry = zin.getNextEntry()) != null) {
if (entry.getName().equals(MODULEXML)) {
foundmoduleXML = true;
+
ModuleBuilder builder = new ModuleBuilder(zin, module, axisConfig);
- //setting module name
- module.setName(new QName(DescriptionBuilder.getShortFileName(
- engine.getCurrentFileItem().getServiceName())));
+
+ // setting module name
+ module.setName(
+ new QName(
+ DescriptionBuilder.getShortFileName(
+ engine.getCurrentFileItem().getServiceName())));
builder.populateModule();
+
break;
}
}
+
zin.close();
+
if (!foundmoduleXML) {
- throw new DeploymentException(Messages.getMessage(
- DeploymentErrorMsgs.MODULEXML_NOT_FOUND_FOR_THE_MODULE, filename));
+ throw new DeploymentException(
+ Messages.getMessage(
+ DeploymentErrorMsgs.MODULEXML_NOT_FOUND_FOR_THE_MODULE, filename));
}
} catch (Exception e) {
throw new DeploymentException(e);
}
} else {
File file = new File(filename, MODULEXML);
+
if (file.exists()) {
InputStream in;
+
try {
in = new FileInputStream(file);
+
ModuleBuilder builder = new ModuleBuilder(in, module, axisConfig);
+
// setting module name
- module.setName(new QName(DescriptionBuilder.getShortFileName(
- engine.getCurrentFileItem().getServiceName())));
+ module.setName(
+ new QName(
+ DescriptionBuilder.getShortFileName(
+ engine.getCurrentFileItem().getServiceName())));
builder.populateModule();
} catch (FileNotFoundException e) {
- throw new DeploymentException(Messages.getMessage(DeploymentErrorMsgs.FILE_NOT_FOUND
- , e.getMessage()));
+ throw new DeploymentException(
+ Messages.getMessage(DeploymentErrorMsgs.FILE_NOT_FOUND, e.getMessage()));
}
} else {
- throw new DeploymentException(Messages.getMessage(
- DeploymentErrorMsgs.MODULEXML_NOT_FOUND_FOR_THE_MODULE, filename));
- }
-
- }
- }
-
-
- /**
- * This method first check whether the given module is there in the user home dirctory if so return
- * that , else try to read the given module form classpath (from resources ) if found first get the module.mar
- * file from the resourceStream and write that into user home/axis2home/nodule directory
- *
- * @param moduleName
- * @return
- * @throws DeploymentException
- */
- public File creatModuleArchivefromResource(String moduleName,
- String axis2repository) throws DeploymentException {
- File modulearchiveFile;
- File modules;
- try {
- int BUFFER = 2048;
- if (axis2repository == null) {
- String userHome = System.getProperty("user.home");
- File userHomedir = new File(userHome);
- File repository = new File(userHomedir, ".axis2home");
- modules = new File(repository, "modules");
- } else {
- modules = new File(axis2repository, "modules");
- }
- String modulearchiveName = moduleName + ".mar";
- modulearchiveFile = new File(modules, modulearchiveName);
- if (modulearchiveFile.exists()) {
- return modulearchiveFile;
- }
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- InputStream in = cl.getResourceAsStream("modules/" + moduleName + ".mar");
- if (in == null) {
- in = cl.getResourceAsStream("modules/" + moduleName + ".jar");
- }
- if (in == null) {
- throw new DeploymentException(Messages.getMessage(
- DeploymentErrorMsgs.MODULEXML_NOT_FOUND_FOR_THE_MODULE, moduleName));
- } else {
- if (!modules.exists()) {
- modules.mkdirs();
- }
- modulearchiveFile.createNewFile();
- FileOutputStream dest = new
- FileOutputStream(modulearchiveFile);
- ZipOutputStream out = new ZipOutputStream(new
- BufferedOutputStream(dest));
- byte data[] = new byte[BUFFER];
- ZipInputStream zin;
- zin = new ZipInputStream(in);
- ZipEntry entry;
- while ((entry = zin.getNextEntry()) != null) {
- ZipEntry zip = new ZipEntry(entry);
- out.putNextEntry(zip);
- int count;
- while ((count = zin.read(data, 0, BUFFER)) != -1) {
- out.write(data, 0, count);
- }
- }
- out.close();
- zin.close();
+ throw new DeploymentException(
+ Messages.getMessage(
+ DeploymentErrorMsgs.MODULEXML_NOT_FOUND_FOR_THE_MODULE, filename));
}
-
- } catch (Exception e) {
- throw new DeploymentException(e);
}
- return modulearchiveFile;
}
-
}
-
-
-
-
-
-
-
-
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/repository/util/WSInfo.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/repository/util/WSInfo.java?rev=357187&r1=357186&r2=357187&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/repository/util/WSInfo.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/repository/util/WSInfo.java Fri Dec 16 09:13:57 2005
@@ -1,26 +1,26 @@
/*
- * Copyright 2004,2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
-package org.apache.axis2.deployment.repository.util;
+package org.apache.axis2.deployment.repository.util;
public class WSInfo {
-
private String fileName;
private long lastModifiedDate;
+
/**
* To check whether the file is a module or a servise
*/
@@ -41,19 +41,19 @@
return fileName;
}
- public void setFileName(String fileName) {
- this.fileName = fileName;
- }
-
public long getLastModifiedDate() {
return lastModifiedDate;
}
- public void setLastModifiedDate(long lastmodifieddate) {
- this.lastModifiedDate = lastmodifieddate;
- }
-
public int getType() {
return type;
+ }
+
+ public void setFileName(String fileName) {
+ this.fileName = fileName;
+ }
+
+ public void setLastModifiedDate(long lastmodifieddate) {
+ this.lastModifiedDate = lastmodifieddate;
}
}
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/repository/util/WSInfoList.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/repository/util/WSInfoList.java?rev=357187&r1=357186&r2=357187&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/repository/util/WSInfoList.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/repository/util/WSInfoList.java Fri Dec 16 09:13:57 2005
@@ -1,18 +1,19 @@
/*
- * Copyright 2004,2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
package org.apache.axis2.deployment.repository.util;
@@ -25,12 +26,12 @@
import java.util.List;
public class WSInfoList implements DeploymentConstants {
+
/**
* This is to store all the jar files in a specified folder (WEB_INF)
*/
private static List jarList = new ArrayList();
-
- private boolean compair = false; // to check wheter the checking is dond
+ private boolean compair = false; // to check wheter the checking is dond
/**
* All the curently updated jars
@@ -47,13 +48,6 @@
}
/**
- * This method is used to initialize the vector
- */
- public void init() {
- jarList.clear();
- }
-
- /**
* First it check whether the file is already available in the
* system call isFileExist , if it is not deployed yet then it will add
* that to jarList and to the deployment engine as new service or module
@@ -70,99 +64,71 @@
*/
public void addWSInfoItem(File file, int type) {
switch (type) {
- case SERVICE:
- {
- if (!isFileExist(file.getName())) { // chacking whether the file is already deployed
- WSInfo wsInfo = new WSInfo(file.getName(),
- file.lastModified(),
- SERVICE);
- jarList.add(wsInfo);
- ArchiveFileData archiveFileData = new ArchiveFileData(file, SERVICE);
- deployer.addWSToDeploy(archiveFileData);//to inform that new web service is deployed
- } else {
- if (deployer.isHotUpdate()) {
- WSInfo tempWSInfo = getFileItem(file.getName());
- if (isModified(file, tempWSInfo)) { // caheck whether file is updated
- tempWSInfo.setLastModifiedDate(file.lastModified());
- WSInfo wsInfo = new WSInfo(tempWSInfo.getFileName(),
- tempWSInfo.getLastModifiedDate(),
- SERVICE);
- deployer.addWSToUndeploy(wsInfo); // add entry to undeploy list
- ArchiveFileData archiveFileData = new ArchiveFileData(file, SERVICE);
- deployer.addWSToDeploy(archiveFileData); // add entry to deploylist
+ case SERVICE : {
+ if (!isFileExist(file.getName())) { // chacking whether the file is already deployed
+ WSInfo wsInfo = new WSInfo(file.getName(), file.lastModified(), SERVICE);
+
+ jarList.add(wsInfo);
+
+ ArchiveFileData archiveFileData = new ArchiveFileData(file, SERVICE);
+
+ deployer.addWSToDeploy(archiveFileData); // to inform that new web service is deployed
+ } else {
+ if (deployer.isHotUpdate()) {
+ WSInfo tempWSInfo = getFileItem(file.getName());
+
+ if (isModified(file, tempWSInfo)) { // caheck whether file is updated
+ tempWSInfo.setLastModifiedDate(file.lastModified());
+
+ WSInfo wsInfo = new WSInfo(tempWSInfo.getFileName(),
+ tempWSInfo.getLastModifiedDate(), SERVICE);
+
+ deployer.addWSToUndeploy(wsInfo); // add entry to undeploy list
- }
+ ArchiveFileData archiveFileData = new ArchiveFileData(file, SERVICE);
+
+ deployer.addWSToDeploy(archiveFileData); // add entry to deploylist
}
}
- break;
}
- case MODULE:
- {
- if (!isFileExist(file.getName())) { // chacking whether the file is already deployed
- WSInfo wsInfo = new WSInfo(file.getName(),
- file.lastModified(),
- MODULE);
- jarList.add(wsInfo);
- ArchiveFileData archiveFileData = new ArchiveFileData(file, MODULE);
- deployer.addWSToDeploy(archiveFileData);//to inform that new web service is deployed
- } else {
-// if (deployer.isHotUpdate()) {
-// WSInfo tempWSInfo = getFileItem(file.getName());
-// if (isModified(file, tempWSInfo)) {
-// tempWSInfo.setLastModifiedDate(file.lastModified());
-// WSInfo wsInfo = new WSInfo(tempWSInfo.getFileName(),
-// tempWSInfo.getLastModifiedDate(),
-// MODULE);
-// deployer.addWSToUndeploy(wsInfo); // add entry to undeploy list
-// ArchiveFileData archiveFileData = new ArchiveFileData(file, MODULE);
-// deployer.addWSToDeploy(archiveFileData); // add entry to deploylist
+
+ break;
+ }
+
+ case MODULE : {
+ if (!isFileExist(file.getName())) { // chacking whether the file is already deployed
+ WSInfo wsInfo = new WSInfo(file.getName(), file.lastModified(), MODULE);
+
+ jarList.add(wsInfo);
+
+ ArchiveFileData archiveFileData = new ArchiveFileData(file, MODULE);
+
+ deployer.addWSToDeploy(archiveFileData); // to inform that new web service is deployed
+ } else {
+
+// if (deployer.isHotUpdate()) {
+// WSInfo tempWSInfo = getFileItem(file.getName());
+// if (isModified(file, tempWSInfo)) {
+// tempWSInfo.setLastModifiedDate(file.lastModified());
+// WSInfo wsInfo = new WSInfo(tempWSInfo.getFileName(),
+// tempWSInfo.getLastModifiedDate(),
+// MODULE);
+// deployer.addWSToUndeploy(wsInfo); // add entry to undeploy list
+// ArchiveFileData archiveFileData = new ArchiveFileData(file, MODULE);
+// deployer.addWSToDeploy(archiveFileData); // add entry to deploylist
//
-// }
-// }
- }
- break;
+// }
+// }
}
- }
- String jarname = file.getName();
- currentJars.add(jarname);
- compair = true;
- }
- /**
- * This method is to use to check the file exist and if so
- * it will return related wsinfo object to the file else return null;
- *
- * @param filename
- */
- public WSInfo getFileItem(String filename) {
- int sise = jarList.size();
- for (int i = 0; i < sise; i++) {
- WSInfo wsInfo = (WSInfo) jarList.get(i);
- if (wsInfo.getFileName().equals(filename)) {
- return wsInfo;
+ break;
}
}
- return null;
- }
- /**
- * comapre the last update dates of both files and if those are differ
- * that will assume as the file is been modified
- *
- * @param file
- * @param wsInfo
- */
- public boolean isModified(File file, WSInfo wsInfo) {
- return (wsInfo.getLastModifiedDate() != file.lastModified());
- }
+ String jarname = file.getName();
- /**
- * to check whether the file is alredy in the list
- *
- * @param filename
- */
- public boolean isFileExist(String filename) {
- return !(getFileItem(filename) == null);
+ currentJars.add(jarname);
+ compair = true;
}
/**
@@ -173,48 +139,65 @@
* that is hot undeployment
*/
public void checkForUndeploye() {
- if(!compair){
+ if (!compair) {
return;
} else {
compair = false;
}
+
Iterator iter = jarList.listIterator();
int size = currentJars.size();
List tempvector = new ArrayList();
+
tempvector.clear();
+
String filename;
- boolean exist ;
+ boolean exist;
+
while (iter.hasNext()) {
WSInfo fileitem = (WSInfo) iter.next();
- if(fileitem.getType() == MODULE){
+
+ if (fileitem.getType() == MODULE) {
continue;
}
+
exist = false;
+
for (int i = 0; i < size; i++) {
filename = (String) currentJars.get(i);
+
if (filename.equals(fileitem.getFileName())) {
exist = true;
+
break;
}
}
if (!exist) {
tempvector.add(fileitem);
- WSInfo wsInfo = new WSInfo(fileitem.getFileName(),
- fileitem.getLastModifiedDate());
- deployer.addWSToUndeploy(wsInfo);//this is to be undeploye
- }
+ WSInfo wsInfo = new WSInfo(fileitem.getFileName(), fileitem.getLastModifiedDate());
+
+ deployer.addWSToUndeploy(wsInfo); // this is to be undeploye
+ }
}
for (int i = 0; i < tempvector.size(); i++) {
WSInfo fileItem = (WSInfo) tempvector.get(i);
+
jarList.remove(fileItem);
}
+
tempvector.clear();
currentJars.clear();
}
+ /**
+ * This method is used to initialize the vector
+ */
+ public void init() {
+ jarList.clear();
+ }
/**
*
@@ -222,11 +205,52 @@
public void update() {
synchronized (deployer) {
checkForUndeploye();
+
if (deployer.isHotUpdate()) {
deployer.unDeploy();
}
+
deployer.doDeploy();
}
}
+ /**
+ * This method is to use to check the file exist and if so
+ * it will return related wsinfo object to the file else return null;
+ *
+ * @param filename
+ */
+ public WSInfo getFileItem(String filename) {
+ int sise = jarList.size();
+
+ for (int i = 0; i < sise; i++) {
+ WSInfo wsInfo = (WSInfo) jarList.get(i);
+
+ if (wsInfo.getFileName().equals(filename)) {
+ return wsInfo;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * to check whether the file is alredy in the list
+ *
+ * @param filename
+ */
+ public boolean isFileExist(String filename) {
+ return !(getFileItem(filename) == null);
+ }
+
+ /**
+ * comapre the last update dates of both files and if those are differ
+ * that will assume as the file is been modified
+ *
+ * @param file
+ * @param wsInfo
+ */
+ public boolean isModified(File file, WSInfo wsInfo) {
+ return (wsInfo.getLastModifiedDate() != file.lastModified());
+ }
}
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/scheduler/DeploymentIterator.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/scheduler/DeploymentIterator.java?rev=357187&r1=357186&r2=357187&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/scheduler/DeploymentIterator.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/scheduler/DeploymentIterator.java Fri Dec 16 09:13:57 2005
@@ -1,18 +1,19 @@
/*
- * Copyright 2004,2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
package org.apache.axis2.deployment.scheduler;
@@ -20,12 +21,11 @@
import java.util.Date;
public class DeploymentIterator {
-
private Calendar calendar = Calendar.getInstance();
public Date next() {
calendar.add(Calendar.SECOND, 10);
+
return calendar.getTime();
}
-
}
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/scheduler/Scheduler.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/scheduler/Scheduler.java?rev=357187&r1=357186&r2=357187&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/scheduler/Scheduler.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/scheduler/Scheduler.java Fri Dec 16 09:13:57 2005
@@ -1,18 +1,19 @@
/*
- * Copyright 2004,2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
package org.apache.axis2.deployment.scheduler;
@@ -21,24 +22,20 @@
import java.util.TimerTask;
public class Scheduler {
-
private final Timer timer = new Timer();
- public class SchedulerTimerTask extends TimerTask {
-
- private SchedulerTask schedulerTask;
- private DeploymentIterator iterator;
-
-
- public SchedulerTimerTask(SchedulerTask schedulerTask,
- DeploymentIterator iterator) {
- this.schedulerTask = schedulerTask;
- this.iterator = iterator;
- }
+ private void reschedule(SchedulerTask schedulerTask, DeploymentIterator iterator) {
+ Date time = iterator.next();
- public void run() {
- schedulerTask.run();
- reschedule(schedulerTask, iterator);
+ if (time == null) {
+ schedulerTask.cancel();
+ } else {
+ synchronized (schedulerTask.lock) {
+ if (schedulerTask.state != SchedulerTask.CANCELLED) {
+ schedulerTask.timerTask = new SchedulerTimerTask(schedulerTask, iterator);
+ timer.schedule(schedulerTask.timerTask, time);
+ }
+ }
}
}
@@ -52,37 +49,32 @@
* @throws IllegalStateException if task was already scheduled or cancelled,
* scheduler was cancelled, or scheduler thread terminated.
*/
-
- public void schedule(SchedulerTask schedulerTask,
- DeploymentIterator iterator) {
-
+ public void schedule(SchedulerTask schedulerTask, DeploymentIterator iterator) {
Date time = iterator.next();
+
if (time == null) {
schedulerTask.cancel();
} else {
synchronized (schedulerTask.lock) {
schedulerTask.state = SchedulerTask.SCHEDULED;
- schedulerTask.timerTask =
- new SchedulerTimerTask(schedulerTask, iterator);
+ schedulerTask.timerTask = new SchedulerTimerTask(schedulerTask, iterator);
timer.schedule(schedulerTask.timerTask, time);
}
}
}
- private void reschedule(SchedulerTask schedulerTask,
- DeploymentIterator iterator) {
- Date time = iterator.next();
- if (time == null) {
- schedulerTask.cancel();
- } else {
- synchronized (schedulerTask.lock) {
- if (schedulerTask.state != SchedulerTask.CANCELLED) {
- schedulerTask.timerTask =
- new SchedulerTimerTask(schedulerTask, iterator);
- timer.schedule(schedulerTask.timerTask, time);
- }
- }
+ public class SchedulerTimerTask extends TimerTask {
+ private DeploymentIterator iterator;
+ private SchedulerTask schedulerTask;
+
+ public SchedulerTimerTask(SchedulerTask schedulerTask, DeploymentIterator iterator) {
+ this.schedulerTask = schedulerTask;
+ this.iterator = iterator;
}
- }
+ public void run() {
+ schedulerTask.run();
+ reschedule(schedulerTask, iterator);
+ }
+ }
}
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/scheduler/SchedulerTask.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/scheduler/SchedulerTask.java?rev=357187&r1=357186&r2=357187&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/scheduler/SchedulerTask.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/scheduler/SchedulerTask.java Fri Dec 16 09:13:57 2005
@@ -1,57 +1,40 @@
/*
- * Copyright 2004,2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
package org.apache.axis2.deployment.scheduler;
-import org.apache.axis2.deployment.DeploymentEngine;
import org.apache.axis2.deployment.listener.RepositoryListener;
import org.apache.axis2.deployment.listener.RepositoryListenerImpl;
import java.util.TimerTask;
public class SchedulerTask implements Runnable {
-
- final Object lock = new Object();
-
- private RepositoryListener wsListener;
-
- int state = 0;
static final int SCHEDULED = 1;
static final int CANCELLED = 2;
-
+ final Object lock = new Object();
+ int state = 0;
TimerTask timerTask;
+ private RepositoryListener wsListener;
/**
* Creates a new scheduler task.
*/
-
public SchedulerTask(RepositoryListener listener) {
- this.wsListener =listener;
- }
-
- /**
- * The action to be performed by this scheduler task.
- */
-
- public void run() {
- checkRepositary();
- }
-
- private void checkRepositary() {
- ((RepositoryListenerImpl) wsListener).startListent();
+ this.wsListener = listener;
}
/**
@@ -61,16 +44,28 @@
*
* @return true if this task was already scheduled to run
*/
-
public boolean cancel() {
synchronized (lock) {
if (timerTask != null) {
timerTask.cancel();
}
+
boolean result = (state == SCHEDULED);
+
state = CANCELLED;
+
return result;
}
}
+ private void checkRepositary() {
+ ((RepositoryListenerImpl) wsListener).startListent();
+ }
+
+ /**
+ * The action to be performed by this scheduler task.
+ */
+ public void run() {
+ checkRepositary();
+ }
}
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/util/PhasesInfo.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/util/PhasesInfo.java?rev=357187&r1=357186&r2=357187&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/util/PhasesInfo.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/util/PhasesInfo.java Fri Dec 16 09:13:57 2005
@@ -1,26 +1,27 @@
/*
- * Copyright 2004,2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
package org.apache.axis2.deployment.util;
import org.apache.axis2.deployment.DeploymentException;
import org.apache.axis2.description.AxisOperation;
import org.apache.axis2.description.HandlerDescription;
-import org.apache.axis2.engine.Phase;
import org.apache.axis2.engine.Handler;
+import org.apache.axis2.engine.Phase;
import org.apache.axis2.om.OMElement;
import org.apache.axis2.phaseresolver.PhaseException;
import org.apache.axis2.phaseresolver.PhaseMetadata;
@@ -30,146 +31,191 @@
import java.util.Iterator;
public class PhasesInfo {
-
private ArrayList INPhases;
- private ArrayList OUTPhases;
private ArrayList IN_FaultPhases;
+ private ArrayList OUTPhases;
private ArrayList OUT_FaultPhases;
- public void setINPhases(ArrayList INPhases) {
- this.INPhases = INPhases;
- }
-
- public void setOUTPhases(ArrayList OUTPhases) {
- this.OUTPhases = OUTPhases;
- }
-
- public void setIN_FaultPhases(ArrayList IN_FaultPhases) {
- this.IN_FaultPhases = IN_FaultPhases;
- }
-
- public void setOUT_FaultPhases(ArrayList OUT_FaultPhases) {
- this.OUT_FaultPhases = OUT_FaultPhases;
- }
+ /**
+ * To copy phase informatoin from one to another
+ *
+ * @param phase
+ */
+ private Phase copyPhase(Phase phase) throws DeploymentException {
+ Phase newPhase = new Phase(phase.getPhaseName());
+ Iterator handlers = phase.getHandlers().iterator();
- public ArrayList getINPhases() {
- return INPhases;
- }
+ while (handlers.hasNext()) {
+ try {
+ Handler handlerDescription = (Handler) handlers.next();
- public ArrayList getOUTPhases() {
- return OUTPhases;
- }
+ newPhase.addHandler(handlerDescription.getHandlerDesc());
+ } catch (PhaseException e) {
+ throw new DeploymentException(e);
+ }
+ }
- public ArrayList getIN_FaultPhases() {
- return IN_FaultPhases;
+ return newPhase;
}
- public ArrayList getOUT_FaultPhases() {
- return OUT_FaultPhases;
- }
+ HandlerDescription makeHandler(OMElement handlerElement) {
+ String name = handlerElement.getAttributeValue(new QName("name"));
+ QName qname = handlerElement.resolveQName(name);
+ HandlerDescription desc = new HandlerDescription(qname);
+ String className = handlerElement.getAttributeValue(new QName("class"));
- public ArrayList getGlobalInflow() {
- ArrayList globalphase = new ArrayList();
- for (int i = 0; i < INPhases.size(); i++) {
- Phase phase = (Phase) INPhases.get(i);
- String phaseName = phase.getPhaseName();
- if (PhaseMetadata.PHASE_TRANSPORTIN.equals(phaseName) ||
- PhaseMetadata.PHASE_PRE_DISPATCH.equals(phaseName) ||
- PhaseMetadata.PHASE_DISPATCH.equals(phaseName) ||
- PhaseMetadata.PHASE_POST_DISPATCH.equals(phaseName)) {
- globalphase.add(phase);
- }
- }
- return globalphase;
- }
+ desc.setClassName(className);
- public ArrayList getOperationInPhases() throws DeploymentException {
- ArrayList operationINPhases = new ArrayList();
- for (int i = 0; i < INPhases.size(); i++) {
- Phase phase = (Phase) INPhases.get(i);
- String phaseName = phase.getPhaseName();
- if (PhaseMetadata.PHASE_TRANSPORTIN.equals(phaseName) ||
- PhaseMetadata.PHASE_PRE_DISPATCH.equals(phaseName) ||
- PhaseMetadata.PHASE_DISPATCH.equals(phaseName) ||
- PhaseMetadata.PHASE_POST_DISPATCH.equals(phaseName)) {
- } else {
- operationINPhases.add(copyPhase(phase));
- }
- }
- return operationINPhases;
+ return desc;
}
public Phase makePhase(OMElement phaseElement) throws PhaseException {
String phaseName = phaseElement.getAttributeValue(new QName("name"));
Phase phase = new Phase(phaseName);
Iterator children = phaseElement.getChildElements();
+
while (children.hasNext()) {
OMElement handlerElement = (OMElement) children.next();
HandlerDescription handlerDesc = makeHandler(handlerElement);
+
phase.addHandler(handlerDesc);
}
+
return phase;
}
- HandlerDescription makeHandler(OMElement handlerElement) {
- String name = handlerElement.getAttributeValue(new QName("name"));
- QName qname = handlerElement.resolveQName(name);
- HandlerDescription desc = new HandlerDescription(qname);
- String className = handlerElement.getAttributeValue(new QName("class"));
- desc.setClassName(className);
- return desc;
+ public ArrayList getGlobalInflow() {
+ ArrayList globalphase = new ArrayList();
+
+ for (int i = 0; i < INPhases.size(); i++) {
+ Phase phase = (Phase) INPhases.get(i);
+ String phaseName = phase.getPhaseName();
+
+ if (PhaseMetadata.PHASE_TRANSPORTIN.equals(phaseName)
+ || PhaseMetadata.PHASE_PRE_DISPATCH.equals(phaseName)
+ || PhaseMetadata.PHASE_DISPATCH.equals(phaseName)
+ || PhaseMetadata.PHASE_POST_DISPATCH.equals(phaseName)) {
+ globalphase.add(phase);
+ }
+ }
+
+ return globalphase;
}
public ArrayList getGlobalOutPhaseList() throws DeploymentException {
+
/**
* I have assumed that PolicyDetermination and MessageProcessing are global out phase
*/
ArrayList globalPhaseList = new ArrayList();
+
for (int i = 0; i < OUTPhases.size(); i++) {
Phase phase = (Phase) OUTPhases.get(i);
String phaseName = phase.getPhaseName();
- if (PhaseMetadata.PHASE_POLICY_DETERMINATION.equals(phaseName) ||
- PhaseMetadata.PHASE_MESSAGE_OUT.equals(phaseName)) {
+
+ if (PhaseMetadata.PHASE_POLICY_DETERMINATION.equals(phaseName)
+ || PhaseMetadata.PHASE_MESSAGE_OUT.equals(phaseName)) {
globalPhaseList.add(copyPhase(phase));
}
}
+
return globalPhaseList;
}
- public ArrayList getOperationOutPhases() throws DeploymentException {
- ArrayList oprationOUTPhases = new ArrayList();
- for (int i = 0; i < OUTPhases.size(); i++) {
- Phase phase = (Phase) OUTPhases.get(i);
- String phaseName = phase.getPhaseName();
- if (PhaseMetadata.PHASE_POLICY_DETERMINATION.equals(phaseName) ||
- PhaseMetadata.PHASE_MESSAGE_OUT.equals(phaseName)) {
- //todo pls check this
- } else {
- oprationOUTPhases.add(copyPhase(phase));
- }
+ public ArrayList getINPhases() {
+ return INPhases;
+ }
- }
- return oprationOUTPhases;
+ public ArrayList getIN_FaultPhases() {
+ return IN_FaultPhases;
+ }
+
+ public ArrayList getOUTPhases() {
+ return OUTPhases;
+ }
+
+ public ArrayList getOUT_FaultPhases() {
+ return OUT_FaultPhases;
}
public ArrayList getOperationInFaultPhases() throws DeploymentException {
ArrayList oprationIN_FaultPhases = new ArrayList();
+
for (int i = 0; i < IN_FaultPhases.size(); i++) {
Phase phase = (Phase) IN_FaultPhases.get(i);
+
oprationIN_FaultPhases.add(copyPhase(phase));
}
+
return oprationIN_FaultPhases;
}
+ public ArrayList getOperationInPhases() throws DeploymentException {
+ ArrayList operationINPhases = new ArrayList();
+
+ for (int i = 0; i < INPhases.size(); i++) {
+ Phase phase = (Phase) INPhases.get(i);
+ String phaseName = phase.getPhaseName();
+
+ if (PhaseMetadata.PHASE_TRANSPORTIN.equals(phaseName)
+ || PhaseMetadata.PHASE_PRE_DISPATCH.equals(phaseName)
+ || PhaseMetadata.PHASE_DISPATCH.equals(phaseName)
+ || PhaseMetadata.PHASE_POST_DISPATCH.equals(phaseName)) {
+ } else {
+ operationINPhases.add(copyPhase(phase));
+ }
+ }
+
+ return operationINPhases;
+ }
+
public ArrayList getOperationOutFaultPhases() throws DeploymentException {
ArrayList oprationOUT_FaultPhases = new ArrayList();
+
for (int i = 0; i < OUT_FaultPhases.size(); i++) {
Phase phase = (Phase) OUT_FaultPhases.get(i);
+
oprationOUT_FaultPhases.add(copyPhase(phase));
}
+
return oprationOUT_FaultPhases;
}
+ public ArrayList getOperationOutPhases() throws DeploymentException {
+ ArrayList oprationOUTPhases = new ArrayList();
+
+ for (int i = 0; i < OUTPhases.size(); i++) {
+ Phase phase = (Phase) OUTPhases.get(i);
+ String phaseName = phase.getPhaseName();
+
+ if (PhaseMetadata.PHASE_POLICY_DETERMINATION.equals(phaseName)
+ || PhaseMetadata.PHASE_MESSAGE_OUT.equals(phaseName)) {
+
+ // todo pls check this
+ } else {
+ oprationOUTPhases.add(copyPhase(phase));
+ }
+ }
+
+ return oprationOUTPhases;
+ }
+
+ public void setINPhases(ArrayList INPhases) {
+ this.INPhases = INPhases;
+ }
+
+ public void setIN_FaultPhases(ArrayList IN_FaultPhases) {
+ this.IN_FaultPhases = IN_FaultPhases;
+ }
+
+ public void setOUTPhases(ArrayList OUTPhases) {
+ this.OUTPhases = OUTPhases;
+ }
+
+ public void setOUT_FaultPhases(ArrayList OUT_FaultPhases) {
+ this.OUT_FaultPhases = OUT_FaultPhases;
+ }
+
public void setOperationPhases(AxisOperation axisOperation) throws DeploymentException {
if (axisOperation != null) {
axisOperation.setRemainingPhasesInFlow(getOperationInPhases());
@@ -178,24 +224,4 @@
axisOperation.setPhasesOutFaultFlow(getOperationOutFaultPhases());
}
}
-
- /**
- * To copy phase informatoin from one to another
- *
- * @param phase
- */
- private Phase copyPhase(Phase phase) throws DeploymentException {
- Phase newPhase = new Phase(phase.getPhaseName());
- Iterator handlers = phase.getHandlers().iterator();
- while (handlers.hasNext()) {
- try {
- Handler handlerDescription = (Handler) handlers.next();
- newPhase.addHandler(handlerDescription.getHandlerDesc());
- } catch (PhaseException e) {
- throw new DeploymentException(e);
- }
- }
- return newPhase;
- }
-
}
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/util/Utils.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/util/Utils.java?rev=357187&r1=357186&r2=357187&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/util/Utils.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/deployment/util/Utils.java Fri Dec 16 09:13:57 2005
@@ -11,6 +11,7 @@
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
+
/*
* Copyright 2004,2005 The Apache Software Foundation.
*
@@ -31,94 +32,116 @@
*/
public class Utils {
+ public static void addFlowHandlers(Flow flow, ClassLoader clsLoader) throws AxisFault {
+ int count = flow.getHandlerCount();
+
+ for (int j = 0; j < count; j++) {
+ HandlerDescription handlermd = flow.getHandler(j);
+ Class handlerClass;
+ Handler handler;
+
+ handlerClass = getHandlerClass(handlermd.getClassName(), clsLoader);
+
+ try {
+ handler = (Handler) handlerClass.newInstance();
+ handler.init(handlermd);
+ handlermd.setHandler(handler);
+ } catch (InstantiationException e) {
+ throw new AxisFault(e);
+ } catch (IllegalAccessException e) {
+ throw new AxisFault(e);
+ }
+ }
+ }
- public static ClassLoader getClassLoader(ClassLoader parent, File file) throws DeploymentException {
+ public static void loadHandler(ClassLoader loader1, HandlerDescription desc)
+ throws DeploymentException {
+ String handlername = desc.getClassName();
+ Handler handler;
+ Class handlerClass;
+
+ try {
+ handlerClass = Class.forName(handlername, true, loader1);
+ handler = (Handler) handlerClass.newInstance();
+ handler.init(desc);
+ desc.setHandler(handler);
+ } catch (ClassNotFoundException e) {
+ throw new DeploymentException(e);
+ } catch (Exception e) {
+ throw new DeploymentException(e);
+ }
+ }
+
+ public static ClassLoader getClassLoader(ClassLoader parent, File file)
+ throws DeploymentException {
URLClassLoader classLoader;
+
if (file != null) {
try {
ArrayList urls = new ArrayList();
+
urls.add(file.toURL());
- //if lib is simple
+
+ // if lib is simple
File libfiles = new File(file, "lib");
+
if (libfiles.exists()) {
urls.add(libfiles.toURL());
- File jarfiles [] = libfiles.listFiles();
+
+ File jarfiles[] = libfiles.listFiles();
+
for (int i = 0; i < jarfiles.length; i++) {
File jarfile = jarfiles[i];
+
if (jarfile.getName().endsWith(".jar")) {
urls.add(jarfile.toURL());
}
}
}
- //if lib is capital
+
+ // if lib is capital
libfiles = new File(file, "Lib");
+
if (libfiles.exists()) {
urls.add(libfiles.toURL());
- File jarfiles [] = libfiles.listFiles();
+
+ File jarfiles[] = libfiles.listFiles();
+
for (int i = 0; i < jarfiles.length; i++) {
File jarfile = jarfiles[i];
+
if (jarfile.getName().endsWith(".jar")) {
urls.add(jarfile.toURL());
}
}
}
- URL urllist [] = new URL[urls.size()];
+
+ URL urllist[] = new URL[urls.size()];
+
for (int i = 0; i < urls.size(); i++) {
urllist[i] = (URL) urls.get(i);
}
+
classLoader = new URLClassLoader(urllist, parent);
+
return classLoader;
} catch (MalformedURLException e) {
throw new DeploymentException(e);
}
}
- return null;
- }
-
- public static void addFlowHandlers(Flow flow, ClassLoader clsLoader) throws AxisFault {
- int count = flow.getHandlerCount();
- for (int j = 0; j < count; j++) {
- HandlerDescription handlermd = flow.getHandler(j);
- Class handlerClass;
- Handler handler;
- handlerClass = getHandlerClass(handlermd.getClassName(), clsLoader);
- try {
- handler = (Handler) handlerClass.newInstance();
- handler.init(handlermd);
- handlermd.setHandler(handler);
-
- } catch (InstantiationException e) {
- throw new AxisFault(e);
- } catch (IllegalAccessException e) {
- throw new AxisFault(e);
- }
- }
+ return null;
}
private static Class getHandlerClass(String className, ClassLoader loader1) throws AxisFault {
Class handlerClass;
+
try {
handlerClass = Class.forName(className, true, loader1);
} catch (ClassNotFoundException e) {
throw new AxisFault(e.getMessage());
}
- return handlerClass;
- }
- public static void loadHandler(ClassLoader loader1, HandlerDescription desc) throws DeploymentException {
- String handlername = desc.getClassName();
- Handler handler;
- Class handlerClass;
- try {
- handlerClass = Class.forName(handlername, true, loader1);
- handler = (Handler) handlerClass.newInstance();
- handler.init(desc);
- desc.setHandler(handler);
- } catch (ClassNotFoundException e) {
- throw new DeploymentException(e);
- } catch (Exception e) {
- throw new DeploymentException(e);
- }
+ return handlerClass;
}
}
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisDescWSDLComponentFactory.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisDescWSDLComponentFactory.java?rev=357187&r1=357186&r2=357187&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisDescWSDLComponentFactory.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisDescWSDLComponentFactory.java Fri Dec 16 09:13:57 2005
@@ -20,97 +20,101 @@
import org.apache.wsdl.WSDLTypes;
import org.apache.wsdl.extensions.ExtensionFactory;
import org.apache.wsdl.extensions.impl.ExtensionFactoryImpl;
-import org.apache.wsdl.impl.*;
+import org.apache.wsdl.impl.MessageReferenceImpl;
+import org.apache.wsdl.impl.WSDLBindingFaultImpl;
+import org.apache.wsdl.impl.WSDLBindingImpl;
+import org.apache.wsdl.impl.WSDLBindingMessageReferenceImpl;
+import org.apache.wsdl.impl.WSDLBindingOperationImpl;
+import org.apache.wsdl.impl.WSDLDescriptionImpl;
+import org.apache.wsdl.impl.WSDLEndpointImpl;
+import org.apache.wsdl.impl.WSDLExtensibilityAttributeImpl;
+import org.apache.wsdl.impl.WSDLFaultReferenceImpl;
+import org.apache.wsdl.impl.WSDLFeatureImpl;
+import org.apache.wsdl.impl.WSDLImportImpl;
+import org.apache.wsdl.impl.WSDLIncludeImpl;
+import org.apache.wsdl.impl.WSDLInterfaceImpl;
+import org.apache.wsdl.impl.WSDLOperationImpl;
+import org.apache.wsdl.impl.WSDLPropertyImpl;
+import org.apache.wsdl.impl.WSDLServiceImpl;
+import org.apache.wsdl.impl.WSDLTypesImpl;
public class AxisDescWSDLComponentFactory implements WSDLComponentFactory {
-
-
- public WSDLDescription createDescription() {
- return new WSDLDescriptionImpl();
- }
-
-
- public WSDLService createService() {
- return new WSDLServiceImpl();
- }
-
-
- public WSDLInterface createInterface() {
- return new WSDLInterfaceImpl();
- }
-
-
- public WSDLTypes createTypes() {
- return new WSDLTypesImpl();
- }
-
-
public WSDLBinding createBinding() {
return new WSDLBindingImpl();
}
-
- public WSDLOperation createOperation() {
-// return new AxisOperation(); // by Deepal
- return new WSDLOperationImpl();
+ public WSDLBindingFault createBindingFault() {
+ return new WSDLBindingFaultImpl();
}
+ public WSDLDescription createDescription() {
+ return new WSDLDescriptionImpl();
+ }
public WSDLEndpoint createEndpoint() {
return new WSDLEndpointImpl();
}
+ /**
+ * @return A new Instance of <code>ExtensionFactory</code> that
+ * is capable of creating the correct <code>ExtensibilityElement</code>
+ * given a <code>QName</code>.
+ */
+ public ExtensionFactory createExtensionFactory() {
+ return new ExtensionFactoryImpl();
+ }
+
+ public WSDLFaultReference createFaultReference() {
+ return new WSDLFaultReferenceImpl();
+ }
public WSDLFeature createFeature() {
return new WSDLFeatureImpl();
}
-
public WSDLImport createImport() {
return new WSDLImportImpl();
}
-
public WSDLInclude createInclude() {
return new WSDLIncludeImpl();
}
-
- public WSDLProperty createProperty() {
- return new WSDLPropertyImpl();
+ public WSDLInterface createInterface() {
+ return new WSDLInterfaceImpl();
}
public MessageReference createMessageReference() {
return new MessageReferenceImpl();
}
- public WSDLBindingMessageReference createWSDLBindingMessageReference() {
- return new WSDLBindingMessageReferenceImpl();
+ public WSDLOperation createOperation() {
+
+// return new AxisOperation(); // by Deepal
+ return new WSDLOperationImpl();
}
- public WSDLBindingOperation createWSDLBindingOperation() {
- return new WSDLBindingOperationImpl();
+ public WSDLProperty createProperty() {
+ return new WSDLPropertyImpl();
}
- public WSDLExtensibilityAttribute createWSDLExtensibilityAttribute() {
- return new WSDLExtensibilityAttributeImpl();
+ public WSDLService createService() {
+ return new WSDLServiceImpl();
}
- /**
- * @return A new Instance of <code>ExtensionFactory</code> that
- * is capable of creating the correct <code>ExtensibilityElement</code>
- * given a <code>QName</code>.
- */
- public ExtensionFactory createExtensionFactory() {
- return new ExtensionFactoryImpl();
+ public WSDLTypes createTypes() {
+ return new WSDLTypesImpl();
}
- public WSDLFaultReference createFaultReference() {
- return new WSDLFaultReferenceImpl();
+ public WSDLBindingMessageReference createWSDLBindingMessageReference() {
+ return new WSDLBindingMessageReferenceImpl();
}
- public WSDLBindingFault createBindingFault() {
- return new WSDLBindingFaultImpl();
+ public WSDLBindingOperation createWSDLBindingOperation() {
+ return new WSDLBindingOperationImpl();
}
+ public WSDLExtensibilityAttribute createWSDLExtensibilityAttribute() {
+ return new WSDLExtensibilityAttributeImpl();
+ }
}
Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisMessage.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisMessage.java?rev=357187&r1=357186&r2=357187&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisMessage.java (original)
+++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/description/AxisMessage.java Fri Dec 16 09:13:57 2005
@@ -4,6 +4,7 @@
import org.apache.axis2.om.OMElement;
import java.util.ArrayList;
+
/*
* Copyright 2004,2005 The Apache Software Foundation.
*
@@ -27,11 +28,9 @@
* This class represent the messages in WSDL , and there can be message element in services.xml
* those will be representd by this class
*/
-
public class AxisMessage implements ParameterInclude {
-
- private ParameterInclude parameterinclude;
private ArrayList handlerChain;
+ private ParameterInclude parameterinclude;
private AxisOperation parent;
public AxisMessage() {
@@ -43,6 +42,7 @@
if (param == null) {
return;
}
+
if (isParameterLocked(param.getName())) {
throw new AxisFault("Parmter is locked can not overide: " + param.getName());
} else {
@@ -50,6 +50,14 @@
}
}
+ public void deserializeParameters(OMElement parameterElement) throws AxisFault {
+ parameterinclude.deserializeParameters(parameterElement);
+ }
+
+ public ArrayList getMessageFlow() {
+ return handlerChain;
+ }
+
public Parameter getParameter(String name) {
return parameterinclude.getParameter(name);
}
@@ -58,34 +66,30 @@
return parameterinclude.getParameters();
}
+ public AxisOperation getParent() {
+ return parent;
+ }
+
public boolean isParameterLocked(String parameterName) {
+
// checking the locked value of parent
boolean loscked = false;
+
if (getParent() != null) {
loscked = getParent().isParameterLocked(parameterName);
}
+
if (loscked) {
return true;
} else {
Parameter parameter = getParameter(parameterName);
- return parameter != null && parameter.isLocked();
- }
- }
- public void deserializeParameters(OMElement parameterElement) throws AxisFault {
- parameterinclude.deserializeParameters(parameterElement);
- }
-
- public ArrayList getMessageFlow() {
- return handlerChain;
+ return (parameter != null) && parameter.isLocked();
+ }
}
public void setMessageFlow(ArrayList operationFlow) {
this.handlerChain = operationFlow;
- }
-
- public AxisOperation getParent() {
- return parent;
}
public void setParent(AxisOperation parent) {