DEMPIERE-330 Zk Web Client: Failed to register addon component and javascript resources
This commit is contained in:
parent
041cd87273
commit
6af268a202
|
@ -49,7 +49,7 @@ Require-Bundle: org.adempiere.report.jasper;bundle-version="1.0.0",
|
|||
org.adempiere.ui;bundle-version="1.0.0",
|
||||
org.zkoss.zk.library;bundle-version="6.0.0"
|
||||
Bundle-Activator: org.adempiere.webui.WebUIActivator
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Eclipse-ExtensibleAPI: true
|
||||
Eclipse-RegisterBuddy: org.zkoss.zk.library
|
||||
Web-ContextPath: webui
|
||||
Service-Component: OSGI-INF/resourceLocator.xml
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
<?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>
|
|
@ -17,13 +17,14 @@ 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 {
|
||||
public class WebUIResourceFinder implements IResourceFinder, IResourceLocator {
|
||||
|
||||
@Override
|
||||
public URL getResource(String name) {
|
||||
|
@ -34,5 +35,4 @@ public class WebUIResourceFinder implements IResourceFinder {
|
|||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,7 +14,10 @@ bin.includes = META-INF/,\
|
|||
WEB-INF/lib/atmosphere-runtime-0.9.jar,\
|
||||
WEB-INF/lib/atmosphere-compat-jbossweb-0.9.jar,\
|
||||
WEB-INF/lib/atmosphere-compat-tomcat-0.9.jar,\
|
||||
WEB-INF/lib/atmosphere-compat-tomcat7-0.9.jar
|
||||
WEB-INF/lib/atmosphere-compat-tomcat7-0.9.jar,\
|
||||
OSGI-INF/,\
|
||||
metainfo/
|
||||
jars.compile.order =
|
||||
src.includes = WEB-INF/classes/,\
|
||||
WEB-INF/tld/,\
|
||||
WEB-INF/web.xml,\
|
||||
|
@ -26,8 +29,7 @@ src.includes = WEB-INF/classes/,\
|
|||
js/,\
|
||||
theme/,\
|
||||
theme.zs,\
|
||||
zul/
|
||||
zul/,\
|
||||
metainfo/
|
||||
bin.excludes = WEB-INF/src/,\
|
||||
WEB-INF/web-2.5.xml
|
||||
jars.compile.order =
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ Copyright (C) 2007 Ashley G Ramdass (ADempiere WebUI).
|
|||
|
||||
<language>
|
||||
|
||||
<addon-name>ADempiere WebUI</addon-name>
|
||||
<addon-name>iDempiere</addon-name>
|
||||
|
||||
<language-name>xul/html</language-name>
|
||||
|
|
@ -20,6 +20,11 @@
|
|||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ds.core.builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
|
|
|
@ -97,7 +97,8 @@ Import-Package: bsh,
|
|||
org.codehaus.groovy.vmplugin,
|
||||
org.codehaus.groovy.vmplugin.v4,
|
||||
org.codehaus.groovy.vmplugin.v5,
|
||||
org.osgi.framework;version="1.3.0"
|
||||
org.osgi.framework;version="1.3.0",
|
||||
org.osgi.service.component;version="1.1.0"
|
||||
Bundle-ClassPath: .,
|
||||
lib/asm.jar,
|
||||
lib/cglib.jar,
|
||||
|
@ -952,3 +953,4 @@ Export-Package: Lib,
|
|||
Bundle-Activator: org.zkoss.zk.library.Activator
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Eclipse-BuddyPolicy: registered
|
||||
Service-Component: OSGI-INF/locatorRegistry.xml
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
<?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>
|
|
@ -1,4 +1,3 @@
|
|||
source.. = src/
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.,\
|
||||
|
@ -15,7 +14,6 @@ bin.includes = META-INF/,\
|
|||
lib/junit.jar,\
|
||||
lib/jxl.jar,\
|
||||
lib/jython.jar,\
|
||||
lib/keylistener.jar,\
|
||||
lib/mvel.jar,\
|
||||
lib/ognl.jar,\
|
||||
lib/timelinez.jar,\
|
||||
|
@ -25,9 +23,10 @@ bin.includes = META-INF/,\
|
|||
lib/zhtml.jar,\
|
||||
lib/zk.jar,\
|
||||
lib/zkplus.jar,\
|
||||
lib/zml.jar,\
|
||||
lib/zul.jar,\
|
||||
lib/zweb.jar,\
|
||||
lib/ckez.jar,\
|
||||
lib/zel.jar,\
|
||||
lib/zkbind.jar
|
||||
lib/zkbind.jar,\
|
||||
OSGI-INF/
|
||||
source.. = src/
|
||||
|
|
|
@ -57,22 +57,43 @@ public class ClassLocator implements XMLResourcesLocator {
|
|||
|
||||
//XMLResourcesLocator//
|
||||
public Enumeration<URL> getResources(String name) throws IOException {
|
||||
List<URL> list = null;
|
||||
name = resolveName(name);
|
||||
if (Activator.getContext() != null) {
|
||||
final Enumeration<URL> en = Activator.getContext().getBundle().getResources(name);
|
||||
if (en != null && en.hasMoreElements()) return en;
|
||||
if (en != null && en.hasMoreElements())
|
||||
list = Collections.list(en);
|
||||
}
|
||||
ClassLoader cl = Thread.currentThread().getContextClassLoader();
|
||||
if (cl != null) {
|
||||
final Enumeration<URL> en = cl.getResources(name);
|
||||
if (en.hasMoreElements()) return en;
|
||||
if (list == null) {
|
||||
ClassLoader cl = Thread.currentThread().getContextClassLoader();
|
||||
if (cl != null) {
|
||||
final Enumeration<URL> en = cl.getResources(name);
|
||||
if (en.hasMoreElements())
|
||||
list = Collections.list(en);
|
||||
}
|
||||
}
|
||||
cl = ClassLocator.class.getClassLoader();
|
||||
if (cl != null) {
|
||||
final Enumeration<URL> en = cl.getResources(name);
|
||||
if (en.hasMoreElements()) return en;
|
||||
if (list == null) {
|
||||
ClassLoader cl = ClassLocator.class.getClassLoader();
|
||||
if (cl != null) {
|
||||
final Enumeration<URL> en = cl.getResources(name);
|
||||
if (en.hasMoreElements())
|
||||
list = Collections.list(en);
|
||||
}
|
||||
}
|
||||
return ClassLoader.getSystemResources(name);
|
||||
if (list == null) {
|
||||
final Enumeration<URL> en = ClassLoader.getSystemResources(name);
|
||||
list = Collections.list(en);
|
||||
}
|
||||
List<IResourceLocator> locators = ResourceLocatorRegistry.getLocators();
|
||||
if (locators != null) {
|
||||
for (IResourceLocator locator : locators) {
|
||||
URL url = locator.getResource(name);
|
||||
if (url != null) {
|
||||
list.add(url);
|
||||
}
|
||||
}
|
||||
}
|
||||
return Collections.enumeration(list);
|
||||
}
|
||||
public List<Resource> getDependentXMLResources(String name, String elName,
|
||||
String elDepends) throws IOException {
|
||||
|
@ -84,6 +105,11 @@ public class ClassLocator implements XMLResourcesLocator {
|
|||
if (old != null)
|
||||
log.warning("Replicate resource: "+xr.name
|
||||
+"\nOverwrite "+old.url+"\nwith "+xr.url);
|
||||
else {
|
||||
if (log.infoable()) {
|
||||
log.info(xr);
|
||||
}
|
||||
}
|
||||
//it is possible if zcommon.jar is placed in both
|
||||
//WEB-INF/lib and shared/lib, i.e., appear twice in the class path
|
||||
//We overwrite because the order is the parent class loader first
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
/******************************************************************************
|
||||
* Copyright (C) 2012 Heng Sin Low *
|
||||
* Copyright (C) 2012 Trek Global *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* 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;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author hengsin
|
||||
*
|
||||
*/
|
||||
public interface IResourceLocator {
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* @return resource url
|
||||
*/
|
||||
public URL getResource(String name);
|
||||
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
/******************************************************************************
|
||||
* Copyright (C) 2012 Heng Sin Low *
|
||||
* Copyright (C) 2012 Trek Global *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* 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;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author hengsin
|
||||
*
|
||||
*/
|
||||
public class ResourceLocatorRegistry {
|
||||
|
||||
private List<IResourceLocator> locators = new ArrayList<IResourceLocator>();
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param locator
|
||||
*/
|
||||
public synchronized void removeLocator(IResourceLocator locator) {
|
||||
locators.remove(locator);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list of resource locator
|
||||
*/
|
||||
public synchronized static List<IResourceLocator> getLocators() {
|
||||
return INSTANCE != null ? INSTANCE.locators : null;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue