[wsas-java-dev] svn commit r1698 - in trunk/wsas/java/modules:
admin/src/org/wso2/wsas/admin/service
admin/src/org/wso2/wsas/admin/service/util www/extensions/core/js
svn at wso2.org
svn at wso2.org
Mon Apr 2 05:30:43 PDT 2007
Author: saminda
Date: Mon Apr 2 05:30:34 2007
New Revision: 1698
Added:
trunk/wsas/java/modules/admin/src/org/wso2/wsas/admin/service/util/CreateArchive.java
Modified:
trunk/wsas/java/modules/admin/src/org/wso2/wsas/admin/service/ServiceAdmin.java
trunk/wsas/java/modules/www/extensions/core/js/services.js
Log:
Initial implemenation of "dump aar" feature
TODO Adminui
TODO Generating services.xml based on ServiceDO
Modified: trunk/wsas/java/modules/admin/src/org/wso2/wsas/admin/service/ServiceAdmin.java
==============================================================================
--- trunk/wsas/java/modules/admin/src/org/wso2/wsas/admin/service/ServiceAdmin.java (original)
+++ trunk/wsas/java/modules/admin/src/org/wso2/wsas/admin/service/ServiceAdmin.java Mon Apr 2 05:30:34 2007
@@ -944,7 +944,7 @@
* Creates and deploys a service. This AAR will contain all the classe from
* the jar/zip file corresponding to <code>archiveId</code>. In addition,
* a services.xml will be created, and all of the
- * <code>serviceClasses</code> will be added as services.
+ * <code>serviceClasses</code> will be added as services. TODO
*
* @param archiveId
* @param serviceClasses
@@ -1418,4 +1418,20 @@
}
+
+ /**
+ * TODO
+ * Get the information from ServiceDO and create the foo.aar and ask user to dump
+ * it any place the uesrs wishes.
+ * @param serviceName
+ * @return
+ * @throws AxisFault
+ */
+ public String dumpAAR(String serviceName) throws AxisFault {
+
+ CreateArchive createArchive = CreateArchive.getInstance();
+
+ return createArchive.createArchive(configCtx,serviceName);
+
+ }
}
Added: trunk/wsas/java/modules/admin/src/org/wso2/wsas/admin/service/util/CreateArchive.java
==============================================================================
--- (empty file)
+++ trunk/wsas/java/modules/admin/src/org/wso2/wsas/admin/service/util/CreateArchive.java Mon Apr 2 05:30:34 2007
@@ -0,0 +1,130 @@
+/*
+ * 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.wso2.wsas.admin.service.util;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.wso2.wsas.ServerConstants;
+import org.wso2.utils.ArchiveManipulator;
+import org.wso2.utils.WSO2Constants;
+
+import java.net.URL;
+import java.io.File;
+import java.io.IOException;
+import java.io.FileFilter;
+import java.util.Map;
+import java.util.Hashtable;
+
+/*
+ *
+ */
+
+public class CreateArchive {
+
+ private static Log log = LogFactory.getLog(CreateArchive.class);
+
+ private static CreateArchive createArchive = new CreateArchive();
+
+ private CreateArchive() {
+ }
+
+ public static CreateArchive getInstance() {
+ return createArchive;
+ }
+
+
+ public String createArchive(ConfigurationContext configurationContext, String serviceName)
+ throws AxisFault {
+ String uuid = String.valueOf(System.currentTimeMillis() + Math.random());
+ AxisService axisService =
+ configurationContext.getAxisConfiguration().getService(serviceName);
+ if (axisService == null) {
+ String error = CreateArchive.class.getName() + " AxisService " + serviceName +
+ " couldn't be found";
+ log.error(error);
+ throw new AxisFault(error);
+ }
+
+ URL fiUrl = axisService.getFileName();
+
+ String workdir = (String) configurationContext.getProperty(ServerConstants.WORK_DIR);
+
+ File f = new File(workdir + File.separator + "dump_aar" + File.separator + uuid);
+ f.mkdirs();
+
+ ArchiveManipulator am = new ArchiveManipulator();
+ try {
+ am.extract(fiUrl.getPath(), f.getAbsolutePath());
+
+ File servicesF =
+ new File(f.getAbsolutePath() + File.separator + "META-INF", "services.xml");
+
+ servicesF.mkdirs();
+
+ File absoluteSf = servicesF.getAbsoluteFile();
+
+ if (absoluteSf.exists()) {
+ absoluteSf.delete();
+ }
+
+ absoluteSf.createNewFile();
+
+ //TODO fill the content of services.xml based on ServiceDO object
+
+ File fout = new File(workdir + File.separator + "dump_aar_output" + File.separator + uuid);
+ fout.mkdirs();
+ String outAARFilename = fout.getAbsolutePath() + File.separator + serviceName + ".aar";
+
+ am.archiveDir(outAARFilename, f.getPath());
+
+ Map fileResourcesMap =
+ (Map) configurationContext.getProperty(WSO2Constants.FILE_RESOURCE_MAP);
+
+ if (fileResourcesMap == null) {
+ fileResourcesMap = new Hashtable();
+ configurationContext.setProperty(WSO2Constants.FILE_RESOURCE_MAP,
+ fileResourcesMap);
+ }
+
+
+ File[] files = fout.listFiles(new FileFilter() {
+ public boolean accept(File f) {
+ return f.getName().endsWith(".aar");
+ }
+ });
+
+ if ((files != null) && (files[0] != null) &&
+ (files[0].getAbsoluteFile() != null)) {
+ fileResourcesMap.put(uuid, files[0].getAbsoluteFile().getAbsolutePath());
+ }
+
+ return WSO2Constants.ContextPaths.DOWNLOAD_PATH + "?id=" + uuid;
+
+
+ } catch (IOException e) {
+ log.error(e);
+ throw new AxisFault(e);
+
+ }
+
+
+ }
+}
Modified: trunk/wsas/java/modules/www/extensions/core/js/services.js
==============================================================================
--- trunk/wsas/java/modules/www/extensions/core/js/services.js (original)
+++ trunk/wsas/java/modules/www/extensions/core/js/services.js Mon Apr 2 05:30:34 2007
@@ -1803,6 +1803,33 @@
+/*
+TODO ########################################################################
+*/
+
+
+function dumpAAR() {
+
+ var body_xml = '<req:dumpAAR xmlns:req="http://org.apache.axis2/xsd">\n' +
+ '<serviceId>' + 'version' + '</serviceId>\n' +
+ '</req:dumpAAR>\n';
+
+ var callURL = serverURL + "/" + "ServiceAdmin" ;
+ send("dumpAAR", body_xml, "", callURL, "", false, dumpAARCallback);
+
+}
+
+function dumpAARCallback() {
+
+ if (!onError()) {
+ return;
+ }
+
+}
+
+
+
+
More information about the Wsas-java-dev
mailing list