2013-05-30 5 views
0

나는 며칠 동안 문제에 직면 해 있으며 해결책을 얻을 수 없습니다. 아래의 내 응용 프로그램 구조입니다 : 내가 춘분 - 서버 측-app.war (사례 사용 warproduct)의 동일한 수준에서 MyearDeployedOnJboss7.ear 내부 ejbapp.jar이jboss에서 춘분 서버 쪽 응용 프로그램에서 jar 클래스를로드하는 방법 7

그리고 난 MyJarToLaoadForEjbapp.jar 느릅 나무가에서 클래스를로드 할 iModernizeWebClient_1.0.0.jar에서 equinox-server-side-app.war의 플러그인 폴더에 있습니다 (포럼 규칙은 이미지를 전송할 수 없으므로 포럼 규칙은이를 수행 할 수 있으려면 10 점이 필요하기 때문에)

내 질문은 ejbapp.jar로드 클래스가 MyWebClient_1.0.0.jar의 플러그인 폴더 안에있는 "MyJarToLaoadForEjbapp.jar"에서 equinox-server-side-app.war에 있음을 허용하는 방법입니다.

나는 servletbridge 클래스 로더를 사용하지만 어떻게 사용하는지는 생각하지 않는다. 내 launch.ini에서

난했습니다 : 도움

답변

0

에 대한

osgi.*[email protected] org.osgi.*[email protected] eclipse.*[email protected] osgi.parentClassloader=app osgi.contextClassLoaderParent=app 

thnx 내가 OSGI 사양에서 서블릿 HttpServiceTracker를 사용하여 내 proble 해결. 그것을 수행하는 방법 : 쓰기 HttpServiceTracker liket 그 :

public void stop(BundleContext context) throws Exception { 
    Activator.plugin = null; 
    serviceTracker.close(); 
    serviceTracker = null; 
    LOGGER.info("servlet unregistered from context !!"); 
    super.stop(context); 
} 

: 정지 방법에서 서블릿 등록 취소

@Override 
public void start(BundleContext context) throws Exception { 
    super.start(context); 
    Activator.plugin = this; 

    BundleContext osgiContext = BundleReference.class 
      .cast(AnyClassOfYourProject.class.getClassLoader()).getBundle() 
      .getBundleContext(); 
    serviceTracker = new HttpServiceTracker(osgiContext); 
    serviceTracker.open(); 
    LOGGER.info("servlet published !!"); 
    LOGGER.info("Bundle started."); 
} 

과에 대한 : 메소드 시작시 플러그인 활성화 클래스

public class HttpServiceTracker extends ServiceTracker { 

private static final Logger logger = Logger 
     .getLogger(HttpServiceTracker.class.getName()); 


public HttpServiceTracker(BundleContext context) { 
    super(context, HttpService.class.getName(), null); 
} 

public Object addingService(ServiceReference reference) { 
    HttpService httpService = (HttpService) context.getService(reference); 
    logger.info("default context path : " 
      + org.eclipse.rap.ui.internal.servlet.HttpServiceTracker.ID_HTTP_CONTEXT); 
    try { 
     logger.info("will register servlet "); 
     httpService.registerServlet("/programLauncherServlet", 
       new ProgramLauncherServlet(), null, null); 
     logger.info("servlet has been registred with http context "); 
     // httpService.registerResources("/", "/html", null); 
    } catch (Exception e) { 
     //e.printStackTrace(); 
     logger.info("The alias '/programLauncherServlet' is already in use"); 
    } 

    return httpService; 
} 

public void removedService(ServiceReference reference, Object service) { 
    logger.info("will unregister servlet "); 
    HttpService httpService = (HttpService) service; 
    httpService.unregister("/programLauncher"); 
    super.removedService(reference, service); 
    logger.info("servlet has been unregistred"); 
} 

그게 다야. 서블릿은 Eclipse 번들 외부에서 액세스 할 수 있으며 번들 내부의 메소드를 호출 할 수 있습니다.