/*-
 * ~~~~~~licensing~~~~~~
 * connection-producing
 * ==========
 * 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.base.objects.connection.producing.adapters;

import java.net.URL;
import java.util.ArrayList;
import java.util.List;

import org.osgi.framework.ServiceRegistration;

import ru.entaxy.base.generator.template.Template;
import ru.entaxy.platform.base.objects.factory.EntaxyFactory;

public class TrackedAdapter {

	protected String id;
	protected long bundleId;
	protected String metadata;
	protected String configuration;
	protected ServiceRegistration<? extends EntaxyFactory> serviceRegistration;
	
	protected List<URL> templates = new ArrayList<>();
	protected List<ServiceRegistration<Template>> templateRegistrations = new ArrayList<>();;
	
	
	public void unregister() {
		try {
			this.serviceRegistration.unregister();
		} catch (Exception e) {
			
		};
		
		for (ServiceRegistration<Template> sr: templateRegistrations)
			try {
				sr.unregister();
			} catch (Exception e) {
				
			};
		
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public long getBundleId() {
		return bundleId;
	}

	public void setBundleId(long bundleId) {
		this.bundleId = bundleId;
	}

	public String getConfiguration() {
		return configuration;
	}

	public void setConfiguration(String configuration) {
		this.configuration = configuration;
	}

	public String getMetadata() {
		return metadata;
	}

	public void setMetadata(String metadata) {
		this.metadata = metadata;
	}

	public ServiceRegistration<? extends EntaxyFactory> getServiceRegistration() {
		return serviceRegistration;
	}

	public void setServiceRegistration(ServiceRegistration<EntaxyFactory> serviceRegistration) {
		this.serviceRegistration = serviceRegistration;
	}

	public List<URL> getTemplates() {
		return templates;
	}

	public List<ServiceRegistration<Template>> getTemplateRegistrations() {
		return templateRegistrations;
	}
	
}
