
it.tidalwave.bluebill.factsheet.impl.DefaultFactSheetFactory Maven / Gradle / Ivy
/***********************************************************************************************************************
*
* blueBill Mobile - open source birdwatching
* ==========================================
*
* Copyright (C) 2009, 2010 by Tidalwave s.a.s. (http://www.tidalwave.it)
* http://bluebill.tidalwave.it/mobile/
*
***********************************************************************************************************************
*
* 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.
*
***********************************************************************************************************************
*
* $Id: DefaultFactSheetFactory.java,v 59f1b76dd766 2010/06/19 00:05:56 fabrizio $
*
**********************************************************************************************************************/
package it.tidalwave.bluebill.factsheet.impl;
import javax.annotation.Nonnull;
import java.io.IOException;
import org.openide.util.Lookup;
import org.openide.util.lookup.ServiceProvider;
import it.tidalwave.util.As;
import it.tidalwave.util.Identifiable;
import it.tidalwave.bluebill.factsheet.FactSheet;
import it.tidalwave.bluebill.factsheet.FactSheetFactory;
import it.tidalwave.bluebill.factsheet.spi.FactSheetProvider;
import it.tidalwave.util.logging.Logger;
/***********************************************************************************************************************
*
* @author Fabrizio Giudici
* @version $Id:$
*
**********************************************************************************************************************/
@ServiceProvider(service=FactSheetFactory.class)
public class DefaultFactSheetFactory implements FactSheetFactory
{
private static final String CLASS = DefaultFactSheetFactory.class.getName();
private static final Logger logger = Logger.getLogger(CLASS);
@Nonnull
public FactSheet createFactSheet (final @Nonnull As object)
{
logger.info("createFactSheet(%s)", object);
FactSheet factSheet = new FactSheet(object.as(Identifiable.class).getId());
for (final FactSheetProvider factSheetProvider : Lookup.getDefault().lookupAll(FactSheetProvider.class))
{
try
{
logger.info(">>>> calling %s...", factSheetProvider);
factSheet = factSheetProvider.fillFactSheet(factSheet);
}
catch (IOException e)
{
logger.severe("Failed calling %s", factSheetProvider);
logger.throwing("createFactSheed()", CLASS, e);
}
}
return factSheet;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy