Cloudera CDH/CDP 및 Hadoop EcoSystem, Semantic IoT등의 개발/운영 기술을 정리합니다. gooper@gooper.com로 문의 주세요.
* rdf4j-http-workbench모듈은 java servlet을 이용하여 구현했고, rdf4j-http-server는 spring기반으로 구현되어 있음
1. rdf4j-http-workbench : rdf4j-workbench.war를 이용하여 web에서 작업할때 사용되는 모듈(프로젝트)
가. /rdf4j-http-workbench/src/main/webapp/WEB-INF/web.xml에서 workbench의 RESTFul API와 매핑되는 class파일을 지정함
*rdf4j-workbench.war의 API에서 사용되는 URL매핑(web.xml파일)
<?xml version="1.0" encoding="UTF-8"?> <web-app> <display-name>RDF4J Workbench</display-name> <description>RDF4J Workbench</description> <filter> <filter-name>redirect</filter-name> <filter-class> org.eclipse.rdf4j.workbench.proxy.RedirectFilter </filter-class> <init-param> <param-name>/</param-name> <param-value>/repositories</param-value> </init-param> </filter> <filter> <filter-name>cache</filter-name> <filter-class> org.eclipse.rdf4j.workbench.proxy.CookieCacheControlFilter </filter-class> </filter> <filter> <filter-name>CacheFilter</filter-name> <filter-class>org.eclipse.rdf4j.workbench.proxy.CacheFilter</filter-class> <init-param> <param-name>Cache-Control</param-name> <param-value>600</param-value> </init-param> </filter> <filter-mapping> <filter-name>redirect</filter-name> <url-pattern>/</url-pattern> </filter-mapping> <filter-mapping> <filter-name>cache</filter-name> <url-pattern>/repositories/*</url-pattern> </filter-mapping> <filter-mapping> <filter-name>CacheFilter</filter-name> <url-pattern>*</url-pattern> </filter-mapping> <servlet> <servlet-name>workbench</servlet-name> <servlet-class> org.eclipse.rdf4j.workbench.proxy.WorkbenchGateway </servlet-class> <init-param> <param-name>transformations</param-name> <param-value>/transformations</param-value> </init-param> <init-param> <param-name>default-server</param-name> <param-value>/rdf4j-server</param-value> </init-param> <init-param> <param-name>accepted-server-prefixes</param-name> <param-value>file: http: https:</param-value> </init-param> <init-param> <param-name>change-server-path</param-name> <param-value>/NONE/server</param-value> </init-param> <init-param> <param-name>cookie-max-age</param-name> <param-value>2592000</param-value> </init-param> <init-param> <param-name>no-repository-id</param-name> <param-value>NONE</param-value> </init-param> <init-param> <param-name>default-path</param-name> <param-value>/NONE/repositories</param-value> </init-param> <init-param> <param-name>default-command</param-name> <param-value>/summary</param-value> </init-param> <init-param> <param-name>default-limit</param-name> <param-value>100</param-value> </init-param> <init-param> <param-name>default-queryLn</param-name> <param-value>SPARQL</param-value> </init-param> <init-param> <param-name>default-infer</param-name> <param-value>true</param-value> </init-param> <init-param> <param-name>default-Accept</param-name> <param-value>application/rdf+xml</param-value> </init-param> <init-param> <param-name>default-Content-Type</param-name> <param-value>application/rdf+xml</param-value> </init-param> <init-param> <param-name>/summary</param-name> <param-value>org.eclipse.rdf4j.workbench.commands.SummaryServlet </param-value> </init-param> <init-param> <param-name>/info</param-name> <param-value>org.eclipse.rdf4j.workbench.commands.InfoServlet</param-value> </init-param> <init-param> <param-name>/information</param-name> <param-value>org.eclipse.rdf4j.workbench.commands.InformationServlet </param-value> </init-param> <init-param> <param-name>/repositories</param-name> <param-value>org.eclipse.rdf4j.workbench.commands.RepositoriesServlet </param-value> </init-param> <init-param> <param-name>/create</param-name> <param-value>org.eclipse.rdf4j.workbench.commands.CreateServlet </param-value> </init-param> <init-param> <param-name>/delete</param-name> <param-value>org.eclipse.rdf4j.workbench.commands.DeleteServlet </param-value> </init-param> <init-param> <param-name>/namespaces</param-name> <param-value>org.eclipse.rdf4j.workbench.commands.NamespacesServlet </param-value> </init-param> <init-param> <param-name>/contexts</param-name> <param-value>org.eclipse.rdf4j.workbench.commands.ContextsServlet </param-value> </init-param> <init-param> <param-name>/types</param-name> <param-value>org.eclipse.rdf4j.workbench.commands.TypesServlet </param-value> </init-param> <init-param> <param-name>/explore</param-name> <param-value>org.eclipse.rdf4j.workbench.commands.ExploreServlet </param-value> </init-param> <init-param> <param-name>/query</param-name> <param-value>org.eclipse.rdf4j.workbench.commands.QueryServlet </param-value> </init-param> <init-param> <param-name>/saved-queries</param-name> <param-value>org.eclipse.rdf4j.workbench.commands.SavedQueriesServlet </param-value> </init-param> <init-param> <param-name>/export</param-name> <param-value>org.eclipse.rdf4j.workbench.commands.ExportServlet </param-value> </init-param> <init-param> <param-name>/add</param-name> <param-value>org.eclipse.rdf4j.workbench.commands.AddServlet</param-value> </init-param> <init-param> <param-name>/remove</param-name> <param-value>org.eclipse.rdf4j.workbench.commands.RemoveServlet </param-value> </init-param> <init-param> <param-name>/clear</param-name> <param-value>org.eclipse.rdf4j.workbench.commands.ClearServlet </param-value> </init-param> <init-param> <param-name>/update</param-name> <param-value>org.eclipse.rdf4j.workbench.commands.UpdateServlet </param-value> </init-param> </servlet> <servlet-mapping> <servlet-name>workbench</servlet-name> <url-pattern>/repositories/*</url-pattern> </servlet-mapping> </web-app>
나. rdf4j-http-workbench.war에서 사용하는 class파일(예,StatementsController.java)은 "/rdf4j-http-server-spring/src/main/java/org/eclipse/rdf4j/http/server/repository/statements/StatementsController.java"등에 위치함
2. rdf4j-http-server : rdf4j-server.war를 이용하여 RESTFul API를 호출할때 사용되는 모듈(프로젝트)
가. /rdf4j-http-server/src/main/webapp/WEB-INF/web.xml에서 아래와 같이 설정xml파일을 지정함
<servlet> <servlet-name>rdf4j-http-server</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/common-webapp-servlet.xml, /WEB-INF/common-webapp-system-servlet.xml, /WEB-INF/rdf4j-http-server-servlet.xml</param-value> </init-param> <load-on-startup>100</load-on-startup> </servlet>
나. /rdf4j-http-server/src/main/webapp/WEB-INF/rdf4j-http-server-servlet.xml에서 API와 매핑되는 class파일을 지정함
*rdf4j-server.war의 repository관련 API에서 사용되는 URL매핑
<bean id="rdf4jRepositoryUrlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> <property name="order" value="2" /> <property name="alwaysUseFullPath" value="true" /> <property name="mappings"> <props> <prop key="/repositories/*/namespaces/*">rdf4jRepositoryNamespaceController</prop> <prop key="/repositories/*/namespaces">rdf4jRepositoryNamespacesController</prop> <prop key="/repositories/*/contexts">rdf4jRepositoryContextsController</prop> <prop key="/repositories/*/statements">rdf4jRepositoryStatementsController</prop> <prop key="/repositories/*/rdf-graphs">rdf4jRepositoryContextsController</prop> <prop key="/repositories/*/rdf-graphs/*">rdf4jRepositoryGraphController</prop> <prop key="/repositories/*/size">rdf4jRepositorySizeController</prop> <prop key="/repositories/*/transactions">rdf4jRepositoryTransactionStartController</prop> <prop key="/repositories/*/transactions/*">rdf4jRepositoryTransactionController</prop> <prop key="/repositories/*">rdf4jRepositoryController</prop> </props> </property> <property name="interceptors"> <list> <ref bean="rdf4jRepositoryInterceptor" /> </list> </property> </bean>
*URL매핑에 해당되는 처리 class매핑
<!-- CONTROLLERS --> <bean id="rdf4jProtocolController" class="org.eclipse.rdf4j.http.server.protocol.ProtocolController" /> <bean id="rdf4jRepositoryListController" class="org.eclipse.rdf4j.http.server.repository.RepositoryListController"> <property name="repositoryManager" ref="rdf4jRepositoryManager" /> </bean> <bean id="rdf4jRepositoryController" class="org.eclipse.rdf4j.http.server.repository.RepositoryController"> <property name="repositoryManager" ref="rdf4jRepositoryManager" /> </bean> <bean id="rdf4jRepositoryContextsController" class="org.eclipse.rdf4j.http.server.repository.contexts.ContextsController" /> <bean id="rdf4jRepositoryNamespacesController" class="org.eclipse.rdf4j.http.server.repository.namespaces.NamespacesController" /> <bean id="rdf4jRepositoryNamespaceController" class="org.eclipse.rdf4j.http.server.repository.namespaces.NamespaceController" /> <bean id="rdf4jRepositorySizeController" class="org.eclipse.rdf4j.http.server.repository.size.SizeController" /> <bean id="rdf4jRepositoryStatementsController" class="org.eclipse.rdf4j.http.server.repository.statements.StatementsController" /> <bean id="rdf4jRepositoryGraphController" class="org.eclipse.rdf4j.http.server.repository.graph.GraphController" /> <bean id="rdf4jRepositoryTransactionController" class="org.eclipse.rdf4j.http.server.repository.transaction.TransactionController" /> <bean id="rdf4jRepositoryTransactionStartController" class="org.eclipse.rdf4j.http.server.repository.transaction.TransactionStartController" />
다 rdf4j-server.war가 사용하는 class파일은(예, StatementsController.java) "/rdf4j-http-server-spring/src/main/java/org/eclipse/rdf4j/http/server/repository/statements/StatementsController.java"에 위치함