forked from kylinsoong/wildfly-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5b9f3c7
commit 0f1f923
Showing
14 changed files
with
754 additions
and
0 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
domain/domain-deployment/src/main/java/org/jboss/logging/LoggerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.jboss.logging; | ||
|
||
import org.jboss.as.host.controller.HostControllerLogger; | ||
|
||
public class LoggerTest { | ||
|
||
public static void main(String[] args) { | ||
|
||
System.out.println(HostControllerLogger.class.getPackage().getName()); | ||
|
||
HostControllerLogger.ROOT_LOGGER.tracef("trying to reconnect to %s current-state (%s) required-state (%s)", "jo004006", "SERVER_STARTED", "SERVER_STARTED"); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>org.wildfly.logging</groupId> | ||
<artifactId>wildfly-logging</artifactId> | ||
<version>1.0</version> | ||
<name>Parent</name> | ||
<description>Parent of WildFly logging</description> | ||
<packaging>pom</packaging> | ||
|
||
<url>https://github.com/kylinsoong</url> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<modules> | ||
<module>quickstart</module> | ||
</modules> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?xml version="1.0"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>org.jboss.logging</groupId> | ||
<artifactId>jboss-logging-quickstart</artifactId> | ||
<version>1.0</version> | ||
<packaging>jar</packaging> | ||
<name>JBoss logging quickstart</name> | ||
<description>JBoss logging quickstart</description> | ||
|
||
<url>https://github.com/kylinsoong</url> | ||
|
||
<properties> | ||
<logging.version>3.1.2.GA-redhat-1</logging.version> | ||
<maven.compiler.target>1.6</maven.compiler.target> | ||
<maven.compiler.source>1.6</maven.compiler.source> | ||
<compiler.plugin.version>2.3.1</compiler.plugin.version> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.jboss.logging</groupId> | ||
<artifactId>jboss-logging</artifactId> | ||
<version>${logging.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<finalName>${artifactId}</finalName> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>${compiler.plugin.version}</version> | ||
<configuration> | ||
<source>${maven.compiler.source}</source> | ||
<target>${maven.compiler.target}</target> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
20 changes: 20 additions & 0 deletions
20
logging/quickstart/src/main/java/org/jboss/logging/sample/HelloWorld.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.jboss.logging.sample; | ||
|
||
import org.jboss.logging.Logger; | ||
|
||
public class HelloWorld { | ||
|
||
private static final Logger LOGGER = Logger.getLogger(HelloWorld.class); | ||
|
||
public static void main(String[] args) { | ||
|
||
LOGGER.trace("TRACE Message"); | ||
LOGGER.debug("DEBUG Message"); | ||
LOGGER.info("INFO Message"); | ||
LOGGER.error("Error Message"); | ||
LOGGER.fatal("FATAL Message"); | ||
|
||
LOGGER.error("Configuration file not found."); | ||
} | ||
|
||
} |
32 changes: 32 additions & 0 deletions
32
logging/quickstart/src/main/java/org/jboss/logging/sample/LocalSystemConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package org.jboss.logging.sample; | ||
|
||
import java.io.FileInputStream; | ||
import java.io.FileNotFoundException; | ||
import java.io.IOException; | ||
import java.util.Properties; | ||
|
||
import org.jboss.logging.Logger; | ||
|
||
public class LocalSystemConfig { | ||
|
||
private static final Logger LOGGER = Logger.getLogger(LocalSystemConfig.class); | ||
|
||
public Properties openCustomProperties(String configname)throws FileNotFoundException { | ||
Properties props = new Properties(); | ||
try { | ||
LOGGER.info("Loading custom configuration from " + configname); | ||
props.load(new FileInputStream(configname)); | ||
} catch (IOException e) { | ||
LOGGER.error("Custom configuration file (" + configname + ") not found. Using defaults."); | ||
throw new FileNotFoundException(configname); | ||
} | ||
|
||
return props; | ||
} | ||
|
||
public static void main(String[] args) throws FileNotFoundException { | ||
|
||
new LocalSystemConfig().openCustomProperties("XXOO"); | ||
} | ||
|
||
} |
16 changes: 16 additions & 0 deletions
16
logging/quickstart/src/main/java/org/jboss/logging/sample/LoggerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.jboss.logging.sample; | ||
|
||
import org.jboss.logging.Logger; | ||
|
||
public class LoggerTest { | ||
|
||
public static void main(String[] args) { | ||
|
||
System.setProperty("org.jboss.logging.provider", "jboss"); | ||
|
||
Logger logger = Logger.getLogger(LoggerTest.class, "com.kylin.test"); | ||
|
||
logger.info("logger test"); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>org.wildfly.remoting</groupId> | ||
<artifactId>wildfly-remoting</artifactId> | ||
<version>1.0</version> | ||
<name>Parent</name> | ||
<description>Parent of WildFly remoting</description> | ||
<packaging>pom</packaging> | ||
|
||
<url>https://github.com/kylinsoong</url> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<modules> | ||
<module>quickstart</module> | ||
</modules> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?xml version="1.0"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>org.jboss.remoting3</groupId> | ||
<artifactId>jboss-remoting-quickstart</artifactId> | ||
<version>1.0</version> | ||
<packaging>jar</packaging> | ||
<name>JBoss Remoting 3 quickstart</name> | ||
<description>JBoss Remoting 3 quickstart</description> | ||
|
||
<url>https://github.com/kylinsoong</url> | ||
|
||
<properties> | ||
<xnio.version>3.0.7.GA-redhat-1</xnio.version> | ||
<maven.compiler.target>1.6</maven.compiler.target> | ||
<maven.compiler.source>1.6</maven.compiler.source> | ||
<compiler.plugin.version>2.3.1</compiler.plugin.version> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.jboss.remoting3</groupId> | ||
<artifactId>jboss-remoting</artifactId> | ||
<version>3.2.16.GA-redhat-1</version> | ||
</dependency> | ||
<!-- --> | ||
<dependency> | ||
<groupId>org.jboss.xnio</groupId> | ||
<artifactId>xnio-nio</artifactId> | ||
<version>${xnio.version}</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<finalName>${artifactId}</finalName> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>${compiler.plugin.version}</version> | ||
<configuration> | ||
<source>${maven.compiler.source}</source> | ||
<target>${maven.compiler.target}</target> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<configuration> | ||
<archive> | ||
<manifest> | ||
<mainClass>org.jboss.remoting3.test.Runner</mainClass> | ||
</manifest> | ||
<manifestEntries> | ||
<Jar-Version>${project.version}</Jar-Version> | ||
<Jar-Name>${project.artifactId}</Jar-Name> | ||
</manifestEntries> | ||
</archive> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
78 changes: 78 additions & 0 deletions
78
remoting/quickstart/src/main/java/org/jboss/remoting3/sample/CharSequenceReceiver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package org.jboss.remoting3.sample; | ||
|
||
import java.io.IOException; | ||
import java.net.InetSocketAddress; | ||
|
||
import org.jboss.remoting3.Channel; | ||
import org.jboss.remoting3.Endpoint; | ||
import org.jboss.remoting3.MessageInputStream; | ||
import org.jboss.remoting3.OpenListener; | ||
import org.jboss.remoting3.Remoting; | ||
import org.jboss.remoting3.remote.RemoteConnectionProviderFactory; | ||
import org.jboss.remoting3.security.SimpleServerAuthenticationProvider; | ||
import org.jboss.remoting3.spi.NetworkServerProvider; | ||
import org.xnio.IoUtils; | ||
import org.xnio.OptionMap; | ||
import org.xnio.Options; | ||
import org.xnio.Sequence; | ||
import org.xnio.channels.AcceptingChannel; | ||
import org.xnio.channels.ConnectedStreamChannel; | ||
|
||
public class CharSequenceReceiver { | ||
|
||
private static final int THREAD_POOL_SIZE = 100; | ||
private static final int BUFFER_SIZE = 8192; | ||
private static byte[] buffer; | ||
|
||
protected final Endpoint serverEndpoint; | ||
|
||
private AcceptingChannel<? extends ConnectedStreamChannel> server; | ||
|
||
public CharSequenceReceiver() throws IOException { | ||
serverEndpoint = Remoting.createEndpoint("connection-test-server", OptionMap.create(Options.WORKER_TASK_CORE_THREADS, THREAD_POOL_SIZE, Options.WORKER_TASK_MAX_THREADS, THREAD_POOL_SIZE)); | ||
serverEndpoint.addConnectionProvider("remote", new RemoteConnectionProviderFactory(), OptionMap.create(Options.SSL_ENABLED, Boolean.FALSE)); | ||
final NetworkServerProvider networkServerProvider = serverEndpoint.getConnectionProviderInterface("remote", NetworkServerProvider.class); | ||
SimpleServerAuthenticationProvider provider = new SimpleServerAuthenticationProvider(); | ||
provider.addUser("bob", "test", "pass".toCharArray()); | ||
server = networkServerProvider.createServer(new InetSocketAddress("localhost", 30123), OptionMap.create(Options.SASL_MECHANISMS, Sequence.of("CRAM-MD5")), provider, null); | ||
System.out.println("Server Created, " + server.getLocalAddress()); | ||
|
||
serverEndpoint.registerService("test", new OpenListener(){ | ||
|
||
public void channelOpened(Channel channel) { | ||
channel.receiveMessage(new Channel.Receiver(){ | ||
|
||
public void handleError(Channel channel, IOException error) { | ||
|
||
} | ||
|
||
public void handleEnd(Channel channel) { | ||
// System.out.println(channel.getConnection().getRemoteEndpointName() + " ended"); | ||
} | ||
|
||
public void handleMessage(Channel channel, MessageInputStream message) { | ||
try { | ||
channel.receiveMessage(this); | ||
buffer = new byte[BUFFER_SIZE]; | ||
while (message.read(buffer) > -1); | ||
System.out.println(" Receive: " + new String(buffer)); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} finally { | ||
IoUtils.safeClose(message); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
public void registrationTerminated() { | ||
|
||
}}, OptionMap.EMPTY); | ||
} | ||
|
||
|
||
public static void main(String[] args) throws IOException { | ||
new CharSequenceReceiver(); | ||
} | ||
|
||
} |
Oops, something went wrong.