Advertisement
Guest User

Untitled

a guest
May 22nd, 2017
343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 11.07 KB | None | 0 0
  1. Environment env = KnowledgeBaseFactory.newEnvironment();
  2. env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, Persistence
  3.         .createEntityManagerFactory("org.drools.persistence.jpa"));
  4. env.set(EnvironmentName.TRANSACTION_MANAGER, TransactionManagerServices
  5.         .getTransactionManager());
  6.  
  7. Properties ruleAgentProps = loadRuleAgentProperties();
  8.  
  9. KnowledgeBuilderConfiguration config = KnowledgeBuilderFactory
  10.         .newKnowledgeBuilderConfiguration(ruleAgentProps, null);
  11. KnowledgeBuilder kbuilder = KnowledgeBuilderFactory
  12.         .newKnowledgeBuilder(config);
  13. kbuilder.add(ResourceFactory.newClassPathResource("HelloWorld.drl"),
  14.         ResourceType.DRL);
  15. KnowledgeBuilderErrors errors = kbuilder.getErrors();
  16. if (errors.size() > 0) {
  17.     for (KnowledgeBuilderError error : errors) {
  18.         System.err.println(error);
  19.     }
  20.     throw new IllegalArgumentException("Could not parse knowledge.");
  21. }
  22.  
  23. KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
  24. kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
  25.  
  26. StatefulKnowledgeSession ksession = JPAKnowledgeService
  27.         .newStatefulKnowledgeSession(kbase, null, env);
  28. KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory
  29.         .newFileLogger(ksession, "test");
  30.  
  31. UserTransaction ut = (UserTransaction) new InitialContext()
  32.         .lookup("java:comp/UserTransaction");
  33. ut.begin();
  34.  
  35. Account account = new Account();
  36. account.setBalance(80);
  37. ksession.insert(account);
  38.  
  39. ksession.fireAllRules();
  40. logger.close();
  41.  
  42. ut.commit();
  43.  
  44. ####################################################
  45.  
  46. rule "basic rule"
  47.    
  48. when
  49.     Account( balance < 100 ) // condition
  50. then
  51.     System.out.println("Account balance is " +
  52.     "less than 100"); // consequence
  53.        
  54. end
  55.  
  56. ####################################################
  57.  
  58. 03/05/2010 10:17:38 org.hibernate.cfg.annotations.Version <clinit>
  59. INFO: Hibernate Annotations 3.4.0.GA
  60. 03/05/2010 10:17:38 org.hibernate.cfg.Environment <clinit>
  61. INFO: Hibernate 3.3.0.SP1
  62. 03/05/2010 10:17:38 org.hibernate.cfg.Environment <clinit>
  63. INFO: hibernate.properties not found
  64. 03/05/2010 10:17:38 org.hibernate.cfg.Environment buildBytecodeProvider
  65. INFO: Bytecode provider name : javassist
  66. 03/05/2010 10:17:38 org.hibernate.cfg.Environment <clinit>
  67. INFO: using JDK 1.4 java.sql.Timestamp handling
  68. 03/05/2010 10:17:38 org.hibernate.annotations.common.Version <clinit>
  69. INFO: Hibernate Commons Annotations 3.1.0.GA
  70. 03/05/2010 10:17:38 org.hibernate.ejb.Version <clinit>
  71. INFO: Hibernate EntityManager 3.4.0.GA
  72. 03/05/2010 10:17:38 org.hibernate.cfg.annotations.QueryBinder bindQuery
  73. INFO: Binding Named query: ProcessInstancesWaitingForEvent => select processInstanceInfo.processInstanceId from ProcessInstanceInfo processInstanceInfo where :type in elements(processInstanceInfo.eventTypes)
  74. 03/05/2010 10:17:38 org.hibernate.cfg.AnnotationBinder bindClass
  75. INFO: Binding entity from annotated class: org.drools.persistence.session.SessionInfo
  76. 03/05/2010 10:17:38 org.hibernate.cfg.annotations.EntityBinder bindTable
  77. INFO: Bind entity org.drools.persistence.session.SessionInfo on table SessionInfo
  78. 03/05/2010 10:17:38 org.hibernate.cfg.AnnotationBinder bindClass
  79. INFO: Binding entity from annotated class: org.drools.persistence.processinstance.ProcessInstanceInfo
  80. 03/05/2010 10:17:38 org.hibernate.cfg.annotations.EntityBinder bindTable
  81. INFO: Bind entity org.drools.persistence.processinstance.ProcessInstanceInfo on table ProcessInstanceInfo
  82. 03/05/2010 10:17:38 org.hibernate.cfg.AnnotationBinder bindClass
  83. INFO: Binding entity from annotated class: org.drools.persistence.processinstance.ProcessInstanceEventInfo
  84. 03/05/2010 10:17:38 org.hibernate.cfg.annotations.EntityBinder bindTable
  85. INFO: Bind entity org.drools.persistence.processinstance.ProcessInstanceEventInfo on table ProcessInstanceEventInfo
  86. 03/05/2010 10:17:38 org.hibernate.cfg.AnnotationBinder bindClass
  87. INFO: Binding entity from annotated class: org.drools.persistence.processinstance.WorkItemInfo
  88. 03/05/2010 10:17:38 org.hibernate.cfg.annotations.EntityBinder bindTable
  89. INFO: Bind entity org.drools.persistence.processinstance.WorkItemInfo on table WorkItemInfo
  90. 03/05/2010 10:17:38 org.hibernate.cfg.AnnotationConfiguration secondPassCompile
  91. INFO: Hibernate Validator not found: ignoring
  92. 03/05/2010 10:17:38 org.hibernate.cfg.search.HibernateSearchEventListenerRegister enableHibernateSearch
  93. INFO: Unable to find org.hibernate.search.event.FullTextIndexEventListener on the classpath. Hibernate Search is not enabled.
  94. 03/05/2010 10:17:38 org.hibernate.connection.DriverManagerConnectionProvider configure
  95. INFO: Using Hibernate built-in connection pool (not for production use!)
  96. 03/05/2010 10:17:38 org.hibernate.connection.DriverManagerConnectionProvider configure
  97. INFO: Hibernate connection pool size: 20
  98. 03/05/2010 10:17:38 org.hibernate.connection.DriverManagerConnectionProvider configure
  99. INFO: autocommit mode: true
  100. 03/05/2010 10:17:38 org.hibernate.connection.DriverManagerConnectionProvider configure
  101. INFO: using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost:3306/drools
  102. 03/05/2010 10:17:38 org.hibernate.connection.DriverManagerConnectionProvider configure
  103. INFO: connection properties: {user=root, password=****, autocommit=true, release_mode=auto}
  104. 03/05/2010 10:17:39 org.hibernate.cfg.SettingsFactory buildSettings
  105. INFO: RDBMS: MySQL, version: 5.1.45-community
  106. 03/05/2010 10:17:39 org.hibernate.cfg.SettingsFactory buildSettings
  107. INFO: JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-5.1.12 ( Revision: ${bzr.revision-id} )
  108. 03/05/2010 10:17:39 org.hibernate.dialect.Dialect <init>
  109. INFO: Using dialect: org.hibernate.dialect.MySQLDialect
  110. 03/05/2010 10:17:39 org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory
  111. INFO: Transaction strategy: org.hibernate.transaction.JDBCTransactionFactory
  112. 03/05/2010 10:17:39 org.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
  113. INFO: instantiating TransactionManagerLookup: org.hibernate.transaction.BTMTransactionManagerLookup
  114. 03/05/2010 10:17:39 org.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
  115. INFO: instantiated TransactionManagerLookup
  116. 03/05/2010 10:17:39 org.hibernate.cfg.SettingsFactory buildSettings
  117. INFO: Automatic flush during beforeCompletion(): disabled
  118. 03/05/2010 10:17:39 org.hibernate.cfg.SettingsFactory buildSettings
  119. INFO: Automatic session close at end of transaction: disabled
  120. 03/05/2010 10:17:39 org.hibernate.cfg.SettingsFactory buildSettings
  121. INFO: JDBC batch size: 15
  122. 03/05/2010 10:17:39 org.hibernate.cfg.SettingsFactory buildSettings
  123. INFO: JDBC batch updates for versioned data: disabled
  124. 03/05/2010 10:17:39 org.hibernate.cfg.SettingsFactory buildSettings
  125. INFO: Scrollable result sets: enabled
  126. 03/05/2010 10:17:39 org.hibernate.cfg.SettingsFactory buildSettings
  127. INFO: JDBC3 getGeneratedKeys(): enabled
  128. 03/05/2010 10:17:39 org.hibernate.cfg.SettingsFactory buildSettings
  129. INFO: Connection release mode: auto
  130. 03/05/2010 10:17:39 org.hibernate.cfg.SettingsFactory buildSettings
  131. INFO: Maximum outer join fetch depth: 2
  132. 03/05/2010 10:17:39 org.hibernate.cfg.SettingsFactory buildSettings
  133. INFO: Default batch fetch size: 1
  134. 03/05/2010 10:17:39 org.hibernate.cfg.SettingsFactory buildSettings
  135. INFO: Generate SQL with comments: disabled
  136. 03/05/2010 10:17:39 org.hibernate.cfg.SettingsFactory buildSettings
  137. INFO: Order SQL updates by primary key: disabled
  138. 03/05/2010 10:17:39 org.hibernate.cfg.SettingsFactory buildSettings
  139. INFO: Order SQL inserts for batching: disabled
  140. 03/05/2010 10:17:39 org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory
  141. INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
  142. 03/05/2010 10:17:39 org.hibernate.hql.ast.ASTQueryTranslatorFactory <init>
  143. INFO: Using ASTQueryTranslatorFactory
  144. 03/05/2010 10:17:39 org.hibernate.cfg.SettingsFactory buildSettings
  145. INFO: Query language substitutions: {}
  146. 03/05/2010 10:17:39 org.hibernate.cfg.SettingsFactory buildSettings
  147. INFO: JPA-QL strict compliance: enabled
  148. 03/05/2010 10:17:39 org.hibernate.cfg.SettingsFactory buildSettings
  149. INFO: Second-level cache: enabled
  150. 03/05/2010 10:17:39 org.hibernate.cfg.SettingsFactory buildSettings
  151. INFO: Query cache: disabled
  152. 03/05/2010 10:17:39 org.hibernate.cfg.SettingsFactory createRegionFactory
  153. INFO: Cache region factory : org.hibernate.cache.impl.NoCachingRegionFactory
  154. 03/05/2010 10:17:39 org.hibernate.cfg.SettingsFactory buildSettings
  155. INFO: Optimize cache for minimal puts: disabled
  156. 03/05/2010 10:17:39 org.hibernate.cfg.SettingsFactory buildSettings
  157. INFO: Structured second-level cache entries: disabled
  158. 03/05/2010 10:17:39 org.hibernate.cfg.SettingsFactory buildSettings
  159. INFO: Statistics: disabled
  160. 03/05/2010 10:17:39 org.hibernate.cfg.SettingsFactory buildSettings
  161. INFO: Deleted entity synthetic identifier rollback: disabled
  162. 03/05/2010 10:17:39 org.hibernate.cfg.SettingsFactory buildSettings
  163. INFO: Default entity-mode: pojo
  164. 03/05/2010 10:17:39 org.hibernate.cfg.SettingsFactory buildSettings
  165. INFO: Named query checking : enabled
  166. 03/05/2010 10:17:39 org.hibernate.impl.SessionFactoryImpl <init>
  167. INFO: building session factory
  168. 03/05/2010 10:17:39 org.hibernate.impl.SessionFactoryObjectFactory addInstance
  169. INFO: Not binding factory to JNDI, no JNDI name configured
  170. 03/05/2010 10:17:39 org.hibernate.tool.hbm2ddl.SchemaExport execute
  171. INFO: Running hbm2ddl schema export
  172. 03/05/2010 10:17:39 org.hibernate.tool.hbm2ddl.SchemaExport execute
  173. INFO: exporting generated schema to database
  174. 03/05/2010 10:17:39 org.hibernate.tool.hbm2ddl.SchemaExport execute
  175. INFO: schema export complete
  176. 03/05/2010 10:17:39 bitronix.tm.BitronixTransactionManager logVersion
  177. INFO: Bitronix Transaction Manager version 1.3.3
  178. 03/05/2010 10:17:39 bitronix.tm.Configuration buildServerIdArray
  179. WARNING: cannot get this JVM unique ID. Make sure it is configured and you only use ASCII characters. Will use IP address instead (unsafe for production usage!).
  180. 03/05/2010 10:17:39 bitronix.tm.Configuration buildServerIdArray
  181. INFO: JVM unique ID: <10.178.27.40>
  182. 03/05/2010 10:17:39 bitronix.tm.journal.DiskJournal open
  183. WARNING: active log file is unclean, previous server crash ?
  184. 03/05/2010 10:17:39 bitronix.tm.recovery.Recoverer run
  185. INFO: recovery committed 0 dangling transaction(s) and rolled back 0 aborted transaction(s) on 0 resource(s) [] (restricted to serverId '10.178.27.40')
  186. 03/05/2010 10:17:39 org.hibernate.impl.SessionFactoryImpl buildCurrentSessionContext
  187. WARNING: JTASessionContext being used with JDBCTransactionFactory; auto-flush will not operate correctly with getCurrentSession()
  188. 03/05/2010 10:17:42 org.hibernate.ejb.AbstractEntityManagerImpl joinTransaction
  189. WARNING: Calling joinTransaction() on a non JTA EntityManager
  190. 03/05/2010 10:17:42 bitronix.tm.twopc.Preparer prepare
  191. WARNING: executing transaction with 0 enlisted resource
  192. 03/05/2010 10:17:42 org.hibernate.ejb.AbstractEntityManagerImpl joinTransaction
  193. WARNING: Calling joinTransaction() on a non JTA EntityManager
  194. 03/05/2010 10:17:42 org.hibernate.ejb.AbstractEntityManagerImpl joinTransaction
  195. WARNING: Calling joinTransaction() on a non JTA EntityManager
  196. Account balance is less than 100
  197. 03/05/2010 10:17:42 bitronix.tm.twopc.Preparer prepare
  198. WARNING: executing transaction with 0 enlisted resource
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement