/*
(non-Javadoc)

@see com.ibm.wsspi.sib.core.SICoreConnection#getSIXAResource()
974206
@Override
    public SIXAResource getSIXAResource()
                    throws SIConnectionUnavailableException, SIConnectionDroppedException,
                    SIErrorException
    {
        if (TraceComponent.isAnyTracingEnabled() && CoreSPIConnection.tc.isEntryEnabled())
            SibTr.entry(CoreSPIConnection.tc, "getSIXAResource", this);
        // See if this connection has been closed
        checkNotClosed();
        checkMPStarted();

        if (TraceComponent.isAnyTracingEnabled() && CoreSPIConnection.tc.isEntryEnabled())
            SibTr.exit(CoreSPIConnection.tc, "getSIXAResource");
        //sanjay liberty change transaction
        return _txManager.createXAResource(true);
    }
191325
public static String getXAResourceEndFlagString(int flag) {
        switch (flag) {
            case XAResource.TMFAIL:
                return "TMFAIL (" + flag + ')'; 

            case XAResource.TMSUCCESS:
                return "TMSUCCESS (" + flag + ')'; 

            case XAResource.TMSUSPEND:
                return "TMSUSPEND (" + flag + ')'; 
        }

        return "UNKNOWN XA RESOURCE END FLAG (" + flag + ')'; 
    }
998075
private IDataSource getDataSource(HttpServletRequest request) throws DataSourceNotFoundException {
        String contextPath = request.getContextPath();
        String requestURI = request.getRequestURI();

        String path = contextPath == null
                ? requestURI
                : requestURI.substring(contextPath.length());

        if (path.equals("/") || path.isEmpty()) {
            final String baseURL = FragmentRequestParserBase.extractBaseURL(request, config);
            return new IndexDataSource(baseURL, dataSources);
        }

        String dataSourceName = path.substring(1);
        IDataSource dataSource = dataSources.get(dataSourceName);
        if (dataSource == null) {
            throw new DataSourceNotFoundException(dataSourceName);
        }
        return dataSource;
    }
883204
protected WebResource getRawWebResource() {
    final com.sun.jersey.api.client.Client client = getJerseyClient();
    return client.resource(getUrl()).path(API_PATH);
  }
707349
DataSource getDataSource() {
        if (com.ibm.websphere.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_WAS.isLoggable(Level.FINER)) {
            LoggingUtil.SESSION_LOGGER_WAS.entering(methodClassName, methodNames[GET_DATA_SOURCE]);
        }

        if (dataSource != null)
            return dataSource;

        try {

            //            Properties p = new Properties();
            //
            //            p.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
            //            InitialContext ic = new javax.naming.InitialContext(p);
            beginDBContext(); // PK06395/d321615
            //            dataSource = (DataSource) ic.lookup(_smc.getJNDIDataSourceName());

            ResourceConfig rc = this.getDatabaseStoreService().getResourceConfigFactory().createResourceConfig("javax.sql.DataSource");
            rc.setResAuthType(ResourceConfig.AUTH_CONTAINER);
            rc.setSharingScope(ResourceConfig.SHARING_SCOPE_SHAREABLE);
            rc.setIsolationLevel(Connection.TRANSACTION_READ_COMMITTED);
            //            ResRef.APPLICATION, // resAuth - org.eclipse.jst.j2ee.common.ResAuthTypeBase.APPLICATION=
            //            ResRef.SHAREABLE, // resSharingScope - org.eclipse.jst.j2ee.common.ResSharingScopeType.SHAREABLE
            //            ResRef.TRANSACTION_READ_COMMITTED); // resIsolationLevel - com.ibm.ejs.models.base.extensions.commonext.IsolationLevelKind.TRANSACTION_READ_COMMITTED
            dataSource = (DataSource) this.getDatabaseStoreService().getDataSourceFactory().createResource(rc);

            //            dataSource = (DataSource)SessionMgrComponentImpl.getDataSourceFactory().createResource(null); // direct JNDI lookup
            endDBContext(); // PK06395/d321615
            return dataSource;

        } catch (Exception e) {
            com.ibm.ws.ffdc.FFDCFilter.processException(e, "com.ibm.ws.session.store.db.DatabaseHashMap.getDataSource", "558", this);
            LoggingUtil.SESSION_LOGGER_WAS.logp(Level.SEVERE, methodClassName, methodNames[GET_DATA_SOURCE], "DatabaseHashMap.dataSrcErr");
            LoggingUtil.SESSION_LOGGER_WAS.logp(Level.SEVERE, methodClassName, methodNames[GET_DATA_SOURCE], "CommonMessage.exception", e);
            dataSource = null;
        }
        return null;
    }
532015
public boolean isSameRM(XAResource xares) throws XAException {

        if (!(xares instanceof JDBCXAResource)) {
            return false;
        }

        return xaDataSource == ((JDBCXAResource) xares).getXADataSource();
    }
849230
@Override
    public String getjcaResource() {
        final boolean trace = TraceComponent.isAnyTracingEnabled();
        Collection<JCAResourceMBeanImpl> c = jcaMBeanRuntime.jcaResources.values();
        Iterator<JCAResourceMBeanImpl> i = c.iterator();
        String jcaResourceString = null;
        while (i.hasNext()) {
            JCAResourceMBeanImpl jcaResource = i.next();
            String resourceAdapter = jcaResource.getResourceAdapter();
            String s = jcaResource.getobjectName().toString();
            if (trace && tc.isDebugEnabled())
                Tr.debug(tc, "getjcaResource - ", s);
            //ResourceAdapter
            if (this.resourceAdapter.equals(resourceAdapter)) {
                // I believe we should only have one that matches, if we have more, its likely a bug.
                // A resource adapter should only have one jcaResource and a jca jcaResource can
                // have several connection factories.   While debugging this code I see we have two
                // jcaResources for this resource adapter.
                jcaResourceString = s;
            }
        }
        return jcaResourceString;
    }
409482
public static String getXAResourceStartFlagString(int flag) {
        switch (flag) {
            case XAResource.TMJOIN:
                return "TMJOIN (" + flag + ')'; 

            case XAResource.TMNOFLAGS:
                return "TMNOFLAGS (" + flag + ')'; 

            case XAResource.TMRESUME:
                return "TMRESUME (" + flag + ')'; 
        }

        return "UNKNOWN XA RESOURCE START FLAG (" + flag + ')'; 
    }
42105
@FFDCIgnore(Exception.class)
    public DataSource getDataSource() throws Exception {
        if (tc.isEntryEnabled())
            Tr.entry(tc, "getDataSource");

        // Retrieve the data source factory from the CustomLogProperties. This Factory should be set in the JTMConfigurationProvider
        // by the jdbc component using DeclarativeServices. TxRecoveryAgentImpl gets the factory from the ConfigurationProvider and
        // then sets it into CustomLogProperties.
        ResourceFactory dataSourceFactory = _customLogProperties.resourceFactory();

        if (dataSourceFactory != null) {
            if (tc.isDebugEnabled())
                Tr.debug(tc, "Using DataSourceFactory " + dataSourceFactory);
        } else {
            if (tc.isEntryEnabled())
                Tr.exit(tc, "getDataSource", "Null ResourceFactory InternalLogException");
            throw new InternalLogException("Failed to locate DataSource, null Resourcefactory", null);
        }

        try {
            nonTranDataSource = (DataSource) dataSourceFactory.createResource(null);
        } catch (Exception e) {
            //e.printStackTrace();
            if (tc.isEntryEnabled())
                Tr.exit(tc, "getDataSource", "Caught exception " + e + "throw InternalLogException");
            throw new InternalLogException("Failed to locate DataSource, caught exception ", null);
        }

/*
 * TEMPORARY This is waiting on fixes to DeclarativeServices which impact the jdbc component. At present it is
 * possible that the DataSource will have been set but that its associated jdbc driver service will still be initialising
 */
//        boolean refSet = false;
//        while (!refSet)
//        {
//            if (tc.isDebugEnabled())
//                Tr.debug(tc, "getDataSource after sleep");
//            try {
//
//                nonTranDataSource = (DataSource) dataSourceFactory.createResource(null);
//                if (tc.isDebugEnabled())
//                    Tr.debug(tc, "Non Tran dataSource is " + nonTranDataSource);
//                Connection conn = nonTranDataSource.getConnection();
//                if (tc.isDebugEnabled())
//                    Tr.debug(tc, "Established connection " + conn);
//
//                DatabaseMetaData mdata = conn.getMetaData();
//
//                String dbName = mdata.getDatabaseProductName();
//                if (tc.isDebugEnabled())
//                    Tr.debug(tc, "Database name " + dbName);
//
//                String dbVersion = mdata.getDatabaseProductVersion();
//                if (tc.isDebugEnabled())
//                    Tr.debug(tc, "Database version " + dbVersion);
//                refSet = true;
//            } catch (Exception e) {
//                // We will catch an exception if the DataSource is not yet fully formed
//                if (tc.isDebugEnabled())
//                    Tr.debug(tc, "Caught exception: " + e);
//            }
//
//            if (!refSet)
//                Thread.sleep(200);
//        }
// eof TEMPORARY

        if (tc.isEntryEnabled())
            Tr.exit(tc, "getDataSource", nonTranDataSource);
        return nonTranDataSource;
    }
313035
private static DataSource getDataSource(String params)
            throws JspException {
        DataSourceWrapper dataSource = new DataSourceWrapper();

        String[] paramString = new String[4];
        int escCount = 0;
        int aryCount = 0;
        int begin = 0;

        for (int index = 0; index < params.length(); index++) {
            char nextChar = params.charAt(index);
            if (TOKEN.indexOf(nextChar) != -1) {
                if (escCount == 0) {
                    paramString[aryCount] = params.substring(begin, index).trim();
                    begin = index + 1;
                    if (++aryCount > 4) {
                        throw new JspTagException(
                            Resources.getMessage("JDBC_PARAM_COUNT"));
                    }
                }
            }
            if (ESCAPE.indexOf(nextChar) != -1) {
                escCount++;
            } else {
                escCount = 0;
            }
        }
        paramString[aryCount] = params.substring(begin).trim();

	// use the JDBC URL from the parameter string
        dataSource.setJdbcURL(paramString[0]);

	// try to load a driver if it's present
        if (paramString[1] != null) {
            try {
                dataSource.setDriverClassName(paramString[1]);
            } catch (Exception ex) {
                throw new JspTagException(
                    Resources.getMessage("DRIVER_INVALID_CLASS",
					 ex.toString()), ex);
            }
	}

	// set the username and password
        dataSource.setUserName(paramString[2]);
        dataSource.setPassword(paramString[3]);

	return dataSource;
    }
1245022
protected XAResource getXAResource(ManagedConnection mc) throws ResourceException
   {
      TransactionalConnectionManager txCM = (TransactionalConnectionManager) cm;
      XAResource xaResource = null;

      if (cm.getConnectionManagerConfiguration().isWrapXAResource())
      {
         String eisProductName = null;
         String eisProductVersion = null;
         String jndiName = cm.getConnectionManagerConfiguration().getJndiName();
         boolean padXid = cm.getConnectionManagerConfiguration().isPadXid();
         Boolean isSameRMOverride = cm.getConnectionManagerConfiguration().isIsSameRMOverride();

         try
         {
            if (mc.getMetaData() != null)
            {
               eisProductName = mc.getMetaData().getEISProductName();
               eisProductVersion = mc.getMetaData().getEISProductVersion();
            }
         }
         catch (ResourceException re)
         {
            // Ignore
         }

         if (eisProductName == null)
            eisProductName = jndiName;

         if (eisProductVersion == null)
            eisProductVersion = jndiName;

         if (cm.getConnectionManagerConfiguration().isConnectable())
         {
            if (mc instanceof org.ironjacamar.core.spi.transaction.ConnectableResource)
            {
               ConnectableResource cr = (ConnectableResource) mc;

               xaResource = txCM.getTransactionIntegration()
                     .createConnectableXAResourceWrapper(mc.getXAResource(), padXid, isSameRMOverride, eisProductName,
                           eisProductVersion, jndiName, cr, statistics);
            }
            else if (txCM.getTransactionIntegration().isConnectableResource(mc))
            {
               xaResource = txCM.getTransactionIntegration()
                     .createConnectableXAResourceWrapper(mc.getXAResource(), padXid, isSameRMOverride, eisProductName,
                           eisProductVersion, jndiName, mc, statistics);
            }
         }

         if (xaResource == null)
         {
            XAResource xar = mc.getXAResource();

            if (!(xar instanceof org.ironjacamar.core.spi.transaction.xa.XAResourceWrapper))
            {
               boolean firstResource = txCM.getTransactionIntegration().isFirstResource(mc);

               xaResource = txCM.getTransactionIntegration()
                     .createXAResourceWrapper(xar, padXid, isSameRMOverride, eisProductName, eisProductVersion,
                           jndiName, firstResource, statistics);
            }
            else
            {
               xaResource = xar;
            }
         }
      }
      else
      {
         xaResource = mc.getXAResource();
      }

      return xaResource;
   }
726854
protected float getXSource(int x, float destLeft, float srcLeft,
			float widthRatio) {

		float dest = getXEncodedLocation(x, encoding);
		float source = getSource(dest, destLeft, srcLeft, widthRatio);

		return source;
	}
399686
@Override
    public SourceLineAnnotation getSourceLines() {
        if (sourceLines == null) {
            this.sourceLines = getSourceLinesForClass(className, sourceFileName);
        }
        return sourceLines;
    }
986293
XAResource reconnectRM() throws XAException
    {
        if (tc.isEntryEnabled())
            Tr.entry(tc, "reconnectRM");

        XAResource resource = null;

        XARecoveryWrapper wrapper = null;

        if (_recoveryData != null)
        {
            wrapper = _recoveryData.getXARecoveryWrapper();
        }

        if (wrapper == null && _recovery)
        {
            // We've not yet deserialized the log data - retry later "quietly"
            final XAException xae = new XAException(XAException.XA_RETRY);
            if (tc.isEntryEnabled())
                Tr.exit(tc, "reconnectRM", xae);
            throw xae;
        }

        // If we have already created an XAResource by this method we need to destroy it
        if (_recoveredRM != null)
        {
            _recoveredRM.closeConnection();
            _recoveredRM = null;
        }

        if (wrapper != null)
        {
            try
            {
                _recoveredRM = _recoveryData.getXARminst();
            } catch (XAException e)
            {
                FFDCFilter.processException(e, "com.ibm.ws.Transaction.JTA.JTAXAResourceImpl.reconnectRM", "607", this);
                if (tc.isEntryEnabled())
                    Tr.exit(tc, "reconnectRM", XAReturnCodeHelper.convertXACode(e.errorCode));
                XAException xae = e;
                // We will convert any RMERR from getXARminst to RMFAIL. We do not want to return RMERR on commit/rollback
                // unless it has come from the resource as that then implies completion and we can then end the tran. An error
                // trying to get the resource should not allow the tran to complete since we may leave a resource in-doubt.
                // The downside of this is that we may retry forever - so the user needs to zap the tran via the console.
                // We need to allow some heuristic error codes through if the RM has been installed.
                if (e.errorCode == XAException.XAER_RMERR)
                {
                    xae = (XAException) (new XAException(XAException.XAER_RMFAIL).initCause(e));
                }
                if (tc.isEntryEnabled())
                    Tr.exit(tc, "reconnectRM", xae);
                throw xae;
            } catch (Throwable t) // @D666666C
            {
                // Catch throwable in case we get OOM etc as we want to retry in this case.
                FFDCFilter.processException(t, "com.ibm.ws.Transaction.JTA.JTAXAResourceImpl.reconnectRM", "524", this);
                if (tc.isDebugEnabled())
                    Tr.debug(tc, "reconnectRM caught ", t);
                final XAException xae = (XAException) (new XAException(XAException.XAER_RMFAIL).initCause(t));
                if (tc.isEntryEnabled())
                    Tr.exit(tc, "reconnectRM", xae);
                throw xae;
            }
            // If we successfully created an XARmist, then get the XAResource to work with
            if (_recoveredRM != null)
                resource = _recoveredRM.getXaResource();
            // Update state from FAILED to IDLE so we dont reconnect unnecessarily
            if (resource != null)
                _state = IDLE; // D419307A
        }

        if (tc.isEntryEnabled())
            Tr.exit(tc, "reconnectRM", resource);
        return resource;
    }
358451
@Override
    public DataSource getSelectedDataSource() {
        final String dataSourceName = selectableDataSourceHolder.getCurrentSelectableDataSourceKey();
        if (dataSourceName != null) {
            return selectableDataSourceHolder.getSelectedDataSource();
        } else { // means no name set on thread local
            try {
                selectableDataSourceHolder.switchSelectableDataSourceKey(SlaveDBAccessor.MASTER_DB); // as default
                return selectableDataSourceHolder.getSelectedDataSource();
            } finally {
                selectableDataSourceHolder.switchSelectableDataSourceKey(null); // restore
            }
        }
    }
1116600
@Override
    public Scriptable getExtraMethodSource(Context cx) {
        if (hasSimpleContent()) {
            String src = toString();
            return ScriptRuntime.toObjectOrNull(cx, src);
        }
        return null;
    }
907018
@Override
    public String getSource() throws WidgetException {
        try {
            return getAttribute("src");
        } catch (Exception e) {
            throw new WidgetException("Error while fetching image source", getByLocator(), e);
        }
    }