Remove deprecated JDBC BC

master
Vitaliy Filippov 2015-12-27 23:27:48 +03:00
parent fc7baf637c
commit 8007e53314
133 changed files with 0 additions and 26844 deletions

View File

@ -1,72 +0,0 @@
<?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>

View File

@ -1,106 +0,0 @@
<?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>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>jdbcbcimpl</artifactId>
<name>jdbcbcimpl</name>
<version>${jdbcbc.artifact.version}</version>
<description>jdbcbcimpl description</description>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<!-- exclude failing test. see IN=107976. RT 4/30/07 -->
<excludes>
<exclude>**/com/sun/jbi/jdbcbc/RuntimeConfigurationTest.java</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>open-jbi-components</groupId>
<artifactId>componentsl</artifactId>
</dependency>
<dependency>
<groupId>net.sf.hulp.meas</groupId>
<artifactId>net.sf.hulp.meas.itf</artifactId>
</dependency>
<dependency>
<groupId>wsdl4j</groupId>
<artifactId>wsdl4j</artifactId>
</dependency>
<dependency>
<groupId>open-jbi-components</groupId>
<artifactId>qos</artifactId>
</dependency>
<dependency>
<groupId>open-jbi-components</groupId>
<artifactId>common-util</artifactId>
</dependency>
<!-- TEST DEPENDENCIES-->
<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>cglib</groupId>
<artifactId>cglib</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>asm</groupId>
<artifactId>asm-all</artifactId>
<version>2.2.3</version>
<scope>test</scope>
</dependency>
<dependency>
<artifactId>asm-parent</artifactId>
<groupId>asm</groupId>
<version>1.5.3</version>
<scope>test</scope>
</dependency>-->
</dependencies>
</project>

View File

@ -1,209 +0,0 @@
/*
* 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]
*/
/*
* @(#)EndpointBean.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc;
import com.sun.jbi.eManager.provider.EndpointStatus;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import com.sun.jbi.jdbcbc.model.runtime.DBConnectionInfo;
/**
* author
*EndPointBean
**/
public class EndpointBean implements Serializable {
static final long serialVersionUID = 42L;
public static final String SERVICE_NAME = "servicename";
public static final String FULL_SERVICE_NAME = "fullservicename";
public static final String ENDPOINT_NAME = "endpointname";
public static final String ENDPOINT_TYPE = "endpointtype";
public static final String OPERATION = "operation";
public static final String ENDPOINT_REFERENCE = "endpointreference";
public static final String URL_CONTEXT = "urlcontext";
public static final String URL_PORT = "urlport";
public static final String MESSAGE_EXCHANGE_PATTERN = "mep";
public static final String ENDPOINT_URL = "endpointurl";
public static final String WSDL_FILE = "wsdlfile";
public static final String JDBC_DATABASE_JNDI_NAME = "jndiName";
public static final String JDBC_TRANSACTION_REQUIRED = "transactionRequired";
public static final String JDBC_DATABASE_DRIVER_CLASS = "driverClassName";
public static final String JDBC_DATABASE_URL = "dbURL";
public static final String JDBC_DATABASE_USER = "userName";
public static final String JDBC_DATABASE_PASSWORD = "password";
public static final String JDBC_DATABASE_NAME = "databaseName";
public static final String STATUS = "status";
public static final String DESCRIPTOR = "descriptor";
// A map from the operation name to the meta data (in msg type, out msg type, soap action, faults, etc)
public static final String OPERATION_NAME_TO_META_DATA = "operationnametometadata";
public static final String ENDPOINT_TYPE_INBOUND = "inbound";
public static final String ENDPOINT_TYPE_OUTBOUND = "outbound";
public static final String STATUS_SHUTDOWN = "SHUTDOWN";
public static final String STATUS_STOPPED = "STOPPED";
public static final String STATUS_RUNNING = "RUNNING";
private final HashMap<String,Object> mConfigTable;
private transient String mDeploymentId;
private transient String mTriggerName = null;
private String mTableName = null;
private EndpointStatus mEndpointStatus;
private List mrecordList = new ArrayList();
private DBConnectionInfo mDBConnectionInfo;
// throttling related info
int maxConcurrencyLimit;
public EndpointBean() {
//mConfigTable = null;
mConfigTable = new HashMap<String,Object>();
}
protected void setDeploymentId(final String asId) {
mDeploymentId = asId;
}
public String getDeploymentId() {
return mDeploymentId;
}
public void setEndpointStatus(final EndpointStatus val) {
mEndpointStatus = val;
}
public EndpointStatus getEndpointStatus() {
return mEndpointStatus;
}
/**
* Get the unique name of this endpoint instance
* @return
*/
public String getUniqueName() {
final String serviceName = getValue(EndpointBean.SERVICE_NAME);
final String endpointName = getValue(EndpointBean.ENDPOINT_NAME);
final String endpointType = getValue(EndpointBean.ENDPOINT_TYPE);
return EndpointBean.getUniqueName(serviceName, endpointName, endpointType);
}
/**
* Utility method to create the unique names with explicit arguments
* @param aServiceName
* @param aEndpointName
* @param aEndpointType
* @return
*/
public static String getUniqueName(final String aServiceName,
final String aEndpointName, final String aEndpointType) {
if ((aServiceName != null) && (aEndpointName != null) &&
(aEndpointType != null)) {
return aServiceName + "," + aEndpointName + "," + aEndpointType;
} else {
return null;
}
}
public void setValue(final String key, String value) {
if (key == null) {
return;
}
if (value == null) {
value = "";
}
mConfigTable.put(key, value);
}
public void setValueObj(final String key, final Object value) {
if (key == null) {
return;
}
mConfigTable.put(key, value);
}
public String getValue(final String key) {
if (key == null) {
return null;
} else {
return (String) mConfigTable.get(key);
}
}
public Object getValueObj(final String key) {
return mConfigTable.get(key);
}
public void setProcessList(final List recordList) {
mrecordList = recordList;
}
public List getProcessList() {
return mrecordList;
}
public void setTriggerName(final String triggerName) {
mTriggerName = triggerName;
}
public void setTableName(final String tableName) {
mTableName = tableName;
}
public String getTriggerName() {
return mTriggerName;
}
public String getTableName() {
return mTableName;
}
public void setDBInfo(DBConnectionInfo dbInfo){
this.mDBConnectionInfo = dbInfo;
}
public DBConnectionInfo getDBInfo(){
return this.mDBConnectionInfo;
}
public void setMaxConcurrencyLimit(int maxConcurrencyLimit){
this.maxConcurrencyLimit = maxConcurrencyLimit;
}
public int getMaxConcurrencyLimit(){
return this.maxConcurrencyLimit;
}
}

View File

@ -1,77 +0,0 @@
/*
* 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]
*/
/*
* @(#)FaultException.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc;
import javax.jbi.messaging.MessagingException;
/**
* Contains the information to reply with a fault
*/
public class FaultException extends Exception {
/**
*
*/
private static final long serialVersionUID = 1L;
private String mFaultCode;
private String mFaultString;
private String mFaultActor;
private String mDetail;
/** Creates a new instance of HttpException */
public FaultException() {
super();
}
protected FaultException(final MessagingException ex) {
// default
mFaultCode = "Server";
//mFaultString;
//mFaultActor;
mDetail = ex.getMessage();
}
protected String getFaultCode() {
return mFaultCode;
}
protected String getFaultString() {
return mFaultString;
}
protected String getFaultActor() {
return mFaultActor;
}
protected String getDetail() {
return mDetail;
}
}

View File

@ -1,961 +0,0 @@
/*
* 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]
*/
/*
* @(#)InboundMessageProcessor.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.jbi.component.ComponentContext;
import javax.jbi.messaging.DeliveryChannel;
import javax.jbi.messaging.ExchangeStatus;
import javax.jbi.messaging.InOnly;
import javax.jbi.messaging.InOut;
import javax.jbi.messaging.MessageExchange;
import javax.jbi.messaging.MessageExchangeFactory;
import javax.jbi.messaging.MessagingException;
import javax.jbi.messaging.NormalizedMessage;
import javax.jbi.servicedesc.ServiceEndpoint;
import javax.naming.Context;
import javax.naming.NamingException;
import javax.sql.DataSource;
import javax.sql.XAConnection;
import javax.transaction.Status;
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
import javax.transaction.xa.XAResource;
import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import com.sun.jbi.internationalization.Messages;
import com.sun.jbi.jdbcbc.model.metadata.DBMetaData;
import com.sun.jbi.jdbcbc.model.runtime.DBConnectionInfo;
import com.sun.jbi.jdbcbc.model.runtime.DatabaseModel;
import com.sun.jbi.jdbcbc.model.runtime.DatabaseModelImpl;
import com.sun.jbi.jdbcbc.model.runtime.Db2DataAccess;
import com.sun.jbi.jdbcbc.model.runtime.DerbyDataAccess;
import com.sun.jbi.jdbcbc.model.runtime.OracleDataAccess;
import com.sun.jbi.jdbcbc.model.runtime.SqlServerDataAccess;
import com.sun.jbi.jdbcbc.transaction.TransactionHelper;
import com.sun.jbi.jdbcbc.transaction.XidImpl;
import com.sun.jbi.nms.exchange.ExchangePattern;
import com.sun.jbi.common.qos.messaging.MessagingChannel;
import com.sun.jbi.common.qos.redelivery.Redelivery;
import com.sun.jbi.common.qos.redelivery.RedeliveryStatus;
/**
* author : Venkat P Process requests received from the External Database
*/
public class InboundMessageProcessor implements Runnable, MessageExchangeReplyListener, RedeliveryListener {
private static final String DERBY_PROD_NAME = "DERBY";
private static final String ORACLE_PROD_NAME = "ORACLE";
private static final String SQLSERVER_PROD_NAME = "SQLSERVER";
private static final String DB2_PROD_NAME = "DB2";
private static final String JDBC_PROD_NAME = "JDBC";
private XidImpl xid = null;
private TransactionHelper mTxHelper = null;
// private boolean mtxFlag;
XAResource xaResource = null;
//private TransactionManager mTxManager = null;
private static final Messages mMessages = Messages.getMessages(InboundMessageProcessor.class);
private static final Logger mLogger = Messages.getLogger(InboundMessageProcessor.class);
@SuppressWarnings("unchecked")
private static final Map mInboundExchanges = Collections.synchronizedMap(new HashMap());
private static Map exchangeIDToMeta = Collections.synchronizedMap(new HashMap());
Map mEndpoint;
EndpointBean epb;
DocumentBuilder mDocBuilder;
//private DeliveryChannel mChannel;
private MessagingChannel mChannel;
private MessageExchange mExchange;
private ComponentContext mContext;
private MessageExchangeFactory mMsgExchangeFactory;
private ServiceEndpoint mServiceEndpoint;
private final QName mOperation;
private AtomicBoolean mMonitor;
private String mPKName = null;
private String mSelectSQL = null;
private String mMarkColumnName = null;
private String mMarkColumnValue = null;
private String mPKType = null;
private String mFlagColumnType = null;
private String mTable = null;
private String mSchemaName = null;
DBConnectionInfo dbConnectionInfo;
private String mXAEnabled = null;
// private DBMetaData mdbMetaData = null;
private DatabaseModel dbDataAccessObject = null;
PreparedStatement ps = null;
Connection connection = null;
Connection con = null;
XAConnection xaConnection = null;
private String mTableName = null;
private String mPollingPostProcessing = null;
private String mMoveRowToTableName = null;
private int mPollMilliSeconds = 10000;
// Settings for custom reliability header extensions
public static final String CUSTOM_RELIABILITY_MESSAGE_ID_PROPERTY = "com.stc.jbi.messaging.messageid"; // NOI18N
public static final String CUSTOM_RELIABILITY_HEADER_NAMESPACE_URI = "http://schemas.stc.com/ws/2005/07/custrm"; // NOI18N
public static final String CUSTOM_RELIABILITY_HEADER_LOCAL_NAME = "MessageID"; // NOI18N
/**
* JBI message exchange properties for message grouping and sequencing (new CRMP)
*/
public static final String CRMP_GROUP_ID = "com.sun.jbi.messaging.groupid";
public static final String CRMP_MESSAGE_ID = "com.sun.jbi.messaging.messageid";
ReplyListener replyListener;
public InboundMessageProcessor(final MessagingChannel chnl, final EndpointBean endpoint,
final ComponentContext context, final QName opname) throws ParserConfigurationException {
mChannel = chnl;
epb = endpoint;
mContext = context;
replyListener = new ReplyListenerImpl(endpoint);
mOperation = opname;
mMonitor = new AtomicBoolean(false);
mTxHelper = new TransactionHelper();
dbConnectionInfo = new DBConnectionInfo();
final DocumentBuilderFactory docBuilderFact = DocumentBuilderFactory.newInstance();
mDocBuilder = docBuilderFact.newDocumentBuilder();
//mTxManager = (TransactionManager) context.getTransactionManager();
}
/**
* @return
*/
public static Map getInboundExchanges() {
return InboundMessageProcessor.mInboundExchanges;
}
/**
*
*/
//@Override
public void run() {
if (mLogger.isLoggable(Level.INFO)) {
mLogger.log(Level.INFO, "SQLSE_R00629.IMP_EP_status");
}
do {
try {
execute();
} catch (final Exception ex) {
mLogger.log(Level.SEVERE, mMessages.getString("SQLSE_E00659.IMP_ERROR_WHILE_EXECUTING_SQL"), ex);
}
if (mLogger.isLoggable(Level.FINE)) {
mLogger.log(Level.INFO,mMessages.getString("SQLSE_R00660.IMP_FINISHED_EXECUTING_SQL"));
}
try {
Thread.sleep(mPollMilliSeconds);
} catch (final Exception e) {
mLogger.log(Level.SEVERE, mMessages.getString("SQLSE_E00661.IMP_THREAD_SLEEP_ABRUPTED"), e);
}
} while (mMonitor.get() != Boolean.TRUE);
}
/**
* @throws MessagingException
* @throws Exception
*/
public void execute() throws MessagingException, Exception {
String exchangeId = null;
try {
if (mMsgExchangeFactory == null) {
mMsgExchangeFactory = mChannel.createExchangeFactory();
}
mExchange = mMsgExchangeFactory.createInOnlyExchange();
if (mServiceEndpoint == null) {
mServiceEndpoint = locateServiceEndpoint();
epb.setValueObj(EndpointBean.ENDPOINT_REFERENCE, mServiceEndpoint);
}
if (mServiceEndpoint == null) {
throw new MessagingException(mMessages.getString("SQLSE_E00643.IMP_Failed_locate_EP"));
}
exchangeId = mExchange.getExchangeId();
final QName serviceName = (QName) epb.getValueObj(EndpointBean.FULL_SERVICE_NAME);
final String epntName = epb.getValue(EndpointBean.ENDPOINT_NAME);
if (mLogger.isLoggable(Level.FINE)) {
mLogger.fine("Getting bean for" + serviceName + epntName);
}
mExchange.setEndpoint(mServiceEndpoint);
mExchange.setOperation(mOperation);
// Adding re-delivery/re-try support
// we are sending instead of the client context to the ReplyListener
// the EndpointBean
MessageExchangeSupport.addReplyListener(mExchange.getExchangeId(), replyListener, epb);
MessageExchangeSupport.addRedeliveryListener(mExchange.getExchangeId(), this, epb);
final String status = epb.getValue(EndpointBean.STATUS);
if (! status.equalsIgnoreCase(EndpointBean.STATUS_RUNNING)) {
final String endName = epb.getValue(EndpointBean.ENDPOINT_NAME);
if (mLogger.isLoggable(Level.INFO)) {
mLogger.log(Level.INFO, "SQLSE_W00630.IMP_EP_NOT_RUNNING", new Object[] { endName,
mExchange.getExchangeId() });
}
} else {
switch (ExchangePattern.valueOf(mExchange)) {
case IN_OUT:
mLogger.log(Level.INFO, "SQLSE_R00631.IMP_Received_INOUT", mExchange.getExchangeId());
processInOut(mExchange, epb);
break;
case IN_ONLY:
mLogger.log(Level.INFO, "SQLSE_R00632.IMP_Received_INONLY", mExchange.getExchangeId());
processInOnly(mExchange, epb);
break;
default:
mLogger.log(Level.INFO, "SQLSE_E00633.IMP_Invalid_pattern", mExchange.getExchangeId());
return;
}
}
} catch (final MessagingException ex) {
InboundMessageProcessor.mInboundExchanges.remove(exchangeId);
mLogger.log(Level.SEVERE, mMessages.getString("SQLSE_E00662.IMP_ERROR_WHILE_EXECUTING_MEP"), exchangeId);
throw ex;
} catch (final Exception e) {
InboundMessageProcessor.mInboundExchanges.remove(exchangeId);
mLogger.log(Level.SEVERE, mMessages.getString("SQLSE_E00662.IMP_ERROR_WHILE_EXECUTING_MEP"), exchangeId);
throw e;
}
}
/**
* @param exchange
* @param epb
*/
public void processInOut(final MessageExchange exchange, final EndpointBean epb) {
}
/**
* @param exchange
* @param epb
*/
public void processInOnly(final MessageExchange exchange, final EndpointBean epb) throws Exception {
String exchangeId = null;
ResultSet rs = null;
String jndiName = null;
try {
epb.getEndpointStatus().incrementReceivedRequests();
NormalizedMessage inMsg = mExchange.createMessage();
exchangeId = exchange.getExchangeId();
final Map operationNameToMetaData = (Map) epb.getValueObj(EndpointBean.OPERATION_NAME_TO_META_DATA);
final OperationMetaData meta = (OperationMetaData) operationNameToMetaData.get(exchange.getOperation().getLocalPart());
if (meta == null) {
throw new MessagingException(InboundMessageProcessor.mMessages.getString("SQLSE_E00634.IMP_Invalid_Operation",
new Object[] { exchange.getOperation() }));
}
mPollMilliSeconds = meta.getJDBCSql().getPollMilliSeconds();
mSelectSQL = meta.getJDBCSql().getSql();
/*mPKName = Qualified(meta.getJDBCSql().getPKName());
mMarkColumnName = Qualified(meta.getJDBCSql().getMarkColumnName());
mMarkColumnValue = meta.getJDBCSql().getMarkColumnValue();
mTableName = Qualified(meta.getJDBCSql().getTableName());
mPollingPostProcessing = meta.getJDBCSql().getPollingPostProcessing();
mMoveRowToTableName = Qualified(meta.getJDBCSql().getMoveRowToTableName());
*/
mPKName = meta.getJDBCSql().getPKName();
mMarkColumnName = meta.getJDBCSql().getMarkColumnName();
mMarkColumnValue = meta.getJDBCSql().getMarkColumnValue();
mTableName = meta.getJDBCSql().getTableName();
mPollingPostProcessing = meta.getJDBCSql().getPollingPostProcessing();
mMoveRowToTableName = meta.getJDBCSql().getMoveRowToTableName();
mXAEnabled = meta.getJDBCSql().getTransaction();
jndiName = epb.getValue(EndpointBean.JDBC_DATABASE_JNDI_NAME);
// createNewDataSource(mXAEnabled,jndiName,epb);
if (mXAEnabled.equalsIgnoreCase("XATransaction")) {
// mtxFlag = startTrasaction();
getTransactionManager().begin();
}
dbDataAccessObject = getDataAccessObject(meta);
mSelectSQL = dbDataAccessObject.generateSelectQuery(mSelectSQL, mTableName);
epb.setTableName(mTableName);
connection = getDatabaseConnection(jndiName);
Transaction tx = getTransactionManager().getTransaction();
if (isSelectStatement(mSelectSQL)) {
rs = executeInboundSQLSelect(epb, meta, connection, mTableName, mSelectSQL);
if (rs != null) {
final JDBCNormalizer normalizer = new JDBCNormalizer();
inMsg = normalizer.normalizeSelectInbound(rs, exchange, meta, epb, mPKName);
final List tempList = epb.getProcessList();
if (!(tempList.isEmpty())) {
// mTxHelper.handleInbound(exchange);
exchange.setMessage(inMsg, "in");
if (tx != null) {
mExchange.setProperty(MessageExchange.JTA_TRANSACTION_PROPERTY_NAME, tx);
getTransactionManager().suspend();
}
mChannel.send(exchange);
epb.getEndpointStatus().incrementSentRequests();
// mTableExistsFlag = new Object();
InboundMessageProcessor.mInboundExchanges.put(exchangeId, new ListenerMeta(
System.currentTimeMillis(), this));
} else {
if (tx != null) {
try {
tx.commit();
} catch (Exception ex) {
mLogger.log(Level.SEVERE,
"SQLSE_E00656.IMP_XA_TX_COMMIT_FAILED",
new Object[] { "commit", ex });
throw ex;
}
} else {
if (mXAEnabled.equalsIgnoreCase("XATransaction")) {
mLogger.log(Level.WARNING,
"SQLSE_W00654.IMP_XA_TX_NOT_FOUND_IN_MSG_XCHANGE",
new Object[] { exchange.getExchangeId() });
}
}
}
// mTableExistsFlag = new Object();
}
}
} catch (final Exception ex) {
mLogger.log(Level.SEVERE, mMessages.getString("SQLSE_E00663.IMP_ERROR_WHILE_PROCESSING_MEP"), ex);
Transaction tx = getTransactionManager().getTransaction();
if(tx != null ) {
tx.rollback();
}
} finally {
try {
if (rs != null) {
rs.close();
}
if (connection != null) {
connection.close();
}
} catch (final SQLException se) {
mLogger.log(Level.SEVERE,mMessages.getString("SQLSE_E00628.OMP_Cleanup_Failure"),se);
}
}
}
public ResultSet executeInboundSQLSelect(final EndpointBean eBean,
final OperationMetaData opMetaData,
Connection connection,
final String mTableName,
String lSelectSQL) throws MessagingException {
ResultSet rs = null;
try {
mLogger.log(Level.INFO, "Executing sql . " + lSelectSQL);
if ((mMarkColumnName == null) || (mMarkColumnName.equals(""))) {
// do nothing
} else {
if(mFlagColumnType != null){
if (mFlagColumnType.equalsIgnoreCase("LONGVARCHAR") || mFlagColumnType.equalsIgnoreCase("CHAR")
|| mFlagColumnType.equalsIgnoreCase("VARCHAR")) {
/*lSelectSQL = lSelectSQL.concat(" where " + mTableName + "." + mMarkColumnName + " != " + "'"
+ mMarkColumnValue + "'" + "or" + mTableName + "." + mMarkColumnName + "is NULL");*/
lSelectSQL = lSelectSQL.concat(" where " + mMarkColumnName + " != " + "'"
+ mMarkColumnValue + "'" + "or " + mMarkColumnName + " is NULL");
} else {
lSelectSQL = lSelectSQL.concat(" where " + mMarkColumnName + " != "
+ mMarkColumnValue + "or " + mMarkColumnName + " is NULL");
}
}else{
final String msg = InboundMessageProcessor.mMessages.getString("SQLSE_E00638.IMP_Error_IVALID_ColumnName") + mMarkColumnName;
throw new MessagingException(msg, new NamingException());
}
}
ps = connection.prepareStatement(lSelectSQL);
rs = ps.executeQuery();
}
catch (final SQLException ex) {
final String msg = InboundMessageProcessor.mMessages.getString("SQLSE_E00639.IMP_Failed_Executing_SQL") + lSelectSQL;
throw new MessagingException(msg, ex);
} catch (final Exception ex) {
final String msg = InboundMessageProcessor.mMessages.getString("SQLSE_E00639.IMP_Failed_Executing_SQL") + lSelectSQL;
throw new MessagingException(msg, ex);
}
return rs;
}
/**
* @return
* @throws MessagingException
*/
public DatabaseModel getDataAccessObject(OperationMetaData meta) throws MessagingException {
DatabaseModel objDataAccess = null;
String jndiName = null;
String prdtName = null;
String catalog = null;
ResultSet rs = null;
jndiName = epb.getValue(EndpointBean.JDBC_DATABASE_JNDI_NAME);
try {
connection = getDatabaseConnection(jndiName);
prdtName = DBMetaData.getDBType(connection);
rs = connection.getMetaData().getColumns(catalog, mSchemaName, mTable, "%");
int noofColCounter = -1;
// if(rs==null){
// final String msg = InboundMessageProcessor.mMessages.getString("IMP_Table_NotExist");
// throw new MessagingException(msg, new NamingException());
// }
while (rs.next()) {
noofColCounter++;
final String colName = rs.getString("COLUMN_NAME");
if (colName.equalsIgnoreCase(meta.getJDBCSql().getPKName())) {
final String defaultValue = rs.getString("COLUMN_DEF");
final int sqlTypeCode = rs.getInt("DATA_TYPE");
final String sqlType = DBMetaData.getSQLTypeDescription(sqlTypeCode);
mPKType = sqlType;
}
if (colName.equalsIgnoreCase(meta.getJDBCSql().getMarkColumnName())) {
final String defaultValue = rs.getString("COLUMN_DEF");
final int sqlTypeCode = rs.getInt("DATA_TYPE");
final String sqlType = DBMetaData.getSQLTypeDescription(sqlTypeCode);
mFlagColumnType = sqlType;
}
}
if(noofColCounter < 0 ){
final String msg = InboundMessageProcessor.mMessages.getString("SQLSE_E00636.IMP_Table_NotExist");
throw new MessagingException(msg, new NamingException());
}
if (mPKType == null) {
final String msg = InboundMessageProcessor.mMessages.getString("SQLSE_E00637.IMP_PrimaryKey_Error");
throw new MessagingException(msg, new NamingException());
}
if (prdtName.equalsIgnoreCase(InboundMessageProcessor.DERBY_PROD_NAME)) {
return objDataAccess = DerbyDataAccess.getInstance();
} else if (prdtName.equalsIgnoreCase(InboundMessageProcessor.ORACLE_PROD_NAME)) {
return objDataAccess = OracleDataAccess.getInstance();
} else if (prdtName.equalsIgnoreCase(InboundMessageProcessor.DB2_PROD_NAME)) {
return objDataAccess = Db2DataAccess.getInstance();
} else if (prdtName.equalsIgnoreCase(InboundMessageProcessor.SQLSERVER_PROD_NAME)) {
return objDataAccess = SqlServerDataAccess.getInstance();
} else if (prdtName.equalsIgnoreCase(InboundMessageProcessor.JDBC_PROD_NAME)) {
return objDataAccess = DatabaseModelImpl.getInstance();
} else {
return objDataAccess = new DatabaseModelImpl();
}
} catch (final NamingException ex) {
final String msg = InboundMessageProcessor.mMessages.getString("SQLSE_E00635.IMP_Error_Lookup") + jndiName;
throw new MessagingException(msg, ex);
} catch (final SQLException ex) {
final String msg = InboundMessageProcessor.mMessages.getString("SQLSE_E00639.IMP_Failed_Executing_SQL");
throw new MessagingException(msg, ex);
} catch (final Exception ex) {
final String msg = InboundMessageProcessor.mMessages.getString("SQLSE_E00639.IMP_Failed_Executing_SQL");
throw new MessagingException(msg, ex);
} finally {
try {
if (rs != null) {
rs.close();
}
if (connection != null) {
connection.close();
}
} catch (final SQLException se) {
mLogger.log(Level.INFO,
InboundMessageProcessor.mMessages.getString("SQLSE_E00628.OMP_Cleanup_Failure"),se);
}
}
}
/**
* @return
*/
public ServiceEndpoint locateServiceEndpoint() {
ServiceEndpoint activatedEndpoint = null;
final QName serviceName = (QName) epb.getValueObj(EndpointBean.FULL_SERVICE_NAME);
final String endpointName = epb.getValue(EndpointBean.ENDPOINT_NAME);
activatedEndpoint = mContext.getEndpoint(serviceName, endpointName);
if (activatedEndpoint != null) {
mLogger.log(Level.INFO, "IMP_locate_EP", new Object[] { serviceName, endpointName });
}
return (activatedEndpoint);
}
public String Qualified(String str) {
int len = 0;
if ((str != null) && (!str.equals(""))) {
final int i = str.indexOf(".");
if (i > 0) {
len = str.length();
mTable = str.substring(i + 1, len);
mSchemaName = str.substring(0, i);
str = "\"" + mSchemaName + "\"" + "." + "\"" + mTable + "\"";
return str;
}
return "\"" + str + "\"";
}
return str;
}
/**
* @param exchange
* @throws Exception
*/
//@Override
public synchronized void processReplyMessage(final MessageExchange exchange) throws Exception {
String sql = null;
String jndiName = null;
Transaction tx = null;
boolean isTransacted = exchange.isTransacted();
if (!(exchange instanceof InOnly) && !(exchange instanceof InOut)) {
mLogger.log(Level.SEVERE, "SQLSE_E00647.IMP_Unsupported_exchange_pattern",
exchange.getPattern().toString());
throw new Exception("SQLSE_E00647.IMP_Unsupported_exchange_pattern");
}
final String messageId = exchange.getExchangeId();
try {
if (InboundMessageProcessor.mInboundExchanges.containsKey(messageId)) {
// Any status other than 'DONE' is considered an error
if (exchange.getStatus() != ExchangeStatus.DONE) {
final String msgError = "Error occured while getting DONE Response ";
throw new Exception(msgError);
}
if (exchange.getStatus() == ExchangeStatus.DONE) {
try {
jndiName = epb.getValue(EndpointBean.JDBC_DATABASE_JNDI_NAME);
if (isTransacted && exchange instanceof InOnly) {
tx = (Transaction) exchange.getProperty(MessageExchange.JTA_TRANSACTION_PROPERTY_NAME);
try {
// we have to resume the suspended transaction
resumeThreadTx(tx);
} catch (Exception ex) {
// for in-only there's no sending of status back to nmr
// failure will be logged
mLogger.log(Level.WARNING, "SQLSE_E00651.IMP_RESUME_FAILED",
new Object[] { ex.getLocalizedMessage() });
}
try {
if (tx.getStatus() == Status.STATUS_MARKED_ROLLBACK) {
try {
// As we are the initiator for tx we have to rollback
rollbackThreadTx(exchange);
} catch (Exception ex) {
// for in-only there's no sending of status back to nmr
// failure will be logged
mLogger.log(Level.WARNING, "SQLSE_E00652.IMP_ROLLBACK_FAILED",
new Object[] { ex.getLocalizedMessage() });
}
}
} catch (Exception ex) {
mLogger.log(Level.INFO, "IMP_POST_PROCESS_FAILED",
new Object[] { ex.getLocalizedMessage() });
}
}
connection = getDatabaseConnection(jndiName);
if (isTransacted && exchange instanceof InOnly) {
connection.setAutoCommit(false);
}
final List records = epb.getProcessList();
for (final Iterator it = records.iterator(); it.hasNext();) {
String pkNameRet = (String) it.next();
if (mPKType.equalsIgnoreCase("LONGVARCHAR") || mPKType.equalsIgnoreCase("CHAR")
|| mPKType.equalsIgnoreCase("VARCHAR")) {
pkNameRet = "'" + pkNameRet + "'";
}
if (mPollingPostProcessing.equalsIgnoreCase("Delete")) {
sql = dbDataAccessObject.createQualifiedQuery(mTableName, mMoveRowToTableName,
mMarkColumnName, mMarkColumnValue, mPKName, "DELETE", mFlagColumnType);
sql = sql + "=" + pkNameRet;
mLogger.log(Level.INFO, "Executing sql . " + sql);
ps = connection.prepareStatement(sql);
final int delcount = ps.executeUpdate();
mLogger.log(Level.SEVERE, "Records deleted are:" + delcount);
} else if (mPollingPostProcessing.equalsIgnoreCase("MarkColumn")) {
sql = dbDataAccessObject.createQualifiedQuery(mTableName, mMoveRowToTableName,
mMarkColumnName, mMarkColumnValue, mPKName, "UPDATE", mFlagColumnType);
sql = sql + "=" + pkNameRet;
mLogger.log(Level.INFO, "Executing sql . " + sql);
ps = connection.prepareStatement(sql);
final int count = ps.executeUpdate();
mLogger.log(Level.SEVERE, "Records updated are " + count);
} else if (mPollingPostProcessing.equalsIgnoreCase("CopyRow")) {
sql = dbDataAccessObject.createQualifiedQuery(mTableName, mMoveRowToTableName,
mMarkColumnName, mMarkColumnValue, mPKName, "INSERT", mFlagColumnType);
sql = sql + "=" + pkNameRet;
mLogger.log(Level.INFO, "Executing sql . " + sql);
ps = connection.prepareStatement(sql);
final int count = ps.executeUpdate();
mLogger.log(Level.SEVERE, "Records updated are " + count);
sql = dbDataAccessObject.createQualifiedQuery(mTableName, mMoveRowToTableName,
mMarkColumnName, mMarkColumnValue, mPKName, "UPDATE", mFlagColumnType);
sql = sql + "=" + pkNameRet;
mLogger.log(Level.INFO, "Executing sql . " + sql);
ps = connection.prepareStatement(sql);
final int updatecount = ps.executeUpdate();
mLogger.log(Level.SEVERE, "Records updated are " + updatecount);
} else if (mPollingPostProcessing.equalsIgnoreCase("MoveRow")) {
sql = dbDataAccessObject.createQualifiedQuery(mTableName, mMoveRowToTableName,
mMarkColumnName, mMarkColumnValue, mPKName, "INSERT", mFlagColumnType);
sql = sql + "=" + pkNameRet;
mLogger.log(Level.INFO, "Executing sql . " + sql);
ps = connection.prepareStatement(sql);
final int count = ps.executeUpdate();
mLogger.log(Level.SEVERE, "Records updated are " + count);
sql = dbDataAccessObject.createQualifiedQuery(mTableName, mMoveRowToTableName,
mMarkColumnName, mMarkColumnValue, mPKName, "DELETE", mFlagColumnType);
sql = sql + "=" + pkNameRet;
mLogger.log(Level.INFO, "Executing sql . " + sql);
ps = connection.prepareStatement(sql);
final int delcount = ps.executeUpdate();
mLogger.log(Level.SEVERE, "Records deleted are:" + delcount);
} // else if
}
if (isTransacted && exchange instanceof InOnly) {
try {
// As we are the initiator for tx we have to commit
commitThreadTx(exchange);
} catch (Exception ex) {
// for in-only there's no sending of status back to nmr
// failure will be logged
mLogger.log(Level.WARNING, "SQLSE_E00657.IMP_COMMIT_FAILED",
new Object[] { ex.getLocalizedMessage() });
}
}
} catch (final SQLException ex) {
final String msg = InboundMessageProcessor.mMessages.getString("SQLSE_E00639.IMP_Failed_Executing_SQL")
+ sql;
mLogger.log(Level.SEVERE, msg, new Object[] {ex.getLocalizedMessage()});
if (isTransacted && exchange instanceof InOnly) {
try {
// As we are the initiator for tx we have to rollback
rollbackThreadTx(exchange);
} catch (Exception exception) {
mLogger.log(Level.SEVERE, mMessages.getString("SQLSE_E00653.IMP_XA_TX_ROLLBACK_FAILED"), exception);
}
}
} catch (final Exception ex) {
final String msg = InboundMessageProcessor.mMessages.getString("SQLSE_E00639.IMP_Failed_Executing_SQL");
mLogger.log(Level.SEVERE, msg, new Object[] {ex.getLocalizedMessage()});
if (isTransacted && exchange instanceof InOnly) {
try {
// As we are the initiator for tx we have to rollback
rollbackThreadTx(exchange);
} catch (Exception exception) {
mLogger.log(Level.SEVERE, mMessages.getString("SQLSE_E00653.IMP_XA_TX_ROLLBACK_FAILED"), exception);
}
}
}
} else {
mLogger.log(Level.SEVERE, "IMP_MXCH_BAD_STATUS", new Object[] { exchange.getStatus().toString(),
messageId });
if (isTransacted && exchange instanceof InOnly) {
try {
// As we are the initiator for tx we have to rollback
rollbackThreadTx(exchange);
} catch (Exception ex) {
// for in-only there's no sending of status back to nmr
mLogger.log(Level.SEVERE, mMessages.getString("SQLSE_E00653.IMP_XA_TX_ROLLBACK_FAILED"), ex);
}
}
}
if (mLogger.isLoggable(Level.INFO)) {
mLogger.log(Level.INFO, "SQLSE_E00648.IMP_Remove_exchange_msg_id", messageId);
}
} else {
mLogger.log(Level.SEVERE, "SQLSE_E00646.IMP_Invalid_reply_msgId", messageId);
}
} finally {
InboundMessageProcessor.mInboundExchanges.remove(messageId);
try {
if(ps != null) {
ps.close();
}
if(connection != null) {
connection.close();
}
} catch (final SQLException se) {
mLogger.log(Level.INFO, mMessages.getString("SQLSE_E00628.OMP_Cleanup_Failure"),se);
}
}
}
// suspend thread transactional context
private void resumeThreadTx(Transaction tx) throws Exception {
if (tx != null) {
((TransactionManager) mContext.getTransactionManager()).resume(tx);
mLogger.log(Level.INFO, " ", new Object[] { tx.toString() });
}
}
private void rollbackThreadTx(MessageExchange msgXChange) throws Exception {
if (msgXChange.isTransacted()) {
Transaction tx = (Transaction) msgXChange.getProperty(MessageExchange.JTA_TRANSACTION_PROPERTY_NAME);
if (tx != null) {
try {
tx.rollback();
} catch (Exception ex) {
mLogger.log(Level.SEVERE, "SQLSE_E00653.IMP_XA_TX_ROLLBACK_FAILED", new Object[] { ex.getLocalizedMessage() });
throw ex;
}
} else {
if (mXAEnabled.equalsIgnoreCase("XATransaction")) {
mLogger.log(Level.WARNING, "SQLSE_W00654.IMP_XA_TX_NOT_FOUND_IN_MSG_XCHANGE",
new Object[] { msgXChange.getExchangeId() });
}
}
}
}
private void commitThreadTx(MessageExchange msgXChange) throws Exception {
if (msgXChange.isTransacted()) {
Transaction tx = (Transaction) msgXChange.getProperty(MessageExchange.JTA_TRANSACTION_PROPERTY_NAME);
if (tx != null) {
try {
tx.commit();
} catch (Exception ex) {
mLogger.log(Level.SEVERE, "SQLSE_E00656.IMP_XA_TX_COMMIT_FAILED", new Object[] { "commit", ex });
throw ex;
}
} else {
if (mXAEnabled.equalsIgnoreCase("XATransaction")) {
mLogger.log(Level.WARNING, "SQLSE_W00654.IMP_XA_TX_NOT_FOUND_IN_MSG_XCHANGE",
new Object[] { msgXChange.getExchangeId() });
}
}
}
}
/**
* @param jndiName
* @return
* @throws javax.naming.NamingException
*/
private Object getDataSourceFromContext(final String jndiName) throws javax.naming.NamingException {
final Context c = mContext.getNamingContext();
return c.lookup(jndiName);
}
/**
* @param jndiName
* @return
* @throws Exception
*/
private Connection getDatabaseConnection(final String jndiName) throws SQLException, NamingException {
return ((DataSource) getDataSourceFromContext(jndiName)).getConnection();
}
/**
* @param prepStmtSQLText
* @return
*/
private boolean isSelectStatement(final String prepStmtSQLText) {
prepStmtSQLText.trim();
final StringTokenizer tok = new StringTokenizer(prepStmtSQLText);
if (tok.hasMoreTokens()) {
final String firstTok = (String) tok.nextToken();
if (firstTok.equalsIgnoreCase("select")) {
return true;
}
}
return false;
}
protected void stopReceiving() {
mLogger.log(Level.INFO, "SQLSE_R00644.IMP_Inbound_stopped");
mMonitor.set(Boolean.TRUE);
}
private TransactionManager getTransactionManager() {
return (TransactionManager)mContext.getTransactionManager();
}
public void setMessageExchangeId(String messageExchangeId, Object retryMetaData) {
exchangeIDToMeta.put(messageExchangeId, retryMetaData);
}
public void onRedelivery(MessageExchange exchange) throws MessagingException {
NormalizedMessage inMsg;
EndpointBean operationMetaData = (EndpointBean) exchangeIDToMeta.remove(exchange.getExchangeId());
String groupId = (String)exchange.getProperty(CRMP_GROUP_ID);
String messageId = (String)exchange.getProperty(CRMP_MESSAGE_ID);
// remove the listener associated with the exchange ID
MessageExchangeSupport.removeRedeliveryListener(exchange.getExchangeId());
try{
switch (ExchangePattern.valueOf(exchange)) {
case IN_OUT:
if (mLogger.isLoggable(Level.FINE)) {
mLogger.log(Level.FINE, "Resending the InOut exchange with group ID '"
+ groupId + "' and message ID '" + messageId + "'...");
}
inMsg = ((InOut)exchange).getInMessage();
InOut inout = mMsgExchangeFactory.createInOutExchange();
// make sure that the message id has is the same
inout.setProperty(CRMP_GROUP_ID, groupId);
inout.setProperty(CRMP_MESSAGE_ID, messageId);
//processInOut(inout, inMsg, operationMetaData);
processInOut(inout,operationMetaData);
break;
case IN_ONLY:
if (mLogger.isLoggable(Level.FINE)) {
mLogger.log(Level.FINE, "Resending the InOnly exchange with group ID '"
+ groupId + "' and message ID '" + messageId + "'...");
}
inMsg = ((InOnly)exchange).getInMessage();
InOnly inonly = mMsgExchangeFactory.createInOnlyExchange();
// make sure that the message id has is the same
inonly.setProperty(CRMP_GROUP_ID, groupId);
inonly.setProperty(CRMP_MESSAGE_ID, messageId);
//processInOnly(inonly, inMsg, operationMetaData);
processInOnly(inonly,operationMetaData);
break;
default:
if (mLogger.isLoggable(Level.FINE)) {
mLogger.log(Level.FINE, "Retry handler receives an unsupported exchange pattern: "
+ExchangePattern.valueOf(exchange) + ". Ignoring the retry attempt...");
}
break;
}
}catch(Exception e){
mLogger.log(Level.SEVERE, "Failed in retry handler",
e.getMessage());
throw new MessagingException(e);
}
}
}

View File

@ -1,336 +0,0 @@
/*
* 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]
*/
/*
* @(#)InboundReceiver.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc;
import com.sun.jbi.common.qos.messaging.MessagingChannel;
import com.sun.jbi.internationalization.Messages;
import com.sun.jbi.jdbcbc.extensions.JDBCOperationInput;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.jbi.component.ComponentContext;
import javax.jbi.messaging.*;
import javax.management.AttributeChangeNotification;
import javax.management.Notification;
import javax.management.NotificationListener;
import javax.wsdl.Binding;
import javax.wsdl.BindingInput;
import javax.wsdl.BindingOperation;
import javax.wsdl.Definition;
import javax.wsdl.Port;
import javax.wsdl.Service;
import javax.wsdl.extensions.ExtensibilityElement;
import javax.xml.namespace.QName;
/**
* Wait for responses/requests from the service engine and
* use thread pools to process them.
*
* Thir receiver not only processes "Inbound" requests initiated by the
* Service engine, but also responses to requests this adapter has sent the SE.
*/
class InboundReceiver {
private static final Messages mMessages = Messages.getMessages(InboundReceiver.class);
private static final Logger mLogger = Messages.getLogger(InboundReceiver.class);
// Pool settings for processing SE "Inbound" requests initated by the SE.
private int mInboundCorePoolSize;
private final int mInboundKeepAliveTime = 60 * 10;
private final TimeUnit mInboundTimeUnit = TimeUnit.SECONDS;
// By using an unbounded queue the max pool size becomes irrelevant
private final int mInboundMaxPoolSize = Integer.MAX_VALUE;
private ThreadPoolExecutor mInboundPooledExecutor;
private final MessagingChannel mChannel;
private final ComponentContext mContext;
// This is removed since never used
//private final Map mEndpoints;
private final Map<String,InboundMessageProcessor> mActivatedInboundMsgProcs;
/**
*
*/
private final NotificationListener listener = new NotificationListener() {
//@Override
public void handleNotification(Notification notification, Object obj) {
if (notification instanceof AttributeChangeNotification) {
AttributeChangeNotification attrNotif = (AttributeChangeNotification) notification;
String attrName = attrNotif.getAttributeName();
if (attrName.equals("Threads")) {
Integer newVal = (Integer) (attrNotif.getNewValue());
setThreads(newVal.intValue());
}
}
}
};
/**
* Construct a receiver for a given binding channel and the relevant endpoints
* @param bc the binding channel to receive from
* @param endpoints EndointBean instances with information about the endpoints
*/
protected InboundReceiver(final MessagingChannel bc, final Map endpoints,
final RuntimeConfiguration runtimeConfig, final ComponentContext context) {
mChannel = bc;
mContext = context;
// Apply existing configuration
final Integer threadCount = runtimeConfig.getThreads();
if (threadCount != null) {
setThreads(threadCount.intValue());
}
// Subscribe for changes to the configuration
runtimeConfig.addNotificationListener(listener, null, null);
mInboundPooledExecutor = new ThreadPoolExecutor(mInboundCorePoolSize,
mInboundMaxPoolSize, mInboundKeepAliveTime, mInboundTimeUnit,
new LinkedBlockingQueue(), Executors.privilegedThreadFactory());
mInboundPooledExecutor.prestartAllCoreThreads();
mActivatedInboundMsgProcs = Collections.synchronizedMap(new HashMap<String,InboundMessageProcessor>());
//mEndpoints = endpoints;
}
/**
* Construct a receiver for a given binding channel and the relevant endpoints
* @param bc the binding channel to receive from
* @param endpoints EndointBean instances with information about the endpoints
*/
/*public InboundReceiver(final DeliveryChannel bc, final Map endpoints,
final SQLSERuntimeConfiguration runtimeConfig, final ComponentContext context) {
mChannel = bc;
mContext = context;
// Apply existing configuration
final Integer threadCount = runtimeConfig.getThreads();
if (threadCount != null) {
setThreads(threadCount.intValue());
}
// Subscribe for changes to the configuration
runtimeConfig.addNotificationListener(listener, null, null);
mInboundPooledExecutor = new ThreadPoolExecutor(mInboundCorePoolSize,
mInboundMaxPoolSize, mInboundKeepAliveTime, mInboundTimeUnit,
new LinkedBlockingQueue(), Executors.privilegedThreadFactory());
mInboundPooledExecutor.prestartAllCoreThreads();
mActivatedInboundMsgProcs = Collections.synchronizedMap(new HashMap());
//mEndpoints = endpoints;
}*/
/**
* Main receiver loop to process replies and requests of SEs
*/
protected void addInboundMessageProcessor(final EndpointBean endpoint)
throws FaultException, MessagingException {
synchronized (mActivatedInboundMsgProcs) {
mLogger.log(Level.INFO, mMessages.getString("SQLSE_C00601.IR_Started"));
final Definition defwsdl = (Definition) endpoint.getValueObj(EndpointBean.DESCRIPTOR);
final String serviceName = endpoint.getValue(EndpointBean.SERVICE_NAME);
final String endpointName = endpoint.getValue(EndpointBean.ENDPOINT_NAME);
List jdbcOper = new ArrayList();
jdbcOper = getJDBCOperations(defwsdl, serviceName, endpointName);
for (final Iterator it = jdbcOper.iterator(); it.hasNext();) {
final QName opname = (QName) it.next();
final String key = endpointName + serviceName + opname.toString();
if (!mActivatedInboundMsgProcs.containsKey(key)) {
try {
final InboundMessageProcessor proc = new InboundMessageProcessor(mChannel,
endpoint, mContext, opname);
final Thread task = new Thread(proc);
task.start();
// Store the thread in the map
mActivatedInboundMsgProcs.put(key, proc);
} catch (final Exception e) {
mLogger.log(Level.INFO,mMessages.getString("SQLSE_E00602.IR_Exception") +
e.getMessage());
}
}
} // for
InboundReceiver.mLogger.log(Level.INFO, InboundReceiver.mMessages.getString("SQLSE_C00603.IR_Shutdown"));
}
}
/**
* Stops and removes the inbound message processor for each
* File binding operation per the given end point.
*
* @param endpoint A service end point.
*/
protected void removeInboundMessageProcessor(final EndpointBean endpoint) {
synchronized (mActivatedInboundMsgProcs) {
mLogger.log(Level.INFO, mMessages.getString("SQLSE_C00604.IR_Remove"));
final Definition defwsdl = (Definition) endpoint.getValueObj(EndpointBean.DESCRIPTOR);
final String serviceName = endpoint.getValue(EndpointBean.SERVICE_NAME);
final String endpointName = endpoint.getValue(EndpointBean.ENDPOINT_NAME);
List jdbcOper = new ArrayList();
jdbcOper = getJDBCOperations(defwsdl, serviceName, endpointName);
for (final Iterator it = jdbcOper.iterator(); it.hasNext();) {
final QName opname = (QName) it.next();
final String key = endpointName + serviceName + opname.toString();
if (mActivatedInboundMsgProcs.containsKey(key)) {
final InboundMessageProcessor proc = mActivatedInboundMsgProcs.get(key);
// Stop the inbound message processor thread
proc.stopReceiving();
// proc.deleteTableTigger(endpoint);
// Remove the thread from the map
mActivatedInboundMsgProcs.remove(key);
} // if
} // for
mLogger.log(Level.INFO, mMessages.getString("SQLSE_C00603.IR_Shutdown"));
}
}
/**
* Set the number or processing threads to use
*/
protected void setThreads(final int threadCount) {
mInboundCorePoolSize = threadCount;
if (mInboundPooledExecutor != null) {
mInboundPooledExecutor.setCorePoolSize(threadCount);
}
}
/**
* Stop the receiver thread.
*/
protected void stopReceiving() {
mLogger.log(Level.INFO, mMessages.getString("SQLSE_C00605.IR_Stop"));
}
/**
*
* @param def
* @param serviceName
* @param endpointName
* @return
*/
protected List<QName> getJDBCOperations(final Definition def, final String serviceName,
final String endpointName) {
final List<QName> jdbcOperations = new ArrayList<QName>();
JDBCOperationInput jdbcOperationInput = null;
final Binding binding = getBinding(def, serviceName, endpointName);
if (binding != null) {
final List bindingOperations = binding.getBindingOperations();
final Iterator extIter = (bindingOperations == null) ? null
: bindingOperations.iterator();
while ((extIter != null) && extIter.hasNext()) {
final BindingOperation oper = (BindingOperation) extIter.next();
jdbcOperationInput = getJDBCOperationInput(oper.getBindingInput());
if (jdbcOperationInput.getOperationType()
.equals(JDBCOperations.OPERATION_TYPE_POLL.toString())) {
jdbcOperations.add(QName.valueOf(oper.getName()));
}
}
}
return jdbcOperations;
}
/**
*
* @param def
* @param serviceName
* @param endpointName
* @return
*/
protected Binding getBinding(final Definition def, final String serviceName,
final String endpointName) {
final Service svc = def.getService(QName.valueOf(serviceName));
if (svc == null) {
return null;
}
final Port port = svc.getPort(QName.valueOf(endpointName).getLocalPart());
if (port == null) {
return null;
} else {
return port.getBinding();
}
}
/**
*
* @param bindingInput
* @return
*/
protected JDBCOperationInput getJDBCOperationInput(final BindingInput bindingInput) {
JDBCOperationInput operationInput = null;
final List extElems = bindingInput.getExtensibilityElements();
// Look for jdbc:input entries
final Iterator extIter = (extElems == null) ? null : extElems.iterator();
while ((extIter != null) && extIter.hasNext()) {
final ExtensibilityElement ee = (ExtensibilityElement) extIter.next();
if (JDBCOperationInput.class.isInstance(ee)) {
operationInput = (JDBCOperationInput) ee;
break;
}
}
return operationInput;
}
}

View File

@ -1,569 +0,0 @@
/*
* 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]
*/
/*
* @(#)JDBCBindingLifeCycle.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc;
import com.sun.jbi.configuration.RuntimeConfigurationHelper;
import com.sun.jbi.eManager.provider.StatusProviderHelper;
import com.sun.jbi.eManager.provider.StatusProviderMBean;
import com.sun.jbi.internationalization.Messages;
import org.w3c.dom.Document;
import org.w3c.dom.DocumentFragment;
import org.xml.sax.SAXException;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
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.component.ServiceUnitManager;
import javax.jbi.management.MBeanNames;
import javax.jbi.messaging.DeliveryChannel;
import javax.jbi.messaging.MessageExchange;
import javax.jbi.messaging.MessagingException;
import javax.jbi.servicedesc.ServiceEndpoint;
import javax.management.MBeanServer;
import javax.management.ObjectName;
import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.DocumentFragment;
import org.xml.sax.SAXException;
import com.sun.jbi.configuration.RuntimeConfigurationHelper;
import com.sun.jbi.eManager.provider.StatusProviderHelper;
import com.sun.jbi.eManager.provider.StatusProviderMBean;
import com.sun.jbi.internationalization.Messages;
import com.sun.jbi.common.qos.messaging.MessagingChannel;
import com.sun.jbi.common.qos.messaging.BaseMessagingChannel;
import com.sun.jbi.jdbcbc.util.AlertsUtil;
import com.sun.jbi.alerter.NotificationEvent;
/**
* BC life cycle implementation of the jbi framework
*
*/
public class JDBCBindingLifeCycle implements ComponentLifeCycle, Component {
private static final Messages mMessages = Messages.getMessages(JDBCBindingLifeCycle.class);
public static Logger mLogger = Messages.getLogger(JDBCBindingLifeCycle.class);
private static final Map<String,JDBCBindingLifeCycle> initializedLifeCycles = new HashMap<String,JDBCBindingLifeCycle>();
public static final String SHORT_DISPLAY_NAME = "JDBC BC";
private JDBCComponentContext mContext = JDBCComponentContext.getInstance();
private OutboundReceiver mOutboundReceiver;
private InboundReceiver mInboundReceiver;
private Thread mOutboundReceiverThread;
Map<String,EndpointBean> mEndpoints = new HashMap<String,EndpointBean>();
Map mEndpointMapping = new HashMap();
private ObjectName mExtensionMBeanName;
private MessagingChannel mChannel;
private ObjectName mDeployerMBeanName;
private JDBCBindingDeployer mDeployer;
private StatusProviderHelper mStatusProviderHelper;
private RuntimeConfiguration mRuntimeConfig;
private RuntimeConfigurationHelper mRuntimeConfigHelper;
public JDBCBindingLifeCycle() {
}
/**
*
* @return
*/
//@Override
public ComponentLifeCycle getLifeCycle() {
return this;
}
/**
*
* @return
*/
//@Override
public ServiceUnitManager getServiceUnitManager() {
return mDeployer;
}
/**
*
* @return
*/
private ObjectName getDeploymentMBeanName() {
return mDeployerMBeanName;
}
/**
*
* @return
*/
//@Override
public ObjectName getExtensionMBeanName() {
return mExtensionMBeanName;
}
/**
*
* @param jbiContext
* @throws JBIException
*/
//@Override
public void init(final ComponentContext jbiContext) throws JBIException {
if (jbiContext == null) {
throw new JBIException("Component Context is null");
}
mContext.setContext(jbiContext);
Messages.registerContext(jbiContext);
JDBCBindingLifeCycle.mLogger = Messages.getLogger(JDBCBindingLifeCycle.class);
JDBCBindingLifeCycle.initializedLifeCycles.put(mContext.getContext().getComponentName(), this);
final MBeanServer mbServer = jbiContext.getMBeanServer();
final MBeanNames mbnHndl = jbiContext.getMBeanNames();
mDeployer = new JDBCBindingDeployer(mContext.getContext(), this);
final String componentName = jbiContext.getComponentName();
try {
mStatusProviderHelper = new StatusProviderHelper(JDBCBindingLifeCycle.SHORT_DISPLAY_NAME,
StatusProviderMBean.COMPONENT_TYPE_BINDING,
jbiContext.getComponentName(), jbiContext.getMBeanServer());
mStatusProviderHelper.registerMBean();
if (JDBCBindingLifeCycle.mLogger.isLoggable(Level.INFO)) {
JDBCBindingLifeCycle.mLogger.log(Level.INFO, "SQLSE_R00102.JDBCBLC_Register_mbean", componentName);
}
} catch (final Exception ex) {
JDBCBindingLifeCycle.mLogger.log(Level.WARNING, "SQLSE_E00103.JDBCBLC_Failed_register_mbean", ex);
throw new JBIException(JDBCBindingLifeCycle.mMessages.getString(
"SQLSE_E00103.JDBCBLC_Failed_register_mbean"), ex);
}
try {
mRuntimeConfig = new RuntimeConfiguration(mContext.getContext().getWorkspaceRoot());
mRuntimeConfigHelper = new RuntimeConfigurationHelper(RuntimeConfigurationHelper.COMPONENT_TYPE_BINDING,
jbiContext.getComponentName(), jbiContext.getMBeanServer());
mRuntimeConfigHelper.registerMBean(mRuntimeConfig);
if (JDBCBindingLifeCycle.mLogger.isLoggable(Level.INFO)) {
JDBCBindingLifeCycle.mLogger.log(Level.INFO, "SQLSE_R00104.JDBCBLC_Register_config_mbean",
componentName);
}
} catch (final Exception ex) {
JDBCBindingLifeCycle.mLogger.log(Level.WARNING,
JDBCBindingLifeCycle.mMessages.getString("SQLSE_E00105.JDBCBLC_Failed_register_config_mbean"), ex);
throw new JBIException(JDBCBindingLifeCycle.mMessages.getString(
"SQLSE_E00105.JDBCBLC_Failed_register_config_mbean"), ex);
}
try {
//mChannel = mContext.getDeliveryChannel();
mChannel = new BaseMessagingChannel(mContext.getContext());
mContext.setBindingChannel(mChannel);
} catch(MessagingException me) {
String text = mMessages.getString("JDBCBC-E00141.No_binding_channel", me.getLocalizedMessage());
mLogger.log(Level.SEVERE, text, me);
AlertsUtil.getAlerter().critical(text,
JDBCBindingLifeCycle.SHORT_DISPLAY_NAME,
null,
AlertsUtil.getServerType(),
AlertsUtil.COMPONENT_TYPE_BINDING,
NotificationEvent.OPERATIONAL_STATE_RUNNING,
NotificationEvent.EVENT_TYPE_ALERT,
"JDBCBC-E00141");
throw me;
}
//try {
mChannel = mContext.getBindingChannel();
//} catch (final MessagingException me) {
// JDBCBindingLifeCycle.mLogger.log(Level.SEVERE, "SQLSE_E00106.JDBCBLC_No_Dev_Channel", me.getMessage());
// throw me;
//}
try {
startOutbound();
} catch (final Exception ex) {
JDBCBindingLifeCycle.mLogger.log(Level.SEVERE,
JDBCBindingLifeCycle.mMessages.getString("SQLSE_E00107.JDBCBLC_Failed_start_outbound",
ex.getMessage()), ex);
throw new JBIException(JDBCBindingLifeCycle.mMessages.getString(
"SQLSE_E00107.JDBCBLC_Failed_start_outbound", ex.getMessage()), ex);
}
try {
startInbound();
} catch (final Exception ex) {
JDBCBindingLifeCycle.mLogger.log(Level.SEVERE,
JDBCBindingLifeCycle.mMessages.getString("JDBCBLC_Failed_start_inbound",
ex.getMessage()), ex);
throw new JBIException(JDBCBindingLifeCycle.mMessages.getString(
"SQLSE_E00108.JDBCBLC_Failed_start_inbound", ex.getMessage()), ex);
}
}
/**
*
* @throws JBIException
*/
//@Override
public void shutDown() throws JBIException {
JDBCBindingLifeCycle.mLogger.info("SQLSE_R00109.JDBCBLC_Shutdown_JDBCBC");
try {
stopOutbound();
stopInbound();
} catch (final Exception ex) {
JDBCBindingLifeCycle.mLogger.log(Level.WARNING,
"Failed to stop the outbound receiver: " + ex.getMessage(), ex);
throw new JBIException("Failed to stop the outbound receiver: " +
ex.getMessage(), ex);
}
if (mChannel != null) {
mChannel.close();
}
try {
mStatusProviderHelper.unregisterMBean();
} catch (final Exception ex) {
JDBCBindingLifeCycle.mLogger.log(Level.WARNING,
JDBCBindingLifeCycle.mMessages.getString("SQLSE_E00110.JDBCBLC_Failed_stop_outbound",
ex.getMessage()), ex);
throw new JBIException(JDBCBindingLifeCycle.mMessages.getString(
"JDBCBLC_Failed_stop_outbound", ex.getMessage()), ex);
}
try {
mRuntimeConfigHelper.unregisterMBean();
} catch (final Exception ex) {
JDBCBindingLifeCycle.mLogger.log(Level.WARNING,
JDBCBindingLifeCycle.mMessages.getString("SQLSE_E00110.JDBCBLC_Failed_unregister_mbean",
mContext.getContext().getComponentName()), ex);
throw new JBIException(JDBCBindingLifeCycle.mMessages.getString(
"JDBCBLC_Failed_unregister_mbean",
mContext.getContext().getComponentName()), ex);
}
JDBCBindingLifeCycle.initializedLifeCycles.remove(mContext.getContext().getComponentName());
mLogger.log(Level.SEVERE,mMessages.getString("SQLSE_E00113.JDBCBLC_Failed_Complete_JDBCBC_shutdown"));
}
/**
*
* @throws JBIException
*/
//@Override
public void start() throws JBIException {
if (JDBCBindingLifeCycle.mLogger.isLoggable(Level.INFO)) {
JDBCBindingLifeCycle.mLogger.info("SQLSE_R00114.JDBCBLC_JDBCBC_started");
}
}
/**
*
* @throws JBIException
*/
//@Override
public void stop() throws JBIException {
if (JDBCBindingLifeCycle.mLogger.isLoggable(Level.INFO)) {
JDBCBindingLifeCycle.mLogger.info("SQLSE_R00118.JDBCBLC_stopped");
}
}
/**
*
* @param endpoint
* @param exchange
* @return
*/
//@Override
public boolean isExchangeWithConsumerOkay(final ServiceEndpoint endpoint,
final MessageExchange exchange) {
// TODO: check whether operation on endpoint actually exists.
return true;
}
/**
*
* @param endpoint
* @param exchange
* @return
*/
//@Override
public boolean isExchangeWithProviderOkay(final ServiceEndpoint endpoint,
final MessageExchange exchange) {
// In FileBC Currently no "inbound" is supported
return false;
}
/**
*
* @param endpoint
* @return
*/
//@Override
public Document getServiceDescription(final ServiceEndpoint endpoint) {
Document result = null;
// TODO: The document returned should be a stand-alone document (no imports or includes)
// TODO: consider whether it should only return the abstract wsdl concerning the endpoint
// TODO: Beware for service engines that they HAVE TO include a specific binding type defined for Service Engines
final String uniqueName = EndpointBean.getUniqueName(endpoint.getServiceName()
.toString(),
endpoint.getEndpointName(), EndpointBean.ENDPOINT_TYPE_OUTBOUND);
final DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
final DocumentBuilder documentBuilder = null;
final EndpointBean foundEndpoint = mEndpoints.get(uniqueName);
if (foundEndpoint == null) {
JDBCBindingLifeCycle.mLogger.info("Endpoint " + uniqueName +
" could not be located in this binding component.");
} else {
try {
final File matchedWSDL = (File) foundEndpoint.getValueObj(EndpointBean.WSDL_FILE);
result = documentBuilder.parse(matchedWSDL);
} catch (final SAXException ex) {
mLogger.log(Level.SEVERE,"Endpoint " + result +
"Cannot get the getServiceDescription Exception in SAXException",ex);
} catch (final IOException exIO) {
mLogger.log(Level.SEVERE,"Endpoint " + result +
"Cannot get the getServiceDescription Exception in IOException",exIO);
// throw exIO;
} catch (final Exception exception) {
mLogger.log(Level.SEVERE,"Endpoint " + result +
"Cannot get the getServiceDescription Exception in Exception",exception);
//throw exception;
}
}
return result;
}
/**
*
* @param fragment
* @return
*/
//@Override
public ServiceEndpoint resolveEndpointReference(final DocumentFragment fragment) {
// Currently we do not support dynamic endpoints
return null;
}
/**
*
* @return
*/
public StatusProviderHelper getStatusProviderHelper() {
return mStatusProviderHelper;
}
/**
*
* @param componentName
* @return
*/
public static JDBCBindingLifeCycle getInstanceForId(final String componentName) {
return JDBCBindingLifeCycle.initializedLifeCycles.get(componentName);
}
/**
*
* @return
*/
public MessagingChannel getMessagingChannel() {
return mChannel;
}
public DeliveryChannel getDeliveryChannel(){
return mContext.getBindingChannel();
}
/**
*
* @param context
* @return
*/
public EndpointBean getEndpointBeanForContext(final String context) {
return (EndpointBean) mEndpointMapping.get(context);
}
/**
*
* @param endpoints
* @throws MessagingException
* @throws java.lang.Exception
*/
public void activateEndpoints(final EndpointBean[] endpoints) throws MessagingException , Exception {
JDBCBindingLifeCycle.mLogger.info("Activating endpoints");
EndpointBean currEndpoint = null;
for (EndpointBean element : endpoints) {
currEndpoint = element;
final String uniqueName = currEndpoint.getUniqueName();
if(!mEndpoints.containsKey(uniqueName)) {
mEndpoints.put(uniqueName, currEndpoint);
} else {
throw new Exception( mMessages.getString("SQLSE_E00120.JDBCBLC_Failed_deploy_EndPoint"));
}
// mEndpoints.put(uniqueName, currEndpoint);
// For inbound endpoints, build an additional mapping from the URL
// context to the endpoint
if (currEndpoint.getValue(EndpointBean.ENDPOINT_TYPE)
.equals(EndpointBean.ENDPOINT_TYPE_INBOUND)) {
try {
mInboundReceiver.addInboundMessageProcessor(currEndpoint);
} catch (final FaultException ex) {
mLogger.log(Level.SEVERE, "SQLSE_R00137.SQLSELC_SU_Failed_start_inbound_EP",
uniqueName + " Reason " + ex.getMessage());
} catch (final JBIException me) {
mLogger.severe("Cannot activate endpoint " + uniqueName +
" Reason " + me.getMessage());
}
} else if (EndpointBean.ENDPOINT_TYPE_OUTBOUND.equals(
currEndpoint.getValue(EndpointBean.ENDPOINT_TYPE))) {
// Activate an outbound endpoint
try {
final QName fullServiceName = (QName) currEndpoint.getValueObj(EndpointBean.FULL_SERVICE_NAME);
final ServiceEndpoint endpointReference = mContext.getContext().activateEndpoint(fullServiceName,
currEndpoint.getValue(EndpointBean.ENDPOINT_NAME));
currEndpoint.setValueObj(EndpointBean.ENDPOINT_REFERENCE,
endpointReference);
if (mLogger.isLoggable(Level.INFO)) {
mLogger.log(Level.INFO,"INFO,SQLSE_R00319.SQLSESU_ENDPOINT_ACTIVATED",
uniqueName);
}
} catch (final JBIException me) {
mLogger.severe("Cannot activate endpoint " + uniqueName +
" Reason " + me.getMessage());
}
}
currEndpoint.setValue(EndpointBean.STATUS,
EndpointBean.STATUS_RUNNING);
}
mLogger.log(Level.INFO,mMessages.getString("SQLSE_R00319.SQLSESU_ENDPOINT_ACTIVATED"));
}
/**
*
* @param endpoints
* @throws MessagingException
*/
public void deactivateEndpoints(final EndpointBean[] endpoints)
throws MessagingException {
EndpointBean currEndpoint = null;
mLogger.info("Deactivating endpoints");
for (EndpointBean element : endpoints) {
currEndpoint = element;
final String uniqueName = currEndpoint.getUniqueName();
mEndpoints.remove(uniqueName);
if (currEndpoint.getValue(EndpointBean.ENDPOINT_TYPE)
.equals(EndpointBean.ENDPOINT_TYPE_INBOUND)) {
try {
final ServiceEndpoint endpointReference = (ServiceEndpoint) currEndpoint.getValueObj(EndpointBean.ENDPOINT_REFERENCE);
mContext.getContext().deactivateEndpoint(endpointReference);
} catch (final JBIException me) {
JDBCBindingLifeCycle.mLogger.severe("Cannot deactivate endpoint " + uniqueName +
" Reason " + me.getMessage());
}
mInboundReceiver.removeInboundMessageProcessor(currEndpoint);
} else {
try {
final ServiceEndpoint endpointReference = (ServiceEndpoint) currEndpoint.getValueObj(EndpointBean.ENDPOINT_REFERENCE);
mContext.getContext().deactivateEndpoint(endpointReference);
} catch (final JBIException me) {
mLogger.log(Level.SEVERE,"Cannot deactivate endpoint " + uniqueName +
" Reason " + me.getMessage());
}
}
currEndpoint.setValue(EndpointBean.STATUS,
EndpointBean.STATUS_STOPPED);
}
mLogger.log(Level.INFO,mMessages.getString("SQLSE_R00320.SQLSESU_ENDPOINT_DEACTIVATED"));
}
/**
*
* @throws JBIException
*/
public void startInbound() throws JBIException {
mInboundReceiver = new InboundReceiver(mChannel, mEndpoints,
mRuntimeConfig, mContext.getContext());
mLogger.log(Level.INFO,mMessages.getString("SQLSE_R00116.JDBCBLC_started_inbound"));
}
/**
*
* @throws JBIException
*/
public void startOutbound() throws JBIException {
mOutboundReceiver = new OutboundReceiver(mChannel, mEndpoints,
mRuntimeConfig, mContext);
mOutboundReceiverThread = new Thread(mOutboundReceiver);
mOutboundReceiverThread.start();
mLogger.log(Level.INFO,mMessages.getString("SQLSE_R00117.JDBCBLC_started_outbound"));
}
public void stopInbound() {
if (mInboundReceiver != null) {
mInboundReceiver.stopReceiving();
}
mLogger.log(Level.INFO,mMessages.getString("SQLSE_R00119.JDBCBLC_stopped_inbound"));
}
public void stopOutbound() {
if (mOutboundReceiver != null) {
mOutboundReceiver.stopReceiving();
}
mLogger.log(Level.INFO,mMessages.getString("SQLSE_R00118.JDBCBLC_stopped_outbound"));
}
}

View File

@ -1,98 +0,0 @@
/*
* 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]
*/
/*
* @(#)JDBCComponentContext.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc;
import com.sun.jbi.common.qos.messaging.MessagingChannel;
import javax.jbi.component.ComponentContext;
import javax.jbi.component.ComponentLifeCycle;
/**
* singleton used to share the component context within the http soap bc
*/
public class JDBCComponentContext {
private static JDBCComponentContext instance = new JDBCComponentContext();
private ComponentContext context;
private MessagingChannel channel;
private ComponentLifeCycle lifeCycle;
/** Creates a new instance of HttpSoapComponentContext */
private JDBCComponentContext() {
}
public static JDBCComponentContext getInstance() {
return instance;
}
public ComponentContext getContext() {
return context;
}
public void setContext(ComponentContext context) {
this.context = context;
}
/**
* @return the component lifecycle associated with this context
* if it has been initialized
*/
public ComponentLifeCycle getAssociatedLifeCycle() {
return lifeCycle;
}
/**
* Set the component lifecycle associated with this context
*/
public void setAssociatedLifeCycle(ComponentLifeCycle aLifeCycle) {
lifeCycle = aLifeCycle;
}
/**
* @return Obtain the channel associated with this context
* if it has been initialized
*/
public MessagingChannel getBindingChannel() {
return channel;
}
/**
* Set the initizalied channel associated with this context
*/
public void setBindingChannel(MessagingChannel aChannel) {
channel = aChannel;
}
}

View File

@ -1,835 +0,0 @@
/*
* 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]
*/
/*
* @(#)JDBCDenormalizer.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc;
import java.io.StringWriter;
import java.sql.CallableStatement;
import java.sql.DatabaseMetaData;
import java.sql.ParameterMetaData;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import com.sun.jbi.jdbcbc.model.metadata.DBMetaData;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
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.Part;
import javax.xml.namespace.QName;
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.DOMResult;
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 com.ibm.wsdl.util.xml.DOMUtils;
import com.sun.jbi.internationalization.Messages;
import com.sun.jbi.jdbcbc.extensions.JDBCOperationInput;
import com.sun.jbi.nms.wsdl11wrapper.HelperFactory;
import com.sun.jbi.nms.wsdl11wrapper.WrapperParser;
import java.io.InputStream;
import java.io.Reader;
import java.util.Scanner;
import javax.xml.transform.stream.StreamSource;
/**
*
* JDBCDenormalizer
*
*/
public class JDBCDenormalizer {
private static final Messages mMessages = Messages.getMessages(JDBCDenormalizer.class);
private static final Logger mLogger = Messages.getLogger(JDBCDenormalizer.class);
private String dbName=null;
private String catalog=null;
private ArrayList outParamIndex = new ArrayList();
private HashMap<Integer,String> outParamTypes = new HashMap<Integer,String>();
private HashMap<Integer,String> outParamNames = new HashMap<Integer,String>();
private String mRecordPrefix = null; //113494
/**
*
* @param normalizedMessage
* @param opMetaData
* @param ps
* @throws MessagingException
*/
protected void denormalizeOutbound(final NormalizedMessage normalizedMessage,
final OperationMetaData opMetaData, final PreparedStatement ps)
throws MessagingException {
if (opMetaData != null) {
final JDBCOperationInput mJdbcOperationInput = opMetaData.getJDBCOperationInput();
final String operationType = mJdbcOperationInput.getOperationType();
if (JDBCUtil.opList.contains(operationType)) {
try {
Element element = transformMessage(normalizedMessage,opMetaData);
if (element != null) {
populatePreparedStatement(element,opMetaData,ps);
}
} catch (final SQLException ex) {
final String msg = JDBCDenormalizer.mMessages.getString("SQLSE_E00709.JDBCDN_FailedPopulate_PS");
throw new MessagingException(msg, ex);
} catch (final Exception ex) {
final String msg = JDBCDenormalizer.mMessages.getString("SQLSE_E00709.JDBCDN_FailedPopulate_PS");
throw new MessagingException(msg, ex);
}
}
}
}
/**
*
* @param normalizedMessage
* @param opMetaData
* @param dbmeta
* @param cs
* @throws MessagingException
*/
protected void denormalizeOutboundProc(final NormalizedMessage normalizedMessage,
final OperationMetaData opMetaData, final DatabaseMetaData dbmeta,final CallableStatement cs)
throws MessagingException {
if (opMetaData != null) {
final JDBCOperationInput mJdbcOperationInput = opMetaData.getJDBCOperationInput();
final String operationType = mJdbcOperationInput.getOperationType();
if (JDBCUtil.dbOperations[JDBCUtil.dbOperations.length-1].equals(operationType)) {
try {
Element element = transformMessage(normalizedMessage,opMetaData);
if (element != null) {
populateProcedure(element, opMetaData,dbmeta,cs);
//registerOutParameters(cs, dbmeta);
}
} catch (final SQLException ex) {
final String msg = JDBCDenormalizer.mMessages.getString(
"SQLSE_E00711.JDBCDN_FailedPopulate_Proc");
throw new MessagingException(msg, ex);
} catch (final Throwable th) {
final String msg = JDBCDenormalizer.mMessages.getString("SQLSE_E00712.JDBCDN_Failed_Proc");
throw new MessagingException(msg, th);
}
}
}
}
/**
*
* @param tableElem
* @param opMetaData
* @param cs
* @throws SQLException
* @throws MessagingException
* @throws Exception
*/
@SuppressWarnings("empty-statement")
private void populateProcedure(final Element tableElem,
final OperationMetaData opMetaData, final DatabaseMetaData dbmeta,CallableStatement cs)
throws SQLException, MessagingException, Exception {
final JDBCOperationInput jdbcSql = opMetaData.getJDBCSql();
String sqltext = jdbcSql.getSql();
String procName = getProcName(sqltext);
String pcatalog = "";
String pschema = "";
if(dbName != null) {
pschema = dbName;
}
if(catalog!=null){
pcatalog = catalog;
}
ResultSet rs = null;
if (jdbcSql != null) {
try {
rs = dbmeta.getProcedureColumns(pcatalog, pschema, procName, "%");;
} catch (final SQLException ex) {
mLogger.log(Level.WARNING, "Could not get Procedure Columns from DBMetaData", ex);
}
if (rs != null) {
int i = 0;
while(rs.next()) {
// set default type.
int targetSqlType = java.sql.Types.VARCHAR;
final String columnName = rs.getString("COLUMN_NAME");
targetSqlType = rs.getInt("DATA_TYPE");
int colType = rs.getShort("COLUMN_TYPE");
String type_Name = rs.getString("TYPE_NAME");
final int columnNumber = i + 1;
if ( colType == DatabaseMetaData.procedureColumnIn) {
if ((targetSqlType == 1111) && (type_Name.equals("PL/SQL TABLE"))) {
targetSqlType = -14;
}
if ((targetSqlType == 1111) && (type_Name.equals("PL/SQL RECORD"))) {
targetSqlType = -14;
}
final Element columnElem = findMatchingColumnElement(columnName,
tableElem, mRecordPrefix); //113494
if (columnElem != null) {
final String value = DOMUtils.getChildCharacterData(columnElem);
if ((value != null) && !value.trim().equals("")) {
cs.setObject(columnNumber,
JDBCUtil.convert(value, targetSqlType), targetSqlType);
}else {
cs.setNull(columnNumber,targetSqlType);
}
}//end of if
}//end of if
if (colType == DatabaseMetaData.procedureColumnInOut || colType == DatabaseMetaData.procedureColumnOut) {
try {
// if the parameter is a cursor type, add its index to the arraylist
if ((targetSqlType == 1111) && (type_Name.equals("REF CURSOR"))) {
targetSqlType = -10;
}
cs.registerOutParameter(columnNumber, targetSqlType);
outParamIndex.add(Integer.valueOf(Double.valueOf(columnNumber).intValue()));
outParamTypes.put(columnNumber, type_Name);
outParamNames.put(columnNumber, columnName);
} catch(SQLException e) {
System.out.println(e.getMessage());
e.printStackTrace();
//throw e;
}
}
// check if the parameter is RETURN type (i.e. it is a function)
if (colType == DatabaseMetaData.procedureColumnReturn) {
try {
// if the parameter is a cursor type, add its index to the arraylist
if ((targetSqlType == 1111) && (type_Name.equals("REF CURSOR"))) {
targetSqlType = -10;
}
cs.registerOutParameter(columnNumber, targetSqlType);
outParamIndex.add(Integer.valueOf(Double.valueOf(columnNumber).intValue()));
outParamTypes.put(columnNumber, type_Name);
outParamNames.put(columnNumber, columnName);
} catch(SQLException e) {
System.out.println(e.getMessage());
e.printStackTrace();
//throw e;
}
}
i++;
}//end of While
}// end of If
}
}
/**
*
* @param tableElem
* @param opMetaData
* @param ps
* @throws SQLException
* @throws MessagingException
* @throws Exception
*/
private void populatePreparedStatement(final Element tableElem,
final OperationMetaData opMetaData, final PreparedStatement ps)
throws SQLException, MessagingException, Exception {
final JDBCOperationInput jdbcSql = opMetaData.getJDBCSql();
if (jdbcSql != null) {
ParameterMetaData paramMetaData = null;
try {
paramMetaData = ps.getParameterMetaData();
} catch (final SQLException ex) {
ex.printStackTrace();
}
//113494 start
mRecordPrefix = opMetaData.getJDBCSql().getTableName();
// see if the table name is null (SQL SE)
// then take the query name as the prefix
if (mRecordPrefix == null) {
mRecordPrefix = opMetaData.getJDBCOperationOutput().getName();
mRecordPrefix = mRecordPrefix.substring(0, mRecordPrefix.indexOf("Response"));
}
//113494 end
if (paramMetaData != null) {
final int parameters = paramMetaData.getParameterCount();
if (parameters != 0) {// If there are no parameter we do not need to set anything
// on Prepared statement
String paramOrder = jdbcSql.getParamOrder();
// changed for SQLSE since the user cannot enter param
// ordering in sqlprojects.
// we should generate a default param ordering.
if (paramOrder == null) {
paramOrder = getDefaultParameterOrderString(paramMetaData);
}
final List columns = extractColumns(paramOrder);
if (columns.size() == parameters) {
for (int i = 0; i < parameters; i++) {
final String columnName = (String) columns.get(i);
final int columnNumber = i + 1;
final Element columnElement = findMatchingColumnElement(
columnName, tableElem, mRecordPrefix); //113494 Issue
if (columnElement != null) {
final String value = DOMUtils
.getChildCharacterData(columnElement);
if ((value != null) && !value.trim().equals("")) {
// set default type.
int columnType = java.sql.Types.VARCHAR;
try {
columnType = paramMetaData
.getParameterType(columnNumber);
} catch (final SQLException e) {
mLogger.log(Level.WARNING, "Driver Does not support getting the Parameter Metadata", e);
}
ps.setObject(columnNumber, JDBCUtil
.convert(value, columnType),
columnType);
}else{
// set default type.
int columnType = java.sql.Types.VARCHAR;
try {
columnType = paramMetaData
.getParameterType(columnNumber);
} catch (final SQLException e) {
mLogger.log(Level.WARNING, "Driver Does not support getting the Datatypes", e);
}
ps.setNull(columnNumber,columnType);
}
}
}
} else {
final String msg = JDBCDenormalizer.mMessages
.getString("SQLSE_E00714.JDBCDN_Failed_PS_Param");
throw new MessagingException(msg);
}
}
}
}
}
/**
*
* @param dbColumnName
* @param tableElem
* @return
*/
private Element findMatchingColumnElement(final String dbColumnName,
final Element tableElem, String recordPrefix) { // 113494 Issue
Element columnElem = null;
NodeList childNodes = tableElem.getChildNodes();
for (int i = 0; i < childNodes.getLength(); i++) {
final Node child = childNodes.item(i);
///////////////////////////////////
if ((child instanceof Element) &&
child.getLocalName().equalsIgnoreCase(recordPrefix + "_Record")) { // 113494 Issue
columnElem = (Element) child;
childNodes = columnElem.getChildNodes();
}
///////////////////////////////////
}
for (int i = 0; i < childNodes.getLength(); i++) {
final Node child = childNodes.item(i);
if ((child instanceof Element) &&
child.getLocalName().equalsIgnoreCase(dbColumnName)) {
columnElem = (Element) child;
break;
}
}
return columnElem;
}
/**
*
* @param paramOrder
* @return
*/
private List<String> extractColumns(final String paramOrder) {
final List<String> columnList = new ArrayList<String>();
if (paramOrder != null) {
final Scanner tok = new Scanner(paramOrder).useDelimiter("\\s*" + "," + "\\s*");
while (tok.hasNext()) {
final String column = tok.next();
columnList.add(column.trim());
}
}
return columnList;
}
/**
*
* @param parent
* @param msgQName
* @return
*/
private Element findChildElement(final Element parent, final QName msgQName) {
final String ns = msgQName.getNamespaceURI();
final String localName = msgQName.getLocalPart();
NodeList nl = null;
if ((ns != null) && !ns.trim().equals("")) {
nl = parent.getElementsByTagNameNS(ns, localName);
} else {
nl = parent.getElementsByTagName(localName);
}
if ((nl != null) && (nl.getLength() > 0)) {
if (JDBCDenormalizer.mLogger.isLoggable(Level.INFO)) {
JDBCDenormalizer.mLogger.log(Level.INFO, "found element with name, " +
localName);
}
final Element e2 = (Element) nl.item(0);
return e2;
}
return null;
}
/**
*
* @param root
* @param elemName
* @return
*/
private Element findPart(final Element root, final String elemName) {
// parts wrappers never have namespace
final NodeList nl = root.getElementsByTagName(elemName);
if ((nl != null) && (nl.getLength() > 0)) {
if (JDBCDenormalizer.mLogger.isLoggable(Level.INFO)) {
JDBCDenormalizer.mLogger.log(Level.INFO, "found element with name, " + elemName);
}
final Element e2 = (Element) nl.item(0);
return e2;
}
return null;
}
/**
** Used by SQLSE to get the default parameter ordering.
* @param pmeta
* @return
*/
private String getDefaultParameterOrderString(final ParameterMetaData pmeta) {
String parameterOrderString = null;
int numParams = 0;
if (pmeta != null) {
try {
numParams = pmeta.getParameterCount();
} catch (final SQLException sqle) {
JDBCDenormalizer.mLogger.log(Level.WARNING,
JDBCDenormalizer.mMessages.getString("JDBCDN_Failed_ParamCount"));
return null;
}
if (numParams > 0) {
for (int i = 1; i <= numParams; i++) {
final String paramname = "param" + String.valueOf(i);
parameterOrderString = (parameterOrderString == null)
? paramname : (parameterOrderString + "," + paramname);
}
}
}
return parameterOrderString;
}
//register out parameters
private void registerOutParameters(CallableStatement cstmt, final DatabaseMetaData dbmeta)
throws SQLException, NullPointerException {
String errMsg = "";
int colCount = 0;
boolean isFunction = false;
boolean hasParameters = true;
// indicates if the procedure is within a package or standalone
boolean isPackaged = true;
ArrayList paramIndices = new ArrayList();
ArrayList result = new ArrayList();
int paramIndex=0;
try {
ParameterMetaData pmeta = cstmt.getParameterMetaData();
if (pmeta != null) {
int numParams = pmeta.getParameterCount();
if (numParams > 0) {
// get info for each parameter
for (int i = 1; i <= numParams; i++) {
// try to get the sql type info - default to VARCHAR
String sqlType = "VARCHAR";
try {
sqlType = DBMetaData.getSQLTypeDescription(pmeta.getParameterType(i));
} catch (SQLException e) {
mLogger.log(Level.WARNING, "Could not get SQL Type Description from DBMetadata", e);
}
// try to get the java type info - default to String
/**
* Changing it to not use metadata class name and instead use the HashMap SQLTOJAVATYPES.
* Without the change the parameter datatypes java.lang.Double and WSDLGenerator look up list
* exepects native type double, float, short etc.
**/
String javaType = "java.lang.String";
javaType = DBMetaData.getJavaFromSQLTypeDescription(sqlType);
// added abey for Procedure ResultSet
try{
if((pmeta.getParameterType(i)==java.sql.Types.OTHER)&&(pmeta.getParameterTypeName(i).equalsIgnoreCase("REF CURSOR"))){
sqlType = "RESULTSET";
javaType = "java.sql.ResultSet";
}
}catch (SQLException e) {
mLogger.log(Level.WARNING, "Could not get Java type information from DBMetadata", e);
}
// try to get the param type, default to IN
// always default it since getParameterMode() in data direct 3.3 throws exception
// and 3.4 return UNKNOWN type
String paramType = "IN";
try {
paramType = DBMetaData.getPrepStmtParamTypeDescription(pmeta.getParameterMode((i)));
} catch (SQLException e) {
mLogger.log(Level.WARNING, "Could not get PreparedStatement Parameter Description", e);
}
// set defalut type
int sqlTypeCode = java.sql.Types.VARCHAR;
if (paramType.equalsIgnoreCase("INOUT") || paramType.equalsIgnoreCase("OUT")) {
try {
// if the parameter is a cursor type, add its index to the arraylist
if ((pmeta.getParameterType(i) == 1111) && (paramType.equals("OTHER"))) {
sqlTypeCode = java.sql.Types.OTHER;
}
} catch(SQLException e) {
mLogger.log(Level.WARNING, "Driver Does not support getting the Datatypes", e);
}
}
if (paramType.equals("RETURN")) {
try {
// if the parameter is a cursor type, add its index to the arraylist
if ((pmeta.getParameterType(i) == 1111) && (paramType.equals("OTHER"))) {
//sqlTypeCode = java.sql.Types.OTHER;
}
} catch(SQLException e) {
mLogger.log(Level.WARNING, "Driver Does not support getting the Datatypes", e);
}
}
cstmt.registerOutParameter(paramIndex, sqlTypeCode);
outParamIndex.add(Integer.valueOf(Double.valueOf(paramIndex).intValue()));
}
}
}
}catch(SQLException e) {
mLogger.log(Level.WARNING, "Could not get Parameter MetaData", e);
}
}
/*
private String getProcName(String sqlText) {
String proc_name = "";
String schema = "";
final Scanner tok = new Scanner(sqlText).useDelimiter("\\s*" + " " + "\\s*");
while (tok.hasNext()) {
String column = tok.next();
int cnt = 0;
column=column.toLowerCase();
if(column.endsWith("call")){
cnt++;
proc_name=tok.next();
if(proc_name.contains(".")){
final Scanner tok1 = new Scanner(proc_name).useDelimiter("\\s*" + "." + "\\s*");
schema=tok1.next();
proc_name=tok1.next();
}
if(proc_name.contains("(")){
int i = proc_name.indexOf("(");
proc_name=proc_name.substring(0, i);
}
if(proc_name.contains("}")){
int i = proc_name.indexOf("}");
proc_name=proc_name.substring(0, i);
}
}
if(cnt>0)
break;
}
return proc_name;
}
*/
private String getProcName(String sqlText) {
String proc_name = "";
String schema = "";
final StringTokenizer tok = new StringTokenizer(sqlText, " ");
while (tok.hasMoreElements()) {
String column = (String) tok.nextElement();
int cnt = 0;
column=column.toLowerCase();
if(column.endsWith("call")){
cnt++;
proc_name=(String)tok.nextElement();
if(proc_name.contains(".")){
final StringTokenizer tok1 = new StringTokenizer(proc_name, ".");
catalog=tok1.nextToken();
proc_name=tok1.nextToken();
}
if(proc_name.contains("(")){
int i = proc_name.indexOf("(");
proc_name=proc_name.substring(0, i);
}
if(proc_name.contains("}")){
int i = proc_name.indexOf("}");
proc_name=proc_name.substring(0, i);
}
}
if(cnt>0)
break;
}
return proc_name;
}
private final Element transformMessage(final NormalizedMessage normalizedMessage,
final OperationMetaData opMetaData) throws MessagingException{
Element element = null;
try {
final TransformerFactory tFactory = TransformerFactory.newInstance();
final Transformer trans = tFactory.newTransformer();
final Source source = normalizedMessage.getContent();
final DOMResult result = new DOMResult();
trans.transform(source, result);
if (source instanceof StreamSource) {
StreamSource stream = (StreamSource) source;
InputStream inputStream = stream.getInputStream();
if (inputStream != null) {
inputStream.reset();
}
Reader reader = stream.getReader();
if (reader != null) {
reader.reset();
}
}
final Node node = result.getNode();
final StringWriter strWriter = new StringWriter();
final StreamResult sResult = new StreamResult(strWriter);
trans.transform(source, sResult);
if (source instanceof StreamSource) {
StreamSource stream = (StreamSource) source;
InputStream inputStream = stream.getInputStream();
if (inputStream != null) {
inputStream.reset();
}
Reader reader = stream.getReader();
if (reader != null) {
reader.reset();
}
}
if (node != null) {
Document normalDoc = null;
if (node instanceof Document) {
normalDoc = (Document) node;
} else {
normalDoc = ((Element) node).getOwnerDocument();
}
final Element normalRoot = normalDoc.getDocumentElement();
//final BindingOperation bindingOperation = opMetaData.getBindingOperation();
final Operation operation = opMetaData.getOperation();
final Input input = operation.getInput();
final Message inputMessage = input.getMessage();
if (HelperFactory.WRAPPER_ENABLED) {
final WrapperParser wrapperParser = HelperFactory.createParser();
wrapperParser.parse(normalDoc, inputMessage);
final Map parts = inputMessage.getParts();
final Iterator it = parts.values().iterator();
while (it.hasNext()) {
final Part part = (Part) it.next();
if (wrapperParser.hasPart(part.getName())) {
final QName elementQName = part.getElementName();
if (elementQName == null) {
final String msgEx = JDBCDenormalizer.mMessages.getString(
"SQLSE_E00706.JDBCDN_Failed_Denormalize") +
part.getName() +
"should have element attribute defined.";
throw new MessagingException(msgEx);
}
//Element element = null;
final NodeList unwrappedList = wrapperParser.getPartNodes(part.getName());
for (int j = 0;
j < unwrappedList.getLength();
j++) {
final Node unwrapped = unwrappedList.item(j);
if ((unwrapped.getNodeType() == Node.ELEMENT_NODE) &&
(unwrapped.getLocalName() != null) &&
unwrapped.getLocalName()
.equals(elementQName.getLocalPart())) {
element = (Element) unwrapped;
break;
}
}
/*if (element != null) {
populateProcedure(element, opMetaData,
dbmeta,cs);
//registerOutParameters(cs);
} else {
final String msgEx = JDBCDenormalizer.mMessages.getString(
"JDBCDN_Failed_Finding_Node") +
elementQName.getLocalPart() +
", in the part wrapper";
JDBCDenormalizer.mLogger.log(Level.WARNING, msgEx);
throw new MessagingException(msgEx);
}*/
}
}
} else {
final Element messageElement = normalRoot;
if (messageElement != null) {
final Map parts = inputMessage.getParts();
final Iterator it = parts.values().iterator();
while (it.hasNext()) {
final Part part = (Part) it.next();
final Element partElement = findPart(messageElement,
part.getName());
if (partElement != null) {
final QName elementQName = part.getElementName();
if (elementQName != null) {
element = findChildElement(partElement,
elementQName);
/*if (element != null) {
populateProcedure(element,
opMetaData, dbmeta,cs);
//registerOutParameters(cs);
}*/
}
}
}
}
}
}
} catch (final TransformerConfigurationException ex) {
final String msg = JDBCDenormalizer.mMessages.getString("SQLSE_E00708.JDBCDN_Failed_Convert_NM");
throw new MessagingException(msg, ex);
} catch (final TransformerException ex) {
final String msg = JDBCDenormalizer.mMessages.getString("SQLSE_E00708.JDBCDN_Failed_Convert_NM");
throw new MessagingException(msg, ex);
} catch (final Throwable th) {
final String msg = JDBCDenormalizer.mMessages.getString("SQLSE_E00712.JDBCDN_Failed_Proc");
throw new MessagingException(msg, th);
}
return element;
}
protected void setDatabaseName(String databaseName){
dbName = databaseName;
}
protected ArrayList getOutParamIndex(){
return outParamIndex;
}
protected HashMap getOutParamTypes(){
return outParamTypes;
}
protected HashMap getOutParamNames(){
return outParamNames;
}
}

View File

@ -1,969 +0,0 @@
/*
* 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]
*/
/*
* @(#)JDBCNormalizer.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.CallableStatement;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.jbi.messaging.MessageExchange;
import javax.jbi.messaging.MessagingException;
import javax.jbi.messaging.NormalizedMessage;
import javax.wsdl.Input;
import javax.wsdl.Message;
import javax.wsdl.Output;
import javax.wsdl.Part;
import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.*;
import javax.xml.transform.dom.DOMSource;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Text;
import com.sun.jbi.internationalization.Messages;
import com.sun.jbi.jdbcbc.extensions.JDBCConstants;
import com.sun.jbi.jdbcbc.extensions.JDBCOperationInput;
import com.sun.jbi.jdbcbc.extensions.JDBCOperationOutput;
import com.sun.jbi.jdbcbc.model.metadata.DBMetaData;
import com.sun.jbi.nms.wsdl11wrapper.HelperFactory;
import com.sun.jbi.nms.wsdl11wrapper.WrapperBuilder;
import com.sun.jbi.nms.wsdl11wrapper.WrapperProcessingException;
import com.sun.jbi.jdbcbc.util.XMLCharUtil;
import com.sun.jbi.jdbcbc.model.metadata.DBMetaData;
/**
*
* To change the template for this generated type comment go to
* Window - Preferences - Java - Code Generation - Code and Comments
*/
public class JDBCNormalizer {
private static final Messages mMessages = Messages.getMessages(JDBCNormalizer.class);
private static final Logger mLogger = Messages.getLogger(JDBCNormalizer.class);
private static DocumentBuilder mBuilder = null;
private WrapperBuilder wrapperBuilder;
private ArrayList outParamIndex = new ArrayList();
private HashMap<Integer,String> outParamTypes = new HashMap<Integer,String>();
private HashMap<Integer,String> outParamNames = new HashMap<Integer,String>();
private String mRecordPrefix = null; //113494
/** Creates a new instance of SoapNormalizer
* @throws javax.jbi.messaging.MessagingException
*/
public JDBCNormalizer() throws MessagingException {
try {
wrapperBuilder = HelperFactory.createBuilder();
} catch (final WrapperProcessingException ex) {
throw new MessagingException(JDBCNormalizer.mMessages.getString(
"SQLSE_E00701.JDBCN_Failed_Create") + ex.getMessage(), ex);
}
}
/**
*
* @param rowsUpdated
* @param exchange
* @param meta
* @return
* @throws MessagingException
*/
public NormalizedMessage normalize(final int rowsUpdated,
final MessageExchange exchange, final OperationMetaData meta)
throws MessagingException {
final NormalizedMessage normalMsg = exchange.createMessage();
try {
Document normalDoc = JDBCNormalizer.newDocument();
String returnPartName = null;
final JDBCOperationOutput jdbcOpOutput = meta.getJDBCOperationOutput();
if (jdbcOpOutput != null) {
returnPartName = jdbcOpOutput.getReturnPartName();
if (returnPartName == null) {
final String msgEx = JDBCNormalizer.mMessages.getString("SQLSE_E00702.JDBCN_Failed_NM") +
"missing " + JDBCOperationOutput.ATTR_RETURN_PART_NAME +
" attribute in " +
JDBCConstants.QNAME_OPERATION_OUTPUT;
throw new MessagingException(msgEx);
}
} else {
final String msgEx = JDBCNormalizer.mMessages.getString("SQLSE_E00702.JDBCN_Failed_NM") +
"missing " + JDBCConstants.QNAME_OPERATION_OUTPUT;
throw new MessagingException(msgEx);
}
if (HelperFactory.WRAPPER_ENABLED) {
String operationOutputName = null;
Message msg = null;
final Output output = meta.getOperation().getOutput();
if (output != null) {
operationOutputName = output.getName();
msg = output.getMessage();
if (msg != null) {
wrapperBuilder.initialize(normalDoc, msg,
operationOutputName);
final Part part = msg.getPart(returnPartName);
if (part != null) {
final Element returnPartElement = normalDoc.createElement(returnPartName);
final Text text = normalDoc.createTextNode("" +
rowsUpdated);
final QName type = part.getTypeName();
{
if (type != null) {
returnPartElement.appendChild(text);
wrapperBuilder.addPart(part.getName(), returnPartElement);
} else {
final QName element = part.getElementName();
final Element elementRoot = normalDoc.createElementNS(element.getNamespaceURI(), element.getLocalPart());
returnPartElement.appendChild(elementRoot);
elementRoot.appendChild(text);
wrapperBuilder.addPart(part.getName(), elementRoot);
}
normalDoc = wrapperBuilder.getResult();
}
} else {
final String msgEx = JDBCNormalizer.mMessages.getString(
"SQLSE_E00703.JDBCN_Failed_NM_Part") + returnPartName +
"in message " + msg.getQName();
throw new MessagingException(msgEx);
}
} else {
final String msgEx = JDBCNormalizer.mMessages.getString(
"SQLSE_E00704.JDBCN_Failed_NM_WS_OPER") +
meta.getOperation().getName() +
" is missing message in its <output>";
throw new MessagingException(msgEx);
}
} else {
final String msgEx = JDBCNormalizer.mMessages.getString(
"SQLSE_E00704.JDBCN_Failed_NM_WS_OPER") +
meta.getOperation().getName() +
" is missing <output> ";
throw new MessagingException(msgEx);
}
} else {
final String operationName = meta.getBindingOperation().getName();
final Element normalRoot = normalDoc.createElement(operationName);
normalDoc.appendChild(normalRoot);
if (returnPartName != null) {
final Element returnElement = normalDoc.createElement(returnPartName);
final Text text = normalDoc.createTextNode("" + rowsUpdated);
returnElement.appendChild(text);
normalRoot.appendChild(returnElement);
}
}
if (JDBCNormalizer.mLogger.isLoggable(Level.INFO)) {
JDBCNormalizer.mLogger.log(Level.INFO, "normalized message", normalDoc);
}
normalMsg.setContent(new DOMSource(normalDoc));
} catch (final ParserConfigurationException tex) {
final String msg = JDBCNormalizer.mMessages.getString("SQLSE_E00705.JDBCN_Failed_NM_DOM");
throw new MessagingException(msg, tex);
} catch (final WrapperProcessingException ex) {
final String exMsg = JDBCNormalizer.mMessages.getString("SQLSE_E00702.JDBCN_Failed_NM") +
ex.getMessage();
throw new MessagingException(exMsg, ex);
}
return normalMsg;
}
/**
*
* @param rs
* @param exchange
* @param meta
* @param epb
* @param pkName
* @return
* @throws MessagingException
* @throws SQLException
* @throws ParserConfigurationException
* @throws TransformerConfigurationException
* @throws TransformerException
*/
public NormalizedMessage normalizeSelectInbound(final ResultSet rs,
final MessageExchange exchange, final OperationMetaData meta, final EndpointBean epb,
final String pkName)
throws MessagingException, SQLException, ParserConfigurationException,
TransformerConfigurationException, TransformerException {
final NormalizedMessage normalMsg = exchange.createMessage();
//113494 start
mRecordPrefix = meta.getJDBCSql().getTableName();
// see if the table name is null (SQL SE)
// then take the query name as the prefix
if (mRecordPrefix == null) {
mRecordPrefix = meta.getJDBCOperationOutput().getName();
mRecordPrefix = mRecordPrefix.substring(0, mRecordPrefix.indexOf("Response"));
}
//113494 end
try {
Document normalDoc = JDBCNormalizer.newDocument();
String returnPartName = null;
String NS = "";
int numberOfRecords = meta.getJDBCOperationInput()
.getNumberOfRecords();
QName elementQName = null;
final JDBCOperationInput jdbcOpInput = meta.getJDBCOperationInput();
if (jdbcOpInput == null) {
final String msgEx = JDBCNormalizer.mMessages.getString("SQLSE_E00702.JDBCN_Failed_NM") +
"missing " + JDBCConstants.QNAME_OPERATION_OUTPUT;
throw new MessagingException(msgEx);
}
if (HelperFactory.WRAPPER_ENABLED) {
String operationInputName = null;
Message msg = null;
final Input input = meta.getOperation().getInput();
if (input != null) {
operationInputName = input.getName();
msg = input.getMessage();
/* Adding for inbound */
final Map parts = msg.getParts();
final Iterator it = parts.values().iterator();
while (it.hasNext()) {
final Part part = (Part) it.next();
elementQName = part.getElementName();
if (elementQName == null) {
final String msgEx = JDBCNormalizer.mMessages.getString(
"SQLSE_E00703.JDBCN_Failed_NM_Part") + part.getName() +
"should have element attribute defined.";
throw new MessagingException(msgEx);
}
// } //while
returnPartName = elementQName.getLocalPart();
if (returnPartName == null) {
final String msgEx = JDBCNormalizer.mMessages.getString(
"SQLSE_E00702.JDBCN_Failed_NM") + "missing "// +
// JDBCOperationInput.ATTR_RETURN_PART_NAME
// + " attribute in "
+ JDBCConstants.QNAME_OPERATION_INPUT;
throw new MessagingException(msgEx);
}
/* End of inbound */
if (msg != null) {
wrapperBuilder.initialize(normalDoc, msg,
operationInputName);
// Part part = msg.getPart(returnPartName);
if (part != null) {
final Element returnPartElement = normalDoc.createElement(returnPartName);
final QName type = part.getTypeName();
{
if (type != null) {
// get resultset metadata rsmd and add it to the element
final ResultSetMetaData rsmd = rs.getMetaData();
if (numberOfRecords == -1) {
while (rs.next()) {
final Element record = normalDoc.createElement(mRecordPrefix + "record"); //113494
for (int j = 1; j <= rsmd.getColumnCount(); j++) {
final String colName = rsmd.getColumnName(j);
final String colValue = rs.getString(j);
final Element e = normalDoc.createElement(XMLCharUtil.makeValidNCName(colName));
e.appendChild(normalDoc.createTextNode(colValue));
record.appendChild(e);
}
returnPartElement.appendChild(record);
}
} else {
while (rs.next() && (numberOfRecords > 0)) {
final Element record = normalDoc.createElement(mRecordPrefix + "record"); //113494
for (int j = 1; j <= rsmd.getColumnCount(); j++) {
final String colName = rsmd.getColumnName(j);
String colValue = rs.getString(j);
if (rs.wasNull()) {
colValue = "";
}
final Element e = normalDoc.createElement(XMLCharUtil.makeValidNCName(colName));
e.appendChild(normalDoc.createTextNode(colValue));
record.appendChild(e);
}
returnPartElement.appendChild(record);
numberOfRecords--;
}
}
wrapperBuilder.addPart(part.getName(), returnPartElement);
} else {
final QName element = part.getElementName();
NS = element.getNamespaceURI();
final Element elementRoot = normalDoc.createElementNS(NS, element.getLocalPart());
// returnPartElement.appendChild(elementRoot);
// get resultset metadata rsmd and add it to the element
final ResultSetMetaData rsmd = rs.getMetaData();
final List<String> pKeyList = new ArrayList<String>();
if (numberOfRecords == -1) {
while (rs.next()) {
final Element record = normalDoc.createElementNS(NS,mRecordPrefix + "record"); //113494
for (int j = 1; j <= rsmd.getColumnCount(); j++) {
final String colName = rsmd.getColumnName(j);
final String colValue = rs.getString(j);
if (colName.equalsIgnoreCase(pkName) || ("\"" + colName + "\"").equalsIgnoreCase(pkName)) {
pKeyList.add(colValue);
}
final Element e = normalDoc.createElementNS(NS, XMLCharUtil.makeValidNCName(colName));
e.appendChild(normalDoc.createTextNode(colValue));
record.appendChild(e);
}
elementRoot.appendChild(record);
}
} else {
while (rs.next() && (numberOfRecords > 0)) {
final Element record = normalDoc.createElementNS(NS,mRecordPrefix + "record"); //113494
for (int j = 1; j <= rsmd.getColumnCount(); j++) {
final String colName = rsmd.getColumnName(j);
String colValue = rs.getString(j);
if (colName.equalsIgnoreCase(pkName) || ("\"" + colName + "\"").equalsIgnoreCase(pkName)) {
pKeyList.add(colValue);
}
final Element e = normalDoc.createElementNS(NS, XMLCharUtil.makeValidNCName(colName));
e.appendChild(normalDoc.createTextNode(colValue));
record.appendChild(e);
}
elementRoot.appendChild(record);
numberOfRecords--;
}
} //else
epb.setProcessList(pKeyList);
wrapperBuilder.addPart(part.getName(), elementRoot);
}
normalDoc = wrapperBuilder.getResult();
}
} else {
final String msgEx = JDBCNormalizer.mMessages.getString(
"SQLSE_E00703.JDBCN_Failed_NM_Part") +
returnPartName + "in message " +
msg.getQName();
throw new MessagingException(msgEx);
}
} else {
final String msgEx = JDBCNormalizer.mMessages.getString(
"SQLSE_E00704.JDBCN_Failed_NM_WS_OPER") +
meta.getOperation().getName() +
" is missing message in its <output>";
throw new MessagingException(msgEx);
}
} // while
} // if(input)
else {
final String msgEx = JDBCNormalizer.mMessages.getString(
"SQLSE_E00704.JDBCN_Failed_NM_WS_OPER") +
meta.getOperation().getName() +
" is missing <output> ";
throw new MessagingException(msgEx);
}
} else {
final String operationName = meta.getBindingOperation().getName();
final Element normalRoot = normalDoc.createElement(operationName);
normalDoc.appendChild(normalRoot);
if (returnPartName != null) {
final Element returnElement = normalDoc.createElement(returnPartName);
// get resultset metadata rsmd and add it to the element
final ResultSetMetaData rsmd = rs.getMetaData();
if (numberOfRecords == -1) {
while (rs.next()) {
final Element record = normalDoc.createElement(mRecordPrefix + "record"); //113494
for (int j = 1; j <= rsmd.getColumnCount(); j++) {
final String colName = rsmd.getColumnName(j);
final String colValue = rs.getString(j);
final Element e = normalDoc.createElement(XMLCharUtil.makeValidNCName(colName));
e.appendChild(normalDoc.createTextNode(colValue));
record.appendChild(e);
}
returnElement.appendChild(record);
}
} else {
while (rs.next() && (numberOfRecords > 0)) {
final Element record = normalDoc.createElement(mRecordPrefix + "record"); //113494
for (int j = 1; j <= rsmd.getColumnCount(); j++) {
final String colName = rsmd.getColumnName(j);
String colValue = rs.getString(j);
if (rs.wasNull()) {
colValue = "";
}
final Element e = normalDoc.createElement(XMLCharUtil.makeValidNCName(colName));
e.appendChild(normalDoc.createTextNode(colValue));
record.appendChild(e);
}
returnElement.appendChild(record);
numberOfRecords--;
}
}
normalRoot.appendChild(returnElement);
}
}
if (JDBCNormalizer.mLogger.isLoggable(Level.INFO)) {
JDBCNormalizer.mLogger.log(Level.INFO, "normalized message", normalDoc);
}
normalMsg.setContent(new DOMSource(normalDoc));
} catch (final ParserConfigurationException tex) {
final String msg = JDBCNormalizer.mMessages.getString("SQLSE_E00705.JDBCN_Failed_NM_DOM");
throw new MessagingException(msg, tex);
} catch (final WrapperProcessingException ex) {
final String exMsg = JDBCNormalizer.mMessages.getString("SQLSE_E00703.JDBCN_Failed_NM_Part") +
ex.getMessage();
throw new MessagingException(exMsg, ex);
}
return normalMsg;
}
/**
*
* @param rs
* @param exchange
* @param meta
* @return
* @throws MessagingException
* @throws SQLException
* @throws ParserConfigurationException
* @throws TransformerConfigurationException
* @throws TransformerException
*/
public NormalizedMessage normalizeSelect(final ResultSet rs,
final MessageExchange exchange, final OperationMetaData meta)
throws MessagingException, SQLException, ParserConfigurationException,
TransformerConfigurationException, TransformerException {
final NormalizedMessage normalMsg = exchange.createMessage();
try {
Document normalDoc = JDBCNormalizer.newDocument();
String returnPartName = null;
String NS = "";
int numberOfRecords = meta.getJDBCOperationInput()
.getNumberOfRecords();
final JDBCOperationOutput jdbcOpOutput = meta.getJDBCOperationOutput();
//113494 start
mRecordPrefix = meta.getJDBCSql().getTableName();
// see if the table name is null (SQL SE)
// then take the query name as the prefix
if (mRecordPrefix == null) {
mRecordPrefix = meta.getJDBCOperationOutput().getName();
mRecordPrefix = mRecordPrefix.substring(0, mRecordPrefix.indexOf("Response"));
}
//113494 end
if (jdbcOpOutput != null) {
returnPartName = jdbcOpOutput.getReturnPartName();
if (returnPartName == null) {
final String msgEx = JDBCNormalizer.mMessages.getString("SQLSE_E00702.JDBCN_Failed_NM") +
"missing " + JDBCOperationOutput.ATTR_RETURN_PART_NAME +
" attribute in " +
JDBCConstants.QNAME_OPERATION_OUTPUT;
throw new MessagingException(msgEx);
}
} else {
final String msgEx = JDBCNormalizer.mMessages.getString("SQLSE_E00702.JDBCN_Failed_NM") +
"missing " + JDBCConstants.QNAME_OPERATION_OUTPUT;
throw new MessagingException(msgEx);
}
if (HelperFactory.WRAPPER_ENABLED) {
String operationOutputName = null;
Message msg = null;
final Output output = meta.getOperation().getOutput();
if (output != null) {
operationOutputName = output.getName();
msg = output.getMessage();
if (msg != null) {
wrapperBuilder.initialize(normalDoc, msg,
operationOutputName);
final Part part = msg.getPart(returnPartName);
if (part != null) {
final Element returnPartElement = normalDoc.createElement(returnPartName);
final QName type = part.getTypeName();
{
if (type != null) {
// get resultset metadata rsmd and add it to the
// element
final ResultSetMetaData rsmd = rs.getMetaData();
if (numberOfRecords == -1) {
while (rs.next()) {
final Element record = normalDoc.createElement(mRecordPrefix + "_Record"); //113494
for (int j = 1; j <= rsmd.getColumnCount(); j++) {
final String colName = rsmd.getColumnName(j);
final String colValue = rs.getString(j);
final Element e = normalDoc.createElement(XMLCharUtil.makeValidNCName(colName));
e.appendChild(normalDoc.createTextNode(colValue));
record.appendChild(e);
}
returnPartElement.appendChild(record);
}
} else {
while (rs.next() && (numberOfRecords > 0)) {
final Element record = normalDoc.createElement(mRecordPrefix + "_Record"); //113494
for (int j = 1; j <= rsmd.getColumnCount(); j++) {
final String colName = rsmd.getColumnName(j);
String colValue = rs.getString(j);
if (rs.wasNull()) {
colValue = "";
}
final Element e = normalDoc.createElement(XMLCharUtil.makeValidNCName(colName));
e.appendChild(normalDoc.createTextNode(colValue));
record.appendChild(e);
}
returnPartElement.appendChild(record);
numberOfRecords--;
}
}
wrapperBuilder.addPart(part.getName(), returnPartElement);
} else {
final QName element = part.getElementName();
NS = element.getNamespaceURI();
final Element elementRoot = normalDoc.createElementNS(NS, element.getLocalPart());
// returnPartElement.appendChild(elementRoot);
// get resultset metadata rsmd and add it to the element
final ResultSetMetaData rsmd = rs.getMetaData();
if (numberOfRecords == -1) {
while (rs.next()) {
final Element record = normalDoc.createElementNS(NS,mRecordPrefix + "_Record"); //113494
for (int j = 1; j <= rsmd.getColumnCount(); j++) {
final String colName = rsmd.getColumnName(j);
String colValue = rs.getString(j);
if (rs.wasNull()) {
colValue = "";
}
final Element e = normalDoc.createElementNS(NS, XMLCharUtil.makeValidNCName(colName));
e.appendChild(normalDoc.createTextNode(colValue));
record.appendChild(e);
}
elementRoot.appendChild(record);
}
} else {
while (rs.next() && (numberOfRecords > 0)) {
final Element record = normalDoc.createElementNS(NS,mRecordPrefix + "_Record"); //113494
for (int j = 1; j <= rsmd.getColumnCount(); j++) {
final String colName = rsmd.getColumnName(j);
String colValue = rs.getString(j);
if (rs.wasNull()) {
colValue = "";
}
final Element e = normalDoc.createElementNS(NS, XMLCharUtil.makeValidNCName(colName));
e.appendChild(normalDoc.createTextNode(colValue));
record.appendChild(e);
}
elementRoot.appendChild(record);
numberOfRecords--;
}
}
wrapperBuilder.addPart(part.getName(), elementRoot);
}
normalDoc = wrapperBuilder.getResult();
}
} else {
final String msgEx = JDBCNormalizer.mMessages.getString(
"SQLSE_E00703.JDBCN_Failed_NM_Part") + returnPartName +
"in message " + msg.getQName();
throw new MessagingException(msgEx);
}
} else {
final String msgEx = JDBCNormalizer.mMessages.getString(
"SQLSE_E00704.JDBCN_Failed_NM_WS_OPER") +
meta.getOperation().getName() +
" is missing message in its <output>";
throw new MessagingException(msgEx);
}
} else {
final String msgEx = JDBCNormalizer.mMessages.getString(
"SQLSE_E00704.JDBCN_Failed_NM_WS_OPER") +
meta.getOperation().getName() +
" is missing <output> ";
throw new MessagingException(msgEx);
}
} else {
final String operationName = meta.getBindingOperation().getName();
final Element normalRoot = normalDoc.createElement(operationName);
normalDoc.appendChild(normalRoot);
if (returnPartName != null) {
final Element returnElement = normalDoc.createElement(returnPartName);
// get resultset metadata rsmd and add it to the element
final ResultSetMetaData rsmd = rs.getMetaData();
if (numberOfRecords == -1) {
while (rs.next()) {
final Element record = normalDoc.createElement(mRecordPrefix + "_Record"); //113494
for (int j = 1; j <= rsmd.getColumnCount(); j++) {
final String colName = rsmd.getColumnName(j);
String colValue = rs.getString(j);
if (rs.wasNull()) {
colValue = "";
}
final Element e = normalDoc.createElement(XMLCharUtil.makeValidNCName(colName));
e.appendChild(normalDoc.createTextNode(colValue));
record.appendChild(e);
}
returnElement.appendChild(record);
}
} else {
while (rs.next() && (numberOfRecords > 0)) {
final Element record = normalDoc.createElement("record");
for (int j = 1; j <= rsmd.getColumnCount(); j++) {
final String colName = rsmd.getColumnName(j);
String colValue = rs.getString(j);
if (rs.wasNull()) {
colValue = "";
}
final Element e = normalDoc.createElement(XMLCharUtil.makeValidNCName(colName));
e.appendChild(normalDoc.createTextNode(colValue));
record.appendChild(e);
}
returnElement.appendChild(record);
numberOfRecords--;
}
}
normalRoot.appendChild(returnElement);
}
}
if (JDBCNormalizer.mLogger.isLoggable(Level.INFO)) {
JDBCNormalizer.mLogger.log(Level.INFO, "normalized message", normalDoc);
}
normalMsg.setContent(new DOMSource(normalDoc));
} catch (final ParserConfigurationException tex) {
final String msg = JDBCNormalizer.mMessages.getString("SQLSE_E00704.JDBCN_Failed_NM_WS_OPER");
throw new MessagingException(msg, tex);
} catch (final WrapperProcessingException ex) {
final String exMsg = JDBCNormalizer.mMessages.getString("SQLSE_E00702.JDBCN_Failed_NM") +
ex.getMessage();
throw new MessagingException(exMsg, ex);
}
return normalMsg;
}
/**
* @param cs
* @param exchange
* @param meta
* @return
* @throws MessagingException
* @throws SQLException
* @throws ParserConfigurationException
* @throws TransformerConfigurationException
* @throws TransformerException
*/
public NormalizedMessage normalizeProcedure(final CallableStatement cs,
final MessageExchange exchange, final OperationMetaData meta)
throws MessagingException, SQLException, ParserConfigurationException,
TransformerConfigurationException, TransformerException {
final NormalizedMessage normalMsg = exchange.createMessage();
try {
Document normalDoc = JDBCNormalizer.newDocument();
String returnPartName = null;
String NS = "";
int numberOfRecords = meta.getJDBCOperationInput()
.getNumberOfRecords();
final JDBCOperationOutput jdbcOpOutput = meta.getJDBCOperationOutput();
if (jdbcOpOutput != null) {
returnPartName = jdbcOpOutput.getReturnPartName();
if (returnPartName == null) {
final String msgEx = JDBCNormalizer.mMessages.getString("SQLSE_E00702.JDBCN_Failed_NM") +
"missing " + JDBCOperationOutput.ATTR_RETURN_PART_NAME +
" attribute in " +
JDBCConstants.QNAME_OPERATION_OUTPUT;
throw new MessagingException(msgEx);
}
} else {
final String msgEx = JDBCNormalizer.mMessages.getString("SQLSE_E00702.JDBCN_Failed_NM") +
"missing " + JDBCConstants.QNAME_OPERATION_OUTPUT;
throw new MessagingException(msgEx);
}
if (HelperFactory.WRAPPER_ENABLED) {
String operationOutputName = null;
Message msg = null;
final Output output = meta.getOperation().getOutput();
if (output != null) {
operationOutputName = output.getName();
msg = output.getMessage();
if (msg != null) {
wrapperBuilder.initialize(normalDoc, msg,
operationOutputName);
final Part part = msg.getPart(returnPartName);
if (part != null) {
final Element returnPartElement = normalDoc.createElement(returnPartName);
final QName type = part.getTypeName();
{
if (type != null) {
// get resultset metadata rsmd and add it to the
// element
for(int i =0; i < outParamIndex.size();i++) {
int paramIndex = (Integer)outParamIndex.get(i);
String paramType = outParamTypes.get(paramIndex);
String paramName = outParamNames.get(paramIndex);
if(paramType.equalsIgnoreCase("REF CURSOR") || paramType.equalsIgnoreCase("RESULTSET")){
ResultSet rs = (ResultSet)cs.getObject(paramIndex);
final ResultSetMetaData rsmd = rs.getMetaData();
while (rs.next()) {
for (int j = 1; j <= rsmd.getColumnCount(); j++) {
final String colName = rsmd.getColumnName(j);
final String colValue = rs.getString(j);
final Element e = normalDoc.createElement(colName);
e.appendChild(normalDoc.createTextNode(colValue));
returnPartElement.appendChild(e);
}
}
} else{
Object paramValue = cs.getObject(paramIndex);
final Element e = normalDoc.createElement(paramName);
e.appendChild(normalDoc.createTextNode(paramValue.toString()));
returnPartElement.appendChild(e);
}
}
wrapperBuilder.addPart(part.getName(), returnPartElement);
} else {
final QName element = part.getElementName();
NS = element.getNamespaceURI();
final Element elementRoot = normalDoc.createElementNS(NS, element.getLocalPart());
// returnPartElement.appendChild(elementRoot);
// get resultset metadata rsmd and add it to the element
for(int i =0; i < outParamIndex.size();i++) {
int paramIndex = (Integer)outParamIndex.get(i);
String paramType = outParamTypes.get(paramIndex);
String paramName = outParamNames.get(paramIndex);
if(paramType.equalsIgnoreCase("REF CURSOR") || paramType.equalsIgnoreCase("RESULTSET")){
ResultSet rs = (ResultSet)cs.getObject(paramIndex);
final ResultSetMetaData rsmd = rs.getMetaData();
while (rs.next()) {
for (int j = 1; j <= rsmd.getColumnCount(); j++) {
final String colName = rsmd.getColumnName(j);
String colValue = rs.getString(j);
if (rs.wasNull()) {
colValue = "";
}
final Element e = normalDoc.createElementNS(NS, colName);
e.appendChild(normalDoc.createTextNode(colValue));
elementRoot.appendChild(e);
}
}
}else{
Object paramValue = cs.getObject(paramIndex);
final Element e = normalDoc.createElement(paramName);
e.appendChild(normalDoc.createTextNode(paramValue.toString()));
returnPartElement.appendChild(e);
}
}
wrapperBuilder.addPart(part.getName(), elementRoot);
}
normalDoc = wrapperBuilder.getResult();
}
} else {
final String msgEx = JDBCNormalizer.mMessages.getString(
"SQLSE_E00703.JDBCN_Failed_NM_Part") + returnPartName +
"in message " + msg.getQName();
throw new MessagingException(msgEx);
}
} else {
final String msgEx = JDBCNormalizer.mMessages.getString(
"SQLSE_E00704.JDBCN_Failed_NM_WS_OPER") +
meta.getOperation().getName() +
" is missing message in its <output>";
throw new MessagingException(msgEx);
}
} else {
final String msgEx = JDBCNormalizer.mMessages.getString(
"SQLSE_E00704.JDBCN_Failed_NM_WS_OPER") +
meta.getOperation().getName() +
" is missing <output> ";
throw new MessagingException(msgEx);
}
} else {
final String operationName = meta.getBindingOperation().getName();
final Element normalRoot = normalDoc.createElement(operationName);
normalDoc.appendChild(normalRoot);
if (returnPartName != null) {
final Element returnElement = normalDoc.createElement(returnPartName);
// get resultset metadata rsmd and add it to the element
for(int i =0; i < outParamIndex.size();i++) {
int paramIndex = (Integer)outParamIndex.get(i);
String paramType = outParamTypes.get(paramIndex);
String paramName = outParamNames.get(paramIndex);
if(paramType.equalsIgnoreCase("REF CURSOR") || paramType.equalsIgnoreCase("RESULTSET")){
ResultSet rs = (ResultSet)cs.getObject(paramIndex);
final ResultSetMetaData rsmd = rs.getMetaData();
while (rs.next()) {
for (int j = 1; j <= rsmd.getColumnCount(); j++) {
final String colName = rsmd.getColumnName(j);
String colValue = rs.getString(j);
if (rs.wasNull()) {
colValue = "";
}
final Element e = normalDoc.createElement(colName);
e.appendChild(normalDoc.createTextNode(colValue));
returnElement.appendChild(e);
}
}
}else{
Object paramValue = cs.getObject(paramIndex);
final Element e = normalDoc.createElement(paramName);
e.appendChild(normalDoc.createTextNode(paramValue.toString()));
returnElement.appendChild(e);
}
}
normalRoot.appendChild(returnElement);
}
}
if (JDBCNormalizer.mLogger.isLoggable(Level.INFO)) {
JDBCNormalizer.mLogger.log(Level.INFO, "normalized message", normalDoc);
}
normalMsg.setContent(new DOMSource(normalDoc));
} catch (final ParserConfigurationException tex) {
final String msg = JDBCNormalizer.mMessages.getString("SQLSE_E00704.JDBCN_Failed_NM_WS_OPER");
throw new MessagingException(msg, tex);
} catch (final WrapperProcessingException ex) {
final String exMsg = JDBCNormalizer.mMessages.getString("SQLSE_E00702.JDBCN_Failed_NM") +
ex.getMessage();
throw new MessagingException(exMsg, ex);
}
return normalMsg;
}
/**
*
* @return
* @throws ParserConfigurationException
*/
private static final Document newDocument() throws ParserConfigurationException {
if (JDBCNormalizer.mBuilder == null) {
final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
JDBCNormalizer.mBuilder = factory.newDocumentBuilder();
}
return JDBCNormalizer.mBuilder.newDocument();
}
protected void setOutParamIndex( ArrayList outParamIndex){
this.outParamIndex = outParamIndex;
}
protected void setOutParamTypes(HashMap outParamTypes ){
this.outParamTypes = outParamTypes;
}
protected void setOutParamNames(HashMap outParamNames){
this.outParamNames = outParamNames;
}
}

View File

@ -1,88 +0,0 @@
/*
* JDBCOperations.java
*
* Created on Sep 25, 2007, 5:56:33 PM
*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.sun.jbi.jdbcbc;
/**
*
* @author narayana rallabandi
*/
public enum JDBCOperations {
OPERATION_TYPE_INSERT,OPERATION_TYPE_UPDATE,OPERATION_TYPE_DELETE,OPERATION_TYPE_SELECT,
OPERATION_TYPE_CREATE,OPERATION_TYPE_FIND,OPERATION_TYPE_POLL,OPERATION_TYPE_ALTER,
OPERATION_TYPE_DROP,OPERATION_TYPE_TRUNCATE,OPERATION_TYPE_EXECUTE;
@Override
public String toString(){
String operation = null;
switch(this){
case OPERATION_TYPE_INSERT:
return "insert";
case OPERATION_TYPE_UPDATE:
return "update";
case OPERATION_TYPE_DELETE:
return "delete";
case OPERATION_TYPE_SELECT:
return "select";
case OPERATION_TYPE_CREATE:
return "create";
case OPERATION_TYPE_FIND:
return "find";
case OPERATION_TYPE_POLL:
return "poll";
case OPERATION_TYPE_ALTER:
return "alter";
case OPERATION_TYPE_DROP:
return "drop";
case OPERATION_TYPE_TRUNCATE:
return "truncate";
case OPERATION_TYPE_EXECUTE:
return "execute";
default:
return operation;
}
}
public static final JDBCOperations getJDBCOperations(String opName){
if(opName.equalsIgnoreCase("insert"))
return OPERATION_TYPE_INSERT;
if(opName.equalsIgnoreCase("update"))
return OPERATION_TYPE_UPDATE;
if(opName.equalsIgnoreCase("delete"))
return OPERATION_TYPE_DELETE;
if(opName.equalsIgnoreCase("select"))
return OPERATION_TYPE_SELECT;
if(opName.equalsIgnoreCase("create"))
return OPERATION_TYPE_CREATE;
if(opName.equalsIgnoreCase("find"))
return OPERATION_TYPE_FIND;
if(opName.equalsIgnoreCase("poll"))
return OPERATION_TYPE_POLL;
if(opName.equalsIgnoreCase("drop"))
return OPERATION_TYPE_DROP;
if(opName.equalsIgnoreCase("truncate"))
return OPERATION_TYPE_TRUNCATE;
else
return OPERATION_TYPE_EXECUTE;
//return null;
}
public static final String getOpType(String sqlText){
String[] st = sqlText.split("\\s");
return st[0];
}
public static void main(String[] args){
//JDBCOperations jdbcops = new JDBCOperations();
System.out.print(JDBCOperations.valueOf("OPERATION_TYPE_ALTER"));//.getJDBCOperations("alter"));
System.out.println("\n\n"+JDBCOperations.OPERATION_TYPE_ALTER.toString());
System.out.println("\n\n"+JDBCOperations.OPERATION_TYPE_UPDATE.toString().equals("update"));
}
}

View File

@ -1,163 +0,0 @@
/*
* 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]
*/
/*
* @(#)JDBCUtil.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc;
import java.math.BigDecimal;
import java.sql.Date;
import java.sql.Timestamp;
import java.sql.Types;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.sun.jbi.internationalization.Messages;
import java.util.Arrays;
import java.util.List;
/**
*
* To change the template for this generated type comment go to
* Window - Preferences - Java - Code Generation - Code and Comments
*/
public class JDBCUtil {
private static final Messages mMessages = Messages.getMessages(JDBCUtil.class);
private static final Logger mLogger = Messages.getLogger(JDBCUtil.class);
public static final String[] dbOperations = {"insert","INSERT","update","UPDATE","delete","DELETE","select","SELECT","create","CREATE",
"find","FIND","poll","POLL","drop","DROP","truncate","TRUNCATE","execute","EXECUTE"};
public static final List<String> opList = Arrays.asList(dbOperations);
/**
*
* @param value
* @param jdbcType
* @return
* @throws Exception
*/
static Object convert(final String value, final int jdbcType)
throws Exception {
Object convertedVal = null;
try {
switch (jdbcType) {
case Types.BIGINT:
convertedVal = Long.valueOf(value);
break;
case Types.BIT:
convertedVal = Boolean.valueOf(value);
break;
case Types.BOOLEAN:
convertedVal = Boolean.valueOf(value);
break;
case Types.DATE:
convertedVal = Date.valueOf(value);
break;
case Types.DISTINCT:
convertedVal = Date.valueOf(value);
break;
case Types.DOUBLE:
convertedVal = Double.valueOf(value);
break;
case Types.DECIMAL:
case Types.NUMERIC:
convertedVal = new BigDecimal(value);
break;
case Types.FLOAT:
convertedVal = Float.valueOf(value);
break;
case Types.INTEGER:
convertedVal = Integer.valueOf(Double.valueOf(value).intValue());
break;
case Types.REAL:
convertedVal = Float.valueOf(value);
break;
case Types.SMALLINT:
convertedVal = Short.valueOf(value);
break;
case Types.TIMESTAMP:
convertedVal = Timestamp.valueOf(value);
break;
case Types.BINARY:
case Types.VARBINARY:
case Types.LONGVARBINARY:
convertedVal = value.getBytes();
break;
case Types.CHAR:
case Types.VARCHAR:
case Types.LONGVARCHAR:default:
convertedVal = value;
break;
}
} catch (final Exception ex) {
JDBCUtil.mLogger.log(Level.INFO, "JDBCUtil_Failed_Convert",
new Object[] { value, jdbcType });
throw new Exception("Failed to convert value " + value +
" to jdbc type " + jdbcType);
}
return convertedVal;
}
public static final String getSQLStatementType(final String sqlText) {
if(opList.contains(sqlText.split("\\s")[0]))
return sqlText.split("\\s")[0];
else return dbOperations[dbOperations.length-1];
/*String opName = JDBCOperations.getOpType(sqlText);
JDBCOperations jdbcOps = JDBCOperations.getJDBCOperations(opName);
return jdbcOps.toString();*/
}
}

View File

@ -1,65 +0,0 @@
/*
* 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]
*/
/*
* @(#)ListenerMeta.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc;
/**
* This is the class that encapsulates metadata
* information about the message exchange listener
*
* @author Venkat P
*
*/
public class ListenerMeta {
private long timestamp;
private MessageExchangeReplyListener listener;
protected ListenerMeta(final long timestamp, final MessageExchangeReplyListener listener) {
this.timestamp = timestamp;
this.listener = listener;
}
/**
*
* @return
*/
protected long getRequestInvocationTime() {
return timestamp;
}
/**
*
* @return
*/
protected MessageExchangeReplyListener getMessageExchangeReplyListener() {
return listener;
}
}

View File

@ -1,52 +0,0 @@
/*
* 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]
*/
/*
* @(#)MessageExchangeReplyListener.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc;
import javax.jbi.messaging.MessageExchange;
/**
* Listener interface to process reply status message
* from message exchanges.
*
* @author Venkat P
*
*/
public interface MessageExchangeReplyListener {
/**
* Processes the (reply) status message in the message exchange.
*
* @param exchange MessageExchange to process.
* @throws java.lang.Exception
*/
public void processReplyMessage(MessageExchange exchange)
throws Exception;
}

View File

@ -1,140 +0,0 @@
/*
* 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]
*/
/*
* @(#)MessageExchangeSupport.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc;
import com.sun.jbi.internationalization.Messages;
import java.util.Collections;
import java.util.Map;
import java.util.HashMap;
import java.util.logging.Logger;
import java.util.logging.Level;
import javax.jbi.messaging.MessageExchange;
import javax.jbi.messaging.MessagingException;
/**
*
*/
public class MessageExchangeSupport {
private static final Messages mMessages =
Messages.getMessages(MessageExchangeSupport.class);
private final static Logger mLogger =
Messages.getLogger(MessageExchangeSupport.class);
static Map replyListeners = Collections.synchronizedMap(new HashMap());
static Map redeliveryListeners = Collections.synchronizedMap(new HashMap());
/** Creates a new instance of MessageExchangeSupport */
public MessageExchangeSupport() {}
/**
* Add a reply listener for a message exchange
* @param messageExchangeId the ID of the exchange to register a reply listener for
* @param listener The reply listener to notify when a reply is available
* @param clientContext A client supplied object to return to the reply listener
*/
public static void addReplyListener(String messageExchangeId, ReplyListener listener, Object clientContext) {
if (mLogger.isLoggable(Level.FINE)) {
mLogger.log(Level.FINE, "Adding reply listener for messsage exchange:" + messageExchangeId);
}
listener.setMessageExchangeId(messageExchangeId, clientContext);
replyListeners.put(messageExchangeId, listener);
}
/**
* Remove the reply listener
* @param messageExchangeId the exchange ID for the reply listener to remove
*/
public static void removeReplyListener(String messageExchangeId) {
replyListeners.remove(messageExchangeId);
}
/**
* Notify the reply listener of a reply being available
* To support MEPs where there might be multiple supplies, this does not remove the reply listener
* from the MessageExchangeSupport.
* Use <code>removeReplyListener<code> to explicitly remove the listener when the MEP is complete.
* @param mep the message exchange instance
*/
public static void notifyOfReply(MessageExchange mep) throws MessagingException {
String messageExchangeId = mep.getExchangeId();
ReplyListener listener = (ReplyListener) replyListeners.get(messageExchangeId);
if (listener != null) {
listener.onReply(mep);
} else {
throw new MessagingException("Cannot process reply exchange "
+ messageExchangeId + " because no reply listener has been registered");
}
}
/**
* Add a redelivery listener for a message exchange
* @param messageExchangeId the ID of the exchange to register a reply listener for
* @param listener The redelivery listener to notify when redelivery criteria is met
* @param exchangeMetaData the metadata needed to reinitiate a message exchange
*/
public static void addRedeliveryListener(String messageExchangeId, RedeliveryListener listener, Object exchangeMetaData) {
if (mLogger.isLoggable(Level.FINE)) {
mLogger.log(Level.FINE, "Adding redelivery listener for messsage exchange:" + messageExchangeId);
}
listener.setMessageExchangeId(messageExchangeId, exchangeMetaData);
redeliveryListeners.put(messageExchangeId, listener);
}
/**
* Remove the redelivery listener
* @param messageExchangeId the exchange ID for the redelivery listener to remove
*/
public static void removeRedeliveryListener(String messageExchangeId) {
redeliveryListeners.remove(messageExchangeId);
}
/**
* Notify the redelivery listener of a re-send of the message exchange if the redelivery
* criteria is met.
* Use <code>removeRedeliveryListener<code> to explicitly remove the listener when retry limit is exhausted.
* @param mep the message exchange instance
*/
public static void notifyOfRedelivery(MessageExchange mep) throws MessagingException {
String messageExchangeId = mep.getExchangeId();
RedeliveryListener listener = (RedeliveryListener) redeliveryListeners.get(messageExchangeId);
if (listener != null) {
listener.onRedelivery(mep);
} else {
throw new MessagingException("Cannot redelivery the message exchange "
+ messageExchangeId + " because no redelivery listener has been registered");
}
}
}

View File

@ -1,171 +0,0 @@
/*
* 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]
*/
/*
* @(#)OperationMetaData.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc;
import com.sun.jbi.jdbcbc.extensions.JDBCOperation;
import com.sun.jbi.jdbcbc.extensions.JDBCOperationInput;
import com.sun.jbi.jdbcbc.extensions.JDBCOperationOutput;
import javax.wsdl.BindingOperation;
import javax.wsdl.Definition;
import javax.wsdl.Operation;
/**
*
* To change the template for this generated type comment go to
* Window - Preferences - Java - Code Generation - Code and Comments
*/
public class OperationMetaData {
private JDBCOperation mJDBCOperation;
private JDBCOperationInput mJDBCOperationInput;
private JDBCOperationOutput mJDBCOperationOutput;
private JDBCOperationInput mJdbcSql;
private Operation mOperation;
private BindingOperation mBindingOperation;
private Definition mDefinition;
public OperationMetaData() {
}
/**
*
* @param jdbcOperation
*/
public void setJDBCOperation(final JDBCOperation jdbcOperation) {
mJDBCOperation = jdbcOperation;
}
/**
*
* @return
*/
public JDBCOperation getJDBCOperation() {
return mJDBCOperation;
}
/**
*
* @param operationInput
*/
public void setJDBCOperationInput(final JDBCOperationInput operationInput) {
mJDBCOperationInput = operationInput;
}
/**
*
* @return
*/
public JDBCOperationInput getJDBCOperationInput() {
return mJDBCOperationInput;
}
/**
*
* @param jdbcSql
*/
public void setJDBCSql(final JDBCOperationInput jdbcSql) {
mJdbcSql = jdbcSql;
}
/**
*
* @return
*/
public JDBCOperationInput getJDBCSql() {
return mJdbcSql;
}
/**
*
* @param operationOutput
*/
public void setJDBCOperationOutput(final JDBCOperationOutput operationOutput) {
mJDBCOperationOutput = operationOutput;
}
/**
*
* @return
*/
public JDBCOperationOutput getJDBCOperationOutput() {
return mJDBCOperationOutput;
}
/**
*
* @param bindingOperation
*/
protected void setBindingOperation(final BindingOperation bindingOperation) {
mBindingOperation = bindingOperation;
mOperation = bindingOperation.getOperation();
}
/**
*
* @return
*/
public BindingOperation getBindingOperation() {
return mBindingOperation;
}
/**
*
* @param operation
*/
public void setOperation(final Operation operation) {
mOperation = operation;
}
/**
*
* @return
*/
Operation getOperation() {
return mOperation;
}
/**
*
* @param definition
*/
protected void setDefinition(final Definition definition) {
mDefinition = definition;
}
/**
*
* @return
*/
private Definition getDefinition() {
return mDefinition;
}
}

View File

@ -1,201 +0,0 @@
/*
* 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]
*/
/*
* @(#)OutboundReceiver.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc;
import java.util.Map;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.jbi.component.ComponentContext;
import javax.jbi.messaging.*;
import javax.management.AttributeChangeNotification;
import javax.management.Notification;
import javax.management.NotificationListener;
import com.sun.jbi.internationalization.Messages;
import com.sun.jbi.common.qos.messaging.MessagingChannel;
/**
* Wait for responses/requests from the service engine and
* use thread pools to process them.
*
* This receiver not only processes "outbound" requests initiated by the
* Service engine, but also responses to requests this adapter has sent the SE.
*/
class OutboundReceiver implements Runnable {
private static final Messages mMessages = Messages.getMessages(OutboundReceiver.class);
public static final Logger mLogger = Messages.getLogger(OutboundReceiver.class);
// Pool settings for processing SE "outbound" requests initated by the SE.
int mOutboundCorePoolSize;
int mOutboundKeepAliveTime = 60 * 10;
TimeUnit mOutboundTimeUnit = TimeUnit.SECONDS;
// By using an unbounded queue the max pool size becomes irrelevant
int mOutboundMaxPoolSize = Integer.MAX_VALUE;
ThreadPoolExecutor mOutboundPooledExecutor;
private MessagingChannel mChannel;
private AtomicBoolean mMonitor;
private Map mEndpoints;
private JDBCComponentContext mContext;
private Map mInboundExchanges;
// Inner class to handle configuration change notifications
public final NotificationListener listener = new NotificationListener() {
// @Override
public void handleNotification(Notification notification, Object obj) {
if (notification instanceof AttributeChangeNotification) {
AttributeChangeNotification attrNotif = (AttributeChangeNotification) notification;
String attrName = attrNotif.getAttributeName();
if (attrName.equals("Threads")) {
Integer newVal = (Integer) (attrNotif.getNewValue());
setThreads(newVal.intValue());
}
}
}
};
/**
* Construct a receiver for a given binding channel and the relevant endpoints
* @param bc the binding channel to receive from
* @param endpoints EndointBean instances with information about the endpoints
*/
public OutboundReceiver(final MessagingChannel bc, final Map endpoints,
final RuntimeConfiguration runtimeConfig, final JDBCComponentContext context) {
mChannel = bc;
mContext = context;
// Apply existing configuration
final Integer threadCount = runtimeConfig.getThreads();
if (threadCount != null) {
setThreads(threadCount.intValue());
}
// Subscribe for changes to the configuration
runtimeConfig.addNotificationListener(listener, null, null);
mOutboundPooledExecutor = new ThreadPoolExecutor(mOutboundCorePoolSize,
mOutboundMaxPoolSize, mOutboundKeepAliveTime,
mOutboundTimeUnit, new LinkedBlockingQueue(),
Executors.privilegedThreadFactory());
mOutboundPooledExecutor.prestartAllCoreThreads();
mInboundExchanges = InboundMessageProcessor.getInboundExchanges();
mMonitor = new AtomicBoolean(false);
mEndpoints = endpoints;
}
/**
* Construct a receiver for a given binding channel and the relevant endpoints
* @param bc the binding channel to receive from
* @param endpoints EndointBean instances with information about the endpoints
*/
public OutboundReceiver(final MessagingChannel bc, final Map endpoints,
final SQLSERuntimeConfiguration runtimeConfig, final JDBCComponentContext context) {
mChannel = bc;
mContext = context;
// Apply existing configuration
final Integer threadCount = runtimeConfig.getThreads();
if (threadCount != null) {
setThreads(threadCount.intValue());
}
// Subscribe for changes to the configuration
runtimeConfig.addNotificationListener(listener, null, null);
mOutboundPooledExecutor = new ThreadPoolExecutor(mOutboundCorePoolSize,
mOutboundMaxPoolSize, mOutboundKeepAliveTime,
mOutboundTimeUnit, new LinkedBlockingQueue(),
Executors.privilegedThreadFactory());
mOutboundPooledExecutor.prestartAllCoreThreads();
mInboundExchanges = InboundMessageProcessor.getInboundExchanges();
mMonitor = new AtomicBoolean(false);
mEndpoints = endpoints;
}
/**
* Main receiver loop to process replies and requests of SEs
*/
//@Override
public void run() {
MessageExchange mExchange = null;
OutboundReceiver.mLogger.log(Level.INFO, OutboundReceiver.mMessages.getString("SQLSE_R00664.OR_Started"));
try {
do {
mExchange = mChannel.accept(500);
if (mExchange != null) {
if (OutboundReceiver.mLogger.isLoggable(Level.INFO)) {
OutboundReceiver.mLogger.log(Level.INFO,
OutboundReceiver.mMessages.getString("SQLSE_R00665.OR_Accepted") +
mExchange.getExchangeId());
}
final OutboundMessageProcessor proc = new OutboundMessageProcessor(mChannel,
mExchange, mEndpoints, mContext, mInboundExchanges);
//final Thread task = new Thread(proc);
//task.start();
mOutboundPooledExecutor.execute(proc);
}
} while (mMonitor.get() != Boolean.TRUE);
} catch (final Exception e) {
OutboundReceiver.mLogger.log(Level.INFO,
OutboundReceiver.mMessages.getString("SQLSE_E00666.OR_Exception") + e.getMessage());
}
OutboundReceiver.mLogger.log(Level.INFO, OutboundReceiver.mMessages.getString("SQLSE_R00667.OR_Shutdown"));
}
/**
* Set the number or processing threads to use
*/
public void setThreads(final int threadCount) {
mOutboundCorePoolSize = threadCount;
if (mOutboundPooledExecutor != null) {
mOutboundPooledExecutor.setCorePoolSize(threadCount);
}
}
/**
* Stop the receiver thread.
*/
public void stopReceiving() {
OutboundReceiver.mLogger.log(Level.INFO, OutboundReceiver.mMessages.getString("SQLSE_R00669.OR_Stop"));
mMonitor.set(Boolean.TRUE);
}
}

View File

@ -1,91 +0,0 @@
/*
* 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]
*/
/*
* @(#)PortMapEntry.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc;
import javax.xml.namespace.QName;
/** Used by SQLSE. By SQLSEServiceUnitManager to hold the service metadata
* after parsing the ServiceUnitDescriptor.
*/
public class PortMapEntry {
private QName mServiceName;
private QName mEndPoint;
private String mRole;
private QName mPartnerLink;
/**
* Constructor
* @param service
* @param endpoint
* @param role
* @param partnerlink
*/
PortMapEntry(final QName service, final QName endpoint, final String role,
final QName partnerlink) {
mServiceName = service;
mEndPoint = endpoint;
mRole = role;
mPartnerLink = partnerlink;
}
/**
* returns the service name.
* @return QName
*/
QName getServiceName() {
return mServiceName;
}
/**
* Returns the endpoint.
* @return QName
*/
QName getEndPoint() {
return mEndPoint;
}
/**
* Returns the role.
* @return role
*/
protected String getRole() {
return mRole;
}
/**
* Returns the partnerlink.
* @return QName
*/
QName getPartnerLink() {
return mPartnerLink;
}
}

View File

@ -1,54 +0,0 @@
/*
* 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]
*/
/*
* @(#)ReplyListener.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc;
import javax.jbi.messaging.MessageExchange;
import javax.jbi.messaging.MessagingException;
/**
*
*/
public interface RedeliveryListener {
/**
* Method to handle the redelivery of an inbound message if the
* redelivery configuration is applied to the endpoint
*/
void onRedelivery(MessageExchange exchange) throws MessagingException;
/**
* The framwork will set the exchange metadata associated with
* an exchange
*
* @param messageExchangeId the exchange ID of the message exchange
* @param exchangeMetaData the metadata needed to reinitiate a message exchange
*/
void setMessageExchangeId(String messageExchangeId, Object exchangeMetaData);
}

View File

@ -1,51 +0,0 @@
/*
* 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]
*/
/*
* @(#)ReplyListener.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc;
import javax.jbi.messaging.MessageExchange;
import javax.jbi.messaging.MessagingException;
/**
*
*/
public interface ReplyListener {
/**
* Method asynchronously invoked by the framework once a reply to a message exchange is available
*/
void onReply(MessageExchange exchange) throws MessagingException;
/**
* The framwork will set the corresponding message exchange
* once it initialized the message exchange.
* @param messageExchangeId the exchange id of the message exchange initialized
* @param clientContext returns the client provided object associated with the request
*/
void setMessageExchangeId(String messageExchangeId, Object clientContext);
}

View File

@ -1,245 +0,0 @@
/*
* 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]
*/
/*
* @(#)InboundMessageProcessor.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc;
import javax.jbi.messaging.ExchangeStatus;
import javax.jbi.messaging.Fault;
import javax.jbi.messaging.InOut;
import javax.jbi.messaging.MessagingException;
import javax.jbi.messaging.MessageExchange;
import javax.jbi.messaging.NormalizedMessage;
import java.util.Map;
import java.util.HashMap;
import java.util.Collections;
/*
* This class might need to be refactored if this is
* going to be implemented for SQLSE since SQLSE does not implement
* polling there would not be an Inbound thread
*/
public class ReplyListenerImpl implements ReplyListener{
private EndpointBean targetEndpoint;
private JDBCBindingLifeCycle lifeCycle = null;
private SQLSELifeCycle seLifeCycle = null;
private ReplyListener replyListener;
/**
* A mapping from the JBI message exchange ID to the request context
*/
//TODO: find non-synchronized way of doing this
Map exchangeIDToContext = Collections.synchronizedMap(new HashMap());
public ReplyListenerImpl(EndpointBean targetEndPoint){
this.targetEndpoint = targetEndpoint;
lifeCycle = (JDBCBindingLifeCycle) JDBCComponentContext.getInstance().getAssociatedLifeCycle();
replyListener = this;
}
/*
* currently this makes no sense since we do not have polling for SQLSE
* this constructor is useful if and only if we use polling in SQL SE
*/
public ReplyListenerImpl(EndpointBean targetEndPoint, boolean se){
this.targetEndpoint = targetEndpoint;
//seLifeCycle = (JDBCBindingLifeCycle) JDBCComponentContext.getInstance().getAssociatedLifeCycle();
replyListener = this;
}
/*
* Method asynchronously invoked by the framework once a reply to a message exchange is available
*/
public void onReply(MessageExchange exchange) throws MessagingException{
// MEP is complete, we do not expect any further replies. Remove from MessageExchangeSupport.
// TODO: is this remove really needed? If so, document why
MessageExchangeSupport.removeReplyListener(exchange.getExchangeId());
/*SOAPMessage response = null;
NormalizedMessage outMsg = null;
AsyncProviderCallback asyncProviderCallback = (AsyncProviderCallback) exchangeIDToContext.remove(exchange.getExchangeId());
Probe denormalizationMeasurement = null;
boolean transactionResumed = false;
Transaction transaction = (Transaction) exchange.getProperty(
MessageExchange.JTA_TRANSACTION_PROPERTY_NAME);
try {
if (exchange.getStatus() == ExchangeStatus.ACTIVE) {
// Next step in the message exchange ping-pong game.
// Prcoess the reponse - whether out message or fualt
if (ExchangePattern.isInOut(exchange)) {
InOut inout = (InOut) exchange;
NormalizedMessage outMsgOrFault = inout.getOutMessage();
if (outMsgOrFault == null) {
Fault aFault = exchange.getFault();
outMsgOrFault = aFault;
}
// TODO: it should be possible to disallow/disable this completely for compliance reasons
if (mLogger.isLoggable(Level.FINE)) {
if (outMsgOrFault != null) {
DebugLog.debugLog(mLogger, Level.FINE, "Denormalizing received msg", outMsgOrFault.getContent());
} else {
mLogger.log(Level.FINE, "Message received is empty.");
}
}
Map nameToMeta = targetEndpoint.getOperationNameToMetaData();
String operation = exchange.getOperation().getLocalPart();
OperationMetaData operationMetaData = (OperationMetaData) nameToMeta.get(operation);
if (operationMetaData == null) {
throw new MessagingException(mMessages.getString("HTTPBC-E00667.No_opmeta_for_operation", exchange.getOperation()));
}
Denormalizer denormalizer = getProcessorSupport().denormalizer;
denormalizationMeasurement = Probe.info(getClass(),
targetEndpoint.getUniqueName(),
HttpSoapBindingLifeCycle.PERF_CAT_DENORMALIZATION);
response = (SOAPMessage) denormalizer.denormalize(outMsgOrFault, exchange, response, operationMetaData);
} else if (ExchangePattern.isInOnly(exchange)) {
// For one-way exchanges we do not have to provide a reponse, just call JAX-WS back with null
response = null;
}
if (mLogger.isLoggable(Level.FINE)) {
mLogger.log(Level.FINE, "Calling back JAX-WS asynchronously to proceed with response");
}
//response = saajWorkAround(response);
transactionResumed = TransactionsUtil.resumeTransaction(transaction);
// measuring total time taken from receving the SOAP request to send back the response to client
if (mFromInvokeToSendResponse != null) {
mFromInvokeToSendResponse.end();
}
asyncProviderCallback.send(response);
} else if (exchange.getStatus() == ExchangeStatus.DONE) {
// The game is over; the partner component
// is closing the MEP, and so should I.
// For the following MEPs the following are true:
//
// Pattern me.getRole() me Invariant
// ------- ------ ------------
// In CONSUMER getInMessage() != null && getError() == null
// In-out PROVIDER getInMessage() != null &&
// (getOutMessage() != null xor getFaultMessage() != null) &&
// getError() == null
//
// (the invariant conditions with optional responses are
// more complex.)
if (ExchangePattern.isInOnly(exchange)) {
// One-way invoke successful, report 202 accepted
transactionResumed = TransactionsUtil.resumeTransaction(transaction);
asyncProviderCallback.send(null);
}
} else if (exchange.getStatus() == ExchangeStatus.ERROR) {
// The game is over; the partner component
// is abruptly closing the MEP, and so should I.
// ME properties will reflect
// the on-going state of the exchange before it
// was ending by the partner abruptly.
//
// Pattern me.getRole() me Invariant
// ------- ------------ ------------
// In CONSUMER getInMessage() != null
// In-out CONSUMER getInMessage() != null
// In-out PROVIDER getInMessage() != null &&
// (getOutMessage() != null xor getFaultMessage() != null )
Exception errorDetail = null;
if (exchange.getError() != null) {
errorDetail = exchange.getError();
} else {
// Provider did not give details about the error, can only generate a very generic failure
// TODO: i18n
errorDetail = new Exception("Provider for " + targetEndpoint.getServiceName() + " " + targetEndpoint.getEndpointName() + " responded with an error status.");
}
// For inout, convert to our fault format. We may want to consider if we leave this to JAX-WS.
if (ExchangePattern.isInOut(exchange)) {
Denormalizer denormalizer = getProcessorSupport().denormalizer;
response = (SOAPMessage) denormalizer.denormalizeException(errorDetail, response);
if (mLogger.isLoggable(Level.FINE)) {
mLogger.log(Level.FINE, "Sending a fault back to the client via AsyncProviderCallback");
}
//response = saajWorkAround(response);
transactionResumed = TransactionsUtil.resumeTransaction(transaction);
asyncProviderCallback.send(response);
} else {
if (mLogger.isLoggable(Level.FINE)) {
mLogger.log(Level.FINE, "Sending error back to the client via AsyncProviderCallback. Error detail is: " + errorDetail);
}
transactionResumed = TransactionsUtil.resumeTransaction(transaction);
asyncProviderCallback.sendError(errorDetail);
}
}
} catch (Exception e) {
if (mLogger.isLoggable(Level.FINE)) {
mLogger.log(Level.FINE, "Caught failure in response processing, sending error. ", e);
}
asyncProviderCallback.sendError(e);
} finally {
if (denormalizationMeasurement != null) {
denormalizationMeasurement.end();
}
if (!transactionResumed) {
try {
TransactionsUtil.resumeTransaction(transaction);
} catch (Exception e) {
String errmsg = mMessages.getString(
"HTTPBC-E00681.Transaction_resume_failed",
transaction.toString());
mLogger.log(Level.SEVERE, errmsg, e);
}
}
}*/
}
/**
* The framwork will set the corresponding message exchange
* once it initialized the message exchange.
* @param messageExchangeId the exchange id of the message exchange initialized
* @param clientContext returns the client provided object associated with the request
*/
public void setMessageExchangeId(String messageExchangeId, Object clientContext){
exchangeIDToContext.put(messageExchangeId, clientContext);
}
}

View File

@ -1,232 +0,0 @@
/*
* 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]
*/
/*
* @(#)RuntimeConfiguration.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc;
import java.util.Properties;
import java.util.logging.Logger;
import javax.jbi.JBIException;
import javax.management.AttributeChangeNotification;
import javax.management.InvalidAttributeValueException;
import javax.management.ListenerNotFoundException;
import javax.management.MBeanException;
import javax.management.MBeanNotificationInfo;
import javax.management.Notification;
import javax.management.NotificationBroadcasterSupport;
import javax.management.NotificationEmitter;
import javax.management.NotificationFilter;
import javax.management.NotificationListener;
import com.sun.jbi.configuration.ConfigPersistence;
/**
* Runtime configuration MBean, allow configuration to be changed at run-time
*
*/
public class RuntimeConfiguration implements RuntimeConfigurationMBean,
NotificationEmitter {
private static final Logger mLogger = Logger.getLogger(RuntimeConfiguration.class.getName());
// Attribute names
public static final String CONFIG_THREADS = "Threads";
// Default values in the absence of configuration settings
private static final String DEFAULT_THREADS = "16";
// Configuration validation settings
long MIN_THREADS = 1;
long MAX_THREADS = 10000;
// Configuration
Properties mConfig;
String mWorkspaceRoot;
// config schema and config data
private String mConfigSchema;
private String mConfigData;
// Use delegation to support notification
NotificationBroadcasterSupport broadcasterSupport = new NotificationBroadcasterSupport();
/** Creates a new instance of InstallerExt */
RuntimeConfiguration(final String workspaceRoot) throws JBIException {
mWorkspaceRoot = workspaceRoot;
// Load the persisted configuration
mConfig = ConfigPersistence.loadConfig(workspaceRoot);
}
/**
* @return
*/
//@Override
public Integer getThreads() {
final String val = mConfig.getProperty(RuntimeConfiguration.CONFIG_THREADS, RuntimeConfiguration.DEFAULT_THREADS);
return Integer.valueOf(val);
}
/**
*
* @throws javax.management.InvalidAttributeValueException
* @throws javax.management.MBeanException
*/
// @Override
public void setThreads(final Integer val)
throws InvalidAttributeValueException, MBeanException {
final String attrName = RuntimeConfiguration.CONFIG_THREADS;
// Validate the attribute value
Integer newVal = null;
try {
newVal = val;
} catch (final Exception ex) {
throw new InvalidAttributeValueException(
"Invalid argument for setting attribute " + attrName + " :" +
ex.getMessage());
}
if ((newVal.intValue() < MIN_THREADS) ||
(newVal.intValue() > MAX_THREADS)) {
throw new InvalidAttributeValueException("A value of " + newVal +
" is not valid for attribute " + attrName +
". The valid range is " + MIN_THREADS + " - " + MAX_THREADS);
}
// Apply and save the changes
mConfig.put(RuntimeConfiguration.CONFIG_THREADS, val.toString());
persistConfiguration();
// Notify listeners of this change
final long seqNo = 0;
final String msg = "Attribute changed";
final String attrType = Integer.class.getName();
final Integer oldVal = getThreads();
final Notification notif = new AttributeChangeNotification(this, seqNo,
System.currentTimeMillis(), msg, attrName, attrType, oldVal,
newVal);
broadcasterSupport.sendNotification(notif);
}
/**
*
* @throws MBeanException
*/
private void persistConfiguration() throws MBeanException {
// Persist the changed configuration
try {
ConfigPersistence.persistConfig(mWorkspaceRoot, mConfig);
} catch (final JBIException ex) {
throw new MBeanException(ex,
"Failed to persist configuration to " + mWorkspaceRoot + ": " +
ex.getMessage());
}
}
/**
*
* @return
*/
public MBeanNotificationInfo[] getNotificationInfo() {
return new MBeanNotificationInfo[] {
new MBeanNotificationInfo(new String[] {
AttributeChangeNotification.ATTRIBUTE_CHANGE
}, AttributeChangeNotification.class.getName(),
"Attribute changed")
};
}
/**
*
* @param listener
* @param filter
* @param handback
*/
public void addNotificationListener(final NotificationListener listener,
final NotificationFilter filter, final Object handback) {
broadcasterSupport.addNotificationListener(listener, filter, handback);
}
/**
*
* @param listener
* @throws ListenerNotFoundException
*/
public void removeNotificationListener(final NotificationListener listener)
throws ListenerNotFoundException {
broadcasterSupport.removeNotificationListener(listener);
}
/**
*
* @param listener
* @param filter
* @param handback
* @throws ListenerNotFoundException
*/
//@Override
public void removeNotificationListener(final NotificationListener listener,
final NotificationFilter filter, final Object handback)
throws ListenerNotFoundException {
broadcasterSupport.removeNotificationListener(listener, filter, handback);
}
// addition of the configuration display data
/**
* Retrieves the configuration display schema
*/
public String retrieveConfigurationDisplaySchema() {
return this.mConfigSchema;
}
/**
* Retrieves the configuration display data
*/
public String retrieveConfigurationDisplayData() {
return this.mConfigData;
}
// addition of the configuration display data
/**
* Retrieves the configuration display schema
*/
public void setConfigurationDisplaySchema(String mConfigSchema) {
this.mConfigSchema = mConfigSchema;
}
/**
* Retrieves the configuration display data
*/
public void setConfigurationDisplayData(String mConfigData) {
this.mConfigData = mConfigData;
}
}

View File

@ -1,46 +0,0 @@
/*
* 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]
*/
/*
* @(#)RuntimeConfigurationMBean.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc;
import javax.management.InvalidAttributeValueException;
import javax.management.MBeanException;
/**
* MBean interface for run-time configuration
*
*/
public interface RuntimeConfigurationMBean {
public Integer getThreads();
public void setThreads(Integer val)
throws InvalidAttributeValueException, MBeanException;
}

View File

@ -1,213 +0,0 @@
/*
* 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]
*/
/*
* @(#)SQLEngineFileEntry.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc;
/**
* Data structure to hold an entry in the SQLSE engine file. Contains connectivity
* and sqlfile information.
*/
public class SQLEngineFileEntry {
private String sqlText = null;
private String sqlFileName;
private String wsdlFileName;
private String driverClass;
private String dbURL;
private String databaseName;
private String user;
private String password;
private String jndi;
private String transactionRequired;
/**
* sets the sql text used by the user.
* @param sql
*/
protected void setSQLText(final String sql) {
sqlText = sql;
}
/**
* sets the sql file name.
* @param sqlFileName
*/
protected void setSQLFileName(final String sqlFileName) {
this.sqlFileName = sqlFileName;
}
/**
* sets the driverclass used by the sql file.
* @param driverClass
*/
protected void setDriverClass(final String driverClass) {
this.driverClass = driverClass;
}
/**
* sets the URL used for the sql file.
* @param dbURL
*/
protected void setDatabaseUrl(final String dbURL) {
this.dbURL = dbURL;
}
/**
* sets the database name.
* @param databaseName
*/
protected void setDatabaseName(final String databaseName) {
this.databaseName = databaseName;
}
/**
* sets the database user.
* @param user
*/
protected void setDatabaseUserName(final String user) {
this.user = user;
}
/**
* sets the database password.
* @param password
*/
protected void setDatabasePassword(final String password) {
this.password = password;
}
/**
* sets the jndi name.
* @param jndi
*/
protected void setJNDI(final String jndi) {
this.jndi = jndi;
}
/**
* returns the jndi name.
* @return
*/
String getJNDI() {
return jndi;
}
/**
* sets the transaction attribute.
* @param transactionRequired
*
*/
protected void setTransactionRequired(String transactionRequired) {
String trReqd =transactionRequired.toLowerCase().trim();
if (trReqd.equals("yes") || trReqd.equals("true")){
trReqd = "yes";
}
this.transactionRequired = trReqd;
}
/**
* returns the transaction attribute.
* @return
*/
String getTransactionRequired() {
return transactionRequired;
}
/**
* returns the sql text.
* @return
*/
String getSqlText() {
return sqlText;
}
/**
* Returns the sql file name given by the user.
* @return
*/
protected String getSqlFileName() {
return sqlFileName;
}
/**
* Returns the driver class.
* @return
*/
String getDriverClass() {
return driverClass;
}
/**
* Returns the database URL used.
* @return
*/
String getDbURL() {
return dbURL;
}
/**
* Returns the database name.
* @return
*/
String getDatabaseName() {
return databaseName;
}
/**
* Returns the database user.
* @return
*/
String getUser() {
return user;
}
/**
* Returns the database password.
* @return
*/
String getPassword() {
return password;
}
/**
* Returns the wsdl filename.
* @return
*/
private String getWsdlFileName() {
return wsdlFileName;
}
/**
* sets the wsdl file name.
* @param wsdlFileName
*/
private void setWsdlFileName(final String wsdlFileName) {
this.wsdlFileName = wsdlFileName;
}
}

View File

@ -1,228 +0,0 @@
/*
* 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]
*/
/*
* @(#)SQLEngineFileReader.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileFilter;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import com.sun.jbi.internationalization.Messages;
import com.sun.jbi.jdbcbc.util.ExtensionFilter;
/**
* Used by SQLSE.
* Reads a sqlse engine file and generates SQLEngineFileEntry[].
*/
public class SQLEngineFileReader {
private static final Messages mMessages = Messages.getMessages(SQLEngineFileReader.class);
private static final Logger mLogger = Messages.getLogger(SQLEngineFileReader.class);
private static final String SQLDEF_TAG = "sqldef";
/**
* Parses the given file to generate a SQLEngineFileEntry[].
* @param sqlengineFile
* @return SQLEngineFileEntry[]
* @throws org.xml.sax.SAXException
* @throws java.io.IOException
* @throws javax.xml.parsers.ParserConfigurationException
*/
static SQLEngineFileEntry[] parse(final File asaDir, final File sqlengineFile)
throws org.xml.sax.SAXException, java.io.IOException,
javax.xml.parsers.ParserConfigurationException {
assert sqlengineFile != null;
final Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder()
.parse(sqlengineFile);
final Element elem = doc.getDocumentElement();
final NodeList sqldefMaps = elem.getElementsByTagName(SQLEngineFileReader.SQLDEF_TAG);
final SQLEngineFileEntry[] entryArr = new SQLEngineFileEntry[sqldefMaps.getLength()];
for (int i = 0; i < sqldefMaps.getLength(); i++) {
final Node childNode = sqldefMaps.item(i);
final SQLEngineFileEntry engineFileEntry = new SQLEngineFileEntry();
if (childNode.getNodeType() == Node.ELEMENT_NODE) {
final Element childElem = (Element) childNode;
final NodeList sqlFile = childElem.getElementsByTagName("sqlfile");
final NodeList connDef = childElem.getElementsByTagName(
"connectiondef");
if (sqlFile != null) {
final NamedNodeMap val = sqlFile.item(0).getAttributes();
String sqlFileName = val.getNamedItem("name").getNodeValue();
final File sqlFileObj = SQLEngineFileReader.getFileByName(asaDir, sqlFileName);
if (sqlFileName != null) {
final FileReader fr = new FileReader(sqlFileObj);
final BufferedReader reader = new BufferedReader(fr);
final StringBuffer sqlText = new StringBuffer();
String line = null;
while ((line = reader.readLine()) != null) {
if (sqlText.length() != 0) {
sqlText.append("\n");
}
sqlText.append(line);
}
engineFileEntry.setSQLText(sqlText.toString());
sqlFileName = sqlFileName.substring(sqlFileName.lastIndexOf(
File.separator) + File.separator.length(),
sqlFileName.length());
engineFileEntry.setSQLFileName(sqlFileName);
SQLEngineFileReader.mLogger.log(Level.FINE, "SQLFR_READ_SQL",
sqlText.toString());
reader.close();
fr.close();
}
}
if (connDef != null) {
final NamedNodeMap val = connDef.item(0).getAttributes();
final String driverClass = val.getNamedItem("driverClass")
.getNodeValue();
final String dbURL = val.getNamedItem("dbURL").getNodeValue();
final String databaseName = val.getNamedItem("databaseName")
.getNodeValue();
final String user = val.getNamedItem("user").getNodeValue();
String password = val.getNamedItem("password").getNodeValue();
/*String pwd = null;
if(com.sun.jbi.jdbcbc.security.Base64Impl.getInstance().decode(password)!=null)
pwd = com.sun.jbi.jdbcbc.security.Base64Impl.getInstance().decode(password);
else
pwd = password;*/
final String jndi = val.getNamedItem("jndi_name").getNodeValue();
String transactionRequired = "";
if(val.getNamedItem("transactionRequired") != null) {
transactionRequired = val.getNamedItem("transactionRequired").getNodeValue();
}
engineFileEntry.setDriverClass(driverClass);
engineFileEntry.setDatabaseUrl(dbURL);
engineFileEntry.setDatabaseName(databaseName);
engineFileEntry.setDatabaseUserName(user);
engineFileEntry.setDatabasePassword(password);
engineFileEntry.setJNDI(jndi);
engineFileEntry.setTransactionRequired(transactionRequired);
}
}
entryArr[i] = engineFileEntry;
}
SQLEngineFileReader.mLogger.log(Level.FINE, mMessages.getString("SQLSE_C00150.SQLMR_PARSE_SUCCESS"),entryArr);
return entryArr;
}
/**
* Helper method to find a specific SQLEngineFileEntry given a SQLFineEngineFileEntry[]
* @param fea
* @param sqlFileName
* @return SQLEngineFileEntry
*/
static SQLEngineFileEntry findSQLEngineFileEntry(
final SQLEngineFileEntry[] fea, final String sqlFileName) {
SQLEngineFileEntry sqlfeEntry = null;
for (SQLEngineFileEntry element : fea) {
if (element.getSqlFileName().equalsIgnoreCase(sqlFileName)) {
sqlfeEntry = element;
}
}
return sqlfeEntry;
}
protected static List<File> getFilesRecursively(final File dir, final FileFilter filter) {
final List<File> ret = new ArrayList<File>();
if (!dir.isDirectory()) {
return ret;
}
final File[] fileNdirs = dir.listFiles(filter);
for (File element : fileNdirs) {
if (element.isDirectory()) {
ret.addAll(SQLEngineFileReader.getFilesRecursively(element, filter));
} else {
ret.add(element);
}
}
return ret;
}
protected static List getFilesRecursively(final File dir, final String[] extensions) {
FileFilter filter = null;
if (extensions[0].equals(".sql")) {
filter = new ExtensionFilter(extensions);
}
return SQLEngineFileReader.getFilesRecursively(dir, filter);
}
protected static File getFileByName(final File dir, final String fileName) {
final String extension = fileName.substring(fileName.lastIndexOf("."),
fileName.length());
final List files = SQLEngineFileReader.getFilesRecursively(dir, new String[] { extension });
if (files != null) {
final Iterator iter = files.iterator();
while (iter.hasNext()) {
final File sqlFile = (File) iter.next();
if ((sqlFile != null) &&
sqlFile.getName().equalsIgnoreCase(fileName)) {
return sqlFile;
}
}
}
return null;
}
}

View File

@ -1,285 +0,0 @@
/*
* 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]
*/
/*
* @(#)SQLMapEntry.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc;
import java.util.logging.Logger;
import javax.jbi.servicedesc.ServiceEndpoint;
import javax.wsdl.Definition;
import javax.wsdl.Operation;
import javax.wsdl.Output;
import javax.wsdl.PortType;
import javax.xml.namespace.QName;
import com.sun.jbi.eManager.provider.EndpointStatus;
import com.sun.jbi.internationalization.Messages;
import java.util.logging.Level;
/**
* Used by SQLSE.
* Data structure to hold an entry in the sqlmap file.
*/
public final class SQLMapEntry {
public static final String REQUEST_REPLY_SERVICE = "requestReplyService";
public static final String FILTER_ONE_WAY = "filterOneWay";
public static final String FILTER_REQUEST_REPLY = "filterRequestReply";
private static final Messages mMessages = Messages.getMessages(SQLMapEntry.class);
private static final Logger mLogger = Messages.getLogger(SQLMapEntry.class);
private String mServiceUnitName;
private String mType;
private QName mPartnerLink;
private QName mPortType;
private QName mOperation;
private QName mService;
private String mSQLFileName;
private String mWSDLFileName;
private String mEndpointStatusId;
private EndpointStatus mEndpointStatus;
private QName mOutPartnerLink;
private QName mOutPortType;
private QName mOutOperation;
private QName mOutService;
private String mReplyFile;
private String mOutEndpointStatusId;
private EndpointStatus mOutEndpointStatus;
private boolean mStarted;
private ServiceEndpoint mServiceEndpoint;
private Definition mWsdl;
private Output mOutput;
/**
* Creates a new instance of SQLMapEntry
*/
private SQLMapEntry(final String serviceUnitName, final String type, final QName partnerLink,
final QName portType, final QName operation, final String sqlfileName,
final String wsdlFileName, final QName outPartnerLink, final QName outPortType,
final QName outOperation, final String replyFile, final Definition wsdl) {
mServiceUnitName = serviceUnitName;
mType = type;
mPartnerLink = partnerLink;
mPortType = portType;
mOperation = operation;
mSQLFileName = sqlfileName;
mWSDLFileName = wsdlFileName;
mOutPartnerLink = outPartnerLink;
mOutPortType = outPortType;
mOutOperation = outOperation;
mReplyFile = replyFile;
mWsdl = wsdl;
String operationName = null;
if (wsdl != null) {
try {
final PortType pType = wsdl.getPortType(portType);
String opName = operation.toString();
if(opName.lastIndexOf(".sql")>0){
StringBuffer sb = new StringBuffer(operation.toString());
operationName = sb.replace(opName.lastIndexOf(".sql"),opName.length(),"").toString().trim();
}else
operationName = operation.toString();
final Operation outop = pType.getOperation(operationName,
null, null);
mOutput = outop.getOutput();
} catch (final Exception ex) {
mLogger.log(Level.SEVERE,"Could not parse the SQLMap",ex);
// failed to get out messages...
mOutput = null;
}
}
}
static SQLMapEntry newRequestReplyService(final String serviceUnitName,
final QName partnerLink, final QName portType, final QName operation, final String sqlfileName,
final String wsdlFileName, final Definition wsdl) {
return new SQLMapEntry(serviceUnitName, SQLMapEntry.REQUEST_REPLY_SERVICE,
partnerLink, portType, operation, sqlfileName, wsdlFileName, null,
null, null, null, wsdl);
}
static SQLMapEntry newFilterOneWay(final String serviceUnitName,
final QName partnerLink, final QName portType, final QName operation, final String sqlFileName,
final String wsdlFileName, final QName outPartnerLink, final QName outPortType,
final QName outOperation, final Definition wsdl) {
return new SQLMapEntry(serviceUnitName, SQLMapEntry.FILTER_ONE_WAY, partnerLink,
portType, operation, sqlFileName, wsdlFileName, outPartnerLink,
outPortType, outOperation, null, wsdl);
}
static SQLMapEntry newFilterRequestReply(final String serviceUnitName,
final QName partnerLink, final QName portType, final QName operation, final String sqlFileName,
final String wsdlFileName, final QName outPartnerLink, final QName outPortType,
final QName outOperation, final String replyFile, final Definition wsdl) {
return new SQLMapEntry(serviceUnitName, SQLMapEntry.FILTER_REQUEST_REPLY,
partnerLink, portType, operation, sqlFileName, wsdlFileName,
outPartnerLink, outPortType, outOperation, replyFile, wsdl);
}
protected String getServiceUnitName() {
return mServiceUnitName;
}
private String getType() {
assert mType != null;
return mType;
}
QName getPartnerLink() {
assert mPartnerLink != null;
return mPartnerLink;
}
QName getPortType() {
return mPortType;
}
QName getOperation() {
return mOperation;
}
protected void setService(final QName service) {
assert service != null;
assert mService == null; // can only set once
mService = service;
}
QName getService() {
return mService;
}
QName getOutPartnerLink() {
return mOutPartnerLink;
}
QName getOutPortType() {
return mOutPortType;
}
QName getOutOperation() {
return mOutOperation;
}
protected void setOutService(final QName outService) {
assert outService != null;
assert mOutService == null; // can only set once
mOutService = outService;
}
private QName getOutService() {
return mOutService;
}
private boolean hasReplyFile() {
return mReplyFile != null;
}
private String getReplyFile() {
assert mReplyFile != null;
return mReplyFile;
}
protected void setStarted(final boolean started) {
mStarted = started;
}
private boolean isStarted() {
return mStarted;
}
protected void setServiceEndpoint(final ServiceEndpoint endpointRef) {
mServiceEndpoint = endpointRef;
}
ServiceEndpoint getServiceEndpoint() {
return mServiceEndpoint;
}
protected void setEndpointStatus(final String endpointStatusId,
final EndpointStatus endpointStatus) {
mEndpointStatusId = endpointStatusId;
mEndpointStatus = endpointStatus;
}
String getEndpointStatusId() {
return mEndpointStatusId;
}
private EndpointStatus getEndpointStatus() {
return mEndpointStatus;
}
protected void setOutEndpointStatus(final String outEndpointStatusId,
final EndpointStatus outEndpointStatus) {
mOutEndpointStatusId = outEndpointStatusId;
mOutEndpointStatus = outEndpointStatus;
}
String getOutEndpointStatusId() {
return mOutEndpointStatusId;
}
private EndpointStatus getOutEndpointStatus() {
return mOutEndpointStatus;
}
Definition getWsdl() {
return mWsdl;
}
private void setWsdl(final Definition wsdl) {
mWsdl = wsdl;
}
private Output getOutput() {
return mOutput;
}
private void setOutput(final Output output) {
mOutput = output;
}
String getSQLFileName() {
return mSQLFileName;
}
private void setSQLFileName(final String mSQLFileName) {
this.mSQLFileName = mSQLFileName;
}
String getWSDLFileName() {
return mWSDLFileName;
}
private void setWSDLFileName(final String mWSDLFileName) {
this.mWSDLFileName = mWSDLFileName;
}
}

View File

@ -1,101 +0,0 @@
/*
* 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]
*/
/*
* @(#)SQLMapEntryTable.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc;
import java.util.*;
import javax.xml.namespace.QName;
public class SQLMapEntryTable {
private List<SQLMapEntry> mEntryList;
public SQLMapEntryTable() {
mEntryList = new ArrayList<SQLMapEntry>();
}
private SQLMapEntry findSQLEntry(final QName operation, final QName service) {
// Search by operation's fullname and service's fullname
for (final Iterator i = mEntryList.iterator(); i.hasNext();) {
final SQLMapEntry sqlMapEntry = (SQLMapEntry) i.next();
final QName entryOperation = sqlMapEntry.getOperation();
final QName entryService = sqlMapEntry.getService();
if (entryOperation.equals(operation) &&
entryService.equals(service)) {
return sqlMapEntry;
}
}
// Cannot find anything that matches operation's fullname and service's fullname
// Now search by operation's localname and service's fullname
for (final Iterator i = mEntryList.iterator(); i.hasNext();) {
final SQLMapEntry sqlMapEntry = (SQLMapEntry) i.next();
final QName entryOperation = sqlMapEntry.getOperation();
final QName entryService = sqlMapEntry.getService();
if (entryOperation.getLocalPart().equals(operation.getLocalPart()) &&
entryService.equals(service)) {
return sqlMapEntry;
}
}
return null;
}
protected void addEntry(final SQLMapEntry entry) {
if (!mEntryList.contains(entry)) {
mEntryList.add(entry);
}
}
protected void removeEntry(final SQLMapEntry entry) {
mEntryList.remove(entry);
}
List<SQLMapEntry> getEntryListByServiceUnitName(final String serviceUnitName) {
final ArrayList<SQLMapEntry> list = new ArrayList<SQLMapEntry>();
for (int i = 0, I = mEntryList.size(); i < I; i++) {
final SQLMapEntry entry = mEntryList.get(i);
if (entry.getServiceUnitName().equals(serviceUnitName)) {
list.add(entry);
}
}
return list;
}
List<SQLMapEntry> getEntryList() {
return new ArrayList<SQLMapEntry>(mEntryList);
}
}

View File

@ -1,169 +0,0 @@
/*
* 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]
*/
/*
* @(#)SQLMapReader.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc;
import java.io.File;
import java.util.Hashtable;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.wsdl.Definition;
import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.NodeList;
import com.sun.jbi.internationalization.Messages;
/**
* Used by SQLSE.
* Helper class that reads a sqlmap file and generates SQLMapEntryTable containing
* SQLMapEntry values.
*/
public class SQLMapReader {
private static final Messages mMessages = Messages.getMessages(SQLMapReader.class);
private static final Logger mLogger = Messages.getLogger(SQLMapReader.class);
private static final String SQLMAP_TAG = "sql";
private static final String TYPE_TAG = "type";
private static final String SQL_FILE_TAG = "sqlfile";
private static final String WSDL_FILE_TAG = "wsdlfile";
private static final String PARTNERLINK_TAG = "partnerLink";
private static final String PORTTYPE_TAG = "portType";
private static final String OPERATION_TAG = "operation";
private static final String REPLY_FILE_TAG = "replyFile";
private static final String OUT_PARTNERLINK_TAG = "outPartnerLink";
private static final String OUT_PORTTYPE_TAG = "outPortType";
private static final String OUT_OPERATION_TAG = "outOperation";
protected SQLMapReader() {
}
/**
*
* @param sqlmapfile
* @param sqlMapEntryTable
* @param serviceUnitName
* @param deployDir
* @param wsdlMap
* @return
* @throws org.xml.sax.SAXException
* @throws java.io.IOException
* @throws javax.xml.parsers.ParserConfigurationException
*/
protected static SQLMapEntryTable parse(final File sqlmapfile,
final SQLMapEntryTable sqlMapEntryTable, final String serviceUnitName,
final File deployDir, final Hashtable wsdlMap)
throws org.xml.sax.SAXException, java.io.IOException,
javax.xml.parsers.ParserConfigurationException {
assert sqlmapfile != null;
assert sqlMapEntryTable != null;
final Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder()
.parse(sqlmapfile);
final Element elem = doc.getDocumentElement();
final NodeList portmaps = elem.getElementsByTagName(SQLMapReader.SQLMAP_TAG);
for (int i = 0; i < portmaps.getLength(); i++) {
final NamedNodeMap values = portmaps.item(i).getAttributes();
final String type = values.getNamedItem(SQLMapReader.TYPE_TAG).getNodeValue();
final QName partnerLink = SQLMapReader.getQName(values.getNamedItem(SQLMapReader.PARTNERLINK_TAG)
.getNodeValue());
final QName portType = SQLMapReader.getQName(values.getNamedItem(SQLMapReader.PORTTYPE_TAG)
.getNodeValue());
final QName operation = SQLMapReader.getQName(values.getNamedItem(SQLMapReader.OPERATION_TAG)
.getNodeValue());
final String sqlfile = values.getNamedItem(SQLMapReader.SQL_FILE_TAG).getNodeValue();
final String wsdlfile = values.getNamedItem(SQLMapReader.WSDL_FILE_TAG).getNodeValue();
//String fullWSDLFilePath = deployDir.getAbsolutePath() + File.separator + wsdlfile;
QName outPartnerLink = null;
QName outPortType = null;
QName outOperation = null;
String replyFile = null;
String fullReplyFilePath = null;
SQLMapEntry entry = null;
final Definition wsdl = (Definition) wsdlMap.get(portType);
if (SQLMapEntry.REQUEST_REPLY_SERVICE.equals(type)) {
entry = SQLMapEntry.newRequestReplyService(serviceUnitName,
partnerLink, portType, operation, sqlfile, wsdlfile,
wsdl);
sqlMapEntryTable.addEntry(entry);
continue;
}
if (SQLMapEntry.FILTER_ONE_WAY.equals(type)) {
outPartnerLink = SQLMapReader.getQName(values.getNamedItem(
SQLMapReader.OUT_PARTNERLINK_TAG).getNodeValue());
outPortType = SQLMapReader.getQName(values.getNamedItem(SQLMapReader.OUT_PORTTYPE_TAG)
.getNodeValue());
outOperation = SQLMapReader.getQName(values.getNamedItem(SQLMapReader.OUT_OPERATION_TAG)
.getNodeValue());
entry = SQLMapEntry.newFilterOneWay(serviceUnitName,
partnerLink, portType, operation, sqlfile, wsdlfile,
outPartnerLink, outPortType, outOperation, wsdl);
sqlMapEntryTable.addEntry(entry);
continue;
}
if (SQLMapEntry.FILTER_REQUEST_REPLY.equals(type)) {
outPartnerLink = SQLMapReader.getQName(values.getNamedItem(
SQLMapReader.OUT_PARTNERLINK_TAG).getNodeValue());
outPortType = SQLMapReader.getQName(values.getNamedItem(SQLMapReader.OUT_PORTTYPE_TAG)
.getNodeValue());
outOperation = SQLMapReader.getQName(values.getNamedItem(SQLMapReader.OUT_OPERATION_TAG)
.getNodeValue());
replyFile = values.getNamedItem(SQLMapReader.REPLY_FILE_TAG).getNodeValue();
fullReplyFilePath = deployDir.getAbsolutePath() +
File.separator + replyFile;
entry = SQLMapEntry.newFilterRequestReply(serviceUnitName,
partnerLink, portType, operation, sqlfile, wsdlfile,
outPartnerLink, outPortType, outOperation,
fullReplyFilePath, wsdl);
sqlMapEntryTable.addEntry(entry);
continue;
}
}
mLogger.log(Level.FINE, mMessages.getString("SQLSE_C00150.SQLMR_PARSE_SUCCESS"),
sqlmapfile.getAbsolutePath());
return sqlMapEntryTable;
}
private static QName getQName(final String qname) {
return QName.valueOf(qname);
}
}

View File

@ -1,593 +0,0 @@
/*
* 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]
*/
/*
* @(#)SQLSELifeCycle.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
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.component.ServiceUnitManager;
import javax.jbi.management.MBeanNames;
import javax.jbi.messaging.DeliveryChannel;
import javax.jbi.messaging.MessageExchange;
import javax.jbi.messaging.MessagingException;
import javax.jbi.servicedesc.ServiceEndpoint;
import javax.management.MBeanServer;
import javax.management.ObjectName;
import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.DocumentFragment;
import org.xml.sax.SAXException;
import com.sun.jbi.configuration.RuntimeConfigurationHelper;
import com.sun.jbi.eManager.provider.StatusProviderHelper;
import com.sun.jbi.eManager.provider.StatusProviderMBean;
import com.sun.jbi.internationalization.Messages;
import com.sun.jbi.alerter.NotificationEvent;
import com.sun.jbi.jdbcbc.util.AlertsUtil;
import com.sun.jbi.jdbcbc.util.ReadWriteTextFile;
import javax.management.NotificationListener;
import javax.management.Notification;
import javax.management.AttributeChangeNotification;
import com.sun.jbi.common.qos.messaging.MessagingChannel;
import com.sun.jbi.common.qos.messaging.BaseMessagingChannel;
/**
* SE life cycle implementation of the jbi framework
*
*/
public class SQLSELifeCycle implements ComponentLifeCycle, Component {
private static final Messages mMessages = Messages.getMessages(SQLSELifeCycle.class);
private static Logger mLogger = Messages.getLogger(SQLSELifeCycle.class);
private static final Map<String,SQLSELifeCycle> initializedLifeCycles = new HashMap<String,SQLSELifeCycle>();
// A short display name
public static final String SHORT_DISPLAY_NAME = "SQL SE";
private JDBCComponentContext mContext = JDBCComponentContext.getInstance();
private OutboundReceiver mOutboundReceiver;
// private InboundReceiver mInboundReceiver;
private Thread mOutboundReceiverThread;
Map<String,EndpointBean> mEndpoints = new HashMap<String,EndpointBean>();
Map mEndpointMapping = new HashMap();
private ObjectName mExtensionMBeanName;
private MessagingChannel mChannel;
private ObjectName mDeployerMBeanName;
private SQLSEServiceUnitManager mSQLSUDeployer;
private StatusProviderHelper mStatusProviderHelper;
private SQLSERuntimeConfiguration mRuntimeConfig;
private RuntimeConfigurationHelper mRuntimeConfigHelper;
private SQLMapEntryTable mSQLMapEntryTable;
private ObjectName mProcessingExtensionMBeanName;
// JBI MBean type
static final String PROCESSING_EXTENSION = "ProcessingExtension"; // NOI18N
// "Official" Performance Instrumentation Categories
public static final String PERF_CAT_NORMALIZATION = "Normalization"; // NOI18N
public static final String PERF_CAT_DENORMALIZATION = "Denormalization"; // NOI18N
public static final String [] SQLSE_PERF_CATEGORIES =
new String[] {PERF_CAT_NORMALIZATION,
PERF_CAT_DENORMALIZATION};
public SQLSELifeCycle() {
}
//@Override
public ComponentLifeCycle getLifeCycle() {
return this;
}
//@Override
public ServiceUnitManager getServiceUnitManager() {
return mSQLSUDeployer;
}
private ObjectName getDeploymentMBeanName() {
return mDeployerMBeanName;
}
//@Override
public ObjectName getExtensionMBeanName() {
return mExtensionMBeanName;
}
//@Override
public void init(final ComponentContext jbiContext) throws JBIException {
if (jbiContext == null) {
throw new JBIException("Component Context is null");
}
mContext.setContext(jbiContext);
Messages.registerContext(mContext.getContext());
SQLSELifeCycle.mLogger = Messages.getLogger(SQLSELifeCycle.class);
SQLSELifeCycle.initializedLifeCycles.put(mContext.getContext().getComponentName(), this);
final MBeanServer mbServer = jbiContext.getMBeanServer();
final MBeanNames mbnHndl = jbiContext.getMBeanNames();
mProcessingExtensionMBeanName = mbnHndl.createCustomComponentMBeanName(PROCESSING_EXTENSION);
try {
//mChannel = mContext.getDeliveryChannel();
mChannel = new BaseMessagingChannel(mContext.getContext());
mContext.setBindingChannel(mChannel);
} catch(MessagingException me) {
String text = mMessages.getString("JDBCBC-E00141.No_binding_channel", me.getLocalizedMessage());
mLogger.log(Level.SEVERE, text, me);
AlertsUtil.getAlerter().critical(text,
JDBCBindingLifeCycle.SHORT_DISPLAY_NAME,
null,
AlertsUtil.getServerType(),
AlertsUtil.COMPONENT_TYPE_BINDING,
NotificationEvent.OPERATIONAL_STATE_RUNNING,
NotificationEvent.EVENT_TYPE_ALERT,
"JDBCBC-E00141");
throw me;
}
mSQLMapEntryTable = new SQLMapEntryTable();
mSQLSUDeployer = new SQLSEServiceUnitManager(mContext, this,
mSQLMapEntryTable);
try {
mStatusProviderHelper = new StatusProviderHelper(SQLSELifeCycle.SHORT_DISPLAY_NAME,
StatusProviderMBean.COMPONENT_TYPE_ENGINE,
jbiContext.getComponentName(), jbiContext.getMBeanServer());
mStatusProviderHelper.registerMBean();
if (SQLSELifeCycle.mLogger.isLoggable(Level.INFO)) {
SQLSELifeCycle.mLogger.log(Level.INFO, mMessages.getString("SQLSE_R00121.SQLSELC_Register_mbean"),
jbiContext.getComponentName());
}
} catch (final Exception ex) {
SQLSELifeCycle.mLogger.log(Level.WARNING, mMessages.getString("SQLSE_E00122.SQLSELC_Failed_register_mbean"), ex);
throw new JBIException(SQLSELifeCycle.mMessages.getString(
"SQLSELC_Failed_register_mbean"), ex);
}
try {
ObjectName statusMBeanObjName = mbnHndl.createCustomComponentMBeanName("Statistics");
mStatusProviderHelper = new StatusProviderHelper(SHORT_DISPLAY_NAME, statusMBeanObjName, jbiContext.getMBeanServer());
mStatusProviderHelper.registerMBean(SQLSE_PERF_CATEGORIES, new SQLSEPerformanceMeasurement());
if (mLogger.isLoggable(Level.FINE)) {
mLogger.log(Level.FINE, "Registered Status Provider MBean for " + jbiContext.getComponentName());
}
} catch (Exception ex) {
String text = mMessages.getString("SQLSE_E00122.SQLSELC_Failed_register_mbean", ex.getMessage());
AlertsUtil.getAlerter().critical(text,
SHORT_DISPLAY_NAME,
null,
AlertsUtil.getServerType(),
AlertsUtil.COMPONENT_TYPE_ENGINE,
NotificationEvent.OPERATIONAL_STATE_RUNNING,
NotificationEvent.EVENT_TYPE_ALERT,
"SQLSE_E00122");
throw new JBIException(text, ex);
}
try {
// add the details for the component configuration using the templates...
String configData = "";
String configSchema = "";
String configDataFileLoc = jbiContext.getInstallRoot() + File.separator
+"META-INF" + File.separator + "componentConfiguration.xml";
File configDataFile = new File(configDataFileLoc);
if (configDataFile.exists()) {
configData = ReadWriteTextFile.getContents(configDataFile);
}
String configSchemaFileLoc = jbiContext.getInstallRoot() + File.separator
+"META-INF" + File.separator + "componentConfiguration.xsd";
File configSchemaFile = new File(configSchemaFileLoc);
if (configSchemaFile.exists()) {
configSchema = ReadWriteTextFile.getContents(configSchemaFile);
}
mRuntimeConfig = new SQLSERuntimeConfiguration(mContext.getContext().getWorkspaceRoot());
// set the config schema and config data on the runtime configuration
mRuntimeConfig.setConfigurationDisplayData(configData);
mRuntimeConfig.setConfigurationDisplaySchema(configSchema);
mRuntimeConfigHelper = new RuntimeConfigurationHelper(RuntimeConfigurationHelper.COMPONENT_TYPE_ENGINE,
jbiContext.getComponentName(), jbiContext.getMBeanServer());
mRuntimeConfigHelper.registerMBean(mRuntimeConfig);
if (SQLSELifeCycle.mLogger.isLoggable(Level.INFO)) {
SQLSELifeCycle.mLogger.log(Level.INFO, mMessages.getString("SQLSE_R00123.SQLSELC_Register_config_mbean"),
jbiContext.getComponentName());
}
// Subscribe for changes to the configuration
mRuntimeConfig.addNotificationListener(listener, null, null);
} catch (final Exception ex) {
SQLSELifeCycle.mLogger.log(Level.WARNING, mMessages.getString("SQLSE_E00124.SQLSELC_Failed_register_config_mbean"),
ex);
throw new JBIException(mMessages.getString(
"SQLSE_E00124.SQLSELC_Failed_register_config_mbean"), ex);
}
//try {
mChannel = mContext.getBindingChannel();
/*} catch (final MessagingException me) {
mLogger.log(Level.SEVERE, mMessages.getString("SQLSE_E00125.SQLSELC_Failed_DC"), me);
String text = mMessages.getString("SQLSE_E00122.SQLSELC_Failed_register_mbean", me.getLocalizedMessage());
AlertsUtil.getAlerter().critical(text,
SHORT_DISPLAY_NAME,
null,
AlertsUtil.getServerType(),
AlertsUtil.COMPONENT_TYPE_ENGINE,
NotificationEvent.OPERATIONAL_STATE_RUNNING,
NotificationEvent.EVENT_TYPE_ALERT,
"SQLSE_E00122");
throw me;
}*/
try {
startOutbound();
// startInbound();
} catch (final Exception ex) {
mLogger.log(Level.SEVERE, mMessages.getString("SQLSE_R00126.SQLSELC_Failed_start_SE"), ex);
throw new JBIException(mMessages.getString(
"SQLSE_R00126.SQLSELC_Failed_start_SE") + ex.getMessage(), ex);
}
}
//@Override
public void shutDown() throws JBIException {
SQLSELifeCycle.mLogger.log(Level.INFO, "SQLSELC_Shutdown_SE");
try {
stopOutbound();
//stopInbound();
} catch (final Exception ex) {
mLogger.log(Level.SEVERE, "SQLSELC_Failed_stop_SE", ex);
throw new JBIException(mMessages.getString("SQLSELC_Failed_stop_SE") +
ex.getMessage(), ex);
}
if (mChannel != null) {
mChannel.close();
}
try {
mStatusProviderHelper.unregisterMBean();
} catch (final Exception ex) {
mLogger.log(Level.WARNING,
"Failed to un-register status provider MBean for " +
mContext.getContext().getComponentName(), ex);
throw new JBIException(
"Failed to un-register status provider MBean for " +
mContext.getContext().getComponentName(), ex);
}
try {
mRuntimeConfigHelper.unregisterMBean();
} catch (final Exception ex) {
mLogger.log(Level.WARNING, "SQLSELC_Failed_unregister_mbean",
mContext.getContext().getComponentName());
throw new JBIException(mMessages.getString(
"SQLSELC_Failed_unregister_mbean") +
mContext.getContext().getComponentName(), ex);
}
SQLSELifeCycle.initializedLifeCycles.remove(mContext.getContext().getComponentName());
SQLSELifeCycle.mLogger.log(Level.INFO, mMessages.getString("SQLSE_R00128.SQLSELC_Shutdown_SE_DONE") );
}
//@Override
public void start() throws JBIException {
SQLSELifeCycle.mLogger.log(Level.INFO, mMessages.getString("SQLSE_R00129.SQLSELC_started") );
}
//@Override
public void stop() throws JBIException {
SQLSELifeCycle.mLogger.log(Level.INFO, mMessages.getString("SQLSE_R00130.SQLSELC_stopped") );
}
//@Override
public boolean isExchangeWithConsumerOkay(final ServiceEndpoint endpoint,
final MessageExchange exchange) {
// TODO: check whether operation on endpoint actually exists.
return true;
}
//@Override
public boolean isExchangeWithProviderOkay(final ServiceEndpoint endpoint,
final MessageExchange exchange) {
return false;
}
//@Override
public Document getServiceDescription(final ServiceEndpoint endpoint) {
Document result = null;
// TODO: The document returned should be a stand-alone document (no imports or includes)
// TODO: consider whether it should only return the abstract wsdl concerning the endpoint
// TODO: Beware for service engines that they HAVE TO include a specific binding type defined for Service Engines
final String uniqueName = EndpointBean.getUniqueName(endpoint.getServiceName()
.toString(),
endpoint.getEndpointName(), EndpointBean.ENDPOINT_TYPE_OUTBOUND);
final DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
final DocumentBuilder documentBuilder = null;
final EndpointBean foundEndpoint = mEndpoints.get(uniqueName);
if (foundEndpoint == null) {
SQLSELifeCycle.mLogger.log(Level.INFO, mMessages.getString("SQLSE_R00139.SQLSELC_FAILED_LOCATE_EP") );
} else {
try {
final File matchedWSDL = (File) foundEndpoint.getValueObj(EndpointBean.WSDL_FILE);
//result = (Document) foundEndpoint
// .getValueObj(EndpointBean.DESCRIPTOR);
result = documentBuilder.parse(matchedWSDL);
} catch (final SAXException ex) {
mLogger.log(Level.INFO, mMessages.getString("SQLSE_R00140.SQLSELC_FAILED_SAX") );
} catch (final IOException exIO) {
mLogger.log(Level.INFO, mMessages.getString("SQLSE_R00141.SQLSELC_FAILED_IO") );
//throw exIO;
} catch (final Exception exception) {
mLogger.log(Level.SEVERE, mMessages.getString("SQLSE_R00142.SQLSELC_FAILED_Ex") );
//throw exception;
}
}
return result;
}
//@Override
public ServiceEndpoint resolveEndpointReference(final DocumentFragment fragment) {
// Currently we do not support dynamic endpoints
return null;
}
StatusProviderHelper getStatusProviderHelper() {
return mStatusProviderHelper;
}
private static SQLSELifeCycle getInstanceForId(final String componentName) {
return SQLSELifeCycle.initializedLifeCycles.get(componentName);
}
private DeliveryChannel getDeliveryChannel() {
return mChannel;
}
private EndpointBean getEndpointBeanForContext(final String context) {
return (EndpointBean) mEndpointMapping.get(context);
}
protected void activateEndpoints(final EndpointBean[] endpoints) throws MessagingException {
SQLSELifeCycle.mLogger.log(Level.INFO, mMessages.getString("SQLSE_R00135.SQLSELC_START_EP_ACTIVATE") );
EndpointBean currEndpoint = null;
for (EndpointBean element : endpoints) {
currEndpoint = element;
final String uniqueName = currEndpoint.getUniqueName();
mEndpoints.put(uniqueName, currEndpoint);
// For inbound endpoints, build an additional mapping from the URL context to the endpoint
/*if (currEndpoint.getValue(EndpointBean.ENDPOINT_TYPE)
.equals(EndpointBean.ENDPOINT_TYPE_INBOUND)) {
try {
mInboundReceiver.addInboundMessageProcessor(currEndpoint);
} catch (final FaultException ex) {
SQLSELifeCycle.mLogger.log(Level.SEVERE,
"SQLSELC_SU_Failed_start_inbound_EP",
new Object[] { uniqueName, ex.getMessage() });
} catch (final JBIException me) {
SQLSELifeCycle.mLogger.log(Level.SEVERE, "SQLSELC_FAILED_EP_ACTIVATE",
new Object[] { uniqueName, me.getMessage() });
}
} else
*/
if (EndpointBean.ENDPOINT_TYPE_OUTBOUND.equals(
currEndpoint.getValue(EndpointBean.ENDPOINT_TYPE))) {
// Activate an outbound endpoint
try {
final QName fullServiceName = (QName) currEndpoint.getValueObj(EndpointBean.FULL_SERVICE_NAME);
final ServiceEndpoint endpointReference = mContext.getContext().activateEndpoint(fullServiceName,
currEndpoint.getValue(EndpointBean.ENDPOINT_NAME));
currEndpoint.setValueObj(EndpointBean.ENDPOINT_REFERENCE,
endpointReference);
if (mLogger.isLoggable(Level.INFO)) {
mLogger.log(Level.INFO,
"Activated outbound endpoint " + uniqueName);
}
} catch (final JBIException me) {
mLogger.log(Level.SEVERE, mMessages.getString("SQLSE_R00138.SQLSELC_FAILED_EP_ACTIVATE"),
new Object[] { uniqueName, me.getMessage() });
}
}
currEndpoint.setValue(EndpointBean.STATUS,
EndpointBean.STATUS_RUNNING);
}
SQLSELifeCycle.mLogger.log(Level.INFO, mMessages.getString("SQLSE_R00319.SQLSESU_ENDPOINT_ACTIVATED"));
}
private void deactivateEndpoints(final EndpointBean[] endpoints)
throws MessagingException {
EndpointBean currEndpoint = null;
SQLSELifeCycle.mLogger.log(Level.INFO, mMessages.getString("SQLSE_R00143.SQLSELC_START_EP_DEACTIVATE") );
for (EndpointBean element : endpoints) {
currEndpoint = element;
final String uniqueName = currEndpoint.getUniqueName();
mEndpoints.remove(uniqueName);
/*if (currEndpoint.getValue(EndpointBean.ENDPOINT_TYPE)
.equals(EndpointBean.ENDPOINT_TYPE_INBOUND)) {
try {
final ServiceEndpoint endpointReference = (ServiceEndpoint) currEndpoint.getValueObj(EndpointBean.ENDPOINT_REFERENCE);
mContext.deactivateEndpoint(endpointReference);
} catch (final JBIException me) {
SQLSELifeCycle.mLogger.log(Level.SEVERE, "SQLSELC_FAILED_EP_DEACTIVATE",
new Object[] { uniqueName, me.getMessage() });
}
mInboundReceiver.removeInboundMessageProcessor(currEndpoint);
} else */
if(currEndpoint.getValue(EndpointBean.ENDPOINT_TYPE)
.equals(EndpointBean.ENDPOINT_TYPE_OUTBOUND)){
try {
final ServiceEndpoint endpointReference = (ServiceEndpoint) currEndpoint.getValueObj(EndpointBean.ENDPOINT_REFERENCE);
mContext.getContext().deactivateEndpoint(endpointReference);
} catch (final JBIException me) {
SQLSELifeCycle.mLogger.log(Level.SEVERE, mMessages.getString("SQLSE_R00144.SQLSELC_FAILED_EP_DEACTIVATE"),
new Object[] { uniqueName, me.getMessage() });
}
}
currEndpoint.setValue(EndpointBean.STATUS,
EndpointBean.STATUS_STOPPED);
}
SQLSELifeCycle.mLogger.log(Level.INFO, mMessages.getString("SQLSE_R00145.SQLSELC_EP_DEACTIVATE") );
}
/*void startInbound() throws JBIException {
mInboundReceiver = new InboundReceiver(mChannel, mEndpoints,
mRuntimeConfig, mContext);
SQLSELifeCycle.mLogger.log(Level.INFO, "SQLSELC_START_INBOUND");
}*/
private void startOutbound() throws JBIException {
mOutboundReceiver = new OutboundReceiver(mChannel, mEndpoints,
mRuntimeConfig, mContext);
mOutboundReceiverThread = new Thread(mOutboundReceiver);
mOutboundReceiverThread.start();
SQLSELifeCycle.mLogger.log(Level.INFO, mMessages.getString("SQLSE_R00147.SQLSELC_START_OUTBOUND") );
}
/*void stopInbound() {
if (mInboundReceiver != null) {
mInboundReceiver.stopReceiving();
}
SQLSELifeCycle.mLogger.log(Level.INFO, "SQLSELC_STOP_INBOUND");
}*/
private void stopOutbound() {
if (mOutboundReceiver != null) {
mOutboundReceiver.stopReceiving();
}
SQLSELifeCycle.mLogger.log(Level.INFO, mMessages.getString("SQLSE_R00149.SQLSELC_STOP_OUTBOUND") );
}
/*private void populateEndpointWSDLInfo(EndpointStatus endpointStatus, Endpoint endpoint) throws Exception {
// Set the resource info on the endpoint status if it is available
Map importedResources = new HashMap();
Transformer transformer = mTransformerPool.retrieve();
if (endpointStatus != null) {
javax.wsdl.Definition originalWsdlDef = endpoint.getServiceDescriptor();
StringWriter originalWsdl = new StringWriter();
WSDLFactory wsdlFactory = (WSDLFactory)WSDLFactory.newInstance();
WSDLWriter writer = (WSDLWriter)wsdlFactory.newWSDLWriter();
writer.writeWSDL(originalWsdlDef, originalWsdl);
endpointStatus.setWSDLDefinition(originalWsdl.toString());
for (Iterator imports = endpoint.getImportedWSDLDefinitions().values().iterator(); imports.hasNext();) {
Definition aImportedWSDL = (Definition) imports.next();
if (aImportedWSDL != null) {
StringWriter sWriter = new StringWriter();
writer.writeWSDL(aImportedWSDL, sWriter);
importedResources.put(aImportedWSDL.getTargetNamespace(), sWriter.toString());
}
}
for (Iterator imports = endpoint.getImportedXSDSchemas().values().iterator(); imports.hasNext();) {
Element aImportedSchema = (Element) imports.next();
if (aImportedSchema != null) {
Source src = new DOMSource(aImportedSchema);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
StreamResult dest = new StreamResult(baos);
transformer.transform(src, dest);
importedResources.put(aImportedSchema.getAttribute("targetNamespace"), baos.toString());
}
}
endpointStatus.setWSDLImportedResources(importedResources);
mTransformerPool.relinquish(transformer);
}
}*/
// Inner class to handle configuration change notifications
private NotificationListener listener = new NotificationListener() {
public void handleNotification(Notification notification, Object obj) {
if (notification instanceof AttributeChangeNotification) {
AttributeChangeNotification attrNotif = (AttributeChangeNotification) notification;
String attrName = attrNotif.getAttributeName();
if (attrName.equals(RuntimeConfiguration.CONFIG_THREADS)) {
Integer newVal = (Integer) (attrNotif.getNewValue());
try{
mRuntimeConfig.setThreads(newVal.intValue());
}catch(Exception me){
mLogger.log(Level.SEVERE, mMessages.getString("SQLSE_E00125.SQLSELC_Failed_DC"), me);
String text = mMessages.getString("SQLSE_E00122.SQLSELC_Failed_register_mbean", me.getLocalizedMessage());
AlertsUtil.getAlerter().critical(text,
SHORT_DISPLAY_NAME,
null,
AlertsUtil.getServerType(),
AlertsUtil.COMPONENT_TYPE_ENGINE,
NotificationEvent.OPERATIONAL_STATE_RUNNING,
NotificationEvent.EVENT_TYPE_ALERT,
"SQLSE_E00122");
//throw me;
}
}
}
}
};
}

View File

@ -1,57 +0,0 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.sun.jbi.jdbcbc;
import javax.management.MBeanException;
import javax.management.openmbean.TabularData;
import javax.management.openmbean.OpenDataException;
import net.java.hulp.measure.Group;
import com.sun.jbi.eManager.provider.PerformanceMeasurement;
/**
*
* @author narayan
*/
public class SQLSEPerformanceMeasurement implements PerformanceMeasurement{
public static final String HTTP_SOAP_BC_SOURCE_FILTER = ".*jdbcbc.*";
/**
* Retrieves the performance insturmentation measurement for the specified endpoint.
* @param endpoint The endpoint name qualified by service name.
* @return An instance of TabularData which holds the performance instrumentation measurement for the specified endpoint.
* @throws OpenDataException if there's an error related to the openmbean data.
* @throws MBeanException if the endpoint does not exist for the component.
*/
public TabularData getPerformanceInstrumentationMeasurement(String endpoint) throws OpenDataException, MBeanException {
Group gr = Group.createGroup();
gr.addPattern(HTTP_SOAP_BC_SOURCE_FILTER, endpoint, getPerfCatFilter());
return gr.fetchData();
}
/**
* Resets the performance measurements on the endpoint.
* @param endpoint The endpoint name qualified by service name.
* @throws MBeanException if the endpoint does not exist for the component.
*/
public void clearPeformaceInstrumentationMeasurement (String endpoint) throws MBeanException {
Group gr = Group.createGroup();
gr.addPattern(HTTP_SOAP_BC_SOURCE_FILTER, endpoint, getPerfCatFilter());
gr.clearData();
}
private String getPerfCatFilter() {
StringBuffer perfCatFilter = new StringBuffer();
for (int i=0; i < SQLSELifeCycle.SQLSE_PERF_CATEGORIES.length; i++) {
perfCatFilter.append(SQLSELifeCycle.SQLSE_PERF_CATEGORIES[i]);
if (i < SQLSELifeCycle.SQLSE_PERF_CATEGORIES.length-1) {
perfCatFilter.append('|');
}
}
return perfCatFilter.toString();
}
}

View File

@ -1,235 +0,0 @@
/*
* 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]
*/
/*
* @(#)SQLSERuntimeConfiguration.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc;
import java.util.Properties;
import java.util.logging.Logger;
import javax.jbi.JBIException;
import javax.management.AttributeChangeNotification;
import javax.management.InvalidAttributeValueException;
import javax.management.ListenerNotFoundException;
import javax.management.MBeanException;
import javax.management.MBeanNotificationInfo;
import javax.management.Notification;
import javax.management.NotificationBroadcasterSupport;
import javax.management.NotificationEmitter;
import javax.management.NotificationFilter;
import javax.management.NotificationListener;
import com.sun.jbi.configuration.ConfigPersistence;
/**
* Runtime configuration MBean, allow configuration to be changed at run-time
*
*/
public class SQLSERuntimeConfiguration implements SQLSERuntimeConfigurationMBean,
NotificationEmitter {
private static final Logger mLogger = Logger.getLogger(SQLSERuntimeConfiguration.class.getName());
// Attribute names
public static final String CONFIG_THREADS = "Threads";
// Default values in the absence of configuration settings
private static final String DEFAULT_THREADS = "16";
// Configuration validation settings
long MIN_THREADS = 1;
long MAX_THREADS = 10000;
// Configuration
Properties mConfig;
String mWorkspaceRoot;
// config schema and config data
private String mConfigSchema;
private String mConfigData;
// Use delegation to support notification
NotificationBroadcasterSupport broadcasterSupport = new NotificationBroadcasterSupport();
/** Creates a new instance of InstallerExt */
SQLSERuntimeConfiguration(final String workspaceRoot) throws JBIException {
mWorkspaceRoot = workspaceRoot;
// Load the persisted configuration
mConfig = ConfigPersistence.loadConfig(workspaceRoot);
}
/**
* @return
*/
//@Override
public Integer getThreads() {
final String val = mConfig.getProperty(SQLSERuntimeConfiguration.CONFIG_THREADS, SQLSERuntimeConfiguration.DEFAULT_THREADS);
return Integer.valueOf(val);
}
/**
*
* @param val
* @throws javax.management.InvalidAttributeValueException
* @throws javax.management.MBeanException
*/
//@Override
public void setThreads(final Integer val)
throws InvalidAttributeValueException, MBeanException {
final String attrName = SQLSERuntimeConfiguration.CONFIG_THREADS;
// Validate the attribute value
Integer newVal = null;
try {
newVal = val;
} catch (final Exception ex) {
throw new InvalidAttributeValueException(
"Invalid argument for setting attribute " + attrName + " :" +
ex.getMessage());
}
if ((newVal.intValue() < MIN_THREADS) ||
(newVal.intValue() > MAX_THREADS)) {
throw new InvalidAttributeValueException("A value of " + newVal +
" is not valid for attribute " + attrName +
". The valid range is " + MIN_THREADS + " - " + MAX_THREADS);
}
// Apply and save the changes
mConfig.put(SQLSERuntimeConfiguration.CONFIG_THREADS, val.toString());
persistConfiguration();
// Notify listeners of this change
final long seqNo = 0;
final String msg = "Attribute changed";
final String attrType = Integer.class.getName();
final Integer oldVal = getThreads();
final Notification notif = new AttributeChangeNotification(this, seqNo,
System.currentTimeMillis(), msg, attrName, attrType, oldVal,
newVal);
broadcasterSupport.sendNotification(notif);
}
/**
*
* @throws MBeanException
*/
private void persistConfiguration() throws MBeanException {
// Persist the changed configuration
try {
ConfigPersistence.persistConfig(mWorkspaceRoot, mConfig);
} catch (final JBIException ex) {
throw new MBeanException(ex,
"Failed to persist configuration to " + mWorkspaceRoot + ": " +
ex.getMessage());
}
}
/**
*
* @return
*/
public MBeanNotificationInfo[] getNotificationInfo() {
return new MBeanNotificationInfo[] {
new MBeanNotificationInfo(new String[] {
AttributeChangeNotification.ATTRIBUTE_CHANGE
}, AttributeChangeNotification.class.getName(),
"Attribute changed")
};
}
/**
*
* @param listener
* @param filter
* @param handback
*/
public void addNotificationListener(final NotificationListener listener,
final NotificationFilter filter, final Object handback) {
broadcasterSupport.addNotificationListener(listener, filter, handback);
}
/**
*
* @param listener
* @throws ListenerNotFoundException
*/
public void removeNotificationListener(final NotificationListener listener)
throws ListenerNotFoundException {
broadcasterSupport.removeNotificationListener(listener);
}
/**
*
* @param listener
* @param filter
* @param handback
* @throws ListenerNotFoundException
*/
//@Override
public void removeNotificationListener(final NotificationListener listener,
final NotificationFilter filter, final Object handback)
throws ListenerNotFoundException {
broadcasterSupport.removeNotificationListener(listener, filter, handback);
}
// addition of the configuration display data
/**
* Retrieves the configuration display schema
*/
public String retrieveConfigurationDisplaySchema() {
return this.mConfigSchema;
}
/**
* Retrieves the configuration display data
*/
public String retrieveConfigurationDisplayData() {
return this.mConfigData;
}
// addition of the configuration display data
/**
* Retrieves the configuration display schema
*/
public void setConfigurationDisplaySchema(String mConfigSchema) {
this.mConfigSchema = mConfigSchema;
}
/**
* Retrieves the configuration display data
*/
public void setConfigurationDisplayData(String mConfigData) {
this.mConfigData = mConfigData;
}
}

View File

@ -1,65 +0,0 @@
/*
* 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]
*/
/*
* @(#)SQLSERuntimeConfigurationMBean.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc;
import javax.management.InvalidAttributeValueException;
import javax.management.MBeanException;
import com.sun.jbi.jdbcbc.util.Description;
/**
* MBean interface for run-time configuration
*
*/
public interface SQLSERuntimeConfigurationMBean {
@Description("get Thread Count")
public Integer getThreads();
@Description("set Thread Count")
public void setThreads(Integer val)
throws InvalidAttributeValueException, MBeanException;
/**
*
* @return
*/
@Description("Retrieves the Configuration Display Schema")
public String retrieveConfigurationDisplaySchema();
/**
*
* @return
*/
@Description("Retrieves the Configuration Display Data")
public String retrieveConfigurationDisplayData();
}

View File

@ -1,59 +0,0 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.sun.jbi.jdbcbc;
import javax.management.openmbean.TabularData;
import javax.management.InvalidAttributeValueException;
import javax.management.openmbean.OpenDataException;
import javax.management.MBeanException;
/**
*
* @author narayan
*/
public interface SQLSEStatusProviderMBean {
/**
* Gets the performance instrumenation measurement categories supported by a component.
* @return An array of String - each entry in the array specifies the category of measurement contained in the performance instrumenation measurement TabularData returned by the component.
*/
public String[] getPerformanceMeasurementCategories();
/**
* Retrieves the performance insturmentation measurement for the specified endpoint.
* @param endpoint The endpoint name qualified by service name.
* @return An instance of TabularData which holds the performance instrumentation measurement for the specified endpoint.
* @throws OpenDataException if there's an error related to the openmbean data.
* @throws MBeanException if the endpoint does not exist for the component.
*/
public TabularData getPerformanceInstrumentationMeasurement(String endpoint) throws OpenDataException, MBeanException;
/**
* Resets the performance measurements on the endpoint.
* @param endpoint The endpoint name qualified by service name.
* @throws MBeanException if the endpoint does not exist for the component.
*/
public void clearPeformaceInstrumentationMeasurement (String endpoint) throws MBeanException;
/**
* Retrieves the main WSDL associated with the specified endpoint.
* @param endpoint The endpoint name qualified by service name.
* @return The content of the main WSDL associated with the given endpoint.
* @throws MBeanException if the endpoint does not exist for the
*/
public String getWSDLDefinition(String endpoint) throws MBeanException;
/**
* Retrieves the imported WSDL or XSD associated with the specified endpoint.
* @param endpoint The endpoint name qualified by service name.
* @return The content of the imported resource, WSDL or XSD associated with the given endpoint.
*/
public String getWSDLImportedResource(String endpoint, String namespace) throws MBeanException;
}

View File

@ -1,127 +0,0 @@
/*
* 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]
*/
/*
* @(#)ThrottlingConfigInfo.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc;
// common-util and qos imports
import com.sun.jbi.common.descriptor.EndpointInfo;
import com.sun.jbi.common.qos.ServiceQuality;
import com.sun.jbi.common.qos.messaging.MessagingChannel;
import com.sun.jbi.common.qos.descriptor.DeploymentLookup;
import com.sun.jbi.common.qos.throttling.ThrottlingConfig;
import com.sun.jbi.management.descriptor.EndpointIdentifier;
import com.sun.jbi.management.descriptor.SUDescriptorSupport;
import java.util.Map;
import java.util.List;
import java.util.Iterator;
/**
* <code>ThrottlingConfigInfo</code>.
* This class is called by the <code>Throttling</code> instance
* that has been put into the ReadyToRunQueue to be scheduled for
* execution when space is available to make the outbound invocation.
* An instance of this class is maintained in the <code>BPELProcessManager</code>
* in a Map with the key being the <code>EndpointInfo</code> associated with
* the outbound invoke activity.
*
* @author <a href="mailto:pVarghese@PVARGHESE-HP"></a>
* @version 1.0
*/
public class ThrottlingConfigInfo {
EndpointInfo mEndpointInfo = null;
int mProcessingCount = 0;
int mThrottleCount = 0;
public ThrottlingConfigInfo(EndpointInfo info, int throttleCount) {
mEndpointInfo = info;
mThrottleCount = throttleCount;
}
/**
* Increment the endpoint processing count.
* This is called when a <code>BPITForThrottling</code>
* instance for this endpoint is picked up for processing
* when space became available.
*
*/
public void incrementProcessingCount() {
mProcessingCount++;
}
/**
* Decrement the throttling endpoint processing count.
* This is called when the outbound invoke activity has
* either completed successfully or has thrown a
* processing exception.
*
*/
public void decrementProcessingCount() {
mProcessingCount--;
}
/**
* Simple check to determine if there is space available to
* process a throttling thread invocation for this endpoint.
* @return boolean: <code>true</code> or <code>false</code>
*/
public boolean isReady() {
if (mThrottleCount > mProcessingCount) {
return true;
}
return false;
}
public void getQOSConfigurations (EndpointBean jdbcbcEndpoint,
EndpointIdentifier endpointIdentifier,
Map <EndpointInfo, List<ServiceQuality>> qosMap) {
if (qosMap != null && qosMap.size() > 0) {
// Until there's a total transitioning to use the common-util, there's a need to
// create EndpointInfo using EndpointIndentifier
EndpointInfo endpointInfo = new EndpointInfo (false,
endpointIdentifier.getEndpointName(),
null,
endpointIdentifier.getServiceName(),
null);
List<ServiceQuality> qoss = qosMap.get(endpointInfo);
Iterator<ServiceQuality> qossIter = qoss.iterator();
while (qossIter.hasNext()) {
ServiceQuality qos = qossIter.next();
// Gather throttling config
if (qos instanceof ThrottlingConfig) {
ThrottlingConfig throttleConfig = (ThrottlingConfig)qos;
jdbcbcEndpoint.setMaxConcurrencyLimit(throttleConfig.getMaxConcurrencyLimit());
}
// Other services....
}
}
}
}

View File

@ -1,70 +0,0 @@
/*
* 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]
*/
/*
* @(#)InstallerExt.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc.bootstrap;
import java.util.logging.Logger;
import com.sun.jbi.internationalization.Messages;
import java.util.logging.Level;
/**
* Installer Extension MBean, allow configuration to be changed before installation
*/
public class InstallerExt implements InstallerExtMBean {
private static final Messages mMessages = Messages.getMessages(InstallerExt.class);
String mThreads;
private Logger mLogger;
/** Creates a new instance of InstallerExt */
public InstallerExt() {
mLogger = Messages.getLogger(InstallerExt.class);
}
/**
*
* @return
*/
//@Override
public String getThreads() {
mLogger.log(Level.INFO,mMessages.getString("SQLSE_R00224.Get_threads"), mThreads);
return mThreads;
}
/**
*
* @param val
*/
//@Override
public void setThreads(final String val) {
mLogger.log(Level.INFO,mMessages.getString("SQLSE_R00225.Set_threads"), val);
mThreads = val;
}
}

View File

@ -1,41 +0,0 @@
/*
* 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]
*/
/*
* @(#)InstallerExtMBean.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc.bootstrap;
/**
* MBean interface
*/
public interface InstallerExtMBean {
public String getThreads();
public void setThreads(String val);
}

View File

@ -1,162 +0,0 @@
/*
* 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]
*/
/*
* @(#)JDBCBindingBootstrap.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc.bootstrap;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.jbi.JBIException;
import javax.jbi.component.Bootstrap;
import javax.jbi.component.ComponentContext;
import javax.jbi.component.InstallationContext;
import javax.jbi.management.MBeanNames;
import javax.management.MBeanServer;
import javax.management.ObjectName;
import javax.management.StandardMBean;
import org.w3c.dom.DocumentFragment;
import com.sun.jbi.configuration.ConfigPersistence;
import com.sun.jbi.internationalization.Messages;
/**
* HTTP SOAP binding component bootstrap implementation for the JBI framework
*/
public class JDBCBindingBootstrap implements Bootstrap {
private static final Messages mMessages = Messages.getMessages(JDBCBindingBootstrap.class);
public static Logger mLogger;
private InstallationContext mContext;
ObjectName mInstallerExtName;
public JDBCBindingBootstrap() {
}
/**
*
* @return
*/
//@Override
public ObjectName getExtensionMBeanName() {
JDBCBindingBootstrap.mLogger.info("Extension MBean name: " + mInstallerExtName);
return mInstallerExtName;
}
/**
*
* @param installContext
* @throws JBIException
*/
//@Override
public void init(final InstallationContext installContext)
throws JBIException {
mContext = installContext;
final ComponentContext ctx = installContext.getContext();
Messages.registerContext(ctx);
mLogger = Messages.getLogger(JDBCBindingBootstrap.class);
mLogger.log(Level.INFO, mMessages.getString("SQLSE_R00214.Calling_init_method") );
final MBeanServer mbServer = ctx.getMBeanServer();
final MBeanNames mbNames = ctx.getMBeanNames();
mInstallerExtName = mbNames.createCustomComponentMBeanName(MBeanNames.BOOTSTRAP_EXTENSION);
final InstallerExtMBean installerExt = new InstallerExt();
try {
if (!ctx.getMBeanServer().isRegistered(mInstallerExtName)) {
final StandardMBean installerExtMBean = new StandardMBean(installerExt,
InstallerExtMBean.class);
ctx.getMBeanServer()
.registerMBean(installerExtMBean, mInstallerExtName);
}
} catch (final Exception ex) {
mLogger.log(Level.WARNING, mMessages.getString("SQLSE_E00103.JDBCBLC_Failed_register_mbean"), ex);
throw new JBIException(mMessages.getString("SQLSE_E00103.JDBCBLC_Failed_register_mbean"), ex);
}
//if(mLogger.isLoggable(Level.INFO))
mLogger.log(Level.INFO,mMessages.getString("SQLSE_R00221.Register_mbean"), mInstallerExtName);
}
/**
*
* @throws JBIException
*/
//@Override
public void onInstall() throws JBIException {
mLogger.log(Level.INFO,mMessages.getString("SQLSE_R00216.Call_onInstall") );
final ComponentContext ctx = mContext.getContext();
final MBeanServer mbServer = ctx.getMBeanServer();
final DocumentFragment descriptorExtension = mContext.getInstallationDescriptorExtension();
final Properties defaultProperties = ConfigPersistence.parseDefaultConfig(descriptorExtension);
ConfigPersistence.persistInitialConfig(mbServer, mInstallerExtName,
ctx.getWorkspaceRoot(), defaultProperties);
//if(mLogger.isLoggable(Level.INFO))
mLogger.log(Level.INFO,mMessages.getString("SQLSE_R00217.Complete_install"));
}
/**
*
* @throws JBIException
*/
//@Override
public void onUninstall() throws JBIException {
//if(mLogger.isLoggable(Level.INFO))
mLogger.log(Level.INFO,mMessages.getString("SQLSE_R00218.Call_onUninstall") );
//if(mLogger.isLoggable(Level.INFO))
mLogger.log(Level.INFO,mMessages.getString("SQLSE_R00219.Complete_uninstall") );
}
/**
*
* @throws JBIException
*/
//@Override
public void cleanUp() throws JBIException {
try {
if (mInstallerExtName != null) {
final ComponentContext ctx = mContext.getContext();
if ((ctx != null) &&
(ctx.getMBeanServer().isRegistered(mInstallerExtName))) {
ctx.getMBeanServer().unregisterMBean(mInstallerExtName);
//if(mLogger.isLoggable(Level.INFO))
mLogger.log(Level.INFO,mMessages.getString("SQLSE_R00102.JDBCBLC_Register_mbean") + mInstallerExtName);
}
}
} catch (final Exception ex) {
mLogger.log(Level.SEVERE,mMessages.getString("SQLSE_E00111.JDBCBLC_Failed_unregister_mbean"),ex);
throw new JBIException("SQLSE_E00111.JDBCBLC_Failed_unregister_mbean" +
mInstallerExtName, ex);
}
}
}

View File

@ -1,57 +0,0 @@
# message id scheme used:
#
# SQLSE -{contextcode:1 character}{domain-messageid:5 digits}
#
# e.g. SQLSE-C00100
#
# context codes:
# C = Configuration information
# R = Runtime information
# W = Warning cautions
# E = Errors
#
# domain-messageids:
# 100s for Life cycle and Bootstrapping
# 200s for Deployer
# 300s for Service Unit
# 600s for Request/Reply processing (InboundReceiver, OutBound, Inbound MessageProcessor)
# 700s for Message processing (Normalizer - DeNormalizer)
# 1000-1100s for Authentication and proxies
# Package specific ResourceBundle properties file
SQLSE_R00214.Calling_init_method=init method is called.
SQLSE_E00215.Failed_register_mbean=Failed to register installer extension MBean.
SQLSE_R00216.Call_onInstall=onInstall method is called.
SQLSE_R00217.Complete_install=Completed installation.
SQLSE_R00218.Call_onUninstall=onUninstall method is called.
SQLSE_R00219.Complete_uninstall=Completed uninstallation.
SQLSE_R00220.Extension_mbean=Extension MBean name\:
SQLSE_R00221.Register_mbean=Registered MBean\:
SQLSE_R00222.Unregister_mbean=Unregistered MBean\:
SQLSE_E00223.Failed_unregister_mbean=Failed to unregister MBean\:
SQLSE_R00224.Get_threads=Get thread\:
SQLSE_R00225.Set_threads=Set thread to\:
############################ resource bundles for JDBCBindingLifeCycle ################
SQLSE_E00101.JDBCBLC_Null_context=Component Context is null.
SQLSE_R00102.JDBCBLC_Register_mbean=Registered Status Provider MBean for {0}.
SQLSE_E00103.JDBCBLC_Failed_register_mbean=Failed to register status provider MBean.
SQLSE_R00104.JDBCBLC_Register_config_mbean=Registered runtime configuration MBean for {0}.
SQLSE_E00105.JDBCBLC_Failed_register_config_mbean=Failed to register configuration MBean.
SQLSE_E00106.JDBCBLC_No_Dev_Channel=Cannot get Delivery Channel from context\: {0}
SQLSE_E00107.JDBCBLC_Failed_start_outbound=Failed to start the outbound receiver\: {0}
SQLSE_E00108.JDBCBLC_Failed_start_inbound=Failed to start the inbound receiver\: {0}
SQLSE_R00109.JDBCBLC_Shutdown_JDBCBC=Shutting down JDBC Binding component.
SQLSE_E00110.JDBCBLC_Failed_stop_outbound=Failed to stop the outbound receiver\:
SQLSE_E00111.JDBCBLC_Failed_unregister_mbean=Failed to un-register status provider MBean for {0}
SQLSE_E00112.JDBCBLC_Failed_unregister_config_mbean=Failed to un-register runtime configuration MBean for {0}
SQLSE_E00113.JDBCBLC_Failed_Complete_JDBCBC_shutdown=JDBC Binding component shutdown completed.
SQLSE_R00114.JDBCBLC_JDBCBC_started=JDBC Binding component started.
SQLSE_R00115.JDBCBLC_JDBCBC_stopped=JDBC Binding component stopped.
SQLSE_R00116.JDBCBLC_started_inbound=Started inbound receiver.
SQLSE_R00117.JDBCBLC_started_outbound=Started outbound receiver.
SQLSE_R00118.JDBCBLC_stopped_outbound=Stopped outbound receiver.
SQLSE_R00119.JDBCBLC_stopped_inbound=Stopped inbound receiver.
SQLSE_E00120.JDBCBLC_Failed_deploy_EndPoint=Failed to deploy the endpoint

View File

@ -1,130 +0,0 @@
/*
* 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]
*/
/*
* @(#)JDBCAddress.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc.extensions;
import java.io.Serializable;
import javax.wsdl.extensions.ExtensibilityElement;
import javax.xml.namespace.QName;
/**
* To change the template for this generated type comment go to
* Window - Preferences - Java - Code Generation - Code and Comments
*/
public class JDBCAddress implements ExtensibilityElement, Serializable {
public static final String ATTR_JNDI_NAME = "jndiName";
public static final String ATTR_DRIVER_NAME = "driverClassName";
public static final String ATTR_URL_NAME = "dbURL";
public static final String ATTR_USER_NAME = "userName";
public static final String ATTR_PASSWORD_NAME = "password";
private static final long serialVersionUID = 1L;
private QName mFieldElementType = JDBCConstants.QNAME_ADDRESS;
private Boolean mFieldRequired = null;
private String mJndiName = null;
private String mPassword = null;
private String mUserName = null;
private String mUrl = null;
private String mDriver = null;
public JDBCAddress() {
}
/**
* @return mFieldElementType
*/
//@Override
public QName getElementType() {
return mFieldElementType;
}
/**
* @return mFieldRequired
*/
//@Override
public Boolean getRequired() {
return mFieldRequired;
}
///@Override
public void setElementType(final QName elementType) {
mFieldElementType = elementType;
}
//@Override
public void setRequired(final Boolean required) {
mFieldRequired = required;
}
protected void setJndiName(final String jndiName) {
mJndiName = jndiName;
}
public String getJndiName() {
return mJndiName;
}
protected void setPassword(final String password) {
mPassword = password;
}
public String getPassword() {
return mPassword;
}
protected void setUserName(final String username) {
mUserName = username;
}
public String getUserName() {
return mUserName;
}
protected void setDBUrl(final String url) {
mUrl = url;
}
public String getDBUrl() {
return mUrl;
}
protected void setDriverClass(final String driver) {
mDriver = driver;
}
public String getDriverClass() {
return mDriver;
}
}

View File

@ -1,76 +0,0 @@
/*
* 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]
*/
/*
* @(#)JDBCBinding.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc.extensions;
import java.io.Serializable;
import javax.wsdl.extensions.ExtensibilityElement;
import javax.xml.namespace.QName;
/**
*
* To change the template for this generated type comment go to
* Window - Preferences - Java - Code Generation - Code and Comments
*/
public class JDBCBinding implements ExtensibilityElement, Serializable {
private static final long serialVersionUID = 2L;
private QName mFieldElementType = JDBCConstants.QNAME_BINDING;
private Boolean mFieldRequired = null;
public JDBCBinding() {
}
/**
* @return mFieldElementType
*/
public QName getElementType() {
return mFieldElementType;
}
/**
* @return mFieldRequired
*/
public Boolean getRequired() {
return mFieldRequired;
}
public void setElementType(final QName elementType) {
mFieldElementType = elementType;
}
public void setRequired(final Boolean required) {
mFieldRequired = required;
}
}

View File

@ -1,61 +0,0 @@
/*
* 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]
*/
/*
* @(#)JDBCConstants.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc.extensions;
import javax.xml.namespace.QName;
import com.ibm.wsdl.Constants;
/**
* To change the template for this generated type comment go to
* Window - Preferences - Java - Code Generation - Code and Comments
*/
public class JDBCConstants {
//Namespaces
public static final String NS_URI_JDBC = "http://schemas.sun.com/jbi/wsdl-extensions/jdbc/";
//Local element names
public static final String ELEM_ADDRESS = "address";
public static final String ELEM_SQL = "sql";
//Qualified element names
public static final QName QNAME_BINDING = new QName(JDBCConstants.NS_URI_JDBC,
Constants.ELEM_BINDING);
public static final QName QNAME_SQL = new QName(JDBCConstants.NS_URI_JDBC, JDBCConstants.ELEM_SQL);
public static final QName QNAME_OPERATION = new QName(JDBCConstants.NS_URI_JDBC,
Constants.ELEM_OPERATION);
public static final QName QNAME_OPERATION_INPUT = new QName(JDBCConstants.NS_URI_JDBC,
Constants.ELEM_INPUT);
public static final QName QNAME_OPERATION_OUTPUT = new QName(JDBCConstants.NS_URI_JDBC,
Constants.ELEM_OUTPUT);
public static final QName QNAME_ADDRESS = new QName(JDBCConstants.NS_URI_JDBC,
JDBCConstants.ELEM_ADDRESS);
}

View File

@ -1,276 +0,0 @@
/*
* 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]
*/
/*
* @(#)JDBCExtSerializer.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc.extensions;
import java.io.PrintWriter;
import java.io.Serializable;
import javax.wsdl.Binding;
import javax.wsdl.BindingInput;
import javax.wsdl.BindingOperation;
import javax.wsdl.BindingOutput;
import javax.wsdl.Definition;
import javax.wsdl.Port;
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.Element;
import com.ibm.wsdl.util.xml.DOMUtils;
/**
*
* To change the template for this generated type comment go to
* Window - Preferences - Java - Code Generation - Code and Comments
*/
public class JDBCExtSerializer implements ExtensionSerializer,
ExtensionDeserializer, Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
/** Creates a new instance of JDBCExtSerializer */
public JDBCExtSerializer() {
}
/**
*
* @param registry
*/
protected void registerSerializer(final ExtensionRegistry registry) {
registry.registerSerializer(Binding.class, JDBCConstants.QNAME_BINDING,
this);
registry.registerDeserializer(Binding.class,
JDBCConstants.QNAME_BINDING, this);
registry.mapExtensionTypes(Binding.class, JDBCConstants.QNAME_BINDING,
JDBCBinding.class);
registry.registerSerializer(BindingOperation.class,
JDBCConstants.QNAME_OPERATION, this);
registry.registerDeserializer(BindingOperation.class,
JDBCConstants.QNAME_OPERATION, this);
registry.mapExtensionTypes(BindingOperation.class,
JDBCConstants.QNAME_OPERATION, JDBCOperation.class);
registry.registerSerializer(BindingInput.class,
JDBCConstants.QNAME_OPERATION_INPUT, this);
registry.registerDeserializer(BindingInput.class,
JDBCConstants.QNAME_OPERATION_INPUT, this);
registry.mapExtensionTypes(BindingInput.class,
JDBCConstants.QNAME_OPERATION_INPUT, JDBCOperationInput.class);
registry.registerSerializer(BindingOutput.class,
JDBCConstants.QNAME_OPERATION_OUTPUT, this);
registry.registerDeserializer(BindingOutput.class,
JDBCConstants.QNAME_OPERATION_OUTPUT, this);
registry.mapExtensionTypes(BindingOutput.class,
JDBCConstants.QNAME_OPERATION_OUTPUT, JDBCOperationOutput.class);
registry.registerSerializer(Port.class, JDBCConstants.QNAME_ADDRESS,
this);
registry.registerDeserializer(Port.class, JDBCConstants.QNAME_ADDRESS,
this);
registry.mapExtensionTypes(Port.class, JDBCConstants.QNAME_ADDRESS,
JDBCAddress.class);
}
/**
* @param parentType
* @param elementType
* @param extension
* @param pw
* @param def
* @param extReg
* @throws WSDLException
*/
//@Override
public void marshall(final Class parentType, final QName elementType,
final ExtensibilityElement extension, final PrintWriter pw, final Definition def,
final ExtensionRegistry extReg) throws WSDLException {
}
/**
* @param parentType
* @param elementType
* @param el
* @param def
* @param extReg
* @return
* @throws WSDLException
*/
//@Override
public ExtensibilityElement unmarshall(final Class parentType, final QName elementType,
final Element el, final Definition def, final ExtensionRegistry extReg)
throws WSDLException {
ExtensibilityElement returnValue = null;
if (JDBCConstants.QNAME_BINDING.equals(elementType)) {
final JDBCBinding jdbcBinding = new JDBCBinding();
returnValue = jdbcBinding;
} else if (JDBCConstants.QNAME_OPERATION.equals(elementType)) {
final JDBCOperation jdbcOperation = new JDBCOperation();
returnValue = jdbcOperation;
} else if (JDBCConstants.QNAME_OPERATION_INPUT.equals(elementType)) {
final JDBCOperationInput input = new JDBCOperationInput();
// JDBCSql jdbcSql = new JDBCSql();
final String operationType = DOMUtils.getAttribute(el,
JDBCOperationInput.ATTR_OPERATION_TYPE);
if (operationType != null) {
input.setOperationType(operationType);
}
final String numberOfRecords = DOMUtils.getAttribute(el,
JDBCOperationInput.ATTR_NUMBER_OF_RECORDS);
if ((numberOfRecords == null) || (numberOfRecords.equals("")) ) {
input.setNumberOfRecords(-1);
} else {
input.setNumberOfRecords(Integer.parseInt(numberOfRecords));
}
input.setParamOrder(DOMUtils.getAttribute(el,
JDBCOperationInput.ATTR_PARAM_ORDER));
input.setSql(DOMUtils.getAttribute(el, JDBCOperationInput.ATTR_SQL));
input.setTableName(DOMUtils.getAttribute(el,
JDBCOperationInput.TABLE_NAME));
input.setPKName(DOMUtils.getAttribute(el, JDBCOperationInput.PK_NAME));
input.setMarkColumnName(DOMUtils.getAttribute(el,
JDBCOperationInput.MARK_COLUMN_NAME));
input.setMoveRowToTableName(DOMUtils.getAttribute(el,
JDBCOperationInput.MOVE_TABLE_NAME));
input.setPollingPostProcessing(DOMUtils.getAttribute(el,
JDBCOperationInput.POLLING_POST_PROCESS));
input.setMarkColumnValue(DOMUtils.getAttribute(el,
JDBCOperationInput.MARK_COLUMN_VALUE));
input.setTransaction(DOMUtils.getAttribute(el,
JDBCOperationInput.TRANSACTION));
final String pollmilliseconds = DOMUtils.getAttribute(el,
JDBCOperationInput.POLLMILLISECONDS);
if ((pollmilliseconds == null) || (pollmilliseconds.equals("")) ) {
input.setPollMilliSeconds(10000);
} else {
input.setPollMilliSeconds(Integer.parseInt(pollmilliseconds));
}
input.setJDBCSql(input);
// unmarshallJDBCInpputChildren(el, input);
returnValue = input;
} else if (JDBCConstants.QNAME_OPERATION_OUTPUT.equals(elementType)) {
final JDBCOperationOutput output = new JDBCOperationOutput();
final String returnPartName = DOMUtils.getAttribute(el,
JDBCOperationOutput.ATTR_RETURN_PART_NAME);
if (returnPartName != null) {
output.setReturnPartName(returnPartName);
}
returnValue = output;
} else if (JDBCConstants.QNAME_ADDRESS.equals(elementType)) {
final JDBCAddress jdbcAddress = new JDBCAddress();
final String jndiName = DOMUtils.getAttribute(el,
JDBCAddress.ATTR_JNDI_NAME);
final String driver = DOMUtils.getAttribute(el,
JDBCAddress.ATTR_DRIVER_NAME);
final String url = DOMUtils.getAttribute(el,
JDBCAddress.ATTR_URL_NAME);
final String user = DOMUtils.getAttribute(el,
JDBCAddress.ATTR_USER_NAME);
final String password = DOMUtils.getAttribute(el,
JDBCAddress.ATTR_PASSWORD_NAME);
if (jndiName != null) {
jdbcAddress.setJndiName(jndiName);
}
if (driver != null) {
jdbcAddress.setDriverClass(driver);
}
if (url != null) {
jdbcAddress.setDBUrl(url);
}
if (user != null) {
jdbcAddress.setUserName(user);
}
if (password != null) {
jdbcAddress.setPassword(password);
}
returnValue = jdbcAddress;
}
return returnValue;
}
/**
*
* @param e1
* @param input
*/
/* public void unmarshallJDBCInpputChildren(Element e1,
JDBCOperationInput input) {
NodeList childNodes = e1.getChildNodes();
JDBCSql mJdbcSql = new JDBCSql();
Element jdbcEle = null;
for (int i = 0; i < childNodes.getLength(); i++) {
Node node = childNodes.item(i);
if (node instanceof Element) {
Element elem = (Element) node;
String localName = elem.getLocalName();
if (localName.equals(JDBCSql.ATTR_SQL)) {
jdbcEle = elem;
break;
}
}
}
mJdbcSql.setParamOrder(DOMUtils.getAttribute(jdbcEle,
JDBCSql.ATTR_PARAM_ORDER));
mJdbcSql.setSql(DOMUtils.getAttribute(jdbcEle, JDBCSql.ATTR_SQL));
mJdbcSql.setTableName(DOMUtils.getAttribute(jdbcEle, JDBCSql.TABLE_NAME));
mJdbcSql.setPKName(DOMUtils.getAttribute(jdbcEle, JDBCSql.PK_NAME));
mJdbcSql.setMarkColumnName(DOMUtils.getAttribute(jdbcEle, JDBCSql.MARK_COLUMN_NAME));
mJdbcSql.setMoveRowToTableName(DOMUtils.getAttribute(jdbcEle, JDBCSql.MOVE_TABLE_NAME));
mJdbcSql.setPollingPostProcessing(DOMUtils.getAttribute(jdbcEle, JDBCSql.POLLING_POST_PROCESS));
mJdbcSql.setMarkColumnValue(DOMUtils.getAttribute(jdbcEle, JDBCSql.MARK_COLUMN_VALUE));
mJdbcSql.setTransaction(DOMUtils.getAttribute(jdbcEle, JDBCSql.TRANSACTION));
input.setJDBCSql(mJdbcSql);
}
*/
}

View File

@ -1,51 +0,0 @@
/*
* 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]
*/
/*
* @(#)JDBCExtensionRegistry.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc.extensions;
import javax.wsdl.extensions.ExtensionRegistry;
/**
*
* To change the template for this generated type comment go to
* Window - Preferences - Java - Code Generation - Code and Comments
*/
public class JDBCExtensionRegistry extends ExtensionRegistry {
private static final long serialVersionUID = 1L;
/** Creates a new instance of FileExtensionRegistry */
public JDBCExtensionRegistry() {
super();
final JDBCExtSerializer jdbcExtSerializer = new JDBCExtSerializer();
jdbcExtSerializer.registerSerializer(this);
}
}

View File

@ -1,78 +0,0 @@
/*
* 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]
*/
/*
* @(#)JDBCOperation.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc.extensions;
import java.io.Serializable;
import javax.wsdl.extensions.ExtensibilityElement;
import javax.xml.namespace.QName;
/**
*
* To change the template for this generated type comment go to
* Window - Preferences - Java - Code Generation - Code and Comments
*/
public class JDBCOperation implements ExtensibilityElement, Serializable {
private static final long serialVersionUID = 1L;
private QName mFieldElementType = JDBCConstants.QNAME_OPERATION;
private Boolean mFieldRequired = null;
public JDBCOperation() {
}
/**
* @return mFieldElementType
*/
//@Override
public QName getElementType() {
return mFieldElementType;
}
/**
* @return mFieldRequired
*/
//@Override
public Boolean getRequired() {
return mFieldRequired;
}
//@Override
public void setElementType(final QName elementType) {
mFieldElementType = elementType;
}
//@Override
public void setRequired(final Boolean required) {
mFieldRequired = required;
}
}

View File

@ -1,285 +0,0 @@
/*
* 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]
*/
/*
* @(#)JDBCOperationInput.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc.extensions;
import java.io.Serializable;
import javax.wsdl.Message;
import javax.wsdl.extensions.ExtensibilityElement;
import javax.xml.namespace.QName;
/**
*
* To change the template for this generated type comment go to
* Window - Preferences - Java - Code Generation - Code and Comments
*/
public class JDBCOperationInput implements ExtensibilityElement, Serializable {
public static final String ATTR_OPERATION_TYPE = "operationType";
public static final String ATTR_NUMBER_OF_RECORDS = "numberOfRecords";
private static final long serialVersionUID = 1L;
/**Changes**/
public static final String ATTR_PARAM_ORDER = "paramOrder";
public static final String ATTR_SQL = "sql";
public static final String PK_NAME = "PKName";
public static final String MARK_COLUMN_NAME = "MarkColumnName";
public static final String TABLE_NAME = "TableName";
public static final String MOVE_TABLE_NAME = "MoveRowToTableName";
public static final String POLLING_POST_PROCESS = "PollingPostProcessing";
public static final String MARK_COLUMN_VALUE = "MarkColumnValue";
public static final String TRANSACTION = "Transaction";
public static final String POLLMILLISECONDS = "PollMilliSeconds";
private QName mFieldElementType = JDBCConstants.QNAME_OPERATION;
private Boolean mFieldRequired = null;
private String mOperationType = null;
public JDBCOperationInput mJdbcSql = null;
private Message mMessage = null;
private int numberOfRecords = -1;
private int pollmilliseconds = 10000;
private String mInputName = null;
//private QName mFieldElementType = JDBCConstants.QNAME_SQL;
private String mParamOrder = null;
private String mSql = null;
private String mMarkColumnName = null;
private String mMarkColumnValue = null;
private String mpkName = null;
private String mTableName = null;
private String mMoveRowToTableName = null;
private String mPollingPostProcessing = null;
private String mTransaction = "NOTransaction";
/***Changes**/
public JDBCOperationInput() {
}
public void setParamOrder(final String paramOrder) {
mParamOrder = paramOrder;
}
/**
*
* @return mParamOrder
*/
public String getParamOrder() {
return mParamOrder;
}
public void setSql(final String sql) {
mSql = sql;
}
/**
*
* @return mSql
*/
public String getSql() {
return mSql;
}
/**
*
* @return mMarkColumnName
*/
public String getMarkColumnName() {
return mMarkColumnName;
}
/**
*
*
* @param markcolumnName
*/
public void setMarkColumnName(final String markcolumnName) {
mMarkColumnName = markcolumnName;
}
/**
*
* @return mMarkColumnName
*/
public String getMarkColumnValue() {
return mMarkColumnValue;
}
/**
*
* @param MarkColumnValue
*/
public void setMarkColumnValue(final String markColumnValue) {
mMarkColumnValue = markColumnValue;
}
/**
*
* @return mpkName
*/
public String getPKName() {
return mpkName;
}
public void setPKName(final String pkName) {
mpkName = pkName;
}
/**
*
* @return mTableName
*/
public String getTableName() {
return mTableName;
}
public void setTableName(final String tableName) {
mTableName = tableName;
}
/**
*
* @return mMoveRowToTableName
*/
public String getMoveRowToTableName() {
return mMoveRowToTableName;
}
protected void setMoveRowToTableName(final String moveRowToTableName) {
mMoveRowToTableName = moveRowToTableName;
}
/**
*
* @return mPollingPostProcessing
*/
public String getPollingPostProcessing() {
return mPollingPostProcessing;
}
public void setPollingPostProcessing(final String pollingPostProcessing) {
mPollingPostProcessing = pollingPostProcessing;
}
/**
*
* @return mTransaction
*/
public String getTransaction() {
return this.mTransaction;
}
public void setTransaction(final String transaction) {
this.mTransaction = transaction;
}
/**
* @return mFieldElementType
*/
//@Override
public QName getElementType() {
return mFieldElementType;
}
/**
* @return mFieldRequired
*/
//@Override
public Boolean getRequired() {
return mFieldRequired;
}
//@Override
public void setElementType(final QName elementType) {
mFieldElementType = elementType;
}
//@Override
public void setRequired(final Boolean required) {
mFieldRequired = required;
}
public void setOperationType(final String operationType) {
mOperationType = operationType;
}
/**
*
* @return mOperationType
*/
public String getOperationType() {
return mOperationType;
}
public void setJDBCSql(final JDBCOperationInput jdbcSql) {
mJdbcSql = jdbcSql;
}
public JDBCOperationInput getJDBCSql() {
return mJdbcSql;
}
public void setNumberOfRecords(final int numberOfRecords) {
this.numberOfRecords = numberOfRecords;
}
/**
*
* @return numberOfRecords
*/
public int getNumberOfRecords() {
return numberOfRecords;
}
protected Message getMessage() {
return mMessage;
}
public void setMessage(final Message mMessage) {
this.mMessage = mMessage;
}
protected String getOperationName() {
return mInputName;
}
public void setInputName(final String mInputName) {
this.mInputName = mInputName;
}
public int getPollMilliSeconds() {
return pollmilliseconds;
}
protected void setPollMilliSeconds(final int mPollSec) {
this.pollmilliseconds = mPollSec;
}
}

View File

@ -1,111 +0,0 @@
/*
* 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]
*/
/*
* @(#)JDBCOperationOutput.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc.extensions;
import java.io.Serializable;
import javax.wsdl.Message;
import javax.wsdl.extensions.ExtensibilityElement;
import javax.xml.namespace.QName;
/**
*
* To change the template for this generated type comment go to
* Window - Preferences - Java - Code Generation - Code and Comments
*/
public class JDBCOperationOutput implements ExtensibilityElement, Serializable {
public static final String ATTR_RETURN_PART_NAME = "returnPartName";
private static final long serialVersionUID = 1L;
private QName mFieldElementType = JDBCConstants.QNAME_OPERATION;
private Boolean mFieldRequired = null;
private String mReturnPartName;
private String name = null;
private Message message = null;
public JDBCOperationOutput() {
}
/**
* @return mFieldElementType
*/
//@Override
public QName getElementType() {
return mFieldElementType;
}
/**
* @return mFieldRequired
*/
//@Override
public Boolean getRequired() {
return mFieldRequired;
}
//@Override
public void setElementType(final QName elementType) {
mFieldElementType = elementType;
}
//@Override
public void setRequired(final Boolean required) {
mFieldRequired = required;
}
/**
*
* @return mReturnPartName
*/
public String getReturnPartName() {
return mReturnPartName;
}
public void setReturnPartName(final String returnPartName) {
mReturnPartName = returnPartName;
}
public void setName(final String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setMessage(final Message mesg) {
message = mesg;
}
public Message getMessage() {
return message;
}
}

View File

@ -1,229 +0,0 @@
/*
* 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]
*/
/*
* @(#)JDBCSql.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc.extensions;
import java.io.Serializable;
import javax.wsdl.extensions.ExtensibilityElement;
import javax.xml.namespace.QName;
/**
*
* To change the template for this generated type comment go to
* Window - Preferences - Java - Code Generation - Code and Comments
*/
public class JDBCSql implements ExtensibilityElement, Serializable {
private static final long serialVersionUID = 1L;
public static final String ATTR_PARAM_ORDER = "paramOrder";
public static final String ATTR_SQL = "sql";
public static final String PK_NAME = "PKName";
public static final String MARK_COLUMN_NAME = "MarkColumnName";
// public static final String STAG_SELECT = "CreateStageTable";
public static final String TABLE_NAME = "TableName";
public static final String MOVE_TABLE_NAME = "MoveRowToTableName";
public static final String POLLING_POST_PROCESS = "PollingPostProcessing";
public static final String MARK_COLUMN_VALUE = "MarkColumnValue";
public static final String TRANSACTION = "Transaction";
private QName mFieldElementType = JDBCConstants.QNAME_SQL;
private Boolean mFieldRequired = null;
private String mParamOrder = null;
private String mSql = null;
private String mMarkColumnName = null;
private String mMarkColumnValue = null;
private String mpkName = null;
private String mTableName = null;
private String mMoveRowToTableName = null;
private String mPollingPostProcessing = null;
private String mTransaction = "NOTransaction";
public JDBCSql() {
}
/**
* @return mFieldElementType
*/
//@Override
public QName getElementType() {
return mFieldElementType;
}
/**
* @return mFieldRequired
*/
//@Override
public Boolean getRequired() {
return mFieldRequired;
}
//@Override
public void setElementType(final QName elementType) {
mFieldElementType = elementType;
}
//@Override
public void setRequired(final Boolean required) {
mFieldRequired = required;
}
protected void setParamOrder(final String paramOrder) {
mParamOrder = paramOrder;
}
/**
*
* @return mParamOrder
*/
protected String getParamOrder() {
return mParamOrder;
}
protected void setSql(final String sql) {
mSql = sql;
}
/**
*
* @return mSql
*/
protected String getSql() {
return mSql;
}
/**
*
* @return mMarkColumnName
*/
protected String getMarkColumnName() {
return mMarkColumnName;
}
/**
*
*
* @param markcolumnName
*/
protected void setMarkColumnName(final String markcolumnName) {
mMarkColumnName = markcolumnName;
}
/**
*
* @return mMarkColumnName
*/
protected String getMarkColumnValue() {
return mMarkColumnValue;
}
/**
*
* @param MarkColumnValue
*/
protected void setMarkColumnValue(final String MarkColumnValue) {
mMarkColumnValue = MarkColumnValue;
}
/**
*
* @return mpkName
*/
protected String getPKName() {
return mpkName;
}
protected void setPKName(final String pkName) {
mpkName = pkName;
}
/**
*
* @return mTableName
*/
protected String getTableName() {
return mTableName;
}
protected void setTableName(final String tableName) {
mTableName = tableName;
}
/**
*
* @return mMoveRowToTableName
*/
protected String getMoveRowToTableName() {
return mMoveRowToTableName;
}
protected void setMoveRowToTableName(final String MoveRowToTableName) {
mMoveRowToTableName = MoveRowToTableName;
}
/**
*
* @return mPollingPostProcessing
*/
protected String getPollingPostProcessing() {
return mPollingPostProcessing;
}
private void setPollingPostProcessing(final String PollingPostProcessing) {
mPollingPostProcessing = PollingPostProcessing;
}
/**
*
* @return mTransaction
*/
protected String getTransaction() {
return this.mTransaction;
}
protected void setTransaction(final String Transaction) {
this.mTransaction = Transaction;
}
/**
*
* @return mStagName
*/
// public String getCreateStageTable(){
// return this.mStagName;
// }
// public void setCreateStageTable(String stagName){
// this.mStagName = stagName;
// }
}

View File

@ -1,228 +0,0 @@
# message id scheme used:
#
# SQLSE -{contextcode:1 character}{domain-messageid:5 digits}
#
# e.g. SQLSE-C00100
#
# context codes:
# C = Configuration information
# R = Runtime information
# W = Warning cautions
# E = Errors
#
# domain-messageids:
# 100s for Life cycle and Bootstrapping
# 200s for Deployer
# 300s for Service Unit
# 600s for Request/Reply processing (InboundReceiver, OutBound, Inbound MessageProcessor)
# 700s for Message processing (Normalizer - DeNormalizer)
# 1000-1100s for Authentication and proxies
# Package specific ResourceBundle properties file
################## resource bundles for JDBCBindingDeployer ###################
deploy=deploy
SQLSE_R00201.JDBCBD_Deploy_SU=Deploying service unit\: {0} from {1}.
from=from
init=init
SQLSE_R00202.JDBCBD_Init_SU=Initializing service unit\: {0} from {1}.
SQLSE_R00203.JDBCBD_Complete_init_SU=Successfully initialized service unit {0}.
SQLSE_E00204.JDBCBD_Failed_init_SU=Failed to initialize service unit due to\: {0}
start=start
SQLSE_R00205.JDBCBD_Starting_SU=Starting service unit\: {0}.
SQLSE_R00206.JDBCBD_Error_start_SU=Error starting service unit due to\: {0}
SQLSE_R00207.JDBCBD_Complete_start_BC=Successfully started JDBC BC.
stop=stop
SQLSE_R00208.JDBCBD_Stop_SU=Stopping service unit\: {0}.
SQLSE_R00209.JDBCBD_Error_stop_SU=Error stopping service unit due to\: {0}
SQLSE_R00210.JDBCBD_Complete_stop_SU=Successfully stopped service unit\: {0}.
shutdown=shutdown
SQLSE_R00211.JDBCBD_Shutdown_SU=Shutting down service unit\: {0}.
SQLSE_E00212.JDBCBD_Error_shutdown_SU=Error shutting down service unit due to\: {0}
undeploy=undeploy
SQLSE_R00213.JDBCBD_Undeploy_SU=Undeploying service unit\: {0} from {1}.
############################ resource bundles for JDBCBindingLifeCycle ################
SQLSE_E00101.JDBCBLC_Null_context=Component Context is null.
SQLSE_R00102.JDBCBLC_Register_mbean=Registered Status Provider MBean for {0}.
SQLSE_E00103.JDBCBLC_Failed_register_mbean=Failed to register status provider MBean.
SQLSE_R00104.JDBCBLC_Register_config_mbean=Registered runtime configuration MBean for {0}.
SQLSE_E00105.JDBCBLC_Failed_register_config_mbean=Failed to register configuration MBean.
SQLSE_E00106.JDBCBLC_No_Dev_Channel=Cannot get Delivery Channel from context\: {0}
SQLSE_E00107.JDBCBLC_Failed_start_outbound=Failed to start the outbound receiver\: {0}
SQLSE_E00108.JDBCBLC_Failed_start_inbound=Failed to start the inbound receiver\: {0}
SQLSE_R00109.JDBCBLC_Shutdown_JDBCBC=Shutting down JDBC Binding component.
SQLSE_E00110.JDBCBLC_Failed_stop_outbound=Failed to stop the outbound receiver\:
SQLSE_E00111.JDBCBLC_Failed_unregister_mbean=Failed to un-register status provider MBean for {0}
SQLSE_E00112.JDBCBLC_Failed_unregister_config_mbean=Failed to un-register runtime configuration MBean for {0}
SQLSE_E00113.JDBCBLC_Failed_Complete_JDBCBC_shutdown=JDBC Binding component shutdown completed.
SQLSE_R00114.JDBCBLC_JDBCBC_started=JDBC Binding component started.
SQLSE_R00115.JDBCBLC_JDBCBC_stopped=JDBC Binding component stopped.
SQLSE_R00116.JDBCBLC_started_inbound=Started inbound receiver.
SQLSE_R00117.JDBCBLC_started_outbound=Started outbound receiver.
SQLSE_R00118.JDBCBLC_stopped_outbound=Stopped outbound receiver.
SQLSE_R00119.JDBCBLC_stopped_inbound=Stopped inbound receiver.
SQLSE_E00120.JDBCBLC_Failed_deploy_EndPoint=Failed to deploy the endpoint. A Service EndPoint with the same name already activated , please provide different name for service.
############################ resource bundles for InboundMessageProcessor ################
SQLSE_R00629.IMP_EP_status=Endpoint service name is \[{0}\] and endpoint name is \[{1}\].
SQLSE_W00630.IMP_EP_NOT_RUNNING=EndPoint \[{0}\] is not in state RUNNING, but in state .Ignoring received message for exchange \[{1}\].
SQLSE_R00631.IMP_Received_INOUT=Received in-out message.
SQLSE_R00632.IMP_Received_INONLY=Received in-only message.
SQLSE_E00633.IMP_Invalid_pattern=Received invalid pattern info.
SQLSE_E00634.IMP_Invalid_Operation=The requested operation is not defined \[{0}\].
SQLSE_E00635.IMP_Error_Lookup=Error occured while looking up jndi resource with jndi name.
SQLSE_E00636.IMP_Table_NotExist=Table does not exist
SQLSE_E00637.IMP_PrimaryKey_Error=Primary Key Name Specified is not a column in Table or Primary Key Name is Missing
SQLSE_E00638.IMP_Error_IVALID_ColumnName=Error occured due to invalid column name.
SQLSE_E00639.IMP_Failed_Executing_SQL=Error occured while executing sql.
SQLSE_E00640.IMP_Created_Staging_Table=Succesfully Created Stagging Table.
SQLSE_E00641.IMP_Error_Creating_Staging_Table=Excepion Occured while Creating Stagging Table.
SQLSE_E00642.IMP_Error_Closing_Connection=Exception in closing connection and statement.
SQLSE_E00643.IMP_Failed_locate_EP=Failed to locate the service endpoint reference for service and endpoint name.
SQLSE_R00644.IMP_Inbound_stopped=Inbound message processor is stopped.
SQLSE_E00645.IMP_locate_EP=Located service endpoint reference for service \[{0}\] and endpoint name \[{1}\].
SQLSE_E00646.IMP_Invalid_reply_msgId=Encountered an invalid message exchange id of \[{0}\] while processing the message exchange reply status.
SQLSE_E00647.IMP_Unsupported_exchange_pattern=Encountered an invalid message exchange pattern of \[{0}\] while processing the message exchange reply status.
SQLSE_E00648.IMP_Remove_exchange_msg_id=Finished processing message with exchange id of \[{0}\]. Removing the exchange id...
SQLSE_E00649.FAILED_IN_GETTING_CONNECTION=Failed in Getting XAConnection.
SQLSE_E00650.FAILED_IN_DATASOURCE_CREATION=Failed in Getting DataSource Creation.
SQLSE_E00651.IMP_RESUME_FAILED=Resume transaction failed due : {0}
SQLSE_E00652.IMP_ROLLBACK_FAILED=Rollback transaction failed due: {0}
SQLSE_E00653.IMP_XA_TX_ROLLBACK_FAILED=Failed to rollback an XA transaction: {0}
SQLSE_W00654.IMP_XA_TX_NOT_FOUND_IN_MSG_XCHANGE=Configured for XA but unable to get transaction from message exchange ID {0}
SQLSE_E00655.IMP_POST_PROCESS_FAILED=Post process of In-Only failed due : {0}
SQLSE_E00656.IMP_XA_TX_COMMIT_FAILED=Failed to commit an XA transaction: {0}
SQLSE_E00657.IMP_COMMIT_FAILED=Commit transaction failed due : {0}
SQLSE_E00658.IMP_MXCH_BAD_STATUS=Unexpected message exchange status {0} received for message exchange ID {1}
SQLSE_E00659.IMP_ERROR_WHILE_EXECUTING_SQL=Error while executing the SQL.
SQLSE_R00660.IMP_FINISHED_EXECUTING_SQL=Finished executing the SQL successfully.
SQLSE_E00661.IMP_THREAD_SLEEP_ABRUPTED=Unexpected exception Occured In Inbound message processor thread during sleep.
SQLSE_E00662.IMP_ERROR_WHILE_EXECUTING_MEP=Unexpected exception Occured while executing the SQL.
SQLSE_E00663.IMP_ERROR_WHILE_PROCESSING_MEP=Unexpected exception Occured while processing the MEP.
############################ resource bundles for OutboundMessageProcessor ################
SQLSE_R00606.OMP_Accept_msg=Accepted message with exchange ID {0} in JDBC outbound message processor.
SQLSE_E00607.OMP_Unexpected_exception=Unexpected exception\: {0}
SQLSE_R00608.OMP_Complete_processing=Finished processing outbound messages.
SQLSE_R00609.OMP_Resp_Ex=Response for message with exchange ID {0} received after {1}ms.
SQLSE_R00610.OMP_Pattern=Pattern for exchange Id {0} is {1}.
SQLSE_R00611.OMP_EP_state=The endpoint is not in RUNNING state, . Ignoring the received message for exchange...
SQLSE_R00612.OMP_Recv_InOut=Received in-out message {0}.
SQLSE_R00613.OMP_Recv_InOnly=Received in-only message {0}.
SQLSE_W00614.OMP_Not_supported_inonly=NOT SUPPORTED\: Received robust in-only message {0}.
SQLSE_W00615.OMP_Not_supported_outin=NOT SUPPORTED\: Received out-in message {0}.
SQLSE_E00616.OMP_Not_supported_outonly=NOT SUPPORTED\: Received out-only message {0}.
SQLSE_W00617.OMP_Invalid_pattern=Received invalid pattern info for message {0}.
SQLSE_R00618.OMP_Processing_InOnly_inbound=Processing one-way inbound messages...
SQLSE_E00619.OMP_Failed_processing_inonly_inbound=Failed processing one-way inbound messages.
SQLSE_W00620.OMP_Unexpected_ME_status=Unexpected message exchange status for one-way inbound\: exchange ID {0} status {1}.
SQLSE_E00621.OMP_oper_NotDefined=The requested operation is not defined:.
SQLSE_E00622.OMP_Failed_writing=Failed to write message:.
SQLSE_E00623.OMP_Failed_inout=Exception in processing reply for InOut.
SQLSE_E00624.OMP_Failed_inonly=Exception in processing reply for InOnly.
SQLSE_R00624.OMP_Failed_Exec_SQL=Exception in processing SQL.
SQLSE_R00625.OMP_Exec_SQL=Executing SQL....
SQLSE_E00626.OMP_Failed_Exec_SQL=Error occured while executing SQL.
SQLSE_E00627.OMP_Failed_LookUp_JNDI=Error occured while looking up jndi resource with jndi name.
SQLSE_E00628.OMP_Cleanup_Failure=Falied to close the Connection, ResultSet, Callable Statement in OutboundMessage Processor.
JDBCBC-E01036.Failed_to_process_redelivery=JDBCBC-E01036: An exception occured while attempting to redeliver a message exchange with message group ID: {0}, message ID: {1}.
JDBCBC-E00759.Exception_during_reply_processing=JDBCBC-E00759: An exception occured while processing a reply message. {0}
JDBCBC-E00720.Message_exchange_error=JDBCBC-E00720: Provider for service [{0}] endpoint [{1}] responded with an error status. Error detail is: {2}
JDBCBC-E00721.Message_exchange_error_no_detail=JDBCBC-E00721: Provider for service [{0}] endpoint [{1}] responded with an error status. No detail was provided.
############################ resource bundles for InboundReceiver ################
SQLSE_C00601.IR_Started=Receiver started.
SQLSE_E00602.IR_Exception=Exception in JDBC Inbound receiver.
SQLSE_C00603.IR_Shutdown=Receiver shut down.
SQLSE_C00604.IR_Remove=remove Inbound MessageProcessor.
SQLSE_C00605.IR_Stop=Stopping the Receiver Thread.
############################ resource bundles for JDBCDenormalizer ################
SQLSE_E00706.JDBCDN_Failed_Denormalize=Failed to denormalize message.
SQLSE_E00707.JDBCDN_Failed_Finding_Node=Unexpected error, did not find node with element name.
SQLSE_E00708.JDBCDN_Failed_Convert_NM=Unable to convert normalized message content to DOM Node, Check transformer configuration.
SQLSE_E00709.JDBCDN_FailedPopulate_PS=Unable to convert normalized message content to prepared statement, Error occured during populating PreparedStatement.
SQLSE_E00710.JDBCDN_Failed_PS=Unable to convert normalized message to Prepared Statement.
SQLSE_E00711.JDBCDN_FailedPopulate_Proc=Unable to convert normalized message content to Procedure, Error occured during populating Procedure.
SQLSE_E00712.JDBCDN_Failed_Proc=Unable to convert normalized message to procedure.
SQLSE_E00713.JDBCDN_Failed_Proc_Param=Unable to convert normalized message to Procedure. \n input ParamOrder attribute does not have same number of columns as needed in the given sql Procedure.
SQLSE_E00714.JDBCDN_Failed_PS_Param=Unable to convert normalized message to prepared sql statement. \n input ParamOrder attribute does not have same number of columns as needed in the given sql prepared statement.
SQLSE_E00715.JDBCDN_Failed_ParamCount=Exception while getting sql parameter count.
############################ resource bundles for JDBCDenormalizer ################
SQLSE_E00701.JDBCN_Failed_Create=Could not create JDBCNormalizer, failed to create wrapper builder:.
SQLSE_E00702.JDBCN_Failed_NM=Failed to normalize message.
SQLSE_E00703.JDBCN_Failed_NM_Part=Failed to normalize message. missing part with name
SQLSE_E00704.JDBCN_Failed_NM_WS_OPER=Failed to normalize message. wsdl operation
SQLSE_E00705.JDBCN_Failed_NM_DOM=unable to obtain normalized message as a DOM document
############################ resource bundles for JDBCUtil ################
JDBCUtil_Failed_Convert=Failed to convert value \: {0} to jdbc type {1}
############################ resource bundles for OutboundReceiver ################
SQLSE_R00664.OR_Started=Receiver started.
SQLSE_R00665.OR_Accepted=Accepted the message in JDBC Binding.
SQLSE_E00666.OR_Exception=Exception in JDBC Outbound receiver.
SQLSE_R00667.OR_Shutdown=Receiver shut down.
SQLSE_R00668.OR_Remove=remove Inbound MessageProcessor.
SQLSE_R00669.OR_Stop=Stopping the Receiver Thread.
############################ resource bundles for SQLSELifeCycle ################
SQLSE_R00121.SQLSELC_Register_mbean=Registered Status Provider MBean for {0}.
SQLSE_E00122.SQLSELC_Failed_register_mbean=Failed to register status provider MBean.
SQLSE_R00123.SQLSELC_Register_config_mbean=Registered runtime configuration MBean for {0}.
SQLSE_E00124.SQLSELC_Failed_register_config_mbean=Failed to register configuration MBean.
SQLSE_E00125.SQLSELC_Failed_DC=Cannot get Delivery Channel from context.
SQLSE_R00126.SQLSELC_Failed_start_SE=Failed to start the SQL SE.
SQLSE_R00127.SQLSELC_Shutdown_SE=Shutting down SQLSE Service Engine.
SQLSE_R00128.SQLSELC_Shutdown_SE_DONE=Shutting down SQLSE Service Engine completed.
SQLSE_R00129.SQLSELC_started=SQLSE started.
SQLSE_R00130.SQLSELC_stopped=SQLSE stopped.
SQLSE_R00131.SQLSELC_Failed_stop_SE=Failed to stop the SQLSE.
SQLSE_R00132.SQLSELC_Failed_unregister_mbean=Failed to un-register status provider MBean for {0}.
SQLSE_R00134.SQLSELC_Failed_unregister_config_mbean=Failed to un-register runtime configuration MBean for {0}.
SQLSE_R00135.SQLSELC_START_EP_ACTIVATE=Activating endpoints
SQLSE_R00136.SQLSELC_EP_ACTIVATE=Activated endpoints
SQLSE_R00137.SQLSELC_SU_Failed_start_inbound_EP=SU Failed to start inbound EndPoint {0} .Reason {1} .
SQLSE_R00138.SQLSELC_FAILED_EP_ACTIVATE=Cannot activate endpoint {0} .Reason {1} .
SQLSE_R00139.SQLSELC_FAILED_LOCATE_EP=Endpoint {0} could not be located in SQL SE.
SQLSE_R00140.SQLSELC_FAILED_SAX=Endpoint {0} Cannot get the getServiceDescription Exception in SAXException.
SQLSE_R00141.SQLSELC_FAILED_IO=Endpoint {0} cannot get the getServiceDescription Exception in IOException.
SQLSE_R00142.SQLSELC_FAILED_Ex=Endpoint {0} cannot get the getServiceDescription Exception in Exception.
SQLSE_R00143.SQLSELC_START_EP_DEACTIVATE=Deactivating endpoints
SQLSE_R00144.SQLSELC_FAILED_EP_DEACTIVATE=Cannot deactivate endpoint {0} .Reason {1} .
SQLSE_R00145.SQLSELC_EP_DEACTIVATE=Deactivated endpoints.
SQLSE_R00146.SQLSELC_START_INBOUND=Started inbound.
SQLSE_R00147.SQLSELC_START_OUTBOUND=Started outbound.
SQLSE_R00148.SQLSELC_STOP_INBOUND=Stopped inbound.
SQLSE_R00149.SQLSELC_STOP_OUTBOUND=Stopped outbound.
############################ resource bundles for SQLSEServiceUnitManager ################
SQLSE_R00301.SQLSESUM_DEPLOY_SU=Deploying service unit : {0} from {1} .
SQLSE_R00302.SQLSESUM_INIT_SU=Initializing service unit : {0} from {1} .
SQLSE_R00303.SQLSESUM_INIT_SU_SUCCESS=Service unit {0} was initialized successfully.
SQLSE_E00304.SQLSESUM_INIT_SU_FAIL=Failed to initialize: {0} .
SQLSE_R00305.SQLSESUM_SU_START=Starting service unit : {0} .
SQLSE_R00306.SQLSESUM_SU_START_SUCCESS=Started service unit {0} successfully.
SQLSE_R00307.SQLSESUM_SU_STOP=Stopping service unit : {0} .
SQLSE_R00308.SQLSESUM_SU_STOP_SUCCESS=Stopped service unit {0} successfully.
SQLSE_R00309.SQLSESUM_SU_SHUTDOWN=Shutting down service unit {0} .
SQLSE_E00310.SQLSESUM_SU_NOT_DEPLOYED=Service Unit has not been deployed.
SQLSE_R00311.SQLSESUM_SU_SHUTDOWN_SUCCESS=Shutdown service unit {0} successfully.
SQLSE_R00312.SQLSESUM_SU_UNDEPLOY=Undeploying service unit {0} from {1} .
SQLSE_R00313.SQLSESUM_FAIL_LOCATE_ENGINE_ENTRY=Unable to locate an engine file entry for sql file:
SQLSE_R00314.SQLSESUM_MISS_PORT_TYPE=Misssing portType in wsdl for this service :
SQLSE_R00315.SQLSESUM_MISS_OPER=Missing operation definition(s) in wsdl for this service :
SQLSE_R00316.SQLSESUM_MISS_SQL=Missing sql for this service :
SQLSE_R00317.SQLSESUM_UNDEPLOY_SU=Undeploy service unit {0} from {1}.
SQLSE_R00318.SQLSESUM_fail_READ_WSDL=Unable to read WSDL file :
SQLSE_R00319.SQLSESU_ENDPOINT_ACTIVATED=End point activated
SQLSE_R00320.SQLSESU_ENDPOINT_DEACTIVATED=End point deactivated
############################ resource bundles for SQLMapReader ################
SQLSE_C00150.SQLMR_PARSE_SUCCESS=Successfully parsed SQL Map File {0}.
############################ resource bundles for SQLEngineFileReader ################
SQLFR_READ_SQL=Read SQL statement: {0} .
SQLFR_PARSE_SUCCESS=Successfully parsed SQL Engine File.

View File

@ -1,44 +0,0 @@
# ------------------------------
# ---- NO I18N ENTIRE FILE! ----
# ------------------------------
# message id scheme used:
#
# SQLSE -{contextcode:1 character}{domain-messageid:5 digits}
#
# e.g. SQLSE-C00100
#
# context codes:
# C = Configuration information
# R = Runtime information
# W = Warning cautions
# E = Errors
#
# domain-messageids:
# 100s for Life cycle and Bootstrapping
# 200s for Deployer
# 300s for Service Unit
# 600s for Request/Reply processing (InboundReceiver, OutBound, Inbound MessageProcessor)
# 700s for Message processing (Normalizer - DeNormalizer)
# 800s for Application Specific
# 1000-1100s for Authentication and proxies
# Package specific ResourceBundle properties file
SQLSE_E00801.ERROR_NULL_RS = Must supply non-null ResultSet instance for parameter rs.
SQLSE_E00802.ERROR_VALID_RS = Must supply valid ResultSet instance for parameter rs
SQLSE_E00803.ERROR_VALID_RULE = Must supply valid value for newRule
SQLSE_E00804.ERROR_INDEX_TYPE =Must supply valid index type value; {0} is out of range.
SQLSE_E00805.ERROR_PARAMETER_NAME = Must supply non-empty String for parameter colName.
SQLSE_E00806.ERROR_KEY = newList does not contain KeyColumn objects
SQLSE_E00807.ERROR_FK_KEY = newList does not contain ForeignKeyColumn objects!
SQLSE_E00808.NO_PRIMARY_KEY = Table does not contain Primary Key!
SQLSE_E00809.NO_FOREIGN_KEY = Table does not contain Foreign Key!
SQLSE_E00810.NO_SCHEMA_AVAILABLE = Problem retrieving Schema List!
SQLSE_E00811.NO_PATTERN_AVAILABLE = Problem retrieving JDBC Search Pattern!
SQLSE_E00812.NO_TABLELIST_AVAILABLE = Problem retrieving Table List!
SQLSE_E00813.NO_TABLEMETADATA_AVAILABLE = Problem retrieving Table Metadata!
SQLSE_E00814.NO_COLUMNMETADATA_AVAILABLE = Problem retrieving Table Metadata!
SQLSE_E00628.OMP_Cleanup_Failure=Falied to close the Connection, ResultSet, Callable Statement in OutboundMessage Processor.

View File

@ -1,394 +0,0 @@
/*
* 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]
*/
/*
* @(#)ForeignKeyColumn.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc.model.metadata;
import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.ResourceBundle;
import java.util.logging.Logger;
import com.sun.jbi.internationalization.Messages;
/**
* Captures database foreign key metadata associated with a specific database
* table column.
*
* @author Jonathan Giron
* @version
*/
public class ForeignKeyColumn extends KeyColumn {
private static final String RS_PK_NAME = "PK_NAME"; // NOI18N
private static final String RS_PKCATALOG_NAME = "PKTABLE_CAT"; // NOI18N
private static final String RS_PKSCHEMA_NAME = "PKTABLE_SCHEM"; // NOI18N
private static final String RS_PKTABLE_NAME = "PKTABLE_NAME"; // NOI18N
private static final String RS_PKCOLUMN_NAME = "PKCOLUMN_NAME"; // NOI18N
private static final String RS_FK_NAME = "FK_NAME"; // NOI18N
private static final String RS_FKCOLUMN_NAME = "FKCOLUMN_NAME"; // NOI18N
private static final String RS_UPDATE_RULE = "UPDATE_RULE"; // NOI18N
private static final String RS_DELETE_RULE = "DELETE_RULE"; // NOI18N
private static final String RS_DEFERRABILITY = "DEFERRABILITY"; // NOI18N
/*
* name of catalog containing foreign table whose primary key column is
* associated with this foreign key
*/
private static final Messages mMessages = Messages.getMessages(ForeignKeyColumn.class);
private static final Logger mLogger = Messages.getLogger(ForeignKeyColumn.class);
private String importCatalogName;
/*
* name of schema referencing foreign table whose primary key column is
* associated with this foreign key
*/
private String importSchemaName;
/*
* name of foreign table whose primary key column is associated with this
* foreign key
*/
private String importTableName;
/* name of primary key column assocaited with this foreign key */
private String importColumnName;
/* name of import (primary) key associated with this foreign key */
private String importKeyName;
/* short flag indicating applicable update rule for this constraint */
private short updateRule;
/* short flag indicating applicable delete rule for this constraint */
private short deleteRule;
/* short flag indicating policy on evaluation of this constraint */
private short deferrability;
/**
* Creates an instance of ForeignKeyColumn with the given values.
*
* @param fkName name of FK
* @param fkColumn name of column assocaited with FK
* @param pkName name of PK that this FK imports
* @param pkColumn name of column that this FK imports
* @param pkTable name of table containing column that this FK imports
* @param pkSchema name of schema containing table with PK that this FK imports
* @param pkCatalog name of catalog containing table with PK that this FK imports
* @param colSequence sequence of this column within (composite) primary key
* @param updateFlag applicable update rule for this FK; one of
* java.sql.DatabaseMetaData.importedKeyNoAction,
* java.sql.DatabaseMetaData.importedKeyCascade,
* java.sql.DatabaseMetaData.importedKeySetNull,
* java.sql.DatabaseMetaData#importedKeySetDefault, or
* java.sql.DatabaseMetaData#importedKeyRestrict
*
* @param deleteFlag applicable delete rule for this FK; one of
* java.sql.DatabaseMetaData.importedKeyNoAction,
* java.sql.DatabaseMetaData.importedKeyCascade,
* java.sql.DatabaseMetaData.importedKeySetNull,
* java.sql.DatabaseMetaData.importedKeyRestrict, or
* java.sql.DatabaseMetaData.importedKeySetDefault
*
* @param deferFlag deferrability flag for this FK; one of
* java.sql.DatabaseMetaData.importedKeyInitiallyDeferred,
* java.sql.DatabaseMetaData.importedKeyInitiallyImmediate, or
* java.sql.DatabaseMetaData.importedKeyNotDeferrable
*
* @see java.sql.DatabaseMetaData#importedKeyCascade
* @see java.sql.DatabaseMetaData#importedKeyInitiallyDeferred
* @see java.sql.DatabaseMetaData#importedKeyInitiallyImmediate
* @see java.sql.DatabaseMetaData#importedKeyNoAction
* @see java.sql.DatabaseMetaData#importedKeyNotDeferrable
* @see java.sql.DatabaseMetaData#importedKeyRestrict
* @see java.sql.DatabaseMetaData#importedKeySetNull
* @see java.sql.DatabaseMetaData#importedKeySetDefault
*/
public ForeignKeyColumn(final String fkName, final String fkColumn, final String pkName,
final String pkColumn, final String pkTable, final String pkSchema, final String pkCatalog,
final short colSequence, final short updateFlag, final short deleteFlag, final short deferFlag) {
super(fkName, fkColumn, colSequence);
importKeyName = pkName;
importCatalogName = pkCatalog;
importSchemaName = pkSchema;
importTableName = pkTable;
importColumnName = pkColumn;
setUpdateRule(updateFlag);
setDeleteRule(deleteFlag);
setDeferrability(deferFlag);
}
public ForeignKeyColumn(final ForeignKeyColumn fkCol) {
super(fkCol.getName(), fkCol.getColumnName(), fkCol.getColumnSequence());
importKeyName = fkCol.getImportKeyName();
importCatalogName = fkCol.getImportCatalogName();
importSchemaName = fkCol.getImportSchemaName();
importTableName = fkCol.getImportTableName();
importColumnName = fkCol.getImportColumnName();
setUpdateRule(fkCol.getUpdateRule());
setDeleteRule(fkCol.getDeleteRule());
setDeferrability(fkCol.getDeferrability());
}
public ForeignKeyColumn(final ResultSet rs) throws SQLException {
if (rs == null) {
final Locale locale = Locale.getDefault();
final ResourceBundle cMessages = ResourceBundle.getBundle("com/stc/jdbc/builder/Bundle",
locale); // NO i18n
throw new IllegalArgumentException(ForeignKeyColumn.mMessages.getString(
"SQLSE_E00802.ERROR_VALID_RS") + "(ERROR_VALID_RS)");
}
importCatalogName = rs.getString(ForeignKeyColumn.RS_PKCATALOG_NAME);
importSchemaName = rs.getString(ForeignKeyColumn.RS_PKSCHEMA_NAME);
importTableName = rs.getString(ForeignKeyColumn.RS_PKTABLE_NAME);
importColumnName = rs.getString(ForeignKeyColumn.RS_PKCOLUMN_NAME);
importKeyName = rs.getString(ForeignKeyColumn.RS_PK_NAME);
columnName = rs.getString(ForeignKeyColumn.RS_FKCOLUMN_NAME);
keyName = rs.getString(ForeignKeyColumn.RS_FK_NAME);
sequenceNum = rs.getShort(KeyColumn.RS_SEQUENCE_NUM);
updateRule = rs.getShort(ForeignKeyColumn.RS_UPDATE_RULE);
deleteRule = rs.getShort(ForeignKeyColumn.RS_DELETE_RULE);
deferrability = rs.getShort(ForeignKeyColumn.RS_DEFERRABILITY);
}
/**
* Creates a List of ForeignKeyColumn instances from the given ResultSet.
*
* @param rs ResultSet containing foreign key metadata as obtained from
* DatabaseMetaData
* @return List of ForeignKeyColumn instances based from metadata in rs
*
* @throws SQLException if SQL error occurs while reading in data from
* given ResultSet
*/
public static List<ForeignKeyColumn> createForeignKeyColumnList(final ResultSet rs)
throws SQLException {
if (rs == null) {
final Locale locale = Locale.getDefault();
final ResourceBundle cMessages = ResourceBundle.getBundle("com/stc/jdbc/builder/Bundle",
locale); // NO i18n
throw new IllegalArgumentException(ForeignKeyColumn.mMessages.getString(
"SQLSE_E00801.ERROR_NULL_RS") + "(ERROR_NULL_RS)");
}
List<ForeignKeyColumn> fkColumns = Collections.emptyList();
if ((rs != null) && rs.next()) {
fkColumns = new ArrayList<ForeignKeyColumn>();
do {
fkColumns.add(new ForeignKeyColumn(rs));
} while (rs.next());
}
return fkColumns;
}
/**
* Gets name of catalog containing the import table which, in turn,
* contains the imported (primary) key associated with this foreign
* key.
*
* @return name of catalog containing the imported primary key's
* encapsulating table
*/
private String getImportCatalogName() {
return importCatalogName;
}
/**
* Gets name of schema containing the import table which, in turn,
* contains the imported (primary) key associated with this foreign
* key.
*
* @return name of schema containing the imported primary key's
* encapsulating table
*/
private String getImportSchemaName() {
return importSchemaName;
}
/**
* Gets name of import table containing imported (primary) key
* associated with this foreign key.
*
* @return name of table containing imported primary key
*/
private String getImportTableName() {
return importTableName;
}
/**
* Gets name of import column contained within imported (primary) key
* associated with this foreign key.
*
* @return name of imported column
*/
private String getImportColumnName() {
return importColumnName;
}
/**
* Gets key name of imported (primary) key associated with this foreign
* key.
*
* @return name of imported primary key
*/
private String getImportKeyName() {
return importKeyName;
}
/**
* Gets update rule.
*
* @return update rule; one of
* java.sql.DatabaseMetaData.importedKeyNoAction,
* java.sql.DatabaseMetaData.importedKeyCascade,
* java.sql.DatabaseMetaData.importedKeySetNull,
* java.sql.DatabaseMetaData.importedKeyRestrict, or
* java.sql.DatabaseMetaData.importedKeySetDefault.
*
* @see java.sql.DatabaseMetaData#importedKeyNoAction
* @see java.sql.DatabaseMetaData#importedKeyCascade
* @see java.sql.DatabaseMetaData#importedKeySetNull
* @see java.sql.DatabaseMetaData#importedKeyRestrict
* @see java.sql.DatabaseMetaData#importedKeySetDefault
*/
private short getUpdateRule() {
return updateRule;
}
/**
* Gets delete rule.
*
* @return update rule; one of
* java.sql.DatabaseMetaData.importedKeyNoAction,
* java.sql.DatabaseMetaData.importedKeyCascade,
* java.sql.DatabaseMetaData.importedKeySetNull,
* java.sql.DatabaseMetaData.importedKeyRestrict, or
* java.sql.DatabaseMetaData.importedKeySetDefault.
*
* @see java.sql.DatabaseMetaData#importedKeyNoAction
* @see java.sql.DatabaseMetaData#importedKeyCascade
* @see java.sql.DatabaseMetaData#importedKeySetNull
* @see java.sql.DatabaseMetaData#importedKeyRestrict
* @see java.sql.DatabaseMetaData#importedKeySetDefault
*/
private short getDeleteRule() {
return deleteRule;
}
/**
* Gets deferrability flag.
*
* @return deferrability flag; one of
* java.sql.DatabaseMetaData.importedKeyInitiallyDeferred,
* java.sql.DatabaseMetaData.importedKeyInitiallyImmediate, or
* java.sql.DatabaseMetaData.importedKeyNotDeferrable
*
* @see java.sql.DatabaseMetaData#importedKeyInitiallyDeferred,
* @see java.sql.DatabaseMetaData#importedKeyInitiallyImmediate, or
* @see java.sql.DatabaseMetaData#importedKeyNotDeferrable
*/
private short getDeferrability() {
return deferrability;
}
private void setUpdateRule(final short newRule) {
switch (newRule) {
case DatabaseMetaData.importedKeyNoAction:
case DatabaseMetaData.importedKeyCascade:
case DatabaseMetaData.importedKeySetNull:
case DatabaseMetaData.importedKeySetDefault:
case DatabaseMetaData.importedKeyRestrict:
updateRule = newRule;
break;
default:
final Locale locale = Locale.getDefault();
final ResourceBundle cMessages = ResourceBundle.getBundle("com/stc/jdbc/builder/Bundle",
locale); // NO i18n
throw new IllegalArgumentException(ForeignKeyColumn.mMessages.getString(
"SQLSE_E00803.ERROR_VALID_RULE") + "(ERROR_VALID_RULE)");
}
}
private void setDeleteRule(final short newRule) {
switch (newRule) {
case DatabaseMetaData.importedKeyNoAction:
case DatabaseMetaData.importedKeyCascade:
case DatabaseMetaData.importedKeySetNull:
case DatabaseMetaData.importedKeySetDefault:
case DatabaseMetaData.importedKeyRestrict:
deleteRule = newRule;
break;
default:
final Locale locale = Locale.getDefault();
final ResourceBundle cMessages = ResourceBundle.getBundle("com/stc/jdbc/builder/Bundle",
locale); // NO i18n
throw new IllegalArgumentException(ForeignKeyColumn.mMessages.getString(
"SQLSE_E00803.ERROR_VALID_RULE") + "(ERROR_VALID_RULE)");
}
}
private void setDeferrability(final short newFlag) {
switch (newFlag) {
case DatabaseMetaData.importedKeyInitiallyDeferred:
case DatabaseMetaData.importedKeyInitiallyImmediate:
case DatabaseMetaData.importedKeyNotDeferrable:
deferrability = newFlag;
break;
default:
System.err.println(
"Received unrecognized value for newFlag, but carrying on with it anyway.");
deferrability = newFlag;
break;
}
}
}

View File

@ -1,313 +0,0 @@
/*
* 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]
*/
/*
* @(#)IndexColumn.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc.model.metadata;
import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.ResourceBundle;
import java.util.logging.Logger;
import com.sun.jbi.internationalization.Messages;
/**
* Captures database index metadata associated with a specific database table
* column.
*
* @author Jonathan Giron
* @version
*/
public class IndexColumn implements Comparable {
private static final String RS_INDEX_NAME = "INDEX_NAME"; // NOI18N
private static final String RS_COLUMN_NAME = "COLUMN_NAME"; // NOI18N
private static final String RS_NON_UNIQUE = "NON_UNIQUE"; // NOI18N
private static final String RS_TYPE = "TYPE"; // NOI18N
private static final String RS_ORDINAL = "ORDINAL_POSITION"; // NOI18N
private static final String RS_ASC_OR_DESC = "ASC_OR_DESC"; // NOI18N
private static final String RS_CARDINALITY = "CARDINALITY"; // NOI18N
private static final Messages mMessages = Messages.getMessages(IndexColumn.class);
private static final Logger mLogger = Messages.getLogger(IndexColumn.class);
/* Name of index */
private String name;
/* Name of column associated with this index */
private String columnName;
/* Index type: tableIndexClustered, tableIndexHashed, tableIndexOther */
private int type;
/* Column sequence number within a composite index */
private int ordinalPosition;
/* Indicates whether index is unique */
private boolean unique = false;
/* Indicates sort order, if any, of index */
private String sortSequence;
/* Indicates number of unique values in index */
private int cardinality;
public IndexColumn(final ResultSet rs) throws SQLException {
if (rs == null) {
final Locale locale = Locale.getDefault();
final ResourceBundle cMessages = ResourceBundle.getBundle("com/stc/jdbc/builder/Bundle",
locale); // NO i18n
throw new IllegalArgumentException(IndexColumn.mMessages.getString(
"ERROR_VALID_RS") + "(ERROR_VALID_RS)"); // NOI18N
}
name = rs.getString(IndexColumn.RS_INDEX_NAME);
columnName = rs.getString(IndexColumn.RS_COLUMN_NAME);
unique = !(rs.getBoolean(IndexColumn.RS_NON_UNIQUE));
type = rs.getShort(IndexColumn.RS_TYPE);
ordinalPosition = rs.getShort(IndexColumn.RS_ORDINAL);
sortSequence = rs.getString(IndexColumn.RS_ASC_OR_DESC);
cardinality = rs.getInt(IndexColumn.RS_CARDINALITY);
}
/**
* Creates a new instance of IndexColumn using the given values.
*
* @param colName name of column
* @param indexName name of index
* @param indexType index type, as defined in DatabaseMetaData; note that
* tableIndexStatistic is not a valid type for IndexColumn
* @param colOrder sequence of this column within the (composite) index;
* should be 1 for single-column indexes
* @param isUnique true if index enforces unique values, false otherwise
* @param sortOrder "A" for ascending order, "D" for descending order, null for
* no defined sort order
* @param indexCardinality count of unique values contained in the index
*/
public IndexColumn(final String colName, final String indexName, final short indexType,
final short colOrder, final boolean isUnique, final String sortOrder, final int indexCardinality) {
final Locale locale = Locale.getDefault();
final ResourceBundle cMessages = ResourceBundle.getBundle("com/stc/jdbc/builder/Bundle",
locale); // NO i18n
if (colName == null) {
throw new IllegalArgumentException(IndexColumn.mMessages.getString(
"SQLSE_E00805.ERROR_PARAMETER_NAME") + "(ERROR_PARAMETER_NAME)"); // NOI18N
}
if ((indexType != DatabaseMetaData.tableIndexClustered) &&
(indexType != DatabaseMetaData.tableIndexHashed) &&
(indexType != DatabaseMetaData.tableIndexOther)) {
throw new IllegalArgumentException(MessageFormat.format(
IndexColumn.mMessages.getString("SQLSE_E00804.ERROR_INDEX_TYPE"),
new Object[] { new Integer(type) }) + "(ERROR_INDEX_TYPE)"); // NOI18N
}
name = indexName;
columnName = colName;
type = indexType;
ordinalPosition = colOrder;
unique = isUnique;
sortSequence = sortOrder;
cardinality = indexCardinality;
}
public IndexColumn(final IndexColumn iCol) {
final Locale locale = Locale.getDefault();
final ResourceBundle cMessages = ResourceBundle.getBundle("com/stc/jdbc/builder/Bundle",
locale); // NO i18n
if (iCol.getColumnName() == null) {
throw new IllegalArgumentException(IndexColumn.mMessages.getString(
"ERROR_PARAMETER_NAME") + "(ERROR_PARAMETER_NAME)"); // NOI18N
}
if ((iCol.getType() != DatabaseMetaData.tableIndexClustered) &&
(iCol.getType() != DatabaseMetaData.tableIndexHashed) &&
(iCol.getType() != DatabaseMetaData.tableIndexOther)) {
throw new IllegalArgumentException(MessageFormat.format(
IndexColumn.mMessages.getString("SQLSE_E00804.ERROR_INDEX_TYPE"),
new Object[] { new Integer(type) }) + "(ERROR_INDEX_TYPE)"); // NOI18N
}
name = iCol.getIndexName();
columnName = iCol.getColumnName();
type = iCol.getType();
ordinalPosition = iCol.getOrdinalPosition();
unique = iCol.isUnique();
sortSequence = iCol.getSortOrder();
cardinality = iCol.getCardinality();
}
private IndexColumn() {
}
/**
* Creates a List of IndexColumn instances from the given ResultSet.
*
* @param rs ResultSet containing index metadata as obtained from
* DatabaseMetaData
* @return List of IndexColumn instances based from metadata in rs'
*
* @throws SQLException if SQL error occurs while reading in data from
* given ResultSet
*/
public static List<IndexColumn> createIndexList(final ResultSet rs) throws SQLException {
List<IndexColumn> indices = Collections.emptyList();
if ((rs != null) && rs.next()) {
indices = new ArrayList<IndexColumn>();
do {
final IndexColumn newIndex = new IndexColumn(rs);
// Ignore statistics indexes as they are relevant only to the
// DB which sourced this metadata.
if (newIndex.getType() != DatabaseMetaData.tableIndexStatistic) {
indices.add(newIndex);
}
} while (rs.next());
}
return indices;
}
/**
* Gets index name.
*
* @return index name
*/
public String getIndexName() {
return name;
}
/**
* Gets column name.
*
* @return name of column
*/
public String getColumnName() {
return columnName;
}
/**
* Gets index type.
*
* @return index type, one of DatabaseMetaData.tableIndexClustered,
* DatabaseMetaData.tableIndexHashed, or DatabaseMetaData.tableIndexOther
*
* @see java.sql.DatabaseMetaData.tableIndexClustered
* @see java.sql.DatabaseMetaData.tableIndexHashed
* @see java.sql.DatabaseMetaData.tableIndexOther
*/
public int getType() {
return type;
}
/**
* Indicates whether the index associated with this column is unique.
*
* @return true if index is unique, false otherwise
*/
public boolean isUnique() {
return unique;
}
/**
* Gets ordinal position of this column within a (composite) index.
* For an index associated with a single column, this should be 1.
*
* @return ordinal position of column within the composite index; 1 if
*/
public int getOrdinalPosition() {
return ordinalPosition;
}
/**
* Gets sort order, if any, associated with this index.
*
* @return "A" for ascending, "D" for descending, or null if no sort order
* is defined
*/
public String getSortOrder() {
return sortSequence;
}
/**
* Gets index cardinality. It represents the number of unique
* values associated with the index (for clustered, hashed, or other
* index types).
*
* @return count of unique values in the associated index
*/
public int getCardinality() {
return cardinality;
}
/**
* Compares this instance against the given object with respect to some
* "natural" ordering. Useful for sorting IndexColumn instances for UI display.
*
* Note: this class has a natural ordering that is inconsistent with equals.
* @param o Object against which this will be compared
* @return -1 if this is lesser than o; 0 if this is equal to o; 1 if this
* is greater than o
*/
//@Override
public int compareTo(final Object o) {
if (o == this) {
return 0;
}
final IndexColumn idx = (IndexColumn) o;
if (idx != null) {
if (name != null) {
return (idx.name != null) ? name.compareTo(idx.name) : (-1);
} else if (columnName != null) {
return (idx.columnName != null)
? columnName.compareTo(idx.columnName) : (-1);
} else {
return 0;
}
} else {
return -1;
}
}
}

View File

@ -1,163 +0,0 @@
/*
* 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]
*/
/*
* @(#)KeyColumn.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc.model.metadata;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.ResourceBundle;
import java.util.logging.Logger;
import com.sun.jbi.internationalization.Messages;
/**
*
* @author Jonathan Giron
* @version
*/
public class KeyColumn {
/**
* DatabaseMetaData ResultSet column name used to decode name of associated
* primary key
*/
protected static final String RS_KEY_NAME = "PK_NAME"; // NOI18N
private static final String RS_COLUMN_NAME = "COLUMN_NAME"; // NOI18N
/**
* DatabaseMetaData ResultSet column name used to decode key sequence number
*/
protected static final String RS_SEQUENCE_NUM = "KEY_SEQ"; // NOI18N
private static final Messages mMessages = Messages.getMessages(KeyColumn.class);
private static final Logger mLogger = Messages.getLogger(KeyColumn.class);
/** Name of column */
protected String columnName;
/** Name of key associated with this column */
protected String keyName;
/** For composite keys, sequence of this column for the associated key */
protected int sequenceNum;
/**
* Creates an instance of KeyColumn with the given values.
*
* @param name name of key
* @param column name of column
* @param colSequence sequence of this column within (composite) primary key
*/
public KeyColumn(final String name, final String column, final int colSequence) {
keyName = name;
columnName = column;
sequenceNum = colSequence;
}
/** Creates a new instance of KeyColumn */
protected KeyColumn() {
}
public KeyColumn(final ResultSet rs) throws SQLException {
if (rs == null) {
final Locale locale = Locale.getDefault();
final ResourceBundle cMessages = ResourceBundle.getBundle("com/stc/jdbc/builder/Bundle",
locale); // NO i18n
throw new IllegalArgumentException(KeyColumn.mMessages.getString(
"SQLSE_E00802.ERROR_VALID_RS") + "(ERROR_VALID_RS)"); // NO i18n
}
keyName = rs.getString(KeyColumn.RS_KEY_NAME);
columnName = rs.getString(KeyColumn.RS_COLUMN_NAME);
sequenceNum = rs.getShort(KeyColumn.RS_SEQUENCE_NUM);
}
/**
* Creates a List of (primary) KeyColumn instances from the given ResultSet.
*
* @param rs ResultSet containing primary key metadata as obtained from
* DatabaseMetaData
* @return List of KeyColumn instances based from metadata in rs
*
* @throws SQLException if SQL error occurs while reading in data from
* given ResultSet
*/
public static List<KeyColumn> createPrimaryKeyColumnList(final ResultSet rs)
throws SQLException {
if (rs == null) {
final Locale locale = Locale.getDefault();
final ResourceBundle cMessages = ResourceBundle.getBundle("com/stc/jdbc/builder/Bundle",
locale); // NO i18n
throw new IllegalArgumentException(cMessages.getString(
"SQLSE_E00801.ERROR_NULL_RS") + "(ERROR_NULL_RS)"); // NO i18n
}
List<KeyColumn> pkColumns = Collections.emptyList();
if ((rs != null) && rs.next()) {
pkColumns = new ArrayList<KeyColumn>();
do {
pkColumns.add(new KeyColumn(rs));
} while (rs.next());
}
return pkColumns;
}
/**
* Gets name of column name associate with this primary key.
*
* @return name of column
*/
public String getColumnName() {
return columnName;
}
/**
* Gets name of primary key with which this column is associated.
*
* @return name of associated PK
*/
public String getName() {
return keyName;
}
/**
* Gets sequence of this column within the (composite) primary key.
*
* @return column sequence
*/
public int getColumnSequence() {
return sequenceNum;
}
}

View File

@ -1,258 +0,0 @@
/*
* 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]
*/
/*
* @(#)ResultSetColumn.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc.model.metadata;
/**
* Class to hold resultset column metadata.
*
* @author Susan Chen
* @version
*/
public class ResultSetColumn {
private String name = ""; // name of parameter
private String javaType; // Java type - ex. java.lang.String
private String sqlType; // SQL type - ex. BIGINT, NUMERIC
private int ordinalPosition; // ordinal position
private int numericPrecision; // numeric precision
private int numericScale; // numeric scale
private boolean isNullable; //specifies if the parameter is nullable
private String label = ""; // title of column in resultset
/**
* Creates a new instance of ResultSetColumn.
*/
public ResultSetColumn() {
name = "";
javaType = "";
sqlType = "";
ordinalPosition = 0;
numericPrecision = 0;
numericScale = 0;
isNullable = false;
}
public ResultSetColumn(final ResultSetColumn rs) {
name = rs.getName();
javaType = rs.getJavaType();
sqlType = rs.getSqlType();
ordinalPosition = rs.getOrdinalPosition();
numericPrecision = rs.getNumericPrecision();
numericScale = rs.getNumericScale();
isNullable = rs.getIsNullable();
label = rs.getLabel();
}
/**
* Creates a new instance of ResultSetColumn with the given name.
*
* @param newName ResultSetColumn name
*/
public ResultSetColumn(final String newName) {
name = newName;
}
/**
* Creates a new instance of ResultSetColum with the given attributes.
*
* @param newName ResultSetColumn name
* @param newJavaType Java type
*/
public ResultSetColumn(final String newName, final String newJavaType) {
name = newName;
javaType = newJavaType;
}
/**
* Creates a new instance of ResultSetColum with the given attributes.
*
* @param newName ResultSetColumn name
* @param newJavaType Java type
* @param newOrdinalPosition Ordinal position
* @param newNumericPrecision Numeric precision
* @param newNumericScale Numeric scale
* @param newIsNullable Nullable flag
*/
public ResultSetColumn(final String newName, final String newJavaType,
final int newOrdinalPosition, final int newNumericPrecision, final int newNumericScale,
final boolean newIsNullable) {
name = newName;
javaType = newJavaType;
ordinalPosition = newOrdinalPosition;
numericPrecision = newNumericPrecision;
numericScale = newNumericScale;
isNullable = newIsNullable;
}
/**
* Get the ResultSet column name.
*
* @return ResultSet column name.
*/
public String getName() {
return name;
}
/**
* Get the Java type.
*
* @return Java type
*/
public String getJavaType() {
return javaType;
}
/**
* Get the SQL type.
*
* @return SQL type
*/
public String getSqlType() {
return sqlType;
}
/**
* Get the ResultSet column ordinal position.
*
* @return ResultSet column ordinal position
*/
public int getOrdinalPosition() {
return ordinalPosition;
}
/**
* Get the ResultSet column numeric precision.
*
* @return ResultSet column numeric precision
*/
public int getNumericPrecision() {
return numericPrecision;
}
/**
* Get the ResultSet column numeric scale.
*
* @return ResultSet column numeric scale
*/
public int getNumericScale() {
return numericScale;
}
/**
* Get the ResultSet column nullable flag.
*
* @return ResultSet column nullable flag.
*/
public boolean getIsNullable() {
return isNullable;
}
/**
* Set the ResultSet column name.
*
* @param newName ResultSet column name
*/
public void setName(final String newName) {
name = newName;
}
/**
* Set the ResultSet column Java type.
*
* @param newJavaType ResultSet column Java type.
*/
public void setJavaType(final String newJavaType) {
javaType = newJavaType;
}
/**
* Set the ResultSet column SQL type.
*
* @param newSqlType ResultSet column SQL type.
*/
public void setSqlType(final String newSqlType) {
sqlType = newSqlType;
}
/**
* Set the ResultSet column ordinal position.
*
* @param newOrdinalPosition ResultSet column ordinal position.
*/
public void setOrdinalPosition(final int newOrdinalPosition) {
ordinalPosition = newOrdinalPosition;
}
/**
* Set the ResultSet column numeric precision.
*
* @param newNumericPrecision ResultSet column numeric precision.
*/
public void setNumericPrecision(final int newNumericPrecision) {
numericPrecision = newNumericPrecision;
}
/**
* Set the ResultSet column numeric scale.
*
* @param newNumericScale ResultSet column numeric scale.
*/
public void setNumericScale(final int newNumericScale) {
numericScale = newNumericScale;
}
/**
* Set the ResultSet column nullable flag.
*
* @param newIsNullable ResultSet column nullable flag
*/
public void setIsNullable(final boolean newIsNullable) {
isNullable = newIsNullable;
}
/**
* Get the ResultSet column label.
*
* @return ResultSet column label.
*/
public String getLabel() {
return label;
}
/**
* Set the ResultSet column label.
*
* @param newName ResultSet column label
*/
public void setLabel(final String newName) {
label = newName;
}
}

View File

@ -1,153 +0,0 @@
/*
* 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]
*/
/*
* @(#)ResultSetColumns.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
/*****************************************************************
*
* Copyright (c) 2002, SeeBeyond Technology Corporation,
* All Rights Reserved
*
* This program, and all the routines referenced herein,
* are the proprietary properties and trade secrets of
* SEEBEYOND TECHNOLOGY CORPORATION.
*
* Except as provided for by license agreement, this
* program shall not be duplicated, used, or disclosed
* SEEBEYOND TECHNOLOGY CORPORATION.
*
****************************************************************/
/**
** This class represents a parameter in a stored procedure which is a resultset.
** It is named ResultSetColumns to avoid confusing it with the jdbc resultset.
**/
package com.sun.jbi.jdbcbc.model.metadata;
import java.util.ArrayList;
public class ResultSetColumns {
private ArrayList<ResultSetColumn> columns = null;
/**
** Holds the name of the ResultSet
**/
private String name = null;
/**
** constructor
**/
public ResultSetColumns() {
columns = new ArrayList<ResultSetColumn>();
}
/** getter for name;
* @return name;
*/
private String getName() {
return name;
}
/** setter for name;
** @param name
*/
private void setName(final String rsName) {
name = rsName;
}
/** getter for numColumns;
** @return numColumns;
**/
private int getNumColumns() {
return columns.size();
}
/** getter for columns;
* @return columns;
*/
private ArrayList getColumns() {
return columns;
}
/** setter for columns;
* @param columns list of <code>ResultSetColumn</code>
** objects;
*/
private void setColumns(final ArrayList<ResultSetColumn> columns) {
this.columns = columns;
}
/** adds a ResultsetColumn object to this list.
* @param rsCol <code>ResultSetColumn</code>
** object that needs to be added;
*/
private void add(final ResultSetColumn rsCol) {
if (rsCol != null) {
columns.add(rsCol);
}
}
/** gets the ResultsetColumn object at the given index.
* @param index index of <code>ResultSetColumn</code>
** object that needs to be retrieved;
*/
private ResultSetColumn get(final int index) {
return columns.get(index);
}
/** removes the given ResultSetColumn from the list
* @param rsCol <code>ResultSetColumn</code>
** object that needs to be removed;
* @returns true if the Object is in the list & is succesfully removed,
* false otherwise.
*/
private boolean remove(final ResultSetColumn rsCol) {
Object removedRSCol = new Object();
final int remIndex = columns.indexOf(rsCol);
if (remIndex != -1) {
removedRSCol = columns.remove(remIndex);
}
return removedRSCol.equals(rsCol);
}
/** removes a ResultSetColumn from the list at the given index
* @param index index at which the
** object that needs to be removed was set;
* @returns true if the Object is in the list & is succesfully removed,
* false otherwise.
*/
private boolean remove(final int index) {
Object removedRSCol = null;
removedRSCol = columns.remove(index);
return (removedRSCol != null);
}
}

View File

@ -1,515 +0,0 @@
/*
* 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]
*/
/*
* @(#)Table.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc.model.metadata;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.logging.Logger;
import com.sun.jbi.internationalization.Messages;
import java.util.logging.Level;
/**
* Class to hold procedure metadata.
*
* @author
*/
public class Table {
private static final Messages mMessages = Messages.getMessages(Table.class);
private static final Logger mLogger = Messages.getLogger(Table.class);
private String name = ""; // name of table
private String javaName = ""; // java name of table
private String catalog = ""; // catalog
private String schema = ""; // schema
private int numColumns = 0; // number of table columns
private int numColumnsSelected = 0; // number of table columns selected
private TableColumn[] columns; // array of table columns
private String type = "TABLE"; // TABLE, SYSTEM TABLE, VIEW - from driver
private List<IndexColumn> indexList; // List of IndexColumn objects
private List<ForeignKeyColumn> fkColumnList; // List of KeyColumn objects (PK cols)
private List<KeyColumn> pkColumnList; // List of ForeignKeyColumn objects (FK cols)
private boolean selected;
/**
* Creates an instance of Table with the given attributes.
*
* @param tname Table name
* @param tcatalog Catalog name
* @param tschema Schema name
* @param ttype Table type
*/
public Table(final String tname, final String tcatalog, final String tschema, final String ttype) {
name = tname;
catalog = tcatalog;
schema = tschema;
type = ttype;
indexList = Collections.emptyList();
fkColumnList = Collections.emptyList();
pkColumnList = Collections.emptyList();
}
/**
* Creates an instance of Table with the given attributes.
*
* @param tname Table name
* @param jname Table java name
* @param tcatalog Catalog name
* @param tschema Schema name
* @param ttype Table type
*/
public Table(final String tname, final String jname, final String tcatalog, final String tschema,
final String ttype) {
name = tname;
javaName = jname;
catalog = tcatalog;
schema = tschema;
type = ttype;
indexList = Collections.emptyList();
fkColumnList = Collections.emptyList();
pkColumnList = Collections.emptyList();
}
/**
* Creates an instance of Table with the given attributes.
*
* @param nTable
*/
public Table(final Table nTable) {
name = nTable.getName();
javaName = nTable.getJavaName();
catalog = nTable.getCatalog();
schema = nTable.getSchema();
numColumns = nTable.getNumColumns();
numColumnsSelected = nTable.getNumColumnsSelected();
cloneColumns(nTable.getColumns());
type = nTable.getType();
cloneIndexList(nTable.getIndexList());
cloneForeignKeyColumnList(nTable.getForeignKeyColumnList());
clonePrimaryKeyColumnList(nTable.getPrimaryKeyColumnList());
selected = nTable.isSelected();
}
/**
* Get the table name.
*
* @return Table name
*/
public String getName() {
return name;
}
/**
* Get the table java name.
*
* @return Table java name
*/
public String getJavaName() {
return javaName;
}
/**
* Get the catalog name.
*
* @return Catalog name
*/
public String getCatalog() {
return catalog;
}
/**
* Get the schema name.
*
* @return Schema name
*/
public String getSchema() {
return schema;
}
/**
* Get the number of table columns.
*
* @return Number of table columns.
*/
public int getNumColumns() {
return numColumns;
}
/**
* Get the number of columns selected.
*
* @return Number of columns selected.
*/
public int getNumColumnsSelected() {
return numColumnsSelected;
}
/**
* Get the list of table columns.
*
* @return List of table columns
*/
public TableColumn[] getColumns() {
return columns;
}
/**
* Get the table type.
*
* @return Table type
*/
public String getType() {
return type;
}
/**
* Set the table name.
*
* @param newName Table name
*/
public void setName(final String newName) {
name = newName;
}
/**
* Set the table java name.
*
*
* @param newJavaName
*/
public void setJavaName(final String newJavaName) {
javaName = newJavaName;
}
/**
* Set the catalog name.
*
* @param newCatalog Catalog name
*/
public void setCatalog(final String newCatalog) {
catalog = newCatalog;
}
/**
* Set the schema name.
*
* @param newSchema Schema name
*/
public void setSchema(final String newSchema) {
schema = newSchema;
}
/**
* Set the table columns.
*
* @param newColumns Table columns
*/
public void setColumns(final TableColumn[] newColumns) {
columns = newColumns;
// update the number of columns and columns selected
if (columns != null) {
numColumns = columns.length;
int count = 0;
for (TableColumn element : columns) {
if (element.getIsSelected()) {
count++;
}
}
numColumnsSelected = count;
} else {
numColumns = 0;
numColumnsSelected = 0;
}
}
/**
* Clone the table columns.
*
* @param newColumns Table columns
*/
public void cloneColumns(final TableColumn[] newColumns) {
numColumns = 0;
numColumnsSelected = 0;
int count = 0;
if (newColumns != null) {
numColumns = newColumns.length;
if (numColumns > 0) {
columns = new TableColumn[numColumns];
for (int i = 0; i < numColumns; i++) {
columns[i] = new TableColumn(newColumns[i]);
if (columns[i].getIsSelected()) {
count++;
}
}
}
numColumnsSelected = count;
}
}
public void addColumn(final TableColumn col) {
if (null == col) {
return;
}
int numCols = 0;
if (null != columns) {
numCols = columns.length;
}
final TableColumn[] newTable = new TableColumn[numCols + 1];
for (int i = 0; i < numCols; i++) {
newTable[i] = columns[i];
}
newTable[numCols] = col;
setColumns(newTable);
}
public void removeColumn(final int index) {
if ((null == columns) || (index > columns.length)) {
return;
}
final int numCols = columns.length;
final TableColumn[] newTable = new TableColumn[numCols - 1];
for (int i = 0, j = 0; i < numCols; i++, j++) {
if (i == index) {
j--;
} else {
newTable[j] = columns[i];
}
}
setColumns(newTable);
}
/**
* Set the table type.
*
* @param newType Table type
*/
public void setType(final String newType) {
type = newType;
}
/**
* Get the index list.
*
* @return Index list
*/
public List<IndexColumn> getIndexList() {
return indexList;
}
/**
* Set the index list.
*
* @param newList Index list
*/
public void setIndexList(final List<IndexColumn> newList) {
if ((newList != null) && (newList.size() != 0)) {
try {
// Test to ensure that List contains nothing but Index objects.
final IndexColumn[] dummy = newList.toArray(new IndexColumn[newList.size()]);
} catch (final ArrayStoreException e) {
throw new IllegalArgumentException(
"newList does not contain Index objects!");
}
indexList = newList;
}
}
public void cloneIndexList(final List<IndexColumn> newList) {
indexList = Collections.emptyList();
if ((newList != null) && (newList.size() != 0)) {
indexList = new ArrayList<IndexColumn>();
try {
// Test to ensure that List contains nothing but Index objects.
final IndexColumn[] dummy = newList.toArray(new IndexColumn[newList.size()]);
for (int i = 0; i < newList.size(); i++) {
final IndexColumn iCol = newList.get(i);
indexList.add(new IndexColumn(iCol));
}
} catch (final ArrayStoreException e) {
mLogger.log(Level.SEVERE,"newList does not contain Index objects!",e);
throw new IllegalArgumentException(
"newList does not contain Index objects!");
}
}
}
//added by Neena
//to set the selection state of the table
public void setSelected(final boolean selected) {
this.selected = selected;
}
//added by Neena
// to get the selection state of the object
public boolean isSelected() {
return selected;
}
/**
* Gets current List of KeyColumn objects, representing primary key columns
* in this table.
*
* @return List (possibly empty) of KeyColumn instances
*/
public List<KeyColumn> getPrimaryKeyColumnList() {
return pkColumnList;
}
/**
* Sets List of primary key column objects to the given List.
*
* @param newList List containing new collection of KeyColumn objects
* representing primary key columns within this table
*/
public void setPrimaryKeyColumnList(final List<KeyColumn> newList) {
if ((newList != null) && (newList.size() != 0)) {
try {
// Test to ensure that List contains nothing but Index objects.
final KeyColumn[] dummy = newList.toArray(new KeyColumn[newList.size()]);
} catch (final ArrayStoreException e) {
// ResourceBundle cMessages = NbBundle.getBundle(Table.class);
mLogger.log(Level.SEVERE,mMessages.getString("SQLSE_E00806.ERROR_KEY"),e);
throw new IllegalArgumentException(Table.mMessages.getString(
"SQLSE_E00806.ERROR_KEY")); // NO i18n
}
pkColumnList = newList;
}
}
public void clonePrimaryKeyColumnList(final List<KeyColumn> newList) {
pkColumnList = Collections.emptyList();
if ((newList != null) && (newList.size() != 0)) {
pkColumnList = new ArrayList<KeyColumn>();
try {
// Test to ensure that List contains nothing but Index objects.
final KeyColumn[] dummy = newList.toArray(new KeyColumn[newList.size()]);
for (int i = 0; i < newList.size(); i++) {
final KeyColumn tPK = newList.get(i);
pkColumnList.add(new KeyColumn(tPK.getName(),
tPK.getColumnName(), tPK.getColumnSequence()));
}
} catch (final ArrayStoreException e) {
// ResourceBundle cMessages = NbBundle.getBundle(Table.class);
mLogger.log(Level.SEVERE,mMessages.getString("SQLSE_E00806.ERROR_KEY"),e);
throw new IllegalArgumentException(Table.mMessages.getString(
"SQLSE_E00806.ERROR_KEY")); // NO i18n
}
}
}
/**
* Gets current List of ForeignKeyColumn objects, representing foreign key
* columns in this table.
*
* @return List (possibly empty) of ForeignKeyColumn instances
*/
private List<ForeignKeyColumn> getForeignKeyColumnList() {
return fkColumnList;
}
/**
* Sets List of foreign key column objects to the given List.
*
* @param newList List containing new collection of ForeignKeyColumn objects
* representing foreign key columns within this table
*/
public void setForeignKeyColumnList(final List<ForeignKeyColumn> newList) {
if ((newList != null) && (newList.size() != 0)) {
try {
// Test to ensure that List contains nothing but Index objects.
final ForeignKeyColumn[] dummy = newList.toArray(new ForeignKeyColumn[newList.size()]);
} catch (final ArrayStoreException e) {
// ResourceBundle cMessages = NbBundle.getBundle(Table.class);
//throw new IllegalArgumentException(
// cMessages.getString("ERROR_FK_KEY")+"(ERROR_FK_KEY)");// NO i18n
mLogger.log(Level.SEVERE,mMessages.getString("SQLSE_E00806.ERROR_KEY"),e);
throw new IllegalArgumentException(Table.mMessages.getString(
"SQLSE_E00806.ERROR_KEY")); // NO i18n
}
fkColumnList = newList;
}
}
private void cloneForeignKeyColumnList(final List<ForeignKeyColumn> newList) {
fkColumnList = Collections.emptyList();
if ((newList != null) && (newList.size() != 0)) {
fkColumnList = new ArrayList<ForeignKeyColumn>();
try {
// Test to ensure that List contains nothing but Index objects.
final ForeignKeyColumn[] dummy = newList.toArray(new ForeignKeyColumn[newList.size()]);
for (int i = 0; i < newList.size(); i++) {
final ForeignKeyColumn fkCol = newList.get(i);
fkColumnList.add(new ForeignKeyColumn(fkCol));
}
} catch (final ArrayStoreException e) {
// ResourceBundle cMessages = NbBundle.getBundle(Table.class);
// throw new IllegalArgumentException(
// cMessages.getString("ERROR_FK_KEY")+"(ERROR_FK_KEY)");// NO i18n
mLogger.log(Level.SEVERE,mMessages.getString("SQLSE_E00806.ERROR_KEY"),e);
throw new IllegalArgumentException(Table.mMessages.getString(
"SQLSE_E00806.ERROR_KEY")); // NO i18n
}
}
}
}

View File

@ -1,403 +0,0 @@
/*
* 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]
*/
/*
* @(#)TableColumn.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc.model.metadata;
/**
* Captures metadata information for a database table column.
*
* @author
*/
public class TableColumn {
private String name = ""; // name of table column
private String javaType; // Java type - ex. java.lang.String
private String sqlType; // SQL type - ex. BIGINT, NUMERIC
private int sqlTypeCode; // SQL type as java.sql.Types enumeration
private boolean isNullable; // specifies if the column is nullable
private boolean isSelected; // specifies if the column is selected
private boolean isPrimaryKey; // specifies if the column is a primary key
private boolean isForeignKey; // specifies if the column is a foreign key
private int ordinalPosition = 1; // position of column among others in table
private int numericPrecision; // numeric precision
private int numericScale; // numeric scale
private int numericRadix; // radix (number-base) for numeric values
private String defaultValue;
private String value; // added by Neena to hold the value of the column
// constructors
/**
* Constructs an instance of TableColumn.
*/
public TableColumn() {
name = "";
javaType = "";
sqlType = "";
sqlTypeCode = java.sql.Types.OTHER;
isNullable = false;
isSelected = true;
isPrimaryKey = false;
isForeignKey = false;
}
/**
* Constructs an instance of TableColumn using the given name.
*
* @param newName name of this new instance
*/
public TableColumn(final String newName) {
this();
name = newName;
}
/**
* Constructs an instance of TableColumn using the given name and
* Java type.
*
* @param newName name of new instance
* @param newJavaType Java type of this new instance
*/
public TableColumn(final String newName, final String newJavaType) {
this();
name = newName;
javaType = newJavaType;
}
/**
* Constructs a new instance of TableColumn using the given attributes.
*
* @param newName name of new instance
* @param newJavaType Java type of new instance
* @param newIsNullable true if column is nullable, false otherwise
* @param newIsSelected true if column is selected, false otherwise
* @param newIsPrimaryKey true if column is PK, false otherwise
* @param newIsForeignKey true if column if FK, false otherwise
* @param newSqlTypeCode SQL type code as enumerated in java.sql.Types
*/
private TableColumn(final String newName, final String newJavaType,
final boolean newIsNullable, final boolean newIsSelected, final boolean newIsPrimaryKey,
final boolean newIsForeignKey, final int newSqlTypeCode) {
name = newName;
javaType = newJavaType;
isNullable = newIsNullable;
isSelected = newIsSelected;
isPrimaryKey = newIsPrimaryKey;
isForeignKey = newIsForeignKey;
sqlTypeCode = newSqlTypeCode;
}
public TableColumn(final TableColumn tCol) {
name = tCol.getName();
javaType = tCol.getJavaType();
sqlType = tCol.getSqlType();
sqlTypeCode = tCol.getSqlTypeCode();
isNullable = tCol.getIsNullable();
isSelected = tCol.getIsSelected();
isPrimaryKey = tCol.getIsPrimaryKey();
isForeignKey = tCol.getIsForeignKey();
ordinalPosition = tCol.getOrdinalPosition();
numericPrecision = tCol.getNumericPrecision();
numericScale = tCol.getNumericScale();
numericRadix = tCol.getNumericRadix();
defaultValue = tCol.getDefaultValue();
value = tCol.getValue();
}
// getters
/**
* Gets name of column.
*
* @return name
*/
public String getName() {
return name;
}
/**
* Gets Java type.
*
* @return Java type
*/
public String getJavaType() {
return javaType;
}
/**
* Gets JDBC SQL type.
*
* @return JDBC SQL type (as String)
*/
public String getSqlType() {
return sqlType;
}
/**
* Indicates whether column is nullable
*
* @return true if nullable, false otherwise
*/
public boolean getIsNullable() {
return isNullable;
}
/**
* Indicates whether column is selected
*
* @return true if selected, false otherwise
*/
public boolean getIsSelected() {
return isSelected;
}
/**
* Indicates whether column is primary key
*
* @return true if PK, false otherwise
*/
public boolean getIsPrimaryKey() {
return isPrimaryKey;
}
/**
* Indicates whether column is foreign key
*
* @return true if FK, false otherwise
*/
public boolean getIsForeignKey() {
return isForeignKey;
}
/**
* Gets ordinal position of column among siblings in its table.
*
* @return ordinal position
*/
public int getOrdinalPosition() {
return ordinalPosition;
}
/**
* Gets precision (for numeric types) or maximum number of characters
* (for char or date types).
*
* @return numeric precision or maximum number of characters, as determined
* by column type
*/
public int getNumericPrecision() {
return numericPrecision;
}
/**
* Gets numeric scale of this column. Meaningful only for numeric columns.
*
* @return numeric scale of column; meaningless for non-numeric columns
*/
public int getNumericScale() {
return numericScale;
}
/**
* Gets radix (number base) of this column, e.g., 10 (decimal), 2 (binary).
* Meaningful only for numeric columns.
*
* @return numeric radix of column; meaningless for non-numeric columns
*/
public int getNumericRadix() {
return numericRadix;
}
/**
* Gets SQL type code.
*
*
* @return
*/
public int getSqlTypeCode() {
return sqlTypeCode;
}
/**
* Gets String representation of default value for this column (may be
* null).
*
* @return default value, or null if none was defined
*/
public String getDefaultValue() {
return defaultValue;
}
/**
* Gets String representation of value for this column (may be
* null).
*
* @return value, or null if none was defined
*/
public String getValue() {
return value;
}
// setters
/**
* Sets column name.
*
* @param newName new name of column
*/
public void setName(final String newName) {
name = newName;
}
/**
* Sets Java type of column.
*
* @param newJavaType new Java type of column
*/
public void setJavaType(final String newJavaType) {
javaType = newJavaType;
}
/**
* Sets JDBC SQL type of column
*
* @param newSqlType new JDBC SQL type (expressed as String representation)
*/
public void setSqlType(final String newSqlType) {
sqlType = newSqlType;
}
/**
* Sets nullability of column
*
* @param newIsNullable true if nullable; false otherwise
*/
public void setIsNullable(final boolean newIsNullable) {
isNullable = newIsNullable;
}
/**
* Sets selection state of column.
*
* @param newIsSelected true if selected; false otherwise
*/
public void setIsSelected(final boolean newIsSelected) {
isSelected = newIsSelected;
}
/**
* Sets whether column is a primary key. Note that multiple columns
* may participate in a composite PK.
*
* @param newIsPrimaryKey true if PK; false otherwise
*/
public void setIsPrimaryKey(final boolean newIsPrimaryKey) {
isPrimaryKey = newIsPrimaryKey;
}
/**
* Sets whether column is a foreign key. Note that multiple columns
* may participate in a composite FK.
*
* @param newIsForeignKey true if FK; false otherwise
*/
public void setIsForeignKey(final boolean newIsForeignKey) {
isForeignKey = newIsForeignKey;
}
/**
* Sets ordinal position of column.
*
* @param newPosition new ordinal position of column
*/
public void setOrdinalPosition(final int newPosition) {
if (newPosition <= 0) {
throw new IllegalArgumentException(
"Must supply positive integer value for newPosition.");
}
ordinalPosition = newPosition;
}
/**
* Sets numeric precision or maximum character width of column.
*
* @param newNumericPrecision new precision of column
*/
public void setNumericPrecision(final int newNumericPrecision) {
numericPrecision = newNumericPrecision;
}
/**
* Sets numeric scale of column.
*
* @param newNumericScale new scale of column
*/
public void setNumericScale(final int newNumericScale) {
numericScale = newNumericScale;
}
/**
* Sets numeric radix of column.
*
* @param newNumericRadix new radix of column
*/
public void setNumericRadix(final int newNumericRadix) {
numericRadix = newNumericRadix;
}
/**
* Sets default value, if any, of column.
*
* @param newDefault default value; set to null to indicate that no
* default exists.
*/
public void setDefaultValue(final String newDefault) {
defaultValue = newDefault;
}
/**
* Sets value, if any, of column.
*
* @param newValue default value; set to null to indicate that no
* default exists.
*/
public void setValue(final String newValue) {
value = newValue;
}
/**
* Sets SQL type code.
*
* @param newCode SQL code
*/
public void setSqlTypeCode(final int newCode) {
sqlTypeCode = newCode;
}
}

View File

@ -1,32 +0,0 @@
################## resource bundles for DBMetaData ###################
DBMD_Error_CheckPrimaryKeys=Error occurred while Checking Primary Keys.
DBMD_Error_CheckForeignKeys=Error occurred while Checking Foreign Keys.
DBMD_Conn_null=Connection cannot be null.
DBMD_Error_Disconnect=Error occurred while closing the connection to Database.
DBMD_Error_getMetaData=Error occurred while getting the MetaData.
DBMD_Error_getSchemas=Error occurred while getting Schemas.
DBMD_Error_getTables=Error occurred while getting Tables.
DBMD_ParameterMetaData_NotSupported=JDBC driver does not support java.sql.ParameterMetaData.
DBMD_Batch_NotSupported=supports BatchUpdates() failed .
DBMD_Catalog_NotSupported_DM=supports CatalogsInDataManipulation() failed.
DBMD_Catalog_NotSupported_Proc=supportsCatalogsInProcedureCalls() failed.
DBMD_Catalog_NotSupported_Table=supportsCatalogsInTableDefinitions() failed.
DBMD_Catalog_NotSupported_Index=supportsCatalogsInIndexDefinitions() failed.
DBMD_Catalog_NotSupported_PD=supportsCatalogsInPrivilegeDefinitions() failed.
DBMD_Convert_NotSupported=supportsConvert() failed.
DBMD_InOrderBy_NotSupported=supportsExpressionsInOrderBy() failed.
DBMD_Like_NotSupported=supportsLikeEscapeClause() failed.
DBMD_NP_NotSupported=supportsNamedParameters() failed.
DBMD_NonNullCOL_NotSupported=supportsNonNullableColumns() failed.
DBMD_OJ_NotSupported=supportsOuterJoins() failed.
DBMD_PD_NotSupported=supportsPositionedDelete() failed.
DBMD_PU_NotSupported=supportsPositionedUpdate() failed.
################## resource bundles common for all Classes ###################
ERROR_NULL_RS = Must supply non-null ResultSet instance for parameter rs.
ERROR_VALID_RS = Must supply valid ResultSet instance for parameter rs.
ERROR_VALID_RULE = Must supply valid value for newRule.
ERROR_INDEX_TYPE =Must supply valid index type value; {0} is out of range.
ERROR_PARAMETER_NAME = Must supply non-empty String for parameter colName.
ERROR_KEY = newList does not contain KeyColumn objects.
ERROR_FK_KEY = newList does not contain ForeignKeyColumn objects!

View File

@ -1,225 +0,0 @@
/*
* 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]
*/
/*
* @(#)DBConnectionInfo.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc.model.runtime;
import java.sql.SQLException;
import javax.sql.DataSource;
import javax.sql.XADataSource;
import javax.jbi.component.ComponentContext;
import javax.xml.transform.*;
import com.sun.jbi.jdbcbc.EndpointBean;
/*
* This class encapsulates the DBConnection parameters
* while obtaining the connection and will help in identifying
* the
*/
public class DBConnectionInfo {
private String dbUrl;
private String serverName;
private int portNumber;
private String databaseOrSchemaName;
private String username;
private String password;
private int dbType;
private String driverName;
private String mjndiName;
public static final String JDBCDEF_TAG = "connectiondef";
DBConnectionInfo dbConnectionInfo;
private String XAEnabled = null;
public void buildConnectionInfo(String dbUrl) {
//Url format: jdbc:derby://localhost:1527/testDB;create=true
if (dbUrl.startsWith("jdbc:derby://")) {
dbType = DataBases.DERBY.ordinal();
dbUrl = dbUrl.substring("jdbc:derby://".length(), dbUrl.length());
final String[] array1 = dbUrl.split("/");
final String[] array2 = array1[0].split(":");
serverName = array2[0];
portNumber = Integer.valueOf(array2[1]).intValue();
databaseOrSchemaName = array1[1];
} else if (dbUrl.startsWith("jdbc:oracle:thin:@")) {
//jdbc:oracle:thin:@<server>[:<1521>]:<database_name>
dbType = DataBases.ORACLE.ordinal();
}else if (dbUrl.startsWith("jdbc:Seebeyond:db2://")) {
//jdbc:Seebeyond:db2://localhost:1433;DatabaseName=db2
dbType = DataBases.DB2.ordinal();
dbUrl = dbUrl.substring("jdbc:Seebeyond:db2://".length(), dbUrl.length());
final String[] array1 = dbUrl.split(";");
final String[] array2 = array1[0].split(":");
serverName = array2[0];
portNumber = Integer.valueOf(array2[1]).intValue();
databaseOrSchemaName = array1[1];
}else if (dbUrl.startsWith("jdbc:SeeBeyond:sqlserver://")) {
//jdbc:SeeBeyond:sqlserver://rpoon-xp.stc.com:1433;DatabaseName=dgdb
dbType = DataBases.SQLSERVER.ordinal();
dbUrl = dbUrl.substring("jdbc:SeeBeyond:sqlserver://".length(), dbUrl.length());
final String[] array1 = dbUrl.split(";");
final String[] array2 = array1[0].split(":");
serverName = array2[0];
portNumber = Integer.valueOf(array2[1]).intValue();
final String[] array3 = array1[1].split("=");
databaseOrSchemaName = array3[1];
}
}
/*
* This gets the database name based on either the dbUrl or XADataSource or DataSource
* that is available
* @param dbUrl
* @param xads
* @param ds
* @return String
* @throws SQLException
*/
public String getDataBaseName(final String dbUrl, final XADataSource xads, final DataSource ds)
throws SQLException {
if (xads != null) {
return xads.getXAConnection().getConnection().getMetaData()
.getDatabaseProductName();
}
if (ds != null) {
return ds.getConnection().getMetaData().getDatabaseProductName();
}
if (dbUrl.contains("derby")) {
return "DERBY";
} else if (dbUrl.contains("oracle")) {
return "ORACLE";
}else if (dbUrl.contains("sqlserver")) {
return "SQLSERVER";
} else if (dbUrl.contains("db2")) {
return "DB2";
}
return null;
}
public String getDatabaseOrSchemaName() {
return databaseOrSchemaName;
}
public void setDatabaseOrSchemaName(final String databaseOrSchemaName) {
this.databaseOrSchemaName = databaseOrSchemaName;
}
public int getDbType() {
return dbType;
}
public void setDbType(final int dbType) {
this.dbType = dbType;
}
public String getDbUrl() {
return dbUrl;
}
public void setDbUrl(final String dbUrl) {
this.dbUrl = dbUrl;
}
public String getPassword() {
return password;
}
public void setPassword(final String password) {
this.password = password;
}
public int getPortNumber() {
return portNumber;
}
public void setPortNumber(final int portNumber) {
this.portNumber = portNumber;
}
public String getServerName() {
return serverName;
}
public void setServerName(final String serverName) {
this.serverName = serverName;
}
public String getUsername() {
return username;
}
public void setUsername(final String username) {
this.username = username;
}
public String getDriverName() {
return driverName;
}
public void setDriverName(final String driverName) {
this.driverName = driverName;
}
public String getJNDIName(){
return this.mjndiName;
}
public Object CreateDataSource(final ComponentContext componentContext,
final String jndiname, final EndpointBean epb, final String XAEnabled) throws Exception {
dbConnectionInfo = epb.getDBInfo();
final String dbURL = dbConnectionInfo.getDbUrl();
final String driverClass = dbConnectionInfo.getDriverName();
dbConnectionInfo.buildConnectionInfo(dbURL);
dbConnectionInfo.getDataBaseName(dbURL, null, null);
final String dbName = dbConnectionInfo.getDataBaseName(dbURL, null, null);
final DataBases dataBases = DataBases.valueOf(dbName);
dataBases.setDBConnectionInfo(dbConnectionInfo);
Object objDataSource = dataBases.buildDataSource();
this.mjndiName = dataBases.createAndBindJNDIDS(componentContext,objDataSource,jndiname,XAEnabled);
return objDataSource;
}
public String getXAEnabled() {
return XAEnabled;
}
public void setXAEnabled(String enabled) {
XAEnabled = enabled;
}
}

View File

@ -1,301 +0,0 @@
/*
* 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]
*/
/*
* @(#)DataBases.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc.model.runtime;
import com.sun.jbi.internationalization.Messages;
import java.lang.reflect.InvocationTargetException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.jbi.component.ComponentContext;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.*;
import javax.sql.XADataSource;
public enum DataBases {
DERBY,ORACLE,DB2,SQLSERVER,VSAM,MYSQL;
DBConnectionInfo mdbConnectionInfo = null;
private static final Logger mLogger = Logger.getLogger(DataBases.class.getName());
private static final Messages mMessages = Messages.getMessages(DataBases.class);
public int dbType() {
return ordinal();
}
@Override
public String toString() {
switch (this) {
case DERBY:
return "DERBY";
case ORACLE:
return "ORACLE";
case DB2:
return "DB2";
case SQLSERVER:
return "SQLSERVER";
case VSAM:
return "VSAM";
case MYSQL:
return "MYSQL";
}
return null;
}
public Class getXADataSourceClass() throws ClassNotFoundException {
switch (this) {
case DERBY:
return Class.forName("org.apache.derby.jdbc.ClientXADataSource");
case ORACLE:
return Class.forName("oracle.jdbc.xa.client.OracleXADataSource");
case DB2:
return Class.forName("com.ibm.db2.jdbc.DB2XADataSource");
case SQLSERVER:
return Class.forName("com.ddtek.jdbcx.sqlserver.SQLServerDataSource");
}
return null;
}
public Class getDataSourceClass() throws ClassNotFoundException {
switch (this) {
case DERBY:
return Class.forName("org.apache.derby.jdbc.ClientDataSource");
case ORACLE:
return Class.forName("oracle.jdbc.pool.OracleDataSource");
case DB2:
return Class.forName("com.SeeBeyond.db2.jdbcx.db2.DB2DataSource");
case SQLSERVER:
return Class.forName("com.SeeBeyond.sqlserver.jdbcx.sqlserver.SQLServerDataSource");
}
return null;
}
public Object buildDataSource() throws ClassNotFoundException , Exception{
Class dsClass = null;
if (mdbConnectionInfo.getXAEnabled().equalsIgnoreCase("XATransaction"))
dsClass = getXADataSourceClass();
else
dsClass = getDataSourceClass();
return buildDataSource(dsClass);
}
public Object buildDataSource(final Class dsclass) throws ClassNotFoundException, Exception {
try {
final Object dataSourceInstance = dsclass.newInstance();
final Class[] stringParam = new Class[] {String.class};
final Class[] intParam = new Class[]{int.class};
if (this == DERBY) {
dsclass.getMethod("setServerName", stringParam)
.invoke(dataSourceInstance,
new Object[] { mdbConnectionInfo.getServerName() });
dsclass
.getMethod("setPortNumber", new Class[] { int.class })
.invoke(dataSourceInstance,
new Object[] { mdbConnectionInfo.getPortNumber() });
dsclass.getMethod("setDatabaseName", stringParam)
.invoke(dataSourceInstance,
new Object[] { mdbConnectionInfo.getDatabaseOrSchemaName() });
dsclass.getMethod("setUser", stringParam)
.invoke(dataSourceInstance,
new Object[] { mdbConnectionInfo.getUsername() });
dsclass.getMethod("setPassword", stringParam)
.invoke(dataSourceInstance,
new Object[] { mdbConnectionInfo.getPassword() });
} else if (this == ORACLE) {
dsclass.getMethod("setURL", stringParam)
.invoke(dataSourceInstance,
new Object[] { mdbConnectionInfo.getDbUrl()});
dsclass.getMethod("setUser", stringParam)
.invoke(dataSourceInstance,
new Object[] { mdbConnectionInfo.getUsername() });
dsclass.getMethod("setPassword", stringParam)
.invoke(dataSourceInstance,
new Object[] { mdbConnectionInfo.getPassword() });
} else if (this == DB2) {
dsclass.getMethod("setServerName", stringParam)
.invoke(dataSourceInstance,
new Object[] { mdbConnectionInfo.getServerName()});
dsclass.getMethod("setPortNumber", intParam)
.invoke(dataSourceInstance,
new Object[] { mdbConnectionInfo.getPortNumber()});
dsclass.getMethod("setDatabaseName", stringParam)
.invoke(dataSourceInstance,
new Object[] { mdbConnectionInfo.getDatabaseOrSchemaName()});
dsclass.getMethod("setUser", stringParam)
.invoke(dataSourceInstance,
new Object[] { mdbConnectionInfo.getUsername() });
dsclass.getMethod("setPassword", stringParam)
.invoke(dataSourceInstance,
new Object[] { mdbConnectionInfo.getPassword() });
} else if (this == SQLSERVER) {
dsclass.getMethod("setServerName", stringParam)
.invoke(dataSourceInstance,
new Object[] { mdbConnectionInfo.getServerName()});
dsclass.getMethod("setPortNumber", intParam)
.invoke(dataSourceInstance,
new Object[] { mdbConnectionInfo.getPortNumber()});
dsclass.getMethod("setDatabaseName", stringParam)
.invoke(dataSourceInstance,
new Object[] { mdbConnectionInfo.getDatabaseOrSchemaName()});
dsclass.getMethod("setUser", stringParam)
.invoke(dataSourceInstance,
new Object[] { mdbConnectionInfo.getUsername() });
dsclass.getMethod("setPassword", stringParam)
.invoke(dataSourceInstance,
new Object[] { mdbConnectionInfo.getPassword() });
}
return dataSourceInstance;
} catch (final IllegalAccessException iae) {
mLogger.log(Level.SEVERE,"Illegal Access Exception While Dealing with Driver class",iae);
} catch (final NoSuchMethodException nsme) {
mLogger.log(Level.SEVERE,"No Such Method Exception While Dealing with Driver class",nsme);
} catch (final InvocationTargetException ite) {
mLogger.log(Level.SEVERE,"Invocation Target Exception While Dealing with Driver class",ite);
} catch (final InstantiationException ie) {
mLogger.log(Level.SEVERE," Exception While Instantiating the Driver class",ie);
}
return null;
}
/*public Object buildXADataSource() {
try {
final Class dsclass = getXADataSourceClass();
final Object dataSourceInstance = dsclass.newInstance();
final Class[] stringParam = new Class[] { String.class };
final Class[] stringParams = new Class[] {String.class,String.class};
if (this == DERBY) {
dsclass.getMethod("setServerName", stringParam)
.invoke(dataSourceInstance,
new Object[] { dbConnectionInfo.getServerName() });
dsclass.getMethod("setPortNumber", new Class[] { int.class })
.invoke(dataSourceInstance,
new Object[] { dbConnectionInfo.getPortNumber() });
dsclass.getMethod("setDatabaseName", stringParam)
.invoke(dataSourceInstance,
new Object[] { dbConnectionInfo.getDatabaseOrSchemaName() });
dsclass.getMethod("setUser", stringParam)
.invoke(dataSourceInstance,
new Object[] { dbConnectionInfo.getUsername() });
dsclass.getMethod("setPassword", stringParam)
.invoke(dataSourceInstance,
new Object[] { dbConnectionInfo.getPassword() });
} else if (this == ORACLE) {
dsclass.getMethod("setURL", stringParam).invoke(dataSourceInstance,
new Object[] { dbConnectionInfo.getDbUrl()});
dsclass.getMethod("setUser", stringParam)
.invoke(dataSourceInstance,
new Object[] { dbConnectionInfo.getUsername() });
dsclass.getMethod("setPassword", stringParam)
.invoke(dataSourceInstance,
new Object[] { dbConnectionInfo.getPassword() });
}
return dataSourceInstance;
} catch (final ClassNotFoundException cnfe) {
cnfe.getMessage();
} catch (final IllegalAccessException iae) {
} catch (final NoSuchMethodException nsme) {
} catch (final InvocationTargetException ite) {
} catch (final InstantiationException ie) {
}
return null;
}
*/
public void setDBConnectionInfo(final DBConnectionInfo dbConnectionInfo) {
this.mdbConnectionInfo = dbConnectionInfo;
}
public DataBases getValue(final String value) {
if (value.equalsIgnoreCase("DERBY")) {
return DERBY;
} else if (value.equalsIgnoreCase("ORACLE")) {
return ORACLE;
} else if (value.equalsIgnoreCase("VSAM")) {
return VSAM;
} else if (value.equalsIgnoreCase("DB2")) {
return DB2;
} else if (value.equalsIgnoreCase("SQLSERVER")) {
return SQLSERVER;
} else if (value.equalsIgnoreCase("MYSQL")) {
return MYSQL;
} else {
return null;
}
}
public DatabaseModel getDatabaseModel() {
switch (this) {
case DERBY:
return DerbyDataAccess.getInstance();
case ORACLE:
return OracleDataAccess.getInstance();
case DB2:
return Db2DataAccess.getInstance();
case SQLSERVER:
return SqlServerDataAccess.getInstance();
}
return DatabaseModelImpl.getInstance();
}
public String createAndBindJNDIDS(final ComponentContext componentContext,
Object datasource, final String jndiname, final String xaEnabled)
throws NamingException {
final InitialContext namingContext = componentContext.getNamingContext();
if(mdbConnectionInfo.getXAEnabled().equalsIgnoreCase("XATransaction")){
datasource =(XADataSource)datasource;
}else{
datasource =(DataSource)datasource;
}
if(lookup(jndiname,namingContext)){
namingContext.bind(jndiname, datasource);
}
return jndiname;
}
public boolean lookup(final String jndiname,final InitialContext namingContext) throws NamingException{
try{
namingContext.lookup(jndiname);
}catch(javax.naming.NameNotFoundException e){
return true;
}
return false;
}
}

View File

@ -1,45 +0,0 @@
/*
* 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]
*/
/*
* @(#)DatabaseModel.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc.model.runtime;
/**
* @author Venkat P
*
*/
public interface DatabaseModel {
public String createQualifiedQuery(String souTable, String tarTable,
String flagName, String MarkColumnValue, String pkName, String Operation,String FlagColumnType)
throws Exception;
public String generateSelectQuery(String query, String tableName)
throws Exception;
}

View File

@ -1,265 +0,0 @@
/*
* 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]
*/
/*
* @(#)DatabaseModelImpl.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc.model.runtime;
import java.util.logging.Logger;
import com.sun.jbi.internationalization.Messages;
import java.util.logging.Level;
/**
* @author Venkat P
*
*/
public class DatabaseModelImpl implements DatabaseModel {
private static final Messages mMessages = Messages.getMessages(DatabaseModelImpl.class);
private static final Logger mLogger = Messages.getLogger(DatabaseModelImpl.class);
public DatabaseModelImpl(){
}
private static final DatabaseModelImpl instance = new DatabaseModelImpl();
public static final DatabaseModelImpl getInstance(){
return instance;
}
//@Override
public String createQualifiedQuery(final String souTable, final String tarTable,
final String flagName, final String markcolumnValue, final String pkName, final String operation,
final String FlagColumnType)
throws Exception {
String Sql = null;
try {
if (operation.equals("UPDATE")) {
if(FlagColumnType.equalsIgnoreCase("LONGVARCHAR") || FlagColumnType.equalsIgnoreCase("CHAR")
|| FlagColumnType.equalsIgnoreCase("VARCHAR")){
/* Sql = "update " + souTable + " set " + flagName + " = " +
"'"+markcolumnValue+"'"+ " where" + souTable + "." + pkName;*/
Sql = "update " + souTable + " set " + flagName + " = " +
"'"+markcolumnValue+"'"+ " where" + pkName;
}else{
/*Sql = "update " + souTable + " set " + flagName + " = " +
markcolumnValue + " where" + souTable + "." + pkName;*/
Sql = "update " + souTable + " set " + flagName + " = " +
markcolumnValue + " where" + pkName;
}
} else if (operation.equals("DELETE")) {
/*Sql = "delete from " + souTable + " where " + souTable + "." +
pkName;*/
Sql = "delete from " + souTable + " where " + pkName;
} else if (operation.equals("INSERT")) {
/*Sql = "insert into " + tarTable + " select * from " + souTable +
" where " + souTable + "." + pkName;*/
Sql = "insert into " + tarTable + " select * from " + souTable +
" where " + pkName;
} else if (operation.equals("SELECT")) {
Sql = "select * from " + souTable;
}
} catch (final Exception e) {
mLogger.log(Level.SEVERE,mMessages.getString("Derby_Create_Query"),e);
throw new Exception(mMessages.getString("Derby_Create_Query"), e);
}
return Sql;
}
//@Override
public String generateSelectQuery(final String selectSql, final String TableName)
throws Exception {
String Sql = null;
Sql = "select * from " + TableName;
return Sql;
}
}
//public class DerbyDataAccess implements DatabaseModel{
// private String mtabName = null;
// private String mtrigName = null;
// private TableColumn[] mcolumns = null;
// private String mSchemaName = null;
// private String mMarkColumnName = null;
// private String mstageFlag = null;
// private static final Messages mMessages = Messages.getMessages(DerbyDataAccess.class);
// private static Logger mLogger = Messages.getLogger(DerbyDataAccess.class);
/**
* @param souTable
* @param schemaName
* @param flagName
*/
// public void init(Table souTable,String schemaName,String flagName,String stageFlag){
// mMarkColumnName = flagName;
// mstageFlag = stageFlag;
// setTableName(souTable.getName());
// setTriggerName(souTable.getName());
// mcolumns = souTable.getColumns();
// this.mSchemaName = schemaName;
// }
/**
* @throws Exception
*/
// public String createTableQuery() throws Exception {
// StringBuffer sb = new StringBuffer();
// sb.append("create table ");
// sb.append(" ");
// sb.append(getTableName());
// sb.append(" ");
// sb.append("(");
// for (int i = 0; i < this.mcolumns.length; i++) {
// sb.append("\"" + this.mcolumns[i].getName() + "\"");
// sb.append(" ");
// sb.append(this.mcolumns[i].getSqlType());
// if ((this.mcolumns[i].getNumericPrecision() != 0)
// && ((this.mcolumns[i].getSqlType())
// .equalsIgnoreCase("VARCHAR"))) {
// sb.append("(");
// sb.append(this.mcolumns[i].getNumericPrecision());
// sb.append(")");
// }
// sb.append(" ");
// if (this.mcolumns[i].getIsPrimaryKey()) {
// sb.append("primary key");
// }
// sb.append(" ");
// if (this.mcolumns[i].getIsNullable()) {
// sb.append("not null");
// }
// if ((i == (this.mcolumns.length - 1)))
// sb.append(")");
// else
// sb.append(",");
// }
// mLogger.log(Level.INFO, mMessages.getString("Derby_Create_SQL") + sb.toString());
// return sb.toString();
// }
/**
* @param source
* @throws Exception
*/
// public String createTriggerQuery(String source) throws Exception {
// StringBuffer sb = new StringBuffer();
// sb.append("CREATE TRIGGER ");
// sb.append(" ");
// sb.append(getTriggerName());
// sb.append(" ");
// sb.append("AFTER INSERT ON");
// sb.append(" ");
// sb.append(source);
// sb.append(" ");
// sb.append("REFERENCING NEW AS UPDATEDROW FOR EACH ROW MODE DB2SQL");
// sb.append(" ");
// sb.append("INSERT INTO");
// sb.append(" ");
// sb.append(getTableName());
// sb.append(" ");
// sb.append("VALUES");
// sb.append(" ");
// sb.append("(");
// for (int i = 0; i < this.mcolumns.length; i++) {
// sb.append("UPDATEDROW.");
// sb.append("\"");
// sb.append(this.mcolumns[i].getName());
// sb.append("\"");
// if ((i == (this.mcolumns.length - 1)))
// sb.append(")");
// else
// sb.append(",");
// }
// mLogger.log(Level.INFO, mMessages.getString("Derby_Create_SQL") + sb.toString());
// return sb.toString();
// }
//
// public String getTableName(){
// return (getSchemaName()+"."+this.mtabName);
// }
//
// public String getTriggerName(){
// return (getSchemaName()+"."+this.mtrigName);
// }
//
// public String getSchemaName(){
// return "\""+this.mSchemaName+"\"";
// }
//
// public void setTableName(String tabSource){
// mLogger.log(Level.INFO, "Flag Name" + mMarkColumnName);
// if(mMarkColumnName != null && mMarkColumnName != "" && mstageFlag.equalsIgnoreCase("Yes"))
// this.mtabName = "\""+tabSource+"_jdbc_StaggingTable"+"\"";
// else
// this.mtabName = "\""+tabSource+"\"";
// }
//
// public void setTriggerName(String trigName){
// if(mMarkColumnName != null && mMarkColumnName != "" && mstageFlag.equalsIgnoreCase("Yes"))
// this.mtrigName = "\""+trigName+"_jdbc_staggingTrigger"+"\"";
// else
// this.mtabName = "\""+trigName+"\"";
// }
/**
* @param souTable
* @param flagName
* @param pkName
* @param operation
* @throws Exception
*/
// public String createQualifiedQuery(String souTable, String flagName,
// String pkName, String operation) throws Exception {
// String Sql = null;
//
// try {
// if (operation.equals("UPDATE")) {
// Sql = "update " + souTable + " set " + flagName + " = 0 where"
// + souTable + "." + pkName;
// } else if (operation.equals("DELETE")) {
// Sql = "delete from " + souTable + " where " + souTable + "."
// + pkName ;
// } else if (operation.equals("INSERT")) {
// Sql = "insert into " + "\"" + souTable + "\"" + "." + "\""
// + flagName + "_jdbc_StaggingTable" + "\""
// + " select * from " + pkName;
// }
// } catch (Exception e) {
// throw new Exception( mMessages.getString("Derby_Create_Query"), e);
// }
// return Sql;
// }
//}

View File

@ -1,258 +0,0 @@
/*
* 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]
*/
/*
* @(#)Db2DataAccess.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc.model.runtime;
import com.sun.jbi.internationalization.Messages;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* @author Venkat P
*
*/
public class Db2DataAccess implements DatabaseModel {
private static final Messages mMessages = Messages.getMessages(Db2DataAccess.class);
private static final Logger mLogger = Messages.getLogger(Db2DataAccess.class);
private Db2DataAccess(){
}
private static final Db2DataAccess instance = new Db2DataAccess();
public static final Db2DataAccess getInstance(){
return instance;
}
//@Override
public String createQualifiedQuery(final String souTable, final String tarTable,
final String flagName, final String markcolumnValue, final String pkName, final String operation,
final String FlagColumnType)
throws Exception {
String Sql = null;
try {
if (operation.equals("UPDATE")) {
if(FlagColumnType.equalsIgnoreCase("LONGVARCHAR") || FlagColumnType.equalsIgnoreCase("CHAR")
|| FlagColumnType.equalsIgnoreCase("VARCHAR")){
Sql = "update " + souTable + " set " + flagName + " = " +
"'"+markcolumnValue+"'"+ " where" + souTable + "." + pkName;
}else{
Sql = "update " + souTable + " set " + flagName + " = " +
markcolumnValue + " where" + souTable + "." + pkName;
}
} else if (operation.equals("DELETE")) {
Sql = "delete from " + souTable + " where " + souTable + "." +
pkName;
} else if (operation.equals("INSERT")) {
Sql = "insert into " + tarTable + " select * from " + souTable +
" where " + souTable + "." + pkName;
} else if (operation.equals("SELECT")) {
Sql = "select * from " + "\"" + souTable + "\"";
}
} catch (final Exception e) {
mLogger.log(Level.SEVERE,mMessages.getString("Derby_Create_Query"),e);
throw new Exception(Db2DataAccess.mMessages.getString("Derby_Create_Query"), e);
}
return Sql;
}
//@Override
public String generateSelectQuery(final String selectSql, final String TableName)
throws Exception {
String Sql = null;
Sql = "select * from " + TableName;
return Sql;
}
}
//public class Db2DataAccess implements DatabaseModel{
// private String mtabName = null;
// private String mtrigName = null;
// private TableColumn[] mcolumns = null;
// private String mSchemaName = null;
// private String mMarkColumnName = null;
// private String mstageFlag = null;
// private static final Messages mMessages = Messages.getMessages(Db2DataAccess.class);
// private static Logger mLogger = Messages.getLogger(Db2DataAccess.class);
/**
* @param souTable
* @param schemaName
* @param flagName
*/
// public void init(Table souTable,String schemaName,String flagName,String stageFlag){
// mMarkColumnName = flagName;
// mstageFlag = stageFlag;
// setTableName(souTable.getName());
// setTriggerName(souTable.getName());
// mcolumns = souTable.getColumns();
// this.mSchemaName = schemaName;
// }
/**
* @throws Exception
*/
// public String createTableQuery() throws Exception {
// StringBuffer sb = new StringBuffer();
// sb.append("create table ");
// sb.append(" ");
// sb.append(getTableName());
// sb.append(" ");
// sb.append("(");
// for (int i = 0; i < this.mcolumns.length; i++) {
// sb.append("\"" + this.mcolumns[i].getName() + "\"");
// sb.append(" ");
// sb.append(this.mcolumns[i].getSqlType());
// if ((this.mcolumns[i].getNumericPrecision() != 0)
// && ((this.mcolumns[i].getSqlType())
// .equalsIgnoreCase("VARCHAR"))) {
// sb.append("(");
// sb.append(this.mcolumns[i].getNumericPrecision());
// sb.append(")");
// }
// sb.append(" ");
// if (this.mcolumns[i].getIsPrimaryKey()) {
// sb.append("primary key");
// }
// sb.append(" ");
// if (this.mcolumns[i].getIsNullable()) {
// sb.append("not null");
// }
// if ((i == (this.mcolumns.length - 1)))
// sb.append(")");
// else
// sb.append(",");
// }
// mLogger.log(Level.INFO, mMessages.getString("Derby_Create_SQL") + sb.toString());
// return sb.toString();
// }
/**
* @param source
* @throws Exception
*/
// public String createTriggerQuery(String source) throws Exception {
// StringBuffer sb = new StringBuffer();
// sb.append("CREATE TRIGGER ");
// sb.append(" ");
// sb.append(getTriggerName());
// sb.append(" ");
// sb.append("AFTER INSERT ON");
// sb.append(" ");
// sb.append(source);
// sb.append(" ");
// sb.append("REFERENCING NEW AS UPDATEDROW FOR EACH ROW MODE DB2SQL");
// sb.append(" ");
// sb.append("INSERT INTO");
// sb.append(" ");
// sb.append(getTableName());
// sb.append(" ");
// sb.append("VALUES");
// sb.append(" ");
// sb.append("(");
// for (int i = 0; i < this.mcolumns.length; i++) {
// sb.append("UPDATEDROW.");
// sb.append("\"");
// sb.append(this.mcolumns[i].getName());
// sb.append("\"");
// if ((i == (this.mcolumns.length - 1)))
// sb.append(")");
// else
// sb.append(",");
// }
// mLogger.log(Level.INFO, mMessages.getString("Derby_Create_SQL") + sb.toString());
// return sb.toString();
// }
//
// public String getTableName(){
// return (getSchemaName()+"."+this.mtabName);
// }
//
// public String getTriggerName(){
// return (getSchemaName()+"."+this.mtrigName);
// }
//
// public String getSchemaName(){
// return "\""+this.mSchemaName+"\"";
// }
//
// public void setTableName(String tabSource){
// mLogger.log(Level.INFO, "Flag Name" + mMarkColumnName);
// if(mMarkColumnName != null && mMarkColumnName != "" && mstageFlag.equalsIgnoreCase("Yes"))
// this.mtabName = "\""+tabSource+"_jdbc_StaggingTable"+"\"";
// else
// this.mtabName = "\""+tabSource+"\"";
// }
//
// public void setTriggerName(String trigName){
// if(mMarkColumnName != null && mMarkColumnName != "" && mstageFlag.equalsIgnoreCase("Yes"))
// this.mtrigName = "\""+trigName+"_jdbc_staggingTrigger"+"\"";
// else
// this.mtabName = "\""+trigName+"\"";
// }
/**
* @param souTable
* @param flagName
* @param pkName
* @param operation
* @throws Exception
*/
// public String createQualifiedQuery(String souTable, String flagName,
// String pkName, String operation) throws Exception {
// String Sql = null;
//
// try {
// if (operation.equals("UPDATE")) {
// Sql = "update " + souTable + " set " + flagName + " = 0 where"
// + souTable + "." + pkName;
// } else if (operation.equals("DELETE")) {
// Sql = "delete from " + souTable + " where " + souTable + "."
// + pkName ;
// } else if (operation.equals("INSERT")) {
// Sql = "insert into " + "\"" + souTable + "\"" + "." + "\""
// + flagName + "_jdbc_StaggingTable" + "\""
// + " select * from " + pkName;
// }
// } catch (Exception e) {
// throw new Exception( mMessages.getString("Derby_Create_Query"), e);
// }
// return Sql;
// }
//}

View File

@ -1,266 +0,0 @@
/*
* 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]
*/
/*
* @(#)DerbyDataAccess.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc.model.runtime;
import java.util.logging.Logger;
import com.sun.jbi.internationalization.Messages;
import java.util.logging.Level;
/**
* @author Venkat P
*
*/
public class DerbyDataAccess implements DatabaseModel {
private static final Messages mMessages = Messages.getMessages(DerbyDataAccess.class);
private static final Logger mLogger = Messages.getLogger(DerbyDataAccess.class);
private DerbyDataAccess(){
}
private static final DerbyDataAccess instance = new DerbyDataAccess();
public static final DerbyDataAccess getInstance(){
return instance;
}
//@Override
public String createQualifiedQuery(final String souTable, final String tarTable,
final String flagName, final String markcolumnValue, final String pkName, final String operation,
final String FlagColumnType)
throws Exception {
String Sql = null;
try {
if (operation.equals("UPDATE")) {
if(FlagColumnType.equalsIgnoreCase("LONGVARCHAR") || FlagColumnType.equalsIgnoreCase("CHAR")
|| FlagColumnType.equalsIgnoreCase("VARCHAR")){
/* Sql = "update " + souTable + " set " + flagName + " = " +
"'"+markcolumnValue+"'"+ " where" + souTable + "." + pkName;*/
Sql = "update " + souTable + " set " + flagName + " = " +
"'"+markcolumnValue+"'"+ " where" + pkName;
}else{
/*Sql = "update " + souTable + " set " + flagName + " = " +
markcolumnValue + " where" + souTable + "." + pkName;*/
Sql = "update " + souTable + " set " + flagName + " = " +
markcolumnValue + " where" + pkName;
}
} else if (operation.equals("DELETE")) {
/*Sql = "delete from " + souTable + " where " + souTable + "." +
pkName;*/
Sql = "delete from " + souTable + " where " + pkName;
} else if (operation.equals("INSERT")) {
/*Sql = "insert into " + tarTable + " select * from " + souTable +
" where " + souTable + "." + pkName;*/
Sql = "insert into " + tarTable + " select * from " + souTable +
" where " + pkName;
} else if (operation.equals("SELECT")) {
Sql = "select * from "+ souTable;
}
} catch (final Exception e) {
mLogger.log(Level.SEVERE,mMessages.getString("Derby_Create_Query"),e);
throw new Exception(DerbyDataAccess.mMessages.getString("Derby_Create_Query"), e);
}
return Sql;
}
//@Override
public String generateSelectQuery(final String selectSql, final String TableName)
throws Exception {
String Sql = null;
Sql = "select * from " + TableName;
return Sql;
}
}
//public class DerbyDataAccess implements DatabaseModel{
// private String mtabName = null;
// private String mtrigName = null;
// private TableColumn[] mcolumns = null;
// private String mSchemaName = null;
// private String mMarkColumnName = null;
// private String mstageFlag = null;
// private static final Messages mMessages = Messages.getMessages(DerbyDataAccess.class);
// private static Logger mLogger = Messages.getLogger(DerbyDataAccess.class);
/**
* @param souTable
* @param schemaName
* @param flagName
*/
// public void init(Table souTable,String schemaName,String flagName,String stageFlag){
// mMarkColumnName = flagName;
// mstageFlag = stageFlag;
// setTableName(souTable.getName());
// setTriggerName(souTable.getName());
// mcolumns = souTable.getColumns();
// this.mSchemaName = schemaName;
// }
/**
* @throws Exception
*/
// public String createTableQuery() throws Exception {
// StringBuffer sb = new StringBuffer();
// sb.append("create table ");
// sb.append(" ");
// sb.append(getTableName());
// sb.append(" ");
// sb.append("(");
// for (int i = 0; i < this.mcolumns.length; i++) {
// sb.append("\"" + this.mcolumns[i].getName() + "\"");
// sb.append(" ");
// sb.append(this.mcolumns[i].getSqlType());
// if ((this.mcolumns[i].getNumericPrecision() != 0)
// && ((this.mcolumns[i].getSqlType())
// .equalsIgnoreCase("VARCHAR"))) {
// sb.append("(");
// sb.append(this.mcolumns[i].getNumericPrecision());
// sb.append(")");
// }
// sb.append(" ");
// if (this.mcolumns[i].getIsPrimaryKey()) {
// sb.append("primary key");
// }
// sb.append(" ");
// if (this.mcolumns[i].getIsNullable()) {
// sb.append("not null");
// }
// if ((i == (this.mcolumns.length - 1)))
// sb.append(")");
// else
// sb.append(",");
// }
// mLogger.log(Level.INFO, mMessages.getString("Derby_Create_SQL") + sb.toString());
// return sb.toString();
// }
/**
* @param source
* @throws Exception
*/
// public String createTriggerQuery(String source) throws Exception {
// StringBuffer sb = new StringBuffer();
// sb.append("CREATE TRIGGER ");
// sb.append(" ");
// sb.append(getTriggerName());
// sb.append(" ");
// sb.append("AFTER INSERT ON");
// sb.append(" ");
// sb.append(source);
// sb.append(" ");
// sb.append("REFERENCING NEW AS UPDATEDROW FOR EACH ROW MODE DB2SQL");
// sb.append(" ");
// sb.append("INSERT INTO");
// sb.append(" ");
// sb.append(getTableName());
// sb.append(" ");
// sb.append("VALUES");
// sb.append(" ");
// sb.append("(");
// for (int i = 0; i < this.mcolumns.length; i++) {
// sb.append("UPDATEDROW.");
// sb.append("\"");
// sb.append(this.mcolumns[i].getName());
// sb.append("\"");
// if ((i == (this.mcolumns.length - 1)))
// sb.append(")");
// else
// sb.append(",");
// }
// mLogger.log(Level.INFO, mMessages.getString("Derby_Create_SQL") + sb.toString());
// return sb.toString();
// }
//
// public String getTableName(){
// return (getSchemaName()+"."+this.mtabName);
// }
//
// public String getTriggerName(){
// return (getSchemaName()+"."+this.mtrigName);
// }
//
// public String getSchemaName(){
// return "\""+this.mSchemaName+"\"";
// }
//
// public void setTableName(String tabSource){
// mLogger.log(Level.INFO, "Flag Name" + mMarkColumnName);
// if(mMarkColumnName != null && mMarkColumnName != "" && mstageFlag.equalsIgnoreCase("Yes"))
// this.mtabName = "\""+tabSource+"_jdbc_StaggingTable"+"\"";
// else
// this.mtabName = "\""+tabSource+"\"";
// }
//
// public void setTriggerName(String trigName){
// if(mMarkColumnName != null && mMarkColumnName != "" && mstageFlag.equalsIgnoreCase("Yes"))
// this.mtrigName = "\""+trigName+"_jdbc_staggingTrigger"+"\"";
// else
// this.mtabName = "\""+trigName+"\"";
// }
/**
* @param souTable
* @param flagName
* @param pkName
* @param operation
* @throws Exception
*/
// public String createQualifiedQuery(String souTable, String flagName,
// String pkName, String operation) throws Exception {
// String Sql = null;
//
// try {
// if (operation.equals("UPDATE")) {
// Sql = "update " + souTable + " set " + flagName + " = 0 where"
// + souTable + "." + pkName;
// } else if (operation.equals("DELETE")) {
// Sql = "delete from " + souTable + " where " + souTable + "."
// + pkName ;
// } else if (operation.equals("INSERT")) {
// Sql = "insert into " + "\"" + souTable + "\"" + "." + "\""
// + flagName + "_jdbc_StaggingTable" + "\""
// + " select * from " + pkName;
// }
// } catch (Exception e) {
// throw new Exception( mMessages.getString("Derby_Create_Query"), e);
// }
// return Sql;
// }
//}

View File

@ -1,264 +0,0 @@
/*
* 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]
*/
/*
* @(#)OracleDataAccess.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc.model.runtime;
import java.util.logging.Logger;
import com.sun.jbi.internationalization.Messages;
import java.util.logging.Level;
/**
* @author Venkat P
*
*/
public class OracleDataAccess implements DatabaseModel {
private static final Messages mMessages = Messages.getMessages(DerbyDataAccess.class);
private static final Logger mLogger = Messages.getLogger(DerbyDataAccess.class);
private OracleDataAccess(){
}
private static final OracleDataAccess instance = new OracleDataAccess();
public static final OracleDataAccess getInstance(){
return instance;
}
//@Override
public String createQualifiedQuery(final String souTable, final String tarTable,
final String flagName, final String markcolumnValue, final String pkName, final String operation,
final String FlagColumnType)
throws Exception {
String Sql = null;
try {
if (operation.equals("UPDATE")) {
if(FlagColumnType.equalsIgnoreCase("LONGVARCHAR") || FlagColumnType.equalsIgnoreCase("CHAR")
|| FlagColumnType.equalsIgnoreCase("VARCHAR")){
/*Sql = "update " + souTable + " set " + flagName + " = " +
"'"+markcolumnValue+"'"+ " where" + souTable + "." + pkName;*/
Sql = "update " + souTable + " set " + flagName + " = " +
"'"+markcolumnValue+"'"+ " where" + pkName;
}else{
/*Sql = "update " + souTable + " set " + flagName + " = " +
markcolumnValue + " where" + souTable + "." + pkName;*/
Sql = "update " + souTable + " set " + flagName + " = " +
markcolumnValue + " where" + pkName;
}
} else if (operation.equals("DELETE")) {
/*Sql = "delete from " + souTable + " where " + souTable + "." +
pkName;*/
Sql = "delete from " + souTable + " where " + pkName;
} else if (operation.equals("INSERT")) {
/* Sql = "insert into " + tarTable + " select * from " + souTable +
" where " + souTable + "." + pkName;*/
Sql = "insert into " + tarTable + " select * from " + souTable +
" where " + pkName;
} else if (operation.equals("SELECT")) {
Sql = "select * from " + souTable;
}
} catch (final Exception e) {
mLogger.log(Level.SEVERE,mMessages.getString("Derby_Create_Query"),e);
throw new Exception(OracleDataAccess.mMessages.getString("Derby_Create_Query"), e);
}
return Sql;
}
//@Override
public String generateSelectQuery(final String selectSql, final String TableName)
throws Exception {
String Sql = null;
Sql = "select * from " + TableName;
return Sql;
}
}
//public class OracleDataAccess implements DatabaseModel{
// private String mtabName = null;
// private String mtrigName = null;
// private TableColumn[] mcolumns = null;
// private String mSchemaName = null;
// private String mMarkColumnName = null;
// private String mstageFlag = null;
// private static final Messages mMessages = Messages.getMessages(OracleDataAccess.class);
// private static Logger mLogger = Messages.getLogger(OracleDataAccess.class);
/**
* @param souTable
* @param schemaName
* @param flagName
*/
// public void init(Table souTable,String schemaName,String flagName,String stageFlag){
// mMarkColumnName = flagName;
// mstageFlag = stageFlag;
// setTableName(souTable.getName());
// setTriggerName(souTable.getName());
// mcolumns = souTable.getColumns();
// this.mSchemaName = schemaName;
// }
/**
* @throws Exception
*/
// public String createTableQuery() throws Exception {
// StringBuffer sb = new StringBuffer();
// sb.append("create table ");
// sb.append(" ");
// sb.append(getTableName());
// sb.append(" ");
// sb.append("(");
// for (int i = 0; i < this.mcolumns.length; i++) {
// sb.append("\"");
// sb.append(this.mcolumns[i].getName());
// sb.append("\"");
// sb.append(" ");
// sb.append(this.mcolumns[i].getSqlType());
// if ((this.mcolumns[i].getNumericPrecision() != 0)
// && ((this.mcolumns[i].getSqlType())
// .equalsIgnoreCase("VARCHAR"))) {
// sb.append("(");
// sb.append(this.mcolumns[i].getNumericPrecision());
// sb.append(")");
// }
// sb.append(" ");
// if (this.mcolumns[i].getIsPrimaryKey()) {
// sb.append("primary key");
// }
// sb.append(" ");
// if (this.mcolumns[i].getIsNullable()) {
// sb.append("not null");
// }
// if ((i == (this.mcolumns.length - 1)))
// sb.append(")");
// else
// sb.append(",");
// }
// mLogger.log(Level.INFO, mMessages.getString("ORCL_Create_SQL") + sb.toString());
// return sb.toString();
// }
/**
* @param source
*/
// public String createTriggerQuery(String source) throws Exception{
// StringBuffer sb = new StringBuffer();
// sb.append("CREATE TRIGGER ");
// sb.append(" ");
// sb.append(getTriggerName());
// sb.append(" ");
// sb.append("AFTER INSERT ON");
// sb.append(" ");
// sb.append(source);
// sb.append(" ");
// sb.append("REFERENCING NEW AS UPDATEDROW FOR EACH ROW BEGIN");
// sb.append(" ");
// sb.append("INSERT INTO");
// sb.append(" ");
// sb.append(getTableName());
// sb.append(" ");
// sb.append("VALUES");
// sb.append(" ");
// sb.append("(");
// for (int i = 0; i < this.mcolumns.length; i++) {
// sb.append(":UPDATEDROW.");
// sb.append("\"");
// sb.append(this.mcolumns[i].getName());
// sb.append("\"");
// if((i == (this.mcolumns.length-1))){
// sb.append(")");
// sb.append(";");
// }
// else
// sb.append(",");
// }
// sb.append("END;");
// mLogger.log(Level.INFO, mMessages.getString("ORCL_Create_SQL") + sb.toString());
// return sb.toString();
// }
//
// public String getTableName(){
// return (getSchemaName()+"."+this.mtabName);
// }
//
// public String getTriggerName(){
// return (getSchemaName()+"."+this.mtrigName);
// }
//
//
// public void setTableName(String tabSource){
// if(mMarkColumnName != null && mMarkColumnName != "" && mstageFlag.equalsIgnoreCase("Yes"))
// this.mtabName = "\""+tabSource+"_StagTab"+"\"";
// else
// this.mtabName = "\""+tabSource+"\"";
// }
//
// public void setTriggerName(String trigName){
// if(mMarkColumnName != null && mMarkColumnName != "" && mstageFlag.equalsIgnoreCase("Yes"))
// this.mtrigName = "\""+trigName+"_Trig"+"\"";
// else
// this.mtabName = "\""+trigName+"\"";
// }
//
// public String getSchemaName(){
// return "\""+this.mSchemaName+"\"";
// }
// /**
// * @param souTable
// * @param flagName
// * @param pkName
// * @param operation
// */
// public String createQualifiedQuery(String souTable, String flagName,
// String pkName, String operation) throws Exception {
// String Sql = null;
//
// try {
// if (operation.equals("UPDATE")) {
// Sql = "update " + souTable + " set " + flagName + " = 0 where"
// + "\"" + this.mtabName + "\"" + "." + pkName;
// } else if (operation.equals("DELETE")) {
// Sql = "delete from " + souTable + " where " + "\""
// + this.mtabName + "\"" + "." + pkName;
// } else if (operation.equals("INSERT")) {
// Sql = "insert into " + "\"" + souTable + "\"" + "." + "\""
// + flagName + "_StagTab" + "\"" + " select * from "
// + pkName;
// }
// } catch (Exception e) {
// throw new Exception(mMessages.getString("ORCL_Create_Query"), e);
// }
// return Sql;
// }
//}

View File

@ -1,258 +0,0 @@
/*
* 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]
*/
/*
* @(#)SqlServerDataAccess.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc.model.runtime;
import com.sun.jbi.internationalization.Messages;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* @author Venkat P
*
*/
public class SqlServerDataAccess implements DatabaseModel {
private static final Messages mMessages = Messages.getMessages(SqlServerDataAccess.class);
private static final Logger mLogger = Messages.getLogger(SqlServerDataAccess.class);
private SqlServerDataAccess(){
}
private static final SqlServerDataAccess instance = new SqlServerDataAccess();
public static final SqlServerDataAccess getInstance(){
return instance;
}
//@Override
public String createQualifiedQuery(final String souTable, final String tarTable,
final String flagName, final String markcolumnValue, final String pkName, final String operation,
final String FlagColumnType)
throws Exception {
String Sql = null;
try {
if (operation.equals("UPDATE")) {
if(FlagColumnType.equalsIgnoreCase("LONGVARCHAR") || FlagColumnType.equalsIgnoreCase("CHAR")
|| FlagColumnType.equalsIgnoreCase("VARCHAR")){
Sql = "update " + souTable + " set " + flagName + " = " +
"'"+markcolumnValue+"'"+ " where" + souTable + "." + pkName;
}else{
Sql = "update " + souTable + " set " + flagName + " = " +
markcolumnValue + " where" + souTable + "." + pkName;
}
} else if (operation.equals("DELETE")) {
Sql = "delete from " + souTable + " where " + souTable + "." +
pkName;
} else if (operation.equals("INSERT")) {
Sql = "insert into " + tarTable + " select * from " + souTable +
" where " + souTable + "." + pkName;
} else if (operation.equals("SELECT")) {
Sql = "select * from " + "\"" + souTable + "\"";
}
} catch (final Exception e) {
mLogger.log(Level.SEVERE,mMessages.getString("Derby_Create_Query"),e);
throw new Exception(SqlServerDataAccess.mMessages.getString("Derby_Create_Query"), e);
}
return Sql;
}
//@Override
public String generateSelectQuery(final String selectSql, final String TableName)
throws Exception {
String Sql = null;
Sql = "select * from " + TableName;
return Sql;
}
}
//public class SqlServerDataAccess implements DatabaseModel{
// private String mtabName = null;
// private String mtrigName = null;
// private TableColumn[] mcolumns = null;
// private String mSchemaName = null;
// private String mMarkColumnName = null;
// private String mstageFlag = null;
// private static final Messages mMessages = Messages.getMessages(SqlServerDataAccess.class);
// private static Logger mLogger = Messages.getLogger(SqlServerDataAccess.class);
/**
* @param souTable
* @param schemaName
* @param flagName
*/
// public void init(Table souTable,String schemaName,String flagName,String stageFlag){
// mMarkColumnName = flagName;
// mstageFlag = stageFlag;
// setTableName(souTable.getName());
// setTriggerName(souTable.getName());
// mcolumns = souTable.getColumns();
// this.mSchemaName = schemaName;
// }
/**
* @throws Exception
*/
// public String createTableQuery() throws Exception {
// StringBuffer sb = new StringBuffer();
// sb.append("create table ");
// sb.append(" ");
// sb.append(getTableName());
// sb.append(" ");
// sb.append("(");
// for (int i = 0; i < this.mcolumns.length; i++) {
// sb.append("\"" + this.mcolumns[i].getName() + "\"");
// sb.append(" ");
// sb.append(this.mcolumns[i].getSqlType());
// if ((this.mcolumns[i].getNumericPrecision() != 0)
// && ((this.mcolumns[i].getSqlType())
// .equalsIgnoreCase("VARCHAR"))) {
// sb.append("(");
// sb.append(this.mcolumns[i].getNumericPrecision());
// sb.append(")");
// }
// sb.append(" ");
// if (this.mcolumns[i].getIsPrimaryKey()) {
// sb.append("primary key");
// }
// sb.append(" ");
// if (this.mcolumns[i].getIsNullable()) {
// sb.append("not null");
// }
// if ((i == (this.mcolumns.length - 1)))
// sb.append(")");
// else
// sb.append(",");
// }
// mLogger.log(Level.INFO, mMessages.getString("Derby_Create_SQL") + sb.toString());
// return sb.toString();
// }
/**
* @param source
* @throws Exception
*/
// public String createTriggerQuery(String source) throws Exception {
// StringBuffer sb = new StringBuffer();
// sb.append("CREATE TRIGGER ");
// sb.append(" ");
// sb.append(getTriggerName());
// sb.append(" ");
// sb.append("AFTER INSERT ON");
// sb.append(" ");
// sb.append(source);
// sb.append(" ");
// sb.append("REFERENCING NEW AS UPDATEDROW FOR EACH ROW MODE DB2SQL");
// sb.append(" ");
// sb.append("INSERT INTO");
// sb.append(" ");
// sb.append(getTableName());
// sb.append(" ");
// sb.append("VALUES");
// sb.append(" ");
// sb.append("(");
// for (int i = 0; i < this.mcolumns.length; i++) {
// sb.append("UPDATEDROW.");
// sb.append("\"");
// sb.append(this.mcolumns[i].getName());
// sb.append("\"");
// if ((i == (this.mcolumns.length - 1)))
// sb.append(")");
// else
// sb.append(",");
// }
// mLogger.log(Level.INFO, mMessages.getString("Derby_Create_SQL") + sb.toString());
// return sb.toString();
// }
//
// public String getTableName(){
// return (getSchemaName()+"."+this.mtabName);
// }
//
// public String getTriggerName(){
// return (getSchemaName()+"."+this.mtrigName);
// }
//
// public String getSchemaName(){
// return "\""+this.mSchemaName+"\"";
// }
//
// public void setTableName(String tabSource){
// mLogger.log(Level.INFO, "Flag Name" + mMarkColumnName);
// if(mMarkColumnName != null && mMarkColumnName != "" && mstageFlag.equalsIgnoreCase("Yes"))
// this.mtabName = "\""+tabSource+"_jdbc_StaggingTable"+"\"";
// else
// this.mtabName = "\""+tabSource+"\"";
// }
//
// public void setTriggerName(String trigName){
// if(mMarkColumnName != null && mMarkColumnName != "" && mstageFlag.equalsIgnoreCase("Yes"))
// this.mtrigName = "\""+trigName+"_jdbc_staggingTrigger"+"\"";
// else
// this.mtabName = "\""+trigName+"\"";
// }
/**
* @param souTable
* @param flagName
* @param pkName
* @param operation
* @throws Exception
*/
// public String createQualifiedQuery(String souTable, String flagName,
// String pkName, String operation) throws Exception {
// String Sql = null;
//
// try {
// if (operation.equals("UPDATE")) {
// Sql = "update " + souTable + " set " + flagName + " = 0 where"
// + souTable + "." + pkName;
// } else if (operation.equals("DELETE")) {
// Sql = "delete from " + souTable + " where " + souTable + "."
// + pkName ;
// } else if (operation.equals("INSERT")) {
// Sql = "insert into " + "\"" + souTable + "\"" + "." + "\""
// + flagName + "_jdbc_StaggingTable" + "\""
// + " select * from " + pkName;
// }
// } catch (Exception e) {
// throw new Exception( mMessages.getString("Derby_Create_Query"), e);
// }
// return Sql;
// }
//}

View File

@ -1,33 +0,0 @@
# ------------------------------
# ---- NO I18N ENTIRE FILE! ----
# ------------------------------
# message id scheme used:
#
# SQLSE -{contextcode:1 character}{domain-messageid:5 digits}
#
# e.g. SQLSE-C00100
#
# context codes:
# C = Configuration information
# R = Runtime information
# W = Warning cautions
# E = Errors
#
# domain-messageids:
# 100s for Life cycle and Bootstrapping
# 200s for Deployer
# 300s for Service Unit
# 600s for Request/Reply processing (InboundReceiver, OutBound, Inbound MessageProcessor)
# 700s for Message processing (Normalizer - DeNormalizer)
# 800s for Application Specific
# 1000-1100s for Authentication and proxies
# Package specific ResourceBundle properties file
################## resource bundles for DerbyDataAccess ###################
Derby_Create_SQL=SQL to create.
Derby_Create_Query=Exception in creating the qualified String.
################## resource bundles for OracleDataAccess ###################
ORCL_Create_SQL=SQL to create.
ORCL_Create_Query=Exception in creating the qualified String.

View File

@ -1,19 +0,0 @@
/*
* Base64.java
*
* Created on Oct 8, 2007, 4:40:01 PM
*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.sun.jbi.jdbcbc.security;
/**
*
* @author narayan
*/
public interface Base64 {
public String encode(String data);
public String decode(String data);
}

View File

@ -1,66 +0,0 @@
/*
* Base64Impl.java
*
* Created on Oct 8, 2007, 4:40:39 PM
*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.sun.jbi.jdbcbc.security;
/**
*
* @author narayan
*/
public class Base64Impl implements Base64{
private Base64Impl(){
}
private static Base64Impl instance = null;
public static final Base64Impl getInstance(){
if(instance==null)
instance = new Base64Impl();
return instance;
}
public String decode(String data) {
return getUTF8String(com.sun.org.apache.xerces.internal.impl.dv.util.Base64.decode(data));
}
public String encode(String data) {
String encoded = com.sun.org.apache.xerces.internal.impl.dv.util.Base64.encode(getUTF8Bytes(data));
//This encoder adds a new line character at the end of the base64 encoded data, so
//remove this character before returning.
if (encoded != null) {
//encoded = encoded.substring(0, encoded.length() - 1);
}
return encoded;
}
public static byte[] getUTF8Bytes(String data) {
if (data == null) {
return new byte[0];
}
try {
return data.getBytes("UTF-8");
} catch (java.io.UnsupportedEncodingException uee) {
// Default encoding if UTF-8 is not available.
return data.getBytes();
}
}
public static String getUTF8String(byte [] data) {
try {
return new String(data, "UTF-8");
} catch (java.io.UnsupportedEncodingException uee) {
// default encoding ...
return new String(data);
}
}
}

View File

@ -1,150 +0,0 @@
/*
* 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]
*/
/*
* @(#)GlobalId.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc.transaction;
/**
*
* @author Venkat P
*/
import java.io.IOException;
import javax.transaction.xa.Xid;
/**
* This object encapsulates the global transaction ID of a transaction.
* It is similar to an Xid, but holds only the GlobalId part.
* This implementation is immutable and always serializable at runtime.
*
* @see XidImpl
* @author <a href="mailto:Narayana.Rallabandi@Sun.Com">Narayana Rallabandi</a>
* @version
*/
public class GlobalId implements java.io.Externalizable{
static final long serialVersionUID = 234567891L;
private int formatId;
//Global Transaction Id
private byte[] globalId;
// hash code for the global id
private int hash;
public GlobalId(){
}
protected GlobalId(int formatId, byte[] globalId, int hash){
this.formatId = formatId;
this.globalId = globalId;
this.hash = hash;
}
protected GlobalId(int formatId, byte[] globalId){
this.formatId = formatId;
this.globalId = globalId;
hash = computeHash();
}
private GlobalId(Xid xid){
formatId = xid.getFormatId();
globalId = xid.getGlobalTransactionId();
if (xid instanceof XidImpl) {
hash = xid.hashCode();
}else{
hash = computeHash();
}
}
private GlobalId(int formatId, int bqual_length, byte[] tid){
this.formatId = formatId;
if (bqual_length == 0)
globalId = tid;
else {
int len = tid.length - bqual_length;
globalId = new byte[len];
System.arraycopy(tid, 0, globalId, 0, len);
}
hash = computeHash();
}
// @Override
public boolean equals(Object obj){
if (obj instanceof GlobalId) {
GlobalId other = (GlobalId)obj;
if (formatId != other.formatId)
return false;
if (globalId == other.globalId)
return true;
if (globalId.length != other.globalId.length)
return false;
int len = globalId.length;
for (int i = 0; i < len; ++i)
if (globalId[i] != other.globalId[i])
return false;
return true;
}
return false;
}
//@Override
public int hashCode(){
return hash;
}
//@Override
public String toString() {
return getClass().getName() + "[formatId=" + formatId
+ ", globalId=" + new String(globalId).trim()
+ ", hash=" + hash + "]";
}
//@Override
public void writeExternal(java.io.ObjectOutput out) throws IOException {
out.writeInt(formatId);
out.writeObject(globalId);
}
// @Override
public void readExternal(java.io.ObjectInput in) throws IOException, ClassNotFoundException{
formatId = in.readInt();
globalId = (byte[])in.readObject();
hash = computeHash();
}
private int computeHash(){
int len = globalId.length;
int hashval = 0;
// TODO: use a better hash function
for (int i = 0; i < len; ++i)
hashval = 3 * globalId[i] + hashval;
hashval += formatId;
return hashval;
}
}

View File

@ -1,116 +0,0 @@
/*
* 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]
*/
/*
* @(#)LocalId.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc.transaction;
/**
*
* @author Venkat P
*/
/**
* LocalId symbloizes the transaction id from the Application Server
* This class implements the Externizable interface for making the object
* serialiable during runtime.
*
* @author <a href="Narayana.Rallabandi@Sun.Com">Narayana Rallabandi</a>
* @version
*/
public class LocalId implements java.io.Externalizable{
static final long serialVersionUID = 123456789L;
private long localIdvalue; //
public LocalId(){
}
protected LocalId(long localIdvalue){
this.localIdvalue = localIdvalue;
}
protected LocalId(XidImpl xid){
this(xid.getLocalIdValue());
}
private long getValue(){
return localIdvalue;
}
//@Override
public boolean equals(Object obj){
return (obj instanceof LocalId) ?
(localIdvalue == ((LocalId)obj).localIdvalue): false;
}
//@Override
public int hashCode(){
return (int)localIdvalue;
}
//@Override
public void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException
{
out.writeLong(localIdvalue);
}
//@Override
public void readExternal(java.io.ObjectInput in)
throws java.io.IOException, ClassNotFoundException {
localIdvalue = in.readLong();
}
// this morphs the long under consideration
// which fecilitates to Obtain the global transaction identifier
// part of XID as an array of bytes
private static void toByteArray(long localId, byte[] destination, int dstBegin){
destination[dstBegin + 0] = (byte)(0xff & (localId >>> 56));
destination[dstBegin + 1] = (byte)(0xff & (localId >>> 48));
destination[dstBegin + 2] = (byte)(0xff & (localId >>> 40));
destination[dstBegin + 3] = (byte)(0xff & (localId >>> 32));
destination[dstBegin + 4] = (byte)(0xff & (localId >>> 24));
destination[dstBegin + 5] = (byte)(0xff & (localId >>> 16));
destination[dstBegin + 6] = (byte)(0xff & (localId >>> 8));
destination[dstBegin + 7] = (byte)(0xff & (localId >>> 0));
}
// this morphs the byrearray source under consideration
// which fecilitates to Obtain the global transaction identifier
// as long which is part of XID.
private static long fromByteArray(byte[] source, int srcBegin) {
return ((long)(source[srcBegin + 0] & 0xff) << 56)
| ((long)(source[srcBegin + 1] & 0xff) << 48)
| ((long)(source[srcBegin + 2] & 0xff) << 40)
| ((long)(source[srcBegin + 3] & 0xff) << 32)
| ((long)(source[srcBegin + 4] & 0xff) << 24)
| ((long)(source[srcBegin + 5] & 0xff) << 16)
| ((long)(source[srcBegin + 6] & 0xff) << 8)
| ((long)(source[srcBegin + 7] & 0xff));
}
}

View File

@ -1,696 +0,0 @@
/*
* 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]
*/
/*
* @(#)TransactionHelper.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc.transaction;
import com.sun.jbi.internationalization.Messages;
import javax.transaction.Status;
import javax.transaction.Synchronization;
import javax.transaction.SystemException;
import javax.transaction.xa.XAException;
import javax.transaction.xa.XAResource;
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
import javax.transaction.RollbackException;
import java.util.ArrayList;
import javax.jbi.component.ComponentContext;
import javax.jbi.messaging.MessageExchange;
import javax.jbi.messaging.ExchangeStatus;
import javax.jbi.messaging.InOnly;
import javax.sql.XAConnection;
import javax.sql.XADataSource;
import java.sql.SQLException;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.transaction.NotSupportedException;
import javax.transaction.HeuristicMixedException;
import javax.transaction.HeuristicRollbackException;
import javax.transaction.InvalidTransactionException;
import javax.transaction.xa.Xid;
/**
*
* @author Narayanaa
*/
public class TransactionHelper {
//private static final Messages mMessages = Messages.getMessages(TransactionHelper.class);
private static final Logger mLogger = Messages.getLogger(TransactionHelper.class);
/** Creates a new instance of TransactionHelper */
public TransactionHelper() {
xid = xidFactory.newXid();
gid = xid.getTrulyGlobalId();
status = Status.STATUS_ACTIVE;
start = System.currentTimeMillis();
}
public void setComponentContext(ComponentContext componentContext) throws Exception{
manager = (TransactionManager)componentContext.getTransactionManager();
transaction = manager.getTransaction();
if(transaction == null){
begin();
transaction = manager.getTransaction();
}
status = manager.getStatus();
xid = xidFactory.newXid();
}
public void setMessageExchange(MessageExchange messageExchange) throws Exception{
this.messageExchange = messageExchange;
}
public boolean isInOnly(MessageExchange me) {
return (me instanceof InOnly);
}
public boolean isTxEnabled(MessageExchange me) {
return ((tx_enable==null || tx_enable.equalsIgnoreCase("true"))
&& !isInOnly(me));
}
public void setXAResource(XAResource xar){
this.xar = xar;
start = System.currentTimeMillis();
try{
this.timeoutPeriod = xar.getTransactionTimeout();
}catch(XAException xae){
mLogger.log(Level.SEVERE,"Error While setting the XA Resource",xae);
}
}
public void setDataSource(XADataSource xads){
this.xads = xads;
try{
xac = xads.getXAConnection();
xar = xads.getXAConnection().getXAResource();
start = System.currentTimeMillis();
this.timeoutPeriod = xar.getTransactionTimeout();
}catch(SQLException se){
mLogger.log(Level.SEVERE,"Error While setting the Data Source",se);
//se.getStackTrace();
}catch(XAException xe){
mLogger.log(Level.SEVERE,"Error While getting the XA Connection",xe);
//xe.getStackTrace();
}
}
public void registerXAResouce() {
// componentContext = (com.sun.jbi.framework.ComponentContext)componentContext;
// componentContext.registerXAResource(xar);
}
public XAConnection getXAConnection(){
return this.xac;
}
public void handleInbound(MessageExchange me) throws Exception {
if(!isTxEnabled(me))
return;
suspendTx(me);
}
public void handleOutbound(MessageExchange me) throws Exception {
if(!isTxEnabled(me))
return;
resumeTx(me);
}
public TransactionManager getTransactionManager (){
return this.manager;
}
public void suspendTx(MessageExchange me) throws SystemException {
TransactionManager tm = getTransactionManager();
Transaction tx = tm.getTransaction();
if (tx != null) {
if(me.getStatus().equals(ExchangeStatus.ERROR))
tx.setRollbackOnly();
tx = tm.suspend();
me.setProperty(MessageExchange.JTA_TRANSACTION_PROPERTY_NAME, tx);
}
}
public void resumeTx(MessageExchange me) throws
SystemException,
InvalidTransactionException {
TransactionManager tm = getTransactionManager();
Transaction tx = (Transaction)me.getProperty(MessageExchange.JTA_TRANSACTION_PROPERTY_NAME);
if(tx != null) {
if(me.getStatus().equals(ExchangeStatus.ERROR))
tx.setRollbackOnly();
manager.resume(tx);
}
}
//@Override
public int hashCode() {
return xid.hashCode();
}
//@Override
public String toString() {
return "TransactionHelper:" + xidFactory.toString(xid);
}
//@Override
public boolean equals(Object obj) {
if (obj != null && obj instanceof TransactionHelper)
return getLocalIdValue() == (((TransactionHelper)obj).getLocalIdValue());
return false;
}
/**
* Returns the local id of this transaction. The local id is used as
* a transaction propagation context within the JBoss server, and
* in the TxManager for mapping local transaction ids to transactions.
*/
public long getLocalIdValue() {
return xid.getLocalIdValue();
}
/**
* Returns the local id of this transaction. The local id is used as
* a transaction propagation context within the JBoss server, and
* in the TxManager for mapping local transaction ids to transactions.
*/
public LocalId getLocalId() {
return xid.getLocalId();
}
/**
* Returns the global id of this transaction. Ths global id is used in
* the TxManager, which keeps a map from global ids to transactions.
*/
public GlobalId getGlobalId() {
return gid;
}
/**
* Returns the xid of this transaction.
*/
public XidImpl getXid() {
return xid;
}
private long lastBranchId = 0;
private Xid createXidBranch() {
long branchId = ++lastBranchId;
return xidFactory.newBranch(xid, branchId);
}
// commit the transaction underconsideration
//
public void commit()
throws RollbackException,
java.lang.SecurityException,
java.lang.IllegalStateException,
SystemException,
Exception{
status = transaction.getStatus();
if(lock.tryLock()){
try {
if (status == Status.STATUS_COMMITTED){
xar.commit(xid,true);
transaction.commit();
// checkHeuristics();
}else{
Throwable causedByThrowable = exceptionReason;
//rollbackResources();
//completeTransaction();
xar.rollback(xid);
transaction.rollback();
// throw jboss rollback exception with the saved off exceptionReason
mLogger.log(Level.SEVERE,"Error While Commiting the transaction",causedByThrowable);
throw new Exception("Unable to commit, tx=" +
toString() + " status=" + TransactionStateUtility.getStringStatus(status),
causedByThrowable);
}
} finally {
lock.unlock();
}
}
}
public void rollback()
throws java.lang.IllegalStateException,
java.lang.SecurityException,
SystemException {
status = transaction.getStatus();
if(lock.tryLock()){
try {
switch (status) {
case Status.STATUS_ACTIVE:
status = Status.STATUS_MARKED_ROLLBACK;
transaction.setRollbackOnly();
case Status.STATUS_MARKED_ROLLBACK:
//endResources();
xar.end(xid,XAResource.TMFAIL);
transaction.rollback();
case Status.STATUS_PREPARING:
status = Status.STATUS_MARKED_ROLLBACK;
transaction.setRollbackOnly();
return;
default:
mLogger.log(Level.SEVERE,"Error While Setting the Transaction Status");
throw new IllegalStateException("Cannot rollback(), " +
"tx=" + toString() +
" status=" +
TransactionStateUtility.getStringStatus(status));
}
} catch(XAException xe){
mLogger.log(Level.SEVERE,"Error While Setting the Transaction Status",xe);
//xe.getStackTrace();
}finally {
//Thread.interrupted();// clear timeout that did an interrupt
lock.unlock();
}
}
}
public boolean enlist() throws RollbackException,
java.lang.IllegalStateException,
SystemException {
if (xar == null)
throw new IllegalArgumentException("null xaRes tx=" + this);
//get status from the TM
if(transaction != null)
status = transaction.getStatus();
if(lock.tryLock()){
try {
switch (status) {
case Status.STATUS_ACTIVE:
case Status.STATUS_PREPARING:
break;
case Status.STATUS_PREPARED:
throw new IllegalStateException("Already prepared. " + this);
case Status.STATUS_COMMITTING:
throw new IllegalStateException("Already started committing. " + this);
case Status.STATUS_COMMITTED:
throw new IllegalStateException("Already committed. " + this);
case Status.STATUS_MARKED_ROLLBACK:
throw new RollbackException("Already marked for rollback " + this);
case Status.STATUS_ROLLING_BACK:
throw new RollbackException("Already started rolling back. " + this);
case Status.STATUS_ROLLEDBACK:
throw new RollbackException("Already rolled back. " + this);
case Status.STATUS_NO_TRANSACTION:
if(transaction == null)
break;
else
throw new IllegalStateException("No transaction. " + this);
case Status.STATUS_UNKNOWN:
throw new IllegalStateException("Unknown state " + this);
default:
throw new IllegalStateException("Illegal status: " + TransactionStateUtility.getStringStatus(status) + " tx=" + this);
}
isEnlisted = transaction.enlistResource(xar);
} finally {
lock.unlock();
}
}
return isEnlisted;
}
public void delist()throws java.lang.IllegalStateException,
SystemException,XAException {
if(lock.tryLock()){
try{
delist(transaction.getStatus());
}finally{
lock.unlock();
}
}
}
public void begin() throws NotSupportedException,SystemException{
if(lock.tryLock()){
try{
manager.begin();
}finally{
lock.unlock();
}
}
}
public void TMCommit() throws RollbackException,
HeuristicMixedException,
HeuristicRollbackException,
SystemException{
if(lock.tryLock()){
try{
manager.commit();
}catch(RollbackException re){
try{
manager.rollback();
}catch(SystemException se){
mLogger.log(Level.SEVERE,"Error While Commiting the Transaction",se);
}
}finally{
lock.unlock();
}
}
}
public void suspend() throws SystemException{
if(lock.tryLock()){
try{
manager.suspend();
}finally{
lock.unlock();
}
}
}
public void resume() throws SystemException,InvalidTransactionException{
if(lock.tryLock()){
try{
manager.resume(transaction);
}finally{
lock.unlock();
}
}
}
private int getStatus() throws SystemException {
if (done)
return Status.STATUS_NO_TRANSACTION;
return status;
}
public boolean isDone() {
return done;
}
public boolean isEnlisted() {
return this.isEnlisted;
}
public synchronized void instanceDone() {
status = Status.STATUS_NO_TRANSACTION;
notifyAll();
done = true;
}
// for registering synchronizations during transaction
public void registerSynchronization(Synchronization s)
throws RollbackException,
java.lang.IllegalStateException,
SystemException {
if (s == null)
throw new IllegalArgumentException("Null synchronization " + this);
//get status of the transaction
status = transaction.getStatus();
if(lock.tryLock()){
try {
switch (status) {
case Status.STATUS_ACTIVE:
case Status.STATUS_PREPARING:
break;
case Status.STATUS_PREPARED:
throw new IllegalStateException("Already prepared. " + this);
case Status.STATUS_COMMITTING:
throw new IllegalStateException("Already started committing. " + this);
case Status.STATUS_COMMITTED:
throw new IllegalStateException("Already committed. " + this);
case Status.STATUS_MARKED_ROLLBACK:
throw new RollbackException("Already marked for rollback " + this);
case Status.STATUS_ROLLING_BACK:
throw new RollbackException("Already started rolling back. " + this);
case Status.STATUS_ROLLEDBACK:
throw new RollbackException("Already rolled back. " + this);
case Status.STATUS_NO_TRANSACTION:
throw new IllegalStateException("No transaction. " + this);
case Status.STATUS_UNKNOWN:
throw new IllegalStateException("Unknown state " + this);
default:
throw new IllegalStateException("Illegal status: " + TransactionStateUtility.getStringStatus(status) + " tx=" + this);
}
if (syncCount == syncAllocSize) {
syncAllocSize = 2 * syncAllocSize;
Synchronization[] sy = new Synchronization[syncAllocSize];
System.arraycopy(sync, 0, sy, 0, syncCount);
sync = sy;
}
sync[syncCount++] = s;
} finally {
lock.unlock();
}
}
}
public boolean delist(int flag)
throws java.lang.IllegalStateException,
SystemException, XAException{
boolean isDelisted = false;
if (xar == null)
throw new IllegalArgumentException("null xaRes tx=" + this);
if (flag != XAResource.TMSUCCESS &&
flag != XAResource.TMSUSPEND &&
flag != XAResource.TMFAIL)
throw new IllegalArgumentException("Bad flag: " + flag + " tx=" + this);
if(lock.tryLock()){
try {
status = transaction.getStatus();
switch (status) {
case Status.STATUS_ACTIVE:
case Status.STATUS_MARKED_ROLLBACK:
break;
case Status.STATUS_PREPARING:
throw new IllegalStateException("Already started preparing. " + this);
case Status.STATUS_ROLLING_BACK:
throw new IllegalStateException("Already started rolling back. " + this);
case Status.STATUS_PREPARED:
throw new IllegalStateException("Already prepared. " + this);
case Status.STATUS_COMMITTING:
throw new IllegalStateException("Already started committing. " + this);
case Status.STATUS_COMMITTED:
throw new IllegalStateException("Already committed. " + this);
case Status.STATUS_ROLLEDBACK:
throw new IllegalStateException("Already rolled back. " + this);
case Status.STATUS_NO_TRANSACTION:
throw new IllegalStateException("No transaction. " + this);
case Status.STATUS_UNKNOWN:
throw new IllegalStateException("Unknown state " + this);
default:
throw new IllegalStateException("Illegal status: " + TransactionStateUtility.getStringStatus(status) + " tx=" + this);
}
try{
xar.end(xid,XAResource.TMSUCCESS);
isDelisted= transaction.delistResource(xar,flag);
}catch(XAException xae){
xar.end(xid,XAResource.TMFAIL);
transaction.setRollbackOnly();
transaction.delistResource(xar,XAResource.TMFAIL);
}
} finally {
lock.unlock();
}
}
return isDelisted;
}
public void setRollbackOnly()
throws java.lang.IllegalStateException,
SystemException,
XAException{
status = transaction.getStatus();
if(lock.tryLock()){
try {
switch (status) {
case Status.STATUS_ACTIVE:
case Status.STATUS_PREPARING:
case Status.STATUS_PREPARED:
status = Status.STATUS_MARKED_ROLLBACK;
xar.rollback(xid);
transaction.setRollbackOnly();
case Status.STATUS_MARKED_ROLLBACK:
case Status.STATUS_ROLLING_BACK:
xar.rollback(xid);
transaction.setRollbackOnly();
return;
case Status.STATUS_COMMITTING:
throw new IllegalStateException("Already started committing. " + this);
case Status.STATUS_COMMITTED:
throw new IllegalStateException("Already committed. " + this);
case Status.STATUS_ROLLEDBACK:
throw new IllegalStateException("Already rolled back. " + this);
case Status.STATUS_NO_TRANSACTION:
throw new IllegalStateException("No transaction. " + this);
case Status.STATUS_UNKNOWN:
throw new IllegalStateException("Unknown state " + this);
default:
throw new IllegalStateException("Illegal status: " + TransactionStateUtility.getStringStatus(status) + " tx=" + this);
}
} finally {
lock.unlock();
}
}
}
// this needs to be brought into the code for
public void timedOut() throws SystemException{
status = transaction.getStatus();
if(lock.tryLock()){
try {
switch (status) {
case Status.STATUS_ROLLEDBACK:
case Status.STATUS_COMMITTED:
case Status.STATUS_NO_TRANSACTION:
return;
case Status.STATUS_ROLLING_BACK:
return;
case Status.STATUS_COMMITTING:
gotHeuristic(null, XAException.XA_HEURMIX);
status = Status.STATUS_MARKED_ROLLBACK;
return; // commit will fail
case Status.STATUS_PREPARED:
case Status.STATUS_ACTIVE:
status = Status.STATUS_MARKED_ROLLBACK;
case Status.STATUS_MARKED_ROLLBACK:
return;
case Status.STATUS_PREPARING:
status = Status.STATUS_MARKED_ROLLBACK;
return; // commit will fail
default:
return;
}
} catch(XAException xe){
mLogger.log(Level.SEVERE,"Error While Setting the Transaction Status",xe);
//xe.printStackTrace();
}finally {
lock.unlock();
}
}
}
// need to do
public void gotHeuristic(XAResource resource, int code) throws XAException{
switch (code) {
case XAException.XA_HEURMIX:
heuristicCode = XAException.XA_HEURMIX;
break;
case XAException.XA_HEURRB:
if (heuristicCode == HEUR_NONE)
heuristicCode = XAException.XA_HEURRB;
else if (heuristicCode == XAException.XA_HEURCOM ||
heuristicCode == XAException.XA_HEURHAZ)
heuristicCode = XAException.XA_HEURMIX;
break;
case XAException.XA_HEURCOM:
if (heuristicCode == HEUR_NONE)
heuristicCode = XAException.XA_HEURCOM;
else if (heuristicCode == XAException.XA_HEURRB ||
heuristicCode == XAException.XA_HEURHAZ)
heuristicCode = XAException.XA_HEURMIX;
break;
case XAException.XA_HEURHAZ:
if (heuristicCode == HEUR_NONE)
heuristicCode = XAException.XA_HEURHAZ;
else if (heuristicCode == XAException.XA_HEURCOM ||
heuristicCode == XAException.XA_HEURRB)
heuristicCode = XAException.XA_HEURMIX;
break;
default:
throw new IllegalArgumentException();
}
if (resource != null)
resource.forget(xid);
}
public void checkHeuristics()
throws HeuristicMixedException, HeuristicRollbackException {
switch (heuristicCode) {
case XAException.XA_HEURHAZ:
case XAException.XA_HEURMIX:
heuristicCode = HEUR_NONE;
throw new HeuristicMixedException();
case XAException.XA_HEURRB:
heuristicCode = HEUR_NONE;
throw new HeuristicRollbackException();
case XAException.XA_HEURCOM:
heuristicCode = HEUR_NONE;
return;
}
}
private static final int HEUR_NONE = XAException.XA_RETRY;
private XidImpl xid;
private GlobalId gid;
//callback synchronizations
private Synchronization[] sync = new Synchronization[3];
private int syncAllocSize = 3;
private int syncCount = 0;
private ArrayList resources = new ArrayList(3);
private int heuristicCode = HEUR_NONE;
private int status;
private long start;
private long timeoutPeriod;
private boolean done = false;
private Throwable exceptionReason;
public static XidFactory xidFactory = new XidFactory();//XidFactory.getXidFactoryInstance();
private final Lock lock = new ReentrantLock(true);
private String tx_enable = System.getProperty("com.sun.enterprise.jbi.tx.enable");
TransactionManager manager = null;
Transaction transaction = null;
XADataSource xads = null;
XAResource xar = null;
XAConnection xac = null;
boolean isEnlisted = false;
ComponentContext componentContext = null;
MessageExchange messageExchange = null;
}

View File

@ -1,309 +0,0 @@
/*
* 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]
*/
/*
* @(#)TransactionStateUtility.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc.transaction;
import com.sun.jbi.internationalization.Messages;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.transaction.Status;
import javax.transaction.SystemException;
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
import javax.transaction.UserTransaction;
import javax.transaction.xa.XAException;
import javax.transaction.xa.XAResource;
/**
*
* @author Venkat P
*/
public class TransactionStateUtility {
private static final Messages mMessages = Messages.getMessages(TransactionStateUtility.class);
private static final Logger mLogger = Messages.getLogger(TransactionStateUtility.class);
/** Creates a new instance of TransactionStateUtility */
private TransactionStateUtility() {
}
/** Transaction Status Strings */
private static final String[] TxStatusStrings =
{
"STATUS_ACTIVE",
"STATUS_MARKED_ROLLBACK",
"STATUS_PREPARED",
"STATUS_COMMITTED",
"STATUS_ROLLEDBACK",
"STATUS_UNKNOWN",
"STATUS_NO_TRANSACTION",
"STATUS_PREPARING",
"STATUS_COMMITTING",
"STATUS_ROLLING_BACK"
};
private static boolean isActive(Transaction tx) throws Exception{
try {
return tx != null && (tx.getStatus() == Status.STATUS_ACTIVE);
} catch (SystemException error) {
mLogger.log(Level.SEVERE,"Error While Setting the Transaction Status");
throw new Exception(error);
}
}
private static boolean isActive(TransactionManager tm) throws Exception{
try {
return isActive(tm.getTransaction());
} catch (SystemException error) {
mLogger.log(Level.SEVERE,"Error While Setting the Transaction Status");
throw new Exception(error);
}
}
private static boolean isActive(UserTransaction ut) throws Exception{
try {
return ut.getStatus() == Status.STATUS_ACTIVE;
} catch (SystemException error) {
mLogger.log(Level.SEVERE,"Error While Setting the Transaction Status");
throw new Exception(error);
}
}
private static boolean isUncommitted(Transaction tx) throws Exception{
try {
if (tx == null)
return false;
int status = tx.getStatus();
return status == Status.STATUS_ACTIVE || status == Status.STATUS_MARKED_ROLLBACK;
} catch (SystemException error) {
mLogger.log(Level.SEVERE,"Error While Setting the Transaction Status");
throw new Exception(error);
}
}
private static boolean isUncommitted(TransactionManager tm)throws Exception {
try {
return isUncommitted(tm.getTransaction());
} catch (SystemException error) {
mLogger.log(Level.SEVERE,"Error While Setting the Transaction Status");
throw new Exception(error);
}
}
private static boolean isUncommitted(UserTransaction ut) throws Exception {
try {
int status = ut.getStatus();
return status == Status.STATUS_ACTIVE || status == Status.STATUS_MARKED_ROLLBACK;
} catch (SystemException error) {
throw new Exception(error);
}
}
private static boolean isCompleted(Transaction tx) throws Exception{
try {
if (tx == null)
return true;
int status = tx.getStatus();
return status == Status.STATUS_COMMITTED
|| status == Status.STATUS_ROLLEDBACK
|| status == Status.STATUS_NO_TRANSACTION;
} catch (SystemException error) {
mLogger.log(Level.SEVERE,"Error While Setting the Transaction Status");
throw new Exception(error);
}
}
private static boolean isCompleted(TransactionManager tm) throws Exception{
try {
return isCompleted(tm.getTransaction());
} catch (SystemException error) {
mLogger.log(Level.SEVERE,"Error While Setting the Transaction Status");
throw new Exception(error);
}
}
private static boolean isCompleted(UserTransaction ut) throws Exception{
try {
int status = ut.getStatus();
return status == Status.STATUS_COMMITTED
|| status == Status.STATUS_ROLLEDBACK
|| status == Status.STATUS_NO_TRANSACTION;
} catch (SystemException error) {
mLogger.log(Level.SEVERE,"Error While Setting the Transaction Status");
throw new Exception(error);
}
}
/**
* Converts a tx Status index to a String
*
* @see javax.transaction.Status
*
* @param status the Status index
* @return status as String or "STATUS_INVALID"
*/
private static String getStatusAsString(int status) {
if (status >= Status.STATUS_ACTIVE && status <= Status.STATUS_ROLLING_BACK) {
return TxStatusStrings[status];
} else {
return "STATUS_INVALID";
}
}
/**
* Converts a XAResource flag to a String
*
* @see javax.transaction.xa.XAResource
*
* @param flags the flags passed in to start(), end(), recover()
* @return the flags in String form
*/
private static String getXAResourceFlagsAsString(int flags) {
if (flags == XAResource.TMNOFLAGS) {
return "|TMNOFLAGS";
} else {
StringBuffer sbuf = new StringBuffer(64);
if ((flags & XAResource.TMONEPHASE) != 0) {
sbuf.append("|TMONEPHASE");
}
if ((flags & XAResource.TMJOIN) != 0) {
sbuf.append("|TMJOIN");
}
if ((flags & XAResource.TMRESUME) != 0) {
sbuf.append("|TMRESUME");
}
if ((flags & XAResource.TMSUCCESS) != 0) {
sbuf.append("|TMSUCCESS");
}
if ((flags & XAResource.TMFAIL) != 0) {
sbuf.append("|TMFAIL");
}
if ((flags & XAResource.TMSUSPEND) != 0) {
sbuf.append("|TMSUSPEND");
}
if ((flags & XAResource.TMSTARTRSCAN) != 0) {
sbuf.append("|TMSTARTRSCAN");
}
if ((flags & XAResource.TMENDRSCAN) != 0) {
sbuf.append("|TMENDRSCAN");
}
return sbuf.toString();
}
}
/**
* Return a string representation of the given status code.
*/
static String getStringStatus(int status) {
switch (status) {
case Status.STATUS_PREPARING:
return "STATUS_PREPARING";
case Status.STATUS_PREPARED:
return "STATUS_PREPARED";
case Status.STATUS_ROLLING_BACK:
return "STATUS_ROLLING_BACK";
case Status.STATUS_ROLLEDBACK:
return "STATUS_ROLLEDBACK";
case Status.STATUS_COMMITTING:
return "STATUS_COMMITING";
case Status.STATUS_COMMITTED:
return "STATUS_COMMITED";
case Status.STATUS_NO_TRANSACTION:
return "STATUS_NO_TRANSACTION";
case Status.STATUS_UNKNOWN:
return "STATUS_UNKNOWN";
case Status.STATUS_MARKED_ROLLBACK:
return "STATUS_MARKED_ROLLBACK";
case Status.STATUS_ACTIVE:
return "STATUS_ACTIVE";
default:
return "STATUS_UNKNOWN(" + status + ")";
}
}
/**
* Return a string representation of the given XA error code.
*/
private static String getStringXAErrorCode(int errorCode) {
switch (errorCode) {
case XAException.XA_HEURCOM:
return "XA_HEURCOM";
case XAException.XA_HEURHAZ:
return "XA_HEURHAZ";
case XAException.XA_HEURMIX:
return "XA_HEURMIX";
case XAException.XA_HEURRB:
return "XA_HEURRB";
case XAException.XA_NOMIGRATE:
return "XA_NOMIGRATE";
case XAException.XA_RBCOMMFAIL:
return "XA_RBCOMMFAIL";
case XAException.XA_RBDEADLOCK:
return "XA_RBDEADLOCK";
case XAException.XA_RBINTEGRITY:
return "XA_RBINTEGRITY";
case XAException.XA_RBOTHER:
return "XA_RBOTHER";
case XAException.XA_RBPROTO:
return "XA_RBPROTO";
case XAException.XA_RBROLLBACK:
return "XA_RBROLLBACK";
case XAException.XA_RBTIMEOUT:
return "XA_RBTIMEOUT";
case XAException.XA_RBTRANSIENT:
return "XA_RBTRANSIENT";
case XAException.XA_RDONLY:
return "XA_RDONLY";
case XAException.XA_RETRY:
return "XA_RETRY";
case XAException.XAER_ASYNC:
return "XAER_ASYNC";
case XAException.XAER_DUPID:
return "XAER_DUPID";
case XAException.XAER_INVAL:
return "XAER_INVAL";
case XAException.XAER_NOTA:
return "XAER_NOTA";
case XAException.XAER_OUTSIDE:
return "XAER_OUTSIDE";
case XAException.XAER_PROTO:
return "XAER_PROTO";
case XAException.XAER_RMERR:
return "XAER_RMERR";
case XAException.XAER_RMFAIL:
return "XAER_RMFAIL";
default:
return "XA_UNKNOWN(" + errorCode + ")";
}
}
}

View File

@ -1,171 +0,0 @@
/*
* 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]
*/
/*
* @(#)XAResourceImpl.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc.transaction;
import java.sql.SQLException;
import javax.sql.XAConnection;
import javax.transaction.xa.XAException;
import javax.transaction.xa.XAResource;
import javax.transaction.xa.Xid;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.sql.XADataSource;
/**
*
* @author Venkat P
*/
public class XAResourceImpl implements XAResource{
protected final Object stateLock = new Object();
protected AtomicBoolean inLocalTransaction = new AtomicBoolean(false);
protected boolean jdbcAutoCommit = true;
protected boolean underlyingAutoCommit = true;
protected boolean jdbcReadOnly;
protected boolean underlyingReadOnly;
protected int jdbcTransactionIsolation;
protected boolean destroyed = false;
protected final XAConnection xaConnection;
protected final XAResource xaResource;
protected Xid currentXid;
/** Creates a new instance of XAResourceImpl */
public XAResourceImpl(){
xaConnection = null;
xaResource = null;
}
private XAResourceImpl(XADataSource xad) throws SQLException{
xaConnection = xad.getXAConnection();
xaResource = xaConnection.getXAResource();
}
private XAResourceImpl(XAConnection xaConnection) throws SQLException{
this.xaConnection = xaConnection;
xaConnection.addConnectionEventListener(new javax.sql.ConnectionEventListener(){
//@Override
public void connectionClosed(javax.sql.ConnectionEvent ce){
//only we can do this, ignore
}
//@Override
public void connectionErrorOccurred(javax.sql.ConnectionEvent ce){
}
});
this.xaResource = xaConnection.getXAResource();
}
protected XAResource getXAResource() throws Exception{
return this;
}
protected void destroy() throws Exception{
try{
//xaResource.end();
}
finally{
try{
xaConnection.close();
}catch (SQLException e){
throw e;
}
}
}
//@Override
public void start(Xid xid, int flags) throws XAException{
xaResource.start(xid, flags);
synchronized (stateLock){
currentXid = xid;
}
}
//@Override
public void end(Xid xid, int flags) throws XAException{
xaResource.end(xid, flags);
//we want to allow ending transactions that are not the current
//one. When one does this, inManagedTransaction is still true.
synchronized (stateLock){
if (currentXid != null && currentXid.equals(xid)){
currentXid = null;
}
}
}
//@Override
public int prepare(Xid xid) throws XAException
{
return xaResource.prepare(xid);
}
//@Override
public void commit(Xid xid, boolean onePhase) throws XAException{
xaResource.commit(xid, onePhase);
}
//@Override
public void rollback(Xid xid) throws XAException{
xaResource.rollback(xid);
}
//@Override
public void forget(Xid xid) throws XAException{
xaResource.forget(xid);
}
//@Override
public Xid[] recover(int flag) throws XAException{
return xaResource.recover(flag);
}
//@Override
public boolean isSameRM(XAResource other) throws XAException{
return true;
}
//@Override
public int getTransactionTimeout() throws XAException{
return xaResource.getTransactionTimeout();
}
//@Override
public boolean setTransactionTimeout(int seconds) throws XAException{
return xaResource.setTransactionTimeout(seconds);
}
protected void checkState() throws SQLException{
synchronized (stateLock){
// Check readonly
if (jdbcReadOnly != underlyingReadOnly){
//xaConnection.setReadOnly(jdbcReadOnly);
underlyingReadOnly = jdbcReadOnly;
}
}
}
}

View File

@ -1,141 +0,0 @@
/*
* 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]
*/
/*
* @(#)XidFactory.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc.transaction;
import java.net.InetAddress;
import javax.transaction.xa.Xid;
import java.net.UnknownHostException;
/**
* Factory class for generation of Xids
* @author Venkat P
*/
public class XidFactory {
private String globalId;
private long globalIdAsNumber = 0;
private boolean isPadApplied = false;
private byte[] branchId = new byte[1];
private byte[] globalIdToBytes;
private static XidFactory instance = null;
public static XidFactory getXidFactoryInstance(){
if (instance == null) {
instance = new XidFactory();
}
return instance;
}
public XidFactory() {
try {
globalId = InetAddress.getLocalHost().getHostName();
if (globalId.length() > Xid.MAXGTRIDSIZE - 15)
globalId = globalId.substring(0, Xid.MAXGTRIDSIZE - 15);
globalId = globalId + "/";
} catch (UnknownHostException e) {
globalId = "localhost/";
}
globalIdToBytes = globalId.getBytes();
}
public String getBaseGlobalId() {
return globalId;
}
public void setBaseGlobalId(final String baseGlobalId) {
this.globalId = baseGlobalId;
globalIdToBytes = baseGlobalId.getBytes();
}
public synchronized long getGlobalIdNumber() {
return globalIdAsNumber;
}
public synchronized void setGlobalIdNumber(final long globalIdNumber) {
this.globalIdAsNumber = globalIdNumber;
}
public boolean isPadApplied() {
return isPadApplied;
}
public void setPadApplied(boolean pad) {
this.isPadApplied = pad;
if (pad)
branchId = new byte[Xid.MAXBQUALSIZE];
else
branchId = new byte[1];
}
public XidImpl newXid() {
long localId = getNextId();
String id = Long.toString(localId);
int len = isPadApplied?Xid.MAXGTRIDSIZE:id.length()+globalIdToBytes.length;
byte[] globalId = new byte[len];
System.arraycopy(globalIdToBytes, 0, globalId, 0, globalIdToBytes.length);
id.getBytes(0, id.length(), globalId, globalIdToBytes.length);
return new XidImpl(globalId, branchId, (int)localId, localId);
}
public XidImpl newBranch(XidImpl xid, long branchIdNum) {
String id = Long.toString(branchIdNum);
int len = isPadApplied?Xid.MAXBQUALSIZE:id.length();
byte[] branchId = new byte[len];
id.getBytes(0, id.length(), branchId, 0);
return new XidImpl(xid, branchId);
}
public long extractLocalIdFrom(byte[] globalId) {
int i, start;
int len = globalId.length;
for (i = 0; globalId[i++] != (byte)'/'; )
;
start = i;
while (i < len && globalId[i] != 0)
i++;
String globalIdNumber = new String(globalId, 0, start, i - start);
return Long.parseLong(globalIdNumber);
}
public String toString(Xid xid) {
if (xid instanceof XidImpl)
return XidImpl.toString(xid);
else
return xid.toString();
}
public synchronized long getNextId() {
return ++globalIdAsNumber;
}
}

View File

@ -1,216 +0,0 @@
/*
* 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]
*/
/*
* @(#)XidImpl.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc.transaction;
/**
*
* @author Venkat P
*/
import javax.transaction.xa.Xid;
/**
* This object encapsulates the ID of a transaction.
* This implementation is immutable and always serializable at runtime.
*
* @author <a href="Narayana.Rallabandi@Sun.Com">Narayana Rallabandi</a>
* @version
*/
public class XidImpl implements Xid, java.io.Serializable {
static final long serialVersionUID = -123456789L;
public static final int FORMAT_ID = 0x0101;
private static boolean trulyGlobalIdsEnabled = false;
// represents the format id for this xid
private final int formatId;
// global id immutable once set
private final byte[] globalId;
// branch qualifier
private final byte[] branchId;
// hash for the xid
private final int hash;
// local id for this xid
private final long localId;
//global id
private final GlobalId trulyGlobalId;
public static void setTrulyGlobalIdsEnabled(boolean newValue) {
trulyGlobalIdsEnabled = newValue;
}
public static boolean getTrulyGlobalIdsEnabled() {
return trulyGlobalIdsEnabled;
}
public static String toString(Xid id){
if (id == null)
return "[NULL Xid]";
String s = id.getClass().getName();
s = s.substring(s.lastIndexOf('.') + 1);
s = s + "[FormatId=" + id.getFormatId()
+ ", GlobalId=" + new String(id.getGlobalTransactionId()).trim()
+ ", BranchQual=" + new String(id.getBranchQualifier()).trim()
+ ((id instanceof XidImpl) ? ", localId=" + ((XidImpl)id).localId
: "")
+ "]";
return s;
}
public XidImpl(int formatId,
byte[] globalId, byte[] branchId, int hash, long localId){
this.formatId = formatId;
this.globalId = globalId;
this.branchId = branchId;
this.hash = hash;
this.localId = localId;
this.trulyGlobalId = (trulyGlobalIdsEnabled)
? new GlobalId(formatId, globalId)
: null;
}
/**
* Create a new instance with JBOSS_FORMAT_ID.
*/
public XidImpl(byte[] globalId, byte[] branchId, int hash, long localId){
this.formatId = FORMAT_ID;
this.globalId = globalId;
this.branchId = branchId;
this.hash = hash;
this.localId = localId;
this.trulyGlobalId = (trulyGlobalIdsEnabled)
? new GlobalId(FORMAT_ID, globalId, hash)
: null;
}
public XidImpl(final XidImpl xidImpl, final byte[] branchId){
this.formatId = xidImpl.formatId;
this.globalId = xidImpl.globalId;
this.branchId = branchId;
this.hash = xidImpl.hash;
this.localId = xidImpl.localId;
this.trulyGlobalId = (trulyGlobalIdsEnabled)
? xidImpl.trulyGlobalId
: null;
}
// retrun the Global TxId
//@Override
public byte[] getGlobalTransactionId(){
return (byte[])globalId.clone();
}
// return branch qualifier
//@Override
public byte[] getBranchQualifier(){
if (branchId.length == 0)
return branchId;
else
return (byte[])branchId.clone();
}
//@Override
public int getFormatId() {
return formatId;
}
/**
* checks for same format id, the same global transaction id
* and the same transaction branch qualifier.
*/
//@Override
public boolean equals(Object obj)
{
if(obj==this)
return true;
if (obj instanceof XidImpl) {
XidImpl other = (XidImpl)obj;
if (formatId != other.formatId ||
globalId.length != other.globalId.length ||
branchId.length != other.branchId.length)
return false;
for (int i = 0; i < globalId.length; ++i)
if (globalId[i] != other.globalId[i])
return false;
for (int i = 0; i < branchId.length; ++i)
if (branchId[i] != other.branchId[i])
return false;
return true;
}
return false;
}
@Override
public int hashCode(){
return hash;
}
@Override
public String toString(){
return toString(this);
}
public long getLocalIdValue() {
return localId;
}
public LocalId getLocalId() {
return new LocalId(localId);
}
public GlobalId getTrulyGlobalId() {
return trulyGlobalId;
}
public boolean sameTransaction(XidImpl other){
if(other == this)
return true;
if (formatId != other.formatId ||
globalId.length != other.globalId.length)
return false;
for (int i = 0; i < globalId.length; ++i)
if (globalId[i] != other.globalId[i])
return false;
return true;
}
//returns a reference to the global id byte array
public byte[] getInternalGlobalTransactionId(){
return globalId;
}
}

View File

@ -1,61 +0,0 @@
/*
* 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]
*/
/*
* @(#)StringUtil.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc.util;
import com.sun.jbi.alerter.Alerter;
import com.sun.jbi.alerter.AlerterImpl;
/**
*
* @author Sun
*/
public class AlertsUtil {
public static final String SERVER_TYPE_GLASSFISH = "Glassfish";
public static final String COMPONENT_TYPE_BINDING = "BindingComponent";
public static final String COMPONENT_TYPE_ENGINE = "ServiceEngine";
private static Alerter alertDel;
private static AlertsUtil singleton;
private AlertsUtil () {alertDel = new AlerterImpl();}
public static Alerter getAlerter() {
if (singleton == null) {
singleton = new AlertsUtil();
}
return alertDel;
}
public static String getServerType() {
return SERVER_TYPE_GLASSFISH;
}
}

View File

@ -1,101 +0,0 @@
/*
* 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]
*/
/*
* @(#)ConfigReader.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc.util;
import java.io.IOException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.FactoryConfigurationError;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import com.sun.jbi.jdbcbc.util.Configuration.PortMap;
/**
*ConfigReader
*/
public class ConfigReader {
/** Creates a new instance of ConfigReader */
public ConfigReader() {
}
/**
*
* @param is
* @return
* @throws IOException
* @throws FactoryConfigurationError
* @throws ParserConfigurationException
* @throws SAXException
*/
private static Configuration parse(final InputSource is)
throws IOException, FactoryConfigurationError,
ParserConfigurationException, SAXException {
final Configuration conf = new Configuration();
final DocumentBuilderFactory fact = DocumentBuilderFactory.newInstance();
final DocumentBuilder builder = fact.newDocumentBuilder();
final Document doc = builder.parse(is);
final Element root = doc.getDocumentElement();
final NodeList nl = root.getElementsByTagName(Configuration.PORT_MAP);
for (int i = 0; (nl != null) && (i < nl.getLength()); i++) {
final Node n = nl.item(i);
final Element e = (Element) n;
final String s0 = e.getAttribute(Configuration.TARGETNAMESPACE);
final String s1 = e.getAttribute(Configuration.SERVICE);
final String s2 = e.getAttribute(Configuration.END_POINT);
final String s3 = e.getAttribute(Configuration.DIRECTION);
final String s4 = e.getAttribute(Configuration.WSDL_FILE);
final PortMap pm = conf.newPortMap(s0, s1, s2, s3, s4);
conf.addPortMap(pm);
}
return conf;
}
/**
*
* @param argv
*/
public static void main(final String[] argv) {
try {
final Configuration c = ConfigReader.parse(new InputSource(
System.getProperty("ALASKA_ROOT") + "/jbi/test/bps/src/bpelasa/portmap.xml"));
} catch (final Exception e) {
e.printStackTrace();
}
}
}

View File

@ -1,126 +0,0 @@
/*
* 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]
*/
/*
* @(#)Configuration.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc.util;
import java.util.ArrayList;
import java.util.List;
/**
*
*Configuration
*/
public class Configuration {
public static final String TARGETNAMESPACE = "targetNamespace";
public static final String SERVICE = "service";
public static final String END_POINT = "endPoint";
public static final String DIRECTION = "direction";
public static final String WSDL_FILE = "wsdlFile";
public static final String PORT_MAP = "portmap";
// use arraylist for now
private ArrayList services;
/** Creates a new instance of Configuration */
public Configuration() {
services = new ArrayList();
}
/**
*
* @param p
*/
protected void addPortMap(final PortMap p) {
services.add(p);
}
/**
*
* @return
*/
private List portMaps() {
return services;
}
/**
*
* @param targetNameSpace
* @param service
* @param endPoint
* @param direction
* @param wsdlFile
* @return
*/
PortMap newPortMap(final String targetNameSpace, final String service,
final String endPoint, final String direction, final String wsdlFile) {
final PortMap pm = new PortMap(targetNameSpace, service, endPoint, direction,
wsdlFile);
return pm;
}
public static class PortMap {
private String mService;
private String mEndPoint;
private String mDirection;
private String mWsdlFile;
private String mTargetNameSpace;
protected PortMap(final String targetNameSpace, final String service,
final String endPoint, final String direction, final String wsdlFile) {
mTargetNameSpace = targetNameSpace;
mService = service;
mEndPoint = endPoint;
mDirection = direction;
mWsdlFile = wsdlFile;
}
private String getTargetNameSpace() {
return mTargetNameSpace;
}
private String getService() {
return mService;
}
private String getEndPoint() {
return mEndPoint;
}
public String getDirection() {
return mDirection;
}
private String getWsdlFile() {
return mWsdlFile;
}
}
}

View File

@ -1,96 +0,0 @@
/*
* 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]
*/
/*
* @(#)DebugLog.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc.util;
import com.sun.jbi.internationalization.Messages;
import java.io.StringWriter;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
/** This class may not be Multi-thread safe
*
* DebugLog
*/
public class DebugLog {
static Transformer transformer = null;
private static final Logger mLogger = Messages.getLogger(DebugLog.class);
/** Creates a new instance of DebugLog */
public DebugLog() {
}
private static synchronized void debugLog(final Logger aLogger, final String msg,
final Document doc) {
if (doc != null) {
DebugLog.debugLog(aLogger, msg, doc.getDocumentElement());
} else {
aLogger.warning("document is null");
}
}
private static synchronized void debugLog(final Logger aLogger, final String msg,
final Element elem) {
if (DebugLog.transformer == null) {
try {
final TransformerFactory fact = TransformerFactory.newInstance();
DebugLog.transformer = fact.newTransformer();
} catch (final TransformerConfigurationException ex) {
mLogger.log(Level.SEVERE,"Transformer Configuration Exception",ex);
//ex.printStackTrace();
}
}
try {
if ((elem != null) && (aLogger != null)) {
final DOMSource src = new DOMSource(elem);
final StringWriter writer = new StringWriter();
final StreamResult dest = new StreamResult(writer);
DebugLog.transformer.transform(src, dest);
final String s = msg + ":\n" + writer.toString();
aLogger.info(s);
}
} catch (final Exception ex) {
mLogger.log(Level.SEVERE,"Transformer Configuration Exception",ex);
//ex.printStackTrace();
}
}
}

View File

@ -1,70 +0,0 @@
/*
* 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]
*/
/*
* @(#)Description.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc.util;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Check out the meta-annotations in java.lang.annotation Retention specifies
* whether the annotation is used only by tools (like the compiler) that read
* source code; or by tools that read class files; or by code that uses
* reflection. You might want to define some annotations that work in
* conjunction with the apt tool, in which case all three retention values could
* be interesting. Usually, though, you will want RetentionPolicy.RUNTIME.
*
* Target specifies a list of places in the Java language syntax where the
* annotation can be used. This one is only appropriate as an annotation on
* parameters, so that's what you say.
*
* @author narayanaa
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target( { ElementType.CONSTRUCTOR, ElementType.METHOD, ElementType.PARAMETER,
ElementType.TYPE })
public @interface Description {
/**
* By the way, it's important that the name of the method in the
*
* @Description annotation be value and not anything else. If it were called
* name, say, you would have to write
* @Description(name="n") rather than just
* @Description("n").
*
* @return description string
*/
String value();
}

View File

@ -1,109 +0,0 @@
/*
* 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]
*/
/*
* @(#)ExtensionFilter.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc.util;
import java.io.File;
import java.io.FileFilter;
/**
*
* @author Bing Lu
*/
public class ExtensionFilter implements FileFilter {
private String[] mExtensions;
private boolean mInclude;
public ExtensionFilter(final String[] extensions) {
this(extensions, true);
}
/**
* @param extensions
* @todo Document this constructor
*/
private ExtensionFilter(final String[] extensions, final boolean include) {
mExtensions = ExtensionFilter.duplicate(extensions);
mInclude = include;
}
/**
* @param file
* @todo Document this method
*/
//@Override
public boolean accept(final File file) {
if ((mExtensions == null) || (mExtensions.length == 0)) {
return true;
}
if (file.isDirectory()) {
return true;
}
final String fileName = file.getName();
final int dotInd = fileName.lastIndexOf('.');
if (dotInd != -1) {
final String ext = fileName.substring(dotInd);
for (String element : mExtensions) {
if (ext.equalsIgnoreCase(element)) {
return mInclude;
}
}
}
return false;
}
private static Object[] duplicate(final Object[] a) {
if (a == null) {
return a;
}
final Object[] c = new Object[a.length];
System.arraycopy(a, 0, c, 0, a.length);
return c;
}
private static String[] duplicate(final String[] a) {
if (a == null) {
return a;
}
final String[] c = new String[a.length];
System.arraycopy(a, 0, c, 0, a.length);
return c;
}
}

View File

@ -1,149 +0,0 @@
/*
* 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]
*/
/*
* @(#)ReadWriteTextFile.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc.util;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
/**
*
* @author graj
*/
public class ReadWriteTextFile {
/**
* Fetch the entire contents of a text file, and return it in a String. This
* style of implementation does not throw Exceptions to the caller.
*
* @param aFile
* is a file which already exists and can be read.
*/
static public String getContents(File aFile) {
// ...checks on aFile are elided
StringBuffer contents = new StringBuffer();
// declared here only to make visible to finally clause
BufferedReader input = null;
try {
// use buffering, reading one line at a time
// FileReader always assumes default encoding is OK!
input = new BufferedReader(new FileReader(aFile));
String line = null; // not declared within while loop
/*
* readLine is a bit quirky : it returns the content of a line MINUS
* the newline. it returns null only for the END of the stream. it
* returns an empty String if two newlines appear in a row.
*/
while ((line = input.readLine()) != null) {
contents.append(line);
contents.append(System.getProperty("line.separator"));
}
} catch (FileNotFoundException ex) {
ex.printStackTrace();
} catch (IOException ex) {
ex.printStackTrace();
} finally {
try {
if (input != null) {
// flush and close both "input" and its underlying
// FileReader
input.close();
}
} catch (IOException ex) {
ex.printStackTrace();
}
}
return contents.toString();
}
/**
* Change the contents of text file in its entirety, overwriting any
* existing text.
*
* This style of implementation throws all exceptions to the caller.
*
* @param aFile
* is an existing file which can be written to.
* @throws IllegalArgumentException
* if param does not comply.
* @throws FileNotFoundException
* if the file does not exist.
* @throws IOException
* if problem encountered during write.
*/
static public void setContents(File aFile, String aContents)
throws FileNotFoundException, IOException {
if (aFile == null) {
throw new IllegalArgumentException("File should not be null.");
}
if (!aFile.exists()) {
throw new FileNotFoundException("File does not exist: " + aFile);
}
if (!aFile.isFile()) {
throw new IllegalArgumentException("Should not be a directory: "
+ aFile);
}
if (!aFile.canWrite()) {
throw new IllegalArgumentException("File cannot be written: "
+ aFile);
}
// declared here only to make visible to finally clause; generic
// reference
Writer output = null;
try {
// use buffering
// FileWriter always assumes default encoding is OK!
output = new BufferedWriter(new FileWriter(aFile));
output.write(aContents);
} finally {
// flush and close both "output" and its underlying FileWriter
if (output != null)
output.close();
}
}
/**
* Simple test harness.
*/
public static void main(String... aArguments) throws IOException {
File testFile = new File("/tmp/blah.txt");
System.out.println("Original file contents: " + getContents(testFile));
setContents(testFile, "Somebody says hello.");
System.out.println("New file contents: " + getContents(testFile));
}
}

View File

@ -1,154 +0,0 @@
/*
* 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]
*/
/*
* @(#)XMLCharUtil.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc.util;
import java.util.ArrayList;
/**
* @author M.S.Veerendra
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public final class XMLCharUtil {
public static final char[] specialChars = { '~','!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '+', '|', '}', '{', '"', ':', '?', '>', '<', '`', '-', '=', '\\', ']', '[', '\'', ';', '/', '.',','};
public static final String[] replaceChars={ "_T_","_E_","_R_","_ASH_","_D_","_P_","_C_","_A_","_S_","_OP_","_CL_","_PL_","_OR_","_CB_","_OB_","_DQ_","_CLN_","_Q_","_GT_","_LT_","_QO_","_MI_","_EQ_","_BS_","_BC_","_BO_","_AP_","_SCL_","_FS_","_DOT_","_COM_"};
public static final String[] appendCols={"_C","_CN","_FD","_FS","_MF","_M","_MD","_MR","_Q","_RS","_RC","_RT","_R","_RSA","_T","_UC","_W"};
public static final String[] reservedCols={"Concurrency","CursorName","FetchDirection","FetchSize","MaxFiledSize","MaxRows","MetaData","MoreResults","QueryTimeout","ResultSet","ResultSetConcurrency","ResultSetType","Row","RSAgent","Type","UpdateCount","Warnings"};
public static String getReplacement(char c)
{
for (int i=0;i<specialChars.length;i++)
{
System.out.println(specialChars[i]+" " + replaceChars[i]);
}
for (int i=0;i<specialChars.length;i++)
{
if(specialChars[i]==c)
{
return replaceChars[i];
}
}
System.out.println(specialChars.length);
System.out.println(specialChars.length);
return null;
}
public static String makeValidNCName(String name) {
StringBuffer nCName = new StringBuffer();
if (name == null)
name = "";
name = name.trim();
int size = name.length();
char ncChars[] = name.toCharArray();
int i = 0;
for (i = 0; i < size; i++) {
char ch = ncChars[i];
if (((i == 0)
&& !(Character.isJavaIdentifierStart(ch) && (ch != '$')) && !Character
.isDigit(ch))
|| ((i > 0) && !(Character.isJavaIdentifierPart(ch) && (ch != '$')))) {
String replace = getReplacement(ch);
if (replace != null) {
nCName.insert(nCName.length(), replace);
} else {
nCName.insert(nCName.length(), "_Z_");
}
} else {
nCName.append(ncChars[i]);
}
}
if ((i > 0) && Character.isDigit(nCName.charAt(0))) {
nCName.insert(0, "X_");
}
if ((i > 0) && nCName.charAt(0) == '_') {
nCName.insert(0, "X");
}
return nCName.toString();
}
public static boolean isJavaName(String name) {
if (name == null) {
name = "";
}
name = name.trim();
int size = name.length();
char ncChars[] = name.toCharArray();
int i = 0;
for (i = 1; i < size; i++) {
char ch = ncChars[i];
char ch0=ncChars[0];
if ( !Character.isJavaIdentifierStart(ch0)
|| Character.isDigit(ch0)
|| !Character.isJavaIdentifierPart(ch)){
return false;
}
}
return true;
}
public static String validColName(String name){
StringBuffer nCName = new StringBuffer();
nCName=nCName.insert(0,name);
for (int k=0;k<reservedCols.length;k++)
{
String temp=reservedCols[k];
if (temp.equals(name))
{
nCName = nCName.insert(nCName.length(),appendCols[k]);
break;
}
}
return nCName.toString();
}
}

View File

@ -1 +0,0 @@
#To be added for util package

View File

@ -1,53 +0,0 @@
/*
* 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]
*/
/*
* @(#)WSDLDefinition.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc.wsdlmodel;
import java.util.Collection;
import javax.wsdl.Definition;
/**
*
* To change the template for this generated type comment go to
* Window - Preferences - Java - Code Generation - Code and Comments
*/
public interface WSDLDefinition {
public static final String NS_SCHEMA = "http://www.w3.org/2001/XMLSchema";
public Definition getDefinition();
public Collection getAllSchemas();
public Collection getInlineSchemas();
public Collection getImportedSchemas();
}

View File

@ -1,69 +0,0 @@
/*
* 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]
*/
/*
* @(#)WSDLDefinitionFactory.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc.wsdlmodel;
import com.sun.jbi.internationalization.Messages;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.wsdl.Definition;
/**
*
* To change the template for this generated type comment go to
* Window - Preferences - Java - Code Generation - Code and Comments
*/
public abstract class WSDLDefinitionFactory {
private static WSDLDefinitionFactory mInstance;
private static final Logger mLogger = Messages.getLogger(WSDLDefinitionFactory.class);
private static WSDLDefinitionFactory getInstance() throws Exception {
if (WSDLDefinitionFactory.mInstance == null) {
final String factoryImplName = System.getProperty("com.sun.jbi.jdbcbc.wsdlmodel.WSDLDefinitionFactory",
"com.sun.jbi.jdbcbc.wsdlmodel.impl.WSDLDefinitionFactoryImpl");
try {
final Class cls = Class.forName(factoryImplName);
WSDLDefinitionFactory.mInstance = (WSDLDefinitionFactory) cls.newInstance();
} catch (final ClassNotFoundException ex) {
mLogger.log(Level.SEVERE,"WSDL factory could not be found!!!",ex);
throw new Exception("failed to create concrete factory class for com.sun.jbi.jdbcbc.wsdlmodel.WSDLDefinitionFactory",
ex);
}
}
return WSDLDefinitionFactory.mInstance;
}
abstract WSDLDefinition newWSDLDefinition(Definition definition);
}

View File

@ -1,51 +0,0 @@
/*
* 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]
*/
/*
* @(#)WSDLDefinitionFactoryImpl.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc.wsdlmodel.impl;
import javax.wsdl.Definition;
import com.sun.jbi.jdbcbc.wsdlmodel.WSDLDefinition;
import com.sun.jbi.jdbcbc.wsdlmodel.WSDLDefinitionFactory;
/**
*
* To change the template for this generated type comment go to
* Window - Preferences - Java - Code Generation - Code and Comments
*/
public abstract class WSDLDefinitionFactoryImpl extends WSDLDefinitionFactory {
public WSDLDefinitionFactoryImpl() {
}
//@Override
public WSDLDefinition newWSDLDefinition(final Definition definition) {
return new WSDLDefinitionImpl(definition);
}
}

View File

@ -1,116 +0,0 @@
/*
* 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]
*/
/*
* @(#)WSDLDefinitionImpl.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc.wsdlmodel.impl;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import javax.wsdl.Definition;
import javax.wsdl.Types;
import javax.wsdl.extensions.ExtensibilityElement;
import javax.xml.namespace.QName;
import com.sun.jbi.jdbcbc.wsdlmodel.WSDLDefinition;
/**
*
* To change the template for this generated type comment go to
* Window - Preferences - Java - Code Generation - Code and Comments
*/
public class WSDLDefinitionImpl implements WSDLDefinition {
private Definition mDefinition;
private List mAllSchemas;
private List mInlineSchemas;
private List mImportedSchemas;
WSDLDefinitionImpl(final Definition definition) {
mDefinition = definition;
initialize();
}
//@Override
public Definition getDefinition() {
return mDefinition;
}
//@Override
public Collection getAllSchemas() {
return mAllSchemas;
}
//@Override
public Collection getInlineSchemas() {
return mInlineSchemas;
}
//@Override
public Collection getImportedSchemas() {
return mImportedSchemas;
}
private void initialize() {
mInlineSchemas = loadInlineSchemas();
mInlineSchemas = loadImportSchemas();
}
private List loadInlineSchemas() {
final List inlineSchemas = new ArrayList();
final Types types = mDefinition.getTypes();
if (types != null) {
final List extElements = types.getExtensibilityElements();
if (extElements != null) {
final Iterator it = extElements.iterator();
while (it.hasNext()) {
final ExtensibilityElement exElement = (ExtensibilityElement) it.next();
final QName schemaQName = exElement.getElementType();
final String ns = schemaQName.getNamespaceURI();
final String localName = schemaQName.getLocalPart();
if ((ns != null) && ns.equals(WSDLDefinition.NS_SCHEMA) &&
localName.equals("schema")) {
}
}
}
}
return inlineSchemas;
}
private List loadImportSchemas() {
//TODO: implement this
return null;
}
}

View File

@ -1 +0,0 @@
#To be added for wsdlmodel package

View File

@ -1,125 +0,0 @@
/*
* 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]
*/
/*
* @(#)EndpointBeanTest.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc;
import com.sun.jbi.eManager.provider.EndpointStatus;
import junit.framework.*;
import org.jmock.*;
/**
*
*
*/
public class EndpointBeanTest extends MockObjectTestCase {
EndpointBean instance = null;
public EndpointBeanTest(final String testName) {
super(testName);
}
//@Override
public void setUp() throws Exception {
instance = new EndpointBean();
}
//@Override
public void tearDown() throws Exception {
}
public static Test suite() {
final TestSuite suite = new TestSuite(EndpointBeanTest.class);
return suite;
}
/**
* Test of setEndpointStatus and getEndpointStatus method, of class com.sun.jbi.filebc.EndpointImpl.
*/
public void testSetGetEndpointStatus() {
System.out.println("Testing setEndpointStatus and getEndpointStatus");
final Mock endpointStatus = mock(EndpointStatus.class);
instance.setEndpointStatus((EndpointStatus) endpointStatus.proxy());
final EndpointStatus result = instance.getEndpointStatus();
Assert.assertTrue(result instanceof EndpointStatus);
System.out.println(
"Successfully tested setEndpointStatus and getEndpointStatus");
}
public void testSetGetValue() {
System.out.println("Testing setValue and getValue");
instance.setValue("servicename", "servicenameValue");
final String result = instance.getValue("servicename");
Assert.assertEquals("servicenameValue", result);
System.out.println("Successfully tested setvalue and getValue");
}
/**
* Test of setDeploymentId method, of class com.sun.jbi.jdbcbc.EndpointBean.
*/
/**
* Test of getDeploymentId method, of class com.sun.jbi.jdbcbc.EndpointBean.
*/
public void testSetGetDeploymentId() {
System.out.println("Testing Set Get DeploymentId");
final String asId = "depID";
instance.setDeploymentId(asId);
final String expResult = "depID";
final String result = instance.getDeploymentId();
Assert.assertEquals(expResult, result);
}
/**
* Test of getUniqueName method, of class com.sun.jbi.jdbcbc.EndpointBean.
*/
public void testGetUniqueName() {
System.out.println("getUniqueName");
final String servicename = "servicename";
final String endpointName = "endpoint";
final String endpointtype = "endpointtype";
final String expResult = "servicename" + "," + "endpoint" + "," +
"endpointtype";
final String result = EndpointBean.getUniqueName(servicename, endpointName,
endpointtype);
Assert.assertEquals(expResult, result);
}
}

View File

@ -1,85 +0,0 @@
/*
* 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]
*/
/*
* @(#)FaultExceptionTest.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc;
import junit.framework.*;
import javax.jbi.messaging.MessagingException;
/**
*
*
*/
public class FaultExceptionTest extends TestCase {
FaultException instance = new FaultException(new MessagingException(
"Testing exception message"));
public FaultExceptionTest(final String testName) {
super(testName);
}
//@Override
public void setUp() throws Exception {
}
//@Override
public void tearDown() throws Exception {
}
public static Test suite() {
final TestSuite suite = new TestSuite(FaultExceptionTest.class);
return suite;
}
/**
* Test of getFaultCode method, of class com.sun.jbi.jdbcbc.FaultException.
*/
public void testSetGetFaultCode() {
System.out.println("Testing getFaultCode");
final String expResult = "Server";
final String result = instance.getFaultCode();
Assert.assertEquals(expResult, result);
}
/**
* Test of getDetail method, of class com.sun.jbi.jdbcbc.FaultException.
*/
public void testGetDetail() {
System.out.println("Testing getDetail");
final String expResult = "Testing exception message";
final String result = instance.getDetail();
Assert.assertEquals(expResult, result);
}
}

View File

@ -1,201 +0,0 @@
/*
* 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]
*/
/*
* @(#)InboundMessageProcessorTest.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc;
import com.sun.jbi.common.qos.messaging.MessagingChannel;
import com.sun.jbi.eManager.provider.EndpointStatus;
import junit.framework.*;
import org.jmock.*;
import java.util.HashMap;
import java.util.Map;
import javax.jbi.component.ComponentContext;
import javax.jbi.messaging.DeliveryChannel;
import javax.jbi.messaging.InOut;
import javax.jbi.messaging.MessageExchange;
import javax.jbi.messaging.MessageExchangeFactory;
import javax.jbi.messaging.NormalizedMessage;
import javax.jbi.servicedesc.ServiceEndpoint;
import javax.xml.namespace.QName;
/**
*
*
*/
public class InboundMessageProcessorTest extends MockObjectTestCase {
static final QName THE_OPERATION = new QName("myoperation");
static final QName THE_SERVICE = new QName("myServiceName");
static final String THE_ENDPOINT = "myEndpointName";
InboundMessageProcessor instance = null;
Mock deliveryChannel = null;
Mock componentContext = null;
EndpointBean endpoint = null;
Mock endpointStatus = null;
Mock serviceEndpoint = null;
Mock msgExchange = null;
Mock msgExchangeFactory = null;
JDBCNormalizer normalizer = null;
Mock normalizedMsg = null;
Map operations = new HashMap();
Map operationMeps = new HashMap();
public InboundMessageProcessorTest(final String testName) {
super(testName);
}
//@Override
public void setUp() throws Exception {
componentContext = mock(ComponentContext.class);
deliveryChannel = mock(MessagingChannel.class);
endpoint = new EndpointBean();
endpointStatus = mock(EndpointStatus.class);
serviceEndpoint = mock(ServiceEndpoint.class);
msgExchangeFactory = mock(MessageExchangeFactory.class);
msgExchange = mock(MessageExchange.class);
normalizer = new JDBCNormalizer();
normalizedMsg = mock(NormalizedMessage.class);
instance = new InboundMessageProcessor((MessagingChannel) deliveryChannel.proxy(),
endpoint,
(ComponentContext) componentContext.proxy(), InboundMessageProcessorTest.THE_OPERATION);
}
//@Override
public void tearDown() throws Exception {
}
public static Test suite() {
final TestSuite suite = new TestSuite(InboundMessageProcessorTest.class);
return suite;
}
/**
* Test of run method, of class com.sun.jbi.jdbcbc.InboundMessageProcessor
* for the scenario where the message exchange pattern is not valid
*/
public void testRunInvalidMEP() {
System.out.println(
"Testing run() for the scenario where the message exchange pattern is not valid");
/*
JDBCOperation jdbcoperation = new JDBCOperation();
operations.put(THE_OPERATION, jdbcoperation);
JDBCOperationInput jdbcopInput = new JDBCOperationInput();
jdbcopInput.setJDBCSql(new JDBCSql());
deliveryChannel.expects(atLeastOnce()).method("createExchangeFactory");
msgExchangeFactory.expects(atLeastOnce()).method("createInOnlyExchange").will(returnValue(msgExchange));
endpoint.expects(atLeastOnce()).method("getValueObj").will(returnValue(THE_SERVICE));
endpoint.expects(atLeastOnce()).method("getValue").will(returnValue(THE_ENDPOINT));
msgExchange.expects(atLeastOnce()).method("setEndpoint");
msgExchange.expects(atLeastOnce()).method("setOperation");
// 1. testing the case where message exchange pattern is not found (null)
operationMeps.remove(THE_OPERATION);
operationMeps.put("dummyOperation", "inonly");
instance.run();
// 2. testing the case where message exchange status is invalid (not inonly or inout)
operationMeps.put(THE_OPERATION, "outin");
instance.run();
*/
}
/**
* Test of processReplyMessage method, of class com.sun.jbi.filebc.InboundMessageProcessor.
*/
public void testProcessInOnly() {
System.out.println("Testing processInOnly");
}
/**
* Test of processReplyMessage method, of class com.sun.jbi.filebc.InboundMessageProcessor.
*/
public void testProcessReplyMessage() {
System.out.println("Testing processReplyMessage");
final Map inboundReplys = new HashMap();
final Map Ids = new HashMap();
msgExchange = mock(MessageExchange.class);
msgExchange.stubs().method("isTransacted").will(returnValue(false));
msgExchange.stubs().method("getPattern");
// testing invalid message exchange
try {
instance.processReplyMessage((MessageExchange) msgExchange.proxy());
Assert.fail(
"Failed to test processReplyMessage when an validation exception should be caught.");
} catch (final Exception e) {
System.out.println(
"Successfully tested processReply when the MessageExchange is neither in-out nor in-only");
}
// testing no exchangeId found
msgExchange = mock(InOut.class);
msgExchange.expects(atLeastOnce()).method("getExchangeId")
.will(returnValue("789"));
Ids.put("123", "");
msgExchange.stubs().method("isTransacted").will(returnValue(false));
//instance.setInboundExchangeIds(Ids);
try {
instance.processReplyMessage((InOut) msgExchange.proxy());
System.out.println(
"Successfully tested processReply when message exchange ID is not found");
} catch (final Exception e) {
Assert.fail(
"Failed to test processReplyMessage when message exchange ID is not found.");
}
// testing exchange Id is found and status is DONE
msgExchange.expects(atLeastOnce()).method("getExchangeId")
.will(returnValue("123"));
//msgExchange.expects(atLeastOnce()).method("getStatus").will(returnValue(ExchangeStatus.DONE));
try {
instance.processReplyMessage((InOut) msgExchange.proxy());
final Map inboundIds = InboundMessageProcessor.getInboundExchanges();
Assert.assertTrue(!inboundIds.containsKey("123"));
} catch (final Exception e) {
Assert.fail(
"Failed to test processReplyMessage when message exchange status is DONE.");
}
System.out.println("Successfully tested processReplyMessage");
}
}

View File

@ -1,250 +0,0 @@
/*
* 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]
*/
/*
* @(#)InboundReceiverTest.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc;
import com.sun.jbi.common.qos.messaging.MessagingChannel;
import java.util.HashMap;
import java.util.Map;
import javax.jbi.component.ComponentContext;
import javax.jbi.messaging.DeliveryChannel;
import javax.wsdl.Definition;
import javax.xml.namespace.QName;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.jmock.Mock;
import org.jmock.MockObjectTestCase;
import com.sun.jbi.jdbcbc.extensions.JDBCOperation;
/**
*
*
*/
public class InboundReceiverTest extends MockObjectTestCase {
InboundReceiver instance = null;
Mock runtimeConfig = null;
Mock deliveryChannel = null;
EndpointBean epb = null;
Mock componentContext = null;
Map operations = new HashMap();
Map endpoints = new HashMap();
EndpointBean endpoint = new EndpointBean();
Definition defwsdl;
public InboundReceiverTest(final String testName) {
super(testName);
}
//@Override
public void setUp() throws Exception {
runtimeConfig = mock(RuntimeConfigurationMBean.class);
componentContext = mock(ComponentContext.class);
deliveryChannel = mock(MessagingChannel.class);
//runtimeConfig.expects(once()).method("getThreads").will(returnValue(new Integer(10)));
//runtimeConfig.expects(once()).method("addNotificationListener").withAnyArguments();
//instance = new InboundReceiver((DeliveryChannel) deliveryChannel.proxy(),
// endpoints,(RuntimeConfiguration) runtimeConfig.proxy(),(ComponentContext) componentContext.proxy());
}
@Override
public void tearDown() throws Exception {
}
public static Test suite() {
final TestSuite suite = new TestSuite(InboundReceiverTest.class);
return suite;
}
/**
* Test of addInboundMessageProcessor method, of class com.sun.jbi.filebc.InboundReceiver.
*/
public void testAddInboundMessageProcessor() throws Exception {
System.out.println("Testing addInboundMessageProcessor");
epb = new EndpointBean();
// 1. testing for inbound endpoint
endpoint.setValue("descriptor", "descriptor");
endpoint.setValue("servicename", "servicename");
endpoint.setValue("endpointname", "endpointname");
endpoint.setValue("endpointtype", "endpointtype");
operations.put(new QName("somenamespace", "someOp1"),
new JDBCOperation());
operations.put(new QName("somenamespace", "someOp2"),
new JDBCOperation());
operations.put(new QName("somenamespace", "someOp3"),
new JDBCOperation());
operations.put(new QName("somenamespace", "someOp4"),
new JDBCOperation());
operations.put(new QName("somenamespace", "someOp5"),
new JDBCOperation());
operations.put(new QName("somenamespace", "someOp6"),
new JDBCOperation());
operations.put(new QName("somenamespace", "someOp7"),
new JDBCOperation());
operations.put(new QName("somenamespace", "someOp8"),
new JDBCOperation());
//endpoint.setFileOperations(operations);
try {
//instance.addInboundMessageProcessor(endpoint);
//epb.expects(atLeastOnce()).method("getValueObj").withAnyArguments().will(returnValue(defwsdl));
//epb.expects(atLeastOnce()).method("getValue").withAnyArguments().will(returnValue("endpointName"));
} catch (final Exception e) {
//fail("Failed to test addInboundMessageProcessor due to: " + e.getMessage());
}
}
/**
* Test of removeInboundMessageProcessor method, of class com.sun.jbi.filebc.InboundReceiver.
*/
public void testRemoveInboundMessageProcessor() {
System.out.println("Testing removeInboundMessageProcessor");
final Map dummyProcs = new HashMap();
final QName serviceName = new QName("someServiceName");
final String endpointName = "someEndpointName";
try {
dummyProcs.put(serviceName + endpointName +
"{somenamespace}someOp1",
new InboundMessageProcessor(
(MessagingChannel) deliveryChannel.proxy(), endpoint,
(ComponentContext) componentContext.proxy(),
new QName("somenamespace", "someOp1")));
dummyProcs.put(serviceName + endpointName +
"{somenamespace}someOp2",
new InboundMessageProcessor(
(MessagingChannel) deliveryChannel.proxy(), endpoint,
(ComponentContext) componentContext.proxy(),
new QName("somenamespace", "someOp2")));
dummyProcs.put(serviceName + endpointName +
"{somenamespace}someOp3",
new InboundMessageProcessor(
(MessagingChannel) deliveryChannel.proxy(), endpoint,
(ComponentContext) componentContext.proxy(),
new QName("somenamespace", "someOp3")));
dummyProcs.put(serviceName + endpointName +
"{somenamespace}someOp4",
new InboundMessageProcessor(
(MessagingChannel) deliveryChannel.proxy(), endpoint,
(ComponentContext) componentContext.proxy(),
new QName("somenamespace", "someOp4")));
dummyProcs.put(serviceName + endpointName +
"{somenamespace}someOp5",
new InboundMessageProcessor(
(MessagingChannel) deliveryChannel.proxy(), endpoint,
(ComponentContext) componentContext.proxy(),
new QName("somenamespace", "someOp5")));
dummyProcs.put(serviceName + endpointName +
"{somenamespace}someOp6",
new InboundMessageProcessor(
(MessagingChannel) deliveryChannel.proxy(), endpoint,
(ComponentContext) componentContext.proxy(),
new QName("somenamespace", "someOp6")));
dummyProcs.put(serviceName + endpointName +
"{somenamespace}someOp7",
new InboundMessageProcessor(
(MessagingChannel) deliveryChannel.proxy(), endpoint,
(ComponentContext) componentContext.proxy(),
new QName("somenamespace", "someOp7")));
dummyProcs.put(serviceName + endpointName +
"{somenamespace}someOp8",
new InboundMessageProcessor(
(MessagingChannel) deliveryChannel.proxy(), endpoint,
(ComponentContext) componentContext.proxy(),
new QName("somenamespace", "someOp8")));
} catch (final Exception e) {
//fail("Failed to set up successfully to test removeInboundMessageProcessor");
}
// 1. testing removing some of the activated processors
endpoint.setValue("descriptor", "descriptor");
endpoint.setValue("servicename", "servicename");
endpoint.setValue("endpointname", "endpointname");
endpoint.setValue("endpointtype", "endpointtype");
operations.clear();
operations.put(new QName("somenamespace", "someOp4"),
new JDBCOperation());
operations.put(new QName("somenamespace", "someOp5"),
new JDBCOperation());
//instance.setActivatedInboundMsgProcs(dummyProcs);
try {
//instance.removeInboundMessageProcessor(endpoint);
} catch (final Exception e) {
//fail("Failed to test removeInboundMessageProcessor due to: " + e.getMessage());
}
//instance.removeInboundMessageProcessor(endpoint);
//Map procs = instance.getActivatedInboundMsgProcs();
//assertEquals(6, procs.size());
// 2. testing for outbound endpoint
operations.put(new QName("somenamespace", "someOp1"),
new JDBCOperation());
operations.put(new QName("somenamespace", "someOp2"),
new JDBCOperation());
operations.put(new QName("somenamespace", "someOp3"),
new JDBCOperation());
operations.put(new QName("somenamespace", "someOp4"),
new JDBCOperation());
operations.put(new QName("somenamespace", "someOp5"),
new JDBCOperation());
operations.put(new QName("somenamespace", "someOp6"),
new JDBCOperation());
operations.put(new QName("somenamespace", "someOp7"),
new JDBCOperation());
operations.put(new QName("somenamespace", "someOp8"),
new JDBCOperation());
//endpoint.setFileOperations(operations);
//endpoint.setEndpointType(1);
//procs = instance.getActivatedInboundMsgProcs();
//assertEquals(6, procs.size());
// 3. testing removing all activated processors
//endpoint.setEndpointType(0);
try {
//instance.removeInboundMessageProcessor(endpoint);
} catch (final Exception e) {
//fail("Failed to test removeInboundMessageProcessor due to: " + e.getMessage());
}
//instance.removeInboundMessageProcessor(endpoint);
//procs = instance.getActivatedInboundMsgProcs();
//assertEquals(0, procs.size());
}
}

View File

@ -1,242 +0,0 @@
/*
* 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]
*/
/*
* @(#)JDBCBindingDeployerTest.java
*
* Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
*
* END_HEADER - DO NOT EDIT
*/
package com.sun.jbi.jdbcbc;
import com.sun.jbi.eManager.provider.StatusProviderHelper;
import junit.framework.*;
import org.jmock.*;
import java.util.HashMap;
import javax.jbi.component.ComponentContext;
import javax.management.MBeanServer;
/**
*
*
*/
public class JDBCBindingDeployerTest extends org.jmock.cglib.MockObjectTestCase {
JDBCBindingDeployer instance = null;
Mock componentContext = mock(ComponentContext.class);
Mock lifeCycle = mock(JDBCBindingLifeCycle.class);
public JDBCBindingDeployerTest(final String testName) {
super(testName);
}
//@Override
public void setUp() throws Exception {
instance = new JDBCBindingDeployer((ComponentContext) componentContext.proxy(),
(JDBCBindingLifeCycle) lifeCycle.proxy());
}
//@Override
public void tearDown() throws Exception {
}
public static Test suite() {
final TestSuite suite = new TestSuite(JDBCBindingDeployerTest.class);
return suite;
}
/**
* Test of deploy method, of class com.sun.jbi.jdbcbc.JDBCBindingDeployer.
*/
public void testDeploy() throws Exception {
System.out.println("Testing deploy");
componentContext.expects(once()).method("getComponentName")
.will(returnValue("someComponentName"));
final String result = instance.deploy("testSUId", "testSUDir");
Assert.assertNotNull(result);
}
/**
* Test of init method, of class com.sun.jbi.jdbcbc.JDBCBindingDeployer.
*/
public void testInit() throws Exception {
System.out.println("Testing init");
// 1. testing the scenario when a new service unit is to be initialized.
final RuntimeConfiguration runtimeConfig = new RuntimeConfiguration(
"test/com/sun/jbi/jdbcbc/testDir");
final StatusProviderHelper statusHelper = new StatusProviderHelper("shortName",
"componentType", "componentName",
(MBeanServer) mock(MBeanServer.class).proxy());
final HashMap endpoints = new HashMap();
//InboundReceiver inboundReceiver = new InboundReceiver((DeliveryChannel) mock(DeliveryChannel.class).proxy(),
// endpoints,runtimeConfig,
// (ComponentContext) componentContext.proxy());
final HashMap serviceUnits = new HashMap();
//lifeCycle.expects(once()).method("getStatusProviderHelper").will(returnValue(statusHelper));
//lifeCycle.expects(once()).method("activateEndpoints");
//componentContext.expects(once()).method("getComponentName").will(returnValue("someComponentName"));
//lifeCycle.expects(once()).method("getInboundReceiver").will(returnValue(inboundReceiver));
try {
//componentContext.expects(once()).method("getComponentName").will(returnValue("someComponentName"));
//instance.init("testSUId", "test/com/sun/jbi/jdbcbc/packaging/descriptors");
System.out.println(
"Successfully tested init for a new service unit");
} catch (final Exception e) {
e.printStackTrace();
//fail("Failed to test init for a new service unit");
}
// 2. testing the scenario when the service unit is already initialized
//serviceUnits.put("testSUId", mock(ServiceUnit.class).proxy());
try {
//componentContext.expects(once()).method("getComponentName").will(returnValue("someComponentName"));
//instance.init("testSUId", "testSURoot");
System.out.println(
"Successfully tested init for an existing service unit");
} catch (final Exception e) {
//fail("Failed to test init for an existing service unit");
}
}
/**
* Test of start method, of class com.sun.jbi.jdbcbc.JDBCBindingDeployer.
*/
public void testStart() throws Exception {
System.out.println("Testing start");
// 1. testing the scenario when the service unit is initialized
try {
instance.start("testSUId");
System.out.println(
"Successfully tested start when the service unit is initialized");
} catch (final Exception e) {
Assert.fail(
"Failed to test start when the service unit is initialized due to: " +
e.getMessage());
}
// 2. testing the scenario when the service unit is not initialized
try {
instance.start("noMatchSUId");
System.out.println(
"Successfully tested start when the service unit is not initialized");
} catch (final Exception e) {
Assert.fail(
"Failed to test start when the service unit is not initialized due to: " +
e.getMessage());
}
}
/**
* Test of stop method, of class com.sun.jbi.jdbcbc.JDBCBindingDeployer.
*/
public void testStop() throws Exception {
System.out.println("Testing stop");
// 1. testing the scenario when the service unit is initialized
try {
instance.stop("testSUId");
System.out.println(
"Successfully tested stop when the service unit is initialized");
} catch (final Exception e) {
Assert.fail(
"Failed to test stop when the service unit is initialized due to: " +
e.getMessage());
}
// 2. testing the scenario when the service unit is not initialized
try {
instance.stop("noMatchSUId");
System.out.println(
"Successfully tested stop when the service unit is not initialized");
} catch (final Exception e) {
Assert.fail(
"Failed to test stop when the service unit is not initialized due to: " +
e.getMessage());
}
}
/**
* Test of shutDown method, of class com.sun.jbi.jdbcbc.JDBCBindingDeployer.
*/
public void testShutDown() throws Exception {
System.out.println("Testing shutDown");
// 1. testing the scenario when the service unit is initialized
try {
//lifeCycle.expects(once()).method("deactivateEndpoints");
componentContext.expects(once()).method("getComponentName")
.will(returnValue("someComponentName"));
instance.shutDown("testSUId");
System.out.println(
"Successfully tested shutDown when the service unit is initialized");
} catch (final Exception e) {
Assert.fail(
"Failed to test shutDown when the service unit is initialized due to: " +
e.getMessage());
}
// 2. testing the scenario when the service unit is not initialized
try {
componentContext.expects(once()).method("getComponentName")
.will(returnValue("someComponentName"));
instance.shutDown("noMatchSUId");
System.out.println(
"Successfully tested shutDown when the service unit is not initialized");
} catch (final Exception e) {
Assert.fail(
"Failed to test shutDown when the service unit is not initialized due to: " +
e.getMessage());
}
}
/**
* Test of undeploy method, of class com.sun.jbi.jdbcbc.JDBCBindingDeployer.
*/
public void testUndeploy() throws Exception {
System.out.println("Testing undeploy");
try {
componentContext.expects(once()).method("getComponentName")
.will(returnValue("someComponentName"));
instance.undeploy("testSUId",
"test/com/sun/jbi/jdbcbc/packaging/descriptors");
} catch (final Exception e) {
Assert.fail(
"Failed to test Undeploy when the service unit is initialized due to: " +
e.getMessage());
}
//assertNull(instance.getServiceUnits().get("testSUId"));
}
}

Some files were not shown because too many files have changed in this diff Show More