| Method from org.apache.axis2.deployment.RepositoryListener Detail: |
public void addFileToDeploy(File file,
Deployer deployer,
int type) {
wsInfoList.addWSInfoItem(file, deployer, type);
}
|
public void checkModules() {
File root = deploymentEngine.getModulesDir();
File[] files = root.listFiles();
if (files != null) {
for (int i = 0; i < files.length; i++) {
File file = files[i];
if (isSourceControlDir(file)) {
continue;
}
if (!file.isDirectory()) {
if (DeploymentFileData.isModuleArchiveFile(file.getName())) {
addFileToDeploy(file, deploymentEngine.getModuleDeployer(),
WSInfo.TYPE_MODULE);
}
} else {
if (!"lib".equalsIgnoreCase(file.getName())) {
addFileToDeploy(file, deploymentEngine.getModuleDeployer(),
WSInfo.TYPE_MODULE);
}
}
}
}
}
Finds a list of modules in the folder and adds to wsInfoList. |
public void checkServices() {
findServicesInDirectory();
loadOtherDirectories();
update();
}
Finds a list of services in the folder and adds to wsInfoList. |
protected void findServicesInDirectory() {
File root = deploymentEngine.getServicesDir();
File[] files = root.listFiles();
if (files != null && files.length > 0) {
for (int i = 0; i < files.length; i++) {
File file = files[i];
if (isSourceControlDir(file)) {
continue;
}
if (!file.isDirectory()) {
if (DeploymentFileData.isServiceArchiveFile(file.getName())) {
addFileToDeploy(file, deploymentEngine.getServiceDeployer(),
WSInfo.TYPE_SERVICE);
} else {
String ext = DeploymentFileData.getFileExtension(file.getName());
Deployer deployer = deploymentEngine.getDeployerForExtension(ext);
// If we found a deployer for this type of file, use it. Otherwise
// ignore the file.
if (deployer != null) {
addFileToDeploy(file, deployer, WSInfo.TYPE_SERVICE);
}
}
} else {
if (!"lib".equalsIgnoreCase(file.getName())) {
addFileToDeploy(file, deploymentEngine.getServiceDeployer(),
WSInfo.TYPE_SERVICE);
}
}
}
}
}
Searches a given folder for jar files and adds them to a list in the WSInfolist class. |
protected String getLocation() {
try {
Class clazz = Loader.loadClass("org.apache.axis2.engine.AxisEngine");
java.net.URL url = clazz.getProtectionDomain().getCodeSource().getLocation();
String location = url.toString();
if (location.startsWith("jar")) {
url = ((java.net.JarURLConnection)url.openConnection()).getJarFileURL();
location = url.toString();
}
if (location.startsWith("file")) {
File file = Utils.toFile(url);
return file.getAbsolutePath();
} else {
return url.toString();
}
} catch (Throwable t) {
return null;
}
}
To get the location of the Axis2.jar from that I can drive the location of class path |
public void init() {
wsInfoList.init();
checkModules();
deploymentEngine.doDeploy();
}
First initializes the WSInfoList, then calls checkModule to load all the modules and calls
update() to update the Deployment engine and engine registry. |
public void init2(boolean isClasspath) {
if (!isClasspath) {
init();
}
loadClassPathModules();
}
|
protected boolean isSourceControlDir(File file) {
if (file.isDirectory()) {
String name = file.getName();
if (name.equalsIgnoreCase("CVS") || name.equalsIgnoreCase(".svn")) {
return true;
}
}
return false;
}
|
protected void loadClassPathModules() {
ModuleDeployer deployer = deploymentEngine.getModuleDeployer();
// Find Modules on the class path (i.e. if classpath includes "addressing.mar" then
// addressing will be available for engaging)
ClassLoader loader = Thread.currentThread().getContextClassLoader();
try {
Enumeration moduleURLs = loader.getResources("META-INF/module.xml");
while (moduleURLs.hasMoreElements()) {
try {
URL url = (URL)moduleURLs.nextElement();
URI moduleURI;
if (url.getProtocol().equals("file")) {
String urlString = url.toString();
moduleURI = new URI(urlString.substring(0,
urlString.lastIndexOf("/META-INF/module.xml")));
} else {
// Check if the URL refers to an archive (such as
// jar:file:/dir/some.jar!/META-INF/module.xml) and extract the
// URL of the archive. In general the protocol will be "jar", but
// some containers may use other protocols, e.g. WebSphere uses
// "wsjar" (AXIS2-4258).
String path = url.getPath();
int idx = path.lastIndexOf("!/");
if (idx != -1 && path.substring(idx+2).equals("META-INF/module.xml")) {
moduleURI = new URI(path.substring(0, idx));
if (!moduleURI.getScheme().equals("file")) {
continue;
}
} else {
continue;
}
}
log.debug("Deploying module from classpath at '" + moduleURI + "'");
File f = new File(moduleURI);
addFileToDeploy(f, deployer, WSInfo.TYPE_MODULE);
} catch (URISyntaxException e) {
log.info(e);
}
}
} catch (Exception e) {
// Oh well, log the problem
log.debug(e);
}
String classPath = getLocation();
if (classPath == null) return;
int lstindex = classPath.lastIndexOf(File.separatorChar);
if (lstindex > 0) {
classPath = classPath.substring(0, lstindex);
} else {
classPath = ".";
}
File root = new File(classPath);
File[] files = root.listFiles();
if (files != null) {
for (int i = 0; i < files.length; i++) {
File file = files[i];
if (!file.isDirectory()) {
if (DeploymentFileData.isModuleArchiveFile(file.getName())) {
//adding modules in the class path
addFileToDeploy(file, deployer, WSInfo.TYPE_MODULE);
}
}
}
}
ClassLoader cl = deploymentEngine.getAxisConfig().getModuleClassLoader();
while (cl != null) {
if (cl instanceof URLClassLoader) {
URL[] urls = ((URLClassLoader)cl).getURLs();
for (int i = 0; (urls != null) && i < urls.length; i++) {
String path = urls[i].getPath();
//If it is a drive letter, adjust accordingly.
if (path.length() >= 3 && path.charAt(0) == '/" && path.charAt(2) == ':") {
path = path.substring(1);
}
try {
path = URLDecoder.decode(path, Utils.defaultEncoding);
} catch (UnsupportedEncodingException e) {
// Log this?
}
File file = new File(path.replace('/", File.separatorChar).replace('|", ':"));
if (file.isFile()) {
if (DeploymentFileData.isModuleArchiveFile(file.getName())) {
//adding modules in the class path
addFileToDeploy(file, deployer, WSInfo.TYPE_MODULE);
}
}
}
}
cl = cl.getParent();
}
deploymentEngine.doDeploy();
}
|
public void startListener() {
checkServices();
// update();
}
Method invoked from the scheduler to start the listener. |
public void update() {
wsInfoList.update();
}
Updates WSInfoList object. |
public void updateRemote() throws Exception {
findServicesInDirectory();
update();
}
|