Skip to content

Commit

Permalink
[refactor] Spun my functional utilities out into their own project ht…
Browse files Browse the repository at this point in the history
  • Loading branch information
adamretter committed Oct 14, 2016
1 parent 862a038 commit d153b82
Show file tree
Hide file tree
Showing 52 changed files with 74 additions and 763 deletions.
1 change: 1 addition & 0 deletions .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<classpathentry kind="src" path="extensions/debuggee/test"/>
<classpathentry kind="src" path="extensions/webdav/src"/>
<classpathentry kind="src" path="extensions/commands/src"/>
<classpathentry kind="src" path="lib/core/j8fu-1.0.jar"/>
<classpathentry kind="lib" path="lib/core/pkg-repo.jar"/>
<classpathentry kind="lib" path="lib/core/rsyntaxtextarea-2.5.6.jar"/>
<classpathentry kind="lib" path="lib/endorsed/xml-apis-1.4.01.jar"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
import org.exist.storage.DBBroker;
import org.exist.storage.btree.DBException;
import org.exist.util.DatabaseConfigurationException;
import org.exist.util.function.Function2E;
import org.exist.util.function.FunctionE;
import com.evolvedbinary.j8fu.function.Function2E;
import com.evolvedbinary.j8fu.function.FunctionE;
import org.exist.xquery.XPathException;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
import org.exist.security.internal.aider.GroupAider;
import org.exist.security.internal.aider.UserAider;
import org.exist.storage.DBBroker;
import org.exist.util.function.Function2E;
import com.evolvedbinary.j8fu.function.Function2E;
import org.scribe.exceptions.OAuthException;

/**
Expand Down
Binary file added lib/core/j8fu-1.0.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion src/org/exist/backup/Backup.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
package org.exist.backup;

import org.exist.util.FileUtils;
import org.exist.util.function.FunctionE;
import com.evolvedbinary.j8fu.function.FunctionE;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;

Expand Down
2 changes: 1 addition & 1 deletion src/org/exist/backup/SystemExport.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
import org.exist.util.FileUtils;
import org.exist.util.LockException;
import org.exist.util.UTF8;
import org.exist.util.function.FunctionE;
import com.evolvedbinary.j8fu.function.FunctionE;
import org.exist.util.serializer.AttrList;
import org.exist.util.serializer.Receiver;
import org.exist.util.serializer.SAXSerializer;
Expand Down
2 changes: 1 addition & 1 deletion src/org/exist/config/Configurator.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
import org.exist.storage.txn.TransactionManager;
import org.exist.storage.txn.Txn;
import org.exist.util.MimeType;
import org.exist.util.function.ConsumerE;
import com.evolvedbinary.j8fu.function.ConsumerE;
import org.exist.util.serializer.SAXSerializer;
import org.exist.xmldb.FullXmldbURI;
import org.exist.xmldb.XmldbURI;
Expand Down
2 changes: 1 addition & 1 deletion src/org/exist/management/impl/DiskUsage.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import org.exist.storage.journal.Journal;
import org.exist.util.Configuration;
import org.exist.util.FileUtils;
import org.exist.util.function.FunctionE;
import com.evolvedbinary.j8fu.function.FunctionE;

/**
* Class DiskUsage. Retrieves data from the java File object
Expand Down
4 changes: 2 additions & 2 deletions src/org/exist/security/AbstractRealm.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
import org.exist.storage.txn.TransactionManager;
import org.exist.storage.txn.Txn;
import org.exist.util.LockException;
import org.exist.util.function.Consumer2E;
import org.exist.util.function.ConsumerE;
import com.evolvedbinary.j8fu.function.Consumer2E;
import com.evolvedbinary.j8fu.function.ConsumerE;
import org.exist.xmldb.XmldbURI;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/org/exist/security/PermissionFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import org.exist.storage.txn.TransactionException;
import org.exist.storage.txn.TransactionManager;
import org.exist.storage.txn.Txn;
import org.exist.util.function.ConsumerE;
import com.evolvedbinary.j8fu.function.ConsumerE;
import org.exist.xmldb.XmldbURI;
import org.exist.xquery.XPathException;

Expand Down
3 changes: 2 additions & 1 deletion src/org/exist/start/start.config
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ lib/core/xmlrpc-common-%latest%.jar always
lib/core/xmlrpc-server-%latest%.jar always
lib/core/clj-ds-%latest%.jar always
lib/core/cglib-nodep-%latest%.jar always
lib/core/j8fu-%latest%.jar always
lib/optional/* mode == jetty
lib/optional/* mode == other
lib/optional/* mode == backup
Expand Down Expand Up @@ -109,4 +110,4 @@ tools/yajsw/lib/extended/velocity/velocity-%latest%.jar mode == other
tools/yajsw/lib/core/commons/commons-configuration2-%latest%.jar mode == other
tools/yajsw/lib/core/commons/commons-lang3-%latest%.jar mode == other
tools/yajsw/lib/core/netty/netty-all-4.0.35.Final.jar mode == other
tools/yajsw/lib/core/jna/jna-platform-%latest%.jar mode == other
tools/yajsw/lib/core/jna/jna-platform-%latest%.jar mode == other
67 changes: 31 additions & 36 deletions src/org/exist/storage/BrokerPoolServicesManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@

import net.jcip.annotations.NotThreadSafe;
import org.exist.util.Configuration;
import com.evolvedbinary.j8fu.fsm.AtomicFSM;
import com.evolvedbinary.j8fu.fsm.FSM;

import static com.evolvedbinary.j8fu.fsm.TransitionTable.transitionTable;


import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -51,7 +56,24 @@ private enum ManagerState {
MULTI_USER
}

private ManagerState state = ManagerState.REGISTRATION;
private enum ManagerEvent {
CONFIGURE,
PREPARE,
ENTER_SYSTEM_MODE,
PREPARE_ENTER_MULTI_USER_MODE,
ENTER_MULTI_USER_MODE
}

@SuppressWarnings("unchecked")
private FSM<ManagerState, ManagerEvent> states = new AtomicFSM<>(ManagerState.REGISTRATION, transitionTable(ManagerState.class, ManagerEvent.class)
.when(ManagerState.REGISTRATION)
.on(ManagerEvent.CONFIGURE).switchTo(ManagerState.CONFIGURATION)
.on(ManagerEvent.PREPARE).switchTo(ManagerState.PREPARATION)
.on(ManagerEvent.ENTER_SYSTEM_MODE).switchTo(ManagerState.SYSTEM)
.on(ManagerEvent.PREPARE_ENTER_MULTI_USER_MODE).switchTo(ManagerState.PRE_MULTI_USER)
.on(ManagerEvent.ENTER_MULTI_USER_MODE).switchTo(ManagerState.MULTI_USER)
.build()
);

final List<BrokerPoolService> brokerPoolServices = new ArrayList<>();

Expand All @@ -69,9 +91,10 @@ private enum ManagerState {
* after any other service has been configured.
*/
<T extends BrokerPoolService> T register(final T brokerPoolService) {
if(state != ManagerState.REGISTRATION) {
final ManagerState currentState = states.getCurrentState();
if(currentState != ManagerState.REGISTRATION) {
throw new IllegalStateException(
"Services may only be registered during the registration state. Current state is: " + state.name());
"Services may only be registered during the registration state. Current state is: " + currentState.name());
}

brokerPoolServices.add(brokerPoolService);
Expand All @@ -91,12 +114,7 @@ <T extends BrokerPoolService> T register(final T brokerPoolService) {
* after any other service has been prepared.
*/
void configureServices(final Configuration configuration) throws BrokerPoolServiceException {
if(state != ManagerState.REGISTRATION) {
throw new IllegalStateException(
"Services may only be configured after the registration state. Current state is: " + state.name());
} else {
state = ManagerState.CONFIGURATION;
}
states.process(ManagerEvent.CONFIGURE);

for(final BrokerPoolService brokerPoolService : brokerPoolServices) {
brokerPoolService.configure(configuration);
Expand All @@ -116,12 +134,7 @@ void configureServices(final Configuration configuration) throws BrokerPoolServi
* after any other service has entered start system service.
*/
void prepareServices(final BrokerPool brokerPool) throws BrokerPoolServiceException {
if(state != ManagerState.CONFIGURATION) {
throw new IllegalStateException(
"Services may only be prepared after the configuration state. Current state is: " + state.name());
} else {
state = ManagerState.PREPARATION;
}
states.process(ManagerEvent.PREPARE);

for(final BrokerPoolService brokerPoolService : brokerPoolServices) {
brokerPoolService.prepare(brokerPool);
Expand All @@ -146,13 +159,7 @@ void prepareServices(final BrokerPool brokerPool) throws BrokerPoolServiceExcept
* after any other service has entered the start pre-multi-user system mode.
*/
void startSystemServices(final DBBroker systemBroker) throws BrokerPoolServiceException {
if(state != ManagerState.PREPARATION) {
throw new IllegalStateException(
"Services may only be started in system mode after the preparation state. Current state is: "
+ state.name());
} else {
this.state = ManagerState.SYSTEM;
}
states.process(ManagerEvent.ENTER_SYSTEM_MODE);

for(final BrokerPoolService brokerPoolService : brokerPoolServices) {
brokerPoolService.startSystem(systemBroker);
Expand All @@ -177,13 +184,7 @@ void startSystemServices(final DBBroker systemBroker) throws BrokerPoolServiceEx
* after any other service has entered multi-user.
*/
void startPreMultiUserSystemServices(final DBBroker systemBroker) throws BrokerPoolServiceException {
if(state != ManagerState.SYSTEM) {
throw new IllegalStateException(
"Services may only be started in pre-multi-user mode after the system state. Current state is: "
+ state.name());
} else {
this.state = ManagerState.PRE_MULTI_USER;
}
states.process(ManagerEvent.PREPARE_ENTER_MULTI_USER_MODE);

for(final BrokerPoolService brokerPoolService : brokerPoolServices) {
brokerPoolService.startPreMultiUserSystem(systemBroker);
Expand All @@ -202,13 +203,7 @@ void startPreMultiUserSystemServices(final DBBroker systemBroker) throws BrokerP
* before we have completed pre-multi-user mode
*/
void startMultiUserServices(final BrokerPool brokerPool) throws BrokerPoolServiceException {
if(state != ManagerState.PRE_MULTI_USER) {
throw new IllegalStateException(
"Services may only be started in pre-multi-user mode after the system state. Current state is: "
+ state.name());
} else {
this.state = ManagerState.MULTI_USER;
}
states.process(ManagerEvent.ENTER_MULTI_USER_MODE);

for(final BrokerPoolService brokerPoolService : brokerPoolServices) {
brokerPoolService.startMultiUser(brokerPool);
Expand Down
2 changes: 1 addition & 1 deletion src/org/exist/storage/BrokerPools.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.exist.EXistException;
import org.exist.util.Configuration;
import org.exist.util.DatabaseConfigurationException;
import org.exist.util.function.ConsumerE;
import com.evolvedbinary.j8fu.function.ConsumerE;

import java.util.*;
import java.util.concurrent.locks.Lock;
Expand Down
1 change: 0 additions & 1 deletion src/org/exist/storage/DBBroker.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
import org.exist.storage.sync.Sync;
import org.exist.storage.txn.Txn;
import org.exist.util.*;
import org.exist.util.function.Tuple2;
import org.exist.xmldb.XmldbURI;
import org.exist.xquery.TerminatedException;
import org.w3c.dom.Document;
Expand Down
4 changes: 2 additions & 2 deletions src/org/exist/storage/NativeBroker.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
import org.exist.storage.txn.TransactionManager;
import org.exist.storage.txn.Txn;
import org.exist.util.*;
import org.exist.util.function.ConsumerE;
import com.evolvedbinary.j8fu.function.ConsumerE;
import org.exist.xmldb.XmldbURI;
import org.exist.xquery.TerminatedException;
import org.exist.xquery.value.Type;
Expand All @@ -93,7 +93,7 @@

import org.exist.dom.persistent.StoredNode;
import org.exist.storage.dom.INodeIterator;
import org.exist.util.function.Tuple2;
import com.evolvedbinary.j8fu.tuple.Tuple2;

/**
* Main class for the native XML storage backend.
Expand Down
2 changes: 1 addition & 1 deletion src/org/exist/storage/NativeValueIndex.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.apache.logging.log4j.Logger;

import org.exist.util.*;
import org.exist.util.function.FunctionE;
import com.evolvedbinary.j8fu.function.FunctionE;
import org.exist.xquery.XQueryWatchDog;
import org.w3c.dom.Node;

Expand Down
2 changes: 1 addition & 1 deletion src/org/exist/storage/recovery/RecoveryManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import org.exist.storage.txn.Checkpoint;
import org.exist.util.FileUtils;
import org.exist.util.ProgressBar;
import org.exist.util.function.SupplierE;
import com.evolvedbinary.j8fu.function.SupplierE;
import org.exist.util.hashtable.Long2ObjectHashMap;
import org.exist.util.sanity.SanityCheck;

Expand Down
2 changes: 1 addition & 1 deletion src/org/exist/storage/serializers/XIncludeFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import org.exist.source.Source;
import org.exist.source.StringSource;
import org.exist.storage.XQueryPool;
import org.exist.util.function.Either;
import com.evolvedbinary.j8fu.Either;
import org.exist.util.serializer.AttrList;
import org.exist.util.serializer.Receiver;
import org.exist.xmldb.XmldbURI;
Expand Down
2 changes: 1 addition & 1 deletion src/org/exist/util/FileUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.exist.util.function.FunctionE;
import com.evolvedbinary.j8fu.function.FunctionE;

import java.io.File;
import java.io.IOException;
Expand Down
2 changes: 1 addition & 1 deletion src/org/exist/util/HtmlToXmlParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.exist.util.function.Either;
import com.evolvedbinary.j8fu.Either;
import org.xml.sax.*;

import java.util.Map;
Expand Down
4 changes: 2 additions & 2 deletions src/org/exist/util/VirtualTempFileInputSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.exist.util.function.Either;
import org.exist.util.function.SupplierE;
import com.evolvedbinary.j8fu.Either;
import com.evolvedbinary.j8fu.function.SupplierE;
import org.xml.sax.InputSource;

import java.io.BufferedInputStream;
Expand Down
33 changes: 0 additions & 33 deletions src/org/exist/util/function/BiConsumerE.java

This file was deleted.

37 changes: 0 additions & 37 deletions src/org/exist/util/function/BiFunction2E.java

This file was deleted.

Loading

0 comments on commit d153b82

Please sign in to comment.