Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 0BEFB200C6C for ; Fri, 5 May 2017 18:02:28 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 0A8A8160BAF; Fri, 5 May 2017 16:02:28 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 29ACC160B97 for ; Fri, 5 May 2017 18:02:27 +0200 (CEST) Received: (qmail 14611 invoked by uid 500); 5 May 2017 16:02:25 -0000 Mailing-List: contact dev-help@polygene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@polygene.apache.org Delivered-To: mailing list dev@polygene.apache.org Received: (qmail 14599 invoked by uid 99); 5 May 2017 16:02:25 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 May 2017 16:02:25 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id D1CF7C137A for ; Fri, 5 May 2017 16:02:24 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.48 X-Spam-Level: ** X-Spam-Status: No, score=2.48 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.001, HTML_MESSAGE=2, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_SORBS_SPAM=0.5, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd4-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id nUQRXwUjICQb for ; Fri, 5 May 2017 16:02:22 +0000 (UTC) Received: from mail-lf0-f50.google.com (mail-lf0-f50.google.com [209.85.215.50]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id 95D2D5F566 for ; Fri, 5 May 2017 16:02:21 +0000 (UTC) Received: by mail-lf0-f50.google.com with SMTP id 99so6002774lfu.1 for ; Fri, 05 May 2017 09:02:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=hPp4DyuEqdowlBRaQizabPPLExuIOdieLYnLzRc1lPU=; b=RgAkrC2NbhG1K9xD7Eg8yq0djRHD8iHNLd/P50lqPLWWGO8OEEDwfyTZ0MFfRSRiul llYQsHygesdf/Iw2EvmJSWYoPFeg5/98hKFGsxT0x5Ke2xK+PLZhctydMvV0vzm4APY5 1LLcnCyYGKVoeD6EPIwxr7OokYgP8y51xcCmRN9HuxCkgy1KrEaiZlVq2x+nVUZtEVXh XRuJnOcx+Fc9d5BxbY7NNE4aSdiXFtStlRHUuIcvd5R7U/v9OMPLQCNOdQog2Fk/KMil W1JpThJpr2EP2+B9C4lYESdqFc+xQtvdeb/snrM73i6xnngkRDJSGZ+IYqLk+ednru46 h23Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=hPp4DyuEqdowlBRaQizabPPLExuIOdieLYnLzRc1lPU=; b=lqJ46UEXpZuo56XfT5ARH659iuGPCsuPBilpZbGt0oJg72XjrgA+Y/M4/w3bBBGf8u htDyhj9I/QN7swbyfc3jKD5UIsYysSvDpzOvuWq4vN2+jYaFEkQqvsxLMUr+T8Opb8kU 4U6kTpnH4rhKFkUlsdq5K8ICbnovbvmEim0VDcvbPExl4pMbyORPLpjD+0PrPuyZHLA5 34cXL3GqPbndKpVstGc6vu+/5YqQpASJHonuv0wQkXVeUPEBLgp3ABNBpONbpc2bnvdg 4tgUomPIJfqEGZ1Y0wniN8UwIRRSaibWn+wKyhrqW+H6ncWhiq2EwX10piIIpmP5Yq9H oegQ== X-Gm-Message-State: AN3rC/7huR9TZaSraRWiCoxqei3BLW6EjOwWsbbWFqhiWQdMPimaAMv+ dYv9DpVt/v2oaoyOq5jrM7fBYFFSNw== X-Received: by 10.25.166.81 with SMTP id p78mr17788651lfe.92.1494000140740; Fri, 05 May 2017 09:02:20 -0700 (PDT) MIME-Version: 1.0 Sender: hedhman@gmail.com Received: by 10.46.20.94 with HTTP; Fri, 5 May 2017 09:02:00 -0700 (PDT) In-Reply-To: <169905597.5961093.1493993653216@mail.yahoo.com> References: <1238123843.2331442.1493806131814.ref@mail.yahoo.com> <1238123843.2331442.1493806131814@mail.yahoo.com> <506421228.5656795.1493983333767@mail.yahoo.com> <702776525.5694784.1493985348734@mail.yahoo.com> <169905597.5961093.1493993653216@mail.yahoo.com> From: Niclas Hedhman Date: Sat, 6 May 2017 00:02:00 +0800 X-Google-Sender-Auth: pUhWPUz0vsx952rTJ66qaygVrE8 Message-ID: Subject: Re: MongoDB Entity Store To: Apostolos Krionidis Cc: "dev@polygene.apache.org" Content-Type: multipart/alternative; boundary=001a11411c3aaeefd8054ec90348 archived-at: Fri, 05 May 2017 16:02:28 -0000 --001a11411c3aaeefd8054ec90348 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I need to look at that tomorrow, especially since this is 2.1 and a fair amount has changed from 2.1 to 3.0 in type management. On Fri, May 5, 2017 at 10:14 PM, Apostolos Krionidis wrote: > Hi, > > I've created a new class: > > public class CustomMongoMapEntityStoreAssembler extends Assemblers.Visibi= lityIdentityConfig > { > @Override > public void assemble(ModuleAssembly module) throws AssemblyException > { > module.services(UuidIdentityGeneratorService.class) > .visibleIn(visibility()); > > ServiceDeclaration service =3D > module.services(MongoMapEntityStoreService.class) > .withConcerns(MongoEntityStoreConfigurationConcern.class) > .visibleIn(visibility()); > > if (hasIdentity()) { > > service.identifiedBy(identity()); > } > if (hasConfig()) { > > configModule().entities(MongoEntityStoreConfiguration.class) > .visibleIn(configVisibility()); > } > } > } > > > and then a concern as you suggest: > > public abstract class MongoEntityStoreConfigurationConcern > extends ConcernOf> > implements Configuration > { > @Override > public MongoEntityStoreConfiguration get() > { > try { > MongoEntityStoreConfiguration conf =3D next.get(); > > List serverAddresses =3D new ArrayList<>(); > > serverAddresses.add(new ServerAddress("1.1.1.5", 27017)); > serverAddresses.add(new ServerAddress("1.1.1.6", 27017)); > serverAddresses.add(new ServerAddress("1.1.1.7", 27017)); > > conf.nodes() > .set(serverAddresses); > > return conf; > } > catch (UnknownHostException err) { > throw new RuntimeException(err); > } > } > } > > and I called it as: > > new > CustomMongoMapEntityStoreAssembler().withConfig(configModule, Visibili= ty.application) > .visibleIn(Visibility.application= ) > .identifiedBy("mongodb.booking.st= ore") > .assemble(module); > > > But then I get back the following error: > > > org.qi4j.bootstrap.AssemblyException: Unable to create Application Model. > at org.qi4j.bootstrap.Energy4Java.newApplicationModel(Energy4Java.java:7= 6) > at org.qi4j.bootstrap.Energy4Java.newApplication(Energy4Java.java:83) > at com.projectbeagle.gateway.kernel.scope.wiring.ApplicationPool.fillUp(= ApplicationPool.java:74) > ... 47 more > Caused by: org.qi4j.api.common.InvalidApplicationException: Could not reg= ister [interface org.qi4j.entitystore.mongodb.MongoMapEntityStoreService] > at org.qi4j.runtime.bootstrap.ServiceAssemblyImpl.newServiceModel(Servic= eAssemblyImpl.java:74) > at org.qi4j.runtime.bootstrap.ModuleAssemblyImpl.assembleModule(ModuleAs= semblyImpl.java:544) > at org.qi4j.runtime.bootstrap.ApplicationModelFactoryImpl.newApplication= Model(ApplicationModelFactoryImpl.java:86) > at org.qi4j.bootstrap.Energy4Java.newApplicationModel(Energy4Java.java:7= 2) > ... 49 more > Caused by: java.lang.ClassCastException: sun.reflect.generics.reflectiveO= bjects.ParameterizedTypeImpl cannot be cast to java.lang.Class > at org.qi4j.runtime.injection.DependencyModel.extractRawInjectionClass(D= ependencyModel.java:132) > at org.qi4j.runtime.injection.DependencyModel.extractRawInjectionClass(D= ependencyModel.java:119) > at org.qi4j.runtime.injection.DependencyModel.(DependencyModel.jav= a:96) > at org.qi4j.runtime.injection.InjectedFieldsModel.addModel(InjectedField= sModel.java:81) > at org.qi4j.runtime.injection.InjectedFieldsModel.(InjectedFieldsM= odel.java:56) > at org.qi4j.runtime.composite.AbstractModifierModel.(AbstractModif= ierModel.java:57) > at org.qi4j.runtime.composite.ConcernModel.(ConcernModel.java:27) > at org.qi4j.runtime.bootstrap.AssemblyHelper.getConcernModel(AssemblyHel= per.java:52) > at org.qi4j.runtime.bootstrap.CompositeAssemblyImpl.concernsFor(Composit= eAssemblyImpl.java:591) > at org.qi4j.runtime.bootstrap.CompositeAssemblyImpl.implementMixinType(C= ompositeAssemblyImpl.java:215) > at org.qi4j.runtime.bootstrap.CompositeAssemblyImpl.buildComposite(Compo= siteAssemblyImpl.java:181) > at org.qi4j.runtime.bootstrap.ServiceAssemblyImpl.newServiceModel(Servic= eAssemblyImpl.java:64) > ... 52 more > > > > =CE=A3=CF=84=CE=B9=CF=82 3:29 =CE=BC.=CE=BC. =CE=A0=CE=B1=CF=81=CE=B1=CF= =83=CE=BA=CE=B5=CF=85=CE=AE, 5 =CE=9C=CE=B1=CE=90=CE=BF=CF=85 2017, =CE=BF/= =CE=B7 Niclas Hedhman < > niclas@hedhman.org> =CE=AD=CE=B3=CF=81=CE=B1=CF=88=CE=B5: > > > Yes, the registration of values(ServerAddress.class) should not be there. > That was an oversight on my behalf. > > A few things that could be a work-around. > > 1. Create a Concern that intercepts the configuration and populates the > nodes. You add the Concern in your own Assembler (copy source from > MongoDbEntityStoreAssembler), so instead of; > > ServiceDeclaration service =3D module > .services( MongoMapEntityStoreService.class ) > .visibleIn( visibility() ); > > add the Concern as; > > ServiceDeclaration service =3D module > .services( MongoMapEntityStoreService.class ) > .withConcerns( MyConfigurationConcern.class ) > .visibleIn( visibility() ); > > > Then your MyConfigurationConcern would be something like; > > public abstract class MyConfigurationConcern extends > ConcernOf> > implements Configuration > { > @Override > public MongoEntityStoreConfiguration get() > { > MongoEntityStoreConfiguration conf =3D next.get(); > conf.nodes().set( MY_NODES ); > return conf; > } > } > > > 2. Maybe you want your own Configuration store. Create (or use) an Entity > Store that does not require any Polygene Configuration, and drop that int= o > the Configuration Module. Perhaps read configuration from "Java > Preferences", maybe a configured Zookeeper cluster or maybe ETCD. And if > the configuration entity store is populated, then there will be no fallba= ck > to properties/yaml files. > This is of course a fairly advanced option, but I would recommend it for > production setup. > > > But I am sure Paul will say; "Just ..." :-) > > Cheers > Niclas > > On Fri, May 5, 2017 at 7:55 PM, Apostolos Krionidis > wrote: > > > Yes you are right ServerAddress is a Immutable POJO but here the proble= m > > seems to by before > > json serialization, in ValueComposite registration. > > > > Is there any other way to set prices in the nodes() property after the > > .property file loading? > > > > > > > > > > =CE=A3=CF=84=CE=B9=CF=82 2:44 =CE=BC.=CE=BC. =CE=A0=CE=B1=CF=81=CE=B1= =CF=83=CE=BA=CE=B5=CF=85=CE=AE, 5 =CE=9C=CE=B1=CE=90=CE=BF=CF=85 2017, =CE= =BF/=CE=B7 Niclas Hedhman < > > niclas@hedhman.org> =CE=AD=CE=B3=CF=81=CE=B1=CF=88=CE=B5: > > > > > > Of course... ServerAddress is a pojo, and it doesn't have a POJO > > compatible format for Jackson et al. > > > > Paul, how was this supposed to work? > > > > Cheers > > > > > > -- > > Niclas Hedhman, Software Developer > > http://polygene.apache.org - New Energy for Java > > > > > > > > > > -- > Niclas Hedhman, Software Developer > http://polygene.apache.org - New Energy for Java > > > --=20 Niclas Hedhman, Software Developer http://polygene.apache.org - New Energy for Java --001a11411c3aaeefd8054ec90348--