Search in sources :

Example 11 with Energy4Java

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");
}
Also used : Energy4Java(org.qi4j.bootstrap.Energy4Java) Assembler(org.qi4j.bootstrap.Assembler) EntityTestAssembler(org.qi4j.test.EntityTestAssembler) ApplicationAssemblerAdapter(org.qi4j.bootstrap.ApplicationAssemblerAdapter) Before(org.junit.Before)

Example 12 with Energy4Java

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);
}
Also used : Energy4Java(org.qi4j.bootstrap.Energy4Java) Assembler(org.qi4j.sample.dcicargo.sample_a.bootstrap.assembly.Assembler) ApplicationDescriptor(org.qi4j.api.structure.ApplicationDescriptor) Envisage(org.qi4j.envisage.Envisage)

Example 13 with Energy4Java

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);
}
Also used : Energy4Java(org.qi4j.bootstrap.Energy4Java) Assembler(org.qi4j.sample.dcicargo.sample_b.bootstrap.assembly.Assembler) ApplicationDescriptor(org.qi4j.api.structure.ApplicationDescriptor) Envisage(org.qi4j.envisage.Envisage)

Example 14 with Energy4Java

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);
    }
}
Also used : SchemaFactory(javax.xml.validation.SchemaFactory) StreamSource(javax.xml.transform.stream.StreamSource) Schema(javax.xml.validation.Schema) DOMSource(javax.xml.transform.dom.DOMSource) StreamSource(javax.xml.transform.stream.StreamSource) Source(javax.xml.transform.Source) TransformerException(javax.xml.transform.TransformerException) ServletException(javax.servlet.ServletException) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) SAXException(org.xml.sax.SAXException) ServiceReference(org.qi4j.api.service.ServiceReference) ServletException(javax.servlet.ServletException) ApplicationAssembler(org.qi4j.bootstrap.ApplicationAssembler) Energy4Java(org.qi4j.bootstrap.Energy4Java) Module(org.qi4j.api.structure.Module)

Example 15 with Energy4Java

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();
}
Also used : ContextRestlet(org.qi4j.library.rest.server.api.ContextRestlet) Server(org.restlet.Server) ForumAssembler(org.qi4j.samples.forum.assembler.ForumAssembler) Energy4Java(org.qi4j.bootstrap.Energy4Java) ChallengeAuthenticator(org.restlet.security.ChallengeAuthenticator) MapVerifier(org.restlet.security.MapVerifier) Application(org.qi4j.api.structure.Application) MetadataService(org.restlet.service.MetadataService)

Aggregations

Energy4Java (org.qi4j.bootstrap.Energy4Java)39 Assembler (org.qi4j.bootstrap.Assembler)19 Application (org.qi4j.api.structure.Application)18 ApplicationAssemblerAdapter (org.qi4j.bootstrap.ApplicationAssemblerAdapter)17 Test (org.junit.Test)15 ModuleAssembly (org.qi4j.bootstrap.ModuleAssembly)12 ApplicationAssembler (org.qi4j.bootstrap.ApplicationAssembler)11 ApplicationDescriptor (org.qi4j.api.structure.ApplicationDescriptor)8 AssemblyException (org.qi4j.bootstrap.AssemblyException)8 Before (org.junit.Before)7 ApplicationAssembly (org.qi4j.bootstrap.ApplicationAssembly)7 ApplicationAssemblyFactory (org.qi4j.bootstrap.ApplicationAssemblyFactory)7 Module (org.qi4j.api.structure.Module)6 EntityTestAssembler (org.qi4j.test.EntityTestAssembler)6 LayerAssembly (org.qi4j.bootstrap.LayerAssembly)4 UnitOfWork (org.qi4j.api.unitofwork.UnitOfWork)3 Envisage (org.qi4j.envisage.Envisage)3 UnitOfWorkCompletionException (org.qi4j.api.unitofwork.UnitOfWorkCompletionException)2 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1