[Carbon-commits] [Carbon] svn commit r45786 - in trunk/carbon/org.wso2.carbon.core/src/main/java/org/wso2/carbon/core: . deployment init
isuru at wso2.com
isuru at wso2.com
Sat Sep 19 09:44:04 PDT 2009
Author: isuru
Date: Sat Sep 19 09:44:04 2009
New Revision: 45786
URL: http://wso2.org/svn/browse/wso2?view=rev&revision=45786
Log:
implementing registry based repository support
Added:
trunk/carbon/org.wso2.carbon.core/src/main/java/org/wso2/carbon/core/RegistryRepoHandler.java
Modified:
trunk/carbon/org.wso2.carbon.core/src/main/java/org/wso2/carbon/core/deployment/DeploymentInterceptor.java
trunk/carbon/org.wso2.carbon.core/src/main/java/org/wso2/carbon/core/init/CarbonServerManager.java
Added: trunk/carbon/org.wso2.carbon.core/src/main/java/org/wso2/carbon/core/RegistryRepoHandler.java
URL: http://wso2.org/svn/browse/wso2/trunk/carbon/org.wso2.carbon.core/src/main/java/org/wso2/carbon/core/RegistryRepoHandler.java?pathrev=45786
==============================================================================
--- (empty file)
+++ trunk/carbon/org.wso2.carbon.core/src/main/java/org/wso2/carbon/core/RegistryRepoHandler.java Sat Sep 19 09:44:04 2009
@@ -0,0 +1,69 @@
+package org.wso2.carbon.core;
+
+import org.wso2.carbon.registry.core.Registry;
+import org.wso2.carbon.registry.core.Resource;
+import org.wso2.carbon.registry.dump.RegistryToFileSystemHandler;
+import org.wso2.carbon.core.internal.CarbonCoreServiceComponent;
+import org.wso2.carbon.utils.CarbonUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.*;
+
+
+public class RegistryRepoHandler {
+
+ private static Log log = LogFactory.getLog(RegistryRepoHandler.class);
+
+ private static String metaDir = ".repo";
+
+ /**
+ * Copies the repository in the given path to the local file system and returns the path.
+ * We are using java tmp dir to get the copy of the repository
+ * @param registryPath - path of the repository in registry
+ * @return local repo path
+ */
+ public static String prepareRepository(String registryPath) {
+ String tmpRepo = System.getProperty("java.io.tmpdir");
+ String[] temp = registryPath.split("/");
+ String repoDirName = temp[temp.length - 1];
+
+ String repoPath = tmpRepo + File.separator + repoDirName;
+ String metaPath = tmpRepo + File.separator + RegistryRepoHandler.metaDir;
+
+ try {
+ Registry registry = CarbonCoreServiceComponent
+ .getRegistryService().getSystemRegistry();
+ RegistryToFileSystemHandler dumpHandler = new RegistryToFileSystemHandler(registry);
+
+ File repo = new File(repoPath);
+ if (repo.exists()) {
+ dumpHandler.update(repoPath, metaPath + File.separator + repoDirName);
+ } else {
+ dumpHandler.dumpToFilesystem(registryPath, tmpRepo, metaPath);
+ }
+ } catch (Exception e) {
+ log.error("Error dumping repository from registry.", e);
+ }
+
+ return repoPath;
+ }
+
+ /**
+ * Stores an artifact in the repository which is in Registry
+ * @param artifactStream - input stream of the artifact
+ * @param resourcePath - path to store
+ * @throws Exception - error in accessing registry
+ */
+ public static void storeArtifactInRegistry(InputStream artifactStream,
+ String resourcePath) throws Exception {
+ String registryRepoPath = CarbonUtils.getRegistryRepoPath();
+ if (registryRepoPath != null) {
+ Registry registry = CarbonCoreServiceComponent.getRegistryService().getSystemRegistry();
+ Resource artifactResource = registry.newResource();
+ artifactResource.setContentStream(artifactStream);
+ registry.put(resourcePath, artifactResource);
+ }
+ }
+
+}
Modified: trunk/carbon/org.wso2.carbon.core/src/main/java/org/wso2/carbon/core/deployment/DeploymentInterceptor.java
URL: http://wso2.org/svn/browse/wso2/trunk/carbon/org.wso2.carbon.core/src/main/java/org/wso2/carbon/core/deployment/DeploymentInterceptor.java?rev=45786&r1=45785&r2=45786&view=diff
==============================================================================
--- trunk/carbon/org.wso2.carbon.core/src/main/java/org/wso2/carbon/core/deployment/DeploymentInterceptor.java (original)
+++ trunk/carbon/org.wso2.carbon.core/src/main/java/org/wso2/carbon/core/deployment/DeploymentInterceptor.java Sat Sep 19 09:44:04 2009
@@ -33,6 +33,7 @@
import org.wso2.carbon.Axis2ModuleNotFound;
import org.wso2.carbon.CarbonConstants;
import org.wso2.carbon.core.RegistryResources;
+import org.wso2.carbon.core.internal.CarbonCoreServiceComponent;
import org.wso2.carbon.core.persistence.PersistenceManager;
import org.wso2.carbon.core.util.SystemFilter;
import org.wso2.carbon.registry.core.Resource;
@@ -73,8 +74,7 @@
// No need to do a null check for registry here, as the corresponding check is done
// inside the Persistence Manager. This registry instance is used to start/stop
// transactions.
- Registry registry =
- (Registry) axisConfig.getParameterValue(WSO2Constants.REGISTRY_INSTANCE);
+ registry = CarbonCoreServiceComponent.getRegistryService().getSystemRegistry();
} catch (Exception e) {
log.error("Error while initializing the persistence manager for deployment interceptor", e);
}
Modified: trunk/carbon/org.wso2.carbon.core/src/main/java/org/wso2/carbon/core/init/CarbonServerManager.java
URL: http://wso2.org/svn/browse/wso2/trunk/carbon/org.wso2.carbon.core/src/main/java/org/wso2/carbon/core/init/CarbonServerManager.java?rev=45786&r1=45785&r2=45786&view=diff
==============================================================================
--- trunk/carbon/org.wso2.carbon.core/src/main/java/org/wso2/carbon/core/init/CarbonServerManager.java (original)
+++ trunk/carbon/org.wso2.carbon.core/src/main/java/org/wso2/carbon/core/init/CarbonServerManager.java Sat Sep 19 09:44:04 2009
@@ -33,6 +33,7 @@
import org.wso2.carbon.core.ServerInitializer;
import org.wso2.carbon.core.ServerManagement;
import org.wso2.carbon.core.ServerStatus;
+import org.wso2.carbon.core.RegistryRepoHandler;
import org.wso2.carbon.core.deployment.OSGiAxis2ServiceDeployer;
import org.wso2.carbon.core.internal.CarbonCoreServiceComponent;
import org.wso2.carbon.core.internal.HTTPGetProcessorListener;
@@ -42,7 +43,6 @@
import org.wso2.carbon.core.transports.CarbonServlet;
import org.wso2.carbon.core.transports.CommonTransportLoader;
import org.wso2.carbon.core.transports.TransportBuilder;
-import org.wso2.carbon.core.util.ClusteringUtil;
import org.wso2.carbon.core.util.HouseKeepingTask;
import org.wso2.carbon.core.util.ParameterUtil;
import org.wso2.carbon.core.util.SystemRestarter;
@@ -458,19 +458,25 @@
}
private void setAxis2RepoLocation() {
- if (System.getProperty("axis2.repo") != null) {
+ //First check whether repository should be read from the registry
+ String regRepoPath = CarbonUtils.getRegistryRepoPath();
+
+ if (regRepoPath != null) {
+ axis2RepoLocation = RegistryRepoHandler.prepareRepository(regRepoPath);
+ } else if (System.getProperty("axis2.repo") != null) {
axis2RepoLocation = System.getProperty("axis2.repo");
serverConfig.setConfigurationProperty(ServerConfiguration.AXIS2_CONFIG_REPO_LOCATION,
- axis2RepoLocation);
+ axis2RepoLocation);
} else {
if (isEmbedEnv) {
axis2RepoLocation =
serverConfig.getFirstProperty(ServerConfiguration.AXIS2_CONFIG_REPO_LOCATION);
} else {
- axis2RepoLocation =
- System.getProperty(ServerConstants.AXIS2_HOME) + File.separator + "repository" + File.separator;
+ axis2RepoLocation = System.getProperty(ServerConstants.AXIS2_HOME)
+ + File.separator + "repository" + File.separator;
}
}
+
if (!axis2RepoLocation.endsWith("/")) {
serverConfig.setConfigurationProperty(ServerConfiguration.AXIS2_CONFIG_REPO_LOCATION,
axis2RepoLocation + "/");
More information about the Carbon-commits
mailing list