你好看过使用Amdatu framwork构建的osgi webapp的例子可以在ShowCase获得,即使每次服务实例总是为null时,实现的表现与示例完全相同。 此外,我已阅读security module Amdatu上的文档,但无法配置它,有没有人有关于如何使用TokenProvider的演练?
谢谢
当执行dm notavail命令时,我得到:
[1] agenda.web.filters
javax.servlet.Filter(pattern=/*.*) unregistered
org.amdatu.security.tokenprovider.TokenProvider service required unavailable
[15] org.amdatu.security.tokenprovider.impl
org.amdatu.security.tokenprovider.TokenProvider unregistered
org.amdatu.security.tokenprovider configuration required available
org.amdatu.security.tokenprovider.TokenStorageProvider service required unavailable
org.osgi.service.log.LogService service optional (not tracking)
[16] org.amdatu.security.tokenstorage.mongo
org.amdatu.security.tokenprovider.TokenStorageProvider, org.amdatu.security.tokenstorage.mongo.ExpiredTokenPurger unregistered
org.amdatu.mongo.MongoDBService service required unavailable
org.osgi.service.log.LogService service optional (not tracking)
org.quartz.Job unregistered
org.amdatu.security.tokenstorage.mongo.ExpiredTokenPurger service required unavailable
org.osgi.service.log.LogService service optional (not tracking)
My Activator就是这样:
import java.util.Properties;
import javax.servlet.Filter;
import org.amdatu.security.tokenprovider.TokenProvider;
import org.apache.felix.dm.DependencyActivatorBase;
import org.apache.felix.dm.DependencyManager;
import org.osgi.framework.BundleContext;
import org.osgi.service.log.LogService;
import agenda.web.filters.teste.AdminLoginResource;
import agenda.web.filters.teste.RedirectFilter;
import agenda.web.filters.teste.SecurityFilter;
public class Activator extends DependencyActivatorBase {
@Override
public void init(BundleContext arg0, DependencyManager dm)
throws Exception {
Properties properties = new Properties();
properties.put("pattern", "/*.*");
dm.add(createComponent()
.setInterface(Filter.class.getName(), properties)
.setImplementation(SecurityFilter.class)
.add(createServiceDependency().setService(TokenProvider.class).setRequired(true))
.add(createServiceDependency()
.setService(LogService.class)
.setRequired(false)));
}
@Override
public void destroy(BundleContext arg0, DependencyManager arg1)
throws Exception {
// TODO Auto-generated method stub
}
}
答案 0 :(得分:1)
查看DM的输出似乎是MongoDbService不可用的问题。 MongoDbService由托管服务工厂创建,因此您可能错过了它的配置。至少一个" dbName"应该配置,请在此处查看更多文档:http://amdatu.org/components/mongodb.html