Getting Laravel Workbench Package Config Values From Within ServiceProvider Registration - laravel

Within MymoduleServiceProvider->register(),
I want to be able to pull configuration values from the same package.
However whenever I
var_dump($app['config']['file.option']
I get a null value
I know that the file structure is correct because if I do:
Config::get('package::file.option');
from a controller, I get the correct value
How can I load my packages configuration values from within the ServiceProvider->register() method?

$app['config'] is an instance of Config stored in the IOC container.
So try using the get() method directly from the IOC container like so:
$app['config']->get('package::file.option');
as an equivalent to using the facade
\Config::get('package::file.option');

Related

Autowired not working with Azure function

I am quit new in Azure function.
I found it as a interesting topic.right now,I have already develped azure function and works fine.
BUT my story will not end here. In the Function Method, I am trying to Autowiring my Repository class in spring in order to access to my DB layer.
but it gives me a null pointer exception. means that , "#Autowired" annotation is not working and not initiate my HotelController Class.
Any Idea , why I am not able to get the instance in Azure function?
I think you should take a look at:
spring-cloud-function-adapter-azure
This project provides an adapter layer for a Spring Cloud Function application onto Azure. You can write an app with a single #Bean of type Function and it will be deployable in Azure if you get the JAR file laid out right.
There is an AzureSpringBootRequestHandler which you must extend, and provide the input and output types as annotated method parameters (enabling Azure to inspect the class and create JSON bindings). The base class has two useful methods (handleRequest and handleOutput) to which you can delegate the actual function call, so mostly the function will only ever have one line.
And the sample that shows how to use it.
Hope it helps!

Spring bind not working in velocity template

I have added a object to the command in spring bean. I am using that command in y velocity template and trying to bind the new object i created using springFormInput. I am using velocity template. Here is the syntax
#springFormInput("command.newObject.newName", "class=s11")
I do not see that the data i am entering here as text in the form is not getting bind to the command.
Any idea on why this is not working. There are some other fields in form like checkbox and they are binding. Its only this new object that i created in the command does not seem to be working. Pls help.
I have something in the controller class where the controller has objects defined in it that allows binds. So when i specified the objects there under allow binding form, I could see the spring bind is working.

What are the options of using scoped variables in grails?

In my grails service I have a variable that stores some JSON obtained by fetching data from web service. I would like to make that variable unique for every user of the app. I am guessing i would need to move that variable to controller and use session[] to make it happen or is there an alternative?
If you want a separate instance of the variable per user of the application, you could either store it in the session, or make the service session-scoped (they are singletons by default) and store it in the service.
class MyService {
static scope = 'session'
}

How can I change the value for application.properties dynamically?

How can I change the value for application-properties.xml file dynamically through the program in the spring hibernate framework. Actually Iam using config-mysql.xml for connecting database. In that I want to change the database name dynamically at runtime. for example in that file having jdbc:mysql://localhost:3306/usermgmt . now I want to change the usermgmt value at dynamically.Thanks in advance.

How can I access an instance method/property of a Host from Test Bundle Fragment?

I have a bundle test.Bundle1 that have some properties fulfilled by Blueprint injections.
I've created one test fragment whose Host is test.Bundle1 and I would like to obtain myClassA instantiated singleton to access those properties.
I know that I could acess the bundle from a class name using FrameworkUtil.getBundle(), but I don't know how to get the instance of this class.
How could I do that?
thanks
Cristiano
One way to go about this is to simply publish that instance as a service, so you can look it up in code that needs it.

Resources