diff --git a/ojc-core/jdbcbc/jdbcbcimpl/nbactions.xml b/ojc-core/jdbcbc/jdbcbcimpl/nbactions.xml deleted file mode 100755 index 5658d512b..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/nbactions.xml +++ /dev/null @@ -1,72 +0,0 @@ - - - - clean - - * - - - clean - - - true - - - - build - - * - - - install - - - true - - - - test - - * - - - package - - - false - - - - rebuild - - * - - - clean - install - - - true - - - - CUSTOM-testreport - testreport - - surefire-report:report-only - - - true - - - - CUSTOM-allreports - allreports - - site - - - true - - - diff --git a/ojc-core/jdbcbc/jdbcbcimpl/pom.xml b/ojc-core/jdbcbc/jdbcbcimpl/pom.xml deleted file mode 100755 index 00f45c4f7..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/pom.xml +++ /dev/null @@ -1,106 +0,0 @@ - - - - - - - build-common - open-jbi-components - 1.1 - ../../build-common - - 4.0.0 - open-jbi-components - jdbcbcimpl - jdbcbcimpl - ${jdbcbc.artifact.version} - jdbcbcimpl description - - - - maven-surefire-plugin - - - - **/com/sun/jbi/jdbcbc/RuntimeConfigurationTest.java - - - - - - - - open-jbi-components - componentsl - - - net.sf.hulp.meas - net.sf.hulp.meas.itf - - - wsdl4j - wsdl4j - - - open-jbi-components - qos - - - open-jbi-components - common-util - - - - jmock - jmock - test - - - jmock - jmock-cglib - test - - - - diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/EndpointBean.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/EndpointBean.java deleted file mode 100755 index 147d7d625..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/EndpointBean.java +++ /dev/null @@ -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 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(); - } - - 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; - } - -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/FaultException.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/FaultException.java deleted file mode 100755 index 77ca5d46a..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/FaultException.java +++ /dev/null @@ -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; - } -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/InboundMessageProcessor.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/InboundMessageProcessor.java deleted file mode 100755 index 2e45ae593..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/InboundMessageProcessor.java +++ /dev/null @@ -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); - } - } - -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/InboundReceiver.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/InboundReceiver.java deleted file mode 100755 index 3c8c50d4e..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/InboundReceiver.java +++ /dev/null @@ -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 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()); - - //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 getJDBCOperations(final Definition def, final String serviceName, - final String endpointName) { - final List jdbcOperations = new ArrayList(); - 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; - } -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/JDBCBindingDeployer.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/JDBCBindingDeployer.java deleted file mode 100755 index 2f23476a9..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/JDBCBindingDeployer.java +++ /dev/null @@ -1,1146 +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] - */ - -/* - * @(#)JDBCBindingDeployer.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.FileNotFoundException; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.logging.Level; -import java.util.logging.Logger; -import javax.jbi.component.ComponentContext; -import javax.jbi.component.ServiceUnitManager; -import javax.jbi.management.DeploymentException; -import javax.jbi.messaging.MessagingException; -import javax.wsdl.Binding; -import javax.wsdl.BindingInput; -import javax.wsdl.BindingOperation; -import javax.wsdl.BindingOutput; -import javax.wsdl.Definition; -import javax.wsdl.Operation; -import javax.wsdl.OperationType; -import javax.wsdl.Port; -import javax.wsdl.PortType; -import javax.wsdl.Service; -import javax.wsdl.extensions.ExtensibilityElement; -import javax.wsdl.factory.WSDLFactory; -import javax.wsdl.xml.WSDLReader; -import javax.xml.namespace.QName; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import org.apache.xml.resolver.CatalogManager; -import org.apache.xml.resolver.tools.CatalogResolver; -import org.xml.sax.EntityResolver; -import com.ibm.wsdl.factory.WSDLFactoryImpl; -import com.sun.jbi.eManager.provider.EndpointStatus; -import com.sun.jbi.eManager.provider.StatusProviderHelper; -import com.sun.jbi.eManager.provider.StatusReporting; -import com.sun.jbi.internationalization.Messages; -import com.sun.jbi.jdbcbc.extensions.JDBCAddress; -import com.sun.jbi.jdbcbc.extensions.JDBCBinding; -import com.sun.jbi.jdbcbc.extensions.JDBCExtensionRegistry; -import com.sun.jbi.jdbcbc.extensions.JDBCOperation; -import com.sun.jbi.jdbcbc.extensions.JDBCOperationInput; -import com.sun.jbi.jdbcbc.extensions.JDBCOperationOutput; -import com.sun.jbi.jdbcbc.util.Configuration.PortMap; -import com.sun.jbi.management.descriptor.EndpointIdentifier; -import com.sun.jbi.management.descriptor.SUDescriptorSupport; -import com.sun.jbi.management.message.DefaultJBITaskMessageBuilder; -import com.sun.jbi.management.message.JBITaskMessageBuilder; - -import org.apache.xml.resolver.CatalogManager; -import org.apache.xml.resolver.tools.CatalogResolver; -import org.xml.sax.EntityResolver; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.logging.Level; -import java.util.logging.Logger; - -import javax.jbi.component.ComponentContext; -import javax.jbi.component.ServiceUnitManager; -import javax.jbi.management.DeploymentException; -import javax.jbi.messaging.MessagingException; - -import javax.wsdl.Binding; -import javax.wsdl.BindingInput; -import javax.wsdl.BindingOperation; -import javax.wsdl.BindingOutput; -import javax.wsdl.Definition; -import javax.wsdl.Operation; -import javax.wsdl.OperationType; -import javax.wsdl.Port; -import javax.wsdl.PortType; -import javax.wsdl.Service; -import javax.wsdl.extensions.ExtensibilityElement; -import javax.wsdl.factory.WSDLFactory; -import javax.wsdl.xml.WSDLReader; - -import javax.xml.namespace.QName; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; - -// Additional imports for replacing the ibm WSDL factory to Sun extensions -import com.sun.wsdl4j.ext.impl.WSDLFactoryEx; -import com.sun.wsdl4j.ext.impl.WSDLReaderEx; - - -/** - * - *JDBCBindingDeployer - */ -public class JDBCBindingDeployer implements ServiceUnitManager { - private static final Messages mMessages = Messages.getMessages(JDBCBindingDeployer.class); - private static final Logger mLogger = Messages.getLogger(JDBCBindingDeployer.class); - private final Map mDeployedIds; - private final Map mDeployedEndpoints; - private final ComponentContext mContext; - private final DeployHelper mHelper; - private final JDBCBindingLifeCycle mLifeCycle; - - /** Creates a new instance of DeployerMBean */ - JDBCBindingDeployer(final ComponentContext context, - final JDBCBindingLifeCycle lifeCycle) { - mContext = context; - mDeployedIds = new HashMap(); - mDeployedEndpoints = new HashMap(); - mHelper = new DeployHelper(); - mLifeCycle = lifeCycle; - } - - /** - * Initiate a BC Deployment. - * - * @param suId - - * ID of the ASA being deployed - * @param asaFilePath - * @return - * @throws javax.jbi.management.DeploymentException - * - */ - //@Override - public String deploy(final String suId, final String asaFilePath) - throws DeploymentException { - String retMsg = null; - final String taskName = "deploy"; - - if (JDBCBindingDeployer.mLogger.isLoggable(Level.INFO)) { - JDBCBindingDeployer.mLogger.log(Level.INFO, "SQLSE_R00201.JDBCBD_Deploy_SU", - new Object[] { suId, asaFilePath }); - } - - retMsg = createSuccessMessage(taskName, mContext.getComponentName()); - - return retMsg; - } - - /** - * @param suId - * @param suPath - * @throws DeploymentException - */ - //@Override - public void init(final String suId, final String suPath) - throws DeploymentException { - final String taskName = "init"; - if (JDBCBindingDeployer.mLogger.isLoggable(Level.INFO)) { - JDBCBindingDeployer.mLogger.log(Level.INFO, "SQLSE_R00202.JDBCBD_Init_SU", - new Object[] { suId, suPath }); - } - - try { - // Prepare for start if the deployment hasn't been processed yet. - if (mDeployedIds.get(suId) == null) { - final StatusProviderHelper statusProviderHelper = mLifeCycle.getStatusProviderHelper(); - processDeployment(suId, suPath, statusProviderHelper); - } - - if (JDBCBindingDeployer.mLogger.isLoggable(Level.INFO)) { - JDBCBindingDeployer.mLogger.log(Level.INFO, "SQLSE_R00203.JDBCBD_Complete_init_SU", suId); - } - } catch (final DeploymentException ex) { - final String errMsg = JDBCBindingDeployer.mMessages.getString("SQLSE_E00204.JDBCBD_Failed_init_SU", - ex.getMessage()); - JDBCBindingDeployer.mLogger.log(Level.SEVERE, errMsg); - - final String exMsg = createExceptionMessage(mContext.getComponentName(), - taskName, "FAILED", "JDBCBC_INIT_1", null, errMsg, ex); - throw new DeploymentException(exMsg, ex); - } - } - - /** - * Process a deployment, validating it and preparing to start it.. - * - * @param suId - * the name of the Service Unit being initialized. - * @param path - * the full path to the Service Unit artifact root directory. - * @throws javax.jbi.management.DeploymentException - * if the Service Unit is not deployed, or is in an incorrect - * state. - */ - private void processDeployment(final String suId, final String path, - final StatusProviderHelper statusProviderHelper) throws DeploymentException { - final String taskName = "processDeployment"; - - try { - final File asaDir = new File(path); - mHelper.deploy(asaDir, suId, mContext, statusProviderHelper); - - final EndpointBean[] endPointsArr = mDeployedEndpoints.get(suId); - - mLifeCycle.activateEndpoints(endPointsArr); - setEndpointsStatus(endPointsArr, EndpointBean.STATUS_RUNNING); - } catch (final FileNotFoundException ex) { - final String exMsg = createExceptionMessage(mContext.getComponentName(), - taskName, "FAILED", "FBC_PROCESS_2", suId, - "Processing deployment error: " + ex.getMessage(), ex); - throw new DeploymentException(exMsg); - } catch (final IOException ex) { - final String exMsg = createExceptionMessage(mContext.getComponentName(), - taskName, "FAILED", "FBC_PROCESS_3", suId, - "Processing deployment error: " + ex.getMessage(), ex); - throw new DeploymentException(exMsg); - } catch (final MessagingException ex) { - final String exMsg = createExceptionMessage(mContext.getComponentName(), - taskName, "FAILED", "FBC_PROCESS_4", suId, - "Processing deployment error: " + ex.getMessage(), ex); - throw new DeploymentException(exMsg); - } catch (final Exception e) { - final String exMsg = createExceptionMessage(mContext.getComponentName(), - taskName, "FAILED", "FBC_PROCESS_4", suId, - "Processing deployment error: " + e.getMessage(), e); - throw new DeploymentException(exMsg); - } - } - - /** - * @param suId - * @throws DeploymentException - */ - // @Override - public void start(final String suId) throws DeploymentException { - if (JDBCBindingDeployer.mLogger.isLoggable(Level.INFO)) { - JDBCBindingDeployer.mLogger.log(Level.INFO, "SQLSE_R00205.JDBCBD_Starting_SU", suId); - } - - final EndpointBean[] endPointsArr = mDeployedEndpoints.get(suId); - setEndpointsStatus(endPointsArr, EndpointBean.STATUS_RUNNING); - - if (JDBCBindingDeployer.mLogger.isLoggable(Level.INFO)) { - JDBCBindingDeployer.mLogger.log(Level.INFO, "SQLSE_R00207.JDBCBD_Complete_start_BC"); - } - } - - /** - * @param suId - * @throws DeploymentException - */ - //@Override - public void stop(final String suId) throws DeploymentException { - if (JDBCBindingDeployer.mLogger.isLoggable(Level.INFO)) { - JDBCBindingDeployer.mLogger.log(Level.INFO, "SQLSE_R00208.JDBCBD_Stop_SU", suId); - } - - final EndpointBean[] endPointsArr = mDeployedEndpoints.get(suId); - - setEndpointsStatus(endPointsArr, EndpointBean.STATUS_STOPPED); - - if (JDBCBindingDeployer.mLogger.isLoggable(Level.INFO)) { - JDBCBindingDeployer.mLogger.log(Level.INFO, "SQLSE_R00210.JDBCBD_Complete_stop_SU", suId); - } - } - - /** - * @param suId - * @throws DeploymentException - */ - //@Override - public void shutDown(final String suId) throws DeploymentException { - final String taskName = "shutDown"; - - if (JDBCBindingDeployer.mLogger.isLoggable(Level.INFO)) { - JDBCBindingDeployer.mLogger.log(Level.INFO, "SQLSE_R00211.JDBCBD_Shutdown_SU", suId); - } - - final File asaDir = mDeployedIds.get(suId); - - if (asaDir == null) { - JDBCBindingDeployer.mLogger.info("Service unit " + mContext.getComponentName() + - " is not deployed."); - } else { - final EndpointBean[] endPointsArr = mDeployedEndpoints.get(suId); - - try { - mLifeCycle.deactivateEndpoints(endPointsArr); - } catch (final MessagingException ex) { - final String errMsg = mMessages.getString("SQLSE_E00212.JDBCBD_Error_shutdown_SU", - ex.getMessage()); - JDBCBindingDeployer.mLogger.log(Level.SEVERE, errMsg); - - final String exMsg = createExceptionMessage(mContext.getComponentName(), - taskName, "FAILED", "JDBCBC_SHUTDOWN_1", null, errMsg, - ex); - throw new DeploymentException(exMsg, ex); - } - - setEndpointsStatus(endPointsArr, EndpointBean.STATUS_SHUTDOWN); - - final StatusProviderHelper statusProviderHelper = mLifeCycle.getStatusProviderHelper(); - mHelper.undeploy(suId, asaDir, statusProviderHelper); - } - } - - /** - * Cancel a Service Deployment. If the deployment is in use (has - * dependencies), then this operation may fail. - * - * @param name - - * name of the service unit - * @param root - - * root of the service unit - * @return - * @throws DeploymentException - */ - //@Override - public String undeploy(final String name, final String root) throws DeploymentException { - String retMsg = null; - final String taskName = "undeploy"; - - if (JDBCBindingDeployer.mLogger.isLoggable(Level.INFO)) { - JDBCBindingDeployer.mLogger.log(Level.INFO, "SQLSE_R00213.JDBCBD_Undeploy_SU", - new Object[] { name, root }); - } - - retMsg = createSuccessMessage(taskName, mContext.getComponentName()); - - return retMsg; - } - - /** - * Determine the message exchange pattern. For handling 1.1 wsdls, map - * transmission primitives to the closest message exchange pattern, taking - * into account the endpoint direction direction inbound: request-response - * and solicit-response -> in-out one-way and notification -> in-only - * direction outbound: request-response and solicit-response -> out-in - * one-way and notification -> out-only - * - * @param pm - * the endpoint configuration from the portmap - * @param po - * the binding operation definition from the wsdl - * @return the message exchange pattern, null if no mapping could be - * determined. - */ - private String determineMEP(final PortMap pm, final BindingOperation bo) { - String mep = null; - final OperationType type = bo.getOperation().getStyle(); - - if (pm.getDirection().equals(EndpointBean.ENDPOINT_TYPE_INBOUND)) { - if (type.equals(OperationType.REQUEST_RESPONSE) || - type.equals(OperationType.SOLICIT_RESPONSE)) { - mep = "inout"; - } else if (type.equals(OperationType.ONE_WAY) || - type.equals(OperationType.NOTIFICATION)) { - mep = "inonly"; - } - } else { - if (type.equals(OperationType.REQUEST_RESPONSE) || - type.equals(OperationType.SOLICIT_RESPONSE)) { - mep = "outin"; - } else if (type.equals(OperationType.ONE_WAY) || - type.equals(OperationType.NOTIFICATION)) { - mep = "outonly"; - } - } - - return mep; - } - - /** - * Keep track of the running status of each endpoint. This allows for quick - * look-up of the state and provides for extensibility where an individual - * endpoint could be controlled rather than the whole SU. - */ - private void setEndpointsStatus(final EndpointBean[] endpoints, final String status) { - if (endpoints != null) { - for (EndpointBean element : endpoints) { - element.setValue(EndpointBean.STATUS, status); - } - } - } - - private String createSuccessMessage(final String taskName, final String componentName) { - final JBITaskMessageBuilder msgBuilder = new DefaultJBITaskMessageBuilder(); - msgBuilder.setComponentName(componentName); - - final String retMsg = msgBuilder.createSuccessMessage(taskName); - - return retMsg; - } - - private String createExceptionMessage(final String componentName, - final String taskName, final String status, final String locToken, final String locParam, - final String locMessage, final Throwable exObj) { - final JBITaskMessageBuilder msgBuilder = new DefaultJBITaskMessageBuilder(); - msgBuilder.setComponentName(componentName); - - final String retMsg = msgBuilder.createExceptionMessage(taskName, locToken, - locMessage, locParam, exObj); - - return retMsg; - } - - /** - * List all wsdl files in the currentDir and below - * @author Administrator - * - */ - private class DeployHelper { - private List listWSDLFiles(final File currentDir) { - final List cumulativeResults = new ArrayList(); - final File[] filesInCurrentDir = currentDir.listFiles(); - - for (File element : filesInCurrentDir) { - - if (element.isFile()) { - - if (element.getName().toLowerCase().endsWith(".wsdl")) { - cumulativeResults.add(element); - } - } else if (element.isDirectory()) { - final List wsdlsInSubDirectories = listWSDLFiles(element); - cumulativeResults.addAll(wsdlsInSubDirectories); - } - } - return cumulativeResults; - } - - /** - * - * @param f - * @param resolver - * @return - * @throws javax.wsdl.WSDLException - */ - private Definition readWsdl(final File f, final EntityResolver resolver) - throws javax.wsdl.WSDLException { - /*final WSDLFactory wsdlFactory = WSDLFactory.newInstance(); - final WSDLReader reader = ((WSDLFactoryImpl) wsdlFactory).newWSDLReader(resolver); - reader.setExtensionRegistry(new JDBCExtensionRegistry()); - - final Definition def = reader.readWSDL(f.getAbsolutePath());*/ - - // above default Implementation changed with current sun extension - final WSDLFactoryEx wsdlFactory = new WSDLFactoryEx(); - WSDLReaderEx reader = wsdlFactory.newWSDLReaderEx(); - reader.setEntityResolver(resolver); - reader.setExtensionRegistry(new JDBCExtensionRegistry()); - final Definition def = reader.readWSDL(f.getAbsolutePath()); - - return def; - } - - /** - * - * @param def - * @param serviceName - * @param endpointName - * @return - */ - private 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 def - * @param portTypeName - * @param operationName - * @return - */ - private Operation getOperation(final Definition def, final String portTypeName, - final String operationName) { - Operation operation = null; - final PortType pType = def.getPortType(QName.valueOf(portTypeName)); - - if (pType != null) { - operation = pType.getOperation(operationName, null, null); - } - - return operation; - } - - /** - * - * @param def - * @param serviceName - * @param endpointName - * @return - */ - private JDBCAddress getJDBCAddress(final Definition def, final String serviceName, - final String endpointName) { - JDBCAddress address = null; - 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) { - final List extElems = port.getExtensibilityElements(); - - // Look for jdbc:address - final Iterator extIter = (extElems == null) ? null : extElems.iterator(); - - while ((extIter != null) && extIter.hasNext() && - (address == null)) { - final ExtensibilityElement ee = (ExtensibilityElement) extIter.next(); - - if (JDBCAddress.class.isInstance(ee)) { - address = (JDBCAddress) ee; - } - } - } - - return address; - } - - /** - * - * @param def - * @param serviceName - * @param endpointName - * @return - */ - private JDBCBinding getJDBCBinding(final Definition def, final String serviceName, - final String endpointName) { - JDBCBinding jdbcBinding = null; - final Binding binding = getBinding(def, serviceName, endpointName); - - if (binding != null) { - final List extElems = binding.getExtensibilityElements(); - - // Look for jdbc:binding - final Iterator extIter = (extElems == null) ? null : extElems.iterator(); - - while ((extIter != null) && extIter.hasNext() && - (jdbcBinding == null)) { - final ExtensibilityElement ee = (ExtensibilityElement) extIter.next(); - - if (JDBCBinding.class.isInstance(ee)) { - jdbcBinding = (JDBCBinding) ee; - } - } - } - - return jdbcBinding; - } - - /** - * - * @param def - * @param serviceName - * @param endpointName - * @return - */ - private JDBCOperation[] getJDBCOperations(final Definition def, - final String serviceName, final String endpointName) { - final List jdbcOperations = new ArrayList(); - final Binding binding = getBinding(def, serviceName, endpointName); - - if (binding != null) { - final List bindingOperations = binding.getBindingOperations(); - final Iterator operIter = (bindingOperations == null) ? null - : bindingOperations.iterator(); - - while ((operIter != null) && operIter.hasNext()) { - final BindingOperation oper = (BindingOperation) operIter.next(); - final List extElems = oper.getExtensibilityElements(); - - // Look for file:operation entries - final Iterator extIter = (extElems == null) ? null - : extElems.iterator(); - - while ((extIter != null) && extIter.hasNext()) { - final ExtensibilityElement ee = (ExtensibilityElement) extIter.next(); - - if (JDBCOperation.class.isInstance(ee)) { - jdbcOperations.add(ee); - } - } - } - } - - return jdbcOperations.toArray(new JDBCOperation[0]); - } - - /** - * - * @param bindingInput - * @return - */ - private 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; - } - - /** - * - * @param bindingOutput - * @return - */ - private JDBCOperationOutput getJDBCOperationOutput( - final BindingOutput bindingOutput) { - JDBCOperationOutput operationOutput = null; - - final List extElems = bindingOutput.getExtensibilityElements(); - - // Look for jdbc:output entries - final Iterator extIter = (extElems == null) ? null : extElems.iterator(); - - while ((extIter != null) && extIter.hasNext()) { - final ExtensibilityElement ee = (ExtensibilityElement) extIter.next(); - - if (JDBCOperationOutput.class.isInstance(ee)) { - operationOutput = (JDBCOperationOutput) ee; - - break; - } - } - - return operationOutput; - } - - /** - * - * @param jdbcOperation - * @param def - * @param serviceName - * @param endpointName - * @return - */ - private BindingOperation getParentBindingOperation( - final JDBCOperation jdbcOperation, final Definition def, final String serviceName, - final String endpointName) { - BindingOperation bindingOperation = null; - - final Binding binding = getBinding(def, serviceName, endpointName); - - if (binding != null) { - final List l = binding.getBindingOperations(); - final Iterator it = l.iterator(); - - while (it.hasNext()) { - final BindingOperation bOperation = (BindingOperation) it.next(); - final List exElements = bOperation.getExtensibilityElements(); - - if ((exElements != null) && - exElements.contains(jdbcOperation)) { - bindingOperation = bOperation; - - break; - } - } - } - - return bindingOperation; - } - - /** - * - * @param asaDir - * @param id - * @param compContext - * @param statusProviderHelper - * @throws IOException - * @throws DeploymentException - * @throws javax.jbi.messaging.MessagingException - */ - private void deploy(final File asaDir, final String id, - final ComponentContext compContext, - final StatusProviderHelper statusProviderHelper) - throws IOException, DeploymentException, - javax.jbi.messaging.MessagingException { - final String taskName = "deploy"; - - final DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder documentBuilder = null; - - try { - documentBuilder = docBuilderFactory.newDocumentBuilder(); - } catch (final Exception ex) { - final String msg = "Failed to obtain a DOM parser: " + - ex.getMessage(); - JDBCBindingDeployer.mLogger.severe(msg); - - final String exMsg = createExceptionMessage(mContext.getComponentName(), - taskName, "FAILED", "FBC_DEPLOY_HELPER_1", id, msg, null); - throw new DeploymentException(exMsg); - } - - // read all wsdl files to see if - final FileToDefinitionInfo[] fileToDefs = readAllDefinitions(asaDir, id, - taskName, "FBC_DEPLOY_HELPER_4"); - - final ArrayList endPoints = new ArrayList(); - - if (SUDescriptorSupport.TEMP_SWITCH_ENABLE_JBI_ROUTING) { - JDBCBindingDeployer.mLogger.info( - "About to parse jbi.xml to resolve service end point."); - - EndpointIdentifier[] svcs = null; - - try { - final SUDescriptorSupport descSupport = new SUDescriptorSupport(asaDir.getAbsolutePath()); - svcs = descSupport.getServices(); - } catch (final Exception ex) { - final String exMsg = createExceptionMessage(mContext.getComponentName(), - taskName, "FAILED", "FBC_DEPLOY_12_1", id, - "Error parsing SU descriptor from" + - asaDir.getAbsolutePath() + " for " + id, ex); - throw new DeploymentException(exMsg); - } - - final int len = svcs.length; - - for (int i = 0; i < len; i++) { - Definition matchedDef = null; - File matchedWSDL = null; - JDBCBinding jdbcBinding = null; - JDBCOperation[] jdbcOperations = null; - final BindingOperation[] bindingOperations = null; - JDBCAddress jdbcAddress = null; - - // Document result = null; - final EndpointIdentifier epDesc = svcs[i]; - - for (FileToDefinitionInfo element : fileToDefs) { - jdbcBinding = getJDBCBinding(element.getDefinition(), - epDesc.getServiceName().toString(), - epDesc.getEndpointName()); - - if (jdbcBinding != null) { - matchedDef = element.getDefinition(); - // this is the wsdl that contains the service - // endpoint, save it - matchedWSDL = element.getFile(); - - break; - } - } - - // If no jdbc:binding is defined, the jdbcbc does not - // service this wsdl - if (jdbcBinding != null) { - // Prepare and cache the endpoint descriptor - /* - * try { result = documentBuilder.parse(matchedWSDL); } - * catch (Exception ex) { String msg = "Failed to parse - * WSDL to prepare endpoint descriptor for " + - * epDesc.getServiceName().toString() + " " + - * epDesc.getEndpointName() + ":" + ex.getMessage(); - * String exMsg = createExceptionMessage(mContext - * .getComponentName(), taskName, "FAILED", - * "FBC_DEPLOY_HELPER_11", id, msg, ex); throw new - * DeploymentException(exMsg); } - */ - jdbcAddress = getJDBCAddress(matchedDef, - epDesc.getServiceName().toString(), - epDesc.getEndpointName()); - - if (jdbcAddress == null) { - final String msg = "Missing jdbc:address in wsdl for this service " + - epDesc.getServiceName().toString(); - final String exMsg = createExceptionMessage(mContext.getComponentName(), - taskName, "FAILED", "FBC_DEPLOY_HELPER_5", - id, msg, null); - throw new DeploymentException(exMsg); - } else if (jdbcAddress.getJndiName() == null) { - final String msg = "Missing " + - JDBCAddress.ATTR_JNDI_NAME + - " in jdbc:address of wsdl for this service " + - epDesc.getServiceName().toString(); - final String exMsg = createExceptionMessage(mContext.getComponentName(), - taskName, "FAILED", "FBC_DEPLOY_HELPER_6", - id, msg, null); - throw new DeploymentException(exMsg); - } - - jdbcOperations = getJDBCOperations(matchedDef, - epDesc.getServiceName().toString(), - epDesc.getEndpointName()); - - if ((jdbcOperations == null) || - (jdbcOperations.length == 0)) { - final String msg = "Missing jdbc:operation definition(s) in wsdl for this service " + - epDesc.getServiceName().toString(); - final String exMsg = createExceptionMessage(mContext.getComponentName(), - taskName, "FAILED", "FBC_DEPLOY_HELPER_7", - id, msg, null); - throw new DeploymentException(exMsg); - } - - // create endpoint bean for each operation - final EndpointBean bcEndpoint = new EndpointBean(); - - bcEndpoint.setValueObj(EndpointBean.WSDL_FILE, - matchedWSDL); - bcEndpoint.setValueObj(EndpointBean.DESCRIPTOR, - matchedDef); // result - bcEndpoint.setValue(EndpointBean.JDBC_DATABASE_JNDI_NAME, - jdbcAddress.getJndiName()); - - bcEndpoint.setValue(EndpointBean.JDBC_DATABASE_DRIVER_CLASS, - jdbcAddress.getDriverClass()); - bcEndpoint.setValue(EndpointBean.JDBC_DATABASE_URL, - jdbcAddress.getDBUrl()); - bcEndpoint.setValue(EndpointBean.JDBC_DATABASE_USER, - jdbcAddress.getUserName()); - bcEndpoint.setValue(EndpointBean.JDBC_DATABASE_PASSWORD, - jdbcAddress.getPassword()); - - final String endpoint = epDesc.getEndpointName(); - final String endpointNameLocalPart = QName.valueOf(endpoint) - .getLocalPart(); - bcEndpoint.setValue(EndpointBean.ENDPOINT_NAME, - endpointNameLocalPart); - bcEndpoint.setValue(EndpointBean.SERVICE_NAME, - epDesc.getServiceName().toString()); - bcEndpoint.setValueObj(EndpointBean.FULL_SERVICE_NAME, - epDesc.getServiceName()); - bcEndpoint.setValue(EndpointBean.STATUS, - EndpointBean.STATUS_SHUTDOWN); - - if (epDesc.isProvider()) { - bcEndpoint.setValue(EndpointBean.ENDPOINT_TYPE, - EndpointBean.ENDPOINT_TYPE_OUTBOUND); - } else { - bcEndpoint.setValue(EndpointBean.ENDPOINT_TYPE, - EndpointBean.ENDPOINT_TYPE_INBOUND); - } - - final StatusReporting reporting = statusProviderHelper.getStatusReporter(); - final QName serviceName = (QName) bcEndpoint.getValueObj(EndpointBean.FULL_SERVICE_NAME); - final String portName = bcEndpoint.getValue(EndpointBean.ENDPOINT_NAME); - String uniqueName = null; - - if (bcEndpoint.getValue(EndpointBean.ENDPOINT_TYPE) - .equals(EndpointBean.ENDPOINT_TYPE_INBOUND)) { - uniqueName = statusProviderHelper.createConsumingEndpointIdentifier(serviceName, - portName); - reporting.addConsumingEndpoint(uniqueName); - } else { - uniqueName = statusProviderHelper.createProvisioningEndpointIdentifier(serviceName, - portName); - reporting.addProvisioningEndpoint(uniqueName); - } - - final EndpointStatus stat = reporting.getEndpointStatus(uniqueName); - bcEndpoint.setEndpointStatus(stat); - endPoints.add(bcEndpoint); - - final Map operationNameToMetaData = new HashMap(); - - for (final JDBCOperation jdbcOperation : jdbcOperations) { - // TODO: keep all the info separately in - // endpointbean. - final BindingOperation bindingOperation = getParentBindingOperation(jdbcOperation, - matchedDef, - epDesc.getServiceName().toString(), - epDesc.getEndpointName()); - - if (bindingOperation == null) { - final String msg = "Misssing binding operation in wsdl for this service " + - epDesc.getServiceName().toString(); - final String exMsg = createExceptionMessage(mContext.getComponentName(), - taskName, "FAILED", - "FBC_DEPLOY_HELPER_11", id, msg, null); - throw new DeploymentException(exMsg); - } - - final Binding binding = getBinding(matchedDef, - epDesc.getServiceName().toString(), - epDesc.getEndpointName()); - final PortType pt = binding.getPortType(); - - if (pt == null) { - final String msg = "Misssing binding portType in wsdl for this service " + - epDesc.getServiceName().toString() + - " portType : " + pt.getQName(); - final String exMsg = createExceptionMessage(mContext.getComponentName(), - taskName, "FAILED", - "FBC_DEPLOY_HELPER_12", id, msg, null); - throw new DeploymentException(exMsg); - } - - final Operation operation = getOperation(matchedDef, - pt.getQName().toString(), - bindingOperation.getName()); - - if (operation == null) { - final String msg = "Misssing portType operation in wsdl for this service " + - epDesc.getServiceName().toString() + - " portType : " + pt.getQName() + - "operation : " + - bindingOperation.getName(); - final String exMsg = createExceptionMessage(mContext.getComponentName(), - taskName, "FAILED", - "FBC_DEPLOY_HELPER_13", id, msg, null); - throw new DeploymentException(exMsg); - } - - JDBCOperationInput jdbcOperationInput = null; - - if (bindingOperation.getBindingInput() != null) { - jdbcOperationInput = getJDBCOperationInput(bindingOperation.getBindingInput()); - } - - JDBCOperationOutput jdbcOperationOutput = null; - - if (bindingOperation.getBindingOutput() != null) { - jdbcOperationOutput = getJDBCOperationOutput(bindingOperation.getBindingOutput()); - } - - JDBCOperationInput jdbcSql = null; - - if (jdbcOperationInput != null) { - jdbcOperationInput.setJDBCSql(jdbcOperationInput); - } - jdbcSql = jdbcOperationInput.getJDBCSql(); - - final String jdbcSqlStr = jdbcSql.getSql().trim(); - - if (jdbcSqlStr == null) { - final String msg = "Missing sql under jdbc:input element in wsdl for this service " + - epDesc.getServiceName().toString(); - final String exMsg = createExceptionMessage(mContext.getComponentName(), - taskName, "FAILED", - "JDBC_DEPLOY_HELPER_8", id, msg, null); - throw new DeploymentException(exMsg); - } - - JDBCBindingDeployer.mLogger.info("JDBC binding operation " + - jdbcOperationInput.getOperationType() + - " sql " + jdbcSqlStr); - - // create operation meta data - final OperationMetaData opMetaData = new OperationMetaData(); - opMetaData.setBindingOperation(bindingOperation); - opMetaData.setJDBCOperation(jdbcOperation); - opMetaData.setJDBCOperationInput(jdbcOperationInput); - opMetaData.setJDBCSql(jdbcSql); - opMetaData.setJDBCOperationOutput(jdbcOperationOutput); - opMetaData.setOperation(operation); - opMetaData.setDefinition(matchedDef); - operationNameToMetaData.put(bindingOperation.getName(), - opMetaData); - } - - bcEndpoint.setValueObj(EndpointBean.OPERATION_NAME_TO_META_DATA, - operationNameToMetaData); - } - } - } - - // todo : should consider what happens if one endpoint fails to - // activate - // what type of cleanup should we do? - final EndpointBean[] endPointsArr = endPoints.toArray(new EndpointBean[0]); - mDeployedIds.put(id, asaDir); - mDeployedEndpoints.put(id, endPointsArr); - } - - /** - * - * @param asaId - * @param asaDir - * @param statusProviderHelper - * @throws DeploymentException - */ - private void undeploy(final String asaId, final File asaDir, - final StatusProviderHelper statusProviderHelper) - throws DeploymentException { - final String taskName = "undeploy"; - - if (JDBCBindingDeployer.mLogger.isLoggable(Level.INFO)) { - JDBCBindingDeployer.mLogger.log(Level.INFO, "SQLSE_R00213.JDBCBD_Undeploy_SU", - new Object[] { asaId, asaDir }); - } - - try { - mDeployedIds.remove(asaId); - - final EndpointBean[] endpoints = mDeployedEndpoints.remove(asaId); - - if (endpoints != null) { - final StatusReporting reporting = statusProviderHelper.getStatusReporter(); - - for (EndpointBean element : endpoints) { - final QName serviceName = (QName) element.getValueObj(EndpointBean.FULL_SERVICE_NAME); - final String portName = element.getValue(EndpointBean.ENDPOINT_NAME); - String uniqueName = null; - - if (element.getValue( - EndpointBean.ENDPOINT_TYPE) - .equals(EndpointBean.ENDPOINT_TYPE_INBOUND)) { - uniqueName = statusProviderHelper.createConsumingEndpointIdentifier(serviceName, - portName); - reporting.removeConsumingEndpoints(new String[] { - uniqueName - }); - } else { - uniqueName = statusProviderHelper.createProvisioningEndpointIdentifier(serviceName, - portName); - reporting.removeProvisioningEndpoints(new String[] { - uniqueName - }); - } - } - } - } catch (final Exception e) { - final String exMsg = createExceptionMessage(mContext.getComponentName(), - taskName, "FAILED", "JDBCBC_UNDEPLOY_HELPER_1", asaId, - "Failed to undeploy " + e.getMessage(), e); - throw new DeploymentException(exMsg, e); - } - } - - /** - * - * @param asaDir - * @param id - * @param taskName - * @param locToken - * @return - * @throws DeploymentException - */ - private FileToDefinitionInfo[] readAllDefinitions(final File asaDir, final String id, - final String taskName, final String locToken) throws DeploymentException { - final CatalogManager catalogManager = new CatalogManager(); - catalogManager.setCatalogFiles(asaDir.getAbsolutePath() + - File.separator + "xml-catalog.xml"); - catalogManager.setRelativeCatalogs(true); - - final EntityResolver resolver = new CatalogResolver(catalogManager); - - final List wsdls = listWSDLFiles(asaDir); - final File[] wsdlFiles = wsdls.toArray(new File[0]); - - // read all wsdl files to see if - FileToDefinitionInfo[] fileToDefs = null; - - if (wsdlFiles != null) { - fileToDefs = new FileToDefinitionInfo[wsdlFiles.length]; - - for (int i = 0; i < wsdlFiles.length; i++) { - try { - final Definition def = readWsdl(wsdlFiles[i], resolver); - fileToDefs[i] = new FileToDefinitionInfo(wsdlFiles[i], - def); - } catch (final Exception e) { - final String msg = "Unable to read WSDL file " + - wsdlFiles[i] + " : " + e.getMessage(); - final String exMsg = createExceptionMessage(mContext.getComponentName(), - taskName, "FAILED", locToken, id, msg, e); - throw new DeploymentException(exMsg, e); - } - } - } - - return fileToDefs; - } - - /** - * - * @author Administrator - * - */ - class FileToDefinitionInfo { - private File mFile; - private Definition mDefinition; - - private FileToDefinitionInfo(final File file, final Definition definition) { - mFile = file; - mDefinition = definition; - } - - private File getFile() { - return mFile; - } - - private Definition getDefinition() { - return mDefinition; - } - } - } -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/JDBCBindingLifeCycle.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/JDBCBindingLifeCycle.java deleted file mode 100755 index 06a36d3d8..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/JDBCBindingLifeCycle.java +++ /dev/null @@ -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 initializedLifeCycles = new HashMap(); - public static final String SHORT_DISPLAY_NAME = "JDBC BC"; - private JDBCComponentContext mContext = JDBCComponentContext.getInstance(); - private OutboundReceiver mOutboundReceiver; - private InboundReceiver mInboundReceiver; - private Thread mOutboundReceiverThread; - Map mEndpoints = new HashMap(); - 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")); - } -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/JDBCComponentContext.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/JDBCComponentContext.java deleted file mode 100755 index 2a133930f..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/JDBCComponentContext.java +++ /dev/null @@ -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; - } - - -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/JDBCDenormalizer.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/JDBCDenormalizer.java deleted file mode 100755 index 8547dc261..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/JDBCDenormalizer.java +++ /dev/null @@ -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 outParamTypes = new HashMap(); - private HashMap outParamNames = new HashMap(); - 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 extractColumns(final String paramOrder) { - final List columnList = new ArrayList(); - - 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; - } - -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/JDBCNormalizer.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/JDBCNormalizer.java deleted file mode 100755 index 9f03234f6..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/JDBCNormalizer.java +++ /dev/null @@ -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 outParamTypes = new HashMap(); - private HashMap outParamNames = new HashMap(); - 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 "; - throw new MessagingException(msgEx); - } - } else { - final String msgEx = JDBCNormalizer.mMessages.getString( - "SQLSE_E00704.JDBCN_Failed_NM_WS_OPER") + - meta.getOperation().getName() + - " is missing "; - 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 pKeyList = new ArrayList(); - - 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 "; - 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 "; - 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 "; - throw new MessagingException(msgEx); - } - } else { - final String msgEx = JDBCNormalizer.mMessages.getString( - "SQLSE_E00704.JDBCN_Failed_NM_WS_OPER") + - meta.getOperation().getName() + - " is missing "; - 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 "; - throw new MessagingException(msgEx); - } - } else { - final String msgEx = JDBCNormalizer.mMessages.getString( - "SQLSE_E00704.JDBCN_Failed_NM_WS_OPER") + - meta.getOperation().getName() + - " is missing "; - 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; - } - -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/JDBCOperations.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/JDBCOperations.java deleted file mode 100755 index fcff610d5..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/JDBCOperations.java +++ /dev/null @@ -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")); - } -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/JDBCUtil.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/JDBCUtil.java deleted file mode 100755 index 8793f015e..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/JDBCUtil.java +++ /dev/null @@ -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 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();*/ - } -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/ListenerMeta.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/ListenerMeta.java deleted file mode 100755 index 2a9db3198..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/ListenerMeta.java +++ /dev/null @@ -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; - } -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/MessageExchangeReplyListener.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/MessageExchangeReplyListener.java deleted file mode 100755 index ce87798ac..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/MessageExchangeReplyListener.java +++ /dev/null @@ -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; -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/MessageExchangeSupport.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/MessageExchangeSupport.java deleted file mode 100755 index a12b9cbcd..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/MessageExchangeSupport.java +++ /dev/null @@ -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 removeReplyListener 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 removeRedeliveryListener 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"); - } - } -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/OperationMetaData.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/OperationMetaData.java deleted file mode 100755 index 2b8fe4e62..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/OperationMetaData.java +++ /dev/null @@ -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; - } -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/OutboundMessageProcessor.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/OutboundMessageProcessor.java deleted file mode 100755 index 47ca01065..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/OutboundMessageProcessor.java +++ /dev/null @@ -1,1244 +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] - */ - -/* - * @(#)OutboundMessageProcessor.java - * - * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved. - * - * END_HEADER - DO NOT EDIT - */ - -package com.sun.jbi.jdbcbc; - -import com.sun.jbi.alerter.NotificationEvent; -import com.sun.jbi.internationalization.Messages; -import com.sun.jbi.nms.exchange.ExchangePattern; -import com.sun.jbi.jdbcbc.extensions.JDBCOperationInput; -import java.net.URI; -import java.sql.CallableStatement; -import java.sql.Connection; -import java.sql.DatabaseMetaData; -import java.sql.DriverManager; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; -import java.util.StringTokenizer; -import java.util.logging.Level; -import java.util.logging.Logger; -import javax.jbi.component.ComponentContext; -import javax.jbi.messaging.*; -import javax.naming.Context; -import javax.sql.DataSource; -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.transaction.*; - -import javax.transaction.xa.XAResource; -import com.sun.jbi.jdbcbc.model.runtime.DBConnectionInfo; -import javax.sql.*; -import javax.transaction.Transaction; -import javax.transaction.TransactionManager; -import javax.transaction.Status; - -import com.sun.jbi.common.qos.messaging.MessagingChannel; -import com.sun.jbi.common.qos.redelivery.Redelivery; -import com.sun.jbi.common.qos.redelivery.RedeliveryStatus; -import com.sun.jbi.jdbcbc.util.AlertsUtil; -import com.sun.jbi.eManager.provider.EndpointStatus; - -/** - * Process replies/requests received from the SE. - */ -public class OutboundMessageProcessor implements Runnable { - private static final Messages mMessages = Messages.getMessages(OutboundMessageProcessor.class); - - private static final Logger mLogger = Messages.getLogger(OutboundMessageProcessor.class); - - Map mEndpoints; - - DocumentBuilder mDocBuilder; - - private MessagingChannel mChannel; - - private MessageExchange mExchange; - - private JDBCComponentContext mContext; - - private Map mInboundExchanges; - - DBConnectionInfo dbConnectionInfo; - - XAConnection xaConnection = null; - - private String mXAEnabled = null; - - Connection connection = null; - - //private TransactionManager mTxManager = null; - - private XidImpl xid = null; - - TransactionHelper mtxHelper = null; - - private boolean mtxFlag; - - XAResource xaResource = null; - - // 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"; - - private ReplyListener replyListener = null; - - private ArrayList outParamIndex = new ArrayList(); - private HashMap outParamTypes = new HashMap(); - private HashMap outParamNames = new HashMap(); - - - protected OutboundMessageProcessor(final MessagingChannel chnl, final MessageExchange exchange, final Map endpoints, - final JDBCComponentContext context, final Map inboundMessageExchanges) throws ParserConfigurationException { - mChannel = chnl; - mEndpoints = endpoints; - mExchange = exchange; - mContext = context; - mInboundExchanges = inboundMessageExchanges; - //mTxManager = (TransactionManager) context.getTransactionManager(); - - final DocumentBuilderFactory docBuilderFact = DocumentBuilderFactory.newInstance(); - mDocBuilder = docBuilderFact.newDocumentBuilder(); - // mtxHelper = new TransactionHelper(); - dbConnectionInfo = new DBConnectionInfo(); - } - - /** - * - */ - //@Override - public void run() { - if (mLogger.isLoggable(Level.INFO)) { - mLogger.log(Level.INFO, "SQLSE_R00606.OMP_Accept_msg", mExchange.getExchangeId()); - } - - try { - execute(); - } catch (final Exception ex) { - mLogger.log(Level.SEVERE, OutboundMessageProcessor.mMessages.getString( - "SQLSE_E00607.OMP_Unexpected_exception", ex.getLocalizedMessage()), ex); - } - - if (mLogger.isLoggable(Level.FINE)) { - mLogger.log(Level.INFO, "SQLSE_R00608.OMP_Complete_processing"); - } - } - - /** - * Process the message exchange - */ - public void execute() { - if (mExchange != null) { - final String exchangeId = mExchange.getExchangeId(); - - if (mLogger.isLoggable(Level.INFO)) { - mLogger.log(Level.INFO, "SQLSE_R00606.OMP_Accept_msg", exchangeId); - } - - final boolean inbound = mInboundExchanges.containsKey(exchangeId); - final ListenerMeta listenerMeta = (ListenerMeta) mInboundExchanges.get(exchangeId); - MessageExchangeReplyListener listener = null; - - if (listenerMeta != null) { - listener = listenerMeta.getMessageExchangeReplyListener(); - } - - if (inbound) { - final long invocationTime = listenerMeta.getRequestInvocationTime(); - - if (mLogger.isLoggable(Level.INFO)) { - final long difference = System.currentTimeMillis() - invocationTime; - mLogger.log(Level.INFO, "SQLSE_R00609.OMP_Resp_Ex", new Object[] { exchangeId, - difference }); - } - } - - final URI pattern = mExchange.getPattern(); - - if (mLogger.isLoggable(Level.INFO)) { - mLogger.log(Level.INFO, "SQLSE_R00610.OMP_Pattern", new Object[] { exchangeId, pattern }); - } - - final String serviceName = mExchange.getEndpoint().getServiceName().toString(); - final String endpointName = mExchange.getEndpoint().getEndpointName(); - - if (mLogger.isLoggable(Level.FINE)) { - mLogger.fine("Gettin bean for " + serviceName + endpointName); - } - - String epName = null; - - if (inbound) { - epName = EndpointBean.getUniqueName(serviceName, endpointName, EndpointBean.ENDPOINT_TYPE_INBOUND); - } else { - epName = EndpointBean.getUniqueName(serviceName, endpointName, EndpointBean.ENDPOINT_TYPE_OUTBOUND); - } - - final EndpointBean epb = (EndpointBean) mEndpoints.get(epName); - - // Create a reply listener and add the ME Support for the same - if (replyListener == null){ - replyListener = new ReplyListenerImpl(epb); - } - MessageExchangeSupport.addReplyListener(exchangeId,replyListener,epb); - - final String status = epb.getValue(EndpointBean.STATUS); - - if (!status.equals(EndpointBean.STATUS_RUNNING)) { - // If the endpoint is not in the RUNNING state (i.e. is stopped - // or - // shutdown), ignore the message - if (mLogger.isLoggable(Level.INFO)) { - mLogger.log(Level.INFO, "SQLSE_R00611.OMP_EP_state"); - } - } else { - - switch (ExchangePattern.valueOf(mExchange)) { - case IN_OUT: - mLogger.log(Level.INFO, "SQLSE_R00612.OMP_Recv_InOut", mExchange.getExchangeId()); - if(epb.JDBC_TRANSACTION_REQUIRED == "yes" && mExchange.isTransacted()){ - // Start of nested diagnostic context prior to processing of message - Logger.getLogger("com.sun.EnterContext").fine("context"); - processInOutXA((InOut) mExchange, epb); - // End of nested diagnostic context prior to processing of message - Logger.getLogger("com.sun.ExitContext").fine("context"); - } else { - // Start of nested diagnostic context prior to processing of message - Logger.getLogger("com.sun.EnterContext").fine("context"); - processInOut((InOut) mExchange, epb); - // End of nested diagnostic context prior to processing of message - Logger.getLogger("com.sun.ExitContext").fine("context"); - } - break; - case IN_ONLY: - mLogger.log(Level.INFO, "SQLSE_R00613.OMP_Recv_InOnly", mExchange.getExchangeId()); - - if (inbound) { - // Start of nested diagnostic context prior to processing of message - Logger.getLogger("com.sun.EnterContext").fine("context"); - processInOnlyInbound((InOnly) mExchange, epb, listener); - // End of nested diagnostic context prior to processing of message - Logger.getLogger("com.sun.ExitContext").fine("context"); - } else { - // Start of nested diagnostic context prior to processing of message - Logger.getLogger("com.sun.EnterContext").fine("context"); - processInOnly((InOnly) mExchange, epb); - // End of nested diagnostic context prior to processing of message - Logger.getLogger("com.sun.ExitContext").fine("context"); - } - break; - case ROBUST_IN_ONLY: - mLogger.log(Level.WARNING, "SQLSE_W00614.OMP_Not_supported_inonly", - mExchange.getExchangeId()); - break; - case IN_OPTIONAL_OUT: - mLogger.log(Level.WARNING, "SQLSE_W00615.OMP_Not_supported_outin", - mExchange.getExchangeId()); - break; - default: - mLogger.log(Level.WARNING, "SQLSE_W00617.OMP_Invalid_pattern", exchangeId); - return; - } - } - } // if(exchange) - } - - /** - * @param inonly - * @param endpoint - * @param listener - */ - protected void processInOnlyInbound(final InOnly inonly, - final EndpointBean endpoint, - final MessageExchangeReplyListener listener) { - mLogger.info("SQLSE_R00618.OMP_Processing_InOnly_inbound"); - - if (inonly.getStatus() == ExchangeStatus.DONE) { - endpoint.getEndpointStatus().incrementReceivedDones(); - } else if (inonly.getStatus() == ExchangeStatus.ERROR) { - endpoint.getEndpointStatus().incrementReceivedErrors(); - } else { - mLogger.log(Level.WARNING, "SQLSE_W00620.OMP_Unexpected_ME_status", new Object[] { - inonly.getEndpoint(), inonly.getStatus() }); - } - - try { - listener.processReplyMessage(inonly); - } catch (final Exception ex) { - mLogger.log(Level.SEVERE, "SQLSE_E00619.OMP_Failed_processing_inonly_inbound", ex); - } - } - - /** - * @param inout - * @param epb - */ - protected void processInOut(final InOut inout, final EndpointBean epb) { - ResultSet rs = null; - Connection connection = null; - CallableStatement cs = null; - - boolean success = true; - if (inout.getStatus() == ExchangeStatus.DONE) { - - // added for retry support - updateTallyReceivedReplies(epb); - // remove the redelivery listener handler - no retry needed. - MessageExchangeSupport.removeRedeliveryListener(inout.getExchangeId()); - - epb.getEndpointStatus().incrementReceivedDones(); - } else if (inout.getStatus() == ExchangeStatus.ERROR) { - - // added for retry support - - updateTallyReceives(epb, false); - - // send alerts - String errorMsg = inout.getError().getMessage(); - if (errorMsg != null) { - String msg = mMessages.getString("JDBCBC-E00720.Message_exchange_error", - new Object[] { - String.valueOf(inout.getService()), - inout.getEndpoint().getEndpointName(), - errorMsg - }); - mLogger.log(Level.SEVERE, msg); - AlertsUtil.getAlerter().warning(msg, - JDBCBindingLifeCycle.SHORT_DISPLAY_NAME, - epb.getDeploymentId(), - AlertsUtil.getServerType(), - AlertsUtil.COMPONENT_TYPE_BINDING, - NotificationEvent.OPERATIONAL_STATE_RUNNING, - NotificationEvent.EVENT_TYPE_ALERT, - "JDBCBC-E00720"); - } else { - String msg = mMessages.getString("JDBCBC-E00721.Message_exchange_error_no_detail", - new Object[] { - String.valueOf(inout.getService()), - inout.getEndpoint().getEndpointName() - }); - mLogger.log(Level.SEVERE, msg); - AlertsUtil.getAlerter().warning(msg, - JDBCBindingLifeCycle.SHORT_DISPLAY_NAME, - epb.getDeploymentId(), - AlertsUtil.getServerType(), - AlertsUtil.COMPONENT_TYPE_BINDING, - NotificationEvent.OPERATIONAL_STATE_RUNNING, - NotificationEvent.EVENT_TYPE_ALERT, - "JDBCBC-E00721"); - } - /** - // let's see if retry is configured or not - EndpointInfo info = new EndpointInfo(false, - epb.getEndpointName(), - null, - epb.getServiceName(), - null); - RedeliveryConfig retryConfig = mChannel.getServiceQuality(info, RedeliveryConfig.class); - **/ - - RedeliveryStatus retryStatus = Redelivery.getRedeliveryStatus(inout); - if (retryStatus != null && retryStatus.getRemainingRetries() > 0) { - try { - MessageExchangeSupport.notifyOfRedelivery(inout); - } catch (Exception e) { - String groupId = (String)inout.getProperty(CRMP_GROUP_ID); - String messageId = (String)inout.getProperty(CRMP_MESSAGE_ID); - if (mLogger.isLoggable(Level.WARNING)) { - String text = mMessages.getString("JDBCBC-E01036.Failed_to_process_redelivery", new Object[] { groupId, messageId }); - mLogger.log(Level.WARNING, text, e); - AlertsUtil.getAlerter().warning(text, - JDBCBindingLifeCycle.SHORT_DISPLAY_NAME, - epb.getDeploymentId(), - AlertsUtil.getServerType(), - AlertsUtil.COMPONENT_TYPE_BINDING, - NotificationEvent.OPERATIONAL_STATE_RUNNING, - NotificationEvent.EVENT_TYPE_ALERT, - "JDBCBC-E01036"); - } - } - } - - epb.getEndpointStatus().incrementReceivedErrors(); - } else { - - // added for retry support - try { - MessageExchangeSupport.notifyOfReply(inout); - } catch (Exception ex) { - if (mLogger.isLoggable(Level.WARNING)) { - String text = mMessages.getString("JDBCBC-E00759.Exception_during_reply_processing", ex.getLocalizedMessage()); - mLogger.log(Level.WARNING, text, ex); - AlertsUtil.getAlerter().warning(text, - JDBCBindingLifeCycle.SHORT_DISPLAY_NAME, - epb.getDeploymentId(), - AlertsUtil.getServerType(), - AlertsUtil.COMPONENT_TYPE_BINDING, - NotificationEvent.OPERATIONAL_STATE_RUNNING, - NotificationEvent.EVENT_TYPE_ALERT, - "JDBCBC-E00759"); - } - success = false; - } - - try { - Map operationNameToMetaData = (Map) epb.getValueObj(EndpointBean.OPERATION_NAME_TO_META_DATA); - OperationMetaData meta = (OperationMetaData) operationNameToMetaData.get(inout.getOperation().getLocalPart()); - - if (meta == null) { - throw new MessagingException(mMessages.getString("SQLSE_E00621.OMP_oper_NotDefined") - + inout.getOperation()); - } - - final NormalizedMessage inMsg = inout.getInMessage(); - NormalizedMessage outMsg = mExchange.createMessage(); - //boolean success = true; - String statusMessage = ""; - String jndiName = null; - - try { - rs = null; - int rowsUpdated = -1; - - // writeMessage(inMsg, destinationAddress, false); - JDBCOperationInput input = meta.getJDBCSql(); - final String sql = input.getSql(); - jndiName = epb.getValue(EndpointBean.JDBC_DATABASE_JNDI_NAME); - - connection = getDatabaseConnection(epb); - if (isSelectStatement(sql)) { - rs = executeOutboundSQLSelect(inMsg, epb, meta, connection); - - if (rs != null) { - statusMessage = "Success : ResultSet returned "; - } - - final JDBCNormalizer normalizer = new JDBCNormalizer(); - outMsg = normalizer.normalizeSelect(rs, inout, meta); - inout.setOutMessage(outMsg); - } else { - if (meta.getJDBCOperationInput().getOperationType().equalsIgnoreCase(JDBCOperations.OPERATION_TYPE_EXECUTE.toString())) { - cs = executeOutboundProc(inMsg, epb, meta, connection); - final JDBCNormalizer normalizer = new JDBCNormalizer(); - normalizer.setOutParamIndex(outParamIndex); - normalizer.setOutParamNames(outParamNames); - normalizer.setOutParamTypes(outParamTypes); - outMsg = normalizer.normalizeProcedure(cs, inout, meta); - } else { - rowsUpdated = executeOutboundSQL(inMsg, epb, meta, connection); - statusMessage = "Success : " + rowsUpdated + " are updated ."; - - final JDBCNormalizer normalizer = new JDBCNormalizer(); - outMsg = normalizer.normalize(rowsUpdated, inout, meta); - } - inout.setOutMessage(outMsg); - } - } catch (final Exception ex) { - mLogger.log(Level.SEVERE, - mMessages.getString("SQLSE_E00622.OMP_Failed_writing"), ex); - // should this populate a full fault instead? - // inout.setError(ex); - statusMessage = "Failed " + ex.getMessage(); - success = false; - inout.setError(ex); - - } - - mChannel.send(inout); - - // Added for retry support - updateTallySends(epb, success); - if (success) { - epb.getEndpointStatus().incrementSentDones(); - } else { - epb.getEndpointStatus().incrementSentErrors(); - } - } catch (final Exception ex) { - mLogger.log(Level.SEVERE, - mMessages.getString("SQLSE_E00623.OMP_Failed_inout"), ex); - } finally { - try { - if (rs != null) { - rs.close(); - } - if (cs != null) { - cs.close(); - } - if (connection != null) { - connection.close(); - } - } catch (SQLException sqlexception) { - mLogger.log(Level.SEVERE, - mMessages.getString("SQLSE_E00628.OMP_Cleanup_Failure"), - sqlexception); - } - } - } - } - - private void processInOutXA(final InOut inout, final EndpointBean epb) { - ResultSet rs = null; - XAConnection xaconnection = null; - CallableStatement cs = null; - Transaction transaction = null; - - boolean success = true; - - if (inout.getStatus() == ExchangeStatus.DONE) { - - // added for retry support - updateTallyReceivedReplies(epb); - // remove the redelivery listener handler - no retry needed. - MessageExchangeSupport.removeRedeliveryListener(inout.getExchangeId()); - - epb.getEndpointStatus().incrementReceivedDones(); - } else if (inout.getStatus() == ExchangeStatus.ERROR) { - - // added for retry support - - updateTallyReceives(epb, false); - - // send alerts - String errorMsg = inout.getError().getMessage(); - if (errorMsg != null) { - String msg = mMessages.getString("JDBCBC-E00720.Message_exchange_error", - new Object[] { - String.valueOf(inout.getService()), - inout.getEndpoint().getEndpointName(), - errorMsg - }); - mLogger.log(Level.SEVERE, msg); - AlertsUtil.getAlerter().warning(msg, - JDBCBindingLifeCycle.SHORT_DISPLAY_NAME, - epb.getDeploymentId(), - AlertsUtil.getServerType(), - AlertsUtil.COMPONENT_TYPE_BINDING, - NotificationEvent.OPERATIONAL_STATE_RUNNING, - NotificationEvent.EVENT_TYPE_ALERT, - "JDBCBC-E00720"); - } else { - String msg = mMessages.getString("JDBCBC-E00721.Message_exchange_error_no_detail", - new Object[] { - String.valueOf(inout.getService()), - inout.getEndpoint().getEndpointName() - }); - mLogger.log(Level.SEVERE, msg); - AlertsUtil.getAlerter().warning(msg, - JDBCBindingLifeCycle.SHORT_DISPLAY_NAME, - epb.getDeploymentId(), - AlertsUtil.getServerType(), - AlertsUtil.COMPONENT_TYPE_BINDING, - NotificationEvent.OPERATIONAL_STATE_RUNNING, - NotificationEvent.EVENT_TYPE_ALERT, - "JDBCBC-E00721"); - } - /** - // let's see if retry is configured or not - EndpointInfo info = new EndpointInfo(false, - epb.getEndpointName(), - null, - epb.getServiceName(), - null); - RedeliveryConfig retryConfig = mChannel.getServiceQuality(info, RedeliveryConfig.class); - **/ - - RedeliveryStatus retryStatus = Redelivery.getRedeliveryStatus(inout); - if (retryStatus != null && retryStatus.getRemainingRetries() > 0) { - try { - MessageExchangeSupport.notifyOfRedelivery(inout); - } catch (Exception e) { - String groupId = (String)inout.getProperty(CRMP_GROUP_ID); - String messageId = (String)inout.getProperty(CRMP_MESSAGE_ID); - if (mLogger.isLoggable(Level.WARNING)) { - String text = mMessages.getString("JDBCBC-E01036.Failed_to_process_redelivery", new Object[] { groupId, messageId }); - mLogger.log(Level.WARNING, text, e); - AlertsUtil.getAlerter().warning(text, - JDBCBindingLifeCycle.SHORT_DISPLAY_NAME, - epb.getDeploymentId(), - AlertsUtil.getServerType(), - AlertsUtil.COMPONENT_TYPE_BINDING, - NotificationEvent.OPERATIONAL_STATE_RUNNING, - NotificationEvent.EVENT_TYPE_ALERT, - "JDBCBC-E01036"); - } - } - } - - epb.getEndpointStatus().incrementReceivedErrors(); - } else { - - // added for retry support - try { - MessageExchangeSupport.notifyOfReply(inout); - } catch (Exception ex) { - if (mLogger.isLoggable(Level.WARNING)) { - String text = mMessages.getString("JDBCBC-E00759.Exception_during_reply_processing", ex.getLocalizedMessage()); - mLogger.log(Level.WARNING, text, ex); - AlertsUtil.getAlerter().warning(text, - JDBCBindingLifeCycle.SHORT_DISPLAY_NAME, - epb.getDeploymentId(), - AlertsUtil.getServerType(), - AlertsUtil.COMPONENT_TYPE_BINDING, - NotificationEvent.OPERATIONAL_STATE_RUNNING, - NotificationEvent.EVENT_TYPE_ALERT, - "JDBCBC-E00759"); - } - success = false; - } - - try { - Map operationNameToMetaData = (Map) epb.getValueObj(EndpointBean.OPERATION_NAME_TO_META_DATA); - OperationMetaData meta = (OperationMetaData) operationNameToMetaData.get(inout.getOperation().getLocalPart()); - - if (meta == null) { - throw new MessagingException(mMessages.getString("SQLSE_E00621.OMP_oper_NotDefined") - + inout.getOperation()); - } - - final NormalizedMessage inMsg = inout.getInMessage(); - NormalizedMessage outMsg = mExchange.createMessage(); - - String statusMessage = ""; - String jndiName = null; - - try { - rs = null; - int rowsUpdated = -1; - - // writeMessage(inMsg, destinationAddress, false); - JDBCOperationInput input = meta.getJDBCSql(); - final String sql = input.getSql(); - jndiName = epb.getValue(EndpointBean.JDBC_DATABASE_JNDI_NAME); - if (inout.isTransacted()) { - // Removing manual enlistment. Moving to automatic resource enlistment - // mtxHelper.handleOutbound(mExchange); - // enlistResource(epb); - transaction = (Transaction) inout.getProperty(MessageExchange.JTA_TRANSACTION_PROPERTY_NAME); - } - if (transaction != null) { - resumeThreadTx(transaction); - } - - xaconnection = getXADatabaseConnection(epb); - XAResource xaresource = xaconnection.getXAResource(); - transaction.enlistResource(xaresource); - connection = xaconnection.getConnection(); - if (isSelectStatement(sql)) { - rs = executeOutboundSQLSelect(inMsg, epb, meta, connection); - - if (rs != null) { - statusMessage = "Success : ResultSet returned "; - } - - final JDBCNormalizer normalizer = new JDBCNormalizer(); - outMsg = normalizer.normalizeSelect(rs, inout, meta); - inout.setOutMessage(outMsg); - } else { - if (meta.getJDBCOperationInput().getOperationType().equalsIgnoreCase(JDBCOperations.OPERATION_TYPE_EXECUTE.toString())) { - cs = executeOutboundProc(inMsg, epb, meta, connection); - final JDBCNormalizer normalizer = new JDBCNormalizer(); - outMsg = normalizer.normalizeProcedure(cs, inout, meta); - } else { - rowsUpdated = executeOutboundSQL(inMsg, epb, meta, connection); - statusMessage = "Success : " + rowsUpdated + " are updated ."; - - final JDBCNormalizer normalizer = new JDBCNormalizer(); - outMsg = normalizer.normalize(rowsUpdated, inout, meta); - } - inout.setOutMessage(outMsg); - - - } - } catch (final Exception ex) { - mLogger.log(Level.WARNING, - OutboundMessageProcessor.mMessages.getString("SQLSE_E00622.OMP_Failed_writing"), ex); - // should this populate a full fault instead? - // inout.setError(ex); - statusMessage = "Failed " + ex.getMessage(); - success = false; - inout.setError(ex); - if (transaction != null) { - rollbackThreadTx(mExchange); - } - } - if (transaction != null) { - getTransactionManager().suspend(); - } - mChannel.send(inout); - - // Added for retry support - updateTallySends(epb, success); - - - if (success) { - epb.getEndpointStatus().incrementSentDones(); - } else { - epb.getEndpointStatus().incrementSentErrors(); - } - } catch (final Exception ex) { - mLogger.log(Level.WARNING, - OutboundMessageProcessor.mMessages.getString("SQLSE_E00623.OMP_Failed_inout"), ex); - } finally { - try { - if (rs != null) { - rs.close(); - } - if (cs != null) { - cs.close(); - } - if (connection != null) { - connection.close(); - } - } catch (SQLException sqlexception) { - mLogger.log(Level.SEVERE, - mMessages.getString("SQLSE_E00628.OMP_Cleanup_Failure"), sqlexception); - } - } - } - } - - /** - * @param inonly - * @param epb - */ - protected void processInOnly(final InOnly inonly, final EndpointBean epb) { - Connection connection = null; - CallableStatement cs = null; - Transaction transaction = null; - boolean success = true; - - if (inonly.getStatus() == ExchangeStatus.DONE) { - - // added for retry support - updateTallyReceivedReplies(epb); - // remove the redelivery listener handler - no retry needed. - MessageExchangeSupport.removeRedeliveryListener(inonly.getExchangeId()); - - epb.getEndpointStatus().incrementReceivedDones(); - } else if (inonly.getStatus() == ExchangeStatus.ERROR) { - - // added for retry support - - updateTallyReceives(epb, false); - - // send alerts - String errorMsg = inonly.getError().getMessage(); - if (errorMsg != null) { - String msg = mMessages.getString("JDBCBC-E00720.Message_exchange_error", - new Object[] { - String.valueOf(inonly.getService()), - inonly.getEndpoint().getEndpointName(), - errorMsg - }); - mLogger.log(Level.SEVERE, msg); - AlertsUtil.getAlerter().warning(msg, - JDBCBindingLifeCycle.SHORT_DISPLAY_NAME, - epb.getDeploymentId(), - AlertsUtil.getServerType(), - AlertsUtil.COMPONENT_TYPE_BINDING, - NotificationEvent.OPERATIONAL_STATE_RUNNING, - NotificationEvent.EVENT_TYPE_ALERT, - "JDBCBC-E00720"); - } else { - String msg = mMessages.getString("JDBCBC-E00721.Message_exchange_error_no_detail", - new Object[] { - String.valueOf(inonly.getService()), - inonly.getEndpoint().getEndpointName() - }); - mLogger.log(Level.SEVERE, msg); - AlertsUtil.getAlerter().warning(msg, - JDBCBindingLifeCycle.SHORT_DISPLAY_NAME, - epb.getDeploymentId(), - AlertsUtil.getServerType(), - AlertsUtil.COMPONENT_TYPE_BINDING, - NotificationEvent.OPERATIONAL_STATE_RUNNING, - NotificationEvent.EVENT_TYPE_ALERT, - "JDBCBC-E00721"); - } - /** - // let's see if retry is configured or not - EndpointInfo info = new EndpointInfo(false, - epb.getEndpointName(), - null, - epb.getServiceName(), - null); - RedeliveryConfig retryConfig = mChannel.getServiceQuality(info, RedeliveryConfig.class); - **/ - - RedeliveryStatus retryStatus = Redelivery.getRedeliveryStatus(inonly); - if (retryStatus != null && retryStatus.getRemainingRetries() > 0) { - try { - MessageExchangeSupport.notifyOfRedelivery(inonly); - } catch (Exception e) { - String groupId = (String)inonly.getProperty(CRMP_GROUP_ID); - String messageId = (String)inonly.getProperty(CRMP_MESSAGE_ID); - if (mLogger.isLoggable(Level.WARNING)) { - String text = mMessages.getString("JDBCBC-E01036.Failed_to_process_redelivery", new Object[] { groupId, messageId }); - mLogger.log(Level.WARNING, text, e); - AlertsUtil.getAlerter().warning(text, - JDBCBindingLifeCycle.SHORT_DISPLAY_NAME, - epb.getDeploymentId(), - AlertsUtil.getServerType(), - AlertsUtil.COMPONENT_TYPE_BINDING, - NotificationEvent.OPERATIONAL_STATE_RUNNING, - NotificationEvent.EVENT_TYPE_ALERT, - "JDBCBC-E01036"); - } - } - } - - epb.getEndpointStatus().incrementReceivedErrors(); - } - - // added for retry support - try { - MessageExchangeSupport.notifyOfReply(inonly); - } catch (Exception ex) { - if (mLogger.isLoggable(Level.WARNING)) { - String text = mMessages.getString("JDBCBC-E00759.Exception_during_reply_processing", ex.getLocalizedMessage()); - mLogger.log(Level.WARNING, text, ex); - AlertsUtil.getAlerter().warning(text, - JDBCBindingLifeCycle.SHORT_DISPLAY_NAME, - epb.getDeploymentId(), - AlertsUtil.getServerType(), - AlertsUtil.COMPONENT_TYPE_BINDING, - NotificationEvent.OPERATIONAL_STATE_RUNNING, - NotificationEvent.EVENT_TYPE_ALERT, - "JDBCBC-E00759"); - } - success = false; - } - - try { - epb.getEndpointStatus().incrementReceivedRequests(); - - final NormalizedMessage inMsg = inonly.getInMessage(); - final Map operationNameToMetaData = (Map) epb.getValueObj(EndpointBean.OPERATION_NAME_TO_META_DATA); - final OperationMetaData meta = (OperationMetaData) operationNameToMetaData.get(inonly.getOperation().getLocalPart()); - String jndiName = null; - - if (meta == null) { - throw new MessagingException(OutboundMessageProcessor.mMessages.getString("SQLSE_E00621.OMP_oper_NotDefined") - + inonly.getOperation()); - } - - - jndiName = epb.getValue(EndpointBean.JDBC_DATABASE_JNDI_NAME); - - if (inonly.isTransacted()) { - // Removing manual enlistment. Moving to automatic resource enlistment - // mtxHelper.handleOutbound(mExchange); - // enlistResource(epb); - transaction = (Transaction) inonly.getProperty(MessageExchange.JTA_TRANSACTION_PROPERTY_NAME); - } - - try { - if (transaction != null) { - getTransactionManager().resume(transaction); - } - connection = getDatabaseConnection(epb); - if(transaction != null) { - connection.setAutoCommit(false); - } - // writeMessage(inMsg, destinationAddress, false); - if (meta.getJDBCOperationInput().getOperationType().equalsIgnoreCase(JDBCOperations.OPERATION_TYPE_EXECUTE.toString())) { - // executeOutboundProc(inMsg, epb, meta); - // Auto enlistment: pass the transaction retrieved from the Message exchange. - cs = executeOutboundProc(inMsg, epb, meta, connection); - } else { - // executeOutboundSQL(inMsg, epb, meta); - // Auto enlistment: pass the transaction retrieved from the Message exchange. - executeOutboundSQL(inMsg, epb, meta, connection); - } - inonly.setStatus(ExchangeStatus.DONE); - } catch (final Exception ex) { - success = false; - mLogger.log(Level.WARNING, - OutboundMessageProcessor.mMessages.getString("SQLSE_E00622.OMP_Failed_writing"), ex); - inonly.setError(ex); - if (transaction != null) { - transaction.setRollbackOnly(); - } - } finally { - try{ - if (cs != null) { - cs.close(); - } - if (connection != null) { - connection.close(); - } - }catch(SQLException sqlexception){ - mLogger.log(Level.SEVERE, - mMessages.getString("SQLSE_E00628.OMP_Cleanup_Failure"), sqlexception); - } - } - - /* - * if (inonly.isTransacted()) { mtxHelper.handleInbound(mExchange); } - */ - - if (transaction != null) { - getTransactionManager().suspend(); - } - mChannel.send(inonly); - - // Added for retry support - updateTallySends(epb, success); - - if (success) { - epb.getEndpointStatus().incrementSentDones(); - } else { - epb.getEndpointStatus().incrementSentErrors(); - } - } catch (final Exception ex) { - mLogger.log(Level.WARNING, - OutboundMessageProcessor.mMessages.getString("SQLSE_E00624.OMP_Failed_inonly"), ex); - } - } - - - /** - * @param nMsg - * @param eBean - * @param opMetaData - * @return - * @throws MessagingException - */ - protected ResultSet executeOutboundSQLSelect(final NormalizedMessage nMsg, - final EndpointBean eBean, - final OperationMetaData opMetaData, - Connection connection) throws MessagingException { - String sql = null; - ResultSet rs = null; - - try { - sql = opMetaData.getJDBCSql().getSql(); - mLogger.log(Level.INFO, - OutboundMessageProcessor.mMessages.getString("SQLSE_R00625.OMP_Exec_SQL") + sql); - - final PreparedStatement ps = connection.prepareStatement(sql); - - final JDBCDenormalizer denormalizer = new JDBCDenormalizer(); - denormalizer.denormalizeOutbound(nMsg, opMetaData, ps); - rs = ps.executeQuery(); - } - catch (final SQLException ex) { - final String msg = OutboundMessageProcessor.mMessages.getString("SQLSE_E00626.OMP_Failed_Exec_SQL") + sql; - throw new MessagingException(msg, ex); - } catch (final Exception ex) { - final String msg = OutboundMessageProcessor.mMessages.getString("SQLSE_E00626.OMP_Failed_Exec_SQL") + sql; - throw new MessagingException(msg, ex); - } - - return rs; - } - - /** - * @param nMsg - * @param eBean - * @param opMetaData - * @return - * @throws MessagingException - */ - protected int executeOutboundSQL(final NormalizedMessage nMsg, - final EndpointBean eBean, - final OperationMetaData opMetaData, - Connection connection) throws MessagingException { - String sql = null; - int rowsUpdated = -1; - - try { - sql = opMetaData.getJDBCSql().getSql(); - mLogger.log(Level.INFO, - mMessages.getString("SQLSE_R00625.OMP_Exec_SQL") + sql); - - final PreparedStatement ps = connection.prepareStatement(sql); - - final JDBCDenormalizer denormalizer = new JDBCDenormalizer(); - denormalizer.denormalizeOutbound(nMsg, opMetaData, ps); - rowsUpdated = ps.executeUpdate(); - } - catch (final SQLException ex) { - final String msg = mMessages.getString("SQLSE_E00626.OMP_Failed_Exec_SQL") + sql; - throw new MessagingException(msg, ex); - } catch (final Exception ex) { - final String msg = OutboundMessageProcessor.mMessages.getString("SQLSE_E00626.OMP_Failed_Exec_SQL") + sql; - throw new MessagingException(msg, ex); - } - - return rowsUpdated; - } - - /** - * @param nMsg - * @param eBean - * @param opMetaData - * @return - * @throws MessagingException - */ - protected CallableStatement executeOutboundProc(final NormalizedMessage nMsg, - final EndpointBean eBean, - final OperationMetaData opMetaData, - Connection connnection) throws MessagingException { - String sql = null; - int rowsUpdated = -1; - - try { - sql = opMetaData.getJDBCSql().getSql(); - mLogger.log(Level.INFO, - mMessages.getString("SQLSE_R00625.OMP_Exec_SQL") + sql); - - final CallableStatement cs = connnection.prepareCall(sql); - DatabaseMetaData dbmeta = connnection.getMetaData(); - - final JDBCDenormalizer denormalizer = new JDBCDenormalizer(); - if (eBean.getValue(EndpointBean.JDBC_DATABASE_NAME) != null) { - denormalizer.setDatabaseName(eBean.getValue(EndpointBean.JDBC_DATABASE_NAME)); - } - denormalizer.denormalizeOutboundProc(nMsg, opMetaData, dbmeta, cs); - outParamIndex = denormalizer.getOutParamIndex(); - outParamTypes = denormalizer.getOutParamTypes(); - outParamNames = denormalizer.getOutParamNames(); - // rowsUpdated = cs.executeUpdate(); - boolean b = cs.execute(); - return cs; - } - catch (final SQLException ex) { - final String msg = OutboundMessageProcessor.mMessages.getString("SQLSE_R00624.OMP_Failed_Exec_SQL") + sql; - throw new MessagingException(msg, ex); - } catch (final Exception ex) { - final String msg = OutboundMessageProcessor.mMessages.getString("SQLSE_R00624.OMP_Failed_Exec_SQL") + sql; - throw new MessagingException(msg, ex); - } - - // return rowsUpdated; - } - - // resumes the transaction - private void resumeThreadTx(Transaction tx) throws Exception { - if (tx != null) { - ((TransactionManager) mContext.getContext().getTransactionManager()).resume(tx); - mLogger.log(Level.INFO, " ", new Object[] { tx.toString() }); - } - } - - //rolls back the transaction - 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() }); - } - } - } - } - - //commit the transaction - 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.getContext().getNamingContext(); - - return c.lookup(jndiName); - } - - /** - * @param jndiName - * @return - * @throws Exception - */ - private Connection getDatabaseConnection(final String jndiName) throws Exception { - final DataSource ds = (DataSource) getDataSourceFromContext(jndiName); - final Connection con = ds.getConnection(); - - return con; - } - - private Connection getDatabaseConnection(final EndpointBean epbean) throws Exception { - if (epbean.getValue(EndpointBean.JDBC_DATABASE_JNDI_NAME) == null - || epbean.getValue(EndpointBean.JDBC_DATABASE_JNDI_NAME).equals("")) { - final String driverClass = epbean.getValue(EndpointBean.JDBC_DATABASE_DRIVER_CLASS); - final String dbURL = epbean.getValue(EndpointBean.JDBC_DATABASE_URL); - final String user = epbean.getValue(EndpointBean.JDBC_DATABASE_USER); - final String password = epbean.getValue(EndpointBean.JDBC_DATABASE_PASSWORD); - // Thread.currentThread().getContextClassLoader().loadClass(driverClass).newInstance(); - Class.forName(driverClass).newInstance(); - - return DriverManager.getConnection(dbURL, user, password); - } else { - final DataSource ds = (DataSource) getDataSourceFromContext(epbean.getValue(EndpointBean.JDBC_DATABASE_JNDI_NAME)); - final Connection con = ds.getConnection(); - - return con; - } - } - - private XAConnection getXADatabaseConnection(final EndpointBean epbean) throws Exception { - try { - final XADataSource ds = (XADataSource) getDataSourceFromContext(epbean.getValue(EndpointBean.JDBC_DATABASE_JNDI_NAME)); - final XAConnection con = ds.getXAConnection(); - return con; - }catch(Exception e){ - mLogger.log(Level.INFO, "Either the JNDI NAME is NULL or Could not establish connection using JNDI NAME :" + EndpointBean.JDBC_DATABASE_JNDI_NAME); - } - return null; - } - - /** - * @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; - } - - private TransactionManager getTransactionManager() { - return (TransactionManager)mContext.getContext().getTransactionManager(); - } - - private void updateTallyReceivedReplies(EndpointBean e) { - if (e != null) { - EndpointStatus status = e.getEndpointStatus(); - if (status != null) { - status.incrementReceivedReplies(); - } - } - } - - private void updateTallyReceivedRequests(EndpointBean e) { - if (e != null) { - EndpointStatus status = e.getEndpointStatus(); - if (status != null) { - status.incrementReceivedRequests(); - } - } - } - - private void updateTallySentReplies(EndpointBean e) { - if (e != null) { - EndpointStatus status = e.getEndpointStatus(); - if (status != null) { - status.incrementSentReplies(); - } - } - } - - private void updateTallySentRequests(EndpointBean e) { - if (e != null) { - EndpointStatus status = e.getEndpointStatus(); - if (status != null) { - status.incrementSentRequests(); - } - } - } - - private void updateTallyReceives(EndpointBean e, boolean successfulReceive) { - if (e != null) { - EndpointStatus status = e.getEndpointStatus(); - if (status != null) { - if (successfulReceive) { - status.incrementReceivedDones(); - } else { - status.incrementReceivedErrors(); - } - } - } - } - - private void updateTallySends(EndpointBean e, boolean successfulSend) { - if (e != null) { - EndpointStatus status = e.getEndpointStatus(); - if (status != null) { - if (successfulSend) { - status.incrementSentDones(); - } else { - status.incrementSentErrors(); - } - } - } - } - -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/OutboundReceiver.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/OutboundReceiver.java deleted file mode 100755 index 970301e07..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/OutboundReceiver.java +++ /dev/null @@ -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); - } -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/PortMapEntry.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/PortMapEntry.java deleted file mode 100755 index 71e198ac8..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/PortMapEntry.java +++ /dev/null @@ -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; - } -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/RedeliveryListener.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/RedeliveryListener.java deleted file mode 100755 index 1f04d2336..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/RedeliveryListener.java +++ /dev/null @@ -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); -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/ReplyListener.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/ReplyListener.java deleted file mode 100755 index c31a1352c..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/ReplyListener.java +++ /dev/null @@ -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); -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/ReplyListenerImpl.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/ReplyListenerImpl.java deleted file mode 100755 index 75435d5ff..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/ReplyListenerImpl.java +++ /dev/null @@ -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); - } - -} \ No newline at end of file diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/RuntimeConfiguration.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/RuntimeConfiguration.java deleted file mode 100755 index 4dc84bf6b..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/RuntimeConfiguration.java +++ /dev/null @@ -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; - } - -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/RuntimeConfigurationMBean.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/RuntimeConfigurationMBean.java deleted file mode 100755 index add4f7893..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/RuntimeConfigurationMBean.java +++ /dev/null @@ -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; -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/SQLEngineFileEntry.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/SQLEngineFileEntry.java deleted file mode 100755 index adc363a63..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/SQLEngineFileEntry.java +++ /dev/null @@ -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; - } -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/SQLEngineFileReader.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/SQLEngineFileReader.java deleted file mode 100755 index ac997697f..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/SQLEngineFileReader.java +++ /dev/null @@ -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 getFilesRecursively(final File dir, final FileFilter filter) { - final List ret = new ArrayList(); - - 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; - } -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/SQLMapEntry.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/SQLMapEntry.java deleted file mode 100755 index 3c84abe63..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/SQLMapEntry.java +++ /dev/null @@ -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; - } -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/SQLMapEntryTable.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/SQLMapEntryTable.java deleted file mode 100755 index 03a9980d6..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/SQLMapEntryTable.java +++ /dev/null @@ -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 mEntryList; - - public SQLMapEntryTable() { - mEntryList = new ArrayList(); - } - - 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 getEntryListByServiceUnitName(final String serviceUnitName) { - final ArrayList list = new ArrayList(); - - 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 getEntryList() { - return new ArrayList(mEntryList); - } -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/SQLMapReader.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/SQLMapReader.java deleted file mode 100755 index b025c0084..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/SQLMapReader.java +++ /dev/null @@ -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); - } -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/SQLSELifeCycle.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/SQLSELifeCycle.java deleted file mode 100755 index 67ed34d0a..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/SQLSELifeCycle.java +++ /dev/null @@ -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 initializedLifeCycles = new HashMap(); - - // 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 mEndpoints = new HashMap(); - 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; - } - } - } - } - }; - -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/SQLSEPerformanceMeasurement.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/SQLSEPerformanceMeasurement.java deleted file mode 100755 index 231a3b55c..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/SQLSEPerformanceMeasurement.java +++ /dev/null @@ -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(); - } -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/SQLSERuntimeConfiguration.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/SQLSERuntimeConfiguration.java deleted file mode 100755 index 68511e1e2..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/SQLSERuntimeConfiguration.java +++ /dev/null @@ -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; - } - -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/SQLSERuntimeConfigurationMBean.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/SQLSERuntimeConfigurationMBean.java deleted file mode 100755 index af681c34c..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/SQLSERuntimeConfigurationMBean.java +++ /dev/null @@ -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(); -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/SQLSEServiceUnitManager.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/SQLSEServiceUnitManager.java deleted file mode 100755 index 0ac1799fb..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/SQLSEServiceUnitManager.java +++ /dev/null @@ -1,1048 +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] - */ - -/* - * @(#)SQLSEServiceUnitManager.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.FileNotFoundException; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.logging.Level; -import java.util.logging.Logger; -import javax.jbi.component.ComponentContext; -import javax.jbi.component.ServiceUnitManager; -import javax.jbi.management.DeploymentException; -import javax.jbi.messaging.MessagingException; -import javax.jbi.servicedesc.ServiceEndpoint; -import javax.wsdl.BindingOperation; -import javax.wsdl.Definition; -import javax.wsdl.Input; -import javax.wsdl.Operation; -import javax.wsdl.OperationType; -import javax.wsdl.Output; -import javax.wsdl.PortType; -import javax.wsdl.extensions.ExtensibilityElement; -import javax.wsdl.extensions.UnknownExtensibilityElement; -import javax.wsdl.factory.WSDLFactory; -import javax.wsdl.xml.WSDLReader; -import javax.xml.namespace.QName; -import org.apache.xml.resolver.CatalogManager; -import org.apache.xml.resolver.tools.CatalogResolver; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.EntityResolver; -import com.ibm.wsdl.factory.WSDLFactoryImpl; -import com.sun.jbi.eManager.provider.EndpointStatus; -import com.sun.jbi.eManager.provider.StatusProviderHelper; -import com.sun.jbi.eManager.provider.StatusReporting; -import com.sun.jbi.internationalization.Messages; -import com.sun.jbi.jdbcbc.extensions.JDBCExtensionRegistry; -import com.sun.jbi.jdbcbc.extensions.JDBCOperation; -import com.sun.jbi.jdbcbc.extensions.JDBCOperationInput; -import com.sun.jbi.jdbcbc.extensions.JDBCOperationOutput; -import com.sun.jbi.jdbcbc.util.Configuration.PortMap; -import com.sun.jbi.management.descriptor.Provides; -import com.sun.jbi.management.descriptor.SUDescriptorSupport; -import com.sun.jbi.management.message.DefaultJBITaskMessageBuilder; -import com.sun.jbi.management.message.JBITaskMessageBuilder; -import java.util.Arrays; - -// Additional imports for replacing the ibm WSDL factory to Sun extensions -import com.sun.wsdl4j.ext.impl.WSDLFactoryEx; -import com.sun.wsdl4j.ext.impl.WSDLReaderEx; - -// 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; - - -/** - * Used by SQLSE. - * Implements the ServiceUnitManager interface of JBI. - */ -public class SQLSEServiceUnitManager implements ServiceUnitManager { - private static final Messages mMessages = Messages.getMessages(SQLSEServiceUnitManager.class); - private static final Logger mLogger = Messages.getLogger(SQLSEServiceUnitManager.class); - private static final String PARTNER_MYROLE = "myRole"; - private static final String PARTNER_PARTNERROLE = "partnerRole"; - private HashMap mDeployedIds; - private HashMap mDeployedEndpoints; - private JDBCComponentContext mContext; - private DeployHelper mHelper; - private SQLSELifeCycle mLifeCycle; - private SQLMapEntryTable mSQLMapEntryTable; - private final Hashtable mWSDLMap = new Hashtable(); - private SQLEngineFileEntry[] mSQLEngineFileEntries; - - private Map> mEndpointQos; - - /** Creates a new instance of DeployerMBean - * @param context - * @param lifeCycle - * @param sqlmap - */ - /*protected SQLSEServiceUnitManager(final ComponentContext context, - final SQLSELifeCycle lifeCycle, final SQLMapEntryTable sqlmap) { - mContext = context; - mDeployedIds = new HashMap(); - mDeployedEndpoints = new HashMap(); - mHelper = new DeployHelper(); - mLifeCycle = lifeCycle; - mSQLMapEntryTable = sqlmap; - }*/ - - protected SQLSEServiceUnitManager(final JDBCComponentContext context, - final SQLSELifeCycle lifeCycle, final SQLMapEntryTable sqlmap) { - mContext = context; - mDeployedIds = new HashMap(); - mDeployedEndpoints = new HashMap(); - mHelper = new DeployHelper(); - mLifeCycle = lifeCycle; - mSQLMapEntryTable = sqlmap; - } - - /** - * Initiate a BC Deployment. - * - * @param suId - - * ID of the ASA being deployed - * Path of the ASA jar file - * @param asaFilePath - * @return - * @throws javax.jbi.management.DeploymentException - */ - //@Override - public String deploy(final String suId, final String asaFilePath) - throws DeploymentException { - String retMsg = null; - final String taskName = "deploy"; - - if (SQLSEServiceUnitManager.mLogger.isLoggable(Level.INFO)) { - SQLSEServiceUnitManager.mLogger.log(Level.INFO, mMessages.getString("SQLSE_R00301.SQLSESUM_DEPLOY_SU"), - new Object[] { suId, asaFilePath }); - } - - retMsg = createSuccessMessage(taskName, mContext.getContext().getComponentName()); - - return retMsg; - } - - //@Override - public void init(final String suId, final String suPath) throws DeploymentException { - if (mLogger.isLoggable(Level.INFO)) { - mLogger.log(Level.INFO, mMessages.getString("SQLSE_R00302.SQLSESUM_INIT_SU"), - new Object[] { suId, suPath }); - } - - // have the throttling configuration loaded for the endpoint thats being Initialized. - DeploymentLookup lookUpUtil = new DeploymentLookup(mContext.getContext()); - mEndpointQos = lookUpUtil.lookupServiceQualities(suPath); - if (mEndpointQos != null && mEndpointQos.size() > 0) { - for (Iterator itor = mEndpointQos.keySet().iterator(); itor.hasNext(); ) { - EndpointInfo endpointInfo = (EndpointInfo) itor.next(); - ServiceQuality[] qos = - (ServiceQuality[])((List)mEndpointQos.get(endpointInfo)).toArray(new ServiceQuality[0]); - mContext.getBindingChannel().addServiceQualityToEndpoint(endpointInfo, qos); - } - } - - try { - // Prepare for start if the deployment hasn't been processed yet. - if (mDeployedIds.get(suId) == null) { - final StatusProviderHelper statusProviderHelper = mLifeCycle.getStatusProviderHelper(); - processDeployment(suId, suPath, statusProviderHelper); - } - - if (mLogger.isLoggable(Level.INFO)) { - mLogger.log(Level.INFO, mMessages.getString("SQLSE_R00303.SQLSESUM_INIT_SU_SUCCESS"), suId); - } - } catch (final DeploymentException ex) { - mLogger.log(Level.SEVERE, mMessages.getString("SQLSE_E00304.SQLSESUM_INIT_SU_FAIL"), ex); - throw ex; - } - } - - /** - * Process a deployment, validating it and preparing to start it.. - * - * @param suId - * the name of the Service Unit being initialized. - * @param path - * the full path to the Service Unit artifact root directory. - * @throws DeploymentException - * if the Service Unit is not deployed, or is in an incorrect - * state. - */ - private void processDeployment(final String suId, final String path, - final StatusProviderHelper statusProviderHelper) throws DeploymentException { - final String taskName = "processDeployment"; - - try { - final File asaDir = new File(path); - final String[] files = asaDir.list(); - String sqlmapfile = null; - String engineFile = null; - - for (final String filename : files) { - if (filename.endsWith("sqlmap.xml")) { - sqlmapfile = asaDir.getAbsolutePath() + File.separator + - filename; - } else if (filename.endsWith("sqlse_engine.xml")) { - engineFile = asaDir.getAbsolutePath() + File.separator + - filename; - } - } - - // process wsdls and place them into wsdl map - mHelper.readAllDefinitions(asaDir, suId, taskName, "SQLSE_Init_2"); - - SQLMapReader.parse(new File(sqlmapfile), mSQLMapEntryTable, suId, - asaDir, mWSDLMap); - mSQLEngineFileEntries = SQLEngineFileReader.parse(asaDir, - new File(engineFile)); - mHelper.deploy(asaDir, suId, mContext.getContext(), path, statusProviderHelper); - - - } catch (final FileNotFoundException ex) { - final String exMsg = createExceptionMessage(mContext.getContext().getComponentName(), - taskName, "FAILED", "SQLSE_PROCESS_2", suId, - "Processing deployment error: " + ex.getMessage(), ex); - mLogger.log(Level.SEVERE,"Deployment failure owing to",ex); - throw new DeploymentException(exMsg); - } catch (final IOException ex) { - final String exMsg = createExceptionMessage(mContext.getContext().getComponentName(), - taskName, "FAILED", "SQLSE_PROCESS_3", suId, - "Processing deployment error: " + ex.getMessage(), ex); - mLogger.log(Level.SEVERE,"Deployment failure owing to",ex); - throw new DeploymentException(exMsg); - } catch (final MessagingException ex) { - final String exMsg = createExceptionMessage(mContext.getContext().getComponentName(), - taskName, "FAILED", "SQLSE_PROCESS_4", suId, - "Processing deployment error: " + ex.getMessage(), ex); - mLogger.log(Level.SEVERE,"Deployment failure owing to",ex); - throw new DeploymentException(exMsg); - } catch (final Exception e) { - final String exMsg = createExceptionMessage(mContext.getContext().getComponentName(), - taskName, "FAILED", "SQLSE_PROCESS_5", suId, - "Processing deployment error: " + e.getMessage(), e); - mLogger.log(Level.SEVERE,"Deployment failure owing to",e); - throw new DeploymentException(exMsg); - } - } - - //@Override - public void start(final String suId) throws DeploymentException { - mLogger.log(Level.INFO, mMessages.getString("SQLSE_R00305.SQLSESUM_SU_START") + suId); - - final List list = mSQLMapEntryTable.getEntryListByServiceUnitName(suId); - - for (int i = 0, I = list.size(); i < I; i++) { - final SQLMapEntry etlMapEntry = (SQLMapEntry) list.get(i); - etlMapEntry.setStarted(true); - } - - mLogger.log(Level.INFO, mMessages.getString("SQLSE_R00306.SQLSESUM_SU_START_SUCCESS"), suId); - } - - //@Override - public void stop(final String suId) throws DeploymentException { - mLogger.log(Level.INFO, mMessages.getString("SQLSE_R00307.SQLSESUM_SU_STOP"), suId); - - final List list = mSQLMapEntryTable.getEntryListByServiceUnitName(suId); - - for (int i = 0, I = list.size(); i < I; i++) { - final SQLMapEntry sqlMapEntry = (SQLMapEntry) list.get(i); - sqlMapEntry.setStarted(false); - } - - mLogger.log(Level.INFO, mMessages.getString("SQLSE_R00308.SQLSESUM_SU_STOP_SUCCESS"), suId); - } - - //@Override - public void shutDown(final String suId) throws DeploymentException { - - //qos shoutdown - try { - // remove the QoS attributes for the undeployed endpoints - if (mEndpointQos != null && mEndpointQos.size() > 0) { - for (Iterator it = mEndpointQos.keySet().iterator(); it.hasNext();) { - EndpointInfo endpointInfo = (EndpointInfo) it.next(); - ServiceQuality[] qos = - (ServiceQuality[])((List)mEndpointQos.get(endpointInfo)).toArray(new ServiceQuality[0]); - mContext.getBindingChannel().removeServiceQualityFromEndpoint(endpointInfo, qos); - } - } - }catch(Exception e){ - final String extMsg = mMessages.getString("SQLSE_E00310.SQLSESUM_SU_NOT_DEPLOYED"); - throw new DeploymentException(extMsg); - } - final String taskName = "init"; - SQLSEServiceUnitManager.mLogger.log(Level.INFO, mMessages.getString("SQLSE_R00309.SQLSESUM_SU_SHUTDOWN"), suId); - - if (!mDeployedIds.containsKey((suId))) { - final String extMsg = mMessages.getString("SQLSE_E00310.SQLSESUM_SU_NOT_DEPLOYED"); - throw new DeploymentException(extMsg); - } - - try { - // Remove suId from lookup table - mDeployedIds.remove(suId); - - final StatusReporting reporting = mLifeCycle.getStatusProviderHelper() - .getStatusReporter(); - final List list = mSQLMapEntryTable.getEntryListByServiceUnitName(suId); - - for (int i = 0, I = list.size(); i < I; i++) { - final SQLMapEntry etlMapEntry = (SQLMapEntry) list.get(i); - final ServiceEndpoint serviceEndpoint = etlMapEntry.getServiceEndpoint(); - - if (serviceEndpoint != null) { - mContext.getContext().deactivateEndpoint(serviceEndpoint); - } - - final String endpointStatusId = etlMapEntry.getEndpointStatusId(); - - if (endpointStatusId != null) { - reporting.removeProvisioningEndpoints(new String[] { - endpointStatusId - }); - } - - final String outEndpointStatusId = etlMapEntry.getOutEndpointStatusId(); - - if (outEndpointStatusId != null) { - reporting.removeConsumingEndpoints(new String[] { - outEndpointStatusId - }); - } - - mSQLMapEntryTable.removeEntry(etlMapEntry); - } - } catch (final Exception e) { - final String extMsg = createExceptionMessage(mContext.getContext().getComponentName(), - taskName, "FAILED", "SQLSeSum_ShutDown_2", suId, - "Service Unit shutDown error", e); - throw new DeploymentException(extMsg, e); - } - - SQLSEServiceUnitManager.mLogger.log(Level.INFO, "SQLSESUM_SU_SHUTDOWN_SUCCESS", suId); - } - - /** - * Cancel a Service Deployment. If the deployment is in use (has - * dependencies), then this operation may fail. - * - * @param name - - * name of the service unit - * @param root - - * root of the service unit - * @return - * @throws javax.jbi.management.DeploymentException - */ - //@Override - public String undeploy(final String name, final String root) throws DeploymentException { - String retMsg = null; - final String taskName = "undeploy"; - - if (SQLSEServiceUnitManager.mLogger.isLoggable(Level.FINE)) { - SQLSEServiceUnitManager.mLogger.log(Level.FINE, "SQLSESUM_SU_UNDEPLOY", - new Object[] { name, root }); - } - - retMsg = createSuccessMessage(taskName, mContext.getContext().getComponentName()); - - return retMsg; - } - - /** - * Determine the message exchange pattern. For handling 1.1 wsdls, map - * transmission primitives to the closest message exchange pattern, taking - * into account the endpoint direction direction inbound: request-response - * and solicit-response -> in-out one-way and notification -> in-only - * direction outbound: request-response and solicit-response -> out-in - * one-way and notification -> out-only - * - * @param pm - * the endpoint configuration from the portmap - * the binding operation definition from the wsdl - * @return the message exchange pattern, null if no mapping could be - * determined. - */ - private String determineMEP(final PortMap pm, final BindingOperation bo) { - String mep = null; - final OperationType type = bo.getOperation().getStyle(); - - if (pm.getDirection().equals(EndpointBean.ENDPOINT_TYPE_INBOUND)) { - if (type.equals(OperationType.REQUEST_RESPONSE) || - type.equals(OperationType.SOLICIT_RESPONSE)) { - mep = "inout"; - } else if (type.equals(OperationType.ONE_WAY) || - type.equals(OperationType.NOTIFICATION)) { - mep = "inonly"; - } - } else { - if (type.equals(OperationType.REQUEST_RESPONSE) || - type.equals(OperationType.SOLICIT_RESPONSE)) { - mep = "outin"; - } else if (type.equals(OperationType.ONE_WAY) || - type.equals(OperationType.NOTIFICATION)) { - mep = "outonly"; - } - } - - return mep; - } - - /** - * Keep track of the running status of each endpoint. This allows for quick - * look-up of the state and provides for extensibility where an individual - * endpoint could be controlled rather than the whole SU. - */ - private void setEndpointsStatus(final EndpointBean[] endpoints, final String status) { - if (endpoints != null) { - for (EndpointBean element : endpoints) { - element.setValue(EndpointBean.STATUS, status); - } - } - } - - private String createSuccessMessage(final String taskName, final String componentName) { - final JBITaskMessageBuilder msgBuilder = new DefaultJBITaskMessageBuilder(); - msgBuilder.setComponentName(componentName); - - final String retMsg = msgBuilder.createSuccessMessage(taskName); - - return retMsg; - } - - private String createExceptionMessage(final String componentName, - final String taskName, final String status, final String locToken, final String locParam, - final String locMessage, final Throwable exObj) { - final JBITaskMessageBuilder msgBuilder = new DefaultJBITaskMessageBuilder(); - msgBuilder.setComponentName(componentName); - - final String retMsg = msgBuilder.createExceptionMessage(taskName, locToken, - locMessage, locParam, exObj); - - return retMsg; - } - - private class DeployHelper { - /** - * List all wsdl files in the currentDir and below - */ - private List listWSDLFiles(final File currentDir) { - final List cumulativeResults = new ArrayList(); - final File[] filesInCurrentDir = currentDir.listFiles(); - - for (File element : filesInCurrentDir) { - if (element.isFile()) { - if (element.getName().toLowerCase() - .endsWith(".wsdl")) { - cumulativeResults.add(element); - } - } else if (element.isDirectory()) { - final List wsdlsInSubDirectories = listWSDLFiles(element); - cumulativeResults.addAll(wsdlsInSubDirectories); - } - } - - return cumulativeResults; - } - - private Definition readWsdl(final File f, final EntityResolver resolver) - throws javax.wsdl.WSDLException { - /*final WSDLFactory wsdlFactory = WSDLFactory.newInstance(); - final WSDLReader reader = ((WSDLFactoryImpl) wsdlFactory).newWSDLReader(resolver); - reader.setExtensionRegistry(new JDBCExtensionRegistry()); - - final Definition def = reader.readWSDL(f.getAbsolutePath()); - */ - - // above default Implementation changed with current sun extension - final WSDLFactoryEx wsdlFactory = new WSDLFactoryEx(); - WSDLReaderEx reader = wsdlFactory.newWSDLReaderEx(); - reader.setEntityResolver(resolver); - reader.setExtensionRegistry(new JDBCExtensionRegistry()); - final Definition def = reader.readWSDL(f.getAbsolutePath()); - return def; - } - - private QName getWsdlMapKey(final Definition def) { - QName key = null; - final Iterator iterator = def.getPortTypes().keySet().iterator(); - - while (iterator.hasNext()) { - final QName element = (QName) iterator.next(); - final PortType pt = def.getPortType(element); - key = pt.getQName(); - - break; - } - - return key; - } - - private PortType[] getPortTypes(final Definition def, final String serviceName, - final String endpointName) { - final List extensibilityElems = def.getExtensibilityElements(); - final Iterator iter = extensibilityElems.iterator(); - PortType portType = null; - final PortType[] portTypes = new PortType[def.getPortTypes().size()]; - UnknownExtensibilityElement unknownElem = null; - Element elem = null; - int numPortTypes = 0; - - while (iter.hasNext()) { - final ExtensibilityElement exElem = (ExtensibilityElement) iter.next(); - final QName elemType = exElem.getElementType(); - - if ((elemType != null) && (elemType.getLocalPart() != null) && - (exElem.getElementType().getLocalPart() - .equals("partnerLinkType"))) { - if (exElem instanceof UnknownExtensibilityElement) { - unknownElem = (UnknownExtensibilityElement) exElem; - elem = unknownElem.getElement(); - } - - if (elem != null) { - final NodeList list = elem.getElementsByTagNameNS("http://docs.oasis-open.org/wsbpel/2.0/plnktype", - "role"); - - for (int i = 0; i < list.getLength(); i++) { - final Node n = list.item(i); - final Node partnerLinkNode = n.getAttributes() - .getNamedItem("name"); - - if (((n != null) && (partnerLinkNode != null)) && - (partnerLinkNode.getNodeValue() - .equals(endpointName))) { - final Node portTypeNode = n.getAttributes() - .getNamedItem("portType"); - final String portTypeValue = portTypeNode.getNodeValue(); - String portTypePrefix = ""; - String portTypeLocalPart = ""; - - if (portTypeValue != null) { - int prefixIndex = -1; - prefixIndex = portTypeNode.getNodeValue() - .indexOf(":"); - portTypePrefix = portTypeValue.substring(0, - prefixIndex); - portTypeLocalPart = portTypeValue.substring(prefixIndex + - 1, portTypeValue.length()); - } - - final QName qname = new QName(def.getNamespace( - portTypePrefix), portTypeLocalPart); - portType = def.getPortType(qname); - portTypes[numPortTypes++] = portType; - } - } - } - } - } - - return portTypes; - } - - private Operation getOperation(final Definition def, final String portTypeName, - final String operationName) { - Operation operation = null; - final PortType pType = def.getPortType(QName.valueOf(portTypeName)); - - if (pType != null) { - operation = pType.getOperation(operationName, null, null); - } - - return operation; - } - - private JDBCOperation[] getJDBCOperations(final PortType portType) { - final List jdbcOperations = new ArrayList(); - - if (portType != null) { - final List operations = portType.getOperations(); - final Iterator operIter = (operations == null) ? null - : operations.iterator(); - - while ((operIter != null) && operIter.hasNext()) { - operIter.next(); //just move the cursor to the next element. - - final JDBCOperation op = new JDBCOperation(); - jdbcOperations.add(op); - } - } - - return jdbcOperations.toArray(new JDBCOperation[jdbcOperations.size()]); - } - - private JDBCOperationInput getJDBCOperationInput(final Input input, - final String sqlText) { - JDBCOperationInput operationInput = null; - operationInput = new JDBCOperationInput(); - // JDBCOperationInput jsql = new JDBCOperationInput(); - operationInput.setSql(sqlText); - operationInput.setMessage(input.getMessage()); - operationInput.setInputName(input.getName()); - operationInput.setJDBCSql(operationInput); - operationInput.setOperationType(JDBCUtil.getSQLStatementType(sqlText)); - - return operationInput; - } - - private JDBCOperationOutput getJDBCOperationOutput(final Output output) { - JDBCOperationOutput operationOutput = null; - operationOutput = new JDBCOperationOutput(); - operationOutput.setMessage(output.getMessage()); - operationOutput.setName(output.getName()); - operationOutput.setReturnPartName(output.getName() + "Part"); - operationOutput.setElementType(output.getMessage() - .getPart(output.getName() + - "Part").getTypeName()); - - return operationOutput; - } - - private void deploy(final File asaDir, final String id, - final ComponentContext compContext, final String suPath, - final StatusProviderHelper statusProviderHelper) - throws IOException, DeploymentException, - javax.jbi.messaging.MessagingException { - try { - // process wsdls and place them into wsdl map - final SUDescriptorSupport sud = new SUDescriptorSupport(suPath); - - EndpointIdentifier[] svcs = sud.getServices(); - - final Iterator portmaps = mHelper.parseSUD(sud); - final ArrayList endPointArr = new ArrayList(); - - // bind portmap entry and sql entry using partnerLink - while (portmaps.hasNext()) { - final PortMapEntry entry = (PortMapEntry) portmaps.next(); - final QName serviceName = entry.getServiceName(); - final QName partnerLink = entry.getPartnerLink(); - final QName endpoint = entry.getEndPoint(); - - if (entry.getRole().equalsIgnoreCase(SQLSEServiceUnitManager.PARTNER_MYROLE)) { - final List list = mSQLMapEntryTable.getEntryList(); - - for (int i = 0, I = list.size(); i < I; i++) { - final SQLMapEntry sqlMapEntry = (SQLMapEntry) list.get(i); - final QName sqlPartnerLink = sqlMapEntry.getPartnerLink(); - - if (partnerLink.equals(sqlPartnerLink)) { - final ServiceEndpoint serviceEndpoint = mContext.getContext().activateEndpoint(serviceName, - endpoint.getLocalPart()); - sqlMapEntry.setService(serviceName); - sqlMapEntry.setServiceEndpoint(serviceEndpoint); - - final StatusReporting reporting = statusProviderHelper.getStatusReporter(); - final String statusId = statusProviderHelper.createProvisioningEndpointIdentifier(serviceName, - endpoint.getLocalPart()); - reporting.addProvisioningEndpoint(statusId); - - final EndpointStatus endpointStatus = reporting.getEndpointStatus(statusId); - sqlMapEntry.setEndpointStatus(statusId, - endpointStatus); - - SQLSEServiceUnitManager.mLogger.log(Level.INFO, - "Activated wsdl (" + - sqlMapEntry.getWSDLFileName() + ", " + - sqlMapEntry.getPortType() + ", " + - sqlMapEntry.getOperation() + - ") inout service: " + serviceName); - - final EndpointBean epBean = createEndPointBean(sqlMapEntry,svcs); - endPointArr.add(epBean); - } - } - - continue; - } - - if (entry.getRole().equalsIgnoreCase(SQLSEServiceUnitManager.PARTNER_PARTNERROLE)) { - final List list = mSQLMapEntryTable.getEntryList(); - - for (int i = 0, I = list.size(); i < I; i++) { - final SQLMapEntry sqlMapEntry = (SQLMapEntry) list.get(i); - final QName sqlOutPartnerLink = sqlMapEntry.getOutPartnerLink(); // sqlOutPartnerLink maybe null - - if (partnerLink.equals(sqlOutPartnerLink)) { - sqlMapEntry.setOutService(serviceName); - - final StatusReporting reporting = statusProviderHelper.getStatusReporter(); - final String statusId = statusProviderHelper.createConsumingEndpointIdentifier(serviceName, - endpoint.getLocalPart()); - reporting.addConsumingEndpoint(statusId); - - final EndpointStatus outEndpointStatus = reporting.getEndpointStatus(statusId); - sqlMapEntry.setOutEndpointStatus(statusId, - outEndpointStatus); - - SQLSEServiceUnitManager.mLogger.log(Level.INFO, - "Set outbound service (" + serviceName + - "," + sqlMapEntry.getWSDLFileName() + ", " + - sqlMapEntry.getOutPortType() + ", " + - sqlMapEntry.getOutOperation() + ")"); - - final EndpointBean epBean = createEndPointBean(sqlMapEntry, svcs); - endPointArr.add(epBean); - } - } - - continue; - } - } - - // Add suId to lookup table - mDeployedIds.put(id, asaDir); - - final EndpointBean[] epbArray = new EndpointBean[endPointArr.size()]; - - for (int j = 0; j < endPointArr.size(); j++) { - epbArray[j] = endPointArr.get(j); - } - - mDeployedEndpoints.put(id, epbArray); - mLifeCycle.activateEndpoints(epbArray); - } catch (final Exception e) { - e.printStackTrace(); - } - } - - private EndpointBean createEndPointBean(final SQLMapEntry sqlMapEntry,EndpointIdentifier[] svcs) - throws DeploymentException { - // create endpoint bean for each operation - final EndpointBean bcEndpoint = new EndpointBean(); - final String serviceName = sqlMapEntry.getServiceEndpoint() - .getServiceName().toString(); - final String endPointName = sqlMapEntry.getServiceEndpoint() - .getEndpointName(); - final SQLEngineFileEntry engineEntry = SQLEngineFileReader.findSQLEngineFileEntry(mSQLEngineFileEntries, - sqlMapEntry.getSQLFileName()); - - if (engineEntry == null) { - final String msg = SQLSEServiceUnitManager.mMessages.getString( - "SQLSESUM_FAIL_LOCATE_ENGINE_ENTRY") + - sqlMapEntry.getSQLFileName(); - final String exMsg = createExceptionMessage(mContext.getContext().getComponentName(), - "createEndPointBean", "FAILED", - "SQLSE_DEPLOY_HELPER_7", sqlMapEntry.getSQLFileName(), - msg, null); - throw new DeploymentException(exMsg); - } - - final ArrayList endPoints = new ArrayList(); - - bcEndpoint.setValueObj(EndpointBean.WSDL_FILE, - sqlMapEntry.getWSDLFileName()); - bcEndpoint.setValueObj(EndpointBean.DESCRIPTOR, - sqlMapEntry.getWsdl()); //result - bcEndpoint.setValue(EndpointBean.JDBC_DATABASE_DRIVER_CLASS, - engineEntry.getDriverClass()); - - bcEndpoint.setValue(EndpointBean.JDBC_DATABASE_URL, - engineEntry.getDbURL()); - - bcEndpoint.setValue(EndpointBean.JDBC_DATABASE_NAME, - engineEntry.getDatabaseName()); - - bcEndpoint.setValue(EndpointBean.JDBC_DATABASE_USER, - engineEntry.getUser()); - - bcEndpoint.setValue(EndpointBean.JDBC_DATABASE_PASSWORD, - engineEntry.getPassword()); - - bcEndpoint.setValue(EndpointBean.JDBC_DATABASE_JNDI_NAME, - engineEntry.getJNDI()); - - bcEndpoint.setValue(EndpointBean.JDBC_TRANSACTION_REQUIRED, - engineEntry.getTransactionRequired()); - - - final String endpointNameLocalPart = QName.valueOf(endPointName) - .getLocalPart(); - bcEndpoint.setValue(EndpointBean.ENDPOINT_NAME, - endpointNameLocalPart); - bcEndpoint.setValue(EndpointBean.SERVICE_NAME, serviceName); - bcEndpoint.setValueObj(EndpointBean.FULL_SERVICE_NAME, - sqlMapEntry.getServiceEndpoint().getServiceName()); - bcEndpoint.setValue(EndpointBean.STATUS, - EndpointBean.STATUS_SHUTDOWN); - - bcEndpoint.setValue(EndpointBean.ENDPOINT_TYPE, - EndpointBean.ENDPOINT_TYPE_OUTBOUND); - - final StatusReporting reporting = mLifeCycle.getStatusProviderHelper() - .getStatusReporter(); - final QName serviceNameQ = (QName) bcEndpoint.getValueObj(EndpointBean.FULL_SERVICE_NAME); - final String portName = bcEndpoint.getValue(EndpointBean.ENDPOINT_NAME); - String uniqueName = null; - - uniqueName = mLifeCycle.getStatusProviderHelper() - .createProvisioningEndpointIdentifier(serviceNameQ, - portName); - reporting.addProvisioningEndpoint(uniqueName); - - final EndpointStatus stat = reporting.getEndpointStatus(uniqueName); - bcEndpoint.setEndpointStatus(stat); - - endPoints.add(bcEndpoint); - - final Map operationNameToMetaData = new HashMap(); - final PortType[] portTypes = getPortTypes(sqlMapEntry.getWsdl(), - serviceName, endPointName); - - if ((portTypes == null) || (portTypes.length == 0)) { - final String msg = SQLSEServiceUnitManager.mMessages.getString("SQLSESUM_MISS_PORT_TYPE") + - serviceName; - final String exMsg = createExceptionMessage(mContext.getContext().getComponentName(), - "createEndPointBean", "FAILED", - "SQLSE_DEPLOY_HELPER_12", serviceName, msg, null); - throw new DeploymentException(exMsg); - } - - for (final PortType portType : portTypes) { - final JDBCOperation[] jdbcOperations = getJDBCOperations(portType); - - if ((jdbcOperations == null) || (jdbcOperations.length == 0)) { - final String msg = SQLSEServiceUnitManager.mMessages.getString("SQLSESUM_MISS_OPER") + - serviceName; - final String exMsg = createExceptionMessage(mContext.getContext().getComponentName(), - "createEndPointBean", "FAILED", - "SQLSE_DEPLOY_HELPER_7", serviceName, msg, null); - throw new DeploymentException(exMsg); - } - - for (int operCount = 0; operCount < jdbcOperations.length; - operCount++) { - final JDBCOperation jdbcOperation = jdbcOperations[operCount]; - - // TODO: keep all the info separately in - // endpointbean. - JDBCOperationInput jdbcOperationInput = null; - final Operation op = (Operation) portType.getOperations() - .get(operCount); - String sqlFileName = op.getName() + ".sql"; - final SQLEngineFileEntry engineEntry1 = SQLEngineFileReader.findSQLEngineFileEntry(mSQLEngineFileEntries, - sqlFileName); - - if (op.getInput() != null) { - jdbcOperationInput = getJDBCOperationInput(op.getInput(), - engineEntry1.getSqlText()); - } - - JDBCOperationOutput jdbcOperationOutput = null; - - if (op.getOutput() != null) { - jdbcOperationOutput = getJDBCOperationOutput(op.getOutput()); - } - - JDBCOperationInput jdbcSql = null; - - // if (jdbcOperationInput != null) { - // jdbcSql = jdbcOperationInput.getJDBCSql(); - // } - jdbcSql = jdbcOperationInput.getJDBCSql(); - - final String jdbcSqlStr = jdbcSql.getSql().trim(); - - if (jdbcSqlStr == null) { - final String msg = mMessages.getString("SQLSESUM_MISS_SQL") + - serviceName; - final String exMsg = createExceptionMessage(mContext.getContext().getComponentName(), - "createEndPointBean", "FAILED", - "SQLSE_DEPLOY_HELPER_8", serviceName, msg, null); - throw new DeploymentException(exMsg); - } - - SQLSEServiceUnitManager.mLogger.log(Level.INFO, - "SQLSE portType operation " + - jdbcOperationInput.getOperationType() + " sql " + - jdbcSqlStr); - - // create operation meta data - final OperationMetaData opMetaData = new OperationMetaData(); - opMetaData.setOperation(op); - opMetaData.setJDBCOperation(jdbcOperation); - opMetaData.setJDBCOperationInput(jdbcOperationInput); - opMetaData.setJDBCSql(jdbcSql); - opMetaData.setJDBCOperationOutput(jdbcOperationOutput); - opMetaData.setDefinition(sqlMapEntry.getWsdl()); - operationNameToMetaData.put(op.getName(), opMetaData); - } - } - - bcEndpoint.setValueObj(EndpointBean.OPERATION_NAME_TO_META_DATA, - operationNameToMetaData); - - return bcEndpoint; - } - - private void undeploy(final String asaId, final File asaDir, - final StatusProviderHelper statusProviderHelper) - throws DeploymentException { - final String taskName = "undeploy"; - mLogger.log(Level.INFO, mMessages.getString("SQLSE_R00317.SQLSESUM_UNDEPLOY_SU"), - new Object[] { asaId, asaDir }); - - try { - mDeployedIds.remove(asaId); - - final EndpointBean[] endpoints = mDeployedEndpoints.remove(asaId); - - if (endpoints != null) { - final StatusReporting reporting = statusProviderHelper.getStatusReporter(); - - for (EndpointBean element : endpoints) { - final QName serviceName = (QName) element.getValueObj(EndpointBean.FULL_SERVICE_NAME); - final String portName = element.getValue(EndpointBean.ENDPOINT_NAME); - String uniqueName = null; - - if (element.getValue( - EndpointBean.ENDPOINT_TYPE) - .equals(EndpointBean.ENDPOINT_TYPE_INBOUND)) { - uniqueName = statusProviderHelper.createConsumingEndpointIdentifier(serviceName, - portName); - reporting.removeConsumingEndpoints(new String[] { - uniqueName - }); - } else { - uniqueName = statusProviderHelper.createProvisioningEndpointIdentifier(serviceName, - portName); - reporting.removeProvisioningEndpoints(new String[] { - uniqueName - }); - } - } - } - } catch (final Exception e) { - final String exMsg = createExceptionMessage(mContext.getContext().getComponentName(), - taskName, "FAILED", "SQLSE_UNDEPLOY_HELPER_1", asaId, - "Failed to undeploy " + e.getMessage(), e); - throw new DeploymentException(exMsg, e); - } - } - - private void readAllDefinitions(final File asaDir, final String id, - final String taskName, final String locToken) throws DeploymentException { - final CatalogManager catalogManager = new CatalogManager(); - catalogManager.setCatalogFiles(asaDir.getAbsolutePath() + - File.separator + "xml-catalog.xml"); - catalogManager.setRelativeCatalogs(true); - - final EntityResolver resolver = new CatalogResolver(catalogManager); - - final List wsdls = listWSDLFiles(asaDir); - final File[] wsdlFiles = wsdls.toArray(new File[0]); - - if (wsdlFiles != null) { - for (File element : wsdlFiles) { - try { - final Definition def = readWsdl(element, resolver); - final QName key = getWsdlMapKey(def); - mWSDLMap.put(key, def); - } catch (final Exception e) { - final String msg = SQLSEServiceUnitManager.mMessages.getString( - "SQLSESUM_fail_READ_WSDL") + element + - " : " + e.getMessage(); - final String exMsg = createExceptionMessage(mContext.getContext().getComponentName(), - taskName, "FAILED", locToken, id, msg, e); - throw new DeploymentException(exMsg, e); - } - } - } - } - - private Iterator parseSUD(final SUDescriptorSupport sud) { - LinkedList entries = null; - - final Provides[] pds = sud.getProvides(); - - for (final Provides p : pds) { - final QName service = p.getServiceName(); - final QName endpoint = new QName(p.getEndpointName()); - final String role = "myRole"; - final QName partnerlink = p.getServiceName(); - - if (entries == null) { - entries = new LinkedList(); - } - - final PortMapEntry entry = new PortMapEntry(service, endpoint, role, - partnerlink); - entries.add(entry); - } - - return (entries != null) ? entries.iterator() : null; - } - - - } - - public void getQOSConfigurations (EndpointBean jdbcbcEndpoint, - EndpointIdentifier endpointIdentifier, - Map > 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 qoss = qosMap.get(endpointInfo); - Iterator 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.... - } - } - } - -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/SQLSEStatusProviderMBean.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/SQLSEStatusProviderMBean.java deleted file mode 100755 index 44482ead2..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/SQLSEStatusProviderMBean.java +++ /dev/null @@ -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; - -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/ThrottlingConfigInfo.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/ThrottlingConfigInfo.java deleted file mode 100755 index 64baab596..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/ThrottlingConfigInfo.java +++ /dev/null @@ -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; - -/** - * ThrottlingConfigInfo. - * This class is called by the Throttling 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 BPELProcessManager - * in a Map with the key being the EndpointInfo associated with - * the outbound invoke activity. - * - * @author - * @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 BPITForThrottling - * 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: true or false - */ - public boolean isReady() { - if (mThrottleCount > mProcessingCount) { - return true; - } - return false; - } - - public void getQOSConfigurations (EndpointBean jdbcbcEndpoint, - EndpointIdentifier endpointIdentifier, - Map > 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 qoss = qosMap.get(endpointInfo); - Iterator 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.... - } - } - } -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/bootstrap/InstallerExt.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/bootstrap/InstallerExt.java deleted file mode 100755 index f0abae961..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/bootstrap/InstallerExt.java +++ /dev/null @@ -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; - } -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/bootstrap/InstallerExtMBean.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/bootstrap/InstallerExtMBean.java deleted file mode 100755 index e2570213f..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/bootstrap/InstallerExtMBean.java +++ /dev/null @@ -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); -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/bootstrap/JDBCBindingBootstrap.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/bootstrap/JDBCBindingBootstrap.java deleted file mode 100755 index f23a7bd35..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/bootstrap/JDBCBindingBootstrap.java +++ /dev/null @@ -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); - } - } -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/bootstrap/messages/Bundle.properties b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/bootstrap/messages/Bundle.properties deleted file mode 100755 index 123b559ef..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/bootstrap/messages/Bundle.properties +++ /dev/null @@ -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 \ No newline at end of file diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/extensions/JDBCAddress.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/extensions/JDBCAddress.java deleted file mode 100755 index e7dc845c3..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/extensions/JDBCAddress.java +++ /dev/null @@ -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; - } -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/extensions/JDBCBinding.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/extensions/JDBCBinding.java deleted file mode 100755 index 0d8a63ae4..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/extensions/JDBCBinding.java +++ /dev/null @@ -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; - } -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/extensions/JDBCConstants.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/extensions/JDBCConstants.java deleted file mode 100755 index 73d54586e..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/extensions/JDBCConstants.java +++ /dev/null @@ -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); -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/extensions/JDBCExtSerializer.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/extensions/JDBCExtSerializer.java deleted file mode 100755 index 556e6fa54..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/extensions/JDBCExtSerializer.java +++ /dev/null @@ -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); - } - */ -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/extensions/JDBCExtensionRegistry.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/extensions/JDBCExtensionRegistry.java deleted file mode 100755 index 8b7882ab6..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/extensions/JDBCExtensionRegistry.java +++ /dev/null @@ -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); - } -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/extensions/JDBCOperation.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/extensions/JDBCOperation.java deleted file mode 100755 index 1c9397cac..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/extensions/JDBCOperation.java +++ /dev/null @@ -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; - } -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/extensions/JDBCOperationInput.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/extensions/JDBCOperationInput.java deleted file mode 100755 index 694dbbc7f..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/extensions/JDBCOperationInput.java +++ /dev/null @@ -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; - } -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/extensions/JDBCOperationOutput.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/extensions/JDBCOperationOutput.java deleted file mode 100755 index 64d9b85a6..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/extensions/JDBCOperationOutput.java +++ /dev/null @@ -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; - } -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/extensions/JDBCSql.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/extensions/JDBCSql.java deleted file mode 100755 index 4d0ed28b8..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/extensions/JDBCSql.java +++ /dev/null @@ -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; - // } -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/extensions/messages/Bundle.properties b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/extensions/messages/Bundle.properties deleted file mode 100755 index d26cfb002..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/extensions/messages/Bundle.properties +++ /dev/null @@ -1 +0,0 @@ -JDBCExtSerializer diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/messages/Bundle.properties b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/messages/Bundle.properties deleted file mode 100755 index d0ea62bbc..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/messages/Bundle.properties +++ /dev/null @@ -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. diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/model/metadata/Bundle.properties b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/model/metadata/Bundle.properties deleted file mode 100755 index d72d9121a..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/model/metadata/Bundle.properties +++ /dev/null @@ -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. - - diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/model/metadata/DBMetaData.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/model/metadata/DBMetaData.java deleted file mode 100755 index d4fc8e92f..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/model/metadata/DBMetaData.java +++ /dev/null @@ -1,2326 +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] - */ - -/* - * @(#)DBMetaData.java - * - * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved. - * - * END_HEADER - DO NOT EDIT - */ - -package com.sun.jbi.jdbcbc.model.metadata; - -import com.sun.jbi.internationalization.Messages; -import java.sql.Connection; -import java.sql.DatabaseMetaData; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.ResultSetMetaData; -import java.sql.ParameterMetaData; -import java.sql.SQLException; -import java.sql.Driver; -import java.sql.DriverPropertyInfo; - -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Properties; - -import java.util.StringTokenizer; -import java.util.concurrent.CopyOnWriteArrayList; -import java.util.logging.Level; -import java.util.logging.Logger; -/** - * Extracts database metadata information (table names and constraints, their associated columns, - * etc.) - * - * @author - */ - -class DriverShim implements Driver { - private final Driver driver; - - private DriverShim(final Driver d) { - this.driver = d; - } - - //@Override - public Logger getParentLogger() { - return null; - } - - //@Override - public boolean acceptsURL(final String u) throws SQLException { - return this.driver.acceptsURL(u); - } - - //@Override - public Connection connect(final String u, final Properties p) throws SQLException { - return this.driver.connect(u, p); - } - - //@Override - public int getMajorVersion() { - return this.driver.getMajorVersion(); - } - - //@Override - public int getMinorVersion() { - return this.driver.getMinorVersion(); - } - - //@Override - public DriverPropertyInfo[] getPropertyInfo(final String u, final Properties p) throws SQLException { - return this.driver.getPropertyInfo(u, p); - } - - //@Override - public boolean jdbcCompliant() { - return this.driver.jdbcCompliant(); - } -} - -public final class DBMetaData { - // constants - - /** Index to the name field for results of table/view/procedure searches */ - public static final int NAME = 0; - - /** Index to the catalog field for results of table/view/procedure searches */ - public static final int CATALOG = 1; - - /** Index to the schema field for results of table/view/procedure searches */ - public static final int SCHEMA = 2; - - /** Index to the type field for results of table/view/procedure searches */ - public static final int TYPE = 3; - - /** Database OTD type for DB2 */ - public static final String DB2 = "DB2"; // NOI18N - - /** Database OTD type for Oracle */ - public static final String ORACLE = "ORACLE"; // NOI18N - - /** Database OTD type for SQL Server */ - public static final String SQLSERVER = "SQLSERVER"; // NOI18N - - /** Database OTD type for JDBC */ - public static final String JDBC = "JDBC"; // NOI18N - - /** Database OTD type for VSAM */ - public static final String VSAM_ADABAS_IAM = "LEGACY"; // NOI18N - - /** Database OTD type for JDBC-ODBC */ - public static final String JDBC_ODBC = "JDBC"; // NOI18N - - /** Database type display description for DB2 */ - public static final String DB2_TEXT = "DB2"; // NOI18N - - /** Database type display description for Oracle */ - public static final String ORACLE_TEXT = "ORACLE"; // NOI18N - - /** Database type display description for Derby */ - public static final String DERBY = "DERBY"; // NOI18N - - /** Database type display description for SQL Server */ - public static final String SQLSERVER_TEXT = "SQL SERVER"; // NOI18N - - /** Database type display description for JDBC */ - // public static final String JDBC_TEXT = "JDBC"; // NOI18N - /** Database type display description for VSAM/ADABAS/IAM */ - public static final String VSAM_ADABAS_IAM_TEXT = "VSAM/ADABAS/IAM"; // NOI18N - - /** Database type display description for JDBC-ODBC */ - public static final String JDBC_TEXT = "JDBC-ODBC"; // NOI18N - - /** List of database type display descriptions */ - public static final String[] DBTYPES = { DBMetaData.DB2_TEXT, DBMetaData.ORACLE_TEXT, DBMetaData.SQLSERVER_TEXT, DBMetaData.JDBC_TEXT, DBMetaData.VSAM_ADABAS_IAM_TEXT, - DBMetaData.JDBC_TEXT }; - - /** List of Java types */ - public static final String[] JAVATYPES = { "boolean", "byte", "byte[]", "double", "float", "int", - "java.lang.String", "java.lang.Object", "java.math.BigDecimal", "java.net.URL", "java.sql.Array", - "java.sql.Blob", "java.sql.Clob", "java.sql.Date", "java.sql.Ref", "java.sql.Struct", "java.sql.Time", - "java.sql.Timestamp", "long", "short" }; - - /** List of JDBC SQL types */ - public static final String[] SQLTYPES = { "ARRAY", "BIGINT", "BINARY", "BIT", "BLOB", "BOOLEAN", "CHAR", "CLOB", - "DATALINK", "DATE", "DECIMAL", "DISTINCT", "DOUBLE", "FLOAT", "INTEGER", "JAVA_OBJECT", "LONGVARBINARY", - "LONGVARCHAR", "NULL", "NUMERIC", "OTHER", "REAL", "REF", "SMALLINT", "STRUCT", "TIME", "TIMESTAMP", - "TINYINT", "VARBINARY", "VARCHAR" }; - - public static final int[] SQLTYPE_CODES = { - java.sql.Types.ARRAY, - java.sql.Types.BIGINT, - java.sql.Types.BINARY, - java.sql.Types.BIT, - java.sql.Types.BLOB, - 16, // java.sql.Types.BOOLEAN, - java.sql.Types.CHAR, - java.sql.Types.CLOB, - 70, // case java.sql.Types.DATALINK, - java.sql.Types.DATE, java.sql.Types.DECIMAL, java.sql.Types.DISTINCT, java.sql.Types.DOUBLE, - java.sql.Types.FLOAT, java.sql.Types.INTEGER, java.sql.Types.JAVA_OBJECT, java.sql.Types.LONGVARBINARY, - java.sql.Types.LONGVARCHAR, java.sql.Types.NULL, java.sql.Types.NUMERIC, java.sql.Types.OTHER, - java.sql.Types.REAL, java.sql.Types.REF, java.sql.Types.SMALLINT, java.sql.Types.STRUCT, - java.sql.Types.TIME, java.sql.Types.TIMESTAMP, java.sql.Types.TINYINT, java.sql.Types.VARBINARY, - java.sql.Types.VARCHAR }; - - /** Map SQL type to Java type */ - public static final HashMap SQLTOJAVATYPES = new HashMap(); - static { - DBMetaData.SQLTOJAVATYPES.put("ARRAY", "java.sql.Array"); // NOI18N - DBMetaData.SQLTOJAVATYPES.put("BIGINT", "long"); // NOI18N - DBMetaData.SQLTOJAVATYPES.put("BINARY", "byte[]"); // NOI18N - DBMetaData.SQLTOJAVATYPES.put("BIT", "boolean"); // NOI18N - DBMetaData.SQLTOJAVATYPES.put("BLOB", "java.sql.Blob"); // NOI18N - DBMetaData.SQLTOJAVATYPES.put("BOOLEAN", "boolean"); // NOI18N - DBMetaData.SQLTOJAVATYPES.put("CHAR", "java.lang.String"); // NOI18N - DBMetaData.SQLTOJAVATYPES.put("CLOB", "java.sql.Clob"); // NOI18N - DBMetaData.SQLTOJAVATYPES.put("DATALINK", "java.net.URL"); // NOI18N - DBMetaData.SQLTOJAVATYPES.put("DATE", "java.sql.Date"); // NOI18N - DBMetaData.SQLTOJAVATYPES.put("DECIMAL", "java.math.BigDecimal"); // NOI18N - DBMetaData.SQLTOJAVATYPES.put("DISTINCT", "java.lang.String"); // NOI18N - DBMetaData.SQLTOJAVATYPES.put("DOUBLE", "double"); // NOI18N - DBMetaData.SQLTOJAVATYPES.put("FLOAT", "double"); // NOI18N - DBMetaData.SQLTOJAVATYPES.put("INTEGER", "int"); // NOI18N - DBMetaData.SQLTOJAVATYPES.put("JAVA_OBJECT", "java.lang.Object"); // NOI18N - DBMetaData.SQLTOJAVATYPES.put("LONGVARBINARY", "byte[]"); // NOI18N - DBMetaData.SQLTOJAVATYPES.put("LONGVARCHAR", "java.lang.String"); // NOI18N - DBMetaData.SQLTOJAVATYPES.put("NULL", "java.lang.String"); // NOI18N - DBMetaData.SQLTOJAVATYPES.put("NUMERIC", "java.math.BigDecimal"); // NOI18N - DBMetaData.SQLTOJAVATYPES.put("OTHER", "java.lang.String"); // NOI18N - DBMetaData.SQLTOJAVATYPES.put("REAL", "float"); // NOI18N - DBMetaData.SQLTOJAVATYPES.put("REF", "java.sql.Ref"); // NOI18N - DBMetaData.SQLTOJAVATYPES.put("SMALLINT", "short"); // NOI18N - DBMetaData.SQLTOJAVATYPES.put("STRUCT", "java.sql.Struct"); // NOI18N - DBMetaData.SQLTOJAVATYPES.put("TIME", "java.sql.Time"); // NOI18N - DBMetaData.SQLTOJAVATYPES.put("TIMESTAMP", "java.sql.Timestamp"); // NOI18N - DBMetaData.SQLTOJAVATYPES.put("TINYINT", "byte"); // NOI18N - DBMetaData.SQLTOJAVATYPES.put("VARBINARY", "byte[]"); // NOI18N - DBMetaData.SQLTOJAVATYPES.put("VARCHAR", "java.lang.String"); // NOI18N - // added abey for Procedure ResultSets - DBMetaData.SQLTOJAVATYPES.put("RESULTSET", "java.sql.ResultSet"); // NOI18N - } - - // String used in java.sql.DatabaseMetaData to indicate system tables. - private static final String SYSTEM_TABLE = "SYSTEM TABLE"; // NOI18N - - // String used in java.sql.DatabaseMetaData to indicate system tables. - private static final String TABLE = "TABLE"; // NOI18N - - // String used in java.sql.DatabaseMetaData to indicate system tables. - private static final String VIEW = "VIEW"; // NOI18N - - //private Connection dbconn; // db connection - - //private DatabaseMetaData dbmeta; // db metadata - - //private String errMsg; // error message - - //private boolean checkPrepStmtMetaData = true; // indicates driver does not - - // fully support finding prepared - // statement metadata - //private boolean errPrepStmtParameters = false; // error getting prep. stmt. parameters - - //private boolean errPrepStmtResultSetColumns = false; // error getting prep. stmt. resultset - - // columns - - private static final Logger mLogger = Logger.getLogger(DBMetaData.class.getName()); - private static final Messages mMessages = Messages.getMessages(DBMetaData.class); - - - /** - * Gets the primary keys for a table. - * - * @param newTable Table to get the primary key(s) for - * @throws Exception DOCUMENT ME! - */ - private static final void checkPrimaryKeys(final Table newTable,final Connection connection) throws Exception { - //this.errMsg = ""; - try { - // get the primary keys - final List primaryKeys = getPrimaryKeys(newTable.getCatalog(), newTable.getSchema(), newTable.getName(),connection); - - if (primaryKeys.size() != 0) { - newTable.setPrimaryKeyColumnList(primaryKeys); - - // create a hash set of the keys - final java.util.Set primaryKeysSet = new java.util.HashSet(); - for (int i = 0; i < primaryKeys.size(); i++) { - final KeyColumn key = (KeyColumn) primaryKeys.get(i); - primaryKeysSet.add(key.getColumnName()); - } - - // now loop through all the columns flagging the primary keys - final TableColumn[] columns = newTable.getColumns(); - if (columns != null) { - for (int i = 0; i < columns.length; i++) { - if (primaryKeysSet.contains(columns[i].getName())) { - columns[i].setIsPrimaryKey(true); - } - } - } - } - } catch (final Exception e) { - mLogger.log(Level.SEVERE,mMessages.getString("SQLSE_E00808.NO_PRIMARY_KEY"),e); - throw e; - } - } - - /** - * Gets the foreign keys for a table. - * - * @param newTable Table to get the foreign key(s) for - * @throws Exception DOCUMENT ME! - */ - private static void checkForeignKeys(final Table newTable,final Connection connection) throws Exception { - //this.errMsg = ""; - try { - // get the foreing keys - final List foreignKeys = getForeignKeys(newTable.getCatalog(), newTable.getSchema(), newTable.getName(),connection); - if (foreignKeys != null) { - newTable.setForeignKeyColumnList(foreignKeys); - - // create a hash set of the keys - final java.util.Set foreignKeysSet = new java.util.HashSet(); - for (int i = 0; i < foreignKeys.size(); i++) { - final ForeignKeyColumn key = (ForeignKeyColumn) foreignKeys.get(i); - foreignKeysSet.add(key.getColumnName()); - } - - // now loop through all the columns flagging the foreign keys - final TableColumn[] columns = newTable.getColumns(); - if (columns != null) { - for (int i = 0; i < columns.length; i++) { - if (foreignKeysSet.contains(columns[i].getName())) { - columns[i].setIsForeignKey(true); - } - } - } - } - - } catch (final Exception e) { - mLogger.log(Level.SEVERE,mMessages.getString("SQLSE_E00809.NO_FOREIGN_KEY"),e); - throw e; - } - } - - /** - * Establishes a connection to the database. - * - * @param conn JDBC connection - * @throws Exception DOCUMENT ME! - */ - /*public void connectDB(final Connection conn) throws Exception { - this.errMsg = ""; - if (conn == null) { - throw new IllegalArgumentException("Connection can't be null."); - } - - this.dbconn = conn; - this.getDBMetaData(); - }*/ - - /** - * Disconnects from the database. - * - * @throws Exception DOCUMENT ME! - */ - /*public void disconnectDB() throws Exception { - this.errMsg = ""; - // close connection to database - try { - if (this.dbconn != null && !this.dbconn.isClosed()) { - this.dbconn.close(); - this.dbconn = null; - } - } catch (final SQLException e) { - e.printStackTrace(); - this.errMsg = e.getLocalizedMessage(); - throw e; - } - }*/ - - /*private void getDBMetaData() throws Exception { - this.errMsg = ""; - // get the metadata - try { - this.dbmeta = this.dbconn.getMetaData(); - } catch (final SQLException e) { - e.printStackTrace(); - this.errMsg = e.getLocalizedMessage(); - throw e; - } - }*/ - - /** - * Returns the database product name - * - * @return String database product name - * @throws Exception DOCUMENT ME! - */ - /*public String getDBName() throws Exception { - String dbname = ""; - - this.errMsg = ""; - // get the database product name - try { - dbname = this.dbmeta.getDatabaseProductName(); - } catch (final SQLException e) { - e.printStackTrace(); - this.errMsg = e.getLocalizedMessage(); - throw e; - } - return dbname; - }*/ - - /** - * Returns the database OTD type. - * - * @param conn - * @return String Database OTD type - * @throws Exception DOCUMENT ME! - */ - public static String getDBType(final Connection conn) throws Exception { - String dbtype = ""; - - // get the database type based on the product name converted to lowercase - final String dbname = conn.getMetaData().getDatabaseProductName().toLowerCase(); - if (dbname.equals("microsoft sql server")) { - // Microsoft SQL Server - dbtype = DBMetaData.SQLSERVER; - } else if (dbname.equals("sql server") || dbname.indexOf("jdbc") > -1) { - // JDBC - dbtype = DBMetaData.JDBC; - } else if (dbname.indexOf("db2") > -1 || dbname.equals("as")) { - // DB2 - dbtype = DBMetaData.DB2; - } else if (dbname.equals("exadas") || dbname.equals("attunity connect driver")) { - // VSAM - dbtype = DBMetaData.VSAM_ADABAS_IAM; - } else if (dbname.indexOf("orac") > -1) { - // Oracle - dbtype = DBMetaData.ORACLE; - } else if (dbname.indexOf("derby") > -1) { - // derby - dbtype = DBMetaData.DERBY; - } else { - // other type, default to JDBC-ODBC - dbtype = DBMetaData.JDBC_ODBC; - } - - return dbtype; - } - - private static final String getJDBCSearchPattern(final String guiPattern, final Connection connection) throws Exception { - //this.errMsg = ""; - - // Converts the passed in GUI pattern to one understood by the - // JDBC driver: - // change _ to _ - // change % to % - // change * to % = GUI uses * to represent 0 or more characters - // change ? to _ = GUI uses ? to represent any single character - try { - String jdbcPattern = guiPattern; - final String escapeChar = connection.getMetaData().getSearchStringEscape(); - - // change _ to _ - // PP:See bug 10718. Disabling the escape character for _ - // jdbcPattern = replaceAllChars(jdbcPattern, '_', escapeChar + "_"); - - // change % to % - jdbcPattern = replaceAllChars(jdbcPattern, '%', escapeChar + "%"); - - // change * to % - jdbcPattern = jdbcPattern.replace('*', '%'); - - // change ? to _ - jdbcPattern = jdbcPattern.replace('?', '_'); - - return jdbcPattern; - } catch (final Exception e) { - mLogger.log(Level.SEVERE,mMessages.getString("SQLSE_E00811.NO_PATTERN_AVAILABLE"),e); - throw e; - } - } - - /** - * Returns a list of schemas in the database. - * - * @return String[] List of schema names - * @throws Exception DOCUMENT ME! - */ - private static final String[] getSchemas(final Connection connection) throws Exception { - //this.errMsg = ""; - // get all schemas - try { - final ResultSet rs = connection.getMetaData().getSchemas(); - final CopyOnWriteArrayList v = new CopyOnWriteArrayList(); - String[] schemaNames = null; - - while (rs.next()) { - final String schema = rs.getString("TABLE_SCHEM"); - v.add(schema); - } - if (v.size() > 0) { - // copy into array to return - schemaNames = new String[v.size()]; - v.toArray(schemaNames); - } - rs.close(); - return schemaNames; - } catch (final Exception e) { - mLogger.log(Level.SEVERE,mMessages.getString("SQLSE_E00810.NO_SCHEMA_AVAILABLE"),e); - throw e; - } - } - - /** - * Returns a list of tables matching in the passed in filters. - * - * @param catalog Catalog name - * @param schemaPattern Schema pattern - * @param tablePattern Table name pattern - * @param includeSystemTables Indicate whether to include system tables in search - * @return String[][] List of tables matching search filters - * @throws Exception DOCUMENT ME! - */ - private static final String[][] getTablesOnly(final String catalog, - final String schemaPattern, - final String tablePattern, - final boolean includeSystemTables,final Connection connection) throws Exception { - String[] tableTypes; - { - if (includeSystemTables) { - final String[] types = {DBMetaData.TABLE, DBMetaData.SYSTEM_TABLE}; - tableTypes = types; - } else { - final String[] types = {DBMetaData.TABLE}; - tableTypes = types; - } - - } - - return getTables(catalog, schemaPattern, tablePattern, tableTypes, connection); - } - - /** - * Returns a list of views matching in the passed in filters. - * - * @param catalog Catalog name - * @param schemaPattern Schema pattern - * @param viewPattern View name pattern - * @param includeSystemTables Indicate whether to include system tables in search - * @return String[][] List of views matching search filters - * @throws Exception DOCUMENT ME! - */ - private static final String[][] getViewsOnly(final String catalog, final String schemaPattern, final String viewPattern, final boolean includeSystemTables, final Connection connection) - throws Exception { - String[] tableTypes; - { - if (includeSystemTables) { - final String[] types = {DBMetaData.VIEW, DBMetaData.SYSTEM_TABLE}; - tableTypes = types; - } else { - final String[] types = {DBMetaData.VIEW}; - tableTypes = types; - } - } - - return getTables(catalog, schemaPattern, viewPattern, tableTypes,connection); - } - - /** - * Returns a list of tables and views matching in the passed in filters. - * - * @param catalog Catalog name - * @param schemaPattern Schema pattern - * @param tablePattern Table/View name pattern - * @param includeSystemTables Indicate whether to include system tables in search - * @return String[][] List of tables and views matching search filters - * @throws Exception DOCUMENT ME! - */ - private static final String[][] getTablesAndViews(final String catalog, - final String schemaPattern, - final String tablePattern, - final boolean includeSystemTables,final Connection connection) throws Exception { - String[] tableTypes; - { - if (includeSystemTables) { - final String[] types = {DBMetaData.TABLE, DBMetaData.VIEW, DBMetaData.SYSTEM_TABLE}; - tableTypes = types; - } else { - final String[] types = {DBMetaData.TABLE, DBMetaData.VIEW}; - tableTypes = types; - } - } - - return getTables(catalog, schemaPattern, tablePattern, tableTypes,connection); - } - - /** - * Returns a list of tables/views matching in the passed in filters. - * - * @param catalog Catalog name - * @param schemaPattern Schema pattern - * @param tablePattern Table/View name pattern - * @param tableTypes List of table types to include (ex. TABLE, VIEW) - * @return String[][] List of tables matching search filters - * @throws Exception DOCUMENT ME! - */ - private static final String[][] getTables(String catalog, String schemaPattern, String tablePattern, final String[] tableTypes, final Connection connection) - throws Exception { - //this.errMsg = ""; - try { - if (catalog.equals("")) { - catalog = null; - } - if (schemaPattern.equals("")) { - schemaPattern = null; - } - if (tablePattern.equals("")) { - tablePattern = null; - } - - if (tablePattern != null) { - tablePattern = getJDBCSearchPattern(tablePattern, connection); - } - - final ResultSet rs = connection.getMetaData().getTables(catalog, schemaPattern, tablePattern, tableTypes); - - final CopyOnWriteArrayList v = new CopyOnWriteArrayList(); - String[][] tables = null; // array of table structures: Name, Catalog, Schema - - while (rs.next()) { - String tableCatalog = rs.getString("TABLE_CAT"); - String tableSchema = rs.getString("TABLE_SCHEM"); - final String tableName = rs.getString("TABLE_NAME"); - final String tableType = rs.getString("TABLE_TYPE"); - - if (tableCatalog == null) { - tableCatalog = ""; - } - if (tableSchema == null) { - tableSchema = ""; - } - - // fill in table info - final String[] tableItem = new String[4]; // hold info for each table - tableItem[DBMetaData.NAME] = tableName; - tableItem[DBMetaData.CATALOG] = tableCatalog; - tableItem[DBMetaData.SCHEMA] = tableSchema; - tableItem[DBMetaData.TYPE] = tableType; - - // add table to Vector - v.add(tableItem); - } - - // now copy Vector to array to return back - if (v.size() > 0) { - tables = new String[v.size()][4]; - v.toArray(tables); - } - rs.close(); - return tables; - } catch (final Exception e) { - mLogger.log(Level.SEVERE,mMessages.getString("SQLSE_E00812.NO_TABLELIST_AVAILABLE"),e); - throw e; - } - } - - /** - * Gets the prepared statement metadata (parameters, resultsets). - * - * @param catalog Catalog name - * @param schema Schema name - * @param name Prepared statement name - * @param sqlText SQL text of prepared statement - * @return PrepStmt Prepared statement object - * @throws Exception DOCUMENT ME! - */ - /*public static final PrepStmt getPrepStmtMetaData(final String catalog, final String schema, final String name, final String sqlText,final Connection connection) throws Exception { - - //this.errMsg = ""; - //this.checkPrepStmtMetaData = false; - - try { - PrepStmt newPrepStmt = null; - - // make sure there is some sql text for the prepared statement - if (sqlText == null || sqlText.equals("")) { - return null; - } - - // fill in name and sql text - newPrepStmt = new PrepStmt(name, catalog, schema, sqlText); - - // prepare the statement - final PreparedStatement pstmt = connection.prepareStatement(sqlText); - - // Parameter metadata only available through JDBC 3.0, JDK 1.4 - // get parameter meta data of the prepared statment from the DB connection - Parameter[] parameters = null; - - // pass sqlText to getPrepStmtParameters(...) so that in case - // the driver does not support java.sql.ParameterMetaData we - // can construct a paramters array using default values. see - // details inside getPrepStmtParameters(...) - parameters = getPrepStmtParameters(pstmt, sqlText,connection); - - newPrepStmt.setParameters(parameters); - - ResultSetColumn[] cols = null; - - // get the resultset metadata - // of the prepared statment from the DB connection - cols = getPrepStmtResultSetColumns(pstmt); - - // set the prepared statement's resultset columns - newPrepStmt.setResultSetColumns(cols); - - //this.checkPrepStmtMetaData = this.errPrepStmtParameters && this.errPrepStmtResultSetColumns; - - pstmt.close(); - - return newPrepStmt; - } catch (final Exception e) { - e.printStackTrace(); - //this.errMsg = e.getLocalizedMessage(); - throw e; - } - }*/ - - /** - * Returns a list of procedures matching in the passed in filters. - * - * @param catalog Catalog name - * @param schemaPattern Schema pattern - * @param procedurePattern Procedure name pattern - * @return String[][] List of procedures matching search filters - * @throws Exception DOCUMENT ME! - */ - /*public static final String[][] getProcedures(String catalog, String schemaPattern, String procedurePattern, final Connection connection) throws Exception { - //this.errMsg = ""; - try { - if (catalog.equals("")) { - catalog = null; - } - if (schemaPattern.equals("")) { - schemaPattern = null; - } - if (procedurePattern.equals("")) { - procedurePattern = null; - } - - if (procedurePattern != null) { - procedurePattern = getJDBCSearchPattern(procedurePattern,connection); - } - - final Vector v = new Vector(); - String[][] procedures = null; // array of procedure structures: Name, Catalog, Schema, - // Type - - final ResultSet rs = connection.getMetaData().getProcedures(catalog, schemaPattern, procedurePattern); - while (rs.next()) { - String procedureCatalog = rs.getString("PROCEDURE_CAT"); - String procedureSchema = rs.getString("PROCEDURE_SCHEM"); - final String procedureName = rs.getString("PROCEDURE_NAME"); - final String procedureType = getProcedureTypeDescription(rs.getShort("PROCEDURE_TYPE")); - - if (procedureCatalog == null) { - procedureCatalog = ""; - } - if (procedureSchema == null) { - procedureSchema = ""; - } - - // fill in procedure info - final String[] procedureItem = new String[4]; // hold info for each procedure - procedureItem[DBMetaData.NAME] = procedureName; - procedureItem[DBMetaData.CATALOG] = procedureCatalog; - procedureItem[DBMetaData.SCHEMA] = procedureSchema; - procedureItem[DBMetaData.TYPE] = procedureType; - - // add procedure to Vector - v.add(procedureItem); - } - - // now copy Vector to array to return back - if (v.size() > 0) { - procedures = new String[v.size()][4]; - v.copyInto(procedures); - } - rs.close(); - return procedures; - } catch (final Exception e) { - e.printStackTrace(); - //this.errMsg = e.getLocalizedMessage(); - throw e; - } - }*/ - - /** - * Returns a list of primary keys for a table. - * - * @param tcatalog Catalog name - * @param tschema Schema name - * @param tname Table name - * @return List List of primary keys - * @throws Exception DOCUMENT ME! - */ - private static final List getPrimaryKeys(String tcatalog, String tschema, final String tname,final Connection connection) throws Exception { - List pkList = Collections.emptyList(); - ResultSet rs = null; - - //this.errMsg = ""; - try { - if (tcatalog.equals("")) { - tcatalog = null; - } - if (tschema.equals("")) { - tschema = null; - } - - rs = connection.getMetaData().getPrimaryKeys(tcatalog, tschema, tname); - pkList = KeyColumn.createPrimaryKeyColumnList(rs); - } catch (final Exception e) { - mLogger.log(Level.SEVERE,mMessages.getString("SQLSE_E00808.NO_PRIMARY_KEY"),e); - throw e; - } finally { - if (rs != null) { - try { - rs.close(); - } catch (final SQLException e) { - mLogger.log(Level.SEVERE,mMessages.getString("SQLSE_E00628.OMP_Cleanup_Failure"),e); - } - } - } - - return pkList; - } - - /** - * Returns a list of foreign keys for a table. - * - * @param tcatalog Catalog name - * @param tschema Schema name - * @param tname Table name - * @return List List of foreign keys - * @throws Exception DOCUMENT ME! - */ - private static final List getForeignKeys(String tcatalog, String tschema, final String tname, final Connection connection) throws Exception { - //this.errMsg = ""; - List fkList = Collections.emptyList(); - ResultSet rs = null; - - try { - if (tcatalog.equals("")) { - tcatalog = null; - } - if (tschema.equals("")) { - tschema = null; - } - try { - rs = connection.getMetaData().getImportedKeys(tcatalog, tschema, tname); - fkList = ForeignKeyColumn.createForeignKeyColumnList(rs); - } catch (final Exception e) { - e.printStackTrace(); - mLogger.warning("JDBC driver does not support java.sql.ParameterMetaData " + e.getMessage()); - //this.errMsg = e.getLocalizedMessage(); - } - } catch (final Exception e) { - mLogger.log(Level.SEVERE,mMessages.getString("SQLSE_E00809.NO_FOREIGN_KEY"),e); - throw e; - } finally { - if (rs != null) { - try { - rs.close(); - } catch (final SQLException e) { - mLogger.log(Level.SEVERE,mMessages.getString("SQLSE_E00628.OMP_Cleanup_Failure"),e); - } - } - } - - return fkList; - } - - /** - * Gets the procedure metadata (parameters). - * - * @param pcatalog Catalog name - * @param pschema Schema name - * @param pname Procedure name - * @param ptype Procedure type - * @return Procedure object - * @throws Exception DOCUMENT ME! - */ - /*public static final Procedure getProcedureMetaData(String pcatalog, String pschema, final String pname, final String ptype,final Connection connection) throws Exception { - //this.errMsg = ""; - try { - // create a new procedure object - final Procedure newProcedure = new Procedure(pname, pcatalog, pschema, ptype); - final Vector v = new Vector(); - - if (pcatalog.equals("")) { - pcatalog = null; - } - if (pschema.equals("")) { - pschema = null; - } - - // get procedure parameter information - final ResultSet rs = connection.getMetaData().getProcedureColumns(pcatalog, pschema, pname, "%"); - - Parameter[] parameters = null; - int pos = 0; - boolean hasReturn = false; - - while (rs.next()) { - pos++; - String parmName = rs.getString("COLUMN_NAME"); - if (parmName != null) { - // strip off "@" in front of parameter name - if (parmName.charAt(0) == '@') { - parmName = parmName.substring(1); - } - } else { - // parameter name is not return - call it "param" - parmName = "param" + String.valueOf(pos); - } - String sqlType = DBMetaData.getSQLTypeDescription(rs.getInt("DATA_TYPE")); - String javaType = getJavaFromSQLTypeDescription(sqlType); - // added abey for Procedure ResultSet - final int dataType = rs.getInt("DATA_TYPE"); - if (dataType == java.sql.Types.OTHER && rs.getString("TYPE_NAME").equalsIgnoreCase("REF CURSOR")) { - sqlType = "RESULTSET"; - javaType = "java.sql.ResultSet"; - } - final String paramType = getParamTypeDescription(rs.getShort("COLUMN_TYPE")); - final int nullable = rs.getShort("NULLABLE"); - final int numericPrecision = rs.getInt("PRECISION"); - final short numericScale = rs.getShort("SCALE"); - - // create a parameter and add it to the vector - final Parameter parm = new Parameter(parmName, javaType); - boolean isNullable = false; - if (nullable == DatabaseMetaData.procedureNullable) { - isNullable = true; - } - parm.setJavaType(javaType); - parm.setSqlType(sqlType); - parm.setParamType(paramType); - parm.setOrdinalPosition(pos); - parm.setNumericPrecision(numericPrecision); - parm.setNumericScale(numericScale); - parm.setIsNullable(isNullable); - - if (paramType.equals("RETURN")) { - hasReturn = true; - } - - // add to vector - v.add(parm); - } - rs.close(); - - // now copy Vector to array - if (v.size() > 0) { - parameters = new Parameter[v.size()]; - v.copyInto(parameters); - } - - // now set up parameters in the procedure to return - newProcedure.setParameters(parameters); - newProcedure.setHasReturn(hasReturn); - - return newProcedure; - } catch (final Exception e) { - e.printStackTrace(); - //this.errMsg = e.getLocalizedMessage(); - throw e; - } - }*/ - - /** - * Gets the table metadata (columns). - * - * @param tcatalog Catalog name - * @param tschema Schema name - * @param tname Table name - * @param ttype Table type - * @return Table object - * @throws Exception DOCUMENT ME! - */ - private static final Table getTableMetaData(String tcatalog, String tschema, final String tname, final String ttype, final Connection connection) throws Exception { - //this.errMsg = ""; - ResultSet rs = null; - - try { - // create a new Table object - final Table newTable = new Table(tname, tcatalog, tschema, ttype); - final CopyOnWriteArrayList v = new CopyOnWriteArrayList(); - - if (tcatalog.equals("")) { - tcatalog = null; - } - - if (tschema.equals("")) { - tschema = null; - } - - // get table column information - rs = connection.getMetaData().getColumns(tcatalog, tschema, tname, "%"); - - TableColumn[] columns = null; - - while (rs.next()) { - final String defaultValue = rs.getString("COLUMN_DEF"); - - final int sqlTypeCode = rs.getInt("DATA_TYPE"); - - final String colName = rs.getString("COLUMN_NAME"); - final String sqlType = DBMetaData.getSQLTypeDescription(sqlTypeCode); - final String javaType = getJavaFromSQLTypeDescription(sqlType); - - final int position = rs.getInt("ORDINAL_POSITION"); - - final int scale = rs.getInt("DECIMAL_DIGITS"); - final int precision = rs.getInt("COLUMN_SIZE"); - final int radix = rs.getInt("NUM_PREC_RADIX"); - - // create a table column and add it to the vector - final TableColumn col = new TableColumn(colName, javaType); - boolean isNullable = false; - if (rs.getString("IS_NULLABLE").equals("YES")) { - isNullable = true; - } - col.setJavaType(javaType); - col.setSqlType(sqlType); - col.setIsNullable(isNullable); - col.setIsSelected(true); - col.setIsPrimaryKey(false); - col.setIsForeignKey(false); - col.setSqlTypeCode(sqlTypeCode); - - col.setOrdinalPosition(position); - col.setNumericPrecision(precision); - col.setNumericScale(scale); - col.setNumericRadix(radix); - - if (defaultValue != null) { - col.setDefaultValue(defaultValue.trim()); - } - - // add to vector - v.add(col); - } - - // now copy Vector to array - if (v.size() > 0) { - columns = new TableColumn[v.size()]; - v.toArray(columns); - } - - // now set up columns in the table to return - newTable.setColumns(columns); - - // now check the columns that are primary keys - checkPrimaryKeys(newTable,connection); - - // now check the columns that are foreign keys - checkForeignKeys(newTable,connection); - - // catch exceptions for this as index only makes sense for - // tables and not views (can't check the table type because it's dependent on driver) - try { - // get index info for this table - rs = connection.getMetaData().getIndexInfo(tcatalog, tschema, tname, false, true); - newTable.setIndexList(IndexColumn.createIndexList(rs)); - } catch (final Exception e) { - // ignore and continue - //this.errMsg = e.getLocalizedMessage(); - } - - return newTable; - } catch (final Exception e) { - mLogger.log(Level.SEVERE,mMessages.getString("SQLSE_E00813.NO_TABLEMETADATA_AVAILABLE"),e); - throw e; - } finally { - if (rs != null) { - try { - rs.close(); - } catch (final SQLException e) { - mLogger.log(Level.SEVERE,mMessages.getString("SQLSE_E00628.OMP_Cleanup_Failure"),e); - } - } - } - } - - /** - * Converts a JDBC SQL Type to a Java Type. - * - * @param sqlType JDBC SQL Type - * @return Java Type - */ - public static final String getJavaFromSQLTypeDescription(final String sqlType) { - Object t; - String javaType = "java.lang.String"; // default value - t = DBMetaData.SQLTOJAVATYPES.get(sqlType); - - if (t != null) { - javaType = t.toString(); - } - - return javaType; - } - - /** - * Converts the numeric value of a JDBC SQL type to a display string. - * - * @param type JDBC numeric SQL type value - * @return JDBC SQL type string - */ - public static final String getSQLTypeDescription(final int type) { - // returns a String representing the passed in numeric - // SQL type - switch (type) { - case java.sql.Types.ARRAY: - return "ARRAY"; - case java.sql.Types.BIGINT: - return "BIGINT"; - case java.sql.Types.BINARY: - return "BINARY"; - case java.sql.Types.BIT: - return "BIT"; - case java.sql.Types.BLOB: - return "BLOB"; - case 16: - // case java.sql.Types.BOOLEAN: - return "BOOLEAN"; - case java.sql.Types.CHAR: - return "CHAR"; - case java.sql.Types.CLOB: - return "CLOB"; - case 70: - // case java.sql.Types.DATALINK: - return "DATALINK"; - case java.sql.Types.DATE: - return "DATE"; - case java.sql.Types.DECIMAL: - return "DECIMAL"; - case java.sql.Types.DOUBLE: - return "DOUBLE"; - case java.sql.Types.FLOAT: - return "FLOAT"; - case java.sql.Types.INTEGER: - return "INTEGER"; - case java.sql.Types.JAVA_OBJECT: - return "JAVA_OBJECT"; - case java.sql.Types.LONGVARBINARY: - return "LONGVARBINARY"; - case java.sql.Types.LONGVARCHAR: - return "LONGVARCHAR"; - case java.sql.Types.NULL: - return "NULL"; - case java.sql.Types.NUMERIC: - return "NUMERIC"; - case java.sql.Types.OTHER: - return "OTHER"; - case java.sql.Types.REAL: - return "REAL"; - case java.sql.Types.REF: - return "REF"; - case java.sql.Types.SMALLINT: - return "SMALLINT"; - case java.sql.Types.STRUCT: - return "STRUCT"; - case java.sql.Types.TIME: - return "TIME"; - case java.sql.Types.TIMESTAMP: - return "TIMESTAMP"; - case java.sql.Types.TINYINT: - return "TINYINT"; - case java.sql.Types.VARBINARY: - return "VARBINARY"; - case java.sql.Types.VARCHAR: - return "VARCHAR"; - } - // all others default to OTHER - return "OTHER"; - } - - /** - * Converts a text representation of a JDBC SQL type to a display string. - * - * @param sqlText JDBC SQL type string - * @return JDBC numeric SQL type value - */ - public static final int getSQLTypeCode(String sqlText) { - if (sqlText == null) { - throw new IllegalArgumentException("Must supply non-null String value for sqlText."); - } - - sqlText = sqlText.trim().toUpperCase(); - for (int i = 0; i < DBMetaData.SQLTYPES.length; i++) { - if (DBMetaData.SQLTYPES[i].equals(sqlText)) { - return DBMetaData.SQLTYPE_CODES[i]; - } - } - - return java.sql.Types.OTHER; - } - - public static final String getJavaTypeDescription(final int type) { - // converts a numeric SQL type to a Java type - String javaType = "java.lang.String"; - - switch (type) { - case java.sql.Types.ARRAY: - javaType = "java.sql.ARRAY"; - break; - case java.sql.Types.BIGINT: - javaType = "long"; - break; - case java.sql.Types.BINARY: - javaType = "byte[]"; - break; - case java.sql.Types.BIT: - javaType = "boolean"; - break; - case java.sql.Types.BLOB: - javaType = "java.sql.Blob"; - break; - // case java.sql.Types.BOOLEAN: - // javaType = "boolean"; - case java.sql.Types.CHAR: - javaType = "java.lang.String"; - break; - case java.sql.Types.CLOB: - javaType = "java.sql.Clob"; - break; - case java.sql.Types.DATE: - javaType = "java.sql.Date"; - break; - case java.sql.Types.DECIMAL: - javaType = "java.math.BigDecimal"; - break; - case java.sql.Types.DOUBLE: - javaType = "double"; - break; - case java.sql.Types.FLOAT: - javaType = "double"; - break; - case java.sql.Types.INTEGER: - javaType = "int"; - break; - case java.sql.Types.LONGVARBINARY: - javaType = "byte[]"; - break; - case java.sql.Types.LONGVARCHAR: - javaType = "java.lang.String"; - break; - case java.sql.Types.NUMERIC: - javaType = "java.math.BigDecimal"; - break; - // case java.sql.Types.OTHER: - // javaType = "java.sql.Blob"; - case java.sql.Types.REAL: - javaType = "float"; - break; - case java.sql.Types.REF: - javaType = "java.sql.Ref"; - break; - case java.sql.Types.SMALLINT: - javaType = "short"; - break; - case java.sql.Types.STRUCT: - javaType = "java.sql.Struct"; - break; - case java.sql.Types.TIME: - javaType = "java.sql.Time"; - break; - case java.sql.Types.TIMESTAMP: - javaType = "java.sql.Timestamp"; - break; - case java.sql.Types.TINYINT: - javaType = "byte"; - break; - case java.sql.Types.VARBINARY: - javaType = "byte[]"; - break; - case java.sql.Types.VARCHAR: - javaType = "java.lang.String"; - break; - } - return javaType; - } - - public static final String getParamTypeDescription(final int type) { - String descr = ""; - - if (type == DatabaseMetaData.procedureColumnIn) { - descr = "IN"; - } else if (type == DatabaseMetaData.procedureColumnInOut) { - descr = "INOUT"; - } else if (type == DatabaseMetaData.procedureColumnOut) { - descr = "OUT"; - } else if (type == DatabaseMetaData.procedureColumnReturn) { - descr = "RETURN"; - } else if (type == DatabaseMetaData.procedureColumnResult) { - descr = "RESULT"; - } else { - descr = "UNKNOWN"; - } - - return descr; - } - - /*private static final String getProcedureTypeDescription(final int type) { - // converts the numeric procedure type code to a string description - String descr = ""; - if (type == DatabaseMetaData.procedureNoResult) { - descr = Procedure.PROCEDURE; - } else if (type == DatabaseMetaData.procedureReturnsResult) { - descr = Procedure.FUNCTION; - } else if (type == DatabaseMetaData.procedureResultUnknown) { - descr = Procedure.UNKNOWN; - } else { - descr = Procedure.UNKNOWN; - } - - return descr; - }*/ - - public static final String getPrepStmtParamTypeDescription(final int type) { - String descr = ""; - - if (type == ParameterMetaData.parameterModeIn) { - descr = "IN"; - } else if (type == ParameterMetaData.parameterModeInOut) { - descr = "INOUT"; - } else - descr = "UNKNOWN"; - - return descr; - } - - public static final String replaceAllChars(final String orig, final char oldChar, final String replStr) { - String newString = ""; - - for (int i = 0; i < orig.length(); i++) { - if (orig.charAt(i) == oldChar) { - newString = newString + replStr; - } else { - newString = newString + orig.charAt(i); - } - } - return newString; - } - - /** - * Get String representing current error message, if any. - * - * @return error message - */ - /*public String getErrString() { - return this.errMsg; - }*/ - - /* private static final Parameter[] getPrepStmtParameters(final PreparedStatement pstmt, final String sqlText,final Connection connection) { - String errMsg = ""; - //errPrepStmtParameters = false; - Parameter[] parameters = null; - - try { - ParameterMetaData pmeta = null; - try { - pmeta = pstmt.getParameterMetaData(); - } - // just catch all exception since - // attunity throws java.lang.AbstractMethodError - // SequeLink throws SQLException - catch (final AbstractMethodError absE) { - DBMetaData.mLogger.log(Level.INFO, "JDBC driver does not support java.sql.ParameterMetaData " + absE.getMessage()); - return handleUnsupportParameterMetaData(sqlText); - } catch (final SQLException sqlE) { - DBMetaData.mLogger.log(Level.INFO, "JDBC driver does not support java.sql.ParameterMetaData " + sqlE.getMessage()); - return handleUnsupportParameterMetaData(sqlText); - } catch (final Exception e) { - DBMetaData.mLogger.log(Level.INFO, "JDBC driver does not support java.sql.ParameterMetaData " + e.getMessage()); - return handleUnsupportParameterMetaData(sqlText); - } - - if (pmeta != null) { - final int numParams = pmeta.getParameterCount(); - if (numParams > 0) { - parameters = new Parameter[numParams]; - // get info for each parameter - for (int i = 1; i <= numParams; i++) { - final Parameter currParam = new Parameter(); - final String paramname = "param" + String.valueOf(i); - currParam.setName(paramname); - - // try to get the sql type info - default to VARCHAR - String sqltype = "VARCHAR"; - try { - sqltype = DBMetaData.getSQLTypeDescription(pmeta.getParameterType(i)); - } catch (final SQLException e) { - // default to VARCHAR if we can't get the type - //this.errPrepStmtParameters = true; - e.printStackTrace(); - errMsg = e.getLocalizedMessage(); - } - - // 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 = getJavaFromSQLTypeDescription(sqltype); - - // try to get the numeric precision, default to 0 - int precision = 0; - try { - precision = pmeta.getPrecision(i); - } catch (final SQLException e) { - //this.errPrepStmtParameters = true; - e.printStackTrace(); - errMsg = e.getLocalizedMessage(); - } - - // try to get the numeric scale, default to 0 - int scale = 0; - try { - scale = pmeta.getScale(i); - } catch (final SQLException e) { - //this.errPrepStmtParameters = true; - e.printStackTrace(); - errMsg = e.getLocalizedMessage(); - } - - // try to get the param type, default to IN - String paramType = "IN"; - try { - paramType = getPrepStmtParamTypeDescription(pmeta.getParameterMode(i)); - } catch (final SQLException e) { - //this.errPrepStmtParameters = true; - e.printStackTrace(); - errMsg = e.getLocalizedMessage(); - } - - // try to get is nullable, default to TRUE - boolean isNullable = true; - try { - if (pmeta.isNullable(i) == java.sql.ParameterMetaData.parameterNullable) { - isNullable = true; - } else { - isNullable = false; - } - } catch (final SQLException e) { - //this.errPrepStmtParameters = true; - e.printStackTrace(); - errMsg = e.getLocalizedMessage(); - } - - currParam.setJavaType(javatype); - currParam.setSqlType(sqltype); - currParam.setNumericPrecision(precision); - currParam.setNumericScale(scale); - currParam.setOrdinalPosition(i); - currParam.setParamType(paramType); - currParam.setIsNullable(isNullable); - - parameters[i - 1] = currParam; - } - } - } - } catch (final Exception e) { - // parameter metadata not supported - parameters = null; - //this.errPrepStmtParameters = true; - e.printStackTrace(); - errMsg = e.getLocalizedMessage(); - } - - return parameters; - }*/ - - private static final ResultSetColumn[] getPrepStmtResultSetColumns(final PreparedStatement pstmt) { - String errMsg = ""; - //this.errPrepStmtResultSetColumns = false; - ResultSetColumn[] cols = null; - try { - final ResultSetMetaData rsmd = pstmt.getMetaData(); - int count = 0; - if (rsmd != null) { - count = rsmd.getColumnCount(); - } else { - //this.errPrepStmtResultSetColumns = true; - } - if (count > 0) { - // scroll through the resultset column information - cols = new ResultSetColumn[count]; - for (int i = 1; i <= count; i++) { - final ResultSetColumn currCol = new ResultSetColumn(); - currCol.setName(rsmd.getColumnName(i)); - currCol.setSqlType(DBMetaData.getSQLTypeDescription(rsmd.getColumnType(i))); - currCol.setJavaType(getJavaFromSQLTypeDescription(currCol.getSqlType())); - currCol.setOrdinalPosition(i); - currCol.setNumericPrecision(rsmd.getPrecision(i)); - currCol.setNumericScale(rsmd.getScale(i)); - - if (rsmd.isNullable(i) == DatabaseMetaData.columnNullable) { - currCol.setIsNullable(true); - } else { - currCol.setIsNullable(false); - } - - cols[i - 1] = currCol; - } - } - - } catch (final Exception e) { - // resultset column metadata not supported - //this.errPrepStmtResultSetColumns = true; - cols = null; - mLogger.log(Level.SEVERE,mMessages.getString("SQLSE_E00814.NO_COLUMNMETADATA_AVAILABLE"),e); - } - - return cols; - } - - /** - * check all the used APIs to see if they are supported. - * - * @param type none - * @return boolean - */ - /*public boolean checkAPIsForSupport() { - boolean support = true; - - try { - this.dbmeta.supportsBatchUpdates(); - } catch (final SQLException e) { - support = false; - DBMetaData.mLogger.warning("supportsBatchUpdates() failed - " + e.getMessage()); - } catch (final AbstractMethodError errE) { - support = false; - DBMetaData.mLogger.warning("supportsBatchUpdates() failed - " + errE.getMessage()); - } - try { - this.dbmeta.supportsCatalogsInDataManipulation(); - } catch (final SQLException e) { - support = false; - DBMetaData.mLogger.warning("supportsCatalogsInDataManipulation() failed - " + e.getMessage()); - } catch (final AbstractMethodError errE) { - support = false; - DBMetaData.mLogger.warning("supportsCatalogsInDataManipulation() failed - " + errE.getMessage()); - } - try { - this.dbmeta.supportsCatalogsInProcedureCalls(); - } catch (final SQLException e) { - support = false; - DBMetaData.mLogger.warning("supportsCatalogsInProcedureCalls() failed - " + e.getMessage()); - } catch (final AbstractMethodError errE) { - support = false; - DBMetaData.mLogger.warning("supportsCatalogsInProcedureCalls() failed - " + errE.getMessage()); - } - try { - this.dbmeta.supportsCatalogsInTableDefinitions(); - } catch (final SQLException e) { - support = false; - DBMetaData.mLogger.warning("supportsCatalogsInTableDefinitions() failed - " + e.getMessage()); - } catch (final AbstractMethodError errE) { - support = false; - DBMetaData.mLogger.warning("supportsCatalogsInTableDefinitions() failed - " + errE.getMessage()); - } - try { - this.dbmeta.supportsCatalogsInIndexDefinitions(); - } catch (final AbstractMethodError errE) { - support = false; - DBMetaData.mLogger.warning("supportsCatalogsInIndexDefinitions() failed - " + errE.getMessage()); - } catch (final SQLException e) { - support = false; - DBMetaData.mLogger.warning("supportsCatalogsInIndexDefinitions() failed - " + e.getMessage()); - } - try { - this.dbmeta.supportsCatalogsInPrivilegeDefinitions(); - } catch (final SQLException e) { - support = false; - DBMetaData.mLogger.warning("supportsCatalogsInPrivilegeDefinitions() failed - " + e.getMessage()); - } catch (final AbstractMethodError errE) { - support = false; - DBMetaData.mLogger.warning("supportsCatalogsInPrivilegeDefinitions() failed - " + errE.getMessage()); - } - try { - this.dbmeta.supportsConvert(); - } catch (final SQLException e) { - support = false; - DBMetaData.mLogger.warning("supportsConvert() failed - " + e.getMessage()); - } catch (final AbstractMethodError errE) { - support = false; - DBMetaData.mLogger.warning("supportsConvert() failed - " + errE.getMessage()); - } - try { - this.dbmeta.supportsExpressionsInOrderBy(); - } catch (final SQLException e) { - support = false; - DBMetaData.mLogger.warning("supportsExpressionsInOrderBy() failed - " + e.getMessage()); - } catch (final AbstractMethodError errE) { - support = false; - DBMetaData.mLogger.warning("supportsExpressionsInOrderBy() failed - " + errE.getMessage()); - } - try { - this.dbmeta.supportsLikeEscapeClause(); - } catch (final SQLException e) { - support = false; - DBMetaData.mLogger.warning("supportsLikeEscapeClause() failed - " + e.getMessage()); - } catch (final AbstractMethodError errE) { - support = false; - DBMetaData.mLogger.warning("supportsLikeEscapeClause() failed - " + errE.getMessage()); - } - try { - this.dbmeta.supportsNamedParameters(); - } catch (final Exception e) { - support = false; - DBMetaData.mLogger.warning("supportsNamedParameters() failed - " + e.getMessage()); - } catch (final AbstractMethodError errE) { - support = false; - DBMetaData.mLogger.warning("supportsNamedParameters() failed - " + errE.getMessage()); - } - try { - this.dbmeta.supportsNonNullableColumns(); - } catch (final SQLException e) { - support = false; - DBMetaData.mLogger.warning("supportsNonNullableColumns() failed - " + e.getMessage()); - } catch (final AbstractMethodError errE) { - support = false; - DBMetaData.mLogger.warning("supportsNonNullableColumns() failed - " + errE.getMessage()); - } - try { - this.dbmeta.supportsOuterJoins(); - } catch (final SQLException e) { - support = false; - DBMetaData.mLogger.warning("supportsOuterJoins() failed - " + e.getMessage()); - } catch (final AbstractMethodError errE) { - support = false; - DBMetaData.mLogger.warning("supportsOuterJoins() failed - " + errE.getMessage()); - } - try { - this.dbmeta.supportsPositionedDelete(); - } catch (final SQLException e) { - support = false; - DBMetaData.mLogger.warning("supportsPositionedDelete() failed - " + e.getMessage()); - } catch (final AbstractMethodError errE) { - support = false; - DBMetaData.mLogger.warning("supportsPositionedDelete() failed - " + errE.getMessage()); - } - try { - this.dbmeta.supportsPositionedUpdate(); - } catch (final SQLException e) { - support = false; - DBMetaData.mLogger.warning("supportsPositionedUpdate() failed - " + e.getMessage()); - } catch (final AbstractMethodError errE) { - support = false; - DBMetaData.mLogger.warning("supportsPositionedUpdate() failed - " + errE.getMessage()); - } - try { - this.dbmeta.supportsResultSetConcurrency(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); - } catch (final SQLException e) { - support = false; - DBMetaData.mLogger.warning("supportsResultSetConcurrency(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY ) failed - " - + e.getMessage()); - } catch (final AbstractMethodError errE) { - support = false; - DBMetaData.mLogger.warning("supportsResultSetConcurrency(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY ) failed - " - + errE.getMessage()); - } - try { - this.dbmeta.supportsResultSetConcurrency(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE); - } catch (final SQLException e) { - support = false; - DBMetaData.mLogger.warning("supportsResultSetConcurrency(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE) failed - " - + e.getMessage()); - } catch (final AbstractMethodError errE) { - support = false; - DBMetaData.mLogger.warning("supportsResultSetConcurrency(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE) failed - " - + errE.getMessage()); - } - try { - this.dbmeta.supportsResultSetConcurrency(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); - } catch (final SQLException e) { - support = false; - DBMetaData.mLogger.warning("supportsResultSetConcurrency(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY ) failed - " - + e.getMessage()); - } catch (final AbstractMethodError errE) { - support = false; - DBMetaData.mLogger.warning("supportsResultSetConcurrency(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY ) failed - " - + errE.getMessage()); - } - try { - this.dbmeta.supportsResultSetConcurrency(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE); - } catch (final SQLException e) { - support = false; - DBMetaData.mLogger.warning("supportsResultSetConcurrency(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE) failed - " - + e.getMessage()); - } catch (final AbstractMethodError errE) { - support = false; - DBMetaData.mLogger.warning("supportsResultSetConcurrency(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE) failed - " - + errE.getMessage()); - } - try { - this.dbmeta.supportsResultSetConcurrency(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY); - } catch (final SQLException e) { - support = false; - DBMetaData.mLogger.warning("supportsResultSetConcurrency(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY ) failed - " - + e.getMessage()); - } catch (final AbstractMethodError errE) { - support = false; - DBMetaData.mLogger.warning("supportsResultSetConcurrency(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY ) failed - " - + errE.getMessage()); - } - try { - this.dbmeta.supportsResultSetConcurrency(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); - } catch (final SQLException e) { - support = false; - DBMetaData.mLogger.warning("supportsResultSetConcurrency(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE) failed - " - + e.getMessage()); - } catch (final AbstractMethodError errE) { - support = false; - DBMetaData.mLogger.warning("supportsResultSetConcurrency(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE) failed - " - + errE.getMessage()); - } - try { - this.dbmeta.supportsResultSetType(ResultSet.TYPE_FORWARD_ONLY); - } catch (final SQLException e) { - support = false; - DBMetaData.mLogger.warning("supportsResultSetType(ResultSet.TYPE_FORWARD_ONLY) failed - " + e.getMessage()); - } catch (final AbstractMethodError errE) { - support = false; - DBMetaData.mLogger.warning("supportsResultSetType(ResultSet.TYPE_FORWARD_ONLY) failed - " + errE.getMessage()); - } - try { - this.dbmeta.supportsResultSetType(ResultSet.TYPE_SCROLL_INSENSITIVE); - } catch (final SQLException e) { - support = false; - DBMetaData.mLogger.warning("supportsResultSetType(ResultSet.TYPE_SCROLL_INSENSITIVE) failed - " + e.getMessage()); - } catch (final AbstractMethodError errE) { - support = false; - DBMetaData.mLogger.warning("supportsResultSetType(ResultSet.TYPE_SCROLL_INSENSITIVE) failed - " + errE.getMessage()); - } - try { - this.dbmeta.supportsResultSetType(ResultSet.TYPE_SCROLL_SENSITIVE); - } catch (final SQLException e) { - support = false; - DBMetaData.mLogger.warning("supportsResultSetType(ResultSet.TYPE_SCROLL_SENSITIVE) failed - " + e.getMessage()); - } catch (final AbstractMethodError errE) { - support = false; - DBMetaData.mLogger.warning("supportsResultSetType(ResultSet.TYPE_SCROLL_SENSITIVE) failed - " + errE.getMessage()); - } - try { - this.dbmeta.supportsSchemasInDataManipulation(); - } catch (final SQLException e) { - support = false; - DBMetaData.mLogger.warning("supportsSchemasInDataManipulation() failed - " + e.getMessage()); - } catch (final AbstractMethodError errE) { - support = false; - DBMetaData.mLogger.warning("supportsSchemasInDataManipulation() failed - " + errE.getMessage()); - } - try { - this.dbmeta.supportsSchemasInIndexDefinitions(); - } catch (final SQLException e) { - support = false; - DBMetaData.mLogger.warning("supportsSchemasInIndexDefinitions() failed - " + e.getMessage()); - } catch (final AbstractMethodError errE) { - support = false; - DBMetaData.mLogger.warning("supportsSchemasInIndexDefinitions() failed - " + errE.getMessage()); - } - try { - this.dbmeta.supportsSchemasInPrivilegeDefinitions(); - } catch (final SQLException e) { - support = false; - DBMetaData.mLogger.warning("supportsSchemasInPrivilegeDefinitions() failed - " + e.getMessage()); - } catch (final AbstractMethodError errE) { - support = false; - DBMetaData.mLogger.warning("supportsSchemasInPrivilegeDefinitions() failed - " + errE.getMessage()); - } - try { - this.dbmeta.supportsSchemasInProcedureCalls(); - } catch (final SQLException e) { - support = false; - DBMetaData.mLogger.warning("supportsSchemasInProcedureCalls() failed - " + e.getMessage()); - } catch (final AbstractMethodError errE) { - support = false; - DBMetaData.mLogger.warning("supportsSchemasInProcedureCalls() failed - " + errE.getMessage()); - } - try { - this.dbmeta.supportsSchemasInTableDefinitions(); - } catch (final SQLException e) { - support = false; - DBMetaData.mLogger.warning("supportsSchemasInTableDefinitions() failed - " + e.getMessage()); - } catch (final AbstractMethodError errE) { - support = false; - DBMetaData.mLogger.warning("supportsSchemasInTableDefinitions() failed - " + errE.getMessage()); - } - try { - this.dbmeta.supportsSelectForUpdate(); - } catch (final SQLException e) { - support = false; - DBMetaData.mLogger.warning("supportsSelectForUpdate() failed - " + e.getMessage()); - } catch (final AbstractMethodError errE) { - support = false; - DBMetaData.mLogger.warning("supportsSelectForUpdate() failed - " + errE.getMessage()); - } - try { - this.dbmeta.supportsStoredProcedures(); - } catch (final SQLException e) { - support = false; - DBMetaData.mLogger.warning("supportsStoredProcedures() failed - " + e.getMessage()); - } catch (final AbstractMethodError errE) { - support = false; - DBMetaData.mLogger.warning("supportsStoredProcedures() failed - " + errE.getMessage()); - } - try { - this.dbmeta.supportsSubqueriesInComparisons(); - } catch (final SQLException e) { - support = false; - DBMetaData.mLogger.warning("supportsSubqueriesInComparisons() failed - " + e.getMessage()); - } catch (final AbstractMethodError errE) { - support = false; - DBMetaData.mLogger.warning("supportsSubqueriesInComparisons() failed - " + errE.getMessage()); - } - try { - this.dbmeta.supportsSubqueriesInExists(); - } catch (final SQLException e) { - support = false; - DBMetaData.mLogger.warning("supportsSubqueriesInExists() failed - " + e.getMessage()); - } catch (final AbstractMethodError errE) { - support = false; - DBMetaData.mLogger.warning("supportsSubqueriesInExists() failed - " + errE.getMessage()); - } - try { - this.dbmeta.supportsSubqueriesInIns(); - } catch (final SQLException e) { - support = false; - DBMetaData.mLogger.warning("supportsSubqueriesInIns() failed - " + e.getMessage()); - } catch (final AbstractMethodError errE) { - support = false; - DBMetaData.mLogger.warning("supportsSubqueriesInIns() failed - " + errE.getMessage()); - } - try { - this.dbmeta.supportsSubqueriesInQuantifieds(); - } catch (final SQLException e) { - support = false; - DBMetaData.mLogger.warning("supportsSubqueriesInQuantifieds() failed - " + e.getMessage()); - } catch (final AbstractMethodError errE) { - support = false; - DBMetaData.mLogger.warning("supportsSubqueriesInQuantifieds() failed - " + errE.getMessage()); - } - try { - this.dbmeta.supportsTableCorrelationNames(); - } catch (final SQLException e) { - support = false; - DBMetaData.mLogger.warning("supportsTableCorrelationNames() failed - " + e.getMessage()); - } catch (final AbstractMethodError errE) { - support = false; - DBMetaData.mLogger.warning("supportsTableCorrelationNames() failed - " + errE.getMessage()); - } - try { - this.dbmeta.supportsTransactionIsolationLevel(Connection.TRANSACTION_NONE); - } catch (final SQLException e) { - support = false; - DBMetaData.mLogger.warning("supportsTransactionIsolationLevel(Connection.TRANSACTION_NONE) failed - " + e.getMessage()); - } catch (final AbstractMethodError errE) { - support = false; - DBMetaData.mLogger.warning("supportsTransactionIsolationLevel(Connection.TRANSACTION_NONE) failed - " - + errE.getMessage()); - } - try { - this.dbmeta.supportsTransactionIsolationLevel(Connection.TRANSACTION_READ_COMMITTED); - } catch (final SQLException e) { - support = false; - DBMetaData.mLogger.warning("supportsTransactionIsolationLevel(Connection.TRANSACTION_READ_COMMITTED) failed - " - + e.getMessage()); - } catch (final AbstractMethodError errE) { - support = false; - DBMetaData.mLogger.warning("supportsTransactionIsolationLevel(Connection.TRANSACTION_READ_COMMITTED) failed - " - + errE.getMessage()); - } - try { - this.dbmeta.supportsTransactionIsolationLevel(Connection.TRANSACTION_READ_UNCOMMITTED); - } catch (final SQLException e) { - support = false; - DBMetaData.mLogger.warning("supportsTransactionIsolationLevel(Connection.TRANSACTION_READ_UNCOMMITTED) failed - " - + e.getMessage()); - } catch (final AbstractMethodError errE) { - support = false; - DBMetaData.mLogger.warning("supportsTransactionIsolationLevel(Connection.TRANSACTION_READ_UNCOMMITTED) failed - " - + errE.getMessage()); - } - try { - this.dbmeta.supportsTransactionIsolationLevel(Connection.TRANSACTION_REPEATABLE_READ); - } catch (final SQLException e) { - support = false; - DBMetaData.mLogger.warning("supportsTransactionIsolationLevel(Connection.TRANSACTION_REPEATABLE_READ) failed - " - + e.getMessage()); - } catch (final AbstractMethodError errE) { - support = false; - DBMetaData.mLogger.warning("supportsTransactionIsolationLevel(Connection.TRANSACTION_REPEATABLE_READ) failed - " - + errE.getMessage()); - } - try { - this.dbmeta.supportsTransactionIsolationLevel(Connection.TRANSACTION_SERIALIZABLE); - } catch (final SQLException e) { - support = false; - DBMetaData.mLogger.warning("supportsTransactionIsolationLevel(Connection.TRANSACTION_SERIALIZABLE) failed - " - + e.getMessage()); - } catch (final AbstractMethodError errE) { - support = false; - DBMetaData.mLogger.warning("supportsTransactionIsolationLevel(Connection.TRANSACTION_SERIALIZABLE) failed - " - + errE.getMessage()); - } - try { - this.dbmeta.supportsTransactions(); - } catch (final SQLException e) { - support = false; - DBMetaData.mLogger.warning("supportsTransactions() failed - " + e.getMessage()); - } catch (final AbstractMethodError errE) { - support = false; - DBMetaData.mLogger.warning("supportsTransactions() failed - " + errE.getMessage()); - } - - return support; - }*/ - - /* private static final Parameter[] handleUnsupportParameterMetaData(final String sqlText) { - int numParams = 0; - for (int i = 0; i < sqlText.length(); i++) { - if (sqlText.charAt(i) == '?') { - numParams++; - } - } - final Parameter[] parameters = new Parameter[numParams]; - for (int i = 1; i <= numParams; i++) { - final Parameter currParam = new Parameter(); - final String paramname = "param" + String.valueOf(i); - currParam.setName(paramname); - final String javatype = "java.lang.String"; - final String sqltype = "VARCHAR"; - final int precision = 0; - final int scale = 0; - final String paramType = "IN"; - final boolean isNullable = true; - - currParam.setJavaType(javatype); - currParam.setSqlType(sqltype); - currParam.setNumericPrecision(precision); - currParam.setNumericScale(scale); - currParam.setOrdinalPosition(i); - currParam.setParamType(paramType); - currParam.setIsNullable(isNullable); - - parameters[i - 1] = currParam; - } - return parameters; - }*/ - - /** - * added by Bobby to retrieve the resultset metadata of a procedure - * - * @param pcatalog Catalog (package) name of the procedure - * @param pschema Schema name of the procdure - * @param pname Name of the procedure - * @param columnName Name of the column - * @return Procedure resultset encapsulated in a Procedure object - * @throws SQLException, NullPointerException - */ - /*public static final Procedure getProcResultSetColumns(final String pcatalog, final String pschema, final String pname, final String columnName,final Connection connection) - throws SQLException, NullPointerException { - - String errMsg = ""; - String cstmtString = ""; - int colCount = 0; - boolean isFunction = false; - boolean hasParameters = true; - // indicates if the procedure is within a package or standalone - boolean isPackaged = true; - - final Procedure procResult = new Procedure(pname, pcatalog, pschema, new String("PROCEDURE")); - final ResultSetColumn resultCol = new ResultSetColumn(); - final ArrayList paramIndices = new ArrayList(); // arraylist to hold the indices of the - // paramters that return resultsets - final ArrayList result = new ArrayList(); // arraylist to hold ResultSetColumns objects - - // check if the procedure is within a package or not - if (pcatalog.trim().equalsIgnoreCase("") || pcatalog == null) { - isPackaged = false; - } - try { - final DatabaseMetaData dbmeta = connection.getMetaData(); - ResultSet rs = dbmeta.getProcedureColumns(pcatalog, pschema, pname, columnName); - - // loop to identify if the procedure is actually a function - while (rs.next()) { - if (rs.getShort("COLUMN_TYPE") == DatabaseMetaData.procedureColumnReturn) { - // this is a function, so set the flag to true - isFunction = true; - } - } - - rs = dbmeta.getProcedureColumns(pcatalog, pschema, pname, columnName); - - // get the count of the parameters - while (rs.next()) { - colCount++; - } - - // check if the procedure has parameters or not - if (colCount == 0) { - hasParameters = false; - } - - // construct the procedure execution command string - if (isFunction == true) { - cstmtString = "{ ? = call "; - // use the package name to qualify the procedure name if the procedure is within a - // package - if (isPackaged) { - cstmtString += pcatalog + "." + pname + "("; - } else { - cstmtString += pname + "("; - } - - for (int j = 1; j < colCount; j++) { - cstmtString += "?,"; - } - - // trim the last comma only if the procedure has any parameters - if (hasParameters) { - cstmtString = cstmtString.substring(0, cstmtString.length() - 1); - } - cstmtString += ") }"; - } else { - cstmtString = "call "; - // use the package name to qualify the procedure name if the procedure is within a - // package - if (isPackaged) { - cstmtString += pcatalog + "." + pname + "("; - } else { - cstmtString += pname + "("; - } - - for (int j = 0; j < colCount; j++) { - cstmtString += "?,"; - } - - // trim the last comma only if the procedure has any parameters - if (hasParameters) { - cstmtString = cstmtString.substring(0, cstmtString.length() - 1); - } - cstmtString += ")"; - } - - final CallableStatement cstmt = connection.prepareCall(cstmtString); - - rs = dbmeta.getProcedureColumns(pcatalog, pschema, pname, columnName); - int paramIndex = 0; - - // loop through the list of parameters and register them - for (int j = 0; j < colCount; j++) { - rs.next(); - paramIndex++; - final String parameterName = rs.getString("COLUMN_NAME"); - int targetSqlType = rs.getInt("DATA_TYPE"); - final int colType = rs.getShort("COLUMN_TYPE"); - final String type_Name = rs.getString("TYPE_NAME"); - cstmt.setNull(paramIndex, targetSqlType); - - 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("OTHER")) { - targetSqlType = java.sql.Types.OTHER; - paramIndices.add(Integer.valueOf(String.valueOf(paramIndex))); - } - cstmt.registerOutParameter(paramIndex, targetSqlType); - } catch (final SQLException e) { - 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("OTHER")) { - targetSqlType = java.sql.Types.OTHER; - paramIndices.add(Integer.valueOf(String.valueOf(paramIndex))); - } - cstmt.registerOutParameter(paramIndex, targetSqlType); - } catch (final SQLException e) { - e.printStackTrace(); - throw e; - } - } - } - - // execute the stored procedure - final boolean resultsAvailable = cstmt.execute(); - int count = -1; - final int numResults = paramIndices.size(); - - final Iterator paramIdxIter = paramIndices.iterator(); - - // iterate through the resultsets returned, whose indices are stored in the arraylist - while (paramIdxIter.hasNext()) { - final ArrayList resultArray = new ArrayList(); // arraylist to hold the objects of - // ResultSetColumn - count += 1; - // get the index (from the arraylist) of the parameter which is a resultset - final int index = ((Integer) paramIdxIter.next()).intValue(); - ResultSet paramRS; - ResultSetMetaData rsmd; - // if the resultset returns nothing, set the metadata object to null - try { - paramRS = (ResultSet) cstmt.getObject(index); - rsmd = paramRS.getMetaData(); - } catch (final SQLException e) { - rsmd = null; - } - - int rsmdColCount = 0; - if (rsmd != null) { - rsmdColCount = rsmd.getColumnCount(); - } - // scroll through the resultset column information - for (int i = 1; i <= rsmdColCount; i++) { - final ResultSetColumn currCol = new ResultSetColumn(); - currCol.setOrdinalPosition(i); - currCol.setName(rsmd.getColumnName(i)); - currCol.setLabel(rsmd.getColumnLabel(i)); - currCol.setSqlType(DBMetaData.getSQLTypeDescription(rsmd.getColumnType(i))); - currCol.setJavaType((String) DBMetaData.SQLTOJAVATYPES.get(DBMetaData.getSQLTypeDescription(rsmd.getColumnType(i)))); - - if (rsmd.isNullable(i) == DatabaseMetaData.columnNullable) { - currCol.setIsNullable(true); - } else { - currCol.setIsNullable(false); - } - // add ResultSetColumn object to the arraylist - final boolean addToArray = resultArray.add(currCol); - } - - // add the arraylist having ResultSetColumn objects to the ResultSetColumns object - // now add this ResultSetColumns object to the arraylist object (result) - if (resultArray.size() > 0) { - final ResultSetColumns rsColbj = new ResultSetColumns(); - rsColbj.setColumns(resultArray); - rsColbj.setName(pname + "_" + count); - result.add(rsColbj); - } - } - } catch (final SQLException e) { - // resultset column metadata not supported - e.printStackTrace(); - errMsg = e.getLocalizedMessage(); - throw e; - } catch (final NullPointerException npe) { - npe.printStackTrace(); - errMsg = npe.getLocalizedMessage(); - throw npe; - } catch (final Exception e) { - // resultset column metadata not supported - e.printStackTrace(); - errMsg = e.getLocalizedMessage(); - } - - // add the arraylist object to the Procedure object - procResult.setResultSetColumns(result); - return procResult; - }*/ - - /** - * added by Bobby to retrieve the resultset metadata of an SQL query - * - * @param pcatalog Catalog (package) name of the procedure - * @param pschema Schema name of the procdure - * @param pname Name of the procedure - * @param sqlText Text of the procedure/function - * @return Procedure resultset encapsulated in a Procedure object - * @throws SQLException, NullPointerException - */ - /* public static final Procedure getQueryResultSet(final String pcatalog, final String pschema, final String pname, final String sqlText,final Connection connection) - throws SQLException, NullPointerException { - String errMsg = ""; - final Procedure procResult = new Procedure(pname, pcatalog, pschema, new String("PROCEDURE")); - ResultSetColumns[] result = null; - final ArrayList resultList = new ArrayList(); - - try { - final DatabaseMetaData dbmeta = connection.getMetaData(); - final Statement stmt = connection.createStatement(); - - // retrieve the names of the fields in the select query - // required if the query contains calculated fields - final String[] queryFields = getQueryFields(sqlText); - - // execute the SQL query and retrieve the resultset - final ResultSet rs = stmt.executeQuery(sqlText); - final ResultSetMetaData rsmd = rs.getMetaData(); - final int numColumns = rsmd.getColumnCount(); - - for (int i = 1; i <= numColumns; i++) { - final ResultSetColumn resultCol = new ResultSetColumn(); - resultCol.setOrdinalPosition(i); - final String colName = rsmd.getColumnName(i).trim(); - final String colLabel = rsmd.getColumnLabel(i).trim(); - - // check if the column names/labels are returned as null - // (this happens in the case of derived/calculated fields and no aliases are - // provided) - if (colName.equalsIgnoreCase("") || colName == null) { - // parse the query string to extract derived field names - final String strFieldName = queryFields[i - 1]; - resultCol.setName(strFieldName); - } else { - resultCol.setName(colName); - } - - if (colLabel.equalsIgnoreCase("") || colLabel == null) { - // parse the query string to extract derived field names - final String strFieldName = queryFields[i - 1]; - resultCol.setLabel(strFieldName); - } else { - resultCol.setLabel(colLabel); - } - - resultCol.setSqlType(DBMetaData.getSQLTypeDescription(rsmd.getColumnType(i))); - resultCol.setJavaType((String) DBMetaData.SQLTOJAVATYPES.get(DBMetaData.getSQLTypeDescription(rsmd.getColumnType(i)))); - - if (rsmd.isNullable(i) == DatabaseMetaData.columnNullable) { - resultCol.setIsNullable(true); - } else { - resultCol.setIsNullable(false); - } - - // add ResultSetColumn object to the arraylist - final boolean addToArray = resultList.add(resultCol); - } - - result = new ResultSetColumns[1]; - result[0] = new ResultSetColumns(); - // add the arraylist to the ResultSetColumns object - result[0].setColumns(resultList); - result[0].setName(pname + "_0"); - } catch (final SQLException e) { - e.printStackTrace(); - errMsg = e.getLocalizedMessage(); - throw e; - } catch (final NullPointerException npe) { - npe.printStackTrace(); - errMsg = npe.getLocalizedMessage(); - throw npe; - } catch (final Exception e) { - // resultset column metadata not supported - e.printStackTrace(); - errMsg = e.getLocalizedMessage(); - } - - // add the ResultSetColumns array to the Procedure object - procResult.setResultSetColumns(result); - return procResult; - }*/ - - /** - * added by Bobby to retrieve the text of a procedure/function - * - * @param Procedure Procedure object representing a procedure or function - * @return String Text of the procedure or function - */ - /*public static final String getProcedureText(final Procedure proc,final Connection connection) { - String procText = ""; - String stmtString = ""; - final String procName = proc.getName(); - final String packageName = proc.getCatalog(); - - // construct the SQL select query depending on whether - // the procedure or function is part of a package or not - if (packageName.equals("") || packageName == null) { - stmtString = "select text from user_source where name = '" + procName + "'"; - } else { - stmtString = "select text from user_source where name = '" + packageName + "'"; - } - - try { - final Statement stmt = connection.createStatement(); - final ResultSet rsProcText = stmt.executeQuery(stmtString); - - while (rsProcText.next()) { - procText += rsProcText.getString(1); - } - } catch (final SQLException e) { - e.printStackTrace(); - //this.errMsg = e.getLocalizedMessage(); - } - - return procText; - }*/ - - /** - * added by Bobby to parse an SQL query string and return a String array containing the names of - * the select fields - * - * @param sqlQuery the SQL query string to be parsed - * @return String array containing the list of derived field names - */ - private static final String[] getQueryFields(final String sqlQuery) { - String[] strFieldNames = null; - - final String queryString = sqlQuery.toUpperCase().trim(); - final int fromIndex = queryString.indexOf("FROM"); - - // extract the part of the query between the SELECT and the FROM keywords - final String searchString = sqlQuery.substring(7, fromIndex); - - final StringTokenizer stFields = new StringTokenizer(searchString,","); - final int noTokens = stFields.countTokens(); - strFieldNames = new String[noTokens]; - - int tokenNo = 0; - // extract the string tokens fom the query (the derived columns) - while (stFields.hasMoreTokens()) { - strFieldNames[tokenNo] = stFields.nextToken().trim(); - tokenNo++; - } - - return strFieldNames; - } -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/model/metadata/ForeignKeyColumn.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/model/metadata/ForeignKeyColumn.java deleted file mode 100755 index 86ab1252e..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/model/metadata/ForeignKeyColumn.java +++ /dev/null @@ -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 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 fkColumns = Collections.emptyList(); - - if ((rs != null) && rs.next()) { - fkColumns = new ArrayList(); - - 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; - } - } -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/model/metadata/IndexColumn.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/model/metadata/IndexColumn.java deleted file mode 100755 index 97d151d4a..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/model/metadata/IndexColumn.java +++ /dev/null @@ -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 createIndexList(final ResultSet rs) throws SQLException { - List indices = Collections.emptyList(); - - if ((rs != null) && rs.next()) { - indices = new ArrayList(); - - 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; - } - } -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/model/metadata/KeyColumn.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/model/metadata/KeyColumn.java deleted file mode 100755 index f1468133d..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/model/metadata/KeyColumn.java +++ /dev/null @@ -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 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 pkColumns = Collections.emptyList(); - - if ((rs != null) && rs.next()) { - pkColumns = new ArrayList(); - - 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; - } -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/model/metadata/ResultSetColumn.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/model/metadata/ResultSetColumn.java deleted file mode 100755 index 8ed5359c2..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/model/metadata/ResultSetColumn.java +++ /dev/null @@ -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; - } -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/model/metadata/ResultSetColumns.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/model/metadata/ResultSetColumns.java deleted file mode 100755 index e50d3894c..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/model/metadata/ResultSetColumns.java +++ /dev/null @@ -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 columns = null; - - /** - ** Holds the name of the ResultSet - **/ - private String name = null; - - /** - ** constructor - **/ - public ResultSetColumns() { - columns = new ArrayList(); - } - - /** 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 ResultSetColumn - ** objects; - */ - private void setColumns(final ArrayList columns) { - this.columns = columns; - } - - /** adds a ResultsetColumn object to this list. - * @param rsCol ResultSetColumn - ** 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 ResultSetColumn - ** 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 ResultSetColumn - ** 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); - } -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/model/metadata/Table.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/model/metadata/Table.java deleted file mode 100755 index 3a14a4bb0..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/model/metadata/Table.java +++ /dev/null @@ -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 indexList; // List of IndexColumn objects - private List fkColumnList; // List of KeyColumn objects (PK cols) - private List 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 getIndexList() { - return indexList; - } - - /** - * Set the index list. - * - * @param newList Index list - */ - public void setIndexList(final List 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 newList) { - indexList = Collections.emptyList(); - - if ((newList != null) && (newList.size() != 0)) { - indexList = new ArrayList(); - - 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 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 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 newList) { - pkColumnList = Collections.emptyList(); - - if ((newList != null) && (newList.size() != 0)) { - pkColumnList = new ArrayList(); - - 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 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 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 newList) { - fkColumnList = Collections.emptyList(); - - if ((newList != null) && (newList.size() != 0)) { - fkColumnList = new ArrayList(); - - 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 - } - } - } -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/model/metadata/TableColumn.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/model/metadata/TableColumn.java deleted file mode 100755 index a0afd1363..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/model/metadata/TableColumn.java +++ /dev/null @@ -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; - } -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/model/metadata/messages/Bundle.properties b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/model/metadata/messages/Bundle.properties deleted file mode 100755 index b980429ce..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/model/metadata/messages/Bundle.properties +++ /dev/null @@ -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! diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/model/runtime/DBConnectionInfo.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/model/runtime/DBConnectionInfo.java deleted file mode 100755 index 94e223be8..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/model/runtime/DBConnectionInfo.java +++ /dev/null @@ -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:@[:<1521>]: - 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; - } -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/model/runtime/DataBases.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/model/runtime/DataBases.java deleted file mode 100755 index 9db1ac488..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/model/runtime/DataBases.java +++ /dev/null @@ -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; - } -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/model/runtime/DatabaseModel.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/model/runtime/DatabaseModel.java deleted file mode 100755 index 1e4ed408b..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/model/runtime/DatabaseModel.java +++ /dev/null @@ -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; -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/model/runtime/DatabaseModelImpl.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/model/runtime/DatabaseModelImpl.java deleted file mode 100755 index 92b0a84f7..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/model/runtime/DatabaseModelImpl.java +++ /dev/null @@ -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; -// } -//} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/model/runtime/Db2DataAccess.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/model/runtime/Db2DataAccess.java deleted file mode 100755 index ab43f9755..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/model/runtime/Db2DataAccess.java +++ /dev/null @@ -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; -// } -//} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/model/runtime/DerbyDataAccess.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/model/runtime/DerbyDataAccess.java deleted file mode 100755 index 72ee32b86..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/model/runtime/DerbyDataAccess.java +++ /dev/null @@ -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; -// } -//} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/model/runtime/OracleDataAccess.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/model/runtime/OracleDataAccess.java deleted file mode 100755 index 58b1e04db..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/model/runtime/OracleDataAccess.java +++ /dev/null @@ -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; -// } -//} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/model/runtime/SqlServerDataAccess.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/model/runtime/SqlServerDataAccess.java deleted file mode 100755 index 6a9a95122..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/model/runtime/SqlServerDataAccess.java +++ /dev/null @@ -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; -// } -//} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/model/runtime/messages/Bundle.properties b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/model/runtime/messages/Bundle.properties deleted file mode 100755 index 8d7875e70..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/model/runtime/messages/Bundle.properties +++ /dev/null @@ -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. diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/security/Base64.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/security/Base64.java deleted file mode 100755 index 6328bbac5..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/security/Base64.java +++ /dev/null @@ -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); -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/security/Base64Impl.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/security/Base64Impl.java deleted file mode 100755 index 7e71f6fbc..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/security/Base64Impl.java +++ /dev/null @@ -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); - } - } -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/transaction/GlobalId.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/transaction/GlobalId.java deleted file mode 100755 index 002f05539..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/transaction/GlobalId.java +++ /dev/null @@ -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 Narayana Rallabandi - * @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; - } - -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/transaction/LocalId.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/transaction/LocalId.java deleted file mode 100755 index bc68a4d3b..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/transaction/LocalId.java +++ /dev/null @@ -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 Narayana Rallabandi - * @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)); - } -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/transaction/TransactionHelper.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/transaction/TransactionHelper.java deleted file mode 100755 index ff4575055..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/transaction/TransactionHelper.java +++ /dev/null @@ -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; -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/transaction/TransactionStateUtility.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/transaction/TransactionStateUtility.java deleted file mode 100755 index db6ad971a..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/transaction/TransactionStateUtility.java +++ /dev/null @@ -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 + ")"; - } - } - -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/transaction/XAResourceImpl.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/transaction/XAResourceImpl.java deleted file mode 100755 index 012baa875..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/transaction/XAResourceImpl.java +++ /dev/null @@ -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; - } - } - } -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/transaction/XidFactory.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/transaction/XidFactory.java deleted file mode 100755 index 00afd6aa4..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/transaction/XidFactory.java +++ /dev/null @@ -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; - } - -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/transaction/XidImpl.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/transaction/XidImpl.java deleted file mode 100755 index 051163513..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/transaction/XidImpl.java +++ /dev/null @@ -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 Narayana Rallabandi - * @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; - } -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/util/AlertsUtil.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/util/AlertsUtil.java deleted file mode 100755 index 3cebe11fd..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/util/AlertsUtil.java +++ /dev/null @@ -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; - } -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/util/ConfigReader.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/util/ConfigReader.java deleted file mode 100755 index 852809ee7..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/util/ConfigReader.java +++ /dev/null @@ -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(); - } - } -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/util/Configuration.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/util/Configuration.java deleted file mode 100755 index c2c667ed3..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/util/Configuration.java +++ /dev/null @@ -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; - } - } -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/util/DebugLog.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/util/DebugLog.java deleted file mode 100755 index 1b5917ffe..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/util/DebugLog.java +++ /dev/null @@ -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(); - } - } -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/util/Description.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/util/Description.java deleted file mode 100755 index f2f0fb309..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/util/Description.java +++ /dev/null @@ -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(); -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/util/ExtensionFilter.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/util/ExtensionFilter.java deleted file mode 100755 index 5482d3d14..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/util/ExtensionFilter.java +++ /dev/null @@ -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; - } -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/util/ReadWriteTextFile.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/util/ReadWriteTextFile.java deleted file mode 100755 index 5a4d4bda2..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/util/ReadWriteTextFile.java +++ /dev/null @@ -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)); - } -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/util/XMLCharUtil.java b/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/util/XMLCharUtil.java deleted file mode 100755 index 4cb767d40..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/src/com/sun/jbi/jdbcbc/util/XMLCharUtil.java +++ /dev/null @@ -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 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 \ No newline at end of file diff --git a/ojc-core/jdbcbc/jdbcbcimpl/test/com/sun/jbi/jdbcbc/packaging/wsdls/TestJdbc.wsdl b/ojc-core/jdbcbc/jdbcbcimpl/test/com/sun/jbi/jdbcbc/packaging/wsdls/TestJdbc.wsdl deleted file mode 100755 index f597c2992..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/test/com/sun/jbi/jdbcbc/packaging/wsdls/TestJdbc.wsdl +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - insert into testJBI values ('60', ?) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ojc-core/jdbcbc/jdbcbcimpl/test/com/sun/jbi/jdbcbc/packaging/wsdls/echo.wsdl b/ojc-core/jdbcbc/jdbcbcimpl/test/com/sun/jbi/jdbcbc/packaging/wsdls/echo.wsdl deleted file mode 100755 index ae71d6bb8..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/test/com/sun/jbi/jdbcbc/packaging/wsdls/echo.wsdl +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/ojc-core/jdbcbc/jdbcbcimpl/test/com/sun/jbi/jdbcbc/packaging/wsdls/echo.xsd b/ojc-core/jdbcbc/jdbcbcimpl/test/com/sun/jbi/jdbcbc/packaging/wsdls/echo.xsd deleted file mode 100755 index fbf31d870..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/test/com/sun/jbi/jdbcbc/packaging/wsdls/echo.xsd +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - diff --git a/ojc-core/jdbcbc/jdbcbcimpl/test/com/sun/jbi/jdbcbc/security/Base64Test.java b/ojc-core/jdbcbc/jdbcbcimpl/test/com/sun/jbi/jdbcbc/security/Base64Test.java deleted file mode 100755 index 13cfcb15f..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/test/com/sun/jbi/jdbcbc/security/Base64Test.java +++ /dev/null @@ -1,68 +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] - */ - -/* - * @(#)Base64Test.java - * - * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved. - * - * END_HEADER - DO NOT EDIT - */ - -package com.sun.jbi.jdbcbc.security; - -import junit.framework.TestCase; - -public class Base64Test extends TestCase { - - /** Creates a new instance of Base64Test */ - public Base64Test() { - } - - public void testEncode() { - try { - Base64 base64 = Base64Impl.getInstance(); - String credential = "Administrator:STC"; - String actual = base64.encode(credential).trim(); - String expected = "QWRtaW5pc3RyYXRvcjpTVEM="; - - assertEquals("Incorrect encoded results received", expected, actual); - - } catch (Exception e) { - fail("Received unexpected exception: " + e.getMessage()); - } - } - - public void testDecode() { - try { - Base64 base64 = Base64Impl.getInstance(); - String encoded = "QWRtaW5pc3RyYXRvcjpTVEM="; - String expected = "Administrator:STC"; - String actual = base64.decode(encoded); - - assertEquals("Incorrect encoded results received", expected, actual); - - } catch (Exception e) { - fail("Received unexpected exception: " + e.getMessage()); - } - } -} diff --git a/ojc-core/jdbcbc/jdbcbcimpl/test/com/sun/jbi/jdbcbc/testDir/config.properties b/ojc-core/jdbcbc/jdbcbcimpl/test/com/sun/jbi/jdbcbc/testDir/config.properties deleted file mode 100755 index 00f7cc8ce..000000000 --- a/ojc-core/jdbcbc/jdbcbcimpl/test/com/sun/jbi/jdbcbc/testDir/config.properties +++ /dev/null @@ -1,2 +0,0 @@ -#Tue Apr 10 14:00:18 PDT 2007 -Threads=10 diff --git a/ojc-core/jdbcbc/nbactions.xml b/ojc-core/jdbcbc/nbactions.xml deleted file mode 100755 index 5658d512b..000000000 --- a/ojc-core/jdbcbc/nbactions.xml +++ /dev/null @@ -1,72 +0,0 @@ - - - - clean - - * - - - clean - - - true - - - - build - - * - - - install - - - true - - - - test - - * - - - package - - - false - - - - rebuild - - * - - - clean - install - - - true - - - - CUSTOM-testreport - testreport - - surefire-report:report-only - - - true - - - - CUSTOM-allreports - allreports - - site - - - true - - - diff --git a/ojc-core/jdbcbc/packaging/nbactions.xml b/ojc-core/jdbcbc/packaging/nbactions.xml deleted file mode 100755 index 5658d512b..000000000 --- a/ojc-core/jdbcbc/packaging/nbactions.xml +++ /dev/null @@ -1,72 +0,0 @@ - - - - clean - - * - - - clean - - - true - - - - build - - * - - - install - - - true - - - - test - - * - - - package - - - false - - - - rebuild - - * - - - clean - install - - - true - - - - CUSTOM-testreport - testreport - - surefire-report:report-only - - - true - - - - CUSTOM-allreports - allreports - - site - - - true - - - diff --git a/ojc-core/jdbcbc/packaging/pom.xml b/ojc-core/jdbcbc/packaging/pom.xml deleted file mode 100755 index b27e8c9bf..000000000 --- a/ojc-core/jdbcbc/packaging/pom.xml +++ /dev/null @@ -1,186 +0,0 @@ - - - - - - - package-common - open-jbi-components - 1.1 - ../../build-common/package-common - - 4.0.0 - open-jbi-components - jdbcbc-installer - sun-jdbc-binding - ${jdbcbc.artifact.version} - jdbc packaging description - - - - META-INF - src - true - - *.xml - - - - - - maven-dependency-plugin - - - ${project.artifactId}-fetch-deps - generate-sources - - copy-dependencies - - - ${project.build.outputDirectory}/lib - true - true - - - - - - maven-surefire-plugin - - true - - - - maven-jar-plugin - - - ${project.build.outputDirectory}/META-INF/MANIFEST.MF - - - - - - - org.apache.felix - maven-bundle-plugin - - - bundle-manifest - process-classes - - manifest - - - - - - - sun-jdbc-binding - JDBC binding - JDBC binding - ${OSGI_VERSION} - <_removeheaders>${OSGI_MANIFEST_REMOVE_HEADERS}, Export-Package - - *;-noimport:=true - - - lib/jdbcbcimpl.jar, - lib/wsdl4j.jar, - lib/resolver.jar, - lib/componentsl.jar, - lib/common-util.jar, - lib/qos.jar, - lib/wsdl4jext.jar, - lib/jsr173_api.jar - - - javax.xml.namespace, - !net.java.hulp.measure, - !xmlbean, - !org.apache.xmlbeans.impl.xpath.saxon, - !com.sun.org.apache.xerces.internal.impl.dv.util, - !org.apache.xmlbeans.impl.xb.xsdschema, - !org.apache.xmlbeans, - *;-nouses:=true - - - - - - - - - - - - open-jbi-components - jdbcbcimpl - true - - - open-jbi-components - wsdl4j - true - - - open-jbi-components - resolver - true - - - open-jbi-components - componentsl - true - - - open-jbi-components - qos - true - - - open-jbi-components - common-util - true - - - open-jbi-components - wsdl4jext - true - - - open-jbi-components - customized-xmlbeans - true - - - xmlbeans - jsr173_api - true - - - diff --git a/ojc-core/jdbcbc/packaging/src/componentConfiguration.xml b/ojc-core/jdbcbc/packaging/src/componentConfiguration.xml deleted file mode 100755 index 504306543..000000000 --- a/ojc-core/jdbcbc/packaging/src/componentConfiguration.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - 10 - - - \ No newline at end of file diff --git a/ojc-core/jdbcbc/packaging/src/componentConfiguration.xsd b/ojc-core/jdbcbc/packaging/src/componentConfiguration.xsd deleted file mode 100755 index ae031c22d..000000000 --- a/ojc-core/jdbcbc/packaging/src/componentConfiguration.xsd +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ojc-core/jdbcbc/packaging/src/jbi.xml b/ojc-core/jdbcbc/packaging/src/jbi.xml deleted file mode 100755 index a63ad47f5..000000000 --- a/ojc-core/jdbcbc/packaging/src/jbi.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - ${project.name} - JDBC binding - - - com.sun.jbi.jdbcbc.JDBCBindingLifeCycle - - lib/jdbcbcimpl.jar - lib/wsdl4j.jar - lib/resolver.jar - lib/componentsl.jar - lib/common-util.jar - lib/qos.jar - lib/wsdl4jext.jar - lib/customized-xmlbeans.jar - lib/jsr173_api.jar - - com.sun.jbi.jdbcbc.bootstrap.JDBCBindingBootstrap - - lib/jdbcbcimpl.jar - lib/componentsl.jar - - - 10 - - - com.sun.jbi.jdbcbc.JDBCBindingDeployer - com.sun.jbi.jdbcbc.SQLSEBindingLifeCycle - com.sun.jbi.jdbcbc.EndpointBean - com.sun.jbi.jdbcbc.InboundMessageProcessor - com.sun.jbi.jdbcbc.OutboundMessageProcessor - com.sun.jbi.jdbcbc.OutboundReceiver - com.sun.jbi.jdbcbc.JDBCNormalizer - com.sun.jbi.jdbcbc.JDBCDenormalizer - com.sun.jbi.jdbcbc.configuration.RuntimeConfiguration - - - diff --git a/ojc-core/jdbcbc/pom.xml b/ojc-core/jdbcbc/pom.xml deleted file mode 100755 index 0db3fd7fc..000000000 --- a/ojc-core/jdbcbc/pom.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - ojc-common - open-jbi-components - 1.1 - ../build-common/ojc-common - - 4.0.0 - open-jbi-components - jdbcbc-top - pom - jdbcbc-top - ${jdbcbc.artifact.version} - Top-level Build for jdbcbc-top - - install - - - - jdbcbcimpl - packaging - sqlse-packaging - - diff --git a/ojc-core/jdbcbc/sqlse-packaging/nbactions.xml b/ojc-core/jdbcbc/sqlse-packaging/nbactions.xml deleted file mode 100755 index 5658d512b..000000000 --- a/ojc-core/jdbcbc/sqlse-packaging/nbactions.xml +++ /dev/null @@ -1,72 +0,0 @@ - - - - clean - - * - - - clean - - - true - - - - build - - * - - - install - - - true - - - - test - - * - - - package - - - false - - - - rebuild - - * - - - clean - install - - - true - - - - CUSTOM-testreport - testreport - - surefire-report:report-only - - - true - - - - CUSTOM-allreports - allreports - - site - - - true - - - diff --git a/ojc-core/jdbcbc/sqlse-packaging/pom.xml b/ojc-core/jdbcbc/sqlse-packaging/pom.xml deleted file mode 100755 index d09788f70..000000000 --- a/ojc-core/jdbcbc/sqlse-packaging/pom.xml +++ /dev/null @@ -1,118 +0,0 @@ - - - - - - - package-common - open-jbi-components - 1.1 - ../../build-common/package-common - - 4.0.0 - open-jbi-components - sqlse-installer - sun-sql-engine - ${jdbcbc.artifact.version} - sqlse packaging description - - - - META-INF - src - true - - *.xml - - - - - - maven-dependency-plugin - - - ${project.artifactId}-fetch-deps - generate-sources - - copy-dependencies - - - ${project.build.outputDirectory}/lib - true - true - - - - - - maven-surefire-plugin - - true - - - - - - - open-jbi-components - jdbcbcimpl - - - open-jbi-components - wsdl4j - - - open-jbi-components - resolver - - - open-jbi-components - componentsl - - - open-jbi-components - qos - - - open-jbi-components - common-util - - - open-jbi-components - wsdl4jext - - - open-jbi-components - customized-xmlbeans - - - xmlbeans - jsr173_api - - - diff --git a/ojc-core/jdbcbc/sqlse-packaging/src/componentConfiguration.xml b/ojc-core/jdbcbc/sqlse-packaging/src/componentConfiguration.xml deleted file mode 100755 index 3e7e86ba2..000000000 --- a/ojc-core/jdbcbc/sqlse-packaging/src/componentConfiguration.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - 10 - - - \ No newline at end of file diff --git a/ojc-core/jdbcbc/sqlse-packaging/src/componentConfiguration.xsd b/ojc-core/jdbcbc/sqlse-packaging/src/componentConfiguration.xsd deleted file mode 100755 index ae031c22d..000000000 --- a/ojc-core/jdbcbc/sqlse-packaging/src/componentConfiguration.xsd +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ojc-core/jdbcbc/sqlse-packaging/src/jbi.xml b/ojc-core/jdbcbc/sqlse-packaging/src/jbi.xml deleted file mode 100755 index 880b1e17e..000000000 --- a/ojc-core/jdbcbc/sqlse-packaging/src/jbi.xml +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - ${project.name} - SQL Service Engine - - - com.sun.jbi.jdbcbc.SQLSELifeCycle - - lib/jdbcbcimpl.jar - lib/wsdl4j.jar - lib/resolver.jar - lib/componentsl.jar - lib/common-util.jar - lib/qos.jar - lib/wsdl4jext.jar - lib/customized-xmlbeans.jar - lib/jsr173_api.jar - - com.sun.jbi.jdbcbc.bootstrap.JDBCBindingBootstrap - - lib/jdbcbcimpl.jar - lib/componentsl.jar - - - 10 - - - - com.sun.jbi.jdbcbc.SQLSEBindingLifeCycle - com.sun.jbi.jdbcbc.EndpointBean - - com.sun.jbi.jdbcbc.OutboundMessageProcessor - com.sun.jbi.jdbcbc.OutboundReceiver - com.sun.jbi.jdbcbc.JDBCNormalizer - com.sun.jbi.jdbcbc.JDBCDenormalizer - com.sun.jbi.jdbcbc.SQLSEServiceUnitManager - com.sun.jbi.jdbcbc.configuration.SQLSERuntimeConfiguration - - - diff --git a/ojc-core/pom.xml b/ojc-core/pom.xml index cbdca689e..e67bf7ab7 100755 --- a/ojc-core/pom.xml +++ b/ojc-core/pom.xml @@ -80,7 +80,6 @@ httpsoapbc imsbc - jdbcbc jmsbc ldapbc smtpbc @@ -165,7 +164,6 @@ httpsoapbc/packaging iepse/packaging imsbc/packaging - jdbcbc/packaging jmsbc/packaging ldapbc/packaging mqbc/packaging