OSGI UserAdmin实施捆绑

时间:2018-11-13 03:53:08

标签: java osgi

这是“我的用户”管理组件类:

package org.siu.casa.remoteservice.consumer.rest;

import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.useradmin.Role;
import org.osgi.service.useradmin.User;
import org.osgi.service.useradmin.UserAdmin;

@Component(service=UserManagement.class, immedeate=true)
public class UserManagement {


    UserAdmin userAdmin;
    @Reference
    void setUserAdmin(UserAdmin admin) {
        this.userAdmin = admin;
    }
    @Activate
    void init() {
        User bob = (User)this.userAdmin.createRole("Bob", Role.USER);
        System.out.println("User Bob created, Type: " + umesh.getType());
    }
}

以下是我使用过的捆绑包的列表:

-runfw: org.eclipse.osgi;version=3.13
-runee: JavaSE-1.8
-runprovidedcapabilities: ${native_capability}

-resolve.effective: active

-runproperties: \
    osgi.console=,\
    osgi.console.enable.builtin=false

-runbundles: \
    org.apache.felix.gogo.command;version='[1.0.2,1.0.3)',\
    org.apache.felix.gogo.runtime;version='[1.0.0,1.0.1)',\
    org.apache.felix.gogo.shell;version='[1.1.0,1.1.1)',\
    org.apache.felix.scr;version='[2.1.12,2.1.13)',\
    org.osgi.util.function;version='[1.1.0,1.1.1)',\
    org.osgi.util.promise;version='[1.1.0,1.1.1)',\
    org.eclipse.equinox.useradmin;version='[1.1.600,1.1.601)',\
    org.osgi.compendium;version='[4.1.0,4.1.1)',\
    org.osgi.service.useradmin;version='[1.1.0,1.1.1)',\
    org.siu.casa.remoteservice.consumer.usermgmt;version=snapshot

-runrequires: \
    osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.shell)',\
    osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.command)',\
    bnd.identity;id='org.osgi.util.function',\
    bnd.identity;id='org.osgi.util.promise',\
    bnd.identity;id='org.apache.felix.scr',\
    **bnd.identity;id='org.eclipse.equinox.useradmin',\**
    **bnd.identity;id='org.osgi.service.useradmin',\**
    bnd.identity;version='latest';id='org.siu.casa.remoteservice.consumer.usermgmt'

现在,当我检查捆绑软件时,该服务未注册。

g! lb


START LEVEL 1
   ID|State      |Level|Name
    0|Active     |    0|OSGi System Bundle (3.13.100.v20180827-1536)|3.13.100.v20180827-1536
    1|Active     |    1|Apache Felix Gogo Command (1.0.2)|1.0.2
    2|Active     |    1|Apache Felix Gogo Runtime (1.0.0)|1.0.0
    3|Active     |    1|Apache Felix Gogo Shell (1.1.0)|1.1.0
    4|Active     |    1|Apache Felix Declarative Services (2.1.12)|2.1.12
    5|Active     |    1|org.osgi:org.osgi.util.function (1.1.0.201802012106)|1.1.0.201802012106
    6|Active     |    1|org.osgi:org.osgi.util.promise (1.1.0.201802012106)|1.1.0.201802012106
    7|Active     |    1|User Admin Service (1.1.600.v20180827-1235)|1.1.600.v20180827-1235
    8|Active     |    1|OSGi R4 Compendium Bundle (4.1.0)|4.1.0
    9|Active     |    1|org.osgi:org.osgi.service.useradmin (1.1.0.201505202023)|1.1.0.201505202023
   10|Active     |    1|org.siu.casa.remoteservice.consumer.usermgmt (0.0.0)|0.0.0
g! bundle 10
LastModified         1542080633968
Headers              [Service-Component=OSGI-INF/org.siu.casa.remoteservice.usermgmt.UserManagement.xml, Manifest-Version=1.0, Created-By=1.8.0_181 (Oracle Corporation), Bnd-LastModified=1542080625379, Private-Package=org.siu.casa.remoteservice.usermgmt, Bundle-Name=org.siu.casa.remoteservice.consumer.usermgmt, Import-Package=org.osgi.service.useradmin;version="[1.1,2)", Provide-Capability=osgi.service;objectClass:List<String>="org.siu.casa.remoteservice.usermgmt.UserManagement", Bundle-ManifestVersion=2, Bundle-SymbolicName=org.siu.casa.remoteservice.consumer.usermgmt, Bundle-Version=0, Require-Capability=osgi.extender;filter:="(&(osgi.extender=osgi.component)(version>=1.3.0)(!(version>=2.0.0)))",osgi.service;filter:="(objectClass=org.osgi.service.useradmin.UserAdmin)";effective:=active,osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))", Tool=Bnd-4.1.0.201810181252]
Version              0.0.0
BundleContext        org.eclipse.osgi.internal.framework.BundleContextImpl@35083305
SymbolicName         org.siu.casa.remoteservice.consumer.usermgmt
BundleId             10
RegisteredServices   null
ServicesInUse        [LogService | LoggerFactory | ExtendedLogService]
Bundle                  10|Active     |    1|org.siu.casa.remoteservice.consumer.usermgmt (0.0.0)
Module               osgi.identity; osgi.identity="org.siu.casa.remoteservice.consumer.usermgmt"; type="osgi.bundle"; version:Version="0.0.0" [id=10]
Location             reference:file:/home/tumesh/osgiExamples/org.siu.casa.remoteservice.consumer/generated/org.siu.casa.remoteservice.consumer.usermgmt.jar
State                32

要正确使用UserAdmin Service,还需要哪些其他jar?我使用了OSGi用户Admin Service http://git.eclipse.org/c/equinox/rt.equinox.bundles.git/tree/bundles/org.eclipse.equinox.useradmin

的以下实现

0 个答案:

没有答案