Reading JNDI properties from Glassfish JavaBeanFactory in Logback - glassfish-3

We use logback and slf4j as logging libraries for our application and glassfish v3 as our application server. For the deployment time configuration properties we have created a "JNDI Custom Resource" in glassfish with the factory class as "org.glassfish.resources.custom.factory.JavaBeanFactory".
Specifying this factory class, glassfish creates an instance of the specified custom java bean (termed as resource type in glassfish) and set the user specified properties in this class instance.
My question is - Is there a way to use one of the properties specified for this java bean in logback? i.e. Is there a way to tell logback (in the tag) to read properties from a java bean?
I intend to add a property in the java bean as the "log location" which I can then use in my logback.xml. This property can be set by the application installer team to configure the location of the log files.
Also since we already have one Custom JNDI resource defined in glassfish we intend to use the same one for all the configuration properties for our application.

If you use the SiftAppender, you can configure a discriminator as JNDIBasedDiscriminator and use JNDI resource value to specify the source of the log file.
However it should be too time consuming.
Related info may be found in:
http://logback.qos.ch/manual/loggingSeparation.html

Related

Configure multiple content stores in Alfresco?

I followed the step given in below link to configure multiple content stores in Alfresco 5.0.d.
http://docs.alfresco.com/5.0/concepts/store-config-fullexample.html
Alfresco instance is not able to start and gives the exeption,
Cannot resolve reference to bean 'storeSelectorContentStore' while setting bean property 'store';
nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'storeSelectorContentStore' defined in file [/opt/alfresco-5.0.d/tomcat/shared/classes/alfresco/extension/content-store-selector-context.xml]:
I also tried the method stated in below link,
https://community.alfresco.com/docs/DOC-5156-content-store-configuration
This gives a different error, alfresco dir root not defined even though it's defined in the properties file.
This is an enterprise only feature. This is why you are getting this error on Community.
Marcus is right about this being an Enterprise only feature, but you could develop your own. It shouldn't be too much of a hassle.
Also, have you tried using this extension, I suspect it has everything you need and is maintained by a well know Alfresco contributor?
https://github.com/Acosix/alfresco-simple-content-stores

When use Extension class, when use Compiler Passes in Symfony?

What is the point of using compiler passes in Symfony?
When we should use Extension class and when Compiler Passes in Symfony?
They come with services definition.
By creating a compiler pass, you are able to update the arguments passed to services.
It's most often done with tagged services.
Also, It can be used for :
Creating new services that require information about other defined services before being defined.
Swapping or adding arguments to a service that you did not write.
Creating and modifying parameters in the container.
I used a compiler pass to register a Factory that make me able to override the doctrine Repository.
You can see the code for more comprehension of how it works:
https://gist.github.com/chalasr/77be8eee5e3ecd3c06ec
Update
Thank's to #Sruj, I added the part I've forgotten about the Extension
Extension are part of dependency injection too, especially of the configuration.
Its primary role is to load the configuration of services across the bundles of your application.
Instead of load your configuration manually by using imports, you can create an extension that does it for you. All your services configuration are registered from your bundle and shared in your whole application.
When you register a vendor in your app configuration, the service container extension of the vendor is invoked.
See "Importing configuration via container extensions" part of the documentation

A welcome message, that is pulled from a servlet that is configurable from the OSGi console

I am new to CQ5. I created a bundle that is configurable via the OSGi console. Now, I need the value that is configured on the console to be returned to my content page. I am not sure how to proceed with this. Looking for any tutorial or help. Thanks in advance.
Assuming the configured value is available via an OSGi service, you can access that service from java code using an #Reference SCR annotation with a suitable build setup to generate the corresponding OSGi metadata. You can also access OSGi services from scripts, in JSP that's done using sling.getService(YourService.class) in a script where you have called or its CQ equivalent.

injected resources from ejb-jar disappeared after changing websphere 7 classloader

I'm configuring an ejb module on websphere 7 and I need to set my classloader to PARENT_LAST to make sure I don't get any classloader issues with wrong version of classes.
The odd thing is, my ejb #Resource annotation does not inject my resources anymore (which are defined in ejb-jar.xml) when I change my classloader to PARENT_LAST. All my fields annotated with #Resource are null.
I suspect your application contains a JAR that contains the javax.annotation.Resource class. The PARENT_LAST setting is causing the class loader to prefer your Resource class over the one in the JDK, which means the WebSphere Application Server injection engine never sees your Resource annotation. You should remove that JAR from your application.
If you want to verify, try adding the following logic to your application before the NPE occurs:
System.out.println(Resource.class.getProtectionDomain().getCodeSource().getLocation());
...or enable the -verbose:class (Verbose JVM class loading) option in your server JVM.

Make visual studio understand the return type of a web service is the same as an existing type

I've been googling for ages now, but cannot find an answer to the problem I'm facing. Here's the situation:
I have a .Net web service (not a wcf service, but an old fashioned web service), that has a web method in it returning, say, an object of type X.
Now when i create a service reference to this web service from a different .Net project, visual studio will generate a proxy class (in the reference.vb), and the return type of the web method in this class is that proxy class (say, type Y) instead of type X.
The thing is, type X is a type that is declared in an external reference that exists in both ends of the web method. Is there ANY way (the service itself should stay a web service, but I don't care if the reference is a "service reference" or a "web reference") i can make visual studio understand that there is no need to create a proxy class and it can use the existing type for the return type of the method?
I know that service references can automatically map types (you can set these settings when creating the service reference). However, this only seems to work when creating a service reference to a wcf service, not to a normal .net web service
Update:
It seems i need to somehow make visual studio match the namespaces of the types. John Saunders hinted me to the xmltype attribute i can use to specify the full namespace of the type. I will try if this works.
I also thought about how visual studio matches the classes. It seems there is no info about namespaces in the wsdl of the web service anywhere (assuming studio uses the wsdl as input for generating the reference) so how can studio match the types?
Update2:
I've tried to use the xmltype to map the namespace. I wasn't sure what namespace to use (the uri kind of the actual ClrNamespace) so i tried both. Using the uri namespace I was able to create a namespace mapping in the svcmap, but this caused the code in the reference.vb file to be generated inside an extra namespace instead of making VS want to map the type. Any new idea's? Can this really be this hard?
It simply doesn't seem possible to do this. The short answer: use a wcf service reference and create a shared library with the types used in the service and reference them in both the service and the application with the reference

Resources