Search in sources :

Example 6 with GatewayArtifactSynchronizerProperties

use of org.wso2.carbon.apimgt.impl.dto.GatewayArtifactSynchronizerProperties in project carbon-apimgt by wso2.

the class GatewayArtifactsMgtDBUtil method initDatasource.

private static synchronized void initDatasource() throws APIManagerDatabaseException {
    if (artifactSynchronizerDataSource == null) {
        if (log.isDebugEnabled()) {
            log.debug("Initializing data source");
        }
        GatewayArtifactSynchronizerProperties gatewayArtifactSynchronizerProperties = ServiceReferenceHolder.getInstance().getAPIManagerConfigurationService().getAPIManagerConfiguration().getGatewayArtifactSynchronizerProperties();
        String artifactSynchronizerDataSourceName = gatewayArtifactSynchronizerProperties.getArtifactSynchronizerDataSource();
        if (artifactSynchronizerDataSourceName != null) {
            try {
                Context ctx = new InitialContext();
                artifactSynchronizerDataSource = (DataSource) ctx.lookup(artifactSynchronizerDataSourceName);
            } catch (NamingException e) {
                throw new APIManagerDatabaseException("Error while looking up the data " + "source: " + artifactSynchronizerDataSourceName, e);
            }
        } else {
            log.error(artifactSynchronizerDataSourceName + " not defined in api-manager.xml.");
        }
    }
}
Also used : InitialContext(javax.naming.InitialContext) Context(javax.naming.Context) GatewayArtifactSynchronizerProperties(org.wso2.carbon.apimgt.impl.dto.GatewayArtifactSynchronizerProperties) APIManagerDatabaseException(org.wso2.carbon.apimgt.api.APIManagerDatabaseException) NamingException(javax.naming.NamingException) InitialContext(javax.naming.InitialContext)

Aggregations

GatewayArtifactSynchronizerProperties (org.wso2.carbon.apimgt.impl.dto.GatewayArtifactSynchronizerProperties)6 Test (org.junit.Test)4 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)4 RealmService (org.wso2.carbon.user.core.service.RealmService)4 HashSet (java.util.HashSet)3 TreeMap (java.util.TreeMap)3 QName (javax.xml.namespace.QName)3 InvocationOnMock (org.mockito.invocation.InvocationOnMock)3 API (org.wso2.carbon.apimgt.api.model.API)3 APIIdentifier (org.wso2.carbon.apimgt.api.model.APIIdentifier)3 Documentation (org.wso2.carbon.apimgt.api.model.Documentation)3 SubscribedAPI (org.wso2.carbon.apimgt.api.model.SubscribedAPI)3 Tier (org.wso2.carbon.apimgt.api.model.Tier)3 URITemplate (org.wso2.carbon.apimgt.api.model.URITemplate)3 ImportExportAPI (org.wso2.carbon.apimgt.impl.importexport.ImportExportAPI)3 ServiceReferenceHolder (org.wso2.carbon.apimgt.impl.internal.ServiceReferenceHolder)3 Organization (org.wso2.carbon.apimgt.persistence.dto.Organization)3 PublisherAPI (org.wso2.carbon.apimgt.persistence.dto.PublisherAPI)3 GenericArtifact (org.wso2.carbon.governance.api.generic.dataobjects.GenericArtifact)3 Resource (org.wso2.carbon.registry.core.Resource)3