resolving classloading problem from includedlibs folder

master
Vishnu 2013-07-24 19:24:40 +05:30
parent bbf4389520
commit c2a4bf3cea
9 changed files with 85 additions and 154 deletions

View File

@ -40,12 +40,8 @@
<artifactId>camel-core</artifactId>
<version>2.11.0</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring</artifactId>
<version>2.11.0</version>
</dependency>
<dependency>
<!--<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>3.1.4.RELEASE</version>
@ -64,52 +60,22 @@
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>3.1.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.5</version>
</dependency>
</dependency>-->
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-asm</artifactId>
<version>3.1.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<version>3.1.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
<version>1.7.5</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jms</artifactId>
<version>2.11.0</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>3.1.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jms</artifactId>
<version>3.1.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-all</artifactId>
<version>5.8.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.5</version>
</dependency>
<!-- camel dependencies -->
@ -119,14 +85,15 @@
<artifactId>componentsl</artifactId>
<scope>provided</scope>
</dependency>
<!--<dependency>
<groupId>open-jbi-components</groupId>
<artifactId>encoder-fw</artifactId>
</dependency>
<dependency>
<groupId>open-jbi-components</groupId>
<artifactId>qos</artifactId>
</dependency>
<!--<dependency>
<groupId>open-jbi-components</groupId>
<artifactId>encoder-fw</artifactId>
</dependency>
<dependency>
<groupId>open-jbi-components</groupId>
<artifactId>compositelock</artifactId>

View File

@ -4,6 +4,7 @@
*/
package org.openesb.components.camelse;
import com.sun.jbi.common.qos.config.ComponentConfig;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@ -38,9 +39,14 @@ public interface CamelSEConfigMBean {
/** relative path in both installPath and workPath*/
private static final String CONFIG_FILE_PATH = "config.properties";
private static final String PROP_CAMEL_HOME = "camel.home";
private static final String PROP_EXCLUDE_CAMEL_LIBS = "exclude.camel.libs";
private static final String PROP_INCLUDE_CAMEL_LIBS = "include.camel.libs";
//private static final String PROP_CAMEL_HOME = "camel.home";
private static final String PROP_CAMEL_HOME = "CamelHome";
//private static final String PROP_EXCLUDE_CAMEL_LIBS = "exclude.camel.libs";
private static final String PROP_EXCLUDE_CAMEL_LIBS = "ExcludeCamelLibs";
//private static final String PROP_INCLUDE_CAMEL_LIBS = "include.camel.libs";
private static final String PROP_INCLUDE_CAMEL_LIBS = "IncludeCamelLibs";
private File mConfigFile;
private Properties mConfigProps;
@ -70,6 +76,12 @@ public interface CamelSEConfigMBean {
}
}
public void setInitialConfigurations(ComponentConfig props) {
setCamelHome(props.getProperty(PROP_CAMEL_HOME).getValue());
setIncludeCamelLibs(props.getProperty(PROP_INCLUDE_CAMEL_LIBS).getValue());
setExcludeCamelLibs(props.getProperty(PROP_EXCLUDE_CAMEL_LIBS).getValue());
}
private File createConfigFile(String configRootPath) {
File confFile = new File(configRootPath, CONFIG_FILE_PATH);
if (!confFile.exists()) {

View File

@ -5,8 +5,6 @@
package org.openesb.components.camelse;
import java.util.ArrayList;
import java.util.List;
import javax.jbi.JBIException;
import javax.jbi.component.ComponentContext;
import javax.jbi.messaging.DeliveryChannel;
@ -14,32 +12,17 @@ import javax.jbi.messaging.ExchangeStatus;
import javax.jbi.messaging.Fault;
import javax.jbi.messaging.InOnly;
import javax.jbi.messaging.InOut;
import javax.jbi.messaging.MessageExchange;
import javax.jbi.messaging.MessagingException;
import javax.jbi.messaging.NormalizedMessage;
import javax.wsdl.Definition;
import javax.wsdl.Input;
import javax.wsdl.Message;
import javax.wsdl.Operation;
import javax.wsdl.OperationType;
import javax.wsdl.Output;
import javax.wsdl.Part;
import javax.wsdl.PortType;
import javax.xml.namespace.QName;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMSource;
import org.openesb.components.camelse.JBIWrapperUtil;
import org.openesb.components.camelse.common.RuntimeHelper;
import org.openesb.components.camelse.common.deployment.ConsumerEndpoint;
import org.openesb.components.camelse.common.deployment.SUDescriptor;
import org.openesb.components.camelse.common.deployment.ServiceUnit;
import org.openesb.components.camelse.common.wsdl.WSDL11JBIWrapper;
import org.w3c.dom.DOMException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
/**
*

View File

@ -34,7 +34,6 @@ package org.openesb.components.camelse;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.jbi.management.MBeanNames;
import javax.management.NotCompliantMBeanException;
import javax.management.ObjectName;
import javax.management.StandardMBean;
import org.openesb.components.camelse.CamelSEConfigMBean.CamelSEConfigMBeanImpl;
@ -80,9 +79,12 @@ public class CamelSEInstaller extends ComponentInstaller {
try {
InstallationContext ctx = this.getInstallationContext();
CamelSEConfigMBeanImpl impl = new CamelSEConfigMBeanImpl(ctx.getInstallRoot());
//ComponentConfig defaultProperties = ComponentConfig.parse(ctx.getInstallRoot());
//impl.setInitialConfigurations(defaultProperties);
StandardMBean configBean = new StandardMBean(impl, CamelSEConfigMBean.class);
return configBean;
} catch (NotCompliantMBeanException ex) {
} catch (Exception ex) {
Logger.getLogger(CamelSEInstaller.class.getName()).log(Level.SEVERE, null, ex);
return null;
}

View File

@ -29,13 +29,8 @@
*/
package org.openesb.components.camelse;
import java.util.ArrayList;
import java.util.List;
import javax.wsdl.Input;
import javax.wsdl.Message;
import javax.wsdl.Operation;
import javax.wsdl.Part;
import javax.xml.transform.dom.DOMSource;
import org.openesb.components.camelse.common.AbstractMessageExchangeHandler;
import org.openesb.components.camelse.common.RuntimeHelper;
import org.openesb.components.camelse.common.wsdl.WSDL11JBIWrapper;
@ -49,15 +44,8 @@ import javax.jbi.messaging.InOnly;
import javax.jbi.messaging.InOut;
import javax.jbi.messaging.MessageExchange;
import javax.jbi.messaging.MessagingException;
import javax.jbi.messaging.NormalizedMessage;
import javax.xml.namespace.QName;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.Source;
import org.w3c.dom.DOMException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
/**
* This class extends the AbstractMessageExchangeHandler to implement the component specific

View File

@ -32,11 +32,9 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.StringTokenizer;
import javax.jbi.messaging.MessageExchange;
import javax.xml.namespace.QName;
import org.apache.camel.CamelContext;
import org.apache.camel.spring.SpringCamelContext;
import org.openesb.components.camelse.camel.JBIBridgeComponent;
import org.openesb.components.camelse.camel.JBIBridgeEndpoint;
import org.openesb.components.camelse.common.RuntimeHelper;
@ -46,6 +44,7 @@ import org.openesb.components.camelse.common.deployment.ServiceUnit;
import org.openesb.components.camelse.common.deployment.ProviderEndpoint;
import org.openesb.components.camelse.common.deployment.SUDescriptor.Provides;
import java.io.File;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
@ -53,7 +52,6 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import javax.jbi.management.DeploymentException;
import javax.wsdl.Definition;
import org.apache.camel.spring.Main;
/**
* This class extends the ServiceUnit to implement the component specific service unit processing.
@ -66,7 +64,8 @@ import org.apache.camel.spring.Main;
public class CamelSEServiceUnit extends ServiceUnit {
private CamelSERuntime mRuntime;
private Main mCamelMain;
private Object mCamelMainObj;
private Class mCamelMainClazz;
/** Creates a new instance of CamelSEServiceUnit */
public CamelSEServiceUnit(String suName, String suRootPath, CamelSERuntime runtime) {
@ -188,14 +187,14 @@ public class CamelSEServiceUnit extends ServiceUnit {
camelCP.addAll(addlCP);
camelCP.addAll(appCP);
URL[] cpURLs = camelCP.toArray(new URL[0]);
URL[] cpURLs = camelCP.toArray(new URL[camelCP.size()]);
URLClassLoader loader = new URLClassLoader(cpURLs, this.getClass().getClassLoader());
RuntimeHelper.logDebug("### CamelSU Classpath ###");
StringBuffer buff = new StringBuffer();
for (URL cpURL : cpURLs) {
buff.append(cpURL).append(":");
buff.append(cpURL).append(",");
}
RuntimeHelper.logDebug(buff);
@ -205,10 +204,16 @@ public class CamelSEServiceUnit extends ServiceUnit {
private void startCamel(ClassLoader loader) {
RuntimeHelper.getLogger().fine("Loading camel in su classloader " + loader);
try {
Class clazz = loader.loadClass("org.apache.camel.spring.Main");
Object obj = clazz.newInstance();
this.mCamelMain = (Main) obj;
this.mCamelMain.start();
loader.loadClass("org.slf4j.LoggerFactory");
mCamelMainClazz = loader.loadClass("org.apache.camel.spring.Main");
mCamelMainObj = mCamelMainClazz.newInstance();
Method startMethod = mCamelMainClazz.getMethod("start", null);
startMethod.invoke(mCamelMainObj, null);
//this.mCamelMain = (Main) obj;
//this.mCamelMain.start();
} catch (Exception ex) {
RuntimeHelper.logError(ex);
}
@ -239,8 +244,10 @@ public class CamelSEServiceUnit extends ServiceUnit {
@Override
public void doStop() throws DeploymentException {
try {
if (this.mCamelMain != null) {
this.mCamelMain.stop();
if (this.mCamelMainObj != null && mCamelMainClazz != null) {
Method stopMethod = mCamelMainClazz.getMethod("stop", null);
stopMethod.invoke(mCamelMainObj, null);
//this.mCamelMain.stop();
}
} catch (Exception ex) {
RuntimeHelper.logDebug(ex);
@ -269,8 +276,14 @@ public class CamelSEServiceUnit extends ServiceUnit {
public List<CamelContext> getCamelContexts() {
List<CamelContext> ctxList = new ArrayList<CamelContext>();
List<CamelContext> springCCtxList = this.mCamelMain.getCamelContexts();
ctxList.addAll(springCCtxList);
try {
Method getCamelContextsMethod = mCamelMainClazz.getMethod("getCamelContexts", null);
List<CamelContext> springCCtxList = (List<CamelContext>)getCamelContextsMethod.invoke(mCamelMainObj, null);
//List<CamelContext> springCCtxList = this.mCamelMain.getCamelContexts();
ctxList.addAll(springCCtxList);
} catch (Exception ex) {
RuntimeHelper.getLogger().log(Level.SEVERE, null, ex);
}
return ctxList;
}

View File

@ -31,19 +31,15 @@ import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.jbi.JBIException;
import javax.jbi.messaging.MessageExchange;
import javax.wsdl.Operation;
import javax.xml.namespace.QName;
import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMSource;
import org.apache.camel.Exchange;
import org.apache.camel.ExchangePattern;
import org.apache.camel.Message;
import org.apache.camel.impl.DefaultProducer;
import org.apache.camel.util.ExchangeHelper;
import org.openesb.components.camelse.CamelSEConsumerEndpoint;
import org.openesb.components.camelse.common.RuntimeHelper;
import org.openesb.components.camelse.common.deployment.ConsumerEndpoint;
/**
*

View File

@ -147,12 +147,8 @@
<artifactId>camel-core</artifactId>
<version>2.11.0</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring</artifactId>
<version>2.11.0</version>
</dependency>
<dependency>
<!--<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>3.1.4.RELEASE</version>
@ -171,52 +167,26 @@
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>3.1.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.5</version>
</dependency>
</dependency>-->
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-asm</artifactId>
<version>3.1.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<version>3.1.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
<version>1.7.5</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jms</artifactId>
<version>2.11.0</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>3.1.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jms</artifactId>
<version>3.1.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-all</artifactId>
<version>5.8.0</version>
</dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.5</version>
</dependency>
<!-- camel dependencies end-->
@ -242,11 +212,11 @@
<artifactId>wsdl4j</artifactId>
<optional>true</optional>
</dependency>
<!--<dependency>
<dependency>
<groupId>open-jbi-components</groupId>
<artifactId>qos</artifactId>
<optional>true</optional>
</dependency>
<!--
<dependency>
<groupId>open-jbi-components</groupId>
<artifactId>compositelock</artifactId>

View File

@ -64,7 +64,7 @@
<shared-library>sun-wsdl-library</shared-library>
-->
<config:Configuration>
<config:Property defaultValue="E:\apache-camel-2.11.0" displayDescription="Apache Camel Installation Directory" displayName="Apache Camel Home" isApplicationRestartRequired="true" isComponentRestartRequired="false" name="CamelHome" showDisplay="all" type="xsd:string"/>
<config:Property defaultValue="" displayDescription="Apache Camel Installation Directory" displayName="Apache Camel Home" isApplicationRestartRequired="true" isComponentRestartRequired="false" name="CamelHome" showDisplay="all" type="xsd:string"/>
<config:Property defaultValue="" displayDescription="comma(,) separated names of Apache Camel Libraries to include in the Camel application classpath" displayName="Included Camel Libraries" isApplicationRestartRequired="true" isComponentRestartRequired="false" name="IncludeCamelLibs" showDisplay="all" type="xsd:string"/>
<config:Property defaultValue="" displayDescription="comma(,) separated names of Apache Camel Libraries to exclude from the Camel application classpath" displayName="Excluded Camel Libraries" isApplicationRestartRequired="true" isComponentRestartRequired="false" name="ExcludeCamelLibs" showDisplay="all" type="xsd:string"/>
</config:Configuration>