You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by ga...@apache.org on 2009/12/06 06:23:37 UTC
svn commit: r887639 - in /geronimo/server/trunk/plugins/aries:
aries-deployer/src/main/plan/
geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/
Author: gawor
Date: Sun Dec 6 05:23:37 2009
New Revision: 887639
URL: http://svn.apache.org/viewvc?rev=887639&view=rev
Log:
GERONIMO-4971: switch to ConfigurationBuilder instead of ModuleBuilder
Added:
geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/AriesAppConfigBuilder.java (contents, props changed)
- copied, changed from r887632, geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/AriesAppModuleBuilder.java
Removed:
geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/AriesAppModuleBuilder.java
Modified:
geronimo/server/trunk/plugins/aries/aries-deployer/src/main/plan/plan.xml
Modified: geronimo/server/trunk/plugins/aries/aries-deployer/src/main/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/aries/aries-deployer/src/main/plan/plan.xml?rev=887639&r1=887638&r2=887639&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/aries/aries-deployer/src/main/plan/plan.xml (original)
+++ geronimo/server/trunk/plugins/aries/aries-deployer/src/main/plan/plan.xml Sun Dec 6 05:23:37 2009
@@ -18,7 +18,7 @@
<module xmlns="http://geronimo.apache.org/xml/ns/deployment-${geronimoSchemaVersion}">
- <gbean name="AriesAppBuilder" class="org.apache.geronimo.aries.builder.AriesAppModuleBuilder">
+ <gbean name="AriesAppBuilder" class="org.apache.geronimo.aries.builder.AriesAppConfigBuilder">
</gbean>
</module>
Copied: geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/AriesAppConfigBuilder.java (from r887632, geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/AriesAppModuleBuilder.java)
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/AriesAppConfigBuilder.java?p2=geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/AriesAppConfigBuilder.java&p1=geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/AriesAppModuleBuilder.java&r1=887632&r2=887639&rev=887639&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/AriesAppModuleBuilder.java (original)
+++ geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/AriesAppConfigBuilder.java Sun Dec 6 05:23:37 2009
@@ -19,8 +19,6 @@
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
-import java.net.URI;
-import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Enumeration;
@@ -36,23 +34,31 @@
import org.apache.aries.application.ApplicationMetadataManager;
import org.apache.aries.application.Content;
import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.deployment.ConfigurationBuilder;
+import org.apache.geronimo.deployment.DeploymentContext;
import org.apache.geronimo.deployment.ModuleIDBuilder;
+import org.apache.geronimo.deployment.util.DeploymentUtil;
import org.apache.geronimo.gbean.AbstractName;
import org.apache.geronimo.gbean.GBeanLifecycle;
import org.apache.geronimo.gbean.annotation.GBean;
+import org.apache.geronimo.gbean.annotation.ParamReference;
import org.apache.geronimo.gbean.annotation.ParamSpecial;
import org.apache.geronimo.gbean.annotation.SpecialAttributeType;
-import org.apache.geronimo.j2ee.deployment.EARContext;
-import org.apache.geronimo.j2ee.deployment.Module;
-import org.apache.geronimo.j2ee.deployment.ModuleBuilder;
-import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+import org.apache.geronimo.kernel.GBeanNotFoundException;
import org.apache.geronimo.kernel.Kernel;
import org.apache.geronimo.kernel.Naming;
+import org.apache.geronimo.kernel.config.ConfigurationAlreadyExistsException;
+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.osgi.BundleUtils;
import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.kernel.repository.ArtifactResolver;
import org.apache.geronimo.kernel.repository.Environment;
+import org.apache.geronimo.kernel.repository.Repository;
import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
import org.osgi.framework.ServiceReference;
import org.slf4j.Logger;
@@ -61,18 +67,24 @@
/**
* @version $Rev:385232 $ $Date$
*/
-@GBean(j2eeType = NameFactory.MODULE_BUILDER)
-public class AriesAppModuleBuilder implements ModuleBuilder, GBeanLifecycle {
+@GBean(j2eeType = "ConfigBuilder")
+public class AriesAppConfigBuilder implements ConfigurationBuilder, GBeanLifecycle {
- private static final Logger LOG = LoggerFactory.getLogger(AriesAppModuleBuilder.class);
+ private static final Logger LOG = LoggerFactory.getLogger(AriesAppConfigBuilder.class);
private Kernel kernel;
- private Bundle bundle;
-
- public AriesAppModuleBuilder(@ParamSpecial(type = SpecialAttributeType.kernel) Kernel kernel,
- @ParamSpecial(type = SpecialAttributeType.bundle) Bundle bundle) {
+ private BundleContext bundleContext;
+ private Collection<Repository> repositories;
+ private ConfigurationManager configurationManager;
+
+ public AriesAppConfigBuilder(@ParamReference(name="Repository", namingType = "Repository")Collection<Repository> repositories,
+ @ParamSpecial(type = SpecialAttributeType.kernel) Kernel kernel,
+ @ParamSpecial(type = SpecialAttributeType.bundleContext) BundleContext bundleContext)
+ throws GBeanNotFoundException {
+ this.repositories = repositories;
this.kernel = kernel;
- this.bundle = bundle;
+ this.bundleContext = bundleContext;
+ this.configurationManager = ConfigurationUtil.getConfigurationManager(kernel);
}
public void doStart() throws Exception {
@@ -85,39 +97,9 @@
doStop();
}
- public Module createModule(File plan, JarFile moduleFile, Naming naming, ModuleIDBuilder idBuilder) throws DeploymentException {
- return createModule(plan, moduleFile, "aries-application", null, null, null, naming, idBuilder);
- }
+
- public Module createModule(Object plan, JarFile moduleFile, String targetPath, URL specDDUrl, Environment environment, Object moduleContextInfo, AbstractName earName, Naming naming, ModuleIDBuilder idBuilder) throws DeploymentException {
- return createModule(plan, moduleFile, targetPath, specDDUrl, environment, earName, naming, idBuilder);
- }
-
- private Module createModule(Object plan, JarFile moduleFile, String targetPath, URL specDDUrl, Environment earEnvironment, AbstractName earName, Naming naming, ModuleIDBuilder idBuilder) throws DeploymentException {
-
- JarEntry appManifest = moduleFile.getJarEntry("META-INF/APPLICATION.MF");
-
- if (appManifest == null) {
- return null;
- }
-
- ApplicationMetadataManager service = getApplicationMetadataManager();
- if (service == null) {
- return null;
- }
-
- ApplicationMetadata appMetadata = null;
- try {
- InputStream in = moduleFile.getInputStream(appManifest);
- appMetadata = service.parseApplication(in);
- } catch (IOException e) {
- throw new DeploymentException("Failed to parse application metadata", e);
- }
-
- if (appMetadata == null) {
- return null;
- }
-
+ /*
LOG.debug("Found Aries Application: {}", appMetadata.getApplicationName());
Environment env = new Environment();
@@ -126,15 +108,15 @@
AbstractName moduleName = naming.createRootName(env.getConfigId(), NameFactory.NULL, NameFactory.J2EE_APPLICATION);
AriesAppModule module = new AriesAppModule(moduleName, env, moduleFile, targetPath, appMetadata);
-
- return module;
- }
+ */
+
+
private ApplicationMetadataManager getApplicationMetadataManager() {
ServiceReference ref =
- bundle.getBundleContext().getServiceReference(ApplicationMetadataManager.class.getName());
+ bundleContext.getServiceReference(ApplicationMetadataManager.class.getName());
if (ref != null) {
- return (ApplicationMetadataManager) bundle.getBundleContext().getService(ref);
+ return (ApplicationMetadataManager) bundleContext.getService(ref);
} else {
return null;
}
@@ -148,21 +130,18 @@
return name;
}
- public void installModule(JarFile earFile, EARContext earContext, Module module, Collection configurationStores, ConfigurationStore targetConfigurationStore, Collection repositories) throws DeploymentException {
- AriesAppModule ariesModule = (AriesAppModule) module;
- JarFile moduleFile = module.getModuleFile();
-
+ public void installModule(JarFile jarFile, ApplicationMetadata appMetadata) throws DeploymentException {
/*
* XXX: This is totally not right but for now allows us to install
* simple Aries applications into Geronimo.
*/
HashMap<String, String> mapping = new HashMap<String, String>();
- Enumeration<JarEntry> entries = moduleFile.entries();
+ Enumeration<JarEntry> entries = jarFile.entries();
while(entries.hasMoreElements()) {
JarEntry entry = entries.nextElement();
if (entry.getName().endsWith(".jar")) {
try {
- InputStream in = moduleFile.getInputStream(entry);
+ InputStream in = jarFile.getInputStream(entry);
JarInputStream jarInput = new JarInputStream(in);
String name = getSymbolicName(jarInput.getManifest());
if (name != null) {
@@ -176,20 +155,20 @@
List<Bundle> installedBundles = new ArrayList<Bundle>();
try {
- for (Content content : ariesModule.getApplicationMetadata().getApplicationContents()) {
+ for (Content content : appMetadata.getApplicationContents()) {
String entryName = mapping.get(content.getContentName());
if (entryName == null) {
LOG.warn("Unknown bundle name in application context {}", content.getContentName());
continue;
}
- ZipEntry entry = moduleFile.getEntry(entryName);
+ ZipEntry entry = jarFile.getEntry(entryName);
if (entry == null) {
// this should not happen
throw new DeploymentException("Jar entry not found " + entryName);
}
- InputStream in = moduleFile.getInputStream(entry);
- Bundle appBundle = bundle.getBundleContext().installBundle(content.getContentName(), in);
+ InputStream in = jarFile.getInputStream(entry);
+ Bundle appBundle = bundleContext.installBundle(content.getContentName(), in);
installedBundles.add(appBundle);
}
@@ -200,20 +179,97 @@
}
} catch (Exception e) {
throw new DeploymentException("Failed to install application", e);
- }
-
- module.setEarContext(earContext);
- module.setRootEarContext(earContext);
+ }
}
- public void initContext(EARContext earContext, Module clientModule, Bundle bundle) throws DeploymentException {
- }
- public void addGBeans(EARContext earContext, Module module, Bundle earBundle, Collection repositories) throws DeploymentException {
+ public Object getDeploymentPlan(File planFile,
+ JarFile jarFile,
+ ModuleIDBuilder idBuilder)
+ throws DeploymentException {
+ if (planFile == null && jarFile == null) {
+ return null;
+ }
+
+ JarEntry appManifest = jarFile.getJarEntry("META-INF/APPLICATION.MF");
+
+ if (appManifest == null) {
+ return null;
+ }
+
+ ApplicationMetadataManager service = getApplicationMetadataManager();
+ if (service == null) {
+ return null;
+ }
+
+ ApplicationMetadata appMetadata = null;
+ try {
+ InputStream in = jarFile.getInputStream(appManifest);
+ appMetadata = service.parseApplication(in);
+ } catch (IOException e) {
+ throw new DeploymentException("Failed to parse application metadata", e);
+ }
+
+ return appMetadata;
}
-
- public String getSchemaNamespace() {
- return null;
+
+ public Artifact getConfigurationID(Object plan,
+ JarFile jarFile,
+ ModuleIDBuilder idBuilder)
+ throws IOException, DeploymentException {
+ ApplicationMetadata appMetadata = (ApplicationMetadata) plan;
+
+ Artifact name = new Artifact("aries", appMetadata.getApplicationSymbolicName(), appMetadata.getApplicationVersion().toString(), "eba");
+
+ return name;
+ }
+
+ public DeploymentContext buildConfiguration(boolean inPlaceDeployment,
+ Artifact configId,
+ Object plan,
+ JarFile jarFile,
+ Collection<ConfigurationStore> configurationStores,
+ ArtifactResolver artifactResolver,
+ ConfigurationStore targetConfigurationStore)
+ throws IOException, DeploymentException {
+ ApplicationMetadata appMetadata = (ApplicationMetadata) plan;
+ installModule(jarFile, appMetadata);
+
+ File outfile;
+ try {
+ outfile = targetConfigurationStore.createNewConfigurationDir(configId);
+ } catch (ConfigurationAlreadyExistsException e) {
+ throw new DeploymentException(e);
+ }
+
+ Environment environment = new Environment();
+ environment.setConfigId(configId);
+
+ Naming naming = kernel.getNaming();
+ AbstractName moduleName = naming.createRootName(configId, configId.toString(), "AriesApplication");
+ try {
+ DeploymentContext context = new DeploymentContext(outfile,
+ inPlaceDeployment && null != jarFile ? DeploymentUtil.toFile(jarFile) : null,
+ environment,
+ moduleName,
+ ConfigurationModuleType.SERVICE,
+ naming,
+ configurationManager,
+ repositories,
+ bundleContext);
+
+
+ context.flush();
+ context.initializeConfiguration();
+
+ return context;
+ } catch (DeploymentException e) {
+ e.printStackTrace();
+ throw e;
+ } catch (IOException e) {
+ e.printStackTrace();
+ throw e;
+ }
}
}
Propchange: geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/AriesAppConfigBuilder.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/AriesAppConfigBuilder.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/AriesAppConfigBuilder.java
------------------------------------------------------------------------------
svn:mergeinfo =
Propchange: geronimo/server/trunk/plugins/aries/geronimo-aries-builder/src/main/java/org/apache/geronimo/aries/builder/AriesAppConfigBuilder.java
------------------------------------------------------------------------------
svn:mime-type = text/plain