Skip to content

Commit

Permalink
Add connection pooling, bump version and fix groovy closures
Browse files Browse the repository at this point in the history
  • Loading branch information
minborg committed Aug 24, 2015
1 parent cc86ecb commit 318151c
Show file tree
Hide file tree
Showing 18 changed files with 991 additions and 175 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -31,7 +31,7 @@

<groupId>com.speedment</groupId>
<artifactId>speedment</artifactId>
<version>2.0.0-EA2</version>
<version>2.1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
83 changes: 49 additions & 34 deletions src/main/java/com/speedment/core/config/model/Dbms.java
Expand Up @@ -23,6 +23,7 @@
import com.speedment.core.config.model.aspects.Node;
import com.speedment.core.config.model.impl.DbmsImpl;
import com.speedment.core.config.model.parameters.DbmsTypeable;
import groovy.lang.Closure;
import java.util.Optional;
import java.util.function.Supplier;

Expand All @@ -36,26 +37,27 @@ public interface Dbms extends Node, Enableable, DbmsTypeable, Child<Project>, Pa
/**
* Factory holder.
*/
enum Holder { HOLDER;
enum Holder {
HOLDER;
private Supplier<Dbms> provider = DbmsImpl::new;
}

/**
* Sets the instantiation method used to create new instances of this
* interface.
*
* @param provider the new constructor
*
* @param provider the new constructor
*/
static void setSupplier(Supplier<Dbms> provider) {
Holder.HOLDER.provider = provider;
}

/**
* Creates a new instance implementing this interface by using the class
* supplied by the default factory. To change implementation, please use
* the {@link #setSupplier(java.util.function.Supplier) setSupplier} method.
* @return the new instance
* supplied by the default factory. To change implementation, please use the
* {@link #setSupplier(java.util.function.Supplier) setSupplier} method.
*
* @return the new instance
*/
static Dbms newDbms() {
return Holder.HOLDER.provider.get();
Expand All @@ -78,10 +80,10 @@ default Class<Project> getParentInterfaceMainClass() {
}

/**
* Creates and adds a new {@link Schema} as a child to this node in the
* Creates and adds a new {@link Schema} as a child to this node in the
* configuration tree.
*
* @return the newly added child
*
* @return the newly added child
*/
default Schema addNewSchema() {
final Schema e = Schema.newSchema();
Expand All @@ -91,23 +93,23 @@ default Schema addNewSchema() {

/**
* Returns the address of the database host if it is specified. The address
* could be an ip-address or a hostname. If no address is specified,
* could be an ip-address or a hostname. If no address is specified,
* {@code empty} will be returned.
* <p>
* This property is editable in the GUI through reflection.
*
* @return the address of the host or {@code empty}
*
* @return the address of the host or {@code empty}
*/
@External(type = String.class)
Optional<String> getIpAddress();

/**
* Sets the address of the database host. The address could be an ip-address
* Sets the address of the database host. The address could be an ip-address
* or a hostname.
* <p>
* This property is editable in the GUI through reflection.
*
* @param ipAddress the new address of the host or {@code null}
*
* @param ipAddress the new address of the host or {@code null}
*/
@External(type = String.class)
void setIpAddress(String ipAddress);
Expand All @@ -117,8 +119,8 @@ default Schema addNewSchema() {
* is specified, {@code empty} is returned.
* <p>
* This property is editable in the GUI through reflection.
*
* @return the port of the database or {@code empty}
*
* @return the port of the database or {@code empty}
*/
@External(type = Integer.class)
Optional<Integer> getPort();
Expand All @@ -128,55 +130,68 @@ default Schema addNewSchema() {
* should be specified, enter {@code null}.
* <p>
* This property is editable in the GUI through reflection.
*
* @param port the port of the database or {@code null}
*
* @param port the port of the database or {@code null}
*/
@External(type = Integer.class)
void setPort(Integer port);

/**
* Returns the database username to use when connecting to the dbms. If no
* Returns the database username to use when connecting to the dbms. If no
* username is specified, {@code empty} is returned.
* <p>
* This property is editable in the GUI through reflection.
*
* @return the database username or {@code empty}
*
* @return the database username or {@code empty}
*/
@External(type = String.class)
Optional<String> getUsername();

/**
* Sets the database username to use when connecting to the dbms. If no
* Sets the database username to use when connecting to the dbms. If no
* username should be specified, use {@code null}.
* <p>
* This property is editable in the GUI through reflection.
*
* @param username the database username or {@code null}
*
* @param username the database username or {@code null}
*/
@External(type = String.class)
void setUsername(String username);

/**
* Returns the password to use when connecting to the dbms. If no
* password is specified, {@code empty} is returned.
* Returns the password to use when connecting to the dbms. If no password
* is specified, {@code empty} is returned.
* <p>
* This property is editable in the GUI through reflection, but will not
* appear in generated configuration files for security reasons.
*
* @return the dbms password or {@code empty}
*
* @return the dbms password or {@code empty}
*/
@External(type = String.class, isSecret = true)
Optional<String> getPassword();

/**
* Sets the password to use when connecting to the dbms. If no password
* Sets the password to use when connecting to the dbms. If no password
* should be specified, use {@code null} instead.
* <p>
* This property is editable in the GUI through reflection, but will not
* appear in generated configuration files for security reasons.
*
* @param password the dbms password or {@code null}
*
* @param password the dbms password or {@code null}
*/
@External(type = String.class, isSecret = true)
void setPassword(String password);
}

/**
* Creates and returns a new Schema.
* <p>
* This method is used by the Groovy parser.
*
* @param c Closure
* @return the new Schema
*/
// DO NOT REMOVE, CALLED VIA REFLECTION
default Schema schema(Closure<?> c) {
return ConfigUtil.groovyDelegatorHelper(c, this::addNewSchema);
}
}
38 changes: 27 additions & 11 deletions src/main/java/com/speedment/core/config/model/ForeignKey.java
Expand Up @@ -22,6 +22,7 @@
import com.speedment.core.config.model.aspects.Enableable;
import com.speedment.core.config.model.aspects.Node;
import com.speedment.core.config.model.impl.ForeignKeyImpl;
import groovy.lang.Closure;
import java.util.function.Supplier;

/**
Expand All @@ -34,26 +35,27 @@ public interface ForeignKey extends Node, Enableable, Child<Table>, Parent<Forei
/**
* Factory holder.
*/
enum Holder { HOLDER;
enum Holder {
HOLDER;
private Supplier<ForeignKey> provider = ForeignKeyImpl::new;
}

/**
* Sets the instantiation method used to create new instances of this
* interface.
*
* @param provider the new constructor
*
* @param provider the new constructor
*/
static void setSupplier(Supplier<ForeignKey> provider) {
Holder.HOLDER.provider = provider;
}

/**
* Creates a new instance implementing this interface by using the class
* supplied by the default factory. To change implementation, please use
* the {@link #setSupplier(java.util.function.Supplier) setSupplier} method.
* @return the new instance
* supplied by the default factory. To change implementation, please use the
* {@link #setSupplier(java.util.function.Supplier) setSupplier} method.
*
* @return the new instance
*/
static ForeignKey newForeignKey() {
return Holder.HOLDER.provider.get();
Expand All @@ -76,14 +78,28 @@ default Class<Table> getParentInterfaceMainClass() {
}

/**
* Creates and adds a new {@link ForeignKeyColumn} as a child to this node
* Creates and adds a new {@link ForeignKeyColumn} as a child to this node
* in the configuration tree.
*
* @return the newly added child
*
* @return the newly added child
*/
default ForeignKeyColumn addNewForeignKeyColumn() {
final ForeignKeyColumn e = ForeignKeyColumn.newForeignKeyColumn();
add(e);
return e;
}
}

/**
* Creates and returns a new ForeignKeyColumn.
* <p>
* This method is used by the Groovy parser.
*
* @param c Closure
* @return the new ForeignKeyColumn
*/
// DO NOT REMOVE, CALLED VIA REFLECTION
default ForeignKeyColumn foreignKeyColumn(Closure<?> c) {
return ConfigUtil.groovyDelegatorHelper(c, this::addNewForeignKeyColumn);
}

}
46 changes: 31 additions & 15 deletions src/main/java/com/speedment/core/config/model/Index.java
Expand Up @@ -22,6 +22,7 @@
import com.speedment.core.config.model.aspects.Enableable;
import com.speedment.core.config.model.aspects.Node;
import com.speedment.core.config.model.impl.IndexImpl;
import groovy.lang.Closure;
import java.util.function.Supplier;

/**
Expand All @@ -34,26 +35,27 @@ public interface Index extends Node, Enableable, Child<Table>, Parent<IndexColum
/**
* Factory holder.
*/
enum Holder { HOLDER;
enum Holder {
HOLDER;
private Supplier<Index> provider = IndexImpl::new;
}

/**
* Sets the instantiation method used to create new instances of this
* interface.
*
* @param provider the new constructor
*
* @param provider the new constructor
*/
static void setSupplier(Supplier<Index> provider) {
Holder.HOLDER.provider = provider;
}

/**
* Creates a new instance implementing this interface by using the class
* supplied by the default factory. To change implementation, please use
* the {@link #setSupplier(java.util.function.Supplier) setSupplier} method.
* @return the new instance
* supplied by the default factory. To change implementation, please use the
* {@link #setSupplier(java.util.function.Supplier) setSupplier} method.
*
* @return the new instance
*/
static Index newIndex() {
return Holder.HOLDER.provider.get();
Expand All @@ -76,10 +78,10 @@ default Class<Table> getParentInterfaceMainClass() {
}

/**
* Creates and adds a new {@link IndexColumn} as a child to this node in the
* Creates and adds a new {@link IndexColumn} as a child to this node in the
* configuration tree.
*
* @return the newly added child
*
* @return the newly added child
*/
default IndexColumn addNewIndexColumn() {
final IndexColumn e = IndexColumn.newIndexColumn();
Expand All @@ -91,8 +93,8 @@ default IndexColumn addNewIndexColumn() {
* Returns whether or not this index is an {@code UNIQUE} index.
* <p>
* This property is editable in the GUI through reflection.
*
* @return {@code true} if this index is {@code UNIQUE}
*
* @return {@code true} if this index is {@code UNIQUE}
*/
@External(type = Boolean.class)
Boolean isUnique();
Expand All @@ -101,9 +103,23 @@ default IndexColumn addNewIndexColumn() {
* Sets whether or not this index is an {@code UNIQUE} index.
* <p>
* This property is editable in the GUI through reflection.
*
* @param unique {@code true} if this index should be {@code UNIQUE}
*
* @param unique {@code true} if this index should be {@code UNIQUE}
*/
@External(type = Boolean.class)
void setUnique(Boolean unique);
}

/**
* Creates and returns a new IndexColumn.
* <p>
* This method is used by the Groovy parser.
*
* @param c Closure
* @return the new IndexColumn
*/
// DO NOT REMOVE, CALLED VIA REFLECTION
default IndexColumn indexColumn(Closure<?> c) {
return ConfigUtil.groovyDelegatorHelper(c, this::addNewIndexColumn);
}

}

0 comments on commit 318151c

Please sign in to comment.