diff --git a/packages/amqp/src/adapter/admin.ts b/packages/amqp/src/adapter/admin.ts
index d032c9d4..9623029b 100644
--- a/packages/amqp/src/adapter/admin.ts
+++ b/packages/amqp/src/adapter/admin.ts
@@ -1,9 +1,12 @@
import { ConnectionFactoryAdapter } from "./connection"
import { RabbitTemplateAdapter } from "./template"
+import { JSClass } from "@ccms/container"
export const RabbitAdmin = Java.type('org.springframework.amqp.rabbit.core.RabbitAdmin')
export class RabbitAdminAdapter {
+ @JSClass('org.springframework.amqp.rabbit.core.RabbitAdmin')
+ private RabbitAdmin: org.springframework.amqp.rabbit.core.RabbitAdmin
private _Handler: org.springframework.amqp.rabbit.core.RabbitAdmin
constructor(config: RabbitTemplateAdapter | org.springframework.amqp.rabbit.core.RabbitTemplate | ConnectionFactoryAdapter | org.springframework.amqp.rabbit.connection.ConnectionFactory) {
this._Handler = new RabbitAdmin((config instanceof RabbitTemplateAdapter || config instanceof ConnectionFactoryAdapter) ? config.getHandler() : config)
diff --git a/packages/amqp/src/adapter/container.ts b/packages/amqp/src/adapter/container.ts
index a2491dd9..e2d1c7da 100644
--- a/packages/amqp/src/adapter/container.ts
+++ b/packages/amqp/src/adapter/container.ts
@@ -2,7 +2,7 @@ import { ConnectionFactoryAdapter, ConnectionFactory } from "./connection"
import { ChannelAwareMessageListenerAdapter, ChannelAwareMessageListener } from "./listener"
export const SimpleMessageListenerContainer = org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer
-export const AcknowledgeMode = org.springframework.amqp.core.AcknowledgeMode
+export const AcknowledgeMode: org.springframework.amqp.core.AcknowledgeMode = Java.type('org.springframework.amqp.core.AcknowledgeMode')
interface ContainerConfig {
connectionFactory: ConnectionFactoryAdapter | typeof ConnectionFactory
queueNames: string[]
diff --git a/packages/amqp/src/admin.ts b/packages/amqp/src/admin.ts
index d60e3499..b23bc1df 100644
--- a/packages/amqp/src/admin.ts
+++ b/packages/amqp/src/admin.ts
@@ -1,8 +1,6 @@
import { JSClass } from "@ccms/container"
import { RabbitAdminAdapter, MessageListenerContainerAdapter, AcknowledgeMode, MessageHandler, ChannelAwareMessageListenerAdapter } from "./adapter"
-const RabbitAdmin = Java.type('org.springframework.amqp.rabbit.core.RabbitAdmin')
-
export class AmqpAdmin {
@JSClass('org.springframework.amqp.core.TopicExchange')
private TopicExchange: typeof org.springframework.amqp.core.TopicExchange
@@ -10,14 +8,15 @@ export class AmqpAdmin {
private Queue: typeof org.springframework.amqp.core.Queue
@JSClass('org.springframework.amqp.core.Binding')
private Binding: typeof org.springframework.amqp.core.Binding
-
+ @JSClass('org.springframework.amqp.rabbit.core.RabbitAdmin')
+ private RabbitAdmin: typeof org.springframework.amqp.rabbit.core.RabbitAdmin
@JSClass('org.springframework.amqp.core.Binding.DestinationType')
- private DestinationType: typeof org.springframework.amqp.core.Binding.DestinationType
+ private DestinationType: org.springframework.amqp.core.Binding.DestinationType
private amqpAdmin: org.springframework.amqp.rabbit.core.RabbitAdmin
constructor(amqpAdmin: org.springframework.amqp.rabbit.core.RabbitAdmin | any) {
- if (amqpAdmin instanceof RabbitAdmin) {
+ if (amqpAdmin instanceof this.RabbitAdmin) {
this.amqpAdmin = amqpAdmin
} else if (amqpAdmin instanceof RabbitAdminAdapter) {
this.amqpAdmin = amqpAdmin.getHandler()
diff --git a/packages/amqp/src/index.ts b/packages/amqp/src/index.ts
index 207ff799..03ead7ab 100644
--- a/packages/amqp/src/index.ts
+++ b/packages/amqp/src/index.ts
@@ -1,8 +1,8 @@
///
-///
-///
-///
-///
+///
+///
+///
+///
import { amqp } from '@ccms/api'
import { getContainer, reduceMetadata } from '@ccms/container'
diff --git a/packages/bukkit/src/index.ts b/packages/bukkit/src/index.ts
index bba8b13d..942f1584 100644
--- a/packages/bukkit/src/index.ts
+++ b/packages/bukkit/src/index.ts
@@ -1,4 +1,4 @@
-///
+///
import { server } from '@ccms/api'
import { Container } from '@ccms/container'
diff --git a/packages/bungee/src/index.ts b/packages/bungee/src/index.ts
index 2993b9ee..c59e0955 100644
--- a/packages/bungee/src/index.ts
+++ b/packages/bungee/src/index.ts
@@ -1,4 +1,4 @@
-///
+///
import { server } from '@ccms/api'
import { Container } from '@ccms/container'
diff --git a/packages/common/package.json b/packages/common/package.json
index 7904597f..80d03d99 100644
--- a/packages/common/package.json
+++ b/packages/common/package.json
@@ -24,7 +24,8 @@
"typescript": "^3.9.2"
},
"dependencies": {
- "@ccms/nashorn": "^0.7.0"
+ "@ccms/nashorn": "^0.7.0",
+ "@javatypes/jdk": "^1.14.0"
},
"gitHead": "562e2d00175c9d3a99c8b672aa07e6d92706a027"
}
diff --git a/packages/common/src/reflect.ts b/packages/common/src/reflect.ts
index 4b201a6b..ea58930b 100644
--- a/packages/common/src/reflect.ts
+++ b/packages/common/src/reflect.ts
@@ -1,4 +1,4 @@
-///
+///
/**
* 反射工具类
@@ -11,7 +11,7 @@ const methodCache = []
class Reflect {
private obj: java.lang.Object
- private class: java.lang.Class
+ private class: java.lang.Class
constructor(obj: any) {
// if (obj === undefined || obj === null) { throw Error(`reflect object can't be ${obj}!`) }
@@ -26,8 +26,8 @@ class Reflect {
}
}
- method(name: string, ...args: any[]) {
- return declaredMethod(this.class, name, args)
+ method(name: string, ...args: java.lang.Class[]) {
+ return declaredMethod(this.class, name, ...args)
}
methods() {
@@ -90,7 +90,7 @@ function types(values: any[], def?: any) {
if (values === null) {
return []
}
- let result: java.lang.Class[] = []
+ let result: java.lang.Class[] = []
values.forEach(t => result.push((t || def) ? JavaObject.class : t instanceof JavaClass ? t : t.class))
return result
}
@@ -119,7 +119,7 @@ function declaredConstructor(clazz, param) {
return accessible(constructor)
}
-function declaredField(clazz: java.lang.Class, name: string | java.lang.String) {
+function declaredField(clazz: java.lang.Class, name: string | java.lang.String) {
if (!clazz) { throw Error(`target class can't be ${clazz}!`) }
let target = clazz
let field = null
@@ -139,17 +139,17 @@ function declaredField(clazz: java.lang.Class, name: string | java.lang.String)
return field
}
-function declaredMethod(clazz: java.lang.Class, name: string, ...clazzs: any[]): java.lang.reflect.Method {
+function declaredMethod(clazz: java.lang.Class, name: string, ...clazzs: java.lang.Class[]): java.lang.reflect.Method {
let key = clazz.getName() + '.' + name + ':' + (clazzs || []).join(':')
if (!methodCache[key]) {
try {
- methodCache[key] = clazz.getMethod(name, clazzs as any)
+ methodCache[key] = clazz.getMethod(name, ...clazzs)
} catch (ex) {
try {
methodCache[key] = clazz.getDeclaredMethod(name, clazzs as any)
} catch (ex) {
for (const m of Java.from(declaredMethods(clazz))) {
- if (m.name == name) {
+ if (m.getName() == name) {
methodCache[key] = m
break
}
@@ -160,8 +160,8 @@ function declaredMethod(clazz: java.lang.Class, name: string, ...clazzs: any[]):
return methodCache[key]
}
-function declaredMethods(clazz) {
- return clazz.declaredMethods
+function declaredMethods(clazz: java.lang.Class) {
+ return clazz.getDeclaredMethods()
}
let classMethodsCache: any[] = []
diff --git a/packages/database/src/database.ts b/packages/database/src/database.ts
index 08950279..160225b8 100644
--- a/packages/database/src/database.ts
+++ b/packages/database/src/database.ts
@@ -1,5 +1,3 @@
-///
-
import { Model } from './model'
const HikariDataSource = Java.type('com.zaxxer.hikari.HikariDataSource')
@@ -69,7 +67,7 @@ export class DataBase {
*/
query(sql: string, ...args: any[]): Array {
let startTime = Date.now()
- let result = Java.from(this.jdbcTemplate.queryForList(sql, args))
+ let result = Java.from(this.jdbcTemplate.queryForList(sql, args))
console.debug(java.lang.String.format(`\n[DB] query \nSQL : ${sql.replace(/\?/ig, '%s')} \nCOST : ${Date.now() - startTime}ms`, args))
return result
}
diff --git a/packages/database/src/index.ts b/packages/database/src/index.ts
index 86de9412..15ab583a 100644
--- a/packages/database/src/index.ts
+++ b/packages/database/src/index.ts
@@ -1,5 +1,6 @@
///
-///
+///
+///
export * from './database'
export * from './manager'
\ No newline at end of file
diff --git a/packages/nashorn/src/index.ts b/packages/nashorn/src/index.ts
index 8026381c..59278cd9 100644
--- a/packages/nashorn/src/index.ts
+++ b/packages/nashorn/src/index.ts
@@ -13,8 +13,8 @@ declare global {
namespace Java {
function type(clazz: string): T
- function from(javaObj: T[]): T[]
- function to(array: T[], type?: T): T[]
+ function from(javaObj: T[]): T[]
+ function to(array: T[], type?: T): T[]
function extend(...parentTypes: any[]): any
function synchronized(func: () => void, lock: any): Function
function asJSONCompatible(obj: T): T
diff --git a/packages/nukkit/src/index.ts b/packages/nukkit/src/index.ts
index b826d37d..855dc4f9 100644
--- a/packages/nukkit/src/index.ts
+++ b/packages/nukkit/src/index.ts
@@ -1,4 +1,4 @@
-///
+///
import { server } from '@ccms/api'
import { Container } from '@ccms/container'
diff --git a/packages/sponge/src/index.ts b/packages/sponge/src/index.ts
index eb6c4eda..da6e1f64 100644
--- a/packages/sponge/src/index.ts
+++ b/packages/sponge/src/index.ts
@@ -1,4 +1,4 @@
-///
+///
import { server } from '@ccms/api'
import { Container } from '@ccms/container'
diff --git a/packages/sponge/src/server.ts b/packages/sponge/src/server.ts
index 33f84a3f..6b9bd5f3 100644
--- a/packages/sponge/src/server.ts
+++ b/packages/sponge/src/server.ts
@@ -1,18 +1,18 @@
import { server, constants } from '@ccms/api'
-import { provideSingleton } from '@ccms/container';
+import { provideSingleton } from '@ccms/container'
import * as reflect from '@ccms/common/dist/reflect'
-const Sponge = org.spongepowered.api.Sponge;
-const TextSerializers = org.spongepowered.api.text.serializer.TextSerializers;
-const File = Java.type("java.io.File");
+const Sponge = org.spongepowered.api.Sponge
+const TextSerializers = org.spongepowered.api.text.serializer.TextSerializers
+const File = Java.type("java.io.File")
@provideSingleton(server.Server)
export class SpongeServer extends server.ReflectServer {
- private pluginsFolder: string;
+ private pluginsFolder: string
constructor() {
- super();
+ super()
this.pluginsFolder = new File(base.getInstance().getClass().getProtectionDomain().getCodeSource().getLocation().getPath()).getParentFile().getCanonicalPath()
}
@@ -35,25 +35,25 @@ export class SpongeServer extends server.ReflectServer {
if (typeof sender === 'string') {
sender = this.getPlayer(sender)
}
- return Sponge.getCommandManager().process(sender, command).getQueryResult().get()
+ return Sponge.getCommandManager().process(sender, command).getQueryResult().get() != 0
}
dispatchConsoleCommand(command: string): boolean {
- return Sponge.getCommandManager().process(Sponge.getServer().getConsole(), command).getQueryResult().get()
+ return Sponge.getCommandManager().process(Sponge.getServer().getConsole(), command).getQueryResult().get() != 0
}
getPluginsFolder(): string {
- return this.pluginsFolder;
+ return this.pluginsFolder
}
getNativePluginManager() {
- return Sponge.getPluginManager() as any;
+ return Sponge.getPluginManager() as any
}
getDedicatedServer() {
return reflect.on(Sponge.getServer()).get()
}
getNettyPipeline() {
- return this.pipeline;
+ return this.pipeline
}
getRootLogger() {
- return this.rootLogger;
+ return this.rootLogger
}
sendJson(sender: string | any, json: string): void {
if (typeof sender === "string") {
diff --git a/packages/web/package.json b/packages/web/package.json
index 3572ae78..92b28991 100644
--- a/packages/web/package.json
+++ b/packages/web/package.json
@@ -24,6 +24,7 @@
"typescript": "^3.9.2"
},
"dependencies": {
+ "@ccms/api": "^0.7.0",
"@ccms/container": "^0.7.0"
}
}
diff --git a/packages/web/src/index.ts b/packages/web/src/index.ts
index 7a0db934..449e781d 100644
--- a/packages/web/src/index.ts
+++ b/packages/web/src/index.ts
@@ -1,7 +1,9 @@
-///
-///
-///
-///
+///
+///
+///
+///
+///
+///
export * from './server'
export * from './decorators'