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;
}
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());
});
}
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);
}
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);
}
Aggregations