mirror of
https://gitee.com/jmix/cuba.git
synced 2024-12-02 19:27:57 +08:00
- ResourceRepository improved
- action-config.xml & menu-config.xml moved into ResourceRepository
This commit is contained in:
parent
e64d86b99c
commit
a095a26d73
@ -6,7 +6,8 @@
|
||||
<property name="root.dir" location="${project.dir}/.."/>
|
||||
|
||||
<property name="src-serv.dir" location="src-serv"/>
|
||||
|
||||
<property name="src-conf.dir" location="src-conf"/>
|
||||
|
||||
<property name="module.name" value="core"/>
|
||||
<property name="module.jar" value="20cuba-core.jar"/>
|
||||
<property name="module.global.jar" value="cuba-core-global.jar"/>
|
||||
@ -58,6 +59,7 @@
|
||||
|
||||
<target name="build-module" depends="compile-module">
|
||||
<echo>==> building ${project.dir} ${module.name}</echo>
|
||||
|
||||
<mkdir dir="${build.dir}"/>
|
||||
<jar basedir="${prod.out.dir}/${module.name}" destfile="${build.dir}/${module.jar}">
|
||||
<exclude name="**/entity/*"/>
|
||||
@ -70,14 +72,23 @@
|
||||
<jar basedir="${test.out.dir}/${module.name}" destfile="${build.dir}/${module.test.jar}">
|
||||
<include name="**/*"/>
|
||||
</jar>
|
||||
|
||||
<copy file="src-serv/${module.service.xml}" todir="${build.dir}"/>
|
||||
<copy file="src-serv/${module.ds.xml}" todir="${build.dir}"/>
|
||||
|
||||
<mkdir dir="${build.dir}/conf"/>
|
||||
<copy todir="${build.dir}/conf">
|
||||
<fileset dir="src-conf" includes="**/*"/>
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<target name="deploy-module" depends="base-mod.deploy-module">
|
||||
<copy file="${build.dir}/${module.global.jar}" todir="${jboss.dir}/server/default/deploy"/>
|
||||
<copy file="${build.dir}/${module.service.xml}" todir="${jboss.deploy.dir}"/>
|
||||
<copy file="${src-serv.dir}/${module.ds.xml}" todir="${jboss.deploy.dir}"/>
|
||||
<copy todir="${jboss.dir}/server/default/conf">
|
||||
<fileset dir="${build.dir}/conf" includes="**/*"/>
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<target name="undeploy-module" depends="base-mod.undeploy-module">
|
||||
|
11
modules/core/src-conf/cuba/permission-config.xml
Normal file
11
modules/core/src-conf/cuba/permission-config.xml
Normal file
@ -0,0 +1,11 @@
|
||||
<permission-config>
|
||||
|
||||
<specific>
|
||||
|
||||
<category name="sampleCategory" description="Sample Category">
|
||||
<permission name="samplePermission" description="Sample Permission"/>
|
||||
</category>
|
||||
|
||||
</specific>
|
||||
|
||||
</permission-config>
|
0
modules/core/src-conf/system.properties
Normal file
0
modules/core/src-conf/system.properties
Normal file
@ -18,6 +18,9 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
import java.util.Collections;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import com.haulmont.cuba.core.Locator;
|
||||
@ -38,7 +41,7 @@ public class ResourceRepository implements ResourceRepositoryMBean
|
||||
public void create() {
|
||||
String confUrl = System.getProperty("jboss.server.config.url");
|
||||
if (confUrl == null)
|
||||
throw new IllegalStateException("Evnironment variable jboss.server.config.url is not set");
|
||||
throw new IllegalStateException("Environment variable jboss.server.config.url is not set");
|
||||
rootPath = URI.create(confUrl).getPath() + "/";
|
||||
}
|
||||
|
||||
@ -46,6 +49,20 @@ public class ResourceRepository implements ResourceRepositoryMBean
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
List<String> list = new ArrayList<String>(repository.keySet());
|
||||
Collections.sort(list);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (String s : list) {
|
||||
sb.append(s).append("<br>");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public void evict(String name) {
|
||||
repository.remove(name);
|
||||
}
|
||||
|
||||
public void evictAll() {
|
||||
repository.clear();
|
||||
}
|
||||
|
@ -10,8 +10,6 @@
|
||||
*/
|
||||
package com.haulmont.cuba.core.app;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
public interface ResourceRepositoryMBean
|
||||
{
|
||||
String OBJECT_NAME = "haulmont.cuba:service=ResourceRepository";
|
||||
@ -20,19 +18,11 @@ public interface ResourceRepositoryMBean
|
||||
|
||||
ResourceRepository getImplementation();
|
||||
|
||||
String getContent();
|
||||
|
||||
void evict(String name);
|
||||
|
||||
void evictAll();
|
||||
|
||||
/**
|
||||
* Loads resource into cache as byte array and returns it
|
||||
* @param name resource file name relative to resources root (jboss/server/default/conf)
|
||||
* @return resource as stream
|
||||
*/
|
||||
InputStream getResAsStream(String name);
|
||||
|
||||
/**
|
||||
* Loads resource into cache as String and returns it
|
||||
* @param name resource file name relative to resources root (jboss/server/default/conf)
|
||||
* @return String resource
|
||||
*/
|
||||
String getResAsString(String name);
|
||||
}
|
||||
|
@ -18,27 +18,24 @@ import org.dom4j.DocumentException;
|
||||
import org.dom4j.Element;
|
||||
import org.dom4j.io.SAXReader;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
import java.io.StringReader;
|
||||
|
||||
public class ActionsConfig
|
||||
{
|
||||
private Log LOG = LogFactory.getLog(ActionsConfig.class);
|
||||
private Map<String, Map<String, Action>> actions = new HashMap<String, Map<String, Action>>();
|
||||
|
||||
public void loadConfig(String moduleName, ResourceBundle resourceBundle, InputStream stream) {
|
||||
if (stream == null)
|
||||
throw new NullPointerException("Null actions config");
|
||||
|
||||
public void loadConfig(String moduleName, ResourceBundle resourceBundle, String xml) {
|
||||
Map<String, Action> actions = new HashMap<String, Action>();
|
||||
|
||||
SAXReader reader = new SAXReader();
|
||||
Document doc;
|
||||
try {
|
||||
doc = reader.read(stream);
|
||||
doc = reader.read(new StringReader(xml));
|
||||
} catch (DocumentException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ import org.dom4j.Element;
|
||||
import org.dom4j.io.SAXReader;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.StringReader;
|
||||
import java.util.*;
|
||||
|
||||
import com.haulmont.cuba.core.global.ClientType;
|
||||
@ -51,11 +52,7 @@ public class MenuConfig
|
||||
return res;
|
||||
}
|
||||
|
||||
public void loadConfig(String moduleName, ActionsConfig actionsConfig, ResourceBundle resourceBundle, InputStream stream) {
|
||||
if (stream == null) {
|
||||
throw new NullPointerException("Null menu config");
|
||||
}
|
||||
|
||||
public void loadConfig(String moduleName, ActionsConfig actionsConfig, ResourceBundle resourceBundle, String xml) {
|
||||
rootItems.clear();
|
||||
|
||||
this.actionsConfig = actionsConfig;
|
||||
@ -64,7 +61,7 @@ public class MenuConfig
|
||||
SAXReader reader = new SAXReader();
|
||||
Document doc;
|
||||
try {
|
||||
doc = reader.read(stream);
|
||||
doc = reader.read(new StringReader(xml));
|
||||
} catch (DocumentException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
@ -23,17 +23,17 @@
|
||||
<fileset refid="server-lib-fs"/>
|
||||
</path>
|
||||
|
||||
<!--<target name="build-module" depends="base-mod.build-module">-->
|
||||
<!--<mkdir dir="${build.dir}/conf"/>-->
|
||||
<!--<copy todir="${build.dir}/conf">-->
|
||||
<!--<fileset dir="src-conf" includes="**/*"/>-->
|
||||
<!--</copy>-->
|
||||
<!--</target>-->
|
||||
<target name="build-module" depends="base-mod.build-module">
|
||||
<mkdir dir="${build.dir}/conf"/>
|
||||
<copy todir="${build.dir}/conf">
|
||||
<fileset dir="src-conf" includes="**/*"/>
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<!--<target name="deploy-module" depends="base-mod.deploy-module">-->
|
||||
<!--<copy todir="${jboss.dir}/server/default/conf">-->
|
||||
<!--<fileset dir="${build.dir}/conf" includes="**/*"/>-->
|
||||
<!--</copy>-->
|
||||
<!--</target>-->
|
||||
<target name="deploy-module" depends="base-mod.deploy-module">
|
||||
<copy todir="${jboss.dir}/server/default/conf">
|
||||
<fileset dir="${build.dir}/conf" includes="**/*"/>
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
</project>
|
@ -16,6 +16,7 @@ import com.haulmont.cuba.security.global.UserSession;
|
||||
import com.haulmont.cuba.web.log.AppLog;
|
||||
import com.haulmont.cuba.web.resource.Messages;
|
||||
import com.haulmont.cuba.core.global.ClientType;
|
||||
import com.haulmont.cuba.core.app.ResourceRepositoryService;
|
||||
import com.itmill.toolkit.Application;
|
||||
import com.itmill.toolkit.service.ApplicationContext;
|
||||
import com.itmill.toolkit.terminal.Terminal;
|
||||
@ -102,12 +103,14 @@ public class App extends Application implements ConnectionListener
|
||||
return actionConfig;
|
||||
}
|
||||
|
||||
protected InputStream getActionsConfigXml() {
|
||||
return getClass().getResourceAsStream("/com/haulmont/cuba/web/app/config/action-config.xml");
|
||||
protected String getActionsConfigXml() {
|
||||
ResourceRepositoryService rrs = ServiceLocator.lookup(ResourceRepositoryService.JNDI_NAME);
|
||||
return rrs.getResAsString("cuba/client/web/action-config.xml");
|
||||
}
|
||||
|
||||
protected InputStream getMenuConfigXml() {
|
||||
return getClass().getResourceAsStream("/com/haulmont/cuba/web/app/config/menu-config.xml");
|
||||
protected String getMenuConfigXml() {
|
||||
ResourceRepositoryService rrs = ServiceLocator.lookup(ResourceRepositoryService.JNDI_NAME);
|
||||
return rrs.getResAsString("cuba/client/web/menu-config.xml");
|
||||
}
|
||||
|
||||
protected ResourceBundle getResourceBundle() {
|
||||
|
Loading…
Reference in New Issue
Block a user