You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(233) |
Sep
(199) |
Oct
(206) |
Nov
(185) |
Dec
(270) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(232) |
Feb
(426) |
Mar
(623) |
Apr
(592) |
May
(506) |
Jun
(389) |
Jul
(160) |
Aug
(3) |
Sep
(1) |
Oct
(1) |
Nov
(2) |
Dec
(5) |
2007 |
Jan
(1) |
Feb
(1) |
Mar
(2) |
Apr
(2) |
May
(4) |
Jun
(2) |
Jul
|
Aug
(3) |
Sep
(5) |
Oct
(9) |
Nov
(6) |
Dec
(6) |
2008 |
Jan
(3) |
Feb
|
Mar
(1) |
Apr
(3) |
May
(3) |
Jun
(5) |
Jul
(10) |
Aug
(2) |
Sep
(12) |
Oct
(10) |
Nov
(54) |
Dec
(49) |
2009 |
Jan
(19) |
Feb
(13) |
Mar
(20) |
Apr
(24) |
May
(44) |
Jun
(29) |
Jul
(32) |
Aug
(10) |
Sep
(7) |
Oct
(10) |
Nov
(4) |
Dec
(17) |
2010 |
Jan
(14) |
Feb
(5) |
Mar
(23) |
Apr
(50) |
May
(31) |
Jun
(9) |
Jul
(5) |
Aug
(4) |
Sep
(7) |
Oct
(5) |
Nov
(2) |
Dec
(3) |
2011 |
Jan
(12) |
Feb
(5) |
Mar
(5) |
Apr
(3) |
May
(4) |
Jun
(3) |
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
2012 |
Jan
(1) |
Feb
(2) |
Mar
|
Apr
(1) |
May
(1) |
Jun
(2) |
Jul
(4) |
Aug
(1) |
Sep
|
Oct
(1) |
Nov
|
Dec
|
2013 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(2) |
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(3) |
Sep
|
Oct
|
Nov
|
Dec
(1) |
2015 |
Jan
|
Feb
|
Mar
(2) |
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2016 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <jbo...@li...> - 2006-01-17 15:07:34
|
Author: ste...@jb... Date: 2006-01-17 10:06:53 -0500 (Tue, 17 Jan 2006) New Revision: 2123 Added: trunk/labs/hibernate/jdbc-redesign/src/org/hibernate/jdbc3/impl/AbstractWorkspace.java trunk/labs/hibernate/jdbc-redesign/src/org/hibernate/jdbc3/impl/JDBCContainerImplementor.java trunk/labs/hibernate/jdbc-redesign/src/org/hibernate/tx/impl/ trunk/labs/hibernate/jdbc-redesign/src/org/hibernate/tx/impl/IsolatedWorkspace.java trunk/labs/hibernate/jdbc-redesign/src/org/hibernate/tx/impl/JDBCIsolationDelegate.java trunk/labs/hibernate/jdbc-redesign/src/org/hibernate/tx/impl/JTAIsolationDelegate.java Modified: trunk/labs/hibernate/jdbc-redesign/src/org/hibernate/jdbc3/impl/JDBCContainerImpl.java trunk/labs/hibernate/jdbc-redesign/src/org/hibernate/tx/IsolationDelegate.java Log: implemented initial doWorkInSeperateTransaction Added: trunk/labs/hibernate/jdbc-redesign/src/org/hibernate/jdbc3/impl/AbstractWorkspace.java =================================================================== --- trunk/labs/hibernate/jdbc-redesign/src/org/hibernate/jdbc3/impl/AbstractWorkspace.java 2006-01-17 12:14:24 UTC (rev 2122) +++ trunk/labs/hibernate/jdbc-redesign/src/org/hibernate/jdbc3/impl/AbstractWorkspace.java 2006-01-17 15:06:53 UTC (rev 2123) @@ -0,0 +1,128 @@ +package org.hibernate.jdbc3.impl; + +import org.hibernate.jdbc3.Workspace; +import org.hibernate.jdbc3.util.SQLStatementLogger; +import org.hibernate.dialect.Dialect; +import org.hibernate.JDBCException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.util.HashSet; +import java.util.Iterator; +import java.sql.SQLException; +import java.sql.PreparedStatement; +import java.sql.ResultSet; + +/** + * @author Steve Ebersole + */ +public abstract class AbstractWorkspace implements Workspace { + + private static final Log log = LogFactory.getLog( AbstractWorkspace.class ); + + protected final JDBCContainerImplementor container; + protected final HashSet registeredStatements = new HashSet(); + protected final HashSet registeredResultSets = new HashSet(); + + public AbstractWorkspace(JDBCContainerImplementor container) { + this.container = container; + opened(); + log.debug( "Opened workspace [" + this + "]" ); + } + + protected void opened() { + } + + protected void closed() { + } + + public final Dialect getDialect() { + return container.getDialect(); + } + + public final SQLStatementLogger getSqlLogger() { + return container.getStatementLogger(); + } + + public final JDBCException convert(SQLException sqlException, String message) { + return container.convert( sqlException, message ); + } + + public final JDBCException convert(SQLException sqlException, String message, String sql) { + return container.convert( sqlException, message, sql ); + } + + public final void register(PreparedStatement statement) { + log.trace( "registering prepared statement [" + statement + "]" ); + registeredStatements.add( statement ); + } + + public final void release(PreparedStatement statement) { + log.trace( "releasing prepared statement [" + statement + "]" ); + registeredStatements.remove( statement ); + close( statement ); + } + + public final void register(ResultSet resultSet) { + log.trace( "registering result set [" + resultSet + "]" ); + registeredResultSets.add( resultSet ); + } + + public final void release(ResultSet resultSet) { + log.trace( "releasing result set [" + resultSet + "]" ); + registeredResultSets.remove( resultSet ); + close( resultSet ); + } + + protected final void close(PreparedStatement statement) { + log.trace( "closing prepared statement [" + statement + "]" ); + try { + // if we are unable to "clean" the prepared statement, + // we do not close it + try { + if ( statement.getMaxRows() != 0 ) { + statement.setMaxRows( 0 ); + } + if ( statement.getQueryTimeout() != 0 ) { + statement.setQueryTimeout( 0 ); + } + } + catch( SQLException sqle ) { + // there was a problem "cleaning" the prepared statement + log.debug( "Exception clearing maxRows/queryTimeout [" + sqle.getMessage() + "]" ); + return; // EARLY EXIT!!! + } + statement.close(); + } + catch( SQLException sqle ) { + log.debug( "Unable to release statement [" + sqle.getMessage() + "]" ); + } + } + + protected final void close(ResultSet resultSet) { + log.trace( "closing result set [" + resultSet + "]" ); + try { + resultSet.close(); + } + catch( SQLException e ) { + log.debug( "Unable to release result set [" + e.getMessage() + "]" ); + } + } + + public final void close() { + log.trace( "closing workspace [" + this + "]" ); + Iterator iter = registeredResultSets.iterator(); + while ( iter.hasNext() ) { + close( ( ResultSet ) iter.next() ); + } + registeredResultSets.clear(); + + iter = registeredStatements.iterator(); + while ( iter.hasNext() ) { + close( ( PreparedStatement ) iter.next() ); + } + registeredStatements.clear(); + + closed(); + } +} Modified: trunk/labs/hibernate/jdbc-redesign/src/org/hibernate/jdbc3/impl/JDBCContainerImpl.java =================================================================== --- trunk/labs/hibernate/jdbc-redesign/src/org/hibernate/jdbc3/impl/JDBCContainerImpl.java 2006-01-17 12:14:24 UTC (rev 2122) +++ trunk/labs/hibernate/jdbc-redesign/src/org/hibernate/jdbc3/impl/JDBCContainerImpl.java 2006-01-17 15:06:53 UTC (rev 2123) @@ -29,7 +29,7 @@ /** * @author Steve Ebersole */ -public class JDBCContainerImpl implements JDBCContainer, Serializable { +public class JDBCContainerImpl implements JDBCContainer, JDBCContainerImplementor, Serializable { // TODO : workspace registration at a higher level: // would love to explore the idea of being able to register a workspace at a @@ -94,13 +94,10 @@ } public void doWorkInSeperateTransaction(Work work) throws HibernateException { - IsolatedWorkspaceImpl workspace = new IsolatedWorkspaceImpl(); - try { - transactionCoordinator.getIsolationDelegate().doWorkInIsolation( work, workspace ); + if ( !work.isConcise() ) { + throw new HibernateException( "non-concise work cannot be done in seperate transaction" ); } - finally { - workspace.close(); - } + transactionCoordinator.getIsolationDelegate().doWorkInIsolation( work, this ); } public void release(Work work) { @@ -117,8 +114,25 @@ } } - // SQLException conversion methods (convenience) ~~~~~~~~~~~~~~~~~~~~~~~~~~ + // JDBCContainerImplementor impl ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + public Dialect getDialect() { + return dialect; + } + + public SQLStatementLogger getStatementLogger() { + return sqlStatementLogger; + } + + public ConnectionProvider getConnectionProvider() { + return connectionProvider; + } + + public StatisticsImplementor getStatistics() { + return stats; + } + public JDBCException convert(SQLException sqle, String message) { return JDBCExceptionHelper.convert( sqlExceptionConverter, sqle, message ); } @@ -214,151 +228,14 @@ } - // Workspace impls ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // Workspace impl ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - public abstract class AbstractWorkspaceImpl implements Workspace { - - protected final HashSet registeredStatements = new HashSet(); - protected final HashSet registeredResultSets = new HashSet(); - - public AbstractWorkspaceImpl() { - log.debug( "Opening workspace [" + this + "]" ); - opened(); + public class WorkspaceImpl extends AbstractWorkspace implements Workspace { + public WorkspaceImpl() { + super( JDBCContainerImpl.this ); } - protected void opened() { - } - - protected void closed() { - } - - public final Dialect getDialect() { - return JDBCContainerImpl.this.dialect; - } - - public final SQLStatementLogger getSqlLogger() { - return JDBCContainerImpl.this.sqlStatementLogger; - } - - public final JDBCException convert(SQLException sqlException, String message) { - return JDBCContainerImpl.this.convert( sqlException, message ); - } - - public final JDBCException convert(SQLException sqlException, String message, String sql) { - return JDBCContainerImpl.this.convert( sqlException, message, sql ); - } - - public final void register(PreparedStatement statement) { - log.trace( "registering prepared statement [" + statement + "]" ); - registeredStatements.add( statement ); - } - - public final void release(PreparedStatement statement) { - log.trace( "releasing prepared statement [" + statement + "]" ); - registeredStatements.remove( statement ); - close( statement ); - } - - public final void register(ResultSet resultSet) { - log.trace( "registering result set [" + resultSet + "]" ); - registeredResultSets.add( resultSet ); - } - - public final void release(ResultSet resultSet) { - log.trace( "releasing result set [" + resultSet + "]" ); - registeredResultSets.remove( resultSet ); - close( resultSet ); - } - - protected final void close(PreparedStatement statement) { - log.trace( "closing prepared statement [" + statement + "]" ); - try { - // if we are unable to "clean" the prepared statement, - // we do not close it - try { - if ( statement.getMaxRows() != 0 ) { - statement.setMaxRows( 0 ); - } - if ( statement.getQueryTimeout() != 0 ) { - statement.setQueryTimeout( 0 ); - } - } - catch( SQLException sqle ) { - // there was a problem "cleaning" the prepared statement - log.debug( "Exception clearing maxRows/queryTimeout [" + sqle.getMessage() + "]" ); - return; // EARLY EXIT!!! - } - statement.close(); - } - catch( SQLException sqle ) { - log.debug( "Unable to release statement [" + sqle.getMessage() + "]" ); - } - } - - protected final void close(ResultSet resultSet) { - log.trace( "closing result set [" + resultSet + "]" ); - try { - resultSet.close(); - } - catch( SQLException e ) { - log.debug( "Unable to release result set [" + e.getMessage() + "]" ); - } - } - - public final void close() { - log.trace( "closing workspace [" + this + "]" ); - Iterator iter = registeredResultSets.iterator(); - while ( iter.hasNext() ) { - close( ( ResultSet ) iter.next() ); - } - registeredResultSets.clear(); - - iter = registeredStatements.iterator(); - while ( iter.hasNext() ) { - close( ( PreparedStatement ) iter.next() ); - } - registeredStatements.clear(); - - closed(); - } - } - - public class IsolatedWorkspaceImpl extends AbstractWorkspaceImpl implements Workspace { - private Connection connection; - public Connection getConnection() { - return connection; - } - - public void prepare() { - try { - connection = connectionProvider.getConnection(); - log.debug( "obtained JDBC connection for isolated work" ); - if ( stats != null ) { - stats.connect(); - } - } - catch( SQLException sqle ) { - throw convert( sqle, "Unable to obtain JDBC connection for isolated work" ); - } - } - - public void release() { - try { - connectionProvider.closeConnection( connection ); - log.debug( "released JDBC connection for isolated work" ); - } - catch( SQLException sqle ) { - log.trace( "unable to release connection on exception [" + sqle + "]" ); - } - finally { - connection = null; - } - } - } - - public class WorkspaceImpl extends AbstractWorkspaceImpl implements Workspace { - public Connection getConnection() { return JDBCContainerImpl.this.getLogicalConnection().getConnection(); } Added: trunk/labs/hibernate/jdbc-redesign/src/org/hibernate/jdbc3/impl/JDBCContainerImplementor.java =================================================================== --- trunk/labs/hibernate/jdbc-redesign/src/org/hibernate/jdbc3/impl/JDBCContainerImplementor.java 2006-01-17 12:14:24 UTC (rev 2122) +++ trunk/labs/hibernate/jdbc-redesign/src/org/hibernate/jdbc3/impl/JDBCContainerImplementor.java 2006-01-17 15:06:53 UTC (rev 2123) @@ -0,0 +1,23 @@ +package org.hibernate.jdbc3.impl; + +import org.hibernate.jdbc3.JDBCContainer; +import org.hibernate.jdbc3.util.SQLStatementLogger; +import org.hibernate.dialect.Dialect; +import org.hibernate.connection.ConnectionProvider; +import org.hibernate.stat.StatisticsImplementor; +import org.hibernate.JDBCException; + +import java.sql.SQLException; + +/** + * @author Steve Ebersole + */ +public interface JDBCContainerImplementor extends JDBCContainer { + public Dialect getDialect(); + public SQLStatementLogger getStatementLogger(); + public ConnectionProvider getConnectionProvider(); + public StatisticsImplementor getStatistics(); + + public JDBCException convert(SQLException sqle, String message); + public JDBCException convert(SQLException sqle, String message, String sql); +} Modified: trunk/labs/hibernate/jdbc-redesign/src/org/hibernate/tx/IsolationDelegate.java =================================================================== --- trunk/labs/hibernate/jdbc-redesign/src/org/hibernate/tx/IsolationDelegate.java 2006-01-17 12:14:24 UTC (rev 2122) +++ trunk/labs/hibernate/jdbc-redesign/src/org/hibernate/tx/IsolationDelegate.java 2006-01-17 15:06:53 UTC (rev 2123) @@ -1,11 +1,11 @@ package org.hibernate.tx; import org.hibernate.jdbc3.Work; -import org.hibernate.jdbc3.impl.JDBCContainerImpl; +import org.hibernate.jdbc3.impl.JDBCContainerImplementor; /** * @author Steve Ebersole */ public interface IsolationDelegate { - public void doWorkInIsolation(Work work, JDBCContainerImpl.IsolatedWorkspaceImpl workspace); + public void doWorkInIsolation(Work work, JDBCContainerImplementor container); } Added: trunk/labs/hibernate/jdbc-redesign/src/org/hibernate/tx/impl/IsolatedWorkspace.java =================================================================== --- trunk/labs/hibernate/jdbc-redesign/src/org/hibernate/tx/impl/IsolatedWorkspace.java 2006-01-17 12:14:24 UTC (rev 2122) +++ trunk/labs/hibernate/jdbc-redesign/src/org/hibernate/tx/impl/IsolatedWorkspace.java 2006-01-17 15:06:53 UTC (rev 2123) @@ -0,0 +1,22 @@ +package org.hibernate.tx.impl; + +import org.hibernate.jdbc3.impl.AbstractWorkspace; +import org.hibernate.jdbc3.impl.JDBCContainerImplementor; + +import java.sql.Connection; + +/** + * @author Steve Ebersole + */ +public class IsolatedWorkspace extends AbstractWorkspace { + private final Connection connection; + + public IsolatedWorkspace(JDBCContainerImplementor container, Connection connection) { + super( container ); + this.connection = connection; + } + + public Connection getConnection() { + return connection; + } +} Added: trunk/labs/hibernate/jdbc-redesign/src/org/hibernate/tx/impl/JDBCIsolationDelegate.java =================================================================== --- trunk/labs/hibernate/jdbc-redesign/src/org/hibernate/tx/impl/JDBCIsolationDelegate.java 2006-01-17 12:14:24 UTC (rev 2122) +++ trunk/labs/hibernate/jdbc-redesign/src/org/hibernate/tx/impl/JDBCIsolationDelegate.java 2006-01-17 15:06:53 UTC (rev 2123) @@ -0,0 +1,77 @@ +package org.hibernate.tx.impl; + +import org.hibernate.tx.IsolationDelegate; +import org.hibernate.jdbc3.Work; +import org.hibernate.jdbc3.impl.JDBCContainerImplementor; +import org.hibernate.HibernateException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import java.sql.Connection; +import java.sql.SQLException; + +/** + * @author Steve Ebersole + */ +public class JDBCIsolationDelegate implements IsolationDelegate { + + private static final Log log = LogFactory.getLog( JDBCIsolationDelegate.class ); + + public void doWorkInIsolation(Work work, JDBCContainerImplementor container) { + Connection connection = null; + boolean wasAutoCommit = false; + try { + connection = container.getConnectionProvider().getConnection(); + if ( connection.getAutoCommit() ) { + wasAutoCommit = true; + connection.setAutoCommit( false ); + } + + IsolatedWorkspace workspace = new IsolatedWorkspace( container, connection ); + try { + work.performWork( workspace ); + } + finally { + workspace.close(); + } + + connection.commit(); + } + catch( Throwable t ) { + try { + if ( connection!= null && !connection.isClosed() ) { + connection.rollback(); + } + } + catch( Throwable ignore ) { + log.trace( "unable to release connection on exception [" + ignore + "]" ); + } + + if ( t instanceof HibernateException ) { + throw ( HibernateException ) t; + } + else if ( t instanceof SQLException ) { + throw container.convert( ( SQLException ) t, "error performing isolated work" ); + } + else { + throw new HibernateException( "error performing isolated work", t ); + } + } + finally { + if ( wasAutoCommit ) { + try { + connection.setAutoCommit( true ); + } + catch( Throwable ignore ) { + log.trace( "was unable to reset connection back to auto-commit" ); + } + } + try { + container.getConnectionProvider().closeConnection( connection ); + } + catch( Throwable ignore ) { + log.info( "unable to release connection obtained for isolated work : " + ignore ); + } + } + } +} Added: trunk/labs/hibernate/jdbc-redesign/src/org/hibernate/tx/impl/JTAIsolationDelegate.java =================================================================== --- trunk/labs/hibernate/jdbc-redesign/src/org/hibernate/tx/impl/JTAIsolationDelegate.java 2006-01-17 12:14:24 UTC (rev 2122) +++ trunk/labs/hibernate/jdbc-redesign/src/org/hibernate/tx/impl/JTAIsolationDelegate.java 2006-01-17 15:06:53 UTC (rev 2123) @@ -0,0 +1,101 @@ +package org.hibernate.tx.impl; + +import org.hibernate.tx.IsolationDelegate; +import org.hibernate.jdbc3.Work; +import org.hibernate.jdbc3.impl.JDBCContainerImplementor; +import org.hibernate.HibernateException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import javax.transaction.TransactionManager; +import javax.transaction.Transaction; +import java.sql.Connection; + +/** + * @author Steve Ebersole + */ +public class JTAIsolationDelegate implements IsolationDelegate { + + private static final Log log = LogFactory.getLog( JTAIsolationDelegate.class ); + + private final TransactionManager transactionManager; + + public JTAIsolationDelegate(TransactionManager transactionManager) { + this.transactionManager = transactionManager; + } + + public void doWorkInIsolation(Work work, JDBCContainerImplementor container) { + Transaction surroundingTransaction = null; + Connection connection = null; + boolean caughtException = false; + + try { + // First we need to suspend any current JTA transaction and obtain + // a JDBC connection + surroundingTransaction = transactionManager.suspend(); + if ( log.isDebugEnabled() ) { + log.debug( "surrounding JTA transaction suspended [" + surroundingTransaction + "]" ); + } + transactionManager.begin(); + connection = container.getConnectionProvider().getConnection(); + + // perform the actual work + IsolatedWorkspace workspace = new IsolatedWorkspace( container, connection ); + try { + work.performWork( workspace ); + } + finally { + workspace.close(); + } + + // if everything went ok, commit the transaction and close the obtained + // connection handle... + container.getConnectionProvider().closeConnection( connection ); + transactionManager.commit(); + } + catch( Throwable t ) { + // at some point the processing went bad, so we need to: + // 1) make sure the connection handle gets released + // 2) try to cleanup the JTA context as much as possible + caughtException = true; + try { + if ( connection != null && !connection.isClosed() ) { + container.getConnectionProvider().closeConnection( connection ); + } + } + catch( Throwable ignore ) { + log.trace( "unable to release connection on exception [" + ignore + "]" ); + } + try { + transactionManager.rollback(); + } + catch( Throwable ignore ) { + log.trace( "unable to rollback new transaction on exception [" + ignore + "]" ); + } + + // finally handle the exception + if ( t instanceof HibernateException ) { + throw ( HibernateException ) t; + } + else { + throw new HibernateException( "error performing isolated work", t ); + } + } + finally { + if ( surroundingTransaction != null ) { + try { + transactionManager.resume( surroundingTransaction ); + if ( log.isDebugEnabled() ) { + log.debug( "surrounding JTA transaction resumed [" + surroundingTransaction + "]" ); + } + } + catch( Throwable t ) { + if ( !caughtException ) { + new HibernateException( "unable to resume previously suspended transaction", t ); + } + } + } + } + } + +} |
From: <jbo...@li...> - 2006-01-17 12:14:31
|
Author: mic...@jb... Date: 2006-01-17 07:14:24 -0500 (Tue, 17 Jan 2006) New Revision: 2122 Modified: trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/IntegrationTest.java Log: more tests Modified: trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/IntegrationTest.java =================================================================== --- trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/IntegrationTest.java 2006-01-17 12:05:06 UTC (rev 2121) +++ trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/IntegrationTest.java 2006-01-17 12:14:24 UTC (rev 2122) @@ -139,14 +139,17 @@ //lets add a rule to it (making 3 rules in total) ruleSet.addRule(new RuleDef("Integration rule 3", "content")); + repo.save(ruleSet); //lets load up the old version, check that there is still only 2 rules ruleSet = repo.loadRuleSet("Integration ruleset 1", 1); assertEquals(2, ruleSet.getRules().size()); assertEquals("draft", ruleSet.getVersionInfoWorking().getStatus()); - + //ooh look, the new one has 3, and they are all different rules ! + assertEquals(3, repo.loadRuleSet("Integration ruleset 1", 2).getRules().size()); + repo.close(); } |
From: <jbo...@li...> - 2006-01-17 12:05:19
|
Author: mic...@jb... Date: 2006-01-17 07:05:06 -0500 (Tue, 17 Jan 2006) New Revision: 2121 Modified: trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RuleSetDef.java trunk/labs/jbossrules/drools-repository/src/main/resources/org/drools/repository/RuleSetDef.hbm.xml Log: wording corrections Modified: trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RuleSetDef.java =================================================================== --- trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RuleSetDef.java 2006-01-17 11:59:10 UTC (rev 2120) +++ trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RuleSetDef.java 2006-01-17 12:05:06 UTC (rev 2121) @@ -96,7 +96,9 @@ this.applicationData ); } - /** Find the current working version info. */ + /** + * Find the current working version info. + * This includes the status of this version of the ruleset. */ public RuleSetVersionInfo getVersionInfoWorking() { for ( Iterator iter = this.versionHistory.iterator(); iter.hasNext(); ) { RuleSetVersionInfo info = (RuleSetVersionInfo) iter.next(); Modified: trunk/labs/jbossrules/drools-repository/src/main/resources/org/drools/repository/RuleSetDef.hbm.xml =================================================================== --- trunk/labs/jbossrules/drools-repository/src/main/resources/org/drools/repository/RuleSetDef.hbm.xml 2006-01-17 11:59:10 UTC (rev 2120) +++ trunk/labs/jbossrules/drools-repository/src/main/resources/org/drools/repository/RuleSetDef.hbm.xml 2006-01-17 12:05:06 UTC (rev 2121) @@ -55,7 +55,7 @@ <filter name="workingVersionFilter" condition=":filteredVersionNumber = versionNumber" /> </set> - <set name="imports" lazy="false" table="RULESET_IMPORS" cascade="all" optimistic-lock="false"> + <set name="imports" lazy="false" table="RULESET_IMPORTS" cascade="all" optimistic-lock="false"> <key column="RULESET_ID"/> <one-to-many class="org.drools.repository.ImportDef"/> <filter name="workingVersionFilter" condition=":filteredVersionNumber = versionNumber" /> |
From: <jbo...@li...> - 2006-01-17 11:59:31
|
Author: mic...@jb... Date: 2006-01-17 06:59:10 -0500 (Tue, 17 Jan 2006) New Revision: 2120 Modified: trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RuleSetDef.java trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/IntegrationTest.java trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/RuleSetPersistenceTest.java Log: refactoring Modified: trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RuleSetDef.java =================================================================== --- trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RuleSetDef.java 2006-01-17 08:45:05 UTC (rev 2119) +++ trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RuleSetDef.java 2006-01-17 11:59:10 UTC (rev 2120) @@ -53,7 +53,7 @@ this.applicationData = new HashSet(); this.imports = new HashSet(); this.workingVersionNumber = 1; - this.versionHistory.add(new RuleSetVersionInfo(1, "New")); + addNewVersionHistory("new", "created"); } /** @@ -97,7 +97,7 @@ } /** Find the current working version info. */ - public RuleSetVersionInfo getCurrentVersionInfo() { + public RuleSetVersionInfo getVersionInfoWorking() { for ( Iterator iter = this.versionHistory.iterator(); iter.hasNext(); ) { RuleSetVersionInfo info = (RuleSetVersionInfo) iter.next(); if (info.getVersionNumber() == this.getWorkingVersionNumber()) { Modified: trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/IntegrationTest.java =================================================================== --- trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/IntegrationTest.java 2006-01-17 08:45:05 UTC (rev 2119) +++ trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/IntegrationTest.java 2006-01-17 11:59:10 UTC (rev 2120) @@ -26,9 +26,10 @@ */ public void testBootstrap() { runVersioningTests(); +// runAttachmentTests(); +// runConcurrentTests(); +// runLocalPersistTests(); - - } @@ -59,7 +60,7 @@ meta.setDescription("A test ruleset"); RuleSetDef ruleSet = new RuleSetDef("Integration ruleset 1", meta); - RuleSetVersionInfo info = ruleSet.getCurrentVersionInfo(); + RuleSetVersionInfo info = ruleSet.getVersionInfoWorking(); info.setStatus("draft"); //time to save it @@ -72,7 +73,7 @@ repo = RepositoryFactory.getStatefulRepository(); assertTrue(repo.listRuleSets().size() > 0); ruleSet = repo.loadRuleSet("Integration ruleset 1", 1); - assertEquals("draft", ruleSet.getCurrentVersionInfo().getStatus()); + assertEquals("draft", ruleSet.getVersionInfoWorking().getStatus()); //now lets work "disconnected" for a while repo.close(); @@ -132,8 +133,8 @@ repo = RepositoryFactory.getStatefulRepository(); ruleSet = repo.loadRuleSet("Integration ruleset 1", 2); assertEquals(2, ruleSet.getVersionHistory().size()); - assertEquals("New version", ruleSet.getCurrentVersionInfo().getVersionComment()); - assertEquals("pending", ruleSet.getCurrentVersionInfo().getStatus()); + assertEquals("New version", ruleSet.getVersionInfoWorking().getVersionComment()); + assertEquals("pending", ruleSet.getVersionInfoWorking().getStatus()); //lets add a rule to it (making 3 rules in total) @@ -143,7 +144,7 @@ //lets load up the old version, check that there is still only 2 rules ruleSet = repo.loadRuleSet("Integration ruleset 1", 1); assertEquals(2, ruleSet.getRules().size()); - assertEquals("draft", ruleSet.getCurrentVersionInfo().getStatus()); + assertEquals("draft", ruleSet.getVersionInfoWorking().getStatus()); repo.close(); Modified: trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/RuleSetPersistenceTest.java =================================================================== --- trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/RuleSetPersistenceTest.java 2006-01-17 08:45:05 UTC (rev 2119) +++ trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/RuleSetPersistenceTest.java 2006-01-17 11:59:10 UTC (rev 2120) @@ -323,7 +323,7 @@ public void testFindWorkingVersionInfo() { RuleSetDef ruleset = new RuleSetDef("nothing", null); - RuleSetVersionInfo info = ruleset.getCurrentVersionInfo(); + RuleSetVersionInfo info = ruleset.getVersionInfoWorking(); assertNotNull(info); assertEquals(1, info.getVersionNumber()); } |
From: <jbo...@li...> - 2006-01-17 08:45:11
|
Author: mla...@jb... Date: 2006-01-17 03:45:05 -0500 (Tue, 17 Jan 2006) New Revision: 2119 Modified: trunk/labs/jbosswebnp/src/windows/build.xml Log: Update version numbers. Modified: trunk/labs/jbosswebnp/src/windows/build.xml =================================================================== --- trunk/labs/jbosswebnp/src/windows/build.xml 2006-01-17 08:43:48 UTC (rev 2118) +++ trunk/labs/jbosswebnp/src/windows/build.xml 2006-01-17 08:45:05 UTC (rev 2119) @@ -16,8 +16,11 @@ <!-- Initialization properties --> <property name="name" value="JBoss.NET.Proxy"/> <property name="title" value="JBoss .NET Proxy Library"/> - <property name="version" value="1.0.0"/> - <property name="version.number" value="100"/> + <property name="version.major" value="1"/> + <property name="version.minor" value="0"/> + <property name="version.patch" value="0"/> + <property name="version" value="${version.major}.${version.minor}"/> + <property name="version.number" value="${version.major}${version.minor}${version.patch}"/> <property name="project" value="NET.mscoree"/> <property name="build.dir" value="./dist"/> <property name="build.src" value="${build.dir}/src"/> @@ -211,15 +214,13 @@ basedir="${build.dir}/bin/classes" excludes="**/*.java"> <manifest> - <section name="NET"> - <attribute name="Specification-Title" value="JBoss.NET.Proxy"/> - <attribute name="Specification-Version" value="${version}"/> - <attribute name="Specification-Vendor" value="JBoss Inc."/> - <attribute name="Implementation-Title" value="org.jboss.NET"/> - <attribute name="Implementation-Vendor" value="JBoss .NET Proxy"/> - <attribute name="Implementation-Vendor-Id" value="org.jboss"/> - <attribute name="Implementation-Version" value="${version} (build ${DSTAMP} ${TSTAMP})"/> - </section> + <attribute name="Specification-Title" value="JBoss .NET Core Proxy Library"/> + <attribute name="Specification-Version" value="${version}"/> + <attribute name="Specification-Vendor" value="JBoss, Inc."/> + <attribute name="Implementation-Title" value="JBoss .NET Core"/> + <attribute name="Implementation-Vendor" value="JBoss, Inc."/> + <attribute name="Implementation-Vendor-Id" value="org.jboss"/> + <attribute name="Implementation-Version" value="${version}.${version.patch}"/> </manifest> <metainf file="${src.dir}/LICENSE"> </metainf> |
From: <jbo...@li...> - 2006-01-17 08:43:54
|
Author: mla...@jb... Date: 2006-01-17 03:43:48 -0500 (Tue, 17 Jan 2006) New Revision: 2118 Added: trunk/labs/jbosswebnp/src/windows/native/build/ trunk/labs/jbosswebnp/src/windows/native/build/NMAKEcommon.inc trunk/labs/jbosswebnp/src/windows/native/build/baseaddr.ref trunk/labs/jbosswebnp/src/windows/native/build/jboss.ico trunk/labs/jbosswebnp/src/windows/native/build/resource.h Log: Initial checkin. Added: trunk/labs/jbosswebnp/src/windows/native/build/NMAKEcommon.inc =================================================================== --- trunk/labs/jbosswebnp/src/windows/native/build/NMAKEcommon.inc 2006-01-17 08:41:54 UTC (rev 2117) +++ trunk/labs/jbosswebnp/src/windows/native/build/NMAKEcommon.inc 2006-01-17 08:43:48 UTC (rev 2118) @@ -0,0 +1,335 @@ +# Copyright 2001-2005 The Apache Software Foundation or its licensors, as +# applicable. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ==================================================================== +# +# NMAKEcommon.inc Master makefile definitions. +# This file defines CPU architecture and basic compiler +# and linker parameters. +# Common params: +# CPU Compile for specified CPU. Supported CPU's are: +# i386 +# AMD64 +# IA64 +# If not specified it will default to the +# PROCESSOR_ARCHITECTURE environment variable +# or to the i386 if not specified. +# WINVER Compile for specified Windows version +# WINNT for Windows 2000 and up(default) +# WINXP for Windows XP and up +# WIN2003 for Windows 2003 and up +# Deprecated targets (may not even compile): +# NT4 for Windows NT4 and up +# WIN9X for Windows 95, 98 and Me +# BUILD Build version +# RETAIL or RELEASE (default) +# DEBUG +# TARGET Build application target +# EXE Console executable (default) +# GUI Windows GUI executable +# DLL Dynamic Link Library +# LIB Static library +# Environment variables used: +# CFLAGS Added to the common CFLAGS +# CPPFLAGS Added to the common CPPFLAGS +# LIBS Added to the common LIBS +# INCLUDES Added to the common INCLUDES +# LFLAGS Added to the common LFLAGS +# RCFLAGS Added to the common RCFLAGS +# +# Originally contributed by Mladen Turk <mturk jboss.com> +# +# ==================================================================== +# + +!IF !DEFINED(CC) || "$(CC)" == "" +CC = cl.exe +!ENDIF + +!IF !DEFINED(LINK) || "$(LINK)" == "" +LINK = link.exe +!ENDIF + +!IF !DEFINED(RC) || "$(RC)" == "" +RC = rc.exe +!ENDIF + +!IF !DEFINED(MT) || "$(MT)" == "" +MT = mt.exe +!ENDIF + +!IF !DEFINED(MKDIR) || "$(MKDIR)" == "" +MKDIR = -mkdir +!ENDIF + +# Read the PROCESSOR_ARCHITECTURE environment value for a CPU type + +!IF !DEFINED(CPU) || "$(CPU)" == "" +!IF "$(PROCESSOR_ARCHITECTURE)" == "" +CPU = I386 +!ELSE +CPU = $(PROCESSOR_ARCHITECTURE) +!ENDIF +!ENDIF + +!IF "$(CPU)" == "i386" || "$(CPU)" == "x86" || "$(CPU)" == "i486" || "$(CPU)" == "i586" || "$(CPU)" == "i686" +CPU = I386 +!ENDIF + +!IF "$(CPU)" == "X64" +FAVOR = "-favor:blend" +CPU = AMD64 +!ELSEIF "$(CPU)" == "AMD64" +FAVOR = "-favor:AMD64" +!ELSEIF "$(CPU)" == "EMT64" +FAVOR = "-favor:EMT64" +CPU = AMD64 +!ENDIF + +!IF "$(CPU)" != "I386" +!IF "$(CPU)" != "AMD64" +!IF "$(CPU)" != "IA64" +!ERROR Must specify CPU environment variable (I386, X64, AMD64, EMT64, IA64) +!ENDIF +!ENDIF +!ENDIF + +!IF !DEFINED(TARGET) || "$(TARGET)" == "" +TARGET=EXE +!ENDIF + +!IF "$(TARGET)" != "EXE" +!IF "$(TARGET)" != "GUI" +!IF "$(TARGET)" != "DLL" +!IF "$(TARGET)" != "LIB" +!ERROR Must specify TARGET environment variable (EXE, GUI, DLL, LIB) +!ENDIF +!ENDIF +!ENDIF +!ENDIF + +!IF !DEFINED(WINVER) || "$(WINVER)" == "" +WINVER=WINNT +!ENDIF + + +!IF "$(WINVER)" != "WINNT" +!IF "$(WINVER)" != "WINXP" +!IF "$(WINVER)" != "WIN2003" +!IF "$(WINVER)" != "NT4" +!IF "$(WINVER)" != "WIN9X" +!ERROR Must specify WINVER environment variable (WINNT, WINXP, WIN2003, NT4, WIN9X) +!ENDIF +!ENDIF +!ENDIF +!ENDIF +!ENDIF + +!IF "$(WINVER)" == "WINNT" +NMAKE_WINVER = 0x0500 +!ELSEIF "$(WINVER)" == "WINXP" +NMAKE_WINVER = 0x0501 +!ELSEIF "$(WINVER)" == "WIN2003" +NMAKE_WINVER = 0x0502 +!ELSEIF "$(WINVER)" == "NT4" +NMAKE_WINVER = 0x0400 +!ENDIF + +!IF !DEFINED(NMAKE_WINVER) || "$(NMAKE_WINVER)" == "" +NMAKE_WINVER = 0x0400 +NMAKE_WINNT = /D_WIN95 /D_WIN32_WINDOWS=$(NMAKE_WINVER) +!ELSE +NMAKE_WINNT = /D_WINNT /D_WIN32_WINNT=$(NMAKE_WINVER) +!ENDIF + +!IF !DEFINED(BUILD) || "$(BUILD)" == "" +BUILD = RELEASE +!ENDIF + +!IFDEF RELEASE +BUILD = RELEASE +!ENDIF + +!IFDEF DEBUG +BUILD = DEBUG +!ENDIF + +!IFDEF NODEBUG +!ENDIF + +!IF "$(BUILD)" != "RELEASE" +!IF "$(BUILD)" != "DEBUG" +!ERROR Must specify BUILD environment variable (RELEASE, DEBUG) +!ELSE +BUILDEXT = D +!ENDIF +!ELSE +BUILDEXT = R +!ENDIF + +!IF "$(FRAMEWORKDIR)" == "" +!ERROR Unspecified FrameworkDir location +!ENDIF + +!IF "$(FRAMEWORKVERSION)" == "" +!ERROR Unspecified FrameworkVersion environment variable +!ENDIF + +!IF "$(FRAMEWORKSDKDIR)" == "" +!ERROR Unspecified FrameworkSDKDir location +!ENDIF + +NET_FRAMEWORK_DIR=$(FRAMEWORKDIR)\$(FRAMEWORKVERSION) +NET_FRAMEWORK_SDK=$(FRAMEWORKSDKDIR) + +# Common flags for all platforms +CMN_CFLAGS = /c /nologo /DWIN32 /D_WIN32 /D_WINDOWS $(NMAKE_WINNT) /W3 + +!IFDEF CLR +!IF "$(CLR)" == "" +!ERROR Must specify CLR option (/clr, /clr:strict, /clr:pure) +!ENDIF + +CMN_CFLAGS = $(CLR) $(CMN_CFLAGS) + +CLR_ASSEMBLIES = \ + /AI "$(NET_FRAMEWORK_DIR)" \ + /FU "System.dll" \ + /FU "System.Configuration.dll" \ + /FU "System.Configuration.Install.dll" \ + /FU "System.Data.dll" \ + /FU "System.Data.OracleClient.dll" \ + /FU "System.DirectoryServices.dll" \ + /FU "System.DirectoryServices.Protocols.dll" \ + /FU "System.Drawing.dll" \ + /FU "System.EnterpriseServices.dll" \ + /FU "System.Messaging.dll" \ + /FU "System.Runtime.Remoting.dll" \ + /FU "System.Security.dll" \ + /FU "System.Transactions.dll" \ + /FU "System.Web.dll" \ + /FU "System.Web.RegularExpressions.dll" \ + /FU "System.Web.Services.dll" \ + /FU "System.Windows.Forms.dll" \ + /FU "System.Xml.dll" + +!ENDIF + +!IF "$(CPU)" == "I386" +CPU_CFLAGS = /D_X86_=1 +!ELSEIF "$(CPU)" == "AMD64" +CPU_CFLAGS = /D_AMD64_=1 /DWIN64 /D_WIN64 /Wp64 /FIPRE64PRA.H +!ELSEIF "$(CPU)" == "IA64" +CPU_CFLAGS = /D_IA64_=1 /DWIN64 /D_WIN64 /Wp64 /Ap64 /FIPRE64PRA.H +!ENDIF + +!IF "$(BUILD)" == "RELEASE" +OPT_CFLAGS = /O2 /Ob2 /Oy- /Zi /DNDEBUG +!ELSE +OPT_CFLAGS = /Od /Zi /DDEBUG /D_DEBUG +!ENDIF + +!IF DEFINED(STATIC_CRT) +CRT_CFLAGS = /D_MT /MT +!ELSE +CRT_CFLAGS = /D_MT /MD +!ENDIF + +!IF "$(BUILD)" == "DEBUG" +CRT_CFLAGS = $(CRT_CFLAGS)d +!ENDIF + +CFLAGS = $(CMN_CFLAGS) $(CPU_CFLAGS) $(OPT_CFLAGS) $(CRT_CFLAGS) $(CFLAGS) + +!IF DEFINED(EXTRA_CFLAGS) +CFLAGS = $(CFLAGS) $(EXTRA_CFLAGS) +!ENDIF + +!IFDEF CLR +CFLAGS = $(CFLAGS) $(CLR_ASSEMBLIES) +!IF "$(BUILD)" == "DEBUG" +LIBS = msvcmrtd.lib $(LIBS) +!ELSE +LIBS = msvcmrt.lib $(LIBS) +!ENDIF +!ENDIF + +# Linker section +LIBS = kernel32.lib advapi32.lib ws2_32.lib mswsock.lib ole32.lib shell32.lib rpcrt4.lib bufferoverflowu.lib $(LIBS) + +!IF DEFINED(EXTRA_LIBS) +LIBS = $(LIBS) $(EXTRA_LIBS) +!ENDIF + +COMMON_LFLAGS = /NOLOGO /DEBUG + +!IFDEF CLR +COMMON_LFLAGS = $(COMMON_LFLAGS) /ERRORREPORT:NONE +!ENDIF + +# Always add debugging to the linker +OPT_LFLAGS = /INCREMENTAL:NO /DEBUG +!IF "$(BUILD)" == "RELEASE" +OPT_LFLAGS = /OPT:REF +!ENDIF + +!IF "$(TARGET)" == "EXE" +LFLAGS = $(COMMON_LFLAGS) /SUBSYSTEM:CONSOLE /MACHINE:$(CPU) +!ELSEIF "$(TARGET)" == "GUI" +LFLAGS = $(COMMON_LFLAGS) /SUBSYSTEM:WINDOWS /MACHINE:$(CPU) +!ELSEIF "$(TARGET)" == "DLL" +LFLAGS = $(COMMON_LFLAGS) /DLL /SUBSYSTEM:WINDOWS /MACHINE:$(CPU) +!ELSEIF "$(TARGET)" == "LIB" +LFLAGS = -lib $(COMMON_LFLAGS) +!ENDIF + +!IF DEFINED(EXTRA_LFLAGS) +LFLAGS = $(LFLAGS) $(EXTRA_LFLAGS) +!ENDIF + +!IF "$(TARGET)" != "LIB" +LFLAGS = $(LFLAGS) $(OPT_LFLAGS) +!ENDIF + +# Resource compiler flags + +BASE_RCFLAGS = /l 0x409 /n +!IF "$(BUILD)" == "RELEASE" +BASE_RCFLAGS = $(BASE_RCFLAGS) /d "NDEBUG" +!ELSE +BASE_RCFLAGS = $(BASE_RCFLAGS) /d "_DEBUG" /d "DEBUG" +!ENDIF +RCFLAGS = $(BASE_RCFLAGS) $(RCFLAGS) + +# Build Target dir e.g. WINNT_I386_RELEASE_DLL +!IF !DEFINED(BUILDIR) || "$(BUILDIR)" == "" +!IF !DEFINED(BUILDIR_EXT) || "$(BUILDIR_EXT)" == "" +BUILDIR = $(WINVER)_$(CPU)_$(TARGET)_$(BUILDEXT) +!ELSE +BUILDIR = $(WINVER)_$(CPU)_$(BUILDIR_EXT)_$(BUILDEXT) +!ENDIF +!ENDIF + +!IF "$(OS)" == "Windows_NT" +CLEANTARGET = if exist "$(BUILDIR)/$(NULL)" rd /s /q $(BUILDIR) +!ELSE +CLEANTARGET = deltree /y $(BUILDIR) +!ENDIF + +MAKETARGET = $(MKDIR) $(BUILDIR) + +!IF DEFINED(JAVA_HOME) && "$(JAVA_HOME)" != "" +JAVA_INCLUDES = /I "$(JAVA_HOME)/include" /I "$(JAVA_HOME)/include/win32" +!ENDIF Added: trunk/labs/jbosswebnp/src/windows/native/build/baseaddr.ref =================================================================== --- trunk/labs/jbosswebnp/src/windows/native/build/baseaddr.ref 2006-01-17 08:41:54 UTC (rev 2117) +++ trunk/labs/jbosswebnp/src/windows/native/build/baseaddr.ref 2006-01-17 08:43:48 UTC (rev 2118) @@ -0,0 +1,15 @@ +; contains the central repository of all module base addresses +; to avoid relocation +; +; WARNING: Update this file by reviewing the image size +; of the debug-generated dll files; release images +; should fit in the larger debug-sized space. +; +; module name base-address max-size + +JNI.core 0x50000000 0x00020000 +JNI.rt 0x50020000 0x00C00000 +JNI.servlet 0x50C20000 0x00080000 +JNI.mscorlib 0x50CA0000 0x01000000 +JMI.core 0x51CA0000 0x00060000 +JMI.mscorlib 0x51D00000 0x01000000 Added: trunk/labs/jbosswebnp/src/windows/native/build/jboss.ico =================================================================== (Binary files differ) Property changes on: trunk/labs/jbosswebnp/src/windows/native/build/jboss.ico ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/labs/jbosswebnp/src/windows/native/build/resource.h =================================================================== --- trunk/labs/jbosswebnp/src/windows/native/build/resource.h 2006-01-17 08:41:54 UTC (rev 2117) +++ trunk/labs/jbosswebnp/src/windows/native/build/resource.h 2006-01-17 08:43:48 UTC (rev 2118) @@ -0,0 +1,48 @@ +/* + * JBoss, the OpenSource J2EE webOS + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ + +#ifndef MAIN_RESOURCE_H +#define MAIN_RESOURCE_H + +#define PRIVATE_BUILD 1 +#define PRERELEASE_BUILD 1 + +#define STR_COPYRIGHT "Copyright 2006 JBoss inc. " \ + "or its licensors, as applicable." + +#define STR_LICENSE "Distributable under LGPL license. " \ + "See terms of license at gnu.org." + +#define STR_COMPANY "JBoss, Inc." +#define STR_TRADEMARK " JBoss Inc." +#define STR_PRODUCT "VM Interoperability Project" + +#if PRIVATE_BUILD +#define STR_PRIVATE "Initial Prerelease" +#define STR_SPECIAL "Basic functionality" +#define STD_FILEFLAGS VS_FF_PRIVATEBUILD | VS_FF_SPECIALBUILD +#else +#define STD_FILEFLAGS 0x0L +#endif + +#if PRERELEASE_BUILD +#define PSTD_FILEFLAGS STD_FILEFLAGS | VS_FF_PRERELEASE +#else +#define PSTD_FILEFLAGS STD_FILEFLAGS +#endif + + +#define STR_VERISON "0.9.1.0" +#define CSV_VERISON 0,9,1,0 + +#ifdef _DEBUG +#define DLL_FILEFLAGS STD_FILEFLAGS | VS_FF_DEBUG +#else +#define DLL_FILEFLAGS STD_FILEFLAGS +#endif + +#endif // MAIN_RESOURCE_H |
From: <jbo...@li...> - 2006-01-17 08:42:06
|
Author: mla...@jb... Date: 2006-01-17 03:41:54 -0500 (Tue, 17 Jan 2006) New Revision: 2117 Added: trunk/labs/jbosswebnp/src/windows/generators/bin/servlet-api.jar trunk/labs/jbosswebnp/src/windows/generators/j2x/ trunk/labs/jbosswebnp/src/windows/generators/j2x/J2X.java trunk/labs/jbosswebnp/src/windows/generators/j2x/gen.javax.servlet.bat trunk/labs/jbosswebnp/src/windows/generators/j2x/gen.rt.bat Log: Initial checkin. Added: trunk/labs/jbosswebnp/src/windows/generators/bin/servlet-api.jar =================================================================== (Binary files differ) Property changes on: trunk/labs/jbosswebnp/src/windows/generators/bin/servlet-api.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/labs/jbosswebnp/src/windows/generators/j2x/J2X.java =================================================================== --- trunk/labs/jbosswebnp/src/windows/generators/j2x/J2X.java 2006-01-17 08:35:48 UTC (rev 2116) +++ trunk/labs/jbosswebnp/src/windows/generators/j2x/J2X.java 2006-01-17 08:41:54 UTC (rev 2117) @@ -0,0 +1,333 @@ +/* + * JBoss, the OpenSource J2EE webOS + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ + +import java.io.*; +import java.lang.reflect.*; +import java.lang.annotation.*; +import java.net.URL; +import java.util.*; + +public class J2X +{ + + public static String toJniType(String t) + { + if (t.charAt(0) == '[') + return t.replace('.', '/'); + if (t.equals("boolean")) + return "Z"; + else if (t.equals("int")) + return "I"; + else if (t.equals("long")) + return "J"; + else if (t.equals("byte")) + return "B"; + else if (t.equals("void")) + return "V"; + else if (t.equals("short")) + return "S"; + else if (t.equals("char")) + return "C"; + else if (t.equals("float")) + return "F"; + else if (t.equals("double")) + return "D"; + else + return ("L" + t + ";").replace('.', '/'); + } + + public static void dumpModifiers(int mod, String p) + { + if (Modifier.isPublic(mod)) + System.out.println(p + "<modifier>public</modifier>"); + if (Modifier.isProtected(mod)) + System.out.println(p + "<modifier>protected</modifier>"); + if (Modifier.isPrivate(mod)) + System.out.println(p + "<modifier>private</modifier>"); + if (Modifier.isFinal(mod)) + System.out.println(p + "<modifier>final</modifier>"); + if (Modifier.isAbstract(mod)) + System.out.println(p + "<modifier>abstract</modifier>"); + if (Modifier.isStatic(mod)) + System.out.println(p + "<modifier>static</modifier>"); + if (Modifier.isSynchronized(mod)) + System.out.println(p + "<modifier>synchronized</modifier>"); + if (Modifier.isNative(mod)) + System.out.println(p + "<modifier>native</modifier>"); + if (Modifier.isInterface(mod)) + System.out.println(p + "<modifier>interface</modifier>"); + } + + public static void dumpParams(Class [] params, String rt) + { + try { + if (params != null) { + int i; + StringBuilder sig = new StringBuilder("("); + for (i = 0; i < params.length; i++) { + String pt = toJniType(params[i].getName()); + String pn = "arg" + i; + System.out.print(" <param name=\"" + pn); + System.out.print("\" type=\"" + pt); + System.out.println("\"></param>"); + sig.append(pt); + } + sig.append(")"); + sig.append(rt); + System.out.println(" <signature>" + sig.toString() + "</signature>"); + } + } + catch(Exception e) {} + } + + public static void dumpThrows(Class [] ex) + { + try { + if (ex != null) { + int i; + for (i = 0; i < ex.length; i++) { + String pt = toJniType(ex[i].getName()); + System.out.print(" <throws type=\"" + pt); + System.out.println("\"></throws>"); + } + } + } + catch(Exception e) {} + } + + public static void dumpCtor(Constructor c) + { + try { + int mod = c.getModifiers(); + if (Modifier.isPrivate(mod)) + return; + if (c.isSynthetic()) + return; + if (!Modifier.isPublic(mod) && !Modifier.isProtected(mod)) + return; + String rt = "V"; + System.out.println(" <init>"); + dumpModifiers(mod, " "); + System.out.println(" <summary>" + c.toString() + "</summary>"); + dumpParams(c.getParameterTypes(), rt); + dumpThrows(c.getExceptionTypes()); + dumpAnnotations(c.getAnnotations()); + System.out.println(" </init>"); + } + catch(Exception e) {} + } + + public static void dumpMethod(Method m) + { + try { + int mod = m.getModifiers(); + if (Modifier.isPrivate(mod)) + return; + if (m.isSynthetic()) + return; + if (m.isBridge()) + return; + if (m.isVarArgs()) + return; + if (!Modifier.isPublic(mod) && !Modifier.isProtected(mod)) + return; + String rt = toJniType(m.getReturnType().getName()); + System.out.println(" <method name=\"" + m.getName() + "\">"); + dumpModifiers(mod, " "); + System.out.println(" <summary>" + m.toString() + "</summary>"); + dumpParams(m.getParameterTypes(), rt); + if (!rt.equals("V")) + System.out.println(" <returns type=\"" + rt + "\"></returns>"); + dumpThrows(m.getExceptionTypes()); + dumpAnnotations(m.getAnnotations()); + System.out.println(" </method>"); + } + catch(Exception e) {} + } + + public static void dumpField(Field f) + { + try { + int mod = f.getModifiers(); + if (Modifier.isNative(mod)) + return; + if (Modifier.isPrivate(mod)) + return; + if (f.isSynthetic()) + return; + if (!Modifier.isPublic(mod) && !Modifier.isProtected(mod)) + return; + String rt = toJniType(f.getType().getName()); + System.out.println(" <field name=\"" + f.getName() + "\">"); + dumpModifiers(mod, " "); + System.out.println(" <summary>" + f.toString() + "</summary>"); + System.out.println(" <signature>" + rt + "</signature>"); + Object val = null; + try { + val = f.get(f); + } + catch(Exception e) { + val = null; + } + if (val != null) { + String v = val.toString(); + if (rt.equals("D") || rt.equals("F")) { + // Skip; + } + else if (rt.equals("C")) { + v = Integer.toString((int)v.charAt(0)); + System.out.println(" <value>" + v + "</value>"); + } + else { + if (!v.startsWith("java.") || rt.equals("Ljava/lang/String;")) + System.out.println(" <value>" + v + "</value>"); + } + } + dumpAnnotations(f.getAnnotations()); + System.out.println(" </field>"); + } + catch(Exception e) {} + } + + public static void dumpAnnotations(Annotation [] ann) + { + try { + if (ann != null) { + int i; + for (i = 0; i < ann.length; i++) { + System.out.print(" <annotation>"); + System.out.print(ann[i].toString()); + System.out.println("</annotation>"); + } + } + } + catch(Exception e) {} + } + + public J2X(String className) + { + try { + int i; + + Class clazz = ClassLoader.getSystemClassLoader().loadClass(className); + System.out.println(" <class>"); + System.out.println(" <name>" + clazz.getName() + "</name>"); + if (clazz.getSuperclass() != null) { + int mod = clazz.getSuperclass().getModifiers(); + if (!Modifier.isPublic(mod) && !Modifier.isProtected(mod)) + System.out.println(" <extends>java.lang.Object</extends>"); + else + System.out.println(" <extends>" + clazz.getSuperclass().getName() + "</extends>"); + } + else + System.out.println(" <extends>java.lang.Object</extends>"); + + dumpModifiers(clazz.getModifiers(), " "); + System.out.println(" <summary>" + clazz.toString() + "</summary>"); + Constructor[] ctors = clazz.getDeclaredConstructors(); + if (ctors != null) { + for (i = 0; i < ctors.length; i++) { + dumpCtor(ctors[i]); + } + } + Method[] methods = clazz.getDeclaredMethods(); + if (methods != null) { + for (i = 0; i < methods.length; i++) { + dumpMethod(methods[i]); + } + } + Field[] fields = clazz.getDeclaredFields(); + if (fields != null) { + for (i = 0; i < fields.length; i++) { + dumpField(fields[i]); + } + } + System.out.println(" </class>"); + } + catch(Exception e) { + System.err.println("Failed " + className); + e.printStackTrace(); + } + } + + public static Class[] getClasses(String packageName) + throws ClassNotFoundException + { + ArrayList<Class> classes = new ArrayList<Class>(); + File directory = null; + try { + ClassLoader cld = ClassLoader.getSystemClassLoader(); + if (cld == null) + throw new ClassNotFoundException("Can't get System class loader."); + String path = packageName.replace('.', '/'); + URL resource = cld.getResource(path); + if (resource == null) + throw new ClassNotFoundException("No resource for " + path); + directory = new File(resource.getFile()); + } + catch(NullPointerException e) { + throw new ClassNotFoundException(packageName + " (" + directory + + ") does not appear to be a valid package"); + } + if (directory.exists()) { + String[] files = directory.list(); + for (int i = 0; i < files.length; i++) { + if (files[i].endsWith(".class")) { + String cn = packageName + '.' + + files[i].substring(0, files[i].length() - 6); + if (cn.indexOf('$') == -1) + classes.add(Class.forName(cn)); + } + } + } + else { + throw new ClassNotFoundException(packageName + + " does not appear to be a valid package"); + } + Class[] classesA = new Class[classes.size()]; + classes.toArray(classesA); + return classesA; + } + + public static void main(String[] args) + { + try { + if (args.length < 1) { + System.err.println("Usage: DumpJavaClass <Class Name>"); + return; + } + if (args[0].equals("head")) { + System.out.println("<?xml version=\"1.0\"?>"); + System.out.println("<classes>"); + } + else if (args[0].equals("tail")) { + System.out.println("</classes>"); + } + else if (args[0].equals("package")) { + if (args.length < 2) { + System.err.println("Usage: DumpJavaClass package <Package Name>"); + return; + } + Class[] classes = getClasses(args[1]); + int c = 0; + for (int i = 0; i < classes.length; i++) { + int m = classes[i].getModifiers(); + if (Modifier.isPublic(m) || Modifier.isProtected(m)) { + J2X generator = new J2X(classes[i].getName()); + c++; + } + } + } + else { + J2X generator = new J2X(args[0]); + } + } + catch(Exception e) { + e.printStackTrace(); + } + } +} Added: trunk/labs/jbosswebnp/src/windows/generators/j2x/gen.javax.servlet.bat =================================================================== --- trunk/labs/jbosswebnp/src/windows/generators/j2x/gen.javax.servlet.bat 2006-01-17 08:35:48 UTC (rev 2116) +++ trunk/labs/jbosswebnp/src/windows/generators/j2x/gen.javax.servlet.bat 2006-01-17 08:41:54 UTC (rev 2117) @@ -0,0 +1,13 @@ +@echo off +REM +REM Unpack servlet-api.jar to this directory +REM and then run this file. +REM +setlocal +set CLASSPATH=.;./servlet-api.jar +java J2X head >javax.servlet.xml + +java J2X package javax.servlet >>javax.servlet.xml +java J2X package javax.servlet.http >>javax.servlet.xml + +java J2X tail >>javax.servlet.xml Added: trunk/labs/jbosswebnp/src/windows/generators/j2x/gen.rt.bat =================================================================== --- trunk/labs/jbosswebnp/src/windows/generators/j2x/gen.rt.bat 2006-01-17 08:35:48 UTC (rev 2116) +++ trunk/labs/jbosswebnp/src/windows/generators/j2x/gen.rt.bat 2006-01-17 08:41:54 UTC (rev 2117) @@ -0,0 +1,50 @@ +@echo off +REM +REM Unpack rt.jar to this directory +REM and then run this file. +REM +java J2X head >java.rt.xml +java J2X package java.lang >>java.rt.xml +java J2X package java.lang.annotation >>java.rt.xml +java J2X package java.lang.instrument >>java.rt.xml +java J2X package java.lang.management >>java.rt.xml +java J2X package java.lang.ref >>java.rt.xml +java J2X package java.lang.reflect >>java.rt.xml + +java J2X package java.io >>java.rt.xml +java J2X package java.math >>java.rt.xml +java J2X package java.net >>java.rt.xml + +java J2X package java.nio >>java.rt.xml +java J2X package java.nio.channels >>java.rt.xml +java J2X package java.nio.channels.spi >>java.rt.xml +java J2X package java.nio.charset >>java.rt.xml +java J2X package java.nio.charset.spi >>java.rt.xml + +java J2X package java.rmi >>java.rt.xml +java J2X package java.rmi.activation >>java.rt.xml +java J2X package java.rmi.dgc >>java.rt.xml +java J2X package java.rmi.registry >>java.rt.xml +java J2X package java.rmi.server >>java.rt.xml + +java J2X package java.security >>java.rt.xml +java J2X package java.security.acl >>java.rt.xml +java J2X package java.security.cert >>java.rt.xml +java J2X package java.security.interfaces >>java.rt.xml +java J2X package java.security.spec >>java.rt.xml + +java J2X package java.sql >>java.rt.xml +java J2X package java.text >>java.rt.xml + +java J2X package java.util >>java.rt.xml +java J2X package java.util.concurrent >>java.rt.xml +java J2X package java.util.concurrent.atomic >>java.rt.xml +java J2X package java.util.concurrent.locks >>java.rt.xml +java J2X package java.util.jar >>java.rt.xml +java J2X package java.util.logging >>java.rt.xml +java J2X package java.util.prefs >>java.rt.xml +java J2X package java.util.regex >>java.rt.xml +java J2X package java.util.zip >>java.rt.xml + +java J2X tail >>java.rt.xml + |
From: <jbo...@li...> - 2006-01-17 08:03:57
|
Author: mic...@jb... Date: 2006-01-17 03:03:52 -0500 (Tue, 17 Jan 2006) New Revision: 2114 Modified: trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/IntegrationTest.java Log: More integration tests and fixes that follow it Modified: trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/IntegrationTest.java =================================================================== --- trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/IntegrationTest.java 2006-01-17 08:02:15 UTC (rev 2113) +++ trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/IntegrationTest.java 2006-01-17 08:03:52 UTC (rev 2114) @@ -25,6 +25,18 @@ * so that is acceptable. */ public void testBootstrap() { + runVersioningTests(); + + + + } + + + /** + * These tests show how it all hangs together. + * You can see versioning in action, save history etc. + */ + private void runVersioningTests() { RepositoryManager repo = RepositoryFactory.getStatefulRepository(); // In the beginning there was a rule @@ -135,9 +147,6 @@ repo.close(); - - - } |
Author: mic...@jb... Date: 2006-01-17 03:02:15 -0500 (Tue, 17 Jan 2006) New Revision: 2113 Modified: trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/MetaData.java trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RuleDef.java trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RuleSetDef.java trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RuleSetVersionInfo.java trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/Tag.java trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/db/HibernateUtil.java trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/db/RepoProxyHandler.java trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/db/RepositoryImpl.java trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/db/StoreEventListener.java trunk/labs/jbossrules/drools-repository/src/main/resources/org/drools/repository/RuleDef.hbm.xml trunk/labs/jbossrules/drools-repository/src/main/resources/org/drools/repository/RuleSetDef.hbm.xml trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/IntegrationTest.java trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/RulePersistenceTest.java trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/RuleSetPersistenceTest.java Log: More integration tests and fixes that follow it Modified: trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/MetaData.java =================================================================== --- trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/MetaData.java 2006-01-17 02:46:13 UTC (rev 2112) +++ trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/MetaData.java 2006-01-17 08:02:15 UTC (rev 2113) @@ -29,6 +29,22 @@ private String coverage; private String rights; + public MetaData() { + } + + public MetaData(String title, + String creator, + String subject, + String description, + String format) { + super(); + this.title = title; + this.creator = creator; + this.subject = subject; + this.description = description; + this.format = format; + } + public String getContributor(){ return contributor; } @@ -156,4 +172,6 @@ return copy; } + + } Modified: trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RuleDef.java =================================================================== --- trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RuleDef.java 2006-01-17 02:46:13 UTC (rev 2112) +++ trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RuleDef.java 2006-01-17 08:02:15 UTC (rev 2113) @@ -28,7 +28,6 @@ /** * Use tagging to aid with searching and sorting of large numbers of rules. - * Tags should not effect the versioning of the rules. */ public RuleDef addTag(String tag) { this.tags.add( new Tag( tag ) ); @@ -39,6 +38,20 @@ this.tags.add( tag ); return this; } + + public void removeTag(Tag tag) { + this.tags.remove(tag); + } + + public void removeTag(String tagVal) { + for ( Iterator iter = this.tags.iterator(); iter.hasNext(); ) { + Tag tag = (Tag) iter.next(); + if (tag.getTag().equals(tagVal)) { + iter.remove(); + return; + } + } + } RuleDef() { } @@ -177,7 +190,8 @@ Set newTags = new HashSet(); for ( Iterator iter = this.getTags().iterator(); iter.hasNext(); ) { Tag tag = (Tag) iter.next(); - newTags.add( new Tag( tag.getTag() ) ); + newTags.add( new Tag( tag.getTag() ) ); + } return newTags; } @@ -203,7 +217,7 @@ } public String toString() { - return "{ id = " + this.getId() + " name = (" + this.name + ") version = " + this.getVersionNumber() + " }"; + return "{ id = " + this.getId() + " name = '" + this.name + "' version = " + this.getVersionNumber() + " }"; } public Long getHistoricalId() { Modified: trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RuleSetDef.java =================================================================== --- trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RuleSetDef.java 2006-01-17 02:46:13 UTC (rev 2112) +++ trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RuleSetDef.java 2006-01-17 08:02:15 UTC (rev 2113) @@ -96,13 +96,24 @@ this.applicationData ); } + /** Find the current working version info. */ + public RuleSetVersionInfo getCurrentVersionInfo() { + for ( Iterator iter = this.versionHistory.iterator(); iter.hasNext(); ) { + RuleSetVersionInfo info = (RuleSetVersionInfo) iter.next(); + if (info.getVersionNumber() == this.getWorkingVersionNumber()) { + return info; + } + } + return null; + } + /** * Removes a rule from the current ruleset. This * DOES NOT delete the rule, and DOES NOT effect any other versions * of the ruleset. * * Note that assets are removed by setting their version number to - * IVersionable.NO_VERSION (-1) so that the do not show up. + * IVersionable.NO_VERSION (-1) so that they do not show up. * This may be changed so they are archived in future, and deleted. * * The repository API has a delete(RuleDef rule) method @@ -255,7 +266,7 @@ * so on without effecting any previous versions of rules and the ruleset. * * Previous rules can be retrieved by changing the value of - * workingVersionNumber. + * workingVersionNumber when loading the ruleset. * * Note that further to this, rules themselves will be versioned on save * (think of that versioning as "minor" versions, and this sort of ruleset @@ -263,13 +274,12 @@ * * Ideally once a new version is created, the RuleSet should be stored and * then loaded fresh, which will hide the non working versions of the rules. - * */ public void createNewVersion(String comment, String newStatus) { this.workingVersionNumber++; - addNewVersionHistory( newStatus ); + addNewVersionHistory( newStatus, comment ); createAndAddNewVersions( this.rules, comment, @@ -294,10 +304,11 @@ } - private void addNewVersionHistory(String newStatus) { + private void addNewVersionHistory(String newStatus, String comment) { RuleSetVersionInfo newVersion = new RuleSetVersionInfo(); newVersion.setStatus( newStatus ); newVersion.setVersionNumber( this.workingVersionNumber ); + newVersion.setVersionComment( comment ); this.versionHistory.add( newVersion ); } Modified: trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RuleSetVersionInfo.java =================================================================== --- trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RuleSetVersionInfo.java 2006-01-17 02:46:13 UTC (rev 2112) +++ trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RuleSetVersionInfo.java 2006-01-17 08:02:15 UTC (rev 2113) @@ -74,6 +74,9 @@ return 0; } + public String toString() { + return "{ versionComment=" + this.versionComment + " versionNumber=" + this.versionNumber + " }"; + } Modified: trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/Tag.java =================================================================== --- trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/Tag.java 2006-01-17 02:46:13 UTC (rev 2112) +++ trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/Tag.java 2006-01-17 08:02:15 UTC (rev 2113) @@ -5,7 +5,7 @@ * This represents a users tag for a rule, ruleset. * This aids with classification of rules in an ad-hoc fashion. * - * A tag it its own entity as tags should be shared as much as possible. + * A tag is its own entity as tags should be shared as much as possible. * * @author <a href="mailto:mic...@gm..."> Michael Neale</a> * Modified: trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/db/HibernateUtil.java =================================================================== --- trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/db/HibernateUtil.java 2006-01-17 02:46:13 UTC (rev 2112) +++ trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/db/HibernateUtil.java 2006-01-17 08:02:15 UTC (rev 2113) @@ -20,17 +20,11 @@ */ public class HibernateUtil { - private static final SessionFactory sessionFactory; + private static SessionFactory sessionFactory; static { try { - - Configuration cfg = new Configuration(); - cfg.setInterceptor( new StoreEventListener() ); - registerPersistentClasses( cfg ); - cfg.configure("drools-repository-db.cfg.xml"); - - sessionFactory = cfg.buildSessionFactory(); + configureSessionFactory(); } catch ( Throwable ex ) { // Make sure you log the exception, as it might be swallowed @@ -40,6 +34,22 @@ } /** + * This will setup the session factory with paramaters + * that are available. + * May be called again to re-establish the factory if needed. + */ + public static void configureSessionFactory() { + Configuration cfg = new Configuration(); + cfg.setInterceptor( new StoreEventListener() ); + registerPersistentClasses( cfg ); +// cfg.setProperty("connection.username", "sa"); +// cfg.setProperty("connection.password", ""); + cfg.configure("drools-repository-db.cfg.xml"); + + sessionFactory = cfg.buildSessionFactory(); + } + + /** * Use class based registration for refactor-friendly goodness. */ private static void registerPersistentClasses(Configuration cfg) { Modified: trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/db/RepoProxyHandler.java =================================================================== --- trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/db/RepoProxyHandler.java 2006-01-17 02:46:13 UTC (rev 2112) +++ trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/db/RepoProxyHandler.java 2006-01-17 08:02:15 UTC (rev 2113) @@ -14,6 +14,10 @@ * This is the glue between the actual implementation and the interface. * Kind of like poor mans aspects. But I couldn't justify AOP for this little thing. * + * This provides the stateful and stateless behaviour. + * It can also be extended to provide user context to the implementation class + * (for auditing, access control and locking for instance). + * * @author <a href="mailto:mic...@gm..."> Michael Neale</a> */ public class RepoProxyHandler @@ -32,6 +36,7 @@ * work with the current session. */ public RepoProxyHandler() { + this(false); } /** @@ -39,9 +44,9 @@ * @param stateful True if stateful operation is desired. */ public RepoProxyHandler(boolean stateful) { + this.stateful = stateful; if (stateful) { this.session = HibernateUtil.getSessionFactory().openSession(); - this.stateful = true; } } @@ -58,6 +63,7 @@ if (this.stateful && method.getName().equals("close")) { session.close(); + StoreEventListener.setCurrentConnection(null); return null; } @@ -68,6 +74,10 @@ Object result = method.invoke(repoImpl, args); session.flush(); tx.commit(); + + if (!stateful) { + this.repoImpl.injectSession(null); //not really needed, but to prove it is stateless ! + } return result; } catch (InvocationTargetException e) { Modified: trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/db/RepositoryImpl.java =================================================================== --- trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/db/RepositoryImpl.java 2006-01-17 02:46:13 UTC (rev 2112) +++ trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/db/RepositoryImpl.java 2006-01-17 08:02:15 UTC (rev 2113) @@ -72,7 +72,7 @@ * @see org.drools.repository.db.RepositoryManager#findRulesByTag(java.lang.String) */ public List findRulesByTag(String tag) { - List result = session.createQuery( "from RuleDef as rule " + + List result = session.createQuery( "select rule from RuleDef as rule " + "join rule.tags as tags " + "where tags.tag = :tag" ).setString( "tag", tag ).list(); return result; @@ -90,9 +90,9 @@ */ public RuleSetDef loadRuleSet(String ruleSetName, long workingVersionNumber) { + session.clear(); //to make sure latest is loaded up, not stale enableWorkingVersionFilter( workingVersionNumber, - session ); - + session ); RuleSetDef def = loadRuleSetByName( ruleSetName, session ); def.setWorkingVersionNumber( workingVersionNumber ); Modified: trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/db/StoreEventListener.java =================================================================== --- trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/db/StoreEventListener.java 2006-01-17 02:46:13 UTC (rev 2112) +++ trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/db/StoreEventListener.java 2006-01-17 08:02:15 UTC (rev 2113) @@ -2,7 +2,6 @@ import java.io.Serializable; import java.sql.Connection; -import java.util.Iterator; import org.drools.repository.ISaveHistory; import org.hibernate.EmptyInterceptor; @@ -44,34 +43,21 @@ Session session = getSessionFactory().openSession( (Connection) currentConnection.get() ); - - System.out.println( "POSSIBLY SAVING COPY" ); - ISaveHistory prev = (ISaveHistory) session.load( entity.getClass(), versionable.getId(), LockMode.NONE ); if ( versionable.isStateChanged( prev ) ) { - ISaveHistory copy = (ISaveHistory) versionable.copy(); - copy.setHistoricalId( prev.getId() ); + ISaveHistory copy = (ISaveHistory) prev.copy(); + copy.setHistoricalId( versionable.getId() ); copy.setHistoricalRecord( true ); session.save( copy ); session.flush(); - //session.close(); + session.close(); System.out.println( "SAVING HISTORY COPY" ); } - else { - System.out.println( "NOPE, not saving." ); - } } - public void postFlush(Iterator entities) { - for ( Iterator iter = entities; iter.hasNext(); ) { - Object element = (Object) iter.next(); - - } - } - /** * Used to set the current session so the interceptor can access it. * @param session @@ -80,49 +66,6 @@ currentConnection.set(conn); } - // public boolean onFlushDirty(Object entity, - // Serializable id, - // Object[] currentState, - // Object[] previousState, - // String[] propertyNames, - // Type[] types) { - // if (entity instanceof IVersionable) { - // handleVersionable( entity ); - // } - // return false; - // } - // - // - // private void handleVersionable(Object entity) { - // IVersionable versionable = (IVersionable) entity; - // if (versionable instanceof RuleDef) { - // handleRuleDef( versionable ); - // } - // } - // - // - // private void handleRuleDef(IVersionable versionable) { - // RuleDef def = (RuleDef) versionable; - // Session current = getSessionFactory().getCurrentSession(); - // Session session = getSessionFactory().openSession(current.connection()); - // - // System.out.println("POSSIBLY SAVING COPY"); - // - // RuleDef prev = (RuleDef) session.load(RuleDef.class, def.getId(), - // LockMode.NONE); - // if (!prev.getContent().equals(def.getContent()) ){ - // RuleDef copy = (RuleDef) def.copy(); - // copy.setHistoricalId(prev.getId()); - // copy.setHistoricalRecord(true); - // session.save(copy); - // session.flush(); - // System.out.println("SAVING RULE HISTORY COPY"); - // } else { - // System.out.println("NOPE, not saving."); - // } - // } - // - private SessionFactory getSessionFactory() { return HibernateUtil.getSessionFactory(); } Modified: trunk/labs/jbossrules/drools-repository/src/main/resources/org/drools/repository/RuleDef.hbm.xml =================================================================== --- trunk/labs/jbossrules/drools-repository/src/main/resources/org/drools/repository/RuleDef.hbm.xml 2006-01-17 02:46:13 UTC (rev 2112) +++ trunk/labs/jbossrules/drools-repository/src/main/resources/org/drools/repository/RuleDef.hbm.xml 2006-01-17 08:02:15 UTC (rev 2113) @@ -15,7 +15,7 @@ <property name="name"/> <property name="versionNumber" /> - <property name="content" /> + <property name="content" type="text" /> <property name="status" /> <property name="checkedOut" /> <property name="checkedOutBy" /> Modified: trunk/labs/jbossrules/drools-repository/src/main/resources/org/drools/repository/RuleSetDef.hbm.xml =================================================================== --- trunk/labs/jbossrules/drools-repository/src/main/resources/org/drools/repository/RuleSetDef.hbm.xml 2006-01-17 02:46:13 UTC (rev 2112) +++ trunk/labs/jbossrules/drools-repository/src/main/resources/org/drools/repository/RuleSetDef.hbm.xml 2006-01-17 08:02:15 UTC (rev 2113) @@ -55,7 +55,7 @@ <filter name="workingVersionFilter" condition=":filteredVersionNumber = versionNumber" /> </set> - <set name="imports" lazy="false" cascade="all" optimistic-lock="false"> + <set name="imports" lazy="false" table="RULESET_IMPORS" cascade="all" optimistic-lock="false"> <key column="RULESET_ID"/> <one-to-many class="org.drools.repository.ImportDef"/> <filter name="workingVersionFilter" condition=":filteredVersionNumber = versionNumber" /> Modified: trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/IntegrationTest.java =================================================================== --- trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/IntegrationTest.java 2006-01-17 02:46:13 UTC (rev 2112) +++ trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/IntegrationTest.java 2006-01-17 08:02:15 UTC (rev 2113) @@ -1,27 +1,169 @@ package org.drools.repository; +import java.util.Iterator; +import java.util.List; + import junit.framework.TestCase; +/** + * This integration test aims to do a full suite of scenarios. + * Including concurrent editing of rules, simulating multiple rules in parallel. + * + * Note that I am using stateful repository instances as it makes it easier to test. + * I can control when the session is closed etc in a single threaded test run. + * + * + * @author <a href="mailto:mic...@gm..."> Michael Neale</a> + */ public class IntegrationTest extends TestCase { - public void testStateful() { - RepositoryManager repo1 = RepositoryFactory.getStatefulRepository(); - RepositoryManager repo2 = RepositoryFactory.getStatefulRepository(); + + /** + * This will all execute as one JUnit test. + * Any failure will cause the test to stop, but this is not a unit test, + * so that is acceptable. + */ + public void testBootstrap() { + RepositoryManager repo = RepositoryFactory.getStatefulRepository(); - RuleDef rule1 = new RuleDef("repo1", "Dsadsadsadsa"); - repo1.save(rule1); - repo1.close(); - repo2.save(rule1); + // In the beginning there was a rule + RuleDef rule = new RuleDef("Integration rule 1", "rule { when bob likes cheese then print 'yeah' }"); + rule.setDocumentation("This is an initial rule"); + rule.addTag("CHEESE RULE"); + rule.setMetaData(new MetaData("a rule", "michael", "cheese", "something", "drl")); + repo.save(rule); -// RuleDef rule2 = repo2.loadRule("repo1", 1); -// rule2.setContent("ABNBNBN"); -// repo2.save(rule2); -// -// rule1.setContent("bnmbmnbmn"); -// repo1.save(rule1); + //now lets load that rule back + List list = repo.findRulesByTag("CHEESE RULE"); + assertEquals(1, list.size()); + rule = (RuleDef) list.get(0); + assertEquals("This is an initial rule", rule.getDocumentation()); + + // lets create a ruleset + MetaData meta = new MetaData(); + meta.setContributor("Michael"); + meta.setDescription("A test ruleset"); + RuleSetDef ruleSet = new RuleSetDef("Integration ruleset 1", meta); + RuleSetVersionInfo info = ruleSet.getCurrentVersionInfo(); + info.setStatus("draft"); + + //time to save it + repo.save(ruleSet); + + //now lets finish this session + repo.close(); + + //check we can load it up + repo = RepositoryFactory.getStatefulRepository(); + assertTrue(repo.listRuleSets().size() > 0); + ruleSet = repo.loadRuleSet("Integration ruleset 1", 1); + assertEquals("draft", ruleSet.getCurrentVersionInfo().getStatus()); + + //now lets work "disconnected" for a while + repo.close(); + + + //lets add the rule to it that we loaded before, and some other goodies + ruleSet.addRule(rule); + ruleSet.addRule(new RuleDef("Integration rule 2", "Some content")); + ruleSet.addFunction(new FunctionDef("this is a function", "blah blah blah")); + ruleSet.addApplicationData(new ApplicationDataDef("blah", "String")); + ruleSet.addImport(new ImportDef("java.lang.String")); + + repo = RepositoryFactory.getStatefulRepository(); + repo.save(ruleSet); + repo.close(); + + //now lets load it again, and work on it disconnected + repo = RepositoryFactory.getStatefulRepository(); + ruleSet = repo.loadRuleSet("Integration ruleset 1", 1); + repo.close(); + + //check its OK first + assertEquals("this is a function", ((FunctionDef) ruleSet.getFunctions().iterator().next()).getFunctionContent()); + assertEquals(2, ruleSet.getRules().size()); + + //now lets go and modify some rules + for ( Iterator iter = ruleSet.getRules().iterator(); iter.hasNext(); ) { + RuleDef myRule = (RuleDef) iter.next(); + myRule.setContent("CHANGED RULE TEXT"); + //this should cause us to have some rule history saved. + //this has nothing to do with ruleset versioning. + } + + //connect and save + repo = RepositoryFactory.getStatefulRepository(); + repo.save(ruleSet); + ruleSet = repo.loadRuleSet("Integration ruleset 1", 1); + + + //just to prove the save history, lets check the history of a rule + rule = ruleSet.findRuleByName("Integration rule 2"); + List history = repo.listRuleSaveHistory(rule); + assertEquals(1, history.size()); + RuleDef historicalRule = (RuleDef) history.get(0); + String oldContent = historicalRule.getContent(); + assertTrue(! oldContent.equals(rule.getContent())); + + //lets also check that the correct number of rules are on the ruleset, history is seperate + assertEquals(2, ruleSet.getRules().size()); + + //now lets create a new major version of the ruleset. + ruleSet.createNewVersion("New version", "pending"); + repo.save(ruleSet); + repo.close(); + + //now we will have 2 versions of the ruleset, lets load up the latest. + repo = RepositoryFactory.getStatefulRepository(); + ruleSet = repo.loadRuleSet("Integration ruleset 1", 2); + assertEquals(2, ruleSet.getVersionHistory().size()); + assertEquals("New version", ruleSet.getCurrentVersionInfo().getVersionComment()); + assertEquals("pending", ruleSet.getCurrentVersionInfo().getStatus()); + + + //lets add a rule to it (making 3 rules in total) + ruleSet.addRule(new RuleDef("Integration rule 3", "content")); + repo.save(ruleSet); + + //lets load up the old version, check that there is still only 2 rules + ruleSet = repo.loadRuleSet("Integration ruleset 1", 1); + assertEquals(2, ruleSet.getRules().size()); + assertEquals("draft", ruleSet.getCurrentVersionInfo().getStatus()); + + + repo.close(); + + + } + + /** + * Lets create 3 rulesets, each with 500 rules. + * Each RuleSet will have several functions, applicationdata, imports and so on. + * Rules will also have tags, a + * */ + public void initialDataSetup() { + create500CheeseRules(); + + + } + + + private void create500CheeseRules() { + RepositoryManager repo = RepositoryFactory.getStatefulRepository(); + + //lets build some rules, stand alone + for (int i = 0; i < 500; i ++) { + RuleDef rule = new RuleDef("cheese-rule-" + i, "The rule body here " + i); + rule.addTag("FIRST").addTag("NUM" + i); + repo.save(rule); + } + + repo.close(); + } + } Modified: trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/RulePersistenceTest.java =================================================================== --- trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/RulePersistenceTest.java 2006-01-17 02:46:13 UTC (rev 2112) +++ trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/RulePersistenceTest.java 2006-01-17 08:02:15 UTC (rev 2113) @@ -26,30 +26,35 @@ def.setContent("new content"); repo.save(def); - def = repo.loadRule("myRule3", 1); assertEquals(id, def.getId()); assertEquals("new content", def.getContent()); + def.removeTag("tag1"); + repo.save(def); + def = repo.loadRule("myRule3", 1); + assertEquals(2, def.getTags().size()); } public void testRetreieveRuleWithTags() { RepositoryManager repo = getRepo(); - RuleDef newRule = new RuleDef("my rule", "content"); - newRule.addTag("HR").addTag("SALARY"); + RuleDef newRule = new RuleDef("my rule RWT", "content"); + newRule.addTag("RWT").addTag("RWT2"); repo.save(newRule); - RuleDef rule = repo.loadRule("my rule", 1); + RuleDef rule = repo.loadRule("my rule RWT", 1); assertNotNull(rule); - assertEquals("my rule", rule.getName()); + assertEquals("my rule RWT", rule.getName()); Set tags = rule.getTags(); assertEquals(2, tags.size()); String[] tagList = rule.listTags(); - assertTrue(tagList[0].equals("HR") || tagList[0].equals("SALARY")); + assertTrue(tagList[0].equals("RWT") || tagList[0].equals("RWT2")); - List rules = repo.findRulesByTag("HR"); - assertTrue(rules.size() > 0); + List rules = repo.findRulesByTag("RWT"); + assertEquals(1, rules.size()); + rule = (RuleDef) rules.get(0); + assertEquals("my rule RWT", rule.getName()); } public void testRuleCopy() { Modified: trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/RuleSetPersistenceTest.java =================================================================== --- trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/RuleSetPersistenceTest.java 2006-01-17 02:46:13 UTC (rev 2112) +++ trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/RuleSetPersistenceTest.java 2006-01-17 08:02:15 UTC (rev 2113) @@ -321,8 +321,15 @@ assertEquals("search rule tags in set", ((RuleDef) list.get(0)).getName()); } + public void testFindWorkingVersionInfo() { + RuleSetDef ruleset = new RuleSetDef("nothing", null); + RuleSetVersionInfo info = ruleset.getCurrentVersionInfo(); + assertNotNull(info); + assertEquals(1, info.getVersionNumber()); + } + // public void testLargeNumbers() { // RuleSetDef large = new RuleSetDef("Large1", null); // |
From: <jbo...@li...> - 2006-01-17 02:46:22
|
Author: mic...@jb... Date: 2006-01-16 21:46:13 -0500 (Mon, 16 Jan 2006) New Revision: 2112 Modified: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/lang/ExpanderContext.java Log: doco change Modified: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/lang/ExpanderContext.java =================================================================== --- trunk/labs/jbossrules/drools-core/src/main/java/org/drools/lang/ExpanderContext.java 2006-01-16 21:49:57 UTC (rev 2111) +++ trunk/labs/jbossrules/drools-core/src/main/java/org/drools/lang/ExpanderContext.java 2006-01-17 02:46:13 UTC (rev 2112) @@ -53,6 +53,9 @@ } /** + * The parser should call this on an expression/line that potentially needs expanding + * BEFORE it parses that line (as the line may change radically as the result of expansion). + * * Expands the expression Just-In-Time for the parser. * If the expression is not meant to be expanded, or if no * appropriate expander is found, it will echo back the same |
From: <jbo...@li...> - 2006-01-16 21:50:08
|
Author: rem...@jb... Date: 2006-01-16 16:49:57 -0500 (Mon, 16 Jan 2006) New Revision: 2111 Modified: trunk/labs/jbossweb/src/share/classes/org/jboss/web/rewrite/Resolver.java trunk/labs/jbossweb/src/share/classes/org/jboss/web/rewrite/RewriteCond.java trunk/labs/jbossweb/src/share/classes/org/jboss/web/rewrite/RewriteMap.java trunk/labs/jbossweb/src/share/classes/org/jboss/web/rewrite/RewriteRule.java trunk/labs/jbossweb/src/share/classes/org/jboss/web/rewrite/RewriteTestCase.java trunk/labs/jbossweb/src/share/classes/org/jboss/web/rewrite/RewriteValve.java trunk/labs/jbossweb/src/share/classes/org/jboss/web/rewrite/Substitution.java trunk/labs/jbossweb/src/share/classes/org/jboss/web/rewrite/TomcatResolver.java Log: - The actual license for these files should be LGPL. Modified: trunk/labs/jbossweb/src/share/classes/org/jboss/web/rewrite/Resolver.java =================================================================== --- trunk/labs/jbossweb/src/share/classes/org/jboss/web/rewrite/Resolver.java 2006-01-16 19:11:04 UTC (rev 2110) +++ trunk/labs/jbossweb/src/share/classes/org/jboss/web/rewrite/Resolver.java 2006-01-16 21:49:57 UTC (rev 2111) @@ -1,18 +1,24 @@ /* - * Copyright 2005 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + * JBoss, Home of Professional Open Source + * Copyright 2006, JBoss Inc., and individual contributors as indicated + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ package org.jboss.web.rewrite; Modified: trunk/labs/jbossweb/src/share/classes/org/jboss/web/rewrite/RewriteCond.java =================================================================== --- trunk/labs/jbossweb/src/share/classes/org/jboss/web/rewrite/RewriteCond.java 2006-01-16 19:11:04 UTC (rev 2110) +++ trunk/labs/jbossweb/src/share/classes/org/jboss/web/rewrite/RewriteCond.java 2006-01-16 21:49:57 UTC (rev 2111) @@ -1,18 +1,24 @@ /* - * Copyright 2005 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + * JBoss, Home of Professional Open Source + * Copyright 2006, JBoss Inc., and individual contributors as indicated + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ package org.jboss.web.rewrite; Modified: trunk/labs/jbossweb/src/share/classes/org/jboss/web/rewrite/RewriteMap.java =================================================================== --- trunk/labs/jbossweb/src/share/classes/org/jboss/web/rewrite/RewriteMap.java 2006-01-16 19:11:04 UTC (rev 2110) +++ trunk/labs/jbossweb/src/share/classes/org/jboss/web/rewrite/RewriteMap.java 2006-01-16 21:49:57 UTC (rev 2111) @@ -1,18 +1,24 @@ /* - * Copyright 2005 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + * JBoss, Home of Professional Open Source + * Copyright 2006, JBoss Inc., and individual contributors as indicated + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ package org.jboss.web.rewrite; Modified: trunk/labs/jbossweb/src/share/classes/org/jboss/web/rewrite/RewriteRule.java =================================================================== --- trunk/labs/jbossweb/src/share/classes/org/jboss/web/rewrite/RewriteRule.java 2006-01-16 19:11:04 UTC (rev 2110) +++ trunk/labs/jbossweb/src/share/classes/org/jboss/web/rewrite/RewriteRule.java 2006-01-16 21:49:57 UTC (rev 2111) @@ -1,18 +1,24 @@ /* - * Copyright 2005 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + * JBoss, Home of Professional Open Source + * Copyright 2006, JBoss Inc., and individual contributors as indicated + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ package org.jboss.web.rewrite; Modified: trunk/labs/jbossweb/src/share/classes/org/jboss/web/rewrite/RewriteTestCase.java =================================================================== --- trunk/labs/jbossweb/src/share/classes/org/jboss/web/rewrite/RewriteTestCase.java 2006-01-16 19:11:04 UTC (rev 2110) +++ trunk/labs/jbossweb/src/share/classes/org/jboss/web/rewrite/RewriteTestCase.java 2006-01-16 21:49:57 UTC (rev 2111) @@ -1,18 +1,24 @@ /* - * Copyright 2005 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + * JBoss, Home of Professional Open Source + * Copyright 2006, JBoss Inc., and individual contributors as indicated + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ package org.jboss.web.rewrite; Modified: trunk/labs/jbossweb/src/share/classes/org/jboss/web/rewrite/RewriteValve.java =================================================================== --- trunk/labs/jbossweb/src/share/classes/org/jboss/web/rewrite/RewriteValve.java 2006-01-16 19:11:04 UTC (rev 2110) +++ trunk/labs/jbossweb/src/share/classes/org/jboss/web/rewrite/RewriteValve.java 2006-01-16 21:49:57 UTC (rev 2111) @@ -1,18 +1,24 @@ /* - * Copyright 2005 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + * JBoss, Home of Professional Open Source + * Copyright 2006, JBoss Inc., and individual contributors as indicated + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ package org.jboss.web.rewrite; Modified: trunk/labs/jbossweb/src/share/classes/org/jboss/web/rewrite/Substitution.java =================================================================== --- trunk/labs/jbossweb/src/share/classes/org/jboss/web/rewrite/Substitution.java 2006-01-16 19:11:04 UTC (rev 2110) +++ trunk/labs/jbossweb/src/share/classes/org/jboss/web/rewrite/Substitution.java 2006-01-16 21:49:57 UTC (rev 2111) @@ -1,18 +1,24 @@ /* - * Copyright 2005 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + * JBoss, Home of Professional Open Source + * Copyright 2006, JBoss Inc., and individual contributors as indicated + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ package org.jboss.web.rewrite; Modified: trunk/labs/jbossweb/src/share/classes/org/jboss/web/rewrite/TomcatResolver.java =================================================================== --- trunk/labs/jbossweb/src/share/classes/org/jboss/web/rewrite/TomcatResolver.java 2006-01-16 19:11:04 UTC (rev 2110) +++ trunk/labs/jbossweb/src/share/classes/org/jboss/web/rewrite/TomcatResolver.java 2006-01-16 21:49:57 UTC (rev 2111) @@ -1,18 +1,24 @@ /* - * Copyright 2005 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ + * JBoss, Home of Professional Open Source + * Copyright 2006, JBoss Inc., and individual contributors as indicated + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ package org.jboss.web.rewrite; |
Author: mic...@jb... Date: 2006-01-16 07:37:22 -0500 (Mon, 16 Jan 2006) New Revision: 2107 Added: trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RepositoryFactory.java trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RepositoryManager.java trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/db/RepoProxyHandler.java trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/IntegrationTest.java trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/RepositoryFactoryTest.java Removed: trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/Repository.java Modified: trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/db/RepositoryImpl.java trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/AttachmentPersistTest.java trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/LocalPersistTest.java trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/RulePersistenceTest.java trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/RuleSetPersistenceTest.java trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/db/PersistentCase.java Log: proxy to handle exceptions, stateful and stateless repo sessions supported Deleted: trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/Repository.java =================================================================== --- trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/Repository.java 2006-01-16 06:47:05 UTC (rev 2106) +++ trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/Repository.java 2006-01-16 12:37:22 UTC (rev 2107) @@ -1,7 +0,0 @@ -package org.drools.repository; - -public interface Repository { - - - -} Added: trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RepositoryFactory.java =================================================================== --- trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RepositoryFactory.java 2006-01-16 06:47:05 UTC (rev 2106) +++ trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RepositoryFactory.java 2006-01-16 12:37:22 UTC (rev 2107) @@ -0,0 +1,47 @@ +package org.drools.repository; + +import java.lang.reflect.Proxy; + +import org.drools.repository.db.RepoProxyHandler; + +/** + * This factory class provides instances of the repository in various flavours. + * + * This is the place to start. + * + * @author <a href="mailto:mic...@gm..."> Michael Neale</a> + */ +public final class RepositoryFactory { + + /** + * The default repository. This is stateless, meaning that a continuous connection is not required. + */ + public static RepositoryManager getRepository() { + RepoProxyHandler handler = new RepoProxyHandler(); + RepositoryManager manager = getProxy( handler ); + return manager; + } + + /** + * This repository is stateful, meaning that a connection to the repository database is + * expected to be available. + * If an error occurs, the repository is invalid and will have to be created again to + * "try again". + * This version can have performance benefits in some cases. + */ + public static RepositoryManager getStatefulRepository() { + RepoProxyHandler handler = new RepoProxyHandler(true); + RepositoryManager manager = getProxy( handler ); + return manager; + } + + private static RepositoryManager getProxy(RepoProxyHandler handler) { + RepositoryManager manager = (RepositoryManager) Proxy.newProxyInstance(RepositoryFactory.class.getClassLoader(), + new Class[] {RepositoryManager.class}, + handler); + return manager; + } + + + +} Property changes on: trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RepositoryFactory.java ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RepositoryManager.java =================================================================== --- trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RepositoryManager.java 2006-01-16 06:47:05 UTC (rev 2106) +++ trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RepositoryManager.java 2006-01-16 12:37:22 UTC (rev 2107) @@ -0,0 +1,70 @@ +package org.drools.repository; + +import java.util.List; + +/** + * The repository manager takes care of storing and sychronising the repository + * data with the repository database. + * + * This interface defines all the operations that cane be performed on the repository. + * A client using this must be able to have a connection to the repository. + * + * @author <a href="mailto:mic...@gm..."> Michael Neale</a> + */ +public interface RepositoryManager { + + /** + * This will simply save the current version of the rule. + * If there is a previous saved version of the rule, it will be stored as a historical record. + */ + public abstract void save(RuleDef newRule); + + public abstract RuleDef loadRule(String ruleName, + long versionNumber); + + /** + * This will return a list of rules of "major versions" - these are rules that have been + * part of a ruleset version. + */ + public abstract List listRuleVersions(String ruleName); + + public abstract List listRuleSaveHistory(RuleDef rule); + + public abstract List findRulesByTag(String tag); + + /** Save the ruleset. The Ruleset will not be reloaded. */ + public abstract void save(RuleSetDef ruleSet); + + /** + * This loads a RuleSet with the appropriate workingVersionNumber applied to + * its assets. + * + * @param workingVersionNumber + * The version of the ruleset and rules you want to work on. + * @param ruleSetName + * The ruleset name to retrieve (ruleset names must be unique). + */ + public abstract RuleSetDef loadRuleSet(String ruleSetName, + long workingVersionNumber); + + public abstract RuleSetAttachment loadAttachment(String name); + + public abstract void save(RuleSetAttachment attachment); + + /** Returns List<String> of Rule set names */ + public abstract List listRuleSets(); + + public abstract void delete(RuleDef rule); + + /** + * Searches the ruleset for a rule with a certain tag. This will search ALL + * VERSIONS. + */ + public abstract List searchRulesByTag(String ruleSetName, + String tag); + + + /** This is only required for stateful Repository session. It will be ignored for stateless ones */ + public abstract void close(); + +} \ No newline at end of file Property changes on: trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RepositoryManager.java ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/db/RepoProxyHandler.java =================================================================== --- trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/db/RepoProxyHandler.java 2006-01-16 06:47:05 UTC (rev 2106) +++ trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/db/RepoProxyHandler.java 2006-01-16 12:37:22 UTC (rev 2107) @@ -0,0 +1,114 @@ +package org.drools.repository.db; + +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +import org.hibernate.Session; +import org.hibernate.Transaction; + +/** + * Dynamic proxy handler for all persistence operations. + * Keeps the hibernate session and transaction handling away from the repository implementation. + * + * This is the glue between the actual implementation and the interface. + * Kind of like poor mans aspects. But I couldn't justify AOP for this little thing. + * + * @author <a href="mailto:mic...@gm..."> Michael Neale</a> + */ +public class RepoProxyHandler + implements + InvocationHandler { + + + private RepositoryImpl repoImpl = new RepositoryImpl(); + private Session session = null; + private boolean stateful = false; + + + /** + * This is essentially for stateless repository access. + * Default implementation uses hibernates getCurrentSession to + * work with the current session. + */ + public RepoProxyHandler() { + } + + /** + * Allows stateful access of the repository. + * @param stateful True if stateful operation is desired. + */ + public RepoProxyHandler(boolean stateful) { + if (stateful) { + this.session = HibernateUtil.getSessionFactory().openSession(); + this.stateful = true; + } + } + + /** + * This will initialise the session to the correct state. + * Allows both stateless and stateful repository options. + */ + public Object invoke(Object proxy, + Method method, + Object[] args) throws Throwable { + + + Session session = getCurrentSession(); + + if (this.stateful && method.getName().equals("close")) { + session.close(); + return null; + } + + Transaction tx = null; + try { + tx = session.beginTransaction(); + configureSession( session ); + Object result = method.invoke(repoImpl, args); + session.flush(); + tx.commit(); + return result; + } + catch (InvocationTargetException e) { + rollback( tx ); + throw e.getTargetException(); + } + catch (Exception e) { + rollback( tx ); + throw e; + } + } + + private void rollback(Transaction tx) { + if (tx !=null) { + tx.rollback(); + } + } + + + /** + * Set the connection for the listeners to use (they use their own session). + * Enable the default filters for historical stuff + * and then provide the session to the repo implementation. + */ + private void configureSession(Session session) { + StoreEventListener.setCurrentConnection( session.connection() ); + repoImpl.enableHistoryFilter( session ); + repoImpl.injectSession( session ); + } + + + /** + * Uses a different session depending on if it is stateful or not. + */ + private Session getCurrentSession() { + if (stateful) { + return session; + } else { + return HibernateUtil.getSessionFactory().getCurrentSession(); + } + } + + +} Property changes on: trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/db/RepoProxyHandler.java ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/db/RepositoryImpl.java =================================================================== --- trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/db/RepositoryImpl.java 2006-01-16 06:47:05 UTC (rev 2106) +++ trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/db/RepositoryImpl.java 2006-01-16 12:37:22 UTC (rev 2107) @@ -2,7 +2,8 @@ import java.util.List; -import org.drools.repository.Repository; + +import org.drools.repository.RepositoryManager; import org.drools.repository.RuleDef; import org.drools.repository.RuleSetAttachment; import org.drools.repository.RuleSetDef; @@ -17,89 +18,86 @@ */ public class RepositoryImpl implements - Repository { + RepositoryManager { - /** This will simply save the current version of the rule */ + private Session session; + + public void injectSession(Session session) { + this.session = session; + } + + /* (non-Javadoc) + * @see org.drools.repository.db.RepositoryManager#save(org.drools.repository.RuleDef) + */ public void save(RuleDef newRule) { - Session session = getSessionNewTx(); - session.saveOrUpdate( newRule ); - - commit( session ); } + /* (non-Javadoc) + * @see org.drools.repository.db.RepositoryManager#loadRule(java.lang.String, long) + */ public RuleDef loadRule(String ruleName, long versionNumber) { - Session session = getSessionNewTx(); + RuleDef result = (RuleDef) session.createQuery( "from RuleDef where name = :name and versionNumber = :version" ) + .setString( "name", ruleName ) + .setLong( "version", versionNumber ) + .uniqueResult(); - RuleDef result = (RuleDef) session.createQuery( "from RuleDef where name = :name and versionNumber = :version" ).setString( "name", - ruleName ).setLong( "version", - versionNumber ).uniqueResult(); - - commit( session ); return result; } + /* (non-Javadoc) + * @see org.drools.repository.db.RepositoryManager#listRuleVersions(java.lang.String) + */ public List listRuleVersions(String ruleName) { - Session session = getSessionNewTx(); - - List result = (List) session.createQuery( "from RuleDef where name = :name order by versionNumber" ).setString( "name", - ruleName ).list(); - - commit( session ); + List result = (List) session.createQuery( "from RuleDef where name = :name order by versionNumber" ) + .setString( "name", ruleName ).list(); return result; } + /* (non-Javadoc) + * @see org.drools.repository.db.RepositoryManager#listRuleSaveHistory(org.drools.repository.RuleDef) + */ public List listRuleSaveHistory(RuleDef rule) { - Session session = getSessionNewTx(); disableHistoryFilter( session ); List result = (List) session.createQuery( "from RuleDef where historicalId = :id" ).setLong( "id", rule.getId().longValue() ).list(); enableHistoryFilter( session ); - commit( session ); return result; } + /* (non-Javadoc) + * @see org.drools.repository.db.RepositoryManager#findRulesByTag(java.lang.String) + */ public List findRulesByTag(String tag) { - Session session = getSessionNewTx(); List result = session.createQuery( "from RuleDef as rule " + "join rule.tags as tags " + "where tags.tag = :tag" ).setString( "tag", tag ).list(); - commit( session ); return result; } - /** Save the ruleset. The Ruleset will not be reloaded. */ + /* (non-Javadoc) + * @see org.drools.repository.db.RepositoryManager#save(org.drools.repository.RuleSetDef) + */ public void save(RuleSetDef ruleSet) { - Session session = getSessionNewTx(); session.saveOrUpdate( ruleSet ); - commit( session ); } - /** - * This loads a RuleSet with the appropriate workingVersionNumber applied to - * its assets. - * - * @param workingVersionNumber - * The version of the ruleset and rules you want to work on. - * @param ruleSetName - * The ruleset name to retrieve (ruleset names must be unique). + /* (non-Javadoc) + * @see org.drools.repository.db.RepositoryManager#loadRuleSet(java.lang.String, long) */ public RuleSetDef loadRuleSet(String ruleSetName, long workingVersionNumber) { - Session session = getSessionNewTx(); - - enableVersionFilter( workingVersionNumber, + enableWorkingVersionFilter( workingVersionNumber, session ); RuleSetDef def = loadRuleSetByName( ruleSetName, session ); def.setWorkingVersionNumber( workingVersionNumber ); - disableVersionFilter( session ); - commit( session ); + disableWorkingVersionFilter( session ); return def; } @@ -110,83 +108,77 @@ return def; } + /* (non-Javadoc) + * @see org.drools.repository.db.RepositoryManager#loadAttachment(java.lang.String) + */ public RuleSetAttachment loadAttachment(String name) { - Session session = getSessionNewTx(); - RuleSetAttachment at = (RuleSetAttachment) session.createQuery( "from RuleSetAttachment where name = :name" ).setString( "name", - name ).uniqueResult(); - commit( session ); + RuleSetAttachment at = (RuleSetAttachment) session.createQuery( "from RuleSetAttachment where name = :name" ) + .setString( "name",name ).uniqueResult(); return at; } + /* (non-Javadoc) + * @see org.drools.repository.db.RepositoryManager#save(org.drools.repository.RuleSetAttachment) + */ public void save(RuleSetAttachment attachment) { - Session session = getSessionNewTx(); session.saveOrUpdate( attachment ); - commit( session ); } - /** Returns List<String> of Rule set names */ + /* (non-Javadoc) + * @see org.drools.repository.db.RepositoryManager#listRuleSets() + */ public List listRuleSets() { - Session session = getSessionNewTx(); List list = session.createQuery( "select distinct name from RuleSetDef where name is not null" ).list(); - commit( session ); return list; } + /* (non-Javadoc) + * @see org.drools.repository.db.RepositoryManager#delete(org.drools.repository.RuleDef) + */ public void delete(RuleDef rule) { - Session session = getSessionNewTx(); session.delete( rule ); - commit( session ); } - /** - * Searches the ruleset for a rule with a certain tag. This will search ALL - * VERSIONS. + /* (non-Javadoc) + * @see org.drools.repository.db.RepositoryManager#searchRulesByTag(java.lang.String, java.lang.String) */ public List searchRulesByTag(String ruleSetName, String tag) { - Session session = getSessionNewTx(); - RuleSetDef def = loadRuleSetByName( ruleSetName, session ); List list = session.createFilter( def.getRules(), "where this.tags.tag = :tag" ).setString( "tag", tag ).list(); - commit( session ); - session.close(); + return list; } - private void commit(Session session) { - session.getTransaction().commit(); - } - private Session getSessionNewTx() { - Session session = HibernateUtil.getSessionFactory().getCurrentSession(); - - session.beginTransaction(); - StoreEventListener.setCurrentConnection( session.connection() ); - enableHistoryFilter( session ); - - return session; - } - - private void enableHistoryFilter(Session session) { + ////////////////////////// + // Filters follow + ////////////////////////// + void enableHistoryFilter(Session session) { session.enableFilter( "historyFilter" ).setParameter( "viewHistory", Boolean.FALSE ); } - private void disableHistoryFilter(Session session) { + void disableHistoryFilter(Session session) { session.disableFilter( "historyFilter" ); } - private void enableVersionFilter(long workingVersionNumber, + void enableWorkingVersionFilter(long workingVersionNumber, Session session) { session.enableFilter( "workingVersionFilter" ).setParameter( "filteredVersionNumber", new Long( workingVersionNumber ) ); } - private void disableVersionFilter(Session session) { + void disableWorkingVersionFilter(Session session) { session.disableFilter( "workingVersionFilter" ); } + + public void close() { /*implemented by the proxy */} + + + } Modified: trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/AttachmentPersistTest.java =================================================================== --- trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/AttachmentPersistTest.java 2006-01-16 06:47:05 UTC (rev 2106) +++ trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/AttachmentPersistTest.java 2006-01-16 12:37:22 UTC (rev 2107) @@ -1,13 +1,12 @@ package org.drools.repository; import org.drools.repository.db.PersistentCase; -import org.drools.repository.db.RepositoryImpl; public class AttachmentPersistTest extends PersistentCase { public void testLoadSave() { RuleSetAttachment at = new RuleSetAttachment("test","test", "test".getBytes(), "blah.xml" ); - RepositoryImpl repo = getRepo(); + RepositoryManager repo = getRepo(); repo.save(at); RuleSetAttachment at2 = repo.loadAttachment("test"); assertEquals("test", at2.getTypeOfAttachment()); Added: trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/IntegrationTest.java =================================================================== --- trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/IntegrationTest.java 2006-01-16 06:47:05 UTC (rev 2106) +++ trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/IntegrationTest.java 2006-01-16 12:37:22 UTC (rev 2107) @@ -0,0 +1,27 @@ +package org.drools.repository; + +import junit.framework.TestCase; + +public class IntegrationTest extends TestCase { + + + public void testStateful() { + RepositoryManager repo1 = RepositoryFactory.getStatefulRepository(); + RepositoryManager repo2 = RepositoryFactory.getStatefulRepository(); + + RuleDef rule1 = new RuleDef("repo1", "Dsadsadsadsa"); + repo1.save(rule1); + repo1.close(); + repo2.save(rule1); + +// RuleDef rule2 = repo2.loadRule("repo1", 1); +// rule2.setContent("ABNBNBN"); +// repo2.save(rule2); +// +// rule1.setContent("bnmbmnbmn"); +// repo1.save(rule1); + + + } + +} Property changes on: trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/IntegrationTest.java ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/LocalPersistTest.java =================================================================== --- trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/LocalPersistTest.java 2006-01-16 06:47:05 UTC (rev 2106) +++ trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/LocalPersistTest.java 2006-01-16 12:37:22 UTC (rev 2107) @@ -1,7 +1,6 @@ package org.drools.repository; import org.drools.repository.db.PersistentCase; -import org.drools.repository.db.RepositoryImpl; import com.thoughtworks.xstream.XStream; import com.thoughtworks.xstream.io.xml.DomDriver; @@ -17,7 +16,7 @@ def = (RuleSetDef) xstream.fromXML(xml); - RepositoryImpl repo = getRepo(); + RepositoryManager repo = getRepo(); repo.save(def); def = repo.loadRuleSet("xstream1", 1); Added: trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/RepositoryFactoryTest.java =================================================================== --- trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/RepositoryFactoryTest.java 2006-01-16 06:47:05 UTC (rev 2106) +++ trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/RepositoryFactoryTest.java 2006-01-16 12:37:22 UTC (rev 2107) @@ -0,0 +1,13 @@ +package org.drools.repository; + +import junit.framework.TestCase; + +public class RepositoryFactoryTest extends TestCase { + + public void testFactory() { + RepositoryManager manager = RepositoryFactory.getRepository(); + assertNotNull(manager); + manager.listRuleSets(); + } + +} Property changes on: trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/RepositoryFactoryTest.java ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/RulePersistenceTest.java =================================================================== --- trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/RulePersistenceTest.java 2006-01-16 06:47:05 UTC (rev 2106) +++ trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/RulePersistenceTest.java 2006-01-16 12:37:22 UTC (rev 2107) @@ -6,12 +6,11 @@ import org.drools.repository.MetaData; import org.drools.repository.RuleDef; import org.drools.repository.db.PersistentCase; -import org.drools.repository.db.RepositoryImpl; public class RulePersistenceTest extends PersistentCase { public void testStoreNewRuleDef() throws Exception { - RepositoryImpl repo = getRepo(); + RepositoryManager repo = getRepo(); RuleDef def = new RuleDef("myRule", "A rule"); repo.save(def); assertNotNull(def.getId()); @@ -35,7 +34,7 @@ } public void testRetreieveRuleWithTags() { - RepositoryImpl repo = getRepo(); + RepositoryManager repo = getRepo(); RuleDef newRule = new RuleDef("my rule", "content"); newRule.addTag("HR").addTag("SALARY"); repo.save(newRule); @@ -54,7 +53,7 @@ } public void testRuleCopy() { - RepositoryImpl repo = getRepo(); + RepositoryManager repo = getRepo(); RuleDef rule1 = new RuleDef("newVersionTest", "XXX"); rule1.addTag("HR").addTag("BOO"); @@ -77,7 +76,7 @@ rs.addRule(new RuleDef("rh2", "xxxxx")); rs.addRule(new RuleDef("rh3", "xxxxx")); - RepositoryImpl repo = getRepo(); + RepositoryManager repo = getRepo(); repo.save(rs); rs = repo.loadRuleSet("rule history", 1); Modified: trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/RuleSetPersistenceTest.java =================================================================== --- trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/RuleSetPersistenceTest.java 2006-01-16 06:47:05 UTC (rev 2106) +++ trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/RuleSetPersistenceTest.java 2006-01-16 12:37:22 UTC (rev 2107) @@ -6,7 +6,6 @@ import java.util.Set; import org.drools.repository.db.PersistentCase; -import org.drools.repository.db.RepositoryImpl; /** * Some quasi unit tests, and some quasi integration tests including versioning. @@ -23,7 +22,7 @@ RuleSetDef def = new RuleSetDef("my ruleset", meta); def.addTag("ME"); def.addRule(new RuleDef("simple", "x")); - RepositoryImpl repo = getRepo(); + RepositoryManager repo = getRepo(); repo.save(def); RuleSetDef def2 = repo.loadRuleSet("my ruleset", 1); @@ -64,7 +63,7 @@ ruleSet.addRule(def); ruleSet.addTag("HR"); - RepositoryImpl repo = getRepo(); + RepositoryManager repo = getRepo(); repo.save(ruleSet); RuleSetDef loaded = repo.loadRuleSet("Uber 1", 1); @@ -83,7 +82,7 @@ "file.txt"); ruleSet.addAttachment(attachment); - RepositoryImpl repo = getRepo(); + RepositoryManager repo = getRepo(); repo.save(ruleSet); RuleSetDef result = repo.loadRuleSet("Attachmate", 1); @@ -102,7 +101,7 @@ history.add(info2); def.setVersionHistory(history); - RepositoryImpl repo = getRepo(); + RepositoryManager repo = getRepo(); repo.save(def); RuleSetDef def2 = repo.loadRuleSet("WithHistory", 1); @@ -114,7 +113,7 @@ RuleDef rule = new RuleDef("addRemove Rule", "xxx"); def.addRule(rule); - RepositoryImpl repo = getRepo(); + RepositoryManager repo = getRepo(); //save and load it fresh repo.save(def); @@ -175,7 +174,7 @@ } - RepositoryImpl repo = getRepo(); + RepositoryManager repo = getRepo(); repo.save(set); //now when we load it, the filter only loads the workingVersion that we specify @@ -226,7 +225,7 @@ RuleSetDef def = new RuleSetDef("para", null); def.addRule(new RuleDef("para1","sss")); - RepositoryImpl repo = getRepo(); + RepositoryManager repo = getRepo(); repo.save(def); //create a new version @@ -266,7 +265,7 @@ public void testSaveHistoryFromCascade() { RuleSetDef old = new RuleSetDef("something old", null); - RepositoryImpl repo = getRepo(); + RepositoryManager repo = getRepo(); RuleDef newRule = new RuleDef("save history 2", "ABC"); old.addRule(newRule); @@ -286,7 +285,7 @@ public void testRuleSetWithFunction() { RuleSetDef def = new RuleSetDef("with functions", null); def.addFunction(new FunctionDef("abc", "123")); - RepositoryImpl repo = getRepo(); + RepositoryManager repo = getRepo(); repo.save(def); def = repo.loadRuleSet("with functions", 1); @@ -311,7 +310,7 @@ } public void testRuleSetSearchRuleTags() { - RepositoryImpl repo = getRepo(); + RepositoryManager repo = getRepo(); RuleSetDef def = new RuleSetDef("rules with tags", null); RuleDef rule = new RuleDef("search rule tags in set", "fdsfdsfds"); rule.addTag("HR"); Modified: trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/db/PersistentCase.java =================================================================== --- trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/db/PersistentCase.java 2006-01-16 06:47:05 UTC (rev 2106) +++ trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/db/PersistentCase.java 2006-01-16 12:37:22 UTC (rev 2107) @@ -1,5 +1,8 @@ package org.drools.repository.db; +import org.drools.repository.RepositoryFactory; +import org.drools.repository.RepositoryManager; + import junit.framework.TestCase; public class PersistentCase extends TestCase { @@ -9,10 +12,8 @@ getRepo(); } - - public RepositoryImpl getRepo() { - RepositoryImpl repo = new RepositoryImpl(); - return repo; + public RepositoryManager getRepo() { + return RepositoryFactory.getRepository(); } |
From: <jbo...@li...> - 2006-01-16 06:47:19
|
Author: mic...@jb... Date: 2006-01-16 01:47:05 -0500 (Mon, 16 Jan 2006) New Revision: 2106 Added: trunk/labs/jbossrules/drools-repository/src/test/resources/drools-repository-db.cfg.xml Removed: trunk/labs/jbossrules/drools-repository/src/test/resources/hibernate.cfg.xml Modified: trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/db/HibernateUtil.java trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/db/RepositoryImpl.java trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/db/StoreEventListener.java Log: better configuration Modified: trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/db/HibernateUtil.java =================================================================== --- trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/db/HibernateUtil.java 2006-01-16 03:51:58 UTC (rev 2105) +++ trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/db/HibernateUtil.java 2006-01-16 06:47:05 UTC (rev 2106) @@ -1,9 +1,23 @@ package org.drools.repository.db; + + +import org.drools.repository.ApplicationDataDef; +import org.drools.repository.FunctionDef; +import org.drools.repository.ImportDef; +import org.drools.repository.RuleDef; +import org.drools.repository.RuleSetAttachment; +import org.drools.repository.RuleSetDef; +import org.drools.repository.RuleSetVersionInfo; +import org.drools.repository.Tag; import org.hibernate.SessionFactory; import org.hibernate.cfg.Configuration; -import org.hibernate.event.SaveOrUpdateEventListener; +/** + * The usual hibernate helper, with a few tweaks. + * @author <a href="mailto:mic...@gm..."> Michael Neale</a> + * + */ public class HibernateUtil { private static final SessionFactory sessionFactory; @@ -11,10 +25,11 @@ static { try { - // Create the SessionFactory from hibernate.cfg.xml - Configuration cfg = new Configuration(); + Configuration cfg = new Configuration(); cfg.setInterceptor( new StoreEventListener() ); - cfg.configure(); + registerPersistentClasses( cfg ); + cfg.configure("drools-repository-db.cfg.xml"); + sessionFactory = cfg.buildSessionFactory(); } catch ( Throwable ex ) { @@ -24,6 +39,21 @@ } } + /** + * Use class based registration for refactor-friendly goodness. + */ + private static void registerPersistentClasses(Configuration cfg) { + cfg + .addClass(ApplicationDataDef.class) + .addClass(FunctionDef.class) + .addClass(RuleDef.class) + .addClass(Tag.class) + .addClass(RuleSetDef.class) + .addClass(RuleSetAttachment.class) + .addClass(RuleSetVersionInfo.class) + .addClass(ImportDef.class); + } + public static SessionFactory getSessionFactory() { return sessionFactory; } Modified: trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/db/RepositoryImpl.java =================================================================== --- trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/db/RepositoryImpl.java 2006-01-16 03:51:58 UTC (rev 2105) +++ trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/db/RepositoryImpl.java 2006-01-16 06:47:05 UTC (rev 2106) @@ -8,195 +8,185 @@ import org.drools.repository.RuleSetDef; import org.hibernate.Session; - /** - * The repository manager takes care of storing and sychronising the repository data with - * the repository database. + * The repository manager takes care of storing and sychronising the repository + * data with the repository database. + * + * @author <a href ="mailto:suj...@co..."> Sujit Pal </a> * @author <a href="mailto:mic...@gm..."> Michael Neale</a> */ -public class RepositoryImpl implements Repository { +public class RepositoryImpl + implements + Repository { /** This will simply save the current version of the rule */ public void save(RuleDef newRule) { Session session = getSessionNewTx(); - session.saveOrUpdate(newRule); + session.saveOrUpdate( newRule ); commit( session ); } - - - - public RuleDef loadRule(String ruleName, long versionNumber) { + public RuleDef loadRule(String ruleName, + long versionNumber) { Session session = getSessionNewTx(); - - RuleDef result = (RuleDef) session.createQuery("from RuleDef where name = :name and versionNumber = :version") - .setString("name", ruleName) - .setLong("version", versionNumber).uniqueResult(); - + + RuleDef result = (RuleDef) session.createQuery( "from RuleDef where name = :name and versionNumber = :version" ).setString( "name", + ruleName ).setLong( "version", + versionNumber ).uniqueResult(); + commit( session ); return result; } - + public List listRuleVersions(String ruleName) { Session session = getSessionNewTx(); - - List result = (List) session.createQuery("from RuleDef where name = :name order by versionNumber") - .setString("name", ruleName).list(); - + + List result = (List) session.createQuery( "from RuleDef where name = :name order by versionNumber" ).setString( "name", + ruleName ).list(); + commit( session ); - return result; + return result; } - + public List listRuleSaveHistory(RuleDef rule) { Session session = getSessionNewTx(); - disableHistoryFilter(session); - - List result = (List) session.createQuery("from RuleDef where historicalId = :id") - .setLong("id", rule.getId().longValue()).list(); - - enableHistoryFilter(session); + disableHistoryFilter( session ); + + List result = (List) session.createQuery( "from RuleDef where historicalId = :id" ).setLong( "id", + rule.getId().longValue() ).list(); + + enableHistoryFilter( session ); commit( session ); return result; } - + public List findRulesByTag(String tag) { Session session = getSessionNewTx(); - List result = session.createQuery("from RuleDef as rule " + - "join rule.tags as tags " + - "where tags.tag = :tag") - .setString("tag", tag) - .list(); + List result = session.createQuery( "from RuleDef as rule " + + "join rule.tags as tags " + + "where tags.tag = :tag" ).setString( "tag", tag ).list(); commit( session ); return result; } - - /** Save the ruleset. The Ruleset will not be reloaded. */ public void save(RuleSetDef ruleSet) { - Session session = getSessionNewTx(); - session.saveOrUpdate(ruleSet); + Session session = getSessionNewTx(); + session.saveOrUpdate( ruleSet ); commit( session ); } - - /** - * This loads a RuleSet with the appropriate workingVersionNumber applied to its assets. - * @param workingVersionNumber The version of the ruleset and rules you want to work on. - * @param ruleSetName The ruleset name to retrieve (ruleset names must be unique). + + /** + * This loads a RuleSet with the appropriate workingVersionNumber applied to + * its assets. + * + * @param workingVersionNumber + * The version of the ruleset and rules you want to work on. + * @param ruleSetName + * The ruleset name to retrieve (ruleset names must be unique). */ - public RuleSetDef loadRuleSet(String ruleSetName, long workingVersionNumber) { + public RuleSetDef loadRuleSet(String ruleSetName, + long workingVersionNumber) { Session session = getSessionNewTx(); - + enableVersionFilter( workingVersionNumber, session ); - + RuleSetDef def = loadRuleSetByName( ruleSetName, - session ); - def.setWorkingVersionNumber(workingVersionNumber); - + session ); + def.setWorkingVersionNumber( workingVersionNumber ); + disableVersionFilter( session ); commit( session ); return def; } - - - private RuleSetDef loadRuleSetByName(String ruleSetName, Session session) { - RuleSetDef def = (RuleSetDef) - session.createQuery("from RuleSetDef where name = :name") - .setString("name", ruleSetName ).uniqueResult(); + RuleSetDef def = (RuleSetDef) session.createQuery( "from RuleSetDef where name = :name" ).setString( "name", + ruleSetName ).uniqueResult(); return def; } - public RuleSetAttachment loadAttachment(String name) { Session session = getSessionNewTx(); - RuleSetAttachment at = (RuleSetAttachment) - session.createQuery("from RuleSetAttachment where name = :name") - .setString("name", name) - .uniqueResult(); + RuleSetAttachment at = (RuleSetAttachment) session.createQuery( "from RuleSetAttachment where name = :name" ).setString( "name", + name ).uniqueResult(); commit( session ); - return at; - } + return at; + } - - - public void save(RuleSetAttachment attachment) { Session session = getSessionNewTx(); - session.saveOrUpdate(attachment); + session.saveOrUpdate( attachment ); commit( session ); } - - + /** Returns List<String> of Rule set names */ public List listRuleSets() { Session session = getSessionNewTx(); - List list = session.createQuery("select name from RuleSetDef where name is not null").list(); + List list = session.createQuery( "select distinct name from RuleSetDef where name is not null" ).list(); commit( session ); return list; } - + public void delete(RuleDef rule) { Session session = getSessionNewTx(); - session.delete(rule); + session.delete( rule ); commit( session ); } - - /** - * Searches the ruleset for a rule with a certain tag. - * This will search ALL VERSIONS. + /** + * Searches the ruleset for a rule with a certain tag. This will search ALL + * VERSIONS. */ - public List searchRulesByTag(String ruleSetName, String tag) { + public List searchRulesByTag(String ruleSetName, + String tag) { Session session = getSessionNewTx(); - - RuleSetDef def = loadRuleSetByName(ruleSetName, session); - List list = session.createFilter(def.getRules(), - "where this.tags.tag = :tag") - .setString("tag", tag).list(); + + RuleSetDef def = loadRuleSetByName( ruleSetName, + session ); + List list = session.createFilter( def.getRules(), + "where this.tags.tag = :tag" ).setString( "tag", + tag ).list(); commit( session ); session.close(); return list; } - - - private void commit(Session session) { session.getTransaction().commit(); } - - - - private Session getSessionNewTx(){ + + private Session getSessionNewTx() { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); - session.beginTransaction(); + + session.beginTransaction(); + StoreEventListener.setCurrentConnection( session.connection() ); enableHistoryFilter( session ); + return session; } private void enableHistoryFilter(Session session) { - session.enableFilter("historyFilter").setParameter("viewHistory", Boolean.FALSE); + session.enableFilter( "historyFilter" ).setParameter( "viewHistory", + Boolean.FALSE ); } - + private void disableHistoryFilter(Session session) { - session.disableFilter("historyFilter"); + session.disableFilter( "historyFilter" ); } - + private void enableVersionFilter(long workingVersionNumber, - Session session){ - session.enableFilter("workingVersionFilter") - .setParameter("filteredVersionNumber", - new Long(workingVersionNumber)); + Session session) { + session.enableFilter( "workingVersionFilter" ).setParameter( "filteredVersionNumber", + new Long( workingVersionNumber ) ); } - private void disableVersionFilter(Session session){ - session.disableFilter("workingVersionFilter"); - } - + private void disableVersionFilter(Session session) { + session.disableFilter( "workingVersionFilter" ); + } + } Modified: trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/db/StoreEventListener.java =================================================================== --- trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/db/StoreEventListener.java 2006-01-16 03:51:58 UTC (rev 2105) +++ trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/db/StoreEventListener.java 2006-01-16 06:47:05 UTC (rev 2106) @@ -1,6 +1,7 @@ package org.drools.repository.db; import java.io.Serializable; +import java.sql.Connection; import java.util.Iterator; import org.drools.repository.ISaveHistory; @@ -21,6 +22,10 @@ public class StoreEventListener extends EmptyInterceptor { private static final long serialVersionUID = -5634072610999632779L; + + //use a threadlocal to get the currentConnection, + //as we may not always use currentSession semantics. + private static ThreadLocal currentConnection = new ThreadLocal(); public boolean onFlushDirty(Object entity, Serializable id, @@ -37,8 +42,8 @@ private void handleSaveHistory(Object entity) { ISaveHistory versionable = (ISaveHistory) entity; - Session current = getSessionFactory().getCurrentSession(); - Session session = getSessionFactory().openSession( current.connection() ); + + Session session = getSessionFactory().openSession( (Connection) currentConnection.get() ); System.out.println( "POSSIBLY SAVING COPY" ); @@ -66,6 +71,14 @@ } } + + /** + * Used to set the current session so the interceptor can access it. + * @param session + */ + public static void setCurrentConnection(Connection conn) { + currentConnection.set(conn); + } // public boolean onFlushDirty(Object entity, // Serializable id, Copied: trunk/labs/jbossrules/drools-repository/src/test/resources/drools-repository-db.cfg.xml (from rev 2105, trunk/labs/jbossrules/drools-repository/src/test/resources/hibernate.cfg.xml) =================================================================== --- trunk/labs/jbossrules/drools-repository/src/test/resources/hibernate.cfg.xml 2006-01-16 03:51:58 UTC (rev 2105) +++ trunk/labs/jbossrules/drools-repository/src/test/resources/drools-repository-db.cfg.xml 2006-01-16 06:47:05 UTC (rev 2106) @@ -0,0 +1,50 @@ +<?xml version='1.0' encoding='utf-8'?> +<!DOCTYPE hibernate-configuration PUBLIC + "-//Hibernate/Hibernate Configuration DTD 3.0//EN" + "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> + +<!-- + **** Drools Repository database configuration. **** + As you can see from the DTD, this makes use of Hibernate 3 for persistence and querying. + + This file is configured for HSQLDB in memory operation (not recommended for production). + + ****************************************************************************** + To provide your own configuration, place your own drools-repository-db.cfg.xml + in the front of the classpath (at the root). + ****************************************************************************** + --> + +<hibernate-configuration> + + <session-factory> + + <!-- Database connection settings --> + <property name="connection.driver_class">org.hsqldb.jdbcDriver</property> + <property name="connection.url">jdbc:hsqldb:mem:unittest</property> + + <property name="connection.username">sa</property> + <property name="connection.password"></property> + + <!-- JDBC connection pool (use the built-in) --> + <property name="connection.pool_size">1</property> + + <!-- SQL dialect --> + <property name="dialect">org.hibernate.dialect.HSQLDialect</property> + + <!-- Enable Hibernate's automatic session context management --> + <property name="current_session_context_class">thread</property> + + <!-- Disable the second-level cache --> + <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property> + + <!-- Echo all executed SQL to stdout --> + <property name="show_sql">false</property> + + <!-- Drop and re-create the database schema on startup --> + <property name="hbm2ddl.auto">create</property> + + + </session-factory> + +</hibernate-configuration> \ No newline at end of file Deleted: trunk/labs/jbossrules/drools-repository/src/test/resources/hibernate.cfg.xml =================================================================== --- trunk/labs/jbossrules/drools-repository/src/test/resources/hibernate.cfg.xml 2006-01-16 03:51:58 UTC (rev 2105) +++ trunk/labs/jbossrules/drools-repository/src/test/resources/hibernate.cfg.xml 2006-01-16 06:47:05 UTC (rev 2106) @@ -1,48 +0,0 @@ -<?xml version='1.0' encoding='utf-8'?> -<!DOCTYPE hibernate-configuration PUBLIC - "-//Hibernate/Hibernate Configuration DTD 3.0//EN" - "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> - -<hibernate-configuration> - - <session-factory> - - <!-- Database connection settings --> - <property name="connection.driver_class">org.hsqldb.jdbcDriver</property> - <property name="connection.url">jdbc:hsqldb:mem:unittest</property> - - <property name="connection.username">sa</property> - <property name="connection.password"></property> - - <!-- JDBC connection pool (use the built-in) --> - <property name="connection.pool_size">1</property> - - <!-- SQL dialect --> - <property name="dialect">org.hibernate.dialect.HSQLDialect</property> - - <!-- Enable Hibernate's automatic session context management --> - <property name="current_session_context_class">thread</property> - - <!-- Disable the second-level cache --> - <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property> - - <!-- Echo all executed SQL to stdout --> - <property name="show_sql">false</property> - - <!-- Drop and re-create the database schema on startup --> - <property name="hbm2ddl.auto">create</property> - - <!-- add in all the objects below --> - <mapping resource="org/drools/repository/RuleDef.hbm.xml"/> - <mapping resource="org/drools/repository/Tag.hbm.xml"/> - <mapping resource="org/drools/repository/RuleSetDef.hbm.xml"/> - <mapping resource="org/drools/repository/RuleSetAttachment.hbm.xml"/> - <mapping resource="org/drools/repository/RuleSetVersionInfo.hbm.xml"/> - <mapping resource="org/drools/repository/ApplicationDataDef.hbm.xml" /> - <mapping resource="org/drools/repository/FunctionDef.hbm.xml" /> - <mapping resource="org/drools/repository/ImportDef.hbm.xml" /> - - - </session-factory> - -</hibernate-configuration> \ No newline at end of file |
From: <jbo...@li...> - 2006-01-16 03:52:02
|
Author: mic...@jb... Date: 2006-01-15 22:51:58 -0500 (Sun, 15 Jan 2006) New Revision: 2105 Removed: trunk/labs/jbossrules/drools-repository/target/ Log: removed target |
From: <jbo...@li...> - 2006-01-16 02:46:54
|
Author: mic...@jb... Date: 2006-01-15 21:46:43 -0500 (Sun, 15 Jan 2006) New Revision: 2104 Added: trunk/labs/jbossrules/drools-natural-dsl/src/test/resources/org/drools/natural/sample.dictionary.properties Log: just an example Added: trunk/labs/jbossrules/drools-natural-dsl/src/test/resources/org/drools/natural/sample.dictionary.properties =================================================================== --- trunk/labs/jbossrules/drools-natural-dsl/src/test/resources/org/drools/natural/sample.dictionary.properties 2006-01-16 02:45:25 UTC (rev 2103) +++ trunk/labs/jbossrules/drools-natural-dsl/src/test/resources/org/drools/natural/sample.dictionary.properties 2006-01-16 02:46:43 UTC (rev 2104) @@ -0,0 +1,32 @@ +############################################ +# +# This is a very simple language config +# +############################################ + +#note escaped spaces +likes\ cheese=${left}.likesCheese() +age\ of=ageOf(${right}) + + + +############################################ +# +# Following are options (all optional) +# +############################################ + +#this means that after compiling, if any unknown tokens +#are left, they will be removed. +#Of course tokens that are parameters to +#stuff defined above are not removed +#by default, they are included in the output +#default is false +ignore.unknown=false + +#when using the general "compile" method +#this will tell it to look for delimiters or not. +#delimiters would then be required when using tokens +#that have spaces in them (like "ago of" above). +#by default is false. +require.delimiters=false \ No newline at end of file Property changes on: trunk/labs/jbossrules/drools-natural-dsl/src/test/resources/org/drools/natural/sample.dictionary.properties ___________________________________________________________________ Name: svn:eol-style + native |
From: <jbo...@li...> - 2006-01-16 02:45:32
|
Author: mic...@jb... Date: 2006-01-15 21:45:25 -0500 (Sun, 15 Jan 2006) New Revision: 2103 Modified: trunk/labs/jbossrules/pom.xml Log: corrected my details Modified: trunk/labs/jbossrules/pom.xml =================================================================== --- trunk/labs/jbossrules/pom.xml 2006-01-15 15:38:37 UTC (rev 2102) +++ trunk/labs/jbossrules/pom.xml 2006-01-16 02:45:25 UTC (rev 2103) @@ -170,12 +170,13 @@ <organization>Cantilever Technologies</organization> </developer> <developer> - <name>Michael Nelae</name> + <name>Michael Neale</name> <id>5</id> <email>mic...@gm...</email> <roles> - <role>Decision table despot</role> + <role>Developer</role> </roles> + <organization>JBoss Inc.</organization> </developer> </developers> |
From: <jbo...@li...> - 2006-01-15 15:38:46
|
Author: mla...@jb... Date: 2006-01-15 10:38:37 -0500 (Sun, 15 Jan 2006) New Revision: 2102 Added: trunk/labs/jbosswebnp/src/windows/LICENSE Modified: trunk/labs/jbosswebnp/src/windows/build.xml Log: Added: trunk/labs/jbosswebnp/src/windows/LICENSE =================================================================== --- trunk/labs/jbosswebnp/src/windows/LICENSE 2006-01-15 13:59:42 UTC (rev 2101) +++ trunk/labs/jbosswebnp/src/windows/LICENSE 2006-01-15 15:38:37 UTC (rev 2102) @@ -0,0 +1,504 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + <one line to give the library's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + <signature of Ty Coon>, 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + Modified: trunk/labs/jbosswebnp/src/windows/build.xml =================================================================== --- trunk/labs/jbosswebnp/src/windows/build.xml 2006-01-15 13:59:42 UTC (rev 2101) +++ trunk/labs/jbosswebnp/src/windows/build.xml 2006-01-15 15:38:37 UTC (rev 2102) @@ -18,12 +18,11 @@ <property name="title" value="JBoss .NET Proxy Library"/> <property name="version" value="1.0.0"/> <property name="version.number" value="100"/> - <property name="project" value="jbcoree"/> + <property name="project" value="NET.mscoree"/> <property name="build.dir" value="./dist"/> <property name="build.src" value="${build.dir}/src"/> <property name="build.dest" value="${build.dir}/bin"/> <property name="src.dir" value="."/> - <property name="final.name" value="${project}-${version}"/> <property name="dist.root" value="./dist"/> <property name="ant.home" value="."/> @@ -208,11 +207,11 @@ <target name="jar" depends="compile" description="Generates the Jar file"> <jar - destfile="${build.dir}/${final.name}.jar" + destfile="${build.dir}/${project}.jar" basedir="${build.dir}/bin/classes" excludes="**/*.java"> <manifest> - <section name="org/jboss/clr"> + <section name="NET"> <attribute name="Specification-Title" value="JBoss.NET.Proxy"/> <attribute name="Specification-Version" value="${version}"/> <attribute name="Specification-Vendor" value="JBoss Inc."/> @@ -222,6 +221,8 @@ <attribute name="Implementation-Version" value="${version} (build ${DSTAMP} ${TSTAMP})"/> </section> </manifest> + <metainf file="${src.dir}/LICENSE"> + </metainf> </jar> </target> |
From: <jbo...@li...> - 2006-01-15 13:59:52
|
Author: ste...@jb... Date: 2006-01-15 08:59:42 -0500 (Sun, 15 Jan 2006) New Revision: 2101 Added: trunk/labs/hibernate/jdbc-redesign/src/org/hibernate/tx/IsolationDelegate.java Modified: trunk/labs/hibernate/jdbc-redesign/src/org/hibernate/jdbc3/JDBCContainer.java trunk/labs/hibernate/jdbc-redesign/src/org/hibernate/jdbc3/JDBCContainerFactory.java trunk/labs/hibernate/jdbc-redesign/src/org/hibernate/jdbc3/impl/JDBCContainerImpl.java trunk/labs/hibernate/jdbc-redesign/src/org/hibernate/tx/TransactionCoordinator.java Log: seperate transaction work Modified: trunk/labs/hibernate/jdbc-redesign/src/org/hibernate/jdbc3/JDBCContainer.java =================================================================== --- trunk/labs/hibernate/jdbc-redesign/src/org/hibernate/jdbc3/JDBCContainer.java 2006-01-15 04:53:37 UTC (rev 2100) +++ trunk/labs/hibernate/jdbc-redesign/src/org/hibernate/jdbc3/JDBCContainer.java 2006-01-15 13:59:42 UTC (rev 2101) @@ -21,6 +21,15 @@ public void doWork(Work work) throws HibernateException; /** + * Performs some work within the confines of this container. + * + * @param work The work to be performed. + * @throws HibernateException Indicates a problem occurred trying to + * perform the requested work. + */ + public void doWorkInSeperateTransaction(Work work) throws HibernateException; + + /** * Cancels the last requested operation. * * @throws HibernateException Indicates a problem cancelling the last Modified: trunk/labs/hibernate/jdbc-redesign/src/org/hibernate/jdbc3/JDBCContainerFactory.java =================================================================== --- trunk/labs/hibernate/jdbc-redesign/src/org/hibernate/jdbc3/JDBCContainerFactory.java 2006-01-15 04:53:37 UTC (rev 2100) +++ trunk/labs/hibernate/jdbc-redesign/src/org/hibernate/jdbc3/JDBCContainerFactory.java 2006-01-15 13:59:42 UTC (rev 2101) @@ -60,6 +60,7 @@ Connection userSuppliedConnection, TransactionCoordinator txCoordinator) { return new JDBCContainerImpl( + txCoordinator, userSuppliedConnection, connectionProvider, releaseMode, @@ -76,6 +77,7 @@ TransactionCoordinator txCoordinator, ConnectionReleaseMode releaseMode) { return new JDBCContainerImpl( + txCoordinator, userSuppliedConnection, connectionProvider, releaseMode, Modified: trunk/labs/hibernate/jdbc-redesign/src/org/hibernate/jdbc3/impl/JDBCContainerImpl.java =================================================================== --- trunk/labs/hibernate/jdbc-redesign/src/org/hibernate/jdbc3/impl/JDBCContainerImpl.java 2006-01-15 04:53:37 UTC (rev 2100) +++ trunk/labs/hibernate/jdbc-redesign/src/org/hibernate/jdbc3/impl/JDBCContainerImpl.java 2006-01-15 13:59:42 UTC (rev 2101) @@ -12,6 +12,7 @@ import org.hibernate.ConnectionReleaseMode; import org.hibernate.HibernateException; import org.hibernate.JDBCException; +import org.hibernate.tx.TransactionCoordinator; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -42,6 +43,7 @@ // private PreparedStatement lastQuery; + private final TransactionCoordinator transactionCoordinator; private final ConnectionProvider connectionProvider; private final ConnectionReleaseMode releaseMode; private final SQLStatementLogger sqlStatementLogger; @@ -53,6 +55,7 @@ private transient LogicalConnection logicalConnection; public JDBCContainerImpl( + TransactionCoordinator transactionCoordinator, Connection userSuppliedConnection, ConnectionProvider connectionProvider, ConnectionReleaseMode releaseMode, @@ -61,6 +64,7 @@ Dialect dialect, SQLStatementLogger sqlStatementLogger, int batchSize) { + this.transactionCoordinator = transactionCoordinator; this.connectionProvider = connectionProvider; this.releaseMode = releaseMode; this.sqlExceptionConverter = sqlExceptionConverter; @@ -89,8 +93,18 @@ } } + public void doWorkInSeperateTransaction(Work work) throws HibernateException { + IsolatedWorkspaceImpl workspace = new IsolatedWorkspaceImpl(); + try { + transactionCoordinator.getIsolationDelegate().doWorkInIsolation( work, workspace ); + } + finally { + workspace.close(); + } + } + public void release(Work work) { - // needed for non-concise work to signal the fact that we are done + // needed for non-concise work to signal the fact that we are closed // with the resources... doRelease( work ); afterStatement(); @@ -199,60 +213,64 @@ return conn; } - public class WorkspaceImpl implements Workspace { - // TODO : implement "connection handle registration" logic + // Workspace impls ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - private HashSet registeredStatements = new HashSet(); - private HashSet registeredResultSets = new HashSet(); + public abstract class AbstractWorkspaceImpl implements Workspace { - public WorkspaceImpl() { + protected final HashSet registeredStatements = new HashSet(); + protected final HashSet registeredResultSets = new HashSet(); + + public AbstractWorkspaceImpl() { log.debug( "Opening workspace [" + this + "]" ); + opened(); } - public Connection getConnection() { - return JDBCContainerImpl.this.getLogicalConnection().getConnection(); + protected void opened() { } - public Dialect getDialect() { + protected void closed() { + } + + public final Dialect getDialect() { return JDBCContainerImpl.this.dialect; } - public SQLStatementLogger getSqlLogger() { + public final SQLStatementLogger getSqlLogger() { return JDBCContainerImpl.this.sqlStatementLogger; } - public JDBCException convert(SQLException sqlException, String message) { + public final JDBCException convert(SQLException sqlException, String message) { return JDBCContainerImpl.this.convert( sqlException, message ); } - public JDBCException convert(SQLException sqlException, String message, String sql) { + public final JDBCException convert(SQLException sqlException, String message, String sql) { return JDBCContainerImpl.this.convert( sqlException, message, sql ); } - public void register(PreparedStatement statement) { + public final void register(PreparedStatement statement) { log.trace( "registering prepared statement [" + statement + "]" ); registeredStatements.add( statement ); } - public void release(PreparedStatement statement) { + public final void release(PreparedStatement statement) { log.trace( "releasing prepared statement [" + statement + "]" ); registeredStatements.remove( statement ); close( statement ); } - public void register(ResultSet resultSet) { + public final void register(ResultSet resultSet) { log.trace( "registering result set [" + resultSet + "]" ); registeredResultSets.add( resultSet ); } - public void release(ResultSet resultSet) { + public final void release(ResultSet resultSet) { log.trace( "releasing result set [" + resultSet + "]" ); registeredResultSets.remove( resultSet ); close( resultSet ); } - private void close(PreparedStatement statement) { + protected final void close(PreparedStatement statement) { log.trace( "closing prepared statement [" + statement + "]" ); try { // if we are unable to "clean" the prepared statement, @@ -277,7 +295,7 @@ } } - private void close(ResultSet resultSet) { + protected final void close(ResultSet resultSet) { log.trace( "closing result set [" + resultSet + "]" ); try { resultSet.close(); @@ -287,7 +305,7 @@ } } - public void close() { + public final void close() { log.trace( "closing workspace [" + this + "]" ); Iterator iter = registeredResultSets.iterator(); while ( iter.hasNext() ) { @@ -301,6 +319,54 @@ } registeredStatements.clear(); + closed(); + } + } + + public class IsolatedWorkspaceImpl extends AbstractWorkspaceImpl implements Workspace { + private Connection connection; + + public Connection getConnection() { + return connection; + } + + public void prepare() { + try { + connection = connectionProvider.getConnection(); + log.debug( "obtained JDBC connection for isolated work" ); + if ( stats != null ) { + stats.connect(); + } + } + catch( SQLException sqle ) { + throw convert( sqle, "Unable to obtain JDBC connection for isolated work" ); + } + } + + public void release() { + try { + connectionProvider.closeConnection( connection ); + log.debug( "released JDBC connection for isolated work" ); + } + catch( SQLException sqle ) { + log.trace( "unable to release connection on exception [" + sqle + "]" ); + } + finally { + connection = null; + } + } + } + + public class WorkspaceImpl extends AbstractWorkspaceImpl implements Workspace { + public Connection getConnection() { + return JDBCContainerImpl.this.getLogicalConnection().getConnection(); + } + + protected void opened() { + // TODO : implement "connection handle registration" logic + } + + protected void closed() { // TODO : release our "hold" on the connection } } Added: trunk/labs/hibernate/jdbc-redesign/src/org/hibernate/tx/IsolationDelegate.java =================================================================== --- trunk/labs/hibernate/jdbc-redesign/src/org/hibernate/tx/IsolationDelegate.java 2006-01-15 04:53:37 UTC (rev 2100) +++ trunk/labs/hibernate/jdbc-redesign/src/org/hibernate/tx/IsolationDelegate.java 2006-01-15 13:59:42 UTC (rev 2101) @@ -0,0 +1,11 @@ +package org.hibernate.tx; + +import org.hibernate.jdbc3.Work; +import org.hibernate.jdbc3.impl.JDBCContainerImpl; + +/** + * @author Steve Ebersole + */ +public interface IsolationDelegate { + public void doWorkInIsolation(Work work, JDBCContainerImpl.IsolatedWorkspaceImpl workspace); +} Modified: trunk/labs/hibernate/jdbc-redesign/src/org/hibernate/tx/TransactionCoordinator.java =================================================================== --- trunk/labs/hibernate/jdbc-redesign/src/org/hibernate/tx/TransactionCoordinator.java 2006-01-15 04:53:37 UTC (rev 2100) +++ trunk/labs/hibernate/jdbc-redesign/src/org/hibernate/tx/TransactionCoordinator.java 2006-01-15 13:59:42 UTC (rev 2101) @@ -4,4 +4,5 @@ * @author Steve Ebersole */ public interface TransactionCoordinator { + public IsolationDelegate getIsolationDelegate(); } |
From: <jbo...@li...> - 2006-01-15 04:53:45
|
Author: mic...@jb... Date: 2006-01-14 23:53:37 -0500 (Sat, 14 Jan 2006) New Revision: 2100 Modified: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/lang/ExpanderContext.java Log: changed to CharSequence Modified: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/lang/ExpanderContext.java =================================================================== --- trunk/labs/jbossrules/drools-core/src/main/java/org/drools/lang/ExpanderContext.java 2006-01-15 04:51:17 UTC (rev 2099) +++ trunk/labs/jbossrules/drools-core/src/main/java/org/drools/lang/ExpanderContext.java 2006-01-15 04:53:37 UTC (rev 2100) @@ -35,8 +35,11 @@ return enabled; } + public void disable() { + this.enabled = false; + } + public ExpanderContext(Collection initialExpanders) { - enabled = true; this.expanders = new HashSet(initialExpanders); } @@ -62,7 +65,7 @@ * If <code>isEnabled()</code> is false then it is not required to * call this method. */ - public String expand(String expression, RuleParser context) { + public CharSequence expand(CharSequence expression, RuleParser context) { return expression; } |
From: <jbo...@li...> - 2006-01-15 04:51:40
|
Author: mic...@jb... Date: 2006-01-14 23:51:17 -0500 (Sat, 14 Jan 2006) New Revision: 2099 Modified: trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/NaturalLanguageCompiler.java trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/ast/BaseSyntaxNode.java trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/ast/ExpressionContext.java trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/ast/LeftInfix.java trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/ast/LeftRightInfix.java trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/ast/LiteralNode.java trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/ast/RightInfix.java trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/grammar/NaturalGrammar.java trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/grammar/SimpleGrammar.java trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/lexer/SimpleSnippetLexer.java trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/NaturalLanguageCompilerTest.java trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/grammar/SimpleGrammarTest.java trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/lexer/GrammarAwareLexerTest.java Log: improvements, can ignore unknown items etc. Modified: trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/NaturalLanguageCompiler.java =================================================================== --- trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/NaturalLanguageCompiler.java 2006-01-14 17:28:55 UTC (rev 2098) +++ trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/NaturalLanguageCompiler.java 2006-01-15 04:51:17 UTC (rev 2099) @@ -1,7 +1,10 @@ package org.drools.natural; +import java.util.Properties; + import org.drools.natural.ast.ExpressionContext; import org.drools.natural.grammar.NaturalGrammar; +import org.drools.natural.grammar.SimpleGrammar; import org.drools.natural.lexer.GrammarAwareLexer; import org.drools.natural.lexer.NaturalSnippetLexer; import org.drools.natural.lexer.SimpleSnippetLexer; @@ -22,7 +25,24 @@ grammar = g; } + public NaturalLanguageCompiler(Properties p) { + grammar = new SimpleGrammar(p); + } + /** + * Build a natural expression. + * This method uses the grammar configuration to + * work out the type of expression it is. + * See NaturalGrammar#compileExpression + * and NaturalGrammar#compileNaturalExpression. + */ + public String compile(String expression) { + if (grammar.delimitersRequired()) { + return this.compileExpression(expression); + } else { + return this.compileNaturalExpression(expression); + } + } /** * Will parse a natural language expression into a compiled version, according to Modified: trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/ast/BaseSyntaxNode.java =================================================================== --- trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/ast/BaseSyntaxNode.java 2006-01-14 17:28:55 UTC (rev 2098) +++ trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/ast/BaseSyntaxNode.java 2006-01-15 04:51:17 UTC (rev 2099) @@ -18,6 +18,7 @@ public BaseSyntaxNode next; public BaseSyntaxNode prev; public String originalValue; + protected ExpressionContext context; /** * Node types return true when all their argument needs have been satisfied. @@ -40,14 +41,14 @@ { BaseSyntaxNode currentNode = this; - boolean flag = true; - while (currentNode != null && flag == true) { + boolean satisfied = true; + while (currentNode != null && satisfied == true) { if (currentNode.isThisCorrectType( nodeType )) { - flag = flag && currentNode.isSatisfied(); + satisfied = satisfied && currentNode.isSatisfied(); } currentNode = currentNode.next; } - return flag; + return satisfied; } @@ -122,6 +123,10 @@ return this; } } + + public void setContext(ExpressionContext context) { + this.context = context; + } } Modified: trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/ast/ExpressionContext.java =================================================================== --- trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/ast/ExpressionContext.java 2006-01-14 17:28:55 UTC (rev 2098) +++ trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/ast/ExpressionContext.java 2006-01-15 04:51:17 UTC (rev 2099) @@ -18,8 +18,9 @@ private BaseSyntaxNode firstNode; private BaseSyntaxNode prevNode; - private NaturalGrammar grammar; - + NaturalGrammar grammar; + private boolean ignoreUnknownTokens = false; + public ExpressionContext(NaturalGrammar grammar) { this.grammar = grammar; } @@ -45,7 +46,7 @@ public String render() { buildTreeByOrderOfPrecedence(); - return firstNode.findStartNode().renderAll(); + return firstNode.findStartNode().renderAll().trim(); } @@ -65,6 +66,7 @@ */ private void addNode(BaseSyntaxNode thisNode) { + thisNode.setContext(this); if (firstNode == null) { firstNode = thisNode; } else { @@ -74,8 +76,8 @@ prevNode = thisNode; } + - Modified: trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/ast/LeftInfix.java =================================================================== --- trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/ast/LeftInfix.java 2006-01-14 17:28:55 UTC (rev 2098) +++ trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/ast/LeftInfix.java 2006-01-15 04:51:17 UTC (rev 2099) @@ -44,10 +44,10 @@ - public List getArguments() { + List getArguments() { return this.args; } - + public String render() { List vars = super.getVariableNameList(); Modified: trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/ast/LeftRightInfix.java =================================================================== --- trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/ast/LeftRightInfix.java 2006-01-14 17:28:55 UTC (rev 2098) +++ trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/ast/LeftRightInfix.java 2006-01-15 04:51:17 UTC (rev 2099) @@ -59,15 +59,16 @@ InfixNode.Direction.RIGHT ); } - public List getArgumentsLeft() + List getArgumentsLeft() { return this.argsLeft; } - public List getArgumentsRight() + List getArgumentsRight() { return this.argsRight; } + public String render() { Modified: trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/ast/LiteralNode.java =================================================================== --- trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/ast/LiteralNode.java 2006-01-14 17:28:55 UTC (rev 2098) +++ trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/ast/LiteralNode.java 2006-01-15 04:51:17 UTC (rev 2099) @@ -14,14 +14,14 @@ super.originalValue = val; } - public boolean equals(Object obj) { - if (!(obj instanceof LiteralNode)) { - return false; - } else { - LiteralNode in = (LiteralNode) obj; - return in.originalValue.equals(super.originalValue); - } - } +// public boolean equals(Object obj) { +// if (!(obj instanceof LiteralNode)) { +// return false; +// } else { +// LiteralNode in = (LiteralNode) obj; +// return in.originalValue.equals(super.originalValue); +// } +// } public boolean isSatisfied() { @@ -39,13 +39,29 @@ /** * if the previous node is also a literal or a sub, then * a space will be inserted to honour the intent of the original. + * + * For literals, if context says to ignore unknown, + * then they will NEVER be included in the output + * unless they are an argument to an infix operator. */ public String render() { + if (ignoreUnknown()) { + return ""; + } + if (prev != null) { return SPACE + super.originalValue; } else { return super.originalValue; } } + + private boolean ignoreUnknown() { + return context != null + && + context.grammar.ignoreUnknownTokens() + && + super.parent == null; + } } Modified: trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/ast/RightInfix.java =================================================================== --- trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/ast/RightInfix.java 2006-01-14 17:28:55 UTC (rev 2098) +++ trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/ast/RightInfix.java 2006-01-15 04:51:17 UTC (rev 2099) @@ -43,11 +43,11 @@ - public List getArguments() { + List getArguments() { return this.args; } + - public String render() { List vars = super.getVariableNameList(); Modified: trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/grammar/NaturalGrammar.java =================================================================== --- trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/grammar/NaturalGrammar.java 2006-01-14 17:28:55 UTC (rev 2098) +++ trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/grammar/NaturalGrammar.java 2006-01-15 04:51:17 UTC (rev 2099) @@ -1,17 +1,19 @@ package org.drools.natural.grammar; -import java.util.List; /** - * All Grammars must implement this simple interface. SimpleGrammar is the default implementation. + * All Grammars must implement this simple interface. + * SimpleGrammar is the default implementation. * - * * @author <a href="mailto:mic...@gm..."> Michael Neale</a> - * */ public interface NaturalGrammar { + + public static final String IGNORE_UNKNOWN_TOKENS = "ignore.unknown"; + public static final String REQUIRE_DELIMITERS = "require.delimiters"; + /** * Return an expression matching that token. */ @@ -24,4 +26,18 @@ */ public abstract String[] listNaturalItems(); + /** + * @return True if unknown tokens are to be ignored for + * this grammar configuration. + * Unknown does not include arguments to infix operators of course. + */ + public boolean ignoreUnknownTokens(); + + /** + * @return True if tokens containing spaces must be delimited, + * to help out the lexer. + */ + public boolean delimitersRequired(); + + } \ No newline at end of file Modified: trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/grammar/SimpleGrammar.java =================================================================== --- trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/grammar/SimpleGrammar.java 2006-01-14 17:28:55 UTC (rev 2098) +++ trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/grammar/SimpleGrammar.java 2006-01-15 04:51:17 UTC (rev 2099) @@ -8,38 +8,42 @@ import org.drools.natural.NaturalLanguageException; /** - * Holds the simple grammar for a natural expressions. + * Holds the simple grammar for a pseudo natural language/dsl. * @author <a href="mailto:mic...@gm..."> Michael Neale</a> * */ public class SimpleGrammar implements Serializable, NaturalGrammar { + private static final long serialVersionUID = -6587260296556962105L; - private static final long serialVersionUID = -6587260296556962105L; - private final Map dictionary; + private Properties dictionary; - public SimpleGrammar() { - dictionary = new HashMap(); + init(new Properties()); } public SimpleGrammar(Properties props) { - dictionary = props; + init(props); + } + + private void init(Properties map) { + dictionary = map; } + public void addToDictionary(String token, String expression) { if (dictionary.containsKey(token)) { throw new NaturalLanguageException("The token [" + token + "] is already in the dictionary."); } - dictionary.put(token, expression); + dictionary.setProperty(token, expression); } /* (non-Javadoc) * @see org.drools.natural.grammar.NaturalGrammar#getExpression(java.lang.String) */ public String getExpression(String token) { - return (String) dictionary.get(token); + return dictionary.getProperty(token); } /* (non-Javadoc) @@ -54,6 +58,17 @@ return (String[]) this.dictionary.keySet().toArray(new String[dictionary.size()]); } + public boolean ignoreUnknownTokens() { + String s = (String) this.dictionary.getProperty(IGNORE_UNKNOWN_TOKENS); + return Boolean.parseBoolean(s); + + } + + public boolean delimitersRequired() { + String s = (String) this.dictionary.getProperty(REQUIRE_DELIMITERS, "false"); + return Boolean.parseBoolean(s); + } + Modified: trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/lexer/SimpleSnippetLexer.java =================================================================== --- trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/lexer/SimpleSnippetLexer.java 2006-01-14 17:28:55 UTC (rev 2098) +++ trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/lexer/SimpleSnippetLexer.java 2006-01-15 04:51:17 UTC (rev 2099) @@ -28,7 +28,6 @@ public SimpleSnippetLexer(String snippet) { - this.snippet = snippet.toCharArray( ); this.tokens = new ArrayList( ); this.currentToken = new StringBuffer( ); Modified: trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/NaturalLanguageCompilerTest.java =================================================================== --- trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/NaturalLanguageCompilerTest.java 2006-01-14 17:28:55 UTC (rev 2098) +++ trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/NaturalLanguageCompilerTest.java 2006-01-15 04:51:17 UTC (rev 2099) @@ -1,5 +1,8 @@ package org.drools.natural; +import java.util.Properties; + +import org.drools.natural.grammar.NaturalGrammar; import org.drools.natural.grammar.SimpleGrammar; import junit.framework.TestCase; @@ -23,10 +26,12 @@ grammar.addToDictionary("->", "${left}.${right}()"); grammar.addToDictionary("or", "||"); grammar.addToDictionary("and", "&&"); + grammar.addToDictionary("less than", "${left} < ${right}"); + grammar.addToDictionary("ignore.unknown", "true"); } public void testNaturalLanguage() { - String snippet = "bob [likes cheese] or [age of] bob < 21 " + + String snippet = "bob [likes cheese] or [age of] bob [less than] 21 " + "or bob equals mark and bob -> health equals good"; NaturalLanguageCompiler parser = new NaturalLanguageCompiler(grammar); @@ -37,13 +42,19 @@ } public void testLookNoBracketsMum() { - String snippet = "bob likes cheese or age of bob < 21 " + + String snippet = "check that bob likes cheese or check the age of bob less than 21 " + "or bob equals mark and bob -> health equals good"; + NaturalLanguageCompiler parser = new NaturalLanguageCompiler(grammar); String result = parser.compileNaturalExpression(snippet); assertEquals("bob.likesCheese() || ageOf(bob) < 21 || bob.equals(mark) && bob.health().equals(good)", result); + + //now check it to make sure it doesn't require brackets by default + result = parser.compile(snippet); + assertEquals("bob.likesCheese() || ageOf(bob) < 21 || bob.equals(mark) && bob.health().equals(good)", result); + } public void testNaturalLanguageNesting() { @@ -57,7 +68,8 @@ public void testNotInDictionary() { String snippet = "nothing is in the dictionary"; - NaturalLanguageCompiler parser = new NaturalLanguageCompiler(grammar); + + NaturalLanguageCompiler parser = new NaturalLanguageCompiler(new SimpleGrammar(new Properties())); assertEquals(snippet, parser.compileExpression(snippet)); snippet = "[well some is like bob likes cheese, but by using brackets is all escaped]"; @@ -65,5 +77,13 @@ assertEquals(bracketsRemoved, parser.compileExpression(snippet)); } + + public void testIgnoreUnknown() { + NaturalLanguageCompiler parser = new NaturalLanguageCompiler(grammar); + String snippet = "that bob likes cheese"; + assertEquals("bob.likesCheese()", parser.compileNaturalExpression(snippet)); + } + + } Modified: trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/grammar/SimpleGrammarTest.java =================================================================== --- trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/grammar/SimpleGrammarTest.java 2006-01-14 17:28:55 UTC (rev 2098) +++ trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/grammar/SimpleGrammarTest.java 2006-01-15 04:51:17 UTC (rev 2099) @@ -38,7 +38,7 @@ { SimpleGrammar g = new SimpleGrammar( ); g.addToDictionary( "A", - "${all-left}.getSomething()" ); + "${left}.getSomething()" ); assertEquals( "A", g.listNaturalItems( )[0] ); @@ -52,5 +52,18 @@ assertEquals(0, g.listNaturalItems().length); } + public void testConfigParams() { + SimpleGrammar g = new SimpleGrammar( ); + g.addToDictionary( "A", + "${left}.getSomething()" ); + assertFalse(g.ignoreUnknownTokens()); + g.addToDictionary(NaturalGrammar.IGNORE_UNKNOWN_TOKENS, "true"); + assertTrue(g.ignoreUnknownTokens()); + + assertFalse(g.delimitersRequired()); + g.addToDictionary(NaturalGrammar.REQUIRE_DELIMITERS, "true"); + assertTrue(g.delimitersRequired()); + } + } Modified: trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/lexer/GrammarAwareLexerTest.java =================================================================== --- trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/lexer/GrammarAwareLexerTest.java 2006-01-14 17:28:55 UTC (rev 2098) +++ trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/lexer/GrammarAwareLexerTest.java 2006-01-15 04:51:17 UTC (rev 2099) @@ -77,6 +77,14 @@ { return items; } + + public boolean ignoreUnknownTokens() { + return false; + } + + public boolean delimitersRequired() { + return false; + } } |
From: <jbo...@li...> - 2006-01-14 17:29:02
|
Author: wrzep Date: 2006-01-14 12:28:55 -0500 (Sat, 14 Jan 2006) New Revision: 2098 Modified: trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/Projects.java Log: deleted debug msg - back to prev verision http://jira.jboss.com/jira/browse/JBLAB-415 Pawel Modified: trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/Projects.java =================================================================== --- trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/Projects.java 2006-01-14 16:26:39 UTC (rev 2097) +++ trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/Projects.java 2006-01-14 17:28:55 UTC (rev 2098) @@ -57,7 +57,6 @@ ProjectsDescriptor.class.getName()); if (pd == null) { - System.out.print("*** update"); pd = (ProjectsDescriptor) ForgeHelper.getForgeManagement().addNodeWatcher(portalName, ProjectsDescriptor.class.getName(), |
From: <jbo...@li...> - 2006-01-14 16:26:46
|
Author: wrzep Date: 2006-01-14 11:26:39 -0500 (Sat, 14 Jan 2006) New Revision: 2097 Modified: trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/Projects.java Log: ProjectsHelper seems to miss project.xml files changes added simple debug msg to check it out http://jira.jboss.com/jira/browse/JBLAB-415 Pawel Modified: trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/Projects.java =================================================================== --- trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/Projects.java 2006-01-14 02:52:11 UTC (rev 2096) +++ trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/Projects.java 2006-01-14 16:26:39 UTC (rev 2097) @@ -50,12 +50,14 @@ /** * Reads and if necessary, updates, a projects descriptor. */ - private synchronized ProjectsDescriptor getProjectsDescriptor() { + private synchronized ProjectsDescriptor getProjectsDescriptor() { + ProjectsDescriptor pd = (ProjectsDescriptor) ForgeHelper.getForgeManagement().getFromCache(portalName, ProjectsDescriptor.class.getName()); if (pd == null) { + System.out.print("*** update"); pd = (ProjectsDescriptor) ForgeHelper.getForgeManagement().addNodeWatcher(portalName, ProjectsDescriptor.class.getName(), |
From: <jbo...@li...> - 2006-01-14 02:52:28
|
Author: mic...@jb... Date: 2006-01-13 21:52:11 -0500 (Fri, 13 Jan 2006) New Revision: 2096 Added: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/lang/Expander.java trunk/labs/jbossrules/drools-core/src/main/java/org/drools/lang/ExpanderContext.java Log: Expander skeleton Added: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/lang/Expander.java =================================================================== --- trunk/labs/jbossrules/drools-core/src/main/java/org/drools/lang/Expander.java 2006-01-13 21:10:43 UTC (rev 2095) +++ trunk/labs/jbossrules/drools-core/src/main/java/org/drools/lang/Expander.java 2006-01-14 02:52:11 UTC (rev 2096) @@ -0,0 +1,16 @@ +package org.drools.lang; + +/** + * Expanders provide just in time expansion for expressions in DRL. + * + * Expanders should ideally not make presumptions on any embedded semantic + * language. For instance, java aware pre processing should be done in + * drools-java semantic module, not in the parser itself. Expanders should + * be reusable across semantic languages. + * + * @author Michael Neale + * + */ +public interface Expander { + +} Property changes on: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/lang/Expander.java ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/lang/ExpanderContext.java =================================================================== --- trunk/labs/jbossrules/drools-core/src/main/java/org/drools/lang/ExpanderContext.java 2006-01-13 21:10:43 UTC (rev 2095) +++ trunk/labs/jbossrules/drools-core/src/main/java/org/drools/lang/ExpanderContext.java 2006-01-14 02:52:11 UTC (rev 2096) @@ -0,0 +1,71 @@ +package org.drools.lang; + +import java.io.Serializable; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +/** + * Expanders are extension points for expanding + * expressions in DRL at parse time. + * This is just-in-time translation, or macro expansion, or + * whatever you want. + * + * The important thing is that it happens at the last possible moment, + * so any errors in expansion are included in the parsers errors. + * + * Just-in-time expansions may include complex pre-compilers, + * or just macros, and everything in between. + * + * @author <a href="mailto:mic...@gm..."> Michael Neale</a> + * + */ +public class ExpanderContext implements Serializable { + + private static final long serialVersionUID = 1806461802987228880L; + private boolean enabled = true; + + private final Set expanders; + + /** + * This indicates that at least one expander has been configured for + * this parser configuration. + */ + public boolean isEnabled() { + return enabled; + } + + public ExpanderContext(Collection initialExpanders) { + enabled = true; + this.expanders = new HashSet(initialExpanders); + } + + public ExpanderContext() { + this.expanders = new HashSet(); + } + + public ExpanderContext addExpander(Expander exp) { + expanders.add(exp); + return this; + } + + /** + * Expands the expression Just-In-Time for the parser. + * If the expression is not meant to be expanded, or if no + * appropriate expander is found, it will echo back the same + * expression. + * + * @param expression The "line" or expression to be expanded/pre-compiled. + * @param context The context of the current state of parsing. This can help + * the expander know if it needs to expand, what to do etc. + * + * If <code>isEnabled()</code> is false then it is not required to + * call this method. + */ + public String expand(String expression, RuleParser context) { + return expression; + } + + + +} Property changes on: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/lang/ExpanderContext.java ___________________________________________________________________ Name: svn:eol-style + native |
Author: dam...@jb... Date: 2006-01-13 16:10:43 -0500 (Fri, 13 Jan 2006) New Revision: 2095 Added: qa/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/Sorting.java Modified: qa/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/Counter.java qa/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCounterDescriptor.java qa/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCounterTools.java qa/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersDescriptor.java qa/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersWatcher.java qa/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/PollDescriptor.java qa/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/PollTools.java qa/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/PollVotesDatabase.java qa/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/PollsDescriptor.java qa/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/PollsWatcher.java qa/forge/portal-extensions/forge-file-access/src/java/org/jboss/forge/fileaccess/portlet/DownloadCounterPortlet.java qa/forge/portal-extensions/forge-freezone/src/web/WEB-INF/portlet-instances.xml qa/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Column.java qa/forge/portal-extensions/forge-theme/jbossForgeLayout.war/layouts/jbossForge.jsp qa/forge/portal-extensions/forge-theme/jbossForgeLayout.war/layouts/twoColumns.jsp qa/forge/portal-extensions/polls/src/java/org/jboss/forge/polls/PollsPortlet.java qa/forge/portal-extensions/polls/src/web/WEB-INF/portlet-instances.xml qa/forge/portal-extensions/portal-default/src/web/WEB-INF/default-portal.xml Log: MERGED: -r 2042:2094 https://svn.labs.jboss.com/trunk/forge into qa for 1.0.8 release testing. Modified: qa/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/Counter.java =================================================================== --- qa/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/Counter.java 2006-01-13 18:45:31 UTC (rev 2094) +++ qa/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/Counter.java 2006-01-13 21:10:43 UTC (rev 2095) @@ -49,6 +49,11 @@ private Boolean visible; /** + * It informs in what way the counter have to be sorted. + */ + private Sorting sorting; + + /** * Main constructor simply initiates values. * * @param value @@ -56,10 +61,11 @@ * @param projectId * Name of project for this counter. */ - Counter (long value,String projectId,Boolean visible) { + Counter (long value,String projectId,Boolean visible,Sorting sorting) { this.value=value; this.projectId=projectId; this.visible = visible; + this.sorting = sorting; } /** @@ -99,7 +105,7 @@ * Method sets visibility of the counter. * @param visible */ - public void setVisible(Boolean visible) { + void setVisible(Boolean visible) { this.visible = visible; } @@ -109,4 +115,21 @@ public String toString () { return Long.toString(value); } + + /** + * Method returns the enum information about how the counter have to be sorted. + * @return + * Sorting order information. + */ + public Sorting getSorting() { + return sorting; + } + + /** + * Sets new sorting. + * @param sorting + */ + public void setSorting(Sorting sorting) { + this.sorting = sorting; + } } Modified: qa/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCounterDescriptor.java =================================================================== --- qa/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCounterDescriptor.java 2006-01-13 18:45:31 UTC (rev 2094) +++ qa/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCounterDescriptor.java 2006-01-13 21:10:43 UTC (rev 2095) @@ -26,8 +26,6 @@ import java.io.IOException; import java.io.InputStream; import java.util.Hashtable; -import java.util.LinkedList; -import java.util.List; import java.util.Map; import org.apache.xerces.parsers.DOMParser; @@ -54,6 +52,11 @@ private Map<String,Boolean> links; /** + * Describes the order in which counters are requested to be displayed. + */ + private Sorting sorting; + + /** * Name of tag in counter.xml containing counter link. */ public static final String LINK = "link"; @@ -69,6 +72,11 @@ public static final String VISIBILITY = "visible"; /** + * This variable contains name of the sorting attribute. + */ + public static final String SORTING = "sorting"; + + /** * This variable contains value for attributes which means TRUE. */ public static final String TRUE = "true"; @@ -104,6 +112,20 @@ // Parsing and gettting download links which are requested to be tracked by download counter. links = new Hashtable<String,Boolean>(); + + // Resolving way of sorting counters. + sorting = Sorting.RANDOM; + String sortingAtt = XmlTools.getAttributeValue(doc.getDocumentElement(),SORTING); + if (sortingAtt!=null && + (sortingAtt.compareToIgnoreCase(Sorting.ASCENDING.name())==0 + || sortingAtt.compareToIgnoreCase(Sorting.ASC.name())==0)) { + sorting = Sorting.ASCENDING; + } else if (sortingAtt!=null && + (sortingAtt.compareToIgnoreCase(Sorting.DESCENDING.name())==0 + || sortingAtt.compareToIgnoreCase(Sorting.DESC.name())==0)) { + sorting = Sorting.DESCENDING; + } + for (int i = 0; i < nodes.getLength(); i++) { n = nodes.item(i); if (n.getNodeType() == Node.ELEMENT_NODE) { @@ -131,6 +153,15 @@ } /** + * Returns sorting description for counters. + * @return + * Requested sorting order. + */ + public Sorting getSorting () { + return sorting; + } + + /** * Method simply returns links from the xml descriptor which are requested to be tracked. * @return * List<String> of download links. Modified: qa/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCounterTools.java =================================================================== --- qa/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCounterTools.java 2006-01-13 18:45:31 UTC (rev 2094) +++ qa/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCounterTools.java 2006-01-13 21:10:43 UTC (rev 2095) @@ -45,6 +45,15 @@ public static final String FORGE_FILE_ACCESS_DIR="file-access"; /** + * Name of the directory in dynamicly changing portal content dir containing download counters' files. + */ + public static final String DOWNLOAD_COUNTERS_DIR="downloads"; + /** + * Dir in portal-content containing dynamicly changing portal content. + */ + public static final String DYNAMIC_CONTENT_DIR = "dynamic-content"; + + /** * Name of JSP view file. */ public static final String DOWNLOADCOUNTER_JSP="normal.jsp"; @@ -144,7 +153,7 @@ * @return Path to main download counters descriptor. */ public static String getMainXmlPath (String portalName) { - return portalName + File.separator + ProjectsHelper.MEMBERS_DIR + File.separator + ProjectsHelper.DOWNLOADCOUNTERMAIN_DESC; + return DYNAMIC_CONTENT_DIR+File.separator+portalName+File.separator+DOWNLOAD_COUNTERS_DIR+File.separator+ProjectsHelper.DOWNLOADCOUNTERMAIN_DESC; } /** Modified: qa/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersDescriptor.java =================================================================== --- qa/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersDescriptor.java 2006-01-13 18:45:31 UTC (rev 2094) +++ qa/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersDescriptor.java 2006-01-13 21:10:43 UTC (rev 2095) @@ -25,15 +25,18 @@ import java.io.File; import java.io.InputStream; +import java.util.Comparator; import java.util.HashSet; import java.util.Hashtable; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.TreeMap; import org.apache.xerces.parsers.DOMParser; import org.jboss.forge.common.XmlTools; +import org.jboss.logging.Logger; import org.jboss.shotoku.ContentManager; import org.jboss.shotoku.Directory; import org.jboss.shotoku.exceptions.ResourceDoesNotExist; @@ -50,7 +53,7 @@ * @author Ryszard Kozmik */ -public class DownloadCountersDescriptor extends AbstractDescriptor{ +public class DownloadCountersDescriptor extends AbstractDescriptor { /** * Name of tag in counters.xml containing counter value. @@ -78,6 +81,11 @@ public static final String VISIBILITY = "visible"; /** + * This variable contains name of the sorting attribute. + */ + public static final String SORTING = "sorting"; + + /** * This variable contains value for attributes which means TRUE. */ public static final String TRUE = "true"; @@ -98,6 +106,11 @@ private ContentManager contentManager; /** + * Logger is used for displaying messages. + */ + private Logger logger; + + /** * This boolean variable turns to true if one of the counters * has been incremented. If value is true the downloadCounters Map * will be synchronized with a main xml descriptor @@ -118,6 +131,9 @@ // Just initializing the changeStatus variable changeStatus=false; + // Initializing logger. + logger = Logger.getLogger(this.getClass()); + // Getting the path to main dowload counters descriptor. String pathToCountersXml = File.separator + DownloadCounterTools.getMainXmlPath(portalName); @@ -143,8 +159,7 @@ synchronizeCounters(descriptors); } catch (Exception e) { - System.out.println ("[DOWNLOADCOUNTERS] Failed to initialize downloadCounters."); - e.printStackTrace(); + logger.error ("Failed to initialize downloadCounters.",e); } } @@ -173,8 +188,7 @@ try { membersDir = contentManager.getDirectory(portalName+File.separator+ProjectsHelper.MEMBERS_DIR); } catch (ResourceDoesNotExist e) { - e.printStackTrace(); - System.out.println ("[DOWNLOADCOUNTERSDESCRIPTOR] Members directory not exists."); + logger.error ("Members directory not exists.",e); return null; } @@ -240,6 +254,7 @@ for (String link:xmlProjectLinks.keySet()) { if (links.keySet().contains(link)) { setCounterVisibility (link,links.get(link)); + setCounterSorting (link,counterDesc.getSorting()); links.keySet().remove(link); } else { linksToDelete.add(link); @@ -248,12 +263,11 @@ removeLinksFromCounting(linksToDelete); - addLinksForCounting (links,projectId); + addLinksForCounting (links,projectId,counterDesc.getSorting()); } catch (Exception e) { - System.out.println ("[DOWNLOADCOUNTER] Problem with opening project "+ - projectId+" download counter descriptor."); - e.printStackTrace(); + logger.warn("Problem with opening project "+ + projectId+" download counter descriptor.",e); } } @@ -290,6 +304,17 @@ } /** + * Method sets sorting order in which this counter will be displayed. + * @param link + * The link to the counter. + * @param sorting + * Requested sorting order. + */ + private synchronized void setCounterSorting (String link,Sorting sorting) { + downloadCounters.get(link).setSorting(sorting); + } + + /** * Method adds links which are wished to be tracked. * * @param links @@ -297,10 +322,10 @@ * @param projectId * Project id name for which the links are added. */ - private synchronized void addLinksForCounting (Map<String,Boolean> links,String projectId) { + private synchronized void addLinksForCounting (Map<String,Boolean> links,String projectId,Sorting sorting) { // Adding new download links for tracking. for (String link:links.keySet()) { - downloadCounters.put(link,new Counter(0,projectId,links.get(link))); + downloadCounters.put(link,new Counter(0,projectId,links.get(link),sorting)); } } @@ -353,7 +378,53 @@ */ public synchronized Map<String,Long> getValuesForPortlet (String projectId) { Map<String,Boolean> links = getProjectLinks(projectId); - Map<String,Long> values = new Hashtable<String,Long>(links.size()); + Map<String,Long> values = null; + if (links.size()==0) { + values = new Hashtable<String,Long>(0); + return values; + } + + // Resolving way of sorting for counters. + Sorting sorting = downloadCounters.get(links.keySet().iterator().next()).getSorting(); + if (sorting==Sorting.ASC || sorting==Sorting.ASCENDING) { + values = new TreeMap<String,Long>(new Comparator<String>() { + /** + * This method is used for comparing counters taking to consideration their values. + * If defines ascending order. + * @param o1 + * First link to compare. + * @param o2 + * Second link to compare. + * @return + * negative integer - when counter for the first link is lower than for second one + * zero - when counters for both links are equal + * positive integer - when counter for the first link is greater than for second one + */ + public synchronized int compare(String link1, String link2) { + return (int)(downloadCounters.get(link1).getValue()-downloadCounters.get(link2).getValue()); + } + }); + } else if (sorting==Sorting.DESC || sorting==Sorting.DESCENDING) { + values = new TreeMap<String,Long>(new Comparator<String>() { + /** + * This method is used for comparing counters taking to consideration their values. + * It defines descending order. + * @param o1 + * First link to compare. + * @param o2 + * Second link to compare. + * @return + * negative integer - when counter for the first link is greater than for second one + * zero - when counters for both links are equal + * positive integer - when counter for the first link is lower than for second one + */ + public synchronized int compare(String link1, String link2) { + return (int)(downloadCounters.get(link2).getValue()-downloadCounters.get(link1).getValue()); + } + }); + } else { + values = new Hashtable<String,Long>(links.size()); + } for (String link : links.keySet()) { if (links.get(link)) { values.put(link,downloadCounters.get(link).getValue()); @@ -417,6 +488,9 @@ Node counterVisibility = doc.createAttribute(VISIBILITY); counterVisibility.appendChild(doc.createTextNode(temporary.getVisible().toString())); newCounter.getAttributes().setNamedItem(counterVisibility); + Node counterSorting = doc.createAttribute(SORTING); + counterSorting.appendChild(doc.createTextNode(temporary.getSorting().name())); + newCounter.getAttributes().setNamedItem(counterSorting); Node newLink = doc.createElement(LINK); Node newLinkText = doc.createTextNode(link); @@ -501,6 +575,17 @@ n = nodes.item(i); if (n.getNodeType() == Node.ELEMENT_NODE) { if (n.getNodeName().equals(DownloadCountersDescriptor.COUNTER)) { + Sorting tempSorting = Sorting.RANDOM; + String sortingAtt = XmlTools.getAttributeValue(n,SORTING); + if (sortingAtt!=null && + (sortingAtt.compareToIgnoreCase(Sorting.ASCENDING.name())==0 + || sortingAtt.compareToIgnoreCase(Sorting.ASC.name())==0)) { + tempSorting = Sorting.ASCENDING; + } else if (sortingAtt!=null && + (sortingAtt.compareToIgnoreCase(Sorting.DESCENDING.name())==0 + || sortingAtt.compareToIgnoreCase(Sorting.DESC.name())==0)) { + tempSorting = Sorting.DESCENDING; + } NodeList counterProps = n.getChildNodes(); String tempLink = null; String tempValue = null; @@ -524,7 +609,7 @@ } } if (tempLink!=null && tempValue!=null && tempId!=null) { - values.put(tempLink,new Counter(Long.valueOf(tempValue),tempId,visibility)); + values.put(tempLink,new Counter(Long.valueOf(tempValue),tempId,visibility,tempSorting)); } } } @@ -532,4 +617,6 @@ return values; } + + } Modified: qa/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersWatcher.java =================================================================== --- qa/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersWatcher.java 2006-01-13 18:45:31 UTC (rev 2094) +++ qa/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/DownloadCountersWatcher.java 2006-01-13 21:10:43 UTC (rev 2095) @@ -23,7 +23,6 @@ package org.jboss.forge.common.projects; -import java.util.Collection; import java.util.Set; import org.jboss.forge.common.service.NodeWatcher; Modified: qa/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/PollDescriptor.java =================================================================== --- qa/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/PollDescriptor.java 2006-01-13 18:45:31 UTC (rev 2094) +++ qa/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/PollDescriptor.java 2006-01-13 21:10:43 UTC (rev 2095) @@ -110,39 +110,29 @@ String tempQuestion = null; Set<String> tempAnswers = Collections.synchronizedSet(new LinkedHashSet<String>()); - System.out.println("[POLLSDESCRIPTOR] IN POLLS"); if (n.getNodeName().equals(POLL)) { - System.out.println("[POLLSDESCRIPTOR] IN POLL"); NodeList counterProps = n.getChildNodes(); for (int j=0;j< counterProps.getLength() ; j++) { - System.out.println("[POLLSDESCRIPTOR] IN CHILDREN OF POLL"); property = counterProps.item(j); if (property.getNodeType()== Node.ELEMENT_NODE){ - System.out.println("[POLLSDESCRIPTOR] IN ELEMENT OF POLL"); if (property.getNodeName().equals(QUESTION) && XmlTools.unmarshallText(property) != null && !XmlTools.unmarshallText(property).trim().equals("")) { tempQuestion = XmlTools.unmarshallText(property).trim(); - System.out.println("[POLLSDESCRIPTOR] IN QUESTION: "+tempQuestion); + } else if (property.getNodeName().equals(ANSWER) && XmlTools.unmarshallText(property) != null && !XmlTools.unmarshallText(property).trim().equals("")) { tempAnswers.add(XmlTools.unmarshallText(property).trim()); - System.out.println("[POLLSDESCRIPTOR] IN answer: "+XmlTools.unmarshallText(property).trim()); } } } // Checking if all needed information was collected and then creating Poll. if (tempQuestion!=null && !tempQuestion.equals("") && tempAnswers.size()>0) { - System.out.println ("ADDING A POLL TO THE POLLS"); polls.add(new Poll(tempAnswers,tempQuestion,Integer.toString((int)(Math.random()*99999999)))); } } } } - System.out.println ("Displaying Polls from PollDescriptor just after reading it."); - for (Poll poll : polls) { - System.out.println (poll); - } } /** Modified: qa/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/PollTools.java =================================================================== --- qa/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/PollTools.java 2006-01-13 18:45:31 UTC (rev 2094) +++ qa/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/PollTools.java 2006-01-13 21:10:43 UTC (rev 2095) @@ -25,10 +25,12 @@ import java.io.File; import java.util.Collection; +import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.Random; import java.util.Set; import javax.portlet.PortletURL; @@ -88,6 +90,11 @@ public static final String POLLS_DIR="polls"; /** + * Dir for dynamicly changing content in portal. + */ + public static final String DYNAMIC_CONTENT_DIR ="dynamic-content"; + + /** * Name of JSP view file prepared for displaying voting results. */ public static final String POLLS_INFO_JSP="polls_info.jsp"; @@ -112,6 +119,10 @@ */ public static final boolean ALL_TYPE = false; + /** + * The limit of failures. + */ + public static final int LIMIT = 20; /** * Private constructor made in order to prevent from creating @@ -129,7 +140,7 @@ * @return Path to polls descriptor. */ public static String getMainXmlPath (final String portalName) { - return portalName + File.separator + ProjectsHelper.MEMBERS_DIR + File.separator + ProjectsHelper.POLLS_DESC; + return DYNAMIC_CONTENT_DIR+File.separator+portalName+File.separator+POLLS_DIR+File.separator+ProjectsHelper.POLLS_DESC; } /** @@ -210,6 +221,40 @@ } /** + * Method adds randomly selected polls with their projectIds to the Map/ + * @param numberOfPolls + * Number of polls which is requested to be received. + * @param portalName + * Name of the portal. + * @param cm + * ContentManager + * @return + * Map<String,String> containing randomly selected polls. + */ + public static Map<String,String> getRandomPolls (int numberOfPolls,String portalName,ContentManager cm) { + Map<String,String> randomPolls = new HashMap<String,String>(); + + PollsDescriptor desc = getDesc(portalName,cm); + Random random = new Random(); + List<String> projectIds = desc.getTrackedProjectIds(); + List<Poll> polls = null; + + // Number of redundant randomly selected pollIds. If it exceeds the limit the while will stop. + int failures = 0; + while (numberOfPolls-->0 && failures<LIMIT) { + String projectId = projectIds.get((int)(random.nextFloat()*projectIds.size())); + polls = desc.getPollsInfoForProject(projectId); + String pollId = polls.get((int)(random.nextFloat()*polls.size())).getPollId(); + if (randomPolls.containsKey(pollId)) { + failures++; + continue; + } + randomPolls.put(pollId,projectId); + } + return randomPolls; + } + + /** * This method returns one of the projectId names which have defined polls. * @param portalName * Portal name. @@ -218,10 +263,11 @@ * @return * Random projectId name. */ - public static String getRandomDefinedProjectId (String portalName,ContentManager cm) { + /*public static String getRandomDefinedProjectId (String portalName,ContentManager cm) { List<String> projectIds = getDesc(portalName,cm).getTrackedProjectIds(); - return projectIds.get((int)(Math.random()*projectIds.size())); - } + Random random = new Random(); + return projectIds.get((int)(random.nextFloat()*projectIds.size())); + }*/ /** * This method returns one of the Polls for specified projectId name. @@ -234,10 +280,11 @@ * @return * Random pollId name. */ - public static String getRandomPollForProjectId (String projectId,String portalName, ContentManager cm) { + /*public static String getRandomPollForProjectId (String projectId,String portalName, ContentManager cm) { List<Poll> polls = getDesc(portalName,cm).getPollsInfoForProject(projectId); - return polls.get((int)(Math.random()*polls.size())).getPollId(); - } + Random random = new Random(); + return polls.get((int)(random.nextFloat()*polls.size())).getPollId(); + }*/ /** * This method produces conten context for JSP view file showing @@ -287,11 +334,7 @@ retaininingPoll.add(pollIdSpecified); values.keySet().retainAll(retaininingPoll); } - - for (String elo : values.keySet()) { - System.out.println ("ZOSTAŁO: "+elo); - } - + // Filling the context for portlet. /** * Context structure: @@ -434,10 +477,10 @@ * Content context for detailed information JSP page. */ public static DelegateContext getVotingContext (String portalName, String projectId, - String error, ContentManager cm,JBossRenderResponse response, String pollIdSpecified) { + String error, ContentManager cm,JBossRenderResponse response, Map<String,String> specifiedPolls) { // If the projectId is null method returns empty DelegateContext object. - if (projectId==null) { + if (projectId==null && (specifiedPolls==null || (specifiedPolls!=null && specifiedPolls.size()==0))) { return new DelegateContext(); } @@ -453,15 +496,18 @@ } // If there is no tracked link for projectId return empty context. - if (!desc.checkForProjectPolls(projectId)) { + if (projectId!=null && !desc.checkForProjectPolls(projectId) && + (specifiedPolls==null || (specifiedPolls!=null && specifiedPolls.size()==0))) { return ctx; } List<Poll> pollDesc=null; - if (pollIdSpecified!=null && !pollIdSpecified.equals("")) { + if (specifiedPolls!=null && specifiedPolls.size()>0) { pollDesc = new LinkedList<Poll>(); - pollDesc.add(desc.getPoll(projectId,pollIdSpecified)); + for (String pollIdString : specifiedPolls.keySet()) { + pollDesc.add(desc.getPoll(specifiedPolls.get(pollIdString),pollIdString)); + } } else { pollDesc = desc.getPollsInfoForProject(projectId); } @@ -488,9 +534,16 @@ for (Poll pollObj : pollDesc) { DelegateContext poll = polls.next("poll"); - + if (specifiedPolls!=null && specifiedPolls.size()>0) { + projectId = specifiedPolls.get(pollObj.getPollId()); + } poll.put("question",pollObj.getQuestion()); poll.put("actionUrl",response.createActionURL().toString()); + PortletURL url = response.createRenderURL(); + url.setParameter(VOTED_PARAMETER_NAME,TRUE); + url.setParameter(POLLID_PARAMETER_NAME,pollObj.getPollId()); + url.setParameter(PROJECTID_PARAMETER_NAME,projectId); + poll.put("renderUrlInfo",url.toString()); poll.put("pollId",pollObj.getPollId()); poll.put("project",projectId); Modified: qa/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/PollVotesDatabase.java =================================================================== --- qa/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/PollVotesDatabase.java 2006-01-13 18:45:31 UTC (rev 2094) +++ qa/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/PollVotesDatabase.java 2006-01-13 21:10:43 UTC (rev 2095) @@ -26,6 +26,7 @@ import java.util.Hashtable; import java.util.Map; +import org.jboss.logging.Logger; import org.jboss.shotoku.ContentManager; import org.jboss.shotoku.Directory; import org.jboss.shotoku.Node; @@ -47,13 +48,18 @@ /** * Location where the *database* is stored in content repository. */ - public static final String DATABASE_LOCATION = "default/polls/database/"; + public static final String DATABASE_LOCATION = "dynamic-content/default/polls/database/"; /** * Shotoku Directory object which points to the *database*. */ private Directory databaseDir; + /** + * Logger is used for displaying messages. + */ + private Logger logger; + @Inject ContentManager contentManager; @@ -65,6 +71,7 @@ */ public PollVotesDatabase() throws ResourceDoesNotExist { databaseDir =contentManager.getDirectory(DATABASE_LOCATION); + logger = Logger.getLogger(this.getClass()); } /** @@ -74,18 +81,14 @@ */ public void createNewPollFile (String fileName) { try { - System.out.println ("POLLVOTESDATABASE CREATENEWPOLL"); Node node = databaseDir.newNode(fileName); node.save("[Polls] Creating new poll's database file."); } catch (ResourceAlreadyExists e) { - System.out.println ("[POLLPORTLET] Database file for poll already exists!"); - e.printStackTrace(); - } catch (SaveException e) { - System.out.println ("[POLLS] Problem while saving property for database file."); - e.printStackTrace(); + logger.error ("Database file for poll already exists!",e); + } catch (SaveException e3) { + logger.error ("Error while saving property for database file.",e3); }catch (RepositoryException e2) { - System.out.println ("[POLLPORTLET] Problem with creating data file for poll!"); - e2.printStackTrace(); + logger.error ("Error while creating data file for poll!",e2); } } @@ -119,8 +122,7 @@ * True if vote was added successfully, false if user has already voted on that Poll. */ public boolean votedOnPoll (String pollId, String userId, String vote) { - System.out.println ("SETTING PROPERTY FOR FILE"); - System.out.println ("POLLID: "+pollId+" USERID: "+userId+" VOTE: "+vote); + Node pollFile=null; try { // Getting the file for Poll @@ -131,29 +133,25 @@ if (voteValue!= null && !voteValue.equals("")) return false; } catch (RepositoryException e) { - System.out.println ("[POLLS] RepositoryException while getting properties for Node."); - e.printStackTrace(); + logger.error ("RepositoryException while getting properties for Node.",e); return false; } catch (ResourceDoesNotExist e2) { - System.out.println("[POLLPORTLET] Database file for poll didn't exist!"); - e2.printStackTrace(); + logger.warn ("Database file for poll didn't exist, creating new one.",e2); // There was no file for Poll so it is created. try { databaseDir.newNode(pollId); } catch (ResourceAlreadyExists e3) { - e3.printStackTrace(); + logger.error("Database file for poll already existed.",e3); } } - System.out.println("PRZED DODANIEM GŁOSU "+pollFile.getClass().getCanonicalName()); + // Saving vote pollFile.setProperty(userId,vote); - System.out.println("PO DODANIU GŁOSU PRZED SAVEM"+pollFile.getClass().getCanonicalName()); + try { pollFile.save("[Polls] Saving property for poll's database file."); - System.out.println("PO DODANU GŁOSU PO SAVIE"+pollFile.getClass().getCanonicalName()); } catch (SaveException e) { - System.out.println ("[POLLS] Problem while saving property for database file."); - e.printStackTrace(); + logger.error ("Error while saving property for database file.",e); } return true; } @@ -167,28 +165,22 @@ * Map<String,String> containing users' votes. */ public Map<String,String> getUserVotesForPollFile (String pollId) { - System.out.println ("GETUSERVOTESFORPOLLFILE POLLID: "+pollId); + Map<String,String> userVotes = null; // if no poll id name was specified, method returns empty Map if (pollId==null) return new Hashtable<String,String>(0); try { // Getting Node for Poll Node pollFile = databaseDir.getNode(pollId); - System.out.println("PRZED GETPROPERTIES "+pollFile.getClass().getCanonicalName()); + //Collecting users' votes. userVotes = pollFile.getProperties(); - System.out.println("PO GETPROPERTIES "+pollFile.getClass().getCanonicalName()); - System.out.println ("I'M BEFORE DISPLAYING FILE PROPERTIES."); - for (String first:userVotes.keySet()){ - System.out.println("PROPERTY: "+first+" VALUE: "+userVotes.get(first)); - } + } catch (RepositoryException e) { - System.out.println ("[POLLS] RepositoryException while getting properties for Node."); - e.printStackTrace(); + logger.error("RepositoryException while getting properties for Node.",e); return new Hashtable<String,String>(0); } catch (ResourceDoesNotExist e2) { - System.out.println("[POLLPORTLET] Database file for poll didn't exist!"); - e2.printStackTrace(); + logger.error("Database file for poll didn't exist!",e2); return new Hashtable<String,String>(0); } return userVotes; @@ -205,15 +197,13 @@ Node pollFile = databaseDir.getNode(pollId); // Removing file. pollFile.delete(); + } catch (ResourceDoesNotExist e2) { - System.out.println ("[POLLS] Poll's data file was already deleted."); - e2.printStackTrace(); + logger.error("Poll's data file was already deleted.",e2); } catch (DeleteException e3) { - System.out.println ("[POLLS] Problem with deleting database file."); - e3.printStackTrace(); + logger.error("Exception with deleting database file.",e3); } catch (RepositoryException e) { - System.out.println ("[POLLPORTLET] Problem while deleting poll's data file."); - e.printStackTrace(); + logger.error("Exception while deleting poll's data file.",e); } } Modified: qa/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/PollsDescriptor.java =================================================================== --- qa/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/PollsDescriptor.java 2006-01-13 18:45:31 UTC (rev 2094) +++ qa/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/PollsDescriptor.java 2006-01-13 21:10:43 UTC (rev 2095) @@ -36,6 +36,7 @@ import org.apache.xerces.parsers.DOMParser; import org.jboss.forge.common.XmlTools; +import org.jboss.logging.Logger; import org.jboss.shotoku.ContentManager; import org.jboss.shotoku.Directory; import org.jboss.shotoku.exceptions.ResourceDoesNotExist; @@ -110,6 +111,11 @@ private PollVotesDatabase database; /** + * Logger is used for displaying messages. + */ + private Logger logger; + + /** * This boolean variable turns to true if one of the polls * has been incremented. If value is true the polls Map * will be synchronized with a main xml polls descriptor. @@ -127,9 +133,12 @@ */ public PollsDescriptor (final String portalName, ContentManager contentManager) { - // Just initializing the changeStatus variable - changeStatus=false; + // Just initializing the changeStatus variable to true so that the file is saved after all modifications. + changeStatus=true; + // Initializing logger. + logger = Logger.getLogger(this.getClass()); + // Getting the path to main polls descriptor. String pathToPollsXml = File.separator + PollTools.getMainXmlPath(portalName); @@ -157,9 +166,10 @@ // projects' poll descriptors. synchronizePolls(descriptors); - System.out.println ("PollsDescriptor created successfuly"); + synchronizeWithFile(portalName); + } catch (Exception e) { - e.printStackTrace(); + logger.error ("Failed to initialize Polls.",e); } } @@ -228,8 +238,7 @@ // Getting all projects dirs in members directory. membersProjectDirs = membersDir.getDirectories(); } catch (ResourceDoesNotExist exception) { - System.out.println ("[POLLSDESCRIPTOR] Cannot get members dir' project folders!"); - exception.printStackTrace(); + logger.error ("Cannot get members dir' project folders!",exception); return nodes; } @@ -246,7 +255,7 @@ nodes.put(projectId,poll); break; } catch (ResourceDoesNotExist e) { - System.out.println ("[POLLSDESCRIPTOR] Failed to get "+projectId+" poll descriptor!"); + logger.warn("Failed to get "+projectId+" poll descriptor!"); } } } @@ -266,7 +275,7 @@ private void synchronizePolls (Map<String,org.jboss.shotoku.Node> projectPolls) { // Checking if tracked projects still have their poll.xml descriptors. - // If not deleting all tracked links for them. + // If not deleting all tracked polls for them. removeNotTrackedProjects(projectPolls.keySet()); // Iterating through projects nodes containing poll descriptors. @@ -304,9 +313,7 @@ addPollsForVoting (descPolls,projectId); } catch (Exception e) { - System.out.println ("[POLLSDESCRIPTOR] Problem with opening project "+ - projectId+" poll descriptor."); - e.printStackTrace(); + logger.error("Problem with opening project "+projectId+" poll descriptor.",e); } } @@ -323,7 +330,7 @@ * Set<String> containing all project id names available. */ private synchronized void removeNotTrackedProjects(Set<String> projectIds) { - //polls.keySet().retainAll(projectIds); + List<String> projectsToDelete = new LinkedList<String>(); for (String projectId : polls.keySet()) { if (!projectIds.contains(projectId)) { @@ -434,7 +441,7 @@ public void synchronizeWithFile(String portalName) { String pathToPollsXml = File.separator + PollTools.getMainXmlPath(portalName); - System.out.println ("SYNCHRONIZING MAIN XML FILE"); + try { DOMParser parser = new DOMParser(); @@ -460,9 +467,9 @@ xmlFile.setContent(xmlString); xmlFile.save ("[Polls] Main xml descriptor file update."); changeStatus=false; - System.out.println ("AFTER SYNCHRONIZING MAIN XML FILE"); + } catch (Exception e) { - e.printStackTrace(); + logger.error("Problem while synchronizing data with main xml descriptor.",e); } } @@ -540,7 +547,7 @@ * Project id name for which is this question. */ synchronized public boolean vote (String answer,String pollId,String userId, String projectId) { - System.out.println ("TRYING TO VOTE"); + List<Poll> projectPolls = polls.get(projectId); if (projectPolls!=null) { Poll poll = null; @@ -554,7 +561,6 @@ return false; } if (poll!=null) { - System.out.println ("VOTING AND CHANGING STATUS"); // Status change to inform about counters modification. changeStatus=true; poll.vote(answer); @@ -668,13 +674,10 @@ values.put(tempProjectId,new ArrayList<Poll>()); } values.get(tempProjectId).add(new Poll(answerVotes,tempQuestion,tempPollId)); - System.out.println ("JESTEM PRZED CREATE"); // Adding data file for saving votes if it isn't already created. if (!database.checkForPollFile(tempPollId)) { - System.out.println ("JESTEM W CREATE"); database.createNewPollFile(tempPollId); } - System.out.println ("JESTEM PO CREATE"); } } } Modified: qa/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/PollsWatcher.java =================================================================== --- qa/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/PollsWatcher.java 2006-01-13 18:45:31 UTC (rev 2094) +++ qa/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/PollsWatcher.java 2006-01-13 21:10:43 UTC (rev 2095) @@ -89,26 +89,23 @@ */ public Object nodeUpdate(String portalName, Object currentValue) { - System.out.println ("IN UPDATE CHANGE STATUS: "+((PollsDescriptor)currentValue).hasChanged()); boolean resources = rw.checkResources(); boolean descriptors = false; if (currentValue!=null) descriptors = checkForNewResources((PollsDescriptor)currentValue,portalName); - System.out.println ("CHECKING RESOURCES: "+resources); - System.out.println ("DESCRITPROS: "+descriptors); - if (currentValue==null || resources//rw.checkResources() - || !descriptors){//checkForNewResources((PollsDescriptor)currentValue,portalName)) { - System.out.println("CREATING NEW DESCRIPTOR OBJECT."); + + if (currentValue==null || resources || !descriptors){ + return getDescriptor(portalName); + } else if (((PollsDescriptor)currentValue).hasChanged()){ - System.out.println ("I'M IN POLLWATCHER MAIN XML UPDATE."); + // There was some change on object connected to main polls xml descriptor // so we must synchronize the object with the file. PollsDescriptor descriptor = (PollsDescriptor)currentValue; descriptor.synchronizeWithFile(portalName); - System.out.println ("I'M IN POLLWATCHER AFTER MAIN XML UPDATE."); return null; } - System.out.println ("AT THE END OF NODEUPDATE"); + return null; } Copied: qa/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/Sorting.java (from rev 2094, trunk/forge/portal-extensions/forge-common/src/java/org/jboss/forge/common/projects/Sorting.java) Modified: qa/forge/portal-extensions/forge-file-access/src/java/org/jboss/forge/fileaccess/portlet/DownloadCounterPortlet.java =================================================================== --- qa/forge/portal-extensions/forge-file-access/src/java/org/jboss/forge/fileaccess/portlet/DownloadCounterPortlet.java 2006-01-13 18:45:31 UTC (rev 2094) +++ qa/forge/portal-extensions/forge-file-access/src/java/org/jboss/forge/fileaccess/portlet/DownloadCounterPortlet.java 2006-01-13 21:10:43 UTC (rev 2095) @@ -41,8 +41,9 @@ import org.jboss.shotoku.aop.Inject; /** + * DownloadCounters portlet. + * * @author Ryszard Kozmik - * Downlaod Counter portlet. */ public class DownloadCounterPortlet extends JBossPortlet { Modified: qa/forge/portal-extensions/forge-freezone/src/web/WEB-INF/portlet-instances.xml =================================================================== --- qa/forge/portal-extensions/forge-freezone/src/web/WEB-INF/portlet-instances.xml 2006-01-13 18:45:31 UTC (rev 2094) +++ qa/forge/portal-extensions/forge-freezone/src/web/WEB-INF/portlet-instances.xml 2006-01-13 21:10:43 UTC (rev 2095) @@ -14,4 +14,14 @@ </preference> </preferences> </instance> + <instance> + <instance-name>FreezoneRightPanelPortletInstance</instance-name> + <component-ref>PrjFreezonePortlet</component-ref> + <preferences> + <preference> + <name>page</name> + <value>default/members/default/freezone/rightPanelContent.html</value> + </preference> + </preferences> + </instance> </instances> Modified: qa/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Column.java =================================================================== --- qa/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Column.java 2006-01-13 18:45:31 UTC (rev 2094) +++ qa/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Column.java 2006-01-13 21:10:43 UTC (rev 2095) @@ -70,15 +70,16 @@ DelegateContext entryContext = projectContext.next("entry"); - Long value = null; + entryContext.put("name", getName()); + try { - value = plugin.getValue(projectId); + Long value = plugin.getValue(projectId); + + if (value != null) { + entryContext.put("value", Long.toString(value)); + } } catch (Exception e) { log.error("Could not get value for plugin: " + plugin.getId(), e); } - - entryContext.put("value", Long.toString(value)); - - entryContext.put("name", getName()); } } Modified: qa/forge/portal-extensions/forge-theme/jbossForgeLayout.war/layouts/jbossForge.jsp =================================================================== --- qa/forge/portal-extensions/forge-theme/jbossForgeLayout.war/layouts/jbossForge.jsp 2006-01-13 18:45:31 UTC (rev 2094) +++ qa/forge/portal-extensions/forge-theme/jbossForgeLayout.war/layouts/jbossForge.jsp 2006-01-13 21:10:43 UTC (rev 2095) @@ -130,8 +130,8 @@ <tr> <td class="leftside"><p:region regionName='left'/></td> <td class="bodycell"><p:region regionName='center'/></td> + <td ><p:region regionName='right'/></td> - </tr> </tbody></table> Modified: qa/forge/portal-extensions/forge-theme/jbossForgeLayout.war/layouts/twoColumns.jsp =================================================================== --- qa/forge/portal-extensions/forge-theme/jbossForgeLayout.war/layouts/twoColumns.jsp 2006-01-13 18:45:31 UTC (rev 2094) +++ qa/forge/portal-extensions/forge-theme/jbossForgeLayout.war/layouts/twoColumns.jsp 2006-01-13 21:10:43 UTC (rev 2095) @@ -113,7 +113,8 @@ <table width="100%" bgcolor="#FFFFFF"> <tr> <td class="leftColumn"><p:region regionName='left'/></td> -<td class="centerColumn"><p:region regionName='center'/></td> +<td class="centerColumn"><p:region regionName='center'/></td> +<td class="centerColumn"><p:region regionName='right'/></td> </tr> </table> @@ -127,4 +128,4 @@ </table> </body> -</html> \ No newline at end of file +</html> Modified: qa/forge/portal-extensions/polls/src/java/org/jboss/forge/polls/PollsPortlet.java =================================================================== --- qa/forge/portal-extensions/polls/src/java/org/jboss/forge/polls/PollsPortlet.java 2006-01-13 18:45:31 UTC (rev 2094) +++ qa/forge/portal-extensions/polls/src/java/org/jboss/forge/polls/PollsPortlet.java 2006-01-13 21:10:43 UTC (rev 2095) @@ -24,19 +24,16 @@ package org.jboss.forge.polls; import java.io.IOException; +import java.util.Map; -import javax.portlet.PortletConfig; import javax.portlet.PortletException; import javax.portlet.PortletRequestDispatcher; -import javax.portlet.PortletSession; -import javax.portlet.PortletURL; import org.jboss.forge.common.ForgeHelper; import org.jboss.forge.common.projects.PollTools; import org.jboss.forge.common.projects.ProjectsHelper; -import org.jboss.portal.common.context.Context; +import org.jboss.logging.Logger; import org.jboss.portal.common.context.DelegateContext; -import org.jboss.portal.core.model.User; import org.jboss.portal.core.servlet.jsp.PortalJsp; import org.jboss.portlet.JBossActionRequest; import org.jboss.portlet.JBossActionResponse; @@ -62,6 +59,11 @@ ContentManager contentManager; /** + * Logger is used for displaying messages. + */ + private Logger logger; + + /** * Method displays one of three views - voting view or scores information view * or voting detailed information. */ @@ -73,20 +75,11 @@ // resolving name of a portal String portalName = ForgeHelper.getPortalName(request); - // Getting name of the project on which the download counter is used. + // Getting name of the project on which the polls are used. String projectId = ProjectsHelper.getSelectedProjectId(request); ProjectsHelper.prepareRequest(request); - // Getting User from request. - User user = request.getUser(); - if (user!=null) { - String userName = user.getUserName(); - System.out.println ("USERNAME: "+userName); - } else { - System.out.println ("USER IS NULL"); - } - // Checking whether user has given his vote. String voted = request.getParameter(PollTools.VOTED_PARAMETER_NAME); @@ -97,16 +90,21 @@ String detailedReq = request.getParameter(PollTools.DETAILED_VIEW_REQUEST); // This variable contains manually requested pollId to render its voting view only. - String pollIdSpecified=null; + Map<String,String> specifiedPolls=null; // It is used if an instance have defined preference in instance descriptor. - Object modeFormPref = request.getPreferences().getValue("random",null); - System.out.println ("REQUESTED: "+modeFormPref); - if (modeFormPref!=null && modeFormPref.equals("all") && - (detailedReq!=null && detailedReq.compareTo(PollTools.TRUE)==0)==false && - (voted!=null && voted.compareTo(PollTools.TRUE)==0)==false ) { - projectId = PollTools.getRandomDefinedProjectId(portalName,contentManager); - pollIdSpecified = PollTools.getRandomPollForProjectId(projectId,portalName,contentManager); + Object modeFromPref = request.getPreferences().getValue("random",null); + + try { + if (modeFromPref!=null && !modeFromPref.equals("") && + (detailedReq!=null && detailedReq.compareTo(PollTools.TRUE)==0)==false && + (voted!=null && voted.compareTo(PollTools.TRUE)==0)==false ) { + Integer numberOfRandomPolls = Integer.parseInt((String)modeFromPref); + specifiedPolls = PollTools.getRandomPolls(numberOfRandomPolls,portalName,contentManager); + } + } catch (NumberFormatException e) { + logger =Logger.getLogger(this.getClass()); + logger.warn("Wrong number format in instance preference.",e); } DelegateContext pollContext=null; @@ -114,7 +112,6 @@ // If user has voted information page with scores will be displayed. if (voted!=null && voted.compareTo(PollTools.TRUE)==0) { - System.out.println ("USER VOTED"); // Getting pollId about which user wants to see information. String pollId = request.getParameter(PollTools.POLLID_PARAMETER_NAME); @@ -124,11 +121,7 @@ if (tempProjectId!=null && !tempProjectId.equals("")) { projectId = tempProjectId; } - - System.out.println("POLLID: "+pollId); - System.out.println("PROJECTID: "+projectId); - System.out.println("------------------"); - + // Getting the poll context for scores information page. pollContext = PollTools.getInfoContext(portalName,projectId,contentManager,response,pollId); rd = getPortletContext().getRequestDispatcher( @@ -137,9 +130,7 @@ // If user has requested detailed information about voting on specified poll. } else if (detailedReq!=null && detailedReq.compareTo(PollTools.TRUE)==0 ) { - - System.out.println ("DETAILED VIEW"); - + // Getting pollId about which user wants to see detailed information. String pollId = request.getParameter(PollTools.POLLID_PARAMETER_NAME); @@ -149,10 +140,6 @@ projectId = tempProjectId; } - System.out.println ("POLLID: "+pollId); - System.out.println ("PROJECTID: "+projectId); - System.out.println ("-------------------"); - // Getting the poll context for detailed voting information on specified poll. pollContext = PollTools.getDetailsContext(portalName,projectId,pollId,contentManager,response); rd = getPortletContext().getRequestDispatcher( @@ -161,15 +148,22 @@ // If user hasn't done anything yet the voting page will be displayed. } else { - System.out.println ("USER HAVEN'T VOTED"); // Getting the poll voting context. - pollContext = PollTools.getVotingContext(portalName,projectId,errorReq,contentManager,response,pollIdSpecified); + pollContext = PollTools.getVotingContext(portalName,projectId,errorReq,contentManager,response,specifiedPolls); rd = getPortletContext().getRequestDispatcher( ForgeHelper.createRepoAccessPath(portalName, PollTools .getVotingJsp())); } + // Claring request parameters after reading them. + Map parameterMap = request.getParameterMap(); + parameterMap.remove(PollTools.POLLID_PARAMETER_NAME); + parameterMap.remove(PollTools.PROJECTID_PARAMETER_NAME); + parameterMap.remove(PollTools.ERROR_PARAMETER_NAME); + parameterMap.remove(PollTools.VOTED_PARAMETER_NAME); + parameterMap.remove(PollTools.DETAILED_VIEW_REQUEST); + // Adding content context to the request attributes. request.setAttribute(PortalJsp.CTX_REQUEST, pollContext); rd.include(request, response); @@ -191,17 +185,12 @@ // Getting name of the project on which the PollsPortlet is used. String projectId = request.getParameter(ProjectsHelper.PROJECT_URL_PARAM); - System.out.println ("HELLO I'M IN POLLPORTLET VOTE: "+vote); - String userId = request.getUser()==null?"user"+Integer.toString((int)(Math.random()*100000)):request.getUser().getUserName(); - - System.out.println("PROJECTID:"+projectId); - - if (vote != null && !vote.equals("")) { - - - System.out.println ("VOTING"); - System.out.println ("VOTE: "+vote+"POLLID:"+pollId+" userId:"+userId+" PROJECTID: "+projectId); - + String userId = request.getUser()!=null?request.getUser().getUserName():null; + + if (userId==null) { + response.setRenderParameter(PollTools.ERROR_PARAMETER_NAME,"You have to login before voting."); + } else if (vote != null && !vote.equals("") && userId!=null) { + // Trying to vote. If it returns true it means that vote was given successfully // if not it means that user has already voted on this poll. if (PollTools.getDesc(portalName,contentManager).vote(vote,pollId,userId,projectId)) { @@ -209,13 +198,11 @@ response.setRenderParameter(PollTools.VOTED_PARAMETER_NAME,PollTools.TRUE); response.setRenderParameter(PollTools.POLLID_PARAMETER_NAME,pollId); response.setRenderParameter(PollTools.PROJECTID_PARAMETER_NAME,projectId); - System.out.println ("ZAGŁOSOWANO"); + } else { response.setRenderParameter(PollTools.ERROR_PARAMETER_NAME,"You have already voted on that poll"); - System.out.println ("GŁOS ODRZUCONO"); } } else { - System.out.println ("USER ZONK"); response.setRenderParameter(PollTools.ERROR_PARAMETER_NAME,"You haven't given your vote."); } } Modified: qa/forge/portal-extensions/polls/src/web/WEB-INF/portlet-instances.xml =================================================================== --- qa/forge/portal-extensions/polls/src/web/WEB-INF/portlet-instances.xml 2006-01-13 18:45:31 UTC (rev 2094) +++ qa/forge/portal-extensions/polls/src/web/WEB-INF/portlet-instances.xml 2006-01-13 21:10:43 UTC (rev 2095) @@ -4,4 +4,14 @@ <instance-name>PollsPortletInstance</instance-name> <component-ref>PollsPortlet</component-ref> </instance> + <instance> + <instance-name>PollsPortletInstanceRandom</instance-name> + <component-ref>PollsPortlet</component-ref> + <preferences> + <preference> + <name>random</name> + <value>3</value> + </preference> + </preferences> + </instance> </instances> Modified: qa/forge/portal-extensions/portal-default/src/web/WEB-INF/default-portal.xml =================================================================== --- qa/forge/portal-extensions/portal-default/src/web/WEB-INF/default-portal.xml 2006-01-13 18:45:31 UTC (rev 2094) +++ qa/forge/portal-extensions/portal-default/src/web/WEB-INF/default-portal.xml 2006-01-13 21:10:43 UTC (rev 2095) @@ -95,6 +95,20 @@ <height>2</height> <window-state>normal</window-state> </window> + <window> + <window-name>PollsPortletWindowDefaultRandom</window-name> + <instance-ref>polls.PollsPortlet.PollsPortletInstanceRandom</instance-ref> + <region>right</region> + <height>0</height> + <window-state>normal</window-state> + </window> + <window> + <window-name>FreezonePortletWindowDefaultRight</window-name> + <instance-ref>prj-freezone.PrjFreezonePortlet.FreezoneRightPanelPortletInstance</instance-ref> + <default>true</default> + <region>right</region> + <height>1</height> + </window> </page> @@ -270,6 +284,13 @@ <region>center</region> <height>0</height> </window> + <window> + <window-name>PollsPortletWindowInfo</window-name> + <instance-ref>polls.PollsPortlet.PollsPortletInstance</instance-ref> + <region>right</region> + <height>1</height> + <window-state>normal</window-state> + </window> </page> <page> @@ -330,13 +351,7 @@ <height>1</height> <window-state>normal</window-state> </window> - <!-- <window> - <window-name>PollsPortletWindowDefaultDownloads</window-name> - <instance-ref>polls.PollsPortlet.PollsPortletInstance</instance-ref> - <region>center</region> - <height>2</height> - <window-state>normal</window-state> - </window>--> + </page> <page> |
From: <jbo...@li...> - 2006-01-13 18:45:36
|
Author: wrzep Date: 2006-01-13 13:45:31 -0500 (Fri, 13 Jan 2006) New Revision: 2094 Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Column.java Log: exception inside plugin could propagate to the main part - fixed http://jira.jboss.com/jira/browse/JBLAB-589 Pawel Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Column.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Column.java 2006-01-13 17:36:27 UTC (rev 2093) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Column.java 2006-01-13 18:45:31 UTC (rev 2094) @@ -70,15 +70,16 @@ DelegateContext entryContext = projectContext.next("entry"); - Long value = null; + entryContext.put("name", getName()); + try { - value = plugin.getValue(projectId); + Long value = plugin.getValue(projectId); + + if (value != null) { + entryContext.put("value", Long.toString(value)); + } } catch (Exception e) { log.error("Could not get value for plugin: " + plugin.getId(), e); } - - entryContext.put("value", Long.toString(value)); - - entryContext.put("name", getName()); } } |