Search in sources :

Example 1 with RemoteLookup

use of eu.ggnet.saft.core.cap.RemoteLookup in project dwoss by gg-net.

the class WildflyLookup method init.

private synchronized void init() {
    if (initialized)
        return;
    Properties p = new Properties();
    p.put("endpoint.name", "client-endpoint");
    p.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "false");
    p.put("remote.connections", "one");
    p.put("remote.connection.one.port", Integer.toString(CONFIG.getPort()));
    p.put("remote.connection.one.host", CONFIG.getHost());
    p.put("remote.connection.one.username", CONFIG.getUsername());
    p.put("remote.connection.one.password", CONFIG.getPassword());
    EJBClientConfiguration cc = new PropertiesBasedEJBClientConfiguration(p);
    ContextSelector<EJBClientContext> selector = new ConfigBasedEJBClientContextSelector(cc);
    EJBClientContext.setSelector(selector);
    final String APP = CONFIG.getApp();
    Object instance = null;
    String discoveryName = "ejb:/" + APP + "//" + Discovery.NAME;
    try {
        instance = context().lookup(discoveryName);
    } catch (NamingException ex) {
        throw new RuntimeException("Error on frist lookup", ex);
    }
    L.debug("Lookup of {} sucessfull", discoveryName);
    Discovery discovery = (Discovery) instance;
    List<String> names = discovery.allJndiNames("java:app/" + APP);
    L.debug("Discovery returned {} raw entries", names.size());
    namesAndLookup = names.stream().filter(n -> n.contains("!")).map(n -> new KeyEquals(n.split("!")[1], "ejb:/" + APP + "//" + n)).distinct().collect(Collectors.toMap(KeyEquals::getKey, KeyEquals::getValue));
    if (L.isDebugEnabled())
        namesAndLookup.forEach((k, v) -> L.debug("Lookup cache key={}, value={}", k, v));
    // namesAndLookup = new HashMap<>();
    // for (String name : names) {
    // if ( !name.contains("!") ) continue;
    // String key = name.split("!")[1];
    // // INFO: There is no solution for ?statefull yet.
    // String value = "ejb:/" + APP + "//" + name;
    // L.debug("Storing lookup key={}, value={}", key, value);
    // namesAndLookup.put(key, value);
    // }
    L.debug("RemoteLookup initilaized");
    initialized = true;
}
Also used : java.util(java.util) Logger(org.slf4j.Logger) Discovery(eu.ggnet.dwoss.discover.Discovery) LoggerFactory(org.slf4j.LoggerFactory) javax.naming(javax.naming) RemoteLookup(eu.ggnet.saft.core.cap.RemoteLookup) Collectors(java.util.stream.Collectors) lombok(lombok) ConfigBasedEJBClientContextSelector(org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector) IsStateful(eu.ggnet.dwoss.common.api.IsStateful) org.jboss.ejb.client(org.jboss.ejb.client) Objects.requireNonNull(java.util.Objects.requireNonNull) EjbConnectionConfiguration(eu.ggnet.dwoss.util.EjbConnectionConfiguration) ConfigBasedEJBClientContextSelector(org.jboss.ejb.client.remoting.ConfigBasedEJBClientContextSelector) Discovery(eu.ggnet.dwoss.discover.Discovery)

Example 2 with RemoteLookup

use of eu.ggnet.saft.core.cap.RemoteLookup in project dwoss by gg-net.

the class RedTapeTryout method main.

public static void main(String[] args) {
    Dl.local().add(RemoteLookup.class, new RemoteLookup() {

        @Override
        public <T> boolean contains(Class<T> clazz) {
            return false;
        }

        @Override
        public <T> T lookup(Class<T> clazz) {
            return null;
        }
    });
    Dl.remote().add(RedTapeAgent.class, new RedTapeAgentStub());
    Dl.remote().add(RedTapeWorker.class, new RedTapeWorkerStub());
    Dl.remote().add(UniversalSearcher.class, new UniversalSearcherStub());
    Dl.remote().add(CustomerService.class, new CustomerServiceStub());
    Dl.remote().add(DocumentSupporter.class, new DocumentSupporter() {

        @Override
        public void mail(Document document, DocumentViewType jtype) throws UserInfoException, RuntimeException {
            System.out.println("Mailing " + document);
        }

        @Override
        public JasperPrint render(Document document, DocumentViewType viewType) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public Dossier briefed(Document detached, String arranger) {
            detached.add(Document.Flag.CUSTOMER_BRIEFED);
            detached.add(Document.Flag.CUSTOMER_EXACTLY_BRIEFED);
            return detached.getDossier();
        }

        @Override
        public FileJacket toXls(String identifier) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }
    });
    Dl.local().add(Guardian.class, new AbstractGuardian() {

        @Override
        public void login(String user, char[] pass) throws AuthenticationException {
            setRights(new Operator(user, 1, Arrays.asList(AtomicRight.values())));
        }
    });
    Dl.remote().add(StockAgent.class, null);
    Dl.remote().add(UniqueUnitAgent.class, null);
    // Dl.remote().add(LegacyRemoteBridge.class, null);
    Dl.remote().add(ShippingCostService.class, null);
    Mandators mandatorSupporterMock = mock(Mandators.class);
    when(mandatorSupporterMock.loadSalesdata()).thenReturn(new DefaultCustomerSalesdata(ShippingCondition.DEFAULT, PaymentCondition.CUSTOMER, PaymentMethod.DIRECT_DEBIT, Arrays.asList(SalesChannel.CUSTOMER, SalesChannel.RETAILER), null));
    Dl.remote().add(Mandators.class, mandatorSupporterMock);
    CustomerUpi ccos = mock(CustomerUpi.class);
    when(ccos.createCustomer(any())).thenReturn(0L);
    when(ccos.updateCustomer(any(), anyLong())).thenReturn(true);
    Dl.local().add(CustomerUpi.class, ccos);
    UiCore.startSwing(() -> new JLabel("Main Applikation"));
    Ui.exec(() -> {
        Ui.build().swing().show(() -> RedTapeController.build().getView());
    });
}
Also used : Operator(eu.ggnet.dwoss.rights.api.Operator) DocumentViewType(eu.ggnet.dwoss.mandator.api.DocumentViewType) AuthenticationException(eu.ggnet.saft.core.auth.AuthenticationException) Document(eu.ggnet.dwoss.redtape.ee.entity.Document) FileJacket(eu.ggnet.dwoss.util.FileJacket) CustomerUpi(eu.ggnet.dwoss.customer.upi.CustomerUpi) JasperPrint(net.sf.jasperreports.engine.JasperPrint) JLabel(javax.swing.JLabel) DefaultCustomerSalesdata(eu.ggnet.dwoss.mandator.api.value.DefaultCustomerSalesdata) AbstractGuardian(eu.ggnet.dwoss.common.AbstractGuardian) RemoteLookup(eu.ggnet.saft.core.cap.RemoteLookup) Mandators(eu.ggnet.dwoss.mandator.Mandators) Dossier(eu.ggnet.dwoss.redtape.ee.entity.Dossier) UserInfoException(eu.ggnet.dwoss.util.UserInfoException)

Example 3 with RemoteLookup

use of eu.ggnet.saft.core.cap.RemoteLookup in project dwoss by gg-net.

the class ReportViewTryout method main.

public static void main(String[] args) {
    Dl.local().add(RemoteLookup.class, new RemoteLookup() {

        @Override
        public <T> boolean contains(Class<T> clazz) {
            return false;
        }

        @Override
        public <T> T lookup(Class<T> clazz) {
            return null;
        }
    });
    TradeName tradeName = TradeName.FUJITSU;
    UiCore.startSwing(() -> new JLabel("Main Applikation"));
    EnumMap<ViewReportResult.Type, NavigableSet<ReportLine>> lines = new EnumMap<>(ViewReportResult.Type.class);
    ReportLineGenerator op = new ReportLineGenerator();
    NavigableSet<ReportLine> invoicedLines = new TreeSet<>();
    NavigableSet<ReportLine> repayedLinesLines = new TreeSet<>();
    for (int i = 0; i < 30; i++) {
        invoicedLines.add(op.makeReportLine(Arrays.asList(tradeName), new Date(), i));
        repayedLinesLines.add(op.makeReportLine(Arrays.asList(tradeName), new Date(), i));
    }
    lines.put(INVOICED, invoicedLines);
    lines.put(REPAYMENTS, repayedLinesLines);
    ViewReportResult result = new ViewReportResult(lines, ReportParameter.builder().reportName("JUnit " + tradeName + " Report").contractor(tradeName).start(new Date()).end(new Date()).build());
    Ui.build().fxml().show(() -> new ReportController.In(result, false), ReportController.class);
}
Also used : TradeName(eu.ggnet.dwoss.rules.TradeName) ReportLine(eu.ggnet.dwoss.report.ee.entity.ReportLine) JLabel(javax.swing.JLabel) RemoteLookup(eu.ggnet.saft.core.cap.RemoteLookup) ViewReportResult(eu.ggnet.dwoss.report.ee.ReportAgent.ViewReportResult) ReportController(eu.ggnet.dwoss.report.ui.main.ReportController) ReportLineGenerator(eu.ggnet.dwoss.report.ee.assist.gen.ReportLineGenerator)

Example 4 with RemoteLookup

use of eu.ggnet.saft.core.cap.RemoteLookup in project dwoss by gg-net.

the class ServiceViewCaskTryout method main.

public static void main(String[] args) {
    Dl.local().add(RemoteLookup.class, new RemoteLookup() {

        @Override
        public <T> boolean contains(Class<T> clazz) {
            return false;
        }

        @Override
        public <T> T lookup(Class<T> clazz) {
            return null;
        }
    });
    UiCore.startSwing(() -> new JLabel("Main Applikation"));
    // () -> Position.builder().type(PositionType.SERVICE).price(30.).build()
    Ui.build().swing().eval(() -> OkCancelWrap.consumerVetoResult(new ServiceViewCask(GENERAL_SALES_TAX_DE_SINCE_2007))).opt().ifPresent(System.out::println);
}
Also used : RemoteLookup(eu.ggnet.saft.core.cap.RemoteLookup) JLabel(javax.swing.JLabel) ServiceViewCask(eu.ggnet.dwoss.redtapext.ui.cao.document.position.ServiceViewCask)

Aggregations

RemoteLookup (eu.ggnet.saft.core.cap.RemoteLookup)4 JLabel (javax.swing.JLabel)3 AbstractGuardian (eu.ggnet.dwoss.common.AbstractGuardian)1 IsStateful (eu.ggnet.dwoss.common.api.IsStateful)1 CustomerUpi (eu.ggnet.dwoss.customer.upi.CustomerUpi)1 Discovery (eu.ggnet.dwoss.discover.Discovery)1 Mandators (eu.ggnet.dwoss.mandator.Mandators)1 DocumentViewType (eu.ggnet.dwoss.mandator.api.DocumentViewType)1 DefaultCustomerSalesdata (eu.ggnet.dwoss.mandator.api.value.DefaultCustomerSalesdata)1 Document (eu.ggnet.dwoss.redtape.ee.entity.Document)1 Dossier (eu.ggnet.dwoss.redtape.ee.entity.Dossier)1 ServiceViewCask (eu.ggnet.dwoss.redtapext.ui.cao.document.position.ServiceViewCask)1 ViewReportResult (eu.ggnet.dwoss.report.ee.ReportAgent.ViewReportResult)1 ReportLineGenerator (eu.ggnet.dwoss.report.ee.assist.gen.ReportLineGenerator)1 ReportLine (eu.ggnet.dwoss.report.ee.entity.ReportLine)1 ReportController (eu.ggnet.dwoss.report.ui.main.ReportController)1 Operator (eu.ggnet.dwoss.rights.api.Operator)1 TradeName (eu.ggnet.dwoss.rules.TradeName)1 EjbConnectionConfiguration (eu.ggnet.dwoss.util.EjbConnectionConfiguration)1 FileJacket (eu.ggnet.dwoss.util.FileJacket)1