From 982bd830bc5517a7919eda06bc4a4fe55b2f2103 Mon Sep 17 00:00:00 2001 From: prabathabey Date: Mon, 22 Dec 2014 18:15:52 +0530 Subject: [PATCH] adding mobile operations related abstractions --- .../carbon/device/mgt/common/Operation.java | 33 ++++++++ .../device/mgt/common/OperationData.java | 75 +++++++++++++++++++ .../device/mgt/common/OperationFactory.java | 24 ++++++ 3 files changed, 132 insertions(+) create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/Operation.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/OperationData.java create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/OperationFactory.java diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/Operation.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/Operation.java new file mode 100644 index 000000000..8424142f7 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/Operation.java @@ -0,0 +1,33 @@ +/** + * Copyright (c) 2012, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.wso2.carbon.device.mgt.common; + +/** + * This class needs to be implemented by all + */ +public interface Operation { + + /** + * Initializes any start-up resources required to execute a particular operation + */ + void init(); + + /** + * Executes the functionality configured within the method implementation + */ + void execute(); + +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/OperationData.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/OperationData.java new file mode 100644 index 000000000..9cb0ad63d --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/OperationData.java @@ -0,0 +1,75 @@ +/** + * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.wso2.carbon.device.mgt.common; + +import java.util.Properties; + +public class OperationData { + + public enum Type { + CONFIG, MESSAGE, STATE + } + + private String name; + private boolean state; + private Properties properties; + private String text; + private Type type; + + public OperationData(String name, Type type) { + this.type = type; + this.name = name; + } + + public OperationData(String name, boolean state) { + this.name = name; + this.type = Type.STATE; + this.state = state; + } + + public OperationData(String name, Properties properties) { + this.name = name; + this.type = Type.CONFIG; + this.properties = properties; + } + + public OperationData(String name, String text) { + this.name = name; + this.type = Type.MESSAGE; + this.text = text; + } + + public Type getType() { + return type; + } + + public boolean getState() { + return state; + } + + public String getText() { + return text; + } + + public Properties getProperties() { + return properties; + } + + public String getName() { + return name; + } + +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/OperationFactory.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/OperationFactory.java new file mode 100644 index 000000000..ae8d0bb68 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/OperationFactory.java @@ -0,0 +1,24 @@ +/** + * Copyright (c) 2012, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.wso2.carbon.device.mgt.common; + +public class OperationFactory { + + public static Operation getOperation(String type) { + return new DefaultOperation(); + } + +}