osgi 中require-bundle import-package 的差别

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/floyddcn/article/details/2410653


To be clear, require-bundle and import-package are not equivalent, but
they certainly overlap. A simple way of looking at require-bundle is
that it is a shorthand way of importing every package that is exported
by another bundle, but it a slightly different than this in reality.

Import-package terminates when a class from the package is not found
(i.e., packages are assumed to be self-contained), while require-bundle
does NOT terminate when a class from a package is not found, it
continues searching other required bundles as well as the local bundle
itself (i.e., packages are assumed to be split).
展开阅读全文

Jetty在OSGI中的使用

04-13

使用jetty作为web容器在osgi中使用,但是启动的时候报rnEXCEPTION java.net.ConnectException: Connection timed out: connectrn at java.net.PlainSocketImpl.socketConnect(Native Method)rn at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)rn at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)rn at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)rn at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)rn at java.net.Socket.connect(Socket.java:529)rn at java.net.Socket.connect(Socket.java:478)rn at sun.net.NetworkClient.doConnect(NetworkClient.java:163)rn at sun.net.www.http.HttpClient.openServer(HttpClient.java:394)rn at sun.net.www.http.HttpClient.openServer(HttpClient.java:529)rn at sun.net.www.http.HttpClient.(HttpClient.java:233)rn at sun.net.www.http.HttpClient.New(HttpClient.java:306)rn at sun.net.www.http.HttpClient.New(HttpClient.java:323)rn at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:970)rn at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:911)rn at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:836)rn at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1172)rn代码如下rntryrn Server server = new Server(); rn Connector connector = new SelectChannelConnector(); rn connector.setPort(8081); rn server.setConnectors(new Connector[]connector); rn Constraint constraint = new Constraint(); rn constraint.setName(Constraint.__BASIC_AUTH);; rn constraint.setRoles(new String[]"user","admin","moderator"); rn constraint.setAuthenticate(true); rn ConstraintMapping cm = new ConstraintMapping(); rn cm.setConstraint(constraint); rn cm.setPathSpec("/*"); rn SecurityHandler sh = new SecurityHandler(); rn sh.setUserRealm(new HashUserRealm("MyRealm","/etc/realm.properties")); rn sh.setConstraintMappings(new ConstraintMapping[]cm); rn WebAppContext webappcontext = new WebAppContext(); rn webappcontext.setContextPath("/com.jetty"); rn webappcontext.setWar("com.jetty.war");rn webappcontext.addHandler(sh); rn HandlerCollection handlers= new HandlerCollection(); rn handlers.setHandlers(new Handler[]webappcontext, new DefaultHandler()); rn server.setHandler(handlers); rn server.start(); //启动报错rn server.join(); rncatch(Exception e)rn e.printStackTrace();rn 论坛

没有更多推荐了,返回首页