Browse files

fixed plugin.xml classname problems and added a test.url solution fil…

…e to demonstrate

the plugin
  • Loading branch information...
1 parent 389f80a commit 7c6e42bc07f75d63fe26c5c04dc4eeb61e8e7853 @adphillips committed May 11, 2011
View
1 .gitignore
@@ -2,3 +2,4 @@ bin
dist
lib
test-lib
+eclipse-bin
View
4 package-res/plugin.spring.xml
@@ -9,8 +9,8 @@
<context:annotation-config />
- <bean id="jaxrsPluginServlet" class="org.pentaho.plugin.jaxrs.JAXRSPluginServlet" />
- <bean class="org.pentaho.plugin.jaxrs.TestResource"/>
+ <bean id="jaxrsPluginServlet" class="org.pentaho.plugin.j2ee.JAXRSPluginServlet" />
+ <bean class="org.pentaho.plugin.j2ee.TestResource"/>
</beans>
View
6 package-res/plugin.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<plugin title='Sample plugin xml for jaxrs-adapter-plugin' name="jaxrs">
- <content-generator id="jaxrs" title="fa la la la la, la la la la" type="notused" class="org.pentaho.plugin.jaxrs.UglyJaxRSAdapter"/>
- <bean id="jaxrsPluginServlet" class="org.pentaho.plugin.jaxrs.JAXRSPluginServlet" />
+<plugin title='Sample plugin xml for j2ee-adapter-plugin' name="j2ee">
+ <content-generator id="j2ee" title="fa la la la la, la la la la" type="notused" class="org.pentaho.plugin.j2ee.ServletAdapterContentGenerator"/>
+ <!--bean id="jaxrsPluginServlet" class="org.pentaho.plugin.j2ee.JAXRSPluginServlet" /-->
</plugin>
View
8 solutions/bi-developers/j2ee/index.xml
@@ -0,0 +1,8 @@
+<index>
+
+ <name>%name</name>
+ <description>%description</description>
+ <visible>true</visible>
+ <display-type>icons</display-type>
+
+</index>
View
6 solutions/bi-developers/j2ee/test.url
@@ -0,0 +1,6 @@
+[InternetShortcut]
+URL=content/j2ee/api/test
+Modified=30E041B5D78BC5012E
+[navigation]
+Name=%name
+Description=%description
View
80 src/org/pentaho/plugin/j2ee/ServletAdapterContentGenerator.java
@@ -23,58 +23,78 @@
@SuppressWarnings("serial")
public class ServletAdapterContentGenerator extends BaseContentGenerator {
-
+
private static final Log logger = LogFactory.getLog(ServletAdapterContentGenerator.class);
+
private IPluginManager pm = PentahoSystem.get(IPluginManager.class);
+
private static ConfigurableApplicationContext appContext;
+
private static JAXRSPluginServlet servlet;
-
+
public ServletAdapterContentGenerator() throws ServletException {
- if(appContext == null) {
- appContext = getSpringBeanFactory();
- servlet = (JAXRSPluginServlet)appContext.getBean("jaxrsPluginServlet");
- ServletConfig servletConfig = new ServletConfig() {
+ final ClassLoader origLoader = Thread.currentThread().getContextClassLoader();
+ final PluginClassLoader tempLoader = (PluginClassLoader) pm.getClassLoader("j2ee");
+ try {
+ Thread.currentThread().setContextClassLoader(tempLoader);
- @Override
- public String getInitParameter(String name) {
- return null;
- }
+ if (appContext == null) {
+ appContext = getSpringBeanFactory();
+ servlet = (JAXRSPluginServlet) appContext.getBean("jaxrsPluginServlet");
+ ServletConfig servletConfig = new ServletConfig() {
- @Override
- public Enumeration getInitParameterNames() {
- return new Hashtable<String, String>().elements();
- }
+ @Override
+ public String getInitParameter(String name) {
+ return null;
+ }
- @Override
- public ServletContext getServletContext() {
- return null;
- }
+ @Override
+ public Enumeration getInitParameterNames() {
+ return new Hashtable<String, String>().elements();
+ }
- @Override
- public String getServletName() {
- return "UglyAdapterServlet";
- }
-
- };
- servlet.init(servletConfig);
+ @Override
+ public ServletContext getServletContext() {
+ return null;
+ }
+
+ @Override
+ public String getServletName() {
+ return "ServletAdapterContentGenerator";
+ }
+
+ };
+ servlet.init(servletConfig);
+ }
+ } finally {
+ Thread.currentThread().setContextClassLoader(origLoader);
}
}
@SuppressWarnings("nls")
@Override
public void createContent() throws Exception {
- HttpServletRequest request = (HttpServletRequest)this.parameterProviders.get("path").getParameter("httprequest");
- HttpServletResponse response = (HttpServletResponse)this.parameterProviders.get("path").getParameter("httpresponse");
- servlet.service(request, response);
+ HttpServletRequest request = (HttpServletRequest) this.parameterProviders.get("path").getParameter("httprequest");
+ HttpServletResponse response = (HttpServletResponse) this.parameterProviders.get("path").getParameter(
+ "httpresponse");
+
+ final ClassLoader origLoader = Thread.currentThread().getContextClassLoader();
+ final PluginClassLoader tempLoader = (PluginClassLoader) pm.getClassLoader("j2ee");
+ try {
+ Thread.currentThread().setContextClassLoader(tempLoader);
+ servlet.service(request, response);
+ } finally {
+ Thread.currentThread().setContextClassLoader(origLoader);
+ }
}
@Override
public Log getLogger() {
return logger;
}
-
+
private ConfigurableApplicationContext getSpringBeanFactory() {
- final PluginClassLoader loader = (PluginClassLoader)pm.getClassLoader("jaxrs");
+ final PluginClassLoader loader = (PluginClassLoader) pm.getClassLoader("j2ee");
File f = new File(loader.getPluginDir(), "plugin.spring.xml"); //$NON-NLS-1$
if (f.exists()) {
logger.debug("Found plugin spring file @ " + f.getAbsolutePath()); //$NON-NLS-1$
View
4 src/org/pentaho/plugin/j2ee/TestResource.java
@@ -6,14 +6,14 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-@Path("/jaxrs/api/test")
+@Path("/j2ee/api/test")
public class TestResource {
private static final Log log = LogFactory.getLog(TestResource.class);
@GET
public String reply() throws Exception {
- return "JAXRS Adapter Plugin works!";
+ return "<html>It works!</html>";
}
}

0 comments on commit 7c6e42b

Please sign in to comment.