ÀÌ ±ÛÀº Neil Bartlett ÀÇ ¿¬Àç ±Û
"Getting started with OSGi"ÀÇ ¹ø¿ªº»ÀÔ´Ï´Ù.
*
ÆÄÆ® 1 - ù¹øÂ° ¹øµé : Your First Bundle
*
ÆÄÆ® 2 - ÇÁ·¹ÀÓ¿öÅ©¿Í ¿¬µ¿Çϱâ : Interacting with the Framework
*
ÆÄÆ® 3 - ¹øµé°£ÀÇ ÀÇÁ¸°ü°è : Dependencies between bundles
*
ÆÄÆ® 4 - ¼ºñ½º µî·ÏÇϱâ : Registering a Service
¿¡ À̾î 5¹øÂ° ±ÛÀÔ´Ï´Ù. ¿ÀÅ»ÀÚ ¹× ÀÌ»óÇÑ ¹ø¿ªÀº ´ñ±Û·Î ³²°ÜÁÖ¼¼¿ä
Getting started with OSGi : OSGi ½ÃÀÛÇÏ±â ÆÄÆ® 5 - ¼ºñ½º »ç¿ëÇϱâ
ÀúÀÚ : Neil Bartlett < njbartlett at gmail dot com >
¿ªÀÚ : ±Ç Á¤Çõ < guruguru at gmail dot com >
±Û¿øº» :
http://www.eclipsezone.com/eclipse/forums/t90796.html - Getting started with OSGi : Consuming a Service
¸¶Áö¸· ±Û¿¡¼ ¿ì¸° ¾î¶»°Ô ¼ºñ½º¸¦ µî·ÏÇÏ´ÂÁö¿¡ ´ëÇØ ¾Ë¾ÆºÃ½À´Ï´Ù. ÀÌÁ¦ ±× ¼ºñ½º¸¦ ã°í ´Ù¸¥ ¹øµé¿¡¼ ±× ¼ºñ½º¸¦ ÀÌ¿ëÇϵµ·Ï ÀÛ¾÷ÇØ º¾½Ã´Ù.
Martin FolwerÀÇ
Dependency Injection¿¡ ´ëÇÑ ±Û¿¡¼ ¿µ°¨À» ¾ò¾ú´ø Áö³¹øÃ³·³, ¿ì¸° ¹®Á¦¸¦ ¿ì¸® ¿ä±¸»çÇ׿¡ Æ÷ÇÔÇÒ °ÍÀÔ´Ï´Ï´Ù. ¿ì¸°
MovieFinder ¸¦ ¼ºñ½º·Î ¸¸µé¾î¼ ¼ºñ½º ·¹Áö½ºÆ®¸®¿¡ µî·ÏÇß½À´Ï´Ù. ÀÌÁ¨ ƯÁ¤ °¨µ¶¿¡ ÀÇÇØ Á¦ÀÛµÈ ¿µÈ¸¦ ã±âÀ§ÇØ
MovieFinder ¸¦ »ç¿ëÇÏ´Â
MovieLister¸¦ ¸¸µé¾îº¼ °ÍÀÔ´Ï´Ù. ±×¸®°í ÀÌ
MovieLister ÀÚüµµ GUI Application °°Àº ´Ù¸¥ ƯÁ¤¹øµé¿¡ »ç¿ëµÇ´Â ¼ºñ½º°¡ µÉ°ÍÀ̶ó°í °¡Á¤ÇÕ´Ï´Ù. ¿©±â¼ ¹®Á¦Á¡Àº, OSGi ¼ºñ½º´Â µ¿ÀûÀ̶ó µî·ÏµÇ°í »ç¶óÁö°í ÇѴٴ°ÍÀÔ´Ï´Ù. Áï, ¿ì¸®°¡
MovieFinder ¼ºñ½º¸¦ È£ÃâÇϰíÀÚ ÇÒ¶§, ¼ºñ½º°¡ ºÒ°¡´ÉÇÒ¼öµµ ÀÖ½À´Ï´Ù.
±×·¯¸é, ¸¸¾à
MovieFinder ¼ºñ½º°¡ Á¸ÀçÇÏÁö ¾Ê´Â´Ù¸é
MovieLister ´Â ¹«¾ùÀ» ÇØ¾ßÇÒ±î¿ä ?
MovieLister °¡ ÇÏ´Â ÀÏÁß¿¡
MovieFinder ¿¡ ´ëÇÑ È£ÃâÀÌ ¸Å¿ì Áß¿äÇÑ °ÍÀ̶ó´Â°ÍÀº È®½ÇÇϹǷÎ, ¿ì¸®°¡ ¼±ÅÃÇÒ¼ö ÀÖ´Â ¿É¼ÇÀº ¸î°¡Áö ¹Û¿¡ ¾ø½À´Ï´Ù.
- ¿¡·¯¸¦ ³½´Ù. (Null À» ¸®ÅÏÇϰųª Exception À» ³»°Å³ª)
- ±â´Ù¸°´Ù.
- óÀ½ºÎÅÍ ¾Æ¿¹ ¼³Ä¡°¡ ¾ÈµÇµµ·Ï ÇÑ´Ù. ( Don't be there in the first place )
ÀÌ ±Û¿¡¼± ½¬¿î ¾Õ¿¡ 2°¡Áö ¹æ¹ý¸¸À» »ìÆìº¸µµ·Ï ÇÕ´Ï´Ù. ¼¼¹øÂ° ¹æ¹ýÀº ¾ÆÁ÷ ¿©·¯ºÐ²² ¾î¶² Àǹ̰¡ ÀÖ°Ô º¸ÀÌÁø ¾Ê°ÚÁö¸¸, ¾Õ¿¡ 2°¡Áö¸¦ º¸°í³ª¸é ¾Ë¼ö ÀÖ°Ô µÇ½Ç°Ì´Ï´Ù.
ù¹øÂ°·Î ÇÒÀÏÀº
MovieLister ¼ºñ½º¿¡ ´ëÇÑ ÀÎÅÍÆäÀ̽º¸¦ ÀÛ¼ºÇϴ°ÍÀÔ´Ï´Ù. ¾Æ·¡ ¼Ò½º¸¦
osgitut/movies/MovieLister.java ¿¡ º¹»çÇϼ¼¿ä.
package osgitut.movies;
import java.util.List;
public interface MovieLister {
List listByDirector(String name);
}
ÀÌÁ¦
osgitut/movies/impl/MovieListerImpl.java ÆÄÀÏÀ» »ý¼ºÇÕ´Ï´Ù.
package osgitut.movies.impl;
import java.util.*;
import osgitut.movies.*;
import org.osgi.framework.*;
import org.osgi.util.tracker.ServiceTracker;
public class MovieListerImpl implements MovieLister {
private final ServiceTracker finderTrack;
public MovieListerImpl(ServiceTracker finderTrack) {
this.finderTrack = finderTrack;
}
public List listByDirector(String name) {
MovieFinder finder = (MovieFinder) finderTrack.getService();
if(finder == null) {
return null;
} else {
return doSearch(name, finder);
}
}
private List doSearch(String name, MovieFinder finder) {
Movie[] movies = finder.findAll();
List result = new LinkedList();
for (int i = 0; i < movies.length; i++) {
if(movies[i].getDirector().indexOf(name) > -1) {
result.add(movies[i]);
}
}
return result;
}
}
À̰ÍÀÌ ¾Æ¸¶ Áö±Ý±îÁö »ùÇÃÁß °¡Àå ±ä ÄÚµåÀϰ̴ϴÙ! ±×·³, ¿©±â¼± ¹«½¼ÀÏÀÌ ÀϾ°í ÀÖÀ»±î¿ä ? ù¹øÂ°·Î ½ÇÁ¦ ¿µÈ¸¦ ã´Â ·ÎÁ÷ÀÌ
doSearch(String,MovieFinder) ¸Þ¼Òµå·Î ºÐ¸®µÇ¾î, OSGi ¿¡ °ü·ÃµÈ Äڵ带 µ¶¸³½Ã۵µ·Ï µµ¿ÍÁÖ°í ÀÖ½À´Ï´Ù. ºÒ°¡ÇÇ ÇϰԵµ, ¿ì¸®°¡ °Ë»öÀ» ÇÏ´Â ¹æ¹ýÀÌ ¸ÛûÇÏ°í ºñÈ¿À²ÀûÀÌÁö¸¸, ±×°Ç ÀÌ Æ©Å丮¾ó¿¡´Â Å©°Ô Á¾¿äÇÏÁö ¾Ê½À´Ï´Ù. ¾îÂ÷ÇÇ ¿ì¸® µ¥ÀÌÅͺ£À̽º¿¡´Â µü! 2°³ÀÇ ¿µÈ¸¸ ÀÖÀ¸´Ï±î¿ä.
Èï¹Ì·Î¿î°Ç ¼ºñ½º ·¹Áö½ºÆ®¸®·ÎºÎÅÍ
MovieFinder ¸¦ ã±âÀ§ÇØ
ServiceTracker¸¦ »ç¿ëÇÏ´Â
listByDirector(String name) ¸Þ¼Òµå ÀÔ´Ï´Ù.
ServiceTracker ´Â OSGi API ÀÇ Àç¹Ì¾ø´Â ÇÏÀ§·¹º§ Äڵ带 Ãß»óȽÃÄÑÁÖ´Â ¸Å¿ì À¯¿ëÇÑ Å¬·¡½ºÀÔ´Ï´Ù. ¾î¶°Å³ª, ¿ì¸° Á¤¸» ¼ºñ½º°¡ Á¸ÀçÇÏ´ÂÁö üũÇÒ Çʿ䰡 ÀÖ½À´Ï´Ù.
ServiceTracker ´Â »ý¼ºÀÚ·Î Àü´ÞµÇ¾ú´Ù°í °¡Á¤ÇÕ´Ï´Ù.
¿©·¯ºÐ²²¼± ¾Æ¸¶µµ
ServiceTracker ¸¦ »ç¿ëÇÏÁö ¾Ê°í ·¹Áö½ºÆ®¸®¿¡¼ ¼ºñ½º¸¦ °¡Á®¿À´Â Äڵ带 º¸¼ÌÀ»¼öµµ ÀÖ½À´Ï´Ù. ¿¹¸¦ µé¾î
BundleContext ¿¡
getServiceReferece ¿Í
getService ¸¦ È£ÃâÇϴ°ÍÀÌ °¡´ÉÇÕ´Ï´Ù. ÇÏÁö¸¸ ÀÌ·± ÄÚµå´Â ²Ï º¹ÀâÇÏ°í »ç¿ëÈÄ Àß Áö¿ìµµ·Ï Á¶½ÉÇØ¾ß ÇÕ´Ï´Ù. Á¦ ÀǰßÀ¸·Ð, ·Î¿ì·¹º§ API¸¦ »ç¿ëÇÏ´Â °ÍÀÇ ÀÌÁ¡Àº ¸Å¿ì ÀÛ°í ¸¹Àº ¹®Á¦°¡ ÀÖ½À´Ï´Ù.
ServiceTracker ¸¦ Ç×»ó »ç¿ëÇϴ°ÍÀÌ ÁÁ½À´Ï´Ù.
ServiceTracker ¸¦ »ý¼ºÇϱ⿡ ÁÁÀº°÷Àº bundle activator ÀÔ´Ï´Ù. ¾Æ·¡ Äڵ带
osgitut/movies/impl/MovieListerActivator.java ¿¡ º¹»çÇϼ¼¿ä.
package osgitut.movies.impl;
import java.util.*;
import org.osgi.framework.*;
import org.osgi.util.tracker.ServiceTracker;
import osgitut.movies.*;
public class MovieListerActivator implements BundleActivator {
private ServiceTracker finderTracker;
private ServiceRegistration listerReg;
public void start(BundleContext context) throws Exception {
// Create and open the MovieFinder ServiceTracker
finderTracker = new ServiceTracker(context, MovieFinder.class.getName(), null);
finderTracker.open();
// Create the MovieLister and register as a service
MovieLister lister = new MovieListerImpl(finderTracker);
listerReg = context.registerService(MovieLister.class.getName(), lister, null);
// Execute the sample search
doSampleSearch(lister);
}
public void stop(BundleContext context) throws Exception {
// Unregister the MovieLister service
listerReg.unregister();
// Close the MovieFinder ServiceTracker
finderTracker.close();
}
private void doSampleSearch(MovieLister lister) {
List movies = lister.listByDirector("Miyazaki");
if(movies == null) {
System.err.println("Could not retrieve movie list");
} else {
for (Iterator it = movies.iterator(); it.hasNext();) {
Movie movie = (Movie) it.next();
System.out.println("Title: " + movie.getTitle());
}
}
}
}
ÀÌÁ¦ Activator °¡ Àç¹ÌÀÖ¾î º¸À̱⠽ÃÀÛÇÕ´Ï´Ù. óÀ½¿¡
start ¸Þ¼Òµå¿¡¼
MovieLister °¡ »ç¿ëÇÒ
ServiceTracker °³Ã¼¸¦ »ý¼ºÇÕ´Ï´Ù. ±×¸®°í´Â
ServiceTracker ¸¦ "¿±´Ï´Ù". À̰Ç
MovieFinder ¼ºñ½ºÀÇ Instance¸¦ ·¹Áö½ºÆ®¸®¿¡¼ ÃßÀûÇÏ´Â°É ½ÃÀÛÇ϶ó´Â °ÍÀÌÁÒ. ±×¸®°í´Â
MovieLister ÀÎÅÍÆäÀ̽º À̸§À¸·Î ¼ºñ½º ·¹Áö½ºÆ®¸®¿¡
MovieListerImpl °³Ã¼¸¦ »ý¼ºÇÏ°í µî·ÏÇÕ´Ï´Ù. ¸¶Áö¸·À¸·Î, ¿ì¸®°¡ ¹øµéÀ» ½ÃÀÛÇßÀ»¶§ ¹º°¡ Àç¹ÌÀִ°ÍÀÌ º¸Àϼö ÀÖµµ·Ï,
MovieLister ¸¦ ÀÌ¿ëÇÏ¿© °£´ÜÇÑ °Ë»öÀ» ½ÇÇàÇÏ°í °á°ú¸¦ Ãâ·ÂÇÕ´Ï´Ù.
ÀÌÁ¦ ÀÌ ¹øµéÀ» ¸¸µé°í ¼³Ä¡ÇØ¾ß ÇÕ´Ï´Ù. ÀÚ¼¼ÇÑ ¼³¸íÀº ÇÏÁö ¾Êµµ·Ï ÇϰڽÀ´Ï´Ù. ÀÌÀü ȸ¸¦ Âü°íÇϸé ÃæºÐÈ÷ ÇϽǼö ÀÖÀ»°Ì´Ï´Ù. Manifest ÆÄÀÏÀ» ¸¸µé°í,
Bundle-Activator ¿¡
osgitut.movies.impl.MovieListerActivator ¸¦ ÁöÁ¤ÇØ¾ß ÇÏ´Â°É ±â¾ïÇØ µÎ¼¼¿ä. ¶ÇÇÑ
Import-Package ¿¡´Â ¿ì¸®°¡ ´Ù¸¥ ¹øµé¿¡¼ ÀÓÆ÷ÆÃÇÏ´Â 3°³ÀÇ ÆÐŰÁö (
org.osgi.framework , org.osgi.util.tracker ±×¸®°í osgitut.movies ) ¸¦ Àû¾îÁÖ¾î¾ß ÇÕ´Ï´Ù.
MovieLister.jar ¸¦ Equinox ·±Å¸ÀӾȿ¡ ¼³Ä¡Çß´Ù¸é, ½ÃÀÛÇÒ ¼ö ÀÖ½À´Ï´Ù. Áö³¹ø¿¡ ¸¸µç
BasicMovieFinder ¹øµéÀÌ µ¿ÀÛÇϰí ÀÖ´ÂÁö¿¡ µû¶ó ´ÙÀ½ 2°³ÀÇ ¸Þ½ÃÁöÁß Çϳª¸¦ º¼¼ö ÀÖ½À´Ï´Ù. ¸¸¾à µ¿ÀÛÁßÀÌ ¾Æ´Ï¶ó¸é,
osgi> start 2
Could not retrieve movie list
¾ÆÁ÷ µ¿ÀÛÁßÀ̶ó¸é
osgi> start 2
Title: Spirited Away
°¢ ¹øµéÀ» ÁßÁö½ÃŰ°í ½ÃÀÛ½ÃÄѺ¸¸é, µÎ°³ÀÇ ¸Þ½ÃÁö¸¦ ¿øÇÏ´Â ´ë·Î º¸½Ç¼ö ÀÖ½À´Ï´Ù. À̰ÍÀÌ À̹ø ¿¬ÀçÀÇ °ÅÀÇ ´ÙÀÔ´Ï´Ù¸¸, Á¦°¡ ¼ºñ½º°¡ »ç¿ë ºÒ°¡´ÉÇÒ¶§(not available) ÇÒ¼ö ÀÖ´Â ÀÏÁß¿¡ ±â´Ù¸®´Â ¹æ¹ýÀÌ ÀÖ´Ù°í ÇѰбâ¾ïÇϽóª¿ä ? ¿ì¸®°¡ °¡Áö°í ÀÖ´Â Äڵ常 ÀÖÀ¸¸é ÀÌ°Ç °£´ÜÇÕ´Ï´Ù.
MovieListerImpl ÀÇ 16¹øÂ° ¶óÀÎÀ»
getService() ¸Þ¼Òµå ´ë½Å
ServiceTracker ÀÇ
waitForService(5000)À¸·Î º¯°æÇϽðí,
InterruptedException ¿¡ ´ëÇÑ
try/catch ºí·ÏÀ» Ãß°¡Çϼ¼¿ä.
À̰ÍÀº
listByDirector() ¸Þ¼Òµå°¡ 5000 ¹Ð¸®¼¼ÄÁµåµ¿¾È
MovieFinder ¼ºñ½º°¡ ³ªÅ¸³¯¶§±îÁö ±â´Ù¸®µµ·Ï ÇÒ°ÍÀÔ´Ï´Ù. ¸¸¾à
MovieFinder ¼ºñ½º°¡ ±× ½Ã°£³»¿¡ ¼³Ä¡µÈ´Ù¸é (¹°·Ð ÀÌ¹Ì ÀÖÀ»¶§¿¡µµ) ¿ì¸° ¹Ù·Î ¼ºñ½º¸¦ °¡Á®¿Í¼ »ç¿ëÀÌ °¡´ÉÇÒ °ÍÀÔ´Ï´Ù.
ÀϹÝÀûÀÎ °æ¿ì¿¡ Àú´Â ÀÌ·±½ÄÀ¸·Î ÁßÁöÇϰí ÀÖ´Â ¾²·¹µå¸¦ »ç¿ëÇ϶ó°í ±Ç°íÇÏÁö¸¸, ÀÌ °æ¿ì¿£
listByDirecor() ¸Þ¼Òµå°¡ ÇÁ·¹ÀÓ¿öÅ© ¾²·¹µå·Î ºÎÅÍ È£ÃâµÇ´Â Bundle activator ÀÇ
start ¸Þ¼Òµå ¿¡¼ È£ÃâÀÌ µÇ¾ú±â ¶§¹®¿¡ À§ÇèÇÒ¼ö ÀÖ½À´Ï´Ù. ¹øµéÀÌ È°¼ºÈ µÉ¶§ ¿©·¯ ÀϵéÀÌ ÀϾ¾ßÇÒ Çʿ䰡 Àֱ⶧¹®¿¡ Activator µéÀº »¡¸® ¸®ÅÏÇØ¾ß ÇÕ´Ï´Ù. ÃÖ¾ÇÀÇ °æ¿ì¿¡´Â ¿ì¸®°¡ ´Ù¸¥°Í¿¡ ÀÇÇØ ÀÌ¹Ì lock µÇ¾úÀ»Áöµµ ¸ð¸£´Â ÇÁ·¹ÀÓ¿öÅ© ¼ÒÀ¯°³Ã¼ÀÇ
synchronized ºí·Ï¿¡ µé¾î°¬À¸¹Ç·Î deadlock ÀÌ ¹ß»ýÇÒ ¼öµµ ÀÖ½À´Ï´Ù. ±âº» °¡À̵å¶óÀÎÀº, ÇÁ·¹ÀÓ¿öÅ©¿¡ ÀÇÇØ È£ÃâµÇ´Â ¸ðµçÄÚµå ¶Ç´Â ¹øµéÀÇ activator ¿¡ ÀÖ´Â
start ¸Þ¼Òµå¿¡¼´Â ½Ã°£ÀÌ ¿À·¡ °É¸®´Â ÀÛ¾÷À̳ª ºí·ÏÅ· ¿ÀÆÛ·¹À̼ÇÀ» ÇÏÁö ¸»¶ó´Â °ÍÀÔ´Ï´Ù.
´ÙÀ½ ȸ¿¡¼± ÀÇÁ¸°³Ã¼°¡ ¾øÀ» °æ¿ìÀÇ ½ÅºñÇÑ 3¹øÂ° ¿É¼Ç "Don't exist in the first place" ¿¡ ´ëÇØ ¾Ë¾Æº¸°Ú½À´Ï´Ù. ±â´ëÇØ ÁÖ¼¼¿ä!
org.osgi.framework.BundleException: The bundle could not be resolved. Reason: mi
ssing imported package osgitut.movies_[1.0.0,2.0.0)
at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(Bundl
eHost.java:296)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(Abstrac
tBundle.java:266)
at org.eclipse.osgi.framework.internal.core.FrameworkCommandProvider._st
art(FrameworkCommandProvider.java:232)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.eclipse.osgi.framework.internal.core.FrameworkCommandInterpreter.
execute(FrameworkCommandInterpreter.java:145)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.docommand(F
rameworkConsole.java:294)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.console(Fra
meworkConsole.java:279)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.console(Fra
meworkConsole.java:237)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.run(Framewo
rkConsole.java:208)
at java.lang.Thread.run(Thread.java:534)
À§¿Í°°ÀÌ ¿À·ù°¡ ³µ½À´Ï´Ù. ¾îÂîÇØ¾ß ÇÒ±î¿ä ¤Ð¤Ð ÈÄ,,,ÇÏ·çÁ¾ÀÏ ÇØµµ éÅÍ 5¹øÀ» ¼º°ø½ÃŰÁö ¸øÇϰí ÀÖ´Â ÀúÀÔ´Ï´Ù!
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Movie Lister
Bundle-SymbolicName: MovieLister
Bundle-Version: 1.0.0
Bundle-Activator: osgitut.movies.impl.MovieListerActivator
Import-Package: org.osgi.framework, org.osgi.util.tracker, osgitut.movies;version="[1.0.0,2.0.0)"
Long °ªÀÌ¶ó ¿Ø¸¸Å »ç¿ëÇϼż´Â ¹®Á¦ ¾ÈµÉ°Ì´Ï´Ù. :)
equinox.jar
MoviesInterface.jar
BasicMovieFinder.jar
MovieLister.jar (ÀÌ°Ç Ã©ÅÍ5Àå¿¡¼ ¸¸µé¾î¼ ¼³Ä¡ÇÏ°í ½ÇÇà ÇÔ)
¿Ö start°¡ ¾È¸ÔÈúÁö? ÄÄÆÄÀÏÀ̳ª jar ÆÄÀÏ ¸¸µå´Âµ¥ ¹®Á¦°¡ ÀÖ¾ú³ª¿ä?¾Æ·¡Ã³·³ ÄÄÆÄÀÏÇϰí jarÆÄÀÏ ¸¸µçÈÄ¿¡ ½ÇÇàÇß¾î¿ä
javac -classpath equinox.jar;MoviesInterface.jar osgitut/movies/impl/*.java osgitut/movies/*.java
jar -cfm MovieLister.jar MovieLister.mf osgitut/movies/impl/*.class osgitut/movies/*.class
osgi> ss
Framework is launched.
id State Bundle
0 ACTIVE system.bundle_3.1.0
40 ACTIVE BasicMovieFinder_1.0.0
41 RESOLVED MoviesInterface_1.0.0
42 RESOLVED MovieLister_1.0.0
osgi> start 42
org.osgi.framework.BundleException: The activator osgitut.movies.impl.MovieListe
rActivator for bundle MovieLister is invalid
at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadBundleAct
ivator(AbstractBundle.java:151)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(Bund
leContextImpl.java:965)
at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(Bundl
eHost.java:321)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(Abstrac
tBundle.java:266)
at org.eclipse.osgi.framework.internal.core.FrameworkCommandProvider._st
art(FrameworkCommandProvider.java:232)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.eclipse.osgi.framework.internal.core.FrameworkCommandInterpreter.
execute(FrameworkCommandInterpreter.java:145)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.docommand(F
rameworkConsole.java:294)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.console(Fra
meworkConsole.java:279)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.console(Fra
meworkConsole.java:237)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.run(Framewo
rkConsole.java:208)
at java.lang.Thread.run(Thread.java:534)
Caused by: java.lang.NoClassDefFoundError: osgitut/movies/MovieLister
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:1618)
at java.lang.Class.getConstructor0(Class.java:1930)
at java.lang.Class.newInstance0(Class.java:278)
at java.lang.Class.newInstance(Class.java:261)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadBundleAct
ivator(AbstractBundle.java:146)
... 14 more
Nested Exception:
java.lang.NoClassDefFoundError: osgitut/movies/MovieLister
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:1618)
at java.lang.Class.getConstructor0(Class.java:1930)
at java.lang.Class.newInstance0(Class.java:278)
at java.lang.Class.newInstance(Class.java:261)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadBundleAct
ivator(AbstractBundle.java:146)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(Bund
leContextImpl.java:965)
at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(Bundl
eHost.java:321)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(Abstrac
tBundle.java:266)
at org.eclipse.osgi.framework.internal.core.FrameworkCommandProvider._st
art(FrameworkCommandProvider.java:232)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.eclipse.osgi.framework.internal.core.FrameworkCommandInterpreter.
execute(FrameworkCommandInterpreter.java:145)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.docommand(F
rameworkConsole.java:294)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.console(Fra
meworkConsole.java:279)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.console(Fra
meworkConsole.java:237)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.run(Framewo
rkConsole.java:208)
at java.lang.Thread.run(Thread.java:534)
Nested Exception:
java.lang.NoClassDefFoundError: osgitut/movies/MovieLister
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:1618)
at java.lang.Class.getConstructor0(Class.java:1930)
at java.lang.Class.newInstance0(Class.java:278)
at java.lang.Class.newInstance(Class.java:261)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadBundleAct
ivator(AbstractBundle.java:146)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(Bund
leContextImpl.java:965)
at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(Bundl
eHost.java:321)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(Abstrac
tBundle.java:266)
at org.eclipse.osgi.framework.internal.core.FrameworkCommandProvider._st
art(FrameworkCommandProvider.java:232)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.eclipse.osgi.framework.internal.core.FrameworkCommandInterpreter.
execute(FrameworkCommandInterpreter.java:145)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.docommand(F
rameworkConsole.java:294)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.console(Fra
meworkConsole.java:279)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.console(Fra
meworkConsole.java:237)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.run(Framewo
rkConsole.java:208)
at java.lang.Thread.run(Thread.java:534)
Framework is launched.
id State Bundle
0 ACTIVE system.bundle_3.1.0
48 RESOLVED MovieLister_1.0.0
49 ACTIVE MoviesInterface_1.0.0
osgi> bundle 49
file:MoviesInterface.jar [49]
Id=49, Status=ACTIVE Data Root=C:JavaExosgiEXconfigurationorg.eclipse
.osgiundles49data No registered services.
No services in use.
Exported packages
osgitut.movies; specification-version="1.0.0"[exported]
No imported packages
No fragment bundles
Named class space
MoviesInterface; bundle-version="1.0.0"[provided]
No required bundles
À̿Ͱ°Àº ½ÄÀ¸·Î È®ÀÎÀÌ 됬½À´Ï´Ù,,export´Â µÈµíÇѵ¥ ¸Ó°¡ ¹®Á¦Àϱî¿ä? ù¹øÂ° ¾´ ¿À·ù ±¸¹®ÀÌ ±Ã±ÝÇϳ׿ä,
rActivator for bundle MovieLister is invalid
at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadBundleAct
ivator(AbstractBundle.java:141)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(Bund
leContextImpl.java:970)
at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(Bundl
eHost.java:346)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(Abstrac
tBundle.java:260)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(Abstrac
tBundle.java:252)
at org.eclipse.osgi.framework.internal.core.FrameworkCommandProvider._st
art(FrameworkCommandProvider.java:260)
at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.osgi.framework.internal.core.FrameworkCommandInterpreter.
execute(FrameworkCommandInterpreter.java:150)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.docommand(F
rameworkConsole.java:300)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.console(Fra
meworkConsole.java:285)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.run(Framewo
rkConsole.java:221)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoClassDefFoundError: osgitut/movies/MovieLister
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadBundleAct
ivator(AbstractBundle.java:136)
... 13 more
Nested Exception:
java.lang.NoClassDefFoundError: osgitut/movies/MovieLister
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadBundleAct
ivator(AbstractBundle.java:136)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(Bund
leContextImpl.java:970)
at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(Bundl
eHost.java:346)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(Abstrac
tBundle.java:260)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(Abstrac
tBundle.java:252)
at org.eclipse.osgi.framework.internal.core.FrameworkCommandProvider._st
art(FrameworkCommandProvider.java:260)
at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.osgi.framework.internal.core.FrameworkCommandInterpreter.
execute(FrameworkCommandInterpreter.java:150)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.docommand(F
rameworkConsole.java:300)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.console(Fra
meworkConsole.java:285)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.run(Framewo
rkConsole.java:221)
at java.lang.Thread.run(Unknown Source)
Nested Exception:
java.lang.NoClassDefFoundError: osgitut/movies/MovieLister
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadBundleAct
ivator(AbstractBundle.java:136)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(Bund
leContextImpl.java:970)
at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(Bundl
eHost.java:346)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(Abstrac
tBundle.java:260)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(Abstrac
tBundle.java:252)
at org.eclipse.osgi.framework.internal.core.FrameworkCommandProvider._st
art(FrameworkCommandProvider.java:260)
at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.osgi.framework.internal.core.FrameworkCommandInterpreter.
execute(FrameworkCommandInterpreter.java:150)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.docommand(F
rameworkConsole.java:300)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.console(Fra
meworkConsole.java:285)
at org.eclipse.osgi.framework.internal.core.FrameworkConsole.run(Framewo
rkConsole.java:221)
at java.lang.Thread.run(Unknown Source)
ÀÌ°Ç ¹«½¼¿¡·¯Àΰ¡¿ä...¤Ð¤Ð 5¹ø µû¶óÇϴµ¥ ¸®½º³Ê¸¦ ÀνºÅç½ÃŰ°í ½ÇÇàÀ» ÇØµµ À§°°Àº°á°ú°¡ ¾È³ª¿É´Ï´Ù..
¸®½º³Ê¸¦ startÇϸé À§°°Àº¿¡·¯°¡³ª¿À°í¿ä..¤Ð¤Ð
mfÆÄÀÏÀº Á¦´ë·Î µÇ¾îÀִ°Ű°Àºµ¥..
¸í·É¾îÁ» Àû¾îÁÖ¼¼¿ä..¤Ð¤Ð
> jar -cfm HelloWorld.jar HelloWorld.mf HelloActivator.class
¸í·ÉÀº 1¹ø °Á¿¡ ÀÖµíÀÌ À§¿Í °°½À´Ï´Ù.