DEMPIERE-330 Zk Web Client: Failed to register addon component and javascript resources.
This commit is contained in:
parent
57c669ce71
commit
e8f72ee777
|
@ -1,7 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" immediate="true" name="org.adempiere.ui.zk.ResourceLocator">
|
||||
<implementation class="org.adempiere.webui.util.WebUIResourceFinder"/>
|
||||
<service>
|
||||
<provide interface="org.zkoss.util.resource.IResourceLocator"/>
|
||||
</service>
|
||||
</scr:component>
|
|
@ -32,10 +32,12 @@ import javax.servlet.http.HttpServletResponse;
|
|||
import org.compiere.Adempiere;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.Ini;
|
||||
import org.zkoss.util.resource.ClassLocator;
|
||||
import org.zkoss.zk.ui.http.DHtmlLayoutServlet;
|
||||
|
||||
import org.adempiere.util.ServerContext;
|
||||
import org.adempiere.util.ServerContextURLHandler;
|
||||
import org.adempiere.webui.util.ZkResourceLocator;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -52,6 +54,8 @@ public class WebUIServlet extends DHtmlLayoutServlet
|
|||
|
||||
public void init(ServletConfig servletConfig) throws ServletException
|
||||
{
|
||||
ClassLocator.addResourceLocator(new ZkResourceLocator());
|
||||
|
||||
super.init(servletConfig);
|
||||
|
||||
/** Initialise context for the current thread*/
|
||||
|
|
|
@ -17,14 +17,13 @@ import java.net.URL;
|
|||
|
||||
import org.adempiere.base.IResourceFinder;
|
||||
import org.adempiere.webui.WebUIActivator;
|
||||
import org.zkoss.util.resource.IResourceLocator;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author hengsin
|
||||
*
|
||||
*/
|
||||
public class WebUIResourceFinder implements IResourceFinder, IResourceLocator {
|
||||
public class WebUIResourceFinder implements IResourceFinder {
|
||||
|
||||
@Override
|
||||
public URL getResource(String name) {
|
||||
|
|
|
@ -11,45 +11,35 @@
|
|||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
*****************************************************************************/
|
||||
package org.zkoss.util.resource;
|
||||
package org.adempiere.webui.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.net.URL;
|
||||
|
||||
import org.adempiere.webui.WebUIActivator;
|
||||
import org.zkoss.util.resource.IResourceLocator;
|
||||
|
||||
/**
|
||||
* @author hengsin
|
||||
*
|
||||
*/
|
||||
public class ResourceLocatorRegistry {
|
||||
public class ZkResourceLocator implements IResourceLocator {
|
||||
|
||||
private List<IResourceLocator> locators = new ArrayList<IResourceLocator>();
|
||||
private static ZkResourceLocator INSTANCE;
|
||||
|
||||
private static ResourceLocatorRegistry INSTANCE = null;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param locator
|
||||
*/
|
||||
public synchronized void addLocator(IResourceLocator locator) {
|
||||
System.err.println("addLocator " + locator);
|
||||
locators.add(locator);
|
||||
if (INSTANCE == null) {
|
||||
INSTANCE = this;
|
||||
}
|
||||
public ZkResourceLocator() {
|
||||
INSTANCE = this;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param locator
|
||||
/* (non-Javadoc)
|
||||
* @see org.zkoss.util.resource.IResourceLocator#getResource(java.lang.String)
|
||||
*/
|
||||
public synchronized void removeLocator(IResourceLocator locator) {
|
||||
locators.remove(locator);
|
||||
@Override
|
||||
public URL getResource(String name) {
|
||||
return WebUIActivator.getBundleContext().getBundle().getEntry(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list of resource locator
|
||||
*/
|
||||
public synchronized static List<IResourceLocator> getLocators() {
|
||||
return INSTANCE != null ? INSTANCE.locators : null;
|
||||
public static boolean isStarted() {
|
||||
return INSTANCE != null;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/asm.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/cglib.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/commons-el.jar"/>
|
||||
|
@ -26,7 +27,6 @@
|
|||
<classpathentry exported="true" kind="lib" path="lib/zweb.jar" sourcepath="lib/zweb-sources.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/ckez.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/zel.jar"/>
|
||||
<classpathentry exported="true" kind="lib" path="lib/zkbind.jar"/>
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.zkoss.zk.library.ResourceLocatorRegistry">
|
||||
<implementation class="org.zkoss.util.resource.ResourceLocatorRegistry"/>
|
||||
<reference bind="addLocator" cardinality="0..n" interface="org.zkoss.util.resource.IResourceLocator" name="IResourceLocator" policy="dynamic" unbind="removeLocator"/>
|
||||
</scr:component>
|
|
@ -16,6 +16,7 @@ Copyright (C) 2005 Potix Corporation. All Rights Reserved.
|
|||
*/
|
||||
package org.zkoss.util.resource;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
@ -51,9 +52,19 @@ import org.zkoss.idom.input.SAXBuilder;
|
|||
*/
|
||||
public class ClassLocator implements XMLResourcesLocator {
|
||||
private static final Log log = Log.lookup(ClassLocator.class);
|
||||
|
||||
private static List<IResourceLocator> resourceLocators = new ArrayList<IResourceLocator>();
|
||||
|
||||
public ClassLocator() {
|
||||
}
|
||||
|
||||
public static synchronized void addResourceLocator(IResourceLocator locator) {
|
||||
resourceLocators.add(locator);
|
||||
}
|
||||
|
||||
private static synchronized IResourceLocator[] getResourceLocators() {
|
||||
return resourceLocators.toArray(new IResourceLocator[0]);
|
||||
}
|
||||
|
||||
//XMLResourcesLocator//
|
||||
public Enumeration<URL> getResources(String name) throws IOException {
|
||||
|
@ -84,8 +95,8 @@ public class ClassLocator implements XMLResourcesLocator {
|
|||
final Enumeration<URL> en = ClassLoader.getSystemResources(name);
|
||||
list = Collections.list(en);
|
||||
}
|
||||
List<IResourceLocator> locators = ResourceLocatorRegistry.getLocators();
|
||||
if (locators != null) {
|
||||
IResourceLocator[] locators = ClassLocator.getResourceLocators();
|
||||
if (locators != null && locators.length > 0) {
|
||||
for (IResourceLocator locator : locators) {
|
||||
URL url = locator.getResource(name);
|
||||
if (url != null) {
|
||||
|
|
Loading…
Reference in New Issue