You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by gn...@apache.org on 2006/02/06 14:17:15 UTC
svn commit: r375275 - in
/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework:
AdminCommandsService.java AdminCommandsServiceMBean.java
InstallationService.java
Author: gnodet
Date: Mon Feb 6 05:17:13 2006
New Revision: 375275
URL: http://svn.apache.org/viewcvs?rev=375275&view=rev
Log:
Handle properties at component installation time
Modified:
incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/AdminCommandsService.java
incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/AdminCommandsServiceMBean.java
incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/InstallationService.java
Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/AdminCommandsService.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/AdminCommandsService.java?rev=375275&r1=375274&r2=375275&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/AdminCommandsService.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/AdminCommandsService.java Mon Feb 6 05:17:13 2006
@@ -28,6 +28,7 @@
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
+import java.util.Properties;
public class AdminCommandsService extends BaseSystemService implements AdminCommandsServiceMBean {
private JBIContainer container;
@@ -50,6 +51,17 @@
* @return
*/
public String installComponent(String file) throws Exception {
+ return installComponent(file, null);
+ }
+
+ /**
+ * Install a JBI component (a Service Engine or Binding Component)
+ *
+ * @param file jbi component archive to install
+ * @param props installation properties
+ * @return
+ */
+ public String installComponent(String file, Properties props) throws Exception {
try {
container.getInstallationService().install(file);
return success("installComponent", file);
Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/AdminCommandsServiceMBean.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/AdminCommandsServiceMBean.java?rev=375275&r1=375274&r2=375275&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/AdminCommandsServiceMBean.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/AdminCommandsServiceMBean.java Mon Feb 6 05:17:13 2006
@@ -28,6 +28,8 @@
String installComponent(String file) throws Exception;
+ String installComponent(String file, Properties properties) throws Exception;
+
String uninstallComponent(String name) throws Exception;
String installSharedLibrary(String file) throws Exception;
Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/InstallationService.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/InstallationService.java?rev=375275&r1=375274&r2=375275&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/InstallationService.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/InstallationService.java Mon Feb 6 05:17:13 2006
@@ -18,13 +18,17 @@
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
+import java.util.Iterator;
import java.util.Map;
+import java.util.Properties;
import javax.jbi.JBIException;
import javax.jbi.management.DeploymentException;
import javax.jbi.management.InstallerMBean;
+import javax.management.Attribute;
import javax.management.JMException;
import javax.management.MBeanOperationInfo;
+import javax.management.MBeanServer;
import javax.management.ObjectName;
import javax.resource.spi.work.Work;
import javax.resource.spi.work.WorkException;
@@ -286,10 +290,14 @@
* @param location
* @throws DeploymentException
*/
- public void install(String location) throws DeploymentException{
+ public void install(String location) throws DeploymentException {
install(location,false);
}
+ public void install(String location, Properties props) throws DeploymentException {
+ install(location, props, false);
+ }
+
/**
* Install an archive
*
@@ -297,12 +305,16 @@
* @param autoStart
* @throws DeploymentException
*/
- public void install(String location,boolean autoStart) throws DeploymentException{
+ public void install(String location, boolean autoStart) throws DeploymentException {
+ install(location, null, autoStart);
+ }
+
+ public void install(String location, Properties props, boolean autoStart) throws DeploymentException {
File tmpDir=AutoDeploymentService.unpackLocation(environmentContext.getTmpDir(),location);
if(tmpDir!=null){
Descriptor root=AutoDeploymentService.buildDescriptor(tmpDir);
if(root!=null){
- install(tmpDir,root,autoStart);
+ install(tmpDir, props, root, autoStart);
}else{
log.error("Could not find Descriptor from: "+location);
}
@@ -319,18 +331,39 @@
* @param autoStart
* @throws DeploymentException
*/
- protected void install(File tmpDir,Descriptor root,boolean autoStart) throws DeploymentException{
- if(root.getComponent()!=null){
- String componentName=root.getComponent().getIdentification().getName();
- if(!installers.containsKey(componentName)){
- InstallerMBeanImpl installer=doInstallArchive(tmpDir,root);
- if(installer!=null){
- try{
+ protected void install(File tmpDir, Descriptor root, boolean autoStart) throws DeploymentException {
+ install(tmpDir, null, root, autoStart);
+ }
+
+ protected void install(File tmpDir, Properties props, Descriptor root, boolean autoStart) throws DeploymentException {
+ if (root.getComponent() != null) {
+ String componentName = root.getComponent().getIdentification().getName();
+ if (!installers.containsKey(componentName)) {
+ InstallerMBeanImpl installer = doInstallArchive(tmpDir,root);
+ if (installer != null) {
+ try {
+ if (props != null && props.size() > 0) {
+ ObjectName on = installer.getInstallerConfigurationMBean();
+ if (on == null ) {
+ log.warn("Could not find installation configuration MBean. Installation properties will be ignored.");
+ } else {
+ MBeanServer mbs = managementContext.getMBeanServer();
+ for (Iterator it = props.keySet().iterator(); it.hasNext();) {
+ String key = (String) it.next();
+ String val = props.getProperty(key);
+ try {
+ mbs.setAttribute(on, new Attribute(key, val));
+ } catch (JMException e) {
+ throw new DeploymentException("Could not set installation property: (" + key + " = " + val, e);
+ }
+ }
+ }
+ }
installer.install();
- }catch(JBIException e){
+ } catch(JBIException e) {
throw new DeploymentException(e);
}
- if(autoStart){
+ if (autoStart) {
try{
ComponentNameSpace cns=new ComponentNameSpace(container.getName(),componentName,
componentName);