001/*
002 * JGrapes Event Driven Framework
003 * Copyright (C) 2016, 2018  Michael N. Lipp
004 *
005 * This program is free software; you can redistribute it and/or modify it 
006 * under the terms of the GNU Affero General Public License as published by 
007 * the Free Software Foundation; either version 3 of the License, or 
008 * (at your option) any later version.
009 *
010 * This program is distributed in the hope that it will be useful, but 
011 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
012 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License 
013 * for more details.
014 *
015 * You should have received a copy of the GNU Affero General Public License along 
016 * with this program; if not, see <http://www.gnu.org/licenses/>.
017 */
018
019package org.jgrapes.osgi.portlets.upnpbrowser;
020
021import java.util.Map;
022import java.util.Optional;
023
024import org.jgrapes.core.Channel;
025import org.jgrapes.core.ComponentType;
026import org.jgrapes.portal.base.PortletComponentFactory;
027import org.osgi.framework.BundleContext;
028import org.osgi.service.component.annotations.Reference;
029import org.osgi.service.component.annotations.ServiceScope;
030import org.osgi.service.component.runtime.ServiceComponentRuntime;
031
032/**
033 * The factory service for {@link UPnPBrowserPortlet}s.
034 */
035@org.osgi.service.component.annotations.Component(
036    scope = ServiceScope.SINGLETON)
037public class UPnPBrowserPortletFactory implements PortletComponentFactory {
038
039    private ServiceComponentRuntime scr;
040
041    @Reference
042    public void setScr(ServiceComponentRuntime scr) {
043        this.scr = scr;
044    }
045
046    /*
047     * (non-Javadoc)
048     * 
049     * @see org.jgrapes.core.ComponentFactory#componentType()
050     */
051    @Override
052    public Class<? extends ComponentType> componentType() {
053        return UPnPBrowserPortlet.class;
054    }
055
056    /*
057     * (non-Javadoc)
058     * 
059     * @see org.jgrapes.core.ComponentFactory#create(org.jgrapes.core.Channel,
060     * java.util.Map)
061     */
062    @Override
063    public Optional<ComponentType> create(Channel componentChannel,
064            Map<Object, Object> properties) {
065        return Optional.of(new UPnPBrowserPortlet(componentChannel,
066            (BundleContext) properties.get(BundleContext.class), scr));
067    }
068
069}