-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
521 changed files
with
44,973 additions
and
15,267 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
88 changes: 46 additions & 42 deletions
88
.../java/org/gsc/common/app/Application.java → ...g/gsc/common/application/Application.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,46 @@ | ||
/* | ||
* gsc-core is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* gsc-core 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 General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package org.gsc.common.app; | ||
|
||
import org.gsc.config.Args; | ||
import org.gsc.db.Manager; | ||
import org.gsc.service.Service; | ||
import org.springframework.context.ApplicationContext; | ||
|
||
public interface Application { | ||
|
||
void setOptions(Args args); | ||
|
||
void init(Args args, ApplicationContext ctx); | ||
|
||
void initServices(Args args); | ||
|
||
void startup(); | ||
|
||
void shutdown(); | ||
|
||
void startServices(); | ||
|
||
void shutdownServices(); | ||
|
||
void addService(Service service); | ||
|
||
Manager getDbManager(); | ||
} | ||
/* | ||
* java-gsc is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* java-gsc 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 General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package org.gsc.common.application; | ||
|
||
import org.gsc.core.config.args.Args; | ||
import org.gsc.core.db.BlockStore; | ||
import org.gsc.core.db.Manager; | ||
import org.gsc.core.net.node.Node; | ||
|
||
public interface Application { | ||
|
||
void setOptions(Args args); | ||
|
||
void init(Args args); | ||
|
||
void initServices(Args args); | ||
|
||
void startup(); | ||
|
||
void shutdown(); | ||
|
||
void startServices(); | ||
|
||
void shutdownServices(); | ||
|
||
Node getP2pNode(); | ||
|
||
BlockStore getBlockStoreS(); | ||
|
||
void addService(Service service); | ||
|
||
Manager getDbManager(); | ||
} |
50 changes: 50 additions & 0 deletions
50
src/main/java/org/gsc/common/application/ApplicationFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* java-gsc is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* java-gsc 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 General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package org.gsc.common.application; | ||
|
||
import com.google.inject.Guice; | ||
import com.google.inject.Injector; | ||
import org.springframework.context.ApplicationContext; | ||
|
||
public class ApplicationFactory { | ||
|
||
/** | ||
* Build a Guice instance. | ||
* | ||
* @return Guice | ||
*/ | ||
public Injector buildGuice() { | ||
return Guice.createInjector( | ||
new Module()); | ||
} | ||
|
||
/** | ||
* Build a new application. | ||
*/ | ||
public Application build() { | ||
return new ApplicationImpl(); | ||
} | ||
|
||
/** | ||
* Build a new cli application. | ||
*/ | ||
//public CliApplication buildCli() { | ||
// return new CliApplication(buildGuice()); | ||
public static Application create(ApplicationContext ctx) { | ||
return ctx.getBean(ApplicationImpl.class); | ||
//return new ApplicationImpl(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
src/main/java/org/gsc/common/application/CliApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* java-gsc is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* java-gsc 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 General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.gsc.common.application; | ||
|
||
import org.gsc.core.config.args.Args; | ||
import org.gsc.core.db.BlockStore; | ||
import org.gsc.core.db.Manager; | ||
import org.gsc.core.net.node.Node; | ||
|
||
public class CliApplication implements Application { | ||
|
||
@Override | ||
public void setOptions(Args args) { | ||
|
||
} | ||
|
||
@Override | ||
public void init( Args args) { | ||
|
||
} | ||
|
||
@Override | ||
public void initServices(Args args) { | ||
|
||
} | ||
|
||
@Override | ||
public void startup() { | ||
|
||
} | ||
|
||
@Override | ||
public void shutdown() { | ||
|
||
} | ||
|
||
@Override | ||
public void startServices() { | ||
|
||
} | ||
|
||
@Override | ||
public void shutdownServices() { | ||
|
||
} | ||
|
||
@Override | ||
public Node getP2pNode() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public BlockStore getBlockStoreS() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void addService(Service service) { | ||
|
||
} | ||
|
||
@Override | ||
public Manager getDbManager() { | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* java-gsc is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* java-gsc 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 General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package org.gsc.common.application; | ||
|
||
import static org.gsc.core.Constant.BLOCK_DB_NAME; | ||
import static org.gsc.core.Constant.TRANSACTION_DB_NAME; | ||
|
||
import com.google.inject.AbstractModule; | ||
import com.google.inject.Provides; | ||
import com.google.inject.Singleton; | ||
import javax.inject.Named; | ||
import org.gsc.core.Constant; | ||
import org.gsc.common.storage.leveldb.LevelDbDataSourceImpl; | ||
import org.gsc.core.config.args.Args; | ||
|
||
public class Module extends AbstractModule { | ||
|
||
@Override | ||
protected void configure() { | ||
|
||
} | ||
|
||
/** | ||
* build transaction database. | ||
*/ | ||
@Provides | ||
@Singleton | ||
@Named("transaction") | ||
public LevelDbDataSourceImpl buildTransactionDb() { | ||
LevelDbDataSourceImpl db = new LevelDbDataSourceImpl(Args.getInstance().getOutputDirectory(), | ||
Constant.TRANSACTION_DB_NAME); | ||
db.initDB(); | ||
return db; | ||
} | ||
|
||
/** | ||
* build block database. | ||
*/ | ||
@Provides | ||
@Singleton | ||
@Named("block") | ||
public LevelDbDataSourceImpl buildBlockDb() { | ||
LevelDbDataSourceImpl db = new LevelDbDataSourceImpl(Args.getInstance().getOutputDirectory(), | ||
Constant.BLOCK_DB_NAME); | ||
db.initDB(); | ||
return db; | ||
} | ||
} |
Oops, something went wrong.