You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by dj...@apache.org on 2006/02/17 09:38:15 UTC
svn commit: r378459 [1/2] - in /geronimo/branches/configid:
applications/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/
applications/console-standard/src/java/org/apache/geronimo/console/jmsmanager/wizard/
applications/conso...
Author: djencks
Date: Fri Feb 17 00:37:43 2006
New Revision: 378459
URL: http://svn.apache.org/viewcvs?rev=378459&view=rev
Log:
Further refactoring: compiles but not all tests pass
Modified:
geronimo/branches/configid/applications/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/CreateDestinationHandler.java
geronimo/branches/configid/applications/console-standard/src/java/org/apache/geronimo/console/jmsmanager/wizard/AbstractHandler.java
geronimo/branches/configid/applications/console-standard/src/java/org/apache/geronimo/console/jmsmanager/wizard/JMSProviderData.java
geronimo/branches/configid/applications/console-standard/src/java/org/apache/geronimo/console/util/PortletManager.java
geronimo/branches/configid/modules/connector-builder/src/test/org/apache/geronimo/connector/deployment/ConnectorModuleBuilderTest.java
geronimo/branches/configid/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java
geronimo/branches/configid/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java
geronimo/branches/configid/modules/j2ee-builder/src/test/org/apache/geronimo/j2ee/deployment/EARConfigBuilderTest.java
geronimo/branches/configid/modules/jetty-builder/src/test/org/apache/geronimo/jetty/deployment/JettyModuleBuilderTest.java
geronimo/branches/configid/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java
geronimo/branches/configid/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationData.java
geronimo/branches/configid/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationManagerImpl.java
geronimo/branches/configid/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationStore.java
geronimo/branches/configid/modules/kernel/src/java/org/apache/geronimo/kernel/repository/Environment.java
geronimo/branches/configid/modules/kernel/src/test/org/apache/geronimo/kernel/ConfigTest.java
geronimo/branches/configid/modules/system/src/java/org/apache/geronimo/system/configuration/ExecutableConfigurationUtil.java
geronimo/branches/configid/modules/system/src/java/org/apache/geronimo/system/configuration/LocalConfigStore.java
geronimo/branches/configid/modules/tomcat-builder/src/test/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilderTest.java
geronimo/branches/configid/plugins/geronimo-packaging-plugin/src/java/org/apache/geronimo/plugin/packaging/MavenConfigStore.java
Modified: geronimo/branches/configid/applications/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/CreateDestinationHandler.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/applications/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/CreateDestinationHandler.java?rev=378459&r1=378458&r2=378459&view=diff
==============================================================================
--- geronimo/branches/configid/applications/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/CreateDestinationHandler.java (original)
+++ geronimo/branches/configid/applications/console-standard/src/java/org/apache/geronimo/console/jmsmanager/handlers/CreateDestinationHandler.java Fri Feb 17 00:37:43 2006
@@ -35,6 +35,7 @@
import org.apache.geronimo.kernel.config.ConfigurationUtil;
import org.apache.geronimo.kernel.repository.Artifact;
import org.apache.geronimo.kernel.repository.Version;
+import org.apache.geronimo.kernel.repository.Environment;
import javax.jms.Queue;
import javax.jms.Topic;
@@ -47,6 +48,9 @@
import java.net.URI;
import java.util.Arrays;
import java.util.List;
+import java.util.Collections;
+import java.util.ArrayList;
+import java.util.LinkedHashSet;
public class CreateDestinationHandler extends AbstractJMSManager implements PortletResponseHandler {
protected static Log log = LogFactory
@@ -117,15 +121,11 @@
ObjectName storeName = (ObjectName) stores.iterator().next();
File installDir = (File) kernel.invoke(storeName,
"createNewConfigurationDir");
- //DeploymentContext deploymentContext = new
- // DeploymentContext(installDir, configId,
- // ConfigurationModuleType.SERVICE, parentId, kernel);
- ConfigurationData configData = new ConfigurationData();
- configData.setId(configId);
- configData.setParentId(parentId);
- configData.setModuleType(ConfigurationModuleType.SERVICE);
- //deploymentContext.addGBean(adminObjectData);
- configData.addGBean(adminObjectData);
+ Environment environment = new Environment();
+ environment.setConfigId(configId);
+ environment.setImports(parentId);
+ List gbeans = new ArrayList();
+ gbeans.add(adminObjectData);
// If we are adding a topic we have to add a browser so we can view
// its messages later.
if (Topic.class.getName().equals(destinationType)) {
@@ -144,8 +144,13 @@
tBrowserBeanData.setReferencePattern("TopicWrapper",
adminObjectName);
- configData.addGBean(tBrowserBeanData);
+ gbeans.add(tBrowserBeanData);
}
+ ConfigurationData configData = new ConfigurationData(ConfigurationModuleType.SERVICE,
+ new LinkedHashSet(),
+ gbeans,
+ Collections.EMPTY_LIST,
+ environment);
//saves it.
//deploymentContext.close();
Modified: geronimo/branches/configid/applications/console-standard/src/java/org/apache/geronimo/console/jmsmanager/wizard/AbstractHandler.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/applications/console-standard/src/java/org/apache/geronimo/console/jmsmanager/wizard/AbstractHandler.java?rev=378459&r1=378458&r2=378459&view=diff
==============================================================================
--- geronimo/branches/configid/applications/console-standard/src/java/org/apache/geronimo/console/jmsmanager/wizard/AbstractHandler.java (original)
+++ geronimo/branches/configid/applications/console-standard/src/java/org/apache/geronimo/console/jmsmanager/wizard/AbstractHandler.java Fri Feb 17 00:37:43 2006
@@ -513,7 +513,7 @@
//data.instanceName = data.instanceName.replaceAll("\\s", "");
DeploymentManager mgr = PortletManager.getDeploymentManager(request);
try {
- URL url = PortletManager.getRepositoryEntry(request, data.getRarURI());
+ URL url = PortletManager.getRepositoryEntry(request, data.getRarURI()).toURL();
String str = url.toString();
if(str.indexOf(' ') > -1) {
url = new URL(str.replaceAll(" ", "%20")); // try to avoid problems with spaces in path on Windows
Modified: geronimo/branches/configid/applications/console-standard/src/java/org/apache/geronimo/console/jmsmanager/wizard/JMSProviderData.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/applications/console-standard/src/java/org/apache/geronimo/console/jmsmanager/wizard/JMSProviderData.java?rev=378459&r1=378458&r2=378459&view=diff
==============================================================================
--- geronimo/branches/configid/applications/console-standard/src/java/org/apache/geronimo/console/jmsmanager/wizard/JMSProviderData.java (original)
+++ geronimo/branches/configid/applications/console-standard/src/java/org/apache/geronimo/console/jmsmanager/wizard/JMSProviderData.java Fri Feb 17 00:37:43 2006
@@ -28,6 +28,8 @@
import java.io.Serializable;
import java.io.InputStream;
import java.io.IOException;
+import java.io.File;
+import java.io.FileInputStream;
import java.util.*;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipEntry;
@@ -203,8 +205,8 @@
}
private static void loadRARData(JMSProviderData data, PortletRequest request) throws IOException {
- URL url = PortletManager.getRepositoryEntry(request, data.getRaURI());
- ZipInputStream in = new ZipInputStream(url.openStream());
+ File url = PortletManager.getRepositoryEntry(request, data.getRaURI());
+ ZipInputStream in = new ZipInputStream(new FileInputStream(url));
ZipEntry entry;
Document doc = null;
try {
Modified: geronimo/branches/configid/applications/console-standard/src/java/org/apache/geronimo/console/util/PortletManager.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/applications/console-standard/src/java/org/apache/geronimo/console/util/PortletManager.java?rev=378459&r1=378458&r2=378459&view=diff
==============================================================================
--- geronimo/branches/configid/applications/console-standard/src/java/org/apache/geronimo/console/util/PortletManager.java (original)
+++ geronimo/branches/configid/applications/console-standard/src/java/org/apache/geronimo/console/util/PortletManager.java Fri Feb 17 00:37:43 2006
@@ -25,6 +25,7 @@
import org.apache.geronimo.kernel.repository.ListableRepository;
import org.apache.geronimo.kernel.repository.Repository;
import org.apache.geronimo.kernel.repository.WriteableRepository;
+import org.apache.geronimo.kernel.repository.Artifact;
import org.apache.geronimo.management.J2EEDomain;
import org.apache.geronimo.management.ResourceAdapter;
import org.apache.geronimo.management.geronimo.*;
@@ -52,6 +53,7 @@
import java.net.URL;
import java.net.URISyntaxException;
import java.net.MalformedURLException;
+import java.io.File;
/**
* @version $Rev$ $Date$
@@ -65,7 +67,7 @@
private final static String JVM_KEY = "org.apache.geronimo.console.JVM";
private final static String SYSTEM_LOG_KEY = "org.apache.geronimo.console.SystemLog";
// The following may change based on the user's selections
- // nothing yet
+ // nothing yet
private static ManagementHelper createHelper() {
//todo: consider making this configurable; we could easily connect to a remote kernel if we wanted to
@@ -75,7 +77,7 @@
} catch (NamingException e) {
// log.error("Unable to look up kernel in JNDI", e);
}
- if(kernel == null) {
+ if (kernel == null) {
log.debug("Unable to find kernel in JNDI; using KernelRegistry instead");
kernel = KernelRegistry.getSingleKernel();
}
@@ -94,7 +96,7 @@
public static ManagementHelper getManagementHelper(PortletRequest request) {
ManagementHelper helper = (ManagementHelper) request.getPortletSession(true).getAttribute(HELPER_KEY, PortletSession.APPLICATION_SCOPE);
- if(helper == null) {
+ if (helper == null) {
helper = createHelper();
request.getPortletSession().setAttribute(HELPER_KEY, helper, PortletSession.APPLICATION_SCOPE);
}
@@ -103,7 +105,7 @@
public static ManagementHelper getManagementHelper(HttpSession session) {
ManagementHelper helper = (ManagementHelper) session.getAttribute(HELPER_KEY);
- if(helper == null) {
+ if (helper == null) {
helper = createHelper();
session.setAttribute(HELPER_KEY, helper);
}
@@ -112,7 +114,7 @@
public static J2EEDomain getCurrentDomain(PortletRequest request) {
J2EEDomain domain = (J2EEDomain) request.getPortletSession(true).getAttribute(DOMAIN_KEY, PortletSession.APPLICATION_SCOPE);
- if(domain == null) {
+ if (domain == null) {
domain = getManagementHelper(request).getDomains()[0]; //todo: some day, select a domain
request.getPortletSession().setAttribute(DOMAIN_KEY, domain, PortletSession.APPLICATION_SCOPE);
}
@@ -122,12 +124,11 @@
public static J2EEServer getCurrentServer(PortletRequest request) {
J2EEServer server = (J2EEServer) request.getPortletSession(true).getAttribute(SERVER_KEY, PortletSession.APPLICATION_SCOPE);
- if(server == null) {
+ if (server == null) {
ManagementHelper helper = getManagementHelper(request);
server = helper.getServers(getCurrentDomain(request))[0]; //todo: some day, select a server from the domain
request.getPortletSession().setAttribute(SERVER_KEY, server, PortletSession.APPLICATION_SCOPE);
- }
- else {
+ } else {
// to do handle "should not occur" error - message?
}
return server;
@@ -135,7 +136,7 @@
public static JVM getCurrentJVM(PortletRequest request) {
JVM jvm = (JVM) request.getPortletSession(true).getAttribute(JVM_KEY, PortletSession.APPLICATION_SCOPE);
- if(jvm == null) {
+ if (jvm == null) {
ManagementHelper helper = getManagementHelper(request);
jvm = helper.getJavaVMs(getCurrentServer(request))[0]; //todo: some day, select a JVM from the server
request.getPortletSession().setAttribute(JVM_KEY, jvm, PortletSession.APPLICATION_SCOPE);
@@ -174,7 +175,7 @@
List result = new ArrayList();
for (int i = 0; i < list.length; i++) {
Repository repository = list[i];
- if(repository instanceof ListableRepository) {
+ if (repository instanceof ListableRepository) {
result.add(repository);
}
}
@@ -187,7 +188,7 @@
List result = new ArrayList();
for (int i = 0; i < list.length; i++) {
Repository repository = list[i];
- if(repository instanceof WriteableRepository) {
+ if (repository instanceof WriteableRepository) {
result.add(repository);
}
}
@@ -216,12 +217,12 @@
public static JCAManagedConnectionFactory[] getOutboundFactoriesForRA(PortletRequest request, String resourceAdapterModuleName) {
ManagementHelper helper = getManagementHelper(request);
- return helper.getOutboundFactories((ResourceAdapterModule)helper.getObject(resourceAdapterModuleName));
+ return helper.getOutboundFactories((ResourceAdapterModule) helper.getObject(resourceAdapterModuleName));
}
public static JCAManagedConnectionFactory[] getOutboundFactoriesForRA(PortletRequest request, String resourceAdapterModuleName, String iface) {
ManagementHelper helper = getManagementHelper(request);
- return helper.getOutboundFactories((ResourceAdapterModule)helper.getObject(resourceAdapterModuleName), iface);
+ return helper.getOutboundFactories((ResourceAdapterModule) helper.getObject(resourceAdapterModuleName), iface);
}
public static JCAManagedConnectionFactory[] getOutboundFactoriesForRA(PortletRequest request, ResourceAdapterModule module) {
@@ -280,7 +281,7 @@
ManagementHelper helper = getManagementHelper(request);
WebManager manager = (WebManager) helper.getObject(managerObjectName);
String objectName = manager.addConnector(containerObjectName, name, protocol, host, port);
- return (WebConnector)helper.getObject(objectName);
+ return (WebConnector) helper.getObject(objectName);
}
public static WebConnector[] getWebConnectors(PortletRequest request, String managerObjectName) {
@@ -341,7 +342,7 @@
ManagementHelper helper = getManagementHelper(request);
JMSManager manager = (JMSManager) helper.getObject(managerObjectName);
String objectName = manager.addConnector(containerObjectName, name, protocol, host, port);
- return (JMSConnector)helper.getObject(objectName);
+ return (JMSConnector) helper.getObject(objectName);
}
public static JMSConnector[] getJMSConnectors(PortletRequest request, String managerObjectName) {
@@ -390,7 +391,7 @@
public static SystemLog getCurrentSystemLog(PortletRequest request) {
SystemLog log = (SystemLog) request.getPortletSession(true).getAttribute(SYSTEM_LOG_KEY, PortletSession.APPLICATION_SCOPE);
- if(log == null) {
+ if (log == null) {
ManagementHelper helper = getManagementHelper(request);
log = helper.getSystemLog(getCurrentJVM(request));
request.getPortletSession().setAttribute(SYSTEM_LOG_KEY, log, PortletSession.APPLICATION_SCOPE);
@@ -418,20 +419,14 @@
return helper.getConfigurationNameFor(objectName);
}
- public static URL getRepositoryEntry(PortletRequest request, String repositoryURI) {
- try {
- Repository[] repos = getRepositories(request);
- URI uri = new URI(repositoryURI);
- for (int i = 0; i < repos.length; i++) {
- Repository repo = repos[i];
- if(repo.hasURI(uri)) {
- return repo.getURL(uri);
- }
+ public static File getRepositoryEntry(PortletRequest request, String repositoryURI) {
+ Repository[] repos = getRepositories(request);
+ Artifact uri = Artifact.create(repositoryURI);
+ for (int i = 0; i < repos.length; i++) {
+ Repository repo = repos[i];
+ if (repo.contains(uri)) {
+ return repo.getLocation(uri);
}
- } catch (URISyntaxException e) {
- log.error("Unable to access repository entry '"+repositoryURI+"'", e);
- } catch (MalformedURLException e) {
- log.error("Unable to access repository entry '"+repositoryURI+"'", e);
}
return null;
}
@@ -441,14 +436,14 @@
* is in one of the portlets. We're kind of hacking our way there, but hey,
* it beats hardcoding.
*/
- public static String getConsoleFrameworkServletPath (HttpServletRequest request) {
+ public static String getConsoleFrameworkServletPath(HttpServletRequest request) {
String contextPath = "";
Object o = request.getAttribute("javax.portlet.response");
- if (o!=null && o instanceof RenderResponse) { // request came from a portlet
- RenderResponse renderResponse = (RenderResponse)o;
+ if (o != null && o instanceof RenderResponse) { // request came from a portlet
+ RenderResponse renderResponse = (RenderResponse) o;
contextPath = renderResponse.createRenderURL().toString();
int index = contextPath.indexOf(request.getPathInfo());
- contextPath = contextPath.substring(0,index);
+ contextPath = contextPath.substring(0, index);
} else { // request did not come from a portlet
contextPath = request.getContextPath();
}
Modified: geronimo/branches/configid/modules/connector-builder/src/test/org/apache/geronimo/connector/deployment/ConnectorModuleBuilderTest.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/modules/connector-builder/src/test/org/apache/geronimo/connector/deployment/ConnectorModuleBuilderTest.java?rev=378459&r1=378458&r2=378459&view=diff
==============================================================================
--- geronimo/branches/configid/modules/connector-builder/src/test/org/apache/geronimo/connector/deployment/ConnectorModuleBuilderTest.java (original)
+++ geronimo/branches/configid/modules/connector-builder/src/test/org/apache/geronimo/connector/deployment/ConnectorModuleBuilderTest.java Fri Feb 17 00:37:43 2006
@@ -633,6 +633,10 @@
return null;
}
+ public URL resolve(Artifact configId, URI uri) throws NoSuchConfigException, MalformedURLException {
+ return null;
+ }
+
public final static GBeanInfo GBEAN_INFO;
private static final byte[] NO_OBJECTS_OS;
Modified: geronimo/branches/configid/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java?rev=378459&r1=378458&r2=378459&view=diff
==============================================================================
--- geronimo/branches/configid/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java (original)
+++ geronimo/branches/configid/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java Fri Feb 17 00:37:43 2006
@@ -247,13 +247,6 @@
// this is good
}
- // create a configuration dir to write the configuration during the building proces
- configurationDir = store.createNewConfigurationDir();
-
- // create te meta-inf dir
- File metaInf = new File(configurationDir, "META-INF");
- metaInf.mkdirs();
-
// create the manifest
Manifest manifest;
if (mainClass != null) {
@@ -276,21 +269,22 @@
manifest = null;
}
+//TODO this is ludicrous! give the builder a location factory!
+ // create a configuration dir to write the configuration during the building proces
+ configurationDir = store.createNewConfigurationDir();
+
+ // create te meta-inf dir
+ File metaInf = new File(configurationDir, "META-INF");
+ metaInf.mkdirs();
+
ConfigurationData configurationData = builder.buildConfiguration(plan, module, configurationDir);
try {
if (targetFile != null) {
ExecutableConfigurationUtil.createExecutableConfiguration(configurationData, manifest, configurationDir, targetFile);
}
if (install) {
- store.install(configurationData, configurationDir);
List deployedURIs = new ArrayList();
- deployedURIs.add(configurationData.getId().toString());
- // todo this should support a tree structure since configurations could be nested to any depth
- for (Iterator iterator = configurationData.getChildConfigurations().iterator(); iterator.hasNext();) {
- ConfigurationData childConfiguration = (ConfigurationData) iterator.next();
- deployedURIs.add(childConfiguration.getId().toString());
- // todo install the child conifgurations here
- }
+ recursiveInstall(configurationData, configurationDir, deployedURIs);
return deployedURIs;
} else {
if (!DeploymentUtil.recursiveDelete(configurationDir)) {
@@ -324,6 +318,23 @@
throw new Error(e);
} finally {
DeploymentUtil.close(module);
+ }
+ }
+
+ private void recursiveInstall(ConfigurationData configurationData, File configurationDir, List deployedURIs) throws IOException, InvalidConfigException {
+ //TODO use 2nd copy, commented out
+ deployedURIs.add(configurationData.getId().toString());
+ //TODO FIXME
+ if (configurationDir == null) {
+ return;
+ }
+ store.install(configurationData, configurationDir);
+ //TODO uncomment
+// deployedURIs.add(configurationData.getId().toString());
+ for (Iterator iterator = configurationData.getChildConfigurations().iterator(); iterator.hasNext();) {
+ ConfigurationData childConfiguration = (ConfigurationData) iterator.next();
+ //TODO extremely broken... configDir should NOT BE IN THIS SIG! should be in configurationData.
+ recursiveInstall(childConfiguration, null, deployedURIs);
}
}
Modified: geronimo/branches/configid/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java?rev=378459&r1=378458&r2=378459&view=diff
==============================================================================
--- geronimo/branches/configid/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java (original)
+++ geronimo/branches/configid/modules/deployment/src/java/org/apache/geronimo/deployment/DeploymentContext.java Fri Feb 17 00:37:43 2006
@@ -26,9 +26,9 @@
import org.apache.geronimo.kernel.config.ConfigurationData;
import org.apache.geronimo.kernel.config.ConfigurationManager;
import org.apache.geronimo.kernel.config.ConfigurationModuleType;
+import org.apache.geronimo.kernel.config.ConfigurationStore;
import org.apache.geronimo.kernel.config.ConfigurationUtil;
import org.apache.geronimo.kernel.config.InvalidConfigException;
-import org.apache.geronimo.kernel.config.MultiParentClassLoader;
import org.apache.geronimo.kernel.config.NoSuchConfigException;
import org.apache.geronimo.kernel.management.State;
import org.apache.geronimo.kernel.repository.Artifact;
@@ -58,6 +58,7 @@
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
+import java.util.LinkedHashSet;
import java.util.jar.Attributes;
import java.util.jar.JarFile;
import java.util.jar.Manifest;
@@ -69,15 +70,17 @@
*/
public class DeploymentContext {
- private static final ClassLoader[] DEFAULT_PARENT_CLASSLOADERS = new ClassLoader[]{DeploymentContext.class.getClassLoader()};
+ private final Environment environment;
+ private final ConfigurationModuleType moduleType;
+ private final LinkedHashSet classpath = new LinkedHashSet();
private final Kernel kernel;
- private final ConfigurationData configurationData;
private final GBeanDataRegistry gbeans = new GBeanDataRegistry();
private final File baseDir;
private final URI baseUri;
private final byte[] buffer = new byte[4096];
private final List loadedAncestors = new ArrayList();
private final List startedAncestors = new ArrayList();
+ private final List childConfigurationDatas = new ArrayList();
public DeploymentContext(File baseDir, Environment environment, ConfigurationModuleType type, Kernel kernel) throws DeploymentException {
@@ -85,6 +88,8 @@
assert environment != null: "environment is null";
assert type != null: "type is null";
+ this.environment = environment;
+ this.moduleType = type;
this.kernel = kernel;
if (!baseDir.exists()) {
@@ -96,26 +101,20 @@
this.baseDir = baseDir;
this.baseUri = baseDir.toURI();
- configurationData = new ConfigurationData();
- configurationData.setId(environment.getConfigId());
- configurationData.setModuleType(type);
- //TODO configid this is broken, need Artifact to URI conversion or configData to use Artifacts.
- configurationData.setParentId(new ArrayList(environment.getImports()));
- configurationData.setNameKeys(environment.getProperties());
-
determineNaming();
determineInherited();
+ determineMinimalParents();
}
private void determineNaming() throws DeploymentException {
- if (configurationData.getNameKeys() != null && !configurationData.getNameKeys().isEmpty()) {
+ if (environment.getProperties() != null && !environment.getProperties().isEmpty()) {
return;
}
- List parentId = configurationData.getParentId();
+ Collection parentId = environment.getImports();
if (kernel == null || parentId == null || parentId.isEmpty()) {
- throw new DeploymentException("neither domain and server nor any way to determine them was provided for configuration " + configurationData.getId());
+ throw new DeploymentException("neither domain and server nor any way to determine them was provided for configuration " + environment.getConfigId());
}
- Artifact parent = (Artifact) parentId.get(0);
+ Artifact parent = (Artifact) parentId.iterator().next();
ConfigurationManager configurationManager = ConfigurationUtil.getConfigurationManager(kernel);
try {
@@ -126,7 +125,7 @@
}
try {
ObjectName parentName = Configuration.getConfigurationObjectName(parent);
- configurationData.setNameKeys((Map) kernel.getAttribute(parentName, "nameKeys"));
+ environment.setProperties((Map) kernel.getAttribute(parentName, "properties"));
} catch (Exception e) {
throw new DeploymentException("Unable to copy domain and server from parent configuration", e);
} finally {
@@ -136,15 +135,14 @@
}
}
} catch (Exception e) {
- throw new DeploymentException("Unable to load first parent of configuration " + configurationData.getId(), e);
+ throw new DeploymentException("Unable to load first parent of configuration " + environment.getConfigId(), e);
} finally {
ConfigurationUtil.releaseConfigurationManager(kernel, configurationManager);
}
//check that domain and server are now known
- if (configurationData.getNameKeys() == null || configurationData.getNameKeys().isEmpty()) {
- throw new IllegalStateException("Domain or server could not be determined from explicit args or parent configuration. ParentID: " + parentId
- + ", name keys: " + configurationData.getNameKeys());
+ if (environment.getProperties() == null || environment.getProperties().isEmpty()) {
+ throw new IllegalStateException("Properties not be determined from explicit args or parent configuration. ParentID: " + parentId);
}
}
@@ -153,7 +151,7 @@
return;
}
- List parentId = configurationData.getParentId();
+ Collection parentId = environment.getImports();
if (parentId != null && parentId.size() > 0) {
ConfigurationManager configurationManager = ConfigurationUtil.getConfigurationManager(kernel);
List inherited = new ArrayList();
@@ -186,32 +184,16 @@
} catch (Exception e) {
throw new DeploymentException(e);
}
- configurationData.getNonOverridableClasses().addAll(inherited);
+ environment.addNonOverrideableClasses(inherited);
}
}
public Artifact getConfigID() {
- return configurationData.getId();
- }
-
- public void setInverseClassloading(boolean inverseClassloading) {
- configurationData.setInverseClassloading(inverseClassloading);
- }
-
- public void addHiddenClasses(Set hiddenClasses) {
- configurationData.getHiddenClasses().addAll(hiddenClasses);
- }
-
- public void addNonOverridableClasses(Set nonOverridableClasses) {
- configurationData.getNonOverridableClasses().addAll(nonOverridableClasses);
- }
-
- public void addParentId(List parentId) {
- configurationData.getParentId().addAll(parentId);
+ return environment.getConfigId();
}
public ConfigurationModuleType getType() {
- return configurationData.getModuleType();
+ return moduleType;
}
public File getBaseDir() {
@@ -235,10 +217,6 @@
return gbeans.getGBeanInstance(name);
}
- public void addDependency(Artifact artifact) {
- configurationData.addDependency(artifact);
- }
-
/**
* Copy a packed jar file into the deployment context and place it into the
* path specified in the target path. The newly added packed jar is added
@@ -255,7 +233,7 @@
public void addIncludeAsPackedJar(URI targetPath, JarFile jarFile) throws IOException {
File targetFile = getTargetFile(targetPath);
DeploymentUtil.copyToPackedJar(jarFile, targetFile);
- configurationData.addClassPathLocation(targetPath);
+ classpath.add(targetPath);
}
/**
@@ -275,7 +253,7 @@
public void addInclude(URI targetPath, ZipFile zipFile, ZipEntry zipEntry) throws IOException {
File targetFile = getTargetFile(targetPath);
addFile(targetFile, zipFile, zipEntry);
- configurationData.addClassPathLocation(targetPath);
+ classpath.add(targetPath);
}
/**
@@ -294,7 +272,7 @@
public void addInclude(URI targetPath, URL source) throws IOException {
File targetFile = getTargetFile(targetPath);
addFile(targetFile, source);
- configurationData.addClassPathLocation(targetPath);
+ classpath.add(targetPath);
}
/**
@@ -313,7 +291,7 @@
public void addInclude(URI targetPath, File source) throws IOException {
File targetFile = getTargetFile(targetPath);
addFile(targetFile, source);
- configurationData.addClassPathLocation(targetPath);
+ classpath.add(targetPath);
}
/**
@@ -363,7 +341,7 @@
}
URI targetUri = moduleBaseUri.resolve(pathUri);
- configurationData.addClassPathLocation(targetUri);
+ classpath.add(targetUri);
}
}
@@ -387,7 +365,7 @@
assert location.toString().endsWith("/");
if (addToClasspath) {
- configurationData.addClassPathLocation(location);
+ classpath.add(location);
}
String classFileName = fqcn.replace('.', '/') + ".class";
addFile(getTargetFile(new URI(location.toString() + classFileName)), new ByteArrayInputStream(bytes));
@@ -498,12 +476,8 @@
throw new DeploymentException("Cannot convert ID to ObjectName: ", e);
}
try {
- Artifact[] parents = (Artifact[]) kernel.getAttribute(configName, "parentId");
- if (parents == null) {
- return Collections.EMPTY_LIST;
- } else {
- return Arrays.asList(parents);
- }
+ Environment environment = (Environment) kernel.getAttribute(configName, "environment");
+ return environment.getImports();
} catch (Exception e) {
throw new DeploymentException("Cannot find parents of alleged config: ", e);
}
@@ -511,16 +485,15 @@
}
- private ClassLoader[] determineParents() throws DeploymentException {
- ClassLoader[] parentCL;
- List parentId = configurationData.getParentId();
+ private void determineMinimalParents() throws DeploymentException {
+ Collection parentId = environment.getImports();
if (kernel != null && parentId != null && parentId.size() > 0) {
ConfigurationManager configurationManager = ConfigurationUtil.getConfigurationManager(kernel);
try {
loadAncestors(kernel, parentId, loadedAncestors, configurationManager);
ParentSource parentSource = new ConfigurationParentSource(kernel);
parentId = getExtremalSet(parentId, parentSource);
- configurationData.setParentId(parentId);
+ environment.setImports(parentId);
try {
for (Iterator iterator = parentId.iterator(); iterator.hasNext();) {
@@ -537,29 +510,10 @@
} finally {
ConfigurationUtil.releaseConfigurationManager(kernel, configurationManager);
}
- try {
- parentCL = new ClassLoader[parentId.size()];
- for (int i = 0; i < parentId.size(); i++) {
- Artifact uri = (Artifact) parentId.get(i);
- ObjectName parentName = Configuration.getConfigurationObjectName(uri);
- parentCL[i] = (ClassLoader) kernel.getAttribute(parentName, "configurationClassLoader");
- }
-
- } catch (Exception e) {
- throw new DeploymentException(e);
- }
- } else {
- // no explicit parent set, so use the class loader of this class as
- // the parent... this class should be in the root geronimo classloader,
- // which is normally the system class loader but not always, so be safe
- parentCL = DEFAULT_PARENT_CLASSLOADERS;
}
-
-
- return parentCL;
}
- private void loadAncestors(Kernel kernel, List parentId, List loadedAncestors, ConfigurationManager configurationManager) throws DeploymentException {
+ private void loadAncestors(Kernel kernel, Collection parentId, List loadedAncestors, ConfigurationManager configurationManager) throws DeploymentException {
if (kernel != null && parentId != null) {
try {
for (Iterator iterator = parentId.iterator(); iterator.hasNext();) {
@@ -595,33 +549,55 @@
}
public ClassLoader getClassLoader(Repository repository) throws DeploymentException {
- // shouldn't user classpath come before dependencies?
- List dependencies = configurationData.getDependencies();
- List classPath = configurationData.getClassPath();
- URL[] urls = new URL[dependencies.size() + classPath.size()];
try {
- int index = 0;
- for (Iterator iterator = dependencies.iterator(); iterator.hasNext();) {
- Artifact artifact = (Artifact) iterator.next();
- urls[index++] = repository.getLocation(artifact).toURL();
- }
+ Configuration configuration = new Configuration(kernel,
+ null,
+ moduleType,
+ environment,
+ null,
+ new ArrayList(classpath),
+ null,
+ Collections.singleton(repository),
+ new ConfigurationStore() {
- for (Iterator i = classPath.iterator(); i.hasNext();) {
- URI path = (URI) i.next();
- urls[index++] = getTargetFile(path).toURL();
- }
- } catch (MalformedURLException e) {
- throw new DeploymentException(e);
- }
- ClassLoader[] parentCL = determineParents();
+ public Artifact install(URL source) {
+ return null;
+ }
+
+ public void install(ConfigurationData configurationData, File source) {
+ }
+
+ public void uninstall(Artifact configID) {
+ }
+
+ public ObjectName loadConfiguration(Artifact configId) {
+ return null;
+ }
- boolean inverseClassloading = configurationData.isInverseClassloading();
- Set filter = configurationData.getHiddenClasses();
- String[] hiddenFilter = (String[]) filter.toArray(new String[0]);
- filter = configurationData.getNonOverridableClasses();
- String[] nonOverridableFilter = (String[]) filter.toArray(new String[0]);
+ public boolean containsConfiguration(Artifact configID) {
+ return false;
+ }
+
+ public String getObjectName() {
+ return null;
+ }
+
+ public List listConfigurations() {
+ return null;
+ }
- return new MultiParentClassLoader(configurationData.getId(), urls, parentCL, inverseClassloading, hiddenFilter, nonOverridableFilter);
+ public File createNewConfigurationDir() {
+ return null;
+ }
+
+ public URL resolve(Artifact configId, URI uri) throws MalformedURLException {
+ return new File(baseDir, uri.toString()).toURL();
+ }
+ });
+ return configuration.getConfigurationClassLoader();
+ } catch (Exception e) {
+ throw new DeploymentException("Could not construct configuration classloader for deployment context", e);
+ }
}
public void close() throws IOException, DeploymentException {
@@ -648,12 +624,11 @@
}
public void addChildConfiguration(ConfigurationData configurationData) {
- this.configurationData.addChildConfiguration(configurationData);
+ childConfigurationDatas.add(configurationData);
}
public ConfigurationData getConfigurationData() {
- ConfigurationData configurationData = new ConfigurationData(this.configurationData);
- configurationData.setGBeans(Arrays.asList(gbeans.getGBeans()));
+ ConfigurationData configurationData = new ConfigurationData(moduleType, classpath, Arrays.asList(gbeans.getGBeans()), childConfigurationDatas, environment);
return configurationData;
}
Modified: geronimo/branches/configid/modules/j2ee-builder/src/test/org/apache/geronimo/j2ee/deployment/EARConfigBuilderTest.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/modules/j2ee-builder/src/test/org/apache/geronimo/j2ee/deployment/EARConfigBuilderTest.java?rev=378459&r1=378458&r2=378459&view=diff
==============================================================================
--- geronimo/branches/configid/modules/j2ee-builder/src/test/org/apache/geronimo/j2ee/deployment/EARConfigBuilderTest.java (original)
+++ geronimo/branches/configid/modules/j2ee-builder/src/test/org/apache/geronimo/j2ee/deployment/EARConfigBuilderTest.java Fri Feb 17 00:37:43 2006
@@ -48,6 +48,7 @@
import java.io.ObjectOutputStream;
import java.net.URI;
import java.net.URL;
+import java.net.MalformedURLException;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -406,11 +407,10 @@
public ObjectName loadConfiguration(Artifact configId) throws NoSuchConfigException, IOException, InvalidConfigException {
ObjectName configurationObjectName = Configuration.getConfigurationObjectName(configId);
GBeanData configData = new GBeanData(configurationObjectName, Configuration.GBEAN_INFO);
- configData.setAttribute("id", configId);
- Map nameKeys = new HashMap();
- nameKeys.put("domain", "geronimo.test");
- nameKeys.put("J2EEServer", "geronimo");
- configData.setAttribute("nameKeys", nameKeys);
+ Environment environment = new Environment();
+ environment.setConfigId(configId);
+ environment.getProperties().put(NameFactory.JSR77_BASE_NAME_PROPERTY, "geronimo.test:J2EEServer=geronimo");
+ configData.setAttribute("environment", environment);
configData.setAttribute("gBeanState", NO_OBJECTS_OS);
try {
@@ -435,6 +435,10 @@
}
public File createNewConfigurationDir() {
+ return null;
+ }
+
+ public URL resolve(Artifact configId, URI uri) throws NoSuchConfigException, MalformedURLException {
return null;
}
Modified: geronimo/branches/configid/modules/jetty-builder/src/test/org/apache/geronimo/jetty/deployment/JettyModuleBuilderTest.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/modules/jetty-builder/src/test/org/apache/geronimo/jetty/deployment/JettyModuleBuilderTest.java?rev=378459&r1=378458&r2=378459&view=diff
==============================================================================
--- geronimo/branches/configid/modules/jetty-builder/src/test/org/apache/geronimo/jetty/deployment/JettyModuleBuilderTest.java (original)
+++ geronimo/branches/configid/modules/jetty-builder/src/test/org/apache/geronimo/jetty/deployment/JettyModuleBuilderTest.java Fri Feb 17 00:37:43 2006
@@ -22,6 +22,7 @@
import java.io.ObjectOutputStream;
import java.net.URI;
import java.net.URL;
+import java.net.MalformedURLException;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
@@ -399,6 +400,10 @@
}
public File createNewConfigurationDir() {
+ return null;
+ }
+
+ public URL resolve(Artifact configId, URI uri) throws NoSuchConfigException, MalformedURLException {
return null;
}
Modified: geronimo/branches/configid/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java?rev=378459&r1=378458&r2=378459&view=diff
==============================================================================
--- geronimo/branches/configid/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java (original)
+++ geronimo/branches/configid/modules/kernel/src/java/org/apache/geronimo/kernel/config/Configuration.java Fri Feb 17 00:37:43 2006
@@ -17,50 +17,50 @@
package org.apache.geronimo.kernel.config;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.gbean.GAttributeInfo;
+import org.apache.geronimo.gbean.GBeanData;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.gbean.GBeanLifecycle;
+import org.apache.geronimo.kernel.DependencyManager;
+import org.apache.geronimo.kernel.GBeanAlreadyExistsException;
+import org.apache.geronimo.kernel.GBeanNotFoundException;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.ObjectInputStreamExt;
+import org.apache.geronimo.kernel.jmx.JMXUtil;
+import org.apache.geronimo.kernel.management.State;
+import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.kernel.repository.Environment;
+import org.apache.geronimo.kernel.repository.MissingDependencyException;
+import org.apache.geronimo.kernel.repository.Repository;
+
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.EOFException;
+import java.io.File;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
-import java.io.File;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.LinkedHashSet;
import java.util.List;
+import java.util.ListIterator;
import java.util.Map;
import java.util.Set;
-import java.util.ArrayList;
-import java.util.LinkedHashSet;
-import java.util.ListIterator;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.geronimo.gbean.GAttributeInfo;
-import org.apache.geronimo.gbean.GBeanData;
-import org.apache.geronimo.gbean.GBeanInfo;
-import org.apache.geronimo.gbean.GBeanInfoBuilder;
-import org.apache.geronimo.gbean.GBeanLifecycle;
-import org.apache.geronimo.kernel.DependencyManager;
-import org.apache.geronimo.kernel.GBeanAlreadyExistsException;
-import org.apache.geronimo.kernel.GBeanNotFoundException;
-import org.apache.geronimo.kernel.Kernel;
-import org.apache.geronimo.kernel.ObjectInputStreamExt;
-import org.apache.geronimo.kernel.jmx.JMXUtil;
-import org.apache.geronimo.kernel.management.State;
-import org.apache.geronimo.kernel.repository.MissingDependencyException;
-import org.apache.geronimo.kernel.repository.Repository;
-import org.apache.geronimo.kernel.repository.Artifact;
-import org.apache.geronimo.kernel.repository.Environment;
/**
* A Configuration represents a collection of runnable services that can be
@@ -97,13 +97,12 @@
public static ObjectName getConfigurationObjectName(URI configId) throws MalformedObjectNameException {
return new ObjectName("geronimo.config:name=" + ObjectName.quote(configId.toString()));
}
+
public static ObjectName getConfigurationObjectName(Artifact configId) throws InvalidConfigException {
try {
- return new ObjectName("geronimo.config:name=" + ObjectName.quote(configId.toURI().toString()));
+ return new ObjectName("geronimo.config:name=" + ObjectName.quote(configId.toString()));
} catch (MalformedObjectNameException e) {
throw new InvalidConfigException("Could not construct object name for configuration", e);
- } catch (URISyntaxException e) {
- throw new InvalidConfigException("Could not construct uri for artifact for configuration", e);
}
}
@@ -111,11 +110,10 @@
return name.getDomain().equals("geronimo.config") && name.getKeyPropertyList().size() == 1 && name.getKeyProperty("name") != null;
}
- public static URI getConfigurationID(ObjectName objectName) throws URISyntaxException {
+ public static Artifact getConfigurationID(ObjectName objectName) {
if (isConfigurationObjectName(objectName)) {
String name = ObjectName.unquote(objectName.getKeyProperty("name"));
- URI uri = new URI(name);
- return uri;
+ return Artifact.create(name);
} else {
throw new IllegalArgumentException("ObjectName " + objectName + " is not a Configuration name");
}
@@ -196,7 +194,7 @@
*
* @param id the unique id of this Configuration
* @param moduleType the module type identifier
- * @param nameKeys
+ * @param properties
* @param classPath a List<URI> of locations that define the codebase for this Configuration
* @param gbeanState a byte array contain the Java Serialized form of the GBeans in this Configuration
* @param repositories a Collection<Repository> of repositories used to resolve dependencies
@@ -208,22 +206,24 @@
ConfigurationModuleType moduleType,
URL baseURL,
Artifact[] parentIds,
- Map nameKeys,
+ Map properties,
List classPath,
boolean inverseClassLoading,
String[] hiddenClasses,
String[] nonOverridableClasses,
byte[] gbeanState,
Collection repositories,
- List dependencies) throws Exception {
+ List dependencies,
+ ConfigurationStore configurationStore) throws Exception {
this(kernel,
objectName,
moduleType,
- createEnvironment(id, nameKeys, parentIds, inverseClassLoading, hiddenClasses, nonOverridableClasses, dependencies),
+ createEnvironment(id, properties, parentIds, inverseClassLoading, hiddenClasses, nonOverridableClasses, dependencies),
baseURL,
classPath,
gbeanState,
- repositories);
+ repositories,
+ configurationStore);
}
/**
@@ -237,18 +237,19 @@
* @param repositories a Collection<Repository> of repositories used to resolve dependencies
*/
public Configuration(Kernel kernel,
- String objectName,
- ConfigurationModuleType moduleType,
- Environment environment,
- URL baseURL,
- List classPath,
- byte[] gbeanState,
- Collection repositories) throws Exception {
+ String objectName,
+ ConfigurationModuleType moduleType,
+ Environment environment,
+ URL baseURL,
+ List classPath,
+ byte[] gbeanState,
+ Collection repositories,
+ ConfigurationStore configurationStore) throws Exception {
this.kernel = kernel;
this.environment = environment;
this.objectNameString = objectName;
- this.objectName = JMXUtil.getObjectName(objectName);
+ this.objectName = objectName == null ? null : JMXUtil.getObjectName(objectName);
this.moduleType = moduleType;
this.baseURL = baseURL;
this.gbeanState = gbeanState;
@@ -261,8 +262,8 @@
// get proxies to my parent configurations
parents = new ArrayList();
- LinkedHashSet dependencies = environment.getDependencies();
- for (Iterator iterator = dependencies.iterator(); iterator.hasNext();) {
+ LinkedHashSet imports = environment.getImports();
+ for (Iterator iterator = imports.iterator(); iterator.hasNext();) {
Artifact artifact = (Artifact) iterator.next();
if (artifact.getType().equals("car")) {
ObjectName parentName = getConfigurationObjectName(artifact);
@@ -270,18 +271,8 @@
}
}
- // declarae dependencies on parents
- Set parentNames = new HashSet();
- for (Iterator iterator = parents.iterator(); iterator.hasNext();) {
- Configuration configuration = (Configuration) iterator.next();
- ObjectName parentName = getConfigurationObjectName(configuration.getId());
- parentNames.add(parentName);
- }
- DependencyManager dependencyManager = this.kernel.getDependencyManager();
- dependencyManager.addDependencies(this.objectName, parentNames);
-
// build configurationClassLoader
- URL[] urls = buildClassPath();
+ URL[] urls = buildClassPath(configurationStore);
log.debug("ClassPath for " + environment.getConfigId() + " resolved to " + Arrays.asList(urls));
if (parents.size() == 0) {
@@ -294,11 +285,11 @@
}
}
- private static Environment createEnvironment(Artifact id, Map nameKeys, Artifact[] parentIds, boolean inverseClassLoading, String[] hiddenClasses, String[] nonOverridableClasses, List dependencies) {
+ private static Environment createEnvironment(Artifact id, Map properties, Artifact[] parentIds, boolean inverseClassLoading, String[] hiddenClasses, String[] nonOverridableClasses, List dependencies) {
Environment environment = new Environment();
environment.setConfigId(id);
- if (nameKeys != null) {
- environment.setProperties(nameKeys);
+ if (properties != null) {
+ environment.setProperties(properties);
}
environment.setInverseClassLoading(inverseClassLoading);
if (hiddenClasses != null) {
@@ -388,7 +379,7 @@
return classLoaders;
}
- private URL[] buildClassPath() throws MalformedURLException, MissingDependencyException {
+ private URL[] buildClassPath(ConfigurationStore configurationStore) throws MalformedURLException, MissingDependencyException, NoSuchConfigException {
LinkedHashSet dependencies = environment.getDependencies();
List urls = new ArrayList(dependencies.size() + classPath.size());
for (Iterator i = dependencies.iterator(); i.hasNext();) {
@@ -410,11 +401,12 @@
}
for (Iterator i = classPath.iterator(); i.hasNext();) {
URI uri = (URI) i.next();
- urls.add(new URL(baseURL, uri.toString()));
+ urls.add(configurationStore.resolve(environment.getConfigId(), uri));
}
return (URL[]) urls.toArray(new URL[urls.size()]);
}
+ //TODO remove this when web app cl are config. cl.
private static void setGBeanBaseUrl(GBeanData gbeanData, URL baseUrl) {
GBeanInfo gbeanInfo = gbeanData.getGBeanInfo();
Set attributes = gbeanInfo.getAttributes();
@@ -428,6 +420,17 @@
}
public void doStart() throws Exception {
+ assert objectName != null;
+ // declare imports on parents
+ Set parentNames = new HashSet();
+ for (Iterator iterator = parents.iterator(); iterator.hasNext();) {
+ Configuration configuration = (Configuration) iterator.next();
+ ObjectName parentName = getConfigurationObjectName(configuration.getId());
+ parentNames.add(parentName);
+ }
+ DependencyManager dependencyManager = this.kernel.getDependencyManager();
+ dependencyManager.addDependencies(this.objectName, parentNames);
+
log.debug("Started configuration " + environment.getConfigId());
}
@@ -469,6 +472,7 @@
/**
* Gets the parent configurations of this configuration.
+ *
* @return the parents of this configuration
*/
public List getParents() {
@@ -655,20 +659,21 @@
GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(Configuration.class);//does not use jsr-77 naming
infoFactory.addAttribute("kernel", Kernel.class, false);
infoFactory.addAttribute("objectName", String.class, false);
- infoFactory.addAttribute("id", Artifact.class, true, false);
+ infoFactory.addAttribute("environment", Environment.class, true, false);
infoFactory.addAttribute("type", ConfigurationModuleType.class, true, false);
- infoFactory.addAttribute("parentId", Artifact[].class, true, false);
- infoFactory.addAttribute("nameKeys", Map.class, true, false);
+// infoFactory.addAttribute("parentId", Artifact[].class, true, false);
+// infoFactory.addAttribute("properties", Map.class, true, false);
infoFactory.addAttribute("classPath", List.class, true, false);
- infoFactory.addAttribute("inverseClassLoading", boolean.class, true, false);
- infoFactory.addAttribute("hiddenClasses", String[].class, true, false);
- infoFactory.addAttribute("nonOverridableClasses", String[].class, true, false);
- infoFactory.addAttribute("dependencies", List.class, true, false);
+// infoFactory.addAttribute("inverseClassLoading", boolean.class, true, false);
+// infoFactory.addAttribute("hiddenClasses", String[].class, true, false);
+// infoFactory.addAttribute("nonOverridableClasses", String[].class, true, false);
+// infoFactory.addAttribute("dependencies", List.class, true, false);
infoFactory.addAttribute("gBeanState", byte[].class, true, false);
infoFactory.addAttribute("baseURL", URL.class, true, false);
infoFactory.addAttribute("configurationClassLoader", ClassLoader.class, false);
infoFactory.addReference("Repositories", Repository.class, "GBean");
+ infoFactory.addReference("ConfigurationStore", ConfigurationStore.class, "GBean");
infoFactory.addOperation("addGBean", new Class[]{GBeanData.class, boolean.class});
infoFactory.addOperation("removeGBean", new Class[]{ObjectName.class});
@@ -680,20 +685,21 @@
infoFactory.addOperation("unloadGBeans");
infoFactory.setConstructor(new String[]{
- "kernel",
- "objectName",
- "id",
- "type",
- "baseURL",
- "parentId",
- "nameKeys",
- "classPath",
- "inverseClassLoading",
- "hiddenClasses",
- "nonOverridableClasses",
- "gBeanState",
- "Repositories",
- "dependencies",
+ "kernel",
+ "objectName",
+ "type",
+ "environment",
+ "baseURL",
+// "parentId",
+// "properties",
+ "classPath",
+// "inverseClassLoading",
+// "hiddenClasses",
+// "nonOverridableClasses",
+ "gBeanState",
+ "Repositories",
+// "dependencies",
+ "ConfigurationStore"
});
GBEAN_INFO = infoFactory.getBeanInfo();
Modified: geronimo/branches/configid/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationData.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationData.java?rev=378459&r1=378458&r2=378459&view=diff
==============================================================================
--- geronimo/branches/configid/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationData.java (original)
+++ geronimo/branches/configid/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationData.java Fri Feb 17 00:37:43 2006
@@ -17,239 +17,72 @@
package org.apache.geronimo.kernel.config;
-import java.net.URI;
+import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.kernel.repository.Environment;
+
import java.util.ArrayList;
import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
-import java.util.Set;
-import java.util.Map;
-import java.util.HashMap;
-
-import org.apache.geronimo.gbean.GBeanData;
-import org.apache.geronimo.kernel.repository.Artifact;
/**
* @version $Rev$ $Date$
*/
public class ConfigurationData {
- /**
- * URI used to referr to this configuration in the configuration manager
- */
- private Artifact id;
/**
* Identifies the type of configuration (WAR, RAR et cetera)
*/
- private ConfigurationModuleType moduleType;
+ private final ConfigurationModuleType moduleType;
- /**
- * The uris of the parents of this configuration.
- */
- private List parentId = new ArrayList();
-
- /**
- * The uris of the references (configurations required by but not in classpath) of this configuration.
- */
- private List references = new ArrayList();
-
- /**
- * map of key-value pairs for names inside this and child configurations. Typically domain and server
- * Note that domain doesn't have a key name in an object name.
- */
- private Map nameKeys = new HashMap();
-
- /**
- * List of URIs of jar files on which this configuration is dependent on.
- */
- private final LinkedHashSet dependencies = new LinkedHashSet();
/**
* List of URIs in this configuration's classpath. These are for the classes directly included in the configuration
*/
- private final LinkedHashSet classPath = new LinkedHashSet();
+ private final LinkedHashSet classPath;
/**
* GBeans contained in this configuration.
*/
- private final List gbeans = new ArrayList();
+ private final List gbeans;
/**
* Child configurations of this configuration
*/
- private final List childConfigurations = new ArrayList();
+ private final List childConfigurations;
- /**
- * If true, then inverse the standard class loading delegation model.
- */
- private boolean inverseClassLoading;
+ private final Environment environment;
- /**
- * Class filters defining the classes hidden from the configuration.
- */
- private final Set hiddenClasses = new HashSet();
-
- /**
- * Class filters defining the classes that the configuration cannot
- * override.
- */
- private final Set nonOverridableClasses = new HashSet();
-
- public ConfigurationData() {
- }
-
- public ConfigurationData(ConfigurationData configurationData) {
- id = configurationData.id;
- moduleType = configurationData.moduleType;
- parentId.addAll(configurationData.getParentId());
- references.addAll(configurationData.getReferences());
- this.nameKeys.putAll(configurationData.nameKeys);
- setDependencies(new ArrayList(configurationData.dependencies));
- setClassPath(new ArrayList(configurationData.classPath));
- setGBeans(configurationData.gbeans);
- setChildConfigurations(configurationData.childConfigurations);
- inverseClassLoading = configurationData.inverseClassLoading;
- hiddenClasses.addAll(configurationData.hiddenClasses);
- nonOverridableClasses.addAll(configurationData.nonOverridableClasses);
+ public ConfigurationData(ConfigurationModuleType moduleType, LinkedHashSet classPath, List gbeans, List childConfigurations, Environment environment) {
+ this.moduleType = moduleType;
+ this.classPath = classPath;
+ this.gbeans = gbeans;
+ this.childConfigurations = childConfigurations;
+ this.environment = environment;
}
public Artifact getId() {
- return id;
- }
-
- public void setId(Artifact id) {
- this.id = id;
+ return environment.getConfigId();
}
public ConfigurationModuleType getModuleType() {
return moduleType;
}
- public void setModuleType(ConfigurationModuleType moduleType) {
- this.moduleType = moduleType;
- }
-
- public List getParentId() {
- return new ArrayList(parentId);
- }
-
- public void setParentId(List parentId) {
- this.parentId.clear();
- this.parentId.addAll(parentId);
- }
-
- public void addParent(URI parentId) {
- this.parentId.add(parentId);
- }
-
- public List getReferences() {
- return new ArrayList(references);
- }
-
- public void setReferences(List references) {
- this.references.clear();
- this.references.addAll(references);
- }
-
- public void addReference(URI reference) {
- this.references.add(reference);
- }
-
- public Map getNameKeys() {
- return new HashMap(nameKeys);
- }
-
- public void setNameKeys(Map nameKeys) {
- this.nameKeys.clear();
- this.nameKeys.putAll(nameKeys);
- }
-
- public void addNameKey(String key, String value) {
- nameKeys.put(key, value);
- }
-
- public List getDependencies() {
- return Collections.unmodifiableList(new ArrayList(dependencies));
- }
-
- public void setDependencies(List dependencies) {
- this.dependencies.clear();
- for (Iterator iterator = dependencies.iterator(); iterator.hasNext();) {
- Artifact dependency = (Artifact) iterator.next();
- addDependency(dependency);
- }
- }
-
- public void addDependency(Artifact dependency) {
- assert dependency != null;
- this.dependencies.add(dependency);
- }
-
public List getClassPath() {
return Collections.unmodifiableList(new ArrayList(classPath));
}
- public void setClassPath(List classPath) {
- this.classPath.clear();
- for (Iterator iterator = classPath.iterator(); iterator.hasNext();) {
- URI location = (URI) iterator.next();
- addClassPathLocation(location);
- }
- }
-
- public void addClassPathLocation(URI location) {
- assert location != null;
- this.classPath.add(location);
- }
-
public List getGBeans() {
return Collections.unmodifiableList(gbeans);
}
- public void setGBeans(List gbeans) {
- this.gbeans.clear();
- for (Iterator iterator = gbeans.iterator(); iterator.hasNext();) {
- GBeanData gbeanData = (GBeanData) iterator.next();
- addGBean(gbeanData);
- }
- }
-
- public void addGBean(GBeanData gbeanData) {
- assert gbeanData != null;
- gbeans.add(gbeanData);
- }
-
public List getChildConfigurations() {
return Collections.unmodifiableList(childConfigurations);
}
- public void setChildConfigurations(List childConfigurations) {
- this.childConfigurations.clear();
- for (Iterator iterator = childConfigurations.iterator(); iterator.hasNext();) {
- ConfigurationData configurationData = (ConfigurationData) iterator.next();
- addChildConfiguration(configurationData);
- }
- }
- public void addChildConfiguration(ConfigurationData configurationData) {
- assert configurationData != null;
- childConfigurations.add(configurationData);
+ public Environment getEnvironment() {
+ return environment;
}
- public boolean isInverseClassloading() {
- return inverseClassLoading;
- }
-
- public void setInverseClassloading(boolean inverseClassLoading) {
- this.inverseClassLoading = inverseClassLoading;
- }
-
- public Set getHiddenClasses() {
- return hiddenClasses;
- }
-
- public Set getNonOverridableClasses() {
- return nonOverridableClasses;
- }
}
Modified: geronimo/branches/configid/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationManagerImpl.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationManagerImpl.java?rev=378459&r1=378458&r2=378459&view=diff
==============================================================================
--- geronimo/branches/configid/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationManagerImpl.java (original)
+++ geronimo/branches/configid/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationManagerImpl.java Fri Feb 17 00:37:43 2006
@@ -28,6 +28,7 @@
import org.apache.geronimo.kernel.jmx.JMXUtil;
import org.apache.geronimo.kernel.management.State;
import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.kernel.repository.Environment;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
@@ -179,13 +180,11 @@
//put the earliest ancestors first, even if we have already started them.
ancestors.remove(configID);
ancestors.addFirst(configID);
- Artifact[] parents = (Artifact[]) kernel.getAttribute(name, "parentId");
- if (parents != null) {
- for (int i = 0; i < parents.length; i++) {
- Artifact parent = parents[i];
+ Environment environment = (Environment) kernel.getAttribute(name, "environment");
+ for (Iterator iterator = environment.getImports().iterator(); iterator.hasNext();) {
+ Artifact parent = (Artifact) iterator.next();
loadRecursive(parent, ancestors, preloaded);
}
- }
} catch (NoSuchConfigException e) {
throw e;
} catch (IOException e) {
Modified: geronimo/branches/configid/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationStore.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationStore.java?rev=378459&r1=378458&r2=378459&view=diff
==============================================================================
--- geronimo/branches/configid/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationStore.java (original)
+++ geronimo/branches/configid/modules/kernel/src/java/org/apache/geronimo/kernel/config/ConfigurationStore.java Fri Feb 17 00:37:43 2006
@@ -21,6 +21,7 @@
import java.io.IOException;
import java.net.URI;
import java.net.URL;
+import java.net.MalformedURLException;
import java.util.List;
import javax.management.ObjectName;
@@ -95,4 +96,11 @@
File createNewConfigurationDir();
+ /**
+ * Locate the classpath component for the supplied uri in the given artifact
+ * @param configId
+ * @param uri
+ * @return URL for the configuration component.
+ */
+ URL resolve(Artifact configId, URI uri) throws NoSuchConfigException, MalformedURLException;
}
Modified: geronimo/branches/configid/modules/kernel/src/java/org/apache/geronimo/kernel/repository/Environment.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/modules/kernel/src/java/org/apache/geronimo/kernel/repository/Environment.java?rev=378459&r1=378458&r2=378459&view=diff
==============================================================================
--- geronimo/branches/configid/modules/kernel/src/java/org/apache/geronimo/kernel/repository/Environment.java (original)
+++ geronimo/branches/configid/modules/kernel/src/java/org/apache/geronimo/kernel/repository/Environment.java Fri Feb 17 00:37:43 2006
@@ -25,13 +25,14 @@
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.HashSet;
+import java.io.Serializable;
/**
* holds the data from the EnvironmentType xml while it is being resolved, transitively closed, etc.
*
* @version $Rev:$ $Date:$
*/
-public class Environment {
+public class Environment implements Serializable {
private Artifact configId;
Modified: geronimo/branches/configid/modules/kernel/src/test/org/apache/geronimo/kernel/ConfigTest.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/modules/kernel/src/test/org/apache/geronimo/kernel/ConfigTest.java?rev=378459&r1=378458&r2=378459&view=diff
==============================================================================
--- geronimo/branches/configid/modules/kernel/src/test/org/apache/geronimo/kernel/ConfigTest.java (original)
+++ geronimo/branches/configid/modules/kernel/src/test/org/apache/geronimo/kernel/ConfigTest.java Fri Feb 17 00:37:43 2006
@@ -17,17 +17,17 @@
package org.apache.geronimo.kernel;
-import java.net.URI;
-import java.util.Collections;
-import javax.management.ObjectName;
-
import junit.framework.TestCase;
import org.apache.geronimo.gbean.GBeanData;
-import org.apache.geronimo.kernel.config.ConfigurationManagerImpl;
import org.apache.geronimo.kernel.config.Configuration;
+import org.apache.geronimo.kernel.config.ConfigurationManagerImpl;
import org.apache.geronimo.kernel.config.ManageableAttributeStore;
import org.apache.geronimo.kernel.management.State;
import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.kernel.repository.Environment;
+
+import javax.management.ObjectName;
+import java.util.Collections;
/**
* @version $Rev$ $Date$
@@ -35,29 +35,19 @@
public class ConfigTest extends TestCase {
private ObjectName gbeanName1;
private Kernel kernel;
- private byte[] state;
private ObjectName gbeanName2;
+ private GBeanData config;
public void testOnlineConfig() throws Exception {
- Artifact id = new Artifact("geronimo", "test", "1", "car", true);
- ObjectName configName = Configuration.getConfigurationObjectName(id);
-
- // create the config gbean data
- GBeanData config = new GBeanData(Configuration.getConfigurationObjectName(id), Configuration.GBEAN_INFO);
- config.setAttribute("id", id);
- config.setAttribute("classPath", Collections.EMPTY_LIST);
- config.setAttribute("gBeanState", state);
- config.setAttribute("dependencies", Collections.EMPTY_LIST);
- config.setName(configName);
// load and start the config
kernel.loadGBean(config, this.getClass().getClassLoader());
- kernel.startGBean(configName);
- kernel.invoke(configName, "loadGBeans", new Object[] {null}, new String[] {ManageableAttributeStore.class.getName()});
- kernel.invoke(configName, "startRecursiveGBeans");
+ kernel.startGBean(config.getName());
+ kernel.invoke(config.getName(), "loadGBeans", new Object[] {null}, new String[] {ManageableAttributeStore.class.getName()});
+ kernel.invoke(config.getName(), "startRecursiveGBeans");
- assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(configName));
- assertNotNull(kernel.getAttribute(configName, "configurationClassLoader"));
+ assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(config.getName()));
+ assertNotNull(kernel.getAttribute(config.getName(), "configurationClassLoader"));
assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(gbeanName1));
int state = kernel.getGBeanState(gbeanName2);
@@ -82,38 +72,28 @@
assertEquals(new Integer(99), kernel.getAttribute(gbeanName2, "endpointMutableInt"));
assertEquals(new Integer(99), kernel.getAttribute(gbeanName1, "mutableInt"));
- kernel.stopGBean(configName);
+ kernel.stopGBean(config.getName());
try {
kernel.getAttribute(gbeanName1, "value");
fail();
} catch (GBeanNotFoundException e) {
// ok
}
- assertEquals(State.STOPPED_INDEX, kernel.getGBeanState(configName));
- kernel.unloadGBean(configName);
- assertFalse(kernel.isLoaded(configName));
+ assertEquals(State.STOPPED_INDEX, kernel.getGBeanState(config.getName()));
+ kernel.unloadGBean(config.getName());
+ assertFalse(kernel.isLoaded(config.getName()));
}
public void testAddToConfig() throws Exception {
- Artifact id = new Artifact("geronimo", "test", "1", "car", true);
- ObjectName configName = Configuration.getConfigurationObjectName(id);
-
- // create the config gbean data
- GBeanData config = new GBeanData(Configuration.getConfigurationObjectName(id), Configuration.GBEAN_INFO);
- config.setAttribute("id", id);
- config.setAttribute("classPath", Collections.EMPTY_LIST);
- config.setAttribute("gBeanState", state);
- config.setAttribute("dependencies", Collections.EMPTY_LIST);
- config.setName(configName);
// load and start the config
kernel.loadGBean(config, this.getClass().getClassLoader());
- kernel.startGBean(configName);
- kernel.invoke(configName, "loadGBeans", new Object[] {null}, new String[] {ManageableAttributeStore.class.getName()});
- kernel.invoke(configName, "startRecursiveGBeans");
+ kernel.startGBean(config.getName());
+ kernel.invoke(config.getName(), "loadGBeans", new Object[] {null}, new String[] {ManageableAttributeStore.class.getName()});
+ kernel.invoke(config.getName(), "startRecursiveGBeans");
- assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(configName));
- assertNotNull(kernel.getAttribute(configName, "configurationClassLoader"));
+ assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(config.getName()));
+ assertNotNull(kernel.getAttribute(config.getName(), "configurationClassLoader"));
ObjectName gbeanName3 = new ObjectName("geronimo.test:name=MyMockGMBean3");
try {
@@ -125,7 +105,7 @@
mockBean3.setAttribute("value", "1234");
mockBean3.setAttribute("name", "child");
mockBean3.setAttribute("finalInt", new Integer(1));
- kernel.invoke(configName, "addGBean", new Object[]{mockBean3,Boolean.TRUE}, new String[]{GBeanData.class.getName(), boolean.class.getName()});
+ kernel.invoke(config.getName(), "addGBean", new Object[]{mockBean3,Boolean.TRUE}, new String[]{GBeanData.class.getName(), boolean.class.getName()});
assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(gbeanName3));
assertEquals(new Integer(1), kernel.getAttribute(gbeanName3, "finalInt"));
@@ -158,7 +138,18 @@
mockBean2.setReferencePatterns("MockEndpoint", Collections.singleton(gbeanName1));
mockBean2.setReferencePatterns("EndpointCollection", Collections.singleton(gbeanName1));
- state = Configuration.storeGBeans(new GBeanData[] {mockBean1, mockBean2});
+ byte[] state = Configuration.storeGBeans(new GBeanData[] {mockBean1, mockBean2});
+
+ Artifact id = new Artifact("geronimo", "test", "1", "car", true);
+ ObjectName configName = Configuration.getConfigurationObjectName(id);
+
+ // create the config gbean data
+ config = new GBeanData(Configuration.getConfigurationObjectName(id), Configuration.GBEAN_INFO);
+ Environment environment = new Environment();
+ environment.setConfigId(id);
+ config.setAttribute("environment", environment);
+ config.setAttribute("gBeanState", state);
+ config.setName(configName);
}
protected void tearDown() throws Exception {
Modified: geronimo/branches/configid/modules/system/src/java/org/apache/geronimo/system/configuration/ExecutableConfigurationUtil.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/modules/system/src/java/org/apache/geronimo/system/configuration/ExecutableConfigurationUtil.java?rev=378459&r1=378458&r2=378459&view=diff
==============================================================================
--- geronimo/branches/configid/modules/system/src/java/org/apache/geronimo/system/configuration/ExecutableConfigurationUtil.java (original)
+++ geronimo/branches/configid/modules/system/src/java/org/apache/geronimo/system/configuration/ExecutableConfigurationUtil.java Fri Feb 17 00:37:43 2006
@@ -42,6 +42,7 @@
import org.apache.geronimo.kernel.config.ConfigurationData;
import org.apache.geronimo.kernel.config.InvalidConfigException;
import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.kernel.repository.Environment;
/**
* @version $Rev$ $Date$
@@ -158,23 +159,20 @@
config.setAttribute("id", id);
config.setAttribute("type", configurationData.getModuleType());
//TODO configid this might need further improvmement
- Map nameKeys = configurationData.getNameKeys();
- config.setAttribute("nameKeys", nameKeys);
-
- List parentId = configurationData.getParentId();
- if (parentId.size() > 0) {
- config.setAttribute("parentId", parentId.toArray(new Artifact[parentId.size()]));
- }
+// Map nameKeys = configurationData.getNameKeys();
+// config.setAttribute("nameKeys", nameKeys);
+ Environment environment = configurationData.getEnvironment();
+ config.setAttribute("environment", environment);
config.setAttribute("gBeanState", Configuration.storeGBeans(configurationData.getGBeans()));
config.setReferencePatterns("Repositories", Collections.singleton(new ObjectName("*:name=Repository,*")));
- config.setAttribute("dependencies", configurationData.getDependencies());
+// config.setAttribute("dependencies", configurationData.getDependencies());
config.setAttribute("classPath", configurationData.getClassPath());
- config.setAttribute("inverseClassLoading", Boolean.valueOf(configurationData.isInverseClassloading()));
- Set set = configurationData.getHiddenClasses();
- config.setAttribute("hiddenClasses", set.toArray(new String[set.size()]));
- set = configurationData.getNonOverridableClasses();
- config.setAttribute("nonOverridableClasses", set.toArray(new String[set.size()]));
+// config.setAttribute("inverseClassLoading", Boolean.valueOf(configurationData.isInverseClassloading()));
+// Set set = configurationData.getHiddenClasses();
+// config.setAttribute("hiddenClasses", set.toArray(new String[set.size()]));
+// set = configurationData.getNonOverridableClasses();
+// config.setAttribute("nonOverridableClasses", set.toArray(new String[set.size()]));
return config;
} catch (MalformedObjectNameException e) {
Modified: geronimo/branches/configid/modules/system/src/java/org/apache/geronimo/system/configuration/LocalConfigStore.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/configid/modules/system/src/java/org/apache/geronimo/system/configuration/LocalConfigStore.java?rev=378459&r1=378458&r2=378459&view=diff
==============================================================================
--- geronimo/branches/configid/modules/system/src/java/org/apache/geronimo/system/configuration/LocalConfigStore.java (original)
+++ geronimo/branches/configid/modules/system/src/java/org/apache/geronimo/system/configuration/LocalConfigStore.java Fri Feb 17 00:37:43 2006
@@ -30,6 +30,7 @@
import java.net.URI;
import java.net.URL;
import java.net.URISyntaxException;
+import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Iterator;
@@ -88,7 +89,7 @@
serverInfo = null;
this.root = null;
this.rootDir = rootDir;
- log = LogFactory.getLog("LocalConfigStore:"+rootDir.getName());
+ log = LogFactory.getLog("LocalConfigStore:" + rootDir.getName());
}
public LocalConfigStore(Kernel kernel, String objectName, URI root, ServerInfo serverInfo) throws MalformedObjectNameException {
@@ -96,7 +97,7 @@
this.objectName = new ObjectName(objectName);
this.root = root;
this.serverInfo = serverInfo;
- log = LogFactory.getLog("LocalConfigStore:"+root.toString());
+ log = LogFactory.getLog("LocalConfigStore:" + root.toString());
}
public String getObjectName() {
@@ -120,7 +121,7 @@
File indexfile = new File(rootDir, INDEX_NAME);
InputStream indexIs = null;
try {
- indexIs = new BufferedInputStream(new FileInputStream(indexfile));
+ indexIs = new BufferedInputStream(new FileInputStream(indexfile));
index.load(indexIs);
for (Iterator i = index.values().iterator(); i.hasNext();) {
String id = (String) i.next();
@@ -145,7 +146,7 @@
if (pendingIs != null)
pendingIs.close();
}
-
+
// Create and start the reaper...
reaper = new ConfigStoreReaper(REAPER_INTERVAL);
Thread t = new Thread(reaper, "Geronimo Config Store Reaper");
@@ -154,13 +155,13 @@
}
public void doStop() {
- if (reaper !=null) {
+ if (reaper != null) {
reaper.close();
}
}
public void doFail() {
- if (reaper !=null) {
+ if (reaper != null) {
reaper.close();
}
}
@@ -224,6 +225,10 @@
return configurationDir;
}
+ public URL resolve(Artifact configId, URI uri) throws NoSuchConfigException, MalformedURLException {
+ return new URL(getRoot(configId).toURL(), uri.toString());
+ }
+
public Artifact install(URL source) throws IOException, InvalidConfigException {
return (Artifact) install2(source).getAttribute("id");
}
@@ -288,7 +293,7 @@
}
File configDir;
String storeID;
- synchronized(this) {
+ synchronized (this) {
storeID = index.getProperty(id);
if (storeID == null) {
throw new NoSuchConfigException();
@@ -299,7 +304,7 @@
}
delete(configDir);
-
+
// On windoze, any open file descriptor (e.g. a MultiParentClassLoader) will prevent
// the directory/files from being deleted. If we're unable to delete, save the directory
// to the pendingDeletionIndex. ConfigStoreReaper will delete when the classloader has been GC'ed.
@@ -319,6 +324,7 @@
ObjectName name = Configuration.getConfigurationObjectName(configId);
config.setName(name);
+ //TODO configId remove this
config.setAttribute("baseURL", getRoot(configId).toURL());
try {
@@ -377,11 +383,7 @@
private synchronized File getRoot(Artifact configID) throws NoSuchConfigException {
String id = null;
- try {
- id = index.getProperty(configID.toURI().toString());
- } catch (URISyntaxException e) {
-
- }
+ id = index.getProperty(configID.toString());
if (id == null) {
throw new NoSuchConfigException("No such config: " + configID);
}
@@ -445,15 +447,14 @@
private static void delete(File root) throws IOException {
File[] files = root.listFiles();
- if ( null == files ) {
+ if (null == files) {
return;
}
for (int i = 0; i < files.length; i++) {
File file = files[i];
if (file.isDirectory()) {
delete(file);
- }
- else {
+ } else {
file.delete();
}
}
@@ -499,7 +500,7 @@
public void run() {
log.debug("ConfigStoreReaper started");
- while(!done) {
+ while (!done) {
try {
Thread.sleep(reaperInterval);
} catch (InterruptedException e) {
@@ -510,7 +511,7 @@
}
/**
- * For every directory in the pendingDeletionIndex, attempt to delete all
+ * For every directory in the pendingDeletionIndex, attempt to delete all
* sub-directories and files.
*/
public void reap() {
@@ -521,7 +522,7 @@
Enumeration list = pendingDeletionIndex.propertyNames();
boolean dirDeleted = false;
while (list.hasMoreElements()) {
- String dirName = (String)list.nextElement();
+ String dirName = (String) list.nextElement();
File deleteFile = new File(dirName);
try {
delete(deleteFile);
@@ -531,7 +532,7 @@
if (!deleteFile.exists()) {
String configName = pendingDeletionIndex.getProperty(dirName);
pendingDeletionIndex.remove(dirName);
- dirDeleted = true;
+ dirDeleted = true;
log.debug("Reaped configuration " + configName + " in directory " + dirName);
}
}