package br.com.test; import java.util.Properties; import javax.naming.Context; import javax.naming.InitialContext; import org.jboss.deployers.spi.management.ManagementView; import org.jboss.managed.api.ComponentType; import org.jboss.managed.api.ManagedComponent; import org.jboss.managed.api.ManagedProperty; import org.jboss.metatype.api.values.MetaValueFactory; import org.jboss.profileservice.spi.ProfileService; public class SimpleUpdate { private static final String COMPONENT_NAME = "RuntimeEngineDeployer"; private final static String TYPE = "teiid"; private final static String SUBTYPE = "dqp"; private final static String PROP_NAME = "resultSetCacheMaxEntryAge"; private final static Integer PROP_VALUE = 99999; private final static ComponentType COMPONENT_TYPE = new ComponentType(TYPE, SUBTYPE); public static void main(String[] args) { try { ProfileService ps = (ProfileService) getContext().lookup("java:ProfileService"); ManagementView mView = ps.getViewManager(); ManagedComponent mComp = mView.getComponent(COMPONENT_NAME, COMPONENT_TYPE); if(mComp == null){ System.out.println("comp null exiting"); System.exit(0); } for(String name : mComp.getPropertyNames()){ System.out.println("property name: " + name); if(PROP_NAME.equals(name)){ ManagedProperty prop = mComp.getProperty(name); System.out.println("property found for change: " + prop); System.out.println("property value: " + prop.getValue()); System.out.println("changing value to: " + PROP_VALUE); prop.setValue(MetaValueFactory.getInstance().create(PROP_VALUE)); System.out.println("updating component..."); mView.updateComponent(mComp); //FIX for Availability // System.out.println("load: " + mView.load()); } } System.out.println("done"); System.exit(0); } catch (Throwable t) { t.printStackTrace(); } } private static Context getContext() throws Exception { Properties p = new Properties(); p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); p.put(Context.URL_PKG_PREFIXES, "jboss.naming:org.jnp.interfaces"); p.put(Context.PROVIDER_URL, "localhost:1099"); return new InitialContext(p); } }