org.apache.synapse.config.xml.MultiXMLConfigurationBuilder Java Examples

The following examples show how to use org.apache.synapse.config.xml.MultiXMLConfigurationBuilder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LoadBalancerServiceComponent.java    From attic-stratos with Apache License 2.0 6 votes vote down vote up
/**
 * Registers the Endpoint deployer.
 *
 * @param axisConfig         AxisConfiguration to which this deployer belongs
 * @param synapseEnvironment SynapseEnvironment to which this deployer belongs
 */
private void registerDeployer(AxisConfiguration axisConfig,
                              SynapseEnvironment synapseEnvironment)
        throws TenantAwareLoadBalanceEndpointException {
    SynapseConfiguration synCfg = synapseEnvironment
            .getSynapseConfiguration();
    DeploymentEngine deploymentEngine = (DeploymentEngine) axisConfig
            .getConfigurator();
    SynapseArtifactDeploymentStore deploymentStore = synCfg
            .getArtifactDeploymentStore();

    String synapseConfigPath = ServiceBusUtils
            .getSynapseConfigAbsPath(synapseEnvironment
                    .getServerContextInformation());
    String endpointDirPath = synapseConfigPath + File.separator
            + MultiXMLConfigurationBuilder.ENDPOINTS_DIR;

    for (Endpoint ep : synCfg.getDefinedEndpoints().values()) {
        if (ep.getFileName() != null) {
            deploymentStore.addRestoredArtifact(endpointDirPath
                    + File.separator + ep.getFileName());
        }
    }
    deploymentEngine.addDeployer(new EndpointDeployer(), endpointDirPath,
            ServiceBusConstants.ARTIFACT_EXTENSION);
}
 
Example #2
Source File: LoadBalancerServiceComponent.java    From attic-stratos with Apache License 2.0 6 votes vote down vote up
/**
 * Un-registers the Endpoint deployer.
 *
 * @param axisConfig         AxisConfiguration to which this deployer belongs
 * @param synapseEnvironment SynapseEnvironment to which this deployer belongs
 */
private void unregisterDeployer(AxisConfiguration axisConfig,
                                SynapseEnvironment synapseEnvironment)
        throws TenantAwareLoadBalanceEndpointException {
    if (axisConfig != null) {
        DeploymentEngine deploymentEngine = (DeploymentEngine) axisConfig
                .getConfigurator();
        String synapseConfigPath = ServiceBusUtils
                .getSynapseConfigAbsPath(synapseEnvironment
                        .getServerContextInformation());
        String endpointDirPath = synapseConfigPath + File.separator
                + MultiXMLConfigurationBuilder.ENDPOINTS_DIR;
        deploymentEngine.removeDeployer(endpointDirPath,
                ServiceBusConstants.ARTIFACT_EXTENSION);
    }
}
 
Example #3
Source File: MessageStoreStore.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@Override
protected void deleteFile(String fileName, SynapseConfiguration config) {

    File msDir = new File(configPath, MultiXMLConfigurationBuilder.MESSAGE_STORE_DIR);

    if (!msDir.exists()) {
        return;
    }

    File msFile = new File(msDir, fileName);

    config.getArtifactDeploymentStore().addBackedUpArtifact(
            msFile.getAbsolutePath());
    msFile.delete();
}
 
Example #4
Source File: SequencePersistenceTest.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
public void testSequencePersistence() throws IOException {
    System.out.println("Starting sequence persistence test...");

    String fileName = "seq1.xml";
    InputStream in = getClass().getClassLoader().getResourceAsStream(fileName);
    SequenceMediator seq = createSequence(in);
    seq.setFileName(fileName);
    in.close();
    synapseConfigSvc.getSynapseConfiguration().addSequence(seq.getName(), seq);
    getMediationPersistenceManager().saveItem(seq.getName(),
            ServiceBusConstants.ITEM_TYPE_SEQUENCE);
    System.out.println("Added new sequence : " + seq.getName());
    checkSavedSequence(seq);

    seq.addChild(new LogMediator());
    getMediationPersistenceManager().saveItem(seq.getName(),
            ServiceBusConstants.ITEM_TYPE_SEQUENCE);
    System.out.println("Updated sequence : " + seq.getName());
    checkSavedSequence(seq);

    synapseConfigSvc.getSynapseConfiguration().removeSequence(seq.getName());
    getMediationPersistenceManager().deleteItem(seq.getName(), fileName,
            ServiceBusConstants.ITEM_TYPE_SEQUENCE);
    System.out.println("Sequence : " + seq.getName() + " removed");
    hold();

    File file = new File(path + File.separator +
            MultiXMLConfigurationBuilder.SEQUENCES_DIR, fileName);
    if (file.exists()) {
        fail("The file : " + fileName + " has not been deleted");
    }
    System.out.println("Sequence file : " + fileName + " deleted successfully");

    checkSynapseXMLPersistence();

    System.out.println("Sequence persistence test completed successfully...");
}
 
Example #5
Source File: ProxyServicePersistenceTest.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
public void testProxyPersistence() throws IOException {
    System.out.println("Starting proxy persistence test...");

    String fileName = "proxy1.xml";
    InputStream in = getClass().getClassLoader().getResourceAsStream(fileName);
    ProxyService proxy = createProxy(in);
    in.close();
    proxy.setFileName(fileName);
    synapseConfigSvc.getSynapseConfiguration().addProxyService(proxy.getName(), proxy);
    getMediationPersistenceManager().saveItem(proxy.getName(),
            ServiceBusConstants.ITEM_TYPE_PROXY_SERVICE);
    System.out.println("Added new proxy : " + proxy.getName());
    checkSavedProxy(proxy);

    if (proxy.getTargetInLineInSequence() != null) {
        proxy.getTargetInLineInSequence().addChild(new LogMediator());
        getMediationPersistenceManager().saveItem(proxy.getName(),
                ServiceBusConstants.ITEM_TYPE_PROXY_SERVICE);
        System.out.println("Updated proxy : " + proxy.getName());
        checkSavedProxy(proxy);
    }

    synapseConfigSvc.getSynapseConfiguration().removeProxyService(proxy.getName());
    getMediationPersistenceManager().deleteItem(proxy.getName(), fileName,
            ServiceBusConstants.ITEM_TYPE_PROXY_SERVICE);
    System.out.println("Proxy : " + proxy.getName() + " removed");
    hold();

    File file = new File(path + File.separator +
            MultiXMLConfigurationBuilder.PROXY_SERVICES_DIR, fileName);
    if (file.exists()) {
        fail("The file : " + fileName + " has not been deleted");
    }
    System.out.println("Proxy service file : " + fileName + " deleted successfully");

    checkSynapseXMLPersistence();

    System.out.println("Proxy service persistence test completed successfully...");
}
 
Example #6
Source File: EndpointPersistenceTest.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
public void testEndpointPersistence() throws IOException {
    System.out.println("Starting endpoint persistence test...");

    String fileName = "epr1.xml";
    InputStream in = getClass().getClassLoader().getResourceAsStream(fileName);
    Endpoint endpoint = createEndpoint(in);
    in.close();
    endpoint.setFileName(fileName);
    synapseConfigSvc.getSynapseConfiguration().addEndpoint(endpoint.getName(), endpoint);
    getMediationPersistenceManager().saveItem(endpoint.getName(),
            ServiceBusConstants.ITEM_TYPE_ENDPOINT);
    System.out.println("Added new endpoint : " + endpoint.getName());
    checkSavedEndpoint(endpoint);

    if (endpoint instanceof AddressEndpoint) {
        ((AddressEndpoint) endpoint).getDefinition().setAddress("http://wso2.org/services/Foo");
        getMediationPersistenceManager().saveItem(endpoint.getName(),
                ServiceBusConstants.ITEM_TYPE_ENDPOINT);
        System.out.println("Updated endpoint : " + endpoint.getName());
        checkSavedEndpoint(endpoint);
    }

    synapseConfigSvc.getSynapseConfiguration().removeEndpoint(endpoint.getName());
    getMediationPersistenceManager().deleteItem(endpoint.getName(), fileName,
            ServiceBusConstants.ITEM_TYPE_ENDPOINT);
    System.out.println("Endpoint : " + endpoint.getName() + " removed");
    hold();

    File file = new File(path + File.separator +
            MultiXMLConfigurationBuilder.ENDPOINTS_DIR, fileName);
    if (file.exists()) {
        fail("The file : " + fileName + " has not been deleted");
    }
    System.out.println("Endpoint file : " + fileName + " deleted successfully");

    checkSynapseXMLPersistence();

    System.out.println("Endpoint persistence test completed successfully...");
}
 
Example #7
Source File: InboundStore.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({"ResultOfMethodCallIgnored"})
protected void deleteFile(String fileName, SynapseConfiguration synapseConfiguration) {
    File inboundDir = new File(configPath, MultiXMLConfigurationBuilder.INBOUND_ENDPOINT_DIR);
    if (!inboundDir.exists()) {
        return;
    }
    File inboundFile = new File(inboundDir, fileName);
    synapseConfiguration.getArtifactDeploymentStore().addBackedUpArtifact(inboundFile.getAbsolutePath());
    inboundFile.delete();
}
 
Example #8
Source File: APIStore.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({"ResultOfMethodCallIgnored"})
protected void deleteFile(String fileName, SynapseConfiguration synapseConfiguration) {
    File apiDirectory = new File(configPath, MultiXMLConfigurationBuilder.REST_API_DIR);
    if (!apiDirectory.exists()) {
        return;
    }
    File apiFile = new File(apiDirectory, fileName);
    synapseConfiguration.getArtifactDeploymentStore().addBackedUpArtifact(
            apiFile.getAbsolutePath());
    apiFile.delete();
}
 
Example #9
Source File: ExecutorStore.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({"ResultOfMethodCallIgnored"})
protected void deleteFile(String fileName, SynapseConfiguration synapseConfiguration) {
    File executorsDir = new File(configPath, MultiXMLConfigurationBuilder.EXECUTORS_DIR);
    if (!executorsDir.exists()) {
        return;
    }
    File executorFile = new File(executorsDir, fileName);
    synapseConfiguration.getArtifactDeploymentStore().addBackedUpArtifact(
            executorFile.getAbsolutePath());
    executorFile.delete();
}
 
Example #10
Source File: TemplateStore.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({"ResultOfMethodCallIgnored"})
protected void deleteFile(String fileName, SynapseConfiguration synapseConfig) {
    File templateDir = new File(configPath, MultiXMLConfigurationBuilder.TEMPLATES_DIR);
    if (!templateDir.exists()) {
        return;
    }

    File templateFile = new File(templateDir, fileName);
    synapseConfig.getArtifactDeploymentStore().addBackedUpArtifact(
            templateFile.getAbsolutePath());
    templateFile.delete();
}
 
Example #11
Source File: SequenceStore.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({"ResultOfMethodCallIgnored"})
protected void deleteFile(String fileName, SynapseConfiguration synapseConfig) {
    File sequenceDir = new File(configPath, MultiXMLConfigurationBuilder.SEQUENCES_DIR);
    if (!sequenceDir.exists()) {
        return;
    }

    File sequenceFile = new File(sequenceDir, fileName);
    synapseConfig.getArtifactDeploymentStore().addBackedUpArtifact(
            sequenceFile.getAbsolutePath());
    sequenceFile.delete();
}
 
Example #12
Source File: StartupAdminServiceComponent.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
private void registerDeployer(AxisConfiguration axisConfig, SynapseEnvironment synEnv) {

        DeploymentEngine deploymentEngine = (DeploymentEngine) axisConfig.getConfigurator();
        SynapseArtifactDeploymentStore deploymentStore = synEnv.getSynapseConfiguration().getArtifactDeploymentStore();
        String synapseConfigPath = ServiceBusUtils.getSynapseConfigAbsPath(synEnv.getServerContextInformation());
        String taskDirDirPath = synapseConfigPath + File.separator + MultiXMLConfigurationBuilder.TASKS_DIR;
        for (Startup stp : synEnv.getSynapseConfiguration().getStartups()) {
            if (stp.getFileName() != null) {
                deploymentStore.addRestoredArtifact(taskDirDirPath + File.separator + stp.getFileName());
            }
        }
        synchronized (axisConfig) {
            deploymentEngine.addDeployer(new TaskDeployer(), taskDirDirPath, ServiceBusConstants.ARTIFACT_EXTENSION);
        }
    }
 
Example #13
Source File: EndpointTemplateStore.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({"ResultOfMethodCallIgnored"})
protected void deleteFile(String fileName, SynapseConfiguration synapseConfig) {
    File templateDir = new File(configPath, MultiXMLConfigurationBuilder.TEMPLATES_DIR);
    if (!templateDir.exists()) {
        return;
    }

    File templateFile = new File(templateDir, fileName);
    synapseConfig.getArtifactDeploymentStore().addBackedUpArtifact(
            templateFile.getAbsolutePath());
    templateFile.delete();
}
 
Example #14
Source File: EndpointStore.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({"ResultOfMethodCallIgnored"})
protected void deleteFile(String fileName, SynapseConfiguration synapseConfiguration) {
    File endpointsDir = new File(configPath, MultiXMLConfigurationBuilder.ENDPOINTS_DIR);
    if (!endpointsDir.exists()) {
        return;
    }
    File endpointFile = new File(endpointsDir, fileName);
    synapseConfiguration.getArtifactDeploymentStore().addBackedUpArtifact(
            endpointFile.getAbsolutePath());
    endpointFile.delete();
}
 
Example #15
Source File: EventSourceStore.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({"ResultOfMethodCallIgnored"})
protected void deleteFile(String fileName, SynapseConfiguration synapseConfiguration) {
    File eventsDir = new File(configPath, MultiXMLConfigurationBuilder.EVENTS_DIR);
    if (!eventsDir.exists()) {
        return;
    }
    File eventFile = new File(eventsDir, fileName);
    synapseConfiguration.getArtifactDeploymentStore().addBackedUpArtifact(
            eventFile.getAbsolutePath());
    eventFile.delete();
}
 
Example #16
Source File: MessageProcessorStore.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@Override
protected void deleteFile(String fileName, SynapseConfiguration config) {
    File mpDir = new File(configPath, MultiXMLConfigurationBuilder.MESSAGE_PROCESSOR_DIR);

    if (!mpDir.exists()) {
        return;
    }

    File mpFile = new File(mpDir, fileName);

    config.getArtifactDeploymentStore().addBackedUpArtifact(
            mpFile.getAbsolutePath());
    mpFile.delete();
}
 
Example #17
Source File: StartupStore.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({"ResultOfMethodCallIgnored"})
protected void deleteFile(String fileName, SynapseConfiguration synapseConfiguration) {
    File tasksDir = new File(configPath, MultiXMLConfigurationBuilder.TASKS_DIR);
    if (!tasksDir.exists()) {
        return;
    }

    File taskFile = new File(tasksDir, fileName);
    synapseConfiguration.getArtifactDeploymentStore().addBackedUpArtifact(
            taskFile.getAbsolutePath());
    taskFile.delete();
}
 
Example #18
Source File: ProxyServiceStore.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({"ResultOfMethodCallIgnored"})
protected void deleteFile(String fileName, SynapseConfiguration synapseConfiguration) {
    File proxyDir = new File(configPath, MultiXMLConfigurationBuilder.PROXY_SERVICES_DIR);
    if (!proxyDir.exists()) {
        return;
    }
    File proxyFile = new File(proxyDir, fileName);
    synapseConfiguration.getArtifactDeploymentStore().addBackedUpArtifact(
            proxyFile.getAbsolutePath());
    proxyFile.delete();
}
 
Example #19
Source File: ImportStore.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({"ResultOfMethodCallIgnored"})
protected void deleteFile(String fileName, SynapseConfiguration synapseConfiguration) {
    File importsDirectory = new File(configPath, MultiXMLConfigurationBuilder.SYNAPSE_IMPORTS_DIR);
    if (!importsDirectory.exists()) {
        return;
    }
    File importFile = new File(importsDirectory, fileName);
    synapseConfiguration.getArtifactDeploymentStore().addBackedUpArtifact(
            importFile.getAbsolutePath());
    importFile.delete();
}
 
Example #20
Source File: LocalEntryStore.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings({"ResultOfMethodCallIgnored"})
protected void deleteFile(String fileName, SynapseConfiguration synapseConfiguration) {
    File entriesDir = new File(configPath, MultiXMLConfigurationBuilder.LOCAL_ENTRY_DIR);
    if (!entriesDir.exists()) {
        return;
    }
    File entryFile = new File(entriesDir, fileName);
    synapseConfiguration.getArtifactDeploymentStore().addBackedUpArtifact(
            entryFile.getAbsolutePath());
    entryFile.delete();
}
 
Example #21
Source File: SynapseRegistryStore.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
@Override
public void save(String name, SynapseConfiguration config) {
    if (name == null) {
        log.warn("Name of the configuration item is not given");
        return;
    }

    Registry registry = getObjectToPersist(name, config);
    if (registry == null) {
        log.warn("Unable to find the Synapse registry for persistence");
        return;
    }

    try {
        if (!Boolean.valueOf(config.getProperty(
                MultiXMLConfigurationBuilder.SEPARATE_REGISTRY_DEFINITION))) {

            serializer.serializeSynapseXML(config);
        } else {
            serializer.serializeSynapseRegistry(registry, config, null);
        }

    } catch (Exception e) {
        handleException("Error while saving the mediation registry to the file system", e);
    }

}
 
Example #22
Source File: StartupAdminServiceComponent.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * Un-registers the Task Deployer.
 *
 * @param axisConfig         AxisConfiguration to which this deployer belongs
 * @param synapseEnvironment SynapseEnvironment to which this deployer belongs
 */
private void unregistryDeployer(AxisConfiguration axisConfig, SynapseEnvironment synapseEnvironment) {

    if (axisConfig != null && synapseEnvironment != null) {
        DeploymentEngine deploymentEngine = (DeploymentEngine) axisConfig.getConfigurator();
        String synapseConfigPath = ServiceBusUtils
                .getSynapseConfigAbsPath(synapseEnvironment.getServerContextInformation());
        String proxyDirPath = synapseConfigPath + File.separator + MultiXMLConfigurationBuilder.TASKS_DIR;
        deploymentEngine.removeDeployer(proxyDirPath, ServiceBusConstants.ARTIFACT_EXTENSION);
    }
}