[jboss-svn-commits] JBL Code SVN: r32043 - in labs/jbossrules/branches/drools_server_camel_lucaz_baunax/drools-server: src/main/java/org/drools/server and 1 other directory.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Mar 11 14:23:16 EST 2010
Author: lucazamador
Date: 2010-03-11 14:23:15 -0500 (Thu, 11 Mar 2010)
New Revision: 32043
Modified:
labs/jbossrules/branches/drools_server_camel_lucaz_baunax/drools-server/pom.xml
labs/jbossrules/branches/drools_server_camel_lucaz_baunax/drools-server/src/main/java/org/drools/server/KnowledgeService.java
Log:
drool-server: dependencies removed, knowledge service improvements
Modified: labs/jbossrules/branches/drools_server_camel_lucaz_baunax/drools-server/pom.xml
===================================================================
--- labs/jbossrules/branches/drools_server_camel_lucaz_baunax/drools-server/pom.xml 2010-03-11 19:10:25 UTC (rev 32042)
+++ labs/jbossrules/branches/drools_server_camel_lucaz_baunax/drools-server/pom.xml 2010-03-11 19:23:15 UTC (rev 32043)
@@ -1,16 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <!-- README: if you have problems running the build.
- you may need to go up one directory, and run "mvn install" to
- make sure all the deps are ready.
- If by chance the slackers who maintain the other projects have left the build slight broken,
- you can skip the tests by doing:
-
- "mvn -Dmaven.test.skip=true install" and it should work.
-
- -->
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>drools</artifactId>
@@ -36,31 +27,10 @@
<artifactId>drools-vsm</artifactId>
<version>${project.version}</version>
</dependency>
- <!-- we are using the most excellent XStream library for fast XML and JSON streaming -->
<dependency>
- <groupId>com.thoughtworks.xstream</groupId>
- <artifactId>xstream</artifactId>
- </dependency>
- <dependency>
- <groupId>stax</groupId>
- <artifactId>stax</artifactId>
- <version>1.2.0</version>
- </dependency>
- <dependency>
- <groupId>org.codehaus.jettison</groupId>
- <artifactId>jettison</artifactId>
- <version>1.0.1</version>
- </dependency>
- <!-- pulling in compiler as we may have to deal with DRLs at some point -->
- <dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
</dependency>
- <!-- now the deps for the web app -->
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- </dependency>
<!-- CXF deps -->
<dependency>
<groupId>org.apache.cxf</groupId>
@@ -79,6 +49,7 @@
<version>3.1</version>
<scope>test</scope>
</dependency>
+
</dependencies>
</project>
Modified: labs/jbossrules/branches/drools_server_camel_lucaz_baunax/drools-server/src/main/java/org/drools/server/KnowledgeService.java
===================================================================
--- labs/jbossrules/branches/drools_server_camel_lucaz_baunax/drools-server/src/main/java/org/drools/server/KnowledgeService.java 2010-03-11 19:10:25 UTC (rev 32042)
+++ labs/jbossrules/branches/drools_server_camel_lucaz_baunax/drools-server/src/main/java/org/drools/server/KnowledgeService.java 2010-03-11 19:23:15 UTC (rev 32043)
@@ -34,6 +34,8 @@
import org.drools.server.profile.StartupCommandConverter;
import org.drools.vsm.ServiceManager;
import org.drools.vsm.local.ServiceManagerLocalClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
@@ -50,9 +52,8 @@
public class KnowledgeService {
private static final String PROFILE_FILENAME = "/profiles.xml";
+ private static final Logger LOG = LoggerFactory.getLogger(KnowledgeService.class);
- private static KnowledgeService instance;
-
private Map<String, KnowledgeBase> kbases = new ConcurrentHashMap<String, KnowledgeBase>();
private Map<String, JAXBContext> cachedJaxbContexts = new ConcurrentHashMap<String, JAXBContext>();
@@ -61,27 +62,28 @@
private ServiceManager serviceManager;
private ProducerTemplate template;
- public KnowledgeService() throws Exception {
+ private KnowledgeService() {
serviceManager = new ServiceManagerLocalClient();
- Context context = new JndiContext();
- context.bind("sm", serviceManager);
- camelContext = new DefaultCamelContext(context);
- camelContext.start();
- template = camelContext.createProducerTemplate();
- readKnowledgeContextProfiles();
+ try {
+ Context context = new JndiContext();
+ context.bind("sm", serviceManager);
+ camelContext = new DefaultCamelContext(context);
+ camelContext.start();
+ template = camelContext.createProducerTemplate();
+ readKnowledgeContextProfiles();
+ } catch (Exception e) {
+ LOG.error(e.getMessage());
+ }
}
- public static KnowledgeService getInstance() throws Exception {
- if (instance==null) {
- synchronized(KnowledgeService.class) {
- if (instance==null) {
- instance = new KnowledgeService();
- }
- }
- }
- return instance;
+ private static class SingletonHolder {
+ private static KnowledgeService uniqueInstance = new KnowledgeService();
}
+ public static final KnowledgeService getInstance() {
+ return SingletonHolder.uniqueInstance;
+ }
+
public KnowledgeContextProfile getContextProfile(String profileName) {
return profiles.getProfile(profileName);
}
@@ -103,7 +105,7 @@
String classNames[] = KnowledgeBuilderHelper.addXsdModel( ResourceFactory.newClassPathResource(modelFile.getFileName(), getClass()),
kbuilder,
xjcOpts,
- "xsd" );
+ "xsd" );
for (int i = 0; i < classNames.length; i++) {
allClassNames.add(classNames[i]);
}
@@ -143,7 +145,7 @@
throw new CheckedDroolsException("Bad session type. Expected stateless or stateful");
kbases.put(contextProfile.getId(), kbase);
-
+
createCamelRoutes(contextProfile);
// Execute the startups commands
@@ -217,8 +219,7 @@
} catch (Exception e) {
throw new CheckedDroolsException("Error getting lookup: " + e.getMessage(), e);
}
- String lookup = d.getDocumentElement().getAttribute("lookup");
- return lookup;
+ return d.getDocumentElement().getAttribute("lookup");
}
}
More information about the jboss-svn-commits
mailing list