/*-
 * ~~~~~~licensing~~~~~~
 * object-producing-management
 * ==========
 * Copyright (C) 2020 - 2022 EmDev LLC
 * ==========
 * 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.
 * ~~~~~~/licensing~~~~~~
 */
package ru.entaxy.platform.core.producer.management;

import java.util.Map;

import javax.management.openmbean.OpenDataException;
import javax.management.openmbean.TabularData;

import ru.entaxy.esb.platform.base.management.core.Qualifier;
import ru.entaxy.esb.platform.base.management.core.api.MBeanAnnotated;
import ru.entaxy.esb.platform.base.management.core.api.MBeanExportPolicy;
import ru.entaxy.esb.platform.base.management.core.api.Operation;
import ru.entaxy.esb.platform.base.management.core.api.Parameter;
import ru.entaxy.platform.base.objects.factory.EntaxyFactoryException;

@MBeanAnnotated(policy = MBeanExportPolicy.ANNOTATED_ONLY)
public interface FactoryMBean {

	public static final String FACTORY_KEY = "factoryId";
	public static final String CATEGORY_KEY = "category";
	
	public static Qualifier getQualifier(String factoryId, String factoryType) {
		return ProducerMBean.getQualifier(factoryType).attribute(FACTORY_KEY, factoryId);
	}

	@Operation(desc = "Creates and installs a new object")
	public TabularData createObject(
		@Parameter(name = "objectId", desc = "ObjectId for new object, can be omitted in some cases")	
		String objectId,
		@Parameter(name = "scope", desc = "Scope of the new object, 'public' by default")
		String scope,
		@Parameter(name = "properties", desc = "Properties of the new object in JSON format")
		Map<String, Object> properties
			) throws EntaxyFactoryException, OpenDataException;

	@Operation(desc = "Get fields for creating a new object")
	public String getFields(@Parameter(name = "outputType", desc = "Type of output") String outputType);
}
