[
https://issues.jboss.org/browse/TEIIDDES-1459?page=com.atlassian.jira.plu...
]
Barry LaFond commented on TEIIDDES-1459:
----------------------------------------
You'll probably really want to investigate using JBossTools if you want some
ready-made APIs to really help send management commands. Also, discovering the management
port will require you either parsing xml yourself or accessing some string constants in
our server.
Let's start with host. All IServer objects in WTP can get the host simply by
server.getHost(), so that's easy.
For getting the management port, there are a few ways to do it. The first is with raw xml,
searching the proper file. The xpath you'll need and file data is:
as7.0 xpath:
//*[local-name()="management-interfaces"]/*[local-name()="native-interface"]
as7.1 xpath:
//*[local-name()="socket-binding-group"]/*[local-name()="socket-binding"][@name="management-native"]
xpath attribute: port
file to search: standalone/configuration/${jboss_config_file} (probably
standalone.xml)
Obviously here the xpaths differ based on jboss version. AS7.0 has one xpath. AS7.1 has a
different. However, none of these allow the 'overrides' available in the UI. In
the JBossTools UI, you can double-click the server to see the editor. There's a port
section there, and there's the opportunity to ignore the xml value and override it via
UI. So if the default xpath has 9999 but somehow you're using more complicated
features in the standalone.xml such that the actual value is 9998, you'll need to
override this in the UI.
So how to get this value that respects the user's UI choices? Well, two ways. One is
by using hard-coded strings (if you want to avoid dependency on jbosstools). The code for
that would look like this:
{code}
public static final String AS7_MANAGEMENT_PORT_DETECT=
"org.jboss.ide.eclipse.as.core.server.as7.managementPortAutoDetect";
//$NON-NLS-1$
public static final String AS7_MANAGEMENT_PORT =
"org.jboss.ide.eclipse.as.core.server.as7.managementPort"; //$NON-NLS-1$
boolean detect = getAttribute(detectKey, true);
String result = null;
if( !detect ) {
result = getAttribute(attributeKey, (String)null);
} else {
// Load it from the xml xpaths listed above
}
{code}
This is if you're trying to avoid any dependencies on jbosstools of course. If you
don't mind having dependencies on jbosstools, the best way to get this port is as
follows:
{code}
JBoss7Server jb7 = server.loadAdapter(JBoss7Server.class, null);
if( jb7 != null ) {
return jb7.getManagementPort();
}
{code}
So what other benefits can JBT provide other than just helping to find the port? Well, we
can also run your remote commands for you. JBoss7 servers have a remote management service
registered in eclipse, which can run your remote commands and return the results.
The first is our management service. The service interface is IJBoss7ManagerService. You
can see a lot of methods there for deploying or stopping a server. But there's also a
method to run arbitrary commands: public String execute(IAS7ManagementDetails details,
String request) throws Exception;
The way to access this service is via the following command:
JBoss7ManagerUtil.getService(iserverObject);
This API ensures that if for example the protocol changes slightly (either intentionally
or as a bug) between as7.1 and as7.2 / as8.0, the proper service is returned for the
proper AS version. Using these APIs ensure that all the management jars are of the proper
version, talking to the proper remote version. It's possible to do all of this on your
own, but I'm pretty sure you'll find it a LOT more trouble and you'll simply
be replicating our work.
And worse yet, how you intend to get the jboss-as jars on the classpath is a point of
interest. We currently will be bundling the management jars for each version (or more
specifically for any set of jars that cannot talk to each other. We also work hard to
ensure that regressions upstream (ie a new version unable to talk to older ones) is fixed
promptly). If you intend to bundle these jars, it'll be inflating the size of your
product substantially. And you'll most likely be re-engineering our solution for
separation of version jars.
So we've already discussed how to get the port via xml, and how to get a port that
respects user settings. We've discussed how to get the management service regardless
of app-server version. From there, running the default commands is simple. For example:
{code}
JBoss7ManagerUtil.getService(iserverObject).stop(new
AS7ManagementDetails(iserverObject));
{code}
So the last thing that remains is how to run an arbitrary command. Due to classpath and
classloading concerns, we can't have the management service api and interfaces include
references to jboss-as jars or classes like ModelNode, so the method for executing
arbitrary commands is:
{code}
JBoss7ManagerUtil.getService(iserverObject).execute(IAS7ManagementDetails details, String
request) throws Exception;
{code}
The "String request" is a JBoss-dmr string. And to generate that string, we have
yet another plugin called org.jboss.ide.eclipse.as.dmr. By depending on this plugin you
can write code as follows:
{code}
ModelNode request = new ModelNode();
request.get(OP).set(READ_CHILDREN_NAMES_OPERATION);
request.get(CHILD_TYPE).set(getName());
request.get(OP_ADDR).set(getManagementAddress(getParent()));
String requestString = request.toJSONString(true);
String resultString = JBoss7ManagerUtil.getService(iserverObject).execute(new
AS7ManagementDetails(iserverObject), requestString);
ModelNode resultNode = ModelNode.fromJSONString(resultString);
{code}
Another way to do this is via the following:
{code}
protected ModelNode executeWithResult(final IServer server, final String request)
throws Exception {
String resultJSON = JBoss7ManagerUtil.executeWithService(new
JBoss7ManagerUtil.IServiceAware<String>() {
public String execute(IJBoss7ManagerService service) throws Exception {
return service.execute(new AS7ManagementDetails(server), request);
}
}, server);
ModelNode result = ModelNode.fromJSONString(resultJSON);
return result;
}
{code}
Hopefully this gives you a good starting point to discovering ports and running management
commands against AS7, as well as what concerns there are. I'm sure Max or the build
team can assist / advise if you start addign dependencies on jbt plugins.
Integrate Designer to work with JBoss Server view instead of Teiid
View
-----------------------------------------------------------------------
Key: TEIIDDES-1459
URL:
https://issues.jboss.org/browse/TEIIDDES-1459
Project: Teiid Designer
Issue Type: Sub-task
Components: Teiid Integration, VDB & Execution
Affects Versions: 8.0
Reporter: Barry LaFond
Assignee: Paul Richardson
Priority: Blocker
Fix For: 8.0
1) Current Teiid View needs to be removed
2) Need way for users to create/store JDBC connection info (current Server Wizard)
3) Replace Deploy and Execute VDB actions with actions that operate in the JBoss Server
view
4) Replace "Create Data Source" action with action that works within the new
AS7 & Teiid 8.x framework
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see:
http://www.atlassian.com/software/jira