List of usage examples for java.lang Module Module
Module
From source file:com.basho.riak.presto.cli.CLI.java
public static void main(String[] args) throws Exception { Injector i = Guice.createInjector(Stage.PRODUCTION, //new JsonModule()); new Module() { @Override//from w w w. j a va2s . c o m public void configure(Binder binder) { jsonBinder(binder).addDeserializerBinding(Type.class) .to(Deserializer.CLITypeDeserializer.class); binder.bind(ObjectMapper.class).toProvider(ObjectMapperProvider.class); binder.bind(JsonCodecFactory.class).in(Scopes.SINGLETON); } }); log.debug("%s", i.getTypeConverterBindings()); if (args.length < 4) { usage(); return; } String hostname = args[0]; String port = args[1]; String command = args[2]; String schemaName = args[3]; RiakConfig config = new RiakConfig(hostname, port); // Actual command implementations if (command.equals("list-tables") && args.length == 4) { new SchemaDef(i, config).listTables(schemaName); } else if (command.equals("setup-schema") && args.length == 4) { new SchemaDef(i, config).setupSchema(schemaName); } else if (args.length == 5) { String tableArg = args[4]; if (command.equals("create-schema")) { CLI.log("This option is not currently supported."); } else if (command.equals("create-tabledef")) { new TableDef(i, config, schemaName, true).create(tableArg); } else if (command.equals("show-tabledef")) { new TableDef(i, config, schemaName, true).show(tableArg); } else if (command.equals("clear-tabledef")) { new TableDef(i, config, schemaName, true).clear(tableArg); } else if (command.equals("check-tabledef")) { new TableDef(i, config, schemaName, false).check(tableArg); } } else if (args[0].equals("plan")) { System.out.println(args[1]); String node = args[1]; String cookie = "riak"; if (args.length > 2) { cookie = args[2]; } System.out.println("connecting to Riak node " + node + " with cookie=" + cookie); String self = "client@127.0.0.1"; try { DirectConnection conn = new DirectConnection(self, cookie); conn.connect(node); //conn.pid(); //conn.ping(); Coverage coverage = new Coverage(conn); coverage.plan(); List<SplitTask> splits = coverage.getSplits(); System.out.println("print coverage plan=============="); System.out.println(coverage.toString()); for (SplitTask split : splits) { System.out.println("============printing split data at " + split.getHost() + "==============="); split.fetchAllData(conn, "default", "foobartable"); } } catch (java.io.IOException e) { System.err.println(e); } } else { usage(); } // Mock a Wock and don't leave any trash! System.gc(); }
From source file:common.EmailSender.java
public static void init(Jooby jooby) { jooby.use(new CommonsEmail()); jooby.use(new Module()); }
From source file:com.healthcit.cacure.model.ModuleTest.java
@Test @DataSet("classpath:users_roles_dataset.xml") public void testPersist() { Module module = new Module(); module.setDescription("test module 3"); module.setStatus(ModuleStatus.APPROVED_FOR_PILOT); module.setComments("test comments 3"); UserCredentials author = em.find(UserCredentials.class, 1L); module.setAuthor(author);/*from w w w . jav a 2 s . c o m*/ List<QuestionnaireForm> forms = new ArrayList<QuestionnaireForm>(); QuestionnaireForm form1 = (QuestionnaireForm) module.newForm(); form1.setName("form1"); form1.setOrd(3); form1.setAuthor(author); forms.add(form1); QuestionnaireForm form2 = (QuestionnaireForm) module.newForm(); form2.setName("form2"); form2.setOrd(2); form2.setAuthor(author); forms.add(form2); module.getForms().addAll(forms); module.setCompletionTime("completion time"); module.setReleaseDate(date("2011-09-10 00:00:00.000")); // TODO Date assertEquals(0, countRowsInTable("form")); em.persist(module); em.flush(); assertEqualsEntity(module); assertEquals(2, countRowsInTable("form")); assertTrue(existsInDb("form", form1.getId(), form2.getId())); assertEquals(module, form1.getModule()); assertEquals(module, form2.getModule()); }
From source file:org.opensilk.music.ui.settings.FolderPickerActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { ((DaggerInjector) getApplication()).getObjectGraph().plus(new Module()).inject(this); boolean lightTheme = !mSettings.isDarkTheme(); setTheme(lightTheme ? R.style.Theme_Settings_Light : R.style.Theme_Settings_Dark); super.onCreate(savedInstanceState); setContentView(R.layout.blank_framelayout_toolbar); ButterKnife.inject(this); setSupportActionBar(mToolbar);//from ww w .j ava 2 s . com getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setTitle(makeTitle(null)); getSupportActionBar().setSubtitle(makeSubtitle(null)); setResult(RESULT_CANCELED, getIntent()); if (savedInstanceState == null) { final String action = getIntent().getStringExtra(EXTRA_DIR); FolderPickerFragment f = FolderPickerFragment.newInstance(action); getSupportFragmentManager().beginTransaction().replace(R.id.main, f, "folders").commit(); } }
From source file:com.healthcit.cacure.businessdelegates.export.DataExporter.java
public Cure constructModuleXML(long id) { com.healthcit.cacure.model.BaseModule module = moduleManager.getModule(id); com.healthcit.cacure.export.model.ObjectFactory jaxbFactory = new com.healthcit.cacure.export.model.ObjectFactory(); Cure rootElement = jaxbFactory.createCure(); List<Module> xmlModules = rootElement.getModule(); Module xmlModule = new Module(); xmlModule.setUuid(module.getUuid()); xmlModule.setDescription(module.getComments()); xmlModule.setModuleName(module.getDescription()); if (!module.isLibrary()) { xmlModule.setCompletionTime(((com.healthcit.cacure.model.Module) module).getCompletionTime()); }//from ww w . ja va 2 s . c o m xmlModule.setInsertCheckAllThatApplyForMultiSelectAnswers( module.isInsertCheckAllThatApplyForMultiSelectAnswers()); xmlModule.setShowPleaseSelectOptionInDropDown(module.isShowPleaseSelectOptionInDropDown()); xmlModules.add(xmlModule); List<Section> sections = xmlModule.getSection(); List<BaseForm> forms = module.getForms(); for (BaseForm form : forms) { Form xmlForm = processForm(form, rootElement); Section xmlSection = new Section(); xmlSection.setOrder(form.getOrd()); xmlSection.setRef(xmlForm); if (!form.isLibraryForm()) { QuestionnaireForm qForm = (QuestionnaireForm) form; FormSkipRule formSkipRule = qForm.getFormSkipRule(); SkipRuleType skipRuleType = null; if (formSkipRule != null) { skipRuleType = populateSkips(formSkipRule); if (skipRuleType != null) { xmlSection.setSkipRule(skipRuleType); } } } sections.add(xmlSection); } return rootElement; }
From source file:com.cas.model.CourseContent.java
public void populateCourseContent(JSONObject jsonObject) { try {//from ww w .j av a 2 s . co m if (jsonObject != null) { String id = jsonObject.getString("id"); this.setId(Integer.valueOf(id)); String name = jsonObject.optString("name"); if (name != null && name.trim().length() > 0) this.setName(name); String visible = jsonObject.optString("visible"); if (visible != null && visible.trim().length() > 0) this.setVisible(Integer.valueOf(visible)); String summary = jsonObject.optString("summary"); if (summary != null && summary.trim().length() > 0) this.setSummary(summary); JSONArray modules = jsonObject.getJSONArray("modules"); ArrayList<Module> modulesArray = new ArrayList<Module>(); // looping through all Modules for (int i = 0; i < modules.length(); i++) { JSONObject c = modules.getJSONObject(i); Module module = new Module(); module.populateModule(c); //Toast.makeText(context.getApplicationContext(), course.getShortName(), Toast.LENGTH_LONG).show(); // Storing each json item in variable modulesArray.add(module); } if (modulesArray.size() > 0) { this.setModules(modulesArray); } } } catch (JSONException e) { e.printStackTrace(); } }
From source file:moodle.android.moodle.model.CourseContent.java
public void populateCourseContent(JSONObject jsonObject) { try {//from ww w . j a va 2 s . com if (jsonObject != null) { String id = jsonObject.getString("id"); this.setId(Integer.valueOf(id)); String name = jsonObject.optString("name"); if (name != null && name.trim().length() > 0) this.setName(name); String visible = jsonObject.optString("visible"); if (visible != null && visible.trim().length() > 0) this.setVisible(Integer.valueOf(visible)); String summary = jsonObject.optString("summary"); if (summary != null && summary.trim().length() > 0) this.setSummary(summary); JSONArray modules = jsonObject.getJSONArray("modules"); ArrayList<Module> modulesArray = new ArrayList<Module>(); // looping through all Modules for (int i = 0; i < modules.length(); i++) { JSONObject c = modules.getJSONObject(i); Module module = new Module(); module.populateModule(c); //Toast.makeText(context.getApplicationContext(), course.getShortName(), Toast.LENGTH_LONG).show(); // Storing each json item in variable modulesArray.add(module); } if (modulesArray.size() > 0) { this.setModules(modulesArray); } } } catch (JSONException e) { e.printStackTrace(); } }
From source file:org.whitesource.ant.WhitesourceTask.java
private void validateAndPrepare() { // api key/* ww w .j a v a 2 s. co m*/ if (StringUtils.isBlank(apiKey)) { error("Missing API Key"); } // product if (StringUtils.isBlank(product)) { product = getProject().getName(); } // modules if (modules.isEmpty()) { Module module = new Module(); // Treat whole project as single module module.setName("Default Module"); addDefaultPaths(module); modules.add(module); } else { int emptyModules = 0; for (Module module : modules) { if (StringUtils.isBlank(module.getName()) && StringUtils.isBlank(module.getToken())) { error("Expecting module name or token"); } if (module.getPaths().isEmpty()) { emptyModules++; } } if (emptyModules > 0) { if (modules.size() == 1) { addDefaultPaths(modules.iterator().next()); } else { error("Path not set"); } } } // check policies if (!checkPolicies.isEmpty()) { shouldCheckPolicies = true; policyCheck = checkPolicies.iterator().next(); File reportDir = policyCheck.getReportdir(); if (reportDir == null) { reportDir = new File(this.getProject().getBaseDir(), "reports"); policyCheck.setReportdir(reportDir); } if (!reportDir.exists() && !reportDir.mkdirs()) { error("Policies report directory doesn't exists and can not be created"); } } }
From source file:org.jongo.marshall.jackson.JacksonMapperTest.java
@Test public void canAddModule() throws Exception { ObjectId oid = new ObjectId("504482e5e4b0d1b2c47fff66"); Friend friend = new Friend(oid, "Robert"); Mapper mapper = jacksonMapper().registerModule(new Module() { @Override/*from ww w. j av a 2s. co m*/ public String getModuleName() { return "test-module"; } @Override public Version version() { return new Version(2, 0, 0, "", "org.jongo", "testmodule"); } @Override public void setupModule(SetupContext setupContext) { SimpleDeserializers deserializers = new SimpleDeserializers(); deserializers.addDeserializer(String.class, new DoeJsonDeserializer()); setupContext.addDeserializers(deserializers); } }).build(); BsonDocument document = mapper.getMarshaller().marshall(friend); assertThat(document.toString()).contains("\"_id\" : { \"$oid\" : \"504482e5e4b0d1b2c47fff66\"}"); }
From source file:bigbluej.Client.java
private String toXml(ModulesCommand modulesCommand) { Modules modules = new Modules(); modules.setModules(new ArrayList<Module>()); for (ModuleCommand moduleCommand : modulesCommand.getModules()) { Module module = new Module(); module.setName(moduleCommand.getName()); module.setDocuments(new ArrayList<Document>()); for (DocumentCommand documentCommand : moduleCommand.getDocuments()) { Document document = new Document(); document.setUrl(documentCommand.getUrl()); if (StringUtils.isNotBlank(documentCommand.getName())) { document.setName(documentCommand.getName()); document.setValue(Base64.encodeBase64String(documentCommand.getContent())); System.out.println("base64 value> " + document.getValue()); }/*from w ww . j ava 2 s .c o m*/ module.getDocuments().add(document); } modules.getModules().add(module); } StringWriter stringWriter = new StringWriter(); JAXB.marshal(modules, stringWriter); return stringWriter.getBuffer().toString(); }