Olingo
  1. Olingo
  2. OLINGO-41

Export-Package header incorrect in olingo-odata2-core

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: V2 1.0.0
    • Fix Version/s: V2 1.1.0
    • Component/s: odata2-core
    • Labels:
      None
    • Environment:
      Apache Karaf 2.3.3

      Description

      "Export-Package" header in olingo-odata2-core's MANIFEST.MF file misses the package "org.apache.olingo.odata2.core.rest", but includes "org.apache.olingo.odata2.core.rest.app". In my opinion both packages should be included in "Export-Package" header and corresponding section in pom.xml should look like this:

      <Export-Package>
      org.apache.olingo.odata2.core.rest;version=$

      {project.version},
      org.apache.olingo.odata2.core.rest.app;version=${project.version}

      ,
      org.apache.olingo.odata2.core.rt;version=$

      {project.version}

      ,
      </Export-Package>

      PS. I need this package because it was required to create custom ODataRootLocator since default ODataRootLocator accepts only fully qualified factory class name, what causes problems in OSGi environment (my factory class in not visible to olingo-odata2-core bundle)

        Activity

        Hide
        Stephan Klevenz added a comment -

        Will this be a solution for OSGi?

        Implement a servlet filter which attaches the classloader of the web application to the request object. The OData lib then can use it to load the applications factory class.

        The package "org.apache.olingo.odata2.core.rest" is not exposed by purpose and that is because of to keep dependencies to implementation module at minimum.

        Are there reasons against this solution?

        public class ServiceFactoryFilter implements Filter {

        @Override
        public void init(FilterConfig filterConfig) throws ServletException {
        }

        @Override
        public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException

        { request.setAttribute(ODataServiceFactory.FACTORY_CLASSLOADER_LABEL, MyServiceFactory.class.getClassLoader()); chain.doFilter(request, response); }

        @Override
        public void destroy() {
        }
        }

        Show
        Stephan Klevenz added a comment - Will this be a solution for OSGi? Implement a servlet filter which attaches the classloader of the web application to the request object. The OData lib then can use it to load the applications factory class. The package "org.apache.olingo.odata2.core.rest" is not exposed by purpose and that is because of to keep dependencies to implementation module at minimum. Are there reasons against this solution? public class ServiceFactoryFilter implements Filter { @Override public void init(FilterConfig filterConfig) throws ServletException { } @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { request.setAttribute(ODataServiceFactory.FACTORY_CLASSLOADER_LABEL, MyServiceFactory.class.getClassLoader()); chain.doFilter(request, response); } @Override public void destroy() { } }
        Hide
        Vassili Jakovlev added a comment - - edited

        Thanks for a quick reply, Stephan!
        One of the problems here is that core OSGi specification knows nothing about servlet filters, so it will be required either to use Pax Web or to package my bundle as WAR file, but this will make me depend on OSGi container - not all of them support WAR file deployment.

        Maybe, it would be possible to introduce org.apache.olingo.odata2.core.rest.app.ODataAbstractRootLocator where the functionality of retrieving service factory could be overriden without involving direct dependencies to org.apache.olingo.odata2.core.rest package?

        public abstract class ODataAbstractRootLocator

        { .... protected abstract ODataServiceFactory getServiceFactory(); .... }
        Show
        Vassili Jakovlev added a comment - - edited Thanks for a quick reply, Stephan! One of the problems here is that core OSGi specification knows nothing about servlet filters, so it will be required either to use Pax Web or to package my bundle as WAR file, but this will make me depend on OSGi container - not all of them support WAR file deployment. Maybe, it would be possible to introduce org.apache.olingo.odata2.core.rest.app.ODataAbstractRootLocator where the functionality of retrieving service factory could be overriden without involving direct dependencies to org.apache.olingo.odata2.core.rest package? public abstract class ODataAbstractRootLocator { .... protected abstract ODataServiceFactory getServiceFactory(); .... }
        Hide
        Stephan Klevenz added a comment -

        Good point! I will think about if we can put "something" into the "org.apache.olingo.odata2.core.rest.app" package that solves the problem. Let's keep this issue open...

        Show
        Stephan Klevenz added a comment - Good point! I will think about if we can put "something" into the "org.apache.olingo.odata2.core.rest.app" package that solves the problem. Let's keep this issue open...
        Hide
        ASF subversion and git services added a comment -

        Commit 3fc87f4e74e28bfd82568bd1914de6ee0cb34c4e in branch refs/heads/master from Stephan Klevenz
        [ https://git-wip-us.apache.org/repos/asf?p=incubator-olingo-odata2.git;h=3fc87f4 ]

        OLINGO-41 refactor *.core and eliminate jax-rs dependency

        Show
        ASF subversion and git services added a comment - Commit 3fc87f4e74e28bfd82568bd1914de6ee0cb34c4e in branch refs/heads/master from Stephan Klevenz [ https://git-wip-us.apache.org/repos/asf?p=incubator-olingo-odata2.git;h=3fc87f4 ] OLINGO-41 refactor *.core and eliminate jax-rs dependency
        Hide
        ASF subversion and git services added a comment -

        Commit 30fefa9884be340616535842cc9772e130ab4473 in branch refs/heads/master from Stephan Klevenz
        [ https://git-wip-us.apache.org/repos/asf?p=incubator-olingo-odata2.git;h=30fefa9 ]

        OLINGO-41 new AbstractODataApplication for OSGi use case

        Show
        ASF subversion and git services added a comment - Commit 30fefa9884be340616535842cc9772e130ab4473 in branch refs/heads/master from Stephan Klevenz [ https://git-wip-us.apache.org/repos/asf?p=incubator-olingo-odata2.git;h=30fefa9 ] OLINGO-41 new AbstractODataApplication for OSGi use case
        Hide
        ASF subversion and git services added a comment -

        Commit b6772ec1fa1ffde268f032d507e4cc7bf1dadf05 in branch refs/heads/master from Stephan Klevenz
        [ https://git-wip-us.apache.org/repos/asf?p=incubator-olingo-odata2.git;h=b6772ec ]

        OLINGO-41 refactor and cleanup

        Show
        ASF subversion and git services added a comment - Commit b6772ec1fa1ffde268f032d507e4cc7bf1dadf05 in branch refs/heads/master from Stephan Klevenz [ https://git-wip-us.apache.org/repos/asf?p=incubator-olingo-odata2.git;h=b6772ec ] OLINGO-41 refactor and cleanup
        Hide
        Stephan Klevenz added a comment - - edited

        For OSGi usage do the following:

        Implement own ODataApplication:

        import org.apache.olingo.odata2.core.rest.app.AbstractODataApplication;

        public class CarODataApplication extends AbstractODataApplication {

        @Override
        public Class<? extends ODataServiceFactory> getServiceFactoryClass()

        { return CarODataServiceFactory.class; }

        }

        Configure own application in web.xml:

        <servlet>
        <servlet-name>CarServiceServlet</servlet-name>
        <servlet-class>org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet</servlet-class>
        <init-param>
        <param-name>javax.ws.rs.Application</param-name>
        <param-value>com.sap.core.odata.sample.osgi.CarODataApplication</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
        </servlet>

        see also: http://olingo.incubator.apache.org/doc/tutorials/osgi.html

        Show
        Stephan Klevenz added a comment - - edited For OSGi usage do the following: Implement own ODataApplication: import org.apache.olingo.odata2.core.rest.app.AbstractODataApplication; public class CarODataApplication extends AbstractODataApplication { @Override public Class<? extends ODataServiceFactory> getServiceFactoryClass() { return CarODataServiceFactory.class; } } Configure own application in web.xml: <servlet> <servlet-name>CarServiceServlet</servlet-name> <servlet-class>org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet</servlet-class> <init-param> <param-name>javax.ws.rs.Application</param-name> <param-value>com.sap.core.odata.sample.osgi.CarODataApplication</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> see also: http://olingo.incubator.apache.org/doc/tutorials/osgi.html
        Hide
        ASF subversion and git services added a comment -

        Commit 30fefa9884be340616535842cc9772e130ab4473 in branch refs/heads/PocEdmAnnotationsExtension from Stephan Klevenz
        [ https://git-wip-us.apache.org/repos/asf?p=incubator-olingo-odata2.git;h=30fefa9 ]

        OLINGO-41 new AbstractODataApplication for OSGi use case

        Show
        ASF subversion and git services added a comment - Commit 30fefa9884be340616535842cc9772e130ab4473 in branch refs/heads/PocEdmAnnotationsExtension from Stephan Klevenz [ https://git-wip-us.apache.org/repos/asf?p=incubator-olingo-odata2.git;h=30fefa9 ] OLINGO-41 new AbstractODataApplication for OSGi use case
        Hide
        ASF subversion and git services added a comment -

        Commit b6772ec1fa1ffde268f032d507e4cc7bf1dadf05 in branch refs/heads/PocEdmAnnotationsExtension from Stephan Klevenz
        [ https://git-wip-us.apache.org/repos/asf?p=incubator-olingo-odata2.git;h=b6772ec ]

        OLINGO-41 refactor and cleanup

        Show
        ASF subversion and git services added a comment - Commit b6772ec1fa1ffde268f032d507e4cc7bf1dadf05 in branch refs/heads/PocEdmAnnotationsExtension from Stephan Klevenz [ https://git-wip-us.apache.org/repos/asf?p=incubator-olingo-odata2.git;h=b6772ec ] OLINGO-41 refactor and cleanup
        Hide
        Christian Amend added a comment -

        Release is build.

        Show
        Christian Amend added a comment - Release is build.

          People

          • Assignee:
            Stephan Klevenz
            Reporter:
            Vassili Jakovlev
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development