Merged openesb/openesb-components into master
commit
2d4c3dfc32
|
@ -219,6 +219,7 @@
|
|||
<xpathmodel.artifact.version>${jbicomps.currentVersion}</xpathmodel.artifact.version>
|
||||
<xsdmodel.artifact.version>${jbicomps.currentVersion}</xsdmodel.artifact.version>
|
||||
<xsltse.artifact.version>${jbicomps.currentVersion}</xsltse.artifact.version>
|
||||
<camelse.artifact.version>${jbicomps.currentVersion}</camelse.artifact.version>
|
||||
|
||||
<!-- contributed: -->
|
||||
<screenscraperse.release.version>${ojc.default.release.version}</screenscraperse.release.version>
|
||||
|
@ -952,6 +953,17 @@
|
|||
<artifactId>restbc-installer</artifactId>
|
||||
<version>${restbc.artifact.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>open-jbi-components</groupId>
|
||||
<artifactId>camelseimpl</artifactId>
|
||||
<version>${camelse.artifact.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>open-jbi-components</groupId>
|
||||
<artifactId>camelse-installer</artifactId>
|
||||
<version>${camelse.artifact.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<actions>
|
||||
<action>
|
||||
<actionName>clean</actionName>
|
||||
<packagings>
|
||||
<packaging>*</packaging>
|
||||
</packagings>
|
||||
<goals>
|
||||
<goal>clean</goal>
|
||||
</goals>
|
||||
<properties>
|
||||
<maven.test.skip>true</maven.test.skip>
|
||||
</properties>
|
||||
</action>
|
||||
<action>
|
||||
<actionName>build</actionName>
|
||||
<packagings>
|
||||
<packaging>*</packaging>
|
||||
</packagings>
|
||||
<goals>
|
||||
<goal>install</goal>
|
||||
</goals>
|
||||
<properties>
|
||||
<maven.test.skip>true</maven.test.skip>
|
||||
</properties>
|
||||
</action>
|
||||
<action>
|
||||
<actionName>test</actionName>
|
||||
<packagings>
|
||||
<packaging>*</packaging>
|
||||
</packagings>
|
||||
<goals>
|
||||
<goal>package</goal>
|
||||
</goals>
|
||||
<properties>
|
||||
<maven.test.skip>false</maven.test.skip>
|
||||
</properties>
|
||||
</action>
|
||||
<action>
|
||||
<actionName>rebuild</actionName>
|
||||
<packagings>
|
||||
<packaging>*</packaging>
|
||||
</packagings>
|
||||
<goals>
|
||||
<goal>clean</goal>
|
||||
<goal>install</goal>
|
||||
</goals>
|
||||
<properties>
|
||||
<maven.test.skip>true</maven.test.skip>
|
||||
</properties>
|
||||
</action>
|
||||
<action>
|
||||
<actionName>CUSTOM-testreport</actionName>
|
||||
<displayName>testreport</displayName>
|
||||
<goals>
|
||||
<goal>surefire-report:report-only</goal>
|
||||
</goals>
|
||||
<properties>
|
||||
<maven.test.skip>true</maven.test.skip>
|
||||
</properties>
|
||||
</action>
|
||||
<action>
|
||||
<actionName>CUSTOM-allreports</actionName>
|
||||
<displayName>allreports</displayName>
|
||||
<goals>
|
||||
<goal>site</goal>
|
||||
</goals>
|
||||
<properties>
|
||||
<maven.test.skip>true</maven.test.skip>
|
||||
</properties>
|
||||
</action>
|
||||
</actions>
|
|
@ -0,0 +1,143 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
|
||||
<project>
|
||||
<parent>
|
||||
<artifactId>build-common</artifactId>
|
||||
<groupId>open-jbi-components</groupId>
|
||||
<version>1.1</version>
|
||||
<relativePath>../../build-common</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>open-jbi-components</groupId>
|
||||
<artifactId>camelseimpl</artifactId>
|
||||
<name>camelseimpl</name>
|
||||
<version>${jbicomps.currentVersion}</version>
|
||||
<description>camelseimpl description</description>
|
||||
<properties>
|
||||
<component.name>openesb-camel-se</component.name>
|
||||
</properties>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifestEntries>
|
||||
<Component-Version>${camelse.artifact.version}</Component-Version>
|
||||
<Component-Name>${component.name}</Component-Name>
|
||||
</manifestEntries>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
|
||||
<!-- camel dependencies -->
|
||||
<dependency>
|
||||
<groupId>org.apache.camel</groupId>
|
||||
<artifactId>camel-core</artifactId>
|
||||
<version>2.11.0</version>
|
||||
</dependency>
|
||||
|
||||
<!--<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-aop</artifactId>
|
||||
<version>3.1.4.RELEASE</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-beans</artifactId>
|
||||
<version>3.1.4.RELEASE</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context</artifactId>
|
||||
<version>3.1.4.RELEASE</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-core</artifactId>
|
||||
<version>3.1.4.RELEASE</version>
|
||||
</dependency>-->
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-logging</groupId>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
<version>1.1.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>1.7.5</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- camel dependencies -->
|
||||
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>open-jbi-components</groupId>
|
||||
<artifactId>componentsl</artifactId>
|
||||
<scope>provided</scope>
|
||||
</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>
|
||||
</dependency>-->
|
||||
<!-- TEST DEPENDENCIES-->
|
||||
<!--<dependency>
|
||||
<groupId>jbicompsplatform</groupId>
|
||||
<artifactId>compileconf</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>jmock</groupId>
|
||||
<artifactId>jmock</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>jmock</groupId>
|
||||
<artifactId>jmock-cglib</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.sf.hulp.meas</groupId>
|
||||
<artifactId>net.sf.hulp.meas.itf</artifactId>
|
||||
<optional>true</optional>
|
||||
<version>2.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.sf.hulp.meas</groupId>
|
||||
<artifactId>net.sf.hulp.meas.impl</artifactId>
|
||||
<optional>true</optional>
|
||||
<version>2.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>open-esb</groupId>
|
||||
<artifactId>jbi-admin-common</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>-->
|
||||
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,18 @@
|
|||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
# contributor license agreements. See the NOTICE file distributed with
|
||||
# this work for additional information regarding copyright ownership.
|
||||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
class=org.openesb.components.camelse.camel.JBIBridgeComponent
|
|
@ -0,0 +1,20 @@
|
|||
|
||||
#
|
||||
# The logging properties used for eclipse testing, We want to see debug output on the console.
|
||||
#
|
||||
log4j.rootLogger=INFO, out
|
||||
|
||||
# uncomment the following line to turn on Camel debugging
|
||||
#log4j.logger.org.apache.camel=DEBUG
|
||||
|
||||
# uncomment the following line to turn on ActiveMQ debugging
|
||||
#log4j.logger.org.apache.activemq=DEBUG
|
||||
|
||||
log4j.logger.org.springframework=WARN
|
||||
|
||||
|
||||
# CONSOLE appender not used by default
|
||||
log4j.appender.out=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.out.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.out.layout.ConversionPattern=[%30.30t] %-30.30c{1} %-5p %m%n
|
||||
#log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
|
|
@ -0,0 +1,132 @@
|
|||
/*
|
||||
* BEGIN_HEADER - DO NOT EDIT
|
||||
*
|
||||
* The contents of this file are subject to the terms
|
||||
* of the Common Development and Distribution License
|
||||
* (the "License"). You may not use this file except
|
||||
* in compliance with the License.
|
||||
*
|
||||
* You can obtain a copy of the license at
|
||||
* https://open-esb.dev.java.net/public/CDDLv1.0.html.
|
||||
* See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*
|
||||
* When distributing Covered Code, include this CDDL
|
||||
* HEADER in each file and include the License file at
|
||||
* https://open-esb.dev.java.net/public/CDDLv1.0.html.
|
||||
* If applicable add the following below this CDDL HEADER,
|
||||
* with the fields enclosed by brackets "[]" replaced with
|
||||
* your own identifying information: Portions Copyright
|
||||
* [year] [name of copyright owner]
|
||||
*/
|
||||
|
||||
/*
|
||||
*
|
||||
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
*
|
||||
* END_HEADER - DO NOT EDIT
|
||||
*/
|
||||
|
||||
/*
|
||||
* CamelSEComponentLifeCycle.java
|
||||
*/
|
||||
package org.openesb.components.camelse;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.jbi.component.ComponentContext;
|
||||
import javax.jbi.management.MBeanNames;
|
||||
import javax.management.NotCompliantMBeanException;
|
||||
import javax.management.ObjectName;
|
||||
import javax.management.StandardMBean;
|
||||
import org.openesb.components.camelse.CamelSEConfigMBean.CamelSEConfigMBeanImpl;
|
||||
import org.openesb.components.camelse.common.BasicComponentLifeCycle;
|
||||
import org.openesb.components.camelse.common.DefaultMessageExchangeReceiver;
|
||||
import org.openesb.components.camelse.common.MessageExchangeReceiver;
|
||||
import javax.jbi.JBIException;
|
||||
import javax.jbi.component.Component;
|
||||
|
||||
/**
|
||||
* This class extends the basic ComponentLifeCycle implementation to provide component
|
||||
* specific implementation of the ComponentLifeCycle.
|
||||
*
|
||||
* @see javax.jbi.ComponentLifeCycle
|
||||
* @see com.sun.jbi.sample.component.common.BasicComponentLifeCycle
|
||||
* @author chikkala
|
||||
*/
|
||||
public class CamelSEComponentLifeCycle extends BasicComponentLifeCycle {
|
||||
|
||||
private CamelSEConfigMBeanImpl mConfigImpl;
|
||||
|
||||
/** constructor */
|
||||
public CamelSEComponentLifeCycle(Component compRuntime) {
|
||||
super(compRuntime);
|
||||
}
|
||||
|
||||
/**
|
||||
* creates DefaultMessageExchangeReceiver to handles receiving and processing
|
||||
* the message exchanges from the delivery channel.
|
||||
*/
|
||||
@Override
|
||||
protected MessageExchangeReceiver createMessageExchangeReceiver() {
|
||||
return new DefaultMessageExchangeReceiver();
|
||||
}
|
||||
|
||||
/**
|
||||
* chance to extended classes to do the component specific init
|
||||
* @throws javax.jbi.JBIException
|
||||
*/
|
||||
@Override
|
||||
protected void doInit() throws JBIException {
|
||||
super.doInit();
|
||||
//TODO: create and register addtional mbeans if needed();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doShutDown() throws JBIException {
|
||||
super.doShutDown();
|
||||
//TODO: unregister addtional mbeans created and clean the resources if needed.
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doStart() throws JBIException {
|
||||
|
||||
super.doStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doStop() throws JBIException {
|
||||
super.doStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected StandardMBean createExtensionMBean() {
|
||||
try {
|
||||
ComponentContext ctx = this.getComponentContext();
|
||||
if ( this.mConfigImpl == null ) {
|
||||
this.mConfigImpl = new CamelSEConfigMBeanImpl(ctx.getInstallRoot(), ctx.getWorkspaceRoot());
|
||||
}
|
||||
StandardMBean configBean = new StandardMBean(this.mConfigImpl, CamelSEConfigMBean.class);
|
||||
return configBean;
|
||||
} catch (NotCompliantMBeanException ex) {
|
||||
Logger.getLogger(CamelSEComponentLifeCycle.class.getName()).log(Level.SEVERE, null, ex);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ObjectName createExtensionMBeanName() {
|
||||
MBeanNames mbeanNames = this.getComponentContext().getMBeanNames();
|
||||
// return mbeanNames.createCustomComponentMBeanName(mbeanNames.COMPONENT_LIFE_CYCLE_EXTENSION);
|
||||
// return the configuration mbean as the extension mbean for now.
|
||||
//TODO: change this to return null and manage add/remove configuration mbean
|
||||
// as additional mbeans in doInit and doShutDown methods?
|
||||
|
||||
return mbeanNames.createCustomComponentMBeanName("Configuration");
|
||||
}
|
||||
|
||||
protected CamelSEConfigMBean getConfigMBeanImpl() {
|
||||
return this.mConfigImpl;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,206 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
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;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.StringWriter;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author chikkala
|
||||
*/
|
||||
public interface CamelSEConfigMBean {
|
||||
|
||||
public void setCamelHome(String camelHome);
|
||||
|
||||
public String getCamelHome();
|
||||
|
||||
public void setIncludeCamelLibs(String includeLibs);
|
||||
|
||||
public String getIncludeCamelLibs();
|
||||
|
||||
public void setExcludeCamelLibs(String excludeLibs);
|
||||
|
||||
public String getExcludeCamelLibs();
|
||||
|
||||
public static class CamelSEConfigMBeanImpl implements 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_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;
|
||||
|
||||
public CamelSEConfigMBeanImpl(String installPath) {
|
||||
this(installPath, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* if workPath is null, properties are loaded
|
||||
* @param installPath
|
||||
* @param workPath
|
||||
*/
|
||||
public CamelSEConfigMBeanImpl(String installPath, String workPath) {
|
||||
this.mConfigProps = new Properties();
|
||||
if (workPath == null) {
|
||||
this.mConfigFile = createConfigFile(installPath);
|
||||
loadProperties(this.mConfigProps, this.mConfigFile);
|
||||
} else {
|
||||
this.mConfigFile = createConfigFile(workPath);
|
||||
Properties installProps = new Properties();
|
||||
File installFile = findConfigFile(installPath);
|
||||
if (installFile != null) {
|
||||
loadProperties(installProps, installFile);
|
||||
}
|
||||
this.mConfigProps.putAll(installProps);
|
||||
loadProperties(this.mConfigProps, this.mConfigFile);
|
||||
}
|
||||
}
|
||||
|
||||
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()) {
|
||||
try {
|
||||
File confParent = confFile.getParentFile();
|
||||
confParent.mkdirs();
|
||||
FileWriter writer = new FileWriter(confFile);
|
||||
writer.append("# CamelSe Configuration parameters");
|
||||
writer.close();
|
||||
} catch (Exception ex) {
|
||||
//TODO: log.
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (confFile.exists()) {
|
||||
return confFile;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private File findConfigFile(String configRootPath) {
|
||||
File confFile = new File(configRootPath, CONFIG_FILE_PATH);
|
||||
if (confFile.exists()) {
|
||||
return confFile;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void saveProperties(File propFile, Properties props) {
|
||||
FileOutputStream outS = null;
|
||||
try {
|
||||
outS = new FileOutputStream(propFile);
|
||||
props.store(outS, "# CamelSe Configuration parameters");
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
} finally {
|
||||
if (outS != null) {
|
||||
try {
|
||||
outS.close();
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(CamelSEConfigMBean.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void loadProperties(Properties props, File propFile) {
|
||||
|
||||
FileInputStream inS = null;
|
||||
try {
|
||||
inS = new FileInputStream(propFile);
|
||||
props.load(inS);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
} finally {
|
||||
if (inS != null) {
|
||||
try {
|
||||
inS.close();
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(CamelSEConfigMBean.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private StringBuffer readResourceAsString(String resourcePath) {
|
||||
|
||||
StringWriter writer = new StringWriter();
|
||||
InputStream inS = null;
|
||||
try {
|
||||
inS = this.getClass().getResourceAsStream(resourcePath);
|
||||
InputStreamReader reader = new InputStreamReader(inS);
|
||||
char[] buff = new char[1024];
|
||||
int size = 0;
|
||||
while ((size = reader.read(buff)) != -1) {
|
||||
writer.write(buff, 0, size);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger(CamelSEConfigMBean.class.getName()).log(Level.SEVERE, null, ex);
|
||||
} finally {
|
||||
if ( inS != null ) {
|
||||
try {
|
||||
inS.close();
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(CamelSEConfigMBean.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
return writer.getBuffer();
|
||||
}
|
||||
|
||||
public void setCamelHome(String camelHome) {
|
||||
this.mConfigProps.setProperty(PROP_CAMEL_HOME, camelHome);
|
||||
this.saveProperties(mConfigFile, mConfigProps);
|
||||
}
|
||||
|
||||
public String getCamelHome() {
|
||||
return this.mConfigProps.getProperty(PROP_CAMEL_HOME, "");
|
||||
}
|
||||
|
||||
public void setIncludeCamelLibs(String includeLibs) {
|
||||
this.mConfigProps.setProperty(PROP_INCLUDE_CAMEL_LIBS, includeLibs);
|
||||
this.saveProperties(mConfigFile, mConfigProps);
|
||||
}
|
||||
|
||||
public String getIncludeCamelLibs() {
|
||||
return this.mConfigProps.getProperty(PROP_INCLUDE_CAMEL_LIBS, "");
|
||||
}
|
||||
|
||||
public void setExcludeCamelLibs(String excludeLibs) {
|
||||
this.mConfigProps.setProperty(PROP_EXCLUDE_CAMEL_LIBS, excludeLibs);
|
||||
this.saveProperties(mConfigFile, mConfigProps);
|
||||
}
|
||||
|
||||
public String getExcludeCamelLibs() {
|
||||
return this.mConfigProps.getProperty(PROP_EXCLUDE_CAMEL_LIBS, "");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,286 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package org.openesb.components.camelse;
|
||||
|
||||
import javax.jbi.JBIException;
|
||||
import javax.jbi.component.ComponentContext;
|
||||
import javax.jbi.messaging.DeliveryChannel;
|
||||
import javax.jbi.messaging.ExchangeStatus;
|
||||
import javax.jbi.messaging.Fault;
|
||||
import javax.jbi.messaging.InOnly;
|
||||
import javax.jbi.messaging.InOut;
|
||||
import javax.jbi.messaging.NormalizedMessage;
|
||||
import javax.wsdl.Definition;
|
||||
import javax.wsdl.Operation;
|
||||
import javax.wsdl.OperationType;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.transform.Source;
|
||||
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;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author chikkala
|
||||
*/
|
||||
public class CamelSEConsumerEndpoint extends ConsumerEndpoint {
|
||||
private static final String XMLNS_NS = "http://www.w3.org/2000/xmlns/";
|
||||
private static final long SEND_SYNC_TIMEOUT = 60000; // 1 minute
|
||||
|
||||
/** Creates a new instance of CamelSEConsumerEndpoint */
|
||||
public CamelSEConsumerEndpoint(SUDescriptor.Consumes consumes, Definition wsdlDef, ServiceUnit su) {
|
||||
super(consumes, wsdlDef, su);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doInit() throws JBIException {
|
||||
RuntimeHelper.getLogger().fine("CamelSEConsumerEndpoint(Consumer): init called");
|
||||
this.initCamelEndpoint();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doActivate() throws JBIException {
|
||||
RuntimeHelper.getLogger().fine("CamelSEConsumerEndpoint(Consumer): activate called");
|
||||
this.activateCamelEndpoint();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doDeactivate() throws JBIException {
|
||||
RuntimeHelper.getLogger().fine("CamelSEConsumerEndpoint(Consumer): deactivate called");
|
||||
this.deactivateCamelEndpoint();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doClean() throws JBIException {
|
||||
RuntimeHelper.getLogger().fine("CamelSEConsumerEndpoint(Consumer): clean called");
|
||||
this.cleanCamelEndpoint();
|
||||
}
|
||||
|
||||
private void activateCamelEndpoint() {
|
||||
//NOOP
|
||||
}
|
||||
|
||||
private void cleanCamelEndpoint() {
|
||||
//NOOP
|
||||
}
|
||||
|
||||
private void deactivateCamelEndpoint() {
|
||||
//NOOP
|
||||
}
|
||||
|
||||
private void initCamelEndpoint() {
|
||||
//NOOP
|
||||
}
|
||||
|
||||
// /**
|
||||
// * initiate exchange with a sepcified operation.
|
||||
// * @param operation operation local name or qname as string. Assumes the service endpoint's
|
||||
// * interface ns for operations ns
|
||||
// * @param inSource
|
||||
// * @return
|
||||
// * @throws javax.jbi.JBIException
|
||||
// */
|
||||
// public Source initiateMessageExchange(String operation, Source inSource) throws JBIException {
|
||||
// QName opQName = null;
|
||||
// if (operation != null && operation.trim().length() > 0) {
|
||||
// QName qn = QName.valueOf(operation);
|
||||
// if (qn.getNamespaceURI().trim().length() > 0) {
|
||||
// opQName = qn;
|
||||
// } else {
|
||||
// opQName = this.getOperationQName(operation);
|
||||
// }
|
||||
// }
|
||||
// return initiateMessageExchange(opQName, inSource); // with default operation.
|
||||
// }
|
||||
|
||||
/**
|
||||
*
|
||||
* @param operation openration name. can be null for default operation.
|
||||
* @param inSource
|
||||
* @return outSource if any. else null.
|
||||
* @throws javax.jbi.JBIException on exception
|
||||
*/
|
||||
public Source initiateMessageExchange(QName operation, Source inSource) throws JBIException {
|
||||
// 1. Decide what type of message exchange needed for this operation.
|
||||
Source outSource = null;
|
||||
try {
|
||||
Operation wsdlOp = this.getWSDLOperation(operation);
|
||||
if ( wsdlOp == null ) {
|
||||
String msg = "Cannot find the wsdl operation " + operation + " on the jbi consumer endpoint " + this.getID();
|
||||
this.getLogger().fine(msg);
|
||||
throw new JBIException(msg);
|
||||
}
|
||||
QName wsdlOpQName = this.getOperationQName(wsdlOp.getName());
|
||||
if ( OperationType.REQUEST_RESPONSE.equals(wsdlOp.getStyle()) ) {
|
||||
outSource = doInOutMessageExchange(wsdlOpQName, inSource);
|
||||
} else if ( OperationType.ONE_WAY.equals(wsdlOp.getStyle()) ) {
|
||||
doInOnlyMessageExchange(wsdlOpQName, inSource);
|
||||
} else {
|
||||
throw new JBIException("Unsupported MEP " + wsdlOp.getStyle() +
|
||||
"for operation " + operation);
|
||||
}
|
||||
return outSource;
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
throw new JBIException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* invokes the service provider with in-only message exchange sent to delivery channel
|
||||
* by the consumer.
|
||||
* //TODO: pass message headers, attachments and other normalized message settings.
|
||||
* @param operation operation name on a service
|
||||
* @param inSource input xml document for the InOut operation
|
||||
* @throws java.lang.Exception if any error occurs in invoking the operation on the service.
|
||||
* @return output xml document as a Source object received from InOut operation of the
|
||||
* service invoked.
|
||||
*/
|
||||
private void doInOnlyMessageExchange(QName operation, Source inSource)
|
||||
throws Exception {
|
||||
// 2. normalized the message.
|
||||
// 3. locate service endpoint
|
||||
// 4. create message exchange according to the Opeations MEP
|
||||
|
||||
// get the component context and the delivery channel for preparing to send message
|
||||
ComponentContext compContext = this.getComponentContext();
|
||||
DeliveryChannel channel = this.getDeliveryChannel();
|
||||
// create INOUT Message Exchange
|
||||
InOnly inOnlyME = this.createInOnlyMessageExchange(operation);
|
||||
// set the content of the IN normalized message ( Normalize the message )
|
||||
NormalizedMessage inMsg = inOnlyME.getInMessage();
|
||||
Operation wsdlOperation = this.getWSDLOperation(inOnlyME.getOperation());
|
||||
JBIWrapperUtil.addJBIWrapperToInput(wsdlOperation, inMsg, RuntimeHelper.sourceToDOMSource(inSource));
|
||||
//// System.out.println("#### CamelSE ConsumerEndpont.doInOnlyMx : In Message Content for InOnly ");
|
||||
//// System.out.println(RuntimeHelper.readFromSource(inMsg.getContent()));
|
||||
// send the message exchange and wait for response
|
||||
boolean isSent = channel.sendSync(inOnlyME, SEND_SYNC_TIMEOUT);
|
||||
if ( !isSent ) {
|
||||
throw new Exception("JMXBinding:Timeout occured in sending the message to provider");
|
||||
}
|
||||
// check if you got a done message or error ( done or error are only allowed in in-only)
|
||||
// process the Message Exchange to check for done or error message and
|
||||
// complete InOut message exchange with provider
|
||||
//TODO: put this below code in processInOnlyMessageExchangeOnConsumer()
|
||||
ExchangeStatus status = inOnlyME.getStatus();
|
||||
this.getLogger().fine("Consumer:InOnly:Processing Message Exchange with status " + status);
|
||||
if (ExchangeStatus.DONE.equals(status) ) {
|
||||
this.getLogger().fine("Consumer: Completed the INONLY MessageExchange");
|
||||
return;
|
||||
} else if (ExchangeStatus.ERROR.equals(status) ) {
|
||||
// error can occur any time. so just return the error back to client.
|
||||
Exception serverSideEx = inOnlyME.getError();
|
||||
StringBuffer exMsgBuff = RuntimeHelper.getExceptionStackTrace(serverSideEx);
|
||||
throw new Exception("Consumer:INONLY Message Exchange status ERROR.\n" + exMsgBuff);
|
||||
} else {
|
||||
// any other status is error.
|
||||
throw new Exception("Consumer:INONLY Message Exchange error. status: " + status);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* invokes service provider with in-out message exchange sent to delivery channel
|
||||
* by the consumer
|
||||
* @param operation operation name on a service
|
||||
* @param inSource input xml document for the InOut operation
|
||||
* @throws java.lang.Exception if any error occurs in invoking the operation on the service.
|
||||
* @return output xml document as a Source object received from InOut operation of the
|
||||
* service invoked.
|
||||
*/
|
||||
private Source doInOutMessageExchange(QName operation, Source inSource)
|
||||
throws Exception {
|
||||
// 2. normalized the message.
|
||||
// 3. locate service endpoint
|
||||
// 4. create message exchange according to the Opeations MEP
|
||||
|
||||
// get the component context and the delivery channel for preparing to send message
|
||||
ComponentContext compContext = this.getComponentContext();
|
||||
DeliveryChannel channel = this.getDeliveryChannel();
|
||||
// create INOUT Message Exchange
|
||||
InOut inOutME = this.createInOutMessageExchange(operation);
|
||||
// set the content of the IN normalized message ( Normalize the message )
|
||||
NormalizedMessage inMsg = inOutME.getInMessage();
|
||||
Operation wsdlOperation = this.getWSDLOperation(inOutME.getOperation());
|
||||
JBIWrapperUtil.addJBIWrapperToInput(wsdlOperation, inMsg, RuntimeHelper.sourceToDOMSource(inSource));
|
||||
// send the message exchange and wait for response
|
||||
boolean isSent = channel.sendSync(inOutME, SEND_SYNC_TIMEOUT);
|
||||
if ( !isSent ) {
|
||||
throw new Exception("CamelSE:Timeout occured in sending the message to provider");
|
||||
}
|
||||
// check if you got a out message or fault or error
|
||||
// process the Message Exchange to get the output message and
|
||||
// complete InOut message exchange with provider
|
||||
NormalizedMessage outMsg = processInOutMessageExchangeOnConsumer(inOutME);
|
||||
Source outSource = JBIWrapperUtil.removeJBIWrapperFromOutput(wsdlOperation, outMsg);
|
||||
return outSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* takes the InOut message exchange received from sendSync call and processes it further
|
||||
* to complete InOut message exchange with provider and returns the out message or throws
|
||||
* exception in case of error or faults.
|
||||
*/
|
||||
private NormalizedMessage processInOutMessageExchangeOnConsumer(InOut inoutExchange)
|
||||
throws Exception {
|
||||
// InOut MessageExchange processing on consumer side
|
||||
// 1. ACTIVE status receives a fault or out message,
|
||||
// send the done status to complete message exchange
|
||||
// return the fault/out message to external consumer
|
||||
// 2. can not receive DONE status
|
||||
// 3. when received ERROR status, return the error to consumer.
|
||||
|
||||
// process the message exchange based on its state.
|
||||
ExchangeStatus status = inoutExchange.getStatus();
|
||||
this.getLogger().fine("Consumer:Processing Message Exchange with status " + status);
|
||||
|
||||
if (ExchangeStatus.ACTIVE.equals(status) ) {
|
||||
|
||||
Fault fault = inoutExchange.getFault();
|
||||
NormalizedMessage outMsg = inoutExchange.getOutMessage();
|
||||
|
||||
// send done to complete message exchange.
|
||||
DeliveryChannel channel = this.getDeliveryChannel();
|
||||
inoutExchange.setStatus(ExchangeStatus.DONE);
|
||||
channel.send(inoutExchange);
|
||||
this.getLogger().fine("Consumer: Completed the INOUT MessageExchange");
|
||||
|
||||
// process fault or out message
|
||||
if ( fault != null ) {
|
||||
// throw an exception if there is a fault message.
|
||||
Source faultContent = fault.getContent();
|
||||
StringBuffer faultContentBuff = null;
|
||||
if ( faultContent != null ) {
|
||||
faultContentBuff = RuntimeHelper.readFromSource(faultContent);
|
||||
}
|
||||
throw new Exception("Consumer:INOUT message exchange Fault \n" +
|
||||
faultContentBuff);
|
||||
}
|
||||
|
||||
// return the outMessage for processing
|
||||
if ( outMsg != null ) {
|
||||
return outMsg;
|
||||
} else {
|
||||
throw new Exception("Consumer: Null Out message in INOUT message exchange. ");
|
||||
}
|
||||
} else if (ExchangeStatus.DONE.equals(status) ) {
|
||||
// can not get DONE on Consumer side in INOUT message exchange.
|
||||
throw new Exception("Consumer: Illegal status DONE on INOUT message exchange");
|
||||
} else if (ExchangeStatus.ERROR.equals(status) ) {
|
||||
// error can occur any time. so just return the error back to client.
|
||||
Exception serverSideEx = inoutExchange.getError();
|
||||
StringBuffer exMsgBuff = RuntimeHelper.getExceptionStackTrace(serverSideEx);
|
||||
throw new Exception("Consumer:INOUT Message Exchange status ERROR.\n" + exMsgBuff);
|
||||
} else {
|
||||
throw new Exception("Consumer:INOUT Message Exchange error. status: " + status);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,99 @@
|
|||
/*
|
||||
* BEGIN_HEADER - DO NOT EDIT
|
||||
*
|
||||
* The contents of this file are subject to the terms
|
||||
* of the Common Development and Distribution License
|
||||
* (the "License"). You may not use this file except
|
||||
* in compliance with the License.
|
||||
*
|
||||
* You can obtain a copy of the license at
|
||||
* https://open-esb.dev.java.net/public/CDDLv1.0.html.
|
||||
* See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*
|
||||
* When distributing Covered Code, include this CDDL
|
||||
* HEADER in each file and include the License file at
|
||||
* https://open-esb.dev.java.net/public/CDDLv1.0.html.
|
||||
* If applicable add the following below this CDDL HEADER,
|
||||
* with the fields enclosed by brackets "[]" replaced with
|
||||
* your own identifying information: Portions Copyright
|
||||
* [year] [name of copyright owner]
|
||||
*/
|
||||
|
||||
/*
|
||||
*
|
||||
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
*
|
||||
* END_HEADER - DO NOT EDIT
|
||||
*/
|
||||
/*
|
||||
* CamelSEInstaller.java
|
||||
*/
|
||||
package org.openesb.components.camelse;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.jbi.management.MBeanNames;
|
||||
import javax.management.ObjectName;
|
||||
import javax.management.StandardMBean;
|
||||
import org.openesb.components.camelse.CamelSEConfigMBean.CamelSEConfigMBeanImpl;
|
||||
import org.openesb.components.camelse.common.ComponentInstaller;
|
||||
import javax.jbi.JBIException;
|
||||
import javax.jbi.component.InstallationContext;
|
||||
|
||||
/**
|
||||
* This class extends the ComponentInstaller that implements the
|
||||
* javax.jbi.component.Bootstrap for a component installation contract.
|
||||
*
|
||||
* If the default implemenation of the javax.jbi.component.Bootstrap
|
||||
* in com.sun.jbi.sample.component.common.ComponentInstaller is not sufficient
|
||||
* for this components install, uninstall and upgrade requirements, override the
|
||||
* default implementation here to add component specific installation and upgrade
|
||||
* tasks such as initializing configuration mbean and creating resources specific
|
||||
* to component or upgrade workspace and service units during upgrading the component.
|
||||
*
|
||||
* @see javax.jbi.Bootstrap
|
||||
* @see com.sun.jbi.sample.component.common.ComponentInstaller
|
||||
* @author chikkala
|
||||
*/
|
||||
public class CamelSEInstaller extends ComponentInstaller {
|
||||
|
||||
/** Constructor to create the MyEngineInstaller. */
|
||||
public CamelSEInstaller() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doInit() throws JBIException {
|
||||
super.doInit();
|
||||
//// InstallationContext ctx = this.getInstallationContext();
|
||||
//// List classPaths = ctx.getClassPathElements();
|
||||
//// System.out.println("***** BEGIN CAMEL SE CLASS PATH ELEMENTS ******");
|
||||
//// for ( Object path : classPaths ) {
|
||||
//// System.out.println("CAMEL SE:ClassPathEl: " + path);
|
||||
//// }
|
||||
//// System.out.println("***** END CAMEL SE CLASS PATH ELEMENTS ******");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected StandardMBean createExtensionMBean() {
|
||||
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 (Exception ex) {
|
||||
Logger.getLogger(CamelSEInstaller.class.getName()).log(Level.SEVERE, null, ex);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ObjectName createExtensionMBeanName() {
|
||||
MBeanNames mbeanNames = this.getInstallationContext().getContext().getMBeanNames();
|
||||
return mbeanNames.createCustomComponentMBeanName(mbeanNames.COMPONENT_LIFE_CYCLE_EXTENSION);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,105 @@
|
|||
/*
|
||||
* BEGIN_HEADER - DO NOT EDIT
|
||||
*
|
||||
* The contents of this file are subject to the terms
|
||||
* of the Common Development and Distribution License
|
||||
* (the "License"). You may not use this file except
|
||||
* in compliance with the License.
|
||||
*
|
||||
* You can obtain a copy of the license at
|
||||
* https://open-esb.dev.java.net/public/CDDLv1.0.html.
|
||||
* See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*
|
||||
* When distributing Covered Code, include this CDDL
|
||||
* HEADER in each file and include the License file at
|
||||
* https://open-esb.dev.java.net/public/CDDLv1.0.html.
|
||||
* If applicable add the following below this CDDL HEADER,
|
||||
* with the fields enclosed by brackets "[]" replaced with
|
||||
* your own identifying information: Portions Copyright
|
||||
* [year] [name of copyright owner]
|
||||
*/
|
||||
|
||||
/*
|
||||
*
|
||||
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
*
|
||||
* END_HEADER - DO NOT EDIT
|
||||
*/
|
||||
/*
|
||||
* CamelSEProviderEndpoint.java
|
||||
*/
|
||||
|
||||
package org.openesb.components.camelse;
|
||||
|
||||
import org.openesb.components.camelse.camel.JBIBridgeEndpoint;
|
||||
import org.openesb.components.camelse.common.MessageExchangeHandler;
|
||||
import org.openesb.components.camelse.common.RuntimeHelper;
|
||||
import org.openesb.components.camelse.common.MessageExchangeListener;
|
||||
import org.openesb.components.camelse.common.deployment.ProviderEndpoint;
|
||||
import org.openesb.components.camelse.common.deployment.SUDescriptor;
|
||||
import javax.jbi.JBIException;
|
||||
import javax.jbi.messaging.ExchangeStatus;
|
||||
import javax.jbi.messaging.MessageExchange;
|
||||
import javax.wsdl.Definition;
|
||||
|
||||
/**
|
||||
* This class extends the ProviderEndpoint to implement component specific endpoint configuration.
|
||||
* It implements the MessageExchangeListener to receive message exchange notifications from the
|
||||
* MessageExchangeSupport fired by MessageExchangeReceiver and process it using a message exchange
|
||||
* handler.
|
||||
*
|
||||
* This endpoint is configured for a service provided by this component which can receive a xml
|
||||
* document and apply xslt transformation and send the results back in a InOut message exchange
|
||||
* to complete a service invocation on this endpoint.
|
||||
*
|
||||
* @author chikkala
|
||||
*/
|
||||
public class CamelSEProviderEndpoint extends ProviderEndpoint implements MessageExchangeListener {
|
||||
|
||||
/** Creates a new instance of XSLTProviderEndpoint */
|
||||
public CamelSEProviderEndpoint(SUDescriptor.Provides provides, Definition wsdlDef, CamelSEServiceUnit su) {
|
||||
super(provides, wsdlDef, su);
|
||||
}
|
||||
|
||||
public JBIBridgeEndpoint getCamelEndpoint(MessageExchange me) {
|
||||
CamelSEServiceUnit su = (CamelSEServiceUnit)this.getServiceUnit();
|
||||
return su.getCamelEndpoint(me);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doInit() throws JBIException {
|
||||
RuntimeHelper.getLogger().info("ProviderSEEndpoint:doInit called");
|
||||
CamelSEServiceUnit su = (CamelSEServiceUnit) this.getServiceUnit();
|
||||
//TODO: do any service impl specific initiaization
|
||||
}
|
||||
/**
|
||||
* creates the message exchange handler that will be used to process the message exchange
|
||||
* received for this endpoint.
|
||||
*/
|
||||
@Override
|
||||
public MessageExchangeHandler createMessageExchangeHandler() {
|
||||
return new CamelSEProviderMessageExchangeHandler(this);
|
||||
}
|
||||
/**
|
||||
* returns the implementation of the message exchange listener which the
|
||||
* MessageExchangeSupport invokes when a message exchange is received from delivery
|
||||
* channel by MessageExchangeReceiver.
|
||||
*/
|
||||
@Override
|
||||
protected MessageExchangeListener createMessageExchangeListener() {
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* implementation of the message exchange received method of the listener.
|
||||
*/
|
||||
public void messageExchangeReceived(ExchangeStatus status, MessageExchange me) {
|
||||
try {
|
||||
RuntimeHelper.getLogger().fine("MXListener.MessageExchangeReceived: with Status: " + status);
|
||||
processMessageExchangeWithHandler(status, me);
|
||||
// processMessageExchange(me);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,180 @@
|
|||
/*
|
||||
* BEGIN_HEADER - DO NOT EDIT
|
||||
*
|
||||
* The contents of this file are subject to the terms
|
||||
* of the Common Development and Distribution License
|
||||
* (the "License"). You may not use this file except
|
||||
* in compliance with the License.
|
||||
*
|
||||
* You can obtain a copy of the license at
|
||||
* https://open-esb.dev.java.net/public/CDDLv1.0.html.
|
||||
* See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*
|
||||
* When distributing Covered Code, include this CDDL
|
||||
* HEADER in each file and include the License file at
|
||||
* https://open-esb.dev.java.net/public/CDDLv1.0.html.
|
||||
* If applicable add the following below this CDDL HEADER,
|
||||
* with the fields enclosed by brackets "[]" replaced with
|
||||
* your own identifying information: Portions Copyright
|
||||
* [year] [name of copyright owner]
|
||||
*/
|
||||
|
||||
/*
|
||||
* @(#)CamelSEProviderMessageExchangeHandler.java
|
||||
*
|
||||
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
*
|
||||
* END_HEADER - DO NOT EDIT
|
||||
*/
|
||||
package org.openesb.components.camelse;
|
||||
|
||||
import javax.wsdl.Operation;
|
||||
|
||||
import org.openesb.components.camelse.common.AbstractMessageExchangeHandler;
|
||||
import org.openesb.components.camelse.common.RuntimeHelper;
|
||||
import org.openesb.components.camelse.common.wsdl.WSDL11JBIWrapper;
|
||||
import org.openesb.components.camelse.camel.JBIBridgeEndpoint;
|
||||
import java.io.StringReader;
|
||||
import java.util.logging.Logger;
|
||||
import javax.jbi.JBIException;
|
||||
import javax.jbi.messaging.DeliveryChannel;
|
||||
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.xml.namespace.QName;
|
||||
import javax.xml.transform.Source;
|
||||
|
||||
/**
|
||||
* This class extends the AbstractMessageExchangeHandler to implement the component specific
|
||||
* message exchange processing on the provider side in a service engine.
|
||||
*
|
||||
* @author chikkala
|
||||
*/
|
||||
public class CamelSEProviderMessageExchangeHandler extends AbstractMessageExchangeHandler {
|
||||
private static final String XMLNS_NS = "http://www.w3.org/2000/xmlns/";
|
||||
private CamelSEProviderEndpoint mEndpoint;
|
||||
|
||||
/** Creates a new instance of ProviderSEMXHandler */
|
||||
public CamelSEProviderMessageExchangeHandler(CamelSEProviderEndpoint endpoint) {
|
||||
this.mEndpoint = endpoint;
|
||||
}
|
||||
|
||||
protected Logger getLogger() {
|
||||
return this.mEndpoint.getLogger();
|
||||
}
|
||||
|
||||
protected DeliveryChannel getDeliveryChannel() {
|
||||
return this.mEndpoint.getDeliveryChannel();
|
||||
}
|
||||
|
||||
protected void validateMessageExchange() throws MessagingException {
|
||||
MessageExchange msgExchange = this.getMessageExchange();
|
||||
|
||||
if (this.getMessageExchange() == null) {
|
||||
throw new MessagingException("MessageExchange Object is null in MessageExchageHandler");
|
||||
}
|
||||
|
||||
if (MessageExchange.Role.CONSUMER.equals(msgExchange.getRole())) {
|
||||
throw new MessagingException("Provider Message Exchange Handler can not have MessageExchange with CONSUMER Role");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void processError(Exception ex) {
|
||||
MessageExchange msgExchange = this.getMessageExchange();
|
||||
Exception errEx = msgExchange.getError(); // get the error and print
|
||||
|
||||
RuntimeHelper.getLogger().info(
|
||||
" Message Exchange Provider received Error: " + errEx.getMessage());
|
||||
msgExchange.getError().printStackTrace();
|
||||
}
|
||||
|
||||
protected void processDone() {
|
||||
MessageExchange msgExchange = this.getMessageExchange();
|
||||
RuntimeHelper.getLogger().info(" Message Exchange Provider received DONE :" +
|
||||
" END of service invocation");
|
||||
}
|
||||
|
||||
protected void processFault(Fault fault) {
|
||||
MessageExchange msgExchange = this.getMessageExchange();
|
||||
RuntimeHelper.logError(" Message Exchange Provider Handler can not receive Fault on Provider side");
|
||||
}
|
||||
|
||||
protected void processMessage() {
|
||||
try {
|
||||
MessageExchange me = this.getMessageExchange();
|
||||
if (me instanceof InOnly) {
|
||||
processMessageOnProvider((InOnly) me);
|
||||
} else if (me instanceof InOut) {
|
||||
processMessageOnProvider((InOut) me);
|
||||
} else {
|
||||
throw new JBIException("Unsupported message exchage " + me);
|
||||
}
|
||||
// processInMessageOnProvider((InOut)this.getMessageExchange());
|
||||
// processInOnlyMessageOnProvider((InOnly)this.getMessageExchange());
|
||||
} catch (JBIException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* synchronous processing of the inonly message exchange.
|
||||
* @param inOnlyExchange
|
||||
* @throws javax.jbi.JBIException
|
||||
*/
|
||||
protected void processMessageOnProvider(InOnly inOnlyExchange) throws JBIException {
|
||||
RuntimeHelper.getLogger().fine("Processing inonly message exchange" + inOnlyExchange);
|
||||
|
||||
JBIBridgeEndpoint ep = this.mEndpoint.getCamelEndpoint(inOnlyExchange);
|
||||
if (ep == null) {
|
||||
throw new JBIException("Can not find Camel Endpoint for " + inOnlyExchange);
|
||||
}
|
||||
QName operationQName = inOnlyExchange.getOperation();
|
||||
Operation wsdlOperation = this.mEndpoint.getWSDLOperation(operationQName);
|
||||
JBIWrapperUtil.removeJBIWrapperFromInMessage(wsdlOperation, inOnlyExchange.getInMessage());
|
||||
ep.getConsumer().processJBIMessageExchange(inOnlyExchange);
|
||||
|
||||
this.sendDone();
|
||||
}
|
||||
|
||||
/**
|
||||
* synchronour processing of the inout message exchange.
|
||||
* @param inOutExchange
|
||||
* @throws javax.jbi.JBIException
|
||||
*/
|
||||
protected void processMessageOnProvider(InOut inOutExchange) throws JBIException {
|
||||
RuntimeHelper.getLogger().fine("Processing In Message on Provider side " + inOutExchange);
|
||||
// invoke the service operation
|
||||
try {
|
||||
QName opName = inOutExchange.getOperation();
|
||||
QName svcName = inOutExchange.getEndpoint().getServiceName();
|
||||
// process
|
||||
JBIBridgeEndpoint ep = this.mEndpoint.getCamelEndpoint(inOutExchange);
|
||||
if (ep == null) {
|
||||
throw new JBIException("Can not find Camel Endpoint for " + inOutExchange);
|
||||
}
|
||||
QName operationQName = inOutExchange.getOperation();
|
||||
Operation wsdlOperation = this.mEndpoint.getWSDLOperation(operationQName);
|
||||
JBIWrapperUtil.removeJBIWrapperFromInMessage(wsdlOperation, inOutExchange.getInMessage());
|
||||
WSDL11JBIWrapper outWrapper = WSDL11JBIWrapper.createOutputWrapper(wsdlOperation);
|
||||
|
||||
ep.getConsumer().processJBIMessageExchange(inOutExchange, outWrapper);
|
||||
|
||||
} catch (Exception ex) {
|
||||
// exception invoking the operation. so, set exception text as fault content.
|
||||
ex.printStackTrace();
|
||||
String faultText = RuntimeHelper.getExceptionAsXmlText(ex);
|
||||
Source faultContent = RuntimeHelper.createDOMSource(new StringReader(faultText));
|
||||
Fault fault = inOutExchange.createFault();
|
||||
inOutExchange.setFault(fault);
|
||||
fault.setContent(faultContent); // may need to normalize the content.
|
||||
}
|
||||
// send out or fault message.
|
||||
// this.getDeliveryChannel().sendSync(inOutExchange, SEND_SYNC_TIMEOUT);
|
||||
this.send();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
* BEGIN_HEADER - DO NOT EDIT
|
||||
*
|
||||
* The contents of this file are subject to the terms
|
||||
* of the Common Development and Distribution License
|
||||
* (the "License"). You may not use this file except
|
||||
* in compliance with the License.
|
||||
*
|
||||
* You can obtain a copy of the license at
|
||||
* https://open-esb.dev.java.net/public/CDDLv1.0.html.
|
||||
* See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*
|
||||
* When distributing Covered Code, include this CDDL
|
||||
* HEADER in each file and include the License file at
|
||||
* https://open-esb.dev.java.net/public/CDDLv1.0.html.
|
||||
* If applicable add the following below this CDDL HEADER,
|
||||
* with the fields enclosed by brackets "[]" replaced with
|
||||
* your own identifying information: Portions Copyright
|
||||
* [year] [name of copyright owner]
|
||||
*/
|
||||
|
||||
/*
|
||||
* @(#)CamelSERuntime.java
|
||||
*
|
||||
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
*
|
||||
* END_HEADER - DO NOT EDIT
|
||||
*/
|
||||
|
||||
package org.openesb.components.camelse;
|
||||
|
||||
import org.openesb.components.camelse.common.ComponentRuntime;
|
||||
import javax.jbi.component.ComponentLifeCycle;
|
||||
import javax.jbi.component.ServiceUnitManager;
|
||||
|
||||
/**
|
||||
* This class extends the ComponentRuntime that implements javax.jbi.component.Component
|
||||
* interface required for the component contract at runtime.
|
||||
*
|
||||
* This class provides the component specific ComponentLifeCycle implementation
|
||||
* as well as the component specific ServiceUnitManager implementation.
|
||||
*
|
||||
* Add any additional component runtime specific functionality here.
|
||||
*
|
||||
* @see javax.jbi.component.Component
|
||||
* @see com.sun.jbi.sample.component.common.ComponentRuntime
|
||||
* @see com.sun.jbi.sample.component.common.BasicComponentLifecycle
|
||||
* @see com.sun.jbi.sample.component.common.deployment.AbstractServiceUnitManager
|
||||
* @author chikkala
|
||||
*/
|
||||
public class CamelSERuntime extends ComponentRuntime {
|
||||
|
||||
/** Creates a new instance of MyEngineRuntime */
|
||||
public CamelSERuntime() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* overriding the parent's createComponentLifeCycle to create
|
||||
* component specific component lifecycle implementation.
|
||||
*/
|
||||
@Override
|
||||
protected ComponentLifeCycle createComponentLifeCycle() {
|
||||
return new CamelSEComponentLifeCycle(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* overrides the parent's createServiceUnitManager to create component
|
||||
* specific service unit manager
|
||||
*/
|
||||
@Override
|
||||
protected ServiceUnitManager createServiceUnitManager() {
|
||||
return new CamelSESUManager(this);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
* BEGIN_HEADER - DO NOT EDIT
|
||||
*
|
||||
* The contents of this file are subject to the terms
|
||||
* of the Common Development and Distribution License
|
||||
* (the "License"). You may not use this file except
|
||||
* in compliance with the License.
|
||||
*
|
||||
* You can obtain a copy of the license at
|
||||
* https://open-esb.dev.java.net/public/CDDLv1.0.html.
|
||||
* See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*
|
||||
* When distributing Covered Code, include this CDDL
|
||||
* HEADER in each file and include the License file at
|
||||
* https://open-esb.dev.java.net/public/CDDLv1.0.html.
|
||||
* If applicable add the following below this CDDL HEADER,
|
||||
* with the fields enclosed by brackets "[]" replaced with
|
||||
* your own identifying information: Portions Copyright
|
||||
* [year] [name of copyright owner]
|
||||
*/
|
||||
|
||||
/*
|
||||
* @(#)CamelSESUManager.java
|
||||
*
|
||||
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
*
|
||||
* END_HEADER - DO NOT EDIT
|
||||
*/
|
||||
|
||||
|
||||
package org.openesb.components.camelse;
|
||||
|
||||
import org.openesb.components.camelse.common.RuntimeHelper;
|
||||
import org.openesb.components.camelse.common.deployment.AbstractServiceUnitManager;
|
||||
import org.openesb.components.camelse.common.deployment.ServiceUnit;
|
||||
import java.util.logging.Logger;
|
||||
import javax.jbi.management.DeploymentException;
|
||||
|
||||
/**
|
||||
* This class extends the AbstractServiceUnitManager to implement component specific
|
||||
* service unit manager by creating the component specific ServiceUnit implementation.
|
||||
* @see com.sun.jbi.sample.component.common.deployment.AbstractServiceUnitManager
|
||||
* @see com.sun.jbi.sample.component.common.deployment.ServiceUnit
|
||||
* @author chikkala
|
||||
*/
|
||||
public class CamelSESUManager extends AbstractServiceUnitManager {
|
||||
|
||||
private CamelSERuntime mRuntime;
|
||||
|
||||
/** Creates a new instance of CamelSESUManager */
|
||||
public CamelSESUManager(CamelSERuntime compRuntime) {
|
||||
super();
|
||||
this.mRuntime = compRuntime;
|
||||
}
|
||||
protected Logger getLogger() {
|
||||
return RuntimeHelper.getLogger();
|
||||
}
|
||||
|
||||
protected String getComponentName() {
|
||||
return RuntimeHelper.getComponentName();
|
||||
}
|
||||
//TODO implement CamelSEServiceUnit
|
||||
protected ServiceUnit createServiceUnit(String suName, String suRootPath) throws DeploymentException {
|
||||
return new CamelSEServiceUnit(suName, suRootPath, this.mRuntime);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,323 @@
|
|||
/*
|
||||
* BEGIN_HEADER - DO NOT EDIT
|
||||
*
|
||||
* The contents of this file are subject to the terms
|
||||
* of the Common Development and Distribution License
|
||||
* (the "License"). You may not use this file except
|
||||
* in compliance with the License.
|
||||
*
|
||||
* You can obtain a copy of the license at
|
||||
* https://open-esb.dev.java.net/public/CDDLv1.0.html.
|
||||
* See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*
|
||||
* When distributing Covered Code, include this CDDL
|
||||
* HEADER in each file and include the License file at
|
||||
* https://open-esb.dev.java.net/public/CDDLv1.0.html.
|
||||
* If applicable add the following below this CDDL HEADER,
|
||||
* with the fields enclosed by brackets "[]" replaced with
|
||||
* your own identifying information: Portions Copyright
|
||||
* [year] [name of copyright owner]
|
||||
*/
|
||||
/*
|
||||
* @(#)CamelSEServiceUnit.java
|
||||
*
|
||||
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
*
|
||||
* END_HEADER - DO NOT EDIT
|
||||
*/
|
||||
package org.openesb.components.camelse;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import javax.jbi.messaging.MessageExchange;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.apache.camel.CamelContext;
|
||||
import org.openesb.components.camelse.camel.JBIBridgeComponent;
|
||||
import org.openesb.components.camelse.camel.JBIBridgeEndpoint;
|
||||
import org.openesb.components.camelse.common.RuntimeHelper;
|
||||
import org.openesb.components.camelse.common.deployment.ConsumerEndpoint;
|
||||
import org.openesb.components.camelse.common.deployment.SUDescriptor.Consumes;
|
||||
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;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.jbi.management.DeploymentException;
|
||||
import javax.wsdl.Definition;
|
||||
|
||||
/**
|
||||
* This class extends the ServiceUnit to implement the component specific service unit processing.
|
||||
* It creates the component specific ProviderEndpoint implementation to configure the service
|
||||
* provider endpoint on this component deployed in the service unit. It also processes the deployment
|
||||
* artifacts that are specific to the service provided by the component.
|
||||
*
|
||||
* @author chikkala
|
||||
*/
|
||||
public class CamelSEServiceUnit extends ServiceUnit {
|
||||
|
||||
private CamelSERuntime mRuntime;
|
||||
private Object mCamelMainObj;
|
||||
private Class mCamelMainClazz;
|
||||
|
||||
/** Creates a new instance of CamelSEServiceUnit */
|
||||
public CamelSEServiceUnit(String suName, String suRootPath, CamelSERuntime runtime) {
|
||||
super(suName, suRootPath);
|
||||
this.mRuntime = runtime;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ProviderEndpoint createProviderEndpoint(Provides provides, Definition wsdlDef) {
|
||||
return new CamelSEProviderEndpoint(provides, wsdlDef, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ConsumerEndpoint createConsumerEndpoint(Consumes consumes, Definition wsdlDef) {
|
||||
return new CamelSEConsumerEndpoint(consumes, wsdlDef, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* load and validates the component specific deployment artifacts. It loads the xsltmap
|
||||
* properties into XSLTFileLocator which will be used to find the xslt file corresponding
|
||||
* to a service operation.
|
||||
*/
|
||||
@Override
|
||||
protected void loadOtherArtifacts() throws DeploymentException {
|
||||
super.loadOtherArtifacts();
|
||||
// load any component specific service unit artifacts
|
||||
}
|
||||
private List<String> getPaths(String baseDir, String pattern) {
|
||||
List<String> list = new ArrayList<String>();
|
||||
File baseFile = new File(baseDir);
|
||||
if (!baseFile.exists()) {
|
||||
return list;
|
||||
}
|
||||
//TODO: check the pattern for wildcards also.
|
||||
String[] libs = pattern.split(",");
|
||||
for ( String lib : libs) {
|
||||
File path = new File(baseFile, lib);
|
||||
if ( path.exists()) {
|
||||
list.add(path.getAbsolutePath());
|
||||
} else {
|
||||
RuntimeHelper.logDebug("Path for SU classpath does not exist " + path.getPath());
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
/**
|
||||
* Additional Camel libraries configured using component configuration.
|
||||
* compute the list of libraries from includes and exlcudes of the camel
|
||||
* libraries configured.
|
||||
* @return
|
||||
*/
|
||||
private List<URL> getAdditionalCamelClassPath() {
|
||||
List<URL> cp = new ArrayList<URL>();
|
||||
CamelSEConfigMBean configMBean = null;
|
||||
try {
|
||||
//TODO: we can get the configuration via mbean lookup and can avoid runtime dependency.
|
||||
CamelSEComponentLifeCycle lc = (CamelSEComponentLifeCycle) this.mRuntime.getLifeCycle();
|
||||
configMBean = lc.getConfigMBeanImpl();
|
||||
} catch (Exception ex) {
|
||||
RuntimeHelper.logDebug(ex);
|
||||
}
|
||||
if ( configMBean == null ) {
|
||||
return cp;
|
||||
}
|
||||
String camelHome = configMBean.getCamelHome();
|
||||
String includes = configMBean.getIncludeCamelLibs();
|
||||
String excludes = configMBean.getExcludeCamelLibs();
|
||||
|
||||
if ( camelHome == null || camelHome.trim().length() == 0 ) {
|
||||
return cp;
|
||||
}
|
||||
if ( includes == null || includes.trim().length() == 0 ) {
|
||||
return cp;
|
||||
}
|
||||
if ( includes == null || includes.trim().length() == 0 ) {
|
||||
return cp;
|
||||
}
|
||||
List<String> includePaths = getPaths(camelHome, includes);
|
||||
List<String> excludePaths = getPaths(camelHome, excludes);
|
||||
includePaths.removeAll(excludePaths);
|
||||
for ( String path : includePaths ) {
|
||||
try {
|
||||
URL pathURL = (new File(path)).toURL();
|
||||
cp.add(pathURL);
|
||||
} catch (MalformedURLException ex) {
|
||||
Logger.getLogger(CamelSEServiceUnit.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
return cp;
|
||||
}
|
||||
|
||||
/**
|
||||
* classpath url for the camel application code. currently the su root.
|
||||
* //TODO: this may include application specific libraries
|
||||
* @return
|
||||
*/
|
||||
private List<URL> getCamelAppClassPath() {
|
||||
List<URL> cp = new ArrayList<URL>();
|
||||
try {
|
||||
String path = this.getSURootPath();
|
||||
URL pathURL = (new File(path)).toURL();
|
||||
cp.add(pathURL);
|
||||
} catch (MalformedURLException ex) {
|
||||
Logger.getLogger(CamelSEServiceUnit.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
return cp;
|
||||
}
|
||||
|
||||
/**
|
||||
* return the classloader for the camel app including additional camel libraries
|
||||
* configured using config mbean.
|
||||
* @return
|
||||
*/
|
||||
private ClassLoader createCamelSUClassLoader() {
|
||||
List<URL> addlCP = getAdditionalCamelClassPath();
|
||||
List<URL> appCP = getCamelAppClassPath();
|
||||
List<URL> camelCP = new ArrayList<URL>();
|
||||
//TODO: add the file in the same order they were in the two lists.
|
||||
camelCP.addAll(addlCP);
|
||||
camelCP.addAll(appCP);
|
||||
|
||||
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(",");
|
||||
}
|
||||
RuntimeHelper.logDebug(buff);
|
||||
|
||||
return loader;
|
||||
}
|
||||
|
||||
private void startCamel(ClassLoader loader) {
|
||||
RuntimeHelper.getLogger().fine("Loading camel in su classloader " + loader);
|
||||
try {
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
private void startCamelInThreadContext() {
|
||||
ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
|
||||
try {
|
||||
ClassLoader newLoader = createCamelSUClassLoader();
|
||||
Thread.currentThread().setContextClassLoader(newLoader);
|
||||
startCamel(newLoader);
|
||||
} finally {
|
||||
Thread.currentThread().setContextClassLoader(oldClassLoader);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doStart() throws DeploymentException {
|
||||
try {
|
||||
super.doStart();
|
||||
startCamelInThreadContext();
|
||||
updateJBIEndpointBinding();
|
||||
} catch (Exception ex) {
|
||||
RuntimeHelper.logError(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doStop() throws DeploymentException {
|
||||
try {
|
||||
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);
|
||||
}
|
||||
super.doStop();
|
||||
}
|
||||
|
||||
private void updateJBIEndpointBinding() {
|
||||
RuntimeHelper.getLogger().fine("### Updating JBIEndpoint Binding for Consumers");
|
||||
Collection<ConsumerEndpoint> list = this.getConsumerEndpoints();
|
||||
for (ConsumerEndpoint jbiConsumerEP : list) {
|
||||
QName servQName = jbiConsumerEP.getService().getServiceName();
|
||||
String epName = jbiConsumerEP.getService().getEndpointName();
|
||||
List<CamelContext> ctxList = getCamelContexts();
|
||||
for (CamelContext ctx : ctxList) {
|
||||
HashMap<String,JBIBridgeEndpoint> epMap = JBIBridgeComponent.findEndpoints(ctx, servQName, epName);
|
||||
for (JBIBridgeEndpoint jbiBridgeEP : epMap.values() ) {
|
||||
if ( jbiBridgeEP != null ) {
|
||||
RuntimeHelper.getLogger().fine("Updating JBIEndpoint for camelEP " + jbiBridgeEP.getEndpointUri());
|
||||
jbiBridgeEP.setJbiConsumerEP((CamelSEConsumerEndpoint)jbiConsumerEP);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<CamelContext> getCamelContexts() {
|
||||
List<CamelContext> ctxList = new ArrayList<CamelContext>();
|
||||
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;
|
||||
}
|
||||
|
||||
public JBIBridgeEndpoint getCamelEndpoint(QName servQName, String epName, String operation) {
|
||||
JBIBridgeEndpoint camelEP = null;
|
||||
|
||||
List<CamelContext> ctxList = getCamelContexts();
|
||||
// RuntimeHelper.logDebug("Searching for JBI Camel Endpoint with URI " + epURI);
|
||||
|
||||
for (CamelContext ctx : ctxList) {
|
||||
RuntimeHelper.logDebug("Searching for JBI Camel EP in CamelContext " + ctx.getName());
|
||||
camelEP = JBIBridgeComponent.findEndpoint(ctx, servQName, epName, operation);
|
||||
if (camelEP != null) {
|
||||
RuntimeHelper.logDebug("Found CamelEP");
|
||||
break;
|
||||
}
|
||||
}
|
||||
return camelEP;
|
||||
}
|
||||
|
||||
public JBIBridgeEndpoint getCamelEndpoint(MessageExchange me) {
|
||||
QName servQName = me.getEndpoint().getServiceName();
|
||||
String epName = me.getEndpoint().getEndpointName();
|
||||
QName opQName = me.getOperation();
|
||||
String operation = null;
|
||||
if ( opQName != null ) {
|
||||
operation = opQName.getLocalPart();
|
||||
}
|
||||
JBIBridgeEndpoint ep = null;
|
||||
ep = getCamelEndpoint(servQName, epName, operation);
|
||||
if ( ep == null) {
|
||||
// try the default endpoint with operation=null;
|
||||
ep = getCamelEndpoint(servQName, epName, null);
|
||||
}
|
||||
return ep;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,254 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package org.openesb.components.camelse;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.jbi.messaging.MessagingException;
|
||||
import javax.jbi.messaging.NormalizedMessage;
|
||||
import javax.wsdl.Input;
|
||||
import javax.wsdl.Message;
|
||||
import javax.wsdl.Operation;
|
||||
import javax.wsdl.Output;
|
||||
import javax.wsdl.Part;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
import org.openesb.components.camelse.common.RuntimeHelper;
|
||||
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;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author chikkala
|
||||
*/
|
||||
public class JBIWrapperUtil {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(JBIWrapperUtil.class.getName());
|
||||
|
||||
/**
|
||||
* removes the jbi wrapper elements from output if it is not a multipart message. If it is
|
||||
* a multipart message, it returns the message as it is with the wrapper.
|
||||
* @param operation
|
||||
* @param outMsg
|
||||
* @return
|
||||
* @throws javax.jbi.messaging.MessagingException
|
||||
*/
|
||||
public static DOMSource removeJBIWrapperFromOutput(Operation operation, NormalizedMessage outMsg)
|
||||
throws MessagingException {
|
||||
try {
|
||||
|
||||
WSDL11JBIWrapper jbiWrapper = WSDL11JBIWrapper.sourceToWrapper(
|
||||
RuntimeHelper.sourceToDOMSource(outMsg.getContent()) );
|
||||
Output output = operation.getOutput();
|
||||
Message wsdlMsg = output.getMessage();
|
||||
List<Element> msgParts = JBIWrapperUtil.getMessagePartsFromJBIWrapper(jbiWrapper, wsdlMsg);
|
||||
if ( msgParts.size() > 1 ) {
|
||||
// just return the wrapped message
|
||||
return jbiWrapper.toDOMSource();
|
||||
}
|
||||
|
||||
Document msgDoc = jbiWrapper.getDocumentBuilder().newDocument();
|
||||
msgDoc.appendChild(msgDoc.importNode(msgParts.get(0), true));
|
||||
|
||||
DOMSource unwrappedSource = new DOMSource(msgDoc);
|
||||
return unwrappedSource;
|
||||
} catch (DOMException ex) {
|
||||
throw new MessagingException(ex);
|
||||
} catch (ParserConfigurationException ex) {
|
||||
throw new MessagingException(ex);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* normalizes the input message to jbi normalized message
|
||||
*/
|
||||
public static void addJBIWrapperToInput(Operation operation, NormalizedMessage normMsg,
|
||||
DOMSource msgContent) throws MessagingException {
|
||||
try {
|
||||
WSDL11JBIWrapper msgWrapper = WSDL11JBIWrapper.sourceToWrapper(msgContent);
|
||||
if ( msgWrapper != null ) {
|
||||
// already wrappred element. For multipart msg, a jbi wrapped content expected.
|
||||
// so set the content directly and return.
|
||||
//TODO: validate the msgContent against the wsdl input content
|
||||
LOG.fine("*** Wrapped content is passed as Input");
|
||||
if (LOG.isLoggable(Level.FINE)) {
|
||||
LOG.fine(RuntimeHelper.readFromDOMSource(msgContent).toString());
|
||||
}
|
||||
normMsg.setContent(msgContent);
|
||||
return;
|
||||
}
|
||||
|
||||
WSDL11JBIWrapper jbiWrapper = WSDL11JBIWrapper.createInputWrapper(operation);
|
||||
Input input = operation.getInput();
|
||||
Message wsdlMsg = input.getMessage();
|
||||
//TODO: get the binding input extension here if needed.
|
||||
Element msgRoot = RuntimeHelper.getElement(msgContent);
|
||||
|
||||
List<Element> msgParts = new ArrayList<Element>();
|
||||
msgParts.add(msgRoot);
|
||||
|
||||
addMessagePartsToJBIWrapper(jbiWrapper, wsdlMsg, msgParts);
|
||||
|
||||
DOMSource wrappedContent = jbiWrapper.toDOMSource();
|
||||
normMsg.setContent(wrappedContent);
|
||||
} catch (ParserConfigurationException ex) {
|
||||
throw new MessagingException(ex);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* create and add message parts to the jbiWrapper according to the abstract message model. This
|
||||
* method assumes that the each element in the msgParts list passed to it is mapped to the part
|
||||
* of the abstract wsdl message and uses the type or element attribute of the abstract message to
|
||||
* determine whether the element is actual part element or a wrapped part type.
|
||||
* Use this method in normalizing the concrete protocol specific message to jbi wrapper message.
|
||||
* @param jbiWrapper object that holds the jbi wrapper information.
|
||||
* @param wsdlMsg abstract message from the wsdl definition
|
||||
* @param msgParts actual message parts from the concrete message
|
||||
*/
|
||||
public static void addMessagePartsToJBIWrapper(WSDL11JBIWrapper jbiWrapper, Message wsdlMsg, List<Element> msgParts) throws MessagingException {
|
||||
List wsdlParts = wsdlMsg.getOrderedParts(null);
|
||||
for ( int i=0; i < wsdlParts.size(); ++i ) {
|
||||
Part wsdlPart = (Part) wsdlParts.get(i);
|
||||
if ( i >= msgParts.size() ) {
|
||||
throw new MessagingException("missing message content for part " + wsdlPart.getName());
|
||||
}
|
||||
Element msgPart = msgParts.get(i);
|
||||
if ( wsdlPart.getElementName() != null ) {
|
||||
jbiWrapper.appendPart(msgPart);
|
||||
} else {
|
||||
// it is type.
|
||||
// check the element name is same as part
|
||||
if ( !wsdlPart.getName().equals(msgPart.getLocalName()) ) {
|
||||
throw new MessagingException("mismatched message content for part " + wsdlPart.getName());
|
||||
}
|
||||
if ( !wsdlMsg.getQName().getNamespaceURI().equals(msgPart.getNamespaceURI()) ) {
|
||||
throw new MessagingException("mismatched message content namespace for part " + wsdlPart.getName());
|
||||
}
|
||||
// check the content is text or element.
|
||||
List<Element> partContent = JBIWrapperUtil.getChildElements(msgPart);
|
||||
if ( partContent.size() > 0 ) {
|
||||
// add content as part elements
|
||||
jbiWrapper.appendPart(partContent);
|
||||
} else {
|
||||
// add the content as text
|
||||
jbiWrapper.appendPart(msgPart.getTextContent());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* removes the jbi wrpper elements from the Normalized message if it is not a multipart message. If
|
||||
* it is multipart message, it leaves the jbi wrapper elements.
|
||||
* @param operation
|
||||
* @param inMsg
|
||||
* @throws javax.jbi.messaging.MessagingException
|
||||
*/
|
||||
public static void removeJBIWrapperFromInMessage(Operation operation, NormalizedMessage inMsg)
|
||||
throws MessagingException {
|
||||
try {
|
||||
DOMSource inContent = RuntimeHelper.sourceToDOMSource(inMsg.getContent());
|
||||
|
||||
WSDL11JBIWrapper jbiWrapper = WSDL11JBIWrapper.sourceToWrapper(inContent);
|
||||
Input input = operation.getInput();
|
||||
Message wsdlMsg = input.getMessage();
|
||||
List<Element> msgParts = JBIWrapperUtil.getMessagePartsFromJBIWrapper(jbiWrapper, wsdlMsg);
|
||||
if ( msgParts.size() > 1 ) {
|
||||
// don't change the inMessage as it is multi-part and jbiwrapper is what we
|
||||
// return in that case.
|
||||
return;
|
||||
}
|
||||
Document msgDoc = jbiWrapper.getDocumentBuilder().newDocument();
|
||||
msgDoc.appendChild(msgDoc.importNode(msgParts.get(0), true));
|
||||
|
||||
DOMSource unwrappedSource = new DOMSource(msgDoc);
|
||||
inMsg.setContent(unwrappedSource);
|
||||
|
||||
} catch (DOMException ex) {
|
||||
throw new MessagingException(ex);
|
||||
} catch (ParserConfigurationException ex) {
|
||||
throw new MessagingException(ex);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* extracts the message parts from the jbiWrapper according to the abstract wsdl message
|
||||
* definition passed to it. Use this method in denormalizing the jbi wrapper message into the
|
||||
* binding protocol specific concrete message.
|
||||
* @param jbiWrapper jbi wrapper object that contains message parts and the message type information.
|
||||
* @param wsdlMsg abstract wsdl message definition to use in constructing the part elements.
|
||||
*/
|
||||
public static List<Element> getMessagePartsFromJBIWrapper(WSDL11JBIWrapper jbiWrapper, Message wsdlMsg)
|
||||
throws MessagingException, ParserConfigurationException {
|
||||
|
||||
List<Element> msgParts = new ArrayList<Element>();
|
||||
int jbiPartCount = jbiWrapper.getPartCount();
|
||||
List wsdlParts = wsdlMsg.getOrderedParts(null);
|
||||
QName msgType = jbiWrapper.getType();
|
||||
if (!wsdlMsg.getQName().getNamespaceURI().equals(msgType.getNamespaceURI())) {
|
||||
throw new MessagingException("Namespace mismatch between jbi wrapper message type and wsdl message");
|
||||
}
|
||||
Document newDoc = jbiWrapper.getDocumentBuilder().newDocument();
|
||||
for ( int i=0; i < wsdlParts.size(); ++i ) {
|
||||
Part wsdlPart = (Part) wsdlParts.get(i);
|
||||
if ( i >= jbiPartCount ) {
|
||||
throw new MessagingException("missing message content for part " + wsdlPart.getName());
|
||||
}
|
||||
if ( wsdlPart.getElementName() != null ) {
|
||||
msgParts.add(jbiWrapper.getPartAsElement(i));
|
||||
} else {
|
||||
// it is type. create a new element for a typed part
|
||||
// check the element name is same as part
|
||||
String prefix = msgType.getPrefix();
|
||||
String nsURI = msgType.getNamespaceURI();
|
||||
String localName = wsdlPart.getName();
|
||||
Element partEl = newDoc.createElementNS(nsURI, prefix + ":" + localName);
|
||||
partEl.setAttributeNS(WSDL11JBIWrapper.XMLNS_NS, "xmlns:"+prefix, nsURI);
|
||||
NodeList partContent = jbiWrapper.getPart(i);
|
||||
appendChildren(partEl, partContent, newDoc, true);
|
||||
msgParts.add(partEl);
|
||||
}
|
||||
}
|
||||
return msgParts;
|
||||
}
|
||||
/**
|
||||
* utility method that can append the nodeList passed to it to the element children.
|
||||
* @param el element node to which the nodeList should be appended
|
||||
* @param doc the document object that should be used to import the nodeList
|
||||
* @param importNode true if the nodeList should be imported while appending the nodeList to the
|
||||
* element children. false if no import is necessary.
|
||||
*/
|
||||
public static void appendChildren(Element el, NodeList nodeList, Document doc, boolean importNode) {
|
||||
|
||||
for ( int pIdx = 0; pIdx < nodeList.getLength(); ++pIdx) {
|
||||
Node node = nodeList.item(pIdx);
|
||||
if ( importNode ) {
|
||||
node = doc.importNode(node, true);
|
||||
}
|
||||
el.appendChild(node);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @param el element from which to extract the child elements
|
||||
* @return List<Element> list of child Element nodes.
|
||||
*/
|
||||
public static List<Element> getChildElements(Element el) {
|
||||
List<Element> list = new ArrayList<Element>();
|
||||
NodeList nodeList = el.getChildNodes();
|
||||
for ( int i=0; i < nodeList.getLength(); ++i) {
|
||||
Node node = nodeList.item(i);
|
||||
if (!(node instanceof Element) ){
|
||||
continue;
|
||||
}
|
||||
list.add((Element)node);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,436 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.openesb.components.camelse.camel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import org.apache.camel.CamelContext;
|
||||
import org.apache.camel.Endpoint;
|
||||
import org.apache.camel.Exchange;
|
||||
import org.apache.camel.ExchangePattern;
|
||||
import org.apache.camel.Message;
|
||||
import org.apache.camel.impl.MessageSupport;
|
||||
import org.apache.camel.spi.Synchronization;
|
||||
import org.apache.camel.spi.UnitOfWork;
|
||||
import org.apache.camel.util.ExchangeHelper;
|
||||
import org.apache.camel.util.ObjectHelper;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Vishnu
|
||||
*/
|
||||
public abstract class JBIAbstractExchange implements Exchange{
|
||||
|
||||
|
||||
protected final CamelContext context;
|
||||
private Map<String, Object> properties;
|
||||
private Message in;
|
||||
private Message out;
|
||||
private Exception exception;
|
||||
private String exchangeId;
|
||||
private UnitOfWork unitOfWork;
|
||||
private ExchangePattern pattern;
|
||||
private Endpoint fromEndpoint;
|
||||
private String fromRouteId;
|
||||
private List<Synchronization> onCompletions;
|
||||
|
||||
public JBIAbstractExchange(CamelContext context) {
|
||||
this(context, ExchangePattern.InOnly);
|
||||
}
|
||||
|
||||
public JBIAbstractExchange(CamelContext context, ExchangePattern pattern) {
|
||||
this.context = context;
|
||||
this.pattern = pattern;
|
||||
}
|
||||
|
||||
public JBIAbstractExchange(Exchange parent) {
|
||||
this(parent.getContext(), parent.getPattern());
|
||||
this.fromEndpoint = parent.getFromEndpoint();
|
||||
this.fromRouteId = parent.getFromRouteId();
|
||||
this.unitOfWork = parent.getUnitOfWork();
|
||||
}
|
||||
|
||||
public JBIAbstractExchange(Endpoint fromEndpoint) {
|
||||
this(fromEndpoint, ExchangePattern.InOnly);
|
||||
}
|
||||
|
||||
public JBIAbstractExchange(Endpoint fromEndpoint, ExchangePattern pattern) {
|
||||
this(fromEndpoint.getCamelContext(), pattern);
|
||||
this.fromEndpoint = fromEndpoint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Exchange[" + (out == null ? in : out) + "]";
|
||||
}
|
||||
|
||||
public Exchange copy() {
|
||||
JBIAbstractExchange exchange = newInstance();
|
||||
|
||||
if (hasProperties()) {
|
||||
exchange.setProperties(safeCopy(getProperties()));
|
||||
}
|
||||
|
||||
exchange.setIn(getIn().copy());
|
||||
if (hasOut()) {
|
||||
exchange.setOut(getOut().copy());
|
||||
}
|
||||
exchange.setException(getException());
|
||||
return exchange;
|
||||
}
|
||||
|
||||
public abstract JBIAbstractExchange newInstance() ;
|
||||
|
||||
private static Map<String, Object> safeCopy(Map<String, Object> properties) {
|
||||
if (properties == null) {
|
||||
return null;
|
||||
}
|
||||
return new ConcurrentHashMap<String, Object>(properties);
|
||||
}
|
||||
|
||||
public CamelContext getContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
public Object getProperty(String name) {
|
||||
if (properties != null) {
|
||||
return properties.get(name);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Object getProperty(String name, Object defaultValue) {
|
||||
Object answer = getProperty(name);
|
||||
return answer != null ? answer : defaultValue;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T getProperty(String name, Class<T> type) {
|
||||
Object value = getProperty(name);
|
||||
if (value == null) {
|
||||
// lets avoid NullPointerException when converting to boolean for null values
|
||||
if (boolean.class.isAssignableFrom(type)) {
|
||||
return (T) Boolean.FALSE;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// eager same instance type test to avoid the overhead of invoking the type converter
|
||||
// if already same type
|
||||
if (type.isInstance(value)) {
|
||||
return type.cast(value);
|
||||
}
|
||||
|
||||
return ExchangeHelper.convertToType(this, type, value);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T getProperty(String name, Object defaultValue, Class<T> type) {
|
||||
Object value = getProperty(name, defaultValue);
|
||||
if (value == null) {
|
||||
// lets avoid NullPointerException when converting to boolean for null values
|
||||
if (boolean.class.isAssignableFrom(type)) {
|
||||
return (T) Boolean.FALSE;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// eager same instance type test to avoid the overhead of invoking the type converter
|
||||
// if already same type
|
||||
if (type.isInstance(value)) {
|
||||
return type.cast(value);
|
||||
}
|
||||
|
||||
return ExchangeHelper.convertToType(this, type, value);
|
||||
}
|
||||
|
||||
public void setProperty(String name, Object value) {
|
||||
if (value != null) {
|
||||
// avoid the NullPointException
|
||||
getProperties().put(name, value);
|
||||
} else {
|
||||
// if the value is null, we just remove the key from the map
|
||||
if (name != null) {
|
||||
getProperties().remove(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Object removeProperty(String name) {
|
||||
if (!hasProperties()) {
|
||||
return null;
|
||||
}
|
||||
return getProperties().remove(name);
|
||||
}
|
||||
|
||||
public Map<String, Object> getProperties() {
|
||||
if (properties == null) {
|
||||
properties = new ConcurrentHashMap<String, Object>();
|
||||
}
|
||||
return properties;
|
||||
}
|
||||
|
||||
public boolean hasProperties() {
|
||||
return properties != null && !properties.isEmpty();
|
||||
}
|
||||
|
||||
public void setProperties(Map<String, Object> properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
public Message getIn() {
|
||||
if (in == null) {
|
||||
in = createInMessage();
|
||||
configureMessage(in);
|
||||
}
|
||||
return in;
|
||||
}
|
||||
|
||||
public <T> T getIn(Class<T> type) {
|
||||
Message in = getIn();
|
||||
|
||||
// eager same instance type test to avoid the overhead of invoking the type converter
|
||||
// if already same type
|
||||
if (type.isInstance(in)) {
|
||||
return type.cast(in);
|
||||
}
|
||||
|
||||
// fallback to use type converter
|
||||
return context.getTypeConverter().convertTo(type, this, in);
|
||||
}
|
||||
|
||||
public void setIn(Message in) {
|
||||
this.in = in;
|
||||
configureMessage(in);
|
||||
}
|
||||
|
||||
public Message getOut() {
|
||||
// lazy create
|
||||
if (out == null) {
|
||||
out = (in != null && in instanceof MessageSupport)
|
||||
? ((MessageSupport)in).newInstance() : createOutMessage();
|
||||
configureMessage(out);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
public <T> T getOut(Class<T> type) {
|
||||
if (!hasOut()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Message out = getOut();
|
||||
|
||||
// eager same instance type test to avoid the overhead of invoking the type converter
|
||||
// if already same type
|
||||
if (type.isInstance(out)) {
|
||||
return type.cast(out);
|
||||
}
|
||||
|
||||
// fallback to use type converter
|
||||
return context.getTypeConverter().convertTo(type, this, out);
|
||||
}
|
||||
|
||||
public boolean hasOut() {
|
||||
return out != null;
|
||||
}
|
||||
|
||||
public void setOut(Message out) {
|
||||
this.out = out;
|
||||
configureMessage(out);
|
||||
}
|
||||
|
||||
public Exception getException() {
|
||||
return exception;
|
||||
}
|
||||
|
||||
public <T> T getException(Class<T> type) {
|
||||
return ObjectHelper.getException(type, exception);
|
||||
}
|
||||
|
||||
public void setException(Throwable t) {
|
||||
if (t == null) {
|
||||
this.exception = null;
|
||||
} else if (t instanceof Exception) {
|
||||
this.exception = (Exception) t;
|
||||
} else {
|
||||
// wrap throwable into an exception
|
||||
this.exception = ObjectHelper.wrapCamelExecutionException(this, t);
|
||||
}
|
||||
}
|
||||
|
||||
public ExchangePattern getPattern() {
|
||||
return pattern;
|
||||
}
|
||||
|
||||
public void setPattern(ExchangePattern pattern) {
|
||||
this.pattern = pattern;
|
||||
}
|
||||
|
||||
public Endpoint getFromEndpoint() {
|
||||
return fromEndpoint;
|
||||
}
|
||||
|
||||
public void setFromEndpoint(Endpoint fromEndpoint) {
|
||||
this.fromEndpoint = fromEndpoint;
|
||||
}
|
||||
|
||||
public String getFromRouteId() {
|
||||
return fromRouteId;
|
||||
}
|
||||
|
||||
public void setFromRouteId(String fromRouteId) {
|
||||
this.fromRouteId = fromRouteId;
|
||||
}
|
||||
|
||||
public String getExchangeId() {
|
||||
if (exchangeId == null) {
|
||||
exchangeId = createExchangeId();
|
||||
}
|
||||
return exchangeId;
|
||||
}
|
||||
|
||||
public void setExchangeId(String id) {
|
||||
this.exchangeId = id;
|
||||
}
|
||||
|
||||
public boolean isFailed() {
|
||||
return (hasOut() && getOut().isFault()) || getException() != null;
|
||||
}
|
||||
|
||||
public boolean isTransacted() {
|
||||
UnitOfWork uow = getUnitOfWork();
|
||||
if (uow != null) {
|
||||
return uow.isTransacted();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public Boolean isExternalRedelivered() {
|
||||
Boolean answer = null;
|
||||
|
||||
// check property first, as the implementation details to know if the message
|
||||
// was externally redelivered is message specific, and thus the message implementation
|
||||
// could potentially change during routing, and therefore later we may not know if the
|
||||
// original message was externally redelivered or not, therefore we store this detail
|
||||
// as a exchange property to keep it around for the lifecycle of the exchange
|
||||
if (hasProperties()) {
|
||||
answer = getProperty(Exchange.EXTERNAL_REDELIVERED, null, Boolean.class);
|
||||
}
|
||||
|
||||
if (answer == null) {
|
||||
// lets avoid adding methods to the Message API, so we use the
|
||||
// DefaultMessage to allow component specific messages to extend
|
||||
// and implement the isExternalRedelivered method.
|
||||
JBIBridgeMessage msg = getIn(JBIBridgeMessage.class);
|
||||
if (msg != null) {
|
||||
answer = msg.isTransactedRedelivered();
|
||||
// store as property to keep around
|
||||
setProperty(Exchange.EXTERNAL_REDELIVERED, answer);
|
||||
}
|
||||
}
|
||||
|
||||
return answer;
|
||||
}
|
||||
|
||||
public boolean isRollbackOnly() {
|
||||
return Boolean.TRUE.equals(getProperty(Exchange.ROLLBACK_ONLY)) || Boolean.TRUE.equals(getProperty(Exchange.ROLLBACK_ONLY_LAST));
|
||||
}
|
||||
|
||||
public UnitOfWork getUnitOfWork() {
|
||||
return unitOfWork;
|
||||
}
|
||||
|
||||
public void setUnitOfWork(UnitOfWork unitOfWork) {
|
||||
this.unitOfWork = unitOfWork;
|
||||
if (onCompletions != null) {
|
||||
// now an unit of work has been assigned so add the on completions
|
||||
// we might have registered already
|
||||
for (Synchronization onCompletion : onCompletions) {
|
||||
unitOfWork.addSynchronization(onCompletion);
|
||||
}
|
||||
// cleanup the temporary on completion list as they now have been registered
|
||||
// on the unit of work
|
||||
onCompletions.clear();
|
||||
onCompletions = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void addOnCompletion(Synchronization onCompletion) {
|
||||
if (unitOfWork == null) {
|
||||
// unit of work not yet registered so we store the on completion temporary
|
||||
// until the unit of work is assigned to this exchange by the UnitOfWorkProcessor
|
||||
if (onCompletions == null) {
|
||||
onCompletions = new ArrayList<Synchronization>();
|
||||
}
|
||||
onCompletions.add(onCompletion);
|
||||
} else {
|
||||
getUnitOfWork().addSynchronization(onCompletion);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean containsOnCompletion(Synchronization onCompletion) {
|
||||
if (unitOfWork != null) {
|
||||
// if there is an unit of work then the completions is moved there
|
||||
return unitOfWork.containsSynchronization(onCompletion);
|
||||
} else {
|
||||
// check temporary completions if no unit of work yet
|
||||
return onCompletions != null && onCompletions.contains(onCompletion);
|
||||
}
|
||||
}
|
||||
|
||||
public void handoverCompletions(Exchange target) {
|
||||
if (onCompletions != null) {
|
||||
for (Synchronization onCompletion : onCompletions) {
|
||||
target.addOnCompletion(onCompletion);
|
||||
}
|
||||
// cleanup the temporary on completion list as they have been handed over
|
||||
onCompletions.clear();
|
||||
onCompletions = null;
|
||||
} else if (unitOfWork != null) {
|
||||
// let unit of work handover
|
||||
unitOfWork.handoverSynchronization(target);
|
||||
}
|
||||
}
|
||||
|
||||
public List<Synchronization> handoverCompletions() {
|
||||
List<Synchronization> answer = null;
|
||||
if (onCompletions != null) {
|
||||
answer = new ArrayList<Synchronization>(onCompletions);
|
||||
onCompletions.clear();
|
||||
onCompletions = null;
|
||||
}
|
||||
return answer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the message after it has been set on the exchange
|
||||
*/
|
||||
protected void configureMessage(Message message) {
|
||||
if (message instanceof MessageSupport) {
|
||||
MessageSupport messageSupport = (MessageSupport)message;
|
||||
messageSupport.setExchange(this);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
protected String createExchangeId() {
|
||||
String answer = null;
|
||||
if (in != null) {
|
||||
answer = in.createExchangeId();
|
||||
}
|
||||
if (answer == null) {
|
||||
answer = context.getUuidGenerator().generateUuid();
|
||||
}
|
||||
return answer;
|
||||
}
|
||||
|
||||
protected abstract Message createInMessage() ;
|
||||
|
||||
protected abstract Message createOutMessage() ;
|
||||
}
|
|
@ -0,0 +1,101 @@
|
|||
/*
|
||||
* BEGIN_HEADER - DO NOT EDIT
|
||||
*
|
||||
* The contents of this file are subject to the terms
|
||||
* of the Common Development and Distribution License
|
||||
* (the "License"). You may not use this file except
|
||||
* in compliance with the License.
|
||||
*
|
||||
* You can obtain a copy of the license at
|
||||
* https://open-esb.dev.java.net/public/CDDLv1.0.html.
|
||||
* See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*
|
||||
* When distributing Covered Code, include this CDDL
|
||||
* HEADER in each file and include the License file at
|
||||
* https://open-esb.dev.java.net/public/CDDLv1.0.html.
|
||||
* If applicable add the following below this CDDL HEADER,
|
||||
* with the fields enclosed by brackets "[]" replaced with
|
||||
* your own identifying information: Portions Copyright
|
||||
* [year] [name of copyright owner]
|
||||
*/
|
||||
/*
|
||||
*
|
||||
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
*
|
||||
* END_HEADER - DO NOT EDIT
|
||||
*/
|
||||
package org.openesb.components.camelse.camel;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.apache.camel.CamelContext;
|
||||
import org.apache.camel.Endpoint;
|
||||
import org.apache.camel.impl.DefaultComponent;
|
||||
import org.apache.camel.util.CamelContextHelper;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author chikkala
|
||||
*/
|
||||
public class JBIBridgeComponent extends DefaultComponent {
|
||||
|
||||
public static final String URI_SCHEME = "jbi:";
|
||||
private static final Logger LOG = Logger.getLogger(JBIBridgeComponent.class.getName());
|
||||
|
||||
public JBIBridgeComponent() {
|
||||
}
|
||||
|
||||
public JBIBridgeComponent(CamelContext context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
protected Endpoint createEndpoint(String uri, String remaining, Map parameters)
|
||||
throws Exception {
|
||||
LOG.fine("Creating JBI Camel Endpiont URI:" + uri + "\n remaining: " + remaining);
|
||||
JBIBridgeEndpoint result = new JBIBridgeEndpoint(uri, remaining, this);
|
||||
setProperties(result, parameters);
|
||||
return result;
|
||||
}
|
||||
|
||||
private static String getEndpointURI(QName servQName, String epName) {
|
||||
return URI_SCHEME + servQName.getNamespaceURI() + "/" + servQName.getLocalPart() +
|
||||
"/" + epName;
|
||||
}
|
||||
|
||||
/**
|
||||
* finds the camel endpoints for the given jbi endpoint with service qname + endpoint name.
|
||||
* @param ctx
|
||||
* @param servQName
|
||||
* @param epName
|
||||
* @return
|
||||
*/
|
||||
public static HashMap<String, JBIBridgeEndpoint> findEndpoints(CamelContext ctx, QName servQName, String epName) {
|
||||
|
||||
HashMap<String, JBIBridgeEndpoint> epMap = new HashMap<String, JBIBridgeEndpoint>();
|
||||
|
||||
String epURI = getEndpointURI(servQName, epName);
|
||||
|
||||
JBIBridgeEndpoint currentEP = CamelContextHelper.getMandatoryEndpoint(ctx, epURI, JBIBridgeEndpoint.class);
|
||||
|
||||
/*List<JBIBridgeEndpoint> epList = CamelContextHelper.getSingletonEndpoints(ctx, JBIBridgeEndpoint.class);
|
||||
|
||||
for (JBIBridgeEndpoint currentEP : epList) {
|
||||
String currentEPUri = currentEP.getEndpointUri();
|
||||
// LOG.finer("Current EP URI " + currentEPUri);
|
||||
if (currentEPUri.startsWith(epURI)) { // check if the ep uri starts with the jbi:<s-ns>/<s-n>/<ep-n>
|
||||
epMap.put(currentEP.getOperation(), currentEP); // maps null operation key also.
|
||||
}
|
||||
}*/
|
||||
epMap.put(currentEP.getOperation(), currentEP);
|
||||
return epMap;
|
||||
}
|
||||
|
||||
public static JBIBridgeEndpoint findEndpoint(CamelContext ctx, QName servQName, String epName, String operation) {
|
||||
HashMap<String, JBIBridgeEndpoint> epMap = findEndpoints(ctx, servQName, epName);
|
||||
return epMap.get(operation);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,113 @@
|
|||
/*
|
||||
* BEGIN_HEADER - DO NOT EDIT
|
||||
*
|
||||
* The contents of this file are subject to the terms
|
||||
* of the Common Development and Distribution License
|
||||
* (the "License"). You may not use this file except
|
||||
* in compliance with the License.
|
||||
*
|
||||
* You can obtain a copy of the license at
|
||||
* https://open-esb.dev.java.net/public/CDDLv1.0.html.
|
||||
* See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*
|
||||
* When distributing Covered Code, include this CDDL
|
||||
* HEADER in each file and include the License file at
|
||||
* https://open-esb.dev.java.net/public/CDDLv1.0.html.
|
||||
* If applicable add the following below this CDDL HEADER,
|
||||
* with the fields enclosed by brackets "[]" replaced with
|
||||
* your own identifying information: Portions Copyright
|
||||
* [year] [name of copyright owner]
|
||||
*/
|
||||
/*
|
||||
*
|
||||
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
*
|
||||
* END_HEADER - DO NOT EDIT
|
||||
*/
|
||||
package org.openesb.components.camelse.camel;
|
||||
|
||||
import javax.jbi.messaging.Fault;
|
||||
import javax.jbi.messaging.InOnly;
|
||||
import javax.jbi.messaging.InOut;
|
||||
import javax.jbi.messaging.NormalizedMessage;
|
||||
import javax.xml.transform.Source;
|
||||
import org.apache.camel.Processor;
|
||||
import org.apache.camel.impl.DefaultConsumer;
|
||||
import org.openesb.components.camelse.common.RuntimeHelper;
|
||||
import org.openesb.components.camelse.common.wsdl.WSDL11JBIWrapper;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author chikkala
|
||||
*/
|
||||
public class JBIBridgeConsumer extends DefaultConsumer {
|
||||
|
||||
JBIBridgeEndpoint jbiBridgeEndpoint;
|
||||
|
||||
public JBIBridgeConsumer(JBIBridgeEndpoint endpoint, Processor processor) {
|
||||
super(endpoint, processor);
|
||||
this.jbiBridgeEndpoint = endpoint;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* call this when the jbi message exchange is processed on jbi endpiont provider side.
|
||||
* @param jbiMsg
|
||||
*/
|
||||
public void processJBIMessageExchange(InOnly inOnlyExchange) {
|
||||
try {
|
||||
JBIBridgeExchange exchange = jbiBridgeEndpoint.createExchange(inOnlyExchange);
|
||||
getProcessor().process(exchange);
|
||||
} catch (Throwable e) {
|
||||
RuntimeHelper.logError(e);
|
||||
handleException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* call this when the jbi message exchange is processed on jbi endpiont provider side.
|
||||
* @param jbiMsg
|
||||
*/
|
||||
public void processJBIMessageExchange(InOut inOutExchange, WSDL11JBIWrapper outWrapper) throws Exception {
|
||||
try {
|
||||
JBIBridgeExchange exchange = jbiBridgeEndpoint.createExchange(inOutExchange);
|
||||
getProcessor().process(exchange);
|
||||
if (exchange.isFailed()) {
|
||||
Throwable ex = exchange.getException();
|
||||
if (ex != null ) {
|
||||
throw new Exception(ex);
|
||||
} else {
|
||||
// fault
|
||||
JBIBridgeMessage msg = (JBIBridgeMessage) exchange.getOut();
|
||||
if(msg.isFault()){
|
||||
NormalizedMessage faultMsg = msg.getJBIMessage();
|
||||
inOutExchange.setFault((Fault)faultMsg);
|
||||
}else{
|
||||
throw new IllegalStateException("Expected a Fault or Exception but not found");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
JBIBridgeMessage msg = (JBIBridgeMessage) exchange.getOut();
|
||||
NormalizedMessage outMsg = msg.getJBIMessage();
|
||||
addContentToJBIWrapper(outWrapper, msg.getJBIMessage().getContent());
|
||||
outMsg.setContent(outWrapper.toDOMSource());
|
||||
inOutExchange.setOutMessage(outMsg);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
handleException(e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
private void addContentToJBIWrapper(WSDL11JBIWrapper contentWrapper, Source content) {
|
||||
// check if the output from the transformer is in a wrapped form
|
||||
WSDL11JBIWrapper wrapper = WSDL11JBIWrapper.sourceToWrapper(
|
||||
RuntimeHelper.sourceToDOMSource(content));
|
||||
if (wrapper != null) {
|
||||
contentWrapper.appendParts(wrapper.getParts());
|
||||
} else {
|
||||
contentWrapper.appendPart(RuntimeHelper.sourceToDOMSource(content));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,137 @@
|
|||
/*
|
||||
* BEGIN_HEADER - DO NOT EDIT
|
||||
*
|
||||
* The contents of this file are subject to the terms
|
||||
* of the Common Development and Distribution License
|
||||
* (the "License"). You may not use this file except
|
||||
* in compliance with the License.
|
||||
*
|
||||
* You can obtain a copy of the license at
|
||||
* https://open-esb.dev.java.net/public/CDDLv1.0.html.
|
||||
* See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*
|
||||
* When distributing Covered Code, include this CDDL
|
||||
* HEADER in each file and include the License file at
|
||||
* https://open-esb.dev.java.net/public/CDDLv1.0.html.
|
||||
* If applicable add the following below this CDDL HEADER,
|
||||
* with the fields enclosed by brackets "[]" replaced with
|
||||
* your own identifying information: Portions Copyright
|
||||
* [year] [name of copyright owner]
|
||||
*/
|
||||
/*
|
||||
*
|
||||
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
*
|
||||
* END_HEADER - DO NOT EDIT
|
||||
*/
|
||||
package org.openesb.components.camelse.camel;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
import javax.jbi.messaging.InOnly;
|
||||
import javax.jbi.messaging.InOut;
|
||||
import org.apache.camel.Consumer;
|
||||
import org.apache.camel.ExchangePattern;
|
||||
import org.apache.camel.Processor;
|
||||
import org.apache.camel.Producer;
|
||||
import org.apache.camel.impl.DefaultEndpoint;
|
||||
import org.openesb.components.camelse.CamelSEConsumerEndpoint;
|
||||
|
||||
/**
|
||||
* A camel endpoint implementation to invoke services provided in jbi components
|
||||
* or provide a jbi provider endpoint in camel to allow jbi components to invoke
|
||||
* the camel app as a provider.
|
||||
* @author chikkala
|
||||
*/
|
||||
public class JBIBridgeEndpoint extends DefaultEndpoint {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(JBIBridgeEndpoint.class.getName());
|
||||
private JBIBridgeConsumer consumer;
|
||||
private JBIBridgeProducer producer;
|
||||
private CamelSEConsumerEndpoint jbiConsumerEP;
|
||||
private String jbiEndpointURL; // "<service-namespace>/<servicename>/<endpointname>"
|
||||
private String operation;
|
||||
|
||||
protected JBIBridgeEndpoint(String endpointUri, String remaining, JBIBridgeComponent component) {
|
||||
super(endpointUri, component);
|
||||
this.jbiEndpointURL = remaining;
|
||||
}
|
||||
|
||||
public String getJbiEndpointURL() {
|
||||
return jbiEndpointURL;
|
||||
}
|
||||
|
||||
public String getOperation() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
public void setOperation(String operation) {
|
||||
// LOG.info("Setting endpoint operation " + operation);
|
||||
this.operation = operation;
|
||||
}
|
||||
|
||||
public CamelSEConsumerEndpoint getJbiConsumerEP() {
|
||||
return jbiConsumerEP;
|
||||
}
|
||||
|
||||
public void setJbiConsumerEP(CamelSEConsumerEndpoint jbiConsumerEP) {
|
||||
this.jbiConsumerEP = jbiConsumerEP;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a Producer
|
||||
* @throws Exception
|
||||
* @see org.apache.camel.Endpoint#createProducer()
|
||||
*/
|
||||
public Producer createProducer() throws Exception {
|
||||
LOG.fine("Creating Camel 2 JBI JBIBridgeProducer");
|
||||
JBIBridgeProducer result = new JBIBridgeProducer(this);
|
||||
this.producer = result;
|
||||
// do necessary camel 2 jbi initialization.
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param proc
|
||||
* @return a Consumer
|
||||
* @throws Exception
|
||||
* @see org.apache.camel.Endpoint#createConsumer(org.apache.camel.Processor)
|
||||
*/
|
||||
public Consumer createConsumer(Processor proc) throws Exception {
|
||||
LOG.fine("Creating JBI 2 Camel JBIBridgeConsumer");
|
||||
JBIBridgeConsumer result = new JBIBridgeConsumer(this, proc);
|
||||
consumer = result;
|
||||
// do necessary jbi 2 camel initialization.
|
||||
return result;
|
||||
}
|
||||
|
||||
public JBIBridgeConsumer getConsumer() {
|
||||
return consumer;
|
||||
}
|
||||
|
||||
public JBIBridgeProducer getProducer() {
|
||||
return producer;
|
||||
}
|
||||
|
||||
public boolean isSingleton() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public JBIBridgeExchange createExchange(InOnly jbiExchange) {
|
||||
return new JBIBridgeExchange(getCamelContext(), jbiExchange);
|
||||
}
|
||||
|
||||
public JBIBridgeExchange createExchange(InOut jbiExchange) {
|
||||
return new JBIBridgeExchange(getCamelContext(), jbiExchange);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JBIBridgeExchange createExchange() {
|
||||
return new JBIBridgeExchange(getCamelContext(), getExchangePattern());
|
||||
}
|
||||
|
||||
@Override
|
||||
public JBIBridgeExchange createExchange(ExchangePattern pattern) {
|
||||
return new JBIBridgeExchange(getCamelContext(), pattern);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,535 @@
|
|||
/*
|
||||
* BEGIN_HEADER - DO NOT EDIT
|
||||
*
|
||||
* The contents of this file are subject to the terms
|
||||
* of the Common Development and Distribution License
|
||||
* (the "License"). You may not use this file except
|
||||
* in compliance with the License.
|
||||
*
|
||||
* You can obtain a copy of the license at
|
||||
* https://open-esb.dev.java.net/public/CDDLv1.0.html.
|
||||
* See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*
|
||||
* When distributing Covered Code, include this CDDL
|
||||
* HEADER in each file and include the License file at
|
||||
* https://open-esb.dev.java.net/public/CDDLv1.0.html.
|
||||
* If applicable add the following below this CDDL HEADER,
|
||||
* with the fields enclosed by brackets "[]" replaced with
|
||||
* your own identifying information: Portions Copyright
|
||||
* [year] [name of copyright owner]
|
||||
*/
|
||||
/*
|
||||
*
|
||||
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
*
|
||||
* END_HEADER - DO NOT EDIT
|
||||
*/
|
||||
package org.openesb.components.camelse.camel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
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 org.apache.camel.CamelContext;
|
||||
import org.apache.camel.Endpoint;
|
||||
import org.apache.camel.Exchange;
|
||||
import org.apache.camel.ExchangePattern;
|
||||
import org.apache.camel.Message;
|
||||
import org.apache.camel.impl.MessageSupport;
|
||||
import org.apache.camel.spi.Synchronization;
|
||||
import org.apache.camel.spi.UnitOfWork;
|
||||
import org.apache.camel.util.ExchangeHelper;
|
||||
import org.apache.camel.util.ObjectHelper;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author chikkala
|
||||
*/
|
||||
public class JBIBridgeExchange implements Exchange {
|
||||
|
||||
public static final String JBI_OPERATION_PROP = "org.openesb.camelse.jbi.operation";
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(JBIBridgeExchange.class.getName());
|
||||
private MessageExchange jbiExchange;
|
||||
|
||||
|
||||
protected final CamelContext context;
|
||||
private Map<String, Object> properties;
|
||||
private Message in;
|
||||
private Message out;
|
||||
private Exception exception;
|
||||
private String exchangeId;
|
||||
private UnitOfWork unitOfWork;
|
||||
private ExchangePattern pattern;
|
||||
private Endpoint fromEndpoint;
|
||||
private String fromRouteId;
|
||||
private List<Synchronization> onCompletions;
|
||||
|
||||
public JBIBridgeExchange(CamelContext camelContext, ExchangePattern pattern) {
|
||||
this.context = camelContext;
|
||||
this.pattern = pattern;
|
||||
}
|
||||
|
||||
public JBIBridgeExchange(Exchange parent){
|
||||
this(parent.getContext(), parent.getPattern());
|
||||
this.fromEndpoint = parent.getFromEndpoint();
|
||||
this.fromRouteId = parent.getFromRouteId();
|
||||
this.unitOfWork = parent.getUnitOfWork();
|
||||
}
|
||||
|
||||
public JBIBridgeExchange(CamelContext camelContext, InOnly jbiEx) {
|
||||
this.context = camelContext;
|
||||
this.jbiExchange = jbiEx;
|
||||
setIn(new JBIBridgeMessage(jbiEx.getInMessage()));
|
||||
populateJBIExchangeProperties();
|
||||
}
|
||||
|
||||
public JBIBridgeExchange(CamelContext camelContext, InOut jbiEx) {
|
||||
this.context = camelContext;
|
||||
this.jbiExchange = jbiEx;
|
||||
setIn(new JBIBridgeMessage(jbiEx.getInMessage()));
|
||||
populateJBIExchangeProperties();
|
||||
}
|
||||
|
||||
public JBIBridgeExchange(JBIBridgeExchange parent, MessageExchange jbiEx) {
|
||||
this(parent);
|
||||
this.jbiExchange = jbiEx;
|
||||
populateJBIExchangeProperties();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Exchange[" + (out == null ? in : out) + "]";
|
||||
}
|
||||
|
||||
public Exchange copy() {
|
||||
JBIBridgeExchange exchange = new JBIBridgeExchange(this);
|
||||
|
||||
if (hasProperties()) {
|
||||
exchange.setProperties(safeCopy(getProperties()));
|
||||
}
|
||||
|
||||
exchange.setIn(getIn().copy());
|
||||
if (hasOut()) {
|
||||
exchange.setOut(getOut().copy());
|
||||
}
|
||||
exchange.setException(getException());
|
||||
return exchange;
|
||||
}
|
||||
|
||||
|
||||
private static Map<String, Object> safeCopy(Map<String, Object> properties) {
|
||||
if (properties == null) {
|
||||
return null;
|
||||
}
|
||||
return new ConcurrentHashMap<String, Object>(properties);
|
||||
}
|
||||
|
||||
public CamelContext getContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
public Object getProperty(String name) {
|
||||
if (properties != null) {
|
||||
return properties.get(name);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Object getProperty(String name, Object defaultValue) {
|
||||
Object answer = getProperty(name);
|
||||
return answer != null ? answer : defaultValue;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T getProperty(String name, Class<T> type) {
|
||||
Object value = getProperty(name);
|
||||
if (value == null) {
|
||||
// lets avoid NullPointerException when converting to boolean for null values
|
||||
if (boolean.class.isAssignableFrom(type)) {
|
||||
return (T) Boolean.FALSE;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// eager same instance type test to avoid the overhead of invoking the type converter
|
||||
// if already same type
|
||||
if (type.isInstance(value)) {
|
||||
return type.cast(value);
|
||||
}
|
||||
|
||||
return ExchangeHelper.convertToType(this, type, value);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T getProperty(String name, Object defaultValue, Class<T> type) {
|
||||
Object value = getProperty(name, defaultValue);
|
||||
if (value == null) {
|
||||
// lets avoid NullPointerException when converting to boolean for null values
|
||||
if (boolean.class.isAssignableFrom(type)) {
|
||||
return (T) Boolean.FALSE;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// eager same instance type test to avoid the overhead of invoking the type converter
|
||||
// if already same type
|
||||
if (type.isInstance(value)) {
|
||||
return type.cast(value);
|
||||
}
|
||||
|
||||
return ExchangeHelper.convertToType(this, type, value);
|
||||
}
|
||||
|
||||
public void setProperty(String name, Object value) {
|
||||
if (value != null) {
|
||||
// avoid the NullPointException
|
||||
getProperties().put(name, value);
|
||||
} else {
|
||||
// if the value is null, we just remove the key from the map
|
||||
if (name != null) {
|
||||
getProperties().remove(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Object removeProperty(String name) {
|
||||
if (!hasProperties()) {
|
||||
return null;
|
||||
}
|
||||
return getProperties().remove(name);
|
||||
}
|
||||
|
||||
public Map<String, Object> getProperties() {
|
||||
if (properties == null) {
|
||||
properties = new ConcurrentHashMap<String, Object>();
|
||||
}
|
||||
return properties;
|
||||
}
|
||||
|
||||
public boolean hasProperties() {
|
||||
return properties != null && !properties.isEmpty();
|
||||
}
|
||||
|
||||
public void setProperties(Map<String, Object> properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
public Message getIn() {
|
||||
if (in == null) {
|
||||
in = createInMessage();
|
||||
configureMessage(in);
|
||||
}
|
||||
return in;
|
||||
}
|
||||
|
||||
public <T> T getIn(Class<T> type) {
|
||||
Message in = getIn();
|
||||
|
||||
// eager same instance type test to avoid the overhead of invoking the type converter
|
||||
// if already same type
|
||||
if (type.isInstance(in)) {
|
||||
return type.cast(in);
|
||||
}
|
||||
|
||||
// fallback to use type converter
|
||||
return context.getTypeConverter().convertTo(type, this, in);
|
||||
}
|
||||
|
||||
public void setIn(Message in) {
|
||||
this.in = in;
|
||||
configureMessage(in);
|
||||
}
|
||||
|
||||
public Message getOut() {
|
||||
// lazy create
|
||||
if (out == null) {
|
||||
out = (in != null && in instanceof MessageSupport)
|
||||
? ((MessageSupport)in).newInstance() : createOutMessage();
|
||||
configureMessage(out);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
public <T> T getOut(Class<T> type) {
|
||||
if (!hasOut()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Message out = getOut();
|
||||
|
||||
// eager same instance type test to avoid the overhead of invoking the type converter
|
||||
// if already same type
|
||||
if (type.isInstance(out)) {
|
||||
return type.cast(out);
|
||||
}
|
||||
|
||||
// fallback to use type converter
|
||||
return context.getTypeConverter().convertTo(type, this, out);
|
||||
}
|
||||
|
||||
public boolean hasOut() {
|
||||
return out != null;
|
||||
}
|
||||
|
||||
public void setOut(Message out) {
|
||||
this.out = out;
|
||||
configureMessage(out);
|
||||
}
|
||||
|
||||
public Exception getException() {
|
||||
return exception;
|
||||
}
|
||||
|
||||
public <T> T getException(Class<T> type) {
|
||||
return ObjectHelper.getException(type, exception);
|
||||
}
|
||||
|
||||
public void setException(Throwable t) {
|
||||
if (t == null) {
|
||||
this.exception = null;
|
||||
} else if (t instanceof Exception) {
|
||||
this.exception = (Exception) t;
|
||||
} else {
|
||||
// wrap throwable into an exception
|
||||
this.exception = ObjectHelper.wrapCamelExecutionException(this, t);
|
||||
}
|
||||
}
|
||||
|
||||
public ExchangePattern getPattern() {
|
||||
return pattern;
|
||||
}
|
||||
|
||||
public void setPattern(ExchangePattern pattern) {
|
||||
this.pattern = pattern;
|
||||
}
|
||||
|
||||
public Endpoint getFromEndpoint() {
|
||||
return fromEndpoint;
|
||||
}
|
||||
|
||||
public void setFromEndpoint(Endpoint fromEndpoint) {
|
||||
this.fromEndpoint = fromEndpoint;
|
||||
}
|
||||
|
||||
public String getFromRouteId() {
|
||||
return fromRouteId;
|
||||
}
|
||||
|
||||
public void setFromRouteId(String fromRouteId) {
|
||||
this.fromRouteId = fromRouteId;
|
||||
}
|
||||
|
||||
public String getExchangeId() {
|
||||
if (exchangeId == null) {
|
||||
exchangeId = createExchangeId();
|
||||
}
|
||||
return exchangeId;
|
||||
}
|
||||
|
||||
public void setExchangeId(String id) {
|
||||
this.exchangeId = id;
|
||||
}
|
||||
|
||||
public boolean isFailed() {
|
||||
return (hasOut() && getOut().isFault()) || getException() != null;
|
||||
}
|
||||
|
||||
public boolean isTransacted() {
|
||||
UnitOfWork uow = getUnitOfWork();
|
||||
if (uow != null) {
|
||||
return uow.isTransacted();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public Boolean isExternalRedelivered() {
|
||||
Boolean answer = null;
|
||||
|
||||
// check property first, as the implementation details to know if the message
|
||||
// was externally redelivered is message specific, and thus the message implementation
|
||||
// could potentially change during routing, and therefore later we may not know if the
|
||||
// original message was externally redelivered or not, therefore we store this detail
|
||||
// as a exchange property to keep it around for the lifecycle of the exchange
|
||||
if (hasProperties()) {
|
||||
answer = getProperty(Exchange.EXTERNAL_REDELIVERED, null, Boolean.class);
|
||||
}
|
||||
|
||||
if (answer == null) {
|
||||
// lets avoid adding methods to the Message API, so we use the
|
||||
// DefaultMessage to allow component specific messages to extend
|
||||
// and implement the isExternalRedelivered method.
|
||||
JBIBridgeMessage msg = getIn(JBIBridgeMessage.class);
|
||||
if (msg != null) {
|
||||
answer = msg.isTransactedRedelivered();
|
||||
// store as property to keep around
|
||||
setProperty(Exchange.EXTERNAL_REDELIVERED, answer);
|
||||
}
|
||||
}
|
||||
|
||||
return answer;
|
||||
}
|
||||
|
||||
public boolean isRollbackOnly() {
|
||||
return Boolean.TRUE.equals(getProperty(Exchange.ROLLBACK_ONLY)) || Boolean.TRUE.equals(getProperty(Exchange.ROLLBACK_ONLY_LAST));
|
||||
}
|
||||
|
||||
public UnitOfWork getUnitOfWork() {
|
||||
return unitOfWork;
|
||||
}
|
||||
|
||||
public void setUnitOfWork(UnitOfWork unitOfWork) {
|
||||
this.unitOfWork = unitOfWork;
|
||||
if (onCompletions != null) {
|
||||
// now an unit of work has been assigned so add the on completions
|
||||
// we might have registered already
|
||||
for (Synchronization onCompletion : onCompletions) {
|
||||
unitOfWork.addSynchronization(onCompletion);
|
||||
}
|
||||
// cleanup the temporary on completion list as they now have been registered
|
||||
// on the unit of work
|
||||
onCompletions.clear();
|
||||
onCompletions = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void addOnCompletion(Synchronization onCompletion) {
|
||||
if (unitOfWork == null) {
|
||||
// unit of work not yet registered so we store the on completion temporary
|
||||
// until the unit of work is assigned to this exchange by the UnitOfWorkProcessor
|
||||
if (onCompletions == null) {
|
||||
onCompletions = new ArrayList<Synchronization>();
|
||||
}
|
||||
onCompletions.add(onCompletion);
|
||||
} else {
|
||||
getUnitOfWork().addSynchronization(onCompletion);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean containsOnCompletion(Synchronization onCompletion) {
|
||||
if (unitOfWork != null) {
|
||||
// if there is an unit of work then the completions is moved there
|
||||
return unitOfWork.containsSynchronization(onCompletion);
|
||||
} else {
|
||||
// check temporary completions if no unit of work yet
|
||||
return onCompletions != null && onCompletions.contains(onCompletion);
|
||||
}
|
||||
}
|
||||
|
||||
public void handoverCompletions(Exchange target) {
|
||||
if (onCompletions != null) {
|
||||
for (Synchronization onCompletion : onCompletions) {
|
||||
target.addOnCompletion(onCompletion);
|
||||
}
|
||||
// cleanup the temporary on completion list as they have been handed over
|
||||
onCompletions.clear();
|
||||
onCompletions = null;
|
||||
} else if (unitOfWork != null) {
|
||||
// let unit of work handover
|
||||
unitOfWork.handoverSynchronization(target);
|
||||
}
|
||||
}
|
||||
|
||||
public List<Synchronization> handoverCompletions() {
|
||||
List<Synchronization> answer = null;
|
||||
if (onCompletions != null) {
|
||||
answer = new ArrayList<Synchronization>(onCompletions);
|
||||
onCompletions.clear();
|
||||
onCompletions = null;
|
||||
}
|
||||
return answer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the message after it has been set on the exchange
|
||||
*/
|
||||
protected void configureMessage(Message message) {
|
||||
if (message instanceof MessageSupport) {
|
||||
MessageSupport messageSupport = (MessageSupport)message;
|
||||
messageSupport.setExchange(this);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
protected String createExchangeId() {
|
||||
String answer = null;
|
||||
if (in != null) {
|
||||
answer = in.createExchangeId();
|
||||
}
|
||||
if (answer == null) {
|
||||
answer = context.getUuidGenerator().generateUuid();
|
||||
}
|
||||
return answer;
|
||||
}
|
||||
|
||||
/*
|
||||
public MessageExchange getJBIExchange() {
|
||||
return jbiExchange;
|
||||
}
|
||||
|
||||
public void setJBIExchange(MessageExchange jbiEx) {
|
||||
this.jbiExchange = jbiEx;
|
||||
populateJBIExchangeProperties();
|
||||
}*/
|
||||
private void populateJBIExchangeProperties() {
|
||||
if (this.jbiExchange != null ) {
|
||||
// populate jbi exchange properties
|
||||
Set propNames = this.jbiExchange.getPropertyNames();
|
||||
for ( Object propName : propNames) {
|
||||
setProperty((String)propName, this.jbiExchange.getProperty((String)propName));
|
||||
}
|
||||
// always set the operation local name.
|
||||
String opName = null;
|
||||
QName opQName = this.jbiExchange.getOperation();
|
||||
if ( opQName != null ) {
|
||||
opName = opQName.toString();
|
||||
}
|
||||
setProperty(JBI_OPERATION_PROP, opName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private NormalizedMessage createJBIMessage(boolean fault) {
|
||||
NormalizedMessage nm = null;
|
||||
try {
|
||||
if (this.jbiExchange != null) {
|
||||
if (fault) {
|
||||
nm = this.jbiExchange.createFault();
|
||||
} else {
|
||||
nm = this.jbiExchange.createMessage();
|
||||
}
|
||||
}
|
||||
} catch (MessagingException ex) {
|
||||
LOG.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
return nm;
|
||||
}
|
||||
|
||||
/*@Override
|
||||
protected Message createFaultMessage() {
|
||||
NormalizedMessage nm = createJBIMessage(true);
|
||||
return new JBIBridgeMessage(nm);
|
||||
}*/
|
||||
|
||||
private Message createInMessage() {
|
||||
NormalizedMessage nm = createJBIMessage(false);
|
||||
return new JBIBridgeMessage(nm);
|
||||
}
|
||||
|
||||
private Message createOutMessage() {
|
||||
NormalizedMessage nm = createJBIMessage(false);
|
||||
return new JBIBridgeMessage(nm);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,245 @@
|
|||
/*
|
||||
* BEGIN_HEADER - DO NOT EDIT
|
||||
*
|
||||
* The contents of this file are subject to the terms
|
||||
* of the Common Development and Distribution License
|
||||
* (the "License"). You may not use this file except
|
||||
* in compliance with the License.
|
||||
*
|
||||
* You can obtain a copy of the license at
|
||||
* https://open-esb.dev.java.net/public/CDDLv1.0.html.
|
||||
* See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*
|
||||
* When distributing Covered Code, include this CDDL
|
||||
* HEADER in each file and include the License file at
|
||||
* https://open-esb.dev.java.net/public/CDDLv1.0.html.
|
||||
* If applicable add the following below this CDDL HEADER,
|
||||
* with the fields enclosed by brackets "[]" replaced with
|
||||
* your own identifying information: Portions Copyright
|
||||
* [year] [name of copyright owner]
|
||||
*/
|
||||
/*
|
||||
*
|
||||
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
*
|
||||
* END_HEADER - DO NOT EDIT
|
||||
*/
|
||||
package org.openesb.components.camelse.camel;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.io.StringReader;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.activation.DataHandler;
|
||||
import javax.jbi.messaging.MessagingException;
|
||||
import javax.jbi.messaging.NormalizedMessage;
|
||||
import javax.xml.transform.Source;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
import org.apache.camel.Exchange;
|
||||
import org.apache.camel.util.ExchangeHelper;
|
||||
import org.openesb.components.camelse.common.RuntimeHelper;
|
||||
import org.apache.camel.impl.DefaultMessage;
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author chikkala
|
||||
*/
|
||||
public class JBIBridgeMessage extends DefaultMessage {
|
||||
private static final Logger LOG = Logger.getLogger(JBIBridgeMessage.class.getName());
|
||||
private NormalizedMessage jbiMessage;
|
||||
|
||||
public JBIBridgeMessage() {
|
||||
}
|
||||
|
||||
public JBIBridgeMessage(NormalizedMessage jbiMsg) {
|
||||
this.jbiMessage = jbiMsg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "JBIBridgeMessage[" + jbiMessage + "]";
|
||||
}
|
||||
|
||||
public NormalizedMessage getJBIMessage() {
|
||||
return jbiMessage;
|
||||
}
|
||||
|
||||
public void setJBIMessage(NormalizedMessage jbiMsg) {
|
||||
this.jbiMessage = jbiMsg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JBIBridgeExchange getExchange() {
|
||||
return (JBIBridgeExchange) super.getExchange();
|
||||
}
|
||||
|
||||
@Override
|
||||
public JBIBridgeMessage newInstance() {
|
||||
return new JBIBridgeMessage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHeader(String name, Object value) {
|
||||
super.setHeader(name, value);
|
||||
if ( this.jbiMessage != null ) {
|
||||
this.jbiMessage.setProperty(name, value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object removeHeader(String name) {
|
||||
Object value = null;
|
||||
value = super.removeHeader(name);
|
||||
if ( value != null && this.jbiMessage != null ) {
|
||||
Object jbiValue = this.jbiMessage.getProperty(name);
|
||||
if ( jbiValue != null ) {
|
||||
this.jbiMessage.setProperty(name, null);
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHeaders(Map<String, Object> headers) {
|
||||
super.setHeaders(headers);
|
||||
if ( this.jbiMessage != null ) {
|
||||
for (String name : headers.keySet() ) {
|
||||
this.jbiMessage.setProperty(name, headers.get(name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void populateInitialHeaders(Map<String, Object> map) {
|
||||
if (this.jbiMessage == null) {
|
||||
return;
|
||||
}
|
||||
Set<String> propNames = jbiMessage.getPropertyNames();
|
||||
for (String name : propNames) {
|
||||
Object obj = jbiMessage.getProperty(name);
|
||||
map.put(name, obj);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAttachment(String id) {
|
||||
super.removeAttachment(id);
|
||||
if ( this.jbiMessage != null ) {
|
||||
try {
|
||||
this.jbiMessage.removeAttachment(id);
|
||||
} catch (MessagingException ex) {
|
||||
LOG.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAttachment(String id, DataHandler content) {
|
||||
super.addAttachment(id, content);
|
||||
if ( this.jbiMessage != null ) {
|
||||
try {
|
||||
this.jbiMessage.addAttachment(id, content);
|
||||
} catch (MessagingException ex) {
|
||||
LOG.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttachments(Map<String, DataHandler> attachments) {
|
||||
super.setAttachments(attachments);
|
||||
if ( this.jbiMessage != null ) {
|
||||
for ( String id : attachments.keySet()) {
|
||||
try {
|
||||
this.jbiMessage.addAttachment(id, attachments.get(id));
|
||||
} catch (MessagingException ex) {
|
||||
Logger.getLogger(JBIBridgeMessage.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void populateInitialAttachments(Map<String, DataHandler> map) {
|
||||
if (this.jbiMessage == null) {
|
||||
return;
|
||||
}
|
||||
Set<String> attchNames = jbiMessage.getAttachmentNames();
|
||||
for (String attchName : attchNames) {
|
||||
DataHandler attchObj = jbiMessage.getAttachment(attchName);
|
||||
map.put(attchName, attchObj);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getBody() {
|
||||
// this calls create body to get the body from jbiMessage if not null.
|
||||
Object obj = super.getBody();
|
||||
if ( obj == null || obj instanceof Source) {
|
||||
return obj;
|
||||
}
|
||||
// convert the obj to Source object
|
||||
|
||||
if (obj != null) {
|
||||
if ( obj instanceof String ) {
|
||||
obj = RuntimeHelper.createDOMSource(new StringReader((String)obj));
|
||||
} else {
|
||||
Exchange exchange = this.getExchange();
|
||||
if ( exchange != null ) {
|
||||
obj = ExchangeHelper.convertToType(exchange, Reader.class, obj);
|
||||
obj = RuntimeHelper.createDOMSource((Reader)obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBody(Object body) {
|
||||
try {
|
||||
if (jbiMessage != null) {
|
||||
if ( body == null ) {
|
||||
jbiMessage.setContent(null);
|
||||
return;
|
||||
}
|
||||
if (body instanceof Source) {
|
||||
jbiMessage.setContent(RuntimeHelper.sourceToDOMSource((Source) body));
|
||||
} else if (body instanceof Document ) {
|
||||
jbiMessage.setContent(new DOMSource((Document)body));
|
||||
} else {
|
||||
StringReader reader = new StringReader(body.toString());
|
||||
jbiMessage.setContent(RuntimeHelper.createDOMSource(reader));
|
||||
}
|
||||
} else {
|
||||
super.setBody(body);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
RuntimeHelper.logError(ex);
|
||||
super.setBody(body);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object createBody() {
|
||||
if (jbiMessage != null) {
|
||||
Source content = jbiMessage.getContent();
|
||||
if ( content != null ) {
|
||||
return RuntimeHelper.sourceToDOMSource(content);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
return super.createBody();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean isTransactedRedelivered() {
|
||||
// return null by default
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,157 @@
|
|||
/*
|
||||
* BEGIN_HEADER - DO NOT EDIT
|
||||
*
|
||||
* The contents of this file are subject to the terms
|
||||
* of the Common Development and Distribution License
|
||||
* (the "License"). You may not use this file except
|
||||
* in compliance with the License.
|
||||
*
|
||||
* You can obtain a copy of the license at
|
||||
* https://open-esb.dev.java.net/public/CDDLv1.0.html.
|
||||
* See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*
|
||||
* When distributing Covered Code, include this CDDL
|
||||
* HEADER in each file and include the License file at
|
||||
* https://open-esb.dev.java.net/public/CDDLv1.0.html.
|
||||
* If applicable add the following below this CDDL HEADER,
|
||||
* with the fields enclosed by brackets "[]" replaced with
|
||||
* your own identifying information: Portions Copyright
|
||||
* [year] [name of copyright owner]
|
||||
*/
|
||||
/*
|
||||
*
|
||||
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
*
|
||||
* END_HEADER - DO NOT EDIT
|
||||
*/
|
||||
package org.openesb.components.camelse.camel;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.jbi.JBIException;
|
||||
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.impl.DefaultProducer;
|
||||
import org.apache.camel.util.ExchangeHelper;
|
||||
import org.openesb.components.camelse.CamelSEConsumerEndpoint;
|
||||
import org.openesb.components.camelse.common.RuntimeHelper;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author chikkala
|
||||
*/
|
||||
public class JBIBridgeProducer extends DefaultProducer {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(JBIBridgeProducer.class.getName());
|
||||
private final JBIBridgeEndpoint endpoint;
|
||||
|
||||
public JBIBridgeProducer(JBIBridgeEndpoint endpoint) {
|
||||
super(endpoint);
|
||||
this.endpoint = endpoint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JBIBridgeEndpoint getEndpoint() {
|
||||
return (JBIBridgeEndpoint) super.getEndpoint();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param exchange
|
||||
* @see org.apache.camel.Processor#process(Exchange)
|
||||
*/
|
||||
public void process(Exchange exchange) throws Exception {
|
||||
// RuntimeHelper.getLogger().fine("JBIBridgeProducer.process(Exchange)");
|
||||
JBIBridgeExchange jbiBridgeExchange = (JBIBridgeExchange)endpoint.createExchange(exchange);
|
||||
process(jbiBridgeExchange);
|
||||
ExchangeHelper.copyResults(exchange, jbiBridgeExchange);
|
||||
}
|
||||
/**
|
||||
* finds the suitable operation for the jbi message exchange.
|
||||
* @param jbiConsumerEP
|
||||
* @param exchange
|
||||
* @return
|
||||
* @throws java.lang.Exception
|
||||
*/
|
||||
private QName getOperation(CamelSEConsumerEndpoint jbiConsumerEP, JBIBridgeExchange exchange) throws Exception {
|
||||
// 1. check the camel ep uri has operation specified. if yes. use it.
|
||||
// 2. if camel exchange specifies operation and the interface has
|
||||
// multiple operations. valdate and use the operation specified in exchange.
|
||||
// 3. else use the defualt operation in the interface.
|
||||
|
||||
String op = this.endpoint.getOperation();
|
||||
QName opQName = (op ==null) ? QName.valueOf("") : QName.valueOf(op.trim());
|
||||
String opNS = opQName.getNamespaceURI();
|
||||
String opName = opQName.getLocalPart();
|
||||
|
||||
QName ifQName = jbiConsumerEP.getService().getInterface();
|
||||
String ifNS = ifQName.getNamespaceURI();
|
||||
if ( opName.length() > 0 ) {
|
||||
if ( opNS.length() == 0 ) {
|
||||
opNS = ifNS;
|
||||
} else if (!ifNS.equals(opNS)) {
|
||||
throw new Exception("invalid namesapce: namespace for camel endpoint uri operation and jbi endpoint operation are not matching " + opNS + "!=" + ifNS);
|
||||
}
|
||||
opQName = new QName(opNS, opName);
|
||||
} else {
|
||||
//no op specified in camel jbi uri
|
||||
opQName = null;
|
||||
String exOp = (String) exchange.getProperty(JBIBridgeExchange.JBI_OPERATION_PROP);
|
||||
if ( exOp != null && exOp.trim().length() > 0 ) {
|
||||
List opList = jbiConsumerEP.getWSDL().getPortType(ifQName).getOperations();
|
||||
if ( opList.size() > 1 ) {
|
||||
opQName = QName.valueOf(exOp.trim());
|
||||
String exOpNS = opQName.getNamespaceURI();
|
||||
if ( !ifNS.equals(exOpNS)) {
|
||||
throw new Exception("invalid namesapce: namespace for camel exchange operation and jbi endpoint operation are not matching " + exOpNS + "!=" + ifNS);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return opQName;
|
||||
}
|
||||
|
||||
public void process(JBIBridgeExchange exchange) throws Exception {
|
||||
RuntimeHelper.getLogger().fine("JBIBridgeProducer.process(JBIBridgeExchange)");
|
||||
// process exchange.
|
||||
CamelSEConsumerEndpoint jbiConsumerEP = this.endpoint.getJbiConsumerEP();
|
||||
if (jbiConsumerEP == null) {
|
||||
throw new IllegalStateException("No JBI Consumer Endpoint bound to the Camel JBI Endpoint " + this.endpoint.getEndpointUri());
|
||||
}
|
||||
QName opQName = getOperation(jbiConsumerEP, exchange);
|
||||
// if ( opQName == null ) {
|
||||
// throw new IllegalStateException("Cannot find the operation on jbi endpoint " + jbiConsumerEP.getID() + " for camel ep " + this.endpoint.getEndpointUri());
|
||||
// }
|
||||
JBIBridgeMessage msg = (JBIBridgeMessage) exchange.getIn();
|
||||
RuntimeHelper.getLogger().fine("##### JBIBridgeProducer.process processing IN message for operation " + opQName);
|
||||
|
||||
Object obj = msg.getBody();
|
||||
DOMSource inContent = RuntimeHelper.sourceToDOMSource((Source) obj);
|
||||
if ( RuntimeHelper.getLogger().isLoggable(Level.FINE) ) {
|
||||
RuntimeHelper.getLogger().fine(RuntimeHelper.readFromDOMSource(inContent).toString());
|
||||
}
|
||||
Source outContent = null;
|
||||
try {
|
||||
outContent = jbiConsumerEP.initiateMessageExchange(opQName, inContent);
|
||||
if ( outContent != null ) {
|
||||
RuntimeHelper.getLogger().fine("##### JBIBridgeProducer.process recevied OUT message ####");
|
||||
outContent = RuntimeHelper.sourceToDOMSource(outContent);
|
||||
RuntimeHelper.getLogger().fine(RuntimeHelper.readFromSource(outContent).toString());
|
||||
// check if JBIBridgeExchange is of *Out pattern
|
||||
if ( exchange.getPattern().equals(ExchangePattern.InOut)) {
|
||||
RuntimeHelper.getLogger().fine("##### JBIBridgeProducer.process settng OUT message ####");
|
||||
exchange.getOut().setBody(RuntimeHelper.sourceToDOMSource(outContent));
|
||||
}
|
||||
}
|
||||
} catch (JBIException jbiEx) {
|
||||
// fault
|
||||
jbiEx.printStackTrace();
|
||||
exchange.setException(jbiEx);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,138 @@
|
|||
/*
|
||||
* AbstractMessageExchangeHandler.java
|
||||
*
|
||||
*/
|
||||
|
||||
package org.openesb.components.camelse.common;
|
||||
|
||||
import java.io.StringReader;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.jbi.messaging.DeliveryChannel;
|
||||
import javax.jbi.messaging.ExchangeStatus;
|
||||
import javax.jbi.messaging.Fault;
|
||||
import javax.jbi.messaging.MessageExchange;
|
||||
import javax.jbi.messaging.MessagingException;
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
/**
|
||||
* This class is an abstract implementation of the MessageExchangeHandler which
|
||||
* provides the base implementation of the ME processing and provides hooks to
|
||||
* extended classes to implement component specific processing.
|
||||
*
|
||||
* @author chikkala
|
||||
*/
|
||||
public abstract class AbstractMessageExchangeHandler implements MessageExchangeHandler {
|
||||
|
||||
public static String IN_MESSAGE = "in";
|
||||
public static String OUT_MESSAGE = "out";
|
||||
|
||||
private MessageExchange mMessageExchange;
|
||||
private ExchangeStatus mStatus;
|
||||
/** Creates a new instance of AbstractMessageExchangeHandler */
|
||||
protected AbstractMessageExchangeHandler() {
|
||||
this.mMessageExchange = null;
|
||||
}
|
||||
|
||||
protected abstract Logger getLogger();
|
||||
protected abstract DeliveryChannel getDeliveryChannel();
|
||||
protected abstract void validateMessageExchange() throws MessagingException;
|
||||
protected abstract void processError(Exception ex);
|
||||
protected abstract void processDone();
|
||||
protected abstract void processMessage();
|
||||
protected abstract void processFault(Fault fault);
|
||||
|
||||
public final MessageExchange getMessageExchange() {
|
||||
return this.mMessageExchange;
|
||||
}
|
||||
|
||||
public final void setMessageExchange(MessageExchange msgExchange) {
|
||||
this.mMessageExchange = msgExchange;
|
||||
}
|
||||
|
||||
public final ExchangeStatus getMessageExchangeStatus() {
|
||||
if ( this.mStatus != null ) {
|
||||
return this.mStatus;
|
||||
} else if ( this.mMessageExchange != null ) {
|
||||
return this.mMessageExchange.getStatus();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public final void setMessageExchangeStatus(ExchangeStatus status) {
|
||||
this.mStatus = status;
|
||||
}
|
||||
|
||||
protected void send() throws MessagingException {
|
||||
this.getDeliveryChannel().send(this.mMessageExchange);
|
||||
}
|
||||
|
||||
protected boolean sendSync(long timeout) throws MessagingException {
|
||||
return this.getDeliveryChannel().sendSync(this.mMessageExchange, timeout);
|
||||
}
|
||||
|
||||
protected void sendDone() throws MessagingException {
|
||||
this.mMessageExchange.setStatus(ExchangeStatus.DONE);
|
||||
this.getDeliveryChannel().send(this.mMessageExchange);
|
||||
}
|
||||
|
||||
protected void sendError(Exception ex) throws MessagingException {
|
||||
this.mMessageExchange.setError(ex);
|
||||
this.getDeliveryChannel().send(this.mMessageExchange);
|
||||
}
|
||||
|
||||
protected void sendFault(Exception ex, QName type, String name) throws MessagingException {
|
||||
Fault fault = this.mMessageExchange.createFault();
|
||||
if ( ex != null ) {
|
||||
String xmlText = RuntimeHelper.getExceptionAsXmlText(ex);
|
||||
fault.setContent(RuntimeHelper.createDOMSource(new StringReader(xmlText)));
|
||||
}
|
||||
this.mMessageExchange.setFault(fault);
|
||||
this.getDeliveryChannel().send(this.mMessageExchange);
|
||||
}
|
||||
|
||||
protected void processActive() {
|
||||
Fault fault = this.getMessageExchange().getFault();
|
||||
if ( fault != null ) {
|
||||
processFault(fault);
|
||||
} else {
|
||||
processMessage();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* implementation of the MessageExchangeHandler#processMessageExchange method.
|
||||
*/
|
||||
public void processMessageExchange(ExchangeStatus status, MessageExchange msgEx) {
|
||||
|
||||
getLogger().fine("MessageExchangeHandler.processMessageExchange:status: " + status );
|
||||
|
||||
this.setMessageExchangeStatus(status);
|
||||
this.setMessageExchange(msgEx);
|
||||
|
||||
try {
|
||||
validateMessageExchange();
|
||||
} catch (MessagingException ex) {
|
||||
getLogger().log(Level.FINE, "Invalid message exchange for processing ", ex);
|
||||
if ( this.getMessageExchange() != null ) {
|
||||
try {
|
||||
sendError(ex);
|
||||
} catch (MessagingException errEx) {
|
||||
getLogger().log(Level.FINE, "Can not send invalid message exchange error", errEx);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
MessageExchange msgExchange = this.getMessageExchange();
|
||||
|
||||
if (ExchangeStatus.ACTIVE.equals(status) ) {
|
||||
processActive();
|
||||
} else if (ExchangeStatus.DONE.equals(status) ) {
|
||||
processDone();
|
||||
} else if (ExchangeStatus.ERROR.equals(status) ) {
|
||||
processError(msgExchange.getError());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,395 @@
|
|||
/*
|
||||
* AbstractComponentLifeCycle.java
|
||||
*/
|
||||
|
||||
package org.openesb.components.camelse.common;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.jbi.JBIException;
|
||||
import javax.jbi.component.Component;
|
||||
import javax.jbi.component.ComponentContext;
|
||||
import javax.jbi.component.ComponentLifeCycle;
|
||||
import javax.jbi.messaging.DeliveryChannel;
|
||||
import javax.jbi.messaging.MessagingException;
|
||||
import javax.management.MBeanServer;
|
||||
import javax.management.ObjectName;
|
||||
import javax.management.StandardMBean;
|
||||
|
||||
/**
|
||||
* This class implements the javax.jbi.component.ComponentLifeCycle. This is an
|
||||
* abstract class that keeps the reference to the component context and the lifecycle
|
||||
* extension mbeans. It implements the lifecycle method and provide the extended methods
|
||||
* for each lifecycle methods to implement component specific functionality.
|
||||
*<p>
|
||||
* It makes sure that the mininum initialization required for the component
|
||||
* lifecycle is implemented by this class or the classes extending this class.
|
||||
*<p>
|
||||
* Another important functionality implemented in this class is that it initializes the global
|
||||
* RuntimeContext for the component with the ComponentContext passed by the JBI runtime and the
|
||||
* opened delivery channel to make them available globally to any class in the component implementation
|
||||
* that may need it during component lifecycle
|
||||
*<p>
|
||||
* Service engine or a binding component lifecycle implementation can directly extend
|
||||
* this class for their required functionality and override some of the methods to provide
|
||||
* their own implementation.
|
||||
*
|
||||
* @see javax.jbi.ComponentLifeCycle
|
||||
* @author chikkala
|
||||
*/
|
||||
public class BasicComponentLifeCycle implements ComponentLifeCycle {
|
||||
/** reference to the component runtime */
|
||||
private Component mCompRuntime;
|
||||
/** component context */
|
||||
private ComponentContext mComponentContext;
|
||||
/** Extension Mbean Name*/
|
||||
private ObjectName mExtensionMBeanName;
|
||||
/** Extension Mbean Implementation*/
|
||||
private StandardMBean mExtensionMBeanImpl;
|
||||
/** a message receiver that accepts messages from delivery channel */
|
||||
private MessageExchangeReceiver mMsgExchReceiver;
|
||||
|
||||
/**
|
||||
* constructor for the ComponentLifecycle implementation.
|
||||
* @param compRuntime
|
||||
*/
|
||||
protected BasicComponentLifeCycle(Component compRuntime) {
|
||||
this.mCompRuntime = compRuntime;
|
||||
}
|
||||
/**
|
||||
* @return Component
|
||||
*/
|
||||
public final Component getComponentRuntime() {
|
||||
return this.mCompRuntime;
|
||||
}
|
||||
/**
|
||||
* @return ComponentContext component context.
|
||||
*/
|
||||
public final ComponentContext getComponentContext() {
|
||||
return mComponentContext;
|
||||
}
|
||||
/**
|
||||
* @return component name
|
||||
*/
|
||||
protected String getComponentName() {
|
||||
return (this.mComponentContext != null) ?
|
||||
this.mComponentContext.getComponentName() : null;
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// ComponentLifeCycle interface implemenation
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Initializes the component lifecycle. This method makes sure that the
|
||||
* component context passed by the jbi runtime is saved in the lifecycle
|
||||
* object before calling the other component initialization methods to
|
||||
* completely initialize the component.
|
||||
* @param context Component context
|
||||
* @see javax.jbi.component.ComponentLifeCycle#init(javax.jbi.component.ComponentContext)
|
||||
* @throws javax.jbi.JBIException on error
|
||||
*/
|
||||
public final void init(ComponentContext context) throws JBIException {
|
||||
|
||||
if ( context == null ) {
|
||||
throw new JBIException("Null Component Context received in " +
|
||||
"Component Lifecycle init ");
|
||||
}
|
||||
this.mComponentContext = context; // 0. save the component context passed by jbi framework.
|
||||
// initialize the content
|
||||
initGlobalContext(); // 1. Initialize component runtime context.
|
||||
registerExtensionMBean(); // 2. Create and register extension mbean.
|
||||
openDeliveryChannel(); // 3. Open delivery channel.
|
||||
initMessageExchangeReceiver(); // 4. Create message exchange receiver.
|
||||
doInit(); // 5. Do any component specific initialization such
|
||||
// as static service providers and consumers initialization.
|
||||
|
||||
this.getLogger().fine("Component " + this.getComponentName() + " initialized");
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the component. Extended classes can override/implement the methods called
|
||||
* in this method to provide component specify start functionality.
|
||||
*
|
||||
* @see javax.jbi.component.ComponentLifeCycle#start()
|
||||
* @throws javax.jbi.JBIException on error
|
||||
*/
|
||||
public final void start() throws JBIException {
|
||||
|
||||
doStart(); // 1. do any other component specific start tasks such as
|
||||
// activating any static service providers and consumers.
|
||||
startMessageExchangeProcessing(); // 2. begin accepting and processing message exchanges.
|
||||
|
||||
this.getLogger().fine("Component " + this.getComponentName() + " started");
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop the component.Extended classes can override/implement the methods called
|
||||
* in this method to provide component specify stop functionality.
|
||||
* @throws javax.jbi.JBIException
|
||||
* @see javax.jbi.component.ComponentLifeCycle#stop()
|
||||
*/
|
||||
public final void stop() throws JBIException {
|
||||
|
||||
stopMessageExchangeProcessing(); // 1. stop accepting and processing message exchanges.
|
||||
doStop(); // 2. do any other component specific stop tasks such as
|
||||
// deactivating any static service providers and consumers.
|
||||
this.getLogger().fine("Component " + this.getComponentName() + " stopped.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Shut down the component. Extended classes can override/implement the methods called
|
||||
* in this method to provide component specify shut down functionality.
|
||||
* @throws javax.jbi.JBIException
|
||||
* @see javax.jbi.component.ComponentLifeCycle#shutDown()
|
||||
*/
|
||||
public final void shutDown() throws JBIException {
|
||||
// clean up all resources.
|
||||
shutdownMessageExchangeReceiver(); // 1. remove the message receiver.
|
||||
closeDeliveryChannel(); // 2. close delivery channel
|
||||
unregisterExtensionMBean(); // 3. unregister and remove extension mbean if exists.
|
||||
doShutDown(); // 4. do any other component specific clean up tasks such
|
||||
// as clean any static service providers and consumer resource.
|
||||
this.getLogger().fine("Component " + this.getComponentName() + " shut down");
|
||||
}
|
||||
/**
|
||||
* create jmx object name for the extension mbean. default implementation does
|
||||
* not required to have the extension mbean.
|
||||
* @return ObjectName of the extension mbean
|
||||
*/
|
||||
protected ObjectName createExtensionMBeanName() {
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* gets the reference to the extension mbean name.
|
||||
* @see javax.jbi.component.ComponentLifeCycle#getExtensionMBeanName()
|
||||
* @return ObjectName of the extension mbean objectname or null if component
|
||||
* does not support extension mbean
|
||||
*/
|
||||
public final ObjectName getExtensionMBeanName() {
|
||||
if ( this.mExtensionMBeanName == null ) {
|
||||
this.mExtensionMBeanName = this.createExtensionMBeanName();
|
||||
}
|
||||
return this.mExtensionMBeanName;
|
||||
}
|
||||
/**
|
||||
* create mbean implementation for the extension mbean as a StandardMBean. default
|
||||
* implementation does not require the extension mbean
|
||||
* @return the ExtensionMBean implementation as StandardMBean
|
||||
*/
|
||||
protected StandardMBean createExtensionMBean() {
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* gets the reference to the extension mbean.
|
||||
* @return extension mbean implementation or null if component does not support.
|
||||
*/
|
||||
protected final StandardMBean getExtensionMBean() {
|
||||
if ( this.mExtensionMBeanImpl == null ) {
|
||||
this.mExtensionMBeanImpl = this.createExtensionMBean();
|
||||
}
|
||||
return this.mExtensionMBeanImpl;
|
||||
}
|
||||
/**
|
||||
* if there is an extension mbean supported by the component, then register
|
||||
* it with the mbean server.
|
||||
* @throws JBIException on error registering mbean
|
||||
*/
|
||||
protected final void registerExtensionMBean() throws JBIException {
|
||||
// creatre the extension mbean's object name
|
||||
ObjectName mbeanName = this.getExtensionMBeanName();
|
||||
// create the extension mbean implemenation.
|
||||
StandardMBean mbeanImpl = this.getExtensionMBean();
|
||||
|
||||
if ( mbeanName == null || mbeanImpl == null ) {
|
||||
this.getLogger().fine(this.getComponentName() +
|
||||
" Does not have Extension MBean implemenation ");
|
||||
return;
|
||||
}
|
||||
// register with mbean only if object name and implementation are non null
|
||||
try {
|
||||
MBeanServer mbServer = RuntimeHelper.getComponentContext().getMBeanServer();
|
||||
mbServer.registerMBean(mbeanImpl, mbeanName);
|
||||
} catch (Exception e) {
|
||||
throw new JBIException("Failed to register Extension MBean for " +
|
||||
this.getComponentName(), e);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* remove the registered extension mbean from the mbean server if any.
|
||||
*/
|
||||
protected final void unregisterExtensionMBean() {
|
||||
ObjectName mbeanName = this.getExtensionMBeanName();
|
||||
if ( mbeanName == null ) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
MBeanServer mbServer = RuntimeHelper.getComponentContext().getMBeanServer();
|
||||
mbServer.unregisterMBean(mbeanName);
|
||||
} catch (Exception e) {
|
||||
this.getLogger().log(Level.WARNING,
|
||||
"Failed to unregister Extension MBean from MBeanServer for " + this.getComponentName(), e);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* creates MessageExchangeReceiver implementation that handles receiving and processing
|
||||
* the message exchanges from the delivery channel. Component should implement
|
||||
* this method to provide the MessageReceiver.
|
||||
*
|
||||
* Component may return null indicating that they don't need the message receiver
|
||||
* that can receive and process message exchanges from delivery channel. For example,
|
||||
* components that have only service consumers which send a synchronous messages to
|
||||
* providers don't need this.
|
||||
*
|
||||
* @throws java.lang.Exception
|
||||
* @return MessageExchangeReceiver implementation. null if the component does not support it.
|
||||
* @see com.sun.jbi.sample.component.common.DefaultComponentLifecycle#createMessageExchangeReceiver
|
||||
*/
|
||||
protected MessageExchangeReceiver createMessageExchangeReceiver() {
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* returns the message exchange receiver implementation reference
|
||||
* @return MessageExchangeReceiver interface
|
||||
*/
|
||||
protected final MessageExchangeReceiver getMessageExchangeReceiver() {
|
||||
if ( this.mMsgExchReceiver == null ) {
|
||||
this.mMsgExchReceiver = createMessageExchangeReceiver();
|
||||
}
|
||||
return this.mMsgExchReceiver;
|
||||
}
|
||||
/**
|
||||
* creates a message receiver object as part of the component initialization.
|
||||
* @throws javax.jbi.JBIException
|
||||
*/
|
||||
protected void initMessageExchangeReceiver() throws JBIException {
|
||||
// create and initialize the MessageExchangeReceiver
|
||||
MessageExchangeReceiver mxReceiver = getMessageExchangeReceiver();
|
||||
if ( mxReceiver != null ) {
|
||||
mxReceiver.initReceiver();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* allows the component to accept the message exchange objects from the
|
||||
* delivery channel and process it as part of the component startup process.
|
||||
* @throws javax.jbi.JBIException
|
||||
*/
|
||||
protected void startMessageExchangeProcessing() throws JBIException {
|
||||
// start message processing
|
||||
MessageExchangeReceiver mxReceiver = getMessageExchangeReceiver();
|
||||
if ( mxReceiver != null ) {
|
||||
mxReceiver.startProcessing();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* stops the component from accepting the message exchange objects from the
|
||||
* delivery channel as part of the component stop process
|
||||
* @throws javax.jbi.JBIException
|
||||
*/
|
||||
protected void stopMessageExchangeProcessing() throws JBIException {
|
||||
// stop message processing
|
||||
MessageExchangeReceiver mxReceiver = getMessageExchangeReceiver();
|
||||
if ( mxReceiver != null ) {
|
||||
mxReceiver.stopProcessing();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* removes the message receiver as part of the component shutdown process
|
||||
* @throws javax.jbi.JBIException
|
||||
*/
|
||||
protected void shutdownMessageExchangeReceiver() throws JBIException {
|
||||
// clean up message processing.
|
||||
MessageExchangeReceiver mxReceiver = getMessageExchangeReceiver();
|
||||
if ( mxReceiver != null ) {
|
||||
mxReceiver.shutdownReceiver();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Returns logger initialized from the component context or a default logger.
|
||||
* @return Logger
|
||||
*/
|
||||
protected Logger getLogger() {
|
||||
return RuntimeHelper.getLogger();
|
||||
}
|
||||
/**
|
||||
* initializes the RuntimeContext during component init lifecycle phase. This
|
||||
* includes setting the ComponentContext and loggers etc. extended classes must
|
||||
* save the component context in the RuntimeContext in this methods implementation.
|
||||
* @see com.sun.jbi.sample.component.common.DefaultComponentLifecycle#initGlobalContext
|
||||
*/
|
||||
protected void initGlobalContext() {
|
||||
RuntimeContext.getInstance().setComponentContext(this.getComponentContext());
|
||||
RuntimeContext.getInstance().setLogger(this.getClass().getName(), null);
|
||||
}
|
||||
/** opens the delivery channel to accept or send message exchange objects
|
||||
* @see com.sun.jbi.sample.component.common.DefaultComponentLifecycle#openDeliveryChannel
|
||||
*/
|
||||
protected void openDeliveryChannel() {
|
||||
try {
|
||||
DeliveryChannel channel = this.getComponentContext().getDeliveryChannel();
|
||||
RuntimeContext.getInstance().setDeliveryChannel(channel);
|
||||
} catch (MessagingException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
/** closes the delivery channel as part of the component shutdown process.
|
||||
* @see com.sun.jbi.sample.component.common.DefaultComponentLifecycle#closeDeliveryChannel
|
||||
*/
|
||||
protected void closeDeliveryChannel() {
|
||||
// closes delivery channel and remove the reference.
|
||||
try {
|
||||
DeliveryChannel channel = RuntimeHelper.getDeliveryChannel();
|
||||
if ( channel != null ) {
|
||||
channel.close();
|
||||
}
|
||||
} catch (MessagingException ex) {
|
||||
ex.printStackTrace();
|
||||
} finally {
|
||||
RuntimeContext.getInstance().setDeliveryChannel(null);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* chance to extended classes to do any extra component specific init tasks. If the component
|
||||
* supports static service providers or consumers without deployment support, they can be
|
||||
* initialized here in the class extended from this class in implementing such a component.
|
||||
* This method is invoked in the implementation of ComponentLifeCycle#init method by this class.
|
||||
* @throws javax.jbi.JBIException
|
||||
* @see com.sun.jbi.sample.component.common.AbstractComponentLifecycle#init
|
||||
*/
|
||||
protected void doInit() throws JBIException {
|
||||
//NOOP
|
||||
}
|
||||
/**
|
||||
* chance to extended classes to do any extra component specific start tasks. If the component
|
||||
* supports static service providers or consumers without deployment support, they can be
|
||||
* activated here in the class extended from this class in implementing such a component.
|
||||
* This method is invoked in the implementation of ComponentLifeCycle#start method by this class.
|
||||
* @throws javax.jbi.JBIException
|
||||
* @see com.sun.jbi.sample.component.common.AbstractComponentLifecycle#start
|
||||
*/
|
||||
protected void doStart() throws JBIException {
|
||||
//NOOP
|
||||
}
|
||||
/**
|
||||
* chance to extended classes to do any extra component specific stop tasks. If the component
|
||||
* supports static service providers or consumers without deployment support, they can be
|
||||
* deactivated here in the class extended from this class in implementing such a component.
|
||||
* This method is invoked in the implementation of ComponentLifeCycle#stop method by this class.
|
||||
* @throws javax.jbi.JBIException
|
||||
* @see com.sun.jbi.sample.component.common.AbstractComponentLifecycle#stop
|
||||
*/
|
||||
protected void doStop() throws JBIException {
|
||||
//NOOP
|
||||
}
|
||||
/**
|
||||
* chance to extended classes to do any extra component specific shutdown tasks.If the component
|
||||
* supports static service providers or consumers without deployment support, they can be
|
||||
* cleaned up here in the class extended from this class in implementing such a component.
|
||||
* This method is invoked in the implementation of ComponentLifeCycle#shutdown method by this class.
|
||||
* @throws javax.jbi.JBIException
|
||||
* @see com.sun.jbi.sample.component.common.AbstractComponentLifecycle#shutdown
|
||||
*/
|
||||
protected void doShutDown() throws JBIException {
|
||||
//NOOP
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,272 @@
|
|||
/*
|
||||
* ComponentInstaller.java
|
||||
*/
|
||||
package org.openesb.components.camelse.common;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import javax.jbi.component.Bootstrap;
|
||||
import javax.jbi.component.InstallationContext;
|
||||
import java.util.logging.Logger;
|
||||
import javax.jbi.JBIException;
|
||||
import javax.management.MBeanServer;
|
||||
import javax.management.ObjectName;
|
||||
import javax.management.StandardMBean;
|
||||
|
||||
/**
|
||||
* This class implements the javax.jbi.component.Bootstrap. This class implements
|
||||
* the minimum required functionality for component installation contract
|
||||
* of the jbi component in the jbi environment. It also takes care of maintaining
|
||||
* the installation context reference and installation specific logger creation and
|
||||
* installation extension mbean registration and unregistration during initialization
|
||||
* and cleanup. Extended classes only need to supply the mbean name and its implementation
|
||||
* object for the installation extensions.
|
||||
*
|
||||
* It makes sure that the installation context and the loggers are available to
|
||||
* the classes extended from this class to add more installation specific functionality.
|
||||
*
|
||||
* Service engine or a binding component installation implementation can directly use
|
||||
* this class or extend this class to add more functionality to their installation
|
||||
* process.
|
||||
*
|
||||
* @see javax.jbi.Bootstrap
|
||||
* @author chikkala
|
||||
*/
|
||||
public class ComponentInstaller implements Bootstrap {
|
||||
/** default logger*/
|
||||
private Logger mDefLogger;
|
||||
/** bootstrap logger */
|
||||
private Logger mBTLogger ;
|
||||
/** Installation Context . */
|
||||
private InstallationContext mInstallationContext;
|
||||
/** Extension Mbean Name*/
|
||||
private ObjectName mExtensionMBeanName;
|
||||
/** Extension Mbean Implementation*/
|
||||
private StandardMBean mExtensionMBeanImpl;
|
||||
|
||||
/** Constructor to create the ComponentInstaller. */
|
||||
public ComponentInstaller() {
|
||||
}
|
||||
/**
|
||||
* @return InstallationContext of the component.
|
||||
*/
|
||||
public final InstallationContext getInstallationContext() {
|
||||
return this.mInstallationContext;
|
||||
}
|
||||
protected String getComponentName() {
|
||||
return (this.mInstallationContext != null) ?
|
||||
this.mInstallationContext.getComponentName() : null;
|
||||
}
|
||||
/**
|
||||
* @return logger initialized from the installation context or a default
|
||||
* logger.
|
||||
*/
|
||||
protected Logger getLogger() {
|
||||
// try init bootstrap logger
|
||||
if (this.mBTLogger == null && this.mInstallationContext != null ) {
|
||||
try {
|
||||
this.mBTLogger =
|
||||
this.mInstallationContext.getContext().getLogger(this.getClass().getName(), null);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
// init default logger if required
|
||||
if ( this.mBTLogger == null && this.mDefLogger == null) {
|
||||
this.mDefLogger = Logger.getLogger(this.getClass().getName(), null);
|
||||
}
|
||||
return (this.mBTLogger != null) ? this.mBTLogger : this.mDefLogger;
|
||||
}
|
||||
/**
|
||||
* Initializes the installation environment for a component.
|
||||
* @see javax.jbi.component.Bootstrap#init(javax.jbi.component.InstallationContext)
|
||||
*/
|
||||
public final void init(InstallationContext installContext) throws javax.jbi.JBIException {
|
||||
|
||||
if ( installContext == null ) {
|
||||
throw new JBIException("Null Installation Context received in " +
|
||||
"Component Bootstrap initialization");
|
||||
}
|
||||
// save the installation context reference passed by the jbi framework.
|
||||
this.mInstallationContext = installContext;
|
||||
registerExtensionMBean(); // create and register extension mbean
|
||||
doInit(); // do any other extra initialization required specific to the component installation.
|
||||
// initialize logger
|
||||
this.getLogger().fine(this.mInstallationContext.getComponentName() +
|
||||
" : Component Installer initialized");
|
||||
}
|
||||
/**
|
||||
* default implementation just logs the method call. extended classes should override this.
|
||||
* @see javax.jbi.component.Bootstrap#onInstall()
|
||||
*/
|
||||
public void onInstall() throws javax.jbi.JBIException {
|
||||
//TODO: do required initializaton and resource creation
|
||||
this.getLogger().fine(this.mInstallationContext.getComponentName() +
|
||||
" : Component installed.");
|
||||
}
|
||||
/**
|
||||
* default implementation just logs the method call.
|
||||
* @see javax.jbi.component.Bootstrap#onUninstall()
|
||||
*/
|
||||
public void onUninstall() throws javax.jbi.JBIException {
|
||||
//TODO: do clean up the resource and other stuff.
|
||||
this.getLogger().fine(this.mInstallationContext.getComponentName() +
|
||||
" : Component uninstalled");
|
||||
}
|
||||
/**
|
||||
* default noop implementation of the cleanup.
|
||||
* @see javax.jbi.component.Bootstrap#cleanUp()
|
||||
*/
|
||||
public final void cleanUp() throws javax.jbi.JBIException {
|
||||
|
||||
unregisterExtensionMBean(); // unregister extension mbean and remove it
|
||||
doCleanUp(); // do any other extra cleanup specific to the component installation.
|
||||
this.getLogger().fine( this.mInstallationContext.getComponentName() +
|
||||
" Component Installer Cleaned up");
|
||||
}
|
||||
|
||||
/**
|
||||
* create jmx object name for the extension mbean. Extended classes should
|
||||
* return the component specific installer extension mbean name here.
|
||||
*/
|
||||
protected ObjectName createExtensionMBeanName() {
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* default implementation that does not have extension mbean return null.
|
||||
* @see javax.jbi.component.Bootstrap#getExtensionMBeanName()
|
||||
*/
|
||||
public final javax.management.ObjectName getExtensionMBeanName() {
|
||||
if ( this.mExtensionMBeanName == null ) {
|
||||
this.mExtensionMBeanName = createExtensionMBeanName();
|
||||
}
|
||||
return this.mExtensionMBeanName;
|
||||
}
|
||||
/**
|
||||
* create mbean implementation for the extension mbean as a StandardMBean. Extended
|
||||
* classes should return the installer extension mbean implementation as the
|
||||
* standard mbean.
|
||||
*/
|
||||
protected StandardMBean createExtensionMBean() {
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* returns the installation extension mbean implementation.
|
||||
* @return StandardMBean for the extension mbean implementation.
|
||||
*/
|
||||
protected final StandardMBean getExtensionMBean() {
|
||||
if ( this.mExtensionMBeanImpl == null ) {
|
||||
this.mExtensionMBeanImpl = this.createExtensionMBean();
|
||||
}
|
||||
return this.mExtensionMBeanImpl;
|
||||
}
|
||||
/**
|
||||
* Chance to extended classes to do the component installation specific init.
|
||||
* Installation context will be initialized before calling this method. So,
|
||||
* initialize other things if required in this method.
|
||||
* @throws javax.jbi.JBIException on error
|
||||
* @see com.sun.jbi.sample.component.common.ComponentInstaller#init(
|
||||
* javax.jbi.component.InstallationContext)
|
||||
*/
|
||||
protected void doInit() throws JBIException {
|
||||
this.getLogger().info(this.getInstallationContext().getComponentName() +
|
||||
" : Component Installer initialized");
|
||||
}
|
||||
/**
|
||||
* Chance to extended classes to do the component installation specific cleanup.
|
||||
* ExtensionMbean will be unregistered before calling this method.
|
||||
* @throws javax.jbi.JBIException on error
|
||||
* @see com.sun.jbi.sample.component.common.ComponentInstaller#cleanUp(
|
||||
* javax.jbi.component.InstallationContext)
|
||||
*/
|
||||
protected void doCleanUp() throws JBIException {
|
||||
this.getLogger().fine(this.getInstallationContext().getComponentName() +
|
||||
" : Component Installer doCleanUp");
|
||||
}
|
||||
/**
|
||||
* if there is an extension mbean supported by the component, then register
|
||||
* it with the mbean server.
|
||||
*/
|
||||
protected void registerExtensionMBean() throws JBIException {
|
||||
// creatre the installation extension mbean's object name
|
||||
ObjectName mbeanName = this.getExtensionMBeanName();
|
||||
// create the extension mbean implemenation if the object name is created.
|
||||
StandardMBean mbeanImpl = this.getExtensionMBean();
|
||||
|
||||
if ( mbeanName == null || mbeanImpl == null ) {
|
||||
this.getLogger().fine(this.getComponentName() +
|
||||
" Does not have Installation Extension MBean implemenation ");
|
||||
return;
|
||||
}
|
||||
// register with mbean only if object name and implementation are non null
|
||||
try {
|
||||
MBeanServer mbServer = this.getInstallationContext().getContext().getMBeanServer();
|
||||
mbServer.registerMBean(mbeanImpl, mbeanName);
|
||||
} catch (Exception e) {
|
||||
throw new JBIException("Failed to register Installation Extension MBean for "
|
||||
+ this.getComponentName(), e);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* remove the registered extension mbean from the mbean server.
|
||||
*/
|
||||
protected void unregisterExtensionMBean() {
|
||||
ObjectName mbeanName = this.getExtensionMBeanName();
|
||||
if ( mbeanName == null ) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
MBeanServer mbServer = this.getInstallationContext().getContext().getMBeanServer();
|
||||
mbServer.unregisterMBean(mbeanName);
|
||||
} catch (Exception e) {
|
||||
this.getLogger().log(Level.WARNING,
|
||||
"Failed to unregister Installation extension MBean for " + this.getComponentName(), e);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* This method is called by the JBI runtime to allow a component to upgrade
|
||||
* it's workspace and any existing Service Units to match the new version of
|
||||
* the component. The JBI runtime copies the existing workspace root to the
|
||||
* new workspace root prior to calling this method, so that the component
|
||||
* can examine the contents of the workspace root to determine the version
|
||||
* of the component from which the upgrade is being made. All updates to the
|
||||
* workspace root are done in-place; in the event of a failure, the JBI
|
||||
* runtime reverts back to the original workspace root, the original install
|
||||
* root, and the original Service Unit roots for the component.
|
||||
*
|
||||
* Note1: The component must ensure that it never holds open references
|
||||
* to any files in the workspace root or any of the Service Unit roots upon
|
||||
* returning from this method. Failure to do so will cause problems when
|
||||
* the runtime attempts to complete the upgrade processing.
|
||||
*
|
||||
* Note2: The installation context that is normally initialized
|
||||
* by the runtime by calling #init method of the javax.jbi.Bootstrap interface
|
||||
* before install and uninstall will not be called before calling this
|
||||
* upgrade method. So, installation context can not be used in this method's
|
||||
* implementation.
|
||||
*
|
||||
* Note3: Since there won't be any installation context available, the logger
|
||||
* that returned from the #getLogger method is a default logger created using
|
||||
* the package name of this class or extended class if the method is overridden
|
||||
* in the extended class.
|
||||
*
|
||||
* @param workspaceRoot the workspace root for the new version of the
|
||||
* component that will replace the currently installed version. This is
|
||||
* populated with the contents of the original workspace root and the
|
||||
* component must update it to match the new version of the component.
|
||||
* @param serviceUnitRoots a list of directory paths to all of the Service
|
||||
* Units currently deployed to the component. The component must update all
|
||||
* of these to match the new version of the component.
|
||||
* @exception JBIException when there is an error requiring that the upgrade
|
||||
* be terminated.
|
||||
*/
|
||||
public void upgrade(String workspaceRoot, List<String> serviceUnitRoots)
|
||||
throws javax.jbi.JBIException
|
||||
{
|
||||
//TODO: override this method in the extended class to handle the
|
||||
// workspace root and service unit roots upgrade according to the
|
||||
// component's requirement.
|
||||
this.getLogger().fine("Default upgrade implementation. " +
|
||||
"TODO: Implement workspace root and service unit roots upgrade.");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,171 @@
|
|||
/*
|
||||
* ComponentRuntime.java
|
||||
*/
|
||||
package org.openesb.components.camelse.common;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
import javax.jbi.component.Component;
|
||||
import javax.jbi.component.ComponentContext;
|
||||
import javax.jbi.component.ComponentLifeCycle;
|
||||
import javax.jbi.component.ServiceUnitManager;
|
||||
import javax.jbi.messaging.MessageExchange;
|
||||
import javax.jbi.servicedesc.ServiceEndpoint;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.DocumentFragment;
|
||||
|
||||
/**
|
||||
* This class implements javax.jbi.component.Component interface which is
|
||||
* responsible for creating the Component Lifecycle implementation and the
|
||||
* ServiceUnitManager implementation for the jbi component.
|
||||
*
|
||||
* This class makes sure that non null component lifecycle implementation is
|
||||
* returns by this class or any classes extended from this class which is
|
||||
* required as a component contract. It also provides default implementation of
|
||||
* all methods of the Component interface which the extended classes can
|
||||
* override to add more functionality.
|
||||
*
|
||||
* @see javax.jbi.component.Component
|
||||
* @author chikkala
|
||||
*/
|
||||
public class ComponentRuntime implements Component {
|
||||
/** Component LifeCycle implementation */
|
||||
private ComponentLifeCycle mLifeCycle;
|
||||
/** ServiceUnitManager implementation */
|
||||
private ServiceUnitManager mSUManager;
|
||||
/** default logger*/
|
||||
private Logger mDefLogger;
|
||||
|
||||
/** Creates a new instance of ComponentImpl */
|
||||
public ComponentRuntime() {
|
||||
this.mLifeCycle = null;
|
||||
this.mSUManager = null;
|
||||
}
|
||||
/**
|
||||
* returns the ComponentContext. Any component runtime class extended from
|
||||
* this class can override this method to return their own reference to the
|
||||
* ComponentContext.
|
||||
* @return ComponentContext component context.
|
||||
*/
|
||||
public ComponentContext getComponentContext() {
|
||||
ComponentContext ctx = null;
|
||||
if ( this.mLifeCycle != null && this.mLifeCycle instanceof BasicComponentLifeCycle ) {
|
||||
ctx = ((BasicComponentLifeCycle) this.mLifeCycle).getComponentContext();
|
||||
}
|
||||
return ctx;
|
||||
}
|
||||
/**
|
||||
* Returns logger initialized from the component context or a default logger.
|
||||
* @return Logger
|
||||
*/
|
||||
public Logger getLogger() {
|
||||
Logger logger = null;
|
||||
if ( this.mLifeCycle != null && this.mLifeCycle instanceof BasicComponentLifeCycle ) {
|
||||
logger = ((BasicComponentLifeCycle) this.mLifeCycle).getLogger();
|
||||
}
|
||||
// init default logger if required
|
||||
if ( logger == null && this.mDefLogger == null) {
|
||||
this.mDefLogger = Logger.getLogger(this.getClass().getName(), null);
|
||||
}
|
||||
return (logger != null) ? logger : this.mDefLogger;
|
||||
}
|
||||
/**
|
||||
* return the ComponentLifeCycle implementation. if returned null, the
|
||||
* ComponentLifeCycleImpl will be used as the component lifecycle
|
||||
* Extended classes can override this method and do their own ComponentLifecyle
|
||||
* specific creation.
|
||||
*/
|
||||
protected ComponentLifeCycle createComponentLifeCycle() {
|
||||
return new BasicComponentLifeCycle(this);
|
||||
}
|
||||
/**
|
||||
* Get the life cycle control interface for this component.
|
||||
*
|
||||
* @return the life cycle control interface for this component
|
||||
* @see javax.jbi.Component#getLifeCycle()
|
||||
*/
|
||||
public final ComponentLifeCycle getLifeCycle() {
|
||||
if ( this.mLifeCycle == null ) {
|
||||
this.mLifeCycle = createComponentLifeCycle();
|
||||
if ( this.mLifeCycle == null ) {
|
||||
this.getLogger().fine("Creating basic component lifecycle implemenation");
|
||||
// use the default ComponentLifeCycle Impl if a component
|
||||
// specific implementation return null in createComponentLifeCycle.
|
||||
this.mLifeCycle = new BasicComponentLifeCycle(this);
|
||||
}
|
||||
}
|
||||
return this.mLifeCycle;
|
||||
}
|
||||
/**
|
||||
* if this component supports service unit deployment, then return the
|
||||
* service unit manager, else return null.
|
||||
* Extended classes can override this method and do their own ServiceUnitManager
|
||||
* specific creation.
|
||||
*/
|
||||
protected ServiceUnitManager createServiceUnitManager() {
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Get the Service Unit manager for this component.
|
||||
*
|
||||
* @return the <code>ServiceUnitManager</code> for this component, or
|
||||
* <code>null</code> if there is none.
|
||||
* @see javax.jbi.Component#getServiceUnitManager()
|
||||
*/
|
||||
public final ServiceUnitManager getServiceUnitManager() {
|
||||
if ( this.mSUManager == null ) {
|
||||
this.mSUManager = createServiceUnitManager();
|
||||
}
|
||||
return this.mSUManager;
|
||||
}
|
||||
/**
|
||||
* Retrieves a DOM representation containing metadata which describes the
|
||||
* service provided by this component, through the given endpoint.
|
||||
*
|
||||
* Default implementation does not support service description.
|
||||
*
|
||||
* @see javax.jbi.Component#getServiceDescription(javax.jbi.servicedesc.ServiceEndpoint)
|
||||
*/
|
||||
public Document getServiceDescription(ServiceEndpoint serviceEndpoint) {
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* This method is called by JBI to check if this component, in the role of
|
||||
* provider of the service indicated by the given exchange, can actually
|
||||
* perform the operation desired.
|
||||
*
|
||||
* Default implementation has no policy and allows all exchanges with consumer.
|
||||
*
|
||||
* @see javax.jbi.Component#isExchangeWithProviderOkay(
|
||||
* javax.jbi.servicedesc.ServiceEndpoint, javax.jbi.messaging.MessageExchange)
|
||||
*/
|
||||
public boolean isExchangeWithConsumerOkay(
|
||||
ServiceEndpoint serviceEndpoint, MessageExchange messageExchange) {
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* This method is called by JBI to check if this component, in the role of
|
||||
* consumer of the service indicated by the given exchange, can actually
|
||||
* interact with the provider properly. The provider is described by the
|
||||
* given endpoint and the service description supplied by that endpoint.
|
||||
*
|
||||
* Default implementation has no policy and allows all exchanges with provider.
|
||||
*
|
||||
* @see javax.jbi.Component#isExchangeWithProviderOkay(
|
||||
* javax.jbi.servicedesc.ServiceEndpoint, javax.jbi.messaging.MessageExchange)
|
||||
*/
|
||||
public boolean isExchangeWithProviderOkay(
|
||||
ServiceEndpoint serviceEndpoint, MessageExchange messageExchange) {
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Resolve the given endpoint reference.
|
||||
*
|
||||
* Default implementation does not have any XML dialect. So can not resolve the
|
||||
* endpoint from the document fragment.
|
||||
*
|
||||
* @see javax.jbi.Component#resolveEndpointReference(org.w3c.dom.DocumentFragment)
|
||||
*/
|
||||
public ServiceEndpoint resolveEndpointReference(DocumentFragment documentFragment) {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,177 @@
|
|||
/*
|
||||
* DefaultMessageExchangeReceiver.java
|
||||
*
|
||||
*/
|
||||
|
||||
package org.openesb.components.camelse.common;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import javax.jbi.JBIException;
|
||||
import javax.jbi.messaging.DeliveryChannel;
|
||||
import javax.jbi.messaging.ExchangeStatus;
|
||||
import javax.jbi.messaging.MessageExchange;
|
||||
import javax.jbi.messaging.MessagingException;
|
||||
|
||||
/**
|
||||
* This class implements MessageExchangeReceiver interface. This is a default implementation that
|
||||
* demonstrates the multi-threaded environment to receive and process message exchanges from the
|
||||
* delivery channel. It uses a main thread to receive message exchanges from the delivery channel
|
||||
* and then processes the received message exchanges in a individual threads from the thread pool.
|
||||
* The controller methods of MessageExchangeReceiver controls the main thread and the thread pool
|
||||
* execution.
|
||||
*
|
||||
* @author chikkala
|
||||
*/
|
||||
public class DefaultMessageExchangeReceiver implements MessageExchangeReceiver {
|
||||
|
||||
/** delivery channel accept time out */
|
||||
private final static long DC_ACCEPT_TIME_OUT = 3000; // milliseconds
|
||||
/** receiver thread wait time before polling for messages after woke up **/
|
||||
private final static long RECEIVER_WAIT_TIME = 2000; // milliseconds
|
||||
/** receiver thread wait time before force shutdown */
|
||||
private final static long RECEIVER_SHUTDOWN_WAIT_TIME = 10; // seconds
|
||||
/** handler threads wait time before forced shutdown */
|
||||
private final static long HANDLERS_SHUTDOWN_WAIT_TIME = 30; // seconds
|
||||
/** handler thread pool size */
|
||||
private final static int HANDLER_THREAD_POOL_SIZE = 5;
|
||||
/** receiver thread accept message exchange condition */
|
||||
private Boolean mCanAccept = false;
|
||||
/** receiver thread termination condition */
|
||||
private Boolean mContinue = true;
|
||||
/** receiver thread executor service */
|
||||
private ExecutorService mReceiverThreadMgr;
|
||||
/** handler thread executor service */
|
||||
private ExecutorService mHandlerThreadPool;
|
||||
|
||||
/** no default constructor for extended classes */
|
||||
public DefaultMessageExchangeReceiver() {
|
||||
}
|
||||
/**
|
||||
* this method is called from the ComponentLifecyle.init method of the AbstractComponentLifecycle
|
||||
* to initialize the message exchange receiving resources such as threads and thread pools
|
||||
* throws JBIException on error
|
||||
*/
|
||||
public final void initReceiver() throws JBIException {
|
||||
|
||||
this.mHandlerThreadPool = Executors.newFixedThreadPool(HANDLER_THREAD_POOL_SIZE);
|
||||
this.mReceiverThreadMgr = Executors.newSingleThreadExecutor();
|
||||
|
||||
this.mReceiverThreadMgr.execute(new Runnable() {
|
||||
public void run() {
|
||||
Thread t = Thread.currentThread();
|
||||
while ( mContinue ) {
|
||||
if (mCanAccept) {
|
||||
receiveAndProcessMessageExchange();
|
||||
} else {
|
||||
try {
|
||||
t.sleep(RECEIVER_WAIT_TIME);
|
||||
} catch (InterruptedException interruptException) {
|
||||
// someone must have interrupted this thread
|
||||
// do nothing
|
||||
RuntimeHelper.logDebug("Interrupted the MessageReceiverThread in Sleep");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* this method is called from the ComponentLifecyle.shutdown method of the AbstractComponentLifecycle
|
||||
* to cleanup the message exchange receiving resources such as threads and thread pools.
|
||||
* throws JBIException on error
|
||||
*/
|
||||
public final void shutdownReceiver() throws JBIException {
|
||||
|
||||
synchronized ( mContinue ) {
|
||||
mContinue = false;
|
||||
}
|
||||
boolean terminated = false;
|
||||
try {
|
||||
this.mReceiverThreadMgr.shutdown();
|
||||
terminated = this.mReceiverThreadMgr.awaitTermination(
|
||||
RECEIVER_SHUTDOWN_WAIT_TIME, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException ex) {
|
||||
RuntimeHelper.logDebug(ex);
|
||||
} finally {
|
||||
if ( !terminated ) {
|
||||
RuntimeHelper.logDebug("Message Receiver not shutdown. Forcing shutdown");
|
||||
this.mReceiverThreadMgr.shutdownNow();
|
||||
}
|
||||
}
|
||||
shutdownHandlers();
|
||||
}
|
||||
/**
|
||||
* shutdown all the working threads from the thread pool.
|
||||
*/
|
||||
private final void shutdownHandlers() throws JBIException {
|
||||
|
||||
boolean terminated = false;
|
||||
try {
|
||||
this.mHandlerThreadPool.shutdown();
|
||||
terminated = this.mHandlerThreadPool.awaitTermination(
|
||||
HANDLERS_SHUTDOWN_WAIT_TIME, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException ex) {
|
||||
RuntimeHelper.logDebug(ex);
|
||||
} finally {
|
||||
if ( !terminated ) {
|
||||
RuntimeHelper.logDebug("Handler threads not shutdown. Forcing shutdown");
|
||||
this.mHandlerThreadPool.shutdownNow();
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* this method is called from the ComponentLifecyle.start method of the AbstractComponentLifecycle
|
||||
* to start receiving the message exchanges from the delivery channel and process them.
|
||||
* throws JBIException on error
|
||||
*/
|
||||
public final void startProcessing() throws JBIException {
|
||||
|
||||
synchronized ( this.mCanAccept ) {
|
||||
this.mCanAccept = true;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* this method is called from the ComponentLifecyle.stop method of the AbstractComponentLifecycle
|
||||
* to stop receiving the message exchanges from the delivery channel.
|
||||
* throws JBIException on error
|
||||
*/
|
||||
public final void stopProcessing() throws JBIException {
|
||||
|
||||
synchronized ( this.mCanAccept ) {
|
||||
this.mCanAccept = false;
|
||||
}
|
||||
}
|
||||
|
||||
protected MessageExchangeSupport getMessageExchangeSupport() {
|
||||
return RuntimeHelper.getMessageExchangeSupport();
|
||||
}
|
||||
|
||||
private void receiveAndProcessMessageExchange() {
|
||||
try {
|
||||
DeliveryChannel channel = RuntimeHelper.getDeliveryChannel();
|
||||
if ( channel == null ) {
|
||||
RuntimeHelper.logDebug("DeliveryChannel Not Opened for receiving messages");
|
||||
return;
|
||||
}
|
||||
final MessageExchange msgExchange = channel.accept(DC_ACCEPT_TIME_OUT);
|
||||
if ( msgExchange == null ) {
|
||||
// delivery channel timeout occurred. do nothing.
|
||||
// RuntimeHelper.logDebug("DeliveryChannel returned null message exchange from accept");
|
||||
return;
|
||||
}
|
||||
final ExchangeStatus status = msgExchange.getStatus();
|
||||
// process message exchange in a separate thread
|
||||
this.mHandlerThreadPool.execute(new Runnable() {
|
||||
public void run() {
|
||||
getMessageExchangeSupport().fireMessageExchangeReceived(status, msgExchange);
|
||||
}
|
||||
});
|
||||
|
||||
} catch (MessagingException ex) {
|
||||
RuntimeHelper.logWarning(ex);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* MessageExchangeHandler.java
|
||||
*
|
||||
*/
|
||||
|
||||
package org.openesb.components.camelse.common;
|
||||
|
||||
import javax.jbi.messaging.ExchangeStatus;
|
||||
import javax.jbi.messaging.MessageExchange;
|
||||
|
||||
/**
|
||||
* This interface is a Handler to perform message exchanges when the component
|
||||
* receives the MessageExchange object from the delivery channel.
|
||||
* Implementation of this interface should implement the processing of
|
||||
* the active, error, done status of the MessageExchange object according to
|
||||
* the MEP for which the MessageExchange object is created.
|
||||
*
|
||||
* @author chikkala
|
||||
*/
|
||||
public interface MessageExchangeHandler {
|
||||
/**
|
||||
* this method will be invoked to process the MessageExchange
|
||||
* object.
|
||||
* @param msgExchange MessageExchange object to process.
|
||||
*/
|
||||
void processMessageExchange(ExchangeStatus status, MessageExchange msgExchange);
|
||||
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* MessageExchangeListener.java
|
||||
*/
|
||||
|
||||
package org.openesb.components.camelse.common;
|
||||
|
||||
import javax.jbi.messaging.ExchangeStatus;
|
||||
import javax.jbi.messaging.MessageExchange;
|
||||
|
||||
/**
|
||||
* This interface defines the notification mechanism with which the message exchange object received
|
||||
* from the delivery channel is processed by the interesting parties. A particular service endpoint
|
||||
* implementation would first register the implementation of this interface with MessageExchangeSupport
|
||||
* to get the notification of a received message exchange on a particular service endpoint and the
|
||||
* implementation of the interface would process the message exchange when notified.
|
||||
*
|
||||
* When the com.sun.jbi.sample.component.common.DefaultMessageExchangeReceiver receives the message exchange
|
||||
* object, it asks the MessageExchangeSupport to notify the MessageExchangeLister that is registered for the
|
||||
* received message exchange object to process the message exchange object.
|
||||
* @see com.sun.jbi.sample.component.common.MessageExchangeSupport
|
||||
* @see com.sun.jbi.sample.component.common.DefaultMessageExchangeReceiver
|
||||
* @see com.sun.jbi.sample.component.common.deployment.ProviderEndpoint
|
||||
* @see com.sun.jbi.sample.component.common.deployment.ProviderEndpoint
|
||||
* @author chikkala
|
||||
*/
|
||||
public interface MessageExchangeListener {
|
||||
/**
|
||||
* MessageExchangeSupport will call this method to notify the lister implementation that a
|
||||
* message exchange is received from the delivery channel.
|
||||
* @param me MessageExchange Object
|
||||
*/
|
||||
void messageExchangeReceived(ExchangeStatus status, MessageExchange me);
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* MessageExchangeReceiver.java
|
||||
*
|
||||
*/
|
||||
|
||||
package org.openesb.components.camelse.common;
|
||||
|
||||
import javax.jbi.JBIException;
|
||||
|
||||
/**
|
||||
* This interface provides the methods can controls the receiving and processing of the message
|
||||
* exchange objects from the delivery channel during the component lifecycle operations.
|
||||
* The implementation of this interface can use multi-threaded environment to receive and process
|
||||
* message exchanges from the delivery channel during the component lifecycle.
|
||||
* @see com.sun.jbi.sample.component.common.DefaultMessageExchangeReceiver
|
||||
* @author chikkala
|
||||
*/
|
||||
public interface MessageExchangeReceiver {
|
||||
/**
|
||||
* this method is called from the ComponentLifecyle.init method of the AbstractComponentLifecycle
|
||||
* to initialize the message exchange receiving resources such as threads and thread pools
|
||||
* throws JBIException on error
|
||||
*/
|
||||
void initReceiver() throws JBIException;
|
||||
/**
|
||||
* this method is called from the ComponentLifecyle.start method of the AbstractComponentLifecycle
|
||||
* to start receiving the message exchanges from the delivery channel and process them.
|
||||
* throws JBIException on error
|
||||
*/
|
||||
void startProcessing() throws JBIException;
|
||||
/**
|
||||
* this method is called from the ComponentLifecyle.stop method of the AbstractComponentLifecycle
|
||||
* to stop receiving the message exchanges from the delivery channel.
|
||||
* throws JBIException on error
|
||||
*/
|
||||
void stopProcessing() throws JBIException;
|
||||
/**
|
||||
* this method is called from the ComponentLifecyle.shutdown method of the AbstractComponentLifecycle
|
||||
* to cleanup the message exchange receiving resources such as threads and thread pools.
|
||||
* throws JBIException on error
|
||||
*/
|
||||
void shutdownReceiver() throws JBIException;
|
||||
|
||||
}
|
|
@ -0,0 +1,167 @@
|
|||
/*
|
||||
* MessageExchangeSupport.java
|
||||
*
|
||||
*/
|
||||
|
||||
package org.openesb.components.camelse.common;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.jbi.messaging.ExchangeStatus;
|
||||
import javax.jbi.messaging.MessageExchange;
|
||||
import javax.jbi.messaging.MessageExchange.Role;
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
/**
|
||||
* This class supports the registering and unregistering MessageExchangeListeners and the
|
||||
* MessageExchangeHandlers that can be used to process the received message exchange from a
|
||||
* delivery channel. A global reference to this class will be created in RuntimeContext object to
|
||||
* provide access to this class from any where in the component runtime.
|
||||
*
|
||||
* A ProviderEndpoint or ConsumerEndpoint interested in a MessageExchange received from a delivery
|
||||
* channel for a particular service endpoint will register the MessageExchangeListener with this
|
||||
* class. The DefaultMessageExchangeReceiver when received a message exchange object from the delivery
|
||||
* channel uses MessageExchangeSupport.processMessageExchange method to notify the registered listener.
|
||||
*
|
||||
* The MessageExchangeListener implementation ( ProviderEndpoint or ConsumerEndpoint ) while processing
|
||||
* received message ( messageExchangeReceived()) will create and register the message exchange handlers
|
||||
* to process the message exchange.
|
||||
*
|
||||
* @see RuntimeContext#getMessageExchangeSupport
|
||||
* @see RuntimeHelper#getMessageExchangeSupport
|
||||
* @see DefaultMessageExchangeReceiver#receiveAndProcessMessageExchange
|
||||
* @see com.sun.jbi.sample.component.common.deployment.ProviderEndpoint
|
||||
* @author chikkala
|
||||
*/
|
||||
public class MessageExchangeSupport {
|
||||
/** listener map to notify a message exchange received event */
|
||||
private Map<String, MessageExchangeListener> mListeners;
|
||||
/** handlers that can process the message exchange */
|
||||
private Map<String, MessageExchangeHandler> mHandlers;
|
||||
/** Creates a new instance of MessageExchangeSupport */
|
||||
public MessageExchangeSupport() {
|
||||
this.mListeners = Collections.synchronizedMap(new HashMap<String, MessageExchangeListener>());
|
||||
this.mHandlers = Collections.synchronizedMap(new HashMap<String, MessageExchangeHandler>());
|
||||
}
|
||||
/**
|
||||
* generates key that will be used to store the MessageExchangeListener objects.
|
||||
* @param serviceName QName of the service
|
||||
* @param endpointName endpoint name of the service.
|
||||
*/
|
||||
public String createListenerKey(Role role, QName interfaceName, QName serviceName, String endpointName) {
|
||||
|
||||
StringBuffer strBuff = new StringBuffer();
|
||||
strBuff.append(interfaceName).append("+");
|
||||
strBuff.append(serviceName).append("+");
|
||||
strBuff.append(endpointName).append("+");
|
||||
String roleType = null;
|
||||
if ( Role.CONSUMER.equals(role) ) {
|
||||
roleType = "CONSUMER";
|
||||
} else if ( Role.PROVIDER.equals(role) ) {
|
||||
roleType = "PROVIDER";
|
||||
}
|
||||
strBuff.append(roleType);
|
||||
return strBuff.toString();
|
||||
}
|
||||
/**
|
||||
* adds message exchange listener who are interested in receiving the notification when the
|
||||
* message exchange is received from delivery channel. The listener can be registered with the
|
||||
* following combination of the parameters: (role,interfaceName,serviceName, endpointName),
|
||||
* (role,interfaceName,null, null), (role, null,serviceName, endpointName), (role, null,serviceName, null)
|
||||
*
|
||||
* @param role role of the message exchange listener PROVIDER or CONSUMER - can not be null.
|
||||
* @param interfaceName QName of the interface ( protType ) - can be null if the serviceName is not null
|
||||
* @param serviceName QName of the service - can be null if interfaceName is not null.
|
||||
* @param endpointName endpoint name of the service. - can be null if the serviceName is not null.
|
||||
* @param listener MessageExchangeListener object
|
||||
*/
|
||||
public synchronized void addMessageExchangeListener(Role role, QName interfaceName, QName serviceName, String endpointName, MessageExchangeListener listener) {
|
||||
String key = createListenerKey(role, interfaceName, serviceName, endpointName);
|
||||
this.mListeners.put(key, listener);
|
||||
}
|
||||
/**
|
||||
* removes any message exchange listener registered for the service endpoint specified by the serviceName and
|
||||
* endpoint name.
|
||||
* @param serviceName QName of the service
|
||||
* @param endpointName endpoint name of the service.
|
||||
*/
|
||||
public synchronized void removeMessageExchangeListener(Role role, QName interfaceName, QName serviceName, String endpointName) {
|
||||
String key = createListenerKey(role, interfaceName, serviceName, endpointName);
|
||||
MessageExchangeListener listener = this.mListeners.remove(key);
|
||||
if ( listener == null ) {
|
||||
RuntimeHelper.getLogger().fine("No message exchange listener removed with key " + key);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* finds the MessageExchangeListner registers for the endpoint for which the message exchange is
|
||||
* received and call the method on the listener
|
||||
*/
|
||||
public boolean fireMessageExchangeReceived(ExchangeStatus status, MessageExchange me) {
|
||||
boolean notified = false;
|
||||
Role role = me.getRole();
|
||||
QName interfaceName = me.getInterfaceName();
|
||||
QName serviceName = me.getEndpoint().getServiceName();
|
||||
String endpointName = me.getEndpoint().getEndpointName();
|
||||
// lookup with complete service description ( role + interface + service + endpoint )
|
||||
String key = createListenerKey(role, interfaceName, serviceName, endpointName);
|
||||
RuntimeHelper.getLogger().fine("looking up for mx listener with key " + key);
|
||||
MessageExchangeListener listener = this.mListeners.get(key);
|
||||
|
||||
if ( listener == null ) { // lookup with role+interface name
|
||||
key = createListenerKey(role, interfaceName, null, null);
|
||||
RuntimeHelper.getLogger().fine("looking up for mx listener with key " + key);
|
||||
listener = this.mListeners.get(key);
|
||||
}
|
||||
if ( listener == null ) { // lookup with role + serviceName + endpointName
|
||||
key = createListenerKey(role, null, serviceName, endpointName);
|
||||
RuntimeHelper.getLogger().fine("looking up for mx listener with key " + key);
|
||||
listener = this.mListeners.get(key);
|
||||
}
|
||||
if ( listener == null ) { // lookup with with role + serviceName
|
||||
key = createListenerKey(role, null, serviceName, null);
|
||||
RuntimeHelper.getLogger().fine("looking up for mx listener with key " + key);
|
||||
listener = this.mListeners.get(key);
|
||||
}
|
||||
if ( listener == null ) {
|
||||
RuntimeHelper.getLogger().fine("Could not find listener for message exchange" + me);
|
||||
notified = false;
|
||||
} else {
|
||||
listener.messageExchangeReceived(status,me);
|
||||
notified = true;
|
||||
}
|
||||
return notified;
|
||||
}
|
||||
/**
|
||||
* registers the MessageExchangeHandler implementation against the message exchange id.
|
||||
* @param me MessageExchange for which the handler need to be assigned
|
||||
* @param handler MessageExchangeHandler implementation that will be registers.
|
||||
*/
|
||||
public synchronized void addMessageExchangeHandler(MessageExchange me, MessageExchangeHandler handler) {
|
||||
this.mHandlers.put(me.getExchangeId(), handler);
|
||||
}
|
||||
/**
|
||||
* removes the MessageExchangeHandler for the particular message exchange object
|
||||
*/
|
||||
public synchronized void removeMessageExchangeHandler(MessageExchange me) {
|
||||
MessageExchangeHandler handler = this.mHandlers.remove(me.getExchangeId());
|
||||
if ( handler == null ) {
|
||||
RuntimeHelper.getLogger().fine("No MessageExchangeHandler found for removing " + me.getExchangeId());
|
||||
}
|
||||
}
|
||||
/**
|
||||
* looks up the registered message exchange handler for the message exchange object
|
||||
* @param me MessageExchangeHandler.
|
||||
*/
|
||||
public synchronized MessageExchangeHandler findMessageExchangeHandler(MessageExchange me) {
|
||||
return this.mHandlers.get(me.getExchangeId());
|
||||
}
|
||||
/**
|
||||
* looks up the registered message exchange handler for the message exchange object with Id
|
||||
* @param exchangeId message exchange object's id
|
||||
*/
|
||||
public synchronized MessageExchangeHandler findMessageExchangeHandler(String exchangeId) {
|
||||
return this.mHandlers.get(exchangeId);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,173 @@
|
|||
/*
|
||||
* RuntimeContext.java
|
||||
*
|
||||
*/
|
||||
|
||||
package org.openesb.components.camelse.common;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
import javax.jbi.component.ComponentContext;
|
||||
import javax.jbi.messaging.DeliveryChannel;
|
||||
|
||||
/**
|
||||
* This class is global context for all the component runtime to store and
|
||||
* retrieve the information that should be available anywhere in the component runtime.
|
||||
*
|
||||
* Each instance variable of this class will be initialized at various points of the
|
||||
* component runtime using setter methods on this class.
|
||||
*
|
||||
* The two important objects that will be initialized and available from this context are
|
||||
* ComponentContext and the opened DeliveryChannel objects both of which will be set from the
|
||||
* implementation {@link BasicComponentLifeCycle}.
|
||||
*
|
||||
* Note that the ComponentContext from this global context will not be available until
|
||||
* the jbi framework calls the init method of the ComponentLifeCycle of the component and
|
||||
* then intern the implementation of the init method sets the context.
|
||||
*
|
||||
* @see BasicComponentLifeCycle#initGlobalContext
|
||||
* @see BasicComponentLifeCycle#openDeliveryChannel
|
||||
* @see BasicComponentLifeCycle#closeDeliveryChannel
|
||||
* @author chikkala
|
||||
*/
|
||||
public final class RuntimeContext {
|
||||
/** RuntimeContext singleton instance */
|
||||
private static RuntimeContext sRuntimeContext;
|
||||
/** default logger*/
|
||||
private Logger mDefLogger;
|
||||
/** Logger object. */
|
||||
private Logger mLogger;
|
||||
/** Holds value of property ComponentContext. */
|
||||
private ComponentContext mComponentContext;
|
||||
/** Holds value of property DeliveryChannel. */
|
||||
private DeliveryChannel mDeliveryChannel;
|
||||
/** MessageExchange processing support **/
|
||||
private MessageExchangeSupport mMESupport;
|
||||
|
||||
/** outside code can not instantiate RuntimeContext */
|
||||
private RuntimeContext() {
|
||||
}
|
||||
/**
|
||||
* @return RuntimeContext instance.
|
||||
*/
|
||||
public static RuntimeContext getInstance() {
|
||||
if ( sRuntimeContext == null ) {
|
||||
synchronized (RuntimeContext.class) {
|
||||
if ( sRuntimeContext == null ) {
|
||||
sRuntimeContext = new RuntimeContext();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sRuntimeContext;
|
||||
}
|
||||
/**
|
||||
* Getter for to obtaining ComponentContext from any where in the component runtime.
|
||||
* @return ComponentContext.
|
||||
*/
|
||||
public ComponentContext getComponentContext() {
|
||||
return this.mComponentContext;
|
||||
}
|
||||
/**
|
||||
* Sets the Component context reference in Runtime context for global access
|
||||
* any class in the component runtime.
|
||||
* com.sun.jbi.sample.component.common.AbstractComponentLifeCycle#initContext
|
||||
* method implementation should call this method to set the global context.
|
||||
* see com.sun.jbi.sample.component.common.DefaultComponentLifeCycle#initContext
|
||||
* for details.
|
||||
* @param componentContext New value of property ComponentContext.
|
||||
* @see BasicComponentLifeCycle#initGlobalContext
|
||||
*/
|
||||
public void setComponentContext(ComponentContext componentContext) {
|
||||
if ( this.mComponentContext != null ) {
|
||||
(new IllegalStateException("Component Context already " +
|
||||
"initialized in RuntimeContext")).printStackTrace();
|
||||
}
|
||||
this.mComponentContext = componentContext;
|
||||
}
|
||||
/**
|
||||
* Getter for obtaining opened delivery channel from any where in the component runtime.
|
||||
* @return DeliveryChannel.
|
||||
*/
|
||||
public DeliveryChannel getDeliveryChannel() {
|
||||
return this.mDeliveryChannel;
|
||||
}
|
||||
/**
|
||||
* Sets the opened delivery channel reference in Runtime context for global access
|
||||
* any class in the component runtime.
|
||||
* com.sun.jbi.sample.component.common.AbstractComponentLifeCycle#initContext
|
||||
* method implementation should call this method to set the global context.
|
||||
* see com.sun.jbi.sample.component.common.DefaultComponentLifeCycle#initContext
|
||||
* for details.
|
||||
*
|
||||
* @param componentContext New value of property ComponentContext.
|
||||
*/
|
||||
public void setDeliveryChannel(DeliveryChannel deliveryChannel) {
|
||||
if ( deliveryChannel != null && this.mDeliveryChannel != null ) {
|
||||
(new IllegalStateException("Delivery Channel already " +
|
||||
"initialized in RuntimeContext")).printStackTrace();
|
||||
}
|
||||
this.mDeliveryChannel = deliveryChannel;
|
||||
}
|
||||
/**
|
||||
* Sets the logger.
|
||||
*
|
||||
* @param name name for the Logger.
|
||||
* @param resourceBundle resource bundle for the logger. can be null.
|
||||
*/
|
||||
public void setLogger(String name, String resourceBundle) {
|
||||
|
||||
if (this.mComponentContext != null) {
|
||||
// get the logger from component context if the component context is not null
|
||||
try {
|
||||
this.mLogger = this.mComponentContext.getLogger(name, resourceBundle);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
this.mDefLogger = Logger.getLogger(name, resourceBundle);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Returns the logger.
|
||||
*
|
||||
* @return Logger
|
||||
*/
|
||||
public Logger getLogger() {
|
||||
|
||||
// try init logger
|
||||
if (this.mLogger == null && this.mComponentContext != null ) {
|
||||
try {
|
||||
this.mLogger =
|
||||
this.mComponentContext.getLogger(this.getClass().getName(), null);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
// init default logger if required
|
||||
if ( this.mLogger == null && this.mDefLogger == null) {
|
||||
this.mDefLogger = Logger.getLogger(this.getClass().getName(), null);
|
||||
}
|
||||
return (this.mLogger != null) ? this.mLogger : this.mDefLogger;
|
||||
}
|
||||
/**
|
||||
* Returns the Component Name if the ComponentContext is set. else null
|
||||
* @return component name
|
||||
*/
|
||||
public String getComponentName() {
|
||||
String componentName = null;
|
||||
if (this.mComponentContext != null) {
|
||||
componentName = this.mComponentContext.getComponentName();
|
||||
}
|
||||
return componentName;
|
||||
}
|
||||
/**
|
||||
* Global MessageExchangeSupport reference. Various classes in the common
|
||||
* component runtime would use this method to obtain the MessageExchangeSupport
|
||||
* for processing message exchange objects received from delivery channel.
|
||||
*/
|
||||
public MessageExchangeSupport getMessageExchangeSupport() {
|
||||
if ( this.mMESupport == null ) {
|
||||
this.mMESupport = new MessageExchangeSupport();
|
||||
}
|
||||
return this.mMESupport;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,357 @@
|
|||
/*
|
||||
* RuntimeHelper.java
|
||||
*/
|
||||
|
||||
package org.openesb.components.camelse.common;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.Reader;
|
||||
import java.io.StringReader;
|
||||
import java.io.StringWriter;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.jbi.component.ComponentContext;
|
||||
import javax.jbi.messaging.DeliveryChannel;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.transform.OutputKeys;
|
||||
import javax.xml.transform.Source;
|
||||
import javax.xml.transform.Transformer;
|
||||
import javax.xml.transform.TransformerConfigurationException;
|
||||
import javax.xml.transform.TransformerException;
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
import javax.xml.transform.sax.SAXSource;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.xml.sax.EntityResolver;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.SAXParseException;
|
||||
import org.xml.sax.helpers.DefaultHandler;
|
||||
|
||||
/**
|
||||
* This is a helper class that have bunch of methods for xml processing.
|
||||
* @author chikkala
|
||||
*/
|
||||
public class RuntimeHelper {
|
||||
|
||||
public static Logger getLogger() {
|
||||
return RuntimeContext.getInstance().getLogger();
|
||||
}
|
||||
|
||||
public static void logWarning(Object logObj) {
|
||||
if ( logObj instanceof Throwable) {
|
||||
getLogger().log(Level.WARNING, ((Throwable)logObj).getMessage(), (Throwable)logObj);
|
||||
} else {
|
||||
getLogger().warning(logObj.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public static void logError(Object logObj) {
|
||||
if ( logObj instanceof Throwable) {
|
||||
getLogger().log(Level.SEVERE, ((Throwable)logObj).getMessage(), (Throwable)logObj);
|
||||
} else {
|
||||
getLogger().severe(logObj.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public static void logDebug(Object logObj) {
|
||||
if ( logObj instanceof Throwable) {
|
||||
getLogger().log(Level.FINER, ((Throwable)logObj).getMessage(), (Throwable)logObj);
|
||||
} else {
|
||||
getLogger().finer(logObj.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public static String getComponentName() {
|
||||
return RuntimeContext.getInstance().getComponentName();
|
||||
}
|
||||
public static ComponentContext getComponentContext() {
|
||||
return RuntimeContext.getInstance().getComponentContext();
|
||||
}
|
||||
public static DeliveryChannel getDeliveryChannel() {
|
||||
return RuntimeContext.getInstance().getDeliveryChannel();
|
||||
}
|
||||
|
||||
public static MessageExchangeSupport getMessageExchangeSupport() {
|
||||
return RuntimeContext.getInstance().getMessageExchangeSupport();
|
||||
}
|
||||
|
||||
/**
|
||||
* return the DOM Document
|
||||
* @param xmlReader Reader
|
||||
* @return dom document
|
||||
* @throws Exception on parser exception or any other exception
|
||||
*/
|
||||
public static Document buildDOMDocument(Reader xmlReader) throws Exception {
|
||||
InputSource xmlSource = new InputSource(xmlReader);
|
||||
return buildDOMDocument(xmlSource);
|
||||
}
|
||||
/**
|
||||
* return the DOM Document
|
||||
* @param xmlReader Reader
|
||||
* @return dom document
|
||||
* @throws Exception on parser exception or any other exception
|
||||
*/
|
||||
public static Document buildDOMDocument(InputSource xmlSource) throws Exception {
|
||||
Document xmlDoc = null;
|
||||
DocumentBuilderFactory docBuilderFactory =
|
||||
DocumentBuilderFactory.newInstance();
|
||||
docBuilderFactory.setValidating(false);
|
||||
docBuilderFactory.setNamespaceAware(true);
|
||||
DocumentBuilder docBuilder =
|
||||
docBuilderFactory.newDocumentBuilder();
|
||||
docBuilder.setErrorHandler( new DefaultHandler() {
|
||||
public void fatalError(SAXParseException e)
|
||||
throws SAXException {
|
||||
throw new SAXException(e.getMessage());
|
||||
}
|
||||
});
|
||||
|
||||
docBuilder.setEntityResolver(new EntityResolver() {
|
||||
public InputSource resolveEntity(String publicId, String systemId)
|
||||
throws SAXException, IOException {
|
||||
StringReader reader =
|
||||
new StringReader("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); // NOI18N
|
||||
InputSource source = new InputSource(reader);
|
||||
source.setPublicId(publicId);
|
||||
source.setSystemId(systemId);
|
||||
return source;
|
||||
}
|
||||
});
|
||||
|
||||
xmlDoc = docBuilder.parse(xmlSource);
|
||||
|
||||
return xmlDoc;
|
||||
}
|
||||
/**
|
||||
* reads xml text from DOMSource to StringBuffer
|
||||
*/
|
||||
public static StringBuffer readFromDOMSource(DOMSource domSource) {
|
||||
|
||||
StringWriter writer = new StringWriter();
|
||||
|
||||
TransformerFactory tFactory = TransformerFactory.newInstance();
|
||||
Transformer trans = null;
|
||||
try {
|
||||
trans = tFactory.newTransformer();
|
||||
trans.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION,
|
||||
"yes");
|
||||
trans.setOutputProperty(OutputKeys.INDENT, "yes");
|
||||
StreamResult result = new StreamResult(writer);
|
||||
trans.transform(domSource, result);
|
||||
} catch (TransformerConfigurationException ex) {
|
||||
ex.printStackTrace();
|
||||
} catch (TransformerException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
return writer.getBuffer();
|
||||
}
|
||||
/**
|
||||
* reads the xml text from InputSource into a StringBuffer
|
||||
*/
|
||||
public static StringBuffer readFromInputSource(InputSource inSource) {
|
||||
|
||||
StringWriter writer = new StringWriter();
|
||||
PrintWriter out = new PrintWriter(writer);
|
||||
InputStream inStream = inSource.getByteStream();
|
||||
Reader reader = inSource.getCharacterStream();
|
||||
if ( reader == null ) {
|
||||
reader = new InputStreamReader(inStream);
|
||||
}
|
||||
BufferedReader buff = new BufferedReader(reader);
|
||||
try {
|
||||
|
||||
for ( String line = null; (line = buff.readLine()) != null ; ) {
|
||||
out.println(line);
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
return writer.getBuffer();
|
||||
}
|
||||
/**
|
||||
* reads xml from from DOM, SAX or Stream Source into a string buffer
|
||||
*/
|
||||
public static StringBuffer readFromSource(Source source) {
|
||||
if ( source instanceof DOMSource ) {
|
||||
return readFromDOMSource((DOMSource)source);
|
||||
} else {
|
||||
InputSource inSource = SAXSource.sourceToInputSource(source);
|
||||
if ( inSource != null ) {
|
||||
return readFromInputSource(inSource);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* creates a DOMSource from the xml text read from the reader.
|
||||
*/
|
||||
public static DOMSource createDOMSource(Reader xmlReader) {
|
||||
Document doc = null;
|
||||
try {
|
||||
doc = buildDOMDocument(xmlReader);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return new DOMSource(doc);
|
||||
}
|
||||
/**
|
||||
* creates a DOMSource from any source. If the source itself is DOMSource,
|
||||
* the source is returned as it is as DOMSource.
|
||||
*/
|
||||
public static DOMSource sourceToDOMSource(Source source) {
|
||||
if ( source instanceof DOMSource) {
|
||||
return (DOMSource) source;
|
||||
}
|
||||
InputSource xmlSource = SAXSource.sourceToInputSource(source);
|
||||
Document doc = null;
|
||||
try {
|
||||
doc = buildDOMDocument(xmlSource);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return new DOMSource(doc);
|
||||
}
|
||||
/**
|
||||
* converts the ex stracktrace to string.
|
||||
*/
|
||||
public static StringBuffer getExceptionStackTrace(Exception ex) {
|
||||
StringWriter strWriter = new StringWriter();
|
||||
if ( ex != null ) {
|
||||
PrintWriter out = new PrintWriter(strWriter);
|
||||
ex.printStackTrace(out);
|
||||
}
|
||||
return strWriter.getBuffer();
|
||||
}
|
||||
/**
|
||||
* may be used to set the exception as fault content.
|
||||
*/
|
||||
public static String getExceptionAsXmlText(Exception ex) {
|
||||
String message = replaceXmlEscapeCharsToEntityRefereces(ex.getMessage());
|
||||
String stackTrace = replaceXmlEscapeCharsToEntityRefereces(
|
||||
getExceptionStackTrace(ex).toString());
|
||||
String exXmlText =
|
||||
"<java-exception xmlns=\"http://java.sun.com/ns/jbi/samples/java-exception/types/\" >" +
|
||||
"<ex-message>" + message + "</ex-message>" +
|
||||
"<ex-stack-trace>" + stackTrace + "</ex-stack-trace>" +
|
||||
"</java-exception>" ;
|
||||
return exXmlText;
|
||||
}
|
||||
|
||||
/**
|
||||
* may be used to set the exception as fault content.
|
||||
*/
|
||||
public static String getExceptionAsText(Exception ex) {
|
||||
String message = replaceXmlEscapeCharsToEntityRefereces(ex.getMessage());
|
||||
String stackTrace = replaceXmlEscapeCharsToEntityRefereces(
|
||||
getExceptionStackTrace(ex).toString());
|
||||
StringBuffer buff = new StringBuffer();
|
||||
buff.append(message);
|
||||
buff.append(System.getProperty("line.separator", "\n"));
|
||||
buff.append(stackTrace);
|
||||
return buff.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* For attribute values which denote a QName, i.e. include a namespace prefix,
|
||||
* resolve the value into a QName.
|
||||
* If a namespace can not be resolved, it is set to empty - it does not
|
||||
* result in an exception
|
||||
* @param attrValue the string value of the attribute
|
||||
* @param element the element the attribute belongs to
|
||||
*/
|
||||
public static QName resolveAttrQName(String attrValue, Element element) {
|
||||
int aColonLoc = attrValue.indexOf(":");
|
||||
String aLocalName = attrValue;
|
||||
String aPrefix = null;
|
||||
String aNS = null;
|
||||
if (aColonLoc > -1) {
|
||||
aPrefix = attrValue.substring(0, aColonLoc);
|
||||
aLocalName = attrValue.substring(aColonLoc + 1);
|
||||
|
||||
// Traverse up the hierarchy until a namespace definition is found
|
||||
// or the top of the document is reached.
|
||||
Node currNode = element;
|
||||
while ((aNS == null || aNS.equals("")) && currNode != null) {
|
||||
if (currNode.getNodeType() == Node.ELEMENT_NODE) {
|
||||
aNS = ((Element) currNode).getAttribute("xmlns:" + aPrefix);
|
||||
}
|
||||
currNode = currNode.getParentNode();
|
||||
}
|
||||
}
|
||||
|
||||
QName qName = new QName(aNS, aLocalName, aPrefix);
|
||||
|
||||
return qName;
|
||||
}
|
||||
|
||||
/**
|
||||
* replaces the xml entity references with the xml escape chars
|
||||
* @param xmlString Text with the xml escape chars
|
||||
* @param Text with the xml entity references
|
||||
*/
|
||||
public static String replaceXmlEscapeCharsToEntityRefereces(String xmlString) {
|
||||
if ( xmlString == null ) {
|
||||
return xmlString;
|
||||
}
|
||||
|
||||
// just convert < , > and & only
|
||||
StringBuffer sbuff = new StringBuffer(2 * xmlString.length());
|
||||
for ( int i = 0; i < xmlString.length(); ++i ) {
|
||||
switch ( xmlString.charAt(i) ) {
|
||||
case '&': sbuff.append("&");
|
||||
break;
|
||||
case '<': sbuff.append("<");
|
||||
break;
|
||||
case '>': sbuff.append(">");
|
||||
break;
|
||||
default: sbuff.append( xmlString.charAt(i) );
|
||||
}
|
||||
}
|
||||
return sbuff.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* return Element node from a document node or non document. Use to extract
|
||||
* the message root element.
|
||||
* @root node from which the Element node will be extracted.
|
||||
* @return Element node.
|
||||
*/
|
||||
public static Element getElement(Node root) {
|
||||
Element msgEl = null;
|
||||
if ( root instanceof Document) {
|
||||
msgEl = ((Document)root).getDocumentElement();
|
||||
} else if (root instanceof Element) {
|
||||
msgEl = (Element)root;
|
||||
} else {
|
||||
NodeList nodeList = root.getChildNodes();
|
||||
for ( int i=0; i < nodeList.getLength(); ++i) {
|
||||
Node node = nodeList.item(i);
|
||||
if ( node instanceof Element ) {
|
||||
msgEl = (Element) node;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return msgEl;
|
||||
}
|
||||
|
||||
public static Element getElement(DOMSource domSource) {
|
||||
return getElement(domSource.getNode());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,309 @@
|
|||
/*
|
||||
* AbstractServiceUnitManager.java
|
||||
*
|
||||
*/
|
||||
|
||||
package org.openesb.components.camelse.common.deployment;
|
||||
|
||||
import org.openesb.components.camelse.common.RuntimeHelper;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.jbi.component.ServiceUnitManager;
|
||||
import javax.jbi.management.DeploymentException;
|
||||
|
||||
/**
|
||||
* This is an abstract class that implements {@link javax.jbi.component.ServiceUnitManager} to provide a
|
||||
* service unit deployment support for the component. The implementation supported by this service
|
||||
* unit manager and related classes in this package provides WSDL1.1 based service unit deployment
|
||||
* in the component.
|
||||
*
|
||||
* @see javax.jbi.component.ServiceUnitManager
|
||||
* @see ServiceUnit
|
||||
*
|
||||
* @author chikkala
|
||||
*/
|
||||
public abstract class AbstractServiceUnitManager implements ServiceUnitManager {
|
||||
|
||||
/** Map of ServiceUnit Name to the ServiceUnit Object for all the service units
|
||||
* deployed in the component */
|
||||
private Map<String,ServiceUnit> mSUMap;
|
||||
|
||||
/** Creates a new instance of AbstractSUManager */
|
||||
protected AbstractServiceUnitManager() {
|
||||
this.mSUMap = Collections.synchronizedMap(new HashMap<String,ServiceUnit>());
|
||||
}
|
||||
/** returns the component name
|
||||
* @return component name.
|
||||
*/
|
||||
protected abstract String getComponentName();
|
||||
/**
|
||||
* @return Logger
|
||||
*/
|
||||
protected abstract Logger getLogger();
|
||||
/**
|
||||
* returns the creation of the ServiceUnit implementation specific to the service unit deployment
|
||||
* for the component.
|
||||
* @param suName service unit name
|
||||
* @param suRootPath service unit root path
|
||||
* @param concrete implementation of the ServiceUnit class.
|
||||
*/
|
||||
protected abstract ServiceUnit createServiceUnit(String suName, String suRootPath)
|
||||
throws DeploymentException;
|
||||
/**
|
||||
* returns the service unit object deployed by the specified name. or null if not deployed.
|
||||
* @param suName service unit name to look for
|
||||
* @param ServiceUnit object for the suName. or null if not present.
|
||||
*/
|
||||
private ServiceUnit getServiceUnit(String suName) {
|
||||
return this.mSUMap.get(suName);
|
||||
}
|
||||
/**
|
||||
* lookup for the deployed service unit. If not there, throws a deployment exception.
|
||||
* @param suName service unit name
|
||||
* @return ServiceUnit object
|
||||
* @throws DeploymentException if the service unit is not present.
|
||||
*/
|
||||
private ServiceUnit findServiceUnit(String suName) throws DeploymentException {
|
||||
ServiceUnit serviceUnit = getServiceUnit(suName);
|
||||
if ( serviceUnit == null ) {
|
||||
throw new DeploymentException("Service unit " + suName + " does not exist");
|
||||
}
|
||||
return serviceUnit;
|
||||
}
|
||||
/**
|
||||
* add the service unit object to the list of deployed service units. if there is already a
|
||||
* service unit present with the name, throws a deployment exception.
|
||||
* @param su service unit to add
|
||||
* @return ServiceUnit object that is added.
|
||||
* @throws DeploymentException if the service unit already present.
|
||||
*/
|
||||
private ServiceUnit addServiceUnit(ServiceUnit su) throws DeploymentException {
|
||||
String suName = su.getName();
|
||||
ServiceUnit oldSU = getServiceUnit(suName);
|
||||
if ( oldSU != null ) {
|
||||
throw new DeploymentException("Service unit " + suName + "already exists");
|
||||
}
|
||||
this.mSUMap.put(suName, su);
|
||||
return su;
|
||||
}
|
||||
/**
|
||||
* removes service unit object from the list of deployed service units. if there is no
|
||||
* service unit present with the name, throws a deployment exception.
|
||||
* @param su service unit to add
|
||||
* @return ServiceUnit object that is being removed.
|
||||
* @throws DeploymentException if the service unit already present.
|
||||
*/
|
||||
private ServiceUnit removeServiceUnit(ServiceUnit su) throws DeploymentException {
|
||||
String suName = su.getName();
|
||||
ServiceUnit oldSU = getServiceUnit(suName);
|
||||
if ( oldSU == null ) {
|
||||
throw new DeploymentException("Service unit " + suName + " does not exist");
|
||||
}
|
||||
return this.mSUMap.remove(suName);
|
||||
}
|
||||
/**
|
||||
* creates the concrete service unit implementation and calls the load method on it to initialize
|
||||
* the created service unit.
|
||||
* @param suName service unit name to create
|
||||
* @param suRootPath service unit root path.
|
||||
* @return ServiceUnit that is created and loaded.
|
||||
*/
|
||||
private ServiceUnit loadServiceUnit(String suName, String suRootPath) throws DeploymentException {
|
||||
ServiceUnit serviceUnit = createServiceUnit(suName, suRootPath);
|
||||
serviceUnit.doLoad();
|
||||
return serviceUnit;
|
||||
}
|
||||
/**
|
||||
* deploys a service unit. it creates and loads the service unit object for the suName and then call
|
||||
* doDeploy on the service unit and adds it to the deployed service unit list
|
||||
* @return result as jbi management xml
|
||||
* @throws DeploymentException if there is an error deploying.
|
||||
*/
|
||||
private synchronized String deployServiceUnit(String suName, String suRootPath) throws DeploymentException {
|
||||
String result = suName;
|
||||
ServiceUnit oldSU = getServiceUnit(suName);
|
||||
if ( oldSU != null ) {
|
||||
throw new DeploymentException("Service unit " + suName + "already exists");
|
||||
}
|
||||
ServiceUnit serviceUnit = loadServiceUnit(suName, suRootPath);
|
||||
serviceUnit.doDeploy();
|
||||
addServiceUnit(serviceUnit);
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* Deploy a Service Unit to the component.
|
||||
* @see javax.jbi.component.ServiceUnitManager#deploy(String, String);
|
||||
*/
|
||||
public final String deploy(String suName, String suRootPath) throws DeploymentException {
|
||||
this.getLogger().fine("Deploying service unit " + suName + " with suRootPath " + suRootPath);
|
||||
String compName = this.getComponentName();
|
||||
boolean isSuccess = true;
|
||||
String mainMsg = "Successfully deployed service unit " + suName;
|
||||
Exception errEx = null;
|
||||
try {
|
||||
deployServiceUnit(suName, suRootPath);
|
||||
} catch (Exception ex) {
|
||||
isSuccess = false;
|
||||
errEx = ex;
|
||||
mainMsg = "Failed to deploy service unit " + suName ;
|
||||
this.getLogger().log(Level.FINE, mainMsg, ex);
|
||||
}
|
||||
return createComponentTaskResultXML(compName, "deployTask", isSuccess, mainMsg, errEx);
|
||||
}
|
||||
|
||||
/**
|
||||
* undeploys the service unit. it looks up the existing deployed service unit and call doUndeploy
|
||||
* on it and then removes from the deployed service unit list.
|
||||
*/
|
||||
private synchronized String undeployServiceUnit(String suName, String suRootPath) throws DeploymentException {
|
||||
String result = suName;
|
||||
ServiceUnit serviceUnit = findServiceUnit(suName);
|
||||
serviceUnit.doUndeploy();
|
||||
removeServiceUnit(serviceUnit);
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* Undeploy a service unit from the component.
|
||||
* @see javax.jbi.component.ServiceUnitManager#undeploy(String, String);
|
||||
*/
|
||||
public final String undeploy(String suName, String suRootPath) throws DeploymentException {
|
||||
this.getLogger().fine("Undeploying service unit " + suName + " with suRootPath " + suRootPath);
|
||||
String compName = this.getComponentName();
|
||||
boolean isSuccess = true;
|
||||
String mainMsg = "Successfully undeployed service unit " + suName;
|
||||
Exception errEx = null;
|
||||
try {
|
||||
undeployServiceUnit(suName, suRootPath);
|
||||
} catch (Exception ex) {
|
||||
isSuccess = false;
|
||||
errEx = ex;
|
||||
mainMsg = "Failed to undeploy service unit " + suName ;
|
||||
this.getLogger().log(Level.FINE, mainMsg, errEx);
|
||||
}
|
||||
return createComponentTaskResultXML(compName, "undeployTask", isSuccess, mainMsg, errEx);
|
||||
}
|
||||
/**
|
||||
* Initialize the given deployed service unit.
|
||||
* @see javax.jbi.component.ServiceUnitManager#init(String, String); */
|
||||
public final void init(String suName, String suRootPath)
|
||||
throws DeploymentException {
|
||||
this.getLogger().fine("Initializing service unit " + suName + " with suRootPath " + suRootPath);
|
||||
String result = suName;
|
||||
ServiceUnit serviceUnit = getServiceUnit(suName);
|
||||
if ( serviceUnit == null ) { // if the service unit not exists, create and add
|
||||
serviceUnit = loadServiceUnit(suName, suRootPath); // create and load service unit
|
||||
addServiceUnit(serviceUnit); // add service unit to existing service units
|
||||
}
|
||||
serviceUnit.doInit(); // Do Service unit initialization tasks
|
||||
this.getLogger().fine("Service unit initialized:" + suName);
|
||||
}
|
||||
/**
|
||||
* Shut down the deployment.
|
||||
* @see javax.jbi.component.ServiceUnitManager#shutdown(String);
|
||||
*/
|
||||
public final void shutDown(String suName) throws DeploymentException {
|
||||
ServiceUnit serviceUnit = findServiceUnit(suName); // find service unit
|
||||
serviceUnit.doShutdown(); // Do Service unit shutdown tasks
|
||||
this.getLogger().fine("Service unit shut down:" + suName);
|
||||
}
|
||||
/**
|
||||
* Start the deployed service unit.
|
||||
* @see javax.jbi.component.ServiceUnitManager#start(String);
|
||||
*/
|
||||
public final void start(String suName) throws DeploymentException {
|
||||
ServiceUnit serviceUnit = findServiceUnit(suName); // find service unit
|
||||
serviceUnit.doStart(); // Do service unit start tasks.
|
||||
this.getLogger().fine("Service unit started:" + suName );
|
||||
}
|
||||
/**
|
||||
* Stop the deployed service unit.
|
||||
* @see javax.jbi.component.ServiceUnitManager#stop(String);
|
||||
*/
|
||||
public final void stop(String suName) throws DeploymentException {
|
||||
ServiceUnit serviceUnit = findServiceUnit(suName); // find service unit
|
||||
serviceUnit.doStop(); // do service unit stop tasks
|
||||
this.getLogger().fine("Service unit stopped: " + suName + " stopped.");
|
||||
}
|
||||
|
||||
/**
|
||||
* helper method to create result message as jbi management message xml.
|
||||
* @param componentName name of the component for this xml.
|
||||
* @param taskId task id
|
||||
* @param isSuccess true to format a success result, false to format a failed result.
|
||||
* @param mainMsg main result message
|
||||
* @param errEx Exception, null if there is no exception in failure message.
|
||||
* @return XML string.
|
||||
*/
|
||||
protected static String createComponentTaskResultXML(
|
||||
String componentName, String taskId, boolean isSuccess, String mainMsg, Exception errEx ) {
|
||||
|
||||
String exMsgXml = getComponentTaskResultExceptionXML(errEx);
|
||||
String mainMsgXmlEsc = RuntimeHelper.replaceXmlEscapeCharsToEntityRefereces(mainMsg);
|
||||
String taskResult = isSuccess ? "SUCCESS" : "FAILED";
|
||||
String msgType = isSuccess ? "INFO" : "ERROR";
|
||||
|
||||
String xmlResult =
|
||||
"<component-task-result xmlns=\"http://java.sun.com/xml/ns/jbi/management-message\" >" +
|
||||
" <component-name>" + componentName + "</component-name>" +
|
||||
" <component-task-result-details >" +
|
||||
" <task-result-details>" +
|
||||
" <task-id>" + taskId + "</task-id>" +
|
||||
" <task-result>" + taskResult + "</task-result>" +
|
||||
" <message-type>" + msgType + "</message-type>" +
|
||||
" <task-status-msg>" +
|
||||
" <msg-loc-info>" +
|
||||
" <loc-token>SU_MGR_MSG_ID</loc-token>" +
|
||||
" <loc-message>" + mainMsgXmlEsc + "</loc-message>" +
|
||||
" </msg-loc-info>" +
|
||||
" </task-status-msg>" +
|
||||
exMsgXml +
|
||||
" </task-result-details>" +
|
||||
" </component-task-result-details>" +
|
||||
"</component-task-result>";
|
||||
|
||||
return xmlResult;
|
||||
}
|
||||
/**
|
||||
* converts the exception to the jbi management message xml chunk.
|
||||
*/
|
||||
private static String getComponentTaskResultExceptionXML(Exception errEx) {
|
||||
StringBuffer exMsgBuff = new StringBuffer();
|
||||
if ( errEx == null ) {
|
||||
return exMsgBuff.toString(); // empty string.
|
||||
}
|
||||
|
||||
List<Throwable> exList = new ArrayList<Throwable>();
|
||||
int exLevel = 0;
|
||||
for ( Throwable cause = errEx ; cause != null ; cause = cause.getCause() ) {
|
||||
String causeMsg = RuntimeHelper.replaceXmlEscapeCharsToEntityRefereces(
|
||||
cause.getMessage());
|
||||
StringWriter stBuff = new StringWriter();
|
||||
PrintWriter stOut = new PrintWriter(stBuff);
|
||||
StackTraceElement[] stList = cause.getStackTrace();
|
||||
for (StackTraceElement stEl : stList) {
|
||||
stOut.println(stEl.toString());
|
||||
}
|
||||
stOut.close();
|
||||
String causeStackTrace = RuntimeHelper.replaceXmlEscapeCharsToEntityRefereces(
|
||||
stBuff.getBuffer().toString());
|
||||
|
||||
exMsgBuff.append("<exception-info>");
|
||||
exMsgBuff.append(" <nesting-level>" + exLevel + "</nesting-level>");
|
||||
exMsgBuff.append(" <msg-loc-info>" + "<loc-token>SU_MGR_EXP_ID</loc-token>");
|
||||
exMsgBuff.append(" <loc-message>" + causeMsg + "</loc-message>");
|
||||
exMsgBuff.append(" </msg-loc-info>");
|
||||
exMsgBuff.append(" <stack-trace>" + causeStackTrace + "</stack-trace>");
|
||||
exMsgBuff.append("</exception-info>");
|
||||
++exLevel;
|
||||
}
|
||||
|
||||
return exMsgBuff.toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,205 @@
|
|||
/*
|
||||
* ConsumerEndpoint.java
|
||||
*/
|
||||
|
||||
package org.openesb.components.camelse.common.deployment;
|
||||
|
||||
import javax.jbi.JBIException;
|
||||
import javax.jbi.component.ComponentContext;
|
||||
import javax.jbi.messaging.DeliveryChannel;
|
||||
import javax.jbi.messaging.InOnly;
|
||||
import javax.jbi.messaging.InOut;
|
||||
import javax.jbi.messaging.MessageExchange.Role;
|
||||
import javax.jbi.messaging.MessageExchangeFactory;
|
||||
import javax.jbi.messaging.MessagingException;
|
||||
import javax.jbi.messaging.NormalizedMessage;
|
||||
import javax.jbi.servicedesc.ServiceEndpoint;
|
||||
import javax.wsdl.Definition;
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
/**
|
||||
* This class extends from Endpoint class and implements lifecycle methods functionality required for the
|
||||
* endpoint for a service consumer. {@link ServiceUnit#createConsumerEndpoint} creates the object of this
|
||||
* type to implement the service consumer functionality.
|
||||
*
|
||||
* @see ServiceUnit#createConsumerEndpoint
|
||||
* @author chikkala
|
||||
*/
|
||||
|
||||
public class ConsumerEndpoint extends Endpoint {
|
||||
/**
|
||||
* This constructor initializes the endpoint with CONSUMER role and makes sure that the service
|
||||
* description passed to it is of consumer description.
|
||||
*/
|
||||
protected ConsumerEndpoint(SUDescriptor.Consumes consumes, Definition wsdlDef, ServiceUnit su) {
|
||||
super(Role.CONSUMER, consumes, wsdlDef, su);
|
||||
}
|
||||
/**
|
||||
* constructor that does not need service unit information. useful for creating the endpoint for
|
||||
* static services provided by the component.
|
||||
*/
|
||||
protected ConsumerEndpoint(SUDescriptor.Consumes consumes, Definition wsdlDef) {
|
||||
this(consumes, wsdlDef, null);
|
||||
}
|
||||
public final void init() throws JBIException {
|
||||
getLogger().fine("ConsumerEndpoint: init called");
|
||||
doInit(); //1. initialize the endpiont resources
|
||||
addMessageExchangeListener(); //2. register message exchange linster.
|
||||
}
|
||||
public final void activate() throws JBIException {
|
||||
getLogger().fine("ConsumerEndpoint: activate called");
|
||||
//1. do common ativation tasks.
|
||||
doActivate(); //2. do any other activation related tasks.
|
||||
}
|
||||
|
||||
public final void deactivate() throws JBIException {
|
||||
getLogger().fine("ConsumerEndpoint: deactivate called");
|
||||
//1. do common deactivation tasks.
|
||||
doDeactivate(); //2. do any other deactivation related tasks.
|
||||
}
|
||||
|
||||
public final void clean() throws JBIException {
|
||||
getLogger().fine("ConsumerEndpoint: clean called");
|
||||
removeMessageExchangeListener(); //1. remove message exchange listener
|
||||
doClean(); //2. clean up any other resources.
|
||||
}
|
||||
|
||||
protected void doInit() throws JBIException {
|
||||
//NOOP
|
||||
}
|
||||
protected void doActivate() throws JBIException {
|
||||
//NOOP
|
||||
}
|
||||
protected void doDeactivate() throws JBIException {
|
||||
//NOOP
|
||||
}
|
||||
protected void doClean() throws JBIException {
|
||||
//NOOP
|
||||
}
|
||||
|
||||
/**
|
||||
* helper method to find the active ServiceEndpiont for the service described with the
|
||||
* serviceDescriptor. This method looks for the Active ServiceEndpoint using interface or
|
||||
* service name or service name and the endpoint name.
|
||||
*/
|
||||
public ServiceEndpoint findServiceEndpoint() {
|
||||
|
||||
QName serviceType = this.getService().getInterface();
|
||||
QName serviceName = this.getService().getServiceName();
|
||||
String endpointName = this.getService().getEndpointName();
|
||||
|
||||
ServiceEndpoint [] refs = null;
|
||||
ServiceEndpoint serviceEndpoint = null;
|
||||
ComponentContext compContext = this.getComponentContext();
|
||||
|
||||
if ( compContext == null ) {
|
||||
this.getLogger().info("Null Component context. Can not find ServiceEndpoint");
|
||||
return null;
|
||||
}
|
||||
// lookup ServiceEndpiont with concrete service(serice qname + endpoint name).
|
||||
if ( serviceName != null && endpointName != null ) {
|
||||
this.getLogger().info("Looking for ServiceEndpoint with:" +
|
||||
" ServiceName: " + serviceName + " EndpointName: " + endpointName);
|
||||
serviceEndpoint = compContext.getEndpoint(serviceName, endpointName);
|
||||
}
|
||||
// else lookup ServiceEndpiont with Service Name
|
||||
if ( serviceEndpoint == null && serviceName != null && endpointName == null) {
|
||||
this.getLogger().info("Looking for ServiceEndpoint with Service name: " + serviceName);
|
||||
refs = compContext.getEndpointsForService(serviceName);
|
||||
if ( refs != null && refs.length > 0 ) {
|
||||
serviceEndpoint = refs[0];
|
||||
}
|
||||
}
|
||||
// else lookup ServiceEndpont with serviceType
|
||||
if ( serviceEndpoint == null && serviceType != null &&
|
||||
serviceName == null && endpointName == null) {
|
||||
this.getLogger().info("Looking for ServiceEndpoint with Service type: " + serviceType);
|
||||
refs = compContext.getEndpoints(serviceType);
|
||||
if ( refs != null && refs.length > 0 ) {
|
||||
serviceEndpoint = refs[0];
|
||||
}
|
||||
}
|
||||
|
||||
return serviceEndpoint;
|
||||
}
|
||||
|
||||
/**
|
||||
* this method creates a InOutMessageExchange Object and sets the required
|
||||
* data on the MessageExchange object including the create and set the Normalized
|
||||
* message object to hold the input message on the MessageExchange object.
|
||||
*/
|
||||
public InOut createInOutMessageExchange(QName operation)
|
||||
throws MessagingException, JBIException {
|
||||
|
||||
ServiceEndpoint serviceEndpoint = null;
|
||||
// find a ServiceEndpoint activated by the Service Providers for this service
|
||||
serviceEndpoint = findServiceEndpoint();
|
||||
|
||||
if ( serviceEndpoint == null ) {
|
||||
// if not found a activated ServiceEndpoint for this service, throw exception.
|
||||
throw new JBIException("Can not find an Active ServiceEndpoint for \n" + this.getService());
|
||||
} else {
|
||||
this.setServiceEndpoint(serviceEndpoint);
|
||||
}
|
||||
|
||||
InOut inOutME = null;
|
||||
DeliveryChannel channel = this.getDeliveryChannel();
|
||||
// create message exchange factory for the endpiont
|
||||
MessageExchangeFactory factory = channel.createExchangeFactory(serviceEndpoint);
|
||||
// create INOUT Message Exchange
|
||||
inOutME = factory.createInOutExchange();
|
||||
// set operation
|
||||
inOutME.setOperation(operation);
|
||||
// set interface if that is not set
|
||||
if ( inOutME.getInterfaceName() == null ) {
|
||||
inOutME.setInterfaceName(this.getService().getInterface());
|
||||
}
|
||||
// create IN Nomralized Message
|
||||
NormalizedMessage inMsg = inOutME.createMessage();
|
||||
// set IN Normalized message on message exchange
|
||||
inOutME.setInMessage(inMsg);
|
||||
|
||||
return inOutME;
|
||||
}
|
||||
|
||||
/**
|
||||
* this method creates a InOnlyMessageExchange Object and sets the required
|
||||
* data on the MessageExchange object including the create and set the Normalized
|
||||
* message object to hold the input message on the MessageExchange object.
|
||||
*/
|
||||
public InOnly createInOnlyMessageExchange(QName operation)
|
||||
throws MessagingException, JBIException {
|
||||
|
||||
ServiceEndpoint serviceEndpoint = null;
|
||||
// find a ServiceEndpoint activated by the Service Providers for this service
|
||||
serviceEndpoint = findServiceEndpoint();
|
||||
|
||||
if ( serviceEndpoint == null ) {
|
||||
// if not found a activated ServiceEndpoint for this service, throw exception.
|
||||
throw new JBIException("Can not find an Active ServiceEndpoint for \n" + this.getService());
|
||||
} else {
|
||||
this.setServiceEndpoint(serviceEndpoint);
|
||||
}
|
||||
|
||||
InOnly inOnlyME = null;
|
||||
DeliveryChannel channel = this.getDeliveryChannel();
|
||||
// create message exchange factory for the endpiont
|
||||
MessageExchangeFactory factory = channel.createExchangeFactory(serviceEndpoint);
|
||||
// create INOUT Message Exchange
|
||||
inOnlyME = factory.createInOnlyExchange();
|
||||
// set operation
|
||||
inOnlyME.setOperation(operation);
|
||||
// set interface if that is not set
|
||||
if ( inOnlyME.getInterfaceName() == null ) {
|
||||
inOnlyME.setInterfaceName(this.getService().getInterface());
|
||||
}
|
||||
// create IN Nomralized Message
|
||||
NormalizedMessage inMsg = inOnlyME.createMessage();
|
||||
// set IN Normalized message on message exchange
|
||||
inOnlyME.setInMessage(inMsg);
|
||||
|
||||
return inOnlyME;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,286 @@
|
|||
/*
|
||||
* Endpoint.java
|
||||
*
|
||||
*/
|
||||
|
||||
package org.openesb.components.camelse.common.deployment;
|
||||
|
||||
import org.openesb.components.camelse.common.MessageExchangeHandler;
|
||||
import org.openesb.components.camelse.common.MessageExchangeListener;
|
||||
import org.openesb.components.camelse.common.MessageExchangeSupport;
|
||||
import org.openesb.components.camelse.common.RuntimeHelper;
|
||||
import org.openesb.components.camelse.common.wsdl.WSDLProcessor;
|
||||
import java.util.logging.Logger;
|
||||
import javax.jbi.JBIException;
|
||||
import javax.jbi.component.ComponentContext;
|
||||
import javax.jbi.messaging.DeliveryChannel;
|
||||
import javax.jbi.messaging.ExchangeStatus;
|
||||
import javax.jbi.messaging.MessageExchange;
|
||||
import javax.jbi.messaging.MessageExchange.Role;
|
||||
import javax.jbi.servicedesc.ServiceEndpoint;
|
||||
import javax.wsdl.Binding;
|
||||
import javax.wsdl.Definition;
|
||||
import javax.wsdl.Operation;
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
/**
|
||||
* This is an abstract class that represents the Endpoint defined for service provisioning or
|
||||
* consumption in a jbi component. It stores the required service description ( wsdl definition,
|
||||
* role, service unit to which it belongs etc) and defines the lifecycle operations {@link #init},
|
||||
* {@link #activate}, {@link #deactivate}, {@link #clean} to control a service endpoint that
|
||||
* provides or consumes the service.
|
||||
* <p>
|
||||
* Extended classes implement the abstract methods defined in this class to implement the endpoint
|
||||
* functionality by providing the functionality to process the deployment artifacts specific to this
|
||||
* endpoint, configure the endpoint to send/receive messages to/from delivery channel and process them
|
||||
* according to the specific service implementation.
|
||||
*
|
||||
* @author chikkala
|
||||
*/
|
||||
public abstract class Endpoint {
|
||||
/** Role of this endpoint. CONSUMER or PROVIDER */
|
||||
private Role mRole;
|
||||
/** Service description from the SU descriptor for which this endpoint is configured */
|
||||
private SUDescriptor.Service mService;
|
||||
/** WSDL definition corresponding to this endpoint */
|
||||
private Definition mWsdlDef;
|
||||
/** service endpoint corresponding to this endpoint */
|
||||
private ServiceEndpoint mServiceEndpoint;
|
||||
/** service unit from which this endpoint is created */
|
||||
private ServiceUnit mSU; // can be null
|
||||
/** private constructor to force extended classes to use the parameterized constructor */
|
||||
private Endpoint() {
|
||||
}
|
||||
/** Creates a new instance of Endpoint
|
||||
* @param role CONSUMER or PRVODER role.
|
||||
* @param service service description from the su descriptor
|
||||
* @param wsdl wsdl definition corresponding to this endpoint
|
||||
* @param su service unit object which created this endpoint.
|
||||
*/
|
||||
protected Endpoint(Role role, SUDescriptor.Service service, Definition wsdl, ServiceUnit su) {
|
||||
this.mService = service;
|
||||
this.mRole = role;
|
||||
this.mWsdlDef = wsdl;
|
||||
this.mSU = su;
|
||||
}
|
||||
/** Creates a new instance of Endpoint without service unit. may be useful for static endpoints that
|
||||
* are not part of the deployment
|
||||
* @param role CONSUMER or PRVODER role.
|
||||
* @param service service info from the su descriptor
|
||||
* @param wsdl wsdl definition corresponding to this endpoint
|
||||
*/
|
||||
protected Endpoint(Role role, SUDescriptor.Service service, Definition wsdl) {
|
||||
this(role, service, wsdl, null);
|
||||
}
|
||||
/**
|
||||
* should be called to initialize any resources related to this endpoint object
|
||||
* throws JBIException
|
||||
*/
|
||||
public abstract void init() throws JBIException;
|
||||
/**
|
||||
* activates the endpoint to send/receive messages
|
||||
* throws JBIException
|
||||
*/
|
||||
public abstract void activate() throws JBIException;
|
||||
/**
|
||||
* deactivates the endpoint
|
||||
* throws JBIException
|
||||
*/
|
||||
public abstract void deactivate() throws JBIException;
|
||||
/**
|
||||
* clean endpoint
|
||||
* throws JBIException
|
||||
*/
|
||||
public abstract void clean() throws JBIException;
|
||||
|
||||
public final Role getRole() {
|
||||
return this.mRole;
|
||||
}
|
||||
public final boolean isProvider() {
|
||||
return (Role.PROVIDER.equals(this.getRole()));
|
||||
}
|
||||
public final boolean isConsumer() {
|
||||
return (Role.CONSUMER.equals(this.getRole()));
|
||||
}
|
||||
public final Definition getWSDL() {
|
||||
return this.mWsdlDef;
|
||||
}
|
||||
public final SUDescriptor.Service getService() {
|
||||
return this.mService;
|
||||
}
|
||||
public final ServiceEndpoint getServiceEndpoint() {
|
||||
return this.mServiceEndpoint;
|
||||
}
|
||||
protected final void setServiceEndpoint(ServiceEndpoint svcEP) {
|
||||
this.mServiceEndpoint = svcEP;
|
||||
}
|
||||
public final ServiceUnit getServiceUnit() {
|
||||
return this.mSU;
|
||||
}
|
||||
/**
|
||||
* generates an ID that would uniquely identify this endpoint implementation. Use as a key to map
|
||||
* any information to store that is related to this endpoint.
|
||||
*/
|
||||
public final String getID() {
|
||||
StringBuffer strBuff = new StringBuffer();
|
||||
strBuff.append(this.mService.getInterface()).append("+");
|
||||
strBuff.append(this.mService.getServiceName()).append("+");
|
||||
strBuff.append(this.mService.getEndpointName()).append("+");
|
||||
String roleType = null;
|
||||
if ( Role.CONSUMER.equals(this.mRole) ) {
|
||||
roleType = "CONSUMER";
|
||||
} else if ( Role.PROVIDER.equals(this.mRole) ) {
|
||||
roleType = "PROVIDER";
|
||||
}
|
||||
strBuff.append(roleType);
|
||||
return strBuff.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Endpoint : " + "\n" + this.mService;
|
||||
}
|
||||
/**
|
||||
* checks if this endpoint is configured for the binding component or service engine.
|
||||
*/
|
||||
public boolean isForBindingComponent() {
|
||||
boolean isForBindingComponent = false;
|
||||
if ( this.mSU != null ) {
|
||||
try {
|
||||
isForBindingComponent = this.mSU.getSUDescriptor().isForBindingComponent();
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
return isForBindingComponent;
|
||||
}
|
||||
|
||||
public QName getOperationQName(String opName) {
|
||||
return new QName(this.getService().getInterface().getNamespaceURI(), opName);
|
||||
}
|
||||
|
||||
public Operation getWSDLOperation(QName opQName) {
|
||||
String opName = null;
|
||||
if ( opQName != null ) {
|
||||
opName = opQName.getLocalPart();
|
||||
}
|
||||
Operation operation = WSDLProcessor.findOperation(this.getWSDL(),
|
||||
this.getService().getInterface(), opName);
|
||||
return operation;
|
||||
}
|
||||
|
||||
public Binding getWSDLBinding() {
|
||||
QName interfaceName = this.getService().getInterface();
|
||||
QName serviceName = this.getService().getServiceName();
|
||||
String endpointName = this.getService().getEndpointName();
|
||||
if ( serviceName != null ) {
|
||||
return WSDLProcessor.findServiceBinding(this.getWSDL(), serviceName, endpointName);
|
||||
} else {
|
||||
return WSDLProcessor.findInterfaceBinding(this.getWSDL(), interfaceName, null);
|
||||
}
|
||||
}
|
||||
/** @return logger */
|
||||
public Logger getLogger() {
|
||||
return RuntimeHelper.getLogger();
|
||||
}
|
||||
/** @return ComponentContext */
|
||||
public ComponentContext getComponentContext() {
|
||||
return RuntimeHelper.getComponentContext();
|
||||
}
|
||||
/** @return DeliveryChannel */
|
||||
public DeliveryChannel getDeliveryChannel() {
|
||||
return RuntimeHelper.getDeliveryChannel();
|
||||
}
|
||||
/**
|
||||
* helper function to get the MessageExchangeSupport object
|
||||
*/
|
||||
public MessageExchangeSupport getMessageExchangeSupport() {
|
||||
return RuntimeHelper.getMessageExchangeSupport();
|
||||
}
|
||||
|
||||
public MessageExchangeHandler createMessageExchangeHandler() {
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* creates the message exchange listener. Extended classes should return
|
||||
* MessageExchangeListener implementation.
|
||||
* @return MessageExchangeListener or null.
|
||||
*
|
||||
*/
|
||||
protected MessageExchangeListener createMessageExchangeListener() {
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Creates and adds message exchange listener to receive message exchange received notification.
|
||||
*/
|
||||
protected void addMessageExchangeListener() {
|
||||
QName interfaceName = this.getService().getInterface();
|
||||
QName serviceName = this.getService().getServiceName();
|
||||
String endpointName = this.getService().getEndpointName();
|
||||
MessageExchangeListener meListener = createMessageExchangeListener();
|
||||
MessageExchangeSupport meListenerSupport = getMessageExchangeSupport();
|
||||
if ( meListenerSupport != null && meListener != null ) {
|
||||
meListenerSupport.addMessageExchangeListener(
|
||||
this.getRole(), interfaceName, serviceName, endpointName, meListener);
|
||||
if ( serviceName != null ) {
|
||||
meListenerSupport.addMessageExchangeListener(
|
||||
this.getRole(), null, serviceName, endpointName, meListener);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Removes message exchange listener from the MessageExchangeSupport.
|
||||
*/
|
||||
protected void removeMessageExchangeListener() {
|
||||
QName interfaceName = this.getService().getInterface();
|
||||
QName serviceName = this.getService().getServiceName();
|
||||
String endpointName = this.getService().getEndpointName();
|
||||
MessageExchangeSupport meListenerSupport = getMessageExchangeSupport();
|
||||
if ( meListenerSupport != null ) {
|
||||
meListenerSupport.removeMessageExchangeListener(
|
||||
this.getRole(), interfaceName, serviceName, endpointName);
|
||||
if ( serviceName != null ) {
|
||||
meListenerSupport.removeMessageExchangeListener(
|
||||
this.getRole(), null, serviceName, endpointName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public final boolean processMessageExchangeWithHandler(ExchangeStatus status, MessageExchange me) {
|
||||
|
||||
//1. lookup handler
|
||||
//2. if not there create one and register
|
||||
//3. call process message exchange on it
|
||||
//4. check status. if that is the end, remove the handler
|
||||
|
||||
MessageExchangeSupport support = this.getMessageExchangeSupport();
|
||||
if ( support == null ) {
|
||||
getLogger().fine("No MessageExchangeSupport present");
|
||||
return false;
|
||||
}
|
||||
MessageExchangeHandler handler = support.findMessageExchangeHandler(me);
|
||||
if ( handler == null ) {
|
||||
handler = this.createMessageExchangeHandler();
|
||||
if ( handler == null ) {
|
||||
getLogger().fine("MessageExchangeHandler not supported");
|
||||
return false;
|
||||
}
|
||||
support.addMessageExchangeHandler(me, handler);
|
||||
}
|
||||
|
||||
handler.processMessageExchange(status, me);
|
||||
|
||||
getLogger().fine("XXX MX Handler processed ME with STATUS: " + status);
|
||||
|
||||
if (!ExchangeStatus.ACTIVE.equals(status) ) {
|
||||
// DONE or ERROR means done with the me.
|
||||
getLogger().fine("End of ME processing. STATUS: " + status +
|
||||
". Removing the MX Handler ...");
|
||||
support.removeMessageExchangeHandler(me);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,104 @@
|
|||
/*
|
||||
* ProviderEndpoint.java
|
||||
*
|
||||
*/
|
||||
|
||||
package org.openesb.components.camelse.common.deployment;
|
||||
|
||||
import org.openesb.components.camelse.common.deployment.SUDescriptor.Service;
|
||||
import javax.jbi.JBIException;
|
||||
import javax.jbi.messaging.MessageExchange.Role;
|
||||
import javax.jbi.servicedesc.ServiceEndpoint;
|
||||
import javax.wsdl.Definition;
|
||||
|
||||
/**
|
||||
* This class extends from Endpoint class and implements lifecycle methods functionality required for the
|
||||
* endpoint for a service provider. {@link ServiceUnit#createProviderEndpoint} creates the object of this
|
||||
* type to implement the service provider functionality. It makes sure that this class or the extended
|
||||
* classes will activate or deactivate the <code>ServiceEndpoint</code> corresponding to the service
|
||||
* provided by the endpoint is performed during the activate and deactivate method calls as part of the
|
||||
* endpoint lifecycle.
|
||||
*
|
||||
* @see ServiceUnit#createProviderEndpoint
|
||||
* @author chikkala
|
||||
*/
|
||||
|
||||
public class ProviderEndpoint extends Endpoint {
|
||||
/**
|
||||
* This constructor initializes the endpoint with PROVIDER role and makes sure that the service
|
||||
* description passed to it is of provider description.
|
||||
*/
|
||||
protected ProviderEndpoint(SUDescriptor.Provides provides, Definition wsdlDef, ServiceUnit su) {
|
||||
super(Role.PROVIDER, provides, wsdlDef, su);
|
||||
}
|
||||
/**
|
||||
* constructor that does not need service unit information. useful for creating the endpoint for
|
||||
* static services provided by the component.
|
||||
*/
|
||||
protected ProviderEndpoint(SUDescriptor.Provides provides, Definition wsdlDef) {
|
||||
this(provides, wsdlDef, null);
|
||||
}
|
||||
/**
|
||||
* initializes the endpoint and creates and registers the MessageExchangeListener with
|
||||
* MessageExchangeSupport.
|
||||
*/
|
||||
public final void init() throws JBIException {
|
||||
getLogger().fine("ProviderEndpiont: init called");
|
||||
doInit(); //1. initialize the endpiont resources
|
||||
addMessageExchangeListener(); //2. register message exchange linster.
|
||||
}
|
||||
/**
|
||||
* calls activatesServiceEndpoint for the Provider.
|
||||
*/
|
||||
public final void activate() throws JBIException {
|
||||
getLogger().fine("ProviderEndpiont: activate called");
|
||||
activateServiceEndpoint(); //1. activate service endpoint in NMR
|
||||
doActivate(); //2. do any other activation related tasks.
|
||||
}
|
||||
/**
|
||||
* calls deactivateServiceEndpoint for the Provider.
|
||||
*/
|
||||
public final void deactivate() throws JBIException {
|
||||
getLogger().fine("ProviderEndpiont: deactivate called");
|
||||
deactivateServiceEndpoint(); //1. deactivates the service endpoint in NMR
|
||||
doDeactivate(); //2. do any other deactivation related tasks.
|
||||
}
|
||||
/**
|
||||
* removes the message exchange listener. cleans up other resources
|
||||
*/
|
||||
public final void clean() throws JBIException {
|
||||
getLogger().fine("ProviderEndpiont: clean called");
|
||||
removeMessageExchangeListener(); //1. remove message exchange listener
|
||||
doClean(); //2. clean up any other resources.
|
||||
}
|
||||
/**
|
||||
* Activates the ServiceEndpoint with NMR
|
||||
*/
|
||||
private void activateServiceEndpoint() throws JBIException {
|
||||
Service service = this.getService();
|
||||
ServiceEndpoint svcEP = this.getComponentContext().activateEndpoint(
|
||||
service.getServiceName(), service.getEndpointName());
|
||||
this.setServiceEndpoint(svcEP);
|
||||
}
|
||||
/**
|
||||
* Deactivates ServiceEndpoint in NMR
|
||||
*/
|
||||
private void deactivateServiceEndpoint() throws JBIException {
|
||||
this.getComponentContext().deactivateEndpoint(this.getServiceEndpoint());
|
||||
this.setServiceEndpoint(null);
|
||||
}
|
||||
|
||||
protected void doInit() throws JBIException {
|
||||
//NOOP
|
||||
}
|
||||
protected void doActivate() throws JBIException {
|
||||
//NOOP
|
||||
}
|
||||
protected void doDeactivate() throws JBIException {
|
||||
//NOOP
|
||||
}
|
||||
protected void doClean() throws JBIException {
|
||||
//NOOP
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,361 @@
|
|||
/*
|
||||
* SUDescriptor.java
|
||||
*/
|
||||
|
||||
package org.openesb.components.camelse.common.deployment;
|
||||
|
||||
import org.openesb.components.camelse.common.RuntimeHelper;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import javax.jbi.management.DeploymentException;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
/**
|
||||
* This interface represent the service unit descriptor (jbi.xml) model. This will be used in
|
||||
* ServiceUnit implementation to find the services provided and consumed by this service unit.
|
||||
* {@link SUDescriptorFactory#getSUDescriptor} method reads the jbi.xml in the service unit to
|
||||
* to the implementation of this interface.
|
||||
*
|
||||
* @see SUDescriptorFactory
|
||||
* @see Consumes
|
||||
* @see Provides
|
||||
* @see ServiceUnit
|
||||
*
|
||||
* @author chikkala
|
||||
*/
|
||||
public interface SUDescriptor {
|
||||
|
||||
Collection<Provides> getProvidedServices();
|
||||
|
||||
Collection<Consumes> getConsumedServices();
|
||||
|
||||
boolean isForBindingComponent();
|
||||
|
||||
/**
|
||||
* base interface that models the service information described in the service unit descriptor for
|
||||
* consumed services and provided services.
|
||||
*/
|
||||
public interface Service {
|
||||
/**
|
||||
* Getter for property interfaceQName.
|
||||
* @return Value of property interfaceQName.
|
||||
*/
|
||||
QName getInterface();
|
||||
/**
|
||||
* Getter for property serviceName.
|
||||
* @return Value of property serviceName.
|
||||
*/
|
||||
QName getServiceName();
|
||||
/**
|
||||
* Getter for property endpointName.
|
||||
* @return Value of property endpointName.
|
||||
*/
|
||||
String getEndpointName();
|
||||
}
|
||||
/**
|
||||
* marker interface that represents the provided services in the service unit
|
||||
*/
|
||||
public interface Provides extends Service {
|
||||
}
|
||||
/**
|
||||
* this interface represents the consumed service information in the su descriptor.
|
||||
*/
|
||||
public interface Consumes extends Service {
|
||||
|
||||
public final static String STANDARD_LINK = "standard";
|
||||
public final static String SOFT_LINK = "soft";
|
||||
public final static String HARD_LINK = "hard";
|
||||
/**
|
||||
* Getter for property linkType.
|
||||
* @return Value of property linkType.
|
||||
*/
|
||||
String getLinkType();
|
||||
}
|
||||
/**
|
||||
* This is a factory class that can build the Service Unit Descriptor model from the jbi.xml
|
||||
*/
|
||||
public static class SUDescriptorFactory {
|
||||
|
||||
protected final static String JBI_TAG_NAME = "services";
|
||||
protected final static String SERVICES_TAG_NAME = "services";
|
||||
protected final static String BC_TAG_NAME = "binding-component";
|
||||
protected final static String PROVIDES_TAG_NAME = "provides";
|
||||
protected final static String CONSUMES_TAG_NAME = "consumes";
|
||||
protected final static String INTERFACE_TAG_NAME = "interface-name";
|
||||
protected final static String SERVICE_TAG_NAME = "service-name";
|
||||
protected final static String ENDPOINT_TAG_NAME = "endpoint-name";
|
||||
protected final static String LINK_TYPE_TAG_NAME = "link-type";
|
||||
/**
|
||||
* method that builds the Service unit descriptor model from the jbi.xml
|
||||
*/
|
||||
public static SUDescriptor getSUDescriptor(String jbiXmlPath) throws Exception {
|
||||
FileReader reader = null;
|
||||
try {
|
||||
reader = new FileReader(jbiXmlPath);
|
||||
SUDescriptor suDesc = getSUDescriptor(reader);
|
||||
return suDesc;
|
||||
} finally {
|
||||
if ( reader != null ) {
|
||||
try {
|
||||
reader.close();
|
||||
} catch (IOException ex) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* method that builds the Service unit descriptor model from the jbi.xml
|
||||
*/
|
||||
public static SUDescriptor getSUDescriptor(Reader reader) throws Exception {
|
||||
SUDescriptor suDescriptor = null;
|
||||
Document suDescDoc = RuntimeHelper.buildDOMDocument(reader);
|
||||
Element jbiEl = suDescDoc.getDocumentElement();
|
||||
if (JBI_TAG_NAME.equals(jbiEl.getTagName())) {
|
||||
throw new DeploymentException("Invalid service unit descriptor : no jbi root element");
|
||||
}
|
||||
|
||||
NodeList servicesNL = jbiEl.getElementsByTagName(SERVICES_TAG_NAME);
|
||||
if (servicesNL != null && servicesNL.getLength() == 1) {
|
||||
Element servicesEl = (Element) servicesNL.item(0);
|
||||
suDescriptor = SUDescriptorImpl.createSUDescriptor(servicesEl);
|
||||
} else {
|
||||
throw new DeploymentException("Invalid service unit descriptor : invalid services element");
|
||||
}
|
||||
|
||||
return suDescriptor;
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* This class implements SUDescriptor
|
||||
*/
|
||||
public static class SUDescriptorImpl implements SUDescriptor {
|
||||
|
||||
private List<Consumes> mConsumedList;
|
||||
private List<Provides> mProvidedList;
|
||||
private boolean mIsForBindingComponent;
|
||||
|
||||
protected SUDescriptorImpl(boolean isForBindingComponent) {
|
||||
this.mIsForBindingComponent = isForBindingComponent;
|
||||
this.mConsumedList = new ArrayList<Consumes>();
|
||||
this.mProvidedList = new ArrayList<Provides>();
|
||||
}
|
||||
|
||||
protected void addProvidedService(Provides provides) {
|
||||
this.mProvidedList.add(provides);
|
||||
}
|
||||
|
||||
protected void addConsumedService(Consumes consumes) {
|
||||
this.mConsumedList.add(consumes);
|
||||
}
|
||||
|
||||
public Collection<Provides> getProvidedServices() {
|
||||
// return unmodifiable collection
|
||||
return Collections.unmodifiableCollection(this.mProvidedList);
|
||||
}
|
||||
|
||||
public Collection<Consumes> getConsumedServices() {
|
||||
// return unmodifiable collection
|
||||
return Collections.unmodifiableCollection(this.mConsumedList);
|
||||
}
|
||||
|
||||
public boolean isForBindingComponent() {
|
||||
return this.mIsForBindingComponent;
|
||||
}
|
||||
|
||||
protected static SUDescriptor createSUDescriptor(Element servicesEl) throws Exception {
|
||||
boolean isForBC = false;
|
||||
String bcTagString = servicesEl.getAttribute(SUDescriptorFactory.BC_TAG_NAME);
|
||||
isForBC = Boolean.valueOf(bcTagString).booleanValue();
|
||||
SUDescriptorImpl suDesc = new SUDescriptorImpl(isForBC);
|
||||
// add consumes
|
||||
NodeList consumesNL = servicesEl.getElementsByTagName(SUDescriptorFactory.CONSUMES_TAG_NAME);
|
||||
for ( int i=0; i < consumesNL.getLength(); ++i) {
|
||||
Element consumesEl = (Element) consumesNL.item(i);
|
||||
Consumes consumes = ConsumedService.createConsumedService(consumesEl);
|
||||
suDesc.addConsumedService(consumes);
|
||||
}
|
||||
// add provides
|
||||
NodeList providesNL = servicesEl.getElementsByTagName(SUDescriptorFactory.PROVIDES_TAG_NAME);
|
||||
for ( int i=0; i < providesNL.getLength(); ++i) {
|
||||
Element providesEl = (Element) providesNL.item(i);
|
||||
Provides provides = ProvidedService.createProvidedService(providesEl);
|
||||
suDesc.addProvidedService(provides);
|
||||
}
|
||||
|
||||
return suDesc;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Base class that implements the Service interface
|
||||
*/
|
||||
public static abstract class AbstractService implements Service {
|
||||
|
||||
private QName mInterface;
|
||||
private QName mServiceName;
|
||||
private String mEndpointName;
|
||||
|
||||
private AbstractService() {
|
||||
}
|
||||
/**
|
||||
* Getter for property interfaceQName.
|
||||
* @return Value of property interfaceQName.
|
||||
*/
|
||||
public QName getInterface() {
|
||||
return this.mInterface;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for property interfaceQName.
|
||||
* @param interfaceQName New value of property interfaceQName.
|
||||
*/
|
||||
protected void setInterface(QName interfaceQName) {
|
||||
this.mInterface = interfaceQName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for property serviceName.
|
||||
* @return Value of property serviceName.
|
||||
*/
|
||||
public QName getServiceName() {
|
||||
return this.mServiceName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for property serviceName.
|
||||
* @param serviceName New value of property serviceName.
|
||||
*/
|
||||
protected void setServiceName(QName serviceName) {
|
||||
this.mServiceName = serviceName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for property endpointName.
|
||||
* @return Value of property endpointName.
|
||||
*/
|
||||
public String getEndpointName() {
|
||||
return this.mEndpointName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for property endpointName.
|
||||
* @param endpointName New value of property endpointName.
|
||||
*/
|
||||
protected void setEndpointName(String endpointName) {
|
||||
this.mEndpointName = endpointName;
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* This class implements the Provides interface
|
||||
*/
|
||||
public static class ProvidedService
|
||||
extends AbstractService
|
||||
implements Provides {
|
||||
protected ProvidedService(QName interfaceQName, QName serviceName, String endpointName) {
|
||||
this.setInterface(interfaceQName);
|
||||
this.setServiceName(serviceName);
|
||||
this.setEndpointName(endpointName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Provides :" +
|
||||
"\n\t interface-name= " + getInterface() +
|
||||
"\n\t service-name= " + getServiceName() +
|
||||
"\n\t endpont-name= " + getEndpointName();
|
||||
}
|
||||
|
||||
protected static Provides createProvidedService(Element providesEl) throws Exception {
|
||||
|
||||
String ifName = providesEl.getAttribute(SUDescriptorFactory.INTERFACE_TAG_NAME);
|
||||
String serviceName = providesEl.getAttribute(SUDescriptorFactory.SERVICE_TAG_NAME);
|
||||
String endpointName = providesEl.getAttribute(SUDescriptorFactory.ENDPOINT_TAG_NAME);
|
||||
if ( ifName == null || serviceName == null || endpointName == null ) {
|
||||
throw new Exception("Invalid provides element: missing " + SUDescriptorFactory.INTERFACE_TAG_NAME +
|
||||
" or " + SUDescriptorFactory.SERVICE_TAG_NAME + " or " + SUDescriptorFactory.ENDPOINT_TAG_NAME );
|
||||
}
|
||||
QName ifQName = RuntimeHelper.resolveAttrQName(ifName, providesEl);
|
||||
QName serviceQName = RuntimeHelper.resolveAttrQName(serviceName, providesEl);
|
||||
|
||||
return new ProvidedService(ifQName, serviceQName, endpointName);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* This class implements the Consumes interface.
|
||||
*/
|
||||
public static class ConsumedService
|
||||
extends AbstractService
|
||||
implements Consumes {
|
||||
private String mLinkType;
|
||||
protected ConsumedService(QName interfaceQName,
|
||||
QName serviceName, String endpointName, String linkType) {
|
||||
this.setInterface(interfaceQName);
|
||||
this.setServiceName(serviceName);
|
||||
this.setEndpointName(endpointName);
|
||||
this.mLinkType = linkType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for property linkType.
|
||||
* @return Value of property linkType.
|
||||
*/
|
||||
public String getLinkType() {
|
||||
return this.mLinkType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Cosumes :" +
|
||||
"\n\t interface-name= " + getInterface() +
|
||||
"\n\t service-name= " + getServiceName() +
|
||||
"\n\t endpont-name= " + getEndpointName() +
|
||||
"\n\t link-type= " + getLinkType();
|
||||
}
|
||||
|
||||
protected static Consumes createConsumedService(Element consumesEl) throws Exception {
|
||||
|
||||
String ifName = consumesEl.getAttribute(SUDescriptorFactory.INTERFACE_TAG_NAME);
|
||||
String serviceName = consumesEl.getAttribute(SUDescriptorFactory.SERVICE_TAG_NAME);
|
||||
String endpointName = consumesEl.getAttribute(SUDescriptorFactory.ENDPOINT_TAG_NAME);
|
||||
String linkType = consumesEl.getAttribute(SUDescriptorFactory.LINK_TYPE_TAG_NAME);
|
||||
if ( linkType == null || linkType.trim().length() == 0 ) {
|
||||
linkType = STANDARD_LINK;
|
||||
}
|
||||
|
||||
if ( ifName == null ) {
|
||||
throw new Exception("Invalid consumes element: missing " +
|
||||
SUDescriptorFactory.INTERFACE_TAG_NAME );
|
||||
}
|
||||
if ( serviceName == null || endpointName == null ) {
|
||||
throw new Exception("Invalid consumes element: missing " +
|
||||
SUDescriptorFactory.SERVICE_TAG_NAME + " or "
|
||||
+ SUDescriptorFactory.ENDPOINT_TAG_NAME );
|
||||
}
|
||||
|
||||
QName ifQName = RuntimeHelper.resolveAttrQName(ifName, consumesEl);
|
||||
QName serviceQName = null;
|
||||
if ( serviceName != null ) {
|
||||
serviceQName = RuntimeHelper.resolveAttrQName(serviceName, consumesEl);
|
||||
}
|
||||
if ( serviceQName != null && endpointName != null && linkType != null ) {
|
||||
if (!(STANDARD_LINK.equals(linkType) ||
|
||||
SOFT_LINK.equals(linkType) || HARD_LINK.equals(linkType)) ) {
|
||||
throw new Exception("Invalid consumes attribute value" +
|
||||
SUDescriptorFactory.LINK_TYPE_TAG_NAME + "=" + linkType);
|
||||
}
|
||||
}
|
||||
return new ConsumedService(ifQName, serviceQName, endpointName, linkType);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,461 @@
|
|||
/*
|
||||
* ServiceUnit.java
|
||||
*
|
||||
*/
|
||||
|
||||
package org.openesb.components.camelse.common.deployment;
|
||||
|
||||
import org.openesb.components.camelse.common.RuntimeHelper;
|
||||
import org.openesb.components.camelse.common.deployment.SUDescriptor.Consumes;
|
||||
import org.openesb.components.camelse.common.deployment.SUDescriptor.Provides;
|
||||
import org.openesb.components.camelse.common.deployment.SUDescriptor.Service;
|
||||
import org.openesb.components.camelse.common.wsdl.WSDLProcessor;
|
||||
import java.io.File;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.jbi.management.DeploymentException;
|
||||
import javax.wsdl.Definition;
|
||||
import javax.wsdl.WSDLException;
|
||||
|
||||
/**
|
||||
* This is an abstract class that implements the service unit functionality in the component which
|
||||
* processes the service unit artifacts and implement the actual service unit lifecycle functionality.
|
||||
* The AbstractServiceUnitManager and its extended classes that implement the ServiceUnitManager
|
||||
* functionality creates and maintains the reference to the concrete implementation of this class to
|
||||
* invoke the functionality implemented by this class and its concrete implementation during the
|
||||
* execution of the ServiceUnitMangers lifecycle methods by the jbi runtime.
|
||||
* <p>
|
||||
* The main lifecycle methods of this class that will be called by the ServiceUnitManger implementation
|
||||
* during the service unit deployment lifecycle are {@link #doload}, {@link #doDeploy}, {@link #doUndeploy},
|
||||
* {@link #doInit}, {@link #doStart}, {@link #doStop} and {@link #doShutdown}
|
||||
* <p>
|
||||
* Service unit processing supported by this implementation is based on wsdl 1.1 deployments where the
|
||||
* services provided and consumed in this service unit are described using wsdl 1.1 definitions.
|
||||
* <p>
|
||||
* The main service unit artifacts that will be processed during deployment lifecycle of the service
|
||||
* unit are 1.Service unit descriptor(jbi.xml) that describes the services provided and consumed by
|
||||
* this service unit. 2.WSDL 1.1 document that describes the service definition 3.Component specific
|
||||
* configurations related to services provided and consumed by this service unit.
|
||||
* <p>
|
||||
* When the service unit is for Binding Component, the component specific configurations are read
|
||||
* from the WSDL1.1 extensions defined in the WSDL document corresponding to the service provider
|
||||
* or consumer deployed with this service unit.
|
||||
* <p>
|
||||
* When the service unit is for Service Engine, the component specific configurations are read
|
||||
* from the deployment artifacts such as xslt files and mapping files in the service unit zip file
|
||||
* along with the WSDL document corresponding to the service provider or consumer deployed with this
|
||||
* service unit.
|
||||
*
|
||||
* @see SUDescriptor
|
||||
* @see Endpoint
|
||||
* @see ProviderEndpoint
|
||||
* @see ConsumerEndpoint
|
||||
* @see WSDLProcessor
|
||||
* @author chikkala
|
||||
*/
|
||||
public abstract class ServiceUnit {
|
||||
/** Service Unit Name */
|
||||
private String mSUName;
|
||||
/** Service Unit Root path passed by jbi runtime */
|
||||
private String mSURootPath;
|
||||
/** service unit descriptor model unmarshalled from service unit jbi.xml */
|
||||
private SUDescriptor mSUDescriptor;
|
||||
/** Map of Endpoint Key to ProviderEndpoint configurations in this service unit */
|
||||
private Map<String, ProviderEndpoint> mProviderEndpointMap;
|
||||
/** Map of Endpoint Key to ConsumerEndpoint configurations in this service unit */
|
||||
private Map<String, ConsumerEndpoint> mConsumerEndpointMap;
|
||||
/** Map of Service Key to the WSDL Definition in this service unit */
|
||||
private Map<String, Definition> mWSDLMap;
|
||||
/** WSDLProcessor configured for this service unit to process wsdls in the service unit */
|
||||
private WSDLProcessor mWSDLProcessor;
|
||||
/**
|
||||
*
|
||||
* @param suName
|
||||
* @param suRootPath
|
||||
*/
|
||||
protected ServiceUnit(String suName, String suRootPath) {
|
||||
this.mSUName = suName;
|
||||
this.mSURootPath = suRootPath;
|
||||
this.mSUDescriptor = null;
|
||||
this.mWSDLMap = new HashMap<String,Definition>();
|
||||
this.mProviderEndpointMap = new HashMap<String, ProviderEndpoint>();
|
||||
this.mConsumerEndpointMap = new HashMap<String, ConsumerEndpoint>();
|
||||
}
|
||||
/** returns service unit name
|
||||
* @return service unit name
|
||||
*/
|
||||
public String getName() {
|
||||
return this.mSUName;
|
||||
}
|
||||
/** returns service unit root path where the su artifacts are unzipped by the jbi runtime
|
||||
* @return path to the service unit root directory.
|
||||
*/
|
||||
public String getSURootPath() {
|
||||
return this.mSURootPath;
|
||||
}
|
||||
protected SUDescriptor createSUDescriptor() throws Exception {
|
||||
File jbiXmlFile = new File(this.getSURootPath(), "META-INF/jbi.xml");
|
||||
String jbiXmlPath = jbiXmlFile.getAbsolutePath();
|
||||
return SUDescriptor.SUDescriptorFactory.getSUDescriptor(jbiXmlPath);
|
||||
}
|
||||
/** return the Service unit descriptor model that was read from the jbi.xml
|
||||
* @return SUDescriptor
|
||||
*/
|
||||
public SUDescriptor getSUDescriptor() throws Exception {
|
||||
if ( this.mSUDescriptor == null ) {
|
||||
this.mSUDescriptor = createSUDescriptor();
|
||||
}
|
||||
return this.mSUDescriptor;
|
||||
}
|
||||
public ProviderEndpoint getProviderEndpoint(String providerID) {
|
||||
return this.mProviderEndpointMap.get(providerID);
|
||||
}
|
||||
public Collection<ProviderEndpoint> getProviderEndpoints() {
|
||||
return Collections.unmodifiableCollection(this.mProviderEndpointMap.values());
|
||||
}
|
||||
public ConsumerEndpoint getConsumerEndpoint(String cosumerID) {
|
||||
return this.mConsumerEndpointMap.get(cosumerID);
|
||||
}
|
||||
|
||||
public Collection<ConsumerEndpoint> getConsumerEndpoints() {
|
||||
return Collections.unmodifiableCollection(this.mConsumerEndpointMap.values());
|
||||
}
|
||||
/**
|
||||
* @return Logger
|
||||
*/
|
||||
protected Logger getLogger() {
|
||||
return RuntimeHelper.getLogger();
|
||||
}
|
||||
/**
|
||||
* extended classes implement this method to create the su specific WSDLProcessor. for examples,
|
||||
* a su supporting binding component may have wsdl extensions that it want to registry for reading
|
||||
* the configurations from the wsdl file.
|
||||
* @return WSDLProcessor
|
||||
* @see com.sun.jbi.sample.component.common.wsdl.WSDLProcessor
|
||||
* @see com.sun.jbi.sample.component.common.wsdl.AbstractExtensionRegistry
|
||||
*/
|
||||
protected WSDLProcessor createWSDLProcessor() {
|
||||
return new WSDLProcessor(this.getSURootPath());
|
||||
}
|
||||
/**
|
||||
* return the WSDLProcessor reference by creates if it is not yet created.
|
||||
* @return WSDLProcessor.
|
||||
*/
|
||||
public final WSDLProcessor getWSDLProcessor() {
|
||||
if ( this.mWSDLProcessor == null ) {
|
||||
this.mWSDLProcessor = createWSDLProcessor();
|
||||
}
|
||||
return this.mWSDLProcessor;
|
||||
}
|
||||
/**
|
||||
* loads the service unit artifacts into the SU model. AbstractServiceUnitManager implementation
|
||||
* calls this method during the during deploy and init lifecycle methods when the service unit
|
||||
* object is newly created.
|
||||
*/
|
||||
public void doLoad() throws DeploymentException {
|
||||
try {
|
||||
SUDescriptor suDesc = getSUDescriptor(); // load jbi.xml
|
||||
loadServiceDefinitions(); // check if the wsdls are valid for corresponding services.
|
||||
loadOtherArtifacts(); // additional validations specific to component deployment features.
|
||||
loadEndpoints(); // create endpoints
|
||||
} catch ( DeploymentException jbiEx) {
|
||||
throw jbiEx;
|
||||
} catch (Exception ex) {
|
||||
throw new DeploymentException(ex);
|
||||
}
|
||||
}
|
||||
/** extended classes implement this method to perform the su specific deployment related tasks in
|
||||
* this method implementation.
|
||||
* @throws DeploymentException on error.
|
||||
*/
|
||||
public void doDeploy() throws DeploymentException {
|
||||
// NOOP. doLoad has done it all.
|
||||
this.getLogger().fine("ServiceUnit.doDeploy");
|
||||
}
|
||||
/** extended classes implement this method to perform the su specific undeployment related tasks in
|
||||
* this method implementation.
|
||||
* @throws DeploymentException on error.
|
||||
*/
|
||||
public void doUndeploy() throws DeploymentException {
|
||||
//NOOP
|
||||
this.getLogger().fine("ServiceUnit.doUndeploy");
|
||||
}
|
||||
/** extended classes implement this method to perform the su specific initialization tasks in
|
||||
* this method implementation.
|
||||
* @throws DeploymentException on error.
|
||||
*/
|
||||
public void doInit() throws DeploymentException {
|
||||
this.getLogger().fine("ServiceUnit.doInit");
|
||||
this.doInitEndpoints();
|
||||
}
|
||||
/** extended classes implement this method to perform the su specific tasks on start in
|
||||
* this method implementation.
|
||||
* @throws DeploymentException on error.
|
||||
*/
|
||||
public void doStart() throws DeploymentException {
|
||||
this.getLogger().fine("ServiceUnit.doStart");
|
||||
this.doActivateEndpoints();
|
||||
}
|
||||
/** extended classes implement this method to perform the su specific tasks on stop in
|
||||
* this method implementation.
|
||||
* @throws DeploymentException on error.
|
||||
*/
|
||||
public void doStop() throws DeploymentException {
|
||||
this.getLogger().fine("ServiceUnit.doStop");
|
||||
this.doDeactivateEndpoints();
|
||||
}
|
||||
/** extended classes implement this method to perform the su specific tasks on shutdown in
|
||||
* this method implementation.
|
||||
* @throws DeploymentException on error.
|
||||
*/
|
||||
public void doShutdown() throws DeploymentException {
|
||||
this.getLogger().fine("ServiceUnit.doShutdown");
|
||||
this.doCleanEndpoints();
|
||||
}
|
||||
/**
|
||||
* create the ProviderEndpoint that implement the service provider implementation specific to this su.
|
||||
* @return ProviderEndpoint or null if the SU does not support the service provider access
|
||||
*/
|
||||
protected ProviderEndpoint createProviderEndpoint(Provides provides, Definition wsdlDef) {
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* create the ProviderEndpoint that implement the service consumer implementation specific to this su.
|
||||
* @return ConsumerEndpoint or null if the SU does not support the service consumer access
|
||||
*/
|
||||
protected ConsumerEndpoint createConsumerEndpoint(Consumes consumes, Definition wsdlDef) {
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* generates the key based on the service to store the wsdl definitions .
|
||||
*/
|
||||
protected String getServiceKey(Service service) {
|
||||
StringBuffer strBuff = new StringBuffer();
|
||||
strBuff.append(service.getInterface()).append("+");
|
||||
strBuff.append(service.getServiceName()).append("+");
|
||||
strBuff.append(service.getEndpointName());
|
||||
return strBuff.toString();
|
||||
}
|
||||
/**
|
||||
* looks up the wsdl definition loaded for this service.
|
||||
*/
|
||||
protected Definition findWSDLFor(Service service) throws WSDLException {
|
||||
Definition wsdlDef = null;
|
||||
String key = this.getServiceKey(service);
|
||||
wsdlDef = this.mWSDLMap.get(key);
|
||||
return wsdlDef;
|
||||
}
|
||||
|
||||
protected Definition findWSDL(List<Definition> wsdlList, Service service, boolean ignoreEndpointLookup) {
|
||||
Definition foundDef = null;
|
||||
for ( Definition def : wsdlList ) {
|
||||
if ( WSDLProcessor.isWSDLFor(def, service.getInterface(), service.getServiceName(),
|
||||
((ignoreEndpointLookup) ? null : service.getEndpointName()) ) ) {
|
||||
foundDef = def;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return foundDef;
|
||||
}
|
||||
/**
|
||||
* loads the WSDL definitions corresponds to the service providers and consumers defined in the
|
||||
* service unit descriptor.
|
||||
*/
|
||||
protected void loadServiceDefinitions() throws Exception {
|
||||
|
||||
this.mWSDLMap = new HashMap<String,Definition>();
|
||||
|
||||
WSDLProcessor wsdlProcessor = getWSDLProcessor();
|
||||
List<Definition> wsdlList = wsdlProcessor.readWSDLs(this.getSURootPath());
|
||||
this.getLogger().fine("Number of wsdl definitions in service unit " + wsdlList.size());
|
||||
|
||||
List<Service> services = new ArrayList<Service>();
|
||||
services.addAll(this.getSUDescriptor().getProvidedServices());
|
||||
services.addAll(this.getSUDescriptor().getConsumedServices());
|
||||
|
||||
boolean isForBinding = this.getSUDescriptor().isForBindingComponent();
|
||||
this.getLogger().fine("Is this service unit for Binding? " + isForBinding);
|
||||
|
||||
for ( Service service : services ) {
|
||||
this.getLogger().fine("Looking up WSDL for service " + service);
|
||||
boolean ignoreEndpointLookup = false;
|
||||
boolean providerAtEngine = false;
|
||||
if ( !isForBinding && service instanceof Provides ) {
|
||||
ignoreEndpointLookup = true;
|
||||
providerAtEngine = true;
|
||||
}
|
||||
Definition def = findWSDL(wsdlList, service, ignoreEndpointLookup);
|
||||
if ( def == null ) {
|
||||
throw new Exception("WSDL Definition not found for " + service);
|
||||
}
|
||||
this.mWSDLMap.put(getServiceKey(service), def);
|
||||
if ( providerAtEngine ) {
|
||||
// provider at engine. so add engine binding and endpoint to the wsdl
|
||||
wsdlProcessor.createServiceEngineBinding(def,
|
||||
service.getInterface(), service.getServiceName(), service.getEndpointName());
|
||||
}
|
||||
}
|
||||
}
|
||||
/** extended classes implement this method to perform the su specific artifacts validation in
|
||||
* this method implementation.
|
||||
* @throws DeploymentException on error.
|
||||
*/
|
||||
protected void loadOtherArtifacts() throws DeploymentException {
|
||||
// nothing to validate further.
|
||||
this.getLogger().fine("ServiceUnit.loadOtherArtifacts");
|
||||
}
|
||||
/**
|
||||
* creates ProviderEndpoint and ConsumerEndpoint objects corresponding to the service providers
|
||||
* and consumers described in the su descriptor ( jbi.xml )
|
||||
*/
|
||||
protected void loadEndpoints() throws Exception {
|
||||
|
||||
this.mProviderEndpointMap = new HashMap<String, ProviderEndpoint>();
|
||||
this.mConsumerEndpointMap = new HashMap<String, ConsumerEndpoint>();
|
||||
|
||||
Collection<Provides> providesList = this.getSUDescriptor().getProvidedServices();
|
||||
for ( Provides provides : providesList ) {
|
||||
Definition wsdlDef = findWSDLFor(provides);
|
||||
if ( wsdlDef == null ) {
|
||||
throw new DeploymentException("WSDL Definitions not found for " + provides);
|
||||
}
|
||||
ProviderEndpoint provider = createProviderEndpoint(provides, wsdlDef);
|
||||
this.mProviderEndpointMap.put(provider.getID(), provider);
|
||||
}
|
||||
|
||||
Collection<Consumes> consumesList = this.getSUDescriptor().getConsumedServices();
|
||||
for ( Consumes consumes : consumesList ) {
|
||||
Definition wsdlDef = findWSDLFor(consumes);
|
||||
if ( wsdlDef == null ) {
|
||||
throw new DeploymentException("WSDL Definitions not found for " + consumes);
|
||||
}
|
||||
ConsumerEndpoint consumer = createConsumerEndpoint(consumes, wsdlDef);
|
||||
this.mConsumerEndpointMap.put(consumer.getID(), consumer);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* initializes the Endpoint objects created corresponding to the consumer and providers defined
|
||||
* in the su descriptor
|
||||
*/
|
||||
protected void doInitEndpoints() throws DeploymentException {
|
||||
// init endpoints. if any initialization fails, rollback the already inited endpoints
|
||||
List<Endpoint> initedEndpoints = new ArrayList<Endpoint>();
|
||||
List<Endpoint> allEndpoints = new ArrayList<Endpoint>();
|
||||
allEndpoints.addAll(this.getProviderEndpoints());
|
||||
allEndpoints.addAll(this.getConsumerEndpoints());
|
||||
|
||||
for ( Endpoint endpoint : allEndpoints ) {
|
||||
try {
|
||||
endpoint.init();
|
||||
initedEndpoints.add(endpoint);
|
||||
} catch ( Exception initEx) {
|
||||
doCleanEndpoints(initedEndpoints);
|
||||
throw new DeploymentException(initEx);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* invokes activates method of all provider and consumer endpoint object in this su. if there is
|
||||
* and error activating any one the endpoints, it deactivates the already activated ones and throws
|
||||
* the error
|
||||
*/
|
||||
protected void doActivateEndpoints() throws DeploymentException {
|
||||
// activate providers first and then consumers
|
||||
List<Endpoint> activatedEndpoints = new ArrayList<Endpoint>();
|
||||
List<Endpoint> allEndpoints = new ArrayList<Endpoint>();
|
||||
allEndpoints.addAll(this.getProviderEndpoints());
|
||||
allEndpoints.addAll(this.getConsumerEndpoints());
|
||||
|
||||
for ( Endpoint endpoint : allEndpoints ) {
|
||||
try {
|
||||
endpoint.activate();
|
||||
activatedEndpoints.add(endpoint);
|
||||
} catch ( Exception actEx) {
|
||||
doDeactivateEndpoints(activatedEndpoints);
|
||||
throw new DeploymentException(actEx);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* invokes deactivate method on the list of Endpoint objects passed to this method
|
||||
*/
|
||||
protected void doDeactivateEndpoints(List<Endpoint> endpoints) {
|
||||
for ( Endpoint endpoint : endpoints ) {
|
||||
try {
|
||||
endpoint.deactivate();
|
||||
} catch(Exception ex) {
|
||||
// ignore the exception and log it.
|
||||
this.getLogger().log(Level.FINE, ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* invokes deactivate method on the all consumer and provider endpoint objects
|
||||
*/
|
||||
protected void doDeactivateEndpoints() {
|
||||
// deactivate consumers first and then the providers
|
||||
List<Endpoint> allEndpoints = new ArrayList<Endpoint>();
|
||||
allEndpoints.addAll(this.getConsumerEndpoints());
|
||||
allEndpoints.addAll(this.getProviderEndpoints());
|
||||
doDeactivateEndpoints(allEndpoints);
|
||||
}
|
||||
/**
|
||||
* invokes clean method on the list of endpoint objects
|
||||
*/
|
||||
protected void doCleanEndpoints(List<Endpoint> endpoints) {
|
||||
for ( Endpoint endpoint : endpoints ) {
|
||||
try {
|
||||
endpoint.clean();
|
||||
} catch(Exception ex) {
|
||||
// ignore the exception and log it.
|
||||
this.getLogger().log(Level.FINE, ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* invokes clean method on the all consumer and provider endpoint objects in this su.
|
||||
*/
|
||||
protected void doCleanEndpoints() {
|
||||
|
||||
List<Endpoint> allEndpoints = new ArrayList<Endpoint>();
|
||||
allEndpoints.addAll(this.getConsumerEndpoints());
|
||||
allEndpoints.addAll(this.getProviderEndpoints());
|
||||
doCleanEndpoints(allEndpoints);
|
||||
}
|
||||
/**
|
||||
* prints the service unit description
|
||||
*/
|
||||
protected final String printDetails() {
|
||||
|
||||
StringWriter writer = new StringWriter();
|
||||
PrintWriter out = new PrintWriter(writer);
|
||||
|
||||
out.println("ServiceUnit Name : " + this.getName());
|
||||
out.println("ServiceUnit Root : " + this.getSURootPath());
|
||||
|
||||
SUDescriptor suDesc = null;
|
||||
try {
|
||||
suDesc = this.getSUDescriptor();
|
||||
for ( SUDescriptor.Consumes consumer : suDesc.getConsumedServices()) {
|
||||
out.println(consumer);
|
||||
}
|
||||
for ( SUDescriptor.Provides provides : suDesc.getProvidedServices()) {
|
||||
out.println(provides);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace(out);
|
||||
}
|
||||
return writer.getBuffer().toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* AbstractExtensibilityElement.java
|
||||
*/
|
||||
|
||||
package org.openesb.components.camelse.common.wsdl;
|
||||
|
||||
import javax.wsdl.extensions.ExtensibilityElement;
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
/**
|
||||
* This is an abstract class which can be extended to create jwsdl (wsdl4j's) extension elements model to
|
||||
* read/write the wsdl extension elements in wsdl 1.1 xml.
|
||||
*
|
||||
* @author chikkala
|
||||
*/
|
||||
public abstract class AbstractExtensibilityElement implements ExtensibilityElement, java.io.Serializable {
|
||||
public static final long serialVersionUID = 1;
|
||||
private QName mElementType;
|
||||
private Boolean mRequired;
|
||||
|
||||
/** Creates a new instance of AbstractExtensibilityElement */
|
||||
protected AbstractExtensibilityElement() {
|
||||
}
|
||||
|
||||
public void setElementType(QName elementType) {
|
||||
this.mElementType = elementType;
|
||||
}
|
||||
|
||||
public QName getElementType() {
|
||||
return this.mElementType;
|
||||
}
|
||||
|
||||
public void setRequired(Boolean required) {
|
||||
this.mRequired = required;
|
||||
}
|
||||
|
||||
public Boolean getRequired() {
|
||||
return this.mRequired;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* AbstractExtensionRegistry.java
|
||||
*/
|
||||
|
||||
package org.openesb.components.camelse.common.wsdl;
|
||||
|
||||
import java.util.List;
|
||||
import javax.wsdl.extensions.ExtensionRegistry;
|
||||
|
||||
/**
|
||||
* This is the abstract class used to add the wsdl extension serializers and deserializers to the
|
||||
* wsdl extension registry configured to read/write wsdl extensions into a know java model.
|
||||
* @see AbstractExtensionSerializer
|
||||
* @see WSDLProcessor
|
||||
* @author chikkala
|
||||
*/
|
||||
public abstract class AbstractExtensionRegistry extends ExtensionRegistry {
|
||||
|
||||
/** Creates a new instance of AbstractSerializer
|
||||
* it calls the <code>createSerializers<code> method to get the list of
|
||||
* serializers and then call registerSerializer on each AbstractExtensionSerializer
|
||||
* to register them with this registry.
|
||||
* @see AbstractExtensionSerializer#registerSerializer
|
||||
*/
|
||||
protected AbstractExtensionRegistry() {
|
||||
super();
|
||||
List<AbstractExtensionSerializer> list = createSerializers();
|
||||
for (AbstractExtensionSerializer ser : list ) {
|
||||
ser.registerSerializer(this);
|
||||
}
|
||||
// register ServiceEngine Binding serializers
|
||||
AbstractExtensionSerializer seBindingSer = new SEBindingExt.SEBindingExtSerializer();
|
||||
seBindingSer.registerSerializer(this);
|
||||
}
|
||||
/**
|
||||
* create wsdl extension serializers for each extension element to register with the extension
|
||||
* registry.
|
||||
* @return List of AbstractExtensionSerializer objects for serializing/deserializing the wsdl extensions.
|
||||
* @see AbstractExtensionSerializer
|
||||
*/
|
||||
protected abstract List<AbstractExtensionSerializer> createSerializers();
|
||||
}
|
|
@ -0,0 +1,120 @@
|
|||
/*
|
||||
* AbstractExtensionSerializer.java
|
||||
*/
|
||||
|
||||
package org.openesb.components.camelse.common.wsdl;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.Serializable;
|
||||
import java.util.Set;
|
||||
import javax.wsdl.Definition;
|
||||
import javax.wsdl.WSDLException;
|
||||
import javax.wsdl.extensions.ExtensibilityElement;
|
||||
import javax.wsdl.extensions.ExtensionDeserializer;
|
||||
import javax.wsdl.extensions.ExtensionRegistry;
|
||||
import javax.wsdl.extensions.ExtensionSerializer;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.w3c.dom.Attr;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* This class is an abstract class that should be extended to implements extension serializer and
|
||||
* deserializer. This class implements the code required for registering the serializer and deserializer
|
||||
* implemented by this class. THe AbstractExtensionRegistry class calls the #registerSerializer method
|
||||
* to register the concrete implementation of this class with extension registry.
|
||||
* @see AbstractExtensionRegistry
|
||||
* @author chikkala
|
||||
*/
|
||||
public abstract class AbstractExtensionSerializer
|
||||
implements ExtensionSerializer, ExtensionDeserializer, Serializable {
|
||||
|
||||
public static final long serialVersionUID = 1;
|
||||
|
||||
private Class mParentType;
|
||||
private Class mExtensionType;
|
||||
private QName mElementType;
|
||||
|
||||
/** Creates a new instance of AbstractSerializer */
|
||||
public AbstractExtensionSerializer(Class parentType, QName elementType, Class extensionType) {
|
||||
this.mParentType = parentType;
|
||||
this.mElementType = elementType;
|
||||
this.mExtensionType = extensionType;
|
||||
}
|
||||
|
||||
public Class getParentType() {
|
||||
return this.mParentType;
|
||||
}
|
||||
public QName getElementType() {
|
||||
return this.mElementType;
|
||||
}
|
||||
public Class getExtensionType() {
|
||||
return this.mExtensionType;
|
||||
}
|
||||
|
||||
public void registerSerializer(ExtensionRegistry extReg) {
|
||||
extReg.registerSerializer(this.mParentType, this.mElementType, this);
|
||||
extReg.registerDeserializer(this.mParentType, this.mElementType, this);
|
||||
extReg.mapExtensionTypes(this.mParentType, this.mElementType, this.mExtensionType);
|
||||
}
|
||||
|
||||
public void marshall(Class parentType, QName elementType, ExtensibilityElement extension,
|
||||
PrintWriter pw, Definition def, ExtensionRegistry extReg ) throws WSDLException {
|
||||
// DO NOTHING. Binding component runtime does not need to serialize the wsdl extensions.
|
||||
}
|
||||
|
||||
public ExtensibilityElement unmarshall(Class parentType, QName elementType, Element el,
|
||||
Definition def, ExtensionRegistry extReg) throws WSDLException {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String getAttribute(Element el, String attrName) {
|
||||
String attrValue = null;
|
||||
Attr attr = el.getAttributeNode(attrName);
|
||||
if ( attr != null ) {
|
||||
attrValue = attr.getValue();
|
||||
}
|
||||
return attrValue;
|
||||
}
|
||||
|
||||
protected String getNamespacePrefix(Definition def, String namespaceURI, String defPrefix) {
|
||||
String prefix = null;
|
||||
prefix = def.getPrefix(namespaceURI);
|
||||
if ( prefix == null ) {
|
||||
Set keySet = def.getNamespaces().keySet();
|
||||
String newPrefix = "ns";
|
||||
if ( defPrefix != null && defPrefix.trim().length() > 0 ){
|
||||
newPrefix = defPrefix;
|
||||
}
|
||||
prefix = newPrefix;
|
||||
for ( int i=0; i < Integer.MAX_VALUE; ++i) {
|
||||
if (!keySet.contains(prefix)) {
|
||||
break;
|
||||
} else {
|
||||
prefix = newPrefix + i;
|
||||
}
|
||||
}
|
||||
}
|
||||
return prefix;
|
||||
}
|
||||
/**
|
||||
* @return the name with the prefix defined for the namespaceURI in the wsdl definition.
|
||||
* @throws WSDLException if the prefix not found in the wsdl definition. note that the
|
||||
* default prefix is an empty string.
|
||||
*/
|
||||
protected String getQualifiedName(Definition def,
|
||||
String namespaceURI, String localName) throws WSDLException {
|
||||
String prefix = null;
|
||||
if (namespaceURI != null && !namespaceURI.equals("")) {
|
||||
prefix = def.getPrefix(namespaceURI);
|
||||
if ( prefix == null ) {
|
||||
throw new WSDLException(WSDLException.OTHER_ERROR,
|
||||
"Can not find prefix in WSDL Definition for " + namespaceURI);
|
||||
}
|
||||
}
|
||||
if ( prefix != null && !prefix.equals("")) {
|
||||
return prefix + ":" + localName;
|
||||
} else {
|
||||
return localName;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,226 @@
|
|||
/*
|
||||
* AbstractNormalizer.java
|
||||
*/
|
||||
|
||||
package org.openesb.components.camelse.common.wsdl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.jbi.messaging.MessagingException;
|
||||
import javax.jbi.messaging.NormalizedMessage;
|
||||
import javax.wsdl.Binding;
|
||||
import javax.wsdl.Definition;
|
||||
import javax.wsdl.Message;
|
||||
import javax.wsdl.Operation;
|
||||
import javax.wsdl.Part;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
/**
|
||||
* This is an abstract class that implements most of the functionality to normalize the binding protocol
|
||||
* specific concrete message to jbi wrapper and and denormalize jbi wrapper to the concrete binding
|
||||
* protocol specific message.
|
||||
* <p>
|
||||
* The extended classes specific to particular binding protocol will be used when a jbi binding
|
||||
* component is sending and receiving messages from the external service providers and consumers using
|
||||
* a particular binding protocol known to this class. Extended implementation of this class should make
|
||||
* use of the helper methods in this class in normalizing and denormalizing the messages.
|
||||
* @see JMXBindingNormalizer
|
||||
* @author chikkala
|
||||
*/
|
||||
public abstract class AbstractNormalizer {
|
||||
|
||||
public static final String XMLNS_NS = "http://www.w3.org/2000/xmlns/";
|
||||
/** wsdl definition to use when normalizing and denormalizing */
|
||||
private Definition mWSDL;
|
||||
/** Binding definition to use when normalizing and denormalizing */
|
||||
private Binding mBinding;
|
||||
|
||||
private AbstractNormalizer() {}
|
||||
/** Creates a new instance of JMXBCNormalizer */
|
||||
public AbstractNormalizer(Definition wsdl, Binding binding) {
|
||||
this.mWSDL = wsdl;
|
||||
this.mBinding = binding;
|
||||
}
|
||||
/**
|
||||
* normalize the binding protocol specific concrete message to jbi wrapper.
|
||||
* @param operation wsdl operation for which a concrete message should be normalized.
|
||||
* @param normMsg NoramalizedMessage which will be configurate with normalized data from
|
||||
* the concrete message
|
||||
* @param msgSource concrete mssage of a particular binding protocol.
|
||||
*/
|
||||
public abstract void normalizeInput(Operation operation, NormalizedMessage normMsg, DOMSource msgSource)
|
||||
throws MessagingException;
|
||||
/**
|
||||
* normalize the binding protocol specific concrete message to jbi wrapper.
|
||||
* @param operation wsdl operation for which a concrete message should be normalized.
|
||||
* @param normMsg NoramalizedMessage which will be configurate with normalized data from
|
||||
* the concrete message
|
||||
* @param msgSource concrete message of a particular binding protocol.
|
||||
*/
|
||||
public abstract void normalizeOutput(Operation operation, NormalizedMessage normMsg, DOMSource msgSource)
|
||||
throws MessagingException;
|
||||
/**
|
||||
* normalize the binding protocol specific concrete message to jbi wrapper.
|
||||
* @param operation wsdl operation for which a concrete message should be normalized.
|
||||
* @param normMsg NoramalizedMessage which will be configurate with normalized data from
|
||||
* the concrete message
|
||||
* @param msgSource concrete message of a particular binding protocol.
|
||||
*/
|
||||
public abstract void normalizeFault(Operation operation, String faultName, NormalizedMessage normMsg, DOMSource msgSource)
|
||||
throws MessagingException;
|
||||
/**
|
||||
* denormalize the normalized message into a concrete message for a particular binding protocol
|
||||
* @param operation wsdl operation for which a concrete message should be de-normalized.
|
||||
* @param normMsg NormalizedMessage which should be used to create de-normalized message.
|
||||
*/
|
||||
public abstract DOMSource denormalizeInput(Operation operation, NormalizedMessage normMsg)
|
||||
throws MessagingException;
|
||||
/**
|
||||
* denormalize the normalized message into a concrete message for a particular binding protocol
|
||||
* @param operation wsdl operation for which a concrete message should be denormalized.
|
||||
* @param normMsg NormalizedMessage which should be used to create denormalized message.
|
||||
*/
|
||||
public abstract DOMSource denormalizeOutput(Operation operation, NormalizedMessage normMsg)
|
||||
throws MessagingException;
|
||||
|
||||
/**
|
||||
* denormalized the normalized fault message into a concrete message for a particular binding protocol
|
||||
* @param operation wsdl operation for which a concrete message should be denormalized.
|
||||
* @param normMsg NormalizedMessage which should be used to create denormalized message.
|
||||
*/
|
||||
public abstract DOMSource denormalizeFault(Operation operation, String faultName, NormalizedMessage normMsg)
|
||||
throws MessagingException;
|
||||
/**
|
||||
* @return the wsdl definition to use in normalizing and denormalizing the message
|
||||
*/
|
||||
protected Definition getWSDL() {
|
||||
return this.mWSDL;
|
||||
}
|
||||
/**
|
||||
* @return the wsdl binding definition to use in normalizing and denormalizing the message
|
||||
*/
|
||||
protected Binding getBinding() {
|
||||
return this.mBinding;
|
||||
}
|
||||
/**
|
||||
* create and add message parts to the jbiWrapper according to the abstract message model. This
|
||||
* method assumes that the each element in the msgParts list passed to it is mapped to the part
|
||||
* of the abstract wsdl message and uses the type or element attribute of the abstract message to
|
||||
* determine whether the element is actual part element or a wrapped part type.
|
||||
* Use this method in normalizing the concrete protocol specific message to jbi wrapper message.
|
||||
* @param jbiWrapper object that holds the jbi wrapper information.
|
||||
* @param wsdlMsg abstract message from the wsdl definition
|
||||
* @param msgParts actual message parts from the concrete message
|
||||
*/
|
||||
protected void addMessagePartsToJBIWrapper(WSDL11JBIWrapper jbiWrapper, Message wsdlMsg, List<Element> msgParts) throws MessagingException {
|
||||
List wsdlParts = wsdlMsg.getOrderedParts(null);
|
||||
for ( int i=0; i < wsdlParts.size(); ++i ) {
|
||||
Part wsdlPart = (Part) wsdlParts.get(i);
|
||||
if ( i >= msgParts.size() ) {
|
||||
throw new MessagingException("missing message content for part " + wsdlPart.getName());
|
||||
}
|
||||
Element msgPart = msgParts.get(i);
|
||||
if ( wsdlPart.getElementName() != null ) {
|
||||
jbiWrapper.appendPart(msgPart);
|
||||
} else {
|
||||
// it is type.
|
||||
// check the element name is same as part
|
||||
if ( !wsdlPart.getName().equals(msgPart.getLocalName()) ) {
|
||||
throw new MessagingException("mismatched message content for part " + wsdlPart.getName());
|
||||
}
|
||||
if ( !wsdlMsg.getQName().getNamespaceURI().equals(msgPart.getNamespaceURI()) ) {
|
||||
throw new MessagingException("mismatched message content namespace for part " + wsdlPart.getName());
|
||||
}
|
||||
// check the content is text or element.
|
||||
List<Element> partContent = getChildElements(msgPart);
|
||||
if ( partContent.size() > 0 ) {
|
||||
// add content as part elements
|
||||
jbiWrapper.appendPart(partContent);
|
||||
} else {
|
||||
// add the content as text
|
||||
jbiWrapper.appendPart(msgPart.getTextContent());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* extracts the message parts from the jbiWrapper according to the abstract wsdl message
|
||||
* definition passed to it. Use this method in denormalizing the jbi wrapper message into the
|
||||
* binding protocol specific concrete message.
|
||||
* @param jbiWrapper jbi wrapper object that contains message parts and the message type information.
|
||||
* @param wsdlMsg abstract wsdl message definition to use in constructing the part elements.
|
||||
*/
|
||||
protected List<Element> getMessagePartsFromJBIWrapper(WSDL11JBIWrapper jbiWrapper, Message wsdlMsg)
|
||||
throws MessagingException, ParserConfigurationException {
|
||||
|
||||
List<Element> msgParts = new ArrayList<Element>();
|
||||
int jbiPartCount = jbiWrapper.getPartCount();
|
||||
List wsdlParts = wsdlMsg.getOrderedParts(null);
|
||||
QName msgType = jbiWrapper.getType();
|
||||
if (!wsdlMsg.getQName().getNamespaceURI().equals(msgType.getNamespaceURI())) {
|
||||
throw new MessagingException("Namespace mismatch between jbi wrapper message type and wsdl message");
|
||||
}
|
||||
Document newDoc = jbiWrapper.getDocumentBuilder().newDocument();
|
||||
for ( int i=0; i < wsdlParts.size(); ++i ) {
|
||||
Part wsdlPart = (Part) wsdlParts.get(i);
|
||||
if ( i >= jbiPartCount ) {
|
||||
throw new MessagingException("missing message content for part " + wsdlPart.getName());
|
||||
}
|
||||
if ( wsdlPart.getElementName() != null ) {
|
||||
msgParts.add(jbiWrapper.getPartAsElement(i));
|
||||
} else {
|
||||
// it is type. create a new element for a typed part
|
||||
// check the element name is same as part
|
||||
String prefix = msgType.getPrefix();
|
||||
String nsURI = msgType.getNamespaceURI();
|
||||
String localName = wsdlPart.getName();
|
||||
Element partEl = newDoc.createElementNS(nsURI, prefix + ":" + localName);
|
||||
partEl.setAttributeNS(XMLNS_NS, "xmlns:"+prefix, nsURI);
|
||||
NodeList partContent = jbiWrapper.getPart(i);
|
||||
appendChildren(partEl, partContent, newDoc, true);
|
||||
msgParts.add(partEl);
|
||||
}
|
||||
}
|
||||
return msgParts;
|
||||
}
|
||||
/**
|
||||
* utility method that can append the nodeList passed to it to the element children.
|
||||
* @param el element node to which the nodeList should be appended
|
||||
* @param doc the document object that should be used to import the nodeList
|
||||
* @param importNode true if the nodeList should be imported while appending the nodeList to the
|
||||
* element children. false if no import is necessary.
|
||||
*/
|
||||
protected void appendChildren(Element el, NodeList nodeList, Document doc, boolean importNode) {
|
||||
|
||||
for ( int pIdx = 0; pIdx < nodeList.getLength(); ++pIdx) {
|
||||
Node node = nodeList.item(pIdx);
|
||||
if ( importNode ) {
|
||||
node = doc.importNode(node, true);
|
||||
}
|
||||
el.appendChild(node);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @param el element from which to extract the child elements
|
||||
* @return List<Element> list of child Element nodes.
|
||||
*/
|
||||
protected List<Element> getChildElements(Element el) {
|
||||
List<Element> list = new ArrayList<Element>();
|
||||
NodeList nodeList = el.getChildNodes();
|
||||
for ( int i=0; i < nodeList.getLength(); ++i) {
|
||||
Node node = nodeList.item(i);
|
||||
if (!(node instanceof Element) ){
|
||||
continue;
|
||||
}
|
||||
list.add((Element)node);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,96 @@
|
|||
/*
|
||||
* SEBindingExt.java
|
||||
*/
|
||||
|
||||
package org.openesb.components.camelse.common.wsdl;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import javax.wsdl.Binding;
|
||||
import javax.wsdl.Definition;
|
||||
import javax.wsdl.WSDLException;
|
||||
import javax.wsdl.extensions.ExtensibilityElement;
|
||||
import javax.wsdl.extensions.ExtensionRegistry;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* This interface and its implementation classes implement wsdl 1.1 extension model for the
|
||||
* jbi service engine binding that is defined in jsr 208(sec. 5.5.6.1). to read/write concrete binding
|
||||
* element in the wsdl definition for the service endpoint binding provided by the service engine.
|
||||
* The wsdl definition with this binding information can be used in providing the service provider
|
||||
* metadata returned by the service engine in <code>Component.getServiceDescription</code>.
|
||||
* <p>
|
||||
* <code>AbstractExtensionRegistry</code> by default include this extension serializers in the
|
||||
* registry to read/write this service engine binding type in the wsdl definition.
|
||||
* <p>
|
||||
* During a service unit deployment/initialization in the service engine, the deployed wsdl definition
|
||||
* is loaded and modified to provide this binding for the service provided by the engine.
|
||||
*
|
||||
* @see WSDLProcessor#createServiceEngineBinding
|
||||
* @see AbstractExtensionRegistry
|
||||
* @see com.sun.jbi.sample.component.common.deployment.ServiceUnit#loadServiceDefinitions
|
||||
* @author chikkala
|
||||
*/
|
||||
public interface SEBindingExt extends ExtensibilityElement, java.io.Serializable {
|
||||
|
||||
public static final String NS_URI = "http://java.sun.com/xml/ns/jbi/binding/service+engine";
|
||||
public static final String NS_DEF_PREFIX = "jbise";
|
||||
/** Element names. */
|
||||
public static final String EL_BINDING_EXT = "binding";
|
||||
/**Qualified element names.*/
|
||||
public static final QName QN_BINDING_EXT = new QName(NS_URI, EL_BINDING_EXT);
|
||||
|
||||
public static class SEBindingExtImpl extends AbstractExtensibilityElement implements SEBindingExt {
|
||||
|
||||
public SEBindingExtImpl() {
|
||||
setElementType(QN_BINDING_EXT);
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer buff = new StringBuffer();
|
||||
buff.append("<"+NS_DEF_PREFIX+":"+EL_BINDING_EXT);
|
||||
buff.append("/>");
|
||||
return buff.toString();
|
||||
}
|
||||
/**
|
||||
* creates and adds the jbi service engine binding extensibility element to the wsdl definition
|
||||
* under specified binding definition.
|
||||
*/
|
||||
public static SEBindingExtImpl addExtensibilityElement(Definition wsdlDef, Binding binding) {
|
||||
SEBindingExtImpl bindingExt = new SEBindingExt.SEBindingExtImpl();
|
||||
WSDLProcessor.addExtensibilityElement(wsdlDef, binding, bindingExt, SEBindingExt.NS_DEF_PREFIX);
|
||||
return bindingExt;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* serializer and descrializer implementation for the binding extension element.
|
||||
*/
|
||||
public static class SEBindingExtSerializer extends AbstractExtensionSerializer {
|
||||
|
||||
public SEBindingExtSerializer() {
|
||||
super(Binding.class, QN_BINDING_EXT, SEBindingExtImpl.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExtensibilityElement unmarshall(Class parentType, QName elementType, Element el,
|
||||
Definition def, ExtensionRegistry extReg) throws WSDLException {
|
||||
SEBindingExt extObj = (SEBindingExt)extReg.createExtension(parentType, elementType);
|
||||
return extObj;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void marshall(Class parentType, QName elementType, ExtensibilityElement extension,
|
||||
PrintWriter pw, Definition def, ExtensionRegistry extReg ) throws WSDLException {
|
||||
|
||||
String elName = getQualifiedName(def, NS_URI, EL_BINDING_EXT);
|
||||
|
||||
SEBindingExt extObj = (SEBindingExt)extension;
|
||||
|
||||
StringBuffer buff = new StringBuffer();
|
||||
buff.append("<" + elName );
|
||||
buff.append("/>");
|
||||
pw.println(buff.toString());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,468 @@
|
|||
/*
|
||||
* WSDL11JBIWrapper.java
|
||||
*
|
||||
*/
|
||||
|
||||
package org.openesb.components.camelse.common.wsdl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.wsdl.Fault;
|
||||
import javax.wsdl.Input;
|
||||
import javax.wsdl.Message;
|
||||
import javax.wsdl.Operation;
|
||||
import javax.wsdl.Output;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.w3c.dom.Text;
|
||||
|
||||
/**
|
||||
* This class wraps the wsdl11 messages to the jbi wrapper message suitable for
|
||||
* processing in the wsdl2.0 model of the normalized message in jbi as defined in jsr208 like
|
||||
* <jbi:message version="1.0"
|
||||
* type="qname of message attribute from wsdl:input, wsdl:output or wsdl:fault"
|
||||
* name="optional name attribute from wsdl:input, wsdl:output or wsdl:fault"
|
||||
* xmlns:jbi="http://java.sun.com/xml/ns/jbi/wsdl-11-wrapper">
|
||||
* <jbi:part>
|
||||
* <message-elements/>
|
||||
* </jbi:part>
|
||||
* <jbi:part>
|
||||
* <message-elements/>
|
||||
* </jbi:part>
|
||||
* </jbi:message>
|
||||
*
|
||||
*
|
||||
* @author chikkala
|
||||
*/
|
||||
public class WSDL11JBIWrapper {
|
||||
|
||||
public static final String XMLNS_NS = "http://www.w3.org/2000/xmlns/";
|
||||
public static final String WRAPPER_NAMESPACE = "http://java.sun.com/xml/ns/jbi/wsdl-11-wrapper";
|
||||
public static final String DEF_NS_PREFIX = "jbiwrp";
|
||||
public static final String DEF_MESSAGE_NS_PREFIX = "msgns";
|
||||
public static final String JBI_MESSAGE_EL = "message";
|
||||
public static final String JBI_PART_EL = "part";
|
||||
public static final String VERSION_ATTR = "version";
|
||||
public static final String VERSION_ATTR_VALUE = "1.0";
|
||||
public static final String TYPE_ATTR = "type";
|
||||
public static final String NAME_ATTR = "name";
|
||||
|
||||
private static DocumentBuilder sDocBuilder = null;
|
||||
/** qname of message attribute from wsdl:input, wsdl:output or wsdl:fault */
|
||||
private QName mType;
|
||||
/** optional name attribute from wsdl:input, wsdl:output or wsdl:fault */
|
||||
private String mName;
|
||||
/** each parts contents as node list */
|
||||
List<NodeList> mPartConentList = new ArrayList<NodeList>();
|
||||
|
||||
/** Creates a new instance of WSDL11JBIWrapper */
|
||||
public WSDL11JBIWrapper() {
|
||||
}
|
||||
/** creates the namespace aware document builder. extended classes can override this method
|
||||
* to return the doc builder created else where.
|
||||
*/
|
||||
protected DocumentBuilder createDocumentBuilder() throws ParserConfigurationException {
|
||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
factory.setNamespaceAware(true);
|
||||
return factory.newDocumentBuilder();
|
||||
}
|
||||
/** return the document builder
|
||||
* @return DocumentBuilder
|
||||
*/
|
||||
public final DocumentBuilder getDocumentBuilder() throws ParserConfigurationException {
|
||||
if ( WSDL11JBIWrapper.sDocBuilder == null ) {
|
||||
WSDL11JBIWrapper.sDocBuilder = createDocumentBuilder();
|
||||
}
|
||||
return WSDL11JBIWrapper.sDocBuilder;
|
||||
}
|
||||
/**
|
||||
* @return type qname of message attribute from wsdl:input, wsdl:output or wsdl:fault
|
||||
*/
|
||||
public QName getType() {
|
||||
return this.mType;
|
||||
}
|
||||
/**
|
||||
* @param type qname of message attribute from wsdl:input, wsdl:output or wsdl:fault
|
||||
*/
|
||||
public void setType(QName type) {
|
||||
this.mType = type;
|
||||
}
|
||||
/** @return name attribute from wsdl:input, wsdl:output or wsdl:fault. or null if not set. */
|
||||
public String getName() {
|
||||
return this.mName;
|
||||
}
|
||||
/**
|
||||
* @param name optional name attribute from wsdl:input, wsdl:output or wsdl:fault. can be null.
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.mName = name;
|
||||
}
|
||||
/**
|
||||
* appends part content as node list
|
||||
*/
|
||||
public void appendPart(NodeList partContent) {
|
||||
this.mPartConentList.add(partContent);
|
||||
}
|
||||
/**
|
||||
* append part content from the List of nodes
|
||||
*/
|
||||
public void appendPart(List<? extends Node> partContent) {
|
||||
this.mPartConentList.add(new NodeListImpl(partContent));
|
||||
}
|
||||
/**
|
||||
* append part content as element
|
||||
*/
|
||||
public void appendPart(Element partContent) {
|
||||
this.mPartConentList.add(new NodeListImpl(partContent));
|
||||
}
|
||||
/**
|
||||
* append part content from DOMSource
|
||||
*/
|
||||
public void appendPart(DOMSource partContent) {
|
||||
Element partConentEl = getElement(partContent.getNode());
|
||||
this.mPartConentList.add(new NodeListImpl(partConentEl));
|
||||
}
|
||||
/**
|
||||
* append part content as text node.
|
||||
*/
|
||||
public void appendPart(String partContent) {
|
||||
Text textContent = null;
|
||||
try {
|
||||
textContent = this.getDocumentBuilder().newDocument().createTextNode(partContent);
|
||||
} catch (ParserConfigurationException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
if ( textContent != null ) {
|
||||
this.mPartConentList.add(new NodeListImpl(textContent));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* append list of part contents each is a NodeList to the parts
|
||||
*/
|
||||
public void appendParts(List<NodeList> partContentList) {
|
||||
this.mPartConentList.addAll(partContentList);
|
||||
}
|
||||
/**
|
||||
* returned the ordered list of part contents.
|
||||
*/
|
||||
public List<NodeList> getParts() {
|
||||
return Collections.unmodifiableList(this.mPartConentList);
|
||||
}
|
||||
/**
|
||||
* return the number of parts
|
||||
*/
|
||||
public int getPartCount() {
|
||||
return this.mPartConentList.size();
|
||||
}
|
||||
/**
|
||||
* return the part content at a particular index as NodeList.
|
||||
*/
|
||||
public NodeList getPart(int idx) {
|
||||
return this.mPartConentList.get(idx);
|
||||
}
|
||||
/**
|
||||
* return part context at a particular index as text
|
||||
*/
|
||||
public String getPartAsText(int idx) {
|
||||
NodeList partNodes = getPart(idx);
|
||||
Document doc;
|
||||
try {
|
||||
doc = this.getDocumentBuilder().newDocument();
|
||||
Element el = doc.createElementNS(WRAPPER_NAMESPACE, DEF_NS_PREFIX + ":" + JBI_PART_EL);
|
||||
for ( int i=0; i < partNodes.getLength(); ++i) {
|
||||
el.appendChild(partNodes.item(i));
|
||||
}
|
||||
return el.getTextContent();
|
||||
} catch (ParserConfigurationException ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* return part context at a particular index as Element
|
||||
*/
|
||||
public Element getPartAsElement(int idx) {
|
||||
Element contentEl = null;
|
||||
NodeList partNodes = getPart(idx);
|
||||
for ( int i=0; i < partNodes.getLength(); ++i) {
|
||||
Node node = partNodes.item(i);
|
||||
if ( node instanceof Element) {
|
||||
contentEl = (Element)node;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return contentEl;
|
||||
}
|
||||
/**
|
||||
* creates Document from this wrapper object. Before calling this method,
|
||||
* the type, name (optional) and parts contents should be set.
|
||||
* @return Document containing the wsdl 11 wrapper xml
|
||||
*/
|
||||
public Document toDocument() throws ParserConfigurationException {
|
||||
|
||||
Document wrapperDoc = getDocumentBuilder().newDocument();
|
||||
Element jbiMessage = wrapperDoc.createElementNS(WRAPPER_NAMESPACE, DEF_NS_PREFIX + ":" + JBI_MESSAGE_EL);
|
||||
jbiMessage.setAttribute(VERSION_ATTR, VERSION_ATTR_VALUE);
|
||||
wrapperDoc.appendChild(jbiMessage);
|
||||
|
||||
QName type = this.getType();
|
||||
if ( type == null ) {
|
||||
type = new QName("", "", DEF_MESSAGE_NS_PREFIX);
|
||||
}
|
||||
// set the jbiMessage attributes
|
||||
String prefix = type.getPrefix();
|
||||
if (prefix == null || prefix.length() == 0) {
|
||||
prefix = DEF_MESSAGE_NS_PREFIX;
|
||||
}
|
||||
jbiMessage.setAttribute(TYPE_ATTR, prefix + ":" + type.getLocalPart());
|
||||
jbiMessage.setAttributeNS( XMLNS_NS, "xmlns:" + prefix, type.getNamespaceURI());
|
||||
|
||||
String name = this.getName();
|
||||
if (name != null && name.trim().length() > 0 ) {
|
||||
jbiMessage.setAttribute(NAME_ATTR, name);
|
||||
}
|
||||
|
||||
List<NodeList> partContentList = this.getParts();
|
||||
for ( NodeList nodeList : partContentList ) {
|
||||
// set jbi part message
|
||||
Element jbiPart = wrapperDoc.createElementNS(WRAPPER_NAMESPACE, DEF_NS_PREFIX + ":" + JBI_PART_EL);
|
||||
jbiMessage.appendChild(jbiPart);
|
||||
for ( int i =0; i < nodeList.getLength(); ++i ) {
|
||||
Node importedMsgNode = wrapperDoc.importNode(nodeList.item(i), true);
|
||||
jbiPart.appendChild(importedMsgNode);
|
||||
}
|
||||
}
|
||||
|
||||
return wrapperDoc;
|
||||
|
||||
}
|
||||
/**
|
||||
* creates DOMSource from this wrapper object. Before calling this method,
|
||||
* the type, name (optional) and parts contents should be set.
|
||||
* @return DOMSource containing the wsdl 11 wrapper xml
|
||||
*/
|
||||
public DOMSource toDOMSource() throws ParserConfigurationException {
|
||||
DOMSource wrappedSource = new DOMSource();
|
||||
wrappedSource.setNode(toDocument());
|
||||
return wrappedSource;
|
||||
}
|
||||
/**
|
||||
* return Element node from a document node or non document. Use to extract
|
||||
* the message root element.
|
||||
* @root node from which the Element node will be extracted.
|
||||
* @return Element node.
|
||||
*/
|
||||
public static Element getElement(Node root) {
|
||||
Element msgEl = null;
|
||||
if ( root instanceof Document) {
|
||||
msgEl = ((Document)root).getDocumentElement();
|
||||
} else if (root instanceof Element) {
|
||||
msgEl = (Element)root;
|
||||
} else {
|
||||
NodeList nodeList = root.getChildNodes();
|
||||
for ( int i=0; i < nodeList.getLength(); ++i) {
|
||||
Node node = nodeList.item(i);
|
||||
if ( node instanceof Element ) {
|
||||
msgEl = (Element) node;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return msgEl;
|
||||
}
|
||||
/**
|
||||
* creates wrapper object from the DOMSource that has wsdl 11 wrapper xml.
|
||||
* @param wrappedMsg wsdl 11 wrapper xml as DOMSource
|
||||
* @return WSDL11JBIWrapper representing the wrapper xml.
|
||||
*/
|
||||
public static WSDL11JBIWrapper sourceToWrapper(DOMSource wrappedMsg) {
|
||||
Element jbiMessage = getElement(wrappedMsg.getNode());
|
||||
if ( jbiMessage == null ) {
|
||||
return null;
|
||||
}
|
||||
String nsURI = jbiMessage.getNamespaceURI();
|
||||
String tagName = jbiMessage.getLocalName();
|
||||
if (!WRAPPER_NAMESPACE.equals(nsURI) || !JBI_MESSAGE_EL.equals(tagName)) {
|
||||
return null;
|
||||
}
|
||||
String name = jbiMessage.getAttribute(NAME_ATTR);
|
||||
String typeQN = jbiMessage.getAttribute(TYPE_ATTR);
|
||||
String typePrefix = "";
|
||||
String typeName = "";
|
||||
if ( typeQN != null && typeQN.trim().length() > 0 ) {
|
||||
int idx = typeQN.indexOf(':');
|
||||
if ( idx >= 0 ) {
|
||||
typePrefix = typeQN.substring(0, idx);
|
||||
if ( typeQN.length() > idx ) {
|
||||
typeName = typeQN.substring(idx+1);
|
||||
}
|
||||
} else {
|
||||
typePrefix = "";
|
||||
typeName = typeQN;
|
||||
}
|
||||
}
|
||||
String typeURI = jbiMessage.getAttribute("xmlns:" + typePrefix);
|
||||
QName typeQName = new QName(typeURI, typeName, typePrefix);
|
||||
|
||||
WSDL11JBIWrapper wrapper = new WSDL11JBIWrapper();
|
||||
wrapper.setName(name);
|
||||
wrapper.setType(typeQName);
|
||||
NodeList jbiPartList = jbiMessage.getElementsByTagNameNS(WRAPPER_NAMESPACE, JBI_PART_EL);
|
||||
for ( int i=0; i < jbiPartList.getLength(); ++i) {
|
||||
Node jbiPart = jbiPartList.item(i);
|
||||
wrapper.appendPart(jbiPart.getChildNodes());
|
||||
}
|
||||
return wrapper;
|
||||
}
|
||||
/**
|
||||
* creates the WSDL11JBIWrapper object and sets the type and name of the object
|
||||
* @param type qname of message attribute from wsdl:input, wsdl:output or wsdl:fault
|
||||
* @param name optional name attribute from wsdl:input, wsdl:output or wsdl:fault
|
||||
* @return the jbi message wrapper object
|
||||
*/
|
||||
public static WSDL11JBIWrapper createWrapper(QName type, String name ) throws ParserConfigurationException {
|
||||
WSDL11JBIWrapper wrapper = new WSDL11JBIWrapper();
|
||||
wrapper.setName(name);
|
||||
wrapper.setType(type);
|
||||
return wrapper;
|
||||
}
|
||||
/**
|
||||
* creates the WSDL11JBIWrapper object. useful when the message has one part and the
|
||||
* part content has multiple child element.
|
||||
* @param type qname of message attribute from wsdl:input, wsdl:output or wsdl:fault
|
||||
* @param name optional name attribute from wsdl:input, wsdl:output or wsdl:fault
|
||||
* @param partContent part content as node list
|
||||
* @return the jbi message wrapper object
|
||||
*/
|
||||
public static WSDL11JBIWrapper createWrapper(QName type, String name, NodeList partContent) throws ParserConfigurationException {
|
||||
WSDL11JBIWrapper wrapper = createWrapper(type, name);
|
||||
wrapper.appendPart(partContent);
|
||||
return wrapper;
|
||||
}
|
||||
/**
|
||||
* creates the WSDL11JBIWrapper object. useful when the message has one part and the
|
||||
* part content is a single element
|
||||
* @param type qname of message attribute from wsdl:input, wsdl:output or wsdl:fault
|
||||
* @param name optional name attribute from wsdl:input, wsdl:output or wsdl:fault
|
||||
* @param partContent part content as node list
|
||||
* @return the jbi message wrapper object
|
||||
*/
|
||||
public static WSDL11JBIWrapper createWrapper(QName type, String name, Element msgEl) throws ParserConfigurationException {
|
||||
WSDL11JBIWrapper wrapper = createWrapper(type, name, new WSDL11JBIWrapper.NodeListImpl(msgEl));
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
public static WSDL11JBIWrapper createWrapper(QName type, String name, DOMSource inputSource) throws ParserConfigurationException {
|
||||
WSDL11JBIWrapper wrapper = createWrapper(type, name);
|
||||
Node msgNode = getElement(inputSource.getNode());
|
||||
NodeList nodeList = new WSDL11JBIWrapper.NodeListImpl(msgNode);
|
||||
wrapper.appendPart(nodeList);
|
||||
return wrapper;
|
||||
}
|
||||
/**
|
||||
* creates the wrapped message using the wsdl4j operations input element for type and name.
|
||||
* @param msg DOMSource for the unwrapped message
|
||||
* @param operation wsdl4j operation object representing the operation of the PortType
|
||||
* @return DOMSource wrapped message as DOMSource
|
||||
*/
|
||||
public static WSDL11JBIWrapper createInputWrapper(Operation operation) throws ParserConfigurationException {
|
||||
QName type = null;
|
||||
String name = null;
|
||||
|
||||
Input input = operation.getInput();
|
||||
if ( input == null ) {
|
||||
return null;
|
||||
}
|
||||
name = input.getName();
|
||||
Message wsdlMsg = input.getMessage();
|
||||
type = wsdlMsg.getQName();
|
||||
|
||||
WSDL11JBIWrapper wrapper = createWrapper(type, name);
|
||||
return wrapper;
|
||||
}
|
||||
/**
|
||||
* creates the wrapped message using the wsdl4j operations output element for type and name.
|
||||
* @param msg DOMSource for the unwrapped message
|
||||
* @param operation wsdl4j operation object representing the operation of the PortType
|
||||
* @return DOMSource wrapped message as DOMSource
|
||||
*/
|
||||
public static WSDL11JBIWrapper createOutputWrapper(Operation operation) throws ParserConfigurationException {
|
||||
QName type = null;
|
||||
String name = null;
|
||||
|
||||
Output output = operation.getOutput();
|
||||
if ( output == null) {
|
||||
return null;
|
||||
}
|
||||
name = output.getName();
|
||||
Message wsdlMsg = output.getMessage();
|
||||
type = wsdlMsg.getQName();
|
||||
|
||||
WSDL11JBIWrapper wrapper = createWrapper(type, name);
|
||||
return wrapper;
|
||||
}
|
||||
/**
|
||||
* creates the wrapped message using the wsdl4j operations output element for type and name.
|
||||
* @param msg DOMSource for the unwrapped message
|
||||
* @param operation wsdl4j operation object representing the operation of the PortType
|
||||
* @param faultName fault name, can be null to look for the fault with no name.
|
||||
* @return DOMSource wrapped message as DOMSource
|
||||
*/
|
||||
public static WSDL11JBIWrapper createFaultWrapper(Operation operation, String faultName) throws ParserConfigurationException {
|
||||
QName type = null;
|
||||
String name = null;
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Fault> faultMap = operation.getFaults();
|
||||
Fault fault = faultMap.get(faultName);
|
||||
|
||||
if ( fault == null ) {
|
||||
return null;
|
||||
}
|
||||
name = fault.getName();
|
||||
Message wsdlMsg = fault.getMessage();
|
||||
type = wsdlMsg.getQName();
|
||||
|
||||
WSDL11JBIWrapper wrapper = createWrapper(type, name);
|
||||
return wrapper;
|
||||
}
|
||||
/**
|
||||
* NodeList implementation.
|
||||
*/
|
||||
public static class NodeListImpl extends ArrayList<Node> implements NodeList {
|
||||
|
||||
public NodeListImpl() {
|
||||
super();
|
||||
}
|
||||
|
||||
public NodeListImpl(Node aNode) {
|
||||
super();
|
||||
if (aNode != null) {
|
||||
this.add(aNode);
|
||||
}
|
||||
}
|
||||
|
||||
public NodeListImpl(List<? extends Node> nodes) {
|
||||
if (nodes != null) {
|
||||
this.addAll(nodes);
|
||||
}
|
||||
}
|
||||
|
||||
public int getLength() {
|
||||
return this.size();
|
||||
}
|
||||
|
||||
public Node item(int idx) {
|
||||
return this.get(idx);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,416 @@
|
|||
/*
|
||||
* WSDLProcessor.java
|
||||
*/
|
||||
|
||||
package org.openesb.components.camelse.common.wsdl;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import javax.wsdl.Binding;
|
||||
import javax.wsdl.Definition;
|
||||
import javax.wsdl.Operation;
|
||||
import javax.wsdl.Port;
|
||||
import javax.wsdl.PortType;
|
||||
import javax.wsdl.Service;
|
||||
import javax.wsdl.WSDLException;
|
||||
import javax.wsdl.extensions.ElementExtensible;
|
||||
import javax.wsdl.extensions.ExtensibilityElement;
|
||||
import javax.wsdl.extensions.ExtensionRegistry;
|
||||
import javax.wsdl.factory.WSDLFactory;
|
||||
import javax.wsdl.xml.WSDLReader;
|
||||
import javax.wsdl.xml.WSDLWriter;
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
/**
|
||||
* This class is used to configure jwsdl(wsdl4j) to read and process wsdl documents with wsdl extensions.
|
||||
* It provides set of helper methods to read and process the wsdl definitions from files with .wsdl
|
||||
* extension from a specified directory.
|
||||
* <p>
|
||||
* A Binding Component that is processing the wsdl extensions for its deployment configuration would
|
||||
* extend this class and provide the required ExtensionRegistry that will have the extension serializers
|
||||
* and deserializers configured to read/write the extensions from/to the java model.
|
||||
* <p>
|
||||
* A Service Engine that is processing the wsdl during deployment can directly use this class
|
||||
* to process the wsdl as the default implementation returned by this class configures the wsdl extension
|
||||
* registry to read/write the service engine binding extensions.
|
||||
*
|
||||
* @see AbstractExtensionRegistry
|
||||
* @see SEBindingExt
|
||||
* @author chikkala
|
||||
*/
|
||||
public class WSDLProcessor {
|
||||
|
||||
private String mXmlCatalogPath = "xml-catalog.xml";
|
||||
private String mWsdlDirPath = "";
|
||||
private WSDLReader mReader;
|
||||
|
||||
/** Creates a new instance of WSDLProcessor
|
||||
*/
|
||||
public WSDLProcessor(String wsdlDir) {
|
||||
this(wsdlDir, null);
|
||||
}
|
||||
/** Creates a new instance of WSDLProcessor
|
||||
*/
|
||||
public WSDLProcessor(String wsdlDir, String xmlCatPath) {
|
||||
if ( wsdlDir != null ) {
|
||||
this.mWsdlDirPath = wsdlDir;
|
||||
}
|
||||
if ( xmlCatPath != null ) {
|
||||
this.mXmlCatalogPath = xmlCatPath;
|
||||
}
|
||||
}
|
||||
/** @return directory path from which this class reads the wsdl files with .wsdl as file extension. */
|
||||
public String getWSDLDirectory() {
|
||||
return this.mWsdlDirPath;
|
||||
}
|
||||
/** path to the xml catalog file in the service unit which can be used for Catalog-based entity
|
||||
* and URI resolution.
|
||||
*/
|
||||
public String getXmlCatelogPath() {
|
||||
return this.mXmlCatalogPath;
|
||||
}
|
||||
/** wsdl extension registry required for processing the wsdl extensions in the wsdl definition to
|
||||
* java model. Binding component that is processing the wsdl extensions for its deployment
|
||||
* configuration would provide the required ExtensionRegistry that will have the extension serializers
|
||||
* and deserializers configured to read/write the extensions from/to the java model.
|
||||
* @return ExtensionSerializer
|
||||
* @see AbstractExtensionSerializer
|
||||
*/
|
||||
protected ExtensionRegistry getExtensionRegistry() {
|
||||
return new AbstractExtensionRegistry() {
|
||||
protected List<AbstractExtensionSerializer> createSerializers() {
|
||||
return new ArrayList<AbstractExtensionSerializer>();
|
||||
}
|
||||
};
|
||||
}
|
||||
/**
|
||||
* @return the WSDLReader configured with extension registry to process the wsdl extensions.
|
||||
*/
|
||||
public final WSDLReader getWSDLReader() throws WSDLException {
|
||||
if ( this.mReader == null ) {
|
||||
WSDLFactory factory = WSDLFactory.newInstance();
|
||||
this.mReader = factory.newWSDLReader();
|
||||
// reader.setFeature("javax.wsdl.verbose", true);
|
||||
// reader.setFeature("javax.wsdl.importDocuments", true);
|
||||
this.mReader.setExtensionRegistry(getExtensionRegistry());
|
||||
}
|
||||
return this.mReader;
|
||||
}
|
||||
/**
|
||||
* reads the wsdl file and returns the wsdl definition jwsdl model.
|
||||
* @param wsldFilePath relative path to wsdl file from the the root wsdl directory returns from
|
||||
* #getWSDLDirectory in the service unit or or absolute path .
|
||||
* @return Definition
|
||||
*/
|
||||
public Definition readWSDL(String wsdlFilePath) throws WSDLException {
|
||||
File wsdlFile = new File(wsdlFilePath);
|
||||
if ( !wsdlFile.isAbsolute() ) {
|
||||
wsdlFile = new File(this.mWsdlDirPath, wsdlFilePath);
|
||||
}
|
||||
return getWSDLReader().readWSDL(wsdlFile.getAbsolutePath());
|
||||
}
|
||||
/**
|
||||
* reads the files with .wsdl file extension in a directory. If the directory should
|
||||
* be searched recursively, it searches this directory, all child directories of this
|
||||
* directory and then to their child directories recursively.
|
||||
* @param dir directory file to search for .wsdl files
|
||||
* @param rec if set to true, it recursively searches the directory. if set to false, only
|
||||
* this directory is searched.
|
||||
* @return List of Files with .wsdl extension.
|
||||
*/
|
||||
public List<File> listWSDLFiles(File dir, final boolean rec) throws IOException {
|
||||
if ( dir == null || !dir.isDirectory()) {
|
||||
throw new IOException(dir + " is not a directory for looking up wsdl files");
|
||||
}
|
||||
List<File> wsdlList = new ArrayList<File>();
|
||||
File[] files = dir.listFiles(new FileFilter() {
|
||||
public boolean accept(File pathname) {
|
||||
if ( rec && pathname.isDirectory()) {
|
||||
return true;
|
||||
} else {
|
||||
String name = pathname.getName();
|
||||
int idx = name.lastIndexOf('.');
|
||||
if ( idx < 0 ) {
|
||||
return false;
|
||||
}
|
||||
String ext = name.substring(idx);
|
||||
return ".wsdl".equalsIgnoreCase(ext);
|
||||
}
|
||||
}
|
||||
});
|
||||
for ( File file : files ) {
|
||||
if ( rec && file.isDirectory()) {
|
||||
List<File> wsdlFiles = listWSDLFiles(file, rec);
|
||||
wsdlList.addAll(wsdlFiles);
|
||||
} else {
|
||||
wsdlList.add(file);
|
||||
}
|
||||
}
|
||||
return wsdlList;
|
||||
}
|
||||
/**
|
||||
* reads the files with .wsdl file extension in a directory fromDir and return the list of
|
||||
* wsdl definitions corresponding to them.
|
||||
* @param fromDir path to the directory relative to the root wsdl directory returns from
|
||||
* #getWSDLDirectory or the absolute path to the directory.
|
||||
*/
|
||||
public List<Definition> readWSDLs(String fromDir) throws WSDLException {
|
||||
if ( fromDir == null ) { fromDir = ""; }
|
||||
File wsdlDir = new File(fromDir);
|
||||
if (!wsdlDir.isAbsolute()) {
|
||||
wsdlDir = new File(this.mWsdlDirPath, fromDir);
|
||||
}
|
||||
|
||||
List<File> wsdlFiles = new ArrayList<File>();
|
||||
try {
|
||||
wsdlFiles = listWSDLFiles(wsdlDir, true);
|
||||
} catch (IOException ioEx) {
|
||||
throw new WSDLException("WSDLFileReadError", ioEx.getMessage(),ioEx);
|
||||
}
|
||||
|
||||
List<String> wsdlPaths = new ArrayList<String>();
|
||||
for ( File wsdlFile : wsdlFiles) {
|
||||
wsdlPaths.add(wsdlFile.getAbsolutePath());
|
||||
}
|
||||
Collections.sort(wsdlPaths);
|
||||
|
||||
List<Definition> wsdlList = new ArrayList<Definition>();
|
||||
for ( String wsdlPath : wsdlPaths ) {
|
||||
Definition wsdlDef = readWSDL(wsdlPath);
|
||||
wsdlList.add(wsdlDef);
|
||||
}
|
||||
return wsdlList;
|
||||
}
|
||||
/**
|
||||
* finds PortType using port type ( interface ) qname.
|
||||
*/
|
||||
public static PortType findInterface(Definition wsdlDef, QName interfaceName) {
|
||||
return wsdlDef.getPortType(interfaceName);
|
||||
}
|
||||
/** finds the Service using service qname */
|
||||
public static Service findService(Definition wsdlDef, QName serviceName) {
|
||||
return wsdlDef.getService(serviceName);
|
||||
}
|
||||
/** finds the wsdl port using service qname and endpoint name */
|
||||
public static Port findServiceEndpoint(Definition wsdlDef, QName serviceName, String endpointName) {
|
||||
Service service = null;
|
||||
Port port = null;
|
||||
service = findService(wsdlDef, serviceName);
|
||||
if ( service != null ) {
|
||||
port = service.getPort(endpointName);
|
||||
}
|
||||
return port;
|
||||
}
|
||||
/**
|
||||
* finds the binding definition to which the service with serviceName and endpointName was bound.
|
||||
*/
|
||||
public static Binding findServiceBinding(Definition wsdlDef, QName serviceName, String endpointName) {
|
||||
Binding binding = null;
|
||||
Port port = findServiceEndpoint(wsdlDef, serviceName, endpointName);
|
||||
if ( port != null ) {
|
||||
binding = port.getBinding();
|
||||
}
|
||||
return binding;
|
||||
}
|
||||
/**
|
||||
* finds the binding definition using the interface(portType) qname with a
|
||||
*/
|
||||
public static Binding findInterfaceBinding(Definition wsdlDef,
|
||||
QName interfaceQName, QName extQName) {
|
||||
Map bindingMap = wsdlDef.getBindings();
|
||||
@SuppressWarnings("unchecked")
|
||||
Collection<Binding> bindings = bindingMap.values();
|
||||
for ( Binding binding : bindings ) {
|
||||
if ( binding.getPortType().getQName().equals(interfaceQName)) {
|
||||
return binding;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* find the wsdl4j operation corresponds to the interface+operation.
|
||||
* @param wsdlDef wsdl definition
|
||||
* @param portTypeQName portType QName
|
||||
* @param opName operation name. if null, first operation in the portType
|
||||
* is returned.
|
||||
* @return Operation corresponding to the portType+opName
|
||||
*/
|
||||
public static Operation findOperation(Definition wsdlDef,
|
||||
QName portTypeQName, String opName) {
|
||||
Operation operation = null;
|
||||
PortType portType = wsdlDef.getPortType(portTypeQName);
|
||||
if ( portType != null ) {
|
||||
if ( opName != null ) {
|
||||
operation = portType.getOperation(opName, null, null);
|
||||
} else {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Operation> list = portType.getOperations();
|
||||
if ( list != null && list.size() > 0 ) {
|
||||
operation = list.get(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
return operation;
|
||||
}
|
||||
/**
|
||||
* verifies whether the wsdl definition contains the specified service descriptions or not. Used
|
||||
* to locate the wsdl definition for the services describes in service unit deployment
|
||||
* descriptor(jbi.xm).
|
||||
* @param interfaceName portType qname to find in the definition. can be null if you are trying to
|
||||
* find only service endpoint description.
|
||||
* @param serviceName qname for the service to find in this wsdl. can be null if
|
||||
* you are trying to find only portType (abstract service) description.
|
||||
* @param endpointName port name to find in the service definition. null if only
|
||||
* service with any port should be looked up.
|
||||
*
|
||||
* @return true if the wsdl definition contains the specified service description.
|
||||
*/
|
||||
public static boolean isWSDLFor(Definition wsdlDef,
|
||||
QName interfaceName, QName serviceName, String endpointName) {
|
||||
PortType portType = null;
|
||||
Service service = null;
|
||||
Port port = null;
|
||||
if ( interfaceName != null ) {
|
||||
portType = findInterface(wsdlDef, interfaceName);
|
||||
}
|
||||
|
||||
if ( serviceName != null ) {
|
||||
service = findService(wsdlDef, serviceName);
|
||||
}
|
||||
|
||||
if ( endpointName != null && service != null ) {
|
||||
port = service.getPort(endpointName);
|
||||
}
|
||||
|
||||
boolean isWSDL = true;
|
||||
|
||||
if ( (interfaceName != null && portType == null) ||
|
||||
( serviceName != null && service == null ) ||
|
||||
( endpointName != null && (service == null || port == null)) ) {
|
||||
isWSDL = false;
|
||||
}
|
||||
|
||||
return isWSDL;
|
||||
}
|
||||
/**
|
||||
* creates a binding definition that contains a service engine binding elements in the specified
|
||||
* wsdl definition for a portType. It will try to find/create the binding element with interface
|
||||
* local name with a "_JBISEBinding" suffix and add service engine binding element to it if it
|
||||
* is not present.
|
||||
* @param wsdl wsdl definition
|
||||
* @param interfaceName portType qname to which the binding is created.
|
||||
* @return a Binding contains service engine binding that is created for the portType.
|
||||
*/
|
||||
public Binding createServiceEngineBinding(Definition wsdl, QName interfaceName) {
|
||||
QName bindingQName = new QName(wsdl.getQName().getNamespaceURI(),
|
||||
interfaceName.getLocalPart() + "_JBISEBinding");
|
||||
Binding binding = wsdl.getBinding(bindingQName);
|
||||
if ( binding == null ) {
|
||||
binding = wsdl.createBinding();
|
||||
binding.setQName(bindingQName);
|
||||
binding.setPortType(wsdl.getPortType(interfaceName));
|
||||
binding.setUndefined(false);
|
||||
|
||||
ExtensibilityElement bindingExt =
|
||||
SEBindingExt.SEBindingExtImpl.addExtensibilityElement(wsdl, binding);
|
||||
|
||||
wsdl.addBinding(binding);
|
||||
}
|
||||
return binding;
|
||||
}
|
||||
/**
|
||||
* creates port and binding elements that provide the the service engine binding for a service.
|
||||
* @param wsdl wsdl definition
|
||||
* @param interfaceName portType qname to which the binding is created.
|
||||
* @param serviceName service under which the port definition bound to the service engine binding
|
||||
* should be created.
|
||||
* @param endpointName port name.
|
||||
* @return a Binding contains service engine binding that is created for the portType.
|
||||
*/
|
||||
public Binding createServiceEngineBinding(Definition wsdl, QName interfaceName, QName serviceName, String endpointName ) {
|
||||
Binding binding = null;
|
||||
Service service = findService(wsdl, serviceName);
|
||||
if ( service == null ) {
|
||||
return null;
|
||||
}
|
||||
Port port = service.getPort(endpointName);
|
||||
if ( port != null ) {
|
||||
binding = port.getBinding();
|
||||
} else {
|
||||
// create port
|
||||
port = wsdl.createPort();
|
||||
port.setName(endpointName);
|
||||
binding = createServiceEngineBinding(wsdl, interfaceName);
|
||||
port.setBinding(binding);
|
||||
service.addPort(port);
|
||||
}
|
||||
return binding;
|
||||
}
|
||||
/** prints the wsdl to text from the wsdl definition */
|
||||
public static void printWSDL(PrintWriter out, Definition def) {
|
||||
try {
|
||||
WSDLFactory factory = WSDLFactory.newInstance();
|
||||
WSDLWriter wsdlWriter = factory.newWSDLWriter();
|
||||
wsdlWriter.writeWSDL(def, out);
|
||||
} catch (WSDLException ex) {
|
||||
ex.printStackTrace(out);
|
||||
}
|
||||
}
|
||||
/** prints the wsdl to text from the wsdl definition */
|
||||
public static String printWSDLToString(Definition def) {
|
||||
StringWriter writer = new StringWriter();
|
||||
PrintWriter out = new PrintWriter(writer);
|
||||
printWSDL(out, def);
|
||||
out.close();
|
||||
return writer.getBuffer().toString();
|
||||
}
|
||||
/** returns an existing namespace prefix or create one if not exists for the corresponding namespaceURI */
|
||||
public static String getNamespacePrefix(Definition def, String namespaceURI, String defPrefix) {
|
||||
String prefix = null;
|
||||
prefix = def.getPrefix(namespaceURI);
|
||||
if ( prefix == null ) {
|
||||
Set keySet = def.getNamespaces().keySet();
|
||||
String newPrefix = "ns";
|
||||
if ( defPrefix != null && defPrefix.trim().length() > 0 ){
|
||||
newPrefix = defPrefix;
|
||||
}
|
||||
prefix = newPrefix;
|
||||
for ( int i=0; i < Integer.MAX_VALUE; ++i) {
|
||||
if (!keySet.contains(prefix)) {
|
||||
break;
|
||||
} else {
|
||||
prefix = newPrefix + i;
|
||||
}
|
||||
}
|
||||
}
|
||||
return prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* creates and adds the jbi service engine binding extensibility element to the wsdl definition
|
||||
* under specified binding definition.
|
||||
*/
|
||||
public static void addExtensibilityElement(Definition wsdlDef,
|
||||
ElementExtensible extensibleEl, ExtensibilityElement extEl, String defPrefix) {
|
||||
QName elementType = extEl.getElementType();
|
||||
String namespaceURI = elementType.getNamespaceURI();
|
||||
String prefix = wsdlDef.getPrefix(namespaceURI);
|
||||
if ( prefix == null ) {
|
||||
// no namespace prefix defined. create one.
|
||||
prefix = WSDLProcessor.getNamespacePrefix(wsdlDef, namespaceURI, defPrefix);
|
||||
wsdlDef.addNamespace(prefix, namespaceURI);
|
||||
}
|
||||
extensibleEl.addExtensibilityElement(extEl);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,136 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
targetNamespace="http://www.sun.com/jbi/Configuration/V1.0"
|
||||
xmlns:tns="http://www.sun.com/jbi/Configuration/V1.0"
|
||||
elementFormDefault="qualified">
|
||||
<xsd:element name="Configuration" type="tns:configurationType"/>
|
||||
<xsd:complexType name="configurationType">
|
||||
<xsd:sequence>
|
||||
<xsd:choice minOccurs="0" maxOccurs="unbounded">
|
||||
<xsd:element name="Property" type="tns:propertyType"/>
|
||||
<xsd:element name="PropertyGroup" type="tns:propertyGroupType"/>
|
||||
</xsd:choice>
|
||||
<xsd:element name="ApplicationConfiguration" type="tns:ApplicationConfigurationType" minOccurs="0" maxOccurs="1"/>
|
||||
<xsd:element name="ApplicationVariable" type="tns:applicationVariableType" minOccurs="0" maxOccurs="1"/>
|
||||
</xsd:sequence>
|
||||
<xsd:attribute type="xsd:string" name="name"/>
|
||||
</xsd:complexType>
|
||||
<xsd:complexType name="propertyGroupType">
|
||||
<xsd:complexContent>
|
||||
<xsd:extension base="tns:basePropType">
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="Property" type="tns:propertyType"/>
|
||||
</xsd:choice>
|
||||
</xsd:extension>
|
||||
</xsd:complexContent>
|
||||
</xsd:complexType>
|
||||
<xsd:complexType name="ApplicationConfigurationType">
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="Property" type="tns:propertyType"/>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
<xsd:complexType name="applicationVariableType">
|
||||
<xsd:complexContent>
|
||||
<xsd:extension base="tns:restartPropType">
|
||||
<xsd:sequence>
|
||||
<xsd:element name="name" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Application Variable Name
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:element>
|
||||
<xsd:element name="type" type="tns:appVarTypeEnum" default="String">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
|
||||
Application Variable Type
|
||||
This is an enumeration : {"String", "Number", "Boolean", "Password"}
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:element>
|
||||
<xsd:element name="value" type="xsd:string">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Application Variable Value
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:element>
|
||||
</xsd:sequence>
|
||||
</xsd:extension>
|
||||
</xsd:complexContent>
|
||||
</xsd:complexType>
|
||||
<xsd:simpleType name="appVarTypeEnum">
|
||||
<xsd:restriction base="xsd:string">
|
||||
<xsd:enumeration value="String"/>
|
||||
<xsd:enumeration value="Number"/>
|
||||
<xsd:enumeration value="Boolean"/>
|
||||
<xsd:enumeration value="Password"/>
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
<xsd:complexType name="propertyType">
|
||||
<xsd:complexContent>
|
||||
<xsd:extension base="tns:basePropType">
|
||||
<xsd:sequence>
|
||||
<xsd:element name="Constraint" type="tns:constraintType"
|
||||
minOccurs="0" maxOccurs="unbounded"/>
|
||||
</xsd:sequence>
|
||||
<xsd:attribute type="xsd:QName" name="type" use="required"/>
|
||||
<xsd:attribute type="xsd:string" name="defaultValue"/>
|
||||
<xsd:attribute type="xsd:boolean" name="encrypted" default="false"/>
|
||||
</xsd:extension>
|
||||
</xsd:complexContent>
|
||||
</xsd:complexType>
|
||||
<xsd:complexType name="restartPropType">
|
||||
<xsd:attribute type="xsd:boolean" name="isApplicationRestartRequired"/>
|
||||
<xsd:attribute type="xsd:boolean" name="isComponentRestartRequired"/>
|
||||
<xsd:attribute type="xsd:boolean" name="isServerRestartRequired"/>
|
||||
</xsd:complexType>
|
||||
<xsd:complexType name="basePropType">
|
||||
<xsd:complexContent>
|
||||
<xsd:extension base="tns:restartPropType">
|
||||
<!-- internal attributes, not visible to user -->
|
||||
<xsd:attribute type="xsd:string" name="name" use="required"/> <!-- unique name -->
|
||||
<!-- external attriubutes, visible to user -->
|
||||
<xsd:attribute type="xsd:string" name="displayName" use="required"/>
|
||||
<xsd:attribute type="xsd:string" name="displayDescription" use="required"/>
|
||||
<xsd:attribute type="tns:displayEnum" name="showDisplay" default="runtime"/>
|
||||
<xsd:attribute type="xsd:string" name="onChangeMessage"/>
|
||||
<xsd:attribute type="xsd:boolean" name="required" default="false"/>
|
||||
<xsd:attribute type="xsd:string" name="maxOccurs"/>
|
||||
</xsd:extension>
|
||||
</xsd:complexContent>
|
||||
</xsd:complexType>
|
||||
<xsd:simpleType name="displayEnum">
|
||||
<xsd:restriction base="xsd:string">
|
||||
<xsd:enumeration value="runtime"/>
|
||||
<xsd:enumeration value="install"/>
|
||||
<xsd:enumeration value="all"/>
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
<xsd:complexType name="constraintType">
|
||||
<xsd:attribute type="tns:facetEnum" name="facet"/>
|
||||
<xsd:attribute type="xsd:string" name="value"/>
|
||||
</xsd:complexType>
|
||||
<xsd:simpleType name="facetEnum">
|
||||
<xsd:restriction base="xsd:string">
|
||||
<!--
|
||||
The first 12 are identical to XSD facets per spec.
|
||||
Same constraints apply, though not explicitly stated.
|
||||
-->
|
||||
<xsd:enumeration value="enumeration" />
|
||||
<xsd:enumeration value="fractionDigits" />
|
||||
<xsd:enumeration value="length" />
|
||||
<xsd:enumeration value="maxExclusive" />
|
||||
<xsd:enumeration value="maxInclusive" />
|
||||
<xsd:enumeration value="maxLength" />
|
||||
<xsd:enumeration value="minExclusive" />
|
||||
<xsd:enumeration value="minInclusive" />
|
||||
<xsd:enumeration value="minLength" />
|
||||
<xsd:enumeration value="pattern" />
|
||||
<xsd:enumeration value="totalDigits" />
|
||||
<xsd:enumeration value="whiteSpace" />
|
||||
<xsd:enumeration value="suggestedValue"/>
|
||||
</xsd:restriction>
|
||||
</xsd:simpleType>
|
||||
</xsd:schema>
|
|
@ -0,0 +1,72 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<actions>
|
||||
<action>
|
||||
<actionName>clean</actionName>
|
||||
<packagings>
|
||||
<packaging>*</packaging>
|
||||
</packagings>
|
||||
<goals>
|
||||
<goal>clean</goal>
|
||||
</goals>
|
||||
<properties>
|
||||
<maven.test.skip>true</maven.test.skip>
|
||||
</properties>
|
||||
</action>
|
||||
<action>
|
||||
<actionName>build</actionName>
|
||||
<packagings>
|
||||
<packaging>*</packaging>
|
||||
</packagings>
|
||||
<goals>
|
||||
<goal>install</goal>
|
||||
</goals>
|
||||
<properties>
|
||||
<maven.test.skip>true</maven.test.skip>
|
||||
</properties>
|
||||
</action>
|
||||
<action>
|
||||
<actionName>test</actionName>
|
||||
<packagings>
|
||||
<packaging>*</packaging>
|
||||
</packagings>
|
||||
<goals>
|
||||
<goal>package</goal>
|
||||
</goals>
|
||||
<properties>
|
||||
<maven.test.skip>false</maven.test.skip>
|
||||
</properties>
|
||||
</action>
|
||||
<action>
|
||||
<actionName>rebuild</actionName>
|
||||
<packagings>
|
||||
<packaging>*</packaging>
|
||||
</packagings>
|
||||
<goals>
|
||||
<goal>clean</goal>
|
||||
<goal>install</goal>
|
||||
</goals>
|
||||
<properties>
|
||||
<maven.test.skip>true</maven.test.skip>
|
||||
</properties>
|
||||
</action>
|
||||
<action>
|
||||
<actionName>CUSTOM-testreport</actionName>
|
||||
<displayName>testreport</displayName>
|
||||
<goals>
|
||||
<goal>surefire-report:report-only</goal>
|
||||
</goals>
|
||||
<properties>
|
||||
<maven.test.skip>true</maven.test.skip>
|
||||
</properties>
|
||||
</action>
|
||||
<action>
|
||||
<actionName>CUSTOM-allreports</actionName>
|
||||
<displayName>allreports</displayName>
|
||||
<goals>
|
||||
<goal>site</goal>
|
||||
</goals>
|
||||
<properties>
|
||||
<maven.test.skip>true</maven.test.skip>
|
||||
</properties>
|
||||
</action>
|
||||
</actions>
|
|
@ -0,0 +1,72 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<actions>
|
||||
<action>
|
||||
<actionName>clean</actionName>
|
||||
<packagings>
|
||||
<packaging>*</packaging>
|
||||
</packagings>
|
||||
<goals>
|
||||
<goal>clean</goal>
|
||||
</goals>
|
||||
<properties>
|
||||
<maven.test.skip>true</maven.test.skip>
|
||||
</properties>
|
||||
</action>
|
||||
<action>
|
||||
<actionName>build</actionName>
|
||||
<packagings>
|
||||
<packaging>*</packaging>
|
||||
</packagings>
|
||||
<goals>
|
||||
<goal>install</goal>
|
||||
</goals>
|
||||
<properties>
|
||||
<maven.test.skip>true</maven.test.skip>
|
||||
</properties>
|
||||
</action>
|
||||
<action>
|
||||
<actionName>test</actionName>
|
||||
<packagings>
|
||||
<packaging>*</packaging>
|
||||
</packagings>
|
||||
<goals>
|
||||
<goal>package</goal>
|
||||
</goals>
|
||||
<properties>
|
||||
<maven.test.skip>false</maven.test.skip>
|
||||
</properties>
|
||||
</action>
|
||||
<action>
|
||||
<actionName>rebuild</actionName>
|
||||
<packagings>
|
||||
<packaging>*</packaging>
|
||||
</packagings>
|
||||
<goals>
|
||||
<goal>clean</goal>
|
||||
<goal>install</goal>
|
||||
</goals>
|
||||
<properties>
|
||||
<maven.test.skip>true</maven.test.skip>
|
||||
</properties>
|
||||
</action>
|
||||
<action>
|
||||
<actionName>CUSTOM-testreport</actionName>
|
||||
<displayName>testreport</displayName>
|
||||
<goals>
|
||||
<goal>surefire-report:report-only</goal>
|
||||
</goals>
|
||||
<properties>
|
||||
<maven.test.skip>true</maven.test.skip>
|
||||
</properties>
|
||||
</action>
|
||||
<action>
|
||||
<actionName>CUSTOM-allreports</actionName>
|
||||
<displayName>allreports</displayName>
|
||||
<goals>
|
||||
<goal>site</goal>
|
||||
</goals>
|
||||
<properties>
|
||||
<maven.test.skip>true</maven.test.skip>
|
||||
</properties>
|
||||
</action>
|
||||
</actions>
|
|
@ -0,0 +1,244 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
# BEGIN_HEADER - DO NOT EDIT
|
||||
#
|
||||
# The contents of this file are subject to the terms
|
||||
# of the Common Development and Distribution License
|
||||
# (the "License"). You may not use this file except
|
||||
# in compliance with the License.
|
||||
#
|
||||
# You can obtain a copy of the license at
|
||||
# https://open-jbi-components.dev.java.net/public/CDDLv1.0.html.
|
||||
# See the License for the specific language governing
|
||||
# permissions and limitations under the License.
|
||||
#
|
||||
# When distributing Covered Code, include this CDDL
|
||||
# HEADER in each file and include the License file at
|
||||
# https://open-jbi-components.dev.java.net/public/CDDLv1.0.html.
|
||||
# If applicable add the following below this CDDL HEADER,
|
||||
# with the fields enclosed by brackets "[]" replaced with
|
||||
# your own identifying information: Portions Copyright
|
||||
# [year] [name of copyright owner]
|
||||
-->
|
||||
|
||||
<!--
|
||||
# @(#)pom.xml
|
||||
# Copyright 2006-2008 Sun Microsystems, Inc. All Rights Reserved.
|
||||
#
|
||||
# END_HEADER - DO NOT EDIT
|
||||
-->
|
||||
<project>
|
||||
<parent>
|
||||
<artifactId>package-common</artifactId>
|
||||
<groupId>open-jbi-components</groupId>
|
||||
<version>1.1</version>
|
||||
<relativePath>../../build-common/package-common</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>open-jbi-components</groupId>
|
||||
<artifactId>camelse-installer</artifactId>
|
||||
<name>openesb-camel-se</name>
|
||||
<version>${camelse.artifact.version}</version>
|
||||
<description>camelse packaging description</description>
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<targetPath>META-INF</targetPath>
|
||||
<directory>src</directory>
|
||||
<filtering>true</filtering>
|
||||
<includes>
|
||||
<include>*.xml</include>
|
||||
<include>*.xsd</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>${project.artifactId}-fetch-deps</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>copy-dependencies</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${project.build.outputDirectory}/lib</outputDirectory>
|
||||
<stripVersion>true</stripVersion>
|
||||
<excludeTransitive>true</excludeTransitive>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-bundle-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>bundle-manifest</id>
|
||||
<phase>process-classes</phase>
|
||||
<goals>
|
||||
<goal>manifest</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<instructions>
|
||||
<Bundle-SymbolicName>openesb-camel-engine</Bundle-SymbolicName>
|
||||
<Bundle-Name>Camel Service Engine</Bundle-Name>
|
||||
<Bundle-Description>Camel Service Engine</Bundle-Description>
|
||||
<Bundle-Version>${OSGI_VERSION}</Bundle-Version>
|
||||
<_removeheaders>${OSGI_MANIFEST_REMOVE_HEADERS}, Export-Package</_removeheaders>
|
||||
<Export-Package>*;-noimport:=true</Export-Package>
|
||||
<Bundle-ClassPath>
|
||||
lib/activemq-all.jar,
|
||||
lib/camel-core.jar,
|
||||
lib/camel-jms.jar,
|
||||
lib/camelseimpl.jar,
|
||||
lib/camel-spring.jar
|
||||
lib/commons-logging.jar,
|
||||
lib/common-util.jar,
|
||||
lib/jaxb-impl.jar,
|
||||
lib/slf4j-api.jar,
|
||||
lib/slf4j-nop.jar,
|
||||
lib/spring-aop.jar,
|
||||
lib/spring-asm.jar
|
||||
lib/spring-beans.jar,
|
||||
lib/spring-context.jar,
|
||||
lib/spring-core.jar,
|
||||
lib/spring-expression.jar,
|
||||
lib/spring-jms.jar,
|
||||
lib/spring-tx.jar,
|
||||
lib/wsdl4j.jar,
|
||||
lib/ftpbcimpl.jar,
|
||||
lib/qos.jar,
|
||||
lib/common-util.jar,
|
||||
lib/jakarta-oro-2.0.8.jar,
|
||||
lib/resolver.jar,
|
||||
lib/componentsl.jar,
|
||||
lib/compositelock.jar,
|
||||
lib/net.sf.hulp.meas.itf.jar,
|
||||
lib/net.sf.hulp.meas.impl.jar
|
||||
</Bundle-ClassPath>
|
||||
<Import-Package>
|
||||
javax.xml.namespace,
|
||||
org.openesb.*,
|
||||
!javax.servlet.*,
|
||||
!org.apache.xerces.impl.xpath.regex,
|
||||
*;-nouses:=true
|
||||
</Import-Package>
|
||||
</instructions>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
<!-- camel dependencies start-->
|
||||
<dependency>
|
||||
<groupId>org.apache.camel</groupId>
|
||||
<artifactId>camel-core</artifactId>
|
||||
<version>2.11.0</version>
|
||||
</dependency>
|
||||
|
||||
<!--<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-aop</artifactId>
|
||||
<version>3.1.4.RELEASE</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-beans</artifactId>
|
||||
<version>3.1.4.RELEASE</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context</artifactId>
|
||||
<version>3.1.4.RELEASE</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-core</artifactId>
|
||||
<version>3.1.4.RELEASE</version>
|
||||
</dependency>-->
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-logging</groupId>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
<version>1.1.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>1.7.5</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- camel dependencies end-->
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>open-jbi-components</groupId>
|
||||
<artifactId>componentsl</artifactId>
|
||||
<optional>true</optional>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>open-jbi-components</groupId>
|
||||
<artifactId>camelseimpl</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<!--<dependency>
|
||||
<groupId>open-jbi-components</groupId>
|
||||
<artifactId>resolver</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>-->
|
||||
<dependency>
|
||||
<groupId>open-jbi-components</groupId>
|
||||
<artifactId>wsdl4j</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>open-jbi-components</groupId>
|
||||
<artifactId>qos</artifactId>
|
||||
</dependency>
|
||||
<!--
|
||||
<dependency>
|
||||
<groupId>open-jbi-components</groupId>
|
||||
<artifactId>compositelock</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>open-jbi-components</groupId>
|
||||
<artifactId>common-util</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.sf.hulp.meas</groupId>
|
||||
<artifactId>net.sf.hulp.meas.itf</artifactId>
|
||||
<optional>true</optional>
|
||||
<version>2.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.sf.hulp.meas</groupId>
|
||||
<artifactId>net.sf.hulp.meas.impl</artifactId>
|
||||
<optional>true</optional>
|
||||
<version>2.1-SNAPSHOT</version>
|
||||
</dependency>-->
|
||||
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,72 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
|
||||
<!--
|
||||
Document : jbi.xml
|
||||
Created on : July 10, 2013, 14:22 AM
|
||||
Author : vishnu
|
||||
Description: JBI Component installation descriptor.
|
||||
-->
|
||||
<jbi xmlns="http://java.sun.com/xml/ns/jbi" xmlns:config="http://www.sun.com/jbi/Configuration/V1.0" xmlns:logging="http://www.sun.com/jbi/descriptor/logging" xmlns:ver="http://www.sun.com/jbi/descriptor/identification" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0">
|
||||
<component bootstrap-class-loader-delegation="self-first" component-class-loader-delegation="self-first" type="service-engine">
|
||||
<identification>
|
||||
<name>camel-jbi-se</name>
|
||||
<description>JBI Service Engine that runs Apache Camel Applications in a JBI Container like OpenESB</description>
|
||||
<ver:VersionInfo build-number="@datetimestamp@" specification-version="@specversion@"/>
|
||||
</identification>
|
||||
<!-- FQN of the implementation class for javax.jbi.component.Component interface -->
|
||||
<component-class-name>org.openesb.components.camelse.CamelSERuntime</component-class-name>
|
||||
<!-- component runtime classpath for component execution classloader -->
|
||||
<component-class-path>
|
||||
<path-element>lib/camelseimpl.jar</path-element>
|
||||
<path-element>lib/wsdl4j.jar</path-element>
|
||||
<path-element>lib/camel-core.jar</path-element>
|
||||
<path-element>lib/camel-spring.jar</path-element>
|
||||
<path-element>lib/spring-aop.jar</path-element>
|
||||
<path-element>lib/spring-beans.jar</path-element>
|
||||
<path-element>lib/spring-context.jar</path-element>
|
||||
<path-element>lib/spring-core.jar</path-element>
|
||||
<path-element>lib/slf4j-api.jar</path-element>
|
||||
<path-element>lib/commons-logging.jar</path-element>
|
||||
<path-element>lib/spring-asm.jar</path-element>
|
||||
<path-element>lib/spring-expression.jar</path-element>
|
||||
<path-element>lib/slf4j-nop.jar</path-element>
|
||||
<path-element>lib/camel-jms.jar</path-element>
|
||||
<path-element>lib/spring-tx.jar</path-element>
|
||||
<path-element>lib/spring-jms.jar</path-element>
|
||||
<path-element>lib/activemq-all.jar</path-element>
|
||||
</component-class-path>
|
||||
<!-- FQN of the implementation class for javax.jbi.component.Bootstrap interface -->
|
||||
<bootstrap-class-name>org.openesb.components.camelse.CamelSEInstaller</bootstrap-class-name>
|
||||
<!-- component installation time classpath for component bootstrap classloader -->
|
||||
<bootstrap-class-path>
|
||||
|
||||
<path-element>lib/camelseimpl.jar</path-element>
|
||||
<path-element>lib/wsdl4j.jar</path-element>
|
||||
<path-element>lib/camel-core.jar</path-element>
|
||||
<path-element>lib/camel-spring.jar</path-element>
|
||||
<path-element>lib/spring-aop.jar</path-element>
|
||||
<path-element>lib/spring-beans.jar</path-element>
|
||||
<path-element>lib/spring-context.jar</path-element>
|
||||
<path-element>lib/spring-core.jar</path-element>
|
||||
<path-element>lib/slf4j-api.jar</path-element>
|
||||
<path-element>lib/commons-logging.jar</path-element>
|
||||
<path-element>lib/spring-asm.jar</path-element>
|
||||
<path-element>lib/spring-expression.jar</path-element>
|
||||
<path-element>lib/slf4j-nop.jar</path-element>
|
||||
<path-element>lib/camel-jms.jar</path-element>
|
||||
<path-element>lib/spring-tx.jar</path-element>
|
||||
<path-element>lib/spring-jms.jar</path-element>
|
||||
<path-element>lib/activemq-all.jar</path-element>
|
||||
</bootstrap-class-path>
|
||||
<!-- jbi shared libraries this component is dependent on. The classpaths of these
|
||||
shared libraries will be available to component runtime classloader -->
|
||||
<!--
|
||||
<shared-library>sun-wsdl-library</shared-library>
|
||||
-->
|
||||
<config:Configuration>
|
||||
<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>
|
||||
</component>
|
||||
</jbi>
|
|
@ -0,0 +1,24 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project>
|
||||
<parent>
|
||||
<artifactId>ojc-common</artifactId>
|
||||
<groupId>open-jbi-components</groupId>
|
||||
<version>1.1</version>
|
||||
<relativePath>../build-common/ojc-common</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>open-jbi-components</groupId>
|
||||
<artifactId>camelse-top</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<name>camelse-top</name>
|
||||
<version>${jbicomps.currentVersion}</version>
|
||||
<description>Top-level Build for camelse-top</description>
|
||||
<build>
|
||||
<defaultGoal>install</defaultGoal>
|
||||
</build>
|
||||
<modules>
|
||||
<!-- components: -->
|
||||
<module>camelseimpl</module>
|
||||
<module>packaging</module>
|
||||
</modules>
|
||||
</project>
|
|
@ -176,11 +176,5 @@
|
|||
<version>1.0.19</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javaee</groupId>
|
||||
<artifactId>javaee-api</artifactId>
|
||||
<version>5</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
<path-element>grizzly.jar</path-element>
|
||||
<path-element>webservices-rt.jar</path-element>
|
||||
<path-element>httpbc-ext.jar</path-element>
|
||||
<path-element>javaee-api.jar</path-element>
|
||||
<path-element>javaee.jar</path-element>
|
||||
</component-class-path>
|
||||
<bootstrap-class-name>com.sun.jbi.httpsoapbc.bootstrap.HttpSoapBindingBootstrap</bootstrap-class-name>
|
||||
<bootstrap-class-path>
|
||||
|
@ -40,7 +40,7 @@
|
|||
<path-element>grizzly.jar</path-element>
|
||||
<path-element>webservices-rt.jar</path-element>
|
||||
<path-element>httpbc-ext.jar</path-element>
|
||||
<path-element>javaee-api.jar</path-element>
|
||||
<path-element>javaee.jar</path-element>
|
||||
</bootstrap-class-path>
|
||||
<logging:Logging root="com.sun.jbi.httpsoapbc">
|
||||
<logging:logger displayName="HTTP Extensions">com.sun.jbi.httpsoapbc.Extension</logging:logger>
|
||||
|
|
Binary file not shown.
|
@ -101,6 +101,7 @@
|
|||
<module>xsltse</module>
|
||||
<module>alese</module>
|
||||
<module>pojose</module>
|
||||
<module>camelse</module>
|
||||
<!--
|
||||
# the following projects have non-open-source license dependencies.
|
||||
# you must purchase a licence or agree to license terms and install
|
||||
|
|
Loading…
Reference in New Issue