use of org.qi4j.bootstrap.Energy4Java in project qi4j-sdk by Qi4j.
the class ObjectVisibilityTest method setup.
@Before
public void setup() throws Exception {
qi4j = new Energy4Java();
Assembler[][][] assemblers = new Assembler[][][] { { // Layer Above
{ new AboveAssembler() } }, { // Layer From
{ // From Module
new FromAssembler() }, { // Beside Module
new BesideAssembler() } }, { // Layer Below
{ new BelowAssembler() } } };
app = qi4j.newApplication(new ApplicationAssemblerAdapter(assemblers) {
});
app.activate();
module = app.findModule("From Layer", "From");
}
use of org.qi4j.bootstrap.Energy4Java in project qi4j-sdk by Qi4j.
the class VisualizeApplicationStructure method main.
public static void main(String[] args) throws Exception {
Energy4Java qi4j = new Energy4Java();
Assembler assembler = new Assembler();
ApplicationDescriptor applicationModel = qi4j.newApplicationModel(assembler);
applicationModel.newInstance(qi4j.spi());
/*
* The Envisage Swing app visualizes the application assemblage structure.
*
* Tree view:
* - Click on elements to expand sub-elements.
* - Scroll to change font size.
* - Right click on viewer to re-size to fit window.
*
* Stacked view:
* - Scroll to zoom in/out of structure levels - might freeze though :-(
*
* Click on any element and see details of that element in the upper right pane.
*
* Pretty cool, eh?
* */
new Envisage().run(applicationModel);
int randomTimeoutMs = 18374140;
Thread.sleep(randomTimeoutMs);
}
use of org.qi4j.bootstrap.Energy4Java in project qi4j-sdk by Qi4j.
the class VisualizeApplicationStructure method main.
public static void main(String[] args) throws Exception {
Energy4Java qi4j = new Energy4Java();
Assembler assembler = new Assembler();
ApplicationDescriptor applicationModel = qi4j.newApplicationModel(assembler);
applicationModel.newInstance(qi4j.spi());
/*
* The Envisage Swing app visualizes the application assemblage structure.
*
* Tree view:
* - Click on elements to expand sub-elements.
* - Scroll to change font size.
* - Right click on viewer to re-size to fit window.
*
* Stacked view:
* - Scroll to zoom in/out of structure levels - might freeze though :-(
*
* Click on any element and see details of that element in the upper right pane.
*
* Pretty cool, eh?
* */
new Envisage().run(applicationModel);
int randomTimeoutMs = 18374140;
Thread.sleep(randomTimeoutMs);
}
use of org.qi4j.bootstrap.Energy4Java in project qi4j-sdk by Qi4j.
the class QuikitServlet method init.
@Override
public void init(ServletConfig config) throws ServletException {
try {
mountPoints = new TreeMap<String, Page>();
documentFactory = DocumentBuilderFactory.newInstance();
documentFactory.setNamespaceAware(true);
ClassLoader cl = getClass().getClassLoader();
SchemaFactory schemaFactory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
Source[] schemaSources = new Source[2];
schemaSources[0] = new StreamSource(cl.getResourceAsStream("xhtml1-strict.xsd"));
schemaSources[1] = new StreamSource(cl.getResourceAsStream("xml.xsd"));
Schema schema = schemaFactory.newSchema(schemaSources);
documentFactory.setSchema(schema);
ApplicationAssembler assembler = createApplicationAssembler(config);
Energy4Java qi4j = new Energy4Java();
application = qi4j.newApplication(assembler);
application.activate();
Module module = application.findModule("WebLayer", "PagesModule");
finder = module;
if (application.mode() == Application.Mode.development) {
DataInitializer initializer = module.newTransient(DataInitializer.class);
initializer.initialize();
}
Iterable<ServiceReference<Page>> iterable = finder.findServices(Page.class);
for (ServiceReference<Page> page : iterable) {
PageMetaInfo pageMetaInfo = page.metaInfo(PageMetaInfo.class);
String mountPoint = pageMetaInfo.mountPoint();
mountPoints.put(mountPoint, page.get());
}
} catch (Exception e) {
throw new ServletException("Can not initialize Qi4j.", e);
}
}
use of org.qi4j.bootstrap.Energy4Java in project qi4j-sdk by Qi4j.
the class Main method main.
public static void main(String[] args) throws Exception {
Energy4Java is = new Energy4Java();
Server server = new Server(Protocol.HTTP, 8888);
Application app = is.newApplication(new ForumAssembler(), new MetadataService());
app.activate();
ContextRestlet restlet = app.findModule("REST", "Restlet").newObject(ContextRestlet.class, new org.restlet.Context());
ChallengeAuthenticator guard = new ChallengeAuthenticator(null, ChallengeScheme.HTTP_BASIC, "testRealm");
MapVerifier mapVerifier = new MapVerifier();
mapVerifier.getLocalSecrets().put("rickard", "secret".toCharArray());
guard.setVerifier(mapVerifier);
guard.setNext(restlet);
server.setNext(restlet);
server.start();
}
Aggregations