Examples of DataService


Examples of org.wso2.carbon.dataservices.core.engine.DataService

  /**
   * @see DataServiceRequest#processRequest()
   */
  @Override
  public OMElement processRequest() throws DataServiceFault {
    DataService dataService = this.getDataService();
    boolean inTx = false;
    /* not inside a nested transaction, i.e. boxcarring/batch-requests  */
    if (!dataService.isInTransaction()) {
      /* an active transaction has already started by the transaction manager,
       * e.g. external JMS transaction */
      if (dataService.isEnableXA() && !dataService.getDSSTxManager().hasNoActiveTransaction()) {
        /* signal we are inside a transaction */
        dataService.beginTransaction();
        inTx = true;
      }
    }
    OMElement result = processSingleRequest();
    if (inTx) {
      /* signal the end of transaction, this wont necessarily commit the
       * transaction, it will be done by the external transaction creator */
      dataService.endTransaction();
    }
    return result;
  }
View Full Code Here

Examples of org.wso2.carbon.dataservices.core.engine.DataService

    }
    return result;
  }
 
  private OMElement processSingleRequest() throws DataServiceFault {
    DataService dataService = this.getDataService();
    String requestName = this.getRequestName();
    /* set the operation name to invoke and the parameters */
    DSOMDataSource ds = new DSOMDataSource(dataService, requestName, this.getParams());

    /* check if the current request has a result, if so, return the OMElement */
    if (dataService.hasResultForRequest(this.getRequestName())) {
      /* pre-fetch data - only if streaming is happening */
      if (!this.isDisableStreaming()) {
          ds.prefetchData();
      }
     
      String resultWrapper = dataService.getResultWrapperForRequest(requestName);
      String ns = dataService.getNamespaceForRequest(requestName);
      OMElement responseElement = new OMSourcedElementImpl(new QName(ns,
          resultWrapper), OMAbstractFactory.getOMFactory(), ds);
      Query defQuery = dataService.getCallableRequest(
          requestName).getCallQueryGroup().getDefaultCallQuery().getQuery();
      /*
       * Checks if the result has to be pre-built, because in situations like having an
       * output-event-trigger, for XPath expression evaluations, the following operation
       * must be done, or it wont work.
View Full Code Here

Examples of org.wso2.carbon.dataservices.core.engine.DataService

   * @return Pooled data source
   * @throws Exception
   */
  private DataSource setupDataSource(Config config, DataSource externalDS) throws Exception {
    ConnectionFactory connectionFactory;
    DataService dataService = config.getDataService();
    String jdbcURL = config.getProperty(RDBMS.PROTOCOL);
    String userName = config.getProperty(RDBMS.USER);
    String password = DBUtils.resolvePasswordValue(config.getDataService(),
        config.getProperty(RDBMS.PASSWORD));
    String removeAbandoned = config.getProperty(RDBMS.REMOVE_ABANDONED);
    String removeAbandonedTimeout = config.getProperty(RDBMS.REMOVE_ABONDONED_TIMEOUT);
    String logAbandoned = config.getProperty(RDBMS.LOG_ABANDONED);
    String transactionIsolation = config.getProperty(RDBMS.TRANSACTION_ISOLATION);
    int defaultTransactionIsolation = RDBMSUtils.toIntTransactionIsolation(transactionIsolation);
   
    /* XA data source */
    boolean isXADS = (config instanceof RDBMSConfig) && ((RDBMSConfig) config).hasXADS();

    if (isXADS) {
      if (!dataService.isEnableXA()) {
        throw new DataServiceFault(
            "Internal XADataSource: XA transaction support must be enabled to use XADataSources");
      }
      XADataSourceInfo xaInfo = ((RDBMSConfig) config).getXADataSourceInfo()
      connectionFactory = new DataSourceXAConnectionFactory(
          dataService.getDSSTxManager().getTransactionManager(), xaInfo.getXADataSource());
    } else if (externalDS != null) {
      if (externalDS instanceof XADataSource) {
        if (!dataService.isEnableXA()) {
          throw new DataServiceFault(
              "External XADataSource: XA transaction support must be enabled to use XADataSources");
        }
        connectionFactory = new DataSourceXAConnectionFactory(
            dataService.getDSSTxManager().getTransactionManager(), (XADataSource) externalDS);
      } else {
        connectionFactory = new DataSourceConnectionFactory(externalDS);
      }
    } else {
      connectionFactory = new DriverManagerConnectionFactory(jdbcURL, userName, password);
      if (dataService.isEnableXA()) {
        connectionFactory = new LocalXAConnectionFactory(
            dataService.getDSSTxManager().getTransactionManager(), connectionFactory);       
      }
    }
    this.pool = createGenericConnectionFactory(config);
    AbandonedConfig abandonedConfig = new AbandonedConfig();
    if (!DBUtils.isEmptyString(logAbandoned)) {
      abandonedConfig.setLogAbandoned(Boolean.parseBoolean(logAbandoned));
    }
    if (!DBUtils.isEmptyString(removeAbandonedTimeout)) {
      abandonedConfig.setRemoveAbandonedTimeout(Integer.parseInt(removeAbandonedTimeout));
    }
    if (!DBUtils.isEmptyString(removeAbandoned)) {
      abandonedConfig.setRemoveAbandoned(Boolean.parseBoolean(removeAbandoned));
    }

    String validationQuery = config.getProperty(RDBMS.VALIDATION_QUERY);
    boolean hasValQuery = validationQuery != null && validationQuery.trim().length() > 0;
    PoolableConnectionFactory factory = new PoolableConnectionFactory(connectionFactory,
        this.pool, null, hasValQuery ? validationQuery : null, false, true,
        defaultTransactionIsolation, abandonedConfig);

    this.pool.setFactory(factory);
    PoolingDataSource dataSource;
    if (dataService.isEnableXA()) {
      /* for XA-transactions */
      dataSource = new ManagedDataSource(this.pool,
          ((XAConnectionFactory) connectionFactory).getTransactionRegistry());
    } else {
      dataSource = new PoolingDataSource(this.pool);
View Full Code Here

Examples of org.wso2.carbon.dataservices.core.engine.DataService

   * @see DataService
   */
    @SuppressWarnings("unchecked")
  public static DataService createDataService(OMElement dbsElement,
      String dsLocation) throws DataServiceFault {
    DataService dataService = null;
    try {
      /* get service name */
      String serviceName = dbsElement.getAttributeValue(new QName(DBSFields.NAME));
      String serviceNamespace = dbsElement.getAttributeValue(new QName(DBSFields.SERVICE_NAMESPACE));
      if (DBUtils.isEmptyString(serviceNamespace)) {
        serviceNamespace = DBConstants.WSO2_DS_NAMESPACE;
      }
      String defaultNamespace = dbsElement.getAttributeValue(new QName(DBSFields.BASE_URI));
      if (DBUtils.isEmptyString(defaultNamespace)) {
        defaultNamespace = serviceNamespace;
      }
     
      String serviceGroup = dbsElement.getAttributeValue(new QName(DBSFields.SERVICE_GROUP));
      if (DBUtils.isEmptyString(serviceGroup)) {
        serviceGroup = serviceName;
      }
     
      /* get the description */
      OMElement descEl = dbsElement.getFirstChildWithName(new QName(DBSFields.DESCRIPTION));
      String description = null;
      if (descEl != null) {
        description = descEl.getText();
      }
     
      String serviceStatus = dbsElement.getAttributeValue(
          new QName(DBSFields.SERVICE_STATUS));
     
      boolean batchRequestsEnabled = false;
      boolean boxcarringEnabled = false;

      String batchRequestsEnabledStr = dbsElement.getAttributeValue(
          new QName(DBSFields.ENABLE_BATCH_REQUESTS));
      if (batchRequestsEnabledStr != null) {
        batchRequestsEnabled = Boolean.parseBoolean(batchRequestsEnabledStr);
      }

      String boxcarringEnabledStr = dbsElement.getAttributeValue(
          new QName(DBSFields.ENABLE_BOXCARRING));
      if (boxcarringEnabledStr != null) {
        boxcarringEnabled = Boolean.parseBoolean(boxcarringEnabledStr);
      }

      String emptyParamFixStr = dbsElement.getAttributeValue(
          new QName(DBSFields.EMPTY_PARAM_FIX));
      boolean emptyParamFix = false;
      if (emptyParamFixStr != null) {
        emptyParamFix = Boolean.parseBoolean(emptyParamFixStr);
      }
     
      boolean disableStreaming = false;
      String disableStreamingStr = dbsElement.getAttributeValue(
          new QName(DBSFields.DISABLE_STREAMING));
      if (disableStreamingStr != null) {
        disableStreaming = Boolean.parseBoolean(disableStreamingStr);
      }

      /* transaction management */
      boolean enableDTP = false;
      String enableDTPStr = dbsElement.getAttributeValue(new QName(DBSFields.ENABLE_DTP));
      if (enableDTPStr != null) {
        enableDTP = Boolean.parseBoolean(enableDTPStr);
      }
     
      /* txManagerName property */
      String userTxJNDIName = dbsElement.getAttributeValue(
          new QName(DBSFields.TRANSACTION_MANAGER_JNDI_NAME));     
   
      dataService = new DataService(serviceName, description,
          defaultNamespace, dsLocation, serviceStatus,
          batchRequestsEnabled, boxcarringEnabled, enableDTP,
          userTxJNDIName, emptyParamFix);
     
      /* set service group */
      dataService.setServiceGroup(serviceGroup);
     
      /* set service namespace */
      dataService.setServiceNamespace(serviceNamespace);
           
      /* set disable streaming */
      dataService.setDisableStreaming(disableStreaming);
     
      /* add the password manager */
      Iterator<OMElement> passwordMngrItr = dbsElement.getChildrenWithName(
          new QName(SecurityConstants.PASSWORD_MANAGER_SIMPLE));
      if (passwordMngrItr.hasNext()) {
        SecretResolver secretResolver = SecretResolverFactory.create(dbsElement, false);
        dataService.setSecretResolver(secretResolver);
      }
         
      /* add the configs */
      for (Iterator<OMElement> itr = dbsElement.getChildrenWithName(
          new QName(DBSFields.CONFIG)); itr.hasNext();) {
        dataService.addConfig(ConfigFactory.createConfig(dataService, itr.next()));   
      }

      /* add event triggers */
      for (Iterator<OMElement> itr = dbsElement.getChildrenWithName(
          new QName(DBSFields.EVENT_TRIGGER)); itr.hasNext();) {
        dataService.addEventTrigger(
            EventTriggerFactory.createEventTrigger(dataService,  itr.next()));
      }

      /* add the queries */
      for (Iterator<OMElement> itr = dbsElement
          .getChildrenWithName(new QName(DBSFields.QUERY)); itr.hasNext();) {
        dataService.addQuery(QueryFactory.createQuery(dataService, itr.next()));
      }

      /* add the operations */
      for (Iterator<OMElement> itr = dbsElement
          .getChildrenWithName(new QName(DBSFields.OPERATION)); itr.hasNext();) {
        dataService.addOperation(OperationFactory.createOperation(dataService,
            itr.next()));
      }

      /* add the resources */
      for (Iterator<OMElement> itr = dbsElement.getChildrenWithName(
          new QName(DBSFields.RESOURCE)); itr.hasNext();) {
        dataService.addResource(ResourceFactory.createResource(dataService,
            itr.next()));
      }
   
      /* init the data service object */
      dataService.init();
     
      for (String opName : dataService.getOperationNames()) {
        Result result = dataService.getOperation(opName).getCallQueryGroup()
            .getDefaultCallQuery().getQuery().getResult();
        if (result != null && result.getResultType() == DBConstants.ResultTypes.RDF ) {
          throw new DataServiceFault("Cannot create operation "
              + dataService.getOperation(opName) + "for the result output type RDF");
        }
      }
      /* add necessary equivalent batch operation for the above defined operation */
      if (dataService.isBatchRequestsEnabled()) {
        List<Operation> tmpOpList = new ArrayList<Operation>();
        Operation operation;
        for (String opName : dataService.getOperationNames()) {
          if (isBoxcarringOps(opName)) {
            /* skip boxcarring operations */
            continue;
          }
          operation = dataService.getOperation(opName);
          if (isBatchCompatible(operation)) {
            /* this is a batch operation and the parent operation is also given */
            Operation batchOp = new Operation(
                operation.getDataService(),
                operation.getName()  + DBConstants.BATCH_OPERATON_NAME_SUFFIX,
                "batch operation for '" + operation.getName() + "'",
                operation.getCallQueryGroup(), true,
                operation, operation.isDisableStreamingRequest(),
                operation.isDisableStreamingEffective());
            batchOp.setReturnRequestStatus(operation.isReturnRequestStatus());
            tmpOpList.add(batchOp);
          }
        }
        /* the operations are added outside the loop that iterates the operation list,
         * if we add it inside the loop while iterating, we will get a concurrent modification exception */
        for (Operation tmpOp : tmpOpList) {
          dataService.addOperation(tmpOp);
        }
      }

      /* register data service for event service notification */
      DataServicesDSComponent.registerEventBrokerServiceListener(dataService);
 
View Full Code Here

Examples of org.wso2.carbon.dataservices.core.engine.DataService

  /**
   * @see DataServiceRequest#processRequest()
   */
  @Override
  public OMElement processRequest() throws DataServiceFault {
    DataService dataService = this.getDataService();
    try {
      /* signal that we are batch processing */
      DBUtils.setBatchProcessing(true);
      List<SingleDataServiceRequest> requests = this.getDSRequests();
      int count = requests.size();
      /* set the batch request count in TL */
      DBUtils.setBatchRequestCount(count);
      /* begin a new data service transaction */
      dataService.beginTransaction();
      /* dispatch individual requests */
      for (int i = 0; i < count; i++) {
        /* set the current batch request number in TL */
        DBUtils.setBatchRequestNumber(i);
        /* execute/enqueue request */
        requests.get(i).dispatch();
      }
      /* end transaction */
      dataService.endTransaction();
      /* no result in batch requests */
      return null;
    } catch (DataServiceFault e) {
      dataService.rollbackTransaction();
      throw e;
    } finally {
      /* release participants */
      releaseParticipantResources();
      clearParticipants();
 
View Full Code Here

Examples of org.wso2.carbon.dataservices.core.engine.DataService

      DSSessionManager.getCurrentRequestBox().clear();
      /* set the status to boxcarring */
      DSSessionManager.setBoxcarring(true);
    } else if (BoxcarringOps.END_BOXCAR.equals(this.getRequestName())) {
      /* execute all the stored requests */
      DataService dataService = this.getDSRequest().getDataService();
      try {
        dataService.beginTransaction();
          OMElement lastRequestResult = DSSessionManager.getCurrentRequestBox().execute();
          dataService.endTransaction();
          return lastRequestResult;
      } catch (DataServiceFault e) {
        dataService.rollbackTransaction();
        throw new DataServiceFault(e, "Error in boxcarring end");
      } finally {
        DSSessionManager.getCurrentRequestBox().clear();
        DSSessionManager.setBoxcarring(false);
        TLParamStore.clear();
View Full Code Here

Examples of org.wso2.carbon.dataservices.core.engine.DataService

  private DataService generateService(String datasourceId, String dbName,
      String[] schemas, String[] tableNames, DatabaseMetaData metaData,String serviceNamespace,String serviceName)
      throws DataServiceFault, SQLException {
    //String serviceName = dbName + DBConstants.DataServiceGenerator.SERVICE_NAME_SUFFIX;
    DataService dataService = new DataService(serviceName,
        DBConstants.DataServiceGenerator.SINGLE_SERVICE_DESCRIPTION,null, null, DBConstants.DataServiceGenerator.ACTIVE,
        false, false, false, null, true);
    this.setConfig(dataService, datasourceId);
    if (DBUtils.isEmptyString(serviceNamespace)) {
      dataService.setServiceNamespace(DBConstants.WSO2_DS_NAMESPACE);
    } else {
      dataService.setServiceNamespace(serviceNamespace);
    }
    if (schemas.length != 0) {
      for (String schema : schemas) {
        makeService(dbName, tableNames, metaData, dataService, schema);
      }
View Full Code Here

Examples of org.wso2.carbon.dataservices.core.engine.DataService

      String schema, String datasourceId,String serviceNamespace) throws SQLException,
      DataServiceFault {
   
    for (String tableName : tableNames) {
      String serviceName = tableName + DBConstants.DataServiceGenerator.SERVICE_NAME_SUFFIX;
      DataService dataService = new DataService(serviceName,
          DBConstants.DataServiceGenerator.MUTLIPLE_SERVICE_DESCRIPTION, null, null, DBConstants.DataServiceGenerator.ACTIVE,
          false, false, false, null, true);
      if (DBUtils.isEmptyString(serviceNamespace)) {
        dataService.setServiceNamespace(DBConstants.WSO2_DS_NAMESPACE);
      } else {
        dataService.setServiceNamespace(serviceNamespace);
      }
      this.setConfig(dataService, datasourceId);
      String tablePrimaryKey = this.getPrimaryKey(metaData, dbName,
          schema, tableName);
      this.addOperations(dataService, schema, metaData, dbName,
View Full Code Here

Examples of org.wso2.carbon.dataservices.core.engine.DataService

  public static OMElement dispatch(MessageContext msgContext) throws DataServiceFault {
    DataServiceRequest request = DataServiceRequest.createDataServiceRequest(msgContext);
    OMElement result = request.dispatch();
    if (result == null) {
      DataService ds = request.getDataService();
      String requestName = request.getRequestName();     
      if (!ds.hasResultForRequest(requestName) && ds.isReturningRequestStatus(requestName)) {
        /* in-only and returning the request status */
        result = getRequestSuccessElement();
      }     
    }
    return result;
View Full Code Here

Examples of org.wso2.carbon.dataservices.core.engine.DataService

  public static void deployDataService(AxisConfiguration axisConfig,
      byte[] wsdlContent) throws DataServiceFault {
    try {
      AxisService axisService = getAxisServiceFromWSDL(wsdlContent);
      String serviceName = axisService.getName();
      DataService dataService = createDataServiceFromAxisService(axisService);
      String dsContents = DataServiceSerializer.serializeDataService(dataService).toString();
      writeToRepository(axisConfig, serviceName, dsContents);
    } catch (DataServiceFault e) {
      log.error("Error in deploying contract first data service", e);
      throw e;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.