├── features ├── service │ ├── org.wso2.carbon.rule.service.server.feature │ │ └── resources │ │ │ ├── build.properties │ │ │ ├── p2.inf │ │ │ └── conf │ │ │ └── rule-engine-config.xml │ └── pom.xml ├── mediation │ ├── org.wso2.carbon.rule.mediation.server.feature │ │ └── resources │ │ │ ├── build.properties │ │ │ ├── p2.inf │ │ │ └── conf │ │ │ └── rule-engine-config.xml │ └── pom.xml └── pom.xml ├── .gitignore ├── components └── rule │ ├── org.wso2.carbon.rule.mediation │ └── src │ │ ├── main │ │ ├── resources │ │ │ └── META-INF │ │ │ │ └── services │ │ │ │ ├── org.apache.synapse.config.xml.MediatorFactory │ │ │ │ └── org.apache.synapse.config.xml.MediatorSerializer │ │ └── java │ │ │ └── org │ │ │ └── wso2 │ │ │ └── carbon │ │ │ └── rule │ │ │ └── mediator │ │ │ ├── RuleMediatorSerializer.java │ │ │ ├── internal │ │ │ └── config │ │ │ │ ├── SourceHelper.java │ │ │ │ ├── TargetHelper.java │ │ │ │ └── RuleMediatorConfigHelper.java │ │ │ ├── config │ │ │ └── Source.java │ │ │ └── RuleMediatorFactory.java │ │ └── test │ │ ├── resources │ │ ├── request.xml │ │ └── ruleMediator.xml │ │ └── java │ │ └── org │ │ └── wso2 │ │ └── carbon │ │ └── rule │ │ └── mediator │ │ └── RuleMediatorSessionCreationTestCase.java │ ├── org.wso2.carbon.rule.backend │ └── src │ │ ├── main │ │ ├── resources │ │ │ └── META-INF │ │ │ │ ├── kmodule.xml │ │ │ │ └── kie.conf │ │ └── java │ │ │ └── org │ │ │ └── wso2 │ │ │ └── carbon │ │ │ └── rule │ │ │ └── backend │ │ │ ├── internal │ │ │ ├── RuleServiceValueHolder.java │ │ │ └── RuleServiceDS.java │ │ │ ├── drools │ │ │ ├── DroolsBackendRuntimeFactory.java │ │ │ └── DroolsStatefulSession.java │ │ │ └── jsr94 │ │ │ ├── JSR94StatelessSession.java │ │ │ ├── JSR94StatefulSession.java │ │ │ └── drools │ │ │ └── DroolsJSR94DefaultPropertiesProvider.java │ │ └── test │ │ ├── resources │ │ ├── rule-config.xml │ │ ├── test.xml │ │ └── OrderApproval.drl │ │ └── java │ │ └── samples │ │ └── userguide │ │ ├── OrderReject.java │ │ ├── OrderAccept.java │ │ └── PlaceOrder.java │ ├── org.wso2.carbon.rule.ws.ui │ └── src │ │ └── main │ │ ├── resources │ │ ├── web │ │ │ ├── rule_service │ │ │ │ ├── images │ │ │ │ │ ├── type.gif │ │ │ │ │ ├── rule-service.gif │ │ │ │ │ ├── facts-selector.gif │ │ │ │ │ ├── rule-service-create.gif │ │ │ │ │ └── rule-service-upload.gif │ │ │ │ └── extra_config.jsp │ │ │ └── ruleservices │ │ │ │ ├── docs │ │ │ │ └── images │ │ │ │ │ ├── setp-1.PNG │ │ │ │ │ ├── setp-3.PNG │ │ │ │ │ ├── setp-4.PNG │ │ │ │ │ ├── setp-5.PNG │ │ │ │ │ ├── setp-2-reg.PNG │ │ │ │ │ ├── setp-5-ns.PNG │ │ │ │ │ ├── setp-5-fact.PNG │ │ │ │ │ ├── setp-2-inlined.PNG │ │ │ │ │ ├── setp-2-upload.PNG │ │ │ │ │ └── rule-service-upload.PNG │ │ │ │ ├── op_delete-ajaxprocessor.jsp │ │ │ │ ├── rule_delete_all_files-ajaxprocessor.jsp │ │ │ │ ├── fact_archive_delete-ajaxprocessor.jsp │ │ │ │ ├── rule_script_add-ajaxprocessor.jsp │ │ │ │ ├── rule_file_delete-ajaxprocessor.jsp │ │ │ │ ├── property_save-ajaxprocessor.jsp │ │ │ │ ├── cancel_handler.jsp │ │ │ │ ├── rule_service_wizard_end.jsp │ │ │ │ └── ns_save-ajaxprocessor.jsp │ │ └── org │ │ │ └── wso2 │ │ │ └── carbon │ │ │ └── rule │ │ │ └── ws │ │ │ └── ui │ │ │ └── i18n │ │ │ └── JSResources.properties │ │ └── java │ │ └── org │ │ └── wso2 │ │ └── carbon │ │ └── rule │ │ └── ws │ │ └── ui │ │ ├── Servicemanagement.java │ │ ├── RuleServiceClientException.java │ │ └── ns │ │ ├── NameSpacesInformationRepositoryRegistrar.java │ │ └── NameSpacesInformation.java │ ├── org.wso2.carbon.application.deployer.rule │ └── src │ │ └── main │ │ ├── resources │ │ └── required-features.xml │ │ └── java │ │ └── org │ │ └── wso2 │ │ └── carbon │ │ └── application │ │ └── deployer │ │ └── rule │ │ └── internal │ │ └── RuleAppDeployerDSComponent.java │ ├── org.wso2.carbon.rule.samples │ ├── src │ │ ├── conf │ │ │ └── synapse │ │ │ │ ├── resources │ │ │ │ └── rule │ │ │ │ │ ├── simple_rule_base.drl │ │ │ │ │ ├── tranform_back_rule.drl │ │ │ │ │ ├── tranform_forward_rule.drl │ │ │ │ │ ├── always_ibm.xml │ │ │ │ │ ├── simple_rule_base.xml │ │ │ │ │ └── commission_rule.xml │ │ │ │ ├── synapse_sample_604.xml │ │ │ │ ├── synapse_sample_601.xml │ │ │ │ ├── synapse_sample_600.xml │ │ │ │ ├── synapse_sample_602.xml │ │ │ │ └── synapse_sample_605.xml │ │ └── main │ │ │ └── java │ │ │ └── org │ │ │ └── wso2 │ │ │ └── carbon │ │ │ └── rule │ │ │ └── samples │ │ │ ├── GetQuoteResponse.java │ │ │ ├── GetQuoteRequest.java │ │ │ └── CheckPriceResponse.java │ └── pom.xml │ ├── org.wso2.carbon.rule.kernel │ └── src │ │ ├── test │ │ ├── resources │ │ │ ├── rule-engine-config.xml │ │ │ └── testService.rsl │ │ └── java │ │ │ └── org │ │ │ └── wso2 │ │ │ └── carbon │ │ │ └── rule │ │ │ └── kernel │ │ │ ├── engine │ │ │ ├── DummyRuleSession.java │ │ │ ├── DummyRuleBackendRuntimeFactory.java │ │ │ ├── DummyRuleBackendRuntime.java │ │ │ └── PlaceOrder.java │ │ │ └── internal │ │ │ └── util │ │ │ ├── PlaceOrder.java │ │ │ └── TestDataBindUtil.java │ │ └── main │ │ └── java │ │ └── org │ │ └── wso2 │ │ └── carbon │ │ └── rule │ │ └── kernel │ │ ├── config │ │ ├── RuleEngineConfigService.java │ │ ├── RuleEngineConfig.java │ │ └── RuleEngineProvider.java │ │ ├── internal │ │ ├── config │ │ │ └── CarbonRuleEngineConfigService.java │ │ └── event │ │ │ └── RuleChangeEventDispacher.java │ │ └── backend │ │ ├── Session.java │ │ ├── RuleBackendRuntimeFactory.java │ │ ├── RuleBackendRuntime.java │ │ └── DefaultPropertiesProvider.java │ ├── org.wso2.carbon.rule.ws │ └── src │ │ ├── main │ │ ├── java │ │ │ └── org │ │ │ │ └── wso2 │ │ │ │ └── carbon │ │ │ │ └── rule │ │ │ │ └── ws │ │ │ │ ├── internal │ │ │ │ └── schema │ │ │ │ │ ├── DummyRuleService.java │ │ │ │ │ └── RuleSchemaGenerator.java │ │ │ │ └── receiver │ │ │ │ └── RuleSessionLifecycle.java │ │ └── resources │ │ │ └── META-INF │ │ │ └── component.xml │ │ └── test │ │ └── java │ │ └── org │ │ └── wso2 │ │ └── carbon │ │ └── rule │ │ └── ws │ │ └── internal │ │ ├── schema │ │ ├── PlaceOrder.java │ │ ├── TestRuleSchemaGenerator.java │ │ └── TestSchemaBuilder.java │ │ └── config │ │ └── TestRuleServiceHelper.java │ ├── org.wso2.carbon.rule.common │ └── src │ │ ├── main │ │ └── java │ │ │ └── org │ │ │ └── wso2 │ │ │ └── carbon │ │ │ └── rule │ │ │ └── common │ │ │ ├── exception │ │ │ ├── RuleRuntimeException.java │ │ │ └── RuleConfigurationException.java │ │ │ ├── config │ │ │ ├── RuleHelper.java │ │ │ ├── FactHelper.java │ │ │ ├── OperationHelper.java │ │ │ ├── InputHelper.java │ │ │ ├── OutputHelper.java │ │ │ └── RuleSetHelper.java │ │ │ ├── Operation.java │ │ │ └── Input.java │ │ └── test │ │ └── java │ │ └── org │ │ └── wso2 │ │ └── carbon │ │ └── rule │ │ └── common │ │ ├── TestFact.java │ │ ├── TestRule.java │ │ ├── TestRuleSet.java │ │ ├── TestInput.java │ │ ├── TestOutput.java │ │ └── TestOperation.java │ ├── org.wso2.carbon.rule.ws.admin │ └── src │ │ └── main │ │ ├── java │ │ └── org │ │ │ └── wso2 │ │ │ └── carbon │ │ │ └── rule │ │ │ └── ws │ │ │ └── admin │ │ │ ├── exception │ │ │ └── RuleServiceAdminException.java │ │ │ ├── internal │ │ │ └── config │ │ │ │ ├── RuleServiceHelper.java │ │ │ │ └── RuleService.java │ │ │ └── Paths.java │ │ └── resources │ │ └── META-INF │ │ └── services.xml │ └── pom.xml ├── README.md ├── issue_template.md ├── service-stubs └── rule │ └── pom.xml └── pull_request_template.md /features/service/org.wso2.carbon.rule.service.server.feature/resources/build.properties: -------------------------------------------------------------------------------- 1 | custom = true 2 | root.event=conf 3 | -------------------------------------------------------------------------------- /features/mediation/org.wso2.carbon.rule.mediation.server.feature/resources/build.properties: -------------------------------------------------------------------------------- 1 | custom = true 2 | root.event=conf 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | target 3 | .classpath 4 | .settings 5 | .project 6 | *.iml 7 | *.iws 8 | *.ipr 9 | .idea 10 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.mediation/src/main/resources/META-INF/services/org.apache.synapse.config.xml.MediatorFactory: -------------------------------------------------------------------------------- 1 | org.wso2.carbon.rule.mediator.RuleMediatorFactory -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.mediation/src/main/resources/META-INF/services/org.apache.synapse.config.xml.MediatorSerializer: -------------------------------------------------------------------------------- 1 | org.wso2.carbon.rule.mediator.RuleMediatorSerializer -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.backend/src/main/resources/META-INF/kmodule.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.ws.ui/src/main/resources/web/rule_service/images/type.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wso2/carbon-rules/HEAD/components/rule/org.wso2.carbon.rule.ws.ui/src/main/resources/web/rule_service/images/type.gif -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.ws.ui/src/main/resources/web/rule_service/images/rule-service.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wso2/carbon-rules/HEAD/components/rule/org.wso2.carbon.rule.ws.ui/src/main/resources/web/rule_service/images/rule-service.gif -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.ws.ui/src/main/resources/web/ruleservices/docs/images/setp-1.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wso2/carbon-rules/HEAD/components/rule/org.wso2.carbon.rule.ws.ui/src/main/resources/web/ruleservices/docs/images/setp-1.PNG -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.ws.ui/src/main/resources/web/ruleservices/docs/images/setp-3.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wso2/carbon-rules/HEAD/components/rule/org.wso2.carbon.rule.ws.ui/src/main/resources/web/ruleservices/docs/images/setp-3.PNG -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.ws.ui/src/main/resources/web/ruleservices/docs/images/setp-4.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wso2/carbon-rules/HEAD/components/rule/org.wso2.carbon.rule.ws.ui/src/main/resources/web/ruleservices/docs/images/setp-4.PNG -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.ws.ui/src/main/resources/web/ruleservices/docs/images/setp-5.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wso2/carbon-rules/HEAD/components/rule/org.wso2.carbon.rule.ws.ui/src/main/resources/web/ruleservices/docs/images/setp-5.PNG -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.ws.ui/src/main/resources/web/rule_service/images/facts-selector.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wso2/carbon-rules/HEAD/components/rule/org.wso2.carbon.rule.ws.ui/src/main/resources/web/rule_service/images/facts-selector.gif -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.ws.ui/src/main/resources/web/ruleservices/docs/images/setp-2-reg.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wso2/carbon-rules/HEAD/components/rule/org.wso2.carbon.rule.ws.ui/src/main/resources/web/ruleservices/docs/images/setp-2-reg.PNG -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.ws.ui/src/main/resources/web/ruleservices/docs/images/setp-5-ns.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wso2/carbon-rules/HEAD/components/rule/org.wso2.carbon.rule.ws.ui/src/main/resources/web/ruleservices/docs/images/setp-5-ns.PNG -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.ws.ui/src/main/resources/web/ruleservices/docs/images/setp-5-fact.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wso2/carbon-rules/HEAD/components/rule/org.wso2.carbon.rule.ws.ui/src/main/resources/web/ruleservices/docs/images/setp-5-fact.PNG -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.ws.ui/src/main/resources/web/rule_service/images/rule-service-create.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wso2/carbon-rules/HEAD/components/rule/org.wso2.carbon.rule.ws.ui/src/main/resources/web/rule_service/images/rule-service-create.gif -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.ws.ui/src/main/resources/web/rule_service/images/rule-service-upload.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wso2/carbon-rules/HEAD/components/rule/org.wso2.carbon.rule.ws.ui/src/main/resources/web/rule_service/images/rule-service-upload.gif -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.ws.ui/src/main/resources/web/ruleservices/docs/images/setp-2-inlined.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wso2/carbon-rules/HEAD/components/rule/org.wso2.carbon.rule.ws.ui/src/main/resources/web/ruleservices/docs/images/setp-2-inlined.PNG -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.ws.ui/src/main/resources/web/ruleservices/docs/images/setp-2-upload.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wso2/carbon-rules/HEAD/components/rule/org.wso2.carbon.rule.ws.ui/src/main/resources/web/ruleservices/docs/images/setp-2-upload.PNG -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.ws.ui/src/main/resources/web/ruleservices/docs/images/rule-service-upload.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wso2/carbon-rules/HEAD/components/rule/org.wso2.carbon.rule.ws.ui/src/main/resources/web/ruleservices/docs/images/rule-service-upload.PNG -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.application.deployer.rule/src/main/resources/required-features.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.backend/src/test/resources/rule-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /features/mediation/org.wso2.carbon.rule.mediation.server.feature/resources/p2.inf: -------------------------------------------------------------------------------- 1 | instructions.configure = \ 2 | org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.rule.mediation.server_${feature.version}/conf/rule-engine-config.xml,target:${installFolder}/../../conf/rule-engine-config.xml,overwrite:true);\ 3 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.samples/src/conf/synapse/resources/rule/simple_rule_base.drl: -------------------------------------------------------------------------------- 1 | 2 | 22 | 23 | -------------------------------------------------------------------------------- /features/service/org.wso2.carbon.rule.service.server.feature/resources/p2.inf: -------------------------------------------------------------------------------- 1 | instructions.configure = \ 2 | org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.rule.service.server_${feature.version}/conf/rule-engine-config.xml,target:${installFolder}/../../conf/rule-engine-config.xml,overwrite:true);\ 3 | org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.rule.service.server_${feature.version}/conf/rule.xsd,target:${installFolder}/../../conf/rule.xsd,overwrite:true);\ 4 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.samples/src/conf/synapse/resources/rule/tranform_back_rule.drl: -------------------------------------------------------------------------------- 1 | 2 | 27 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.samples/src/conf/synapse/resources/rule/tranform_forward_rule.drl: -------------------------------------------------------------------------------- 1 | 2 | 26 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.mediation/src/test/resources/request.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | IBM 16 | 10 17 | 100 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.kernel/src/test/resources/rule-engine-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 7 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /features/service/org.wso2.carbon.rule.service.server.feature/resources/conf/rule-engine-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /features/mediation/org.wso2.carbon.rule.mediation.server.feature/resources/conf/rule-engine-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | carbon-rules 2 | ============ 3 | 4 | This project contains the modules implementing Business Rules integration layer for WSO2 Business Rules Server Product. 5 | The project structure consist of service-stubs, components and features. 6 | 7 | In the service-stubs section, services providing admin service API's and their respective clients are implemented. 8 | 9 | In the components section, components corresponding to following functionality are available. 10 | 11 | 1. Rule Engine - Drools rule engine integration and JAVA built-in JSR-94 implementation layer and UI 12 | 2. Mediation- Rule Mediator 13 | 3. Rule Service - Exposing rule implementation as a web service 14 | 15 | In the features section , these individual components are packaged into features as application deployer , mediation and service. 16 | -------------------------------------------------------------------------------- /issue_template.md: -------------------------------------------------------------------------------- 1 | **Description:** 2 | 3 | 4 | **Suggested Labels:** 5 | 6 | 7 | **Suggested Assignees:** 8 | 9 | 10 | **Affected Product Version:** 11 | 12 | **OS, DB, other environment details and versions:** 13 | 14 | **Steps to reproduce:** 15 | 16 | 17 | **Related Issues:** 18 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.mediation/src/test/resources/ruleMediator.xml: -------------------------------------------------------------------------------- 1 | 2 | soapBody|soapHeader|$foo|$bar 3 | soapBody|soapHeader|$foo|$bar 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.kernel/src/main/java/org/wso2/carbon/rule/kernel/config/RuleEngineConfigService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2004,2005 The Apache Software Foundation. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | package org.wso2.carbon.rule.kernel.config; 19 | 20 | public interface RuleEngineConfigService { 21 | 22 | public RuleEngineConfig getRuleConfig(); 23 | 24 | } 25 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.ws/src/main/java/org/wso2/carbon/rule/ws/internal/schema/DummyRuleService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2004,2005 The Apache Software Foundation. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.wso2.carbon.rule.ws.internal.schema; 18 | 19 | /** 20 | * this is a dummy class used to trick a call for an axis2 schema generator. 21 | */ 22 | public class DummyRuleService { 23 | 24 | } 25 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.backend/src/test/java/samples/userguide/OrderReject.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2004,2005 The Apache Software Foundation. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package samples.userguide; 18 | 19 | public class OrderReject { 20 | 21 | private String reason; 22 | 23 | public String getReason() { 24 | return reason; 25 | } 26 | 27 | public void setReason(String reason) { 28 | this.reason = reason; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.ws.ui/src/main/java/org/wso2/carbon/rule/ws/ui/Servicemanagement.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.wso2.carbon.rule.ws.ui; 20 | 21 | public class Servicemanagement { 22 | } 23 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.backend/src/test/java/samples/userguide/OrderAccept.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2004,2005 The Apache Software Foundation. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package samples.userguide; 18 | 19 | public class OrderAccept { 20 | 21 | private String message; 22 | 23 | public String getMessage() { 24 | return message; 25 | } 26 | 27 | public void setMessage(String message) { 28 | this.message = message; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.kernel/src/test/java/org/wso2/carbon/rule/kernel/engine/DummyRuleSession.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2004,2005 The Apache Software Foundation. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.wso2.carbon.rule.kernel.engine; 18 | 19 | import org.wso2.carbon.rule.kernel.backend.Session; 20 | 21 | import java.util.List; 22 | 23 | public class DummyRuleSession implements Session { 24 | 25 | public List execute(List facts) { 26 | return facts; 27 | } 28 | 29 | public void destroy() { 30 | 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.kernel/src/main/java/org/wso2/carbon/rule/kernel/config/RuleEngineConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2004,2005 The Apache Software Foundation. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.wso2.carbon.rule.kernel.config; 18 | 19 | public class RuleEngineConfig { 20 | 21 | private RuleEngineProvider ruleEngineProvider; 22 | 23 | public RuleEngineProvider getRuleEngineProvider() { 24 | return ruleEngineProvider; 25 | } 26 | 27 | public void setRuleEngineProvider(RuleEngineProvider ruleEngineProvider) { 28 | this.ruleEngineProvider = ruleEngineProvider; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.common/src/main/java/org/wso2/carbon/rule/common/exception/RuleRuntimeException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2004,2005 The Apache Software Foundation. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.wso2.carbon.rule.common.exception; 18 | 19 | public class RuleRuntimeException extends Exception{ 20 | 21 | public RuleRuntimeException() { 22 | } 23 | 24 | public RuleRuntimeException(String message) { 25 | super(message); 26 | } 27 | 28 | public RuleRuntimeException(String message, Throwable cause) { 29 | super(message, cause); 30 | } 31 | 32 | public RuleRuntimeException(Throwable cause) { 33 | super(cause); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.common/src/main/java/org/wso2/carbon/rule/common/exception/RuleConfigurationException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2004,2005 The Apache Software Foundation. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.wso2.carbon.rule.common.exception; 18 | 19 | public class RuleConfigurationException extends Exception { 20 | 21 | public RuleConfigurationException() { 22 | } 23 | 24 | public RuleConfigurationException(String message) { 25 | super(message); 26 | } 27 | 28 | public RuleConfigurationException(String message, Throwable cause) { 29 | super(message, cause); 30 | } 31 | 32 | public RuleConfigurationException(Throwable cause) { 33 | super(cause); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.ws.admin/src/main/java/org/wso2/carbon/rule/ws/admin/exception/RuleServiceAdminException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2004,2005 The Apache Software Foundation. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.wso2.carbon.rule.ws.admin.exception; 18 | 19 | public class RuleServiceAdminException extends Exception { 20 | 21 | public RuleServiceAdminException() { 22 | } 23 | 24 | public RuleServiceAdminException(String message) { 25 | super(message); 26 | } 27 | 28 | public RuleServiceAdminException(String message, Throwable cause) { 29 | super(message, cause); 30 | } 31 | 32 | public RuleServiceAdminException(Throwable cause) { 33 | super(cause); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.kernel/src/test/java/org/wso2/carbon/rule/kernel/engine/DummyRuleBackendRuntimeFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2004,2005 The Apache Software Foundation. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.wso2.carbon.rule.kernel.engine; 18 | 19 | import org.wso2.carbon.rule.kernel.backend.RuleBackendRuntimeFactory; 20 | import org.wso2.carbon.rule.kernel.backend.RuleBackendRuntime; 21 | 22 | import java.util.Map; 23 | 24 | public class DummyRuleBackendRuntimeFactory implements RuleBackendRuntimeFactory{ 25 | 26 | public RuleBackendRuntime getRuleBackendRuntime(Map properties, 27 | ClassLoader classLoader) { 28 | return new DummyRuleBackendRuntime(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.ws/src/main/resources/META-INF/component.xml: -------------------------------------------------------------------------------- 1 | 18 | 19 | 20 | 21 | ruleservices 22 | aar 23 | org.wso2.carbon.rule.ws.deploy.RuleServiceDeployer 24 | 25 | 26 | ruleservices 27 | rsl 28 | org.wso2.carbon.rule.ws.deploy.RuleServiceDeployer 29 | 30 | 31 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.ws.admin/src/main/java/org/wso2/carbon/rule/ws/admin/internal/config/RuleServiceHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2004,2005 The Apache Software Foundation. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.wso2.carbon.rule.ws.admin.internal.config; 18 | 19 | import org.apache.axiom.om.OMElement; 20 | import org.wso2.carbon.rule.common.config.HelperUtil; 21 | import org.wso2.carbon.rule.common.util.Constants; 22 | 23 | public class RuleServiceHelper { 24 | 25 | public static RuleService getRuleService(OMElement ruleServiceElement){ 26 | RuleService ruleService = new RuleService(ruleServiceElement); 27 | ruleService.setName(HelperUtil.getAttributeValue(ruleServiceElement, Constants.RULE_CONF_ATTR_NAME)); 28 | return ruleService; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.mediation/src/main/java/org/wso2/carbon/rule/mediator/RuleMediatorSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2004,2005 The Apache Software Foundation. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.wso2.carbon.rule.mediator; 18 | 19 | import org.apache.axiom.om.OMElement; 20 | import org.apache.synapse.Mediator; 21 | import org.apache.synapse.config.xml.AbstractMediatorSerializer; 22 | 23 | public class RuleMediatorSerializer extends AbstractMediatorSerializer { 24 | 25 | protected OMElement serializeSpecificMediator(Mediator mediator) { 26 | RuleMediator ruleMediator = (RuleMediator) mediator; 27 | return ruleMediator.getRuleOMElement(); 28 | } 29 | 30 | public String getMediatorClassName() { 31 | return RuleMediator.class.getName(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.ws.ui/src/main/resources/web/rule_service/extra_config.jsp: -------------------------------------------------------------------------------- 1 | 18 | <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> 19 | <% 20 | String serviceName = request.getParameter("serviceName"); 21 | %> 22 | 23 | 24 | 29 | 30 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.backend/src/test/resources/test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 23.4 7 | 23 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.backend/src/test/java/samples/userguide/PlaceOrder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2004,2005 The Apache Software Foundation. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package samples.userguide; 18 | 19 | public class PlaceOrder { 20 | 21 | String symbol; 22 | int quantity; 23 | double price; 24 | 25 | public String getSymbol() { 26 | return symbol; 27 | } 28 | 29 | public void setSymbol(String symbol) { 30 | this.symbol = symbol; 31 | } 32 | 33 | public int getQuantity() { 34 | return quantity; 35 | } 36 | 37 | public void setQuantity(int quantity) { 38 | this.quantity = quantity; 39 | } 40 | 41 | public double getPrice() { 42 | return price; 43 | } 44 | 45 | public void setPrice(double price) { 46 | this.price = price; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.samples/src/conf/synapse/resources/rule/always_ibm.xml: -------------------------------------------------------------------------------- 1 | 18 | 22 | 23 | 24 | 25 | 26 | symbol.equals("MSFT") || symbol.equals("SUN") 27 | 28 | 29 | update(drools.getWorkingMemory().getFactHandle(symbol),"IBM"); 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.kernel/src/test/java/org/wso2/carbon/rule/kernel/engine/DummyRuleBackendRuntime.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2004,2005 The Apache Software Foundation. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.wso2.carbon.rule.kernel.engine; 18 | 19 | import org.wso2.carbon.rule.kernel.backend.RuleBackendRuntime; 20 | import org.wso2.carbon.rule.kernel.backend.Session; 21 | import org.wso2.carbon.rule.common.exception.RuleConfigurationException; 22 | import org.wso2.carbon.rule.common.exception.RuleRuntimeException; 23 | import org.wso2.carbon.rule.common.RuleSet; 24 | 25 | public class DummyRuleBackendRuntime implements RuleBackendRuntime { 26 | 27 | public void addRuleSet(RuleSet ruleSet) throws RuleConfigurationException { 28 | 29 | } 30 | 31 | public Session createSession(int type) throws RuleRuntimeException { 32 | return new DummyRuleSession(); 33 | } 34 | 35 | } -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.kernel/src/test/java/org/wso2/carbon/rule/kernel/engine/PlaceOrder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2004,2005 The Apache Software Foundation. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.wso2.carbon.rule.kernel.engine; 18 | 19 | public class PlaceOrder { 20 | 21 | private String symbol; 22 | private int quantity; 23 | private double price; 24 | 25 | public String getSymbol() { 26 | return symbol; 27 | } 28 | 29 | public void setSymbol(String symbol) { 30 | this.symbol = symbol; 31 | } 32 | 33 | public int getQuantity() { 34 | return quantity; 35 | } 36 | 37 | public void setQuantity(int quantity) { 38 | this.quantity = quantity; 39 | } 40 | 41 | public double getPrice() { 42 | return price; 43 | } 44 | 45 | public void setPrice(double price) { 46 | this.price = price; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.kernel/src/main/java/org/wso2/carbon/rule/kernel/internal/config/CarbonRuleEngineConfigService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2004,2005 The Apache Software Foundation. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | package org.wso2.carbon.rule.kernel.internal.config; 19 | 20 | import org.wso2.carbon.rule.kernel.config.RuleEngineConfigService; 21 | import org.wso2.carbon.rule.kernel.config.RuleEngineConfig; 22 | 23 | /** 24 | * implementation object of the rule engine provider interface 25 | */ 26 | public class CarbonRuleEngineConfigService implements RuleEngineConfigService { 27 | 28 | private RuleEngineConfig ruleEngineConfig; 29 | 30 | public CarbonRuleEngineConfigService(RuleEngineConfig ruleEngineConfig) { 31 | this.ruleEngineConfig = ruleEngineConfig; 32 | } 33 | 34 | public RuleEngineConfig getRuleConfig() { 35 | return this.ruleEngineConfig; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.ws/src/test/java/org/wso2/carbon/rule/ws/internal/schema/PlaceOrder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2004,2005 The Apache Software Foundation. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.wso2.carbon.rule.ws.internal.schema; 18 | 19 | public class PlaceOrder { 20 | 21 | private String symbol; 22 | private int quantity; 23 | private double price; 24 | 25 | public String getSymbol() { 26 | return symbol; 27 | } 28 | 29 | public void setSymbol(String symbol) { 30 | this.symbol = symbol; 31 | } 32 | 33 | public int getQuantity() { 34 | return quantity; 35 | } 36 | 37 | public void setQuantity(int quantity) { 38 | this.quantity = quantity; 39 | } 40 | 41 | public double getPrice() { 42 | return price; 43 | } 44 | 45 | public void setPrice(double price) { 46 | this.price = price; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.kernel/src/test/java/org/wso2/carbon/rule/kernel/internal/util/PlaceOrder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2004,2005 The Apache Software Foundation. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.wso2.carbon.rule.kernel.internal.util; 18 | 19 | public class PlaceOrder { 20 | 21 | private String symbol; 22 | private int quantity; 23 | private double price; 24 | 25 | public String getSymbol() { 26 | return symbol; 27 | } 28 | 29 | public void setSymbol(String symbol) { 30 | this.symbol = symbol; 31 | } 32 | 33 | public int getQuantity() { 34 | return quantity; 35 | } 36 | 37 | public void setQuantity(int quantity) { 38 | this.quantity = quantity; 39 | } 40 | 41 | public double getPrice() { 42 | return price; 43 | } 44 | 45 | public void setPrice(double price) { 46 | this.price = price; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.backend/src/main/resources/META-INF/kie.conf: -------------------------------------------------------------------------------- 1 | org.kie.api.KieServices = org.drools.compiler.kie.builder.impl.KieServicesImpl 2 | # org.kie.api.KieBase = org.drools.core.impl.KnowledgeBaseImpl 3 | ?org.kie.internal.builder.KnowledgeBuilderFactoryService = org.drools.compiler.builder.impl.KnowledgeBuilderFactoryServiceImpl 4 | ?org.kie.internal.builder.JaxbConfigurationFactoryService = org.drools.compiler.builder.impl.JaxbConfigurationFactoryServiceImpl 5 | org.drools.compiler.kie.builder.impl.KieBaseUpdaters = org.drools.compiler.kie.builder.impl.KieBaseUpdatersImpl 6 | # org.kie.api.io.KieResources = org.drools.core.io.impl.ResourceFactoryServiceImpl 7 | # org.kie.api.concurrent.KieExecutors = org.drools.core.concurrent.ExecutorProviderImpl 8 | # org.drools.compiler.rule.builder.ConstraintBuilder = org.drools.mvel.MVELConstraintBuilder 9 | # org.drools.core.base.CoreComponentsBuilder = org.drools.mvel.MVELCoreComponentsBuilder 10 | # org.drools.core.base.FieldAccessorFactory = org.drools.mvel.asm.ClassFieldAccessorFactory 11 | # org.drools.core.factmodel.ClassBuilderFactory = org.drools.mvel.asm.DefaultClassBuilderFactory 12 | # org.kie.api.internal.assembler.KieAssemblers = org.kie.internal.services.KieAssemblersImpl 13 | # org.kie.api.internal.runtime.KieRuntimes = org.kie.internal.services.KieRuntimesImpl 14 | # org.kie.api.internal.weaver.KieWeavers = org.kie.internal.services.KieWeaversImpl 15 | # org.kie.api.internal.runtime.beliefs.KieBeliefs = org.kie.internal.services.KieBeliefsImpl 16 | 17 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.ws.ui/src/main/resources/org/wso2/carbon/rule/ws/ui/i18n/JSResources.properties: -------------------------------------------------------------------------------- 1 | service.rule.menu.text=Rule Service 2 | rule.fact.editor=Fact Editor 3 | property.editor=Property Editor 4 | rule.result.editor=Result Editor 5 | rule.facteditor.error=Error loading Fact Editor!!! 6 | property.editor.error=Error loading Property Editor!!! 7 | rule.action.delete=Delete 8 | error.occurred=Error calling operation delete ajax processor!!! 9 | resource.tree= Resource Tree 10 | resource.tree.loading= Resource Tree Loading 11 | ns.editor.waiting.text=Namespace editor loading please wait .. 12 | ns.editor.title=Namespace Editor 13 | ns.editor.load.error=Error in loading the Namespace Editor 14 | property.save.error=Error in saving properties 15 | ns.editor.delete.confirmation=Are you sure you want to delete the namespace permanently? 16 | ns.uri.empty=URI of the namespace is empty 17 | ns.prefix.empty=Prefix of the namespace is empty 18 | rule.ns.editor=NS Editor 19 | rule.namespaces=NameSpaces 20 | invalid.fact=Fact type is mandatory 21 | invalid.result=Result type is mandatory 22 | invalid.inputFact=Input Fact type is mandatory 23 | invalid.outputFact=Output Fact type is mandatory 24 | fact.type=Fact Type 25 | result.type=Result Type 26 | fact.delete.confirmation= Are you sure you want to delete the fact permanently? 27 | result.delete.confirmation= Are you sure you want to delete the result permanently? 28 | operation.delete.confirmation= Are you sure you want to delete the operation permanently? 29 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.samples/src/main/java/org/wso2/carbon/rule/samples/GetQuoteResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.wso2.carbon.rule.samples; 20 | 21 | /** 22 | * 23 | */ 24 | public class GetQuoteResponse { 25 | 26 | private String symbol; 27 | private String last; 28 | 29 | public String getSymbol() { 30 | return symbol; 31 | } 32 | 33 | public void setSymbol(String symbol) { 34 | this.symbol = symbol; 35 | } 36 | 37 | public String getLast() { 38 | return last; 39 | } 40 | 41 | public void setLast(String last) { 42 | this.last = last; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.samples/src/conf/synapse/resources/rule/simple_rule_base.xml: -------------------------------------------------------------------------------- 1 | 18 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | symbol.equals("IBM") 30 | 31 | 32 | mc.setProperty("execute_children","true"); 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.ws.admin/src/main/java/org/wso2/carbon/rule/ws/admin/internal/config/RuleService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2004,2005 The Apache Software Foundation. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.wso2.carbon.rule.ws.admin.internal.config; 18 | 19 | import org.apache.axiom.om.OMElement; 20 | 21 | import javax.xml.stream.XMLStreamException; 22 | import java.io.OutputStream; 23 | 24 | public class RuleService { 25 | 26 | private String name; 27 | private OMElement ruleServiceElemet; 28 | 29 | public RuleService(OMElement ruleServiceElemet) { 30 | this.ruleServiceElemet = ruleServiceElemet; 31 | } 32 | 33 | public void serialize(OutputStream outputStream) throws XMLStreamException { 34 | this.ruleServiceElemet.serialize(outputStream); 35 | } 36 | 37 | public String getName() { 38 | return name; 39 | } 40 | 41 | public void setName(String name) { 42 | this.name = name; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.ws.ui/src/main/resources/web/ruleservices/op_delete-ajaxprocessor.jsp: -------------------------------------------------------------------------------- 1 | 18 | <%@ page import="org.wso2.carbon.rule.ws.ui.wizard.RuleServiceAdminClient" %> 19 | <%@ page import="org.wso2.carbon.rule.common.RuleService" %> 20 | <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> 21 | <%@ taglib uri="http://wso2.org/projects/carbon/taglibs/carbontags.jar" prefix="carbon" %> 22 | <% 23 | RuleServiceAdminClient ruleServiceAdminClient = 24 | new RuleServiceAdminClient(config.getServletContext(), session); 25 | RuleService ruleService = ruleServiceAdminClient.getRuleServiceDescription(request); 26 | 27 | String name = request.getParameter("opname"); 28 | if (name != null) { 29 | ruleService.removeOperation(name); 30 | } 31 | %> 32 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.common/src/main/java/org/wso2/carbon/rule/common/config/RuleHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2004,2005 The Apache Software Foundation. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.wso2.carbon.rule.common.config; 18 | 19 | import org.wso2.carbon.rule.common.Rule; 20 | import org.wso2.carbon.rule.common.util.Constants; 21 | import org.apache.axiom.om.OMElement; 22 | 23 | public class RuleHelper { 24 | 25 | public static Rule getRule(OMElement ruleElement){ 26 | Rule rule = new Rule(); 27 | rule.setResourceType(HelperUtil.getAttributeValue( 28 | ruleElement, Constants.RULE_CONF_ATTR_RESOURCE_TYPE)); 29 | rule.setSourceType(HelperUtil.getAttributeValue( 30 | ruleElement, Constants.RULE_CONF_ATTR_SOURCE_TYPE)); 31 | rule.setDescription(HelperUtil.getAttributeValue( 32 | ruleElement, Constants.RULE_CONF_ATTR_DESCRIPTION)); 33 | rule.setValue(ruleElement.getText()); 34 | return rule; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.ws.admin/src/main/java/org/wso2/carbon/rule/ws/admin/Paths.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.wso2.carbon.rule.ws.admin; 20 | 21 | /** 22 | * Represent the service path and the working directory path for the service 23 | */ 24 | public class Paths { 25 | 26 | private String servicePath; 27 | private String workingDirPath; 28 | 29 | public Paths(String servicePath, String workingDirPath) { 30 | this.servicePath = servicePath; 31 | this.workingDirPath = workingDirPath; 32 | } 33 | 34 | public String getServicePath() { 35 | return servicePath; 36 | } 37 | 38 | public String getWorkingDirPath() { 39 | return workingDirPath; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.samples/src/main/java/org/wso2/carbon/rule/samples/GetQuoteRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.wso2.carbon.rule.samples; 20 | 21 | /** 22 | * 23 | */ 24 | public class GetQuoteRequest { 25 | private String symbol; 26 | 27 | public String getSymbol() { 28 | return symbol; 29 | } 30 | 31 | public void setSymbol(String symbol) { 32 | this.symbol = symbol; 33 | } 34 | 35 | public String toXML() { 36 | return "" + 37 | "" + 38 | "" + symbol + "" + 39 | "" + 40 | ""; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.ws.ui/src/main/java/org/wso2/carbon/rule/ws/ui/RuleServiceClientException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.wso2.carbon.rule.ws.ui; 20 | 21 | 22 | /** 23 | * Acts as a decorator and do log in addition to the existing behaviour of the exception 24 | */ 25 | public class RuleServiceClientException extends RuntimeException { 26 | 27 | public RuleServiceClientException() { 28 | } 29 | 30 | public RuleServiceClientException(String message) { 31 | super(message); 32 | } 33 | 34 | public RuleServiceClientException(String message, Throwable cause) { 35 | super(message, cause); 36 | } 37 | 38 | public RuleServiceClientException(Throwable cause) { 39 | super(cause); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.common/src/main/java/org/wso2/carbon/rule/common/config/FactHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2004,2005 The Apache Software Foundation. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.wso2.carbon.rule.common.config; 18 | 19 | import org.wso2.carbon.rule.common.Fact; 20 | import org.wso2.carbon.rule.common.util.Constants; 21 | import org.apache.axiom.om.OMElement; 22 | 23 | public class FactHelper { 24 | 25 | public static Fact getFact(OMElement factElement) { 26 | 27 | Fact fact = new Fact(); 28 | fact.setType(HelperUtil.getAttributeValue(factElement, Constants.RULE_CONF_ATTR_TYPE)); 29 | fact.setElementName(HelperUtil.getAttributeValue(factElement, Constants.RULE_CONF_ATTR_ELEMENT_NAME)); 30 | fact.setNamespace(HelperUtil.getAttributeValue(factElement, Constants.RULE_CONF_ATTR_NAMESPACE)); 31 | fact.setXpath(HelperUtil.getAttributeValue(factElement, Constants.RULE_CONF_ATTR_XPATH)); 32 | fact.setPrefixToNamespaceMap(HelperUtil.getPrefixToNamespaceMap(factElement)); 33 | return fact; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.kernel/src/test/resources/testService.rsl: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.ws.ui/src/main/java/org/wso2/carbon/rule/ws/ui/ns/NameSpacesInformationRepositoryRegistrar.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2009, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.wso2.carbon.rule.ws.ui.ns; 18 | 19 | import javax.servlet.http.HttpSession; 20 | 21 | /** 22 | * Register / un-register NameSpacesInformationRepository instances 23 | */ 24 | public class NameSpacesInformationRepositoryRegistrar { 25 | 26 | public static void unRegisterNameSpacesInformationRepository(HttpSession httpSession) { 27 | httpSession.removeAttribute( 28 | NameSpacesInformationRepository.NAMESPACES_INFORMATION_REPOSITORY); 29 | } 30 | 31 | public static void registerNameSpacesInformationRepository( 32 | NameSpacesInformationRepository repository, 33 | HttpSession httpSession) { 34 | httpSession.setAttribute( 35 | NameSpacesInformationRepository.NAMESPACES_INFORMATION_REPOSITORY, repository); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.ws.ui/src/main/resources/web/ruleservices/rule_delete_all_files-ajaxprocessor.jsp: -------------------------------------------------------------------------------- 1 | 18 | <%@ page import="org.wso2.carbon.rule.ws.ui.wizard.RuleServiceAdminClient" %> 19 | <%@ page import="org.wso2.carbon.rule.common.RuleService" %> 20 | <%@ page import="java.util.*" %> 21 | <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> 22 | <%@ taglib uri="http://wso2.org/projects/carbon/taglibs/carbontags.jar" prefix="carbon" %> 23 | <% 24 | RuleServiceAdminClient ruleServiceAdminClient = 25 | new RuleServiceAdminClient(config.getServletContext(), session); 26 | RuleService ruleService = ruleServiceAdminClient.getRuleServiceDescription(request); 27 | Map scriptList = (Map) session.getAttribute(RuleServiceAdminClient.SCRIPTS); 28 | if(scriptList!=null && !scriptList.isEmpty()){ 29 | ruleServiceAdminClient.deleteAllRuleFiles(ruleService, session); 30 | 31 | } 32 | 33 | %> -------------------------------------------------------------------------------- /features/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | org.wso2.carbon.rules 22 | carbon-rule 23 | 4.5.11-SNAPSHOT 24 | ../pom.xml 25 | 26 | 27 | 4.0.0 28 | rule-feature 29 | pom 30 | WSO2 Carbon - Rule Feature Aggregator Module 31 | http://wso2.org 32 | 33 | 34 | application-deployer/org.wso2.carbon.application.deployer.rule.feature 35 | service 36 | mediation 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.backend/src/main/java/org/wso2/carbon/rule/backend/internal/RuleServiceValueHolder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.wso2.carbon.rule.backend.internal; 18 | 19 | import org.wso2.carbon.registry.core.exceptions.RegistryException; 20 | import org.wso2.carbon.registry.core.service.RegistryService; 21 | 22 | public class RuleServiceValueHolder { 23 | private RegistryService registryService; 24 | private static RuleServiceValueHolder ruleServiceValueHolder = new RuleServiceValueHolder(); 25 | 26 | 27 | public static RuleServiceValueHolder getInstance() { 28 | return ruleServiceValueHolder; 29 | } 30 | 31 | public RegistryService getRegistryService() throws RegistryException { 32 | return registryService; 33 | } 34 | 35 | public void setRegistryService(RegistryService registryService) { 36 | this.registryService = registryService; 37 | } 38 | 39 | public void unsetRegistryService() { 40 | this.registryService = null; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /service-stubs/rule/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 21 | 22 | org.wso2.carbon.rules 23 | carbon-rule 24 | 4.5.11-SNAPSHOT 25 | ../../pom.xml 26 | 27 | 28 | 4.0.0 29 | rule-stubs 30 | pom 31 | WSO2 Carbon - Rule Service Stubs Parent Module 32 | WSO2 Carbon Service Management 33 | http://wso2.org 34 | 35 | 36 | org.wso2.carbon.rule.service.stub 37 | org.wso2.carbon.rule.ws.stub 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.samples/src/conf/synapse/resources/rule/commission_rule.xml: -------------------------------------------------------------------------------- 1 | 18 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | symbol.equals("MSFT") || symbol.equals("SUN") 31 | 32 | 33 | 34 | Double newPrice = price.doubleValue()+ 3000.68; 35 | update(drools.getWorkingMemory().getFactHandle(price),newPrice); 36 | retract(drools.getWorkingMemory().getFactHandle(symbol)); 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.kernel/src/main/java/org/wso2/carbon/rule/kernel/backend/Session.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2004,2005 The Apache Software Foundation. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.wso2.carbon.rule.kernel.backend; 18 | 19 | import org.wso2.carbon.rule.common.exception.RuleRuntimeException; 20 | 21 | import java.util.List; 22 | 23 | /** 24 | * This interface abstracts the rule session concept. Backend can create a session according to the type requested. 25 | * Then session can execute the different fact sets. 26 | */ 27 | public interface Session { 28 | 29 | /** 30 | * apply the rules to the given sent of facts and send the result facts back. 31 | * @param facts - list of facts given as POJOs to be executed against backend runtime 32 | * @return - list of facts after applying the rules 33 | * @throws RuleRuntimeException - if there is a problem occurs 34 | */ 35 | public List execute(List facts) throws RuleRuntimeException; 36 | 37 | /** 38 | * 39 | * @throws RuleRuntimeException - if there is a problem occurs 40 | */ 41 | public void destroy() throws RuleRuntimeException; 42 | } 43 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.mediation/src/main/java/org/wso2/carbon/rule/mediator/internal/config/SourceHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2004,2005 The Apache Software Foundation. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.wso2.carbon.rule.mediator.internal.config; 18 | 19 | import org.wso2.carbon.rule.mediator.config.Source; 20 | import org.wso2.carbon.rule.common.config.HelperUtil; 21 | import org.wso2.carbon.rule.common.util.Constants; 22 | import org.apache.axiom.om.OMElement; 23 | import org.apache.axiom.om.OMNamespace; 24 | 25 | import java.util.Iterator; 26 | import java.util.Map; 27 | import java.util.HashMap; 28 | 29 | public class SourceHelper { 30 | 31 | public static Source getSource(OMElement sourceOMElement){ 32 | Source source = new Source(); 33 | 34 | if (sourceOMElement.getText() != null) { 35 | source.setValue(sourceOMElement.getText()); 36 | } 37 | source.setXpath(HelperUtil.getAttributeValue(sourceOMElement, 38 | Constants.RULE_CONF_ATTR_XPATH)); 39 | source.setPrefixToNamespaceMap(HelperUtil.getPrefixToNamespaceMap(sourceOMElement)); 40 | return source; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.kernel/src/main/java/org/wso2/carbon/rule/kernel/backend/RuleBackendRuntimeFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2004,2005 The Apache Software Foundation. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.wso2.carbon.rule.kernel.backend; 18 | 19 | import org.wso2.carbon.rule.common.exception.RuleConfigurationException; 20 | 21 | import java.util.Map; 22 | 23 | /** 24 | * Factory interface to create the real back end runtimes. 25 | */ 26 | public interface RuleBackendRuntimeFactory { 27 | 28 | /** 29 | * This interface is used to create the Back end runtimes in different types. We use a factory to pass properties 30 | * and other backend specific things so that the factory and take care of creating the real runtimes. 31 | * @param properties - backend runtime properties 32 | * @param classLoader - class loader to be used to load the classes 33 | * @return - back end runtime object corresponding to the given factory 34 | */ 35 | public RuleBackendRuntime getRuleBackendRuntime(Map properties, 36 | ClassLoader classLoader) throws RuleConfigurationException; 37 | 38 | } 39 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.ws/src/test/java/org/wso2/carbon/rule/ws/internal/config/TestRuleServiceHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2004,2005 The Apache Software Foundation. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.wso2.carbon.rule.ws.internal.config; 18 | 19 | import junit.framework.TestCase; 20 | import org.apache.axiom.om.impl.builder.StAXOMBuilder; 21 | import org.wso2.carbon.rule.common.RuleService; 22 | import org.wso2.carbon.rule.common.config.RuleServiceHelper; 23 | import org.wso2.carbon.rule.common.exception.RuleConfigurationException; 24 | 25 | import javax.xml.stream.XMLStreamException; 26 | 27 | public class TestRuleServiceHelper extends TestCase { 28 | 29 | public void testGetRuleService(){ 30 | 31 | try { 32 | StAXOMBuilder stAXOMBuilder = 33 | new StAXOMBuilder(this.getClass().getResourceAsStream("/placeOrder.rsl")); 34 | RuleService ruleService = 35 | RuleServiceHelper.getRuleService(stAXOMBuilder.getDocumentElement()); 36 | System.out.println("OK"); 37 | 38 | } catch (XMLStreamException e) { 39 | e.printStackTrace(); 40 | } catch (RuleConfigurationException e) { 41 | e.printStackTrace(); 42 | } 43 | 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.ws.ui/src/main/resources/web/ruleservices/fact_archive_delete-ajaxprocessor.jsp: -------------------------------------------------------------------------------- 1 | 18 | <%@ page import="org.wso2.carbon.rule.ws.ui.wizard.RuleServiceAdminClient" %> 19 | <%@ page import="org.wso2.carbon.rule.common.RuleService" %> 20 | <%@ page import="java.util.ArrayList" %> 21 | <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> 22 | <%@ taglib uri="http://wso2.org/projects/carbon/taglibs/carbontags.jar" prefix="carbon" %> 23 | <% 24 | RuleServiceAdminClient ruleServiceAdminClient = 25 | new RuleServiceAdminClient(config.getServletContext(), session); 26 | RuleService ruleService = ruleServiceAdminClient.getRuleServiceDescription(request); 27 | String filename = request.getParameter("factArchiveName"); 28 | if (filename != null) { 29 | ruleServiceAdminClient.deleteFactArchive(ruleService,filename, session); 30 | ArrayList factArchiveList = (ArrayList) session.getAttribute(RuleServiceAdminClient.FACTS); 31 | factArchiveList.remove(filename); 32 | session.setAttribute(RuleServiceAdminClient.FACTS, factArchiveList); 33 | } 34 | %> -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.kernel/src/main/java/org/wso2/carbon/rule/kernel/internal/event/RuleChangeEventDispacher.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2004,2005 The Apache Software Foundation. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.wso2.carbon.rule.kernel.internal.event; 18 | 19 | import org.wso2.carbon.event.core.subscription.EventDispatcher; 20 | import org.wso2.carbon.event.core.subscription.Subscription; 21 | import org.wso2.carbon.event.core.Message; 22 | import org.wso2.carbon.rule.kernel.engine.RuleEngine; 23 | import org.wso2.carbon.rule.common.exception.RuleConfigurationException; 24 | import org.apache.commons.logging.Log; 25 | import org.apache.commons.logging.LogFactory; 26 | 27 | public class RuleChangeEventDispacher implements EventDispatcher{ 28 | 29 | private static Log log = LogFactory.getLog(RuleChangeEventDispacher.class); 30 | 31 | private RuleEngine ruleEngine; 32 | 33 | public RuleChangeEventDispacher(RuleEngine ruleEngine) { 34 | this.ruleEngine = ruleEngine; 35 | } 36 | 37 | public void notify(Message message, Subscription subscription) { 38 | try { 39 | this.ruleEngine.loadRuleBackendRuntime(); 40 | } catch (RuleConfigurationException e) { 41 | log.error("Can not refresh the rule set ", e); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.samples/src/main/java/org/wso2/carbon/rule/samples/CheckPriceResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.wso2.carbon.rule.samples; 20 | 21 | /** 22 | * 23 | */ 24 | public class CheckPriceResponse { 25 | private String code; 26 | private Double price; 27 | 28 | public String getCode() { 29 | return code; 30 | } 31 | 32 | public void setCode(String code) { 33 | this.code = code; 34 | } 35 | 36 | public Double getPrice() { 37 | return price; 38 | } 39 | 40 | public void setPrice(Double price) { 41 | this.price = price; 42 | } 43 | 44 | public String toXML() { 45 | return "" + 47 | "" + code + "" + 48 | "" + price + "" + 49 | ""; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.kernel/src/main/java/org/wso2/carbon/rule/kernel/config/RuleEngineProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2004,2005 The Apache Software Foundation. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | 18 | package org.wso2.carbon.rule.kernel.config; 19 | 20 | import java.util.Map; 21 | import java.util.HashMap; 22 | 23 | /** 24 | * class to represents the rule engine provider. 25 | */ 26 | public class RuleEngineProvider { 27 | 28 | /** 29 | * factory class name with implements the back end runtime. 30 | */ 31 | private String className; 32 | 33 | /** 34 | * other properties of the engine provider 35 | */ 36 | private Map properties; 37 | 38 | public RuleEngineProvider() { 39 | this.properties = new HashMap(); 40 | } 41 | 42 | public void addProperty(String name, String value){ 43 | this.properties.put(name, value); 44 | } 45 | 46 | public String getClassName() { 47 | return className; 48 | } 49 | 50 | public void setClassName(String className) { 51 | this.className = className; 52 | } 53 | 54 | public Map getProperties() { 55 | return properties; 56 | } 57 | 58 | public void setProperties(Map properties) { 59 | this.properties = properties; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /components/rule/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | org.wso2.carbon.rules 21 | carbon-rule 22 | 4.5.11-SNAPSHOT 23 | ../../pom.xml 24 | 25 | 26 | 4.0.0 27 | rule 28 | pom 29 | WSO2 Carbon - Rule Aggregator Module 30 | http://wso2.org 31 | 32 | 33 | org.wso2.carbon.application.deployer.rule 34 | org.wso2.carbon.rule.common 35 | org.wso2.carbon.rule.ws 36 | org.wso2.carbon.rule.kernel 37 | org.wso2.carbon.rule.backend 38 | org.wso2.carbon.rule.ws.admin 39 | org.wso2.carbon.rule.ws.ui 40 | org.wso2.carbon.rule.mediation 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.backend/src/main/java/org/wso2/carbon/rule/backend/drools/DroolsBackendRuntimeFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2004,2005 The Apache Software Foundation. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.wso2.carbon.rule.backend.drools; 18 | 19 | import org.kie.api.KieServices; 20 | import org.kie.api.builder.KieFileSystem; 21 | import org.wso2.carbon.rule.kernel.backend.RuleBackendRuntime; 22 | import org.wso2.carbon.rule.kernel.backend.RuleBackendRuntimeFactory; 23 | 24 | import java.util.Map; 25 | import java.util.Properties; 26 | 27 | public class DroolsBackendRuntimeFactory implements RuleBackendRuntimeFactory { 28 | 29 | public RuleBackendRuntime getRuleBackendRuntime(Map properties, 30 | ClassLoader classLoader) { 31 | 32 | ClassLoader existingClassLoader = Thread.currentThread().getContextClassLoader(); 33 | try { 34 | Thread.currentThread().setContextClassLoader(classLoader); 35 | 36 | KieServices kieServices = KieServices.Factory.get(); 37 | KieFileSystem kieFileSystem = kieServices.newKieFileSystem(); 38 | return new DroolsBackendRuntime(kieServices, kieFileSystem , classLoader); 39 | } finally { 40 | Thread.currentThread().setContextClassLoader(existingClassLoader); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.backend/src/test/resources/OrderApproval.drl: -------------------------------------------------------------------------------- 1 | package OrderApproval; 2 | 3 | import samples.userguide.OrderAccept; 4 | import samples.userguide.OrderReject; 5 | import samples.userguide.PlaceOrder; 6 | 7 | rule "Order Approval Rule" dialect "mvel" no-loop true salience 4 8 | 9 | when 10 | $placeOrder : PlaceOrder( ( symbol == "IBM" && quantity > 10 ) || ( symbol == "SUN" && price > 100 ) || ( symbol == "MSFT" && price > 50 && quantity < 200 ) ) 11 | then 12 | 13 | OrderAccept orderAccept = new OrderAccept(); 14 | orderAccept.setMessage("Accepted order for: "+ $placeOrder.quantity + " stocks of "+ 15 | $placeOrder.symbol +" at$ " + $placeOrder.price); 16 | insertLogical(orderAccept); 17 | 18 | end 19 | 20 | rule "IBM Order Deny Rule" dialect "mvel" no-loop true salience 3 21 | 22 | when 23 | not ( OrderAccept()) 24 | $placeOrder : PlaceOrder( symbol == "IBM" ) 25 | then 26 | retract($placeOrder); 27 | OrderReject orderReject = new OrderReject(); 28 | orderReject.setReason("An Order for stocks of IBM is accepted only if the number of stocks is higher than 10."); 29 | insertLogical(orderReject); 30 | end 31 | 32 | rule "SUN Order Deny Rule" dialect "mvel" no-loop true salience 2 33 | when 34 | not ( OrderAccept()) 35 | $placeOrder : PlaceOrder( symbol == "SUN" ) 36 | then 37 | retract($placeOrder); 38 | OrderReject orderReject = new OrderReject(); 39 | orderReject.setReason("An Order for stocks of SUN is accepted only if the stock price is higher than 100 $."); 40 | insertLogical(orderReject); 41 | end 42 | 43 | rule "MSFT Order Deny Rule" dialect "mvel" no-loop true salience 1 44 | when 45 | not ( OrderAccept()) 46 | $placeOrder : PlaceOrder( symbol == "MSFT" ) 47 | then 48 | retract($placeOrder); 49 | OrderReject orderReject = new OrderReject(); 50 | orderReject.setReason("An Order for stocks of MSFT is accepted only if the stock price is higher than 50 $ and the number of stocks is lower than 200."); 51 | insertLogical(orderReject); 52 | end 53 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.mediation/src/main/java/org/wso2/carbon/rule/mediator/internal/config/TargetHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2004,2005 The Apache Software Foundation. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.wso2.carbon.rule.mediator.internal.config; 18 | 19 | import org.wso2.carbon.rule.mediator.config.Target; 20 | import org.wso2.carbon.rule.common.config.HelperUtil; 21 | import org.wso2.carbon.rule.common.util.Constants; 22 | import org.apache.axiom.om.OMElement; 23 | 24 | public class TargetHelper { 25 | 26 | public static Target getTarget(OMElement targetOMElement){ 27 | Target target = new Target(); 28 | 29 | if (targetOMElement.getText() != null){ 30 | target.setValue(targetOMElement.getText()); 31 | } 32 | 33 | target.setXpath(HelperUtil.getAttributeValue(targetOMElement, 34 | Constants.RULE_CONF_ATTR_XPATH)); 35 | target.setResultXpath(HelperUtil.getAttributeValue(targetOMElement, 36 | Constants.RULE_CONF_ATTR_RESULT_XPATH)); 37 | target.setAction(HelperUtil.getAttributeValue(targetOMElement, 38 | Constants.RULE_CONF_ATTR_ACTION)); 39 | target.setPrefixToNamespaceMap(HelperUtil.getPrefixToNamespaceMap(targetOMElement)); 40 | return target; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.common/src/main/java/org/wso2/carbon/rule/common/config/OperationHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2004,2005 The Apache Software Foundation. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.wso2.carbon.rule.common.config; 18 | 19 | import org.apache.axiom.om.OMElement; 20 | import org.wso2.carbon.rule.common.Operation; 21 | import org.wso2.carbon.rule.common.util.Constants; 22 | 23 | import javax.xml.namespace.QName; 24 | 25 | public class OperationHelper { 26 | 27 | public static Operation getOperation(OMElement operationElement){ 28 | Operation operation = new Operation(); 29 | 30 | operation.setName(HelperUtil.getAttributeValue( 31 | operationElement, Constants.RULE_CONF_ATTR_NAME)); 32 | 33 | OMElement inputOMElement = 34 | operationElement.getFirstChildWithName(new QName( 35 | Constants.RULE_CONF_NAMESPACE, Constants.RULE_CONF_ELE_INPUT)); 36 | 37 | operation.setInput(InputHelper.getInput(inputOMElement)); 38 | 39 | OMElement outputElement = 40 | operationElement.getFirstChildWithName(new QName( 41 | Constants.RULE_CONF_NAMESPACE, Constants.RULE_CONF_ELE_OUTPUT)); 42 | if(outputElement != null){ 43 | 44 | operation.setOutput(OutputHelper.getOutput(outputElement)); 45 | } 46 | 47 | return operation; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.ws.ui/src/main/resources/web/ruleservices/rule_script_add-ajaxprocessor.jsp: -------------------------------------------------------------------------------- 1 | 18 | <%@ page import="org.wso2.carbon.rule.ws.ui.wizard.RuleServiceAdminClient" %> 19 | <%@ page import="org.wso2.carbon.rule.common.RuleService" %> 20 | <%@ page import="java.util.*" %> 21 | <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> 22 | <%@ taglib uri="http://wso2.org/projects/carbon/taglibs/carbontags.jar" prefix="carbon" %> 23 | <% 24 | RuleServiceAdminClient ruleServiceAdminClient = 25 | new RuleServiceAdminClient(config.getServletContext(), session); 26 | RuleService ruleService = ruleServiceAdminClient.getRuleServiceDescription(request); 27 | String scriptValue = request.getParameter("scriptValue"); 28 | String scriptSourceType = request.getParameter("scriptSourceType"); 29 | 30 | if(scriptValue != null && !scriptValue.equals("")){ 31 | Map scriptList = (Map) session.getAttribute(RuleServiceAdminClient.SCRIPTS); 32 | if(scriptList == null){ 33 | scriptList = new HashMap(); 34 | } 35 | scriptList.put(scriptValue, scriptSourceType); 36 | session.setAttribute(RuleServiceAdminClient.SCRIPTS, scriptList); 37 | 38 | 39 | } 40 | 41 | %> -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.ws/src/main/java/org/wso2/carbon/rule/ws/internal/schema/RuleSchemaGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2004,2005 The Apache Software Foundation. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.wso2.carbon.rule.ws.internal.schema; 18 | 19 | import org.apache.axis2.description.java2wsdl.DefaultSchemaGenerator; 20 | import org.apache.axis2.description.AxisService; 21 | import org.apache.ws.commons.schema.XmlSchema; 22 | 23 | import javax.xml.namespace.QName; 24 | import java.util.List; 25 | import java.util.ArrayList; 26 | 27 | /** 28 | * this class orverrides some methods of the axis2 schema generator. 29 | */ 30 | public class RuleSchemaGenerator extends DefaultSchemaGenerator { 31 | 32 | public RuleSchemaGenerator(ClassLoader classLoader, 33 | AxisService axisService) throws Exception { 34 | super(classLoader, DummyRuleService.class.getName(), null, null, axisService); 35 | } 36 | 37 | public QName generateSchema(Class aClass) throws Exception { 38 | return super.generateSchema(aClass); 39 | } 40 | 41 | public XmlSchema getXmlSchema(String targetNamespace) { 42 | return super.getXmlSchema(targetNamespace); 43 | } 44 | 45 | public List getSchemaList(){ 46 | List schemas = new ArrayList(); 47 | schemas.addAll(this.schemaMap.values()); 48 | return schemas; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.ws.ui/src/main/resources/web/ruleservices/rule_file_delete-ajaxprocessor.jsp: -------------------------------------------------------------------------------- 1 | 18 | <%@ page import="org.wso2.carbon.rule.ws.ui.wizard.RuleServiceAdminClient" %> 19 | <%@ page import="org.wso2.carbon.rule.common.RuleService" %> 20 | <%@ page import="java.util.*" %> 21 | <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> 22 | <%@ taglib uri="http://wso2.org/projects/carbon/taglibs/carbontags.jar" prefix="carbon" %> 23 | <% 24 | RuleServiceAdminClient ruleServiceAdminClient = 25 | new RuleServiceAdminClient(config.getServletContext(), session); 26 | RuleService ruleService = ruleServiceAdminClient.getRuleServiceDescription(request); 27 | String filename = request.getParameter("ruleFileName"); 28 | String sourceType = request.getParameter("sourceType"); 29 | if (filename != null) { 30 | if(sourceType.equals("file")){ 31 | 32 | ruleServiceAdminClient.deleteRuleFile(ruleService,filename, session); 33 | } 34 | Map scriptList = (Map) session.getAttribute(RuleServiceAdminClient.SCRIPTS); 35 | if(scriptList!=null){ 36 | scriptList.remove(filename); 37 | } 38 | session.setAttribute(RuleServiceAdminClient.SCRIPTS, scriptList); 39 | 40 | } 41 | %> -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.backend/src/main/java/org/wso2/carbon/rule/backend/drools/DroolsStatefulSession.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2004,2005 The Apache Software Foundation. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.wso2.carbon.rule.backend.drools; 18 | 19 | import org.kie.api.runtime.KieSession; 20 | import org.wso2.carbon.rule.kernel.backend.Session; 21 | 22 | import java.util.ArrayList; 23 | import java.util.Iterator; 24 | import java.util.List; 25 | 26 | public class DroolsStatefulSession implements Session { 27 | 28 | private KieSession statefulKnowledgeSession; 29 | 30 | public DroolsStatefulSession(KieSession statefulKnowledgeSession) { 31 | this.statefulKnowledgeSession = statefulKnowledgeSession; 32 | } 33 | 34 | public List execute(List facts) { 35 | 36 | for (Object fact : facts) { 37 | this.statefulKnowledgeSession.insert(fact); 38 | } 39 | this.statefulKnowledgeSession.fireAllRules(); 40 | Iterator results = this.statefulKnowledgeSession.getObjects().iterator(); 41 | List tobeReturn = new ArrayList(); 42 | while (results.hasNext()) { 43 | Object result = results.next(); 44 | if (result != null) { 45 | tobeReturn.add(result); 46 | } 47 | } 48 | return tobeReturn; 49 | } 50 | 51 | public void destroy() { 52 | statefulKnowledgeSession.dispose(); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.kernel/src/main/java/org/wso2/carbon/rule/kernel/backend/RuleBackendRuntime.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2004,2005 The Apache Software Foundation. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.wso2.carbon.rule.kernel.backend; 18 | 19 | import org.wso2.carbon.rule.common.RuleSet; 20 | import org.wso2.carbon.rule.common.exception.RuleConfigurationException; 21 | import org.wso2.carbon.rule.common.exception.RuleRuntimeException; 22 | 23 | /** 24 | * interface to separate the Back end real rule implementation from the xml processing layer 25 | * which is in the kernel module. 26 | */ 27 | public interface RuleBackendRuntime { 28 | 29 | /** 30 | * Adds the rule set to back end runtime. Here the rule is depends on the real rule implementation. 31 | * @param ruleSet - rule set to be added to runtime 32 | * @throws RuleConfigurationException - if there are problems with the configuaration 33 | */ 34 | public void addRuleSet(RuleSet ruleSet) throws RuleConfigurationException; 35 | 36 | /** 37 | * Some rules engines support different sessions types. For an example State ful and state less. We abstract this 38 | * concept with session interface. 39 | * @param type - whether it is a stateful or stateless sesstion 40 | * @return - session created 41 | * @throws RuleRuntimeException - if could not create the session 42 | */ 43 | public Session createSession(int type) throws RuleRuntimeException; 44 | } 45 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.backend/src/main/java/org/wso2/carbon/rule/backend/internal/RuleServiceDS.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.wso2.carbon.rule.backend.internal; 18 | 19 | import org.osgi.service.component.annotations.Component; 20 | import org.osgi.service.component.annotations.Reference; 21 | import org.osgi.service.component.annotations.ReferenceCardinality; 22 | import org.osgi.service.component.annotations.ReferencePolicy; 23 | import org.wso2.carbon.registry.core.exceptions.RegistryException; 24 | import org.wso2.carbon.registry.core.service.RegistryService; 25 | 26 | @Component( 27 | name = "ruleService.component", 28 | immediate = true) 29 | public class RuleServiceDS { 30 | 31 | @Reference( 32 | name = "registry.service", 33 | service = org.wso2.carbon.registry.core.service.RegistryService.class, 34 | cardinality = ReferenceCardinality.MANDATORY, 35 | policy = ReferencePolicy.DYNAMIC, 36 | unbind = "unsetRegistryService") 37 | protected void setRegistryService(RegistryService registryService) throws RegistryException { 38 | 39 | RuleServiceValueHolder.getInstance().setRegistryService(registryService); 40 | } 41 | 42 | protected void unsetRegistryService(RegistryService registryService) { 43 | 44 | RuleServiceValueHolder.getInstance().unsetRegistryService(); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.common/src/main/java/org/wso2/carbon/rule/common/config/InputHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2004,2005 The Apache Software Foundation. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.wso2.carbon.rule.common.config; 18 | 19 | import org.wso2.carbon.rule.common.Input; 20 | import org.wso2.carbon.rule.common.Fact; 21 | import org.wso2.carbon.rule.common.util.Constants; 22 | import org.apache.axiom.om.OMElement; 23 | 24 | import javax.xml.namespace.QName; 25 | import java.util.Iterator; 26 | import java.util.List; 27 | import java.util.ArrayList; 28 | 29 | public class InputHelper { 30 | 31 | public static Input getInput(OMElement inputElement) { 32 | 33 | Input input = new Input(); 34 | input.setWrapperElementName(HelperUtil.getAttributeValue( 35 | inputElement, Constants.RULE_CONF_ATTR_WRAPPER_ELEMENT_NAME)); 36 | input.setNameSpace(HelperUtil.getAttributeValue( 37 | inputElement, Constants.RULE_CONF_ATTR_NAMESPACE)); 38 | 39 | Iterator factIterator = 40 | inputElement.getChildrenWithName(new QName( 41 | Constants.RULE_CONF_NAMESPACE, Constants.RULE_CONF_ELE_FACT)); 42 | OMElement factElement; 43 | List facts = new ArrayList(); 44 | for (; factIterator.hasNext();) { 45 | factElement = (OMElement) factIterator.next(); 46 | facts.add(FactHelper.getFact(factElement)); 47 | } 48 | 49 | input.setFacts(facts); 50 | return input; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.common/src/test/java/org/wso2/carbon/rule/common/TestFact.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2004,2005 The Apache Software Foundation. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.wso2.carbon.rule.common; 18 | 19 | import junit.framework.TestCase; 20 | import org.wso2.carbon.rule.common.config.FactHelper; 21 | 22 | import java.util.HashMap; 23 | import java.util.Map; 24 | 25 | /** 26 | * test case for Fact class parsing and serializing 27 | */ 28 | public class TestFact extends TestCase{ 29 | 30 | public void testFact(){ 31 | Fact fact = new Fact(); 32 | fact.setElementName("sampleFact"); 33 | fact.setNamespace("http://com.test"); 34 | fact.setType("sample.Test"); 35 | fact.setXpath("http://com.test.sample.xml"); 36 | 37 | Map nsMAP = new HashMap(); 38 | nsMAP.put("ns1", "http://com.testNS1"); 39 | nsMAP.put("ns2", "http://com.testNS2"); 40 | nsMAP.put("ns3", "http://com.testNS3"); 41 | fact.setPrefixToNamespaceMap(nsMAP); 42 | 43 | Fact resultFact = FactHelper.getFact(fact.toOM()); 44 | assertEquals(fact.getElementName(), resultFact.getElementName()); 45 | assertEquals(fact.getNamespace(), resultFact.getNamespace()); 46 | Map nsResultMap = resultFact.getPrefixToNamespaceMap(); 47 | assertEquals(nsMAP.get("ns1"), nsResultMap.get("ns1")); 48 | assertEquals(nsMAP.get("ns2"), nsResultMap.get("ns2")); 49 | assertEquals(nsMAP.get("ns3"), nsResultMap.get("ns3")); 50 | 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.ws/src/test/java/org/wso2/carbon/rule/ws/internal/schema/TestRuleSchemaGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2004,2005 The Apache Software Foundation. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.wso2.carbon.rule.ws.internal.schema; 18 | 19 | import junit.framework.TestCase; 20 | 21 | import javax.xml.namespace.QName; 22 | 23 | import org.apache.ws.commons.schema.XmlSchema; 24 | import org.apache.axis2.description.AxisService; 25 | 26 | import java.util.Map; 27 | import java.util.HashMap; 28 | 29 | public class TestRuleSchemaGenerator extends TestCase { 30 | 31 | public void testGenerateSchema() { 32 | try { 33 | 34 | AxisService axisService = new AxisService(); 35 | RuleSchemaGenerator ruleSchemaGenerator = 36 | new RuleSchemaGenerator(this.getClass().getClassLoader(), axisService); 37 | 38 | Map packageToNamespaceMap = new HashMap(); 39 | packageToNamespaceMap.put( 40 | "org.wso2.carbon.rule.ws.internal.schema","http://test.com/rule"); 41 | 42 | ruleSchemaGenerator.setPkg2nsmap(packageToNamespaceMap); 43 | QName result = ruleSchemaGenerator.generateSchema(PlaceOrder.class); 44 | XmlSchema xmlSchema = ruleSchemaGenerator.getXmlSchema("http://test.com/rule"); 45 | xmlSchema.write(System.out); 46 | System.out.println("Xmls schema " + xmlSchema.toString()); 47 | } catch (Exception e) { 48 | e.printStackTrace(); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.common/src/main/java/org/wso2/carbon/rule/common/config/OutputHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2004,2005 The Apache Software Foundation. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.wso2.carbon.rule.common.config; 18 | 19 | import org.wso2.carbon.rule.common.Output; 20 | import org.wso2.carbon.rule.common.Fact; 21 | import org.wso2.carbon.rule.common.util.Constants; 22 | import org.apache.axiom.om.OMElement; 23 | 24 | import javax.xml.namespace.QName; 25 | import java.util.Iterator; 26 | import java.util.List; 27 | import java.util.ArrayList; 28 | 29 | public class OutputHelper { 30 | 31 | public static Output getOutput(OMElement outputElement){ 32 | 33 | Output output = new Output(); 34 | 35 | output.setNameSpace(HelperUtil.getAttributeValue( 36 | outputElement, Constants.RULE_CONF_ATTR_NAMESPACE)); 37 | output.setWrapperElementName(HelperUtil.getAttributeValue( 38 | outputElement, Constants.RULE_CONF_ATTR_WRAPPER_ELEMENT_NAME)); 39 | 40 | Iterator factIterator = 41 | outputElement.getChildrenWithName(new QName( 42 | Constants.RULE_CONF_NAMESPACE, Constants.RULE_CONF_ELE_FACT)); 43 | OMElement factElement; 44 | List facts = new ArrayList(); 45 | for (; factIterator.hasNext();) { 46 | factElement = (OMElement) factIterator.next(); 47 | facts.add(FactHelper.getFact(factElement)); 48 | } 49 | output.setFacts(facts); 50 | return output; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.common/src/test/java/org/wso2/carbon/rule/common/TestRule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2004,2005 The Apache Software Foundation. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.wso2.carbon.rule.common; 18 | 19 | import junit.framework.TestCase; 20 | import org.wso2.carbon.rule.common.config.RuleHelper; 21 | 22 | public class TestRule extends TestCase{ 23 | 24 | public void testRule(){ 25 | Rule rule = new Rule(); 26 | 27 | String resourceType = "drl"; 28 | String sourceType = "inline"; 29 | String value ="package ruleTest;\n" + 30 | "\n" + 31 | "import org.wso2.carbon.rule.common.Test;\n" + 32 | "\n" + 33 | "rule SampleTest\n" + 34 | "\n" + 35 | "when\n" + 36 | "$test : Test( passed == true)\n" + 37 | "\n" + 38 | "then\n" + 39 | "$test.setMessage(\" Test Passed \");\n" + 40 | "\n" ; 41 | rule.setResourceType(resourceType); 42 | rule.setSourceType(sourceType); 43 | rule.setValue(value); 44 | rule.setDescription("test description"); 45 | 46 | Rule resultRule = RuleHelper.getRule(rule.toOM()); 47 | assertEquals(rule.getResourceType(), resultRule.getResourceType()); 48 | assertEquals(rule.getSourceType(), resultRule.getSourceType()); 49 | assertEquals(rule.getValue(), resultRule.getValue()); 50 | assertEquals(rule.getDescription(), resultRule.getDescription()); 51 | 52 | } 53 | } -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.kernel/src/main/java/org/wso2/carbon/rule/kernel/backend/DefaultPropertiesProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2004,2005 The Apache Software Foundation. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.wso2.carbon.rule.kernel.backend; 18 | 19 | import java.util.Map; 20 | 21 | /** 22 | * This class was introduced to locate any default proprieties required by the target rule engine. 23 | *

24 | * This is to overcome some limitations in the JSR 94 API. e.g giving the class loader for the rule set 25 | */ 26 | @SuppressWarnings("unused") 27 | public interface DefaultPropertiesProvider { 28 | 29 | /** 30 | * Returns any default properties required at the rule service provider initialization 31 | * 32 | * @param propertyClassLoader ClassLoader to be used by the the rule service provider 33 | * @return a map of default properties to be used when initiating the rule service provider 34 | */ 35 | public Map getRuleServiceProviderDefaultProperties( 36 | ClassLoader propertyClassLoader); 37 | 38 | /** 39 | * Returns any default properties required at the rule set creation 40 | * 41 | * @param propertyClassLoader ClassLoader to be used by the the rule service provider 42 | * to resolve any classes required when creating the rule set 43 | * @return a map of default properties to be used when creating the rule set 44 | */ 45 | public Map getRuleExecutionSetCreationDefaultProperties( 46 | ClassLoader propertyClassLoader); 47 | 48 | } 49 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.ws.ui/src/main/java/org/wso2/carbon/rule/ws/ui/ns/NameSpacesInformation.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2009, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.wso2.carbon.rule.ws.ui.ns; 18 | 19 | import java.util.Collection; 20 | import java.util.HashMap; 21 | import java.util.Map; 22 | 23 | /** 24 | * Keeps NameSpaces 25 | */ 26 | public class NameSpacesInformation { 27 | 28 | private final Map nameSpaces = new HashMap(); 29 | 30 | public void addNameSpace(String prefix, String nsURI) { 31 | nameSpaces.put(prefix, nsURI); 32 | } 33 | 34 | public String getNameSpaceURI(String prefix) { 35 | return nameSpaces.get(prefix); 36 | } 37 | 38 | public Collection getPrefixes() { 39 | return nameSpaces.keySet(); 40 | } 41 | 42 | public void removeAllNameSpaces() { 43 | nameSpaces.clear(); 44 | } 45 | 46 | public String toString() { 47 | return nameSpaces.toString(); 48 | } 49 | 50 | public Map getNameSpaces() { 51 | return nameSpaces; 52 | } 53 | 54 | public void setNameSpaces(Map namespaceMap) { 55 | Collection prefixes = namespaceMap.keySet(); 56 | if (!prefixes.isEmpty()) { 57 | for (String prefix : prefixes) { 58 | String uri = namespaceMap.get(prefix); 59 | nameSpaces.put(prefix, uri); 60 | } 61 | } 62 | 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.ws/src/main/java/org/wso2/carbon/rule/ws/receiver/RuleSessionLifecycle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.wso2.carbon.rule.ws.receiver; 17 | 18 | import org.apache.axis2.AxisFault; 19 | import org.apache.axis2.context.ServiceContext; 20 | import org.apache.axis2.service.Lifecycle; 21 | import org.apache.commons.logging.Log; 22 | import org.apache.commons.logging.LogFactory; 23 | import org.wso2.carbon.rule.common.exception.RuleRuntimeException; 24 | import org.wso2.carbon.rule.common.util.Constants; 25 | import org.wso2.carbon.rule.kernel.engine.RuleSession; 26 | 27 | 28 | public class RuleSessionLifecycle implements Lifecycle { 29 | 30 | private static Log log = LogFactory.getLog(RuleSessionLifecycle.class); 31 | 32 | @Override 33 | public void init(ServiceContext serviceContext) throws AxisFault { 34 | } 35 | 36 | @Override 37 | public void destroy(ServiceContext serviceContext) { 38 | if (log.isDebugEnabled()) { 39 | log.debug("Destroying rule session bound to transport session"); 40 | } 41 | //get stored rule session 42 | RuleSession ruleSession = (RuleSession) serviceContext.getProperty(Constants.RULE_SESSION_OBJECT); 43 | 44 | //dispose it, if exists 45 | if (ruleSession != null) { 46 | try { 47 | ruleSession.destroy(); 48 | serviceContext.removeProperty(Constants.RULE_SESSION_OBJECT); 49 | 50 | } catch (RuleRuntimeException e) { 51 | log.error("Error occurred while destroying rule session", e); 52 | } 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.common/src/test/java/org/wso2/carbon/rule/common/TestRuleSet.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2004,2005 The Apache Software Foundation. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.wso2.carbon.rule.common; 18 | 19 | import junit.framework.TestCase; 20 | import org.wso2.carbon.rule.common.config.RuleSetHelper; 21 | 22 | import java.util.HashMap; 23 | import java.util.Map; 24 | 25 | public class TestRuleSet extends TestCase{ 26 | 27 | public void testRuleSet(){ 28 | RuleSet ruleSet = new RuleSet(); 29 | 30 | 31 | String resourceType = "drl"; 32 | String sourceType = "inline"; 33 | String value = "package ruleTest;\n" + 34 | "\n" + 35 | "import org.wso2.carbon.rule.common.Test;\n" + 36 | "\n" + 37 | "rule SampleTest\n" + 38 | "\n" + 39 | "when\n" + 40 | "$test : Test( passed == true)\n" + 41 | "\n" + 42 | "then\n" + 43 | "$test.setMessage(\" Test Passed \");\n" + 44 | "\n"; 45 | 46 | // Add rule 47 | Rule rule = new Rule(); 48 | rule.setResourceType(resourceType); 49 | rule.setSourceType(sourceType); 50 | rule.setValue(value); 51 | ruleSet.addRule(rule); 52 | 53 | // Add property Map 54 | Map propertyMAP = new HashMap(); 55 | propertyMAP.put("name1", "value1"); 56 | propertyMAP.put("name2", "value2"); 57 | 58 | ruleSet.setProperties(propertyMAP); 59 | 60 | 61 | RuleSet resultRuleSet = RuleSetHelper.getRuleSet(ruleSet.toOM()); 62 | assertEquals(ruleSet.getProperties(), resultRuleSet.getProperties()); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.common/src/test/java/org/wso2/carbon/rule/common/TestInput.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2004,2005 The Apache Software Foundation. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.wso2.carbon.rule.common; 18 | 19 | import junit.framework.TestCase; 20 | import org.wso2.carbon.rule.common.config.InputHelper; 21 | 22 | import java.util.HashMap; 23 | import java.util.List; 24 | import java.util.Map; 25 | 26 | public class TestInput extends TestCase{ 27 | 28 | public void testInput(){ 29 | Input input = new Input(); 30 | input.setWrapperElementName("sampleTestInput"); 31 | input.setNameSpace("http://com.test"); 32 | 33 | // Create Fact object 34 | Fact inputFact = new Fact(); 35 | inputFact.setElementName("sampleInputFact"); 36 | inputFact.setNamespace("http://com.testInput"); 37 | inputFact.setType("sample.Test.Input"); 38 | inputFact.setXpath("http://com.test.sampleInput.xml"); 39 | 40 | Map nsMAP = new HashMap(); 41 | nsMAP.put("ns1", "http://com.testNS1"); 42 | nsMAP.put("ns2", "http://com.testNS2"); 43 | nsMAP.put("ns3", "http://com.testNS3"); 44 | inputFact.setPrefixToNamespaceMap(nsMAP); 45 | input.addFact(inputFact); 46 | 47 | Input resultInput = InputHelper.getInput(input.toOM()); 48 | List inputFacts = input.getFacts(); 49 | List resultFacts = resultInput.getFacts(); 50 | assertEquals(input.getWrapperElementName(), resultInput.getWrapperElementName()); 51 | assertEquals(input.getNameSpace(), resultInput.getNameSpace()); 52 | assertNotNull(inputFacts); 53 | assertNotNull(resultFacts); 54 | assertEquals(inputFacts.size(), resultFacts.size()); 55 | 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.ws.ui/src/main/resources/web/ruleservices/property_save-ajaxprocessor.jsp: -------------------------------------------------------------------------------- 1 | 18 | <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" %> 19 | <%@ page import="org.wso2.carbon.rule.common.RuleService" %> 20 | <%@ page import="org.wso2.carbon.rule.common.RuleSet" %> 21 | <%@ page import="org.wso2.carbon.rule.ws.ui.wizard.RuleServiceAdminClient" %> 22 | 23 | <% 24 | RuleServiceAdminClient ruleServiceAdminClient = 25 | new RuleServiceAdminClient(config.getServletContext(), session); 26 | 27 | RuleService ruleService = ruleServiceAdminClient.getRuleServiceDescription(request); 28 | RuleSet ruleSet = ruleService.getRuleSet(); 29 | if(ruleSet == null){ 30 | ruleSet = new RuleSet(); 31 | ruleService.setRuleSet(ruleSet); 32 | } 33 | 34 | String CountParameter = request.getParameter("propertyCount"); 35 | if (CountParameter != null && !"".equals(CountParameter)) { 36 | try { 37 | int count = Integer.parseInt(CountParameter.trim()); 38 | for (int i = 0; i < count; i++) { 39 | String name = request.getParameter("name" + i); 40 | if (name == null || "".equals(name)) { 41 | continue; 42 | } 43 | String value = request.getParameter("value" + i); 44 | if (value == null || "".equals(value)) { 45 | continue; 46 | } 47 | ruleSet.addProperties(name, value); 48 | } 49 | } catch (NumberFormatException ignored) { 50 | } 51 | } 52 | %> 53 | 54 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.common/src/test/java/org/wso2/carbon/rule/common/TestOutput.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2004,2005 The Apache Software Foundation. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.wso2.carbon.rule.common; 18 | 19 | import junit.framework.TestCase; 20 | import org.wso2.carbon.rule.common.config.OutputHelper; 21 | 22 | import java.util.HashMap; 23 | import java.util.List; 24 | import java.util.Map; 25 | 26 | public class TestOutput extends TestCase{ 27 | 28 | public void testOutput(){ 29 | 30 | Output output = new Output(); 31 | output.setWrapperElementName("sampleTestOutput"); 32 | output.setNameSpace("http://com.test"); 33 | 34 | // Create Fact object 35 | Fact outputFact = new Fact(); 36 | outputFact.setElementName("sampleOutputFact"); 37 | outputFact.setNamespace("http://com.testOutput"); 38 | outputFact.setType("sample.Test.Output"); 39 | outputFact.setXpath("http://com.test.sampleOutput.xml"); 40 | 41 | Map nsMAP = new HashMap(); 42 | nsMAP.put("ns1", "http://com.testNS1"); 43 | nsMAP.put("ns2", "http://com.testNS2"); 44 | nsMAP.put("ns3", "http://com.testNS3"); 45 | outputFact.setPrefixToNamespaceMap(nsMAP); 46 | output.addFact(outputFact); 47 | 48 | Output resultOutput = OutputHelper.getOutput(output.toOM()); 49 | List outputFacts = output.getFacts(); 50 | List resultFacts = resultOutput.getFacts(); 51 | assertEquals(output.getWrapperElementName(), resultOutput.getWrapperElementName()); 52 | assertEquals(output.getNameSpace(), resultOutput.getNameSpace()); 53 | assertNotNull(outputFact); 54 | assertNotNull(resultFacts); 55 | assertEquals(outputFacts.size(), resultFacts.size()); 56 | 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.ws.ui/src/main/resources/web/ruleservices/cancel_handler.jsp: -------------------------------------------------------------------------------- 1 | 18 | <%@ page import="org.wso2.carbon.rule.ws.ui.ns.NameSpacesInformationRepository" %> 19 | <%@ page import="org.wso2.carbon.rule.ws.ui.wizard.RuleServiceAdminClient" %> 20 | <%@ page import="org.wso2.carbon.rule.common.RuleService" %> 21 | <%@ page import="org.wso2.carbon.ui.CarbonUIMessage" %> 22 | <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> 23 | <%@ taglib uri="http://wso2.org/projects/carbon/taglibs/carbontags.jar" prefix="carbon" %> 24 | 25 | <% 26 | try { 27 | RuleServiceAdminClient ruleServiceAdminClient = 28 | new RuleServiceAdminClient(config.getServletContext(), session); 29 | RuleService ruleService = 30 | ruleServiceAdminClient.getRuleServiceDescription(request); 31 | ruleServiceAdminClient.deleteTempRuleDirectory(ruleService,session); 32 | 33 | } catch (Exception e) { 34 | String msg = "Error cancelling rule service : " + e.getMessage(); 35 | CarbonUIMessage.sendCarbonUIMessage(msg, CarbonUIMessage.ERROR, request, 36 | response, "../admin/error.jsp"); 37 | } finally { 38 | session.removeAttribute(RuleServiceAdminClient.RULE_SERVIE); 39 | session.removeAttribute(RuleServiceAdminClient.FACTS); 40 | session.removeAttribute(RuleServiceAdminClient.SCRIPTS); 41 | session.removeAttribute(NameSpacesInformationRepository.NAMESPACES_INFORMATION_REPOSITORY); 42 | } 43 | 44 | %> 45 | 46 | 49 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.backend/src/main/java/org/wso2/carbon/rule/backend/jsr94/JSR94StatelessSession.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2004,2005 The Apache Software Foundation. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.wso2.carbon.rule.backend.jsr94; 18 | 19 | import org.wso2.carbon.rule.common.exception.RuleRuntimeException; 20 | import org.wso2.carbon.rule.kernel.backend.Session; 21 | 22 | import javax.rules.InvalidRuleSessionException; 23 | import javax.rules.StatelessRuleSession; 24 | import java.rmi.RemoteException; 25 | import java.util.List; 26 | 27 | public class JSR94StatelessSession implements Session { 28 | 29 | /** 30 | * JSR94 StatelessSession 31 | */ 32 | private StatelessRuleSession statelessRuleSession; 33 | 34 | public JSR94StatelessSession(StatelessRuleSession statelessRuleSession) { 35 | this.statelessRuleSession = statelessRuleSession; 36 | } 37 | 38 | @Override 39 | public List execute(List facts) throws RuleRuntimeException { 40 | try { 41 | return statelessRuleSession.executeRules(facts); 42 | } catch (InvalidRuleSessionException e) { 43 | throw new RuleRuntimeException("Error was occurred when executing StateLess Session", e); 44 | } catch (RemoteException e) { 45 | throw new RuleRuntimeException("Error was occurred when executing StateLess Session",e); 46 | } 47 | } 48 | 49 | @Override 50 | public void destroy() throws RuleRuntimeException { 51 | try { 52 | statelessRuleSession.release(); 53 | } catch (RemoteException e) { 54 | throw new RuleRuntimeException("Error was occurred when executing StateLess Session", e); 55 | } catch (InvalidRuleSessionException e) { 56 | throw new RuleRuntimeException("Error was occurred when executing StateLess Session", e); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.common/src/main/java/org/wso2/carbon/rule/common/Operation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2004,2005 The Apache Software Foundation. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.wso2.carbon.rule.common; 18 | 19 | import org.apache.axiom.om.OMAbstractFactory; 20 | import org.apache.axiom.om.OMElement; 21 | import org.apache.axiom.om.OMFactory; 22 | import org.wso2.carbon.rule.common.util.Constants; 23 | 24 | public class Operation { 25 | 26 | private String name; 27 | private Input input; 28 | private Output output; 29 | 30 | public Operation() { 31 | this.input = new Input(); 32 | this.output = new Output(); 33 | } 34 | 35 | public OMElement toOM(){ 36 | OMFactory omFactory = OMAbstractFactory.getOMFactory(); 37 | OMElement ruleOperationOMElement = 38 | omFactory.createOMElement(Constants.RULE_CONF_ELE_OPERATION, 39 | Constants.RULE_CONF_NAMESPACE, 40 | Constants.RULE_CONF_NAMESPACE_PREFIX); 41 | ruleOperationOMElement.addAttribute(Constants.RULE_CONF_ATTR_NAME, this.name, null); 42 | 43 | if(this.input != null){ 44 | ruleOperationOMElement.addChild(this.input.toOM()); 45 | } 46 | if(this.output != null){ 47 | ruleOperationOMElement.addChild(this.output.toOM()); 48 | } 49 | 50 | return ruleOperationOMElement; 51 | } 52 | 53 | public String getName() { 54 | return name; 55 | } 56 | 57 | public void setName(String name) { 58 | this.name = name; 59 | } 60 | 61 | public Input getInput() { 62 | return input; 63 | } 64 | 65 | public void setInput(Input input) { 66 | this.input = input; 67 | } 68 | 69 | public Output getOutput() { 70 | return output; 71 | } 72 | 73 | public void setOutput(Output output) { 74 | this.output = output; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.ws.ui/src/main/resources/web/ruleservices/rule_service_wizard_end.jsp: -------------------------------------------------------------------------------- 1 | 18 | <%@ page import="org.wso2.carbon.rule.ws.ui.ns.NameSpacesInformationRepository" %> 19 | <%@ page import="org.wso2.carbon.rule.ws.ui.wizard.RuleServiceAdminClient" %> 20 | <%@ page import="org.wso2.carbon.ui.CarbonUIMessage" %> 21 | <%@ page import="org.wso2.carbon.rule.common.RuleService" %> 22 | <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> 23 | <%@ taglib uri="http://wso2.org/projects/carbon/taglibs/carbontags.jar" prefix="carbon" %> 24 | <% 25 | try { 26 | RuleServiceAdminClient ruleServiceAdminClient = 27 | new RuleServiceAdminClient(config.getServletContext(), session); 28 | RuleService ruleService = 29 | ruleServiceAdminClient.getRuleServiceDescription(request); 30 | ruleServiceAdminClient.saveService(ruleService); 31 | String msg = "Service was saved successfully : Service Name : " + 32 | ruleService.getName(); 33 | CarbonUIMessage.sendCarbonUIMessage(msg, CarbonUIMessage.INFO, request, 34 | response, "../service-mgt/index.jsp"); 35 | 36 | } catch (Exception e) { 37 | String msg = "Error saving rule service : " + e.getMessage(); 38 | CarbonUIMessage.sendCarbonUIMessage(msg, CarbonUIMessage.ERROR, request, 39 | response, "../admin/error.jsp"); 40 | } finally { 41 | session.removeAttribute(RuleServiceAdminClient.RULE_SERVIE); 42 | session.removeAttribute(RuleServiceAdminClient.FACTS); 43 | session.removeAttribute(RuleServiceAdminClient.SCRIPTS); 44 | session.removeAttribute(NameSpacesInformationRepository.NAMESPACES_INFORMATION_REPOSITORY); 45 | } 46 | %> 47 | 48 | 51 | 52 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.mediation/src/test/java/org/wso2/carbon/rule/mediator/RuleMediatorSessionCreationTestCase.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 The Apache Software Foundation. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.wso2.carbon.rule.mediator; 17 | 18 | import junit.framework.Assert; 19 | import junit.framework.TestCase; 20 | import org.apache.axiom.om.OMElement; 21 | import org.apache.axiom.om.util.AXIOMUtil; 22 | import org.wso2.carbon.rule.common.util.Constants; 23 | import org.wso2.carbon.rule.mediator.config.RuleMediatorConfig; 24 | import org.wso2.carbon.rule.mediator.internal.config.RuleMediatorConfigHelper; 25 | 26 | import javax.xml.stream.XMLStreamException; 27 | 28 | /** 29 | * Testcase for creating check stateless session creation in rule mediator. 30 | */ 31 | public class RuleMediatorSessionCreationTestCase extends TestCase{ 32 | public void testRuleEngine(){ 33 | String EXPECTED = "stateless"; 34 | try { 35 | OMElement ruleOMElement = AXIOMUtil.stringToOM("\n" + 36 | " \n" + 37 | " \n" + 38 | " \n" + 39 | " \n" + 40 | " \n" + 41 | " \n" + 42 | " \n" + 43 | " \n" + 44 | " \n" + 45 | " "); 46 | 47 | RuleMediatorConfig ruleMediatorConfig = RuleMediatorConfigHelper.getRuleMediatorConfig(ruleOMElement); 48 | Assert.assertEquals(ruleMediatorConfig.getSession().getAttributeValue(Constants.RULE_SESSION_TYPE_QNAME),EXPECTED); 49 | 50 | } catch (XMLStreamException e) { 51 | e.printStackTrace(); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /pull_request_template.md: -------------------------------------------------------------------------------- 1 | ## Purpose 2 | > Describe the problems, issues, or needs driving this feature/fix and include links to related issues in the following format: Resolves issue1, issue2, etc. 3 | 4 | ## Goals 5 | > Describe the solutions that this feature/fix will introduce to resolve the problems described above 6 | 7 | ## Approach 8 | > Describe how you are implementing the solutions. Include an animated GIF or screenshot if the change affects the UI (email documentation@wso2.com to review all UI text). Include a link to a Markdown file or Google doc if the feature write-up is too long to paste here. 9 | 10 | ## User stories 11 | > Summary of user stories addressed by this change> 12 | 13 | ## Release note 14 | > Brief description of the new feature or bug fix as it will appear in the release notes 15 | 16 | ## Documentation 17 | > Link(s) to product documentation that addresses the changes of this PR. If no doc impact, enter “N/A” plus brief explanation of why there’s no doc impact 18 | 19 | ## Training 20 | > Link to the PR for changes to the training content in https://github.com/wso2/WSO2-Training, if applicable 21 | 22 | ## Certification 23 | > Type “Sent” when you have provided new/updated certification questions, plus four answers for each question (correct answer highlighted in bold), based on this change. Certification questions/answers should be sent to certification@wso2.com and NOT pasted in this PR. If there is no impact on certification exams, type “N/A” and explain why. 24 | 25 | ## Marketing 26 | > Link to drafts of marketing content that will describe and promote this feature, including product page changes, technical articles, blog posts, videos, etc., if applicable 27 | 28 | ## Automation tests 29 | - Unit tests 30 | > Code coverage information 31 | - Integration tests 32 | > Details about the test cases and coverage 33 | 34 | ## Security checks 35 | - Followed secure coding standards in http://wso2.com/technical-reports/wso2-secure-engineering-guidelines? yes/no 36 | - Ran FindSecurityBugs plugin and verified report? yes/no 37 | - Confirmed that this PR doesn't commit any keys, passwords, tokens, usernames, or other secrets? yes/no 38 | 39 | ## Samples 40 | > Provide high-level details about the samples related to this feature 41 | 42 | ## Related PRs 43 | > List any other related PRs 44 | 45 | ## Migrations (if applicable) 46 | > Describe migration steps and platforms on which migration has been tested 47 | 48 | ## Test environment 49 | > List all JDK versions, operating systems, databases, and browser/versions on which this feature/fix was tested 50 | 51 | ## Learning 52 | > Describe the research phase and any blog posts, patterns, libraries, or add-ons you used to solve the problem. -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.samples/src/conf/synapse/synapse_sample_604.xml: -------------------------------------------------------------------------------- 1 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | file:repository/samples/resources/ 27 | 28 | 15000 29 | 30 | 31 | 32 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 44 | 46 | 47 | 48 | 49 | 50 | 51 | 52 |

53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.common/src/main/java/org/wso2/carbon/rule/common/config/RuleSetHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2004,2005 The Apache Software Foundation. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.wso2.carbon.rule.common.config; 18 | 19 | import org.wso2.carbon.rule.common.RuleSet; 20 | import org.wso2.carbon.rule.common.Rule; 21 | import org.wso2.carbon.rule.common.util.Constants; 22 | import org.apache.axiom.om.OMElement; 23 | 24 | import javax.xml.namespace.QName; 25 | import java.util.*; 26 | 27 | public class RuleSetHelper { 28 | 29 | public static RuleSet getRuleSet(OMElement ruleSetElement) { 30 | 31 | RuleSet ruleSet = new RuleSet(); 32 | 33 | Iterator ruleIterator = 34 | ruleSetElement.getChildrenWithName(new QName( 35 | Constants.RULE_CONF_NAMESPACE, Constants.RULE_CONF_ELE_RULE)); 36 | 37 | OMElement ruleElement; 38 | List rules = new ArrayList(); 39 | 40 | for (; ruleIterator.hasNext();) { 41 | ruleElement = (OMElement) ruleIterator.next(); 42 | rules.add(RuleHelper.getRule(ruleElement)); 43 | } 44 | 45 | ruleSet.setRules(rules); 46 | 47 | OMElement propertiesElement = 48 | ruleSetElement.getFirstChildWithName(new QName( 49 | Constants.RULE_CONF_NAMESPACE, Constants.RULE_CONF_ELE_PROPERTIES)); 50 | Map properties = new HashMap(); 51 | if (propertiesElement != null) { 52 | 53 | Iterator propertiesIter = 54 | propertiesElement.getChildrenWithName(new QName( 55 | Constants.RULE_CONF_NAMESPACE, Constants.RULE_CONF_ELE_PROPERTY)); 56 | OMElement property; 57 | for (; propertiesIter.hasNext();) { 58 | property = (OMElement) propertiesIter.next(); 59 | properties.put(HelperUtil.getAttributeValue(property, Constants.RULE_CONF_ATTR_NAME), 60 | HelperUtil.getAttributeValue(property, Constants.RULE_CONF_ATTR_VALE)); 61 | } 62 | 63 | } 64 | ruleSet.setProperties(properties); 65 | return ruleSet; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.backend/src/main/java/org/wso2/carbon/rule/backend/jsr94/JSR94StatefulSession.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2004,2005 The Apache Software Foundation. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.wso2.carbon.rule.backend.jsr94; 18 | 19 | import org.wso2.carbon.rule.common.exception.RuleRuntimeException; 20 | import org.wso2.carbon.rule.kernel.backend.Session; 21 | 22 | import javax.rules.InvalidRuleSessionException; 23 | import javax.rules.StatefulRuleSession; 24 | import java.rmi.RemoteException; 25 | import java.util.List; 26 | 27 | public class JSR94StatefulSession implements Session { 28 | 29 | private StatefulRuleSession statefulRuleSession; 30 | /* Lock used to ensure thread-safe execution of the rule engine */ 31 | private final Object resourceLock = new Object(); 32 | 33 | public JSR94StatefulSession(StatefulRuleSession statefulRuleSession) { 34 | this.statefulRuleSession = statefulRuleSession; 35 | } 36 | 37 | @Override 38 | public List execute(List facts) throws RuleRuntimeException { 39 | try { 40 | 41 | synchronized (resourceLock) { // TODO optimize this 42 | 43 | statefulRuleSession.addObjects(facts); 44 | statefulRuleSession.executeRules(); 45 | return statefulRuleSession.getObjects(); 46 | } 47 | } catch (InvalidRuleSessionException e) { 48 | throw new RuleRuntimeException("Error was occurred when executing stateful session", e); 49 | } catch (RemoteException e) { 50 | throw new RuleRuntimeException("Error was occurred when executing stateful session", e); 51 | } 52 | } 53 | 54 | @Override 55 | public void destroy() throws RuleRuntimeException { 56 | try { 57 | synchronized (resourceLock) { //TODO 58 | statefulRuleSession.release(); 59 | } 60 | } catch (RemoteException e) { 61 | throw new RuleRuntimeException("Error was occurred when executing stateful session", e); 62 | } catch (InvalidRuleSessionException e) { 63 | throw new RuleRuntimeException("Error was occurred when executing stateful session",e); 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.samples/src/conf/synapse/synapse_sample_601.xml: -------------------------------------------------------------------------------- 1 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | file:repository/samples/resources/ 27 | 28 | 15000 29 | 30 | 31 | 32 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 47 | 48 | 49 | 50 | 51 |
52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.samples/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | org.wso2.carbon.rules 21 | rule 22 | 4.3.0-SNAPSHOT 23 | ../pom.xml 24 | 25 | 26 | 4.0.0 27 | 4.3.0-SNAPSHOT 28 | org.wso2.carbon.rules.rule.samples 29 | bundle 30 | WSO2 Carbon - Rule Samples 31 | 32 | 33 | 34 | 35 | org.apache.maven.plugins 36 | maven-surefire-plugin 37 | 2.3 38 | 39 | 40 | org.apache.felix 41 | maven-bundle-plugin 42 | true 43 | 44 | 45 | ${project.artifactId} 46 | ${project.artifactId} 47 | 48 | org.wso2.carbon.rule.samples.*, 49 | 50 | 51 | !javax.xml.namespace, 52 | javax.xml.namespace; version=0.0.0, 53 | *;resolution:=optional, 54 | 55 | * 56 | 57 | 58 | 59 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.mediation/src/main/java/org/wso2/carbon/rule/mediator/config/Source.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2004,2005 The Apache Software Foundation. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.wso2.carbon.rule.mediator.config; 18 | 19 | import org.apache.axiom.om.OMElement; 20 | import org.apache.axiom.om.OMFactory; 21 | import org.apache.axiom.om.OMAbstractFactory; 22 | import org.wso2.carbon.rule.common.util.Constants; 23 | 24 | import java.util.Map; 25 | 26 | public class Source { 27 | 28 | private String value; 29 | private String xpath; 30 | private Map prefixToNamespaceMap; 31 | 32 | public OMElement toOM(){ 33 | OMFactory omFactory = OMAbstractFactory.getOMFactory(); 34 | 35 | OMElement sourceElement = omFactory.createOMElement(Constants.RULE_CONF_ELE_SOURCE, 36 | Constants.RULE_CONF_NAMESPACE, 37 | Constants.RULE_CONF_NAMESPACE_PREFIX); 38 | if (this.xpath != null){ 39 | sourceElement.addAttribute(Constants.RULE_CONF_ATTR_XPATH, this.xpath, null); 40 | } 41 | 42 | if (this.value != null){ 43 | sourceElement.setText(this.value); 44 | } 45 | if(this.prefixToNamespaceMap != null){ 46 | 47 | for (String prefix : this.prefixToNamespaceMap.keySet()){ 48 | 49 | String nsURI = this.prefixToNamespaceMap.get(prefix); 50 | sourceElement.declareNamespace(nsURI, prefix); 51 | 52 | } 53 | } 54 | 55 | return sourceElement; 56 | } 57 | 58 | public String getValue() { 59 | return value; 60 | } 61 | 62 | public void setValue(String value) { 63 | this.value = value; 64 | } 65 | 66 | public String getXpath() { 67 | return xpath; 68 | } 69 | 70 | public void setXpath(String xpath) { 71 | this.xpath = xpath; 72 | } 73 | 74 | public Map getPrefixToNamespaceMap() { 75 | return prefixToNamespaceMap; 76 | } 77 | 78 | public void setPrefixToNamespaceMap(Map prefixToNamespaceMap) { 79 | this.prefixToNamespaceMap = prefixToNamespaceMap; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.backend/src/main/java/org/wso2/carbon/rule/backend/jsr94/drools/DroolsJSR94DefaultPropertiesProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2004,2005 The Apache Software Foundation. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.wso2.carbon.rule.backend.jsr94.drools; 18 | 19 | import org.wso2.carbon.rule.kernel.backend.DefaultPropertiesProvider; 20 | import org.drools.jsr94.rules.Constants; 21 | import org.drools.core.RuleBaseConfiguration; 22 | import org.drools.compiler.builder.impl.KnowledgeBuilderConfigurationImpl; 23 | 24 | import java.util.Map; 25 | import java.util.HashMap; 26 | 27 | /** 28 | * Provides default properties required by the drools rule engine. 29 | * This is used to provide added capability to the JSR 94 API 30 | */ 31 | public class DroolsJSR94DefaultPropertiesProvider implements DefaultPropertiesProvider { 32 | 33 | public Map getRuleServiceProviderDefaultProperties( 34 | ClassLoader propertyClassLoader) { 35 | return new HashMap(); 36 | } 37 | 38 | /** 39 | * Provides a PackageBuilderConfiguration and a RuleBaseConfiguration 40 | * where the root class loader is one provided as the argument 41 | * 42 | * @param propertyClassLoader ClassLoader to be used by the the rule service provider 43 | * to resolve any classes required when creating the rule set 44 | * @return A map of default properties to be used when creating a rule execution set 45 | */ 46 | public Map getRuleExecutionSetCreationDefaultProperties( 47 | ClassLoader propertyClassLoader) { 48 | // PackageBuilderConfiguration configuration = 49 | // new PackageBuilderConfiguration(propertyClassLoader); 50 | KnowledgeBuilderConfigurationImpl configuration = new KnowledgeBuilderConfigurationImpl(propertyClassLoader); 51 | Map properties = new HashMap(); 52 | properties.put(Constants.RES_PACKAGEBUILDER_CONFIG, configuration); 53 | RuleBaseConfiguration baseConfiguration = new RuleBaseConfiguration(propertyClassLoader); 54 | properties.put(Constants.RES_RULEBASE_CONFIG, baseConfiguration); 55 | return properties; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.application.deployer.rule/src/main/java/org/wso2/carbon/application/deployer/rule/internal/RuleAppDeployerDSComponent.java: -------------------------------------------------------------------------------- 1 | package org.wso2.carbon.application.deployer.rule.internal; 2 | 3 | import org.apache.axiom.om.impl.builder.StAXOMBuilder; 4 | import org.apache.commons.logging.Log; 5 | import org.apache.commons.logging.LogFactory; 6 | import org.osgi.framework.ServiceRegistration; 7 | import org.osgi.service.component.ComponentContext; 8 | import org.osgi.service.component.annotations.Activate; 9 | import org.osgi.service.component.annotations.Component; 10 | import org.osgi.service.component.annotations.Deactivate; 11 | import org.wso2.carbon.application.deployer.AppDeployerConstants; 12 | import org.wso2.carbon.application.deployer.AppDeployerUtils; 13 | import org.wso2.carbon.application.deployer.Feature; 14 | import org.wso2.carbon.application.deployer.handler.AppDeploymentHandler; 15 | import org.wso2.carbon.application.deployer.rule.RuleAppDeployer; 16 | 17 | import java.io.InputStream; 18 | import java.net.URL; 19 | import java.util.List; 20 | import java.util.Map; 21 | 22 | @Component( 23 | name = "application.deployer.rule", 24 | immediate = true) 25 | public class RuleAppDeployerDSComponent { 26 | 27 | private static Log log = LogFactory.getLog(RuleAppDeployerDSComponent.class); 28 | 29 | private static Map> requiredFeatures; 30 | 31 | private static ServiceRegistration appHandlerRegistration; 32 | 33 | @Activate 34 | protected void activate(ComponentContext ctxt) { 35 | 36 | try { 37 | // Register BRS deployer as an OSGi service 38 | RuleAppDeployer brsDeployer = new RuleAppDeployer(); 39 | appHandlerRegistration = ctxt.getBundleContext().registerService(AppDeploymentHandler.class.getName(), 40 | brsDeployer, null); 41 | // read required-features.xml 42 | URL reqFeaturesResource = ctxt.getBundleContext().getBundle().getResource(AppDeployerConstants 43 | .REQ_FEATURES_XML); 44 | if (reqFeaturesResource != null) { 45 | InputStream xmlStream = reqFeaturesResource.openStream(); 46 | requiredFeatures = AppDeployerUtils.readRequiredFeaturs(new StAXOMBuilder(xmlStream) 47 | .getDocumentElement()); 48 | } 49 | } catch (Throwable e) { 50 | log.error("Failed to activate BRS Application Deployer", e); 51 | } 52 | } 53 | 54 | @Deactivate 55 | protected void deactivate(ComponentContext ctxt) { 56 | // Unregister the OSGi service 57 | if (appHandlerRegistration != null) { 58 | appHandlerRegistration.unregister(); 59 | } 60 | } 61 | 62 | public static Map> getRequiredFeatures() { 63 | 64 | return requiredFeatures; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.kernel/src/test/java/org/wso2/carbon/rule/kernel/internal/util/TestDataBindUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2004,2005 The Apache Software Foundation. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.wso2.carbon.rule.kernel.internal.util; 18 | 19 | import org.wso2.carbon.rule.common.exception.RuleRuntimeException; 20 | import org.apache.axiom.om.OMElement; 21 | import junit.framework.TestCase; 22 | 23 | import javax.xml.namespace.QName; 24 | 25 | 26 | public class TestDataBindUtil extends TestCase { 27 | 28 | public void testGetOMElement1() { 29 | 30 | OMElement omElement = DataBindUtil.toOM("Test String", new QName("http://com.test/rule", "custom")); 31 | System.out.println("OMElement ==> " + omElement.toString()); 32 | } 33 | 34 | public void testGetOMElement2() { 35 | 36 | PlaceOrder placeOrder = new PlaceOrder(); 37 | placeOrder.setSymbol("IBM"); 38 | placeOrder.setQuantity(10); 39 | placeOrder.setPrice(20.34); 40 | OMElement omElement = DataBindUtil.toOM(placeOrder, new QName("http://com.test/rule", "custom")); 41 | System.out.println("OMElement ==> " + omElement.toString()); 42 | } 43 | 44 | public void testGetValue() { 45 | 46 | OMElement omElement = DataBindUtil.toOM("Test String", new QName("http://com.test/rule", "custom")); 47 | try { 48 | Object result = DataBindUtil.getValue(omElement, String.class); 49 | assertEquals(result, "Test String"); 50 | } catch (RuleRuntimeException e) { 51 | e.printStackTrace(); 52 | } 53 | 54 | } 55 | 56 | public void testGetValue2() { 57 | 58 | PlaceOrder placeOrder = new PlaceOrder(); 59 | placeOrder.setSymbol("IBM"); 60 | placeOrder.setQuantity(10); 61 | placeOrder.setPrice(20.34); 62 | OMElement omElement = DataBindUtil.toOM(placeOrder, new QName("http://com.test/rule", "custom")); 63 | try { 64 | PlaceOrder result = (PlaceOrder) DataBindUtil.getValue(omElement, PlaceOrder.class); 65 | assertEquals(result.getSymbol(), "IBM"); 66 | assertEquals(result.getQuantity(), 10); 67 | assertEquals(result.getPrice(), 20.34); 68 | } catch (RuleRuntimeException e) { 69 | e.printStackTrace(); 70 | } 71 | 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.ws.ui/src/main/resources/web/ruleservices/ns_save-ajaxprocessor.jsp: -------------------------------------------------------------------------------- 1 | 18 | <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" %> 19 | <%@ page import="org.wso2.carbon.rule.ws.ui.ns.NameSpacesInformation" %> 20 | <%@ page import="org.wso2.carbon.rule.ws.ui.ns.NameSpacesInformationRepository" %> 21 | 22 | <% 23 | String currentID = request.getParameter("currentID"); 24 | if (currentID == null || "".equals(currentID)) { 25 | //TODO 26 | throw new RuntimeException("'currentID' parameter cannot be found"); 27 | } 28 | 29 | String opName = request.getParameter("opName"); 30 | if (opName == null || "".equals(opName)) { 31 | opName = "default"; 32 | } 33 | 34 | NameSpacesInformationRepository repository = (NameSpacesInformationRepository) session.getAttribute( 35 | NameSpacesInformationRepository.NAMESPACES_INFORMATION_REPOSITORY); 36 | NameSpacesInformation information = null; 37 | if (repository == null) { 38 | repository = new NameSpacesInformationRepository(); 39 | session.setAttribute(NameSpacesInformationRepository.NAMESPACES_INFORMATION_REPOSITORY, repository); 40 | } else { 41 | information = repository.getNameSpacesInformation(opName, currentID); 42 | } 43 | if (information == null) { 44 | information = new NameSpacesInformation(); 45 | repository.addNameSpacesInformation(opName, currentID, information); 46 | } 47 | information.removeAllNameSpaces(); 48 | String CountParameter = request.getParameter("nsCount"); 49 | if (CountParameter != null && !"".equals(CountParameter)) { 50 | try { 51 | int count = Integer.parseInt(CountParameter.trim()); 52 | for (int i = 0; i < count; i++) { 53 | String prefix = request.getParameter("prefix" + i); 54 | String uri = request.getParameter("uri" + i); 55 | if (prefix != null && uri != null && !"".equals(uri)) { 56 | information.addNameSpace(prefix.trim(), uri.trim()); 57 | } 58 | } 59 | } catch (NumberFormatException ignored) { 60 | } 61 | } 62 | %> 63 | 64 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.samples/src/conf/synapse/synapse_sample_600.xml: -------------------------------------------------------------------------------- 1 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | symbol.equals("IBM") 38 | 39 | 40 | mc.setProperty("execute_children","true"); 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 51 | 52 | 53 | 54 |
55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.samples/src/conf/synapse/synapse_sample_602.xml: -------------------------------------------------------------------------------- 1 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | file:repository/samples/resources/ 29 | 30 | 15000 31 | 32 | 33 | 34 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 52 | 53 | 54 | 55 | 56 |
57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.ws/src/test/java/org/wso2/carbon/rule/ws/internal/schema/TestSchemaBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2004,2005 The Apache Software Foundation. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.wso2.carbon.rule.ws.internal.schema; 18 | 19 | import junit.framework.TestCase; 20 | import org.apache.axiom.om.impl.builder.StAXOMBuilder; 21 | import org.apache.axis2.description.AxisService; 22 | import org.apache.ws.commons.schema.XmlSchema; 23 | import org.wso2.carbon.rule.common.exception.RuleConfigurationException; 24 | import org.wso2.carbon.rule.common.config.HelperUtil; 25 | import org.wso2.carbon.rule.common.RuleService; 26 | import org.wso2.carbon.rule.common.Operation; 27 | import org.wso2.carbon.rule.common.config.RuleServiceHelper; 28 | 29 | import javax.xml.stream.XMLStreamException; 30 | import java.util.List; 31 | 32 | public class TestSchemaBuilder extends TestCase { 33 | 34 | public void testSchemaBuilder(){ 35 | 36 | try { 37 | SchemaBuilder schemaBuilder = 38 | new SchemaBuilder(this.getClass().getClassLoader(), new AxisService()); 39 | StAXOMBuilder stAXOMBuilder = 40 | new StAXOMBuilder(this.getClass().getResourceAsStream("/placeOrder.rsl")); 41 | RuleService ruleService = 42 | RuleServiceHelper.getRuleService(stAXOMBuilder.getDocumentElement()); 43 | 44 | for (Operation operation : ruleService.getOperations()) { 45 | HelperUtil.processFactDefaultValues(operation.getInput().getFacts(), this.getClass().getClassLoader()); 46 | HelperUtil.processFactDefaultValues(operation.getOutput().getFacts(), this.getClass().getClassLoader()); 47 | } 48 | 49 | List operations = ruleService.getOperations(); 50 | for (Operation operation : operations){ 51 | schemaBuilder.addOperation(operation); 52 | } 53 | 54 | List xmlSchemas = schemaBuilder.getSchemaList(); 55 | for (XmlSchema xmlSchema : xmlSchemas){ 56 | System.out.println("Schema for " + xmlSchema.getTargetNamespace()); 57 | xmlSchema.write(System.out); 58 | } 59 | 60 | 61 | } catch (RuleConfigurationException e) { 62 | e.printStackTrace(); 63 | } catch (XMLStreamException e) { 64 | e.printStackTrace(); 65 | } 66 | 67 | 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.common/src/test/java/org/wso2/carbon/rule/common/TestOperation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2004,2005 The Apache Software Foundation. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.wso2.carbon.rule.common; 18 | 19 | import junit.framework.TestCase; 20 | import org.wso2.carbon.rule.common.config.OperationHelper; 21 | 22 | import java.util.HashMap; 23 | import java.util.Map; 24 | 25 | public class TestOperation extends TestCase{ 26 | 27 | public void testOperation(){ 28 | 29 | Operation operation = new Operation(); 30 | operation.setName("testOperation"); 31 | 32 | // Set input object 33 | Input input = new Input(); 34 | input.setWrapperElementName("sampleTestInput"); 35 | input.setNameSpace("http://com.test"); 36 | 37 | Map nsMAP = new HashMap(); 38 | nsMAP.put("ns1", "http://com.testNS1"); 39 | nsMAP.put("ns2", "http://com.testNS2"); 40 | nsMAP.put("ns3", "http://com.testNS3"); 41 | 42 | // Create Fact object 43 | Fact inputFact = new Fact(); 44 | inputFact.setElementName("sampleInputFact"); 45 | inputFact.setNamespace("http://com.testInput"); 46 | inputFact.setType("sample.Test.Input"); 47 | inputFact.setXpath("http://com.test.sampleInput.xml"); 48 | 49 | inputFact.setPrefixToNamespaceMap(nsMAP); 50 | input.addFact(inputFact); 51 | operation.setInput(input); 52 | 53 | // Set output Object 54 | Output output = new Output(); 55 | output.setWrapperElementName("sampleTestOutput"); 56 | output.setNameSpace("http://com.test"); 57 | 58 | // Create Fact object 59 | Fact outputFact = new Fact(); 60 | outputFact.setElementName("sampleOutputFact"); 61 | outputFact.setNamespace("http://com.testOutput"); 62 | outputFact.setType("sample.Test.Output"); 63 | outputFact.setXpath("http://com.test.sampleOutput.xml"); 64 | outputFact.setPrefixToNamespaceMap(nsMAP); 65 | output.addFact(outputFact); 66 | operation.setOutput(output); 67 | 68 | Operation resultOperation = OperationHelper.getOperation(operation.toOM()); 69 | 70 | assertEquals(operation.getName(), resultOperation.getName()); 71 | assertNotNull(operation.getInput()); 72 | assertNotNull(resultOperation.getInput()); 73 | assertNotNull(operation.getOutput()); 74 | assertNotNull(resultOperation.getOutput()); 75 | 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /features/service/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | org.wso2.carbon.rules 22 | rule-feature 23 | 4.5.11-SNAPSHOT 24 | ../pom.xml 25 | 26 | 27 | 4.0.0 28 | service 29 | pom 30 | WSO2 Carbon - Rule Service Feature Aggregator Module 31 | http://wso2.org 32 | 33 | 34 | org.wso2.carbon.rule.service.common.feature 35 | org.wso2.carbon.rule.service.server.feature 36 | org.wso2.carbon.rule.service.ui.feature 37 | org.wso2.carbon.rule.service.feature 38 | 39 | 40 | 41 | 42 | org.wso2.carbon.rules 43 | org.wso2.carbon.rule.common 44 | 45 | 46 | 47 | org.wso2.carbon.rules 48 | org.wso2.carbon.rule.kernel 49 | 50 | 51 | 52 | org.wso2.carbon.rules 53 | org.wso2.carbon.rule.ws 54 | 55 | 56 | 57 | org.wso2.carbon.rules 58 | org.wso2.carbon.rule.ws.ui 59 | 60 | 61 | 62 | org.wso2.carbon.rules 63 | org.wso2.carbon.rule.service.stub 64 | 65 | 66 | 67 | org.apache.synapse 68 | synapse-core 69 | 70 | 71 | 72 | org.wso2.carbon 73 | org.wso2.carbon.core.server.feature 74 | zip 75 | 76 | 77 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.ws.admin/src/main/resources/META-INF/services.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 22 | 24 | 26 | 27 | 28 | https 29 | 30 | 31 | This service will help to create/modify a rule service. 32 | 33 | /permission/admin/manage/rule 34 | org.wso2.carbon.rule.ws.admin.RuleServiceAdmin 35 | false 36 | 37 | 38 | 39 | 40 | 41 | 43 | 45 | 47 | 48 | 49 | https 50 | 51 | 52 | org.wso2.carbon.rule.ws.admin.RuleServiceFileUploadAdmin 53 | 54 | /permission/admin/manage/rule 55 | true 56 | 57 | 58 | 59 | true 60 | true 61 | 62 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.samples/src/conf/synapse/synapse_sample_605.xml: -------------------------------------------------------------------------------- 1 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | file:repository/samples/resources/ 26 | 27 | 15000 28 | 29 | 30 | 32 | 33 | 34 | 35 |
36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 51 | 55 | 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /features/mediation/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 18 | 19 | 20 | 21 | org.wso2.carbon.rules 22 | rule-feature 23 | 4.5.11-SNAPSHOT 24 | ../pom.xml 25 | 26 | 27 | 4.0.0 28 | rule-mediation 29 | pom 30 | WSO2 Carbon - Rule mediation Feature Aggregator Module 31 | http://wso2.org 32 | 33 | 34 | org.wso2.carbon.rule.mediation.common.feature 35 | org.wso2.carbon.rule.mediation.server.feature 36 | org.wso2.carbon.rule.mediation.feature 37 | 38 | 39 | 40 | 41 | org.wso2.carbon.rules 42 | org.wso2.carbon.rule.common 43 | 44 | 45 | 46 | org.wso2.carbon.rules 47 | org.wso2.carbon.rule.kernel 48 | 49 | 50 | 51 | org.wso2.carbon.rules 52 | org.wso2.carbon.rule.backend 53 | 54 | 55 | 56 | org.wso2.carbon.rules 57 | org.wso2.carbon.rule.ws 58 | 59 | 60 | 61 | org.wso2.carbon.rules 62 | org.wso2.carbon.rule.ws.ui 63 | 64 | 65 | org.wso2.carbon.rules 66 | org.wso2.carbon.rule.service.stub 67 | 68 | 69 | 70 | org.apache.synapse 71 | synapse-core 72 | 73 | 74 | 75 | org.wso2.carbon 76 | org.wso2.carbon.core.server.feature 77 | zip 78 | 79 | 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.mediation/src/main/java/org/wso2/carbon/rule/mediator/RuleMediatorFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2004,2005 The Apache Software Foundation. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.wso2.carbon.rule.mediator; 18 | 19 | import org.apache.axiom.om.OMElement; 20 | import org.apache.synapse.Mediator; 21 | import org.apache.synapse.config.xml.AbstractMediatorFactory; 22 | import org.wso2.carbon.rule.common.config.HelperUtil; 23 | import org.wso2.carbon.rule.common.exception.RuleConfigurationException; 24 | import org.wso2.carbon.rule.common.util.Constants; 25 | import org.wso2.carbon.rule.kernel.engine.RuleEngine; 26 | import org.wso2.carbon.rule.mediator.config.RuleMediatorConfig; 27 | import org.wso2.carbon.rule.mediator.internal.config.RuleMediatorConfigHelper; 28 | 29 | import javax.xml.namespace.QName; 30 | import java.util.Properties; 31 | 32 | public class RuleMediatorFactory extends AbstractMediatorFactory { 33 | 34 | protected Mediator createSpecificMediator(OMElement omElement, Properties properties) { 35 | 36 | RuleMediatorConfig ruleMediatorConfig = RuleMediatorConfigHelper.getRuleMediatorConfig(omElement); 37 | RuleMediator ruleMediator = null; 38 | 39 | try { 40 | processDefaultValues(ruleMediatorConfig, this.getClass().getClassLoader()); 41 | ruleMediatorConfig.getOutput().populateClassTypes(); 42 | RuleEngine ruleEngine = new RuleEngine(ruleMediatorConfig.getRuleSet(), 43 | this.getClass().getClassLoader()); 44 | ruleMediator = new RuleMediator(ruleEngine, 45 | omElement, 46 | ruleMediatorConfig.getSource(), 47 | ruleMediatorConfig.getTarget(), 48 | ruleMediatorConfig.getInput(), 49 | ruleMediatorConfig.getOutput(), 50 | ruleMediatorConfig.getSession()); 51 | } catch (RuleConfigurationException e) { 52 | handleException("Can not create the rule engine ", e); 53 | } 54 | return ruleMediator; 55 | } 56 | 57 | public QName getTagQName() { 58 | return new QName(Constants.RULE_CONF_NAMESPACE, 59 | Constants.RULE_CONF_ELE_RULE); 60 | } 61 | 62 | private void processDefaultValues(RuleMediatorConfig ruleMediatorConfig, 63 | ClassLoader classLoader) throws RuleConfigurationException { 64 | HelperUtil.processFactDefaultValues(ruleMediatorConfig.getInput().getFacts(), classLoader); 65 | HelperUtil.processFactDefaultValues(ruleMediatorConfig.getOutput().getFacts(), classLoader); 66 | 67 | } 68 | 69 | 70 | } 71 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.common/src/main/java/org/wso2/carbon/rule/common/Input.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2004,2005 The Apache Software Foundation. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.wso2.carbon.rule.common; 18 | 19 | import org.apache.axiom.om.OMAbstractFactory; 20 | import org.apache.axiom.om.OMElement; 21 | import org.apache.axiom.om.OMFactory; 22 | import org.wso2.carbon.rule.common.util.Constants; 23 | 24 | import javax.xml.namespace.QName; 25 | import java.util.List; 26 | import java.util.ArrayList; 27 | 28 | public class Input { 29 | 30 | private String wrapperElementName; 31 | private String nameSpace; 32 | private List facts; 33 | 34 | public Input() { 35 | this.facts = new ArrayList(); 36 | } 37 | 38 | public OMElement toOM(){ 39 | OMFactory omFactory = OMAbstractFactory.getOMFactory(); 40 | OMElement ruleInputOMElement = 41 | omFactory.createOMElement(Constants.RULE_CONF_ELE_INPUT, 42 | Constants.RULE_CONF_NAMESPACE, 43 | Constants.RULE_CONF_NAMESPACE_PREFIX); 44 | if((this.nameSpace != null) && (!this.nameSpace.trim().equals(""))){ 45 | ruleInputOMElement.addAttribute(Constants.RULE_CONF_ATTR_NAMESPACE, 46 | this.nameSpace, null); 47 | } 48 | if((this.wrapperElementName != null) && (!this.wrapperElementName.trim().equals(""))){ 49 | ruleInputOMElement.addAttribute(Constants.RULE_CONF_ATTR_WRAPPER_ELEMENT_NAME, 50 | this.wrapperElementName, null); 51 | } 52 | 53 | for(Fact fact : this.facts){ 54 | ruleInputOMElement.addChild(fact.toOM()); 55 | } 56 | 57 | return ruleInputOMElement; 58 | 59 | } 60 | 61 | public void addFact(Fact fact){ 62 | this.facts.add(fact); 63 | } 64 | 65 | public QName getQName(){ 66 | return new QName(this.nameSpace, this.wrapperElementName); 67 | } 68 | 69 | public String getWrapperElementName() { 70 | return wrapperElementName; 71 | } 72 | 73 | public void setWrapperElementName(String wrapperElementName) { 74 | this.wrapperElementName = wrapperElementName; 75 | } 76 | 77 | public String getNameSpace() { 78 | return nameSpace; 79 | } 80 | 81 | public void setNameSpace(String nameSpace) { 82 | this.nameSpace = nameSpace; 83 | } 84 | 85 | public List getFacts() { 86 | return facts; 87 | } 88 | 89 | public void setFacts(List facts) { 90 | this.facts = facts; 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /components/rule/org.wso2.carbon.rule.mediation/src/main/java/org/wso2/carbon/rule/mediator/internal/config/RuleMediatorConfigHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2004,2005 The Apache Software Foundation. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.wso2.carbon.rule.mediator.internal.config; 18 | 19 | import org.wso2.carbon.rule.mediator.config.RuleMediatorConfig; 20 | import org.wso2.carbon.rule.common.config.HelperUtil; 21 | import org.wso2.carbon.rule.common.config.InputHelper; 22 | import org.wso2.carbon.rule.common.config.OutputHelper; 23 | import org.wso2.carbon.rule.common.config.RuleSetHelper; 24 | import org.wso2.carbon.rule.common.util.Constants; 25 | import org.apache.axiom.om.OMElement; 26 | 27 | import javax.xml.namespace.QName; 28 | 29 | public class RuleMediatorConfigHelper { 30 | 31 | public static RuleMediatorConfig getRuleMediatorConfig(OMElement ruleMediatorElement) { 32 | 33 | RuleMediatorConfig ruleMediatorConfig = new RuleMediatorConfig(); 34 | ruleMediatorConfig.setBackendRuntimeFactory(HelperUtil.getAttributeValue( 35 | ruleMediatorElement, Constants.RULE_CONF_ATTR_BACKEND_RUNTIME_FACTORY)); 36 | 37 | OMElement sourceOMElement = ruleMediatorElement.getFirstChildWithName( 38 | new QName(Constants.RULE_CONF_NAMESPACE, Constants.RULE_CONF_ELE_SOURCE)); 39 | ruleMediatorConfig.setSource(SourceHelper.getSource(sourceOMElement)); 40 | 41 | OMElement targetOMElement = ruleMediatorElement.getFirstChildWithName( 42 | new QName(Constants.RULE_CONF_NAMESPACE, Constants.RULE_CONF_ELE_TARGET)); 43 | ruleMediatorConfig.setTarget(TargetHelper.getTarget(targetOMElement)); 44 | 45 | OMElement ruleSetOMElement = ruleMediatorElement.getFirstChildWithName( 46 | new QName(Constants.RULE_CONF_NAMESPACE, Constants.RULE_CONF_ELE_RULE_SET)); 47 | ruleMediatorConfig.setRuleSet(RuleSetHelper.getRuleSet(ruleSetOMElement)); 48 | 49 | OMElement inputOMElement = ruleMediatorElement.getFirstChildWithName( 50 | new QName(Constants.RULE_CONF_NAMESPACE, Constants.RULE_CONF_ELE_INPUT)); 51 | ruleMediatorConfig.setInput(InputHelper.getInput(inputOMElement)); 52 | 53 | OMElement outputOMElement = ruleMediatorElement.getFirstChildWithName( 54 | new QName(Constants.RULE_CONF_NAMESPACE, Constants.RULE_CONF_ELE_OUTPUT)); 55 | ruleMediatorConfig.setOutput(OutputHelper.getOutput(outputOMElement)); 56 | 57 | OMElement sessionOMElement = ruleMediatorElement.getFirstChildWithName( 58 | new QName(Constants.SYNAPSE_NAMESPACE, Constants.RULE_SESSION)); 59 | ruleMediatorConfig.setSession(sessionOMElement); 60 | 61 | return ruleMediatorConfig; 62 | } 63 | } 64 | --------------------------------------------------------------------------------