Refs #1612 Make JMX console to work in complex deployment environments

This commit is contained in:
Yuriy Artamonov 2012-12-29 12:25:44 +00:00
parent 4acaf9e250
commit 3e353924fb
49 changed files with 1636 additions and 731 deletions

View File

@ -569,10 +569,12 @@ create table SYS_FTS_QUEUE (
ID uniqueidentifier,
CREATE_TS datetime,
CREATED_BY varchar(50),
--
ENTITY_ID uniqueidentifier,
ENTITY_NAME varchar(200),
CHANGE_TYPE char(1),
SOURCE_HOST varchar(100),
--
primary key nonclustered (ID)
)^
@ -581,15 +583,16 @@ create clustered index IDX_SYS_FTS_QUEUE_CREATE_TS on SYS_FTS_QUEUE (CREATE_TS)^
------------------------------------------------------------------------------------------------------------
create table SEC_SCREEN_HISTORY (
ID uniqueidentifier,
CREATE_TS datetime,
CREATED_BY varchar(50),
USER_ID uniqueidentifier,
CAPTION varchar(255),
URL varchar(max),
ENTITY_ID uniqueidentifier,
ID uniqueidentifier,
CREATE_TS datetime,
CREATED_BY varchar(50),
--
primary key nonclustered (ID),
USER_ID uniqueidentifier,
CAPTION varchar(255),
URL varchar(max),
ENTITY_ID uniqueidentifier,
--
primary key nonclustered (ID),
constraint FK_SEC_HISTORY_USER foreign key (USER_ID) references SEC_USER (ID)
)^
@ -608,16 +611,18 @@ create table SYS_SENDING_MESSAGE (
UPDATED_BY varchar(50),
DELETE_TS datetime,
DELETED_BY varchar(50),
--
ADDRESS_TO varchar(500),
ADDRESS_FROM varchar(100),
CAPTION varchar(500),
CONTENT_TEXT varchar(max),
DEADLINE datetime,
STATUS int,
DATE_SENT datetime,
ATTEMPTS_COUNT int,
ATTEMPTS_MADE int,
ATTACHMENTS_NAME varchar(500),
CONTENT_TEXT varchar(max),
DEADLINE datetime,
STATUS int,
DATE_SENT datetime,
ATTEMPTS_COUNT int,
ATTEMPTS_MADE int,
ATTACHMENTS_NAME varchar(500),
--
primary key nonclustered (ID)
)^
@ -630,17 +635,17 @@ create clustered index IDX_SYS_SENDING_MESSAGE_CREATE_TS on SYS_SENDING_MESSAGE
------------------------------------------------------------------------------------------------------------
create table SYS_SENDING_ATTACHMENT (
ID uniqueidentifier,
CREATE_TS datetime,
CREATED_BY varchar(50),
--
MESSAGE_ID uniqueidentifier,
CONTENT image,
CONTENT_ID varchar(50),
NAME varchar(500),
--
primary key nonclustered (ID),
constraint FK_SYS_SENDING_ATTACHMENT_SENDING_MESSAGE foreign key (MESSAGE_ID) references SYS_SENDING_MESSAGE (ID)
ID uniqueidentifier,
CREATE_TS datetime,
CREATED_BY varchar(50),
--
MESSAGE_ID uniqueidentifier,
CONTENT image,
CONTENT_ID varchar(50),
NAME varchar(500),
--
primary key nonclustered (ID),
constraint FK_SYS_SENDING_ATTACHMENT_SENDING_MESSAGE foreign key (MESSAGE_ID) references SYS_SENDING_MESSAGE (ID)
)^
create index SYS_SENDING_ATTACHMENT_MESSAGE_IDX on SYS_SENDING_ATTACHMENT (MESSAGE_ID)^
@ -653,14 +658,15 @@ create table SYS_ENTITY_SNAPSHOT (
ID uniqueidentifier not null,
CREATE_TS datetime,
CREATED_BY varchar(50),
--
ENTITY_META_CLASS varchar(50) not null,
ENTITY_ID uniqueidentifier not null,
AUTHOR_ID uniqueidentifier not null,
VIEW_XML varchar(max) not null,
SNAPSHOT_XML varchar(max) not null,
SNAPSHOT_DATE datetime not null,
primary key nonclustered (ID),
--
primary key nonclustered (ID),
constraint FK_SYS_ENTITY_SNAPSHOT_AUTHOR_ID foreign key (AUTHOR_ID) references SEC_USER(ID)
)^
@ -671,7 +677,7 @@ create clustered index IDX_SYS_ENTITY_SNAPSHOT_CREATE_TS on SYS_ENTITY_SNAPSHOT
-------------------------------------------------------------------------------------------------------------
create table SYS_CATEGORY(
ID uniqueidentifier not null,
ID uniqueidentifier not null,
CREATE_TS datetime,
CREATED_BY varchar(50),
VERSION integer,
@ -682,19 +688,19 @@ create table SYS_CATEGORY(
--
NAME varchar(255),
CODE varchar(50),
SPECIAL varchar(50),
ENTITY_TYPE varchar(30),
IS_DEFAULT tinyint,
DISCRIMINATOR integer,
--
primary key (ID)
SPECIAL varchar(50),
ENTITY_TYPE varchar(30),
IS_DEFAULT tinyint,
DISCRIMINATOR integer,
--
primary key (ID)
)^
-------------------------------------------------------------------------------------------------------------
create table SYS_CATEGORY_ATTR (
ID uniqueidentifier not null,
CREATE_TS datetime,
ID uniqueidentifier not null,
CREATE_TS datetime,
CREATED_BY varchar(50),
VERSION integer,
UPDATE_TS datetime,
@ -703,24 +709,24 @@ create table SYS_CATEGORY_ATTR (
DELETED_BY varchar(50),
--
NAME varchar(255),
CATEGORY_ID uniqueidentifier,
IS_ENTITY tinyint,
DATA_TYPE varchar(200),
DEFAULT_STRING varchar(max),
DEFAULT_INT integer,
DEFAULT_DOUBLE numeric,
DEFAULT_DATE datetime,
DEFAULT_DATE_IS_CURRENT tinyint,
DEFAULT_BOOLEAN tinyint,
DEFAULT_ENTITY_VALUE uniqueidentifier,
ENUMERATION varchar(500),
ORDER_NO integer,
SCREEN varchar(255),
REQUIRED tinyint,
LOOKUP tinyint,
--
primary key nonclustered (ID),
constraint SYS_CATEGORY_ATTR_CATEGORY_ID foreign key (CATEGORY_ID) references SYS_CATEGORY(ID)
CATEGORY_ID uniqueidentifier,
IS_ENTITY tinyint,
DATA_TYPE varchar(200),
DEFAULT_STRING varchar(max),
DEFAULT_INT integer,
DEFAULT_DOUBLE numeric,
DEFAULT_DATE datetime,
DEFAULT_DATE_IS_CURRENT tinyint,
DEFAULT_BOOLEAN tinyint,
DEFAULT_ENTITY_VALUE uniqueidentifier,
ENUMERATION varchar(500),
ORDER_NO integer,
SCREEN varchar(255),
REQUIRED tinyint,
LOOKUP tinyint,
--
primary key nonclustered (ID),
constraint SYS_CATEGORY_ATTR_CATEGORY_ID foreign key (CATEGORY_ID) references SYS_CATEGORY(ID)
)^
create clustered index IDX_SYS_CATEGORY_ATTR_CATEGORY on SYS_CATEGORY_ATTR (CATEGORY_ID)^
@ -728,8 +734,8 @@ create clustered index IDX_SYS_CATEGORY_ATTR_CATEGORY on SYS_CATEGORY_ATTR (CATE
-------------------------------------------------------------------------------------------------------------
create table SYS_ATTR_VALUE (
ID uniqueidentifier not null,
CREATE_TS datetime,
ID uniqueidentifier not null,
CREATE_TS datetime,
CREATED_BY varchar(50),
VERSION integer,
UPDATE_TS datetime,
@ -738,28 +744,50 @@ create table SYS_ATTR_VALUE (
DELETED_BY varchar(50),
--
CATEGORY_ATTR_ID uniqueidentifier,
ENTITY_ID uniqueidentifier,
STRING_VALUE varchar(max),
INTEGER_VALUE integer,
DOUBLE_VALUE numeric,
DATE_VALUE datetime,
BOOLEAN_VALUE tinyint,
ENTITY_VALUE uniqueidentifier,
--
primary key nonclustered (ID),
constraint SYS_ATTR_VALUE_CATEGORY_ATTR_ID foreign key (CATEGORY_ATTR_ID) references SYS_CATEGORY_ATTR(ID)
ENTITY_ID uniqueidentifier,
STRING_VALUE varchar(max),
INTEGER_VALUE integer,
DOUBLE_VALUE numeric,
DATE_VALUE datetime,
BOOLEAN_VALUE tinyint,
ENTITY_VALUE uniqueidentifier,
--
primary key nonclustered (ID),
constraint SYS_ATTR_VALUE_CATEGORY_ATTR_ID foreign key (CATEGORY_ATTR_ID) references SYS_CATEGORY_ATTR(ID)
)^
create clustered index IDX_SYS_ATTR_VALUE_ENTITY on SYS_ATTR_VALUE (ENTITY_ID)^
--------------------------------------------------------------------------------------------------------------
create table SYS_JMX_INSTANCE (
ID uniqueidentifier not null,
CREATE_TS datetime,
CREATED_BY varchar(50),
VERSION integer,
UPDATE_TS datetime,
UPDATED_BY varchar(50),
DELETE_TS datetime,
DELETED_BY varchar(50),
--
CLUSTER_NODE_NAME varchar(255),
DESCRIPTION varchar(500),
ADDRESS varchar(500) not null,
LOGIN varchar(50) not null,
PASSWORD varchar(255) not null,
--
primary key (ID)
)^
--------------------------------------------------------------------------------------------------------------
create table SYS_QUERY_RESULT (
ID bigint identity not null,
SESSION_ID uniqueidentifier not null,
QUERY_KEY integer not null,
ENTITY_ID uniqueidentifier,
primary key (ID)
SESSION_ID uniqueidentifier not null,
QUERY_KEY integer not null,
ENTITY_ID uniqueidentifier,
--
primary key (ID)
)^
create index IDX_SYS_QUERY_RESULT_ENTITY_SESSION_KEY on SYS_QUERY_RESULT (ENTITY_ID, SESSION_ID, QUERY_KEY)^

View File

@ -564,15 +564,15 @@ create index IDX_SYS_FTS_QUEUE_CREATE_TS on SYS_FTS_QUEUE (CREATE_TS)^
------------------------------------------------------------------------------------------------------------
create table SEC_SCREEN_HISTORY (
ID uuid,
CREATE_TS timestamp,
CREATED_BY varchar(50),
USER_ID uuid,
CAPTION varchar(255),
URL TEXT,
ENTITY_ID uuid,
ID uuid,
CREATE_TS timestamp,
CREATED_BY varchar(50),
USER_ID uuid,
CAPTION varchar(255),
URL TEXT,
ENTITY_ID uuid,
--
primary key (ID),
primary key (ID),
constraint FK_SEC_HISTORY_USER foreign key (USER_ID) references SEC_USER (ID)
)^
@ -589,16 +589,18 @@ create table SYS_SENDING_MESSAGE (
UPDATED_BY varchar(50),
DELETE_TS timestamp,
DELETED_BY varchar(50),
--
ADDRESS_TO varchar(500),
ADDRESS_FROM varchar(100),
CAPTION varchar(500),
CONTENT_TEXT text,
DEADLINE timestamp,
STATUS int,
DATE_SENT timestamp,
ATTEMPTS_COUNT int,
ATTEMPTS_MADE int,
ATTACHMENTS_NAME varchar(500),
CONTENT_TEXT text,
DEADLINE timestamp,
STATUS int,
DATE_SENT timestamp,
ATTEMPTS_COUNT int,
ATTEMPTS_MADE int,
ATTACHMENTS_NAME varchar(500),
--
primary key (ID)
)^
@ -608,18 +610,18 @@ create index IDX_SYS_SENDING_MESSAGE_DATE_SENT on SYS_SENDING_MESSAGE (DATE_SENT
------------------------------------------------------------------------------------------------------------
create table SYS_SENDING_ATTACHMENT(
ID uuid,
CREATE_TS timestamp,
CREATED_BY varchar(50),
--
MESSAGE_ID uuid,
CONTENT bytea,
CONTENT_ID varchar(50),
NAME varchar(500),
--
primary key (ID),
constraint FK_SYS_SENDING_ATTACHMENT_SENDING_MESSAGE foreign key (MESSAGE_ID) references SYS_SENDING_MESSAGE (ID)
create table SYS_SENDING_ATTACHMENT (
ID uuid,
CREATE_TS timestamp,
CREATED_BY varchar(50),
--
MESSAGE_ID uuid,
CONTENT bytea,
CONTENT_ID varchar(50),
NAME varchar(500),
--
primary key (ID),
constraint FK_SYS_SENDING_ATTACHMENT_SENDING_MESSAGE foreign key (MESSAGE_ID) references SYS_SENDING_MESSAGE (ID)
)^
create index SYS_SENDING_ATTACHMENT_MESSAGE_IDX on SYS_SENDING_ATTACHMENT (MESSAGE_ID)^
@ -630,14 +632,15 @@ create table SYS_ENTITY_SNAPSHOT (
ID uuid not null,
CREATE_TS timestamp,
CREATED_BY varchar(50),
--
ENTITY_META_CLASS varchar(50) not null,
ENTITY_ID uuid not null,
AUTHOR_ID uuid not null,
VIEW_XML text not null,
SNAPSHOT_XML text not null,
SNAPSHOT_DATE timestamp not null,
primary key (ID),
--
primary key (ID),
constraint FK_SYS_ENTITY_SNAPSHOT_AUTHOR_ID foreign key (AUTHOR_ID) references SEC_USER(ID)
)^
@ -646,7 +649,7 @@ create index IDX_SYS_ENTITY_SNAPSHOT_ENTITY_ID on SYS_ENTITY_SNAPSHOT (ENTITY_ID
-------------------------------------------------------------------------------------------------------------
create table SYS_CATEGORY (
ID uuid not null,
ID uuid not null,
CREATE_TS timestamp,
CREATED_BY varchar(50),
VERSION integer,
@ -656,19 +659,19 @@ create table SYS_CATEGORY (
DELETED_BY varchar(50),
--
NAME varchar(255),
SPECIAL varchar(50),
ENTITY_TYPE varchar(30),
IS_DEFAULT boolean,
DISCRIMINATOR integer,
--
primary key (ID)
SPECIAL varchar(50),
ENTITY_TYPE varchar(30),
IS_DEFAULT boolean,
DISCRIMINATOR integer,
--
primary key (ID)
)^
-------------------------------------------------------------------------------------------------------------
create table SYS_CATEGORY_ATTR (
ID uuid not null,
CREATE_TS timestamp,
ID uuid not null,
CREATE_TS timestamp,
CREATED_BY varchar(50),
VERSION integer,
UPDATE_TS timestamp,
@ -678,32 +681,32 @@ create table SYS_CATEGORY_ATTR (
--
NAME varchar(255),
CODE varchar(50),
CATEGORY_ID uuid,
IS_ENTITY boolean,
DATA_TYPE varchar(200),
DEFAULT_STRING varchar,
DEFAULT_INT integer,
DEFAULT_DOUBLE numeric,
DEFAULT_DATE timestamp,
DEFAULT_DATE_IS_CURRENT boolean,
DEFAULT_BOOLEAN boolean,
DEFAULT_ENTITY_VALUE uuid,
ENUMERATION varchar(500),
ORDER_NO integer,
SCREEN varchar(255),
REQUIRED boolean,
LOOKUP boolean,
--
primary key (ID),
constraint SYS_CATEGORY_ATTR_CATEGORY_ID foreign key (CATEGORY_ID) references SYS_CATEGORY(ID)
CATEGORY_ID uuid,
IS_ENTITY boolean,
DATA_TYPE varchar(200),
DEFAULT_STRING varchar,
DEFAULT_INT integer,
DEFAULT_DOUBLE numeric,
DEFAULT_DATE timestamp,
DEFAULT_DATE_IS_CURRENT boolean,
DEFAULT_BOOLEAN boolean,
DEFAULT_ENTITY_VALUE uuid,
ENUMERATION varchar(500),
ORDER_NO integer,
SCREEN varchar(255),
REQUIRED boolean,
LOOKUP boolean,
--
primary key (ID),
constraint SYS_CATEGORY_ATTR_CATEGORY_ID foreign key (CATEGORY_ID) references SYS_CATEGORY(ID)
)^
create index IDX_SYS_CATEGORY_ATTR_CATEGORY on SYS_CATEGORY_ATTR (CATEGORY_ID)^
-------------------------------------------------------------------------------------------------------------
create table SYS_ATTR_VALUE(
ID uuid not null,
CREATE_TS timestamp,
create table SYS_ATTR_VALUE (
ID uuid not null,
CREATE_TS timestamp,
CREATED_BY varchar(50),
VERSION integer,
UPDATE_TS timestamp,
@ -712,22 +715,43 @@ create table SYS_ATTR_VALUE(
DELETED_BY varchar(50),
--
CATEGORY_ATTR_ID uuid,
ENTITY_ID uuid,
STRING_VALUE varchar,
INTEGER_VALUE integer,
DOUBLE_VALUE numeric,
DATE_VALUE timestamp,
BOOLEAN_VALUE boolean,
ENTITY_VALUE uuid,
--
primary key (ID),
constraint SYS_ATTR_VALUE_CATEGORY_ATTR_ID foreign key (CATEGORY_ATTR_ID) references SYS_CATEGORY_ATTR(ID)
ENTITY_ID uuid,
STRING_VALUE varchar,
INTEGER_VALUE integer,
DOUBLE_VALUE numeric,
DATE_VALUE timestamp,
BOOLEAN_VALUE boolean,
ENTITY_VALUE uuid,
--
primary key (ID),
constraint SYS_ATTR_VALUE_CATEGORY_ATTR_ID foreign key (CATEGORY_ATTR_ID) references SYS_CATEGORY_ATTR(ID)
)^
create index IDX_SYS_ATTR_VALUE_ENTITY on SYS_ATTR_VALUE (ENTITY_ID)^
------------------------------------------------------------------------------------------------------------
create table SYS_JMX_INSTANCE (
ID uuid not null,
CREATE_TS timestamp,
CREATED_BY varchar(50),
VERSION integer,
UPDATE_TS timestamp,
UPDATED_BY varchar(50),
DELETE_TS timestamp,
DELETED_BY varchar(50),
--
CLUSTER_NODE_NAME varchar(255),
DESCRIPTION varchar(500),
ADDRESS varchar(500) not null,
LOGIN varchar(50) not null,
PASSWORD varchar(255) not null,
--
primary key (ID)
)^
------------------------------------------------------------------------------------------------------------
create sequence SYS_QUERY_RESULT_SEQ
^

View File

@ -14,11 +14,11 @@ create table SYS_SERVER (
UPDATED_BY varchar(50),
DELETE_TS timestamp,
DELETED_BY varchar(50),
--
NAME varchar(255),
ADDRESS varchar(255),
IS_RUNNING smallint,
--
primary key (ID)
);
@ -31,10 +31,10 @@ create table SYS_CONFIG (
VERSION integer,
UPDATE_TS timestamp,
UPDATED_BY varchar(50),
--
NAME varchar(255),
VALUE varchar(1500),
--
primary key (ID),
constraint SYS_CONFIG_UNIQ_NAME unique (NAME)
);
@ -52,12 +52,12 @@ create table SYS_FILE (
UPDATED_BY varchar(50),
DELETE_TS timestamp,
DELETED_BY varchar(50),
--
NAME varchar(500),
EXT varchar(20),
SIZE integer,
CREATE_DATE timestamp,
--
primary key (ID)
);
@ -67,10 +67,10 @@ create table SYS_LOCK_CONFIG (
ID varchar(36),
CREATE_TS timestamp,
CREATED_BY varchar(50),
--
NAME varchar(100),
TIMEOUT_SEC integer,
--
primary key (ID)
);
@ -82,14 +82,14 @@ create table SYS_ENTITY_STATISTICS (
CREATED_BY varchar(50),
UPDATE_TS timestamp,
UPDATED_BY varchar(50),
--
NAME varchar(50),
INSTANCE_COUNT bigint,
FETCH_UI integer,
MAX_FETCH_UI integer,
LAZY_COLLECTION_THRESHOLD integer,
LOOKUP_SCREEN_THRESHOLD integer,
--
primary key (ID)
);
@ -103,7 +103,7 @@ create table SYS_SCHEDULED_TASK (
UPDATED_BY varchar(50),
DELETE_TS timestamp,
DELETED_BY varchar(50),
--
BEAN_NAME varchar(50),
METHOD_NAME varchar(50),
METHOD_PARAMS varchar(1000),
@ -124,7 +124,7 @@ create table SYS_SCHEDULED_TASK (
LAST_START_TIME timestamp,
LAST_START_SERVER varchar(50),
DESCRIPTION varchar(1000),
--
primary key (ID),
constraint UNIQ_SYS_SCHEDULED_TASK_BEAN_METHOD unique (BEAN_NAME, METHOD_NAME)
);
@ -135,13 +135,13 @@ create table SYS_SCHEDULED_EXECUTION (
ID varchar(36) not null,
CREATE_TS timestamp,
CREATED_BY varchar(50),
--
TASK_ID varchar(36),
SERVER varchar(50),
START_TIME timestamp,
FINISH_TIME timestamp,
RESULT longvarchar,
--
primary key (ID),
constraint SYS_SCHEDULED_EXECUTION_TASK foreign key (TASK_ID) references SYS_SCHEDULED_TASK(ID)
);
@ -159,13 +159,13 @@ create table SEC_ROLE (
UPDATED_BY varchar(50),
DELETE_TS timestamp,
DELETED_BY varchar(50),
--
NAME varchar(255),
LOC_NAME varchar(255),
DESCRIPTION varchar(1000),
IS_DEFAULT_ROLE smallint,
TYPE integer,
--
primary key (ID)
);
@ -182,10 +182,10 @@ create table SEC_GROUP (
UPDATED_BY varchar(50),
DELETE_TS timestamp,
DELETED_BY varchar(50),
--
NAME varchar(255),
PARENT_ID varchar(36),
--
primary key (ID),
constraint SEC_GROUP_PARENT foreign key (PARENT_ID) references SEC_GROUP(ID)
);
@ -198,11 +198,11 @@ create table SEC_GROUP_HIERARCHY (
ID varchar(36),
CREATE_TS timestamp,
CREATED_BY varchar(50),
--
GROUP_ID varchar(36),
PARENT_ID varchar(36),
LEVEL integer,
--
primary key (ID),
constraint SEC_GROUP_HIERARCHY_GROUP foreign key (GROUP_ID) references SEC_GROUP(ID),
constraint SEC_GROUP_HIERARCHY_PARENT foreign key (PARENT_ID) references SEC_GROUP(ID)
@ -223,7 +223,7 @@ create table SEC_USER (
UPDATED_BY varchar(50),
DELETE_TS timestamp,
DELETED_BY varchar(50),
--
LOGIN varchar(50) not null,
LOGIN_LC varchar(50) not null,
PASSWORD varchar(255),
@ -240,7 +240,7 @@ create table SEC_USER (
IP_MASK varchar(200),
TYPE varchar(1),
CHANGE_PASSWORD_AT_LOGON smallint,
--
primary key (ID),
constraint SEC_USER_UNIQ_LOGIN unique (LOGIN_LC, DELETE_TS),
constraint SEC_USER_GROUP foreign key (GROUP_ID) references SEC_GROUP(ID),
@ -265,10 +265,10 @@ create table SEC_USER_ROLE (
UPDATED_BY varchar(50),
DELETE_TS timestamp,
DELETED_BY varchar(50),
--
USER_ID varchar(36),
ROLE_ID varchar(36),
--
primary key (ID),
constraint SEC_USER_ROLE_USER foreign key (USER_ID) references SEC_USER(ID),
constraint SEC_USER_ROLE_ROLE foreign key (ROLE_ID) references SEC_ROLE(ID),
@ -292,12 +292,12 @@ create table SEC_PERMISSION (
UPDATED_BY varchar(50),
DELETE_TS timestamp,
DELETED_BY varchar(50),
--
TYPE integer,
TARGET varchar(100),
VALUE integer,
ROLE_ID varchar(36),
--
primary key (ID),
constraint SEC_PERMISSION_ROLE foreign key (ROLE_ID) references SEC_ROLE(ID),
constraint SEC_PERMISSION_UNIQUE unique (ROLE_ID, TYPE, TARGET, DELETE_TS)
@ -318,12 +318,12 @@ create table SEC_CONSTRAINT (
UPDATED_BY varchar(50),
DELETE_TS timestamp,
DELETED_BY varchar(50),
--
ENTITY_NAME varchar(50),
JOIN_CLAUSE varchar(500),
WHERE_CLAUSE varchar(1000),
GROUP_ID varchar(36),
--
primary key (ID),
constraint SEC_CONSTRAINT_GROUP foreign key (GROUP_ID) references SEC_GROUP(ID)
);
@ -341,12 +341,12 @@ create table SEC_SESSION_ATTR (
UPDATED_BY varchar(50),
DELETE_TS timestamp,
DELETED_BY varchar(50),
--
NAME varchar(50),
STR_VALUE varchar(1000),
DATATYPE varchar(20),
GROUP_ID varchar(36),
--
primary key (ID),
constraint SEC_SESSION_ATTR_GROUP foreign key (GROUP_ID) references SEC_GROUP(ID)
);
@ -359,12 +359,12 @@ create table SEC_USER_SETTING (
ID varchar(36),
CREATE_TS timestamp,
CREATED_BY varchar(50),
--
USER_ID varchar(36),
CLIENT_TYPE char(1),
NAME varchar(255),
VALUE longvarchar,
--
primary key (ID),
constraint SEC_USER_SETTING_USER foreign key (USER_ID) references SEC_USER(ID),
constraint SEC_USER_SETTING_UNIQ unique (USER_ID, NAME, CLIENT_TYPE)
@ -385,12 +385,12 @@ create table SEC_USER_SUBSTITUTION (
UPDATED_BY varchar(50),
DELETE_TS timestamp,
DELETED_BY varchar(50),
--
USER_ID varchar(36),
SUBSTITUTED_USER_ID varchar(36),
START_DATE timestamp,
END_DATE timestamp,
--
primary key (ID),
constraint FK_SEC_USER_SUBSTITUTION_USER foreign key (USER_ID) references SEC_USER(ID),
constraint FK_SEC_USER_SUBSTITUTION_SUBSTITUTED_USER foreign key (SUBSTITUTED_USER_ID)
@ -407,11 +407,11 @@ create table SEC_LOGGED_ENTITY (
ID varchar(36),
CREATE_TS timestamp,
CREATED_BY varchar(50),
--
NAME varchar(100),
AUTO smallint,
MANUAL smallint,
--
primary key (ID),
constraint SEC_LOGGED_ENTITY_UNIQ_NAME unique (NAME)
);
@ -424,10 +424,10 @@ create table SEC_LOGGED_ATTR (
ID varchar(36),
CREATE_TS timestamp,
CREATED_BY varchar(50),
--
ENTITY_ID varchar(36),
NAME varchar(50),
--
primary key (ID),
constraint FK_SEC_LOGGED_ATTR_ENTITY foreign key (ENTITY_ID) references SEC_LOGGED_ENTITY(ID),
constraint SEC_LOGGED_ATTR_UNIQ_NAME unique (ENTITY_ID, NAME)
@ -443,14 +443,14 @@ create table SEC_ENTITY_LOG (
ID varchar(36),
CREATE_TS timestamp,
CREATED_BY varchar(50),
--
EVENT_TS timestamp,
USER_ID varchar(36),
TYPE char(1),
ENTITY varchar(100),
ENTITY_ID varchar(36),
CHANGES longvarchar,
--
primary key (ID),
constraint FK_SEC_ENTITY_LOG_USER foreign key (USER_ID) references SEC_USER(ID)
);
@ -463,13 +463,13 @@ create table SEC_ENTITY_LOG_ATTR (
ID varchar(36),
CREATE_TS timestamp,
CREATED_BY varchar(50),
--
ITEM_ID varchar(36),
NAME varchar(50),
VALUE varchar(1500),
VALUE_ID varchar(36),
MESSAGES_PACK varchar(200),
--
primary key (ID),
constraint FK_SEC_ENTITY_LOG_ATTR_ITEM foreign key (ITEM_ID) references SEC_ENTITY_LOG(ID)
);
@ -487,13 +487,13 @@ create table SEC_FILTER (
UPDATED_BY varchar(50),
DELETE_TS timestamp,
DELETED_BY varchar(50),
--
COMPONENT varchar(200),
NAME varchar(255),
CODE varchar(200),
XML varchar(7000),
USER_ID varchar(36),
--
primary key (ID),
constraint FK_SEC_FILTER_USER foreign key (USER_ID) references SEC_USER(ID)
);
@ -511,13 +511,13 @@ create table SYS_FOLDER (
UPDATED_BY varchar(50),
DELETE_TS timestamp,
DELETED_BY varchar(50),
--
TYPE char(1),
PARENT_ID varchar(36),
NAME varchar(100),
TAB_NAME varchar(100),
SORT_ORDER integer,
--
primary key (ID),
constraint FK_SYS_FOLDER_PARENT foreign key (PARENT_ID) references SYS_FOLDER(ID)
);
@ -533,7 +533,7 @@ create table SYS_APP_FOLDER (
VISIBILITY_SCRIPT longvarchar,
QUANTITY_SCRIPT longvarchar,
APPLY_DEFAULT smallint,
--
primary key (FOLDER_ID),
constraint FK_SYS_APP_FOLDER_FOLDER foreign key (FOLDER_ID) references SYS_FOLDER(ID)
);
@ -548,13 +548,13 @@ create table SEC_PRESENTATION (
CREATED_BY varchar(50),
UPDATE_TS timestamp,
UPDATED_BY varchar(50),
--
COMPONENT varchar(200),
NAME varchar(255),
XML varchar(7000),
USER_ID varchar(36),
IS_AUTO_SAVE smallint,
--
primary key (ID),
constraint SEC_PRESENTATION_USER foreign key (USER_ID) references SEC_USER(ID)
);
@ -572,7 +572,7 @@ create table SEC_SEARCH_FOLDER (
APPLY_DEFAULT smallint,
IS_SET smallint,
ENTITY_TYPE varchar(50),
--
primary key (FOLDER_ID),
constraint FK_SEC_SEARCH_FOLDER_FOLDER foreign key (FOLDER_ID) references SYS_FOLDER(ID),
constraint FK_SEC_SEARCH_FOLDER_USER foreign key (USER_ID) references SEC_USER(ID),
@ -593,12 +593,12 @@ create table SYS_FTS_QUEUE (
ID varchar(36),
CREATE_TS timestamp,
CREATED_BY varchar(50),
--
ENTITY_ID varchar(36),
ENTITY_NAME varchar(200),
CHANGE_TYPE char(1),
SOURCE_HOST varchar(100),
--
primary key (ID)
);
@ -631,15 +631,15 @@ INSERT INTO sec_filter (id,create_ts,created_by,version,update_ts,updated_by,del
--------------------------------------------------------------------------------------------------------------
create table SEC_SCREEN_HISTORY (
ID varchar(36),
CREATE_TS timestamp,
CREATED_BY varchar(50),
USER_ID varchar(36),
CAPTION varchar(255),
URL varchar(4000),
ENTITY_ID varchar(36),
primary key (ID),
ID varchar(36),
CREATE_TS timestamp,
CREATED_BY varchar(50),
USER_ID varchar(36),
CAPTION varchar(255),
URL varchar(4000),
ENTITY_ID varchar(36),
--
primary key (ID),
constraint FK_SEC_HISTORY_USER foreign key (USER_ID) references SEC_USER (ID)
);
@ -654,28 +654,32 @@ create table SYS_SENDING_MESSAGE (
UPDATED_BY varchar(50),
DELETE_TS timestamp,
DELETED_BY varchar(50),
--
ADDRESS_TO varchar(500),
ADDRESS_FROM varchar(100),
CAPTION varchar(500),
CONTENT_TEXT longvarchar,
DEADLINE timestamp,
STATUS integer,
DATE_SENT timestamp,
ATTEMPTS_COUNT integer,
ATTEMPTS_MADE integer,
ATTACHMENTS_NAME varchar(500),
CONTENT_TEXT longvarchar,
DEADLINE timestamp,
STATUS integer,
DATE_SENT timestamp,
ATTEMPTS_COUNT integer,
ATTEMPTS_MADE integer,
ATTACHMENTS_NAME varchar(500),
--
primary key (ID)
);
create table SYS_SENDING_ATTACHMENT(
ID varchar(36),
CREATE_TS timestamp,
CREATED_BY varchar(50),
MESSAGE_ID varchar(36),
CONTENT longvarbinary,
CONTENT_ID varchar(50),
NAME varchar(500),
primary key (ID)
create table SYS_SENDING_ATTACHMENT (
ID varchar(36),
CREATE_TS timestamp,
CREATED_BY varchar(50),
--
MESSAGE_ID varchar(36),
CONTENT longvarbinary,
CONTENT_ID varchar(50),
NAME varchar(500),
--
primary key (ID)
);
alter table SYS_SENDING_ATTACHMENT add constraint FK_SYS_SENDING_ATTACHMENT_SENDING_MESSAGE foreign key (MESSAGE_ID) references SYS_SENDING_MESSAGE (ID);
@ -693,18 +697,20 @@ create table SYS_ENTITY_SNAPSHOT (
ID varchar(36),
CREATE_TS timestamp,
CREATED_BY varchar(50),
--
ENTITY_META_CLASS varchar(50),
ENTITY_ID varchar(36),
VIEW_XML longvarchar,
SNAPSHOT_XML longvarchar,
SNAPSHOT_DATE timestamp,
primary key (ID)
--
primary key (ID)
);
-------------------------------------------------------------------------------------------------------------
create table SYS_CATEGORY(
ID varchar(36) not null,
ID varchar(36) not null,
CREATE_TS timestamp,
CREATED_BY varchar(50),
VERSION integer,
@ -712,63 +718,69 @@ create table SYS_CATEGORY(
UPDATED_BY varchar(50),
DELETE_TS timestamp,
DELETED_BY varchar(50),
--
NAME varchar(255),
SPECIAL varchar(50),
ENTITY_TYPE varchar(30),
IS_DEFAULT boolean,
DISCRIMINATOR integer,
primary key (ID)
ENTITY_TYPE varchar(30),
IS_DEFAULT boolean,
DISCRIMINATOR integer,
--
primary key (ID)
);
create table SYS_CATEGORY_ATTR(
ID varchar(36) not null,
CREATE_TS timestamp,
ID varchar(36) not null,
CREATE_TS timestamp,
CREATED_BY varchar(50),
VERSION integer,
UPDATE_TS timestamp,
UPDATED_BY varchar(50),
DELETE_TS timestamp,
DELETED_BY varchar(50),
--
NAME varchar(255),
CODE varchar(50),
CATEGORY_ID varchar(36),
IS_ENTITY boolean,
DATA_TYPE varchar(200),
DEFAULT_STRING varchar,
DEFAULT_INT integer,
DEFAULT_DOUBLE numeric,
DEFAULT_DATE date,
DEFAULT_DATE_IS_CURRENT boolean,
DEFAULT_BOOLEAN boolean,
DEFAULT_ENTITY_VALUE varchar(36),
ENUMERATION varchar(500),
CATEGORY_ID varchar(36),
IS_ENTITY boolean,
DATA_TYPE varchar(200),
DEFAULT_STRING varchar,
DEFAULT_INT integer,
DEFAULT_DOUBLE numeric,
DEFAULT_DATE date,
DEFAULT_DATE_IS_CURRENT boolean,
DEFAULT_BOOLEAN boolean,
DEFAULT_ENTITY_VALUE varchar(36),
ENUMERATION varchar(500),
ORDER_NO integer,
SCREEN varchar(255),
REQUIRED boolean,
LOOKUP boolean,
primary key (ID)
SCREEN varchar(255),
REQUIRED boolean,
LOOKUP boolean,
--
primary key (ID)
);
alter table SYS_CATEGORY_ATTR add constraint SYS_CATEGORY_ATTR_CATEGORY_ID foreign key (CATEGORY_ID) references SYS_CATEGORY(ID);
create table SYS_ATTR_VALUE(
ID varchar(36) not null,
CREATE_TS timestamp,
ID varchar(36) not null,
CREATE_TS timestamp,
CREATED_BY varchar(50),
VERSION integer,
UPDATE_TS timestamp,
UPDATED_BY varchar(50),
DELETE_TS timestamp,
DELETED_BY varchar(50),
--
CATEGORY_ATTR_ID varchar(36),
ENTITY_ID varchar(36),
STRING_VALUE varchar,
INTEGER_VALUE integer,
DOUBLE_VALUE numeric,
DATE_VALUE date,
BOOLEAN_VALUE boolean,
ENTITY_VALUE varchar(36),
primary key (ID)
ENTITY_ID varchar(36),
STRING_VALUE varchar,
INTEGER_VALUE integer,
DOUBLE_VALUE numeric,
DATE_VALUE date,
BOOLEAN_VALUE boolean,
ENTITY_VALUE varchar(36),
--
primary key (ID)
);
alter table SYS_ATTR_VALUE add constraint SYS_ATTR_VALUE_CATEGORY_ATTR_ID foreign key (CATEGORY_ATTR_ID) references SYS_CATEGORY_ATTR(ID);
@ -777,8 +789,30 @@ alter table SYS_ATTR_VALUE add constraint SYS_ATTR_VALUE_CATEGORY_ATTR_ID foreig
create table SYS_QUERY_RESULT (
ID identity not null,
SESSION_ID varchar(36) not null,
QUERY_KEY integer not null,
ENTITY_ID varchar(36) not null,
primary key (ID)
SESSION_ID varchar(36) not null,
QUERY_KEY integer not null,
ENTITY_ID varchar(36) not null,
--
primary key (ID)
);
--------------------------------------------------------------------------------------------------------------
create table SYS_JMX_INSTANCE (
ID varchar(36) not null,
CREATE_TS timestamp,
CREATED_BY varchar(50),
VERSION integer,
UPDATE_TS timestamp,
UPDATED_BY varchar(50),
DELETE_TS timestamp,
DELETED_BY varchar(50),
--
CLUSTER_NODE_NAME varchar(255),
DESCRIPTION varchar(500),
ADDRESS varchar(500) not null,
LOGIN varchar(50) not null,
PASSWORD varchar(255) not null,
--
primary key (ID)
);

View File

@ -0,0 +1,21 @@
-- $Id$
-- Description: add SYS_JMX_INSTANCE table
create table SYS_JMX_INSTANCE (
ID uniqueidentifier not null,
CREATE_TS datetime,
CREATED_BY varchar(50),
VERSION integer,
UPDATE_TS datetime,
UPDATED_BY varchar(50),
DELETE_TS datetime,
DELETED_BY varchar(50),
--
CLUSTER_NODE_NAME varchar(255),
DESCRIPTION varchar(500),
ADDRESS varchar(500) not null,
LOGIN varchar(50) not null,
PASSWORD varchar(255) not null,
--
primary key (ID)
)^

View File

@ -0,0 +1,21 @@
-- $Id$
-- Description: add SYS_JMX_INSTANCE table
create table SYS_JMX_INSTANCE (
ID uuid not null,
CREATE_TS timestamp,
CREATED_BY varchar(50),
VERSION integer,
UPDATE_TS timestamp,
UPDATED_BY varchar(50),
DELETE_TS timestamp,
DELETED_BY varchar(50),
--
CLUSTER_NODE_NAME varchar(255),
DESCRIPTION varchar(500),
ADDRESS varchar(500) not null,
LOGIN varchar(50) not null,
PASSWORD varchar(255) not null,
--
primary key (ID)
)^

View File

@ -1,337 +0,0 @@
/*
* Copyright (c) 2008-2010 Haulmont Technology Ltd. All Rights Reserved.
* Haulmont Technology proprietary and confidential.
* Use is subject to license terms.
*
* Author: Alexander Budarov
* Created: 17.08.2010 10:40:00
* $Id$
*/
package com.haulmont.cuba.jmxcontrol.app;
import com.haulmont.cuba.jmxcontrol.entity.*;
import com.haulmont.cuba.jmxcontrol.global.JmxControlException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Service;
import javax.management.*;
import java.io.IOException;
import java.io.Serializable;
import java.lang.management.ManagementFactory;
import java.lang.reflect.Proxy;
import java.util.*;
@Service(JmxControlService.NAME)
public class JmxControlServiceBean implements JmxControlService {
private static Log log = LogFactory.getLog(JmxControlServiceBean.class);
/**
* Constant identifier for the role field in a JMX {@link Descriptor}.
*/
protected static final String FIELD_ROLE = "role";
/**
* Constant identifier for the getter role field value in a JMX {@link Descriptor}.
*/
protected static final String ROLE_GETTER = "getter";
/**
* Constant identifier for the setter role field value in a JMX {@link Descriptor}.
*/
protected static final String ROLE_SETTER = "setter";
public List<ManagedBeanInfo> getManagedBeans() {
MBeanServerConnection connection = getConnection();
try {
Set<ObjectName> names = connection.queryNames(null, null);
List<ManagedBeanInfo> infoList = new ArrayList<ManagedBeanInfo>();
for (ObjectName name : names) {
MBeanInfo info = connection.getMBeanInfo(name);
ManagedBeanInfo mbi = new ManagedBeanInfo();
mbi.setClassName(info.getClassName());
mbi.setDescription(info.getDescription());
mbi.setObjectName(name.toString());
mbi.setDomain(name.getDomain());
mbi.setPropertyList(name.getKeyPropertyListString());
loadOperations(mbi, info);
infoList.add(mbi);
}
Collections.sort(infoList, new MBeanComparator());
return infoList;
}
catch (IOException e) {
throw new JmxControlException(e);
}
catch (IntrospectionException e) {
throw new JmxControlException(e);
}
catch (ReflectionException e) {
throw new JmxControlException(e);
}
catch (InstanceNotFoundException e) {
throw new JmxControlException(e);
}
}
private String cleanType(String type) {
if (type != null && type.startsWith("[L") && type.endsWith(";")) {
return type.substring(2, type.length() - 1) + "[]";
}
return type;
}
public ManagedBeanInfo loadAttributes(ManagedBeanInfo mbinfo) {
try {
MBeanServerConnection connection = getConnection();
ObjectName name = new ObjectName(mbinfo.getObjectName());
MBeanInfo info = connection.getMBeanInfo(name);
List<ManagedBeanAttribute> attrs = new ArrayList<ManagedBeanAttribute>();
MBeanAttributeInfo[] attributes = info.getAttributes();
for (MBeanAttributeInfo attribute : attributes) {
ManagedBeanAttribute mba = new ManagedBeanAttribute();
mba.setMbean(mbinfo);
mba.setName(attribute.getName());
mba.setType(cleanType(attribute.getType()));
mba.setReadable(attribute.isReadable());
mba.setWriteable(attribute.isWritable());
String mask = "";
if (attribute.isReadable()) mask += "R";
if (attribute.isWritable()) mask += "W";
mba.setReadableWriteable(mask);
if (mba.getReadable())
try {
Object value = connection.getAttribute(name, mba.getName());
setSerializableValue(mba, value);
}
catch (Exception e) {
log.error(e);
mba.setValue(e.getMessage());
mba.setWriteable(false);
}
attrs.add(mba);
}
Collections.sort(attrs, new AttributeComparator());
mbinfo.setAttributes(attrs);
return mbinfo;
}
catch (Exception e) {
throw new JmxControlException(e);
}
}
private void setSerializableValue(ManagedBeanAttribute mba, Object value) {
if (value instanceof Serializable && !(value instanceof Proxy))
mba.setValue(value);
else if (value != null)
mba.setValue(value.toString());
}
public ManagedBeanAttribute loadAttributeValue(ManagedBeanAttribute attr) {
try {
MBeanServerConnection connection = getConnection();
ObjectName name = new ObjectName(attr.getMbean().getObjectName());
Object value = null;
if (attr.getReadable())
try {
value = connection.getAttribute(name, attr.getName());
}
catch (Exception e) {
log.error(e);
value = e.getMessage();
}
setSerializableValue(attr, value);
return attr;
}
catch (MalformedObjectNameException e) {
throw new JmxControlException(e);
}
}
public void saveAttributeValue(ManagedBeanAttribute attr) {
try {
MBeanServerConnection connection = getConnection();
ObjectName name = new ObjectName(attr.getMbean().getObjectName());
Attribute a = new Attribute(attr.getName(), attr.getValue());
connection.setAttribute(name, a);
}
catch (Exception e) {
throw new JmxControlException(e);
}
}
private void loadOperations(ManagedBeanInfo mbean, MBeanInfo info) {
List<ManagedBeanOperation> opList = new ArrayList<ManagedBeanOperation>();
MBeanOperationInfo[] operations = info.getOperations();
for (MBeanOperationInfo operation: operations) {
String role = (String) operation.getDescriptor().getFieldValue(FIELD_ROLE);
if (ROLE_GETTER.equals(role) || ROLE_SETTER.equals(role)) {
continue; // these operations do the same as reading / writing attributes
}
ManagedBeanOperation o = new ManagedBeanOperation();
o.setName(operation.getName());
o.setDescription(operation.getDescription());
o.setMbean(mbean);
o.setReturnType(cleanType(operation.getReturnType()));
List<ManagedBeanOperationParameter> paramList = new ArrayList<ManagedBeanOperationParameter>();
if (operation.getSignature() != null) {
for (int index = 0; index < operation.getSignature().length; index++) {
MBeanParameterInfo pinfo = operation.getSignature()[index];
ManagedBeanOperationParameter p = new ManagedBeanOperationParameter();
p.setName(pinfo.getName());
p.setType(cleanType(pinfo.getType()));
p.setDescription(pinfo.getDescription());
p.setOperation(o);
// fix name if it is not set
if (p.getName() == null || p.getName().length() == 0 || p.getName().equals(p.getType())) {
p.setName("arg" + index);
}
paramList.add(p);
}
}
o.setParameters(paramList);
opList.add(o);
}
Collections.sort(opList, new OperationComparator());
mbean.setOperations(opList);
}
public Object invokeOperation(ManagedBeanOperation operation, Object[] parameterValues) {
try {
MBeanServerConnection connection = getConnection();
ObjectName name = new ObjectName(operation.getMbean().getObjectName());
String[] types = new String[operation.getParameters().size()];
for (int i = 0; i < operation.getParameters().size(); i++) {
types[i] = operation.getParameters().get(i).getType();
}
Object result = connection.invoke(name, operation.getName(), parameterValues, types);
return result;
}
catch (IOException e) {
throw new JmxControlException(e);
}
catch (MalformedObjectNameException e) {
throw new JmxControlException(e);
}
catch (ReflectionException e) {
throw new JmxControlException(e);
}
catch (MBeanException e) {
throw new JmxControlException(e);
}
catch (InstanceNotFoundException e) {
throw new JmxControlException(e);
}
}
public List<ManagedBeanDomain> getDomains() {
MBeanServerConnection connection = getConnection();
try {
String[] domains = connection.getDomains();
List<ManagedBeanDomain> domainList = new ArrayList<ManagedBeanDomain>();
for (String d : domains) {
ManagedBeanDomain mbd = new ManagedBeanDomain();
mbd.setName(d);
domainList.add(mbd);
}
Collections.sort(domainList, new DomainComparator());
return domainList;
}
catch (IOException e) {
throw new JmxControlException(e);
}
}
private MBeanServerConnection getConnection() {
return ManagementFactory.getPlatformMBeanServer();
}
/*private MBeanServerConnection getRemoteConnection() {
MBeanServerConnectionFactoryBean factoryBean = new MBeanServerConnectionFactoryBean();
try {
JmxControlConfig configuration = ConfigProvider.getConfig(JmxControlConfig.class);
int port = configuration.getPort();
factoryBean.setServiceUrl("service:jmx:rmi:///jndi/rmi://localhost:" + String.valueOf(port) + "/jmxrmi");
String username = configuration.getUsername();
if (StringUtils.isNotEmpty(username)) {
Properties properties = new Properties();
properties.put("jmx.remote.credentials", new String[] {username, configuration.getPassword()});
factoryBean.setEnvironment(properties);
}
factoryBean.afterPropertiesSet();
return factoryBean.getObject();
}
catch (MalformedURLException e) {
throw new RuntimeException(e);
}
catch (IOException e) {
throw new RuntimeException(e);
}
}*/
public static class DomainComparator implements Comparator {
public int compare(Object o1, Object o2) {
ManagedBeanDomain mbd1 = (ManagedBeanDomain) o1;
ManagedBeanDomain mbd2 = (ManagedBeanDomain) o2;
return mbd1 != null && mbd1.getName() != null
? mbd1.getName().compareTo(mbd2.getName())
: (mbd2 != null && mbd2.getName() != null ? 1 : 0);
}
}
public static class MBeanComparator implements Comparator {
public int compare(Object o1, Object o2) {
ManagedBeanInfo mbd1 = (ManagedBeanInfo) o1;
ManagedBeanInfo mbd2 = (ManagedBeanInfo) o2;
return mbd1 != null && mbd1.getPropertyList() != null
? mbd1.getPropertyList().compareTo(mbd2.getPropertyList())
: (mbd2 != null && mbd2.getPropertyList() != null ? 1 : 0);
}
}
public static class AttributeComparator implements Comparator {
public int compare(Object o1, Object o2) {
ManagedBeanAttribute mbd1 = (ManagedBeanAttribute) o1;
ManagedBeanAttribute mbd2 = (ManagedBeanAttribute) o2;
return mbd1 != null && mbd1.getName() != null
? mbd1.getName().compareTo(mbd2.getName())
: (mbd2 != null && mbd2.getName() != null ? 1 : 0);
}
}
/* Sorts operations alphabetically by name */
private class OperationComparator implements Comparator<ManagedBeanOperation> {
@Override
public int compare(ManagedBeanOperation o1, ManagedBeanOperation o2) {
return o1 != null && o1.getName() != null
? o1.getName().compareTo(o2.getName())
: (o2 != null && o2.getName() != null ? 1 : 0);
}
}
}

View File

@ -127,6 +127,8 @@
value-ref="cuba_ObjectsCacheManagerMBean"/>
<entry key="${cuba.webContextName}.cuba:type=PasswordEncryptionSupport"
value-ref="cuba_PasswordEncryptionSupportMBean"/>
<entry key="${cuba.webContextName}.cuba:type=JmxNodeIdentifier"
value-ref="cuba_JmxNodeIdentifierMBean"/>
</map>
</property>
</bean>

Binary file not shown.

After

Width:  |  Height:  |  Size: 500 B

View File

@ -50,7 +50,6 @@
<entry key="cuba_ConfigStorageService" value="com.haulmont.cuba.core.app.ConfigStorageService"/>
<entry key="cuba_PersistenceManagerService" value="com.haulmont.cuba.core.app.PersistenceManagerService"/>
<entry key="cuba_LockService" value="com.haulmont.cuba.core.app.LockService"/>
<entry key="cuba_JmxControlService" value="com.haulmont.cuba.jmxcontrol.app.JmxControlService"/>
<entry key="cuba_UserSessionService" value="com.haulmont.cuba.security.app.UserSessionService"/>
<entry key="cuba_FoldersService" value="com.haulmont.cuba.core.app.FoldersService"/>
<entry key="cuba_EmailService" value="com.haulmont.cuba.core.app.EmailService"/>

View File

@ -0,0 +1,101 @@
/*
* Copyright (c) 2012 Haulmont Technology Ltd. All Rights Reserved.
* Haulmont Technology proprietary and confidential.
* Use is subject to license terms.
*/
package com.haulmont.cuba.core.entity;
import com.haulmont.chile.core.annotations.NamePattern;
import com.haulmont.cuba.core.entity.annotation.SystemLevel;
import org.apache.commons.lang.StringUtils;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
* @author artamonov
* @version $Id$
*/
@Entity(name = "sys$JmxInstance")
@Table(name = "SYS_JMX_INSTANCE")
@NamePattern("#getCaption|clusterNodeName,address,description")
@SystemLevel
public class JmxInstance extends StandardEntity {
@Column(name = "CLUSTER_NODE_NAME", length = 255, nullable = false)
protected String clusterNodeName;
@Column(name = "DESCRIPTION", length = 500)
protected String description;
@Column(name = "ADDRESS", length = 500, nullable = false)
protected String address;
@Column(name = "LOGIN", length = LOGIN_FIELD_LEN, nullable = false)
protected String login;
@Column(name = "PASSWORD", length = 255)
protected String password;
public JmxInstance() {
}
public JmxInstance(String clusterNodeName) {
this.clusterNodeName = clusterNodeName;
}
public String getClusterNodeName() {
return clusterNodeName;
}
public void setClusterNodeName(String clusterNodeName) {
this.clusterNodeName = clusterNodeName;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getLogin() {
return login;
}
public void setLogin(String login) {
this.login = login;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getCaption() {
StringBuilder sb = new StringBuilder();
if (StringUtils.isNotEmpty(description))
sb.append(description);
else
sb.append(clusterNodeName);
if (StringUtils.isNotEmpty(address))
sb.append(" (").append(address).append(")");
return sb.toString();
}
}

View File

@ -82,7 +82,12 @@ ScheduledExecution.startTime = Start time
ScheduledExecution.finishTime = Finish time
ScheduledExecution.result = Result
ScheduledTaskDefinedBy.BEAN=Bean
ScheduledTaskDefinedBy.CLASS=Class
ScheduledTaskDefinedBy.SCRIPT=Script
JmxInstance.clusterNodeName=Cluster node name
JmxInstance.description=Description
JmxInstance.address=JMX Address
JmxInstance.login=Login
JmxInstance.password=Password

View File

@ -81,3 +81,9 @@ ScheduledExecution.result = Result
ScheduledTaskDefinedBy.BEAN=Bean
ScheduledTaskDefinedBy.CLASS=Класс
ScheduledTaskDefinedBy.SCRIPT=Скрипт
JmxInstance.clusterNodeName=Cluster node name
JmxInstance.description=Description
JmxInstance.address=JMX Address
JmxInstance.login=Login
JmxInstance.password=Password

View File

@ -0,0 +1,18 @@
/*
* Copyright (c) 2012 Haulmont Technology Ltd. All Rights Reserved.
* Haulmont Technology proprietary and confidential.
* Use is subject to license terms.
*/
package com.haulmont.cuba.core.global;
/**
* @author artamonov
* @version $Id$
*/
public interface ClusterNodeIdentifier {
String NAME = "cuba_ClusterNodeIdentifier";
String getClusterNodeName();
}

View File

@ -0,0 +1,28 @@
/*
* Copyright (c) 2012 Haulmont Technology Ltd. All Rights Reserved.
* Haulmont Technology proprietary and confidential.
* Use is subject to license terms.
*/
package com.haulmont.cuba.core.jmx;
import com.haulmont.cuba.core.global.ClusterNodeIdentifier;
import javax.annotation.ManagedBean;
import javax.inject.Inject;
/**
* @author artamonov
* @version $Id$
*/
@ManagedBean("cuba_JmxNodeIdentifierMBean")
public class JmxNodeIdentifier implements JmxNodeIdentifierMBean {
@Inject
private ClusterNodeIdentifier clusterNodeIdentifier;
@Override
public String getClusterNodeName() {
return clusterNodeIdentifier.getClusterNodeName();
}
}

View File

@ -0,0 +1,16 @@
/*
* Copyright (c) 2012 Haulmont Technology Ltd. All Rights Reserved.
* Haulmont Technology proprietary and confidential.
* Use is subject to license terms.
*/
package com.haulmont.cuba.core.jmx;
/**
* @author artamonov
* @version $Id$
*/
public interface JmxNodeIdentifierMBean {
String getClusterNodeName();
}

View File

@ -0,0 +1,27 @@
/*
* Copyright (c) 2012 Haulmont Technology Ltd. All Rights Reserved.
* Haulmont Technology proprietary and confidential.
* Use is subject to license terms.
*/
package com.haulmont.cuba.core.sys;
import com.haulmont.cuba.core.global.AppBeans;
import com.haulmont.cuba.core.global.ClusterNodeIdentifier;
import com.haulmont.cuba.core.global.Configuration;
import com.haulmont.cuba.core.global.GlobalConfig;
import javax.annotation.ManagedBean;
/**
* @author artamonov
* @version $Id$
*/
@ManagedBean(ClusterNodeIdentifier.NAME)
public class ClusterNodeIdentifierImpl implements ClusterNodeIdentifier {
@Override
public String getClusterNodeName() {
GlobalConfig globalConfig = AppBeans.get(Configuration.class).getConfig(GlobalConfig.class);
return globalConfig.getWebHostName() + ":" + globalConfig.getWebPort();
}
}

View File

@ -1,33 +0,0 @@
/*
* Copyright (c) 2008-2010 Haulmont Technology Ltd. All Rights Reserved.
* Haulmont Technology proprietary and confidential.
* Use is subject to license terms.
*
* Author: Alexander Budarov
* Created: 17.08.2010 10:40:21
* $Id$
*/
package com.haulmont.cuba.jmxcontrol.app;
import com.haulmont.cuba.jmxcontrol.entity.ManagedBeanAttribute;
import com.haulmont.cuba.jmxcontrol.entity.ManagedBeanDomain;
import com.haulmont.cuba.jmxcontrol.entity.ManagedBeanInfo;
import com.haulmont.cuba.jmxcontrol.entity.ManagedBeanOperation;
import java.util.List;
public interface JmxControlService {
String NAME = "cuba_JmxControlService";
public List<ManagedBeanInfo> getManagedBeans();
public ManagedBeanInfo loadAttributes(ManagedBeanInfo info);
public ManagedBeanAttribute loadAttributeValue(ManagedBeanAttribute attr);
public void saveAttributeValue(ManagedBeanAttribute attr);
public Object invokeOperation(ManagedBeanOperation operation, Object[] parameterValues);
public List<ManagedBeanDomain> getDomains();
}

View File

@ -13,6 +13,7 @@ package com.haulmont.cuba.jmxcontrol.entity;
import com.haulmont.chile.core.annotations.MetaClass;
import com.haulmont.chile.core.annotations.MetaProperty;
import com.haulmont.cuba.core.entity.AbstractNotPersistentEntity;
import com.haulmont.cuba.core.entity.JmxInstance;
import java.util.List;
@ -35,6 +36,8 @@ public class ManagedBeanInfo extends AbstractNotPersistentEntity {
@MetaProperty
private String propertyList;
private JmxInstance jmxInstance;
private List<ManagedBeanAttribute> attributes;
private List<ManagedBeanOperation> operations;
@ -94,4 +97,12 @@ public class ManagedBeanInfo extends AbstractNotPersistentEntity {
public void setAttributes(List<ManagedBeanAttribute> attributes) {
this.attributes = attributes;
}
public JmxInstance getJmxInstance() {
return jmxInstance;
}
public void setJmxInstance(JmxInstance jmxInstance) {
this.jmxInstance = jmxInstance;
}
}

View File

@ -16,14 +16,6 @@ import com.haulmont.cuba.core.global.SupportedByClient;
public class JmxControlException extends RuntimeException {
private static final long serialVersionUID = -7683677050143447151L;
public JmxControlException(String message) {
super(message);
}
public JmxControlException(String message, Throwable cause) {
super(message, cause);
}
public JmxControlException(Throwable cause) {
super(cause);
}

View File

@ -53,6 +53,8 @@
<class>com.haulmont.cuba.core.entity.CategoryAttribute</class>
<class>com.haulmont.cuba.core.entity.CategoryAttributeValue</class>
<class>com.haulmont.cuba.core.entity.JmxInstance</class>
<properties>
<property name="openjpa.Log" value="log4j"/>

View File

@ -167,6 +167,7 @@ public interface PickerField extends Field, Component.ActionsHolder {
if (!items.isEmpty()) {
final Object item = items.iterator().next();
pickerField.setValue(item);
afterSelect(items);
}
}
},
@ -176,6 +177,9 @@ public interface PickerField extends Field, Component.ActionsHolder {
}
}
public void afterSelect(Collection items) {
}
@Override
public KeyCombination getKeyCombination() {
ClientConfig clientConfig = AppBeans.get(Configuration.class).getConfig(ClientConfig.class);

View File

@ -35,7 +35,11 @@ public class ItemTrackingAction extends AbstractAction implements CollectionData
@Override
public void itemChanged(Datasource ds, Entity prevItem, Entity item) {
super.setEnabled(enabledFlag && item != null);
super.setEnabled(enabledFlag && isApplicableTo(ds.getState(), item));
}
public boolean isApplicableTo(Datasource.State state, Entity item) {
return Datasource.State.VALID.equals(state) && item != null;
}
@Override
@ -51,7 +55,7 @@ public class ItemTrackingAction extends AbstractAction implements CollectionData
@Override
public void stateChanged(Datasource ds, Datasource.State prevState, Datasource.State state) {
super.setEnabled(Datasource.State.VALID.equals(state) && ds.getItem() != null);
super.setEnabled(isApplicableTo(ds.getState(), ds.getItem()));
}
@Override

View File

@ -30,6 +30,7 @@ import java.util.*;
public abstract class AbstractTreeDatasource<T extends Entity<K>, K>
extends CollectionDatasourceImpl<T, K>
implements HierarchicalDatasource<T, K> {
protected Tree<T> tree;
protected Map<K, Node<T>> nodes;
@ -46,7 +47,7 @@ public abstract class AbstractTreeDatasource<T extends Entity<K>, K>
this.tree = loadTree(params);
Map<K, Node<T>> targetNodes = new HashMap<K, Node<T>>();
Map<K, Node<T>> targetNodes = new HashMap<>();
clear();
if (tree != null) {
@ -139,4 +140,4 @@ public abstract class AbstractTreeDatasource<T extends Entity<K>, K>
public boolean canHasChildren(K itemId) {
return true;
}
}
}

View File

@ -1,23 +1,22 @@
package com.haulmont.cuba.gui.data.impl;
import com.haulmont.cuba.core.entity.Entity;
import com.haulmont.cuba.gui.data.TreeTableDatasource;
import com.haulmont.cuba.gui.data.DsContext;
import com.haulmont.cuba.gui.data.DataService;
import com.haulmont.bali.datastruct.Node;
import com.haulmont.chile.core.model.MetaClass;
import com.haulmont.chile.core.model.MetaPropertyPath;
import com.haulmont.bali.datastruct.Node;
import com.haulmont.cuba.core.entity.Entity;
import com.haulmont.cuba.gui.data.DataService;
import com.haulmont.cuba.gui.data.DsContext;
import com.haulmont.cuba.gui.data.TreeTableDatasource;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* User: Nikolay Gorodnov
* Date: 03.06.2009
* @author gorodnov
* @version $Id$
*/
public abstract class AbstractTreeTableDatasource<T extends Entity<K>, K>
extends AbstractTreeDatasource<T, K>
@ -32,6 +31,7 @@ public abstract class AbstractTreeTableDatasource<T extends Entity<K>, K>
entityComparator = new EntityComparator<T>(propertyPath, asc);
}
@Override
public int compare(Node<T> n1, Node<T> n2) {
T e1 = n1.getData();
T e2 = n2.getData();
@ -82,4 +82,4 @@ public abstract class AbstractTreeTableDatasource<T extends Entity<K>, K>
return new TreeTableNodeComparator<T>(propertyPath, asc);
}
}
}

View File

@ -36,7 +36,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
* @author artamonov
* @version $Id$
*/
@ManagedBean("cuba_FileUploading")
@ManagedBean(FileUploadingAPI.NAME)
public class FileUploading implements FileUploadingAPI, FileUploadingMBean {
protected Map<UUID, File> tempFiles = new ConcurrentHashMap<>();

View File

@ -63,7 +63,6 @@
<entry key="cuba_ConfigStorageService" value="com.haulmont.cuba.core.app.ConfigStorageService"/>
<entry key="cuba_PersistenceManagerService" value="com.haulmont.cuba.core.app.PersistenceManagerService"/>
<entry key="cuba_LockService" value="com.haulmont.cuba.core.app.LockService"/>
<entry key="cuba_JmxControlService" value="com.haulmont.cuba.jmxcontrol.app.JmxControlService"/>
<entry key="cuba_UserSessionService" value="com.haulmont.cuba.security.app.UserSessionService"/>
<entry key="cuba_FoldersService" value="com.haulmont.cuba.core.app.FoldersService"/>
<entry key="cuba_EmailService" value="com.haulmont.cuba.core.app.EmailService"/>

Binary file not shown.

After

Width:  |  Height:  |  Size: 500 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 500 B

View File

@ -6,20 +6,24 @@
package com.haulmont.cuba.web.app.ui.jmxcontrol.browse;
import com.haulmont.cuba.core.entity.Entity;
import com.haulmont.cuba.core.entity.JmxInstance;
import com.haulmont.cuba.gui.WindowManager;
import com.haulmont.cuba.gui.components.*;
import com.haulmont.cuba.gui.components.actions.ItemTrackingAction;
import com.haulmont.cuba.gui.components.actions.RefreshAction;
import com.haulmont.cuba.gui.data.CollectionDatasource;
import com.haulmont.cuba.gui.data.Datasource;
import com.haulmont.cuba.gui.data.ValueListener;
import com.haulmont.cuba.jmxcontrol.entity.ManagedBeanInfo;
import com.haulmont.cuba.web.app.ui.jmxcontrol.ds.ManagedBeanInfoDatasource;
import com.haulmont.cuba.web.app.ui.jmxinstance.edit.JmxInstanceEditor;
import com.haulmont.cuba.web.jmx.JmxControlAPI;
import org.apache.commons.lang.StringUtils;
import javax.annotation.Resource;
import javax.inject.Inject;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.*;
/**
* @author budarov
@ -28,13 +32,25 @@ import java.util.UUID;
public class MbeansDisplayWindow extends AbstractWindow {
@Inject
private TextField objectNameField;
protected ManagedBeanInfoDatasource mbeanDs;
@Inject
private CollectionDatasource<ManagedBeanInfo, UUID> mbeanDs;
protected CollectionDatasource<JmxInstance, UUID> jmxInstancesDs;
@Inject
protected TextField objectNameField;
@Inject
protected TextField localJmxField;
@Resource(name = "mbeans")
private TreeTable mbeansTable;
protected TreeTable mbeansTable;
@Inject
protected LookupPickerField jmxConnectionField;
@Inject
protected JmxControlAPI jmxControlAPI;
@Override
public void init(Map<String, Object> params) {
@ -44,7 +60,7 @@ public class MbeansDisplayWindow extends AbstractWindow {
mbeansTable.addAction(new RefreshAction(mbeansTable));
Action inspectAction = new AbstractAction("inspect") {
Action inspectAction = new ItemTrackingAction("inspect") {
@Override
public void actionPerform(Component component) {
Set<ManagedBeanInfo> selected = mbeansTable.getSelected();
@ -64,6 +80,12 @@ public class MbeansDisplayWindow extends AbstractWindow {
}
}
@Override
public boolean isApplicableTo(Datasource.State state, Entity item) {
return super.isApplicableTo(state, item) &&
((ManagedBeanInfo)item).getObjectName() != null;
}
@Override
public String getCaption() {
return getMessage("action.inspect");
@ -71,10 +93,58 @@ public class MbeansDisplayWindow extends AbstractWindow {
};
mbeansTable.addAction(inspectAction);
mbeansTable.setItemClickAction(inspectAction);
mbeansTable.getDatasource().refresh();
JmxInstance localJmxInstance = jmxControlAPI.getLocalInstance();
jmxInstancesDs.refresh();
jmxConnectionField.setValue(localJmxInstance);
jmxConnectionField.setRequired(true);
jmxConnectionField.addListener(new ValueListener() {
@Override
public void valueChanged(Object source, String property, Object prevValue, Object value) {
mbeanDs.setJmxInstance(jmxConnectionField.<JmxInstance>getValue());
mbeanDs.refresh();
}
});
for (Action action : new LinkedList<>(jmxConnectionField.getActions())) {
jmxConnectionField.removeAction(action);
}
jmxConnectionField.addAction(new PickerField.LookupAction(jmxConnectionField) {
@Override
public void afterSelect(Collection items) {
jmxInstancesDs.refresh();
}
});
jmxConnectionField.addAction(new AbstractAction("add") {
@Override
public void actionPerform(Component component) {
final JmxInstanceEditor instanceEditor = openEditor("sys$JmxInstance.edit", new JmxInstance(), WindowManager.OpenType.DIALOG);
instanceEditor.addListener(new CloseListener() {
@Override
public void windowClosed(String actionId) {
if (COMMIT_ACTION_ID.equals(actionId)) {
jmxInstancesDs.refresh();
jmxConnectionField.setValue(instanceEditor.getItem());
}
}
});
}
@Override
public String getIcon() {
return "icons/plus-btn.png";
}
});
mbeanDs.setJmxInstance(localJmxInstance);
mbeanDs.refresh();
localJmxField.setValue(jmxControlAPI.getLocalNodeName());
localJmxField.setEditable(false);
}
private class ObjectNameFieldListener implements ValueListener {

View File

@ -9,6 +9,10 @@
</metadataContext>
<dsContext>
<collectionDatasource id="jmxInstancesDs" class="com.haulmont.cuba.core.entity.JmxInstance" view="_local">
<datasourceClass>com.haulmont.cuba.web.app.ui.jmxcontrol.ds.JmxInstancesDatasource</datasourceClass>
</collectionDatasource>
<collectionDatasource
id="mbeanDs"
class="com.haulmont.cuba.jmxcontrol.entity.ManagedBeanInfo"
@ -19,11 +23,28 @@
<layout expand="mbeans" spacing="true">
<groupBox width="100%">
<hbox width="-1" expandable="false" spacing="true">
<label value="msg://searchByObjectName" width="-1"/>
<textField id="objectNameField" width="400px"/>
</hbox>
<grid spacing="true">
<columns>
<column/>
<column/>
</columns>
<rows>
<row>
<label value="msg://localJmxNode"/>
<textField id="localJmxField" width="400px" datatype="string"/>
</row>
<row>
<label value="msg://targetJmxNode"/>
<lookupPickerField id="jmxConnectionField" optionsDatasource="jmxInstancesDs" width="400px"/>
</row>
<row>
<label value="msg://searchByObjectName"/>
<textField id="objectNameField" width="400px"/>
</row>
</rows>
</grid>
</groupBox>
<treeTable id="mbeans" editable="false" width="100%">
<buttonsPanel>
<button action="mbeans.refresh" icon="icons/refresh.png"/>

View File

@ -0,0 +1,52 @@
/*
* Copyright (c) 2012 Haulmont Technology Ltd. All Rights Reserved.
* Haulmont Technology proprietary and confidential.
* Use is subject to license terms.
*/
package com.haulmont.cuba.web.app.ui.jmxcontrol.ds;
import com.haulmont.chile.core.model.MetaClass;
import com.haulmont.cuba.core.entity.JmxInstance;
import com.haulmont.cuba.core.global.AppBeans;
import com.haulmont.cuba.gui.data.DataService;
import com.haulmont.cuba.gui.data.DsContext;
import com.haulmont.cuba.gui.data.impl.CollectionDatasourceImpl;
import com.haulmont.cuba.gui.logging.UIPerformanceLogger;
import com.haulmont.cuba.web.jmx.JmxControlAPI;
import org.apache.log4j.Logger;
import org.perf4j.StopWatch;
import org.perf4j.log4j.Log4JStopWatch;
import java.util.Map;
import java.util.UUID;
/**
* @author artamonov
* @version $Id$
*/
public class JmxInstancesDatasource extends CollectionDatasourceImpl<JmxInstance, UUID> {
private JmxControlAPI jmxControlAPI = AppBeans.get(JmxControlAPI.NAME);
public JmxInstancesDatasource(DsContext context, DataService dataservice, String id,
MetaClass metaClass, String viewName) {
super(context, dataservice, id, metaClass, viewName);
}
@Override
protected void loadData(Map<String, Object> params) {
String tag = getLoggingTag("CDS");
StopWatch sw = new Log4JStopWatch(tag, Logger.getLogger(UIPerformanceLogger.class));
detachListener(data.values());
data.clear();
for (JmxInstance jmxInstance : jmxControlAPI.getInstances()) {
data.put(jmxInstance.getId(), jmxInstance);
attachListener(jmxInstance);
}
sw.stop();
}
}

View File

@ -8,15 +8,14 @@ package com.haulmont.cuba.web.app.ui.jmxcontrol.ds;
import com.haulmont.chile.core.model.MetaClass;
import com.haulmont.cuba.core.global.AppBeans;
import com.haulmont.cuba.core.global.View;
import com.haulmont.cuba.gui.data.DataService;
import com.haulmont.cuba.gui.data.Datasource;
import com.haulmont.cuba.gui.data.DsContext;
import com.haulmont.cuba.gui.data.impl.CollectionDatasourceImpl;
import com.haulmont.cuba.jmxcontrol.app.JmxControlService;
import com.haulmont.cuba.jmxcontrol.entity.ManagedBeanAttribute;
import com.haulmont.cuba.jmxcontrol.entity.ManagedBeanInfo;
import com.haulmont.cuba.jmxcontrol.global.JmxControlException;
import com.haulmont.cuba.web.jmx.JmxControlAPI;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ -31,15 +30,10 @@ public class ManagedBeanAttributeDatasource extends CollectionDatasourceImpl<Man
private Log log = LogFactory.getLog(getClass());
public ManagedBeanAttributeDatasource(DsContext context, DataService dataservice, String id, MetaClass metaClass, String viewName, boolean softDeletion) {
super(context, dataservice, id, metaClass, viewName, softDeletion);
}
private JmxControlAPI jmxControlAPI = AppBeans.get(JmxControlAPI.NAME);
public ManagedBeanAttributeDatasource(DsContext context, DataService dataservice, String id, MetaClass metaClass, View view) {
super(context, dataservice, id, metaClass, view);
}
public ManagedBeanAttributeDatasource(DsContext context, DataService dataservice, String id, MetaClass metaClass, String viewName) {
public ManagedBeanAttributeDatasource(DsContext context, DataService dataservice, String id,
MetaClass metaClass, String viewName) {
super(context, dataservice, id, metaClass, viewName);
}
@ -51,16 +45,14 @@ public class ManagedBeanAttributeDatasource extends CollectionDatasourceImpl<Man
ManagedBeanInfo mbean = (ManagedBeanInfo) mbeanDs.getItem();
if (mbean != null) {
JmxControlService jcs = AppBeans.get(JmxControlService.NAME);
try {
mbean = jcs.loadAttributes(mbean);
}
catch (JmxControlException e) {
mbean = jmxControlAPI.loadAttributes(mbean);
} catch (JmxControlException e) {
log.error(e);
}
if (mbean.getAttributes() != null) {
for (ManagedBeanAttribute attr: mbean.getAttributes()) {
for (ManagedBeanAttribute attr : mbean.getAttributes()) {
data.put(attr.getId(), attr);
}
}

View File

@ -9,13 +9,18 @@ package com.haulmont.cuba.web.app.ui.jmxcontrol.ds;
import com.haulmont.bali.datastruct.Node;
import com.haulmont.bali.datastruct.Tree;
import com.haulmont.chile.core.model.MetaClass;
import com.haulmont.cuba.core.entity.JmxInstance;
import com.haulmont.cuba.core.global.AppBeans;
import com.haulmont.cuba.gui.data.DataService;
import com.haulmont.cuba.gui.data.DsContext;
import com.haulmont.cuba.gui.data.impl.AbstractTreeTableDatasource;
import com.haulmont.cuba.jmxcontrol.app.JmxControlService;
import com.haulmont.cuba.gui.logging.UIPerformanceLogger;
import com.haulmont.cuba.jmxcontrol.entity.ManagedBeanDomain;
import com.haulmont.cuba.jmxcontrol.entity.ManagedBeanInfo;
import com.haulmont.cuba.web.jmx.JmxControlAPI;
import org.apache.log4j.Logger;
import org.perf4j.StopWatch;
import org.perf4j.log4j.Log4JStopWatch;
import java.util.*;
@ -25,50 +30,59 @@ import java.util.*;
*/
public class ManagedBeanInfoDatasource extends AbstractTreeTableDatasource<ManagedBeanInfo, UUID> {
public ManagedBeanInfoDatasource(DsContext context, DataService dataservice, String id, MetaClass metaClass, String viewName) {
private JmxInstance jmxInstance = null;
private JmxControlAPI jmxControlAPI = AppBeans.get(JmxControlAPI.NAME);
public ManagedBeanInfoDatasource(DsContext context, DataService dataservice, String id,
MetaClass metaClass, String viewName) {
super(context, dataservice, id, metaClass, viewName);
}
@Override
protected Tree<ManagedBeanInfo> loadTree(Map<String, Object> params) {
Map<String, Node<ManagedBeanInfo>> domainMap = new HashMap<>();
JmxControlService srv = AppBeans.get(JmxControlService.NAME);
List<ManagedBeanDomain> domains = srv.getDomains();
String tag = getLoggingTag("TDS");
StopWatch sw = new Log4JStopWatch(tag, Logger.getLogger(UIPerformanceLogger.class));
List<Node<ManagedBeanInfo>> nodes = new ArrayList<>();
for (ManagedBeanDomain mbd : domains) {
ManagedBeanInfo dummy = new ManagedBeanInfo();
dummy.setDomain(mbd.getName());
if (jmxInstance != null) {
List<ManagedBeanDomain> domains = jmxControlAPI.getDomains(jmxInstance);
Node<ManagedBeanInfo> node = new Node<>(dummy);
domainMap.put(mbd.getName(), node);
nodes.add(node);
}
Map<String, Node<ManagedBeanInfo>> domainMap = new HashMap<>();
List<ManagedBeanInfo> list = loadManagedBeans(srv, params);
for (ManagedBeanInfo mbi : list) {
if (mbi != null) {
if (domainMap.containsKey(mbi.getDomain())) {
domainMap.get(mbi.getDomain()).addChild(new Node<>(mbi));
for (ManagedBeanDomain mbd : domains) {
ManagedBeanInfo dummy = new ManagedBeanInfo();
dummy.setDomain(mbd.getName());
Node<ManagedBeanInfo> node = new Node<>(dummy);
domainMap.put(mbd.getName(), node);
nodes.add(node);
}
List<ManagedBeanInfo> list = loadManagedBeans(params);
for (ManagedBeanInfo mbi : list) {
if (mbi != null) {
if (domainMap.containsKey(mbi.getDomain())) {
domainMap.get(mbi.getDomain()).addChild(new Node<>(mbi));
}
}
}
// remove root nodes that might have left without children after filtering
for (Node<ManagedBeanInfo> rootNode : new ArrayList<>(nodes)) {
if (rootNode.getChildren().isEmpty()) {
nodes.remove(rootNode);
}
}
}
// remove root nodes that might have left without children after filtering
for (Node<ManagedBeanInfo> rootNode : new ArrayList<>(nodes)) {
if (rootNode.getChildren().isEmpty()) {
nodes.remove(rootNode);
}
}
sw.stop();
return new Tree<>(nodes);
}
private List<ManagedBeanInfo> loadManagedBeans(JmxControlService srv, Map<String, Object> params) {
List<ManagedBeanInfo> managedBeans = srv.getManagedBeans();
private List<ManagedBeanInfo> loadManagedBeans(Map<String, Object> params) {
List<ManagedBeanInfo> managedBeans = jmxControlAPI.getManagedBeans(jmxInstance);
List<ManagedBeanInfo> res = new ArrayList<>();
// filter by object name
@ -97,4 +111,12 @@ public class ManagedBeanInfoDatasource extends AbstractTreeTableDatasource<Manag
ManagedBeanInfo mbi = (ManagedBeanInfo) data.get(itemId);
return mbi.getDomain();
}
public JmxInstance getJmxInstance() {
return jmxInstance;
}
public void setJmxInstance(JmxInstance jmxInstance) {
this.jmxInstance = jmxInstance;
}
}

View File

@ -11,14 +11,14 @@ import com.haulmont.cuba.gui.WindowManager;
import com.haulmont.cuba.gui.components.*;
import com.haulmont.cuba.gui.data.CollectionDatasource;
import com.haulmont.cuba.gui.data.impl.CollectionDsListenerAdapter;
import com.haulmont.cuba.jmxcontrol.app.JmxControlService;
import com.haulmont.cuba.jmxcontrol.entity.ManagedBeanAttribute;
import com.haulmont.cuba.jmxcontrol.entity.ManagedBeanInfo;
import com.haulmont.cuba.jmxcontrol.entity.ManagedBeanOperation;
import com.haulmont.cuba.jmxcontrol.entity.ManagedBeanOperationParameter;
import com.haulmont.cuba.jmxcontrol.util.AttributeHelper;
import com.haulmont.cuba.web.gui.components.*;
import com.haulmont.cuba.web.app.ui.jmxcontrol.util.AttributeEditor;
import com.haulmont.cuba.web.gui.components.*;
import com.haulmont.cuba.web.jmx.JmxControlAPI;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ -40,7 +40,7 @@ public class MbeanInspectWindow extends AbstractEditor {
protected Action editAttributeAction;
@Inject
protected JmxControlService jmxService;
protected JmxControlAPI jmxControlAPI;
@Inject
protected BoxLayout operations;
@ -94,7 +94,7 @@ public class MbeanInspectWindow extends AbstractEditor {
}
private void reloadAttribute(ManagedBeanAttribute attribute) {
attribute = jmxService.loadAttributeValue(attribute);
attribute = jmxControlAPI.loadAttributeValue(attribute);
attrTable.getDatasource().updateItem(attribute);
}
@ -201,7 +201,7 @@ public class MbeanInspectWindow extends AbstractEditor {
}
try {
Object res = jmxService.invokeOperation(op, paramValues);
Object res = jmxControlAPI.invokeOperation(op, paramValues);
if (res != null) {
params.put("result", res);
}

View File

@ -10,9 +10,9 @@ import com.haulmont.cuba.core.entity.Entity;
import com.haulmont.cuba.gui.components.AbstractEditor;
import com.haulmont.cuba.gui.components.GridLayout;
import com.haulmont.cuba.gui.components.IFrame;
import com.haulmont.cuba.jmxcontrol.app.JmxControlService;
import com.haulmont.cuba.jmxcontrol.entity.ManagedBeanAttribute;
import com.haulmont.cuba.web.app.ui.jmxcontrol.util.AttributeEditor;
import com.haulmont.cuba.web.jmx.JmxControlAPI;
import org.apache.commons.lang.ObjectUtils;
import javax.inject.Inject;
@ -26,7 +26,7 @@ public class AttributeEditWindow extends AbstractEditor {
private AttributeEditor valueHolder;
@Inject
protected JmxControlService jmxControlService;
protected JmxControlAPI jmxControlAPI;
@Override
public void setItem(Entity item) {
@ -60,7 +60,7 @@ public class AttributeEditWindow extends AbstractEditor {
if (newValue != null) {
if (!ObjectUtils.equals(mba.getValue(), newValue)) {
mba.setValue(newValue);
jmxControlService.saveAttributeValue(mba);
jmxControlAPI.saveAttributeValue(mba);
}
return true;
}

View File

@ -45,3 +45,5 @@ close = Close
refresh = Refresh
searchByObjectName = Search by ObjectName:
targetJmxNode = JMX Connection:
localJmxNode = Local node:

View File

@ -44,3 +44,5 @@ close = Закрыть
refresh = Обновить
searchByObjectName = Поиск по ObjectName:
targetJmxNode = JMX Connection:
localJmxNode = Local node:

View File

@ -0,0 +1,36 @@
/*
* Copyright (c) 2012 Haulmont Technology Ltd. All Rights Reserved.
* Haulmont Technology proprietary and confidential.
* Use is subject to license terms.
*/
package com.haulmont.cuba.web.app.ui.jmxinstance.browse;
import com.haulmont.cuba.gui.WindowManager;
import com.haulmont.cuba.gui.components.AbstractLookup;
import com.haulmont.cuba.gui.components.actions.CreateAction;
import com.haulmont.cuba.gui.components.actions.EditAction;
import javax.inject.Named;
import java.util.Map;
/**
* @author artamonov
* @version $Id$
*/
public class JmxInstanceBrowser extends AbstractLookup {
@Named("jmxInstancesTable.create")
protected CreateAction createInstanceAction;
@Named("jmxInstancesTable.edit")
protected EditAction editInstanceAction;
@Override
public void init(Map<String, Object> params) {
super.init(params);
createInstanceAction.setOpenType(WindowManager.OpenType.DIALOG);
editInstanceAction.setOpenType(WindowManager.OpenType.DIALOG);
}
}

View File

@ -0,0 +1,44 @@
<!--
~ Copyright (c) 2012 Haulmont Technology Ltd. All Rights Reserved.
~ Haulmont Technology proprietary and confidential.
~ Use is subject to license terms.
-->
<window xmlns="http://schemas.haulmont.com/cuba/4.0/window.xsd"
class="com.haulmont.cuba.web.app.ui.jmxinstance.browse.JmxInstanceBrowser"
messagesPack="com.haulmont.cuba.web.app.ui.jmxinstance"
lookupComponent="jmxInstancesTable"
caption="msg://browserCaption"
focusComponent="jmxInstancesTable">
<dsContext>
<collectionDatasource id="jmxInstancesDs" class="com.haulmont.cuba.core.entity.JmxInstance" view="_local">
<query><![CDATA[
select jmx from sys$JmxInstance jmx
]]>
</query>
</collectionDatasource>
</dsContext>
<layout expand="jmxInstancesTable" spacing="true">
<table id="jmxInstancesTable" width="100%">
<actions>
<action id="create"/>
<action id="edit"/>
<action id="remove"/>
</actions>
<buttonsPanel alwaysVisible="true">
<button action="jmxInstancesTable.create"/>
<button action="jmxInstancesTable.edit"/>
<button action="jmxInstancesTable.remove"/>
</buttonsPanel>
<rowsCount/>
<columns>
<column id="clusterNodeName"/>
<column id="description"/>
<column id="address"/>
<column id="login"/>
</columns>
<rows datasource="jmxInstancesDs"/>
</table>
</layout>
</window>

View File

@ -0,0 +1,75 @@
/*
* Copyright (c) 2012 Haulmont Technology Ltd. All Rights Reserved.
* Haulmont Technology proprietary and confidential.
* Use is subject to license terms.
*/
package com.haulmont.cuba.web.app.ui.jmxinstance.edit;
import com.haulmont.cuba.core.entity.JmxInstance;
import com.haulmont.cuba.gui.components.AbstractEditor;
import com.haulmont.cuba.gui.components.Component;
import com.haulmont.cuba.gui.components.FieldGroup;
import com.haulmont.cuba.gui.components.TextField;
import com.haulmont.cuba.gui.data.Datasource;
import com.haulmont.cuba.gui.xml.layout.ComponentsFactory;
import com.haulmont.cuba.web.jmx.JmxControlAPI;
import javax.inject.Inject;
import java.util.Map;
/**
* @author artamonov
* @version $Id$
*/
public class JmxInstanceEditor extends AbstractEditor<JmxInstance> {
@Inject
protected ComponentsFactory factory;
@Inject
protected FieldGroup jmxFieldGroup;
protected TextField passwordField;
@Inject
protected JmxControlAPI jmxControlAPI;
@Override
public void init(Map<String, Object> params) {
super.init(params);
jmxFieldGroup.addCustomField("password", new FieldGroup.CustomFieldGenerator() {
@Override
public Component generateField(Datasource datasource, String propertyId) {
passwordField = factory.createComponent(TextField.NAME);
passwordField.setRequired(true);
passwordField.setRequiredMessage(getMessage("passwordRequiredMsg"));
passwordField.setSecret(true);
return passwordField;
}
});
}
@Override
protected void postInit() {
super.postInit();
passwordField.setValue(getItem().getPassword());
}
@Override
protected boolean preCommit() {
getItem().setPassword(passwordField.<String>getValue());
// try to connect to instance and assign cluster node name
try {
String remoteNodeName = jmxControlAPI.getRemoteNodeName(getItem());
getItem().setClusterNodeName(remoteNodeName);
} catch (Exception e) {
showNotification(getMessage("unableToConnectToInterface"), NotificationType.WARNING);
return false;
}
return super.preCommit();
}
}

View File

@ -0,0 +1,28 @@
<!--
~ Copyright (c) 2012 Haulmont Technology Ltd. All Rights Reserved.
~ Haulmont Technology proprietary and confidential.
~ Use is subject to license terms.
-->
<window xmlns="http://schemas.haulmont.com/cuba/4.0/window.xsd"
class="com.haulmont.cuba.web.app.ui.jmxinstance.edit.JmxInstanceEditor"
messagesPack="com.haulmont.cuba.web.app.ui.jmxinstance"
datasource="jmxInstanceDs"
caption="msg://editorCaption">
<dsContext>
<datasource id="jmxInstanceDs" class="com.haulmont.cuba.core.entity.JmxInstance" view="_local"/>
</dsContext>
<layout expand="windowActions">
<fieldGroup id="jmxFieldGroup" datasource="jmxInstanceDs">
<column width="350px">
<field id="clusterNodeName" editable="false"/>
<field id="description"/>
<field id="address"/>
<field id="login"/>
<field id="password" custom="true"/>
</column>
</fieldGroup>
<iframe id="windowActions" screen="editWindowActions"/>
</layout>
</window>

View File

@ -0,0 +1,12 @@
#
# Copyright (c) 2012 Haulmont Technology Ltd. All Rights Reserved.
# Haulmont Technology proprietary and confidential.
# Use is subject to license terms.
#
browserCaption=JMX interfaces
editorCaption=JMX Connection
passwordRequiredMsg=Password isn't specified
unableToConnectToInterface=Unable to connect to specified JMX interface
doNotUseLocalAlias=Do not set "Local" to connection description

View File

@ -0,0 +1,12 @@
#
# Copyright (c) 2012 Haulmont Technology Ltd. All Rights Reserved.
# Haulmont Technology proprietary and confidential.
# Use is subject to license terms.
#
browserCaption=JMX interfaces
editorCaption=JMX Connection
passwordRequiredMsg=Заполните поле "Password"
unableToConnectToInterface=Невозможно подключиться к указанному JMX интерфейсу
doNotUseLocalAlias=Название "Local" зарезервировано

View File

@ -2,10 +2,6 @@
* Copyright (c) 2008 Haulmont Technology Ltd. All Rights Reserved.
* Haulmont Technology proprietary and confidential.
* Use is subject to license terms.
* Author: Dmitry Abramov
* Created: 05.03.2009 12:33:12
* $Id$
*/
package com.haulmont.cuba.web.gui.components;
@ -33,11 +29,15 @@ import org.apache.commons.lang.StringUtils;
import java.util.*;
/**
* @author abramov
* @version $Id$
*/
public class WebPickerField
extends
WebAbstractField<com.haulmont.cuba.web.toolkit.ui.PickerField>
WebAbstractField<com.haulmont.cuba.web.toolkit.ui.PickerField>
implements
PickerField, Component.Wrapper {
PickerField, Component.Wrapper {
protected CaptionMode captionMode = CaptionMode.ITEM;
protected String captionProperty;
@ -283,6 +283,8 @@ public class WebPickerField
actionHandler.addAction(action);
PickerButton pButton = new PickerButton();
pButton.setAction(action);
// no captions for picker buttons
pButton.<Button>getComponent().setCaption("");
component.addButton(pButton.<Button>getComponent());
// apply Editable after action owner is set
if (action instanceof StandardAction)
@ -368,4 +370,4 @@ public class WebPickerField
}
}
}
}
}

View File

@ -2,10 +2,6 @@
* Copyright (c) 2008 Haulmont Technology Ltd. All Rights Reserved.
* Haulmont Technology proprietary and confidential.
* Use is subject to license terms.
* Author: Dmitry Abramov
* Created: 06.04.2009 10:39:36
* $Id$
*/
package com.haulmont.cuba.web.gui.components;
@ -32,12 +28,16 @@ import com.vaadin.terminal.Resource;
import java.util.*;
/**
* @author abramov
* @version $Id$
*/
public class WebTreeTable
extends
WebAbstractTable<com.haulmont.cuba.web.toolkit.ui.TreeTable>
implements
TreeTable, Component.Wrapper
{
TreeTable, Component.Wrapper {
protected String hierarchyProperty;
public WebTreeTable() {
@ -59,39 +59,48 @@ public class WebTreeTable
component.setItemCaptionPropertyId(metaProperty);
}
@Override
public String getHierarchyProperty() {
return hierarchyProperty;
}
@Override
public void setDatasource(HierarchicalDatasource datasource) {
setDatasource((CollectionDatasource) datasource);
}
@Override
protected CollectionDsWrapper createContainerDatasource(
CollectionDatasource datasource, Collection<MetaPropertyPath> columns) {
return new TreeTableDsWrapper((HierarchicalDatasource) datasource);
}
@Override
public void expandAll() {
component.expandAll();
}
@Override
public void expand(Object itemId) {
component.setExpanded(itemId);
}
@Override
public void collapseAll() {
component.collapseAll();
}
@Override
public void collapse(Object itemId) {
component.setCollapsed(itemId);
}
@Override
public int getLevel(Object itemId) {
return component.getLevel(itemId);
}
@Override
public boolean isExpanded(Object itemId) {
return component.isExpanded(itemId);
}
@ -132,10 +141,12 @@ public class WebTreeTable
};
}
@Override
public boolean isCaption(Object itemId) {
return treeTableDatasource && ((TreeTableDatasource) datasource).isCaption(itemId);
}
@Override
public String getCaption(Object itemId) {
if (treeTableDatasource) {
return ((TreeTableDatasource) datasource).getCaption(itemId);
@ -143,10 +154,12 @@ public class WebTreeTable
return null;
}
@Override
public boolean setCaption(Object itemId, String caption) {
throw new UnsupportedOperationException();
}
@Override
public int getLevel(Object itemId) {
return getItemLevel(itemId);
}
@ -159,6 +172,7 @@ public class WebTreeTable
return getItemLevel(parentId) + 1;
}
@Override
public void sort(Object[] propertyId, boolean[] ascending) {
List<CollectionDatasource.Sortable.SortInfo> infos = new ArrayList<CollectionDatasource.Sortable.SortInfo>();
for (int i = 0; i < propertyId.length; i++) {
@ -174,42 +188,52 @@ public class WebTreeTable
((CollectionDatasource.Sortable) datasource).sort(infos.toArray(new CollectionDatasource.Sortable.SortInfo[infos.size()]));
}
@Override
public Collection getSortableContainerPropertyIds() {
return properties;
}
@Override
public Object nextItemId(Object itemId) {
return ((CollectionDatasource.Sortable) datasource).nextItemId(itemId);
}
@Override
public Object prevItemId(Object itemId) {
return ((CollectionDatasource.Sortable) datasource).prevItemId(itemId);
}
@Override
public Object firstItemId() {
return ((CollectionDatasource.Sortable) datasource).firstItemId();
}
@Override
public Object lastItemId() {
return ((CollectionDatasource.Sortable) datasource).lastItemId();
}
@Override
public boolean isFirstId(Object itemId) {
return ((CollectionDatasource.Sortable) datasource).isFirstId(itemId);
}
@Override
public boolean isLastId(Object itemId) {
return ((CollectionDatasource.Sortable) datasource).isLastId(itemId);
}
@Override
public Object addItemAfter(Object previousItemId) throws UnsupportedOperationException {
throw new UnsupportedOperationException();
}
@Override
public Item addItemAfter(Object previousItemId, Object newItemId) throws UnsupportedOperationException {
throw new UnsupportedOperationException();
}
@Override
public Collection getAggregationPropertyIds() {
if (aggregationProperties != null) {
return Collections.unmodifiableList(aggregationProperties);
@ -217,10 +241,12 @@ public class WebTreeTable
return Collections.emptyList();
}
@Override
public Type getContainerPropertyAggregation(Object propertyId) {
throw new UnsupportedOperationException();
}
@Override
public void addContainerPropertyAggregation(Object propertyId, Type type) {
if (aggregationProperties == null) {
aggregationProperties = new LinkedList<Object>();
@ -230,6 +256,7 @@ public class WebTreeTable
aggregationProperties.add(propertyId);
}
@Override
public void removeContainerPropertyAggregation(Object propertyId) {
if (aggregationProperties != null) {
aggregationProperties.remove(propertyId);
@ -239,6 +266,7 @@ public class WebTreeTable
}
}
@Override
public Map<Object, Object> aggregate(Context context) {
return __aggregate(this, context);
}
@ -271,4 +299,4 @@ public class WebTreeTable
paintSpecificContent(target);
}
}
}
}

View File

@ -0,0 +1,97 @@
/*
* Copyright (c) 2012 Haulmont Technology Ltd. All Rights Reserved.
* Haulmont Technology proprietary and confidential.
* Use is subject to license terms.
*/
package com.haulmont.cuba.web.jmx;
import com.haulmont.cuba.core.entity.JmxInstance;
import com.haulmont.cuba.jmxcontrol.entity.ManagedBeanAttribute;
import com.haulmont.cuba.jmxcontrol.entity.ManagedBeanDomain;
import com.haulmont.cuba.jmxcontrol.entity.ManagedBeanInfo;
import com.haulmont.cuba.jmxcontrol.entity.ManagedBeanOperation;
import java.util.List;
/**
* Interface to provide JMX control functionality for local and remote JMX interfaces
*
* @author artamonov
* @version $Id$
*/
public interface JmxControlAPI {
String NAME = "cuba_JmxControl";
/**
* @return the list with available JMX nodes in cluster
*/
List<JmxInstance> getInstances();
/**
* @return the local JMX node descriptor
*/
JmxInstance getLocalInstance();
/**
* @return the local cluster node name
*/
String getLocalNodeName();
/**
* @return the remote cluster node name
*/
String getRemoteNodeName(JmxInstance jmxInstance);
/**
* Loads the list of managed bean infos
*
* @param instance JMX node descriptor
* @return the list with managed beans
*/
List<ManagedBeanInfo> getManagedBeans(JmxInstance instance);
/**
* Loads attributes for managed bean descriptor
*
* @param instance JMX node descriptor
* @param info managed bean descriptor
* @return managed bean descriptor with attributes
*/
ManagedBeanInfo loadAttributes(ManagedBeanInfo info);
/**
* Loads attribute value for managed bean attribute
*
* @param instance JMX node descriptor
* @param attribute attribute descriptor
* @return attribute descriptor with value
*/
ManagedBeanAttribute loadAttributeValue(ManagedBeanAttribute attribute);
/**
* Saves attribute value to JMX node
*
* @param instance JMX node descriptor
* @param attribute attribute descriptor
*/
void saveAttributeValue(ManagedBeanAttribute attribute);
/**
* Invokes method of managed bean
*
* @param instance JMX node descriptor
* @param operation operation descriptor
* @param parameterValues array with parameter values
* @return invocation result
*/
Object invokeOperation(ManagedBeanOperation operation, Object[] parameterValues);
/**
* Loads list of managed bean domains
*
* @param instance JMX node descriptor
* @return the list of managed bean domains
*/
List<ManagedBeanDomain> getDomains(JmxInstance instance);
}

View File

@ -0,0 +1,431 @@
/*
* Copyright (c) 2012 Haulmont Technology Ltd. All Rights Reserved.
* Haulmont Technology proprietary and confidential.
* Use is subject to license terms.
*/
package com.haulmont.cuba.web.jmx.impl;
import com.haulmont.chile.core.model.utils.InstanceUtils;
import com.haulmont.cuba.core.app.DataService;
import com.haulmont.cuba.core.entity.JmxInstance;
import com.haulmont.cuba.core.global.ClusterNodeIdentifier;
import com.haulmont.cuba.core.global.LoadContext;
import com.haulmont.cuba.core.jmx.JmxNodeIdentifier;
import com.haulmont.cuba.jmxcontrol.entity.*;
import com.haulmont.cuba.jmxcontrol.global.JmxControlException;
import com.haulmont.cuba.web.jmx.JmxControlAPI;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.Predicate;
import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.jmx.support.MBeanServerConnectionFactoryBean;
import javax.annotation.ManagedBean;
import javax.inject.Inject;
import javax.management.*;
import java.io.IOException;
import java.io.Serializable;
import java.lang.management.ManagementFactory;
import java.lang.reflect.Proxy;
import java.util.*;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* @author artamonov
* @version $Id$
*/
@ManagedBean(JmxControlAPI.NAME)
public class JmxControl implements JmxControlAPI {
private static final String CLUSTER_NODE_NAME_ATTRIBUTE = "ClusterNodeName";
private final JmxInstance LOCAL_JMX_INSTANCE = new JmxInstance("Local");
private final Log log = LogFactory.getLog(getClass());
@Inject
private DataService dataService;
@Inject
private ClusterNodeIdentifier clusterNodeIdentifier;
/**
* Constant identifier for the role field in a JMX {@link Descriptor}.
*/
protected static final String FIELD_ROLE = "role";
/**
* Constant identifier for the getter role field value in a JMX {@link Descriptor}.
*/
protected static final String ROLE_GETTER = "getter";
/**
* Constant identifier for the setter role field value in a JMX {@link Descriptor}.
*/
protected static final String ROLE_SETTER = "setter";
@Override
public List<JmxInstance> getInstances() {
LoadContext loadContext = new LoadContext(JmxInstance.class);
loadContext.setView("_local");
loadContext.setQueryString("select jmx from sys$JmxInstance jmx");
List<JmxInstance> jmxInstances = new ArrayList<>();
jmxInstances.add(getLocalInstance());
List<JmxInstance> clusterInstances = dataService.loadList(loadContext);
if (clusterInstances != null)
jmxInstances.addAll(clusterInstances);
return jmxInstances;
}
@Override
public JmxInstance getLocalInstance() {
JmxInstance localJmxInstance = new JmxInstance();
InstanceUtils.copy(LOCAL_JMX_INSTANCE, localJmxInstance);
return localJmxInstance;
}
@Override
public String getLocalNodeName() {
return clusterNodeIdentifier.getClusterNodeName();
}
@Override
public String getRemoteNodeName(JmxInstance instance) {
checkNotNull(instance);
String remoteNodeName;
final MBeanServerConnection connection = getConnection(instance);
try {
Set<ObjectName> names = connection.queryNames(null, null);
ObjectName nodeIdentifierBeanInfo = (ObjectName) CollectionUtils.find(names, new Predicate() {
@Override
public boolean evaluate(Object o) {
ObjectName objectName = (ObjectName) o;
MBeanInfo info;
try {
info = connection.getMBeanInfo(objectName);
} catch (Exception e) {
throw new JmxControlException(e);
}
return StringUtils.equals(JmxNodeIdentifier.class.getName(), info.getClassName());
}
});
if (nodeIdentifierBeanInfo != null) {
Object clusterNodeName = connection.getAttribute(nodeIdentifierBeanInfo, CLUSTER_NODE_NAME_ATTRIBUTE);
if (clusterNodeName != null)
remoteNodeName = clusterNodeName.toString();
else
remoteNodeName = getDefaultNodeName(instance);
} else {
remoteNodeName = getDefaultNodeName(instance);
}
} catch (IOException | ReflectionException | InstanceNotFoundException
| AttributeNotFoundException | MBeanException e) {
throw new JmxControlException(e);
}
return remoteNodeName;
}
@Override
public List<ManagedBeanInfo> getManagedBeans(JmxInstance instance) {
checkNotNull(instance);
MBeanServerConnection connection = getConnection(instance);
try {
Set<ObjectName> names = connection.queryNames(null, null);
List<ManagedBeanInfo> infoList = new ArrayList<>();
for (ObjectName name : names) {
MBeanInfo info = connection.getMBeanInfo(name);
ManagedBeanInfo mbi = new ManagedBeanInfo();
mbi.setClassName(info.getClassName());
mbi.setDescription(info.getDescription());
mbi.setObjectName(name.toString());
mbi.setDomain(name.getDomain());
mbi.setPropertyList(name.getKeyPropertyListString());
mbi.setJmxInstance(instance);
loadOperations(mbi, info);
infoList.add(mbi);
}
Collections.sort(infoList, new MBeanComparator());
return infoList;
} catch (IOException | IntrospectionException | ReflectionException | InstanceNotFoundException e) {
throw new JmxControlException(e);
}
}
@Override
public ManagedBeanInfo loadAttributes(ManagedBeanInfo mbinfo) {
checkNotNull(mbinfo);
checkNotNull(mbinfo.getJmxInstance());
try {
MBeanServerConnection connection = getConnection(mbinfo.getJmxInstance());
ObjectName name = new ObjectName(mbinfo.getObjectName());
MBeanInfo info = connection.getMBeanInfo(name);
List<ManagedBeanAttribute> attrs = new ArrayList<>();
MBeanAttributeInfo[] attributes = info.getAttributes();
for (MBeanAttributeInfo attribute : attributes) {
ManagedBeanAttribute mba = new ManagedBeanAttribute();
mba.setMbean(mbinfo);
mba.setName(attribute.getName());
mba.setType(cleanType(attribute.getType()));
mba.setReadable(attribute.isReadable());
mba.setWriteable(attribute.isWritable());
String mask = "";
if (attribute.isReadable()) mask += "R";
if (attribute.isWritable()) mask += "W";
mba.setReadableWriteable(mask);
if (mba.getReadable())
try {
Object value = connection.getAttribute(name, mba.getName());
setSerializableValue(mba, value);
} catch (Exception e) {
log.error(e);
mba.setValue(e.getMessage());
mba.setWriteable(false);
}
attrs.add(mba);
}
Collections.sort(attrs, new AttributeComparator());
mbinfo.setAttributes(attrs);
return mbinfo;
} catch (Exception e) {
throw new JmxControlException(e);
}
}
@Override
public ManagedBeanAttribute loadAttributeValue(ManagedBeanAttribute attribute) {
checkNotNull(attribute);
checkNotNull(attribute.getMbean());
checkNotNull(attribute.getMbean().getJmxInstance());
try {
MBeanServerConnection connection = getConnection(attribute.getMbean().getJmxInstance());
ObjectName name = new ObjectName(attribute.getMbean().getObjectName());
Object value = null;
if (attribute.getReadable())
try {
value = connection.getAttribute(name, attribute.getName());
} catch (Exception e) {
log.error(e);
value = e.getMessage();
}
setSerializableValue(attribute, value);
return attribute;
} catch (MalformedObjectNameException e) {
throw new JmxControlException(e);
}
}
@Override
public void saveAttributeValue(ManagedBeanAttribute attribute) {
checkNotNull(attribute);
checkNotNull(attribute.getMbean());
checkNotNull(attribute.getMbean().getJmxInstance());
try {
MBeanServerConnection connection = getConnection(attribute.getMbean().getJmxInstance());
ObjectName name = new ObjectName(attribute.getMbean().getObjectName());
Attribute a = new Attribute(attribute.getName(), attribute.getValue());
connection.setAttribute(name, a);
} catch (Exception e) {
throw new JmxControlException(e);
}
}
@Override
public Object invokeOperation(ManagedBeanOperation operation, Object[] parameterValues) {
checkNotNull(operation);
checkNotNull(operation.getMbean());
checkNotNull(operation.getMbean().getJmxInstance());
try {
MBeanServerConnection connection = getConnection(operation.getMbean().getJmxInstance());
ObjectName name = new ObjectName(operation.getMbean().getObjectName());
String[] types = new String[operation.getParameters().size()];
for (int i = 0; i < operation.getParameters().size(); i++) {
types[i] = operation.getParameters().get(i).getType();
}
return connection.invoke(name, operation.getName(), parameterValues, types);
} catch (IOException | MalformedObjectNameException | ReflectionException
| MBeanException | InstanceNotFoundException e) {
throw new JmxControlException(e);
}
}
@Override
public List<ManagedBeanDomain> getDomains(JmxInstance instance) {
checkNotNull(instance);
MBeanServerConnection connection = getConnection(instance);
try {
String[] domains = connection.getDomains();
List<ManagedBeanDomain> domainList = new ArrayList<>();
for (String d : domains) {
ManagedBeanDomain mbd = new ManagedBeanDomain();
mbd.setName(d);
domainList.add(mbd);
}
Collections.sort(domainList, new DomainComparator());
return domainList;
} catch (IOException e) {
throw new JmxControlException(e);
}
}
private MBeanServerConnection getConnection(JmxInstance instance) {
if (ObjectUtils.equals(instance, LOCAL_JMX_INSTANCE))
return getLocalConnection();
else
return getRemoteConnection(instance);
}
private MBeanServerConnection getLocalConnection() {
return ManagementFactory.getPlatformMBeanServer();
}
private MBeanServerConnection getRemoteConnection(JmxInstance instance) {
MBeanServerConnectionFactoryBean factoryBean = new MBeanServerConnectionFactoryBean();
try {
factoryBean.setServiceUrl("service:jmx:rmi:///jndi/rmi://" + instance.getAddress() + "/jmxrmi");
String username = instance.getLogin();
if (StringUtils.isNotEmpty(username)) {
Properties properties = new Properties();
properties.put("jmx.remote.credentials", new String[]{username, instance.getPassword()});
factoryBean.setEnvironment(properties);
}
factoryBean.afterPropertiesSet();
return factoryBean.getObject();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
private void loadOperations(ManagedBeanInfo mbean, MBeanInfo info) {
List<ManagedBeanOperation> opList = new ArrayList<>();
MBeanOperationInfo[] operations = info.getOperations();
for (MBeanOperationInfo operation : operations) {
String role = (String) operation.getDescriptor().getFieldValue(FIELD_ROLE);
if (ROLE_GETTER.equals(role) || ROLE_SETTER.equals(role)) {
continue; // these operations do the same as reading / writing attributes
}
ManagedBeanOperation o = new ManagedBeanOperation();
o.setName(operation.getName());
o.setDescription(operation.getDescription());
o.setMbean(mbean);
o.setReturnType(cleanType(operation.getReturnType()));
List<ManagedBeanOperationParameter> paramList = new ArrayList<>();
if (operation.getSignature() != null) {
for (int index = 0; index < operation.getSignature().length; index++) {
MBeanParameterInfo pinfo = operation.getSignature()[index];
ManagedBeanOperationParameter p = new ManagedBeanOperationParameter();
p.setName(pinfo.getName());
p.setType(cleanType(pinfo.getType()));
p.setDescription(pinfo.getDescription());
p.setOperation(o);
// fix name if it is not set
if (p.getName() == null || p.getName().length() == 0 || p.getName().equals(p.getType())) {
p.setName("arg" + index);
}
paramList.add(p);
}
}
o.setParameters(paramList);
opList.add(o);
}
Collections.sort(opList, new OperationComparator());
mbean.setOperations(opList);
}
private String cleanType(String type) {
if (type != null && type.startsWith("[L") && type.endsWith(";")) {
return type.substring(2, type.length() - 1) + "[]";
}
return type;
}
private void setSerializableValue(ManagedBeanAttribute mba, Object value) {
if (value instanceof Serializable && !(value instanceof Proxy))
mba.setValue(value);
else if (value != null)
mba.setValue(value.toString());
}
private String getDefaultNodeName(JmxInstance instance) {
return "Unknown JMX interface";
}
/** Sorts domains alphabetically by name **/
private static class DomainComparator implements Comparator<ManagedBeanDomain> {
@Override
public int compare(ManagedBeanDomain mbd1, ManagedBeanDomain mbd2) {
return mbd1 != null && mbd1.getName() != null
? mbd1.getName().compareTo(mbd2.getName())
: (mbd2 != null && mbd2.getName() != null ? 1 : 0);
}
}
/** Sorts mbeans alphabetically by name **/
private static class MBeanComparator implements Comparator<ManagedBeanInfo> {
@Override
public int compare(ManagedBeanInfo mbd1, ManagedBeanInfo mbd2) {
return mbd1 != null && mbd1.getPropertyList() != null
? mbd1.getPropertyList().compareTo(mbd2.getPropertyList())
: (mbd2 != null && mbd2.getPropertyList() != null ? 1 : 0);
}
}
/** Sorts attributes alphabetically by name **/
private static class AttributeComparator implements Comparator<ManagedBeanAttribute> {
@Override
public int compare(ManagedBeanAttribute mbd1, ManagedBeanAttribute mbd2) {
return mbd1 != null && mbd1.getName() != null
? mbd1.getName().compareTo(mbd2.getName())
: (mbd2 != null && mbd2.getName() != null ? 1 : 0);
}
}
/** Sorts operations alphabetically by name **/
private static class OperationComparator implements Comparator<ManagedBeanOperation> {
@Override
public int compare(ManagedBeanOperation o1, ManagedBeanOperation o2) {
return o1 != null && o1.getName() != null
? o1.getName().compareTo(o2.getName())
: (o2 != null && o2.getName() != null ? 1 : 0);
}
}
}

View File

@ -38,6 +38,12 @@
<screen id="jmxcontrol$OperationResult"
template="/com/haulmont/cuba/web/app/ui/jmxcontrol/inspect/operation/operation-result.xml"/>
<screen id="sys$JmxInstance.lookup"
template="/com/haulmont/cuba/web/app/ui/jmxinstance/browse/jmxinstance-browse.xml"/>
<screen id="sys$JmxInstance.edit"
template="/com/haulmont/cuba/web/app/ui/jmxinstance/edit/jmxinstance-edit.xml"/>
<!-- -->
<screen id="sec$ScreenHistory.browse"

View File

@ -36,6 +36,7 @@
<entry key="${cuba.webContextName}.cuba:type=ConfigStorage" value-ref="cuba_ConfigStorageMBean"/>
<entry key="${cuba.webContextName}.cuba:type=CachingFacade" value-ref="cuba_CachingFacadeMBean"/>
<entry key="${cuba.webContextName}.cuba:type=FileUploading" value-ref="cuba_FileUploading"/>
<entry key="${cuba.webContextName}.cuba:type=JmxNodeIdentifier" value-ref="cuba_JmxNodeIdentifierMBean"/>
</map>
</property>
</bean>
@ -60,7 +61,6 @@
<entry key="cuba_ConfigStorageService" value="com.haulmont.cuba.core.app.ConfigStorageService"/>
<entry key="cuba_PersistenceManagerService" value="com.haulmont.cuba.core.app.PersistenceManagerService"/>
<entry key="cuba_LockService" value="com.haulmont.cuba.core.app.LockService"/>
<entry key="cuba_JmxControlService" value="com.haulmont.cuba.jmxcontrol.app.JmxControlService"/>
<entry key="cuba_UserSessionService" value="com.haulmont.cuba.security.app.UserSessionService"/>
<entry key="cuba_FoldersService" value="com.haulmont.cuba.core.app.FoldersService"/>
<entry key="cuba_EmailService" value="com.haulmont.cuba.core.app.EmailService"/>