나는 camel-archetype-blueprint maven 아키타 입을 사용하여 OSGi 번들을 만들었습니다. 나는 Karaf에 이것을 설치하려고 시도했으나 번들은 GracePeriod로 들어갔다. diag를 실행 한 후에는 jar 파일 내부에 종속성이 없습니다.Karaf : 내 항아리에 누락 된 클래스
좋아, 긴 버전 :
$ jar tvf myproject-1.0-SNAPSHOT.jar
455 Tue Jul 26 11:25:10 UTC 2016 META-INF/MANIFEST.MF
0 Tue Jul 26 11:25:10 UTC 2016 META-INF/
0 Tue Jul 26 11:25:10 UTC 2016 META-INF/maven/
0 Tue Jul 26 11:25:10 UTC 2016 META-INF/maven/com.petewall/
0 Tue Jul 26 11:25:10 UTC 2016 META-INF/maven/com.petewall/myproject/
143 Tue Jul 26 11:25:10 UTC 2016 META-INF/maven/com.petewall/myproject/pom.properties
3418 Tue Jul 26 11:25:06 UTC 2016 META-INF/maven/com.petewall/myproject/pom.xml
0 Tue Jul 26 11:25:10 UTC 2016 OSGI-INF/
0 Tue Jul 26 11:25:10 UTC 2016 OSGI-INF/blueprint/
1376 Tue Jul 26 11:20:12 UTC 2016 OSGI-INF/blueprint/blueprint-bean.xml
961 Tue Jul 26 11:20:12 UTC 2016 OSGI-INF/blueprint/blueprint-service.xml
0 Tue Jul 26 11:25:10 UTC 2016 com/
0 Tue Jul 26 11:25:10 UTC 2016 com/petewall/
143 Tue Jul 26 11:24:56 UTC 2016 com/petewall/Hello.class
1022 Tue Jul 26 11:24:56 UTC 2016 com/petewall/HelloBean.class
676 Tue Jul 26 11:20:12 UTC 2016 log4j.properties
내가 deploy 디렉토리에이 jar 파일을 떨어 :
는 원형에서 생성 된 jar 파일이 원형에서 포함 된 안녕하세요 HelloBean 클래스가 포함내 karaf 인스턴스. 번들이 설치되고 bundle:list
명령에 나열됩니다. 그러나 번들이 시작되면 GracePeriod로 이동합니다. 그것은 종속성 실종 보여줍니다 진단 :
[email protected]()> exports
Package Name | Version | ID | Bundle Name
-----------------------------------------------------------------------------
...
com.petewall | 1.0.0.SNAPSHOT | 98 | myproject
...
그리고 classes
명령 : 난
[email protected]()> classes
...
com/petewall/Hello.class
com/petewall/HelloBean.class
그러나
[email protected]()> bundle:diag 98
Camel Blueprint Route (98)
--------------------------
Status: GracePeriod
Blueprint
7/26/16 6:26 PM
Missing dependencies:
(objectClass=com.petewall.Hello)
을, 그 클래스는 심지어 karaf의 exports
명령을 사용하여 발견 이러한 모든 기술 (Karaf, Camel, OSGi 등)에 새로운 것이므로 뭔가를 놓치고 있다고 확신합니다. 제발, 누군가가 나를 올바른 방향으로 향하게 할 수 있습니까?
업데이트 1 : archetype은 청사진 서비스와 빈을 정의하는 것으로 보이는 두 개의 XML 파일을 생성합니다.
청사진-bean.xml :
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="..." xmlns:xsi="..." xmlns:cm="..." xsi:schemaLocation="...">
<cm:property-placeholder persistent-id="HelloBean" update-strategy="reload">
<cm:default-properties>
<cm:property name="greeting" value="Hi from Camel" />
</cm:default-properties>
</cm:property-placeholder>
<bean id="helloBean" class="com.petewall.HelloBean">
<property name="say" value="${greeting}"/>
</bean>
<camelContext id="blueprint-bean-context" xmlns="http://camel.apache.org/schema/blueprint">
<route id="timerToLog">
<from uri="timer:foo?period=5000"/>
<setBody>
<method ref="helloBean" method="hello"/>
</setBody>
<log message="The message contains ${body}"/>
<to uri="mock:result"/>
</route>
</camelContext>
</blueprint>
청사진-service.xml :
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="..." xmlns:xsi="..." xmlns:cm="..." xsi:schemaLocation="...">
<reference id="helloService" interface="com.petewall.Hello" />
<camelContext id="blueprint-service-context" xmlns="http://camel.apache.org/schema/blueprint">
<route id="timerToLog">
<from uri="timer:foo?period=5000"/>
<setBody>
<method ref="helloService" method="hello"/>
</setBody>
<log message="The message contains ${body}"/>
<to uri="mock:result"/>
</route>
</camelContext>
</blueprint>
는 아키가 인터페이스를 생성 Hello
번 방법 정의를 String hello()
. HelloBean
클래스는 해당 인터페이스를 구현하고 private String say
매개 변수를 사용하여 hello()
메서드가 인쇄하는 내용을 변경합니다.
기본적으로 Karaf가로드 한 번들을 원하고 낙타 타이머를 활성화하여 주기적으로 기능을 호출합니다. – Pete
그래서'Hello' 인터페이스의 역할은 무엇입니까? 이것은 주기적으로 호출되어야하는 기능을 정의합니까? Camel에 익숙하지 않지만 Camel이 정의한 인터페이스를 사용하여 타이머 기능을 구현해야합니까? –
청사진 정의에서 제공하는 OSGi 서비스는 동일한 번들에 정의 된 종속성에 연결되지 않으므로 해당 묶음을 내부적으로 빈으로 참조해야합니다. –