Author: keith
Date: Mon Apr 28 02:41:19 2008
New Revision: 16248
Log:
At deployment time create a .work directory in the Mashup Server home directory
and create a axis repository in there than containes the rampart mar. We can
then use this as a client side axis2
repository when the Mashup Server acts as a client. This will be used by the
WSRequestHostImpl and also the login stuff of the mashup server.
Modified:
trunk/mashup/java/modules/core/src/org/wso2/mashup/MashupConstants.java
trunk/mashup/java/modules/javascriptdeployer/src/org/wso2/mashup/deployer/JSDeployer.java
Modified:
trunk/mashup/java/modules/core/src/org/wso2/mashup/MashupConstants.java
==============================================================================
--- trunk/mashup/java/modules/core/src/org/wso2/mashup/MashupConstants.java
(original)
+++ trunk/mashup/java/modules/core/src/org/wso2/mashup/MashupConstants.java
Mon Apr 28 02:41:19 2008
@@ -236,4 +236,23 @@
// "http://services.mashup.wso2.org/" + serviceName and the
schemaTargetNamespace will be of the
// form http://services.mashup.wso2.org/" + serviceName + "?xsd";
public static String TARGET_NAMESPACE_PREFIX =
"http://services.mashup.wso2.org/";
+
+ //The name of the work Directory that we create a Axis2 Repository
+ public static String WORK_DIRECTORY = ".work";
+
+ //The name of the Directory that we create a Axis2 Repository that the
Mashup Server can
+ // use when its acting as a client
+ public static String REPO_DIRECTORY = "repo";
+
+ //The name of the Directory that we drop in Axis2 modules that the Mashup
Server can
+ // use when its acting as a client
+ public static String MODULES_DIRECTORY = "modules";
+
+ // The system property that points to the WSAS home directory
+ public static String WSO2WSAS_HOME = "wso2wsas.home";
+
+ // Refers to the rampart module
+ public static String RAMPART = "rampart";
+
+ public static int BUFFER_SIZE = 40960;
}
Modified:
trunk/mashup/java/modules/javascriptdeployer/src/org/wso2/mashup/deployer/JSDeployer.java
==============================================================================
---
trunk/mashup/java/modules/javascriptdeployer/src/org/wso2/mashup/deployer/JSDeployer.java
(original)
+++
trunk/mashup/java/modules/javascriptdeployer/src/org/wso2/mashup/deployer/JSDeployer.java
Mon Apr 28 02:41:19 2008
@@ -73,6 +73,7 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
@@ -82,6 +83,9 @@
import java.util.Iterator;
import java.util.Map;
import java.util.TreeMap;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+import java.util.zip.ZipOutputStream;
/**
* This is a custom Axis2 deployer written for deploying JavaScript services.
@@ -145,6 +149,7 @@
// Mashup Server gets control before JavaScript Services are
deployed.
// We prepare the registry for mashups to be added into it.
RegistryInitializer.initRegistry(configCtx);
+ createInitialWorkDirectory();
} catch (MashupFault mashupFault) {
throw new RuntimeException(mashupFault);
} catch (SchedulerException e) {
@@ -1019,4 +1024,81 @@
soap11BindingOperation.setProperty(WSDL2Constants.ATTR_WSOAP_ACTION,
inputAction);
return soap11BindingOperation;
}
+
+ /**
+ * Cretes a work directory for the Mashup Server. We create a axis2 repo
in this so that the
+ * Mashup Server can use this repo when acting as a client.
+ * @throws DeploymentException Thrown in case the work directory cannot be
created properly
+ */
+ private void createInitialWorkDirectory() throws DeploymentException {
+
+ final String WSAS_MODULES_DIR = "modules";
+ String wso2wsasHome =
System.getProperty(MashupConstants.WSO2WSAS_HOME);
+
+ // represents the .work directry
+ File workDir = new File (wso2wsasHome, MashupConstants.WORK_DIRECTORY);
+ if (!workDir.exists()) {
+ workDir.mkdir();
+ }
+
+ // represents .work/repo directory
+ File repositoryDir = new File (workDir,
MashupConstants.REPO_DIRECTORY);
+ if (!repositoryDir.exists()) {
+ repositoryDir.mkdir();
+ }
+
+ // represents .work/repo/modules directory
+ File modulesDir = new File (repositoryDir,
MashupConstants.MODULES_DIRECTORY);
+ if (!modulesDir.exists()) {
+ modulesDir.mkdir();
+ }
+ File wsasModules = new File (wso2wsasHome, WSAS_MODULES_DIR);
+ File[] modules = wsasModules.listFiles();
+
+ // Serach for the rampart module in the WSAS
+ String rampartFileName = null;
+ for (int i = 0; i < modules.length; i++) {
+ File module = modules[i];
+ String moduleName = module.getName();
+ if (moduleName.startsWith(MashupConstants.RAMPART)) {
+ rampartFileName = moduleName;
+ break;
+ }
+ }
+ File wsasRampartModule = new File(wsasModules, rampartFileName);
+ File clientRampartModule = new File (modulesDir, rampartFileName);
+
+ // If the rampart module exits in the client repo then we can skip
copying it
+ if (clientRampartModule.exists()) {
+ return;
+ }
+
+ // Here we copy over the rampart mar from the WSAS repository in to
our new client side
+ // repository
+ try {
+ byte[] readBuffer = new byte[MashupConstants.BUFFER_SIZE];
+ ZipOutputStream zipOutputStream =
+ new ZipOutputStream(new
FileOutputStream(clientRampartModule));
+ ZipInputStream zipInputStream =
+ new ZipInputStream(new FileInputStream(wsasRampartModule));
+ ZipEntry ze;
+ while ((ze = zipInputStream.getNextEntry()) != null) {
+ if (ze.isDirectory())
+ continue;//ignore directories
+ String fname = ze.getName();
+ //copy the entry from zipInputStream to zipOutputStream
+ int bytes;
+ zipOutputStream.putNextEntry(new ZipEntry(fname));
+ while ((bytes = zipInputStream.read(readBuffer, 0,
readBuffer.length)) > 0) {
+ zipOutputStream.write(readBuffer, 0, bytes);
+ }
+ zipInputStream.closeEntry();
+ zipOutputStream.closeEntry();
+ }
+ zipInputStream.close();
+ zipOutputStream.close();
+ } catch (IOException e) {
+ throw new DeploymentException(e);
+ }
+ }
}
\ No newline at end of file
_______________________________________________
Mashup-dev mailing list
[email protected]
http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev