RHQ - JMX plugin - Update attribute value - jboss7.x

I'm using RHQ JMX plugin to get operations and attributes of one custom Mbean.
It is working but I would like to add the possibility to update an attribute value and I can't use the setter function to update it as it's not recognized as an operation.
How can I update my plugin to add this possibility ?

If you're writing your own plugin, you can declare the bean attribute as a:
measurement, to get history of values
resource configuration property, to easily update the value from RHQ
Declaring an int MBean attribue in resource configuration works as follow:
<resource-configuration>
<c:simple-property name="MyAttributeName" type="integer"/>
</resource-configuration>

Related

Make field insertable but not updatable in Spring Data REST + MongoDB

With Spring Data REST and Spring Data Mongo, I want to make a domain field (field username of domain User in my example) insertable when create but un-updatable when update. In other words an equivalent of JPA #Column(insertable = true, updatable = false).
I try a few approach but not work.
In my github project, domain class and repository are put in /src/main/java/*/*/User.java and UserRepository.java. The test is put in /src/test/java/*/*UserTest.java.
1. Spring Data annotation #ReadOnlyProperty and #Transient
The field is un-insertable when save to DB. See package readonlyproperty and transient_ in the project.
2. Jackson annotation #JsonProperty(access=READ_ONLY)
The field is un-insertable when create via POST request, because the JSON property is ignored when initiate an object. See package jsonpropertyreadonly in the project.
3. #JsonCreator on constructor and #JsonIgnore on setter
If the un-updatable field username is contained in json body of PUT or PATCH request, and username value changes, username get updated, which is unexpected. See package jsoncreator in the project.
4. Do not write a setter
same as 3. See package nosetter in the project.
5. Toggle on/off feature
spring.jackson.deserialization.fail-on-ignored-properties=false
spring.jackson.deserialization.fail-on-unknown-properties=false
spring.jackson.mapper.infer-property-mutators=false
not help
Spring Data REST PUT and PATCH Internal Implementation
PUT: it uses Jackson ObjectMapper.readerFor(Class) to initiate a new object
PATCH: it uses Jackson ObjectMapper.readerForUpdating(objectToUpdate).readValue(json), which use setter to update the objectToUpdate. Seems readerForUpdating doesn't see the #JsonIgnore on setter.
The only solution I know is implementing the setter in below way
void setUsername(String usernameToSet) {
if (null == this.username)
this.username = usernameToSet;
}
And disable PUT method, only use PATCH to update. See package setterchecknull.
Is there a better way? Thank you very much!!

How to sert autoReorg=false

Where can I specify autoReorg=false.
I see that by default autoReorg is set to true.
Attempting to set the property in a properties file or command line results in an error:
Unexpected error running Liquibase: Unknown parameter: 'autoReorg'
I got the above error message using Liquibase 3.5.3 and 3.6.2.
I need to be able to specify autoReorg=false when working with DB2.
Its currently not possible to set this via properties or commandline. You must pass it as a java property.
https://liquibase.jira.com/browse/CORE-3257
Problem It is not possible to turn off automatically generated reorg
statements for DB2 using liquibase properties. This is because in
Main.java, there is no field for the property 'autoReorg', and hence
liquibase throws a CommandLineParsingException in
parsePropertiesFile().
Expected result Reorg statements should not be generated for DB2 when
the liquibase property file contains the property autoReorg=false or
when this property is passed via the command line.
Workaround A workaround is to set the property
-Dliquibase.autoReorg=false as a java property.

How to read values dynamically from a file for a property in updateAttribute?

I added some custom properties in the 'updateAttribute' processor using the '+' button. For example: I declared a property 'DBConnectionURL' and gave the value as 'jdbc:mysql://localhost:3306/test'. Then, in the 'DBCPConnectionPool' service controller, I simple used the value'${DBConnectionURL}' for 'Database Connection URL' property. But, I manually gave the value for 'DBConnectionURL' property.I want a way where I can feed the value dynamically from a file, so that i just need to change the value in the file and the value for 'DBConnectionURL' changes dynamically based on the value present in the file. Is there a way to do it?
Rishab,
You have to use nifi variable registry.
In conf/nifi.properties, you could configure the below configuration in it for dynamically update a value in your data flow.
nifi.variable.registry.properties=./dynamic.properties
You can give your variables in that file dynamic.properties it should present in conf directory.
For an example, If dynamic.properties files contains below values
DBCPURL= jdbc://<host>:<port>
you can use that in your data flow by using ${DBCPURL}
Note: You should restart nifi services if you change any configuration in conf/nifi.properties.Otherwise your changes not worked in dataflow.
Feel free to accept it be answer if it worked for you.

Tomee stateless bean pool size setting

According to http://tomee.apache.org/containers-and-resources.html for stateless beans the max poolsize can be set as a property within
<Container id="Foo" type="STATELESS">
</Container>
I need to know how ID attribute is related to the server instance. Can I use any name instead of "Foo"? If not, where do I declare Foo?
Id is really the name of the container. You can define multiple and bind a container to an EJB through openejb-jar.xml if desired but if there is only one it is the global container for all EJB.
Value is not important.

How to read properties from .properties file in Mule

I'm trying to use Mule Credentials Vault security feature.
I've created .properties file, Security Property Placeholder and defined the key and encryption algorithm.
Now I want to use some of the properties from the file when I return HTTP response.
I have the file src/main/resources/data.properties that contains for example:
In my canvas, under Configuration XML I added:
<secure-property-placeholder:config name="Secure_Property_Placeholder" key="24681357" location="data.properties" doc:name="Secure Property Placeholder" encryptionAlgorithm="DES"/>
<set-variable variableName="card.number" value="${number}" />
In my canvas I have message flow that builds xml 'Create XML response based on User'. The value in settings is:
This doesn't work. The error I get is:
-> org.mule.module.launcher.DeploymentInitException: IllegalArgumentException: Could not resolve placeholder 'key' in string value "${key}"
-> Caused by: org.mule.api.lifecycle.InitialisationException: Invalid bean definition with name 'org.mule.autogen.bean.13' defined in null: Could not resolve placeholder 'key' in string value "${key}"; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'key' in string value "${key}"
-> Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'key' in string value "${key}"
Does anyone know how can I read the properties from .properties file (credentials vault)? And then use it in my flow?
Thanks,
Keren
If you simply want to get the value for the property number and add it into the XML you can use ${number} from .properties. No need to define any other variables in Configuration XML.
<set-payload value="<user><name>Royal Bank of Canada</name><id>Royal_Bank_Of_Canada</id><cc><company>>Visa</company><number>${number}</number><secret>123</secret></cc></user>" doc:name="Set Payload"/>
However note that the property placeholder is resolved at startup so you will not be able to dynamically retrieve a property based on some user input. For this you will have to do some Java coding. This SO post gives you some hints on how this can be achieved. Based on those answers I have created a simple example on how this can be done with a very simple helper bean.
I'm afraid you just can't. The Mule Credentials Vault is an enterprise feature and therefore tipically you won't have access to the source code unless you are a MuleSoft customer.
Even if you were a customer, the api you'd use would be sort of unsupported. I suggest to manually create a custom java component levearing your code and Jasypt (not as a property placeholder but as a library).
The other option, if you are a customer (I guess you are given you are using the credentials vault) is to contact the official support so they take care of it for you.
The property placeholder is used resolve at startup so you will not be able to dynamically retrieve a property based on some user input.
Use ${propertyName} from .properties in MEL to access particular property
From Dataweave you can read it as given below
p('variablename')
where variablename is defined in property files ex: variablename = 15